Run Mode Guide
Run mode = live choreography execution. The scene becomes alive.
Lifecycle -- startRunMode():
- Snapshot entity transforms (position, scale, rotation, opacity, visible)
- Lazy-import
@sajou/core(Choreographer, BrowserClock) - Create RenderAdapter (Three.js bridge) + CommandSink + Clock + Choreographer
- Convert editor ChoreographyDefs -> runtime ChoreographyDefinitions
- Choreos with filtered wires -> registered under synthetic type
__f:<choreoId> - Choreos without filters -> registered with original
ontype
- Choreos with filtered wires -> registered under synthetic type
- Create BindingExecutor (peer of choreographer for property bindings)
- Subscribe to
onSignal()-- wire-aware dispatch with filter chains - Activate run mode UI (workspace--running class)
- Start spritesheet animations (idle cycles)
Lifecycle -- stopRunMode(): 0. Stop spritesheet animations (restore original textures)
- Dispose choreographer
- Dispose binding executor
- Unsubscribe signal listener
- Restore entity snapshot (position, scale, rotation, opacity, visible)
- Dispose filter chains
- Clean up state
Signal dispatch flow in run mode:
Signal arrives
|
for each choreography:
|
+-- Check if signal.type is in effectiveTypes
|
+-- If filtered choreo:
| For each input wire matching signal.type:
| Run FilterChain.process(signal)
| If passes -> dispatch "__f:<choreoId>"
|
+-- If unfiltered choreo:
Dispatch original type (once per type)
|
+-- Binding executor evaluates in parallel
+-- Signal counter incrementedBindings:
- Peer of choreographer -- evaluates on every signal dispatch
- Direct property assignments:
animation.state,visible,opacity,rotation,scale,position.x,position.y,teleportTo - Mapping functions:
lerp,clamp,step,smoothstep - Uses
whenclause matching for conditional execution
Editor -> Runtime conversion:
- Strips editor-only fields (id, nodeX, nodeY, collapsed)
- Flattens
paramsbag into step object - Resolves
defaultTargetEntityId-> stepentityfield - Structural actions (parallel, onArrive, onInterrupt) convert recursively
Key files:
tools/scene-builder/src/run-mode/run-mode-controller.ts-- lifecycle managertools/scene-builder/src/run-mode/run-mode-bindings.ts-- binding executortools/scene-builder/src/run-mode/run-mode-state.ts-- snapshot/statetools/scene-builder/src/run-mode/run-mode-sink.ts-- CommandSink adaptertools/scene-builder/src/run-mode/run-mode-animator.ts-- spritesheet animations