@needle-tools/gltf-progressive 3.1.0 → 3.1.1

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.
@@ -1,59 +1,59 @@
1
- var Ye = Object.defineProperty;
2
- var He = (o, t, e) => t in o ? Ye(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var u = (o, t, e) => (He(o, typeof t != "symbol" ? t + "" : t, e), e), Be = (o, t, e) => {
1
+ var He = Object.defineProperty;
2
+ var Qe = (o, t, e) => t in o ? He(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var u = (o, t, e) => (Qe(o, typeof t != "symbol" ? t + "" : t, e), e), Ee = (o, t, e) => {
4
4
  if (!t.has(o))
5
5
  throw TypeError("Cannot " + e);
6
6
  };
7
- var y = (o, t, e) => (Be(o, t, "read from private field"), e ? e.call(o) : t.get(o)), H = (o, t, e) => {
7
+ var L = (o, t, e) => (Ee(o, t, "read from private field"), e ? e.call(o) : t.get(o)), H = (o, t, e) => {
8
8
  if (t.has(o))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  t instanceof WeakSet ? t.add(o) : t.set(o, e);
11
- }, q = (o, t, e, s) => (Be(o, t, "write to private field"), s ? s.call(o, e) : t.set(o, e), e);
12
- import { BufferGeometry as xe, Mesh as se, Texture as oe, TextureLoader as Qe, Matrix4 as Ge, Clock as je, MeshStandardMaterial as Je, Sphere as Ze, Box3 as Ee, Vector3 as W } from "three";
11
+ }, V = (o, t, e, s) => (Ee(o, t, "write to private field"), s ? s.call(o, e) : t.set(o, e), e);
12
+ import { BufferGeometry as Le, Mesh as se, Texture as oe, TextureLoader as je, Matrix4 as Ie, Clock as Je, MeshStandardMaterial as Ze, Sphere as et, Box3 as $e, Vector3 as W } from "three";
13
13
  import { GLTFLoader as Ce } from "three/examples/jsm/loaders/GLTFLoader.js";
14
- import { MeshoptDecoder as et } from "three/examples/jsm/libs/meshopt_decoder.module.js";
15
- import { DRACOLoader as tt } from "three/examples/jsm/loaders/DRACOLoader.js";
16
- import { KTX2Loader as st } from "three/examples/jsm/loaders/KTX2Loader.js";
17
- const rt = "";
18
- globalThis.GLTF_PROGRESSIVE_VERSION = rt;
14
+ import { MeshoptDecoder as tt } from "three/examples/jsm/libs/meshopt_decoder.module.js";
15
+ import { DRACOLoader as st } from "three/examples/jsm/loaders/DRACOLoader.js";
16
+ import { KTX2Loader as rt } from "three/examples/jsm/loaders/KTX2Loader.js";
17
+ const it = "";
18
+ globalThis.GLTF_PROGRESSIVE_VERSION = it;
19
19
  console.debug("[gltf-progressive] version -");
20
- let V = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", re = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
21
- const it = V, nt = re, Re = new URL(V + "draco_decoder.js");
22
- Re.searchParams.append("range", "true");
23
- fetch(Re, {
20
+ let q = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", re = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
21
+ const nt = q, ot = re, Fe = new URL(q + "draco_decoder.js");
22
+ Fe.searchParams.append("range", "true");
23
+ fetch(Fe, {
24
24
  method: "GET",
25
25
  headers: {
26
26
  Range: "bytes=0-1"
27
27
  }
28
28
  }).catch((o) => {
29
- console.debug(`Failed to fetch remote Draco decoder from ${V} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), V === it && ot("./include/draco/"), re === nt && at("./include/ktx2/");
29
+ console.debug(`Failed to fetch remote Draco decoder from ${q} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), q === nt && at("./include/draco/"), re === ot && lt("./include/ktx2/");
30
30
  }).finally(() => {
31
- Fe();
31
+ Ne();
32
32
  });
33
- function ot(o) {
34
- V = o, I && I[Pe] != V ? (console.debug("Updating Draco decoder path to " + o), I[Pe] = V, I.setDecoderPath(V), I.preload()) : console.debug("Setting Draco decoder path to " + o);
35
- }
36
33
  function at(o) {
37
- re = o, U && U.transcoderPath != re ? (console.debug("Updating KTX2 transcoder path to " + o), U.setTranscoderPath(re), U.init()) : console.debug("Setting KTX2 transcoder path to " + o);
34
+ q = o, k && k[Pe] != q ? (console.debug("Updating Draco decoder path to " + o), k[Pe] = q, k.setDecoderPath(q), k.preload()) : console.debug("Setting Draco decoder path to " + o);
35
+ }
36
+ function lt(o) {
37
+ re = o, N && N.transcoderPath != re ? (console.debug("Updating KTX2 transcoder path to " + o), N.setTranscoderPath(re), N.init()) : console.debug("Setting KTX2 transcoder path to " + o);
38
38
  }
39
39
  const Pe = Symbol("dracoDecoderPath");
40
- let I, Le, U;
41
- function Fe() {
42
- I || (I = new tt(), I[Pe] = V, I.setDecoderPath(V), I.setDecoderConfig({ type: "js" }), I.preload()), U || (U = new st(), U.setTranscoderPath(re), U.init()), Le || (Le = et);
40
+ let k, xe, N;
41
+ function Ne() {
42
+ k || (k = new st(), k[Pe] = q, k.setDecoderPath(q), k.setDecoderConfig({ type: "js" }), k.preload()), N || (N = new rt(), N.setTranscoderPath(re), N.init()), xe || (xe = tt);
43
43
  }
44
44
  function Ue(o) {
45
- return Fe(), o ? U.detectSupport(o) : o !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: I, ktx2Loader: U, meshoptDecoder: Le };
45
+ return Ne(), o ? N.detectSupport(o) : o !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: k, ktx2Loader: N, meshoptDecoder: xe };
46
46
  }
47
- function Ne(o) {
48
- o.dracoLoader || o.setDRACOLoader(I), o.ktx2Loader || o.setKTX2Loader(U), o.meshoptDecoder || o.setMeshoptDecoder(Le);
47
+ function ze(o) {
48
+ o.dracoLoader || o.setDRACOLoader(k), o.ktx2Loader || o.setKTX2Loader(N), o.meshoptDecoder || o.setMeshoptDecoder(xe);
49
49
  }
50
50
  const Te = /* @__PURE__ */ new WeakMap();
51
- function ze(o, t) {
51
+ function Ve(o, t) {
52
52
  let e = Te.get(o);
53
53
  e ? e = Object.assign(e, t) : e = t, Te.set(o, e);
54
54
  }
55
- const De = Ce.prototype.load;
56
- function lt(...o) {
55
+ const Me = Ce.prototype.load;
56
+ function ut(...o) {
57
57
  const t = Te.get(this);
58
58
  let e = o[0];
59
59
  const s = new URL(e, window.location.href);
@@ -61,9 +61,9 @@ function lt(...o) {
61
61
  const r = (t == null ? void 0 : t.progressive) !== void 0 ? t.progressive : !0, i = t != null && t.usecase ? t.usecase : "default";
62
62
  r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${i}` : this.requestHeader.Accept = `*/*;usecase=${i}`, e = s.toString();
63
63
  }
64
- return o[0] = e, De == null ? void 0 : De.call(this, ...o);
64
+ return o[0] = e, Me == null ? void 0 : Me.call(this, ...o);
65
65
  }
66
- Ce.prototype.load = lt;
66
+ Ce.prototype.load = ut;
67
67
  de("debugprogressive");
68
68
  function de(o) {
69
69
  if (typeof window > "u")
@@ -71,7 +71,7 @@ function de(o) {
71
71
  const e = new URL(window.location.href).searchParams.get(o);
72
72
  return e == null || e === "0" || e === "false" ? !1 : e === "" ? !0 : e;
73
73
  }
74
- function ut(o, t) {
74
+ function dt(o, t) {
75
75
  if (t === void 0 || t.startsWith("./") || t.startsWith("http") || o === void 0)
76
76
  return t;
77
77
  const e = o.lastIndexOf("/");
@@ -84,10 +84,10 @@ function ut(o, t) {
84
84
  return t;
85
85
  }
86
86
  let ae;
87
- function dt() {
87
+ function ct() {
88
88
  return ae !== void 0 || (ae = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), de("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", ae)), ae;
89
89
  }
90
- function ct() {
90
+ function Ge() {
91
91
  if (typeof window > "u")
92
92
  return !1;
93
93
  const o = new URL(window.location.href), t = o.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);
@@ -113,8 +113,8 @@ class ft {
113
113
  }
114
114
  add(t, e) {
115
115
  this._running.has(t) || (this._running.set(t, e), e.finally(() => {
116
- this._running.delete(t), this.debug && console.debug(`[PromiseQueue]: Promise for key ${t} finished, running: ${this._running.size}, waiting: ${this._queue.length}`);
117
- }), this.debug && console.debug(`[PromiseQueue]: Adding promise for key ${t}, running: ${this._running.size}, waiting: ${this._queue.length}`));
116
+ this._running.delete(t), this.debug && console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${t})`);
117
+ }), this.debug && console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${t})`));
118
118
  }
119
119
  internalUpdate() {
120
120
  const t = this.maxConcurrent - this._running.size;
@@ -129,7 +129,7 @@ class ft {
129
129
  }
130
130
  const ht = typeof window > "u" && typeof document > "u", Ae = Symbol("needle:raycast-mesh");
131
131
  function ce(o) {
132
- return (o == null ? void 0 : o[Ae]) instanceof xe ? o[Ae] : null;
132
+ return (o == null ? void 0 : o[Ae]) instanceof Le ? o[Ae] : null;
133
133
  }
134
134
  function gt(o, t) {
135
135
  if ((o.type === "Mesh" || o.type === "SkinnedMesh") && !ce(o)) {
@@ -155,14 +155,14 @@ function pt(o = !0) {
155
155
  }
156
156
  let le = null;
157
157
  function mt(o) {
158
- const t = new xe();
158
+ const t = new Le();
159
159
  for (const e in o.attributes)
160
160
  t.setAttribute(e, o.getAttribute(e));
161
161
  return t.setIndex(o.getIndex()), t;
162
162
  }
163
- const j = new Array(), x = de("debugprogressive");
163
+ const j = new Array(), y = de("debugprogressive");
164
164
  let me, te = -1;
165
- if (x) {
165
+ if (y) {
166
166
  let o = function() {
167
167
  te += 1, te >= t && (te = -1), console.log(`Toggle LOD level [${te}]`);
168
168
  }, t = 6;
@@ -173,14 +173,14 @@ if (x) {
173
173
  });
174
174
  }
175
175
  function qe(o) {
176
- if (x)
176
+ if (y)
177
177
  if (Array.isArray(o))
178
178
  for (const t of o)
179
179
  qe(t);
180
180
  else
181
181
  o && "wireframe" in o && (o.wireframe = me === !0);
182
182
  }
183
- const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = class {
183
+ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), O = class {
184
184
  constructor(t, e) {
185
185
  u(this, "parser");
186
186
  u(this, "url");
@@ -192,10 +192,10 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
192
192
  const e = (n = (s = this.parser.json.meshes[t]) == null ? void 0 : s.extensions) == null ? void 0 : n[X];
193
193
  return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((r) => {
194
194
  var i;
195
- return this._isLoadingMesh = !1, r && D.registerMesh(this.url, e.guid, r, (i = e.lods) == null ? void 0 : i.length, 0, e), r;
195
+ return this._isLoadingMesh = !1, r && O.registerMesh(this.url, e.guid, r, (i = e.lods) == null ? void 0 : i.length, 0, e), r;
196
196
  })) : null;
197
197
  });
198
- x && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
198
+ y && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
199
199
  }
200
200
  /** The name of the extension */
201
201
  get name() {
@@ -223,7 +223,7 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
223
223
  this.getMaterialMinMaxLODsCount(a, e);
224
224
  return t[n] = e, e;
225
225
  }
226
- if (x === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
226
+ if (y === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
227
227
  const a = t;
228
228
  for (const l of Object.keys(a.uniforms)) {
229
229
  const c = a.uniforms[l].value;
@@ -241,9 +241,9 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
241
241
  const d = s.lodInfos.get(c.key);
242
242
  if (d && d.lods) {
243
243
  l.min_count = Math.min(l.min_count, d.lods.length), l.max_count = Math.max(l.max_count, d.lods.length);
244
- for (let p = 0; p < d.lods.length; p++) {
245
- const f = d.lods[p];
246
- f.width && (l.lods[p] = l.lods[p] || { min_height: 1 / 0, max_height: 0 }, l.lods[p].min_height = Math.min(l.lods[p].min_height, f.height), l.lods[p].max_height = Math.max(l.lods[p].max_height, f.height));
244
+ for (let h = 0; h < d.lods.length; h++) {
245
+ const f = d.lods[h];
246
+ f.width && (l.lods[h] = l.lods[h] || { min_height: 1 / 0, max_height: 0 }, l.lods[h].min_height = Math.min(l.lods[h].min_height, f.height), l.lods[h].max_height = Math.max(l.lods[h].max_height, f.height));
247
247
  }
248
248
  }
249
249
  }
@@ -308,15 +308,15 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
308
308
  return Promise.resolve(null);
309
309
  for (const i of j)
310
310
  (s = i.onBeforeGetLODMesh) == null || s.call(i, t, e);
311
- return t["LOD:requested level"] = e, D.getOrLoadLOD(n, e).then((i) => {
311
+ return t["LOD:requested level"] = e, O.getOrLoadLOD(n, e).then((i) => {
312
312
  if (Array.isArray(i)) {
313
313
  const a = r.index || 0;
314
314
  i = i[a];
315
315
  }
316
- return t["LOD:requested level"] === e && (delete t["LOD:requested level"], i && n != i && ((i == null ? void 0 : i.isBufferGeometry) ? t.geometry = i : x && console.error("Invalid LOD geometry", i))), i;
316
+ return t["LOD:requested level"] === e && (delete t["LOD:requested level"], i && n != i && ((i == null ? void 0 : i.isBufferGeometry) ? t.geometry = i : y && console.error("Invalid LOD geometry", i))), i;
317
317
  }).catch((i) => (console.error("Error loading mesh LOD", t, i), null));
318
318
  } else
319
- x && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
319
+ y && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
320
320
  return Promise.resolve(null);
321
321
  }
322
322
  static assignTextureLOD(t, e = 0) {
@@ -374,45 +374,59 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
374
374
  return Promise.resolve(null);
375
375
  }
376
376
  static assignTextureLODForSlot(t, e, s, n) {
377
- return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : D.getOrLoadLOD(t, e).then((r) => {
377
+ return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : O.getOrLoadLOD(t, e).then((r) => {
378
378
  if (Array.isArray(r))
379
- return null;
379
+ return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen", r), null;
380
380
  if ((r == null ? void 0 : r.isTexture) === !0) {
381
381
  if (r != t && s && n) {
382
382
  const i = s[n];
383
- if (i && !x) {
383
+ if (i && !y) {
384
384
  const a = this.getAssignedLODInformation(i);
385
385
  if (a && (a == null ? void 0 : a.level) < e)
386
- return x === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, e, s, i, r), null;
386
+ return y === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, e, s, i, r), null;
387
387
  }
388
388
  s[n] = r;
389
389
  }
390
390
  return r;
391
391
  } else
392
- x == "verbose" && console.warn("No LOD found for", t, e);
392
+ y == "verbose" && console.warn("No LOD found for", t, e);
393
393
  return null;
394
394
  }).catch((r) => (console.error("Error loading LOD", t, r), null));
395
395
  }
396
+ // private _isLoadingTexture;
397
+ // loadTexture = (textureIndex: number) => {
398
+ // if (this._isLoadingTexture) return null;
399
+ // const ext = this.parser.json.textures[textureIndex]?.extensions?.[EXTENSION_NAME] as NEEDLE_ext_progressive_texture;
400
+ // if (!ext) return null;
401
+ // this._isLoadingTexture = true;
402
+ // return this.parser.getDependency("texture", textureIndex).then(tex => {
403
+ // this._isLoadingTexture = false;
404
+ // if (tex) {
405
+ // NEEDLE_progressive.registerTexture(this.url, tex as Texture, ext.lods?.length, textureIndex, ext);
406
+ // }
407
+ // return tex;
408
+ // });
409
+ // }
396
410
  afterRoot(t) {
397
411
  var e, s;
398
- return x && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, r) => {
412
+ return y && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, r) => {
399
413
  var i;
400
414
  if (n != null && n.extensions) {
401
415
  const a = n == null ? void 0 : n.extensions[X];
402
416
  if (a) {
403
417
  if (!a.lods) {
404
- x && console.warn("Texture has no LODs", a);
418
+ y && console.warn("Texture has no LODs", a);
405
419
  return;
406
420
  }
407
421
  let l = !1;
408
422
  for (const c of this.parser.associations.keys())
409
423
  if (c.isTexture === !0) {
410
424
  const d = this.parser.associations.get(c);
411
- (d == null ? void 0 : d.textures) === r && (l = !0, D.registerTexture(this.url, c, (i = a.lods) == null ? void 0 : i.length, r, a));
425
+ (d == null ? void 0 : d.textures) === r && (l = !0, O.registerTexture(this.url, c, (i = a.lods) == null ? void 0 : i.length, r, a));
412
426
  }
413
427
  l || this.parser.getDependency("texture", r).then((c) => {
414
428
  var d;
415
- c && D.registerTexture(this.url, c, (d = a.lods) == null ? void 0 : d.length, r, a);
429
+ c && O.registerTexture(this.url, c, (d = a.lods) == null ? void 0 : d.length, r, a);
416
430
  });
417
431
  }
418
432
  }
@@ -423,7 +437,7 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
423
437
  for (const a of this.parser.associations.keys())
424
438
  if (a.isMesh) {
425
439
  const l = this.parser.associations.get(a);
426
- (l == null ? void 0 : l.meshes) === r && D.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
440
+ (l == null ? void 0 : l.meshes) === r && O.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
427
441
  }
428
442
  }
429
443
  }
@@ -431,114 +445,114 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
431
445
  }
432
446
  static async getOrLoadLOD(t, e) {
433
447
  var a, l, c, d;
434
- const s = x == "verbose", n = t.userData.LODS;
448
+ const s = y == "verbose", n = this.getAssignedLODInformation(t);
435
449
  if (!n)
436
- return null;
450
+ return y && console.warn(`[gltf-progressive] No LOD information found: ${t.name}, uuid: ${t.uuid}, type: ${t.type}`, t), null;
437
451
  const r = n == null ? void 0 : n.key;
438
452
  let i;
439
453
  if (t.isTexture === !0) {
440
- const p = t;
441
- p.source && p.source[Oe] && (i = p.source[Oe]);
454
+ const h = t;
455
+ h.source && h.source[Oe] && (i = h.source[Oe]);
442
456
  }
443
- if (i || (i = D.lodInfos.get(r)), i) {
457
+ if (i || (i = O.lodInfos.get(r)), i) {
444
458
  if (e > 0) {
445
459
  let w = !1;
446
- const M = Array.isArray(i.lods);
447
- if (M && e >= i.lods.length ? w = !0 : M || (w = !0), w)
460
+ const v = Array.isArray(i.lods);
461
+ if (v && e >= i.lods.length ? w = !0 : v || (w = !0), w)
448
462
  return this.lowresCache.get(r);
449
463
  }
450
- const p = Array.isArray(i.lods) ? (a = i.lods[e]) == null ? void 0 : a.path : i.lods;
451
- if (!p)
452
- return x && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
453
- const f = ut(n.url, p);
464
+ const h = Array.isArray(i.lods) ? (a = i.lods[e]) == null ? void 0 : a.path : i.lods;
465
+ if (!h)
466
+ return y && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
467
+ const f = dt(n.url, h);
454
468
  if (f.endsWith(".glb") || f.endsWith(".gltf")) {
455
469
  if (!i.guid)
456
470
  return console.warn("missing pointer for glb/gltf texture", i), null;
457
- const w = f + "_" + i.guid, M = this.previouslyLoaded.get(w);
458
- if (M !== void 0) {
471
+ const w = f + "_" + i.guid, v = this.previouslyLoaded.get(w);
472
+ if (v !== void 0) {
459
473
  s && console.log(`LOD ${e} was already loading/loaded: ${w}`);
460
- let h = await M.catch((C) => (console.error(`Error loading LOD ${e} from ${f}
461
- `, C), null)), L = !1;
462
- if (h == null || (h instanceof oe && t instanceof oe ? (l = h.image) != null && l.data || (c = h.source) != null && c.data ? h = this.copySettings(t, h) : (L = !0, this.previouslyLoaded.delete(w)) : h instanceof xe && t instanceof xe && ((d = h.attributes.position) != null && d.array || (L = !0, this.previouslyLoaded.delete(w)))), !L)
463
- return h;
474
+ let g = await v.catch((E) => (console.error(`Error loading LOD ${e} from ${f}
475
+ `, E), null)), x = !1;
476
+ if (g == null || (g instanceof oe && t instanceof oe ? (l = g.image) != null && l.data || (c = g.source) != null && c.data ? g = this.copySettings(t, g) : (x = !0, this.previouslyLoaded.delete(w)) : g instanceof Le && t instanceof Le && ((d = g.attributes.position) != null && d.array || (x = !0, this.previouslyLoaded.delete(w)))), !x)
477
+ return g;
464
478
  }
465
- const A = await this.queue.slot(f);
466
- if (!A.use)
467
- return x && console.log(`LOD ${e} was aborted: ${f}`), null;
468
- const b = i, R = new Promise(async (h, L) => {
469
- const C = new Ce();
470
- Ne(C), x && (await new Promise((v) => setTimeout(v, 1e3)), s && console.warn("Start loading (delayed) " + f, b.guid));
471
- let N = f;
472
- if (b && Array.isArray(b.lods)) {
473
- const v = b.lods[e];
474
- v.hash && (N += "?v=" + v.hash);
479
+ const P = await this.queue.slot(f);
480
+ if (!P.use)
481
+ return y && console.log(`LOD ${e} was aborted: ${f}`), null;
482
+ const M = i, R = new Promise(async (g, x) => {
483
+ const E = new Ce();
484
+ ze(E), y && (await new Promise((D) => setTimeout(D, 1e3)), s && console.warn("Start loading (delayed) " + f, M.guid));
485
+ let U = f;
486
+ if (M && Array.isArray(M.lods)) {
487
+ const D = M.lods[e];
488
+ D.hash && (U += "?v=" + D.hash);
475
489
  }
476
- const S = await C.loadAsync(N).catch((v) => (console.error(`Error loading LOD ${e} from ${f}
477
- `, v), h(null)));
490
+ const S = await E.loadAsync(U).catch((D) => (console.error(`Error loading LOD ${e} from ${f}
491
+ `, D), g(null)));
478
492
  if (!S)
479
- return h(null);
493
+ return g(null);
480
494
  const ee = S.parser;
481
- s && console.log("Loading finished " + f, b.guid);
482
- let B = 0;
495
+ s && console.log("Loading finished " + f, M.guid);
496
+ let I = 0;
483
497
  if (S.parser.json.textures) {
484
- let v = !1;
498
+ let D = !1;
485
499
  for (const m of S.parser.json.textures) {
486
500
  if (m != null && m.extensions) {
487
- const g = m == null ? void 0 : m.extensions[X];
488
- if (g != null && g.guid && g.guid === b.guid) {
489
- v = !0;
501
+ const p = m == null ? void 0 : m.extensions[X];
502
+ if (p != null && p.guid && p.guid === M.guid) {
503
+ D = !0;
490
504
  break;
491
505
  }
492
506
  }
493
- B++;
507
+ I++;
494
508
  }
495
- if (v) {
496
- let m = await ee.getDependency("texture", B);
497
- return m && D.assignLODInformation(n.url, m, r, e, void 0), s && console.log('change "' + t.name + '" → "' + m.name + '"', f, B, m, w), t instanceof oe && (m = this.copySettings(t, m)), m && (m.guid = b.guid), h(m);
509
+ if (D) {
510
+ let m = await ee.getDependency("texture", I);
511
+ return m && O.assignLODInformation(n.url, m, r, e, void 0), s && console.log('change "' + t.name + '" → "' + m.name + '"', f, I, m, w), t instanceof oe && (m = this.copySettings(t, m)), m && (m.guid = M.guid), g(m);
498
512
  } else
499
- x && console.warn("Could not find texture with guid", b.guid, S.parser.json);
513
+ y && console.warn("Could not find texture with guid", M.guid, S.parser.json);
500
514
  }
501
- if (B = 0, S.parser.json.meshes) {
502
- let v = !1;
515
+ if (I = 0, S.parser.json.meshes) {
516
+ let D = !1;
503
517
  for (const m of S.parser.json.meshes) {
504
518
  if (m != null && m.extensions) {
505
- const g = m == null ? void 0 : m.extensions[X];
506
- if (g != null && g.guid && g.guid === b.guid) {
507
- v = !0;
519
+ const p = m == null ? void 0 : m.extensions[X];
520
+ if (p != null && p.guid && p.guid === M.guid) {
521
+ D = !0;
508
522
  break;
509
523
  }
510
524
  }
511
- B++;
525
+ I++;
512
526
  }
513
- if (v) {
514
- const m = await ee.getDependency("mesh", B);
515
- if (s && console.log(`Loaded Mesh "${m.name}"`, f, B, m, w), m.isMesh === !0) {
516
- const g = m.geometry;
517
- return D.assignLODInformation(n.url, g, r, e, 0), h(g);
527
+ if (D) {
528
+ const m = await ee.getDependency("mesh", I);
529
+ if (s && console.log(`Loaded Mesh "${m.name}"`, f, I, m, w), m.isMesh === !0) {
530
+ const p = m.geometry;
531
+ return O.assignLODInformation(n.url, p, r, e, 0), g(p);
518
532
  } else {
519
- const g = new Array();
533
+ const p = new Array();
520
534
  for (let _ = 0; _ < m.children.length; _++) {
521
- const G = m.children[_];
522
- if (G.isMesh === !0) {
523
- const E = G.geometry;
524
- D.assignLODInformation(n.url, E, r, e, _), g.push(E);
535
+ const $ = m.children[_];
536
+ if ($.isMesh === !0) {
537
+ const A = $.geometry;
538
+ O.assignLODInformation(n.url, A, r, e, _), p.push(A);
525
539
  }
526
540
  }
527
- return h(g);
541
+ return g(p);
528
542
  }
529
543
  } else
530
- x && console.warn("Could not find mesh with guid", b.guid, S.parser.json);
544
+ y && console.warn("Could not find mesh with guid", M.guid, S.parser.json);
531
545
  }
532
- return h(null);
546
+ return g(null);
533
547
  });
534
- return this.previouslyLoaded.set(w, R), A.use(R), await R;
548
+ return this.previouslyLoaded.set(w, R), P.use(R), await R;
535
549
  } else if (t instanceof oe) {
536
550
  s && console.log("Load texture from uri: " + f);
537
- const M = await new Qe().loadAsync(f);
538
- return M ? (M.guid = i.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = t.colorSpace, s && console.log(i, M)) : x && console.warn("failed loading", f), M;
551
+ const v = await new je().loadAsync(f);
552
+ return v ? (v.guid = i.guid, v.flipY = !1, v.needsUpdate = !0, v.colorSpace = t.colorSpace, s && console.log(i, v)) : y && console.warn("failed loading", f), v;
539
553
  }
540
554
  } else
541
- x && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
555
+ y && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
542
556
  return null;
543
557
  }
544
558
  static assignLODInformation(t, e, s, n, r) {
@@ -546,50 +560,55 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
546
560
  return;
547
561
  e.userData || (e.userData = {});
548
562
  const i = new yt(t, s, n, r);
549
- e.userData.LODS = i;
563
+ e.userData.LODS = i, "source" in e && typeof e.source == "object" && (e.source.LODS = i);
550
564
  }
551
565
  static getAssignedLODInformation(t) {
552
- var e;
553
- return ((e = t == null ? void 0 : t.userData) == null ? void 0 : e.LODS) || null;
566
+ var e, s;
567
+ return t ? (e = t.userData) != null && e.LODS ? t.userData.LODS : "source" in t && ((s = t.source) != null && s.LODS) ? t.source.LODS : null : null;
554
568
  }
555
569
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
556
570
  static copySettings(t, e) {
557
- return e ? (x && console.warn(`Copy texture settings
571
+ return e ? (y && console.warn(`Copy texture settings
558
572
  `, t.uuid, `
559
573
  `, e.uuid), e = e.clone(), e.offset = t.offset, e.repeat = t.repeat, e.colorSpace = t.colorSpace, e.magFilter = t.magFilter, e.minFilter = t.minFilter, e.wrapS = t.wrapS, e.wrapT = t.wrapT, e.flipY = t.flipY, e.anisotropy = t.anisotropy, e.mipmaps || (e.generateMipmaps = t.generateMipmaps), e) : t;
560
574
  }
561
575
  };
562
- let P = D;
576
+ let T = O;
563
577
  /**
564
578
  * Register a texture with LOD information
565
579
  */
566
- u(P, "registerTexture", (t, e, s, n, r) => {
567
- if (x && console.log("> Progressive: register texture", n, e.name, e.uuid, e, r), !e) {
568
- x && console.error("gltf-progressive: Register texture without texture");
580
+ u(T, "registerTexture", (t, e, s, n, r) => {
581
+ var a, l, c, d, h, f, w, v;
582
+ if (!e) {
583
+ y && console.error("gltf-progressive: Called register texture without texture");
569
584
  return;
570
585
  }
586
+ if (y) {
587
+ const P = ((a = e.image) == null ? void 0 : a.width) || ((c = (l = e.source) == null ? void 0 : l.data) == null ? void 0 : c.width) || 0, M = ((d = e.image) == null ? void 0 : d.height) || ((f = (h = e.source) == null ? void 0 : h.data) == null ? void 0 : f.height) || 0;
588
+ console.log(`> Progressive: register texture[${n}] "${e.name || e.uuid}", Current: ${P}x${M}, Max: ${(w = r.lods[0]) == null ? void 0 : w.width}x${(v = r.lods[0]) == null ? void 0 : v.height}, uuid: ${e.uuid}`, r, e);
589
+ }
571
590
  e.source && (e.source[Oe] = r);
572
591
  const i = r.guid;
573
- D.assignLODInformation(t, e, i, s, n), D.lodInfos.set(i, r), D.lowresCache.set(i, e);
592
+ O.assignLODInformation(t, e, i, s, n), O.lodInfos.set(i, r), O.lowresCache.set(i, e);
574
593
  }), /**
575
594
  * Register a mesh with LOD information
576
595
  */
577
- u(P, "registerMesh", (t, e, s, n, r, i) => {
596
+ u(T, "registerMesh", (t, e, s, n, r, i) => {
578
597
  var c;
579
598
  const a = s.geometry;
580
599
  if (!a) {
581
- x && console.warn("gltf-progressive: Register mesh without geometry");
600
+ y && console.warn("gltf-progressive: Register mesh without geometry");
582
601
  return;
583
602
  }
584
- a.userData || (a.userData = {}), x && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, i, s), D.assignLODInformation(t, a, e, n, r), D.lodInfos.set(e, i);
585
- let l = D.lowresCache.get(e);
586
- l ? l.push(s.geometry) : l = [s.geometry], D.lowresCache.set(e, l), n > 0 && !ce(s) && gt(s, a);
603
+ a.userData || (a.userData = {}), y && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, i, s), O.assignLODInformation(t, a, e, n, r), O.lodInfos.set(e, i);
604
+ let l = O.lowresCache.get(e);
605
+ l ? l.push(s.geometry) : l = [s.geometry], O.lowresCache.set(e, l), n > 0 && !ce(s) && gt(s, a);
587
606
  for (const d of j)
588
607
  (c = d.onRegisteredNewMesh) == null || c.call(d, s, i);
589
608
  }), /** A map of key = asset uuid and value = LOD information */
590
- u(P, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
591
- u(P, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
592
- u(P, "lowresCache", /* @__PURE__ */ new Map()), u(P, "queue", new ft(100, { debug: x != !1 }));
609
+ u(T, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
610
+ u(T, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
611
+ u(T, "lowresCache", /* @__PURE__ */ new Map()), u(T, "queue", new ft(100, { debug: y != !1 }));
593
612
  class yt {
594
613
  constructor(t, e, s, n) {
595
614
  u(this, "url");
@@ -644,7 +663,7 @@ class ye {
644
663
  }
645
664
  add(t, e, s) {
646
665
  if (this._resolved) {
647
- x && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
666
+ y && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
648
667
  return;
649
668
  }
650
669
  if (!(this._currentFrame > this.frame_capture_end)) {
@@ -652,7 +671,7 @@ class ye {
652
671
  if (this._seen.has(e)) {
653
672
  let n = this._seen.get(e);
654
673
  if (n >= this._maxPromisesPerObject) {
655
- x && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
674
+ y && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
656
675
  return;
657
676
  }
658
677
  this._seen.set(e, n + 1);
@@ -677,14 +696,14 @@ u(ye, "addPromise", (t, e, s, n) => {
677
696
  r.add(t, e, s);
678
697
  });
679
698
  });
680
- const F = de("debugprogressive"), xt = de("noprogressive"), be = Symbol("Needle:LODSManager"), Se = Symbol("Needle:LODState"), Q = Symbol("Needle:CurrentLOD"), $ = { mesh_lod: -1, texture_lod: -1 };
681
- var k, K, _e, J, ie, we, Y;
682
- const O = class {
699
+ const F = de("debugprogressive"), Lt = de("noprogressive"), be = Symbol("Needle:LODSManager"), Se = Symbol("Needle:LODState"), Q = Symbol("Needle:CurrentLOD"), G = { mesh_lod: -1, texture_lod: -1 };
700
+ var B, K, we, J, ie, _e, Y;
701
+ const b = class {
683
702
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
684
703
  constructor(t, e) {
685
704
  u(this, "renderer");
686
705
  u(this, "context");
687
- u(this, "projectionScreenMatrix", new Ge());
706
+ u(this, "projectionScreenMatrix", new Ie());
688
707
  /**
689
708
  * The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
690
709
  * @default 200_000
@@ -701,7 +720,7 @@ const O = class {
701
720
  * @default "auto"
702
721
  */
703
722
  u(this, "updateInterval", "auto");
704
- H(this, k, 1);
723
+ H(this, B, 1);
705
724
  /**
706
725
  * If set to true, the LODsManager will not update the LODs.
707
726
  * @default false
@@ -717,17 +736,17 @@ const O = class {
717
736
  u(this, "_promiseGroupIds", 0);
718
737
  u(this, "_lodchangedlisteners", []);
719
738
  H(this, K, void 0);
720
- H(this, _e, new je());
739
+ H(this, we, new Je());
721
740
  H(this, J, 0);
722
741
  H(this, ie, 0);
723
- H(this, we, 0);
742
+ H(this, _e, 0);
724
743
  H(this, Y, 0);
725
744
  u(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
726
745
  // private testIfLODLevelsAreAvailable() {
727
- u(this, "_sphere", new Ze());
728
- u(this, "_tempBox", new Ee());
729
- u(this, "_tempBox2", new Ee());
730
- u(this, "tempMatrix", new Ge());
746
+ u(this, "_sphere", new et());
747
+ u(this, "_tempBox", new $e());
748
+ u(this, "_tempBox2", new $e());
749
+ u(this, "tempMatrix", new Ie());
731
750
  u(this, "_tempWorldPosition", new W());
732
751
  u(this, "_tempBoxSize", new W());
733
752
  u(this, "_tempBox2Size", new W());
@@ -752,7 +771,7 @@ const O = class {
752
771
  static get(t, e) {
753
772
  if (t[be])
754
773
  return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[be];
755
- const s = new O(t, {
774
+ const s = new b(t, {
756
775
  engine: "unknown",
757
776
  ...e
758
777
  });
@@ -766,12 +785,12 @@ const O = class {
766
785
  * Call to await LODs loading during the next render cycle.
767
786
  */
768
787
  awaitLoading(t) {
769
- const e = this._promiseGroupIds++, s = new ye(y(this, J), { ...t });
788
+ const e = this._promiseGroupIds++, s = new ye(L(this, J), { ...t });
770
789
  this._newPromiseGroups.push(s);
771
790
  const n = performance.now();
772
791
  return s.ready.finally(() => {
773
792
  const r = this._newPromiseGroups.indexOf(s);
774
- r >= 0 && (this._newPromiseGroups.splice(r, 1), ct() && performance.measure("LODsManager:awaitLoading", {
793
+ r >= 0 && (this._newPromiseGroups.splice(r, 1), Ge() && performance.measure("LODsManager:awaitLoading", {
775
794
  start: n,
776
795
  detail: { id: e, name: t == null ? void 0 : t.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
777
796
  }));
@@ -780,7 +799,7 @@ const O = class {
780
799
  _postprocessPromiseGroups() {
781
800
  if (this._newPromiseGroups.length !== 0)
782
801
  for (let t = this._newPromiseGroups.length - 1; t >= 0; t--)
783
- this._newPromiseGroups[t].update(y(this, J));
802
+ this._newPromiseGroups[t].update(L(this, J));
784
803
  }
785
804
  addEventListener(t, e) {
786
805
  t === "changed" && this._lodchangedlisteners.push(e);
@@ -795,21 +814,21 @@ const O = class {
795
814
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
796
815
  */
797
816
  enable() {
798
- if (y(this, K))
817
+ if (L(this, K))
799
818
  return;
800
819
  console.debug("[gltf-progressive] Enabling LODsManager for renderer");
801
820
  let t = 0;
802
- q(this, K, this.renderer.render);
821
+ V(this, K, this.renderer.render);
803
822
  const e = this;
804
823
  Ue(this.renderer), this.renderer.render = function(s, n) {
805
824
  const r = e.renderer.getRenderTarget();
806
- (r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, q(e, J, y(e, J) + 1), q(e, ie, y(e, _e).getDelta()), q(e, we, y(e, we) + y(e, ie)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / y(e, ie)), q(e, Y, e._fpsBuffer.reduce((a, l) => a + l) / e._fpsBuffer.length), F && y(e, J) % 200 === 0 && console.log("FPS", Math.round(y(e, Y)), "Interval:", y(e, k)));
825
+ (r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, V(e, J, L(e, J) + 1), V(e, ie, L(e, we).getDelta()), V(e, _e, L(e, _e) + L(e, ie)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / L(e, ie)), V(e, Y, e._fpsBuffer.reduce((a, l) => a + l) / e._fpsBuffer.length), F && L(e, J) % 200 === 0 && console.log("FPS", Math.round(L(e, Y)), "Interval:", L(e, B)));
807
826
  const i = t++;
808
- y(e, K).call(this, s, n), e.onAfterRender(s, n, i);
827
+ L(e, K).call(this, s, n), e.onAfterRender(s, n, i);
809
828
  };
810
829
  }
811
830
  disable() {
812
- y(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, K), q(this, K, void 0));
831
+ L(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = L(this, K), V(this, K, void 0));
813
832
  }
814
833
  update(t, e) {
815
834
  this.internalUpdate(t, e);
@@ -824,7 +843,7 @@ const O = class {
824
843
  (a.name === "EffectMaterial" || a.name === "CopyShader") && (i = !1);
825
844
  }
826
845
  if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
827
- if (xt || (this.updateInterval === "auto" ? y(this, Y) < 40 && y(this, k) < 10 ? (q(this, k, y(this, k) + 1), F && console.warn("↓ Reducing LOD updates", y(this, k), y(this, Y).toFixed(0))) : y(this, Y) >= 60 && y(this, k) > 1 && (q(this, k, y(this, k) - 1), F && console.warn("↑ Increasing LOD updates", y(this, k), y(this, Y).toFixed(0))) : q(this, k, this.updateInterval), y(this, k) > 0 && y(this, J) % y(this, k) != 0))
846
+ if (Lt || (this.updateInterval === "auto" ? L(this, Y) < 40 && L(this, B) < 10 ? (V(this, B, L(this, B) + 1), F && console.warn("↓ Reducing LOD updates", L(this, B), L(this, Y).toFixed(0))) : L(this, Y) >= 60 && L(this, B) > 1 && (V(this, B, L(this, B) - 1), F && console.warn("↑ Increasing LOD updates", L(this, B), L(this, Y).toFixed(0))) : V(this, B, this.updateInterval), L(this, B) > 0 && L(this, J) % L(this, B) != 0))
828
847
  return;
829
848
  this.internalUpdate(t, e), this._postprocessPromiseGroups();
830
849
  }
@@ -853,21 +872,21 @@ const O = class {
853
872
  }
854
873
  if (F === "color" && d.material && !d.object.progressive_debug_color) {
855
874
  d.object.progressive_debug_color = !0;
856
- const f = Math.random() * 16777215, w = new Je({ color: f });
875
+ const f = Math.random() * 16777215, w = new Ze({ color: f });
857
876
  d.object.material = w;
858
877
  }
859
- const p = d.object;
860
- (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
878
+ const h = d.object;
879
+ (h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
861
880
  }
862
881
  const i = s.transparent;
863
882
  for (const d of i) {
864
- const p = d.object;
865
- (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
883
+ const h = d.object;
884
+ (h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
866
885
  }
867
886
  const a = s.transmissive;
868
887
  for (const d of a) {
869
- const p = d.object;
870
- (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
888
+ const h = d.object;
889
+ (h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
871
890
  }
872
891
  }
873
892
  /** Update the LOD levels for the renderer. */
@@ -875,15 +894,15 @@ const O = class {
875
894
  var a, l;
876
895
  s.userData || (s.userData = {});
877
896
  let r = s[Se];
878
- if (r || (r = new Lt(), s[Se] = r), r.frames++ < 2)
897
+ if (r || (r = new xt(), s[Se] = r), r.frames++ < 2)
879
898
  return;
880
899
  for (const c of j)
881
900
  (a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, t, e, s);
882
- const i = O.overrideGlobalLodLevel !== void 0 ? O.overrideGlobalLodLevel : te;
883
- i >= 0 ? ($.mesh_lod = i, $.texture_lod = i) : (this.calculateLodLevel(e, s, r, n, $), $.mesh_lod = Math.round($.mesh_lod), $.texture_lod = Math.round($.texture_lod)), $.mesh_lod >= 0 && this.loadProgressiveMeshes(s, $.mesh_lod), s.material && $.texture_lod >= 0 && this.loadProgressiveTextures(s.material, $.texture_lod), x && s.material && !s.isGizmo && qe(s.material);
901
+ const i = b.overrideGlobalLodLevel !== void 0 ? b.overrideGlobalLodLevel : te;
902
+ i >= 0 ? (G.mesh_lod = i, G.texture_lod = i) : (this.calculateLodLevel(e, s, r, n, G), G.mesh_lod = Math.round(G.mesh_lod), G.texture_lod = Math.round(G.texture_lod)), G.mesh_lod >= 0 && this.loadProgressiveMeshes(s, G.mesh_lod), s.material && G.texture_lod >= 0 && this.loadProgressiveTextures(s.material, G.texture_lod), y && s.material && !s.isGizmo && qe(s.material);
884
903
  for (const c of j)
885
- (l = c.onAfterUpdatedLOD) == null || l.call(c, this.renderer, t, e, s, $);
886
- r.lastLodLevel_Mesh = $.mesh_lod, r.lastLodLevel_Texture = $.texture_lod;
904
+ (l = c.onAfterUpdatedLOD) == null || l.call(c, this.renderer, t, e, s, G);
905
+ r.lastLodLevel_Mesh = G.mesh_lod, r.lastLodLevel_Texture = G.texture_lod;
887
906
  }
888
907
  /** Load progressive textures for the given material
889
908
  * @param material the material to load the textures for
@@ -903,7 +922,7 @@ const O = class {
903
922
  const n = t["DEBUG:LOD"];
904
923
  if (n != null && (s = t[Q] != n, e = n), s) {
905
924
  t[Q] = e;
906
- const r = P.assignTextureLOD(t, e).then((i) => {
925
+ const r = T.assignTextureLOD(t, e).then((i) => {
907
926
  this._lodchangedlisteners.forEach((a) => a({ type: "texture", level: e, object: t }));
908
927
  });
909
928
  ye.addPromise("texture", t, r, this._newPromiseGroups);
@@ -922,7 +941,7 @@ const O = class {
922
941
  const n = t["DEBUG:LOD"];
923
942
  if (n != null && (s = t[Q] != n, e = n), s) {
924
943
  t[Q] = e;
925
- const r = t.geometry, i = P.assignMeshLOD(t, e).then((a) => (a && t[Q] == e && r != t.geometry && this._lodchangedlisteners.forEach((l) => l({ type: "mesh", level: e, object: t })), a));
944
+ const r = t.geometry, i = T.assignMeshLOD(t, e).then((a) => (a && t[Q] == e && r != t.geometry && this._lodchangedlisteners.forEach((l) => l({ type: "mesh", level: e, object: t })), a));
926
945
  return ye.addPromise("mesh", t, i, this._newPromiseGroups), i;
927
946
  }
928
947
  return Promise.resolve(null);
@@ -932,7 +951,7 @@ const O = class {
932
951
  return this._tempPtInside.set(r, i, s.z).applyMatrix4(e).z < 0;
933
952
  }
934
953
  calculateLodLevel(t, e, s, n, r) {
935
- var b, R, Z;
954
+ var M, R, Z;
936
955
  if (!e) {
937
956
  r.mesh_lod = -1, r.texture_lod = -1;
938
957
  return;
@@ -944,102 +963,102 @@ const O = class {
944
963
  let a = 10 + 1, l = !1;
945
964
  if (F && e["DEBUG:LOD"] != null)
946
965
  return e["DEBUG:LOD"];
947
- const c = (b = P.getMeshLODExtension(e.geometry)) == null ? void 0 : b.lods, d = P.getPrimitiveIndex(e.geometry), p = c && c.length > 0, f = P.getMaterialMinMaxLODsCount(e.material), w = (f == null ? void 0 : f.min_count) != 1 / 0 && f.min_count > 0 && f.max_count > 0;
948
- if (!p && !w) {
966
+ const c = (M = T.getMeshLODExtension(e.geometry)) == null ? void 0 : M.lods, d = T.getPrimitiveIndex(e.geometry), h = c && c.length > 0, f = T.getMaterialMinMaxLODsCount(e.material), w = (f == null ? void 0 : f.min_count) != 1 / 0 && f.min_count > 0 && f.max_count > 0;
967
+ if (!h && !w) {
949
968
  r.mesh_lod = 0, r.texture_lod = 0;
950
969
  return;
951
970
  }
952
- p || (l = !0, a = 0);
953
- const M = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
954
- let A = e.geometry.boundingBox;
971
+ h || (l = !0, a = 0);
972
+ const v = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
973
+ let P = e.geometry.boundingBox;
955
974
  if (e.type === "SkinnedMesh") {
956
- const h = e;
957
- if (!h.boundingBox)
958
- h.computeBoundingBox();
975
+ const g = e;
976
+ if (!g.boundingBox)
977
+ g.computeBoundingBox();
959
978
  else if (this.skinnedMeshAutoUpdateBoundsInterval > 0) {
960
- if (!h[O.$skinnedMeshBoundsOffset]) {
961
- const C = O.skinnedMeshBoundsFrameOffsetCounter++;
962
- h[O.$skinnedMeshBoundsOffset] = C;
979
+ if (!g[b.$skinnedMeshBoundsOffset]) {
980
+ const E = b.skinnedMeshBoundsFrameOffsetCounter++;
981
+ g[b.$skinnedMeshBoundsOffset] = E;
963
982
  }
964
- const L = h[O.$skinnedMeshBoundsOffset];
965
- if ((s.frames + L) % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
966
- const C = ce(h), N = h.geometry;
967
- C && (h.geometry = C), h.computeBoundingBox(), h.geometry = N;
983
+ const x = g[b.$skinnedMeshBoundsOffset];
984
+ if ((s.frames + x) % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
985
+ const E = ce(g), U = g.geometry;
986
+ E && (g.geometry = E), g.computeBoundingBox(), g.geometry = U;
968
987
  }
969
988
  }
970
- A = h.boundingBox;
989
+ P = g.boundingBox;
971
990
  }
972
- if (A) {
973
- const h = t;
991
+ if (P) {
992
+ const g = t;
974
993
  if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
975
994
  this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
976
- const g = t.getWorldPosition(this._tempWorldPosition);
977
- if (this._sphere.containsPoint(g)) {
995
+ const p = t.getWorldPosition(this._tempWorldPosition);
996
+ if (this._sphere.containsPoint(p)) {
978
997
  r.mesh_lod = 0, r.texture_lod = 0;
979
998
  return;
980
999
  }
981
1000
  }
982
- if (this._tempBox.copy(A), this._tempBox.applyMatrix4(e.matrixWorld), h.isPerspectiveCamera && O.isInside(this._tempBox, this.projectionScreenMatrix)) {
1001
+ if (this._tempBox.copy(P), this._tempBox.applyMatrix4(e.matrixWorld), g.isPerspectiveCamera && b.isInside(this._tempBox, this.projectionScreenMatrix)) {
983
1002
  r.mesh_lod = 0, r.texture_lod = 0;
984
1003
  return;
985
1004
  }
986
- if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && h.isPerspectiveCamera && h.fov > 70) {
987
- const g = this._tempBox.min, _ = this._tempBox.max;
988
- let G = g.x, E = g.y, z = _.x, ne = _.y;
989
- const fe = 2, ve = 1.5, he = (g.x + _.x) * 0.5, ge = (g.y + _.y) * 0.5;
990
- G = (G - he) * fe + he, E = (E - ge) * fe + ge, z = (z - he) * fe + he, ne = (ne - ge) * fe + ge;
991
- const Xe = G < 0 && z > 0 ? 0 : Math.min(Math.abs(g.x), Math.abs(_.x)), Ke = E < 0 && ne > 0 ? 0 : Math.min(Math.abs(g.y), Math.abs(_.y)), Me = Math.max(Xe, Ke);
992
- s.lastCentrality = (ve - Me) * (ve - Me) * (ve - Me);
1005
+ if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && g.isPerspectiveCamera && g.fov > 70) {
1006
+ const p = this._tempBox.min, _ = this._tempBox.max;
1007
+ let $ = p.x, A = p.y, z = _.x, ne = _.y;
1008
+ const fe = 2, ve = 1.5, he = (p.x + _.x) * 0.5, ge = (p.y + _.y) * 0.5;
1009
+ $ = ($ - he) * fe + he, A = (A - ge) * fe + ge, z = (z - he) * fe + he, ne = (ne - ge) * fe + ge;
1010
+ const Ke = $ < 0 && z > 0 ? 0 : Math.min(Math.abs(p.x), Math.abs(_.x)), Ye = A < 0 && ne > 0 ? 0 : Math.min(Math.abs(p.y), Math.abs(_.y)), De = Math.max(Ke, Ye);
1011
+ s.lastCentrality = (ve - De) * (ve - De) * (ve - De);
993
1012
  } else
994
1013
  s.lastCentrality = 1;
995
- const L = this._tempBox.getSize(this._tempBoxSize);
996
- L.multiplyScalar(0.5), screen.availHeight > 0 && M > 0 && L.multiplyScalar(M / screen.availHeight), t.isPerspectiveCamera ? L.x *= t.aspect : t.isOrthographicCamera;
997
- const C = t.matrixWorldInverse, N = this._tempBox2;
998
- N.copy(A), N.applyMatrix4(e.matrixWorld), N.applyMatrix4(C);
999
- const S = N.getSize(this._tempBox2Size), ee = Math.max(S.x, S.y);
1000
- if (Math.max(L.x, L.y) != 0 && ee != 0 && (L.z = S.z / Math.max(S.x, S.y) * Math.max(L.x, L.y)), s.lastScreenCoverage = Math.max(L.x, L.y, L.z), s.lastScreenspaceVolume.copy(L), s.lastScreenCoverage *= s.lastCentrality, F && O.debugDrawLine) {
1001
- const g = this.tempMatrix.copy(this.projectionScreenMatrix);
1002
- g.invert();
1003
- const _ = O.corner0, G = O.corner1, E = O.corner2, z = O.corner3;
1004
- _.copy(this._tempBox.min), G.copy(this._tempBox.max), G.x = _.x, E.copy(this._tempBox.max), E.y = _.y, z.copy(this._tempBox.max);
1014
+ const x = this._tempBox.getSize(this._tempBoxSize);
1015
+ x.multiplyScalar(0.5), screen.availHeight > 0 && v > 0 && x.multiplyScalar(v / screen.availHeight), t.isPerspectiveCamera ? x.x *= t.aspect : t.isOrthographicCamera;
1016
+ const E = t.matrixWorldInverse, U = this._tempBox2;
1017
+ U.copy(P), U.applyMatrix4(e.matrixWorld), U.applyMatrix4(E);
1018
+ const S = U.getSize(this._tempBox2Size), ee = Math.max(S.x, S.y);
1019
+ if (Math.max(x.x, x.y) != 0 && ee != 0 && (x.z = S.z / Math.max(S.x, S.y) * Math.max(x.x, x.y)), s.lastScreenCoverage = Math.max(x.x, x.y, x.z), s.lastScreenspaceVolume.copy(x), s.lastScreenCoverage *= s.lastCentrality, F && b.debugDrawLine) {
1020
+ const p = this.tempMatrix.copy(this.projectionScreenMatrix);
1021
+ p.invert();
1022
+ const _ = b.corner0, $ = b.corner1, A = b.corner2, z = b.corner3;
1023
+ _.copy(this._tempBox.min), $.copy(this._tempBox.max), $.x = _.x, A.copy(this._tempBox.max), A.y = _.y, z.copy(this._tempBox.max);
1005
1024
  const ne = (_.z + z.z) * 0.5;
1006
- _.z = G.z = E.z = z.z = ne, _.applyMatrix4(g), G.applyMatrix4(g), E.applyMatrix4(g), z.applyMatrix4(g), O.debugDrawLine(_, G, 255), O.debugDrawLine(_, E, 255), O.debugDrawLine(G, z, 255), O.debugDrawLine(E, z, 255);
1025
+ _.z = $.z = A.z = z.z = ne, _.applyMatrix4(p), $.applyMatrix4(p), A.applyMatrix4(p), z.applyMatrix4(p), b.debugDrawLine(_, $, 255), b.debugDrawLine(_, A, 255), b.debugDrawLine($, z, 255), b.debugDrawLine(A, z, 255);
1007
1026
  }
1008
- let v = 999;
1027
+ let D = 999;
1009
1028
  if (c && s.lastScreenCoverage > 0)
1010
- for (let g = 0; g < c.length; g++) {
1011
- const _ = c[g];
1012
- if ((((R = _.densities) == null ? void 0 : R[d]) || _.density || 1e-5) / s.lastScreenCoverage < n) {
1013
- v = g;
1029
+ for (let p = 0; p < c.length; p++) {
1030
+ const _ = c[p], A = (((R = _.densities) == null ? void 0 : R[d]) || _.density || 1e-5) / s.lastScreenCoverage;
1031
+ if (d > 0 && Ge() && !_.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] = !0, console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")), A < n) {
1032
+ D = p;
1014
1033
  break;
1015
1034
  }
1016
1035
  }
1017
- v < a && (a = v, l = !0);
1036
+ D < a && (a = D, l = !0);
1018
1037
  }
1019
1038
  if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, F && r.mesh_lod != s.lastLodLevel_Mesh) {
1020
- const L = c == null ? void 0 : c[r.mesh_lod];
1021
- L && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${L.density.toFixed(0)}) - ${e.name}`);
1039
+ const x = c == null ? void 0 : c[r.mesh_lod];
1040
+ x && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${x.density.toFixed(0)}) - ${e.name}`);
1022
1041
  }
1023
1042
  if (w) {
1024
- const h = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
1043
+ const g = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
1025
1044
  if (s.lastLodLevel_Texture < 0) {
1026
1045
  if (r.texture_lod = f.max_count - 1, F) {
1027
- const L = f.lods[f.max_count - 1];
1028
- F && console.log(`First Texture LOD ${r.texture_lod} (${L.max_height}px) - ${e.name}`);
1046
+ const x = f.lods[f.max_count - 1];
1047
+ F && console.log(`First Texture LOD ${r.texture_lod} (${x.max_height}px) - ${e.name}`);
1029
1048
  }
1030
1049
  } else {
1031
- const L = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
1032
- let C = s.lastScreenCoverage * 4;
1033
- ((Z = this.context) == null ? void 0 : Z.engine) === "model-viewer" && (C *= 1.5);
1034
- const S = M / window.devicePixelRatio * C;
1050
+ const x = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
1051
+ let E = s.lastScreenCoverage * 4;
1052
+ ((Z = this.context) == null ? void 0 : Z.engine) === "model-viewer" && (E *= 1.5);
1053
+ const S = v / window.devicePixelRatio * E;
1035
1054
  let ee = !1;
1036
- for (let B = f.lods.length - 1; B >= 0; B--) {
1037
- const v = f.lods[B];
1038
- if (!(h && v.max_height >= 2048) && !(dt() && v.max_height > 4096) && (v.max_height > S || !ee && B === 0)) {
1039
- if (ee = !0, r.texture_lod = B, r.texture_lod < s.lastLodLevel_Texture) {
1040
- const m = v.max_height;
1055
+ for (let I = f.lods.length - 1; I >= 0; I--) {
1056
+ const D = f.lods[I];
1057
+ if (!(g && D.max_height >= 2048) && !(ct() && D.max_height > 4096) && (D.max_height > S || !ee && I === 0)) {
1058
+ if (ee = !0, r.texture_lod = I, r.texture_lod < s.lastLodLevel_Texture) {
1059
+ const m = D.max_height;
1041
1060
  F && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${m}px
1042
- Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${L.toFixed(1)}
1061
+ Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${x.toFixed(1)}
1043
1062
  ${e.name}`);
1044
1063
  }
1045
1064
  break;
@@ -1050,15 +1069,15 @@ ${e.name}`);
1050
1069
  r.texture_lod = 0;
1051
1070
  }
1052
1071
  };
1053
- let T = O;
1054
- k = new WeakMap(), K = new WeakMap(), _e = new WeakMap(), J = new WeakMap(), ie = new WeakMap(), we = new WeakMap(), Y = new WeakMap(), /**
1072
+ let C = b;
1073
+ B = new WeakMap(), K = new WeakMap(), we = new WeakMap(), J = new WeakMap(), ie = new WeakMap(), _e = new WeakMap(), Y = new WeakMap(), /**
1055
1074
  * Assign a function to draw debug lines for the LODs. This function will be called with the start and end position of the line and the color of the line when the `debugprogressive` query parameter is set.
1056
1075
  */
1057
- u(T, "debugDrawLine"), /**
1076
+ u(C, "debugDrawLine"), /**
1058
1077
  * Force override the LOD level for all objects in the scene
1059
1078
  */
1060
- u(T, "overrideGlobalLodLevel"), u(T, "corner0", new W()), u(T, "corner1", new W()), u(T, "corner2", new W()), u(T, "corner3", new W()), u(T, "_tempPtInside", new W()), u(T, "skinnedMeshBoundsFrameOffsetCounter", 0), u(T, "$skinnedMeshBoundsOffset", Symbol("gltf-progressive-skinnedMeshBoundsOffset"));
1061
- class Lt {
1079
+ u(C, "overrideGlobalLodLevel"), u(C, "corner0", new W()), u(C, "corner1", new W()), u(C, "corner2", new W()), u(C, "corner3", new W()), u(C, "_tempPtInside", new W()), u(C, "skinnedMeshBoundsFrameOffsetCounter", 0), u(C, "$skinnedMeshBoundsOffset", Symbol("gltf-progressive-skinnedMeshBoundsOffset"));
1080
+ class xt {
1062
1081
  constructor() {
1063
1082
  u(this, "frames", 0);
1064
1083
  u(this, "lastLodLevel_Mesh", -1);
@@ -1068,41 +1087,41 @@ class Lt {
1068
1087
  u(this, "lastCentrality", 0);
1069
1088
  }
1070
1089
  }
1071
- const $e = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
1090
+ const Be = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
1072
1091
  let ue = null;
1073
- function Ve() {
1074
- const o = _t();
1092
+ function We() {
1093
+ const o = wt();
1075
1094
  o && (o.mapURLs(function(t) {
1076
1095
  return ke(), t;
1077
1096
  }), ke(), ue == null || ue.disconnect(), ue = new MutationObserver((t) => {
1078
1097
  t.forEach((e) => {
1079
1098
  e.addedNodes.forEach((s) => {
1080
- s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && We(s);
1099
+ s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Xe(s);
1081
1100
  });
1082
1101
  });
1083
1102
  }), ue.observe(document, { childList: !0, subtree: !0 }));
1084
1103
  }
1085
- function _t() {
1104
+ function wt() {
1086
1105
  if (typeof customElements > "u")
1087
1106
  return null;
1088
1107
  const o = customElements.get("model-viewer");
1089
1108
  return o || (customElements.whenDefined("model-viewer").then(() => {
1090
- console.debug("[gltf-progressive] model-viewer defined"), Ve();
1109
+ console.debug("[gltf-progressive] model-viewer defined"), We();
1091
1110
  }), null);
1092
1111
  }
1093
1112
  function ke() {
1094
1113
  if (typeof document > "u")
1095
1114
  return;
1096
1115
  document.querySelectorAll("model-viewer").forEach((t) => {
1097
- We(t);
1116
+ Xe(t);
1098
1117
  });
1099
1118
  }
1100
- const Ie = /* @__PURE__ */ new WeakSet();
1101
- let wt = 0;
1102
- function We(o) {
1103
- if (!o || Ie.has(o))
1119
+ const Re = /* @__PURE__ */ new WeakSet();
1120
+ let _t = 0;
1121
+ function Xe(o) {
1122
+ if (!o || Re.has(o))
1104
1123
  return null;
1105
- Ie.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++wt + `
1124
+ Re.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++_t + `
1106
1125
  `, o.getAttribute("src"));
1107
1126
  let t = null, e = null, s = null;
1108
1127
  for (let n = o; n != null; n = Object.getPrototypeOf(n)) {
@@ -1122,8 +1141,8 @@ function We(o) {
1122
1141
  }
1123
1142
  };
1124
1143
  console.debug("[gltf-progressive] setup model-viewer");
1125
- const r = T.get(t, { engine: "model-viewer" });
1126
- return T.addPlugin(new vt()), r.enable(), r.addEventListener("changed", () => {
1144
+ const r = C.get(t, { engine: "model-viewer" });
1145
+ return C.addPlugin(new vt()), r.enable(), r.addEventListener("changed", () => {
1127
1146
  s == null || s.call(o);
1128
1147
  }), o.addEventListener("model-visibility", (i) => {
1129
1148
  i.detail.visible && (s == null || s.call(o));
@@ -1161,25 +1180,25 @@ class vt {
1161
1180
  const s = this.tryGetCurrentGLTF(t), n = this.tryGetCurrentModelViewer(t), r = this.getUrl(n);
1162
1181
  if (r && s && e.material) {
1163
1182
  let i = function(l) {
1164
- var d, p, f;
1183
+ var d, h, f;
1165
1184
  if (l[pe] == !0)
1166
1185
  return;
1167
1186
  l[pe] = !0, l.userData && (l.userData.LOD = -1);
1168
1187
  const c = Object.keys(l);
1169
1188
  for (let w = 0; w < c.length; w++) {
1170
- const M = c[w], A = l[M];
1171
- if ((A == null ? void 0 : A.isTexture) === !0) {
1172
- const b = (p = (d = A.userData) == null ? void 0 : d.associations) == null ? void 0 : p.textures;
1173
- if (b == null)
1189
+ const v = c[w], P = l[v];
1190
+ if ((P == null ? void 0 : P.isTexture) === !0) {
1191
+ const M = (h = (d = P.userData) == null ? void 0 : d.associations) == null ? void 0 : h.textures;
1192
+ if (M == null)
1174
1193
  continue;
1175
- const R = s.parser.json.textures[b];
1194
+ const R = s.parser.json.textures[M];
1176
1195
  if (!R) {
1177
- console.warn("Texture data not found for texture index " + b);
1196
+ console.warn("Texture data not found for texture index " + M);
1178
1197
  continue;
1179
1198
  }
1180
1199
  if ((f = R == null ? void 0 : R.extensions) != null && f[X]) {
1181
1200
  const Z = R.extensions[X];
1182
- Z && r && P.registerTexture(r, A, Z.lods.length, b, Z);
1201
+ Z && r && T.registerTexture(r, P, Z.lods.length, M, Z);
1183
1202
  }
1184
1203
  }
1185
1204
  }
@@ -1194,34 +1213,34 @@ class vt {
1194
1213
  }
1195
1214
  tryParseMeshLOD(t, e) {
1196
1215
  var i, a;
1197
- if (e[$e] == !0)
1216
+ if (e[Be] == !0)
1198
1217
  return;
1199
- e[$e] = !0;
1218
+ e[Be] = !0;
1200
1219
  const s = this.tryGetCurrentModelViewer(t), n = this.getUrl(s);
1201
1220
  if (!n)
1202
1221
  return;
1203
1222
  const r = (a = (i = e.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[X];
1204
1223
  if (r && n) {
1205
1224
  const l = e.uuid;
1206
- P.registerMesh(n, l, e, 0, r.lods.length, r);
1225
+ T.registerMesh(n, l, e, 0, r.lods.length, r);
1207
1226
  }
1208
1227
  }
1209
1228
  }
1210
- function Mt(o, t, e, s) {
1211
- Ue(t), Ne(e), ze(e, {
1229
+ function Dt(o, t, e, s) {
1230
+ Ue(t), ze(e), Ve(e, {
1212
1231
  progressive: !0,
1213
1232
  ...s == null ? void 0 : s.hints
1214
- }), e.register((r) => new P(r, o));
1215
- const n = T.get(t);
1233
+ }), e.register((r) => new T(r, o));
1234
+ const n = C.get(t);
1216
1235
  return (s == null ? void 0 : s.enableLODsManager) !== !1 && n.enable(), n;
1217
1236
  }
1218
- Ve();
1237
+ We();
1219
1238
  if (!ht) {
1220
1239
  const o = {
1221
1240
  gltfProgressive: {
1222
- useNeedleProgressive: Mt,
1223
- LODsManager: T,
1224
- configureLoader: ze,
1241
+ useNeedleProgressive: Dt,
1242
+ LODsManager: C,
1243
+ configureLoader: Ve,
1225
1244
  getRaycastMesh: ce,
1226
1245
  useRaycastMeshes: pt
1227
1246
  }
@@ -1234,17 +1253,17 @@ if (!ht) {
1234
1253
  }
1235
1254
  export {
1236
1255
  X as EXTENSION_NAME,
1237
- T as LODsManager,
1238
- P as NEEDLE_progressive,
1239
- rt as VERSION,
1240
- Ne as addDracoAndKTX2Loaders,
1241
- ze as configureLoader,
1256
+ C as LODsManager,
1257
+ T as NEEDLE_progressive,
1258
+ it as VERSION,
1259
+ ze as addDracoAndKTX2Loaders,
1260
+ Ve as configureLoader,
1242
1261
  Ue as createLoaders,
1243
1262
  ce as getRaycastMesh,
1244
- Ve as patchModelViewer,
1263
+ We as patchModelViewer,
1245
1264
  gt as registerRaycastMesh,
1246
- ot as setDracoDecoderLocation,
1247
- at as setKTX2TranscoderLocation,
1248
- Mt as useNeedleProgressive,
1265
+ at as setDracoDecoderLocation,
1266
+ lt as setKTX2TranscoderLocation,
1267
+ Dt as useNeedleProgressive,
1249
1268
  pt as useRaycastMeshes
1250
1269
  };