瀏覽代碼

Examples: make resize listeners consistent

Marco Fugaro 4 年之前
父節點
當前提交
61225db161

+ 4 - 2
examples/games_fps.html

@@ -135,14 +135,16 @@
 
 			}, false );
 
-			window.addEventListener( 'resize', () => {
+			window.addEventListener( 'resize', onWindowResize );
+
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();
 
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
-			}, false );
+			}
 
 			document.addEventListener( 'click', () => {
 

+ 2 - 2
examples/webaudio_visualizer.html

@@ -136,13 +136,13 @@
 
 				//
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 				animate();
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				renderer.setSize( window.innerWidth, window.innerHeight );
 

+ 2 - 2
examples/webgl_furnace_test.html

@@ -34,7 +34,7 @@
 				renderer.setPixelRatio( window.devicePixelRatio );
 				document.body.appendChild( renderer.domElement );
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 				document.body.addEventListener( 'mouseover', function () {
 
@@ -114,7 +114,7 @@
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				const width = window.innerWidth;
 				const height = window.innerHeight;

+ 2 - 2
examples/webgl_lights_rectarealight.html

@@ -78,14 +78,14 @@
 
 				//
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 				stats = new Stats();
 				document.body.appendChild( stats.dom );
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				camera.aspect = ( window.innerWidth / window.innerHeight );

+ 2 - 2
examples/webgl_lights_spotlight.html

@@ -98,11 +98,11 @@
 
 				render();
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();

+ 3 - 3
examples/webgl_lights_spotlights.html

@@ -80,8 +80,8 @@
 				scene.add( lightHelper1, lightHelper2, lightHelper3 );
 
 				document.body.appendChild( renderer.domElement );
-				onResize();
-				window.addEventListener( 'resize', onResize, false );
+				onWindowResize();
+				window.addEventListener( 'resize', onWindowResize );
 
 				controls.target.set( 0, 7, 0 );
 				controls.maxPolarAngle = Math.PI / 2;
@@ -103,7 +103,7 @@
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();

+ 2 - 2
examples/webgl_math_orientation_transform.html

@@ -65,7 +65,7 @@
 
 				//
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 				//
 
@@ -73,7 +73,7 @@
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();

+ 2 - 2
examples/webgl_pmrem_test.html

@@ -50,7 +50,7 @@
 
 				document.body.appendChild( renderer.domElement );
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 				// scene
 
@@ -169,7 +169,7 @@
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				const width = window.innerWidth;
 				const height = window.innerHeight;

+ 11 - 11
examples/webgl_postprocessing_pixel.html

@@ -40,16 +40,6 @@
 
 			}
 
-			function resize() {
-
-				camera.aspect = window.innerWidth / window.innerHeight;
-				camera.updateProjectionMatrix();
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
-				pixelPass.uniforms[ "resolution" ].value.set( window.innerWidth, window.innerHeight ).multiplyScalar( window.devicePixelRatio );
-
-			}
-
 			function init() {
 
 				const container = document.getElementById( 'container' );
@@ -122,7 +112,7 @@
 				pixelPass.uniforms[ "resolution" ].value.multiplyScalar( window.devicePixelRatio );
 				composer.addPass( pixelPass );
 
-				window.addEventListener( 'resize', resize );
+				window.addEventListener( 'resize', onWindowResize );
 
 				params = {
 					pixelSize: 16,
@@ -134,6 +124,16 @@
 
 			}
 
+			function onWindowResize() {
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				pixelPass.uniforms[ "resolution" ].value.set( window.innerWidth, window.innerHeight ).multiplyScalar( window.devicePixelRatio );
+
+			}
+
 			function update() {
 
 				controls.update();

+ 2 - 2
examples/webgl_refraction.html

@@ -100,11 +100,11 @@
 
 				//
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();

+ 3 - 3
examples/webgl_tiled_forward.html

@@ -330,7 +330,7 @@
 
 			}
 
-			function resize() {
+			function onWindowResize() {
 
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
@@ -358,10 +358,10 @@
 
 				const geometry = object.children[ 0 ].geometry;
 
-				window.addEventListener( 'resize', resize );
+				window.addEventListener( 'resize', onWindowResize );
 
 				init( geometry );
-				resize();
+				onWindowResize();
 
 				renderer.setAnimationLoop( function ( time ) {
 

+ 2 - 2
examples/webgl_water.html

@@ -163,11 +163,11 @@
 
 				//
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();

+ 2 - 2
examples/webgl_water_flowmap.html

@@ -105,11 +105,11 @@
 
 				//
 
-				window.addEventListener( 'resize', onResize, false );
+				window.addEventListener( 'resize', onWindowResize );
 
 			}
 
-			function onResize() {
+			function onWindowResize() {
 
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();