Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: Added onWindowResize callback to CSS3D examples #20068

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion examples/css3d_orthographic.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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() {
Expand Down
14 changes: 14 additions & 0 deletions examples/css3d_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down