@relu-interactives/spatial-ecs 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{System-AV2_87Zr.d.cts → System-KTHuWc-i.d.cts} +1 -1
- package/dist/{System-AV2_87Zr.d.ts → System-KTHuWc-i.d.ts} +1 -1
- package/dist/{Video-D6mObK_5.d.ts → Video-BnrYbbzu.d.cts} +2 -2
- package/dist/{Video-Bn93p6XV.d.cts → Video-Ds_0Aj66.d.ts} +2 -2
- package/dist/{chunk-ODCWJHPS.js → chunk-OIOUWDOS.js} +3 -3
- package/dist/{chunk-ODCWJHPS.js.map → chunk-OIOUWDOS.js.map} +1 -1
- package/dist/{chunk-Y7KXYSPD.js → chunk-UU6VYCIO.js} +4 -4
- package/dist/{chunk-Y7KXYSPD.js.map → chunk-UU6VYCIO.js.map} +1 -1
- package/dist/{chunk-AZR6SLQN.js → chunk-XPCVEXMY.js} +2 -2
- package/dist/{chunk-AZR6SLQN.js.map → chunk-XPCVEXMY.js.map} +1 -1
- package/dist/{chunk-LE6ARNYQ.js → chunk-YLRCC4EK.js} +4 -4
- package/dist/{chunk-LE6ARNYQ.js.map → chunk-YLRCC4EK.js.map} +1 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/docs/api/Behaviour/classes/Behaviour.md +29 -29
- package/dist/docs/api/Component/classes/Component.md +3 -1
- package/dist/docs/api/components/classes/AnimationComponent.md +26 -26
- package/dist/docs/api/components/classes/AudioComponent.md +19 -19
- package/dist/docs/api/components/classes/CameraComponent.md +14 -14
- package/dist/docs/api/components/classes/EntityType.md +4 -4
- package/dist/docs/api/components/classes/Environment.md +3 -3
- package/dist/docs/api/components/classes/ImageComponent.md +7 -7
- package/dist/docs/api/components/classes/ImageTarget.md +7 -7
- package/dist/docs/api/components/classes/ImageTargetAnchor.md +4 -4
- package/dist/docs/api/components/classes/InstanceSlotComponent.md +52 -0
- package/dist/docs/api/components/classes/InstancedMeshComponent.md +82 -0
- package/dist/docs/api/components/classes/LightComponent.md +6 -6
- package/dist/docs/api/components/classes/MaterialComponent.md +11 -11
- package/dist/docs/api/components/classes/MeshComponent.md +3 -3
- package/dist/docs/api/components/classes/MeshGeometryComponent.md +9 -9
- package/dist/docs/api/components/classes/ModelComponent.md +4 -4
- package/dist/docs/api/components/classes/Name.md +3 -3
- package/dist/docs/api/components/classes/Object3DRef.md +4 -4
- package/dist/docs/api/components/classes/ParentId.md +3 -3
- package/dist/docs/api/components/classes/PhysicsComponent.md +6 -6
- package/dist/docs/api/components/classes/Postprocessing.md +3 -3
- package/dist/docs/api/components/classes/ScriptComponent.md +5 -5
- package/dist/docs/api/components/classes/Selectable.md +3 -3
- package/dist/docs/api/components/classes/SelectionTransformState.md +5 -5
- package/dist/docs/api/components/classes/SpriteComponent.md +7 -7
- package/dist/docs/api/components/classes/TransformComponent.md +12 -12
- package/dist/docs/api/components/classes/VideoComponent.md +28 -28
- package/dist/docs/api/components/functions/normalizePhysicsState.md +1 -1
- package/dist/docs/api/components/index.md +6 -0
- package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +9 -9
- package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +13 -13
- package/dist/docs/api/components/type-aliases/CameraProjection.md +1 -1
- package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +1 -1
- package/dist/docs/api/components/type-aliases/ColliderShape.md +1 -1
- package/dist/docs/api/components/type-aliases/ColliderState.md +20 -20
- package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +4 -4
- package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +8 -8
- package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +7 -7
- package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +1 -1
- package/dist/docs/api/components/type-aliases/EnvironmentState.md +5 -5
- package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +3 -3
- package/dist/docs/api/components/type-aliases/ImageTargetReference.md +7 -7
- package/dist/docs/api/components/type-aliases/InstanceTransform.md +49 -0
- package/dist/docs/api/components/type-aliases/InstancedMeshKind.md +15 -0
- package/dist/docs/api/components/type-aliases/LightValueState.md +11 -11
- package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +1 -1
- package/dist/docs/api/components/type-aliases/MaterialValueState.md +28 -28
- package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +1 -1
- package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +7 -7
- package/dist/docs/api/components/type-aliases/PhysicsState.md +3 -3
- package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +3 -3
- package/dist/docs/api/components/type-aliases/PostprocessingState.md +62 -62
- package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +3 -3
- package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +2 -2
- package/dist/docs/api/components/type-aliases/RigidbodyState.md +17 -17
- package/dist/docs/api/components/type-aliases/RigidbodyType.md +1 -1
- package/dist/docs/api/components/type-aliases/ScriptEntry.md +9 -9
- package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +1 -1
- package/dist/docs/api/components/type-aliases/TransformData.md +4 -4
- package/dist/docs/api/components/type-aliases/TransformModeValue.md +1 -1
- package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +1 -1
- package/dist/docs/api/components/type-aliases/Vec3.md +4 -4
- package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_INSTANCED_MESH_PARAMETERS.md +15 -0
- package/dist/docs/api/components/variables/DEFAULT_INSTANCE_TRANSFORM.md +15 -0
- package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +1 -1
- package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +1 -1
- package/dist/docs/api/index/classes/AnimationStateMachine.md +16 -16
- package/dist/docs/api/index/classes/AnimationStateManager.md +13 -13
- package/dist/docs/api/index/classes/AnimationSystem.md +3 -3
- package/dist/docs/api/index/classes/AudioSystem.md +4 -4
- package/dist/docs/api/index/classes/CameraSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +4 -4
- package/dist/docs/api/index/classes/InputSystem.md +33 -33
- package/dist/docs/api/index/classes/InstancedMeshSystem.md +62 -0
- package/dist/docs/api/index/classes/LightSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/MaterialSyncSystem.md +3 -3
- package/dist/docs/api/index/classes/MeshGeometrySystem.md +2 -2
- package/dist/docs/api/index/classes/ObjectManagementSystem.md +14 -14
- package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +2 -2
- package/dist/docs/api/index/classes/PhysicsSyncSystem.md +4 -4
- package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +4 -4
- package/dist/docs/api/index/classes/RenderSystem.md +3 -3
- package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +4 -4
- package/dist/docs/api/index/classes/TransformSyncSystem.md +2 -2
- package/dist/docs/api/index/classes/VideoSystem.md +4 -4
- package/dist/docs/api/index/classes/World.md +82 -82
- package/dist/docs/api/index/functions/createAnimationComponent.md +1 -1
- package/dist/docs/api/index/functions/createAudioComponent.md +1 -1
- package/dist/docs/api/index/functions/createCameraComponent.md +1 -1
- package/dist/docs/api/index/functions/createEntityTypeComponent.md +2 -2
- package/dist/docs/api/index/functions/createEnvironmentComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +1 -1
- package/dist/docs/api/index/functions/createImageTargetComponent.md +1 -1
- package/dist/docs/api/index/functions/createInstanceSlotComponent.md +30 -0
- package/dist/docs/api/index/functions/createInstancedMeshComponent.md +36 -0
- package/dist/docs/api/index/functions/createLightComponent.md +1 -1
- package/dist/docs/api/index/functions/createMaterialComponent.md +1 -1
- package/dist/docs/api/index/functions/createMeshComponent.md +1 -1
- package/dist/docs/api/index/functions/createMeshGeometryComponent.md +1 -1
- package/dist/docs/api/index/functions/createModelComponent.md +1 -1
- package/dist/docs/api/index/functions/createNameComponent.md +1 -1
- package/dist/docs/api/index/functions/createObject3DRefComponent.md +1 -1
- package/dist/docs/api/index/functions/createParentIdComponent.md +1 -1
- package/dist/docs/api/index/functions/createPhysicsComponent.md +1 -1
- package/dist/docs/api/index/functions/createPostprocessingComponent.md +1 -1
- package/dist/docs/api/index/functions/createScriptComponent.md +1 -1
- package/dist/docs/api/index/functions/createSelectableComponent.md +1 -1
- package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +1 -1
- package/dist/docs/api/index/functions/createSpriteComponent.md +1 -1
- package/dist/docs/api/index/functions/createTransformComponent.md +1 -1
- package/dist/docs/api/index/functions/createVideoComponent.md +1 -1
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +1 -1
- package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +1 -1
- package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +1 -1
- package/dist/docs/api/index/functions/registerDefaultFactories.md +1 -1
- package/dist/docs/api/index/index.md +3 -0
- package/dist/docs/api/index/interfaces/EcsSystem.md +3 -3
- package/dist/docs/api/index/interfaces/StateMachine.md +13 -13
- package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +4 -4
- package/dist/docs/api/index/type-aliases/ComponentFactory.md +1 -1
- package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +3 -2
- package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +3 -3
- package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +4 -4
- package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +3 -3
- package/dist/docs/api/index/type-aliases/KeyboardKey.md +1 -1
- package/dist/docs/api/index/type-aliases/MouseButton.md +1 -1
- package/dist/docs/api/index/type-aliases/SelectionContext.md +4 -4
- package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +1 -1
- package/dist/docs/api/index/variables/KeyboardKeys.md +89 -89
- package/dist/docs/api/typedoc-sidebar.json +1 -1
- package/dist/docs/api/types/type-aliases/AssetInput.md +3 -3
- package/dist/docs/api/types/type-aliases/CheckboxInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ColorInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ComponentInput.md +4 -4
- package/dist/docs/api/types/type-aliases/ComponentKind.md +3 -1
- package/dist/docs/api/types/type-aliases/DropdownInput.md +3 -3
- package/dist/docs/api/types/type-aliases/DropdownOption.md +3 -3
- package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +1 -1
- package/dist/docs/api/types/type-aliases/EcsEntityKind.md +4 -2
- package/dist/docs/api/types/type-aliases/EntityId.md +1 -1
- package/dist/docs/api/types/type-aliases/EntityInput.md +3 -3
- package/dist/docs/api/types/type-aliases/FloatInput.md +1 -1
- package/dist/docs/api/types/type-aliases/IntersectionResult.md +3 -3
- package/dist/docs/api/types/type-aliases/ParentLookup.md +3 -3
- package/dist/docs/api/types/type-aliases/SelectionListener.md +1 -1
- package/dist/docs/api/types/type-aliases/SliderInput.md +5 -5
- package/dist/docs/api/types/type-aliases/TextInput.md +1 -1
- package/dist/docs/api/types/type-aliases/ToggleInput.md +1 -1
- package/dist/docs/api/types/type-aliases/Vec3.md +1 -1
- package/dist/docs/api/types/type-aliases/Vector2Input.md +3 -3
- package/dist/docs/api/types/type-aliases/Vector3Input.md +4 -4
- package/dist/docs/api/types/type-aliases/WorldEntityView.md +1 -1
- package/dist/docs/guide/components/instance-slot.md +102 -0
- package/dist/docs/guide/components/instanced-mesh.md +189 -0
- package/dist/docs/guide/spawning/index.md +4 -0
- package/dist/docs/guide/spawning/instanced-mesh.md +267 -0
- package/dist/docs/guide/systems/_sidebar.json +4 -0
- package/dist/docs/guide/systems/instanced-mesh-system.md +32 -0
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +2 -2
- package/dist/factories/index.d.ts +2 -2
- package/dist/factories/index.js +3 -3
- package/dist/{index-B4-ABchF.d.cts → index-ComEYKYI.d.cts} +2 -2
- package/dist/{index-BO49V8aS.d.ts → index-D-gUELQS.d.ts} +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -8
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -2
- package/dist/systems/index.d.ts +2 -2
- package/dist/systems/index.js +3 -3
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/worldSnapshotUtils.d.cts +1 -1
- package/dist/worldSnapshotUtils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ type IntersectionResult = {
|
|
|
13
13
|
};
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Defined in: [types.ts:
|
|
16
|
+
Defined in: [types.ts:155](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L155)
|
|
17
17
|
|
|
18
18
|
Single hit returned by `World.raycast` / `World.raycastFrom`. Pairs the
|
|
19
19
|
standard `THREE.Intersection` (`threeResult`) with the owning entity id
|
|
@@ -25,5 +25,5 @@ editor helper).
|
|
|
25
25
|
|
|
26
26
|
| Property | Type | Description | Defined in |
|
|
27
27
|
| ------ | ------ | ------ | ------ |
|
|
28
|
-
| <a id="entityid"></a> `entityId` | [`EntityId`](EntityId.md) \| `null` | The entity that owns the hit object, or `null` if untracked. | [types.ts:
|
|
29
|
-
| <a id="threeresult"></a> `threeResult` | `THREE.Intersection` | The underlying three.js intersection record. | [types.ts:
|
|
28
|
+
| <a id="entityid"></a> `entityId` | [`EntityId`](EntityId.md) \| `null` | The entity that owns the hit object, or `null` if untracked. | [types.ts:157](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L157) |
|
|
29
|
+
| <a id="threeresult"></a> `threeResult` | `THREE.Intersection` | The underlying three.js intersection record. | [types.ts:159](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L159) |
|
|
@@ -13,7 +13,7 @@ type ParentLookup = {
|
|
|
13
13
|
};
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Defined in: [types.ts:
|
|
16
|
+
Defined in: [types.ts:132](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L132)
|
|
17
17
|
|
|
18
18
|
Result of a parent lookup. `parent` is `null` for entities at the root or
|
|
19
19
|
for entities without a [ParentId](../../components/classes/ParentId.md) component.
|
|
@@ -22,5 +22,5 @@ for entities without a [ParentId](../../components/classes/ParentId.md) componen
|
|
|
22
22
|
|
|
23
23
|
| Property | Type | Description | Defined in |
|
|
24
24
|
| ------ | ------ | ------ | ------ |
|
|
25
|
-
| <a id="parentidcomponent"></a> `parentIdComponent` | [`ParentId`](../../components/classes/ParentId.md) \| `null` | The entity's `ParentId` component, or `null` if it has none. | [types.ts:
|
|
26
|
-
| <a id="parent"></a> `parent` | [`WorldEntityView`](WorldEntityView.md) \| `null` | The resolved parent entity view, or `null` if the entity is at the root. | [types.ts:
|
|
25
|
+
| <a id="parentidcomponent"></a> `parentIdComponent` | [`ParentId`](../../components/classes/ParentId.md) \| `null` | The entity's `ParentId` component, or `null` if it has none. | [types.ts:134](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L134) |
|
|
26
|
+
| <a id="parent"></a> `parent` | [`WorldEntityView`](WorldEntityView.md) \| `null` | The resolved parent entity view, or `null` if the entity is at the root. | [types.ts:136](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L136) |
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
type SelectionListener = (entityId) => void;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [types.ts:
|
|
13
|
+
Defined in: [types.ts:45](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L45)
|
|
14
14
|
|
|
15
15
|
Callback invoked when the selected entity changes. `null` indicates a deselection.
|
|
16
16
|
|
|
@@ -15,13 +15,13 @@ type SliderInput = {
|
|
|
15
15
|
};
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Defined in: [types.ts:
|
|
18
|
+
Defined in: [types.ts:55](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L55)
|
|
19
19
|
|
|
20
20
|
## Properties
|
|
21
21
|
|
|
22
22
|
| Property | Type | Defined in |
|
|
23
23
|
| ------ | ------ | ------ |
|
|
24
|
-
| <a id="min"></a> `min` | `number` | [types.ts:
|
|
25
|
-
| <a id="max"></a> `max` | `number` | [types.ts:
|
|
26
|
-
| <a id="step"></a> `step` | `number` | [types.ts:
|
|
27
|
-
| <a id="value"></a> `value` | `number` | [types.ts:
|
|
24
|
+
| <a id="min"></a> `min` | `number` | [types.ts:56](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L56) |
|
|
25
|
+
| <a id="max"></a> `max` | `number` | [types.ts:57](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L57) |
|
|
26
|
+
| <a id="step"></a> `step` | `number` | [types.ts:58](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L58) |
|
|
27
|
+
| <a id="value"></a> `value` | `number` | [types.ts:59](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L59) |
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
type TextInput = string;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [types.ts:
|
|
13
|
+
Defined in: [types.ts:50](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L50)
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
type ToggleInput = boolean;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [types.ts:
|
|
13
|
+
Defined in: [types.ts:64](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L64)
|
|
@@ -16,7 +16,7 @@ type Vec3 =
|
|
|
16
16
|
};
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Defined in: [types.ts:
|
|
19
|
+
Defined in: [types.ts:144](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L144)
|
|
20
20
|
|
|
21
21
|
Loose 3D vector accepted by raycast and other spatial helpers. Either a
|
|
22
22
|
live `THREE.Vector3` or a plain `{ x, y, z }` object — both are normalized
|
|
@@ -13,11 +13,11 @@ type Vector2Input = {
|
|
|
13
13
|
};
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Defined in: [types.ts:
|
|
16
|
+
Defined in: [types.ts:53](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L53)
|
|
17
17
|
|
|
18
18
|
## Properties
|
|
19
19
|
|
|
20
20
|
| Property | Type | Defined in |
|
|
21
21
|
| ------ | ------ | ------ |
|
|
22
|
-
| <a id="x"></a> `x` | `number` | [types.ts:
|
|
23
|
-
| <a id="y"></a> `y` | `number` | [types.ts:
|
|
22
|
+
| <a id="x"></a> `x` | `number` | [types.ts:53](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L53) |
|
|
23
|
+
| <a id="y"></a> `y` | `number` | [types.ts:53](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L53) |
|
|
@@ -14,12 +14,12 @@ type Vector3Input = {
|
|
|
14
14
|
};
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Defined in: [types.ts:
|
|
17
|
+
Defined in: [types.ts:54](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L54)
|
|
18
18
|
|
|
19
19
|
## Properties
|
|
20
20
|
|
|
21
21
|
| Property | Type | Defined in |
|
|
22
22
|
| ------ | ------ | ------ |
|
|
23
|
-
| <a id="x"></a> `x` | `number` | [types.ts:
|
|
24
|
-
| <a id="y"></a> `y` | `number` | [types.ts:
|
|
25
|
-
| <a id="z"></a> `z` | `number` | [types.ts:
|
|
23
|
+
| <a id="x"></a> `x` | `number` | [types.ts:54](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L54) |
|
|
24
|
+
| <a id="y"></a> `y` | `number` | [types.ts:54](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L54) |
|
|
25
|
+
| <a id="z"></a> `z` | `number` | [types.ts:54](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L54) |
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
type WorldEntityView = NonNullable<ReturnType<World["getEntityById"]>>;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [types.ts:
|
|
13
|
+
Defined in: [types.ts:126](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/557de6ec692f18eb77e7225eb98be3af4dfc0e33/core/types.ts#L126)
|
|
14
14
|
|
|
15
15
|
Lightweight, read-only view of an entity returned by `World.getEntityById`.
|
|
16
16
|
Contains the entity id and its current component list at the moment of the
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Instance Slot
|
|
2
|
+
|
|
3
|
+
Marks an entity as a single instance within an [`InstancedMeshComponent`](./instanced-mesh) group. Instance slot entities are lightweight data containers — they carry a `TransformComponent` (the per-instance local transform) and this component, but do **not** have an `Object3DRef`. `InstancedMeshSystem` reads every slot's `TransformComponent` each frame to compose the instance matrix for that slot's index.
|
|
4
|
+
|
|
5
|
+
Slot entities appear in the hierarchy as children of their owning `instancedMesh` group entity. Removing a slot entity from the world (or removing its ID from `InstancedMeshComponent.instanceEntityIds`) retires that instance.
|
|
6
|
+
|
|
7
|
+
> **Used by:** [`InstancedMeshSystem`](../systems/instanced-mesh-system), [`InstancedMeshComponent`](./instanced-mesh)
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
| Property | Type | Description |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `groupEntityId` | `number` | Entity ID of the owning `InstancedMeshComponent` group entity. |
|
|
14
|
+
| `slotIndex` | `number` | Zero-based index of this slot within the group's `instanceEntityIds` array. Used by `InstancedMeshSystem` to write the correct column of the instance-matrix buffer. |
|
|
15
|
+
|
|
16
|
+
## API reference
|
|
17
|
+
|
|
18
|
+
- Class: [`InstanceSlotComponent`](../../api/components/classes/InstanceSlotComponent.md)
|
|
19
|
+
- Source: [`core/components/InstanceSlotComponent.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/components/InstanceSlotComponent.ts)
|
|
20
|
+
|
|
21
|
+
## Scripting examples
|
|
22
|
+
|
|
23
|
+
::: tip Component access patterns
|
|
24
|
+
Use `this.getComponent(X)` to access a component on the **entity this script is attached to**. Use `this.world.getEntityByName` to find another entity by name, then `this.world.getComponent` to read its component:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Component on the entity this script is on
|
|
28
|
+
const slot = this.getComponent(InstanceSlotComponent);
|
|
29
|
+
|
|
30
|
+
// Component on another entity
|
|
31
|
+
const other = this.world.getEntityByName("Instance 3");
|
|
32
|
+
if (other) {
|
|
33
|
+
const slot = this.world.getComponent(other.entityId, InstanceSlotComponent);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
:::
|
|
37
|
+
|
|
38
|
+
### Find the group from a slot
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import {
|
|
42
|
+
Behaviour,
|
|
43
|
+
InstanceSlotComponent,
|
|
44
|
+
InstancedMeshComponent,
|
|
45
|
+
} from "@relu-interactives/spatial-ecs";
|
|
46
|
+
|
|
47
|
+
export default class SlotInfo extends Behaviour {
|
|
48
|
+
protected init() {
|
|
49
|
+
const slot = this.getComponent(InstanceSlotComponent);
|
|
50
|
+
if (!slot) return;
|
|
51
|
+
|
|
52
|
+
const groupEntity = this.world.getEntityById(slot.groupEntityId);
|
|
53
|
+
if (!groupEntity) return;
|
|
54
|
+
|
|
55
|
+
const group = this.world.getComponent(slot.groupEntityId, InstancedMeshComponent);
|
|
56
|
+
console.log(
|
|
57
|
+
`This is slot #${slot.slotIndex} of a group with ${group?.instanceEntityIds.length} instances`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Accept a slot reference via ComponentInput
|
|
64
|
+
|
|
65
|
+
Use a `ComponentInput` field so the inspector can wire any instance slot entity to this script.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import {
|
|
69
|
+
Behaviour,
|
|
70
|
+
InstanceSlotComponent,
|
|
71
|
+
TransformComponent,
|
|
72
|
+
} from "@relu-interactives/spatial-ecs";
|
|
73
|
+
import type { ComponentInput, FloatInput } from "@relu-interactives/spatial-ecs";
|
|
74
|
+
|
|
75
|
+
export default class MoveSlot extends Behaviour {
|
|
76
|
+
data = {
|
|
77
|
+
targetSlot: {
|
|
78
|
+
type: "component",
|
|
79
|
+
componentKind: "InstanceSlot",
|
|
80
|
+
value: null,
|
|
81
|
+
} as unknown as ComponentInput<InstanceSlotComponent>,
|
|
82
|
+
offsetX: 1 as FloatInput,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
protected init() {
|
|
86
|
+
const slot = this.data.targetSlot.value as InstanceSlotComponent | null;
|
|
87
|
+
if (!slot) return;
|
|
88
|
+
|
|
89
|
+
const transform = this.world.getComponentById(slot.groupEntityId, TransformComponent);
|
|
90
|
+
// Operate on the slot entity's own transform instead:
|
|
91
|
+
const slotEntity = this.world.getEntityById(
|
|
92
|
+
// find the slot entity ID from the group
|
|
93
|
+
(this.world.getComponent(slot.groupEntityId, { prototype: {} } as never) as never) ?? -1,
|
|
94
|
+
);
|
|
95
|
+
// Simpler: if this script is on the slot entity itself:
|
|
96
|
+
const ownTransform = this.getComponent(TransformComponent);
|
|
97
|
+
if (ownTransform) {
|
|
98
|
+
ownTransform.position.x += this.data.offsetX;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Instanced Mesh
|
|
2
|
+
|
|
3
|
+
Groups one or more instance-slot entities into a single GPU-instanced draw call. Each instance's transform comes from its corresponding `InstanceSlotComponent` entity; `InstancedMeshSystem` reads those transforms every frame and writes the instance matrices into the underlying `THREE.InstancedMesh`.
|
|
4
|
+
|
|
5
|
+
Use instanced meshes when you need tens, hundreds, or thousands of identical objects (trees, tiles, particles, projectiles, obstacles) without paying individual draw-call cost per object.
|
|
6
|
+
|
|
7
|
+
> **Managed by:** [`InstancedMeshSystem`](../systems/instanced-mesh-system)
|
|
8
|
+
|
|
9
|
+
## Editor inspector
|
|
10
|
+
|
|
11
|
+
::: tip Screenshot
|
|
12
|
+
Add a screenshot of the **Instanced Mesh** component in the editor inspector here.
|
|
13
|
+
Suggested asset path: `/public/images/inspector/instanced-mesh.png`
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
## Properties
|
|
17
|
+
|
|
18
|
+
| Property | Type | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| `meshKind` | `InstancedMeshKind` | Geometry used for every instance. One of `"cube"`, `"sphere"`, `"plane"`, `"cylinder"`, `"capsule"`, `"model"`. |
|
|
21
|
+
| `modelPath` | `string` | Source URL or `localasset://` path of the GLTF/GLB asset. Only read when `meshKind === "model"`. |
|
|
22
|
+
| `meshParameters` | `MeshGeometryParameters` | Geometry dimensions (width/height/depth for box, radius/height for cylinder/capsule, radius for sphere, width/height for plane). Ignored when `meshKind === "model"`. |
|
|
23
|
+
| `castShadow` | `boolean` | Whether all instances cast shadows. |
|
|
24
|
+
| `receiveShadow` | `boolean` | Whether all instances receive shadows. |
|
|
25
|
+
| `instanceEntityIds` | `number[]` | Ordered list of entity IDs for the `InstanceSlotComponent` entities owned by this group. Each slot carries its own `TransformComponent`. |
|
|
26
|
+
| `instancedMesh` | `THREE.Object3D \| null` | Live runtime object managed by `InstancedMeshSystem`. `null` until the system builds the mesh. **Not serialized — do not persist or clone this field.** |
|
|
27
|
+
|
|
28
|
+
## API reference
|
|
29
|
+
|
|
30
|
+
- Class: [`InstancedMeshComponent`](../../api/components/classes/InstancedMeshComponent.md)
|
|
31
|
+
- Source: [`core/components/InstancedMesh.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/components/InstancedMesh.ts)
|
|
32
|
+
|
|
33
|
+
## Scripting examples
|
|
34
|
+
|
|
35
|
+
::: tip Component access patterns
|
|
36
|
+
Use `this.getComponent(X)` to access a component on the **entity this script is attached to**. Use `this.world.getEntityByName` to find another entity by name, then `this.world.getComponent` to read its component:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Component on the entity this script is on
|
|
40
|
+
const instanced = this.getComponent(InstancedMeshComponent);
|
|
41
|
+
|
|
42
|
+
// Component on another named entity
|
|
43
|
+
const other = this.world.getEntityByName("Tree Group");
|
|
44
|
+
if (other) {
|
|
45
|
+
const instanced = this.world.getComponent(other.entityId, InstancedMeshComponent);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
:::
|
|
49
|
+
|
|
50
|
+
### Read instance count
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Behaviour, InstancedMeshComponent } from "@relu-interactives/spatial-ecs";
|
|
54
|
+
|
|
55
|
+
export default class InstanceCounter extends Behaviour {
|
|
56
|
+
protected init() {
|
|
57
|
+
const instanced = this.getComponent(InstancedMeshComponent);
|
|
58
|
+
if (instanced) {
|
|
59
|
+
console.log(`This group has ${instanced.instanceEntityIds.length} instances`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Toggle shadows on all instances at runtime
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { Behaviour, InstancedMeshComponent } from "@relu-interactives/spatial-ecs";
|
|
69
|
+
import type { BooleanInput } from "@relu-interactives/spatial-ecs";
|
|
70
|
+
|
|
71
|
+
export default class ToggleShadows extends Behaviour {
|
|
72
|
+
data = {
|
|
73
|
+
castShadow: true as BooleanInput,
|
|
74
|
+
receiveShadow: true as BooleanInput,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
protected init() {
|
|
78
|
+
const instanced = this.getComponent(InstancedMeshComponent);
|
|
79
|
+
if (!instanced) return;
|
|
80
|
+
instanced.castShadow = this.data.castShadow;
|
|
81
|
+
instanced.receiveShadow = this.data.receiveShadow;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Animate every instance's Y position
|
|
87
|
+
|
|
88
|
+
Move each slot entity up and down using a sine wave. `InstancedMeshSystem` reads the `TransformComponent` of each slot every frame, so mutating the transform is all that is needed.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import {
|
|
92
|
+
Behaviour,
|
|
93
|
+
InstancedMeshComponent,
|
|
94
|
+
TransformComponent,
|
|
95
|
+
} from "@relu-interactives/spatial-ecs";
|
|
96
|
+
|
|
97
|
+
export default class WaveInstances extends Behaviour {
|
|
98
|
+
private elapsed = 0;
|
|
99
|
+
|
|
100
|
+
protected onUpdate() {
|
|
101
|
+
const instanced = this.getComponent(InstancedMeshComponent);
|
|
102
|
+
if (!instanced) return;
|
|
103
|
+
|
|
104
|
+
this.elapsed += this.deltaTime;
|
|
105
|
+
|
|
106
|
+
for (let i = 0; i < instanced.instanceEntityIds.length; i++) {
|
|
107
|
+
const slotId = instanced.instanceEntityIds[i];
|
|
108
|
+
const transform = this.world.getComponentById(slotId, TransformComponent);
|
|
109
|
+
if (transform) {
|
|
110
|
+
transform.position.y = Math.sin(this.elapsed + i * 0.5) * 2;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Accept a group reference via ComponentInput
|
|
118
|
+
|
|
119
|
+
Use a `ComponentInput` field so the inspector can wire any `InstancedMeshComponent` entity to this script — useful when the script lives on a different entity than the group.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import {
|
|
123
|
+
Behaviour,
|
|
124
|
+
InstancedMeshComponent,
|
|
125
|
+
TransformComponent,
|
|
126
|
+
} from "@relu-interactives/spatial-ecs";
|
|
127
|
+
import type { ComponentInput } from "@relu-interactives/spatial-ecs";
|
|
128
|
+
|
|
129
|
+
export default class ScatterInstances extends Behaviour {
|
|
130
|
+
data = {
|
|
131
|
+
group: {
|
|
132
|
+
type: "component",
|
|
133
|
+
componentKind: "InstancedMesh",
|
|
134
|
+
value: null,
|
|
135
|
+
} as unknown as ComponentInput<InstancedMeshComponent>,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
protected init() {
|
|
139
|
+
const instanced = this.data.group.value as InstancedMeshComponent | null;
|
|
140
|
+
if (!instanced) return;
|
|
141
|
+
|
|
142
|
+
// Scatter each instance randomly within a 10-unit area
|
|
143
|
+
for (const slotId of instanced.instanceEntityIds) {
|
|
144
|
+
const transform = this.world.getComponentById(slotId, TransformComponent);
|
|
145
|
+
if (transform) {
|
|
146
|
+
transform.position.x = (Math.random() - 0.5) * 10;
|
|
147
|
+
transform.position.z = (Math.random() - 0.5) * 10;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Spawn a new instance slot at runtime
|
|
155
|
+
|
|
156
|
+
Add a new slot entity to an existing group from a script. The new slot's transform is registered with the group and `InstancedMeshSystem` picks it up on the next frame.
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import {
|
|
160
|
+
Behaviour,
|
|
161
|
+
InstancedMeshComponent,
|
|
162
|
+
} from "@relu-interactives/spatial-ecs";
|
|
163
|
+
|
|
164
|
+
export default class DynamicSpawner extends Behaviour {
|
|
165
|
+
protected init() {
|
|
166
|
+
const instanced = this.getComponent(InstancedMeshComponent);
|
|
167
|
+
if (!instanced) return;
|
|
168
|
+
|
|
169
|
+
const groupId = this.entityId;
|
|
170
|
+
const objects = this.world.getObjectManagementSystem();
|
|
171
|
+
objects?.requestCreate(
|
|
172
|
+
"instanceSlot",
|
|
173
|
+
{
|
|
174
|
+
name: `Instance ${instanced.instanceEntityIds.length + 1}`,
|
|
175
|
+
transform: { position: { x: 2, y: 0, z: 0 } },
|
|
176
|
+
options: {
|
|
177
|
+
groupEntityId: groupId,
|
|
178
|
+
slotIndex: instanced.instanceEntityIds.length,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
(slotId) => {
|
|
182
|
+
instanced.instanceEntityIds.push(slotId);
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
See the [Spawning Instanced Meshes](../spawning/instanced-mesh) guide for the full `requestCreate` API reference.
|
|
@@ -57,6 +57,10 @@ Kind-specific fields go on `payload.path` (asset URL) or `payload.options` (type
|
|
|
57
57
|
- [Cylinder](./cylinder)
|
|
58
58
|
- [Empty](./empty)
|
|
59
59
|
|
|
60
|
+
### Instanced Meshes
|
|
61
|
+
|
|
62
|
+
- [Instanced Mesh](./instanced-mesh) — GPU-instanced groups with dynamic slot management
|
|
63
|
+
|
|
60
64
|
### Media
|
|
61
65
|
|
|
62
66
|
- [Model](./model)
|