Spawn a mesh from a primitive shape. Almost every visible entity in a scene has a MeshPrimitive (or a Mesh for .glb assets).
Component shape
The MeshPrimitiveComponent stores the input plus the resulting MeshHandle once the System has created the mesh.
Events
Listen to CREATED if your other systems need to know when a mesh becomes available (e.g., the camera attaches to it). Listen to DESTROYED to clean up references that held the entity's mesh handle.
JSON examples
A player capsule:
A textured ground plane:
A spinning torus:
What the System does
MeshPrimitiveSystem does three things:
- On
onEntityAdded— callsrenderer.createMesh(meshId, spec), stores the returnedMeshHandleon the component, emitsMeshPrimitiveEvents.CREATED. - On
onEntityRemoved— callsrenderer.destroyMesh(handle), emitsDESTROYED. - On input events — listens for
SET_POSITION,SET_ROTATION, etc., and forwards to the adapter'ssetMeshPosition,setMeshRotation, etc.
The component's meshId is a stable string derived from the entity's ID. Other components (Physics, Shadow, Animation, Movement) use that meshId to find the right mesh in the adapter.
What about runtime updates
Most of the time, don't emit SET_POSITION every frame from your gameplay code — let Physics or Movement own that. Use the input events when you need to teleport an entity, snap to a checkpoint, or apply a one-off transform from UI.
For per-frame movement, attach a Movement or Physics component. Those Systems handle the per-frame setMeshPosition calls efficiently.
Where to next
- Input & Movement — KeyboardMover, PlayerInput, Movement
- Physics — rigid bodies on a primitive mesh