Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / InstancedMeshComponent

Class: InstancedMeshComponent

Defined in: components/InstancedMesh.ts:64

Holds authored instanced-mesh data for an entity that renders as a THREE.InstancedMesh. Supports primitive geometry kinds (cube, sphere, plane, capsule, cylinder).

The instancedMesh field is a live runtime reference that is not serialized into snapshots — it is excluded by the snapshot normalizer in worldSnapshotUtils.ts to prevent history churn.

Extends

Constructors

Constructor

ts
new InstancedMeshComponent(
   meshKind?, 
   meshParameters?, 
   options?): InstancedMeshComponent;

Defined in: components/InstancedMesh.ts:93

Parameters

ParameterTypeDefault value
meshKindInstancedMeshKind"cube"
meshParameters?Partial<MeshGeometryParameters>undefined
options?{ castShadow?: boolean; receiveShadow?: boolean; instanceEntityIds?: number[]; modelPath?: string; }undefined
options.castShadow?booleanundefined
options.receiveShadow?booleanundefined
options.instanceEntityIds?number[]undefined
options.modelPath?stringundefined

Returns

InstancedMeshComponent

Overrides

Component.constructor

Properties

PropertyTypeDescriptionDefined in
meshKindInstancedMeshKindGeometry kind for all instances. Use "model" for a custom GLTF/GLB asset.components/InstancedMesh.ts:66
modelPathstringPath to the GLTF/GLB asset when meshKind === "model". Serialized in snapshots and restored on hydration.components/InstancedMesh.ts:71
meshParametersMeshGeometryParametersEditable geometry parameters (width/height/depth, radius, etc.). Ignored when meshKind === "model".components/InstancedMesh.ts:73
castShadowbooleanWhether all instances cast shadows.components/InstancedMesh.ts:75
receiveShadowbooleanWhether all instances receive shadows.components/InstancedMesh.ts:77
instanceEntityIdsnumber[]Ordered list of entity IDs for the instance slot entities owned by this group. Each slot entity carries a TransformComponent that InstancedMeshSystem reads every frame to build the per-instance matrix.components/InstancedMesh.ts:83
instancedMeshObject3D<Object3DEventMap> | nullLive runtime container managed by InstancedMeshSystem: - For primitive kinds: a THREE.InstancedMesh. - For "model" kind: a THREE.Group containing per-mesh THREE.InstancedMesh objects. Excluded from snapshot serialization — do not read this in hydration code.components/InstancedMesh.ts:91

Methods

getSanitizedParameters()

ts
getSanitizedParameters(): MeshGeometryParameters;

Defined in: components/InstancedMesh.ts:117

Sanitize and return a copy of the current mesh parameters with valid values.

Returns

MeshGeometryParameters