Skip to content

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, or THREE.CapsuleGeometry when an entity's MeshGeometryComponent is first seen or its kind changes.
  • Recreating the geometry when parameter values (dimensions, radius, height) change.
  • Assigning the geometry to the THREE.Mesh found via Object3DRef.
  • Disposing the previous geometry before replacing it to free GPU memory.

Queried components ​

ComponentAccess
MeshGeometryComponentRead (kind, parameters)
Object3DRefRead (the live THREE.js mesh)

Supported geometry kinds ​

KindParameters
cubewidth, height, depth
planewidth, height
sphereradius
cylinderradiusTop, radiusBottom, height
capsuleradius, height

Behavior notes ​

  • Parameter sanitization — all dimension values are clamped to a minimum (0.01 for dimensions, 0.001 for 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 BufferGeometry is disposed before the new one is assigned, preventing accumulated GPU memory usage when parameters change frequently.

API reference ​