@needle-tools/gltf-progressive 3.1.0-next.f550970 → 3.1.0

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 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) => {
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) => {
4
4
  if (!t.has(o))
5
5
  throw TypeError("Cannot " + e);
6
6
  };
7
- var L = (o, t, e) => (Ee(o, t, "read from private field"), e ? e.call(o) : t.get(o)), H = (o, t, e) => {
7
+ var y = (o, t, e) => (Be(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
- }, 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";
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";
13
13
  import { GLTFLoader as Ce } from "three/examples/jsm/loaders/GLTFLoader.js";
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;
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;
19
19
  console.debug("[gltf-progressive] version -");
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, {
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, {
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 ${q} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), q === nt && at("./include/draco/"), re === ot && lt("./include/ktx2/");
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/");
30
30
  }).finally(() => {
31
- Ne();
31
+ Fe();
32
32
  });
33
- function at(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);
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
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);
36
+ 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);
38
38
  }
39
39
  const Pe = Symbol("dracoDecoderPath");
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);
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);
43
43
  }
44
44
  function Ue(o) {
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 };
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 };
46
46
  }
47
- function ze(o) {
48
- o.dracoLoader || o.setDRACOLoader(k), o.ktx2Loader || o.setKTX2Loader(N), o.meshoptDecoder || o.setMeshoptDecoder(xe);
47
+ function Ne(o) {
48
+ o.dracoLoader || o.setDRACOLoader(I), o.ktx2Loader || o.setKTX2Loader(U), o.meshoptDecoder || o.setMeshoptDecoder(Le);
49
49
  }
50
50
  const Te = /* @__PURE__ */ new WeakMap();
51
- function Ve(o, t) {
51
+ function ze(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 Me = Ce.prototype.load;
56
- function ut(...o) {
55
+ const De = Ce.prototype.load;
56
+ function lt(...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 ut(...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, Me == null ? void 0 : Me.call(this, ...o);
64
+ return o[0] = e, De == null ? void 0 : De.call(this, ...o);
65
65
  }
66
- Ce.prototype.load = ut;
66
+ Ce.prototype.load = lt;
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 dt(o, t) {
74
+ function ut(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 dt(o, t) {
84
84
  return t;
85
85
  }
86
86
  let ae;
87
- function ct() {
87
+ function dt() {
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 Ge() {
90
+ function ct() {
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 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})`));
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}`));
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 Le ? o[Ae] : null;
132
+ return (o == null ? void 0 : o[Ae]) instanceof xe ? 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 Le();
158
+ const t = new xe();
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(), y = de("debugprogressive");
163
+ const j = new Array(), x = de("debugprogressive");
164
164
  let me, te = -1;
165
- if (y) {
165
+ if (x) {
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 (y) {
173
173
  });
174
174
  }
175
175
  function qe(o) {
176
- if (y)
176
+ if (x)
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"), O = class {
183
+ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = 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"), O = 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 && O.registerMesh(this.url, e.guid, r, (i = e.lods) == null ? void 0 : i.length, 0, e), r;
195
+ return this._isLoadingMesh = !1, r && D.registerMesh(this.url, e.guid, r, (i = e.lods) == null ? void 0 : i.length, 0, e), r;
196
196
  })) : null;
197
197
  });
198
- y && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
198
+ x && 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"), O = c
223
223
  this.getMaterialMinMaxLODsCount(a, e);
224
224
  return t[n] = e, e;
225
225
  }
226
- if (y === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
226
+ if (x === "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"), O = 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 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));
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));
247
247
  }
248
248
  }
249
249
  }
@@ -308,15 +308,15 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), O = 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, O.getOrLoadLOD(n, e).then((i) => {
311
+ return t["LOD:requested level"] = e, D.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 : y && 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 : x && console.error("Invalid LOD geometry", i))), i;
317
317
  }).catch((i) => (console.error("Error loading mesh LOD", t, i), null));
318
318
  } else
