瀏覽代碼

Examples: add resize event for `webgl_postprocessing_crossfade.html` (#28172)

林炳权 1 年之前
父節點
當前提交
e462f0e7cd
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      examples/webgl_postprocessing_crossfade.html

+ 18 - 0
examples/webgl_postprocessing_crossfade.html

@@ -72,6 +72,16 @@
 
 				transition = new Transition( sceneA, sceneB );
 
+				window.addEventListener( 'resize', onWindowResize );
+
+				function onWindowResize() {
+
+					sceneA.resize();
+					sceneB.resize();
+					renderer.setSize( window.innerWidth, window.innerHeight );
+
+				}
+
 			}
 
 			function animate() {
@@ -208,6 +218,14 @@
 
 				};
 
+				this.resize = function () {
+
+					camera.aspect = window.innerWidth / window.innerHeight;
+					camera.updateProjectionMatrix();
+					this.fbo.setSize( window.innerWidth, window.innerHeight );
+
+				};
+
 			}
 
 			function Transition( sceneA, sceneB ) {