@relu-interactives/spatial-ecs 0.2.24 → 0.2.25

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 (39) hide show
  1. package/dist/{Video-ppAXaKt0.d.cts → Video-AIQYTAAr.d.cts} +15 -3
  2. package/dist/{Video-C1IOat7L.d.ts → Video-DlZ4G9ig.d.ts} +15 -3
  3. package/dist/{chunk-CCE5K2TU.js → chunk-3P3ZBP7K.js} +17 -13
  4. package/dist/chunk-3P3ZBP7K.js.map +1 -0
  5. package/dist/{chunk-JHCPRVBC.js → chunk-J6736FFO.js} +16 -6
  6. package/dist/chunk-J6736FFO.js.map +1 -0
  7. package/dist/{chunk-ZXGHKX7N.js → chunk-OWQSESTO.js} +12 -2
  8. package/dist/chunk-OWQSESTO.js.map +1 -0
  9. package/dist/{chunk-52CHDPRQ.js → chunk-RJ4J5UEX.js} +4 -4
  10. package/dist/{chunk-52CHDPRQ.js.map → chunk-RJ4J5UEX.js.map} +1 -1
  11. package/dist/{chunk-WKGCC7YL.js → chunk-XFD74BQL.js} +3 -3
  12. package/dist/{chunk-WKGCC7YL.js.map → chunk-XFD74BQL.js.map} +1 -1
  13. package/dist/components/index.cjs +12 -2
  14. package/dist/components/index.cjs.map +1 -1
  15. package/dist/components/index.d.cts +2 -2
  16. package/dist/components/index.d.ts +2 -2
  17. package/dist/components/index.js +1 -1
  18. package/dist/factories/index.cjs +11 -2
  19. package/dist/factories/index.cjs.map +1 -1
  20. package/dist/factories/index.d.cts +1 -1
  21. package/dist/factories/index.d.ts +1 -1
  22. package/dist/factories/index.js +3 -3
  23. package/dist/{index-DdiWu1b6.d.ts → index-BwiRJNIT.d.ts} +3 -2
  24. package/dist/{index-Cu2Pt7wN.d.cts → index-Gr8aCPRM.d.cts} +3 -2
  25. package/dist/index.cjs +36 -12
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +3 -3
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +9 -9
  30. package/dist/systems/index.cjs +24 -11
  31. package/dist/systems/index.cjs.map +1 -1
  32. package/dist/systems/index.js +3 -3
  33. package/dist/worldSnapshotUtils.cjs +10 -0
  34. package/dist/worldSnapshotUtils.cjs.map +1 -1
  35. package/dist/worldSnapshotUtils.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-CCE5K2TU.js.map +0 -1
  38. package/dist/chunk-JHCPRVBC.js.map +0 -1
  39. package/dist/chunk-ZXGHKX7N.js.map +0 -1