319
- y && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
319
+ x && 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,59 +374,45 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), O = 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) : O.getOrLoadLOD(t, e).then((r) => {
377
+ return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : D.getOrLoadLOD(t, e).then((r) => {
378
378
  if (Array.isArray(r))
379
- return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen", r), null;
379
+ return 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 && !y) {
383
+ if (i && !x) {
384
384
  const a = this.getAssignedLODInformation(i);
385
385
  if (a && (a == null ? void 0 : a.level) < e)
386
- return y === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, e, s, i, r), null;
386
+ return x === "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
- y == "verbose" && console.warn("No LOD found for", t, e);
392
+ x == "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
- // }
410
396
  afterRoot(t) {
411
397
  var e, s;
412
- return y && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, r) => {
398
+ return x && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, r) => {
413
399
  var i;
414
400
  if (n != null && n.extensions) {
415
401
  const a = n == null ? void 0 : n.extensions[X];
416
402
  if (a) {
417
403
  if (!a.lods) {
418
- y && console.warn("Texture has no LODs", a);
404
+ x && console.warn("Texture has no LODs", a);
419
405
  return;
420
406
  }
421
407
  let l = !1;
422
408
  for (const c of this.parser.associations.keys())
423
409
  if (c.isTexture === !0) {
424
410
  const d = this.parser.associations.get(c);
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));
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));
426
412
  }
427
413
  l || this.parser.getDependency("texture", r).then((c) => {
428
414
  var d;
429
- c && O.registerTexture(this.url, c, (d = a.lods) == null ? void 0 : d.length, r, a);
415
+ c && D.registerTexture(this.url, c, (d = a.lods) == null ? void 0 : d.length, r, a);
430
416
  });
431
417
  }
432
418
  }
@@ -437,7 +423,7 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), O = c
437
423
  for (const a of this.parser.associations.keys())
438
424
  if (a.isMesh) {
439
425
  const l = this.parser.associations.get(a);
440
- (l == null ? void 0 : l.meshes) === r && O.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
426
+ (l == null ? void 0 : l.meshes) === r && D.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
441
427
  }
442
428
  }
443
429
  }
@@ -445,114 +431,114 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), O = c
445
431
  }
446
432
  static async getOrLoadLOD(t, e) {
447
433
  var a, l, c, d;
448
- const s = y == "verbose", n = this.getAssignedLODInformation(t);
434
+ const s = x == "verbose", n = t.userData.LODS;
449
435
  if (!n)
450
- return y && console.warn(`[gltf-progressive] No LOD information found: ${t.name}, uuid: ${t.uuid}, type: ${t.type}`, t), null;
436
+ return null;
451
437
  const r = n == null ? void 0 : n.key;
452
438
  let i;
453
439
  if (t.isTexture === !0) {
454
- const h = t;
455
- h.source && h.source[Oe] && (i = h.source[Oe]);
440
+ const p = t;
441
+ p.source && p.source[Oe] && (i = p.source[Oe]);
456
442
  }
457
- if (i || (i = O.lodInfos.get(r)), i) {
443
+ if (i || (i = D.lodInfos.get(r)), i) {
458
444
  if (e > 0) {
459
445
  let w = !1;
460
- const v = Array.isArray(i.lods);
461
- if (v && e >= i.lods.length ? w = !0 : v || (w = !0), w)
446
+ const M = Array.isArray(i.lods);
447
+ if (M && e >= i.lods.length ? w = !0 : M || (w = !0), w)
462
448
  return this.lowresCache.get(r);
463
449
  }
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);
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);
468
454
  if (f.endsWith(".glb") || f.endsWith(".gltf")) {
469
455
  if (!i.guid)
470
456
  return console.warn("missing pointer for glb/gltf texture", i), null;
471
- const w = f + "_" + i.guid, v = this.previouslyLoaded.get(w);
472
- if (v !== void 0) {
457
+ const w = f + "_" + i.guid, M = this.previouslyLoaded.get(w);
458
+ if (M !== void 0) {
473
459
  s && console.log(`LOD ${e} was already loading/loaded: ${w}`);
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;
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;
478
464
  }
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);
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);
489
475
  }
490
- const S = await E.loadAsync(U).catch((D) => (console.error(`Error loading LOD ${e} from ${f}
491
- `, D), g(null)));
476
+ const S = await C.loadAsync(N).catch((v) => (console.error(`Error loading LOD ${e} from ${f}
477
+ `, v), h(null)));
492
478
  if (!S)
493
- return g(null);
479
+ return h(null);
494
480
  const ee = S.parser;
