@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
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { k as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, l as World, S as SpawnPrefabSource, m as SpawnPrefabOptions, n as ComponentClass, o as ParentLookup, p as EcsEntityKind, O as ObjectManagementSystem, q as SubtreeSnapshot, r as EntityId, s as ExternalRefWarning } from './System-CYWZ_Zx5.cjs';
2
2
  export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFactory, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, B as EcsComponentFactoryKind, F as EcsEntityEditorKind, G as EntityInput, H as FloatInput, I as InputSystem, J as IntersectionResult, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, N as PREFAB_FILE_VERSION, Q as PREFAB_FILE_VERSION_NESTED, R as PrefabAsset, U as RemapSnapshotOptions, X as RenderSystem, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a0 as TransformSyncSystem, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, a4 as clearPrefabCache, a5 as despawnPrefab, a6 as loadPrefab, a7 as parsePrefabAsset, a8 as prefabFileVersionFor, a9 as remapSnapshotEntityIds, aa as setPrefabAssetUrlResolver, ab as spawnPrefab } from './System-CYWZ_Zx5.cjs';
3
3
  import * as THREE from 'three';
4
- import { O as Object3DRef } from './Video-ppAXaKt0.cjs';
5
- export { a6 as AnimationStateCallbacks, a7 as AnimationStateMachine, a8 as AnimationStateManager, a9 as StateMachine } from './Video-ppAXaKt0.cjs';
6
- export { i as CoreComponents } from './index-Cu2Pt7wN.cjs';
4
+ import { O as Object3DRef } from './Video-AIQYTAAr.cjs';
5
+ export { a7 as AnimationStateCallbacks, a8 as AnimationStateMachine, a9 as AnimationStateManager, aa as StateMachine } from './Video-AIQYTAAr.cjs';
6
+ export { i as CoreComponents } from './index-Gr8aCPRM.cjs';
7
7
  export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InstancedMeshSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ModuleLoader, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObjectSystem, SelectionContext, VideoSystem } from './systems/index.cjs';
8
8
  export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.cjs';
9
9
  import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { k as EcsSystem, C as Component, W as WorldEntityView, T as TransformComponent, l as World, S as SpawnPrefabSource, m as SpawnPrefabOptions, n as ComponentClass, o as ParentLookup, p as EcsEntityKind, O as ObjectManagementSystem, q as SubtreeSnapshot, r as EntityId, s as ExternalRefWarning } from './System-CYWZ_Zx5.js';
2
2
  export { A as AssetInput, t as CheckboxInput, u as ColorInput, v as ComponentFactory, w as ComponentInput, x as ComponentKind, y as DropdownInput, z as DropdownOption, B as EcsComponentFactoryKind, F as EcsEntityEditorKind, G as EntityInput, H as FloatInput, I as InputSystem, J as IntersectionResult, K as KeyboardKey, L as KeyboardKeys, M as MouseButton, N as PREFAB_FILE_VERSION, Q as PREFAB_FILE_VERSION_NESTED, R as PrefabAsset, U as RemapSnapshotOptions, X as RenderSystem, Y as SelectionListener, Z as SliderInput, _ as TextInput, $ as ToggleInput, a0 as TransformSyncSystem, a1 as Vec3, a2 as Vector2Input, a3 as Vector3Input, a4 as clearPrefabCache, a5 as despawnPrefab, a6 as loadPrefab, a7 as parsePrefabAsset, a8 as prefabFileVersionFor, a9 as remapSnapshotEntityIds, aa as setPrefabAssetUrlResolver, ab as spawnPrefab } from './System-CYWZ_Zx5.js';
3
3
  import * as THREE from 'three';
4
- import { O as Object3DRef } from './Video-C1IOat7L.js';
5
- export { a6 as AnimationStateCallbacks, a7 as AnimationStateMachine, a8 as AnimationStateManager, a9 as StateMachine } from './Video-C1IOat7L.js';
6
- export { i as CoreComponents } from './index-DdiWu1b6.js';
4
+ import { O as Object3DRef } from './Video-DlZ4G9ig.js';
5
+ export { a7 as AnimationStateCallbacks, a8 as AnimationStateMachine, a9 as AnimationStateManager, aa as StateMachine } from './Video-DlZ4G9ig.js';
6
+ export { i as CoreComponents } from './index-BwiRJNIT.js';
7
7
  export { AnimationSystem, AudioSystem, CameraSyncSystem, EnvironmentSyncSystem, InstancedMeshSystem, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ModuleLoader, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, SCRIPT_OBJECT_ROOT_FLAG, ScriptBehaviourSystem, ScriptObjectSystem, SelectionContext, VideoSystem } from './systems/index.js';
