Engine API
Phase order
Section titled “Phase order”Systems and GameComponent.update() run once per fixed tick in this exact order:
| # | Phase | Constant | Description |
|---|---|---|---|
| 1 | input | PHASE.INPUT | Sample input devices (keyboard, mouse, gamepad) at the top of the frame. |
| 2 | prePhysics | PHASE.PRE_PHYSICS | Apply forces/intents to rigid bodies before the physics step. |
| 3 | physics | PHASE.PHYSICS | Step the Rapier physics world (fixed timestep). |
| 4 | postPhysics | PHASE.POST_PHYSICS | Read physics results back; sync transforms from bodies to Object3D. |
| 5 | gameLogic | PHASE.GAME_LOGIC | General gameplay behavior. Default phase for GameComponents. |
| 6 | animation | PHASE.ANIMATION | Advance animation graphs / mixers. |
| 7 | preRender | PHASE.PRE_RENDER | Final per-frame fixups (cameras, HUD state) before drawing. |
| 8 | render | PHASE.RENDER | Draw the frame. |
GameComponent
Section titled “GameComponent”Base class for game components attached to entities. The Three.js Object3D IS the entity — there is no separate entity id.
statics
Section titled “statics”phase— Which phase this component’s update runs in. Override in subclasses.schema— Optional Zod object schema for authored fields. When set, scene data is validated + defaulted throughschema.parse(data)before assignment.
fields
Section titled “fields”object3D— The Object3D this component is attached to. The Object3D IS the entity.rigidBody— The entity’s Rapier rigid body, if it has physics.collider— The entity’s Rapier collider, if it has physics.
init— Called once after the entity is fully constructed (object3D, physics, etc.).update— Called every fixed timestep, in the component’s phase. Required (abstract).dispose— Called when the entity is destroyed or the component is removed.onTriggerEnter— Called when a sensor overlap withotherbegins.onTriggerExit— Called when a sensor overlap withotherends.