@jdultra/threedtiles 13.1.0 → 13.1.2

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.
@@ -2530,12 +2530,12 @@ class Ni {
2530
2530
  if (this.timeout = e.timeout != null ? e.timeout : 5e3, this.renderer = e.renderer, this.zUpToYUpMatrix = new E.Matrix4(), this.zUpToYUpMatrix.set(1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1), this.maxCachedItems = 100, this.proxy = e.proxy, e && (this.meshCallback = e.meshCallback, this.pointsCallback = e.pointsCallback, e.maxCachedItems != null && (this.maxCachedItems = e.maxCachedItems)), this.gltfLoader = new Dt(), e && e.dracoLoader) this.gltfLoader.setDRACOLoader(e.dracoLoader), this.hasDracoLoader = !0;
2531
2531
  else {
2532
2532
  const a = new Rt();
2533
- a.setDecoderPath("https://storage.googleapis.com/ogc-3d-tiles/draco/"), this.gltfLoader.setDRACOLoader(a), this.gltfLoader.hasDracoLoader = !0;
2533
+ a.setDecoderPath("https://storage.googleapis.com/ogc-3d-tiles/draco/"), this.dracoLoader = a, this.gltfLoader.setDRACOLoadMer(a), this.gltfLoader.hasDracoLoader = !0;
2534
2534
  }
2535
2535
  if (e && e.ktx2Loader) this.gltfLoader.setKTX2Loader(e.ktx2Loader), this.hasKTX2Loader = !0;
2536
2536
  else if (e && e.renderer) {
2537
2537
  const a = new L();
2538
- a.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(e.renderer), this.gltfLoader.setKTX2Loader(a), this.gltfLoader.hasKTX2Loader = !0;
2538
+ a.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(e.renderer), this.ktx2loader = a, this.gltfLoader.setKTX2Loader(a), this.gltfLoader.hasKTX2Loader = !0;
2539
2539
  }
2540
2540
  this.gltfLoader.setMeshoptDecoder(Vt), this.hasMeshOptDecoder = !0, this.b3dmDecoder = new jt(this.gltfLoader), this.splatsDecoder = new XA(this.gltfLoader, this.renderer), this.cache = new kt(), this.register = {}, this.ready = [], this.downloads = [], this.nextReady = [], this.nextDownloads = [];
2541
2541
  }
@@ -2681,22 +2681,30 @@ class Ni {
2681
2681
  invalidate(e, a) {
2682
2682
  const t = ct(e);
2683
2683
  this.register[t] && setTimeout(() => {
2684
- delete this.register[t][a], this._checkSize();
2684
+ this.register && (delete this.register[t][a], this._checkSize());
2685
2685
  }, this.timeout);
2686
2686
  }
2687
+ dispose() {
2688
+ let e = this.cache.head();
2689
+ for (this._disposeEntryContent(e); (e = e.next()).key != null; ) this._disposeEntryContent(e);
2690
+ this.cache.reset(), this.cache = void 0, this.register = void 0, this.dracoLoader && this.dracoLoader.dispose(), this.ktx2loader && this.ktx2loader.dispose();
2691
+ }
2687
2692
  _checkSize() {
2688
2693
  const e = this;
2689
2694
  let a = 0;
2690
2695
  for (; e.cache.size() > e.maxCachedItems && a < e.cache.size(); ) {
2691
2696
  a++;
2692
2697
  const t = e.cache.head(), A = e.register[t.key];
2693
- A && (Object.keys(A).length > 0 ? (e.cache.remove(t.key), e.cache.put(t.key, t.value)) : (e.cache.remove(t.key), delete e.register[t.key], t.value.isSplatsBatch ? t.value.remove() : t.value.traverse && t.value.traverse((i) => {
2694
- if (i.material) if (i.material.length) for (let s = 0; s < i.material.length; ++s) i.material[s].dispose();
2695
- else i.material.dispose();
2696
- i.geometry && i.geometry.dispose();
2697
- })));
2698
+ A && (Object.keys(A).length > 0 ? (e.cache.remove(t.key), e.cache.put(t.key, t.value)) : (e.cache.remove(t.key), delete e.register[t.key], e._disposeEntryContent(t)));
2698
2699
  }
2699
2700
  }
2701
+ _disposeEntryContent(e) {
2702
+ e.value && (e.value.isSplatsBatch ? e.value.remove() : e.value.traverse && e.value.traverse((a) => {
2703
+ if (a.material) if (a.material.length) for (let t = 0; t < a.material.length; ++t) a.material[t].dispose();
2704
+ else a.material.dispose();
2705
+ a.geometry && a.geometry.dispose();
2706
+ }));
2707
+ }
2700
2708
  }
