瀏覽代碼

Added onWindowResize()

WestLangley 5 年之前
父節點
當前提交
3da94849d0
共有 1 個文件被更改,包括 17 次插入0 次删除
  1. 17 0
      examples/css2d_label.html

+ 17 - 0
examples/css2d_label.html

@@ -108,8 +108,25 @@
 				controls.minDistance = 5;
 				controls.minDistance = 5;
 				controls.maxDistance = 100;
 				controls.maxDistance = 100;
 
 
+				//
+
+				window.addEventListener( 'resize', onWindowResize, false );
+
 			}
 			}
 
 
+			function onWindowResize() {
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+
+				camera.updateProjectionMatrix();
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				labelRenderer.setSize( window.innerWidth, window.innerHeight );
+
+			}
+
+
 			function animate() {
 			function animate() {
 
 
 				requestAnimationFrame( animate );
 				requestAnimationFrame( animate );