495
- s && console.log("Loading finished " + f, M.guid);
496
- let I = 0;
481
+ s && console.log("Loading finished " + f, b.guid);
482
+ let B = 0;
497
483
  if (S.parser.json.textures) {
498
- let D = !1;
484
+ let v = !1;
499
485
  for (const m of S.parser.json.textures) {
500
486
  if (m != null && m.extensions) {
501
- const p = m == null ? void 0 : m.extensions[X];
502
- if (p != null && p.guid && p.guid === M.guid) {
503
- D = !0;
487
+ const g = m == null ? void 0 : m.extensions[X];
488
+ if (g != null && g.guid && g.guid === b.guid) {
489
+ v = !0;
504
490
  break;
505
491
  }
506
492
  }
507
- I++;
493
+ B++;
508
494
  }
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);
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);
512
498
  } else
513
- y && console.warn("Could not find texture with guid", M.guid, S.parser.json);
499
+ x && console.warn("Could not find texture with guid", b.guid, S.parser.json);
514
500
  }
515
- if (I = 0, S.parser.json.meshes) {
516
- let D = !1;
501
+ if (B = 0, S.parser.json.meshes) {
502
+ let v = !1;
517
503
  for (const m of S.parser.json.meshes) {
518
504
  if (m != null && m.extensions) {
519
- const p = m == null ? void 0 : m.extensions[X];
520
- if (p != null && p.guid && p.guid === M.guid) {
521
- D = !0;
505
+ const g = m == null ? void 0 : m.extensions[X];
506
+ if (g != null && g.guid && g.guid === b.guid) {
507
+ v = !0;
522
508
  break;
523
509
  }
524
510
  }
525
- I++;
511
+ B++;
526
512
  }
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);
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);
532
518
  } else {
533
- const p = new Array();
519
+ const g = new Array();
534
520
  for (let _ = 0; _ < m.children.length; _++) {
535
- const $ = m.children[_];
536
- if ($.isMesh === !0) {
537
- const A = $.geometry;
538
- O.assignLODInformation(n.url, A, r, e, _), p.push(A);
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);
539
525
  }
540
526
  }
541
- return g(p);
527
+ return h(g);
542
528
  }
543
529
  } else
544
- y && console.warn("Could not find mesh with guid", M.guid, S.parser.json);
530
+ x && console.warn("Could not find mesh with guid", b.guid, S.parser.json);
545
531
  }
546
- return g(null);
532
+ return h(null);
547
533
  });
548
- return this.previouslyLoaded.set(w, R), P.use(R), await R;
534
+ return this.previouslyLoaded.set(w, R), A.use(R), await R;
549
535
  } else if (t instanceof oe) {
550
536
  s && console.log("Load texture from uri: " + f);
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;
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;
553
539
  }
554
540
  } else
555
- y && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
541
+ x && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
556
542
  return null;
557
543
  }
558
544
  static assignLODInformation(t, e, s, n, r) {
@@ -560,55 +546,50 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), O = c
560
546
  return;
561
547
  e.userData || (e.userData = {});
562
548
  const i = new yt(t, s, n, r);
563
- e.userData.LODS = i, "source" in e && typeof e.source == "object" && (e.source.LODS = i);
549
+ e.userData.LODS = i;
564
550
  }
565
551
  static getAssignedLODInformation(t) {
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;
552
+ var e;
553
+ return ((e = t == null ? void 0 : t.userData) == null ? void 0 : e.LODS) || null;
568
554
  }
