@relu-interactives/spatial-ecs 0.2.23 → 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 (40) 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-7BEZBIVB.js → chunk-3P3ZBP7K.js} +106 -76
  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/docs/guide/systems/physics-sync-system.md +1 -1
  19. package/dist/factories/index.cjs +11 -2
  20. package/dist/factories/index.cjs.map +1 -1
  21. package/dist/factories/index.d.cts +1 -1
  22. package/dist/factories/index.d.ts +1 -1
  23. package/dist/factories/index.js +3 -3
  24. package/dist/{index-DdiWu1b6.d.ts → index-BwiRJNIT.d.ts} +3 -2
  25. package/dist/{index-Cu2Pt7wN.d.cts → index-Gr8aCPRM.d.cts} +3 -2
  26. package/dist/index.cjs +125 -75
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +3 -3
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +9 -9
  31. package/dist/systems/index.cjs +113 -74
  32. package/dist/systems/index.cjs.map +1 -1
  33. package/dist/systems/index.js +3 -3
  34. package/dist/worldSnapshotUtils.cjs +10 -0
  35. package/dist/worldSnapshotUtils.cjs.map +1 -1
  36. package/dist/worldSnapshotUtils.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-7BEZBIVB.js.map +0 -1
  39. package/dist/chunk-JHCPRVBC.js.map +0 -1
  40. 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';
@@ -974,82 +974,108 @@ function createColliderDesc(RAPIER, values, triMeshData) {
974
974
  return desc;
975
975
  }
976
976
  __name(createColliderDesc, "createColliderDesc");