8
8
  export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './factories/index.js';
9
9
  import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-7BEZBIVB.js';
2
- 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 } from './chunk-7BEZBIVB.js';
3
- import { registerDefaultFactories } from './chunk-52CHDPRQ.js';
4
- export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-52CHDPRQ.js';
5
- import { ObjectManagementSystem } from './chunk-WKGCC7YL.js';
6
- export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, clearModelCache, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath } from './chunk-WKGCC7YL.js';
7
- import { SelectionTransformState, Object3DRef, Name, EntityType, ParentId, Environment, Postprocessing, ScriptComponent } from './chunk-JHCPRVBC.js';
8
- export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents } from './chunk-JHCPRVBC.js';
1
+ import { MeshGeometrySystem, InstancedMeshSystem, EnvironmentSyncSystem, PostprocessingSyncSystem, LightSyncSystem, MaterialSyncSystem, PhysicsSyncSystem, AnimationSystem, AudioSystem, VideoSystem, CameraSyncSystem, TransformSyncSystem, ObjectVisibilitySystem, RenderSystem, spawnPrefab, despawnPrefab, buildNodeKeyMapsFromSnapshot, indexSnapshotByEntity, findTopLevelNestedRegions, collectSnapshotSubtreeIds, groupOverridePaths, OVERRIDE_DIFF_EXCLUDED_COMPONENTS, OVERRIDE_ROOT_EXCLUDED_COMPONENTS, canonicalizeComponentValue, mergeComponentValue, decanonicalizeComponentValue, computeInstanceOverrides, collectEntitySubtree, ADDED_NODE_MARKER_COMPONENT } from './chunk-3P3ZBP7K.js';
2
+ 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 } from './chunk-3P3ZBP7K.js';
3
+ import { registerDefaultFactories } from './chunk-RJ4J5UEX.js';
4
+ export { createAnimationComponent, createAudioComponent, createCameraComponent, createEntityTypeComponent, createEnvironmentComponent, createImageComponent, createImageTargetAnchorComponent, createImageTargetComponent, createInstanceSlotComponent, createInstancedMeshComponent, createLightComponent, createMaterialComponent, createMeshComponent, createMeshGeometryComponent, createModelComponent, createNameComponent, createObject3DRefComponent, createParentIdComponent, createPhysicsComponent, createPostprocessingComponent, createScriptComponent, createScriptObjectComponent, createSelectableComponent, createSelectionTransformStateComponent, createSpriteComponent, createTransformComponent, createVideoComponent, registerDefaultComponentFactories, registerDefaultFactories } from './chunk-RJ4J5UEX.js';
5
+ import { ObjectManagementSystem } from './chunk-XFD74BQL.js';
6
+ export { ObjectManagementSystem, SHARED_MODEL_RESOURCE_FLAG, clearModelCache, loadSharedGltf, resolveDracoDecoderPath, setDracoDecoderPath } from './chunk-XFD74BQL.js';
7
+ import { SelectionTransformState, Object3DRef, Name, EntityType, ParentId, Environment, Postprocessing, ScriptComponent } from './chunk-J6736FFO.js';
8
+ export { AnimationStateMachine, AnimationStateManager, components_exports as CoreComponents } from './chunk-J6736FFO.js';
9
9
  import './chunk-QHILSPT4.js';
10
- import { normalizeDebugValue, DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue } from './chunk-ZXGHKX7N.js';
10
+ import { normalizeDebugValue, DEBUG_CHANGE_IGNORED_SYSTEMS, cloneHistoryValue } from './chunk-OWQSESTO.js';
11
11
  import { __name } from './chunk-OY7ZODZP.js';
12
12
  export { Component } from './chunk-OY7ZODZP.js';
13
13
  import * as THREE from 'three';
@@ -1596,12 +1596,21 @@ function normalizePhysicsState(value) {
1596
1596
  };
1597
1597
  }
1598
1598
  __name(normalizePhysicsState, "normalizePhysicsState");
