Repository navigation
Conversation
Aymericr
left a comment
There was a problem hiding this comment.
Thanks @kruschdev for taking #1280, and for keeping older saved views (position + target only) working. Capturing fov/zoom with the view and forwarding them through CameraControlFrameEvent.pose is the right shape. A few points before this can go in:
- Schema change in
CameraSchema: dropping.default('perspective')frommodechanges what every parsed node looks like. Old saved cameras now parse withmode: undefinedinstead of'perspective'. I see why you want that (an old view shouldn't force perspective), but it's a public schema change for@pascal-app/coreconsumers and MCP clients that readnode.camera.mode. Please call it out in the description, and add a schema test showing an old camera parses withoutmodeand still round-trips. _zoomEnd:captureSavedCameraViewreads a privateCameraControlsfield. If camera-controls renames it, the code silently falls back tocamera.zoom, which can be mid-transition. Could you capture after the zoom settles, or keep this behind a small helper with a comment and a test that fails if the field disappears?- Screen recording: this changes what the user sees on project open and from the views bar. Please add a short clip showing an orthographic view with custom zoom, and a perspective view with a non-default FOV, saved, then reopened and restored from the views bar.
- Small:
saved-camera-view.tshas itsimportstatements split around atypedeclaration. Biome may not catch that, but grouping the imports at the top reads better.
I couldn't run saved-camera-view.test.tsx locally (it needs built viewer packages), so CI will be the check. It's waiting on maintainer approval for this fork.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cd93aaa. Configure here.
|
Thanks @Aymericr! I addressed all four points in cd93aaa and updated the PR description:
|

What does this PR do?
Fixes #1280
When opening a project with a saved camera view (
site.cameraorbuilding.camera) or invoking the saved-camera view actions (camera-controls:view, Preview mode, and header/roomframeViewerNodeframing), onlypositionandtargetwere previously applied, andhandleNodeCaptureonly recordedposition,target, andmodewithoutfovorzoom. Views saved in orthographic mode or with a custom lens therefore reopened in the active projection and lens instead of the saved one.I updated the saved-camera capture and restore paths so projection and lens round-trip together while keeping older saved views backwards-compatible:
packages/editor/src/components/editor/saved-camera-view.ts,custom-camera-controls.tsx):captureSavedCameraViewrecordsfovin perspective mode and settledzoomin orthographic mode alongsideposition,target, andmode.CustomCameraControlsswitchescameraModewhen needed and defers pose + lens application until the matching Three.js camera andCameraControlsinstance mount across project open (openingFrame),camera-controls:view(handleNodeView), Preview entry, andcamera-controls:frame(handleFrame), while ignoring initialnulltolevel_0floor hydration so off-floor saved targets are not reset totargetY.packages/core/src/events/bus.ts,packages/viewer/src/ui/lib/viewer-selection.ts):CameraControlFrameEvent.poseandviewerFrameEventforward optionalmode,fov, andzoomfromnode.camera, andframeViewerCameraapplies perspectivefovand orthographiczoomwhen present.packages/viewer/src/components/viewer/viewer-camera.tsx): HoistedDEFAULT_CAMERA_POSITIONso React Three Fiber prop reconciliation does not resetcamera.positionto[10, 10, 10]whenViewerCamerare-renders after a non-transitioned camera restore.packages/core/src/schema/camera.ts,camera.test.ts): ChangedCameraSchema.modefrom.default('perspective')to.optional(). For@pascal-app/coreconsumers and MCP clients readingnode.camera.mode, legacy{ position, target }cameras now parse withmode: undefinedinstead of'perspective'so restoring an older saved view preserves the active projection and lens. Addedpackages/core/src/schema/camera.test.tsverifying legacy cameras parse withoutmodeand round-trip cleanly.mode,fov, orzoomkeep the active projection and lens unchanged and applypositionandtargetas before.How to test
bunx biome checkon the modified files inpackages/core,packages/viewer, andpackages/editor(0 errors, 0 warnings).bunx turbo run build check-types test --filter=@pascal-app/core --filter=@pascal-app/viewer --filter=@pascal-app/editorandbun run check:render-bundle.#1280round-trip suite inpackages/editor/src/components/editor/saved-camera-view.test.tsx: perspective views with customfovand orthographic views with customzoomround-trip across capture, project open,camera-controls:view, andframeViewerNode, while legacy{ position, target }views preserve the current projection and lens.Screenshots / screen recording
Screen recording: cold project open on saved orthographic view (
zoom = 85), switching via the views bar toStudiosaved in perspective mode (fov = 24), switching back toStudio House(orthographic,zoom = 85), and reloading the project:Project opened cold with
site.camerasaved inorthographicmode atzoom = 85(position: [12, 10, 12],target: [2, 1.2, -1.5]):After switching to Perspective and clicking
Scene -> Site -> Camera snapshot -> View snapshot(restores identicalorthographicprojection andzoom = 85):Checklist
bun devbun checkto verify)mainbranchNote
Medium Risk
Touches core camera schema semantics and many editor camera lifecycle paths (open, preview, framing); behavior change for legacy
node.camerawithoutmode, mitigated by tests but worth regression on navigation edge cases.Overview
Extends saved node cameras so projection and lens settings round-trip with position/target: orthographic zoom and perspective FOV are captured on snapshot, restored on project open, View snapshot, preview, and views-bar /
frameViewerNodeframing, with deferred application whencameraModemust switch first.A new
saved-camera-viewmodule centralizes read/capture/apply (including settled orthographic zoom viacamera-controls’_zoomEnd).CustomCameraControlsroutes opening frame, preview, capture/view, and frame events throughapplyOrDeferSavedViewand tightens level-follow so initial floor hydration does not stomp off-floor saved targets.CameraControlFrameEvent.poseandframeViewerCameraforward and apply optionalmode,fov, andzoom.CameraSchema.modeis optional (no default'perspective') so legacy{ position, target }data keeps the active projection/lens on restore.ViewerCamerahoists default position to avoid R3F resetting the camera after instant restores.Added schema and integration tests covering legacy cameras and #1280 round-trips (open, view, framing, preview exit).
Reviewed by Cursor Bugbot for commit 783208b. Bugbot is set up for automated code reviews on this repo. Configure here.