977
- function findFirstMeshWithGeometry(object) {
978
- if (object instanceof THREE7.Mesh && object.geometry) {
979
- return object;
977
+ function collectTriMeshParts(object) {
978
+ if (!object) {
979
+ return null;
980
980
  }
981
- let found = null;
981
+ object.updateWorldMatrix(true, true);
982
+ const worldScale = new THREE7.Vector3();
983
+ object.getWorldScale(worldScale);
984
+ const scale = {
985
+ x: Math.abs(worldScale.x) || 1,
986
+ y: Math.abs(worldScale.y) || 1,
987
+ z: Math.abs(worldScale.z) || 1
988
+ };
989
+ const worldToObject = new THREE7.Matrix4().copy(object.matrixWorld).invert();
990
+ const parts = [];
982
991
  object.traverse((child) => {
983
- if (found) {
992
+ if (!(child instanceof THREE7.Mesh) || !child.geometry) {
984
993
  return;
985
994
  }
986
- if (child instanceof THREE7.Mesh && child.geometry) {
987
- found = child;
995
+ const geometry = child.geometry;
996
+ const positionAttribute = geometry.getAttribute("position");
997
+ if (!positionAttribute || positionAttribute.itemSize < 3) {
998
+ return;
988
999
  }
1000
+ const positionCount = positionAttribute.count;
1001
+ if (positionCount < 3) {
1002
+ return;
1003
+ }
1004
+ const indexAttribute = geometry.getIndex();
1005
+ const indexCount = indexAttribute ? indexAttribute.count : Math.floor(positionCount / 3) * 3;
1006
+ if (indexCount < 3) {
1007
+ return;
1008
+ }
1009
+ const relativeMatrix = new THREE7.Matrix4().multiplyMatrices(
1010
+ worldToObject,
1011
+ child.matrixWorld
1012
+ );
1013
+ const matrixSignature = relativeMatrix.elements.map((value) => value.toFixed(5)).join(",");
1014
+ parts.push({
1015
+ positionAttribute,
1016
+ indexAttribute,
1017
+ positionCount,
1018
+ indexCount,
1019
+ relativeMatrix,
1020
+ signature: `${child.uuid}:${geometry.uuid}:${positionCount}:${indexCount}:${matrixSignature}`
1021
+ });
989
1022
  });
990
- return found;
991
- }
992
- __name(findFirstMeshWithGeometry, "findFirstMeshWithGeometry");
993
- function createTriMeshData(object) {
994
- if (!object) {
1023
+ if (parts.length === 0) {
995
1024
  return null;
996
1025
  }
997
- const mesh = findFirstMeshWithGeometry(object);
998
- if (!mesh) {
1026
+ const scaleSignature = `${scale.x.toFixed(5)},${scale.y.toFixed(5)},${scale.z.toFixed(5)}`;
1027
+ return {
1028
+ parts,
1029
+ scale,
1030
+ signature: `${scaleSignature}|${parts.map((p) => p.signature).join("|")}`
1031
+ };
1032
+ }
1033
+ __name(collectTriMeshParts, "collectTriMeshParts");
1034
+ function createTriMeshData(collected) {
1035
+ if (!collected) {
999
1036
  return null;
1000
1037
  }
1001
- const geometry = mesh.geometry;
1002
- const positionAttribute = geometry.getAttribute("position");
1003
- if (!positionAttribute || positionAttribute.itemSize < 3) {
1004
- return null;
1038
+ const { parts, scale } = collected;
1039
+ let vertexTotal = 0;
1040
+ let indexTotal = 0;
1041
+ for (const part of parts) {
1042
+ vertexTotal += part.positionCount;
1043
+ indexTotal += part.indexCount;
1005
1044
  }
1006
- const positionCount = positionAttribute.count;
1007
- if (positionCount < 3) {
1045
+ if (vertexTotal < 3 || indexTotal < 3) {
1008
1046
  return null;
1009
1047
  }
1010
- object.updateWorldMatrix(true, true);
1011
- mesh.updateWorldMatrix(true, true);
1012
- const worldToObject = new THREE7.Matrix4().copy(object.matrixWorld).invert();
1013
- const relativeMatrix = new THREE7.Matrix4().multiplyMatrices(
1014
- worldToObject,
1015
- mesh.matrixWorld
1016
- );
1017
- const vertices = new Float32Array(positionCount * 3);
1048
+ const vertices = new Float32Array(vertexTotal * 3);
1049
+ const indices = new Uint32Array(indexTotal);
1018
1050
  const point = new THREE7.Vector3();
1019
- for (let index = 0; index < positionCount; index += 1) {
1020
- point.set(
1021
- positionAttribute.getX(index),
1022
- positionAttribute.getY(index),
1023
- positionAttribute.getZ(index)
1024
- ).applyMatrix4(relativeMatrix);
1025
- const outputIndex = index * 3;
1026
- vertices[outputIndex] = point.x;
1027
- vertices[outputIndex + 1] = point.y;
1028
- vertices[outputIndex + 2] = point.z;
1029
- }
1030
- const indexAttribute = geometry.getIndex();
1031
- let indices;
1032
- if (indexAttribute) {
1033
- indices = new Uint32Array(indexAttribute.count);
1034
- for (let index = 0; index < indexAttribute.count; index += 1) {
1035
- indices[index] = indexAttribute.getX(index);
1036
- }
1037
- } else {
1038
- const triangleIndexCount = Math.floor(positionCount / 3) * 3;
1039
- if (triangleIndexCount < 3) {
1040
- return null;
1041
- }
1042
- indices = new Uint32Array(triangleIndexCount);
1043
- for (let index = 0; index < triangleIndexCount; index += 1) {
1044
- indices[index] = index;
1051
+ let vertexOffset = 0;
1052
+ let indexOffset = 0;
1053
+ for (const part of parts) {
1054
+ const { positionAttribute, indexAttribute, relativeMatrix } = part;
1055
+ for (let index = 0; index < part.positionCount; index += 1) {
1056
+ point.set(
1057
+ positionAttribute.getX(index),
1058
+ positionAttribute.getY(index),
1059
+ positionAttribute.getZ(index)
1060
+ ).applyMatrix4(relativeMatrix);
1061
+ const outputIndex = (vertexOffset + index) * 3;
1062
+ vertices[outputIndex] = point.x * scale.x;
1063
+ vertices[outputIndex + 1] = point.y * scale.y;
1064
+ vertices[outputIndex + 2] = point.z * scale.z;
1065
+ }
1066
+ if (indexAttribute) {
1067
+ for (let index = 0; index < part.indexCount; index += 1) {
1068
+ indices[indexOffset + index] = vertexOffset + indexAttribute.getX(index);
1069
+ }
1070
+ } else {
1071
+ for (let index = 0; index < part.indexCount; index += 1) {
1072
+ indices[indexOffset + index] = vertexOffset + index;
1073
+ }
1045
1074
  }
1075
+ vertexOffset += part.positionCount;
1076
+ indexOffset += part.indexCount;
1046
1077
  }
1047
- const matrixSignature = relativeMatrix.elements.map((value) => value.toFixed(5)).join(",");
1048
- return {
1049
- vertices,
1050
- indices,
1051
- signature: `${mesh.uuid}:${geometry.uuid}:${positionCount}:${indices.length}:${matrixSignature}`
1052
- };
1078
+ return { vertices, indices, signature: collected.signature };
1053
1079
  }
1054
1080
  __name(createTriMeshData, "createTriMeshData");
1055
1081
  function syncBodyFromTransform(body, transform) {
@@ -1163,8 +1189,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1163
1189
  }
1164
1190
  if (!physics.values.rigidbody.enabled) {
1165
1191
  this.removeEntityPhysics(physicsWorld, entityId);
1166
- physics.rigidBody = null;
1167
- physics.collider = null;
1192
+ setPhysicsLiveRef(physics, "rigidBody", null);
1193
+ setPhysicsLiveRef(physics, "collider", null);
1168
1194
  continue;
1169
1195
  }
1170
1196
  const rigidBodySignature = JSON.stringify(physics.values.rigidbody);
@@ -1208,7 +1234,7 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1208
1234
  }
1209
1235
  this.rigidBodyHandles.set(entityId, body2.handle);
1210
1236
  this.rigidBodySignatures.set(entityId, rigidBodySignature);
1211
- physics.rigidBody = body2;
1237
+ setPhysicsLiveRef(physics, "rigidBody", body2);
1212
1238
  }
1213
1239
  const rigidBodyHandle = this.rigidBodyHandles.get(entityId);
1214
1240
  if (typeof rigidBodyHandle !== "number") {
@@ -1217,16 +1243,16 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1217
1243
  const body = physicsWorld.getRigidBody(rigidBodyHandle);
1218
1244
  if (!body) {
1219
1245
  this.removeEntityPhysics(physicsWorld, entityId);
1220
- physics.rigidBody = null;
1221
- physics.collider = null;
1246
+ setPhysicsLiveRef(physics, "rigidBody", null);
1247
+ setPhysicsLiveRef(physics, "collider", null);
1222
1248
  continue;
1223
1249
  }
1224
- physics.rigidBody = body;
1250
+ setPhysicsLiveRef(physics, "rigidBody", body);
1225
1251
  if (this.isEditorMode || physics.values.rigidbody.type !== "dynamic") {
1226
1252
  syncBodyFromTransform(body, transform);
1227
1253
  }
1228
1254
  const effectiveCollider = computeColliderState(physics.values.collider, object);
1229
- const triMeshData = effectiveCollider.shape === "trimesh" ? createTriMeshData(object) : null;
1255
+ const triMeshParts = effectiveCollider.shape === "trimesh" ? collectTriMeshParts(object) : null;
1230
1256
  if (!effectiveCollider || !effectiveCollider.enabled) {
1231
1257
  const colliderHandle = this.colliderHandles.get(entityId);
1232
1258
  if (typeof colliderHandle === "number") {
@@ -1237,10 +1263,10 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1237
1263
  }
1238
1264
  this.colliderHandles.delete(entityId);
1239
1265
  this.colliderSignatures.delete(entityId);
1240
- physics.collider = null;
1266
+ setPhysicsLiveRef(physics, "collider", null);
1241
1267
  continue;
1242
1268
  }
1243
- const colliderSignature = `${JSON.stringify(effectiveCollider)}:${triMeshData?.signature ?? ""}`;
1269
+ const colliderSignature = `${JSON.stringify(effectiveCollider)}:${triMeshParts?.signature ?? ""}`;
1244
1270
  const previousColliderSignature = this.colliderSignatures.get(entityId);
1245
1271
  if (!this.colliderHandles.has(entityId) || previousColliderSignature !== colliderSignature) {
1246
1272
  const previousColliderHandle = this.colliderHandles.get(entityId);
@@ -1253,15 +1279,19 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
1253
1279
  const colliderDesc = createColliderDesc(
1254
1280
  this.rapier,
1255
1281
  effectiveCollider,
1256
- triMeshData
1282
+ createTriMeshData(triMeshParts)
1257
1283
  );
1258
1284
  const createdCollider = physicsWorld.createCollider(colliderDesc, body);
1259
1285
  this.colliderHandles.set(entityId, createdCollider.handle);
1260
1286
  this.colliderSignatures.set(entityId, colliderSignature);
1261
- physics.collider = createdCollider;
1287
+ setPhysicsLiveRef(physics, "collider", createdCollider);
1262
1288
  } else {
1263
1289
  const colliderHandle = this.colliderHandles.get(entityId);
1264
- 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
+ );
1265
1295
  }
1266
1296
  }
1267
1297
  if (!this.isEditorMode) {
@@ -5809,5 +5839,5 @@ __name(_VideoSystem, "VideoSystem");
5809
5839
  var VideoSystem = _VideoSystem;
5810
5840
 
5811
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 };
5812
- //# sourceMappingURL=chunk-7BEZBIVB.js.map
5813
- //# sourceMappingURL=chunk-7BEZBIVB.js.map
5842
+ //# sourceMappingURL=chunk-3P3ZBP7K.js.map
5843
+ //# sourceMappingURL=chunk-3P3ZBP7K.js.map