1599
+ function setPhysicsLiveRef(component, key, value) {
1600
+ Object.defineProperty(component, key, {
1601
+ value,
1602
+ writable: true,
1603
+ configurable: true,
1604
+ enumerable: false
1605
+ });
1606
+ }
1607
+ __name(setPhysicsLiveRef, "setPhysicsLiveRef");
1599
1608
  var _PhysicsComponent = class _PhysicsComponent extends Component {
1600
1609
  constructor(values) {
1601
1610
  super();
1602
1611
  this.values = normalizePhysicsState(values);
1603
- this.rigidBody = null;
1604
- this.collider = null;
1612
+ setPhysicsLiveRef(this, "rigidBody", null);
1613
+ setPhysicsLiveRef(this, "collider", null);
1605
1614
  }
1606
1615
  /**
1607
1616
  * Patch rigidbody and/or collider state. Each sub-object is deep-merged
@@ -3013,82 +3022,108 @@ function createColliderDesc(RAPIER, values, triMeshData) {
3013
3022
  return desc;
3014
3023
  }
3015
3024
  __name(createColliderDesc, "createColliderDesc");
3016
- function findFirstMeshWithGeometry(object) {
3017
- if (object instanceof THREE14__namespace.Mesh && object.geometry) {
3018
- return object;
3025
+ function collectTriMeshParts(object) {
3026
+ if (!object) {
3027
+ return null;
3019
3028
  }
3020
- let found = null;
3029
+ object.updateWorldMatrix(true, true);
3030
+ const worldScale = new THREE14__namespace.Vector3();
3031
+ object.getWorldScale(worldScale);
3032
+ const scale = {
3033
+ x: Math.abs(worldScale.x) || 1,
3034
+ y: Math.abs(worldScale.y) || 1,
3035
+ z: Math.abs(worldScale.z) || 1
3036
+ };
3037
+ const worldToObject = new THREE14__namespace.Matrix4().copy(object.matrixWorld).invert();
3038
+ const parts = [];
3021
3039
  object.traverse((child) => {
3022
- if (found) {
3040
+ if (!(child instanceof THREE14__namespace.Mesh) || !child.geometry) {
3023
3041
  return;
3024
3042
  }
3025
- if (child instanceof THREE14__namespace.Mesh && child.geometry) {
3026
- found = child;
3043
+ const geometry = child.geometry;
3044
+ const positionAttribute = geometry.getAttribute("position");
3045
+ if (!positionAttribute || positionAttribute.itemSize < 3) {
3046
+ return;
3047
+ }
3048
+ const positionCount = positionAttribute.count;
3049
+ if (positionCount < 3) {
3050
+ return;
3051
+ }
3052
+ const indexAttribute = geometry.getIndex();
3053
+ const indexCount = indexAttribute ? indexAttribute.count : Math.floor(positionCount / 3) * 3;
3054
+ if (indexCount < 3) {
3055
+ return;
3027
3056
  }
3057
+ const relativeMatrix = new THREE14__namespace.Matrix4().multiplyMatrices(
3058
+ worldToObject,
3059
+ child.matrixWorld
3060
+ );
3061
+ const matrixSignature = relativeMatrix.elements.map((value) => value.toFixed(5)).join(",");
3062
+ parts.push({
3063
+ positionAttribute,
3064
+ indexAttribute,
3065
+ positionCount,
3066
+ indexCount,
3067
+ relativeMatrix,
3068
+ signature: `${child.uuid}:${geometry.uuid}:${positionCount}:${indexCount}:${matrixSignature}`
3069
+ });
3028
3070
  });
3029
- return found;
3030
- }
3031
- __name(findFirstMeshWithGeometry, "findFirstMeshWithGeometry");
3032
- function createTriMeshData(object) {
3033
- if (!object) {
3071
+ if (parts.length === 0) {
3034
3072
  return null;
3035
3073
  }
3036
- const mesh = findFirstMeshWithGeometry(object);
3037
- if (!mesh) {
3074
+ const scaleSignature = `${scale.x.toFixed(5)},${scale.y.toFixed(5)},${scale.z.toFixed(5)}`;
3075
+ return {
3076
+ parts,
3077
+ scale,
3078
+ signature: `${scaleSignature}|${parts.map((p) => p.signature).join("|")}`
3079
+ };
3080
+ }
3081
+ __name(collectTriMeshParts, "collectTriMeshParts");
3082
+ function createTriMeshData(collected) {
3083
+ if (!collected) {
3038
3084
  return null;
3039
3085
  }
3040
- const geometry = mesh.geometry;
3041
- const positionAttribute = geometry.getAttribute("position");
3042
- if (!positionAttribute || positionAttribute.itemSize < 3) {
3043
- return null;
3086
+ const { parts, scale } = collected;
3087
+ let vertexTotal = 0;
3088
+ let indexTotal = 0;
3089
+ for (const part of parts) {
3090
+ vertexTotal += part.positionCount;
3091
+ indexTotal += part.indexCount;
3044
3092
  }
3045
- const positionCount = positionAttribute.count;
3046
- if (positionCount < 3) {
3093
+ if (vertexTotal < 3 || indexTotal < 3) {
3047
3094
  return null;
3048
3095
  }
3049
- object.updateWorldMatrix(true, true);
3050
- mesh.updateWorldMatrix(true, true);
3051
- const worldToObject = new THREE14__namespace.Matrix4().copy(object.matrixWorld).invert();
3052
- const relativeMatrix = new THREE14__namespace.Matrix4().multiplyMatrices(
3053
- worldToObject,
3054
- mesh.matrixWorld
3055
- );
3056
- const vertices = new Float32Array(positionCount * 3);
3096
+ const vertices = new Float32Array(vertexTotal * 3);
3097
+ const indices = new Uint32Array(indexTotal);
3057
3098
  const point = new THREE14__namespace.Vector3();
3058
- for (let index = 0; index < positionCount; index += 1) {
3059
- point.set(
3060
- positionAttribute.getX(index),
3061
- positionAttribute.getY(index),
3062
- positionAttribute.getZ(index)
3063
- ).applyMatrix4(relativeMatrix);
3064
- const outputIndex = index * 3;
3065
- vertices[outputIndex] = point.x;
3066
- vertices[outputIndex + 1] = point.y;
3067
- vertices[outputIndex + 2] = point.z;
3068
- }
3069
- const indexAttribute = geometry.getIndex();
3070
- let indices;
3071
- if (indexAttribute) {
3072
- indices = new Uint32Array(indexAttribute.count);
3073
- for (let index = 0; index < indexAttribute.count; index += 1) {
3074
- indices[index] = indexAttribute.getX(index);
3075
- }
3076
- } else {
3077
- const triangleIndexCount = Math.floor(positionCount / 3) * 3;
3078
- if (triangleIndexCount < 3) {
3079
- return null;
3080
- }
3081
- indices = new Uint32Array(triangleIndexCount);
3082
- for (let index = 0; index < triangleIndexCount; index += 1) {
3083
- indices[index] = index;
3099
+ let vertexOffset = 0;
3100
+ let indexOffset = 0;
3101
+ for (const part of parts) {
3102
+ const { positionAttribute, indexAttribute, relativeMatrix } = part;
3103
+ for (let index = 0; index < part.positionCount; index += 1) {
3104
+ point.set(
3105
+ positionAttribute.getX(index),
3106
+ positionAttribute.getY(index),
3107
+ positionAttribute.getZ(index)
3108
+ ).applyMatrix4(relativeMatrix);
3109
+ const outputIndex = (vertexOffset + index) * 3;
3110
+ vertices[outputIndex] = point.x * scale.x;
3111
+ vertices[outputIndex + 1] = point.y * scale.y;
3112
+ vertices[outputIndex + 2] = point.z * scale.z;
3113
+ }
3114
+ if (indexAttribute) {
3115
+ for (let index = 0; index < part.indexCount; index += 1) {
3116
+ indices[indexOffset + index] = vertexOffset + indexAttribute.getX(index);
3117
+ }
3118
+ } else {
3119
+ for (let index = 0; index < part.indexCount; index += 1) {
3120
+ indices[indexOffset + index] = vertexOffset + index;
3121
+ }
3084
3122
  }
3123
+ vertexOffset += part.positionCount;
3124
+ indexOffset += part.indexCount;
3085
3125
  }
3086
- const matrixSignature = relativeMatrix.elements.map((value) => value.toFixed(5)).join(",");
3087
- return {
3088
- vertices,
3089
- indices,
3090
- signature: `${mesh.uuid}:${geometry.uuid}:${positionCount}:${indices.length}:${matrixSignature}`
3091
- };
3126
+ return { vertices, indices, signature: collected.signature };
3092
3127
  }
3093
3128
  __name(createTriMeshData, "createTriMeshData");
3094
3129
  function syncBodyFromTransform(body, transform) {
@@ -3202,8 +3237,8 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
3202
3237
  }
3203
3238
  if (!physics.values.rigidbody.enabled) {
3204
3239
  this.removeEntityPhysics(physicsWorld, entityId);
3205
- physics.rigidBody = null;
3206
- physics.collider = null;
3240
+ setPhysicsLiveRef(physics, "rigidBody", null);
3241
+ setPhysicsLiveRef(physics, "collider", null);
3207
3242
  continue;
3208
3243
  }
3209
3244
  const rigidBodySignature = JSON.stringify(physics.values.rigidbody);
@@ -3247,7 +3282,7 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
3247
3282
  }
3248
3283
  this.rigidBodyHandles.set(entityId, body2.handle);
3249
3284
  this.rigidBodySignatures.set(entityId, rigidBodySignature);
3250
- physics.rigidBody = body2;
3285
+ setPhysicsLiveRef(physics, "rigidBody", body2);
3251
3286
  }
3252
3287
  const rigidBodyHandle = this.rigidBodyHandles.get(entityId);
3253
3288
  if (typeof rigidBodyHandle !== "number") {
@@ -3256,16 +3291,16 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
3256
3291
  const body = physicsWorld.getRigidBody(rigidBodyHandle);
3257
3292
  if (!body) {
3258
3293
  this.removeEntityPhysics(physicsWorld, entityId);
3259
- physics.rigidBody = null;
3260
- physics.collider = null;
3294
+ setPhysicsLiveRef(physics, "rigidBody", null);
3295
+ setPhysicsLiveRef(physics, "collider", null);
3261
3296
  continue;
3262
3297
  }
3263
- physics.rigidBody = body;
3298
+ setPhysicsLiveRef(physics, "rigidBody", body);
3264
3299
  if (this.isEditorMode || physics.values.rigidbody.type !== "dynamic") {
3265
3300
  syncBodyFromTransform(body, transform);
3266
3301
  }
3267
3302
  const effectiveCollider = computeColliderState(physics.values.collider, object);
3268
- const triMeshData = effectiveCollider.shape === "trimesh" ? createTriMeshData(object) : null;
3303
+ const triMeshParts = effectiveCollider.shape === "trimesh" ? collectTriMeshParts(object) : null;
3269
3304
  if (!effectiveCollider || !effectiveCollider.enabled) {
3270
3305
  const colliderHandle = this.colliderHandles.get(entityId);
3271
3306
  if (typeof colliderHandle === "number") {
@@ -3276,10 +3311,10 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
3276
3311
  }
3277
3312
  this.colliderHandles.delete(entityId);
3278
3313
  this.colliderSignatures.delete(entityId);
3279
- physics.collider = null;
3314
+ setPhysicsLiveRef(physics, "collider", null);
3280
3315
  continue;
3281
3316
  }
3282
- const colliderSignature = `${JSON.stringify(effectiveCollider)}:${triMeshData?.signature ?? ""}`;
3317
+ const colliderSignature = `${JSON.stringify(effectiveCollider)}:${triMeshParts?.signature ?? ""}`;
3283
3318
  const previousColliderSignature = this.colliderSignatures.get(entityId);
3284
3319
  if (!this.colliderHandles.has(entityId) || previousColliderSignature !== colliderSignature) {
3285
3320
  const previousColliderHandle = this.colliderHandles.get(entityId);
@@ -3292,15 +3327,19 @@ var _PhysicsSyncSystem = class _PhysicsSyncSystem {
3292
3327
  const colliderDesc = createColliderDesc(
3293
3328
  this.rapier,
3294
3329
  effectiveCollider,
3295
- triMeshData
3330
+ createTriMeshData(triMeshParts)
3296
3331
  );
3297
3332
  const createdCollider = physicsWorld.createCollider(colliderDesc, body);
3298
3333
  this.colliderHandles.set(entityId, createdCollider.handle);
3299
3334
  this.colliderSignatures.set(entityId, colliderSignature);
3300
- physics.collider = createdCollider;
3335
+ setPhysicsLiveRef(physics, "collider", createdCollider);
3301
3336
  } else {
3302
3337
  const colliderHandle = this.colliderHandles.get(entityId);
3303
- physics.collider = typeof colliderHandle === "number" ? physicsWorld.getCollider(colliderHandle) ?? null : null;
3338
+ setPhysicsLiveRef(
3339
+ physics,
3340
+ "collider",
3341
+ typeof colliderHandle === "number" ? physicsWorld.getCollider(colliderHandle) ?? null : null
3342
+ );
3304
3343
  }
3305
3344
  }
3306
3345
  if (!this.isEditorMode) {