2701
2709
  function ct(c) {
2702
2710
  for (var e = c.split("/"), a = [], t = 0, A = 0; A < e.length; A++) {
@@ -3124,7 +3132,7 @@ void main() {
3124
3132
  this.copyQuad = new xa(f, this.copyMaterial2D), this.copyScene.add(this.copyQuad), this.copyScene.matrixAutoUpdate = !1, this.copyQuad.matrixAutoUpdate = !1;
3125
3133
  }
3126
3134
  dispose() {
3127
- this.material.dispose(), this.copyMaterial2D.dispose(), this.copyMaterial3D.dispose(), this.cov1RenderTarget.dispose(), this.cov2RenderTarget.dispose(), this.positionRenderTarget.dispose(), this.colorRenderTarget.dispose(), this.worker.terminate(), this.worker = null, this.geometry.dispose();
3135
+ this.material.dispose(), this.copyMaterial2D.dispose(), this.copyMaterial3D.dispose(), this.cov1RenderTarget.dispose(), this.cov2RenderTarget.dispose(), this.positionRenderTarget.dispose(), this.colorRenderTarget.dispose(), this.worker.terminate(), this.worker = null, this.orderAttribute.array = void 0, this.geometry.dispose();
3128
3136
  }
3129
3137
  copyTex2D(e, a, t, A) {
3130
3138
  this.copyMaterial2D.uniforms.sourceTexture.value = e;
@@ -3147,11 +3155,12 @@ void main() {
3147
3155
  this.material.uniforms.cropRadius.value = e;
3148
3156
  }
3149
3157
  sort(e) {
3150
- !e && this.cameraPosition ? this.worker.postMessage({ method: "sort", xyz: [this.cameraPosition.x, this.cameraPosition.z, -this.cameraPosition.y], id: this.sortID++ }) : this.cameraPosition && e.equals(this.cameraPosition) || (this.cameraPosition.copy(e), this.worker.postMessage({ method: "sort", xyz: [this.cameraPosition.x, this.cameraPosition.z, -this.cameraPosition.y], id: this.sortID++ }));
3158
+ this.worker && (!e && this.cameraPosition ? this.worker.postMessage({ method: "sort", xyz: [this.cameraPosition.x, this.cameraPosition.z, -this.cameraPosition.y], id: this.sortID++ }) : this.cameraPosition && e.equals(this.cameraPosition) || (this.cameraPosition.copy(e), this.worker.postMessage({ method: "sort", xyz: [this.cameraPosition.x, this.cameraPosition.z, -this.cameraPosition.y], id: this.sortID++ })));
3151
3159
  }
3152
3160
  raycast(e, a) {
3153
3161
  }
3154
3162
  addSplatsTile(e, a, t, A) {
3163
+ if (!this.worker) return;
3155
3164
  const i = this, s = e.data ? e.data.array : e.array, r = e.data && e.data.isInterleavedBuffer ? e.data.stride : 3, o = e.data && e.data.isInterleavedBuffer ? e.offset : 0, n = Math.ceil(s.length / (this.batchSize * r)), d = [], b = [];
3156
3165
  let g = () => {
3157
3166
  };
@@ -3174,15 +3183,15 @@ void main() {
3174
3183
  i.worker.postMessage({ method: "addBatches", insertionIndexes: b, positions: s.buffer, offset: o, stride: r, batchSize: i.batchSize }, [s.buffer]);
3175
3184
  let h = !1;
3176
3185
  return { hide: () => {
3177
- h == 1 && (i.numVisibleBatches--, h = !1, i.worker.postMessage({ method: "hideBatches", insertionIndexes: b, xyz: [i.cameraPosition.x, i.cameraPosition.z, -i.cameraPosition.y], id: i.sortID++ }));
3186
+ h == 1 && i.worker && (i.numVisibleBatches--, h = !1, i.worker.postMessage({ method: "hideBatches", insertionIndexes: b, xyz: [i.cameraPosition.x, i.cameraPosition.z, -i.cameraPosition.y], id: i.sortID++ }));
3178
3187
  }, show: (f) => {
3179
- if (h == 0) {
3188
+ if (h == 0 && i.worker) {
3180
3189
  i.numVisibleBatches--, h = !0;
3181
3190
  const I = i.sortID, m = (u) => u >= I && (f(), !0);
3182
3191
  i.sortListeners.push(m), i.worker.postMessage({ method: "showBatches", insertionIndexes: b, xyz: [i.cameraPosition.x, i.cameraPosition.z, -i.cameraPosition.y], id: i.sortID++ });
3183
3192
  }
3184
3193
  }, remove: () => {
3185
- g = void 0, i.worker.postMessage({ method: "removeBatches", insertionIndexes: b, xyz: [i.cameraPosition.x, i.cameraPosition.z, -i.cameraPosition.y], id: i.sortID++ }), d.forEach((f) => i.freeAddresses.add(f));
3194
+ i.worker && (g = void 0, i.worker.postMessage({ method: "removeBatches", insertionIndexes: b, xyz: [i.cameraPosition.x, i.cameraPosition.z, -i.cameraPosition.y], id: i.sortID++ }), d.forEach((f) => i.freeAddresses.add(f)));
3186
3195
  }, sort: this.sort, raycast: g, isSplatsBatch: !0 };
3187
3196
  }
3188
3197
  addSplatsBatch(e, a, t, A, i, s) {
@@ -3561,7 +3570,7 @@ class Wt extends E.Object3D {
3561
3570
  a && a.asset && a.asset.copyright && (a.asset.copyright.split(";").forEach((t) => {
3562
3571
  Z[t] && Z[t]--;
3563
3572
  }), e.displayCopyright && pa());
3564
- }), e.childrenTiles.forEach((a) => a.dispose()), e.deleted = !0, e.splatsMesh && (e.meshContent.forEach((a) => a.hide()), e.parentTile || e.splatsMesh.dispose()), e.contentURL && (e.contentURL.forEach((a) => {
3573
+ }), e.childrenTiles.forEach((a) => a.dispose()), e.deleted = !0, e.splatsMesh && (e.meshContent.forEach((a) => a.hide()), e.parentTile || (e.splatsMesh.dispose(), e.splatsMesh = void 0)), e.contentURL && (e.contentURL.forEach((a) => {
3565
3574
  e.tileLoader.invalidate(a, e.uuid);
3566
3575
  }), e.contentURL = []), e.abortController && !e.jsonRequested && e.abortController.abort("tile not needed"), this.parent = null, e.meshContent = [], e.bbox && e.bbox.dispose(), this.dispatchEvent({ type: "removed" });
3567
3576
  }