From aff4a5616e625f3ff2fd5511320ac92b7add9fda Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Fri, 1 May 2026 01:11:40 -0700 Subject: [PATCH] PageScene: read camera/freeCamState/focalLengthToFov from CameraController Phase 1 moved camera, freeCamState, and focalLengthToFov off Editor and onto CameraController, but two camera-update blocks in PageEditor (handleSelectCamera and handleAddCamera) still read editorEngine.camera, editorEngine.focalLengthToFov, and editorEngine.freeCamState. Those fields are undefined now, so the cam-update guards short-circuited and the reset/random-camera buttons silently did nothing. Sweep both blocks to read from editorEngine.cameraController.* and collapse the chain into a local `cam` const. --- .../app/src/pages/PageScene/PageEditor.tsx | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) 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(); } };