@relu-interactives/spatial-ecs 0.2.7 → 0.2.8

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 (49) hide show
  1. package/dist/{System-CIiWteft.d.cts → System-AV2_87Zr.d.cts} +1 -1
  2. package/dist/{System-CIiWteft.d.ts → System-AV2_87Zr.d.ts} +1 -1
  3. package/dist/{Video-Dj4KBqQ1.d.cts → Video-Bn93p6XV.d.cts} +27 -5
  4. package/dist/{Video-B-qMljTn.d.ts → Video-D6mObK_5.d.ts} +27 -5
  5. package/dist/{chunk-R5D5PWXV.js → chunk-AZR6SLQN.js} +16 -4
  6. package/dist/chunk-AZR6SLQN.js.map +1 -0
  7. package/dist/{chunk-EIC5B3A7.js → chunk-LE6ARNYQ.js} +84 -13
  8. package/dist/chunk-LE6ARNYQ.js.map +1 -0
  9. package/dist/{chunk-FDWNCXU3.js → chunk-ODCWJHPS.js} +3 -3
  10. package/dist/{chunk-FDWNCXU3.js.map → chunk-ODCWJHPS.js.map} +1 -1
  11. package/dist/{chunk-G2DUXNTQ.js → chunk-PHIEXEKJ.js} +10 -3
  12. package/dist/chunk-PHIEXEKJ.js.map +1 -0
  13. package/dist/{chunk-2F6T3BVO.js → chunk-TVBWYIGY.js} +42 -28
  14. package/dist/chunk-TVBWYIGY.js.map +1 -0
  15. package/dist/components/index.cjs +13 -1
  16. package/dist/components/index.cjs.map +1 -1
  17. package/dist/components/index.d.cts +2 -2
  18. package/dist/components/index.d.ts +2 -2
  19. package/dist/components/index.js +1 -1
  20. package/dist/factories/index.cjs +92 -9
  21. package/dist/factories/index.cjs.map +1 -1
  22. package/dist/factories/index.d.cts +7 -4
  23. package/dist/factories/index.d.ts +7 -4
  24. package/dist/factories/index.js +3 -3
  25. package/dist/{index-Cf-PaKyN.d.ts → index-B4-ABchF.d.cts} +4 -3
  26. package/dist/{index-B12sx9yF.d.cts → index-BO49V8aS.d.ts} +4 -3
  27. package/dist/index.cjs +182 -39
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +6 -6
  30. package/dist/index.d.ts +6 -6
  31. package/dist/index.js +52 -14
  32. package/dist/index.js.map +1 -1
  33. package/dist/systems/index.cjs +39 -30
  34. package/dist/systems/index.cjs.map +1 -1
  35. package/dist/systems/index.d.cts +2 -2
  36. package/dist/systems/index.d.ts +2 -2
  37. package/dist/systems/index.js +3 -3
  38. package/dist/types.d.cts +1 -1
  39. package/dist/types.d.ts +1 -1
  40. package/dist/worldSnapshotUtils.cjs +8 -1
  41. package/dist/worldSnapshotUtils.cjs.map +1 -1
  42. package/dist/worldSnapshotUtils.d.cts +1 -1
  43. package/dist/worldSnapshotUtils.d.ts +1 -1
  44. package/dist/worldSnapshotUtils.js +1 -1
  45. package/package.json +1 -1
  46. package/dist/chunk-2F6T3BVO.js.map +0 -1
  47. package/dist/chunk-EIC5B3A7.js.map +0 -1
  48. package/dist/chunk-G2DUXNTQ.js.map +0 -1
  49. package/dist/chunk-R5D5PWXV.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { resolveDracoDecoderPath, applyTransform } from './chunk-FDWNCXU3.js';
2
- import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, AudioComponent, VideoComponent } from './chunk-R5D5PWXV.js';
1
+ import { resolveDracoDecoderPath, applyTransform } from './chunk-ODCWJHPS.js';
2
+ import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, AudioComponent, VideoComponent } from './chunk-AZR6SLQN.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';
@@ -2329,14 +2329,14 @@ var _euler = new THREE7.Euler();
2329
2329
  var _scale = new THREE7.Vector3();
2330
2330
  var _matrix = new THREE7.Matrix4();
2331
2331
  var _modelMatrix = new THREE7.Matrix4();
