@relu-interactives/spatial-ecs 0.2.6 → 0.2.7
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/{chunk-NRSUYDBA.js → chunk-2F6T3BVO.js} +27 -18
- package/dist/chunk-2F6T3BVO.js.map +1 -0
- package/dist/index.cjs +25 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/systems/index.cjs +25 -16
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +3 -2
- package/dist/systems/index.d.ts +3 -2
- package/dist/systems/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NRSUYDBA.js.map +0 -1
|
@@ -2368,8 +2368,9 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2368
2368
|
constructor() {
|
|
2369
2369
|
/** Signature tracking for geometry + instance count changes. */
|
|
2370
2370
|
this.geometrySignatures = /* @__PURE__ */ new Map();
|
|
2371
|
-
/**
|
|
2372
|
-
|
|
2371
|
+
/** Signature being loaded per entity. Maps entityId → geometrySignature in-flight.
|
|
2372
|
+
* Prevents re-dispatching a load every frame while comp.instancedMesh is still null. */
|
|
2373
|
+
this.loadingSignatures = /* @__PURE__ */ new Map();
|
|
2373
2374
|
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
2374
2375
|
this.modelMeshEntries = /* @__PURE__ */ new Map();
|
|
2375
2376
|
}
|
|
@@ -2379,8 +2380,8 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2379
2380
|
for (const trackedId of this.geometrySignatures.keys()) {
|
|
2380
2381
|
if (!alive.has(trackedId)) this.geometrySignatures.delete(trackedId);
|
|
2381
2382
|
}
|
|
2382
|
-
for (const trackedId of this.
|
|
2383
|
-
if (!alive.has(trackedId)) this.
|
|
2383
|
+
for (const trackedId of this.loadingSignatures.keys()) {
|
|
2384
|
+
if (!alive.has(trackedId)) this.loadingSignatures.delete(trackedId);
|
|
2384
2385
|
}
|
|
2385
2386
|
for (const trackedId of this.modelMeshEntries.keys()) {
|
|
2386
2387
|
if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
|
|
@@ -2396,7 +2397,8 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2396
2397
|
if (!anchor) continue;
|
|
2397
2398
|
const instanceCount = comp.instances.length;
|
|
2398
2399
|
const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
2399
|
-
const
|
|
2400
|
+
const pendingLoadSignature = this.loadingSignatures.get(entityId);
|
|
2401
|
+
const needsRebuild = (comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature) && pendingLoadSignature !== geometrySignature;
|
|
2400
2402
|
if (needsRebuild) {
|
|
2401
2403
|
if (comp.instancedMesh) {
|
|
2402
2404
|
anchor.remove(comp.instancedMesh);
|
|
@@ -2407,16 +2409,18 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2407
2409
|
}
|
|
2408
2410
|
comp.instancedMesh = null;
|
|
2409
2411
|
}
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
+
if (pendingLoadSignature !== void 0 && pendingLoadSignature !== geometrySignature) {
|
|
2413
|
+
this.loadingSignatures.delete(entityId);
|
|
2414
|
+
this.modelMeshEntries.delete(entityId);
|
|
2415
|
+
}
|
|
2412
2416
|
if (comp.meshKind === "model") {
|
|
2413
|
-
if (comp.modelPath && !this.
|
|
2414
|
-
this.
|
|
2417
|
+
if (comp.modelPath && !this.loadingSignatures.has(entityId)) {
|
|
2418
|
+
this.loadingSignatures.set(entityId, geometrySignature);
|
|
2415
2419
|
const targetSignature = geometrySignature;
|
|
2416
2420
|
const targetEntityId = entityId;
|
|
2417
2421
|
loadGLTF(comp.modelPath).then((gltf) => {
|
|
2418
2422
|
if (!world.hasEntity(targetEntityId)) {
|
|
2419
|
-
this.
|
|
2423
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2420
2424
|
return;
|
|
2421
2425
|
}
|
|
2422
2426
|
const currentComp = world.getComponent(
|
|
@@ -2424,20 +2428,25 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2424
2428
|
InstancedMeshComponent
|
|
2425
2429
|
);
|
|
2426
2430
|
if (!currentComp) {
|
|
2427
|
-
this.
|
|
2431
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2428
2432
|
return;
|
|
2429
2433
|
}
|
|
2430
2434
|
const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
|
|
2431
2435
|
if (currentSig !== targetSignature) {
|
|
2432
|
-
this.
|
|
2436
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2433
2437
|
return;
|
|
2434
2438
|
}
|
|
2435
2439
|
const currentRef = world.getComponent(targetEntityId, Object3DRef);
|
|
2436
2440
|
const currentAnchor = currentRef?.object ?? null;
|
|
2437
2441
|
if (!currentAnchor) {
|
|
2438
|
-
this.
|
|
2442
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2439
2443
|
return;
|
|
2440
2444
|
}
|
|
2445
|
+
if (currentComp.instancedMesh) {
|
|
2446
|
+
currentAnchor.remove(currentComp.instancedMesh);
|
|
2447
|
+
disposeModelGroup(currentComp.instancedMesh);
|
|
2448
|
+
currentComp.instancedMesh = null;
|
|
2449
|
+
}
|
|
2441
2450
|
const count2 = Math.max(1, currentComp.instances.length);
|
|
2442
2451
|
const entries = [];
|
|
2443
2452
|
gltf.scene.updateWorldMatrix(true, true);
|
|
@@ -2469,7 +2478,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2469
2478
|
entries.push({ localMatrix, instancedMesh: instancedMesh2 });
|
|
2470
2479
|
});
|
|
2471
2480
|
if (entries.length === 0) {
|
|
2472
|
-
this.
|
|
2481
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2473
2482
|
return;
|
|
2474
2483
|
}
|
|
2475
2484
|
const group = new THREE7.Group();
|
|
@@ -2480,9 +2489,9 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
2480
2489
|
currentComp.instancedMesh = group;
|
|
2481
2490
|
this.modelMeshEntries.set(targetEntityId, entries);
|
|
2482
2491
|
this.geometrySignatures.set(targetEntityId, targetSignature);
|
|
2483
|
-
this.
|
|
2492
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2484
2493
|
}).catch(() => {
|
|
2485
|
-
this.
|
|
2494
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
2486
2495
|
});
|
|
2487
2496
|
}
|
|
2488
2497
|
continue;
|
|
@@ -3570,5 +3579,5 @@ __name(_VideoSystem, "VideoSystem");
|
|
|
3570
3579
|
var VideoSystem = _VideoSystem;
|
|
3571
3580
|
|
|
3572
3581
|
export { AnimationSystem, AudioSystem, Behaviour, CameraSyncSystem, EnvironmentSyncSystem, InputSystem, InstancedMeshSystem, KeyboardKeys, LightSyncSystem, MaterialSyncSystem, MeshGeometrySystem, ObjectVisibilitySystem, PhysicsSyncSystem, PostprocessingSyncSystem, RenderSystem, ScriptBehaviourSystem, TransformSyncSystem, VideoSystem };
|
|
3573
|
-
//# sourceMappingURL=chunk-
|
|
3574
|
-
//# sourceMappingURL=chunk-
|
|
3582
|
+
//# sourceMappingURL=chunk-2F6T3BVO.js.map
|
|
3583
|
+
//# sourceMappingURL=chunk-2F6T3BVO.js.map
|