MeshGeometrySystem
Creates and updates the THREE.js BufferGeometry on primitive mesh entities based on their MeshGeometryComponent kind and parameter values.
Overview
MeshGeometrySystem runs every frame and is responsible for:
- Creating
THREE.BoxGeometry,THREE.SphereGeometry,THREE.PlaneGeometry,THREE.CylinderGeometry, orTHREE.CapsuleGeometrywhen an entity'sMeshGeometryComponentis first seen or its kind changes. - Recreating the geometry when parameter values (dimensions, radius, height) change.
- Assigning the geometry to the
THREE.Meshfound viaObject3DRef. - Disposing the previous geometry before replacing it to free GPU memory.
Queried components
| Component | Access |
|---|---|
MeshGeometryComponent | Read (kind, parameters) |
Object3DRef | Read (the live THREE.js mesh) |
Supported geometry kinds
| Kind | Parameters |
|---|---|
cube | width, height, depth |
plane | width, height |
sphere | radius |
cylinder | radiusTop, radiusBottom, height |
capsule | radius, height |
Behavior notes
- Parameter sanitization — all dimension values are clamped to a minimum (
0.01for dimensions,0.001for radii). Non-finite values fall back to component defaults so an invalid inspector input never creates a degenerate geometry. - Signature-based change detection — per-entity signatures are compared each frame; the geometry is only rebuilt when the signature changes.
- Geometry disposal — the previous
BufferGeometryis disposed before the new one is assigned, preventing accumulated GPU memory usage when parameters change frequently.
API reference
- Class:
MeshGeometryComponent - Source:
core/systems/MeshGeometrySystem.ts

