提交 b46942b7 编写于 作者: F Fernando Serrano

Resize cameras viewports correctly on the webgl_camera_array example

上级 1981241f
......@@ -20,6 +20,7 @@
var camera, scene, renderer;
var mesh;
var AMOUNT = 6;
init();
animate();
......@@ -28,7 +29,6 @@
var ASPECT_RATIO = window.innerWidth / window.innerHeight;
var AMOUNT = 6;
var WIDTH = ( window.innerWidth / AMOUNT ) * window.devicePixelRatio;
var HEIGHT = ( window.innerHeight / AMOUNT ) * window.devicePixelRatio;
......@@ -95,9 +95,31 @@
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
var ASPECT_RATIO = window.innerWidth / window.innerHeight;
var WIDTH = ( window.innerWidth / AMOUNT ) * window.devicePixelRatio;
var HEIGHT = ( window.innerHeight / AMOUNT ) * window.devicePixelRatio;
camera.aspect = ASPECT_RATIO;
camera.updateProjectionMatrix();
for ( var y = 0; y < AMOUNT; y ++ ) {
for ( var x = 0; x < AMOUNT; x ++ ) {
var subcamera = camera.cameras[ AMOUNT * y + x ];
subcamera.viewport.set(
Math.floor( x * WIDTH ),
Math.floor( y * HEIGHT ),
Math.ceil( WIDTH ),
Math.ceil( HEIGHT ) );
subcamera.aspect = ASPECT_RATIO;
subcamera.updateProjectionMatrix();
}
}
renderer.setSize( window.innerWidth, window.innerHeight );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册