WestLangley 5 лет назад
Родитель
Сommit
74790fb58e
2 измененных файлов с 35 добавлено и 1 удалено
  1. 21 1
      examples/css3d_orthographic.html
  2. 14 0
      examples/css3d_sandbox.html

+ 21 - 1
examples/css3d_orthographic.html

@@ -31,12 +31,13 @@
 
 			var scene2, renderer2;
 
+			var frustumSize = 500;
+
 			init();
 			animate();
 
 			function init() {
 
-				var frustumSize = 500;
 				var aspect = window.innerWidth / window.innerHeight;
 				camera = new THREE.OrthographicCamera( frustumSize * aspect / - 2, frustumSize * aspect / 2, frustumSize / 2, frustumSize / - 2, 1, 1000 );
 
@@ -116,6 +117,25 @@
 
 				}
 
+				window.addEventListener( 'resize', onWindowResize, false );
+
+			}
+
+			function onWindowResize() {
+
+				var aspect = window.innerWidth / window.innerHeight;
+
+				camera.left = - frustumSize * aspect / 2;
+				camera.right = frustumSize * aspect / 2;
+				camera.top = frustumSize / 2;
+				camera.bottom = - frustumSize / 2;
+
+				camera.updateProjectionMatrix();
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				renderer2.setSize( window.innerWidth, window.innerHeight );
+
 			}
 
 			function animate() {

+ 14 - 0
examples/css3d_sandbox.html

@@ -89,6 +89,20 @@
 
 				controls = new TrackballControls( camera, renderer2.domElement );
 
+				window.addEventListener( 'resize', onWindowResize, false );
+
+			}
+
+			function onWindowResize() {
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+
+				camera.updateProjectionMatrix();
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				renderer2.setSize( window.innerWidth, window.innerHeight );
+
 			}
 
 			function animate() {