Skip to content

fix(editor): restore scene auto-framing on load - #2

Open
ActArtech wants to merge 1 commit into
docs/hs-standardfrom
fix/camera-framing
Open

fix(editor): restore scene auto-framing on load#2
ActArtech wants to merge 1 commit into
docs/hs-standardfrom
fix/camera-framing

Conversation

@ActArtech

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes the empty-viewport camera bug (full root-cause chain documented in wiki/empty-viewport-postmortem.md, filed by the base PR):

  • Restores useAutoFrame() (import + call) in packages/editor/src/components/editor/index.tsx — it was deleted in e688792, so nothing emitted camera-controls:fit-scene and the camera stayed at the hardcoded (20, 20, 20) default pose on every scene load.
  • Stops the level-follow effect in CustomCameraControls from clobbering the auto-framed pose: the first-load default pose now only applies to a scene-less editor, and moveTo only fires on real level switches (not the initial null → level transition).
  • Re-emits camera-controls:fit-scene once the viewer reports scene-ready, so late load-driven effects can't leave the camera unframed on fast (client-side navigation) loads.
  • Removes a process.env.NODE_ENV gate around the window.__pascalCameraControls debug handle that threw in Turbopack-served workspace sources, leaving the handle permanently unset.

How to test

  1. bun run dev in apps/editor, open /scenes, click into a large scene (e.g. Hagia Sophia ground floor) via the scene list.
  2. Expected: the camera frames the building mass in the 3D viewport (previously: interior-of-footprint / empty view).
  3. Switch levels and back — the camera holds its pose except on real level switches.
  4. Hard-refresh on a direct scene URL — framing is still correct.

Screenshots / screen recording

Before/after evidence captured during the fix is documented in wiki/empty-viewport-postmortem.md (base PR). Recording can be attached on request.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify) — biome check output on the touched files is identical at HEAD (pre-existing CRLF noise)
  • I've updated relevant documentation (if applicable) — covered by the base PR's postmortem
  • This PR targets docs/hs-standard (stacked on the documentation PR, not main)

…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 <clio-agent@sisyphuslabs.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant