Repository navigation
[Maintainer] editor: restore scene auto-framing on load - #1244
Conversation
…obbering it useAutoFrame was accidentally removed in e688792, so nothing emitted camera-controls:fit-scene on load; the level-follow effect's first-run default pose then reset the camera after framing on fast client-side navigations. Restore the hook, gate the default pose to scene-less editors, skip the initial null->level transition, and re-emit fit-scene once the viewer signals scene-ready. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
Assert EditorContent mounts useAutoFrame and re-emits fit-scene on viewer scene-ready, and that CustomCameraControls keeps the __pascalCameraControls helper ungated by NODE_ENV.
Bugbot on #766: the level-follow early return treated every same-id rerun and every null->level as a no-op. Keep the first auto-select skip so auto-frame still owns load, but follow exploded/stacked Y changes and a level pick after building/breadcrumb/resetSelection.
Bugbot on #766: skipping the first null->level in the controls lifetime also dropped a real pick when load restored site phase (levelId null). Keep first-load auto-frame / empty-scene default pose; after that, pan on level or levelMode changes. Y-idempotence still swallows no-ops.
Queue fit-scene while orbit controls are unmounted (first-person or pre-ref), flush on orbit resume, and cover the FP->orbit transition with a behavioral helper test for Aymericr's #766 review.
Resolves the conflicts with main's camera rework: - Level-follow keeps the PR's "pan only on a real change" rule, but uses main's sticky last level and also re-rests the pivot when drei builds a new controls instance for a new default camera. - Fit-scene framing rests the pivot on the selected level's ground and keeps the eye over the ground, as main's handler did. - Keeps main's dev-only gate on window.__pascalCameraControls and drops the source-string wiring test that asserted the gate was gone. - The scene-ready re-emit fires once per load, not on every viewer remount. Co-authored-by: ActArtech <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 112fda792e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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 112fda7. Configure here.
computeSceneBoundsXZ mixed a building's world position with its descendants' building-local wall endpoints and polygons, so a moved building framed the span between the origin and the building, and a rotated one ignored the turn. Compose each node's parent chain (position plus rotation yaw, via core's turnPlanPoint/yawOf, the BuildingRenderer convention) before extending the bounds. Co-authored-by: ActArtech <[email protected]>
setLookAt moves only the eye and target, so a persisted orthographic camera kept the previous project's zoom and could open a differently sized scene empty or cropped. The fit-scene look-at now carries a footprint sphere centred on the pivot, and the orthographic apply path fits it with fitToSphere as frameViewerCamera does. Perspective framing is unchanged. Co-authored-by: ActArtech <[email protected]>
…oaded The level-follow effect's first run returned early for any non-empty scene, skipping the default pose and the rest-pivot-on-floor step. Its controls remount on leaving XR or after error-boundary recovery while the once-per-load fit-scene re-emit does not fire again, so the fresh pivot stayed at the origin. planLevelFollow now keeps the default pose for an empty first load only and treats a loaded first run like a camera change (a real load's later scene-ready fit still wins). The previous-value bookkeeping moves after the controls guard. Co-authored-by: ActArtech <[email protected]>
Doors, windows and wall items carry a wall-local position; reading it as level-local pulled the frame towards the origin. The wall's endpoints already bound them. Co-authored-by: ActArtech <[email protected]>
…ments
Conflicts:
- packages/editor/src/i18n/locales/{en,en-XA}/messages.ts: compiled
catalogs conflicted on both branches' new messages; regenerated with
`bun run i18n:extract` rather than hand-merged. `bun run i18n:check`
passes.
Everything else auto-merged; `bun run ci` covers the files both sides
touched (core/index.ts, floating-action-menu.tsx, en/messages.po).
Co-authored-by: sudhir <[email protected]>

What does this PR do?
Maintainer port of #766 by @ActArtech, brought up to current
main. The contributor's commits are kept with their authorship.Opening a project now frames the scene instead of leaving the camera at the default pose:
EditorContentmountsuseAutoFrame()and sendscamera-controls:fit-sceneagain once per load, when the viewer reports the scene ready.3fe423cd, Codex P1):computeSceneBoundsXZaccumulates each ancestor'spositionandrotationyaw, so a moved or rotated building frames on where it actually is.position(dd0570c3).cd4f3cf1, Codex P1): the fit plan includes a sphere centred on the pivot, and an orthographic camera getsfitToSphereaftersetLookAt, the same wayframeViewerCameradoes it. Perspective is unchanged.1df23a00): a pureplanLevelFollowdecides between the default pose (first run, empty scene), a pivot rest (first run over a loaded scene, or a level, level-mode or camera change), or nothing. When the controls rebuild, for example after leaving XR, the pivot rests on the level instead of staying at the origin.main's stickylastLevelId,keepEyeOverGroundand the pivot re-rest when a new controls instance is built.fit-scene-framing.ts. A fit requested in first-person, or before the orbit controls mount, is queued and applied when orbit resumes. Framing rests the pivot on the selected level's ground.window.__pascalCameraControlsstays dev-only.How to test
bun dev, open a project with content far from the origin, e.g./project/villa-offsetor/project/seattle-parking.mainit stays on the default pose (zoomed into the middle of the site).bun test packages/editor/src/components/editor/fit-scene-framing.test.ts packages/editor/src/lib/scene-bounds.test.tsScreenshots / screen recording
main)Load of seattle-parking, before then after (no input):
pr766_load_framing_before_after.mp4
These captures predate the bounds, zoom and level-follow commits.
Checklist
bun devbun checkto verify)mainbranchLocal
bun run cipassed ondd0570c3(exit 0). Remaining follow-ups:Supersedes #766. Credit: @ActArtech.
Co-authored-by: ActArtech [email protected]
To show artifacts inline, enable in settings.
Note
Medium Risk
Changes core editor camera behavior on every project load and level/camera transitions; regressions would affect framing, orthographic zoom, or first-person/orbit handoff rather than security.
Reviewed by Cursor Bugbot for commit dd0570c. Bugbot is set up for automated code reviews on this repo. Configure here.