Skip to content

Engine API

Systems and GameComponent.update() run once per fixed tick in this exact order:

#PhaseConstantDescription
1inputPHASE.INPUTSample input devices (keyboard, mouse, gamepad) at the top of the frame.
2prePhysicsPHASE.PRE_PHYSICSApply forces/intents to rigid bodies before the physics step.
3physicsPHASE.PHYSICSStep the Rapier physics world (fixed timestep).
4postPhysicsPHASE.POST_PHYSICSRead physics results back; sync transforms from bodies to Object3D.
5gameLogicPHASE.GAME_LOGICGeneral gameplay behavior. Default phase for GameComponents.
6animationPHASE.ANIMATIONAdvance animation graphs / mixers.
7preRenderPHASE.PRE_RENDERFinal per-frame fixups (cameras, HUD state) before drawing.
8renderPHASE.RENDERDraw the frame.

Base class for game components attached to entities. The Three.js Object3D IS the entity — there is no separate entity id.

  • 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 through schema.parse(data) before assignment.
  • 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 with other begins.
  • onTriggerExit — Called when a sensor overlap with other ends.