瀏覽代碼

handle resize event

WestLangley 7 年之前
父節點
當前提交
5262440b18
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      examples/webgl_buffergeometry_instancing_lambert.html

+ 13 - 0
examples/webgl_buffergeometry_instancing_lambert.html

@@ -387,6 +387,19 @@
 			stats = new Stats();
 			document.body.appendChild( stats.dom );
 
+			//
+
+			window.addEventListener( 'resize', onWindowResize, false );
+
+		}
+
+		function onWindowResize( event ) {
+
+			renderer.setSize( window.innerWidth, window.innerHeight );
+
+			camera.aspect = window.innerWidth / window.innerHeight;
+			camera.updateProjectionMatrix();
+
 		}
 
 		function animate() {