Skip to content

Decide what a theme switch does to a stage the user framed themselves #36

Description

@Dillpickleschmidt

Question

Should a theme switch preserve the camera the user framed themselves, and if so, at what cost?

A palette change is a stage construction, and fitView() runs unconditionally there (TreeScene.tsx:655, CityScene.tsx:618) — so switching theme re-frames both scenes over whatever the user had. The guard against exactly this already exists twice on other paths: the resize handler and the tallest-column refit both decline to re-frame when userTookCameraRef.current or a live selection pan says the camera is spoken for.

What makes it a question rather than a third copy of that guard is that palette is also a dependency of the mount effect (CityScene.tsx:442, TreeScene.tsx:408). A theme switch therefore tears down the renderer, the OrbitControls, and the WebGL context itself, and re-runs userTookCameraRef.current = false on the way back up. The flag that would drive the guard is wiped by the same rebuild it is meant to survive, so preserving the framing means either lifting that state out of the rebuild or narrowing what a palette change is allowed to reconstruct.

Worth weighing against: rebuilding wholesale is a deliberate choice, on the grounds that "it happens once in a blue moon, and the alternative is a second code path that has to stay in step with scene construction forever" (CityScene.tsx:107). Re-fitting a rebuilt stage is defensible if a rebuild is read as a fresh stage — and the counter-argument is that the user does not experience a theme switch as a fresh stage.

Found resolving #27, and deliberately left out of it: selection state is re-applied across a rebuild now, but the user's own framing is not selection state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions