diff --git a/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx b/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx index efc0822845..aca263e1f4 100644 --- a/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx +++ b/frontend/apps/artcraft/app/src/pages/PageScene/PageEditor.tsx @@ -186,32 +186,30 @@ export const PageEditor = () => { }, 1500); // Update the main camera to match the selected camera's properties - if (editorEngine.camera) { - // First update position and lookAt - editorEngine.camera.position.set( + const cam = editorEngine.cameraController.camera; + if (cam) { + cam.position.set( selectedCamera.position.x, selectedCamera.position.y, selectedCamera.position.z, ); - editorEngine.camera.lookAt( + cam.lookAt( selectedCamera.lookAt.x, selectedCamera.lookAt.y, selectedCamera.lookAt.z, ); - // Update FOV - editorEngine.camera.fov = editorEngine.focalLengthToFov( + cam.fov = editorEngine.cameraController.focalLengthToFov( selectedCamera.focalLength, ); - editorEngine.camera.updateProjectionMatrix(); + cam.updateProjectionMatrix(); // Reset free-cam motion so a switch doesn't carry over a // half-applied drag from the previous camera. - if (editorEngine.freeCamState) { - editorEngine.freeCamState.velocity.set(0, 0, 0); + if (editorEngine.cameraController.freeCamState) { + editorEngine.cameraController.freeCamState.velocity.set(0, 0, 0); } - // Force a render to update the view editorEngine.renderScene(); } @@ -262,19 +260,19 @@ export const PageEditor = () => { setSelectedCameraId(newId); // Update the engine camera to match the new camera's properties - if (editorEngine && editorEngine.camera) { - editorEngine.camera.position.set(randomX, randomY, randomZ); - editorEngine.camera.lookAt(0, 0, 0); - editorEngine.camera.fov = editorEngine.focalLengthToFov(24); - editorEngine.camera.updateProjectionMatrix(); + const cam = editorEngine?.cameraController.camera; + if (editorEngine && cam) { + cam.position.set(randomX, randomY, randomZ); + cam.lookAt(0, 0, 0); + cam.fov = editorEngine.cameraController.focalLengthToFov(24); + cam.updateProjectionMatrix(); // Reset free-cam motion so the camera doesn't drift after // teleport. - if (editorEngine.freeCamState) { - editorEngine.freeCamState.velocity.set(0, 0, 0); + if (editorEngine.cameraController.freeCamState) { + editorEngine.cameraController.freeCamState.velocity.set(0, 0, 0); } - // Force a render to update the view editorEngine.renderScene(); } };