569
555
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
570
556
  static copySettings(t, e) {
571
- return e ? (y && console.warn(`Copy texture settings
557
+ return e ? (x && console.warn(`Copy texture settings
572
558
  `, t.uuid, `
573
559
  `, 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;
574
560
  }
575
561
  };
576
- let T = O;
562
+ let P = D;
577
563
  /**
578
564
  * Register a texture with LOD information
579
565
  */
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");
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");
584
569
  return;
585
570
  }
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
- }
590
571
  e.source && (e.source[Oe] = r);
591
572
  const i = r.guid;
592
- O.assignLODInformation(t, e, i, s, n), O.lodInfos.set(i, r), O.lowresCache.set(i, e);
573
+ D.assignLODInformation(t, e, i, s, n), D.lodInfos.set(i, r), D.lowresCache.set(i, e);
593
574
  }), /**
594
575
  * Register a mesh with LOD information
595
576
  */
596
- u(T, "registerMesh", (t, e, s, n, r, i) => {
577
+ u(P, "registerMesh", (t, e, s, n, r, i) => {
597
578
  var c;
598
579
  const a = s.geometry;
599
580
  if (!a) {
600
- y && console.warn("gltf-progressive: Register mesh without geometry");
581
+ x && console.warn("gltf-progressive: Register mesh without geometry");
601
582
  return;
602
583
  }
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);
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);
606
587
  for (const d of j)
607
588
  (c = d.onRegisteredNewMesh) == null || c.call(d, s, i);
608
589
  }), /** A map of key = asset uuid and value = LOD information */
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 }));
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 }));
612
593
  class yt {
613
594
  constructor(t, e, s, n) {
614
595
  u(this, "url");
@@ -663,7 +644,7 @@ class ye {
663
644
  }
664
645
  add(t, e, s) {
665
646
  if (this._resolved) {
666
- y && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
647
+ x && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
667
648
  return;
668
649
  }
669
650
  if (!(this._currentFrame > this.frame_capture_end)) {
@@ -671,7 +652,7 @@ class ye {
671
652
  if (this._seen.has(e)) {
672
653
  let n = this._seen.get(e);
673
654
  if (n >= this._maxPromisesPerObject) {
674
- y && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
655
+ x && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
675
656
  return;
676
657
  }
677
658
  this._seen.set(e, n + 1);
@@ -696,14 +677,14 @@ u(ye, "addPromise", (t, e, s, n) => {
696
677
  r.add(t, e, s);
697
678
  });
698
679
  });
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 {
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 {
702
683
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
703
684
  constructor(t, e) {
704
685
  u(this, "renderer");
705
686
  u(this, "context");
706
- u(this, "projectionScreenMatrix", new Ie());
687
+ u(this, "projectionScreenMatrix", new Ge());
707
688
  /**
708
689
  * The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
709
690
  * @default 200_000
@@ -720,7 +701,7 @@ const b = class {
720
701
  * @default "auto"
721
702
  */
722
703
  u(this, "updateInterval", "auto");
723
- H(this, B, 1);
704
+ H(this, k, 1);
724
705
  /**
725
706
  * If set to true, the LODsManager will not update the LODs.
726
707
  * @default false
@@ -736,17 +717,17 @@ const b = class {
736
717
  u(this, "_promiseGroupIds", 0);
737
718
  u(this, "_lodchangedlisteners", []);
738
719
  H(this, K, void 0);
739
- H(this, we, new Je());
720
+ H(this, _e, new je());
740
721
  H(this, J, 0);
741
722
  H(this, ie, 0);
742
- H(this, _e, 0);
723
+ H(this, we, 0);
743
724
  H(this, Y, 0);
744
725
  u(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
745
726
  // private testIfLODLevelsAreAvailable() {
746
- u(this, "_sphere", new et());
747
- u(this, "_tempBox", new $e());
748
- u(this, "_tempBox2", new $e());
749
- u(this, "tempMatrix", new Ie());
727
+ u(this, "_sphere", new Ze());
728
+ u(this, "_tempBox", new Ee());
729
+ u(this, "_tempBox2", new Ee());
730
+ u(this, "tempMatrix", new Ge());
750
731
  u(this, "_tempWorldPosition", new W());
751
732
  u(this, "_tempBoxSize", new W());
752
733
  u(this, "_tempBox2Size", new W());
@@ -771,7 +752,7 @@ const b = class {
771
752
  static get(t, e) {
772
753
  if (t[be])
773
754
  return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[be];
774
- const s = new b(t, {
755
+ const s = new O(t, {
775
756
  engine: "unknown",
776
757
  ...e
777
758
  });
@@ -785,12 +766,12 @@ const b = class {
785
766
  * Call to await LODs loading during the next render cycle.
786
767
  */
787
768
  awaitLoading(t) {
788
- const e = this._promiseGroupIds++, s = new ye(L(this, J), { ...t });
769
+ const e = this._promiseGroupIds++, s = new ye(y(this, J), { ...t });
789
770
  this._newPromiseGroups.push(s);
790
771
  const n = performance.now();
791
772
  return s.ready.finally(() => {
792
773
  const r = this._newPromiseGroups.indexOf(s);
793
- r >= 0 && (this._newPromiseGroups.splice(r, 1), Ge() && performance.measure("LODsManager:awaitLoading", {
774
+ r >= 0 && (this._newPromiseGroups.splice(r, 1), ct() && performance.measure("LODsManager:awaitLoading", {
794
775
  start: n,
795
776
  detail: { id: e, name: t == null ? void 0 : t.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
796
777
  }));
@@ -799,7 +780,7 @@ const b = class {
799
780
  _postprocessPromiseGroups() {
800
781
  if (this._newPromiseGroups.length !== 0)
801
782
  for (let t = this._newPromiseGroups.length - 1; t >= 0; t--)
802
- this._newPromiseGroups[t].update(L(this, J));
783
+ this._newPromiseGroups[t].update(y(this, J));
803
784
  }
804
785
  addEventListener(t, e) {
805
786
  t === "changed" && this._lodchangedlisteners.push(e);
@@ -814,21 +795,21 @@ const b = class {
814
795
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
815
796
  */
816
797
  enable() {
817
- if (L(this, K))
798
+ if (y(this, K))
818
799
  return;
819
800
  console.debug("[gltf-progressive] Enabling LODsManager for renderer");
820
801
  let t = 0;
821
- V(this, K, this.renderer.render);
802
+ q(this, K, this.renderer.render);
822
803
  const e = this;
823
804
  Ue(this.renderer), this.renderer.render = function(s, n) {
824
805
  const r = e.renderer.getRenderTarget();
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)));
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)));
826
807
  const i = t++;
827
- L(e, K).call(this, s, n), e.onAfterRender(s, n, i);
808
+ y(e, K).call(this, s, n), e.onAfterRender(s, n, i);
828
809
  };
829
810
  }
830
811
  disable() {
831
- L(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = L(this, K), V(this, K, void 0));
812
+ y(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, K), q(this, K, void 0));
832
813
  }
833
814
  update(t, e) {
834
815
  this.internalUpdate(t, e);
@@ -843,7 +824,7 @@ const b = class {
843
824
  (a.name === "EffectMaterial" || a.name === "CopyShader") && (i = !1);
844
825
  }
845
826
  if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
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))
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))
847
828
  return;
848
829
  this.internalUpdate(t, e), this._postprocessPromiseGroups();
849
830
  }
@@ -872,21 +853,21 @@ const b = class {
872
853
  }
873
854
  if (F === "color" && d.material && !d.object.progressive_debug_color) {
874
855
  d.object.progressive_debug_color = !0;
875
- const f = Math.random() * 16777215, w = new Ze({ color: f });
856
+ const f = Math.random() * 16777215, w = new Je({ color: f });
876
857
  d.object.material = w;
877
858
  }
878
- const h = d.object;
879
- (h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
859
+ const p = d.object;
860
+ (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
880
861
  }
881
862
  const i = s.transparent;
882
863
  for (const d of i) {
883
- const h = d.object;
884
- (h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
864
+ const p = d.object;
865
+ (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
885
866
  }
886
867
  const a = s.transmissive;
887
868
  for (const d of a) {
888
- const h = d.object;
889
- (h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
869
+ const p = d.object;
870
+ (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
890
871
  }
891
872
  }
892
873
  /** Update the LOD levels for the renderer. */
@@ -894,15 +875,15 @@ const b = class {
894
875
  var a, l;
895
876
  s.userData || (s.userData = {});
896
877
  let r = s[Se];
897
- if (r || (r = new xt(), s[Se] = r), r.frames++ < 2)
878
+ if (r || (r = new Lt(), s[Se] = r), r.frames++ < 2)
898
879
  return;
899
880
  for (const c of j)
900
881
  (a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, t, e, s);
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);
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);
903
884
  for (const c of j)
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;
885
+ (l = c.onAfterUpdatedLOD) == null || l.call(c, this.renderer, t, e, s, $);
886
+ r.lastLodLevel_Mesh = $.mesh_lod, r.lastLodLevel_Texture = $.texture_lod;
906
887
  }
907
888
  /** Load progressive textures for the given material
908
889
  * @param material the material to load the textures for
@@ -922,7 +903,7 @@ const b = class {
922
903
  const n = t["DEBUG:LOD"];
923
904
  if (n != null && (s = t[Q] != n, e = n), s) {
924
905
  t[Q] = e;
925
- const r = T.assignTextureLOD(t, e).then((i) => {
906
+ const r = P.assignTextureLOD(t, e).then((i) => {
926
907
  this._lodchangedlisteners.forEach((a) => a({ type: "texture", level: e, object: t }));
927
908
  });
928
909
  ye.addPromise("texture", t, r, this._newPromiseGroups);
@@ -941,7 +922,7 @@ const b = class {
941
922
  const n = t["DEBUG:LOD"];
942
923
  if (n != null && (s = t[Q] != n, e = n), s) {
943
924
  t[Q] = e;
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));
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));
945
926
  return ye.addPromise("mesh", t, i, this._newPromiseGroups), i;
946
927
  }
947
928
  return Promise.resolve(null);
@@ -951,7 +932,7 @@ const b = class {
951
932
  return this._tempPtInside.set(r, i, s.z).applyMatrix4(e).z < 0;
952
933
  }
953
934
  calculateLodLevel(t, e, s, n, r) {
954
- var M, R, Z;
935
+ var b, R, Z;
955
936
  if (!e) {
956
937
  r.mesh_lod = -1, r.texture_lod = -1;
957
938
  return;
@@ -963,102 +944,102 @@ const b = class {
963
944
  let a = 10 + 1, l = !1;
964
945
  if (F && e["DEBUG:LOD"] != null)
965
946
  return e["DEBUG:LOD"];
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) {
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) {
968
949
  r.mesh_lod = 0, r.texture_lod = 0;
969
950
  return;
970
951
  }
971
- h || (l = !0, a = 0);
972
- const v = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
973
- let P = e.geometry.boundingBox;
952
+ p || (l = !0, a = 0);
953
+ const M = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
954
+ let A = e.geometry.boundingBox;
974
955
  if (e.type === "SkinnedMesh") {
975
- const g = e;
976
- if (!g.boundingBox)
977
- g.computeBoundingBox();
956
+ const h = e;
957
+ if (!h.boundingBox)
958
+ h.computeBoundingBox();
978
959
  else if (this.skinnedMeshAutoUpdateBoundsInterval > 0) {
979
- if (!g[b.$skinnedMeshBoundsOffset]) {
980
- const E = b.skinnedMeshBoundsFrameOffsetCounter++;
981
- g[b.$skinnedMeshBoundsOffset] = E;
960
+ if (!h[O.$skinnedMeshBoundsOffset]) {
961
+ const C = O.skinnedMeshBoundsFrameOffsetCounter++;
962
+ h[O.$skinnedMeshBoundsOffset] = C;
982
963
  }
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;
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;
987
968
  }
988
969
  }
989
- P = g.boundingBox;
970
+ A = h.boundingBox;
990
971
  }
991
- if (P) {
992
- const g = t;
972
+ if (A) {
973
+ const h = t;
993
974
  if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
994
975
  this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
995
- const p = t.getWorldPosition(this._tempWorldPosition);
996
- if (this._sphere.containsPoint(p)) {
976
+ const g = t.getWorldPosition(this._tempWorldPosition);
977
+ if (this._sphere.containsPoint(g)) {
997
978
  r.mesh_lod = 0, r.texture_lod = 0;
998
979
  return;
999
980
  }
1000
981
  }
1001
- if (this._tempBox.copy(P), this._tempBox.applyMatrix4(e.matrixWorld), g.isPerspectiveCamera && b.isInside(this._tempBox, this.projectionScreenMatrix)) {
982
+ if (this._tempBox.copy(A), this._tempBox.applyMatrix4(e.matrixWorld), h.isPerspectiveCamera && O.isInside(this._tempBox, this.projectionScreenMatrix)) {
1002
983
  r.mesh_lod = 0, r.texture_lod = 0;
1003
984
  return;
1004
985
  }
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);
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);
1012
993
  } else
1013
994
  s.lastCentrality = 1;
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);
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);
1024
1005
  const ne = (_.z + z.z) * 0.5;
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);
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);
1026
1007
  }
1027
- let D = 999;
1008
+ let v = 999;
1028
1009
  if (c && s.lastScreenCoverage > 0)
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;
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;
1033
1014
  break;
1034
1015
  }
1035
1016
  }
1036
- D < a && (a = D, l = !0);
1017
+ v < a && (a = v, l = !0);
1037
1018
  }
1038
1019
  if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, F && r.mesh_lod != s.lastLodLevel_Mesh) {
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}`);
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}`);
1041
1022
  }
1042
1023
  if (w) {
1043
- const g = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
1024
+ const h = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
1044
1025
  if (s.lastLodLevel_Texture < 0) {
1045
1026
  if (r.texture_lod = f.max_count - 1, F) {
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}`);
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}`);
1048
1029
  }
1049
1030
  } else {
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;
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;
1054
1035
  let ee = !1;
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;
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;
1060
1041
  F && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${m}px
1061
- Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${x.toFixed(1)}
1042
+ Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${L.toFixed(1)}
1062
1043
  ${e.name}`);
