@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
package/dist/index.cjs
CHANGED
|
@@ -6018,8 +6018,9 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6018
6018
|
constructor() {
|
|
6019
6019
|
/** Signature tracking for geometry + instance count changes. */
|
|
6020
6020
|
this.geometrySignatures = /* @__PURE__ */ new Map();
|
|
6021
|
-
/**
|
|
6022
|
-
|
|
6021
|
+
/** Signature being loaded per entity. Maps entityId → geometrySignature in-flight.
|
|
6022
|
+
* Prevents re-dispatching a load every frame while comp.instancedMesh is still null. */
|
|
6023
|
+
this.loadingSignatures = /* @__PURE__ */ new Map();
|
|
6023
6024
|
/** Per-mesh data for model kind, populated after GLTF load. */
|
|
6024
6025
|
this.modelMeshEntries = /* @__PURE__ */ new Map();
|
|
6025
6026
|
}
|
|
@@ -6029,8 +6030,8 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6029
6030
|
for (const trackedId of this.geometrySignatures.keys()) {
|
|
6030
6031
|
if (!alive.has(trackedId)) this.geometrySignatures.delete(trackedId);
|
|
6031
6032
|
}
|
|
6032
|
-
for (const trackedId of this.
|
|
6033
|
-
if (!alive.has(trackedId)) this.
|
|
6033
|
+
for (const trackedId of this.loadingSignatures.keys()) {
|
|
6034
|
+
if (!alive.has(trackedId)) this.loadingSignatures.delete(trackedId);
|
|
6034
6035
|
}
|
|
6035
6036
|
for (const trackedId of this.modelMeshEntries.keys()) {
|
|
6036
6037
|
if (!alive.has(trackedId)) this.modelMeshEntries.delete(trackedId);
|
|
@@ -6046,7 +6047,8 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6046
6047
|
if (!anchor) continue;
|
|
6047
6048
|
const instanceCount = comp.instances.length;
|
|
6048
6049
|
const geometrySignature = comp.meshKind === "model" ? `model:${comp.modelPath}:${instanceCount}` : `${comp.meshKind}:${JSON.stringify(comp.meshParameters)}:${instanceCount}`;
|
|
6049
|
-
const
|
|
6050
|
+
const pendingLoadSignature = this.loadingSignatures.get(entityId);
|
|
6051
|
+
const needsRebuild = (comp.instancedMesh === null || this.geometrySignatures.get(entityId) !== geometrySignature) && pendingLoadSignature !== geometrySignature;
|
|
6050
6052
|
if (needsRebuild) {
|
|
6051
6053
|
if (comp.instancedMesh) {
|
|
6052
6054
|
anchor.remove(comp.instancedMesh);
|
|
@@ -6057,16 +6059,18 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6057
6059
|
}
|
|
6058
6060
|
comp.instancedMesh = null;
|
|
6059
6061
|
}
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
+
if (pendingLoadSignature !== void 0 && pendingLoadSignature !== geometrySignature) {
|
|
6063
|
+
this.loadingSignatures.delete(entityId);
|
|
6064
|
+
this.modelMeshEntries.delete(entityId);
|
|
6065
|
+
}
|
|
6062
6066
|
if (comp.meshKind === "model") {
|
|
6063
|
-
if (comp.modelPath && !this.
|
|
6064
|
-
this.
|
|
6067
|
+
if (comp.modelPath && !this.loadingSignatures.has(entityId)) {
|
|
6068
|
+
this.loadingSignatures.set(entityId, geometrySignature);
|
|
6065
6069
|
const targetSignature = geometrySignature;
|
|
6066
6070
|
const targetEntityId = entityId;
|
|
6067
6071
|
loadGLTF(comp.modelPath).then((gltf) => {
|
|
6068
6072
|
if (!world.hasEntity(targetEntityId)) {
|
|
6069
|
-
this.
|
|
6073
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6070
6074
|
return;
|
|
6071
6075
|
}
|
|
6072
6076
|
const currentComp = world.getComponent(
|
|
@@ -6074,20 +6078,25 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6074
6078
|
InstancedMeshComponent
|
|
6075
6079
|
);
|
|
6076
6080
|
if (!currentComp) {
|
|
6077
|
-
this.
|
|
6081
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6078
6082
|
return;
|
|
6079
6083
|
}
|
|
6080
6084
|
const currentSig = `model:${currentComp.modelPath}:${currentComp.instances.length}`;
|
|
6081
6085
|
if (currentSig !== targetSignature) {
|
|
6082
|
-
this.
|
|
6086
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6083
6087
|
return;
|
|
6084
6088
|
}
|
|
6085
6089
|
const currentRef = world.getComponent(targetEntityId, Object3DRef);
|
|
6086
6090
|
const currentAnchor = currentRef?.object ?? null;
|
|
6087
6091
|
if (!currentAnchor) {
|
|
6088
|
-
this.
|
|
6092
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6089
6093
|
return;
|
|
6090
6094
|
}
|
|
6095
|
+
if (currentComp.instancedMesh) {
|
|
6096
|
+
currentAnchor.remove(currentComp.instancedMesh);
|
|
6097
|
+
disposeModelGroup(currentComp.instancedMesh);
|
|
6098
|
+
currentComp.instancedMesh = null;
|
|
6099
|
+
}
|
|
6091
6100
|
const count2 = Math.max(1, currentComp.instances.length);
|
|
6092
6101
|
const entries = [];
|
|
6093
6102
|
gltf.scene.updateWorldMatrix(true, true);
|
|
@@ -6119,7 +6128,7 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6119
6128
|
entries.push({ localMatrix, instancedMesh: instancedMesh2 });
|
|
6120
6129
|
});
|
|
6121
6130
|
if (entries.length === 0) {
|
|
6122
|
-
this.
|
|
6131
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6123
6132
|
return;
|
|
6124
6133
|
}
|
|
6125
6134
|
const group = new THREE34__namespace.Group();
|
|
@@ -6130,9 +6139,9 @@ var _InstancedMeshSystem = class _InstancedMeshSystem {
|
|
|
6130
6139
|
currentComp.instancedMesh = group;
|
|
6131
6140
|
this.modelMeshEntries.set(targetEntityId, entries);
|
|
6132
6141
|
this.geometrySignatures.set(targetEntityId, targetSignature);
|
|
6133
|
-
this.
|
|
6142
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6134
6143
|
}).catch(() => {
|
|
6135
|
-
this.
|
|
6144
|
+
this.loadingSignatures.delete(targetEntityId);
|
|
6136
6145
|
});
|
|
6137
6146
|
}
|
|
6138
6147
|
continue;
|