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:
|
Aymericr
left a comment
There was a problem hiding this comment.
[Maintainer] Thanks @kruschdev. You addressed the earlier review well: the schema change is called out and has a test, the screen recording is in the description, and legacy position+target views keep working. Two Bugbot findings at 783208b are still open and I think they matter before merge:
saved-camera-view.ts: Bugbot says a legacy{ position, target }camera still getsmode: 'perspective'filled in by a Zod parse somewhere (for exampleupdateNode), soreadSavedCameraViewwould treat it as an intentional perspective snapshot and switch projection. You madeCameraSchema.modeoptional; please confirm no other schema (the site/buildingcamerafields) re-applies the default, and add a test that goes throughupdateNoderather than onlyCameraSchema.parse.custom-camera-controls.tsx: leaving preview can remount the Three.js camera whencameraModeswitched, and the level-follow effect treats the remount ascameraChangedand rest-pivots onto the floor, overwriting the pose just restored bytakePreviewCameraRestore. A test for preview entry in a different projection followed by exit would pin it.
Still open from the first review: _zoomEnd is a private CameraControls field; a small helper with a comment and a test that fails if the field disappears would make that safe.
CI: GitHub Actions have not run on this head (fork workflows are waiting for maintainer approval). Fixes #1280 is correct.
|
Thanks @Aymericr! Both Bugbot findings and the
The branch merges cleanly with |
|
Review at
This changes visible UI, so please attach before/after screenshots or a short clip. P0/P1: 0. CI hasn't run on this fork PR yet because it needs a maintainer to approve the workflow run; it merges once that's green. |
…es (#1350) * core: apply per-fallback-locale plural rules in PascalI18n Ported from #1345 at 03da2d2. Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com> * editor: restore saved camera projection and lens on open and view Ported from #1305 at 783208b. Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com> * nodes: make item physical width, height and depth editable in the item panel Ported from #1308 at 4fed217. Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com> * core: keep active-locale formatting and one resolver for fallback plurals Review fixes for #1345 (Codex review at 03da2d2): - P2 registry.ts:192: `scope.i18n._()`/`t()` used the merged active-locale runtime while `scope._()` used the catalog owner's. The public runtime now routes through the same resolver. - P2 registry.ts:230: the catalog locale also drove number/date formatting, so `de-CH` formatted a `de` message's numbers as German. Only a message that pluralizes now renders with its catalog's runtime; every other message keeps the active locale's formatting. - P3 i18n.test.tsx:124: the pt-PT override test now registers the same id in `pt` with different text and asserts the regional message wins. * nodes: bound item dimension edits and keep them on the item they started on Review fixes for #1308 (Codex review at 4fed217): - P1 dimensions.ts:50: a dimension entry could exceed the Scale maximum of 10 and accepted a non-finite quotient. MIN/MAX_ITEM_SCALE now bound both the Scale and Dimensions controls, and a non-finite quotient is refused. - P2 dimensions.ts:84: the aspect lock clamped each axis separately and changed proportions at the minimum. One factor, limited by every axis's bounds, now applies to all three axes. - P2 panel.tsx:65: a selection change mid-drag dropped the paused preview. The drag remembers its item, the dimension sliders are keyed by item so the gesture ends on a selection change, and cancel restores that item without recording history. - P3 panel.tsx:110: strict equality recorded an undo step for a retyped value that round-trips through the base dimension; scales now compare with a relative tolerance. * editor: keep typed measurements exact and make in-field nudges a draft Review fixes for #1308 (Codex review at 4fed217): - P2 panel.tsx:462: SliderControl rounded every parsed value in the display unit, so `1 m` typed in imperial mode stored 0.999744 m. A measurement typed with its own unit is now kept exactly; a bare number still rounds in the display unit it is read in. - P2 slider-control.tsx:358: Escape could not cancel in-field arrow nudges, which wrote the scene on every press. Nudges now edit the draft text (and preview only when the control previews typing); Enter or blur commits once, Escape discards. * editor: let floor picks and projection changes win over pending camera restores Review fixes for #1305 (Codex review at 783208b): - P2 custom-camera-controls.tsx:891: after the opening view landed, a camera remount re-ran the opening frame, which switched projection back before its "already framed" guard and undid the person's projection change. Once the view has landed the opening no longer switches projection. - P2 custom-camera-controls.tsx:755: a pending saved view whose projection the store had already switched away from held the level follow forever. It is now discarded, and the floor change runs. - P2 custom-camera-controls.tsx:773: a floor picked while a pose interpolated was recorded and lost. A camera remount still keeps the pose; a floor or level-mode change ends it and the camera follows. * viewer: frame a saved view in its own projection outside the editor Review fix for #1305 (Codex review at 783208b): - P2 viewer-selection.ts:463: with perspective controls and an orthographic snapshot, frameViewerCamera aimed the perspective camera and dropped the saved zoom. frameViewerCameraInProjection switches projection first, and ViewerCameraControls frames the same event once the matching controls mount. Tested on the helper, without CustomCameraControls. * editor: type the level id in the camera level-follow tests * viewer: open the standalone viewer on the site view's saved projection and lens Review fix for #1350 (Codex P1, viewer-camera-controls.tsx): the opening path read `site.camera` and called only `setLookAt`, so a read-only viewer opened an orthographic or custom-lens site view in its current projection with the default lens. The opening now frames through the same projection-aware path as the views bar, with `savedViewPose` shared by both. Co-authored-by: Aymeric Rabot <Aymericr@users.noreply.github.com> * editor: keep the landed opening view's pose across a projection switch Review fix for #1350 (Bugbot, custom-camera-controls.tsx:902): once the opening view had landed, a projection switch remounted the camera at the default pose, and the opening frame returned early, which also skipped the level follow's rest pivot. The remount reframe now puts the new camera at the saved view's position and target in the projection the person picked; the follow timers still leave the camera alone. Co-authored-by: Aymeric Rabot <Aymericr@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: kruschdev <249158235+kruschdev@users.noreply.github.com> Co-authored-by: Aymeric Rabot <Aymericr@users.noreply.github.com>
|
Thank you @kruschdev! This landed in #1350 (squash merge 1eb1b27) as its own commit, with you credited as co-author. Fork CI couldn't run here, so we ported it onto current Saved views now restore their projection and lens on open and on view, as you intended. On top of that, review fixes cover a few edge cases. A projection the user picks after the view lands is kept. A stale pending view is dropped. A floor change ends an in-flight pose. The standalone viewer's opening now uses the same projection-aware framing. Each fix has an integration test. Closing this one as landed. Thanks again! |

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.