u-space 0.0.31 → 0.0.33
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/index.cjs +3 -3
- package/dist/index.js +1174 -938
- package/dist/modelDecodeProtocol-CC2tkS8h.js +405 -0
- package/dist/modelDecodeProtocol-pgjndTph.cjs +1 -0
- package/dist/plugins/u-manager/index.cjs +1 -1
- package/dist/plugins/u-manager/index.js +73 -53
- package/dist/src/loaders/ModelLoaderManager.d.ts +13 -1
- package/dist/src/loaders/modelPersistentCache.d.ts +35 -0
- package/dist/src/objects/Model.d.ts +4 -0
- package/dist/src/worker/decodeGltfModel.d.ts +7 -1
- package/dist/src/worker/modelDecodeProtocol.d.ts +2 -0
- package/dist/worker/model-decoder.cjs +1 -1
- package/dist/worker/model-decoder.js +231 -205
- package/docs/api-effects.md +66 -2
- package/docs/api-objects.md +11 -2
- package/docs/changelog.md +18 -0
- package/docs/examples-guide.md +24 -10
- package/docs/getting-started.md +97 -93
- package/docs/index.md +1 -1
- package/docs/mcp.md +13 -2
- package/package.json +1 -1
- package/dist/modelDecodeProtocol-D1Apm9iG.cjs +0 -1
- package/dist/modelDecodeProtocol-wDB7ksYw.js +0 -56
|
@@ -20670,7 +20670,7 @@ class Watermarker extends Scene {
|
|
|
20670
20670
|
return this.mesh.material.map ? Promise.resolve(this.mesh.material.map) : (this.#r ??= TextureLoaderManager.loadAsyncTexture(logo).then((e) => (e.colorSpace = SRGBColorSpace, e)), this.#r);
|
|
20671
20671
|
}
|
|
20672
20672
|
}
|
|
20673
|
-
const _m4 = new Matrix4(), SEMANTIC_ID_KEYS = [
|
|
20673
|
+
const _m4 = new Matrix4(), MAX_CONCURRENT_MODEL_LOADS = 1, SEMANTIC_ID_KEYS = [
|
|
20674
20674
|
"Buildings",
|
|
20675
20675
|
"Stories",
|
|
20676
20676
|
"Walls",
|
|
@@ -20743,7 +20743,7 @@ class SceneParser {
|
|
|
20743
20743
|
}
|
|
20744
20744
|
await Promise.all(t.children.map((o) => l(o, u ?? h)));
|
|
20745
20745
|
};
|
|
20746
|
-
return await Promise.all(e.map((t) => l(t, a))), await this.#
|
|
20746
|
+
return await Promise.all(e.map((t) => l(t, a))), await this.#n(a), a;
|
|
20747
20747
|
}
|
|
20748
20748
|
#r(e) {
|
|
20749
20749
|
const n = new BaseGroup();
|
|
@@ -20790,7 +20790,7 @@ class SceneParser {
|
|
|
20790
20790
|
instances: []
|
|
20791
20791
|
}, this.#e.set(e, n)), n;
|
|
20792
20792
|
}
|
|
20793
|
-
async #
|
|
20793
|
+
async #n(e) {
|
|
20794
20794
|
if (this.#e.size === 0) return;
|
|
20795
20795
|
if (this.editableBatchOptions) {
|
|
20796
20796
|
const a = new SceneEditableBatchLayer(this.editableBatchOptions);
|
|
@@ -20852,9 +20852,11 @@ class SceneLoader extends Loader {
|
|
|
20852
20852
|
editableBatchOptions = null;
|
|
20853
20853
|
_resourceData = null;
|
|
20854
20854
|
_treeData = [];
|
|
20855
|
-
#e;
|
|
20855
|
+
#e = 0;
|
|
20856
|
+
#r = [];
|
|
20857
|
+
#t;
|
|
20856
20858
|
constructor(e) {
|
|
20857
|
-
super(), this.viewer = e, this.#
|
|
20859
|
+
super(), this.viewer = e, this.#t = new Watermarker(e), this.manager = new LoadingManager();
|
|
20858
20860
|
}
|
|
20859
20861
|
setKey(e) {
|
|
20860
20862
|
return this.key = e, this;
|
|
@@ -20867,19 +20869,37 @@ class SceneLoader extends Loader {
|
|
|
20867
20869
|
setEditableBatching(e = !0) {
|
|
20868
20870
|
return this.editableBatchOptions = e === !1 ? null : e === !0 ? {} : e, this;
|
|
20869
20871
|
}
|
|
20872
|
+
async #n() {
|
|
20873
|
+
if (this.#e < MAX_CONCURRENT_MODEL_LOADS) {
|
|
20874
|
+
this.#e++;
|
|
20875
|
+
return;
|
|
20876
|
+
}
|
|
20877
|
+
await new Promise((e) => {
|
|
20878
|
+
this.#r.push(e);
|
|
20879
|
+
});
|
|
20880
|
+
}
|
|
20881
|
+
#i() {
|
|
20882
|
+
const e = this.#r.shift();
|
|
20883
|
+
e ? e() : this.#e--;
|
|
20884
|
+
}
|
|
20870
20885
|
async loadModel(e) {
|
|
20871
|
-
|
|
20872
|
-
this.manager.itemStart(e);
|
|
20886
|
+
await this.#n();
|
|
20873
20887
|
try {
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20888
|
+
const n = new Model();
|
|
20889
|
+
this.manager.itemStart(e);
|
|
20890
|
+
try {
|
|
20891
|
+
await n.loadAsync({
|
|
20892
|
+
url: e
|
|
20893
|
+
});
|
|
20894
|
+
} catch (a) {
|
|
20895
|
+
throw this.manager.itemError(e), a;
|
|
20896
|
+
} finally {
|
|
20897
|
+
this.manager.itemEnd(e);
|
|
20898
|
+
}
|
|
20899
|
+
return n;
|
|
20879
20900
|
} finally {
|
|
20880
|
-
this
|
|
20901
|
+
this.#i();
|
|
20881
20902
|
}
|
|
20882
|
-
return n;
|
|
20883
20903
|
}
|
|
20884
20904
|
async _preareTreeData() {
|
|
20885
20905
|
if (!this.path)
|
|
@@ -20894,7 +20914,7 @@ class SceneLoader extends Loader {
|
|
|
20894
20914
|
if (this._resourceData = a, l)
|
|
20895
20915
|
if (n.encryptWith === "DEBUG")
|
|
20896
20916
|
try {
|
|
20897
|
-
this._treeData = decryptWithDebugKey(a), this.#
|
|
20917
|
+
this._treeData = decryptWithDebugKey(a), this.#t.enable();
|
|
20898
20918
|
} catch {
|
|
20899
20919
|
throw new Error("u-space SceneLoader: decrypt with debug key failed");
|
|
20900
20920
|
}
|
|
@@ -20948,7 +20968,7 @@ class SceneLoader extends Loader {
|
|
|
20948
20968
|
}), this.cachedIds.clear();
|
|
20949
20969
|
}
|
|
20950
20970
|
dispose() {
|
|
20951
|
-
this.clearCache(), this.#
|
|
20971
|
+
this.clearCache(), this.#t.dispose();
|
|
20952
20972
|
}
|
|
20953
20973
|
}
|
|
20954
20974
|
class VerticalShaftMeshError extends Error {
|
|
@@ -21183,12 +21203,12 @@ class FloorSemanticInstanceObject extends InstanceObject {
|
|
|
21183
21203
|
return this.#t = !0, super.setInstanceHighlight(e, l, a), this.floorMesh.setColorAt(this.semanticIndex, new Color(e)), this.floorMesh.setOpacityAt(this.semanticIndex, l), this;
|
|
21184
21204
|
}
|
|
21185
21205
|
clearInstanceHighlight() {
|
|
21186
|
-
return this.#t ? (this.#t = !1, super.clearInstanceHighlight(), this.#
|
|
21206
|
+
return this.#t ? (this.#t = !1, super.clearInstanceHighlight(), this.#n(), this) : this;
|
|
21187
21207
|
}
|
|
21188
21208
|
getInstanceBoundingBox(e = new Box3(), n = !1) {
|
|
21189
21209
|
return this.floorMesh.getBoundingBoxAt(this.semanticIndex, e, n) ?? e.makeEmpty();
|
|
21190
21210
|
}
|
|
21191
|
-
#
|
|
21211
|
+
#n() {
|
|
21192
21212
|
this.#e ? this.floorMesh.setColorAt(this.semanticIndex, this.#e) : this.floorMesh.resetColorAt(this.semanticIndex), this.floorMesh.setOpacityAt(this.semanticIndex, this.#r);
|
|
21193
21213
|
}
|
|
21194
21214
|
}
|
|
@@ -21215,7 +21235,7 @@ class FloorMesh extends BaseMesh {
|
|
|
21215
21235
|
#e;
|
|
21216
21236
|
#r;
|
|
21217
21237
|
#t = [];
|
|
21218
|
-
#
|
|
21238
|
+
#n;
|
|
21219
21239
|
#i;
|
|
21220
21240
|
#o;
|
|
21221
21241
|
#s;
|
|
@@ -21232,7 +21252,7 @@ class FloorMesh extends BaseMesh {
|
|
|
21232
21252
|
Doors: this.doorsInstances,
|
|
21233
21253
|
Windows: this.windowsInstances,
|
|
21234
21254
|
Staircases: this.staircasesInstances
|
|
21235
|
-
}, this.#
|
|
21255
|
+
}, this.#n = h, this.#i = u, this.#o = o, this.#s = s, this.#u = new Mesh(), this.#u.matrixAutoUpdate = !1, this.frustumCulled = !1, this.#r.forEach((c) => {
|
|
21236
21256
|
const d = new FloorSemanticInstanceObject(this, c.index);
|
|
21237
21257
|
d.name = c.name || c.id, d.visible = c.visible, d.setInstanceIdentity({
|
|
21238
21258
|
id: c.id,
|
|
@@ -21276,13 +21296,13 @@ class FloorMesh extends BaseMesh {
|
|
|
21276
21296
|
return this.getSemantics().filter((n) => n.kind === e);
|
|
21277
21297
|
}
|
|
21278
21298
|
getSemanticIdAt(e) {
|
|
21279
|
-
return this.#
|
|
21299
|
+
return this.#a(e).id;
|
|
21280
21300
|
}
|
|
21281
21301
|
getSemanticKindAt(e) {
|
|
21282
|
-
return this.#
|
|
21302
|
+
return this.#a(e).kind;
|
|
21283
21303
|
}
|
|
21284
21304
|
getSemanticNameAt(e) {
|
|
21285
|
-
return this.#
|
|
21305
|
+
return this.#a(e).name;
|
|
21286
21306
|
}
|
|
21287
21307
|
getSemanticObjectAt(e) {
|
|
21288
21308
|
return this.#t[e];
|
|
@@ -21337,33 +21357,33 @@ class FloorMesh extends BaseMesh {
|
|
|
21337
21357
|
return typeof e == "string" ? this.getFacilityById(e) : e;
|
|
21338
21358
|
}
|
|
21339
21359
|
setColorAt(e, n) {
|
|
21340
|
-
const a = this.#
|
|
21360
|
+
const a = this.#a(e);
|
|
21341
21361
|
return copySemanticColor(n, a.color), this.#d(e), this.#l(), this;
|
|
21342
21362
|
}
|
|
21343
21363
|
resetColorAt(e) {
|
|
21344
|
-
const n = this.#
|
|
21364
|
+
const n = this.#a(e), a = n.color.w;
|
|
21345
21365
|
return n.color.copy(n.initialColor), n.color.w = a, this.#d(e), this.#l(), this;
|
|
21346
21366
|
}
|
|
21347
21367
|
getColorAt(e, n = new Vector4()) {
|
|
21348
|
-
const a = this.#
|
|
21368
|
+
const a = this.#a(e).color;
|
|
21349
21369
|
return n.copy(a), n;
|
|
21350
21370
|
}
|
|
21351
21371
|
setOpacityAt(e, n) {
|
|
21352
|
-
const a = this.#
|
|
21372
|
+
const a = this.#a(e);
|
|
21353
21373
|
return a.color.w = Math.max(0, Math.min(1, n)), this.#d(e), this.#l(), this;
|
|
21354
21374
|
}
|
|
21355
21375
|
getOpacityAt(e) {
|
|
21356
|
-
return this.#
|
|
21376
|
+
return this.#a(e).color.w;
|
|
21357
21377
|
}
|
|
21358
21378
|
setVisibleAt(e, n) {
|
|
21359
|
-
const a = this.#
|
|
21379
|
+
const a = this.#a(e);
|
|
21360
21380
|
return a.visible = n, this.#g(e), this;
|
|
21361
21381
|
}
|
|
21362
21382
|
getVisibleAt(e) {
|
|
21363
|
-
return this.#
|
|
21383
|
+
return this.#a(e).visible;
|
|
21364
21384
|
}
|
|
21365
21385
|
setMatrixAt(e, n) {
|
|
21366
|
-
const a = this.#
|
|
21386
|
+
const a = this.#a(e);
|
|
21367
21387
|
return a.matrix.copy(n), a.finalMatrix.multiplyMatrices(a.baseMatrix, a.matrix), this.#y(e), this.#p(e), this;
|
|
21368
21388
|
}
|
|
21369
21389
|
setScaleAt(e, n, a, l) {
|
|
@@ -21377,10 +21397,10 @@ class FloorMesh extends BaseMesh {
|
|
|
21377
21397
|
});
|
|
21378
21398
|
}
|
|
21379
21399
|
getMatrixAt(e, n = new Matrix4()) {
|
|
21380
|
-
return n.copy(this.#
|
|
21400
|
+
return n.copy(this.#a(e).matrix), n;
|
|
21381
21401
|
}
|
|
21382
21402
|
getFinalMatrixAt(e, n = new Matrix4()) {
|
|
21383
|
-
return n.copy(this.#
|
|
21403
|
+
return n.copy(this.#a(e).finalMatrix), n;
|
|
21384
21404
|
}
|
|
21385
21405
|
computeBoundingBox() {
|
|
21386
21406
|
this.boundingBox === null && (this.boundingBox = new Box3()), this.boundingBox.makeEmpty();
|
|
@@ -21393,11 +21413,11 @@ class FloorMesh extends BaseMesh {
|
|
|
21393
21413
|
this.getBoundingSphereAt(e.index, _boundsSphere, !1) && this.boundingSphere.union(_boundsSphere);
|
|
21394
21414
|
}
|
|
21395
21415
|
getBoundingBoxAt(e, n = new Box3(), a = !0) {
|
|
21396
|
-
const l = this.#
|
|
21416
|
+
const l = this.#a(e);
|
|
21397
21417
|
return l.geometry.boundingBox || l.geometry.computeBoundingBox(), l.geometry.boundingBox ? (n.copy(l.geometry.boundingBox).applyMatrix4(l.finalMatrix), a && (this.updateWorldMatrix(!0, !1), n.applyMatrix4(this.matrixWorld)), n) : null;
|
|
21398
21418
|
}
|
|
21399
21419
|
getBoundingSphereAt(e, n = new Sphere(), a = !0) {
|
|
21400
|
-
const l = this.#
|
|
21420
|
+
const l = this.#a(e);
|
|
21401
21421
|
return l.geometry.boundingSphere || l.geometry.computeBoundingSphere(), l.geometry.boundingSphere ? (n.copy(l.geometry.boundingSphere), a ? (this.updateWorldMatrix(!0, !1), _boundsMatrix.multiplyMatrices(this.matrixWorld, l.finalMatrix), n.applyMatrix4(_boundsMatrix)) : n.applyMatrix4(l.finalMatrix), n) : null;
|
|
21402
21422
|
}
|
|
21403
21423
|
raycast(e, n) {
|
|
@@ -21414,7 +21434,7 @@ class FloorMesh extends BaseMesh {
|
|
|
21414
21434
|
}
|
|
21415
21435
|
}
|
|
21416
21436
|
dispose() {
|
|
21417
|
-
this.geometry.dispose(), Array.isArray(this.material) ? this.material.forEach((e) => e.dispose()) : this.material.dispose(), this.#
|
|
21437
|
+
this.geometry.dispose(), Array.isArray(this.material) ? this.material.forEach((e) => e.dispose()) : this.material.dispose(), this.#n.dispose(), this.#i.dispose(), this.#o.dispose(), this.#s.dispose(), this.#r.forEach((e) => e.geometry.dispose());
|
|
21418
21438
|
}
|
|
21419
21439
|
#v(e) {
|
|
21420
21440
|
for (const [n, a] of this.facilityObjectsById)
|
|
@@ -21440,7 +21460,7 @@ class FloorMesh extends BaseMesh {
|
|
|
21440
21460
|
const { facility: n } = e.userData;
|
|
21441
21461
|
return e.instanceName ? e.instanceName : n && typeof n.Name == "string" && n.Name ? n.Name : e.name || void 0;
|
|
21442
21462
|
}
|
|
21443
|
-
#
|
|
21463
|
+
#a(e) {
|
|
21444
21464
|
const n = this.#r[e];
|
|
21445
21465
|
if (!n)
|
|
21446
21466
|
throw new Error(`u-space FloorMesh: invalid semantic index ${e}.`);
|
|
@@ -21483,7 +21503,7 @@ class FloorMesh extends BaseMesh {
|
|
|
21483
21503
|
n(a);
|
|
21484
21504
|
}
|
|
21485
21505
|
#B(e) {
|
|
21486
|
-
const n = this.#
|
|
21506
|
+
const n = this.#a(e), a = this.#f.get(e) ?? n.matrix;
|
|
21487
21507
|
this.#f.has(e) || this.#f.set(e, n.matrix.clone()), a.decompose(_dummyPosition, _dummyQuaternion, _dummyScale), _dummyScale.y *= PLANISH_SCALE_Y, n.matrix.compose(_dummyPosition, _dummyQuaternion, _dummyScale), n.finalMatrix.multiplyMatrices(n.baseMatrix, n.matrix), n.geometry.boundingBox || n.geometry.computeBoundingBox(), n.geometry.boundingBox && (_box.copy(n.geometry.boundingBox).applyMatrix4(n.finalMatrix), _dummyPosition.y += this.pivot.y + getSemanticPlanishOffset(n) - _box.min.y, n.matrix.compose(_dummyPosition, _dummyQuaternion, _dummyScale), n.finalMatrix.multiplyMatrices(n.baseMatrix, n.matrix)), this.#y(e), this.#p(e);
|
|
21488
21508
|
}
|
|
21489
21509
|
#A(e) {
|
|
@@ -21516,21 +21536,21 @@ class FloorMesh extends BaseMesh {
|
|
|
21516
21536
|
}), n.isEmpty() ? null : n;
|
|
21517
21537
|
}
|
|
21518
21538
|
#m(e, n) {
|
|
21519
|
-
const a = this.#
|
|
21539
|
+
const a = this.#a(e);
|
|
21520
21540
|
return a.matrix.decompose(_dummyPosition, _dummyQuaternion, _dummyScale), n(_dummyScale), a.matrix.compose(_dummyPosition, _dummyQuaternion, _dummyScale), a.finalMatrix.multiplyMatrices(a.baseMatrix, a.matrix), this.#y(e), this.#p(e), this;
|
|
21521
21541
|
}
|
|
21522
21542
|
#d(e) {
|
|
21523
|
-
this.#
|
|
21543
|
+
this.#a(e).color.toArray(this.#n.image.data, e * 4), this.#n.needsUpdate = !0;
|
|
21524
21544
|
}
|
|
21525
21545
|
#g(e) {
|
|
21526
|
-
const n = this.#
|
|
21546
|
+
const n = this.#a(e), a = this.#i.image.data;
|
|
21527
21547
|
a[e * 4] = n.visible ? 1 : 0, a[e * 4 + 1] = 0, a[e * 4 + 2] = 0, a[e * 4 + 3] = 1, this.#i.needsUpdate = !0;
|
|
21528
21548
|
}
|
|
21529
21549
|
#p(e) {
|
|
21530
|
-
this.#
|
|
21550
|
+
this.#a(e).finalMatrix.toArray(this.#o.image.data, e * 16), this.#o.needsUpdate = !0;
|
|
21531
21551
|
}
|
|
21532
21552
|
#I(e) {
|
|
21533
|
-
const n = this.#
|
|
21553
|
+
const n = this.#a(e), a = this.#s.image.data;
|
|
21534
21554
|
a[e * 4] = getSemanticRenderOffset(n), a[e * 4 + 1] = 0, a[e * 4 + 2] = 0, a[e * 4 + 3] = 1, this.#s.needsUpdate = !0;
|
|
21535
21555
|
}
|
|
21536
21556
|
}
|
|
@@ -21582,7 +21602,7 @@ class BuildingGroup extends BaseGroup {
|
|
|
21582
21602
|
#e = /* @__PURE__ */ new Set();
|
|
21583
21603
|
#r = /* @__PURE__ */ new Map();
|
|
21584
21604
|
#t = /* @__PURE__ */ new Map();
|
|
21585
|
-
#
|
|
21605
|
+
#n = /* @__PURE__ */ new Map();
|
|
21586
21606
|
#i = /* @__PURE__ */ new Map();
|
|
21587
21607
|
#o = /* @__PURE__ */ new Map();
|
|
21588
21608
|
#s = /* @__PURE__ */ new Map();
|
|
@@ -21624,17 +21644,17 @@ class BuildingGroup extends BaseGroup {
|
|
|
21624
21644
|
return n !== -1 && this.elevatorMeshes.splice(n, 1), rebuildObjectIndex(this.#t, this.elevatorMeshes), this.remove(e), this;
|
|
21625
21645
|
}
|
|
21626
21646
|
addVent(e) {
|
|
21627
|
-
return this.ventMeshes.includes(e) || (this.add(e), this.ventMeshes.push(e), indexObject(this.#
|
|
21647
|
+
return this.ventMeshes.includes(e) || (this.add(e), this.ventMeshes.push(e), indexObject(this.#n, e)), this;
|
|
21628
21648
|
}
|
|
21629
21649
|
getVentAt(e) {
|
|
21630
21650
|
return this.ventMeshes[e];
|
|
21631
21651
|
}
|
|
21632
21652
|
getVentById(e) {
|
|
21633
|
-
return this.#
|
|
21653
|
+
return this.#n.get(e);
|
|
21634
21654
|
}
|
|
21635
21655
|
removeVent(e) {
|
|
21636
21656
|
const n = this.ventMeshes.indexOf(e);
|
|
21637
|
-
return n !== -1 && this.ventMeshes.splice(n, 1), rebuildObjectIndex(this.#
|
|
21657
|
+
return n !== -1 && this.ventMeshes.splice(n, 1), rebuildObjectIndex(this.#n, this.ventMeshes), this.remove(e), this;
|
|
21638
21658
|
}
|
|
21639
21659
|
isolateFloor(e) {
|
|
21640
21660
|
return this.isolateFloors(getFloorReferences(e));
|
|
@@ -21703,7 +21723,7 @@ class SemanticGroup extends BaseGroup {
|
|
|
21703
21723
|
#e = /* @__PURE__ */ new Set();
|
|
21704
21724
|
#r = /* @__PURE__ */ new Map();
|
|
21705
21725
|
#t = /* @__PURE__ */ new Map();
|
|
21706
|
-
#
|
|
21726
|
+
#n = /* @__PURE__ */ new Map();
|
|
21707
21727
|
#i = /* @__PURE__ */ new Map();
|
|
21708
21728
|
#o = !0;
|
|
21709
21729
|
constructor() {
|
|
@@ -21766,12 +21786,12 @@ class SemanticGroup extends BaseGroup {
|
|
|
21766
21786
|
let e = this.#o || this.#i.size !== this.buildings.length;
|
|
21767
21787
|
for (const n of this.buildings)
|
|
21768
21788
|
n.syncFacilityIndexes(), this.#i.get(n) !== n.facilityIndexVersion && (e = !0);
|
|
21769
|
-
e && (this.#t.clear(), this.#
|
|
21789
|
+
e && (this.#t.clear(), this.#n.clear(), this.#i.clear(), this.buildings.forEach((n) => {
|
|
21770
21790
|
n.syncFacilityIndexes(), this.#i.set(n, n.facilityIndexVersion);
|
|
21771
21791
|
for (const a of n.getFacilityIndexIds())
|
|
21772
21792
|
this.#t.has(a) || this.#t.set(a, n);
|
|
21773
21793
|
for (const a of n.getFacilityIndexObjects())
|
|
21774
|
-
this.#
|
|
21794
|
+
this.#n.has(a) || this.#n.set(a, n);
|
|
21775
21795
|
}), this.#o = !1);
|
|
21776
21796
|
}
|
|
21777
21797
|
}
|
|
@@ -22247,7 +22267,7 @@ class SemanticParser {
|
|
|
22247
22267
|
h.push(...o);
|
|
22248
22268
|
continue;
|
|
22249
22269
|
}
|
|
22250
|
-
const r = o.map((d) => this.#
|
|
22270
|
+
const r = o.map((d) => this.#n(d));
|
|
22251
22271
|
l.addInstances(u, s, r) ? r.forEach((d, p) => {
|
|
22252
22272
|
const v = o[p];
|
|
22253
22273
|
this.#o(d, v.facility, a);
|
|
@@ -22257,7 +22277,7 @@ class SemanticParser {
|
|
|
22257
22277
|
}
|
|
22258
22278
|
l.children.length > 0 && n.setFacilityLayer(l), await Promise.all(h.map((u) => this.#i(u, a)));
|
|
22259
22279
|
}
|
|
22260
|
-
#
|
|
22280
|
+
#n(e) {
|
|
22261
22281
|
const { facility: n, story: a, floorMesh: l, treeNode: t, worldMatrix: h } = e, u = new FacilityInstanceObject();
|
|
22262
22282
|
return u.name = n.Name || t.name || "", u.visible = t.visible, u.setInstanceIdentity({
|
|
22263
22283
|
id: n.ID,
|
|
@@ -22277,7 +22297,7 @@ class SemanticParser {
|
|
|
22277
22297
|
async #i(e, n) {
|
|
22278
22298
|
const { facility: a, story: l, treeNode: t } = e, h = await createFacilityModel(a, t, n);
|
|
22279
22299
|
if (!h) return;
|
|
22280
|
-
const u = this.#
|
|
22300
|
+
const u = this.#n(e);
|
|
22281
22301
|
u.userData.instanced = !1, Object.assign(h.userData, {
|
|
22282
22302
|
storyId: l.ID,
|
|
22283
22303
|
floorIndex: l.FloorIndex,
|
|
@@ -7,13 +7,16 @@ import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
|
|
7
7
|
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
|
|
8
8
|
import { SBMXLoader } from './SBMXLoader';
|
|
9
9
|
import { SBMLoader } from './SBMLoader';
|
|
10
|
+
import { type ModelCacheMode } from './modelPersistentCache';
|
|
10
11
|
import type { InteractionEventMap } from '../interactions';
|
|
11
12
|
export interface LoadParameters {
|
|
12
13
|
persistent?: boolean;
|
|
14
|
+
cacheMode?: ModelCacheMode;
|
|
15
|
+
cacheKey?: string;
|
|
13
16
|
signal?: AbortSignal;
|
|
14
17
|
}
|
|
18
|
+
export type { ModelCacheMode } from './modelPersistentCache';
|
|
15
19
|
export declare class ModelLoaderManager {
|
|
16
|
-
private static CACHE_NAME;
|
|
17
20
|
static fileLoader: FileLoader<string | ArrayBuffer>;
|
|
18
21
|
static dracoLoader: DRACOLoader;
|
|
19
22
|
static ktx2Loader: KTX2Loader;
|
|
@@ -45,9 +48,18 @@ export declare class ModelLoaderManager {
|
|
|
45
48
|
* Configure KTX2 transcoder path.
|
|
46
49
|
*/
|
|
47
50
|
static setKTX2Path(path: string): void;
|
|
51
|
+
static getMemoryCacheKey(url: string, persistent: boolean, cacheMode?: ModelCacheMode, cacheKey?: string): string;
|
|
52
|
+
static clearPersistentCache(): Promise<void>;
|
|
53
|
+
static deletePersistentCache(url: string, options?: Pick<LoadParameters, 'cacheKey'>): Promise<void>;
|
|
48
54
|
static loadAsync(url: string, parameters?: LoadParameters): Promise<Object3D<InteractionEventMap>>;
|
|
55
|
+
private static loadRegularModel;
|
|
49
56
|
private static configureGltfLoader;
|
|
50
57
|
private static createParseLoadingManager;
|
|
58
|
+
private static rootResourceOptions;
|
|
59
|
+
private static cacheUseFor;
|
|
60
|
+
private static dependencyResourceOptions;
|
|
61
|
+
private static loadManagedResource;
|
|
62
|
+
private static prepareExternalGltfResources;
|
|
51
63
|
private static loadSourceBuffer;
|
|
52
64
|
private static throwIfAborted;
|
|
53
65
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const MODEL_RESOURCE_CACHE_NAME = "u-space-model-loader-cache-v2";
|
|
2
|
+
export declare const DEFAULT_MODEL_CACHE_POLICY: Readonly<{
|
|
3
|
+
maxAgeMs: number;
|
|
4
|
+
maxEntries: 64;
|
|
5
|
+
maxBytes: number;
|
|
6
|
+
}>;
|
|
7
|
+
export interface ModelCachePolicy {
|
|
8
|
+
maxAgeMs: number;
|
|
9
|
+
maxEntries: number;
|
|
10
|
+
maxBytes: number;
|
|
11
|
+
}
|
|
12
|
+
export type ModelCacheMode = 'no-store' | 'reload' | 'revalidate' | 'force-cache';
|
|
13
|
+
export interface ModelResourceLoadOptions {
|
|
14
|
+
persistent?: boolean;
|
|
15
|
+
/** Bypass, refresh, validate, or force use of the persistent resource cache. */
|
|
16
|
+
cacheMode?: ModelCacheMode;
|
|
17
|
+
/** Caller-controlled cache identity for versioned resources at one URL. */
|
|
18
|
+
cacheKey?: string;
|
|
19
|
+
headers?: HeadersInit;
|
|
20
|
+
credentials?: RequestCredentials;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
policy?: Partial<ModelCachePolicy>;
|
|
23
|
+
}
|
|
24
|
+
export interface LoadedModelResource {
|
|
25
|
+
url: string;
|
|
26
|
+
buffer: ArrayBuffer;
|
|
27
|
+
headers: Headers;
|
|
28
|
+
status: number;
|
|
29
|
+
statusText: string;
|
|
30
|
+
fromCache: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function loadModelResource(url: string, options?: ModelResourceLoadOptions): Promise<LoadedModelResource>;
|
|
33
|
+
export declare function deleteModelResourceCache(url: string, options?: Pick<ModelResourceLoadOptions, 'headers' | 'credentials' | 'cacheKey'>): Promise<void>;
|
|
34
|
+
export declare function clearModelPersistentCache(): Promise<void>;
|
|
35
|
+
export declare function modelPersistentCacheAvailable(): boolean;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type Object3D, AnimationMixer, type AnimationAction, type AnimationClip, Box3, Vector3, type Material } from 'three/webgpu';
|
|
2
|
+
import { type ModelCacheMode } from '../loaders';
|
|
2
3
|
import { type InteractionEventMap } from '../interactions';
|
|
3
4
|
import { BaseGroup } from './BaseGroup';
|
|
4
5
|
export interface ModelParameters {
|
|
5
6
|
url: string;
|
|
6
7
|
cache?: boolean;
|
|
7
8
|
persistent?: boolean;
|
|
9
|
+
cacheMode?: ModelCacheMode;
|
|
10
|
+
cacheKey?: string;
|
|
8
11
|
signal?: AbortSignal;
|
|
9
12
|
}
|
|
10
13
|
export interface PlayAnimationOptions {
|
|
@@ -14,6 +17,7 @@ export interface PlayAnimationOptions {
|
|
|
14
17
|
clampWhenFinished?: boolean;
|
|
15
18
|
}
|
|
16
19
|
export declare class Model extends BaseGroup<InteractionEventMap> {
|
|
20
|
+
private static readonly MAX_MEMORY_CACHE_ENTRIES;
|
|
17
21
|
readonly isModel = true;
|
|
18
22
|
type: string;
|
|
19
23
|
private static memoryCache;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type DecodedGltfModelPacket, type ModelDecodeRequestOptions } from './modelDecodeProtocol';
|
|
2
|
+
import { type ModelResourceLoadOptions } from '../loaders/modelPersistentCache';
|
|
2
3
|
export interface ModelDecodeResourceHandle {
|
|
3
4
|
url: string;
|
|
4
5
|
complete(error?: unknown): void;
|
|
@@ -6,5 +7,10 @@ export interface ModelDecodeResourceHandle {
|
|
|
6
7
|
export interface ModelDecodeResourceResolver {
|
|
7
8
|
resolve(url: string, signal: AbortSignal): Promise<ModelDecodeResourceHandle>;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
interface CachedResourceUse {
|
|
11
|
+
url: string;
|
|
12
|
+
options: Pick<ModelResourceLoadOptions, 'headers' | 'credentials' | 'cacheKey'>;
|
|
13
|
+
}
|
|
14
|
+
export declare function decodeGltfModelPacket(url: string, source: ArrayBuffer, options?: ModelDecodeRequestOptions, signal?: AbortSignal, resourceResolver?: ModelDecodeResourceResolver, cacheUses?: CachedResourceUse[]): Promise<DecodedGltfModelPacket>;
|
|
10
15
|
export declare function loadGltfModelPacket(url: string, options?: ModelDecodeRequestOptions, signal?: AbortSignal, resourceResolver?: ModelDecodeResourceResolver): Promise<DecodedGltfModelPacket>;
|
|
16
|
+
export {};
|
|
@@ -6,6 +6,8 @@ export interface SerializedModelDecodeError {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ModelDecodeRequestOptions {
|
|
8
8
|
persistent?: boolean;
|
|
9
|
+
cacheMode?: 'no-store' | 'reload' | 'revalidate' | 'force-cache';
|
|
10
|
+
cacheKey?: string;
|
|
9
11
|
headers?: Record<string, string>;
|
|
10
12
|
credentials?: RequestCredentials;
|
|
11
13
|
/** Original absolute model URL used to resolve relative glTF dependencies. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../getTransferables-C97JPUVf.cjs"),D=require("../workerImageUtils-lmOMyTQN.cjs"),p=require("../modelDecodeProtocol-pgjndTph.cjs"),U="SBMG----",S=1179937895,C=1313821514,R=5130562,k=new TextDecoder;function g(e){throw new p.UnsupportedModelDecodeError(e)}function L(e,t,n,s=e,a=!1){const i=e.startsWith("data:")||e.startsWith("blob:");let l=!a;if(a&&!i)try{const d=new URL(e),f=new URL(s);l=(d.protocol==="http:"||d.protocol==="https:")&&d.origin===f.origin}catch{l=!1}return i?{signal:n,persistent:!1}:{signal:n,persistent:t.persistent,cacheMode:t.cacheMode,cacheKey:t.cacheKey,headers:l?t.headers:void 0,credentials:l?t.credentials:"omit"}}async function T(e,t,n,s,a,i,l,d){const f=V(e,t),u=i?await i.resolve(f,a):{url:f,complete(){}};try{const r=L(u.url,s,a,n,!0),o=await p.loadModelResource(u.url,r);o.fromCache&&l.push({url:u.url,options:{headers:r.headers,credentials:r.credentials,cacheKey:r.cacheKey}});const c=await d(o);return u.complete(),c}catch(r){throw u.complete(r),r}}function F(e){if(e.byteLength<8||k.decode(new Uint8Array(e,0,8))!==U)return e;const n=new Uint8Array(e.byteLength-8),s=new Uint8Array(e,8);for(let a=0;a<s.length;a++){const i=s[a];n[a]=i>>4&15|i<<4&240}return n.buffer}function B(e){const t=new DataView(e);if(e.byteLength>=12&&t.getUint32(0,!0)===S){const n=t.getUint32(8,!0);if(n>e.byteLength)throw new Error(`Invalid GLB length: expected ${n}, received ${e.byteLength}.`);let s=12,a;const i=[];for(;s+8<=n;){const l=t.getUint32(s,!0),d=t.getUint32(s+4,!0);if(s+=8,s+l>n)throw new Error("Invalid GLB chunk length.");const f=e.slice(s,s+l);d===C?a=JSON.parse(k.decode(f).replace(/\u0000+$/u,"")):d===R&&i.push(f),s+=l}if(!a)throw new Error("GLB does not contain a JSON chunk.");return{document:a,binaryChunks:i}}return{document:JSON.parse(k.decode(e).replace(/^\uFEFF/u,"")),binaryChunks:[]}}function G(e){e.asset?.version?.startsWith("2")||g("Only glTF 2.x static models are supported by the decode worker."),(e.extensionsRequired?.length||e.extensionsUsed?.length)&&g("glTF extensions are not supported by the decode worker."),e.animations?.length&&g("Animated glTF models must use the regular loader."),e.skins?.length&&g("Skinned glTF models must use the regular loader."),e.cameras?.length&&g("glTF cameras must use the regular loader."),p.validateDecodedGltfNodeGraph(e);for(const t of e.accessors??[])t.sparse&&g("Sparse glTF accessors must use the regular loader."),t.bufferView===void 0&&g("Accessors without a bufferView must use the regular loader."),["SCALAR","VEC2","VEC3","VEC4"].includes(t.type)||g(`Accessor type ${t.type} must use the regular loader.`),[5120,5121,5122,5123,5125,5126].includes(t.componentType)||g(`Accessor component type ${t.componentType} must use the regular loader.`);for(const t of e.bufferViews??[])t.extensions&&Object.keys(t.extensions).length>0&&g("Compressed glTF buffer views must use the regular loader.");for(const t of e.nodes??[])(t.skin!==void 0||t.weights?.length||t.camera!==void 0)&&g("Skinned, morphed, or camera glTF nodes must use the regular loader."),t.extensions&&Object.keys(t.extensions).length>0&&g("Extended glTF nodes must use the regular loader.");for(const t of e.meshes??[])for(const n of t.primitives)(n.mode??4)!==4&&g("Only triangle glTF primitives are supported."),n.targets?.length&&g("Morph targets must use the regular loader."),n.extensions&&Object.keys(n.extensions).length>0&&g("Extended glTF primitives must use the regular loader.");for(const t of e.materials??[])t.extensions&&Object.keys(t.extensions).length>0&&g("Extended glTF materials must use the regular loader.");for(const t of e.textures??[])t.extensions&&Object.keys(t.extensions).length>0&&g("Extended glTF textures must use the regular loader.")}function V(e,t){return e.startsWith("data:")||e.startsWith("blob:")?e:new URL(e,t).href}async function _(e,t,n,s,a,i,l,d=[]){const f=[...t],u=[];for(const r of e.buffers??[]){let o;if(r.uri)o=await T(r.uri,n,s,a,i,l,d,c=>c.buffer);else{const c=f.shift();if(!c)throw new Error("glTF buffer is missing its GLB binary chunk.");o=c}if(o.byteLength<r.byteLength)throw new Error(`glTF buffer is truncated: expected ${r.byteLength}, received ${o.byteLength}.`);u.push(o),Reflect.deleteProperty(r,"uri")}return u}function I(e,t,n,s){const a=e.bufferViews?.[n];if(!a)throw new Error(`glTF image references missing bufferView ${n}.`);const i=t[a.buffer];if(!i)throw new Error(`glTF image references missing buffer ${a.buffer}.`);const l=a.byteOffset??0;return new Blob([new Uint8Array(i,l,a.byteLength)],{type:s??"application/octet-stream"})}async function N(e,t,n,s,a,i,l,d=[]){const f=[],u=[];try{for(const r of e.images??[]){let o;if(r.uri)o=await T(r.uri,n,s,a,i,l,d,w=>new Blob([w.buffer],{type:w.headers.get("content-type")??"application/octet-stream"}));else if(r.bufferView!==void 0)o=I(e,t,r.bufferView,r.mimeType);else throw new Error("glTF image is missing both uri and bufferView.");if(i.aborted)throw i.reason??new DOMException("Aborted","AbortError");const c=await globalThis.crypto.subtle.digest("SHA-256",await o.arrayBuffer());if(i.aborted)throw i.reason??new DOMException("Aborted","AbortError");const h=Array.from(new Uint8Array(c),w=>w.toString(16).padStart(2,"0")).join("");u.push(`${o.type}:${o.size}:${h}`),f.push(await D.createWorkerImageBitmap(o,{imageOrientation:"flipY"})),Reflect.deleteProperty(r,"uri")}return{images:f,imageKeys:u}}catch(r){throw f.forEach(o=>o.close()),r}}async function M(e,t,n={},s=new AbortController().signal,a,i=[]){const l=F(t),{document:d,binaryChunks:f}=B(l);G(d);const u=n.resourceBaseUrl??e,r=await _(d,f,u,e,n,s,a,i),{images:o,imageKeys:c}=await N(d,r,u,e,n,s,a,i);return{protocolVersion:p.MODEL_DECODE_PROTOCOL_VERSION,kind:"gltf-static",url:e,document:d,buffers:r,images:o,imageKeys:c}}async function P(e,t={},n=new AbortController().signal,s){const a=L(e,t,n),i=[],l=await p.loadModelResource(e,a);l.fromCache&&i.push({url:e,options:{headers:a.headers,credentials:a.credentials,cacheKey:a.cacheKey}});try{return await M(e,l.buffer,t,n,s,i)}catch(d){if(n.aborted||d instanceof p.UnsupportedModelDecodeError||i.length===0)throw d;await Promise.all(i.map(u=>p.deleteModelResourceCache(u.url,u.options)));const f=await p.loadModelResource(e,a);return M(e,f.buffer,t,n,s)}}function x(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e)}}function $(e=globalThis){const t=[],n=new Set;let s=null,a=!1,i=!1;const l=r=>new Promise(o=>{r.acknowledge=o}),d=(r,o)=>{for(const c of r.resources.values())c.cleanup(),c.reject(o);r.resources.clear()},f=r=>({async resolve(o,c){if(c.aborted)throw c.reason??new DOMException("Aborted","AbortError");const h=r.nextResourceId++,w=await new Promise((b,E)=>{const O=()=>{r.resources.delete(h),E(c.reason??new DOMException("Aborted","AbortError"))},m=()=>c.removeEventListener("abort",O);r.resources.set(h,{resolve(y){m(),r.resources.delete(h),b(y)},reject(y){m(),r.resources.delete(h),E(y)},cleanup:m}),c.addEventListener("abort",O,{once:!0});try{e.postMessage({type:"resolve-resource",id:r.id,resourceId:h,url:o})}catch(y){m(),r.resources.delete(h),E(y instanceof Error?y:new Error(String(y)))}});let v=!1;return{url:w,complete(b){v||(v=!0,e.postMessage({type:"resource-complete",id:r.id,resourceId:h,ok:b===void 0,error:b===void 0?void 0:x(b)}))}}}}),u=async()=>{if(!(a||i)){a=!0;try{for(;!i&&t.length>0;){const r=t.shift();if(n.delete(r.id))continue;const o={id:r.id,controller:new AbortController,nextResourceId:1,resources:new Map};s=o;try{const c=await P(r.url,r.options,o.controller.signal,f(o));if(n.delete(r.id)||i){c.images.forEach(h=>h.close());continue}try{e.postMessage({type:"decoded",id:r.id,packet:c},A.getTransferables(c))}catch(h){throw c.images.forEach(w=>w.close()),h}await l(o)}catch(c){const h=n.delete(r.id);if(o.controller.signal.aborted||h||i)continue;c instanceof p.UnsupportedModelDecodeError?e.postMessage({type:"unsupported",id:r.id,reason:c.message}):e.postMessage({type:"error",id:r.id,error:x(c)})}finally{d(o,new DOMException("Model decode request ended.","AbortError")),n.delete(r.id),s===o&&(s=null)}}}finally{a=!1,!i&&t.length>0&&u()}}};e.addEventListener("message",r=>{const o=r.data;if(o.type==="decode"){if(i)return;t.push(o),u();return}if(o.type==="cancel"){n.add(o.id),s?.id===o.id&&(s.controller.abort(),s.acknowledge?.());return}if(o.type==="ack"){s?.id===o.id&&s.acknowledge?.();return}if(o.type==="resource-resolved"){if(s?.id!==o.id)return;const c=s.resources.get(o.resourceId);if(!c)return;if(o.url!==void 0)c.resolve(o.url);else{const h=new Error(o.error?.message??"Failed to resolve model resource URL.");h.name=o.error?.name??"Error",h.stack=o.error?.stack,c.reject(h)}return}o.type==="dispose"&&(i=!0,t.length=0,s?.controller.abort(),s?.acknowledge?.(),e.postMessage({type:"disposed"}),e.close())})}exports.MODEL_DECODE_PROTOCOL_VERSION=p.MODEL_DECODE_PROTOCOL_VERSION;exports.UnsupportedModelDecodeError=p.UnsupportedModelDecodeError;exports.validateDecodedGltfNodeGraph=p.validateDecodedGltfNodeGraph;exports.installModelDecodeWorker=$;
|