1063
1044
  }
1064
1045
  break;
@@ -1069,15 +1050,15 @@ ${e.name}`);
1069
1050
  r.texture_lod = 0;
1070
1051
  }
1071
1052
  };
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(), /**
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(), /**
1074
1055
  * 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.
1075
1056
  */
1076
- u(C, "debugDrawLine"), /**
1057
+ u(T, "debugDrawLine"), /**
1077
1058
  * Force override the LOD level for all objects in the scene
1078
1059
  */
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 {
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 {
1081
1062
  constructor() {
1082
1063
  u(this, "frames", 0);
1083
1064
  u(this, "lastLodLevel_Mesh", -1);
@@ -1087,41 +1068,41 @@ class xt {
1087
1068
  u(this, "lastCentrality", 0);
1088
1069
  }
1089
1070
  }
1090
- const Be = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
1071
+ const $e = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
1091
1072
  let ue = null;
1092
- function We() {
1093
- const o = wt();
1073
+ function Ve() {
1074
+ const o = _t();
1094
1075
  o && (o.mapURLs(function(t) {
1095
1076
  return ke(), t;
1096
1077
  }), ke(), ue == null || ue.disconnect(), ue = new MutationObserver((t) => {
1097
1078
  t.forEach((e) => {
1098
1079
  e.addedNodes.forEach((s) => {
1099
- s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Xe(s);
1080
+ s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && We(s);
1100
1081
  });
1101
1082
  });
1102
1083
  }), ue.observe(document, { childList: !0, subtree: !0 }));
1103
1084
  }
1104
- function wt() {
1085
+ function _t() {
1105
1086
  if (typeof customElements > "u")
1106
1087
  return null;
1107
1088
  const o = customElements.get("model-viewer");
1108
1089
  return o || (customElements.whenDefined("model-viewer").then(() => {
1109
- console.debug("[gltf-progressive] model-viewer defined"), We();
1090
+ console.debug("[gltf-progressive] model-viewer defined"), Ve();
1110
1091
  }), null);
1111
1092
  }
1112
1093
  function ke() {
1113
1094
  if (typeof document > "u")
1114
1095
  return;
1115
1096
  document.querySelectorAll("model-viewer").forEach((t) => {
1116
- Xe(t);
1097
+ We(t);
1117
1098
  });
1118
1099
  }
1119
- const Re = /* @__PURE__ */ new WeakSet();
1120
- let _t = 0;
1121
- function Xe(o) {
1122
- if (!o || Re.has(o))
1100
+ const Ie = /* @__PURE__ */ new WeakSet();
1101
+ let wt = 0;
1102
+ function We(o) {
1103
+ if (!o || Ie.has(o))
1123
1104
  return null;
1124
- Re.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++_t + `
1105
+ Ie.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++wt + `
1125
1106
  `, o.getAttribute("src"));
