mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
PageScene engine no longer writes to PageSceneStore directly. Engine subsystems emit typed EngineEvents on a per-event-type bus; a single EngineStoreBridge subscribes per event class and is the only file in engine/ that imports usePageSceneStore. Write flow is one-way: UI toggles emit on the bus, the bridge updates the store, an engine-side reactor updates the THREE side. No store->engine subscriptions remain. EngineEventBus is keyed by constructor reference (Map<EventCtor, Set<Listener>>) so emit() walks only listeners for that event type -- no global fan-out, no instanceof chains. Mirrors Chromium's per-type EventListenerMap pattern. MouseControls constructor refactored from 20 positional Function args to a MouseControlsDeps object before adding bus. SceneUtils, SaveManager, CameraController, and Scene now take Deps objects with an explicit bus field. Lifecycle helpers (set3DPageMounted etc.) moved out of editor.ts into a non-engine engineLifecycle.ts so engine/ stays store-free. Same for SceneMetadata (now sceneMetadata.ts at the page root). Action dispatchers no longer dual-write: addCharacter/addObject/ addShape/setCameraAspect/setTransformMode/toggleObjectLock/ toggleObjectVisibility now emit a single bus event each. Prerequisite for componentizing PageScene into @storyteller/ui-pagescene.