@relu-interactives/spatial-ecs 0.2.13 → 0.2.15

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.
Files changed (189) hide show
  1. package/dist/{System-CTTwEGn1.d.cts → System-BeuJ1xt5.d.cts} +2 -0
  2. package/dist/{System-CTTwEGn1.d.ts → System-BeuJ1xt5.d.ts} +2 -0
  3. package/dist/{Video-CV1-u6hL.d.ts → Video-Cym2C52L.d.ts} +1 -1
  4. package/dist/{Video-BMWPYc3q.d.cts → Video-D4B-z74P.d.cts} +1 -1
  5. package/dist/{chunk-KDZ6VBRO.js → chunk-D3AKP6QQ.js} +33 -6
  6. package/dist/chunk-D3AKP6QQ.js.map +1 -0
  7. package/dist/components/index.d.cts +2 -2
  8. package/dist/components/index.d.ts +2 -2
  9. package/dist/docs/api/Behaviour/classes/Behaviour.md +29 -29
  10. package/dist/docs/api/Component/classes/Component.md +1 -1
  11. package/dist/docs/api/components/classes/AnimationComponent.md +26 -26
  12. package/dist/docs/api/components/classes/AudioComponent.md +19 -19
  13. package/dist/docs/api/components/classes/CameraComponent.md +14 -14
  14. package/dist/docs/api/components/classes/EntityType.md +3 -3
  15. package/dist/docs/api/components/classes/Environment.md +3 -3
  16. package/dist/docs/api/components/classes/ImageComponent.md +7 -7
  17. package/dist/docs/api/components/classes/ImageTarget.md +7 -7
  18. package/dist/docs/api/components/classes/ImageTargetAnchor.md +4 -4
  19. package/dist/docs/api/components/classes/InstanceSlotComponent.md +4 -4
  20. package/dist/docs/api/components/classes/InstancedMeshComponent.md +10 -10
  21. package/dist/docs/api/components/classes/LightComponent.md +6 -6
  22. package/dist/docs/api/components/classes/MaterialComponent.md +11 -11
  23. package/dist/docs/api/components/classes/MeshComponent.md +3 -3
  24. package/dist/docs/api/components/classes/MeshGeometryComponent.md +9 -9
  25. package/dist/docs/api/components/classes/ModelComponent.md +4 -4
  26. package/dist/docs/api/components/classes/Name.md +3 -3
  27. package/dist/docs/api/components/classes/Object3DRef.md +4 -4
  28. package/dist/docs/api/components/classes/ParentId.md +3 -3
  29. package/dist/docs/api/components/classes/PhysicsComponent.md +6 -6
  30. package/dist/docs/api/components/classes/Postprocessing.md +3 -3
  31. package/dist/docs/api/components/classes/ScriptComponent.md +5 -5
  32. package/dist/docs/api/components/classes/Selectable.md +3 -3
  33. package/dist/docs/api/components/classes/SelectionTransformState.md +5 -5
  34. package/dist/docs/api/components/classes/SpriteComponent.md +7 -7
  35. package/dist/docs/api/components/classes/TransformComponent.md +12 -12
  36. package/dist/docs/api/components/classes/VideoComponent.md +28 -28
  37. package/dist/docs/api/components/functions/normalizePhysicsState.md +1 -1
  38. package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +9 -9
  39. package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +13 -13
  40. package/dist/docs/api/components/type-aliases/CameraProjection.md +1 -1
  41. package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +1 -1
  42. package/dist/docs/api/components/type-aliases/ColliderShape.md +1 -1
  43. package/dist/docs/api/components/type-aliases/ColliderState.md +20 -20
  44. package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +4 -4
  45. package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +1 -1
  46. package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +8 -8
  47. package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +1 -1
  48. package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +1 -1
  49. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +7 -7
  50. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +1 -1
  51. package/dist/docs/api/components/type-aliases/EnvironmentState.md +5 -5
  52. package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +3 -3
  53. package/dist/docs/api/components/type-aliases/ImageTargetReference.md +7 -7
  54. package/dist/docs/api/components/type-aliases/InstanceTransform.md +13 -13
  55. package/dist/docs/api/components/type-aliases/InstancedMeshKind.md +1 -1
  56. package/dist/docs/api/components/type-aliases/LightValueState.md +11 -11
  57. package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +1 -1
  58. package/dist/docs/api/components/type-aliases/MaterialValueState.md +28 -28
  59. package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +1 -1
  60. package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +7 -7
  61. package/dist/docs/api/components/type-aliases/PhysicsState.md +3 -3
  62. package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +3 -3
  63. package/dist/docs/api/components/type-aliases/PostprocessingState.md +62 -62
  64. package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +3 -3
  65. package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +2 -2
  66. package/dist/docs/api/components/type-aliases/RigidbodyState.md +17 -17
  67. package/dist/docs/api/components/type-aliases/RigidbodyType.md +1 -1
  68. package/dist/docs/api/components/type-aliases/ScriptEntry.md +9 -9
  69. package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +1 -1
  70. package/dist/docs/api/components/type-aliases/TransformData.md +4 -4
  71. package/dist/docs/api/components/type-aliases/TransformModeValue.md +1 -1
  72. package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +1 -1
  73. package/dist/docs/api/components/type-aliases/Vec3.md +4 -4
  74. package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +1 -1
  75. package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +1 -1
  76. package/dist/docs/api/components/variables/DEFAULT_INSTANCED_MESH_PARAMETERS.md +1 -1
  77. package/dist/docs/api/components/variables/DEFAULT_INSTANCE_TRANSFORM.md +1 -1
  78. package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +1 -1
  79. package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +1 -1
  80. package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +1 -1
  81. package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +1 -1
  82. package/dist/docs/api/index/classes/AnimationStateMachine.md +16 -16
  83. package/dist/docs/api/index/classes/AnimationStateManager.md +13 -13
  84. package/dist/docs/api/index/classes/AnimationSystem.md +3 -3
  85. package/dist/docs/api/index/classes/AudioSystem.md +4 -4
  86. package/dist/docs/api/index/classes/CameraSyncSystem.md +2 -2
  87. package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +4 -4
  88. package/dist/docs/api/index/classes/InputSystem.md +33 -33
  89. package/dist/docs/api/index/classes/InstancedMeshSystem.md +2 -2
  90. package/dist/docs/api/index/classes/LightSyncSystem.md +2 -2
  91. package/dist/docs/api/index/classes/MaterialSyncSystem.md +3 -3
  92. package/dist/docs/api/index/classes/MeshGeometrySystem.md +2 -2
  93. package/dist/docs/api/index/classes/ObjectManagementSystem.md +14 -14
  94. package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +2 -2
  95. package/dist/docs/api/index/classes/PhysicsSyncSystem.md +4 -4
  96. package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +4 -4
  97. package/dist/docs/api/index/classes/RenderSystem.md +3 -3
  98. package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +4 -4
  99. package/dist/docs/api/index/classes/TransformSyncSystem.md +2 -2
  100. package/dist/docs/api/index/classes/VideoSystem.md +4 -4
  101. package/dist/docs/api/index/classes/World.md +124 -84
  102. package/dist/docs/api/index/functions/createAnimationComponent.md +1 -1
  103. package/dist/docs/api/index/functions/createAudioComponent.md +1 -1
  104. package/dist/docs/api/index/functions/createCameraComponent.md +1 -1
  105. package/dist/docs/api/index/functions/createEntityTypeComponent.md +1 -1
  106. package/dist/docs/api/index/functions/createEnvironmentComponent.md +1 -1
  107. package/dist/docs/api/index/functions/createImageComponent.md +1 -1
  108. package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +1 -1
  109. package/dist/docs/api/index/functions/createImageTargetComponent.md +1 -1
  110. package/dist/docs/api/index/functions/createInstanceSlotComponent.md +1 -1
  111. package/dist/docs/api/index/functions/createInstancedMeshComponent.md +1 -1
  112. package/dist/docs/api/index/functions/createLightComponent.md +1 -1
  113. package/dist/docs/api/index/functions/createMaterialComponent.md +1 -1
  114. package/dist/docs/api/index/functions/createMeshComponent.md +1 -1
  115. package/dist/docs/api/index/functions/createMeshGeometryComponent.md +1 -1
  116. package/dist/docs/api/index/functions/createModelComponent.md +1 -1
  117. package/dist/docs/api/index/functions/createNameComponent.md +1 -1
  118. package/dist/docs/api/index/functions/createObject3DRefComponent.md +1 -1
  119. package/dist/docs/api/index/functions/createParentIdComponent.md +1 -1
  120. package/dist/docs/api/index/functions/createPhysicsComponent.md +1 -1
  121. package/dist/docs/api/index/functions/createPostprocessingComponent.md +1 -1
  122. package/dist/docs/api/index/functions/createScriptComponent.md +1 -1
  123. package/dist/docs/api/index/functions/createSelectableComponent.md +1 -1
  124. package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +1 -1
  125. package/dist/docs/api/index/functions/createSpriteComponent.md +1 -1
  126. package/dist/docs/api/index/functions/createTransformComponent.md +1 -1
  127. package/dist/docs/api/index/functions/createVideoComponent.md +1 -1
  128. package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +1 -1
  129. package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +1 -1
  130. package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +1 -1
  131. package/dist/docs/api/index/functions/registerDefaultFactories.md +1 -1
  132. package/dist/docs/api/index/interfaces/EcsSystem.md +3 -3
  133. package/dist/docs/api/index/interfaces/StateMachine.md +13 -13
  134. package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +4 -4
  135. package/dist/docs/api/index/type-aliases/ComponentFactory.md +1 -1
  136. package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +1 -1
  137. package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +3 -3
  138. package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +4 -4
  139. package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +3 -3
  140. package/dist/docs/api/index/type-aliases/KeyboardKey.md +1 -1
  141. package/dist/docs/api/index/type-aliases/MouseButton.md +1 -1
  142. package/dist/docs/api/index/type-aliases/SelectionContext.md +4 -4
  143. package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +1 -1
  144. package/dist/docs/api/index/variables/KeyboardKeys.md +89 -89
  145. package/dist/docs/api/types/type-aliases/AssetInput.md +3 -3
  146. package/dist/docs/api/types/type-aliases/CheckboxInput.md +3 -3
  147. package/dist/docs/api/types/type-aliases/ColorInput.md +1 -1
  148. package/dist/docs/api/types/type-aliases/ComponentInput.md +4 -4
  149. package/dist/docs/api/types/type-aliases/ComponentKind.md +1 -1
  150. package/dist/docs/api/types/type-aliases/DropdownInput.md +3 -3
  151. package/dist/docs/api/types/type-aliases/DropdownOption.md +3 -3
  152. package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +1 -1
  153. package/dist/docs/api/types/type-aliases/EcsEntityKind.md +1 -1
  154. package/dist/docs/api/types/type-aliases/EntityId.md +1 -1
  155. package/dist/docs/api/types/type-aliases/EntityInput.md +3 -3
  156. package/dist/docs/api/types/type-aliases/FloatInput.md +1 -1
  157. package/dist/docs/api/types/type-aliases/IntersectionResult.md +3 -3
  158. package/dist/docs/api/types/type-aliases/ParentLookup.md +3 -3
  159. package/dist/docs/api/types/type-aliases/SelectionListener.md +1 -1
  160. package/dist/docs/api/types/type-aliases/SliderInput.md +5 -5
  161. package/dist/docs/api/types/type-aliases/TextInput.md +1 -1
  162. package/dist/docs/api/types/type-aliases/ToggleInput.md +1 -1
  163. package/dist/docs/api/types/type-aliases/Vec3.md +1 -1
  164. package/dist/docs/api/types/type-aliases/Vector2Input.md +3 -3
  165. package/dist/docs/api/types/type-aliases/Vector3Input.md +4 -4
  166. package/dist/docs/api/types/type-aliases/WorldEntityView.md +1 -1
  167. package/dist/docs/guide/components/parent-id.md +25 -0
  168. package/dist/docs/guide/world-api.md +34 -0
  169. package/dist/factories/index.d.cts +2 -2
  170. package/dist/factories/index.d.ts +2 -2
  171. package/dist/{index-D7q4SRCp.d.cts → index-BfoOC2CG.d.cts} +2 -2
  172. package/dist/{index-ByX7502C.d.ts → index-BoJ3_6a3.d.ts} +2 -2
  173. package/dist/index.cjs +49 -4
  174. package/dist/index.cjs.map +1 -1
  175. package/dist/index.d.cts +5 -5
  176. package/dist/index.d.ts +5 -5
  177. package/dist/index.js +21 -3
  178. package/dist/index.js.map +1 -1
  179. package/dist/systems/index.cjs +31 -4
  180. package/dist/systems/index.cjs.map +1 -1
  181. package/dist/systems/index.d.cts +6 -2
  182. package/dist/systems/index.d.ts +6 -2
  183. package/dist/systems/index.js +1 -1
  184. package/dist/types.d.cts +1 -1
  185. package/dist/types.d.ts +1 -1
  186. package/dist/worldSnapshotUtils.d.cts +1 -1
  187. package/dist/worldSnapshotUtils.d.ts +1 -1
  188. package/package.json +1 -1
  189. package/dist/chunk-KDZ6VBRO.js.map +0 -1
