Behaviour Lifecycle & Events
Behaviour is dispatched by the ScriptBehaviourSystem each frame. Knowing the precise order of hooks helps you place state setup, simulation, and cleanup correctly.
Frame order
World.update(dt)
├── ObjectManagementSystem # parent reconciliation, entity lifecycle
├── (geometry / material systems)
├── (custom user systems)
├── ScriptBehaviourSystem
│ ├── for each enabled script:
│ │ ├── if first run → init()
│ │ └── onUpdate()
├── (sync systems)
├── AnimationSystem
├── TransformSyncSystem
└── RenderSystemThis ordering means:
this.transformmutations inonUpdate()are picked up the same frame byTransformSyncSystemand applied to the three.js object.- Animation runs after scripts, so animating a value will overwrite a script's mutation on the same property.
Hook reference
| Hook | Override? | Frequency | Runs in editor? | Purpose |
|---|---|---|---|---|
init() | Yes (protected) | Once before first onUpdate | Only when executeInEditor: true | Default and validate data, cache references |
onUpdate() | Yes (protected) | Every frame | Only when executeInEditor: true | Per-frame logic |
dispose() | Yes | Once on detach/destroy | Only when executeInEditor: true | Release timers, listeners, resources |
onSelect() / onDeselect() | Optional | Editor selection toggles | Yes | UX-only hooks |
onTargetFound() / onTargetLost() | Optional | Image tracking | No | React to AR target visibility |
Set executeInEditor: true on a script entry in the inspector to opt a script into the full lifecycle in editor mode. See Running scripts in the editor.