@@ -598,12 +598,24 @@ declare function normalizePhysicsState(value: {
598
598
  *
599
599
  * @category Components
600
600
  */
601
+ /**
602
+ * Write a live Rapier ref as a NON-ENUMERABLE own property. Always via
603
+ * defineProperty (mirroring ScriptObjectComponent's `instance` ref): a
604
+ * history-restored clone that dropped the original slot would otherwise get an
605
+ * ENUMERABLE property from plain assignment, leaking Rapier objects — and for
606
+ * trimesh their huge vertex buffers — into snapshot/history/debug walks.
607
+ */
608
+ declare function setPhysicsLiveRef(component: PhysicsComponent, key: "rigidBody" | "collider", value: RapierRigidBody | RapierCollider | null): void;
601
609
  declare class PhysicsComponent extends Component {
602
610
  /** Authoring state. Saved with the project. */
603
611
  values: PhysicsState;
604
- /** Live Rapier rigid body. `null` until physics is initialized. */
612
+ /**
613
+ * Live Rapier rigid body. `null` until physics is initialized.
614
+ * NON-ENUMERABLE — Rapier wrappers (and, for trimesh, their vertex buffers)
615
+ * must never leak into snapshots/history/debug walks.
616
+ */
605
617
  rigidBody: RapierRigidBody | null;
606
- /** Live Rapier collider. `null` until physics is initialized. */
618
+ /** Live Rapier collider. `null` until physics is initialized. NON-ENUMERABLE. */
607
619
  collider: RapierCollider | null;
608
620
  constructor(values?: {
609
621
  rigidbody?: Partial<RigidbodyState>;
@@ -1156,4 +1168,4 @@ declare class VideoComponent extends Component {
1156
1168
  stop(): void;
1157
1169
  }
1158
1170
 
1159
- export { SpriteComponent as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, ScriptObjectComponent as W, type ScriptObjectComponentInput as X, type ScriptObjectRuntimeState as Y, Selectable as Z, SelectionTransformState as _, type AnimationComponentOptions as a, type TextureFilteringValue as a0, type TransformModeValue as a1, type TransformSpaceValue as a2, VideoComponent as a3, defaultMaterialValue as a4, normalizePhysicsState as a5, type AnimationStateCallbacks as a6, AnimationStateMachine as a7, AnimationStateManager as a8, type StateMachine as a9, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
1171
+ export { SpriteComponent as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, ScriptObjectComponent as W, type ScriptObjectComponentInput as X, type ScriptObjectRuntimeState as Y, Selectable as Z, SelectionTransformState as _, type AnimationComponentOptions as a, type TextureFilteringValue as a0, type TransformModeValue as a1, type TransformSpaceValue as a2, VideoComponent as a3, defaultMaterialValue as a4, normalizePhysicsState as a5, setPhysicsLiveRef as a6, type AnimationStateCallbacks as a7, AnimationStateMachine as a8, AnimationStateManager as a9, type StateMachine as aa, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
@@ -598,12 +598,24 @@ declare function normalizePhysicsState(value: {
598
598
  *
599
599
  * @category Components
600
600
  */
601
+ /**
602
+ * Write a live Rapier ref as a NON-ENUMERABLE own property. Always via
603
+ * defineProperty (mirroring ScriptObjectComponent's `instance` ref): a
604
+ * history-restored clone that dropped the original slot would otherwise get an
605
+ * ENUMERABLE property from plain assignment, leaking Rapier objects — and for
606
+ * trimesh their huge vertex buffers — into snapshot/history/debug walks.
607
+ */
608
+ declare function setPhysicsLiveRef(component: PhysicsComponent, key: "rigidBody" | "collider", value: RapierRigidBody | RapierCollider | null): void;
601
609
  declare class PhysicsComponent extends Component {
602
610
  /** Authoring state. Saved with the project. */
603
611
  values: PhysicsState;
604
- /** Live Rapier rigid body. `null` until physics is initialized. */
612
+ /**
613
+ * Live Rapier rigid body. `null` until physics is initialized.
614
+ * NON-ENUMERABLE — Rapier wrappers (and, for trimesh, their vertex buffers)
615
+ * must never leak into snapshots/history/debug walks.
616
+ */
605
617
  rigidBody: RapierRigidBody | null;
606
- /** Live Rapier collider. `null` until physics is initialized. */
618
+ /** Live Rapier collider. `null` until physics is initialized. NON-ENUMERABLE. */
607
619
  collider: RapierCollider | null;
608
620
  constructor(values?: {
609
621
  rigidbody?: Partial<RigidbodyState>;
@@ -1156,4 +1168,4 @@ declare class VideoComponent extends Component {
1156
1168
  stop(): void;
1157
1169
  }
1158
1170
 
1159
- export { SpriteComponent as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, ScriptObjectComponent as W, type ScriptObjectComponentInput as X, type ScriptObjectRuntimeState as Y, Selectable as Z, SelectionTransformState as _, type AnimationComponentOptions as a, type TextureFilteringValue as a0, type TransformModeValue as a1, type TransformSpaceValue as a2, VideoComponent as a3, defaultMaterialValue as a4, normalizePhysicsState as a5, type AnimationStateCallbacks as a6, AnimationStateMachine as a7, AnimationStateManager as a8, type StateMachine as a9, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
1171
+ export { SpriteComponent as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, ScriptObjectComponent as W, type ScriptObjectComponentInput as X, type ScriptObjectRuntimeState as Y, Selectable as Z, SelectionTransformState as _, type AnimationComponentOptions as a, type TextureFilteringValue as a0, type TransformModeValue as a1, type TransformSpaceValue as a2, VideoComponent as a3, defaultMaterialValue as a4, normalizePhysicsState as a5, setPhysicsLiveRef as a6, type AnimationStateCallbacks as a7, AnimationStateMachine as a8, AnimationStateManager as a9, type StateMachine as aa, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
@@ -1,5 +1,5 @@
1
- import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-WKGCC7YL.js';
2
- import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, ScriptObjectComponent, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance } from './chunk-JHCPRVBC.js';
1
+ import { resolveDracoDecoderPath, applyTransform, SHARED_MODEL_RESOURCE_FLAG } from './chunk-XFD74BQL.js';
2
+ import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, setPhysicsLiveRef, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, ScriptObjectComponent, InstanceSlotComponent, Name, ImageComponent, SpriteComponent, VideoComponent, AudioComponent, ImageTarget, Selectable, PrefabNode, PrefabInstance } from './chunk-J6736FFO.js';
3
3
  import { __name } from './chunk-OY7ZODZP.js';
4
4
  import * as THREE7 from 'three';
5
5
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
@@ -1189,8 +1189,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1189
1189
  }
1190
1190
  if (!physics.values.rigidbody.enabled) {
1191
1191
  this.removeEntityPhysics(physicsWorld, entityId);
1192
- physics.rigidBody = null;
1193
- physics.collider = null;
1192
+ setPhysicsLiveRef(physics, "rigidBody", null);
1193
+ setPhysicsLiveRef(physics, "collider", null);
1194
1194
  continue;
1195
1195
  }
1196
1196
  const rigidBodySignature = JSON.stringify(physics.values.rigidbody);
@@ -1234,7 +1234,7 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1234
1234
  }
1235
1235
  this.rigidBodyHandles.set(entityId, body2.handle);
1236
1236
  this.rigidBodySignatures.set(entityId, rigidBodySignature);
1237
- physics.rigidBody = body2;
1237
+ setPhysicsLiveRef(physics, "rigidBody", body2);
1238
1238
  }
1239
1239
  const rigidBodyHandle = this.rigidBodyHandles.get(entityId);
1240
1240
  if (typeof rigidBodyHandle !== "number") {
@@ -1243,11 +1243,11 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1243
1243
  const body = physicsWorld.getRigidBody(rigidBodyHandle);
1244
1244
  if (!body) {
1245
1245
  this.removeEntityPhysics(physicsWorld, entityId);
1246
- physics.rigidBody = null;
1247
- physics.collider = null;
1246
+ setPhysicsLiveRef(physics, "rigidBody", null);
1247
+ setPhysicsLiveRef(physics, "collider", null);
1248
1248
  continue;
1249
1249
  }
1250
- physics.rigidBody = body;
1250
+ setPhysicsLiveRef(physics, "rigidBody", body);
1251
1251
  if (this.isEditorMode || physics.values.rigidbody.type !== "dynamic") {
1252
1252
  syncBodyFromTransform(body, transform);
1253
1253
  }
@@ -1263,7 +1263,7 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1263
1263
  }
1264
1264
  this.colliderHandles.delete(entityId);
1265
1265
  this.colliderSignatures.delete(entityId);
1266
- physics.collider = null;
1266
+ setPhysicsLiveRef(physics, "collider", null);
1267
1267
  continue;
1268
1268
  }
1269
1269
  const colliderSignature = `${JSON.stringify(effectiveCollider)}:${triMeshParts?.signature ?? ""}`;
@@ -1284,10 +1284,14 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1284
1284
  const createdCollider = physicsWorld.createCollider(colliderDesc, body);
1285
1285
  this.colliderHandles.set(entityId, createdCollider.handle);
1286
1286
  this.colliderSignatures.set(entityId, colliderSignature);
1287
- physics.collider = createdCollider;
1287
+ setPhysicsLiveRef(physics, "collider", createdCollider);
1288
1288
  } else {
1289
1289
  const colliderHandle = this.colliderHandles.get(entityId);
1290
- physics.collider = typeof colliderHandle === "number" ? physicsWorld.getCollider(colliderHandle) ?? null : null;
1290
+ setPhysicsLiveRef(
1291
+ physics,
1292
+ "collider",
1293
+ typeof colliderHandle === "number" ? physicsWorld.getCollider(colliderHandle) ?? null : null
1294
+ );
1291
1295
  }
1292
1296
  }
1293
1297
  if (!this.isEditorMode) {
@@ -5835,5 +5839,5 @@ __name(_VideoSystem, "VideoSystem");
5835
5839
  var VideoSystem = _VideoSystem;
5836
5840
 
5837
5841
  export { ADDED_NODE_MARKER_COMPONENT, AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, HYDRATABLE_ENTITY_KINDS, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, NODE_KEY_SEPARATOR, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, ObjectVisibilitySystem, PREFAB_FILE_VERSION, PREFAB_FILE_VERSION_NESTED, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObject, ScriptObjectSystem, TransformSyncSystem, VideoSystem, buildComponentValueMaps, buildNodeKeyMapsFromSnapshot, buildNodeMapsFromSnapshot, canonicalizeComponentValue, clearPrefabCache, collectDiffPaths, collectEntitySubtree, collectSnapshotSubtreeIds, computeInstanceOverrides, decanonicalizeComponentValue, despawnPrefab, encodeOverride, findSnapshotRootEntityIds, findTopLevelNestedRegions, groupOverridePaths, hydrateWorldFromSnapshot, hydrateWorldFromSnapshotDetailed, indexSnapshotByEntity, instantiateSubtree, loadPrefab, mergeComponentValue, parseOverride, parsePrefabAsset, prefabFileVersionFor, restoreComponentState, restorePostCreateComponents, setPrefabAssetUrlResolver, spawnPrefab };
5838
- //# sourceMappingURL=chunk-CCE5K2TU.js.map
5839
- //# sourceMappingURL=chunk-CCE5K2TU.js.map
5842
+ //# sourceMappingURL=chunk-3P3ZBP7K.js.map
5843
+ //# sourceMappingURL=chunk-3P3ZBP7K.js.map