Skip to content

Commit

Permalink
Editor: Fix viewport camera resize. (#28443)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 authored May 20, 2024
1 parent 7a2ccef commit 8d1ea27
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions editor/js/Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,24 @@ function Viewport( editor ) {

const camera = editor.cameras[ uuid ];

const aspect = container.dom.offsetWidth / container.dom.offsetHeight;

if ( camera.isPerspectiveCamera ) {

camera.aspect = container.dom.offsetWidth / container.dom.offsetHeight;
camera.aspect = aspect;

} else {

camera.updateProjectionMatrix();
camera.left = - aspect;
camera.right = aspect;

}

camera.updateProjectionMatrix();

const cameraHelper = editor.helpers[ camera.id ];
if ( cameraHelper ) cameraHelper.update();

}

}
Expand Down Expand Up @@ -631,14 +641,10 @@ function Viewport( editor ) {

const viewportCamera = editor.viewportCamera;

if ( viewportCamera.isPerspectiveCamera ) {
if ( viewportCamera.isPerspectiveCamera || viewportCamera.isOrthographicCamera ) {

updateAspectRatio();

} else if ( viewportCamera.isOrthographicCamera ) {

// TODO

}

// disable EditorControls when setting a user camera
Expand Down

0 comments on commit 8d1ea27

Please sign in to comment.