@relu-interactives/spatial-ecs 0.2.7 → 0.2.9
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.
- package/dist/{System-CIiWteft.d.cts → System-AV2_87Zr.d.cts} +1 -1
- package/dist/{System-CIiWteft.d.ts → System-AV2_87Zr.d.ts} +1 -1
- package/dist/{Video-Dj4KBqQ1.d.cts → Video-Bn93p6XV.d.cts} +27 -5
- package/dist/{Video-B-qMljTn.d.ts → Video-D6mObK_5.d.ts} +27 -5
- package/dist/{chunk-R5D5PWXV.js → chunk-AZR6SLQN.js} +16 -4
- package/dist/chunk-AZR6SLQN.js.map +1 -0
- package/dist/{chunk-EIC5B3A7.js → chunk-LE6ARNYQ.js} +84 -13
- package/dist/chunk-LE6ARNYQ.js.map +1 -0
- package/dist/{chunk-FDWNCXU3.js → chunk-ODCWJHPS.js} +3 -3
- package/dist/{chunk-FDWNCXU3.js.map → chunk-ODCWJHPS.js.map} +1 -1
- package/dist/{chunk-G2DUXNTQ.js → chunk-PHIEXEKJ.js} +10 -3
- package/dist/chunk-PHIEXEKJ.js.map +1 -0
- package/dist/{chunk-2F6T3BVO.js → chunk-SABZQFSA.js} +47 -29
- package/dist/chunk-SABZQFSA.js.map +1 -0
- package/dist/components/index.cjs +13 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/factories/index.cjs +92 -9
- package/dist/factories/index.cjs.map +1 -1
- package/dist/factories/index.d.cts +7 -4
- package/dist/factories/index.d.ts +7 -4
- package/dist/factories/index.js +3 -3
- package/dist/{index-Cf-PaKyN.d.ts → index-B4-ABchF.d.cts} +4 -3
- package/dist/{index-B12sx9yF.d.cts → index-BO49V8aS.d.ts} +4 -3
- package/dist/index.cjs +187 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +52 -14
- package/dist/index.js.map +1 -1
- package/dist/systems/index.cjs +44 -31
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +2 -2
- package/dist/systems/index.d.ts +2 -2
- package/dist/systems/index.js +3 -3
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/worldSnapshotUtils.cjs +8 -1
- package/dist/worldSnapshotUtils.cjs.map +1 -1
- package/dist/worldSnapshotUtils.d.cts +1 -1
- package/dist/worldSnapshotUtils.d.ts +1 -1
- package/dist/worldSnapshotUtils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2F6T3BVO.js.map +0 -1
- package/dist/chunk-EIC5B3A7.js.map +0 -1
- package/dist/chunk-G2DUXNTQ.js.map +0 -1
- package/dist/chunk-R5D5PWXV.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveDracoDecoderPath, applyTransform } from './chunk-
|
|
2
|
-
import { AnimationComponent, ModelComponent, CameraComponent, Object3DRef, Environment, Postprocessing, TransformComponent, PhysicsComponent, LightComponent, MaterialComponent, DEFAULT_MESH_GEOMETRY_PARAMETERS, MeshGeometryComponent, InstancedMeshComponent, ParentId, ScriptComponent, AudioComponent, VideoComponent } from './chunk-
|
|
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
|
|
2333
|
-
_position.set(
|
|
2334
|
-
_euler.set(
|
|
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(
|
|
2336
|
+
_scale.set(transform.scale.x, transform.scale.y, transform.scale.z);
|
|
2337
2337
|
out.compose(_position, _quaternion, _scale);
|
|
2338
2338
|
}
|
|
2339
|
-
__name(
|
|
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.
|
|
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;
|
|
@@ -2413,6 +2413,10 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2413
2413
|
this.loadingSignatures.delete(entityId);
|
|
2414
2414
|
this.modelMeshEntries.delete(entityId);
|
|
2415
2415
|
}
|
|
2416
|
+
if (instanceCount === 0) {
|
|
2417
|
+
this.geometrySignatures.set(entityId, geometrySignature);
|
|
2418
|
+
continue;
|
|
2419
|
+
}
|
|
2416
2420
|
if (comp.meshKind === "model") {
|
|
2417
2421
|
if (comp.modelPath && !this.loadingSignatures.has(entityId)) {
|
|
2418
2422
|
this.loadingSignatures.set(entityId, geometrySignature);
|
|
@@ -2431,7 +2435,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2431
2435
|
this.loadingSignatures.delete(targetEntityId);
|
|
2432
2436
|
return;
|
|
2433
2437
|
}
|
|
2434
|
-
const currentSig = `model:${currentComp.modelPath}:${currentComp.
|
|
2438
|
+
const currentSig = `model:${currentComp.modelPath}:${currentComp.instanceEntityIds.length}`;
|
|
2435
2439
|
if (currentSig !== targetSignature) {
|
|
2436
2440
|
this.loadingSignatures.delete(targetEntityId);
|
|
2437
2441
|
return;
|
|
@@ -2447,7 +2451,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2447
2451
|
disposeModelGroup(currentComp.instancedMesh);
|
|
2448
2452
|
currentComp.instancedMesh = null;
|
|
2449
2453
|
}
|
|
2450
|
-
const count2 = Math.max(1, currentComp.
|
|
2454
|
+
const count2 = Math.max(1, currentComp.instanceEntityIds.length);
|
|
2451
2455
|
const entries = [];
|
|
2452
2456
|
gltf.scene.updateWorldMatrix(true, true);
|
|
2453
2457
|
gltf.scene.traverse((child) => {
|
|
@@ -2465,12 +2469,13 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2465
2469
|
instancedMesh2.castShadow = currentComp.castShadow;
|
|
2466
2470
|
instancedMesh2.receiveShadow = currentComp.receiveShadow;
|
|
2467
2471
|
for (let i = 0; i < count2; i++) {
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
}
|
|
2473
|
-
|
|
2472
|
+
const instanceEntityId = currentComp.instanceEntityIds[i];
|
|
2473
|
+
const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
|
|
2474
|
+
if (instTransform) {
|
|
2475
|
+
instanceTransformFromComponent(instTransform, _matrix);
|
|
2476
|
+
} else {
|
|
2477
|
+
_matrix.identity();
|
|
2478
|
+
}
|
|
2474
2479
|
_modelMatrix.multiplyMatrices(_matrix, localMatrix);
|
|
2475
2480
|
instancedMesh2.setMatrixAt(i, _modelMatrix);
|
|
2476
2481
|
}
|
|
@@ -2496,19 +2501,20 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2496
2501
|
}
|
|
2497
2502
|
continue;
|
|
2498
2503
|
}
|
|
2499
|
-
const count =
|
|
2504
|
+
const count = instanceCount;
|
|
2500
2505
|
const geometry = buildGeometry(comp);
|
|
2501
2506
|
const material = new THREE7.MeshStandardMaterial({ color: "#ffffff" });
|
|
2502
2507
|
const instancedMesh = new THREE7.InstancedMesh(geometry, material, count);
|
|
2503
2508
|
instancedMesh.castShadow = comp.castShadow;
|
|
2504
2509
|
instancedMesh.receiveShadow = comp.receiveShadow;
|
|
2505
2510
|
for (let i = 0; i < count; i++) {
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2511
|
+
const instanceEntityId = comp.instanceEntityIds[i];
|
|
2512
|
+
const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
|
|
2513
|
+
if (instTransform) {
|
|
2514
|
+
instanceTransformFromComponent(instTransform, _matrix);
|
|
2515
|
+
} else {
|
|
2516
|
+
_matrix.identity();
|
|
2517
|
+
}
|
|
2512
2518
|
instancedMesh.setMatrixAt(i, _matrix);
|
|
2513
2519
|
}
|
|
2514
2520
|
instancedMesh.instanceMatrix.needsUpdate = true;
|
|
@@ -2519,10 +2525,16 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2519
2525
|
if (comp.meshKind === "model") {
|
|
2520
2526
|
const entries = this.modelMeshEntries.get(entityId);
|
|
2521
2527
|
if (entries) {
|
|
2522
|
-
const count = comp.
|
|
2528
|
+
const count = comp.instanceEntityIds.length;
|
|
2523
2529
|
for (const entry of entries) {
|
|
2524
2530
|
for (let i = 0; i < count; i++) {
|
|
2525
|
-
|
|
2531
|
+
const instanceEntityId = comp.instanceEntityIds[i];
|
|
2532
|
+
const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
|
|
2533
|
+
if (instTransform) {
|
|
2534
|
+
instanceTransformFromComponent(instTransform, _matrix);
|
|
2535
|
+
} else {
|
|
2536
|
+
_matrix.identity();
|
|
2537
|
+
}
|
|
2526
2538
|
_modelMatrix.multiplyMatrices(_matrix, entry.localMatrix);
|
|
2527
2539
|
entry.instancedMesh.setMatrixAt(i, _modelMatrix);
|
|
2528
2540
|
}
|
|
@@ -2533,9 +2545,15 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2533
2545
|
}
|
|
2534
2546
|
} else {
|
|
2535
2547
|
const im = comp.instancedMesh;
|
|
2536
|
-
const count = comp.
|
|
2548
|
+
const count = comp.instanceEntityIds.length;
|
|
2537
2549
|
for (let i = 0; i < count; i++) {
|
|
2538
|
-
|
|
2550
|
+
const instanceEntityId = comp.instanceEntityIds[i];
|
|
2551
|
+
const instTransform = instanceEntityId !== void 0 ? world.getComponent(instanceEntityId, TransformComponent) ?? null : null;
|
|
2552
|
+
if (instTransform) {
|
|
2553
|
+
instanceTransformFromComponent(instTransform, _matrix);
|
|
2554
|
+
} else {
|
|
2555
|
+
_matrix.identity();
|
|
2556
|
+
}
|
|
2539
2557
|
im.setMatrixAt(i, _matrix);
|
|
2540
2558
|
}
|
|
2541
2559
|
im.instanceMatrix.needsUpdate = true;
|
|
@@ -3579,5 +3597,5 @@ __name(_VideoSystem, "VideoSystem");
|
|
|
3579
3597
|
var VideoSystem = _VideoSystem;
|
|
3580
3598
|
|
|
3581
3599
|
export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem };
|
|
3582
|
-
//# sourceMappingURL=chunk-
|
|
3583
|
-
//# sourceMappingURL=chunk-
|
|
3600
|
+
//# sourceMappingURL=chunk-SABZQFSA.js.map
|
|
3601
|
+
//# sourceMappingURL=chunk-SABZQFSA.js.map
|