@@ -103,6 +103,31 @@ export default class Example extends Behaviour {
103
103
  }
104
104
  ```
105
105
 
106
+ ### Navigate the hierarchy with World methods
107
+
108
+ Instead of querying the `ParentId` component directly, use `world.getEntitiesParent` and `world.getEntitiesChildren` for convenient hierarchy traversal:
109
+
110
+ ```typescript
111
+ import { Behaviour } from "@relu-interactives/spatial-ecs";
112
+
113
+ export default class HierarchyLogger extends Behaviour {
114
+ protected init() {
115
+ // Get parent entity
116
+ const parent = this.world.getEntitiesParent(this.entityId);
117
+ if (parent) {
118
+ console.log(`Parent: ${parent.name} (ID: ${parent.entityId})`);
119
+ }
120
+
121
+ // Get all children
122
+ const children = this.world.getEntitiesChildren(this.entityId);
123
+ console.log(`${children.length} child(ren):`);
124
+ for (const child of children) {
125
+ console.log(` - ${child.name} (ID: ${child.entityId})`);
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
106
131
  ::: tip ObjectManagementSystem
107
132
  Do not call `THREE.Object3D.add` / `remove` directly to reparent. Write to `ParentId.value` instead — the `ObjectManagementSystem` reads this every frame and reconciles the scene graph. This keeps the ECS hierarchy state consistent with the three.js scene graph.
108
133
  :::
@@ -55,6 +55,8 @@ export default class Spinner extends Behaviour {
55
55
  | `getEntityByName(name)` | First entity whose `Name` matches, or `null`. |
56
56
  | `getEntitiesByName(name)` | All entities sharing a `Name`. |
57
57
  | `getEntitiesByComponent(component)` | All entities that own a component of the same class. |
58
+ | `getEntitiesChildren(entityId)` | All child entities of the given entity (entities whose `ParentId` component points to this entity). |
59
+ | `getEntitiesParent(entityId)` | The parent entity of the given entity, or `null` if the entity has no parent or is at the world root. |
58
60
 
59
61
  ### Scripts
60
62
 
@@ -150,6 +152,38 @@ export default class FlickerAllLights extends Behaviour {
150
152
  }
151
153
  ```
152
154
 
155
+ ### Navigate the entity hierarchy
156
+
157
+ Use `getEntitiesParent` and `getEntitiesChildren` to traverse parent-child relationships in the scene graph. This is useful for group operations, finding related entities, or building custom hierarchy traversal logic.
158
+
159
+ ```ts
160
+ import { Behaviour } from "@relu-interactives/spatial-ecs";
161
+
162
+ export default class HierarchyWalker extends Behaviour {
163
+ init() {
164
+ // Get the parent of this entity
165
+ const parent = this.world.getEntitiesParent(this.entityId);
166
+ if (parent) {
167
+ console.log(`Parent: ${parent.name} (ID: ${parent.entityId})`);
168
+ }
169
+
170
+ // Get all children of this entity
171
+ const children = this.world.getEntitiesChildren(this.entityId);
172
+ console.log(`Children count: ${children.length}`);
173
+ for (const child of children) {
174
+ console.log(` - ${child.name} (ID: ${child.entityId})`);
175
+ }
176
+
177
+ // Recursively walk up to the root
178
+ let current = this.world.getEntityById(this.entityId);
179
+ while (current) {
180
+ console.log(`Ancestor: ${current.name}`);
181
+ current = this.world.getEntitiesParent(current.entityId);
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
153
187
  ### Talk to another script on a different entity
154
188
 
155
189
  ```ts
@@ -1,5 +1,5 @@
1
- import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent, a0 as VideoComponent } from '../Video-BMWPYc3q.cjs';
2
- import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-CTTwEGn1.cjs';
1
+ import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent, a0 as VideoComponent } from '../Video-D4B-z74P.cjs';
2
+ import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-BeuJ1xt5.cjs';
3
3
  import * as THREE from 'three';
4
4
  import '@dimforge/rapier3d-compat';
5
5
 
@@ -1,5 +1,5 @@
1
- import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent, a0 as VideoComponent } from '../Video-CV1-u6hL.js';
2
- import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-CTTwEGn1.js';
1
+ import { A as AnimationComponent, b as AudioComponent, c as CameraComponentOptions, C as CameraComponent, S as RigidbodyState, g as ColliderState, P as PhysicsComponent, n as EntityType, I as ImageComponent, p as ImageTargetAnchor, o as ImageTarget, L as LightComponent, M as MaterialComponent, z as MeshComponent, B as MeshGeometryComponent, H as ModelComponent, N as Name, O as Object3DRef, V as ScriptEntry, U as ScriptComponent, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, v as InstancedMeshKind, F as MeshGeometryParameters, u as InstancedMeshComponent, s as InstanceSlotComponent, a0 as VideoComponent } from '../Video-Cym2C52L.js';
2
+ import { l as World, g as EnvironmentState, E as Environment, P as ParentId, i as PostprocessingState, h as Postprocessing, T as TransformComponent, O as ObjectManagementSystem } from '../System-BeuJ1xt5.js';
3
3
  import * as THREE from 'three';
4
4
  import '@dimforge/rapier3d-compat';
5
5
 
@@ -1,5 +1,5 @@
1
- import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_INSTANCED_MESH_PARAMETERS, j as DEFAULT_INSTANCE_TRANSFORM, k as DEFAULT_MESH_GEOMETRY_PARAMETERS, l as DEFAULT_PHYSICS_STATE, m as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, n as EntityType, I as ImageComponent, o as ImageTarget, p as ImageTargetAnchor, q as ImageTargetAnchorOptions, r as ImageTargetReference, s as InstanceSlotComponent, t as InstanceTransform, u as InstancedMeshComponent, v as InstancedMeshKind, L as LightComponent, w as LightValueState, M as MaterialComponent, x as MaterialTypeValue, y as MaterialValueState, z as MeshComponent, B as MeshGeometryComponent, F as MeshGeometryParameters, G as MeshGeometryParametersByKind, H as ModelComponent, N as Name, O as Object3DRef, P as PhysicsComponent, J as PhysicsState, K as PlaneMeshParameters, R as RadiusHeightMeshParameters, Q as RadiusMeshParameters, S as RigidbodyState, T as RigidbodyType, U as ScriptComponent, V as ScriptEntry, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, Z as TextureFilteringValue, _ as TransformModeValue, $ as TransformSpaceValue, a0 as VideoComponent, a1 as normalizePhysicsState } from './Video-BMWPYc3q.cjs';
2
- import { D as DEFAULT_ENVIRONMENT_STATE, a as DEFAULT_POSTPROCESSING_STATE, E as Environment, b as EnvironmentFogState, c as EnvironmentFogType, d as EnvironmentGradientEffect, e as EnvironmentSkyboxState, f as EnvironmentSkyboxType, g as EnvironmentState, P as ParentId, h as Postprocessing, i as PostprocessingState, T as TransformComponent, j as TransformData, V as Vec3 } from './System-CTTwEGn1.cjs';
1
+ import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_INSTANCED_MESH_PARAMETERS, j as DEFAULT_INSTANCE_TRANSFORM, k as DEFAULT_MESH_GEOMETRY_PARAMETERS, l as DEFAULT_PHYSICS_STATE, m as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, n as EntityType, I as ImageComponent, o as ImageTarget, p as ImageTargetAnchor, q as ImageTargetAnchorOptions, r as ImageTargetReference, s as InstanceSlotComponent, t as InstanceTransform, u as InstancedMeshComponent, v as InstancedMeshKind, L as LightComponent, w as LightValueState, M as MaterialComponent, x as MaterialTypeValue, y as MaterialValueState, z as MeshComponent, B as MeshGeometryComponent, F as MeshGeometryParameters, G as MeshGeometryParametersByKind, H as ModelComponent, N as Name, O as Object3DRef, P as PhysicsComponent, J as PhysicsState, K as PlaneMeshParameters, R as RadiusHeightMeshParameters, Q as RadiusMeshParameters, S as RigidbodyState, T as RigidbodyType, U as ScriptComponent, V as ScriptEntry, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, Z as TextureFilteringValue, _ as TransformModeValue, $ as TransformSpaceValue, a0 as VideoComponent, a1 as normalizePhysicsState } from './Video-D4B-z74P.cjs';
2
+ import { D as DEFAULT_ENVIRONMENT_STATE, a as DEFAULT_POSTPROCESSING_STATE, E as Environment, b as EnvironmentFogState, c as EnvironmentFogType, d as EnvironmentGradientEffect, e as EnvironmentSkyboxState, f as EnvironmentSkyboxType, g as EnvironmentState, P as ParentId, h as Postprocessing, i as PostprocessingState, T as TransformComponent, j as TransformData, V as Vec3 } from './System-BeuJ1xt5.cjs';
3
3
 
4
4
  declare const index_AnimationComponent: typeof AnimationComponent;
5
5
  declare const index_AnimationComponentOptions: typeof AnimationComponentOptions;
@@ -1,5 +1,5 @@
1
- import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_INSTANCED_MESH_PARAMETERS, j as DEFAULT_INSTANCE_TRANSFORM, k as DEFAULT_MESH_GEOMETRY_PARAMETERS, l as DEFAULT_PHYSICS_STATE, m as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, n as EntityType, I as ImageComponent, o as ImageTarget, p as ImageTargetAnchor, q as ImageTargetAnchorOptions, r as ImageTargetReference, s as InstanceSlotComponent, t as InstanceTransform, u as InstancedMeshComponent, v as InstancedMeshKind, L as LightComponent, w as LightValueState, M as MaterialComponent, x as MaterialTypeValue, y as MaterialValueState, z as MeshComponent, B as MeshGeometryComponent, F as MeshGeometryParameters, G as MeshGeometryParametersByKind, H as ModelComponent, N as Name, O as Object3DRef, P as PhysicsComponent, J as PhysicsState, K as PlaneMeshParameters, R as RadiusHeightMeshParameters, Q as RadiusMeshParameters, S as RigidbodyState, T as RigidbodyType, U as ScriptComponent, V as ScriptEntry, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, Z as TextureFilteringValue, _ as TransformModeValue, $ as TransformSpaceValue, a0 as VideoComponent, a1 as normalizePhysicsState } from './Video-CV1-u6hL.js';
2
- import { D as DEFAULT_ENVIRONMENT_STATE, a as DEFAULT_POSTPROCESSING_STATE, E as Environment, b as EnvironmentFogState, c as EnvironmentFogType, d as EnvironmentGradientEffect, e as EnvironmentSkyboxState, f as EnvironmentSkyboxType, g as EnvironmentState, P as ParentId, h as Postprocessing, i as PostprocessingState, T as TransformComponent, j as TransformData, V as Vec3 } from './System-CTTwEGn1.js';
1
+ import { A as AnimationComponent, a as AnimationComponentOptions, b as AudioComponent, C as CameraComponent, c as CameraComponentOptions, d as CameraProjection, e as CameraRuntimeType, f as ColliderShape, g as ColliderState, h as CubeMeshParameters, D as DEFAULT_COLLIDER_STATE, i as DEFAULT_INSTANCED_MESH_PARAMETERS, j as DEFAULT_INSTANCE_TRANSFORM, k as DEFAULT_MESH_GEOMETRY_PARAMETERS, l as DEFAULT_PHYSICS_STATE, m as DEFAULT_RIGIDBODY_STATE, E as EditableMeshObjectKind, n as EntityType, I as ImageComponent, o as ImageTarget, p as ImageTargetAnchor, q as ImageTargetAnchorOptions, r as ImageTargetReference, s as InstanceSlotComponent, t as InstanceTransform, u as InstancedMeshComponent, v as InstancedMeshKind, L as LightComponent, w as LightValueState, M as MaterialComponent, x as MaterialTypeValue, y as MaterialValueState, z as MeshComponent, B as MeshGeometryComponent, F as MeshGeometryParameters, G as MeshGeometryParametersByKind, H as ModelComponent, N as Name, O as Object3DRef, P as PhysicsComponent, J as PhysicsState, K as PlaneMeshParameters, R as RadiusHeightMeshParameters, Q as RadiusMeshParameters, S as RigidbodyState, T as RigidbodyType, U as ScriptComponent, V as ScriptEntry, W as Selectable, X as SelectionTransformState, Y as SpriteComponent, Z as TextureFilteringValue, _ as TransformModeValue, $ as TransformSpaceValue, a0 as VideoComponent, a1 as normalizePhysicsState } from './Video-Cym2C52L.js';
2
+ import { D as DEFAULT_ENVIRONMENT_STATE, a as DEFAULT_POSTPROCESSING_STATE, E as Environment, b as EnvironmentFogState, c as EnvironmentFogType, d as EnvironmentGradientEffect, e as EnvironmentSkyboxState, f as EnvironmentSkyboxType, g as EnvironmentState, P as ParentId, h as Postprocessing, i as PostprocessingState, T as TransformComponent, j as TransformData, V as Vec3 } from './System-BeuJ1xt5.js';
3
3
 
4
4
  declare const index_AnimationComponent: typeof AnimationComponent;
5
5
  declare const index_AnimationComponentOptions: typeof AnimationComponentOptions;
package/dist/index.cjs CHANGED
@@ -7203,6 +7203,8 @@ var _AudioSystem = class _AudioSystem {
7203
7203
  this.prevPlayingState = /* @__PURE__ */ new Map();
7204
7204
  /** Snapshot of options applied in the previous frame, for change detection. */
7205
7205
  this.prevOptions = /* @__PURE__ */ new Map();
7206
+ /** Tracks entities that were stopped due to invisibility. */
7207
+ this.stoppedDueToInvisibility = /* @__PURE__ */ new Set();
7206
7208
  this.isEditor = isEditor;
7207
7209
  }
7208
7210
  update(world, _deltaTime) {
@@ -7214,12 +7216,21 @@ var _AudioSystem = class _AudioSystem {
7214
7216
  if (!component?.audio) continue;
7215
7217
  const sound = component.audio;
7216
7218
  if (!world.isEntityVisible(entityId)) {
7217
- if (sound.isPlaying) sound.stop();
7219
+ if (sound.isPlaying) {
7220
+ sound.stop();
7221
+ this.stoppedDueToInvisibility.add(entityId);
7222
+ }
7218
7223
  continue;
7219
7224
  }
7225
+ if (this.stoppedDueToInvisibility.has(entityId)) {
7226
+ this.stoppedDueToInvisibility.delete(entityId);
7227
+ if (component.isPlaying && !sound.isPlaying && sound.buffer) {
7228
+ sound.play();
7229
+ }
7230
+ }
7220
7231
  this._syncOptions(entityId, component, sound);
7221
7232
  const prevWasPlaying = this.prevPlayingState.get(entityId) ?? false;
7222
- if (prevWasPlaying && !sound.isPlaying && component.isPlaying && !component.isPaused) {
7233
+ if (prevWasPlaying && !sound.isPlaying && component.isPlaying && !component.isPaused && !this.stoppedDueToInvisibility.has(entityId)) {
7223
7234
  component.isPlaying = false;
7224
7235
  }
7225
7236
  if (component.isPlaying && !sound.isPlaying) {
@@ -7239,6 +7250,7 @@ var _AudioSystem = class _AudioSystem {
7239
7250
  if (!liveEntityIds.has(entityId)) {
7240
7251
  this.prevPlayingState.delete(entityId);
7241
7252
  this.prevOptions.delete(entityId);
7253
+ this.stoppedDueToInvisibility.delete(entityId);
7242
7254
  }
7243
7255
  }
7244
7256
  }
@@ -7271,6 +7283,7 @@ var _AudioSystem = class _AudioSystem {
7271
7283
  dispose(_world) {
7272
7284
  this.prevPlayingState.clear();
7273
7285
  this.prevOptions.clear();
7286
+ this.stoppedDueToInvisibility.clear();
7274
7287
  }
7275
7288
  };
7276
7289
  __name(_AudioSystem, "AudioSystem");
@@ -7298,6 +7311,8 @@ var _VideoSystem = class _VideoSystem {
7298
7311
  this.prevIntent = /* @__PURE__ */ new Map();
7299
7312
  /** Snapshot of options applied in the previous frame, for change detection. */
7300
7313
  this.prevOptions = /* @__PURE__ */ new Map();
7314
+ /** Tracks entities that were manually paused due to invisibility. */
7315
+ this.pausedDueToInvisibility = /* @__PURE__ */ new Set();
7301
7316
  this.isEditor = isEditor;
7302
7317
  }
7303
7318
  update(world, _deltaTime) {
@@ -7309,12 +7324,22 @@ var _VideoSystem = class _VideoSystem {
7309
7324
  if (!component?.videoElement) continue;
7310
7325
  const video = component.videoElement;
7311
7326
  if (!world.isEntityVisible(entityId)) {
7312
- if (!video.paused) video.pause();
7327
+ if (!video.paused) {
7328
+ video.pause();
7329
+ this.pausedDueToInvisibility.add(entityId);
7330
+ }
7313
7331
  continue;
7314
7332
  }
7333
+ if (this.pausedDueToInvisibility.has(entityId)) {
7334
+ this.pausedDueToInvisibility.delete(entityId);
7335
+ if (component.isPlaying && video.paused) {
7336
+ video.play().catch(() => {
7337
+ });
7338
+ }
7339
+ }
7315
7340
  this._syncOptions(entityId, component, video);
7316
7341
  const prev = this.prevIntent.get(entityId) ?? { isPlaying: false, isPaused: false };
7317
- if (prev.isPlaying && video.paused && !video.seeking && component.isPlaying && !component.isPaused) {
7342
+ if (prev.isPlaying && video.paused && !video.seeking && component.isPlaying && !component.isPaused && !this.pausedDueToInvisibility.has(entityId)) {
7318
7343
  component.isPlaying = false;
7319
7344
  }
7320
7345
  const isStoppedNow = !component.isPlaying && !component.isPaused;
@@ -7346,6 +7371,7 @@ var _VideoSystem = class _VideoSystem {
7346
7371
  if (!liveEntityIds.has(entityId)) {
7347
7372
  this.prevIntent.delete(entityId);
7348
7373
  this.prevOptions.delete(entityId);
7374
+ this.pausedDueToInvisibility.delete(entityId);
7349
7375
  }
7350
7376
  }
7351
7377
  }
@@ -7398,6 +7424,7 @@ var _VideoSystem = class _VideoSystem {
7398
7424
  dispose(_world) {
7399
7425
  this.prevIntent.clear();
7400
7426
  this.prevOptions.clear();
7427
+ this.pausedDueToInvisibility.clear();
7401
7428
  }
7402
7429
  };
7403
7430
  __name(_VideoSystem, "VideoSystem");
@@ -7948,6 +7975,24 @@ var _World = class _World {
7948
7975
  }
7949
7976
  return this.toEntityView(entityId);
7950
7977
  }
7978
+ getEntitiesChildren(entityId) {
7979
+ const children = [];
7980
+ const entitiesWithParent = this.query(ParentId);
7981
+ for (const childId of entitiesWithParent) {
7982
+ const parentIdComponent = this.getComponent(childId, ParentId);
7983
+ if (parentIdComponent?.value === entityId) {
7984
+ children.push(this.toEntityView(childId));
7985
+ }
7986
+ }
7987
+ return children;
7988
+ }
7989
+ getEntitiesParent(entityId) {
7990
+ const parentIdComponent = this.getComponent(entityId, ParentId);
7991
+ if (!parentIdComponent || parentIdComponent.value === null) {
7992
+ return null;
7993
+ }
7994
+ return this.getEntityById(parentIdComponent.value);
7995
+ }
7951
7996
  getObjectManagementSystem() {
7952
7997
  if (this.objectManagementSystem) return this.objectManagementSystem;
7953
7998
  const objectManagementSystem = this.systems.find(