1126
1107
  let t = null, e = null, s = null;
1127
1108
  for (let n = o; n != null; n = Object.getPrototypeOf(n)) {
@@ -1141,8 +1122,8 @@ function Xe(o) {
1141
1122
  }
1142
1123
  };
1143
1124
  console.debug("[gltf-progressive] setup model-viewer");
1144
- const r = C.get(t, { engine: "model-viewer" });
1145
- return C.addPlugin(new vt()), r.enable(), r.addEventListener("changed", () => {
1125
+ const r = T.get(t, { engine: "model-viewer" });
1126
+ return T.addPlugin(new vt()), r.enable(), r.addEventListener("changed", () => {
1146
1127
  s == null || s.call(o);
1147
1128
  }), o.addEventListener("model-visibility", (i) => {
1148
1129
  i.detail.visible && (s == null || s.call(o));
@@ -1180,25 +1161,25 @@ class vt {
1180
1161
  const s = this.tryGetCurrentGLTF(t), n = this.tryGetCurrentModelViewer(t), r = this.getUrl(n);
1181
1162
  if (r && s && e.material) {
1182
1163
  let i = function(l) {
1183
- var d, h, f;
1164
+ var d, p, f;
1184
1165
  if (l[pe] == !0)
1185
1166
  return;
1186
1167
  l[pe] = !0, l.userData && (l.userData.LOD = -1);
1187
1168
  const c = Object.keys(l);
1188
1169
  for (let w = 0; w < c.length; w++) {
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)
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)
1193
1174
  continue;
1194
- const R = s.parser.json.textures[M];
1175
+ const R = s.parser.json.textures[b];
1195
1176
  if (!R) {
1196
- console.warn("Texture data not found for texture index " + M);
1177
+ console.warn("Texture data not found for texture index " + b);
1197
1178
  continue;
1198
1179
  }
1199
1180
  if ((f = R == null ? void 0 : R.extensions) != null && f[X]) {
1200
1181
  const Z = R.extensions[X];
1201
- Z && r && T.registerTexture(r, P, Z.lods.length, M, Z);
1182
+ Z && r && P.registerTexture(r, A, Z.lods.length, b, Z);
1202
1183
  }
1203
1184
  }
1204
1185
  }
@@ -1213,34 +1194,34 @@ class vt {
1213
1194
  }
1214
1195
  tryParseMeshLOD(t, e) {
1215
1196
  var i, a;
1216
- if (e[Be] == !0)
1197
+ if (e[$e] == !0)
1217
1198
  return;
1218
- e[Be] = !0;
1199
+ e[$e] = !0;
1219
1200
  const s = this.tryGetCurrentModelViewer(t), n = this.getUrl(s);
1220
1201
  if (!n)
1221
1202
  return;
1222
1203
  const r = (a = (i = e.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[X];
1223
1204
  if (r && n) {
1224
1205
  const l = e.uuid;
1225
- T.registerMesh(n, l, e, 0, r.lods.length, r);
1206
+ P.registerMesh(n, l, e, 0, r.lods.length, r);
1226
1207
  }
1227
1208
  }
1228
1209
  }
1229
- function Dt(o, t, e, s) {
1230
- Ue(t), ze(e), Ve(e, {
1210
+ function Mt(o, t, e, s) {
1211
+ Ue(t), Ne(e), ze(e, {
1231
1212
  progressive: !0,
1232
1213
  ...s == null ? void 0 : s.hints
1233
- }), e.register((r) => new T(r, o));
1234
- const n = C.get(t);
1214
+ }), e.register((r) => new P(r, o));
1215
+ const n = T.get(t);
1235
1216
  return (s == null ? void 0 : s.enableLODsManager) !== !1 && n.enable(), n;
1236
1217
  }
1237
- We();
1218
+ Ve();
1238
1219
  if (!ht) {
1239
1220
  const o = {
1240
1221
  gltfProgressive: {
1241
- useNeedleProgressive: Dt,
1242
- LODsManager: C,
1243
- configureLoader: Ve,
1222
+ useNeedleProgressive: Mt,
1223
+ LODsManager: T,
1224
+ configureLoader: ze,
1244
1225
  getRaycastMesh: ce,
1245
1226
  useRaycastMeshes: pt
1246
1227
  }
@@ -1253,17 +1234,17 @@ if (!ht) {
1253
1234
  }
1254
1235
  export {
1255
1236
  X as EXTENSION_NAME,
1256
- C as LODsManager,
1257
- T as NEEDLE_progressive,
1258
- it as VERSION,
1259
- ze as addDracoAndKTX2Loaders,
1260
- Ve as configureLoader,
1237
+ T as LODsManager,
1238
+ P as NEEDLE_progressive,
1239
+ rt as VERSION,
1240
+ Ne as addDracoAndKTX2Loaders,
1241
+ ze as configureLoader,
1261
1242
  Ue as createLoaders,
1262
1243
  ce as getRaycastMesh,
1263
- We as patchModelViewer,
1244
+ Ve as patchModelViewer,
1264
1245
  gt as registerRaycastMesh,
1265
- at as setDracoDecoderLocation,
1266
- lt as setKTX2TranscoderLocation,
1267
- Dt as useNeedleProgressive,
1246
+ ot as setDracoDecoderLocation,
1247
+ at as setKTX2TranscoderLocation,
1248
+ Mt as useNeedleProgressive,
1268
1249
  pt as useRaycastMeshes
1269
1250
  };