2332
- function instanceTransformToMatrix4(inst, out) {
2333
- _position.set(inst.position.x, inst.position.y, inst.position.z);
2334
- _euler.set(inst.rotation.x, inst.rotation.y, inst.rotation.z, "XYZ");
2332
+ function instanceTransformFromComponent(transform, out) {
2333
+ _position.set(transform.position.x, transform.position.y, transform.position.z);
2334
+ _euler.set(transform.rotation.x, transform.rotation.y, transform.rotation.z, "XYZ");
2335
2335
  _quaternion.setFromEuler(_euler);
2336
- _scale.set(inst.scale.x, inst.scale.y, inst.scale.z);
2336
+ _scale.set(transform.scale.x, transform.scale.y, transform.scale.z);
2337
2337
  out.compose(_position, _quaternion, _scale);
2338
2338
  }
2339
- __name(instanceTransformToMatrix4, "instanceTransformToMatrix4");
2339
+ __name(instanceTransformFromComponent, "instanceTransformFromComponent");
2340
2340
  function disposePrimitiveInstancedMesh(mesh) {
2341
2341
  mesh.geometry.dispose();
2342
2342
  if (Array.isArray(mesh.material)) {
@@ -2395,7 +2395,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2395
2395
  const objectRef = world.getComponent(entityId, Object3DRef);
2396
2396
  const anchor = objectRef?.object ?? null;
2397
2397
  if (!anchor) continue;
2398
- const instanceCount = comp.instances.length;
2398
+ const instanceCount = comp.instanceEntityIds.length;
2399
2399
  const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
2400
2400
  const pendingLoadSignature = this.loadingSignatures.get(entityId);
2401
2401
  const needsRebuild = (comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature) && pendingLoadSignature !== geometrySignature;
@@ -2431,7 +2431,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2431
2431
  this.loadingSignatures.delete(targetEntityId);
2432
2432
  return;
2433
2433
  }
2434
- const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
2434
+ const currentSig = `model:${currentComp.modelPath}:${currentComp.instanceEntityIds.length}`;
2435
2435
  if (currentSig !== targetSignature) {
2436
2436
  this.loadingSignatures.delete(targetEntityId);
2437
2437
  return;
@@ -2447,7 +2447,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2447
2447
  disposeModelGroup(currentComp.instancedMesh);
2448
2448
  currentComp.instancedMesh = null;
2449
2449
  }
2450
- const count2 = Math.max(1, currentComp.instances.length);
2450
+ const count2 = Math.max(1, currentComp.instanceEntityIds.length);
2451
2451
  const entries = [];
2452
2452
  gltf.scene.updateWorldMatrix(true, true);
2453
2453
  gltf.scene.traverse((child) => {
@@ -2465,12 +2465,13 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2465
2465
  instancedMesh2.castShadow = currentComp.castShadow;
2466
2466
  instancedMesh2.receiveShadow = currentComp.receiveShadow;
2467
2467
  for (let i = 0; i < count2; i++) {
2468
- const inst = currentComp.instances[i] ?? {
2469
- position: { x: 0, y: 0, z: 0 },
2470
- rotation: { x: 0, y: 0, z: 0 },
2471
- scale: { x: 1, y: 1, z: 1 }
2472
- };
2473
- instanceTransformToMatrix4(inst, _matrix);
2468
+ const instanceEntityId = currentComp.instanceEntityIds[i];
2469
+ const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
2470
+ if (instTransform) {
2471
+ instanceTransformFromComponent(instTransform, _matrix);
2472
+ } else {
2473
+ _matrix.identity();
2474
+ }
2474
2475
  _modelMatrix.multiplyMatrices(_matrix, localMatrix);
2475
2476
  instancedMesh2.setMatrixAt(i, _modelMatrix);
2476
2477
  }
@@ -2503,12 +2504,13 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2503
2504
  instancedMesh.castShadow = comp.castShadow;
2504
2505
  instancedMesh.receiveShadow = comp.receiveShadow;
2505
2506
  for (let i = 0; i < count; i++) {
2506
- const inst = comp.instances[i] ?? {
2507
- position: { x: 0, y: 0, z: 0 },
2508
- rotation: { x: 0, y: 0, z: 0 },
2509
- scale: { x: 1, y: 1, z: 1 }
2510
- };
2511
- instanceTransformToMatrix4(inst, _matrix);
2507
+ const instanceEntityId = comp.instanceEntityIds[i];
2508
+ const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
2509
+ if (instTransform) {
2510
+ instanceTransformFromComponent(instTransform, _matrix);
2511
+ } else {
2512
+ _matrix.identity();
2513
+ }
2512
2514
  instancedMesh.setMatrixAt(i, _matrix);
2513
2515
  }
2514
2516
  instancedMesh.instanceMatrix.needsUpdate = true;
@@ -2519,10 +2521,16 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2519
2521
  if (comp.meshKind === "model") {
2520
2522
  const entries = this.modelMeshEntries.get(entityId);
2521
2523
  if (entries) {
2522
- const count = comp.instances.length;
2524
+ const count = comp.instanceEntityIds.length;
2523
2525
  for (const entry of entries) {
2524
2526
  for (let i = 0; i < count; i++) {
2525
- instanceTransformToMatrix4(comp.instances[i], _matrix);
2527
+ const instanceEntityId = comp.instanceEntityIds[i];
2528
+ const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
2529
+ if (instTransform) {
2530
+ instanceTransformFromComponent(instTransform, _matrix);
2531
+ } else {
2532
+ _matrix.identity();
2533
+ }
2526
2534
  _modelMatrix.multiplyMatrices(_matrix, entry.localMatrix);
2527
2535
  entry.instancedMesh.setMatrixAt(i, _modelMatrix);
2528
2536
  }
@@ -2533,9 +2541,15 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
2533
2541
  }
2534
2542
  } else {
2535
2543
  const im = comp.instancedMesh;
2536
- const count = comp.instances.length;
2544
+ const count = comp.instanceEntityIds.length;
2537
2545
  for (let i = 0; i < count; i++) {
2538
- instanceTransformToMatrix4(comp.instances[i], _matrix);
2546
+ const instanceEntityId = comp.instanceEntityIds[i];
2547
+ const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
2548
+ if (instTransform) {
2549
+ instanceTransformFromComponent(instTransform, _matrix);
2550
+ } else {
2551
+ _matrix.identity();
2552
+ }
2539
2553
  im.setMatrixAt(i, _matrix);
2540
2554
  }
2541
2555
  im.instanceMatrix.needsUpdate = true;
@@ -3579,5 +3593,5 @@ __name(_VideoSystem, "VideoSystem");
3579
3593
  var VideoSystem = _VideoSystem;
3580
3594
 
3581
3595
  export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem };
3582
- //# sourceMappingURL=chunk-2F6T3BVO.js.map
3583
- //# sourceMappingURL=chunk-2F6T3BVO.js.map
3596
+ //# sourceMappingURL=chunk-TVBWYIGY.js.map
3597
+ //# sourceMappingURL=chunk-TVBWYIGY.js.map