@needle-tools/gltf-progressive 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,67 +1,68 @@
1
1
  var We = Object.defineProperty;
2
- var qe = (n, e, t) => e in n ? We(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var d = (n, e, t) => (qe(n, typeof e != "symbol" ? e + "" : e, t), t), Te = (n, e, t) => {
2
+ var Xe = (n, e, t) => e in n ? We(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var d = (n, e, t) => (Xe(n, typeof e != "symbol" ? e + "" : e, t), t), Ae = (n, e, t) => {
4
4
  if (!e.has(n))
5
5
  throw TypeError("Cannot " + t);
6
6
  };
7
- var m = (n, e, t) => (Te(n, e, "read from private field"), t ? t.call(n) : e.get(n)), K = (n, e, t) => {
7
+ var m = (n, e, t) => (Ae(n, e, "read from private field"), t ? t.call(n) : e.get(n)), J = (n, e, t) => {
8
8
  if (e.has(n))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  e instanceof WeakSet ? e.add(n) : e.set(n, t);
11
- }, U = (n, e, t, s) => (Te(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
12
- import { BufferGeometry as ge, Mesh as Z, Texture as se, TextureLoader as Xe, Matrix4 as Ae, Clock as Ke, MeshStandardMaterial as Ye, Sphere as He, Box3 as Ee, Vector3 as z } from "three";
13
- import { GLTFLoader as be } from "three/examples/jsm/loaders/GLTFLoader.js";
11
+ }, z = (n, e, t, s) => (Ae(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
12
+ import { BufferGeometry as ge, Mesh as j, Texture as re, TextureLoader as qe, Matrix4 as Pe, Clock as Ke, MeshStandardMaterial as Ye, Sphere as He, Box3 as Ee, Vector3 as X } from "three";
13
+ import { GLTFLoader as Te } from "three/examples/jsm/loaders/GLTFLoader.js";
14
14
  import { MeshoptDecoder as Je } from "three/examples/jsm/libs/meshopt_decoder.module.js";
15
15
  import { DRACOLoader as Qe } from "three/examples/jsm/loaders/DRACOLoader.js";
16
16
  import { KTX2Loader as Ze } from "three/examples/jsm/loaders/KTX2Loader.js";
17
- const ke = "";
18
- globalThis.GLTF_PROGRESSIVE_VERSION = ke;
19
- console.debug(`[gltf-progressive] version ${ke}`);
20
- let te = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", ae = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
21
- const je = te, et = ae, tt = new URL(te + "draco_decoder.js");
22
- fetch(tt, {
17
+ const je = "";
18
+ globalThis.GLTF_PROGRESSIVE_VERSION = je;
19
+ console.debug("[gltf-progressive] version -");
20
+ let V = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", ee = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
21
+ const et = V, tt = ee, st = new URL(V + "draco_decoder.js");
22
+ fetch(st, {
23
23
  method: "GET",
24
24
  headers: {
25
25
  Range: "bytes=0-1"
26
26
  }
27
27
  }).catch((n) => {
28
- te === je && (te = "./include/draco/"), ae === et && (ae = "./include/ktx2/");
28
+ console.debug(`Failed to fetch remote Draco decoder from ${V} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), V === et && rt("./include/draco/"), ee === tt && ot("./include/ktx2/");
29
29
  }).finally(() => {
30
30
  Ie();
31
31
  });
32
- function wt(n) {
33
- te = n;
32
+ function rt(n) {
33
+ V = n, B && B[Oe] != V ? (console.debug("Updating Draco decoder path to " + n), B[Oe] = V, B.setDecoderPath(V), B.preload()) : console.debug("Setting Draco decoder path to " + n);
34
34
  }
35
- function vt(n) {
36
- ae = n;
35
+ function ot(n) {
36
+ ee = n, U && U.transcoderPath != ee ? (console.debug("Updating KTX2 transcoder path to " + n), U.setTranscoderPath(ee), U.init()) : console.debug("Setting KTX2 transcoder path to " + n);
37
37
  }
38
- let J, pe, Q;
38
+ const Oe = Symbol("dracoDecoderPath");
39
+ let B, pe, U;
39
40
  function Ie() {
40
- J || (J = new Qe(), J.setDecoderPath(te), J.setDecoderConfig({ type: "js" }), J.preload()), Q || (Q = new Ze(), Q.setTranscoderPath(ae), Q.init()), pe || (pe = Je);
41
+ B || (B = new Qe(), B[Oe] = V, B.setDecoderPath(V), B.setDecoderConfig({ type: "js" }), B.preload()), U || (U = new Ze(), U.setTranscoderPath(ee), U.init()), pe || (pe = Je);
41
42
  }
42
43
  function Ge(n) {
43
- return Ie(), n ? Q.detectSupport(n) : n !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: J, ktx2Loader: Q, meshoptDecoder: pe };
44
+ return Ie(), n ? U.detectSupport(n) : n !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: B, ktx2Loader: U, meshoptDecoder: pe };
44
45
  }
45
46
  function $e(n) {
46
- n.dracoLoader || n.setDRACOLoader(J), n.ktx2Loader || n.setKTX2Loader(Q), n.meshoptDecoder || n.setMeshoptDecoder(pe);
47
+ n.dracoLoader || n.setDRACOLoader(B), n.ktx2Loader || n.setKTX2Loader(U), n.meshoptDecoder || n.setMeshoptDecoder(pe);
47
48
  }
48
- const Oe = /* @__PURE__ */ new WeakMap();
49
- function Fe(n, e) {
50
- let t = Oe.get(n);
51
- t ? t = Object.assign(t, e) : t = e, Oe.set(n, t);
49
+ const _e = /* @__PURE__ */ new WeakMap();
50
+ function Ue(n, e) {
51
+ let t = _e.get(n);
52
+ t ? t = Object.assign(t, e) : t = e, _e.set(n, t);
52
53
  }
53
- const Me = be.prototype.load;
54
- function st(...n) {
55
- const e = Oe.get(this);
54
+ const De = Te.prototype.load;
55
+ function it(...n) {
56
+ const e = _e.get(this);
56
57
  let t = n[0];
57
58
  const s = new URL(t, window.location.href);
58
59
  if (s.hostname.endsWith("needle.tools")) {
59
- const r = (e == null ? void 0 : e.progressive) !== void 0 ? e.progressive : !0, i = e != null && e.usecase ? e.usecase : "default";
60
- r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${i}` : this.requestHeader.Accept = `*/*;usecase=${i}`, t = s.toString();
60
+ const r = (e == null ? void 0 : e.progressive) !== void 0 ? e.progressive : !0, o = e != null && e.usecase ? e.usecase : "default";
61
+ r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${o}` : this.requestHeader.Accept = `*/*;usecase=${o}`, t = s.toString();
61
62
  }
62
- return n[0] = t, Me == null ? void 0 : Me.call(this, ...n);
63
+ return n[0] = t, De == null ? void 0 : De.call(this, ...n);
63
64
  }
64
- be.prototype.load = st;
65
+ Te.prototype.load = it;
65
66
  le("debugprogressive");
66
67
  function le(n) {
67
68
  if (typeof window > "u")
@@ -69,7 +70,7 @@ function le(n) {
69
70
  const t = new URL(window.location.href).searchParams.get(n);
70
71
  return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
71
72
  }
72
- function rt(n, e) {
73
+ function nt(n, e) {
73
74
  if (e === void 0 || e.startsWith("./") || e.startsWith("http") || n === void 0)
74
75
  return e;
75
76
  const t = n.lastIndexOf("/");
@@ -81,49 +82,49 @@ function rt(n, e) {
81
82
  }
82
83
  return e;
83
84
  }
84
- let re;
85
- function it() {
86
- return re !== void 0 || (re = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), le("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", re)), re;
85
+ let oe;
86
+ function at() {
87
+ return oe !== void 0 || (oe = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), le("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", oe)), oe;
87
88
  }
88
- const ot = typeof window > "u" && typeof document > "u", _e = Symbol("needle:raycast-mesh");
89
+ const lt = typeof window > "u" && typeof document > "u", be = Symbol("needle:raycast-mesh");
89
90
  function ce(n) {
90
- return (n == null ? void 0 : n[_e]) instanceof ge ? n[_e] : null;
91
+ return (n == null ? void 0 : n[be]) instanceof ge ? n[be] : null;
91
92
  }
92
- function nt(n, e) {
93
+ function ct(n, e) {
93
94
  if ((n.type === "Mesh" || n.type === "SkinnedMesh") && !ce(n)) {
94
- const s = lt(e);
95
- s.userData = { isRaycastMesh: !0 }, n[_e] = s;
95
+ const s = ft(e);
96
+ s.userData = { isRaycastMesh: !0 }, n[be] = s;
96
97
  }
97
98
  }
98
- function at(n = !0) {
99
+ function ut(n = !0) {
99
100
  if (n) {
100
101
  if (ie)
101
102
  return;
102
- const e = ie = Z.prototype.raycast;
103
- Z.prototype.raycast = function(t, s) {
104
- const o = this, r = ce(o);
105
- let i;
106
- r && o.isMesh && (i = o.geometry, o.geometry = r), e.call(this, t, s), i && (o.geometry = i);
103
+ const e = ie = j.prototype.raycast;
104
+ j.prototype.raycast = function(t, s) {
105
+ const i = this, r = ce(i);
106
+ let o;
107
+ r && i.isMesh && (o = i.geometry, i.geometry = r), e.call(this, t, s), o && (i.geometry = o);
107
108
  };
108
109
  } else {
109
110
  if (!ie)
110
111
  return;
111
- Z.prototype.raycast = ie, ie = null;
112
+ j.prototype.raycast = ie, ie = null;
112
113
  }
113
114
  }
114
115
  let ie = null;
115
- function lt(n) {
116
+ function ft(n) {
116
117
  const e = new ge();
117
118
  for (const t in n.attributes)
118
119
  e.setAttribute(t, n.getAttribute(t));
119
120
  return e.setIndex(n.getIndex()), e;
120
121
  }
121
- const H = new Array(), V = "NEEDLE_progressive", L = le("debugprogressive"), De = Symbol("needle-progressive-texture"), ne = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Set();
122
+ const Z = new Array(), q = "NEEDLE_progressive", L = le("debugprogressive"), Me = Symbol("needle-progressive-texture"), ae = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Set();
122
123
  if (L) {
123
124
  let n = function() {
124
- e += 1, console.log("Toggle LOD level", e, ne), ne.forEach((o, r) => {
125
- for (const i of o.keys) {
126
- const a = r[i];
125
+ e += 1, console.log("Toggle LOD level", e, ae), ae.forEach((i, r) => {
126
+ for (const o of i.keys) {
127
+ const a = r[o];
127
128
  if (a != null)
128
129
  if (a.isBufferGeometry === !0) {
129
130
  const l = T.getMeshLODInformation(a), u = l ? Math.min(e, l.lods.length) : 0;
@@ -133,19 +134,19 @@ if (L) {
133
134
  }
134
135
  }), e >= t && (e = -1);
135
136
  }, e = -1, t = 2, s = !1;
136
- window.addEventListener("keyup", (o) => {
137
- o.key === "p" && n(), o.key === "w" && (s = !s, Se && Se.forEach((r) => {
137
+ window.addEventListener("keyup", (i) => {
138
+ i.key === "p" && n(), i.key === "w" && (s = !s, Se && Se.forEach((r) => {
138
139
  r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = s);
139
140
  }));
140
141
  });
141
142
  }
142
- function Pe(n, e, t) {
143
- var o;
143
+ function Ce(n, e, t) {
144
+ var i;
144
145
  if (!L)
145
146
  return;
146
- ne.has(n) || ne.set(n, { keys: [], sourceId: t });
147
- const s = ne.get(n);
148
- ((o = s == null ? void 0 : s.keys) == null ? void 0 : o.includes(e)) == !1 && s.keys.push(e);
147
+ ae.has(n) || ae.set(n, { keys: [], sourceId: t });
148
+ const s = ae.get(n);
149
+ ((i = s == null ? void 0 : s.keys) == null ? void 0 : i.includes(e)) == !1 && s.keys.push(e);
149
150
  }
150
151
  const v = class {
151
152
  constructor(e, t) {
@@ -153,27 +154,27 @@ const v = class {
153
154
  d(this, "url");
154
155
  d(this, "_isLoadingMesh");
155
156
  d(this, "loadMesh", (e) => {
156
- var s, o;
157
+ var s, i;
157
158
  if (this._isLoadingMesh)
158
159
  return null;
159
- const t = (o = (s = this.parser.json.meshes[e]) == null ? void 0 : s.extensions) == null ? void 0 : o[V];
160
+ const t = (i = (s = this.parser.json.meshes[e]) == null ? void 0 : s.extensions) == null ? void 0 : i[q];
160
161
  return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((r) => {
161
- var i;
162
- return this._isLoadingMesh = !1, r && v.registerMesh(this.url, t.guid, r, (i = t.lods) == null ? void 0 : i.length, void 0, t), r;
162
+ var o;
163
+ return this._isLoadingMesh = !1, r && v.registerMesh(this.url, t.guid, r, (o = t.lods) == null ? void 0 : o.length, void 0, t), r;
163
164
  })) : null;
164
165
  });
165
166
  L && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
166
167
  }
167
168
  /** The name of the extension */
168
169
  get name() {
169
- return V;
170
+ return q;
170
171
  }
171
172
  static getMeshLODInformation(e) {
172
173
  const t = this.getAssignedLODInformation(e);
173
174
  return t != null && t.key ? this.lodInfos.get(t.key) : null;
174
175
  }
175
176
  static getMaterialMinMaxLODsCount(e, t) {
176
- const s = this, o = "LODS:minmax", r = e[o];
177
+ const s = this, i = "LODS:minmax", r = e[i];
177
178
  if (r != null)
178
179
  return r;
179
180
  if (t || (t = {
@@ -183,21 +184,21 @@ const v = class {
183
184
  }), Array.isArray(e)) {
184
185
  for (const a of e)
185
186
  this.getMaterialMinMaxLODsCount(a, t);
186
- return e[o] = t, t;
187
+ return e[i] = t, t;
187
188
  }
188
189
  if (L === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
189
190
  const a = e;
190
191
  for (const l of Object.keys(a.uniforms)) {
191
192
  const u = a.uniforms[l].value;
192
- (u == null ? void 0 : u.isTexture) === !0 && i(u, t);
193
+ (u == null ? void 0 : u.isTexture) === !0 && o(u, t);
193
194
  }
194
195
  } else if (e.isMaterial)
195
196
  for (const a of Object.keys(e)) {
196
197
  const l = e[a];
197
- (l == null ? void 0 : l.isTexture) === !0 && i(l, t);
198
+ (l == null ? void 0 : l.isTexture) === !0 && o(l, t);
198
199
  }
199
- return e[o] = t, t;
200
- function i(a, l) {
200
+ return e[i] = t, t;
201
+ function o(a, l) {
201
202
  const u = s.getAssignedLODInformation(a);
202
203
  if (u) {
203
204
  const c = s.lodInfos.get(u.key);
@@ -219,30 +220,30 @@ const v = class {
219
220
  static hasLODLevelAvailable(e, t) {
220
221
  var r;
221
222
  if (Array.isArray(e)) {
222
- for (const i of e)
223
- if (this.hasLODLevelAvailable(i, t))
223
+ for (const o of e)
224
+ if (this.hasLODLevelAvailable(o, t))
224
225
  return !0;
225
226
  return !1;
226
227
  }
227
228
  if (e.isMaterial === !0) {
228
- for (const i of Object.keys(e)) {
229
- const a = e[i];
229
+ for (const o of Object.keys(e)) {
230
+ const a = e[o];
230
231
  if (a && a.isTexture && this.hasLODLevelAvailable(a, t))
231
232
  return !0;
232
233
  }
233
234
  return !1;
234
235
  } else if (e.isGroup === !0) {
235
- for (const i of e.children)
236
- if (i.isMesh === !0 && this.hasLODLevelAvailable(i, t))
236
+ for (const o of e.children)
237
+ if (o.isMesh === !0 && this.hasLODLevelAvailable(o, t))
237
238
  return !0;
238
239
  }
239
- let s, o;
240
+ let s, i;
240
241
  if (e.isMesh ? s = e.geometry : (e.isBufferGeometry || e.isTexture) && (s = e), s && (r = s == null ? void 0 : s.userData) != null && r.LODS) {
241
- const i = s.userData.LODS;
242
- if (o = this.lodInfos.get(i.key), t === void 0)
243
- return o != null;
244
- if (o)
245
- return Array.isArray(o.lods) ? t < o.lods.length : t === 0;
242
+ const o = s.userData.LODS;
243
+ if (i = this.lodInfos.get(o.key), t === void 0)
244
+ return i != null;
245
+ if (i)
246
+ return Array.isArray(i.lods) ? t < i.lods.length : t === 0;
246
247
  }
247
248
  return !1;
248
249
  }
@@ -264,19 +265,19 @@ const v = class {
264
265
  var s;
265
266
  if (!e)
266
267
  return Promise.resolve(null);
267
- if (e instanceof Z || e.isMesh === !0) {
268
- const o = e.geometry, r = this.getAssignedLODInformation(o);
268
+ if (e instanceof j || e.isMesh === !0) {
269
+ const i = e.geometry, r = this.getAssignedLODInformation(i);
269
270
  if (!r)
270
271
  return Promise.resolve(null);
271
- for (const i of H)
272
- (s = i.onBeforeGetLODMesh) == null || s.call(i, e, t);
273
- return e["LOD:requested level"] = t, v.getOrLoadLOD(o, t).then((i) => {
274
- if (Array.isArray(i)) {
272
+ for (const o of Z)
273
+ (s = o.onBeforeGetLODMesh) == null || s.call(o, e, t);
274
+ return e["LOD:requested level"] = t, v.getOrLoadLOD(i, t).then((o) => {
275
+ if (Array.isArray(o)) {
275
276
  const a = r.index || 0;
276
- i = i[a];
277
+ o = o[a];
277
278
  }
278
- return e["LOD:requested level"] === t && (delete e["LOD:requested level"], i && o != i && ((i == null ? void 0 : i.isBufferGeometry) ? (e.geometry = i, L && Pe(e, "geometry", r.url)) : L && console.error("Invalid LOD geometry", i))), i;
279
- }).catch((i) => (console.error("Error loading mesh LOD", e, i), null));
279
+ return e["LOD:requested level"] === t && (delete e["LOD:requested level"], o && i != o && ((o == null ? void 0 : o.isBufferGeometry) ? (e.geometry = o, L && Ce(e, "geometry", r.url)) : L && console.error("Invalid LOD geometry", o))), o;
280
+ }).catch((o) => (console.error("Error loading mesh LOD", e, o), null));
280
281
  } else
281
282
  L && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
282
283
  return Promise.resolve(null);
@@ -287,72 +288,72 @@ const v = class {
287
288
  if (e.isMesh === !0) {
288
289
  const s = e;
289
290
  if (Array.isArray(s.material)) {
290
- const o = new Array();
291
+ const i = new Array();
291
292
  for (const r of s.material) {
292
- const i = this.assignTextureLOD(r, t);
293
- o.push(i);
293
+ const o = this.assignTextureLOD(r, t);
294
+ i.push(o);
294
295
  }
295
- return Promise.all(o).then((r) => {
296
- const i = new Array();
296
+ return Promise.all(i).then((r) => {
297
+ const o = new Array();
297
298
  for (const a of r)
298
- Array.isArray(a) && i.push(...a);
299
- return i;
299
+ Array.isArray(a) && o.push(...a);
300
+ return o;
300
301
  });
301
302
  } else
302
303
  return this.assignTextureLOD(s.material, t);
303
304
  }
304
305
  if (e.isMaterial === !0) {
305
- const s = e, o = [], r = new Array();
306
+ const s = e, i = [], r = new Array();
306
307
  if (L && Se.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
307
- const i = s;
308
- for (const a of Object.keys(i.uniforms)) {
309
- const l = i.uniforms[a].value;
308
+ const o = s;
309
+ for (const a of Object.keys(o.uniforms)) {
310
+ const l = o.uniforms[a].value;
310
311
  if ((l == null ? void 0 : l.isTexture) === !0) {
311
- const u = this.assignTextureLODForSlot(l, t, s, a).then((c) => (c && i.uniforms[a].value != c && (i.uniforms[a].value = c, i.uniformsNeedUpdate = !0), c));
312
- o.push(u), r.push(a);
312
+ const u = this.assignTextureLODForSlot(l, t, s, a).then((c) => (c && o.uniforms[a].value != c && (o.uniforms[a].value = c, o.uniformsNeedUpdate = !0), c));
313
+ i.push(u), r.push(a);
313
314
  }
314
315
  }
315
316
  } else
316
- for (const i of Object.keys(s)) {
317
- const a = s[i];
317
+ for (const o of Object.keys(s)) {
318
+ const a = s[o];
318
319
  if ((a == null ? void 0 : a.isTexture) === !0) {
319
- const l = this.assignTextureLODForSlot(a, t, s, i);
320
- o.push(l), r.push(i);
320
+ const l = this.assignTextureLODForSlot(a, t, s, o);
321
+ i.push(l), r.push(o);
321
322
  }
322
323
  }
323
- return Promise.all(o).then((i) => {
324
+ return Promise.all(i).then((o) => {
324
325
  const a = new Array();
325
- for (let l = 0; l < i.length; l++) {
326
- const u = i[l], c = r[l];
326
+ for (let l = 0; l < o.length; l++) {
327
+ const u = o[l], c = r[l];
327
328
  u && u.isTexture === !0 ? a.push({ material: s, slot: c, texture: u, level: t }) : a.push({ material: s, slot: c, texture: null, level: t });
328
329
  }
329
330
  return a;
330
331
  });
331
332
  }
332
- if (e instanceof se || e.isTexture === !0) {
333
+ if (e instanceof re || e.isTexture === !0) {
333
334
  const s = e;
334
335
  return this.assignTextureLODForSlot(s, t, null, null);
335
336
  }
336
337
  return Promise.resolve(null);
337
338
  }
338
- static assignTextureLODForSlot(e, t, s, o) {
339
- return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : o === "glyphMap" ? Promise.resolve(e) : v.getOrLoadLOD(e, t).then((r) => {
339
+ static assignTextureLODForSlot(e, t, s, i) {
340
+ return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : i === "glyphMap" ? Promise.resolve(e) : v.getOrLoadLOD(e, t).then((r) => {
340
341
  if (Array.isArray(r))
341
342
  return null;
342
343
  if ((r == null ? void 0 : r.isTexture) === !0) {
343
344
  if (r != e) {
344
- if (s && o) {
345
- const i = s[o];
346
- if (i && !L) {
347
- const a = this.getAssignedLODInformation(i);
345
+ if (s && i) {
346
+ const o = s[i];
347
+ if (o && !L) {
348
+ const a = this.getAssignedLODInformation(o);
348
349
  if (a && (a == null ? void 0 : a.level) < t)
349
- return L === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, t, s, i, r), null;
350
+ return L === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, t, s, o, r), null;
350
351
  }
351
- s[o] = r;
352
+ s[i] = r;
352
353
  }
353
- if (L && o && s) {
354
- const i = this.getAssignedLODInformation(e);
355
- i ? Pe(s, o, i.url) : console.warn("No LOD info for texture", e);
354
+ if (L && i && s) {
355
+ const o = this.getAssignedLODInformation(e);
356
+ o ? Ce(s, i, o.url) : console.warn("No LOD info for texture", e);
356
357
  }
357
358
  }
358
359
  return r;
@@ -363,10 +364,10 @@ const v = class {
363
364
  }
364
365
  afterRoot(e) {
365
366
  var t, s;
366
- return L && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((o, r) => {
367
- var i;
368
- if (o != null && o.extensions) {
369
- const a = o == null ? void 0 : o.extensions[V];
367
+ return L && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, r) => {
368
+ var o;
369
+ if (i != null && i.extensions) {
370
+ const a = i == null ? void 0 : i.extensions[q];
370
371
  if (a) {
371
372
  if (!a.lods) {
372
373
  L && console.warn("Texture has no LODs", a);
@@ -376,7 +377,7 @@ const v = class {
376
377
  for (const u of this.parser.associations.keys())
377
378
  if (u.isTexture === !0) {
378
379
  const c = this.parser.associations.get(u);
379
- (c == null ? void 0 : c.textures) === r && (l = !0, v.registerTexture(this.url, u, (i = a.lods) == null ? void 0 : i.length, r, a));
380
+ (c == null ? void 0 : c.textures) === r && (l = !0, v.registerTexture(this.url, u, (o = a.lods) == null ? void 0 : o.length, r, a));
380
381
  }
381
382
  l || this.parser.getDependency("texture", r).then((u) => {
382
383
  var c;
@@ -384,14 +385,14 @@ const v = class {
384
385
  });
385
386
  }
386
387
  }
387
- }), (s = this.parser.json.meshes) == null || s.forEach((o, r) => {
388
- if (o != null && o.extensions) {
389
- const i = o == null ? void 0 : o.extensions[V];
390
- if (i && i.lods) {
388
+ }), (s = this.parser.json.meshes) == null || s.forEach((i, r) => {
389
+ if (i != null && i.extensions) {
390
+ const o = i == null ? void 0 : i.extensions[q];
391
+ if (o && o.lods) {
391
392
  for (const a of this.parser.associations.keys())
392
393
  if (a.isMesh) {
393
394
  const l = this.parser.associations.get(a);
394
- (l == null ? void 0 : l.meshes) === r && v.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
395
+ (l == null ? void 0 : l.meshes) === r && v.registerMesh(this.url, o.guid, a, o.lods.length, l.primitives, o);
395
396
  }
396
397
  }
397
398
  }
@@ -399,94 +400,94 @@ const v = class {
399
400
  }
400
401
  static async getOrLoadLOD(e, t) {
401
402
  var a, l, u, c;
402
- const s = L == "verbose", o = e.userData.LODS;
403
- if (!o)
403
+ const s = L == "verbose", i = e.userData.LODS;
404
+ if (!i)
404
405
  return null;
405
- const r = o == null ? void 0 : o.key;
406
- let i;
406
+ const r = i == null ? void 0 : i.key;
407
+ let o;
407
408
  if (e.isTexture === !0) {
408
409
  const g = e;
409
- g.source && g.source[De] && (i = g.source[De]);
410
+ g.source && g.source[Me] && (o = g.source[Me]);
410
411
  }
411
- if (i || (i = v.lodInfos.get(r)), i) {
412
+ if (o || (o = v.lodInfos.get(r)), o) {
412
413
  if (t > 0) {
413
- let D = !1;
414
- const w = Array.isArray(i.lods);
415
- if (w && t >= i.lods.length ? D = !0 : w || (D = !0), D)
414
+ let M = !1;
415
+ const w = Array.isArray(o.lods);
416
+ if (w && t >= o.lods.length ? M = !0 : w || (M = !0), M)
416
417
  return this.lowresCache.get(r);
417
418
  }
418
- const g = Array.isArray(i.lods) ? (a = i.lods[t]) == null ? void 0 : a.path : i.lods;
419
+ const g = Array.isArray(o.lods) ? (a = o.lods[t]) == null ? void 0 : a.path : o.lods;
419
420
  if (!g)
420
- return L && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, i)), null;
421
- const p = rt(o.url, g);
421
+ return L && !o["missing:uri"] && (o["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, o)), null;
422
+ const p = nt(i.url, g);
422
423
  if (p.endsWith(".glb") || p.endsWith(".gltf")) {
423
- if (!i.guid)
424
- return console.warn("missing pointer for glb/gltf texture", i), null;
425
- const D = p + "_" + i.guid, w = this.previouslyLoaded.get(D);
424
+ if (!o.guid)
425
+ return console.warn("missing pointer for glb/gltf texture", o), null;
426
+ const M = p + "_" + o.guid, w = this.previouslyLoaded.get(M);
426
427
  if (w !== void 0) {
427
- s && console.log(`LOD ${t} was already loading/loaded: ${D}`);
428
- let h = await w.catch((F) => (console.error(`Error loading LOD ${t} from ${p}
429
- `, F), null)), R = !1;
430
- if (h == null || (h instanceof se && e instanceof se ? (l = h.image) != null && l.data || (u = h.source) != null && u.data ? h = this.copySettings(e, h) : (R = !0, this.previouslyLoaded.delete(D)) : h instanceof ge && e instanceof ge && ((c = h.attributes.position) != null && c.array || (R = !0, this.previouslyLoaded.delete(D)))), !R)
428
+ s && console.log(`LOD ${t} was already loading/loaded: ${M}`);
429
+ let h = await w.catch((N) => (console.error(`Error loading LOD ${t} from ${p}
430
+ `, N), null)), k = !1;
431
+ if (h == null || (h instanceof re && e instanceof re ? (l = h.image) != null && l.data || (u = h.source) != null && u.data ? h = this.copySettings(e, h) : (k = !0, this.previouslyLoaded.delete(M)) : h instanceof ge && e instanceof ge && ((c = h.attributes.position) != null && c.array || (k = !0, this.previouslyLoaded.delete(M)))), !k)
431
432
  return h;
432
433
  }
433
- const x = i, $ = new Promise(async (h, R) => {
434
- const F = new be();
435
- $e(F), L && (await new Promise((S) => setTimeout(S, 1e3)), s && console.warn("Start loading (delayed) " + p, x.guid));
436
- let k = p;
434
+ const x = o, F = new Promise(async (h, k) => {
435
+ const N = new Te();
436
+ $e(N), L && (await new Promise((b) => setTimeout(b, 1e3)), s && console.warn("Start loading (delayed) " + p, x.guid));
437
+ let I = p;
437
438
  if (x && Array.isArray(x.lods)) {
438
- const S = x.lods[t];
439
- S.hash && (k += "?v=" + S.hash);
439
+ const b = x.lods[t];
440
+ b.hash && (I += "?v=" + b.hash);
440
441
  }
441
- const A = await F.loadAsync(k).catch((S) => (console.error(`Error loading LOD ${t} from ${p}
442
- `, S), null));
442
+ const A = await N.loadAsync(I).catch((b) => (console.error(`Error loading LOD ${t} from ${p}
443
+ `, b), null));
443
444
  if (!A)
444
445
  return null;
445
- const N = A.parser;
446
+ const W = A.parser;
446
447
  s && console.log("Loading finished " + p, x.guid);
447
448
  let _ = 0;
448
449
  if (A.parser.json.textures) {
449
- let S = !1;
450
+ let b = !1;
450
451
  for (const f of A.parser.json.textures) {
451
452
  if (f != null && f.extensions) {
452
- const y = f == null ? void 0 : f.extensions[V];
453
+ const y = f == null ? void 0 : f.extensions[q];
453
454
  if (y != null && y.guid && y.guid === x.guid) {
454
- S = !0;
455
+ b = !0;
455
456
  break;
456
457
  }
457
458
  }
458
459
  _++;
459
460
  }
460
- if (S) {
461
- let f = await N.getDependency("texture", _);
462
- return f && v.assignLODInformation(o.url, f, r, t, void 0, void 0), s && console.log('change "' + e.name + '" → "' + f.name + '"', p, _, f, D), e instanceof se && (f = this.copySettings(e, f)), f && (f.guid = x.guid), h(f);
461
+ if (b) {
462
+ let f = await W.getDependency("texture", _);
463
+ return f && v.assignLODInformation(i.url, f, r, t, void 0, void 0), s && console.log('change "' + e.name + '" → "' + f.name + '"', p, _, f, M), e instanceof re && (f = this.copySettings(e, f)), f && (f.guid = x.guid), h(f);
463
464
  } else
464
465
  L && console.warn("Could not find texture with guid", x.guid, A.parser.json);
465
466
  }
466
467
  if (_ = 0, A.parser.json.meshes) {
467
- let S = !1;
468
+ let b = !1;
468
469
  for (const f of A.parser.json.meshes) {
469
470
  if (f != null && f.extensions) {
470
- const y = f == null ? void 0 : f.extensions[V];
471
+ const y = f == null ? void 0 : f.extensions[q];
471
472
  if (y != null && y.guid && y.guid === x.guid) {
472
- S = !0;
473
+ b = !0;
473
474
  break;
474
475
  }
475
476
  }
476
477
  _++;
477
478
  }
478
- if (S) {
479
- const f = await N.getDependency("mesh", _), y = x;
480
- if (s && console.log(`Loaded Mesh "${f.name}"`, p, _, f, D), f.isMesh === !0) {
479
+ if (b) {
480
+ const f = await W.getDependency("mesh", _), y = x;
481
+ if (s && console.log(`Loaded Mesh "${f.name}"`, p, _, f, M), f.isMesh === !0) {
481
482
  const O = f.geometry;
482
- return v.assignLODInformation(o.url, O, r, t, void 0, y.density), h(O);
483
+ return v.assignLODInformation(i.url, O, r, t, void 0, y.density), h(O);
483
484
  } else {
484
485
  const O = new Array();
485
- for (let b = 0; b < f.children.length; b++) {
486
- const E = f.children[b];
487
- if (E.isMesh === !0) {
488
- const X = E.geometry;
489
- v.assignLODInformation(o.url, X, r, t, b, y.density), O.push(X);
486
+ for (let S = 0; S < f.children.length; S++) {
487
+ const P = f.children[S];
488
+ if (P.isMesh === !0) {
489
+ const H = P.geometry;
490
+ v.assignLODInformation(i.url, H, r, t, S, y.density), O.push(H);
490
491
  }
491
492
  }
492
493
  return h(O);
@@ -496,21 +497,21 @@ const v = class {
496
497
  }
497
498
  return h(null);
498
499
  });
499
- return this.previouslyLoaded.set(D, $), await $;
500
- } else if (e instanceof se) {
500
+ return this.previouslyLoaded.set(M, F), await F;
501
+ } else if (e instanceof re) {
501
502
  s && console.log("Load texture from uri: " + p);
502
- const w = await new Xe().loadAsync(p);
503
- return w ? (w.guid = i.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, s && console.log(i, w)) : L && console.warn("failed loading", p), w;
503
+ const w = await new qe().loadAsync(p);
504
+ return w ? (w.guid = o.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, s && console.log(o, w)) : L && console.warn("failed loading", p), w;
504
505
  }
505
506
  } else
506
507
  L && console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`, e.type);
507
508
  return null;
508
509
  }
509
- static assignLODInformation(e, t, s, o, r, i) {
510
+ static assignLODInformation(e, t, s, i, r, o) {
510
511
  if (!t)
511
512
  return;
512
513
  t.userData || (t.userData = {});
513
- const a = new ct(e, s, o, r, i);
514
+ const a = new dt(e, s, i, r, o);
514
515
  t.userData.LODS = a;
515
516
  }
516
517
  static getAssignedLODInformation(e) {
@@ -519,45 +520,45 @@ const v = class {
519
520
  }
520
521
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
521
522
  static copySettings(e, t) {
522
- return L && console.warn(`Copy texture settings
523
+ return t ? (L && console.warn(`Copy texture settings
523
524
  `, e.uuid, `
524
- `, t.uuid), t = t.clone(), t.offset = e.offset, t.repeat = e.repeat, t.colorSpace = e.colorSpace, t.magFilter = e.magFilter, t.minFilter = e.minFilter, t.wrapS = e.wrapS, t.wrapT = e.wrapT, t.flipY = e.flipY, t.anisotropy = e.anisotropy, t.mipmaps || (t.generateMipmaps = e.generateMipmaps), t;
525
+ `, t.uuid), t = t.clone(), t.offset = e.offset, t.repeat = e.repeat, t.colorSpace = e.colorSpace, t.magFilter = e.magFilter, t.minFilter = e.minFilter, t.wrapS = e.wrapS, t.wrapT = e.wrapT, t.flipY = e.flipY, t.anisotropy = e.anisotropy, t.mipmaps || (t.generateMipmaps = e.generateMipmaps), t) : e;
525
526
  }
526
527
  };
527
528
  let T = v;
528
529
  /**
529
530
  * Register a texture with LOD information
530
531
  */
531
- d(T, "registerTexture", (e, t, s, o, r) => {
532
- if (L && console.log("> Progressive: register texture", o, t.name, t.uuid, t, r), !t) {
532
+ d(T, "registerTexture", (e, t, s, i, r) => {
533
+ if (L && console.log("> Progressive: register texture", i, t.name, t.uuid, t, r), !t) {
533
534
  L && console.error("gltf-progressive: Register texture without texture");
534
535
  return;
535
536
  }
536
- t.source && (t.source[De] = r);
537
- const i = r.guid;
538
- v.assignLODInformation(e, t, i, s, o, void 0), v.lodInfos.set(i, r), v.lowresCache.set(i, t);
537
+ t.source && (t.source[Me] = r);
538
+ const o = r.guid;
539
+ v.assignLODInformation(e, t, o, s, i, void 0), v.lodInfos.set(o, r), v.lowresCache.set(o, t);
539
540
  }), /**
540
541
  * Register a mesh with LOD information
541
542
  */
542
- d(T, "registerMesh", (e, t, s, o, r, i) => {
543
+ d(T, "registerMesh", (e, t, s, i, r, o) => {
543
544
  var u;
544
- L && console.log("> Progressive: register mesh", r, s.name, i, s.uuid, s);
545
+ L && console.log("> Progressive: register mesh", r, s.name, o, s.uuid, s);
545
546
  const a = s.geometry;
546
547
  if (!a) {
547
548
  L && console.warn("gltf-progressive: Register mesh without geometry");
548
549
  return;
549
550
  }
550
- a.userData || (a.userData = {}), v.assignLODInformation(e, a, t, o, r, i.density), v.lodInfos.set(t, i);
551
+ a.userData || (a.userData = {}), v.assignLODInformation(e, a, t, i, r, o.density), v.lodInfos.set(t, o);
551
552
  let l = v.lowresCache.get(t);
552
- l ? l.push(s.geometry) : l = [s.geometry], v.lowresCache.set(t, l), o > 0 && !ce(s) && nt(s, a);
553
- for (const c of H)
554
- (u = c.onRegisteredNewMesh) == null || u.call(c, s, i);
553
+ l ? l.push(s.geometry) : l = [s.geometry], v.lowresCache.set(t, l), i > 0 && !ce(s) && ct(s, a);
554
+ for (const c of Z)
555
+ (u = c.onRegisteredNewMesh) == null || u.call(c, s, o);
555
556
  }), /** A map of key = asset uuid and value = LOD information */
556
557
  d(T, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
557
558
  d(T, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
558
559
  d(T, "lowresCache", /* @__PURE__ */ new Map());
559
- class ct {
560
- constructor(e, t, s, o, r) {
560
+ class dt {
561
+ constructor(e, t, s, i, r) {
561
562
  d(this, "url");
562
563
  /** the key to lookup the LOD information */
563
564
  d(this, "key");
@@ -566,17 +567,17 @@ class ct {
566
567
  d(this, "index");
567
568
  /** the mesh density */
568
569
  d(this, "density");
569
- this.url = e, this.key = t, this.level = s, o != null && (this.index = o), r != null && (this.density = r);
570
+ this.url = e, this.key = t, this.level = s, i != null && (this.index = i), r != null && (this.density = r);
570
571
  }
571
572
  }
572
- const I = le("debugprogressive"), ut = le("noprogressive"), we = Symbol("Needle:LODSManager"), ve = Symbol("Needle:LODState"), Y = Symbol("Needle:CurrentLOD"), G = { mesh_lod: -1, texture_lod: -1 };
573
- var C, W, ye, j, ee, me, q;
574
- const P = class {
573
+ const G = le("debugprogressive"), ht = le("noprogressive"), we = Symbol("Needle:LODSManager"), ve = Symbol("Needle:LODState"), Q = Symbol("Needle:CurrentLOD"), $ = { mesh_lod: -1, texture_lod: -1 };
574
+ var C, K, ye, te, se, me, Y;
575
+ const E = class {
575
576
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
576
577
  constructor(e, t) {
577
578
  d(this, "context");
578
579
  d(this, "renderer");
579
- d(this, "projectionScreenMatrix", new Ae());
580
+ d(this, "projectionScreenMatrix", new Pe());
580
581
  /**
581
582
  * The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
582
583
  * @default 200_000
@@ -587,7 +588,7 @@ const P = class {
587
588
  * @default "auto"
588
589
  */
589
590
  d(this, "updateInterval", "auto");
590
- K(this, C, 1);
591
+ J(this, C, 1);
591
592
  /**
592
593
  * If set to true, the LODsManager will not update the LODs.
593
594
  * @default false
@@ -600,21 +601,21 @@ const P = class {
600
601
  */
601
602
  d(this, "manual", !1);
602
603
  d(this, "_lodchangedlisteners", []);
603
- K(this, W, void 0);
604
- K(this, ye, new Ke());
605
- K(this, j, 0);
606
- K(this, ee, 0);
607
- K(this, me, 0);
608
- K(this, q, 0);
604
+ J(this, K, void 0);
605
+ J(this, ye, new Ke());
606
+ J(this, te, 0);
607
+ J(this, se, 0);
608
+ J(this, me, 0);
609
+ J(this, Y, 0);
609
610
  d(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
610
611
  // private testIfLODLevelsAreAvailable() {
611
612
  d(this, "_sphere", new He());
612
613
  d(this, "_tempBox", new Ee());
613
614
  d(this, "_tempBox2", new Ee());
614
- d(this, "tempMatrix", new Ae());
615
- d(this, "_tempWorldPosition", new z());
616
- d(this, "_tempBoxSize", new z());
617
- d(this, "_tempBox2Size", new z());
615
+ d(this, "tempMatrix", new Pe());
616
+ d(this, "_tempWorldPosition", new X());
617
+ d(this, "_tempBoxSize", new X());
618
+ d(this, "_tempBox2Size", new X());
618
619
  this.renderer = e, this.context = { ...t };
619
620
  }
620
621
  /** @internal */
@@ -622,11 +623,11 @@ const P = class {
622
623
  return e[ve];
623
624
  }
624
625
  static addPlugin(e) {
625
- H.push(e);
626
+ Z.push(e);
626
627
  }
627
628
  static removePlugin(e) {
628
- const t = H.indexOf(e);
629
- t >= 0 && H.splice(t, 1);
629
+ const t = Z.indexOf(e);
630
+ t >= 0 && Z.splice(t, 1);
630
631
  }
631
632
  /**
632
633
  * Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
@@ -636,7 +637,7 @@ const P = class {
636
637
  static get(e, t) {
637
638
  if (e[we])
638
639
  return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), e[we];
639
- const s = new P(e, {
640
+ const s = new E(e, {
640
641
  engine: "unknown",
641
642
  ...t
642
643
  });
@@ -644,7 +645,7 @@ const P = class {
644
645
  }
645
646
  /** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
646
647
  get plugins() {
647
- return H;
648
+ return Z;
648
649
  }
649
650
  addEventListener(e, t) {
650
651
  e === "changed" && this._lodchangedlisteners.push(t);
@@ -659,21 +660,21 @@ const P = class {
659
660
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
660
661
  */
661
662
  enable() {
662
- if (m(this, W))
663
+ if (m(this, K))
663
664
  return;
664
665
  console.debug("[gltf-progressive] Enabling LODsManager for renderer");
665
666
  let e = 0;
666
- U(this, W, this.renderer.render);
667
+ z(this, K, this.renderer.render);
667
668
  const t = this;
668
- Ge(this.renderer), this.renderer.render = function(s, o) {
669
+ Ge(this.renderer), this.renderer.render = function(s, i) {
669
670
  const r = t.renderer.getRenderTarget();
670
- (r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, U(t, j, m(t, j) + 1), U(t, ee, m(t, ye).getDelta()), U(t, me, m(t, me) + m(t, ee)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / m(t, ee)), U(t, q, t._fpsBuffer.reduce((a, l) => a + l) / t._fpsBuffer.length), I && m(t, j) % 200 === 0 && console.log("FPS", Math.round(m(t, q)), "Interval:", m(t, C)));
671
- const i = e++;
672
- m(t, W).call(this, s, o), t.onAfterRender(s, o, i);
671
+ (r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, z(t, te, m(t, te) + 1), z(t, se, m(t, ye).getDelta()), z(t, me, m(t, me) + m(t, se)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / m(t, se)), z(t, Y, t._fpsBuffer.reduce((a, l) => a + l) / t._fpsBuffer.length), G && m(t, te) % 200 === 0 && console.log("FPS", Math.round(m(t, Y)), "Interval:", m(t, C)));
672
+ const o = e++;
673
+ m(t, K).call(this, s, i), t.onAfterRender(s, i, o);
673
674
  };
674
675
  }
675
676
  disable() {
676
- m(this, W) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = m(this, W), U(this, W, void 0));
677
+ m(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = m(this, K), z(this, K, void 0));
677
678
  }
678
679
  update(e, t) {
679
680
  this.internalUpdate(e, t);
@@ -682,13 +683,13 @@ const P = class {
682
683
  if (this.pause)
683
684
  return;
684
685
  const r = this.renderer.renderLists.get(e, 0).opaque;
685
- let i = !0;
686
+ let o = !0;
686
687
  if (r.length === 1) {
687
688
  const a = r[0].material;
688
- (a.name === "EffectMaterial" || a.name === "CopyShader") && (i = !1);
689
+ (a.name === "EffectMaterial" || a.name === "CopyShader") && (o = !1);
689
690
  }
690
- if ((t.parent && t.parent.type === "CubeCamera" || s >= 1 && t.type === "OrthographicCamera") && (i = !1), i) {
691
- if (ut || (this.updateInterval === "auto" ? m(this, q) < 40 && m(this, C) < 10 ? (U(this, C, m(this, C) + 1), I && console.warn("↓ Reducing LOD updates", m(this, C), m(this, q).toFixed(0))) : m(this, q) >= 60 && m(this, C) > 1 && (U(this, C, m(this, C) - 1), I && console.warn("↑ Increasing LOD updates", m(this, C), m(this, q).toFixed(0))) : U(this, C, this.updateInterval), m(this, C) > 0 && m(this, j) % m(this, C) != 0))
691
+ if ((t.parent && t.parent.type === "CubeCamera" || s >= 1 && t.type === "OrthographicCamera") && (o = !1), o) {
692
+ if (ht || (this.updateInterval === "auto" ? m(this, Y) < 40 && m(this, C) < 10 ? (z(this, C, m(this, C) + 1), G && console.warn("↓ Reducing LOD updates", m(this, C), m(this, Y).toFixed(0))) : m(this, Y) >= 60 && m(this, C) > 1 && (z(this, C, m(this, C) - 1), G && console.warn("↑ Increasing LOD updates", m(this, C), m(this, Y).toFixed(0))) : z(this, C, this.updateInterval), m(this, C) > 0 && m(this, te) % m(this, C) != 0))
692
693
  return;
693
694
  this.internalUpdate(e, t);
694
695
  }
@@ -698,12 +699,12 @@ const P = class {
698
699
  */
699
700
  internalUpdate(e, t) {
700
701
  var l, u;
701
- const s = this.renderer.renderLists.get(e, 0), o = s.opaque;
702
+ const s = this.renderer.renderLists.get(e, 0), i = s.opaque;
702
703
  this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse);
703
704
  const r = this.targetTriangleDensity;
704
- for (const c of o) {
705
+ for (const c of i) {
705
706
  if (c.material && (((l = c.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((u = c.geometry) == null ? void 0 : u.type) === "BufferGeometry") && (c.material.name === "SphericalGaussianBlur" || c.material.name == "BackgroundCubeMaterial" || c.material.name === "CubemapFromEquirect" || c.material.name === "EquirectangularToCubeUV")) {
706
- I && (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", c, c.material.name, c.material.type)));
707
+ G && (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", c, c.material.name, c.material.type)));
707
708
  continue;
708
709
  }
709
710
  switch (c.material.type) {
@@ -715,40 +716,40 @@ const P = class {
715
716
  case "MeshDepthMaterial":
716
717
  continue;
717
718
  }
718
- if (I === "color" && c.material && !c.object.progressive_debug_color) {
719
+ if (G === "color" && c.material && !c.object.progressive_debug_color) {
719
720
  c.object.progressive_debug_color = !0;
720
- const p = Math.random() * 16777215, D = new Ye({ color: p });
721
- c.object.material = D;
721
+ const p = Math.random() * 16777215, M = new Ye({ color: p });
722
+ c.object.material = M;
722
723
  }
723
724
  const g = c.object;
724
- (g instanceof Z || g.isMesh) && this.updateLODs(e, t, g, r);
725
+ (g instanceof j || g.isMesh) && this.updateLODs(e, t, g, r);
725
726
  }
726
- const i = s.transparent;
727
- for (const c of i) {
727
+ const o = s.transparent;
728
+ for (const c of o) {
728
729
  const g = c.object;
729
- (g instanceof Z || g.isMesh) && this.updateLODs(e, t, g, r);
730
+ (g instanceof j || g.isMesh) && this.updateLODs(e, t, g, r);
730
731
  }
731
732
  const a = s.transmissive;
732
733
  for (const c of a) {
733
734
  const g = c.object;
734
- (g instanceof Z || g.isMesh) && this.updateLODs(e, t, g, r);
735
+ (g instanceof j || g.isMesh) && this.updateLODs(e, t, g, r);
735
736
  }
736
737
  }
737
738
  /** Update the LOD levels for the renderer. */
738
- updateLODs(e, t, s, o) {
739
+ updateLODs(e, t, s, i) {
739
740
  var a, l;
740
741
  s.userData || (s.userData = {});
741
742
  let r = s[ve];
742
- if (r || (r = new ft(), s[ve] = r), r.frames++ < 2)
743
+ if (r || (r = new gt(), s[ve] = r), r.frames++ < 2)
743
744
  return;
744
- for (const u of H)
745
+ for (const u of Z)
745
746
  (a = u.onBeforeUpdateLOD) == null || a.call(u, this.renderer, e, t, s);
746
- this.calculateLodLevel(t, s, r, o, 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);
747
- let i = G.texture_lod;
748
- s.material && i >= 0 && this.loadProgressiveTextures(s.material, i);
749
- for (const u of H)
750
- (l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, e, t, s, G);
751
- r.lastLodLevel_Mesh = G.mesh_lod, r.lastLodLevel_Texture = G.texture_lod;
747
+ this.calculateLodLevel(t, s, r, i, $), $.mesh_lod = Math.round($.mesh_lod), $.texture_lod = Math.round($.texture_lod), $.mesh_lod >= 0 && this.loadProgressiveMeshes(s, $.mesh_lod);
748
+ let o = $.texture_lod;
749
+ s.material && o >= 0 && this.loadProgressiveTextures(s.material, o);
750
+ for (const u of Z)
751
+ (l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, e, t, s, $);
752
+ r.lastLodLevel_Mesh = $.mesh_lod, r.lastLodLevel_Texture = $.texture_lod;
752
753
  }
753
754
  /** Load progressive textures for the given material
754
755
  * @param material the material to load the textures for
@@ -764,10 +765,10 @@ const P = class {
764
765
  return;
765
766
  }
766
767
  let s = !1;
767
- (e[Y] === void 0 || t < e[Y]) && (s = !0);
768
- const o = e["DEBUG:LOD"];
769
- o != null && (s = e[Y] != o, t = o), s && (e[Y] = t, T.assignTextureLOD(e, t).then((r) => {
770
- this._lodchangedlisteners.forEach((i) => i({ type: "texture", level: t, object: e }));
768
+ (e[Q] === void 0 || t < e[Q]) && (s = !0);
769
+ const i = e["DEBUG:LOD"];
770
+ i != null && (s = e[Q] != i, t = i), s && (e[Q] = t, T.assignTextureLOD(e, t).then((r) => {
771
+ this._lodchangedlisteners.forEach((o) => o({ type: "texture", level: t, object: e }));
771
772
  }));
772
773
  }
773
774
  /** Load progressive meshes for the given mesh
@@ -779,21 +780,21 @@ const P = class {
779
780
  loadProgressiveMeshes(e, t) {
780
781
  if (!e)
781
782
  return Promise.resolve(null);
782
- let s = e[Y] !== t;
783
- const o = e["DEBUG:LOD"];
784
- if (o != null && (s = e[Y] != o, t = o), s) {
785
- e[Y] = t;
783
+ let s = e[Q] !== t;
784
+ const i = e["DEBUG:LOD"];
785
+ if (i != null && (s = e[Q] != i, t = i), s) {
786
+ e[Q] = t;
786
787
  const r = e.geometry;
787
- return T.assignMeshLOD(e, t).then((i) => (i && e[Y] == t && r != e.geometry && this._lodchangedlisteners.forEach((a) => a({ type: "mesh", level: t, object: e })), i));
788
+ return T.assignMeshLOD(e, t).then((o) => (o && e[Q] == t && r != e.geometry && this._lodchangedlisteners.forEach((a) => a({ type: "mesh", level: t, object: e })), o));
788
789
  }
789
790
  return Promise.resolve(null);
790
791
  }
791
792
  static isInside(e, t) {
792
- const s = e.min, o = e.max, r = (s.x + o.x) * 0.5, i = (s.y + o.y) * 0.5;
793
- return this._tempPtInside.set(r, i, s.z).applyMatrix4(t).z < 0;
793
+ const s = e.min, i = e.max, r = (s.x + i.x) * 0.5, o = (s.y + i.y) * 0.5;
794
+ return this._tempPtInside.set(r, o, s.z).applyMatrix4(t).z < 0;
794
795
  }
795
- calculateLodLevel(e, t, s, o, r) {
796
- var $;
796
+ calculateLodLevel(e, t, s, i, r) {
797
+ var F;
797
798
  if (!t) {
798
799
  r.mesh_lod = -1, r.texture_lod = -1;
799
800
  return;
@@ -803,10 +804,10 @@ const P = class {
803
804
  return;
804
805
  }
805
806
  let a = 10 + 1, l = !1;
806
- if (I && t["DEBUG:LOD"] != null)
807
+ if (G && t["DEBUG:LOD"] != null)
807
808
  return t["DEBUG:LOD"];
808
- const u = T.getMeshLODInformation(t.geometry), c = u == null ? void 0 : u.lods, g = c && c.length > 0, p = T.getMaterialMinMaxLODsCount(t.material), D = (p == null ? void 0 : p.min_count) != 1 / 0 && p.min_count > 0 && p.max_count > 0;
809
- if (!g && !D) {
809
+ const u = T.getMeshLODInformation(t.geometry), c = u == null ? void 0 : u.lods, g = c && c.length > 0, p = T.getMaterialMinMaxLODsCount(t.material), M = (p == null ? void 0 : p.min_count) != 1 / 0 && p.min_count > 0 && p.max_count > 0;
810
+ if (!g && !M) {
810
811
  r.mesh_lod = 0, r.texture_lod = 0;
811
812
  return;
812
813
  }
@@ -814,17 +815,17 @@ const P = class {
814
815
  const w = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
815
816
  let x = t.geometry.boundingBox;
816
817
  if (t.type === "SkinnedMesh") {
817
- const M = t;
818
- if (!M.boundingBox)
819
- M.computeBoundingBox();
818
+ const D = t;
819
+ if (!D.boundingBox)
820
+ D.computeBoundingBox();
820
821
  else if (s.frames % 30 === 0) {
821
- const h = ce(M), R = M.geometry;
822
- h && (M.geometry = h), M.computeBoundingBox(), M.geometry = R;
822
+ const h = ce(D), k = D.geometry;
823
+ h && (D.geometry = h), D.computeBoundingBox(), D.geometry = k;
823
824
  }
824
- x = M.boundingBox;
825
+ x = D.boundingBox;
825
826
  }
826
827
  if (x) {
827
- const M = e;
828
+ const D = e;
828
829
  if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
829
830
  this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
830
831
  const f = e.getWorldPosition(this._tempWorldPosition);
@@ -833,66 +834,66 @@ const P = class {
833
834
  return;
834
835
  }
835
836
  }
836
- if (this._tempBox.copy(x), this._tempBox.applyMatrix4(t.matrixWorld), M.isPerspectiveCamera && P.isInside(this._tempBox, this.projectionScreenMatrix)) {
837
+ if (this._tempBox.copy(x), this._tempBox.applyMatrix4(t.matrixWorld), D.isPerspectiveCamera && E.isInside(this._tempBox, this.projectionScreenMatrix)) {
837
838
  r.mesh_lod = 0, r.texture_lod = 0;
838
839
  return;
839
840
  }
840
- if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && M.isPerspectiveCamera && M.fov > 70) {
841
+ if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && D.isPerspectiveCamera && D.fov > 70) {
841
842
  const f = this._tempBox.min, y = this._tempBox.max;
842
- let O = f.x, b = f.y, E = y.x, X = y.y;
843
+ let O = f.x, S = f.y, P = y.x, H = y.y;
843
844
  const ue = 2, Le = 1.5, fe = (f.x + y.x) * 0.5, de = (f.y + y.y) * 0.5;
844
- O = (O - fe) * ue + fe, b = (b - de) * ue + de, E = (E - fe) * ue + fe, X = (X - de) * ue + de;
845
- const ze = O < 0 && E > 0 ? 0 : Math.min(Math.abs(f.x), Math.abs(y.x)), Ve = b < 0 && X > 0 ? 0 : Math.min(Math.abs(f.y), Math.abs(y.y)), xe = Math.max(ze, Ve);
845
+ O = (O - fe) * ue + fe, S = (S - de) * ue + de, P = (P - fe) * ue + fe, H = (H - de) * ue + de;
846
+ const ze = O < 0 && P > 0 ? 0 : Math.min(Math.abs(f.x), Math.abs(y.x)), Ve = S < 0 && H > 0 ? 0 : Math.min(Math.abs(f.y), Math.abs(y.y)), xe = Math.max(ze, Ve);
846
847
  s.lastCentrality = (Le - xe) * (Le - xe) * (Le - xe);
847
848
  } else
848
849
  s.lastCentrality = 1;
849
850
  const h = this._tempBox.getSize(this._tempBoxSize);
850
851
  h.multiplyScalar(0.5), screen.availHeight > 0 && w > 0 && h.multiplyScalar(w / screen.availHeight), e.isPerspectiveCamera ? h.x *= e.aspect : e.isOrthographicCamera;
851
- const R = e.matrixWorldInverse, F = this._tempBox2;
852
- F.copy(x), F.applyMatrix4(t.matrixWorld), F.applyMatrix4(R);
853
- const k = F.getSize(this._tempBox2Size), A = Math.max(k.x, k.y);
854
- if (Math.max(h.x, h.y) != 0 && A != 0 && (h.z = k.z / Math.max(k.x, k.y) * Math.max(h.x, h.y)), s.lastScreenCoverage = Math.max(h.x, h.y, h.z), s.lastScreenspaceVolume.copy(h), s.lastScreenCoverage *= s.lastCentrality, I && P.debugDrawLine) {
852
+ const k = e.matrixWorldInverse, N = this._tempBox2;
853
+ N.copy(x), N.applyMatrix4(t.matrixWorld), N.applyMatrix4(k);
854
+ const I = N.getSize(this._tempBox2Size), A = Math.max(I.x, I.y);
855
+ if (Math.max(h.x, h.y) != 0 && A != 0 && (h.z = I.z / Math.max(I.x, I.y) * Math.max(h.x, h.y)), s.lastScreenCoverage = Math.max(h.x, h.y, h.z), s.lastScreenspaceVolume.copy(h), s.lastScreenCoverage *= s.lastCentrality, G && E.debugDrawLine) {
855
856
  const f = this.tempMatrix.copy(this.projectionScreenMatrix);
856
857
  f.invert();
857
- const y = P.corner0, O = P.corner1, b = P.corner2, E = P.corner3;
858
- y.copy(this._tempBox.min), O.copy(this._tempBox.max), O.x = y.x, b.copy(this._tempBox.max), b.y = y.y, E.copy(this._tempBox.max);
859
- const X = (y.z + E.z) * 0.5;
860
- y.z = O.z = b.z = E.z = X, y.applyMatrix4(f), O.applyMatrix4(f), b.applyMatrix4(f), E.applyMatrix4(f), P.debugDrawLine(y, O, 255), P.debugDrawLine(y, b, 255), P.debugDrawLine(O, E, 255), P.debugDrawLine(b, E, 255);
858
+ const y = E.corner0, O = E.corner1, S = E.corner2, P = E.corner3;
859
+ y.copy(this._tempBox.min), O.copy(this._tempBox.max), O.x = y.x, S.copy(this._tempBox.max), S.y = y.y, P.copy(this._tempBox.max);
860
+ const H = (y.z + P.z) * 0.5;
861
+ y.z = O.z = S.z = P.z = H, y.applyMatrix4(f), O.applyMatrix4(f), S.applyMatrix4(f), P.applyMatrix4(f), E.debugDrawLine(y, O, 255), E.debugDrawLine(y, S, 255), E.debugDrawLine(O, P, 255), E.debugDrawLine(S, P, 255);
861
862
  }
862
863
  let _ = 999;
863
864
  if (c && s.lastScreenCoverage > 0) {
864
865
  for (let f = 0; f < c.length; f++)
865
- if (c[f].density / s.lastScreenCoverage < o) {
866
+ if (c[f].density / s.lastScreenCoverage < i) {
866
867
  _ = f;
867
868
  break;
868
869
  }
869
870
  }
870
871
  _ < a && (a = _, l = !0);
871
872
  }
872
- if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, I && r.mesh_lod != s.lastLodLevel_Mesh) {
873
+ if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, G && r.mesh_lod != s.lastLodLevel_Mesh) {
873
874
  const h = c == null ? void 0 : c[r.mesh_lod];
874
875
  h && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${h.density.toFixed(0)}) - ${t.name}`);
875
876
  }
876
- if (D) {
877
- const M = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
877
+ if (M) {
878
+ const D = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
878
879
  if (s.lastLodLevel_Texture < 0) {
879
- if (r.texture_lod = p.max_count - 1, I) {
880
+ if (r.texture_lod = p.max_count - 1, G) {
880
881
  const h = p.lods[p.max_count - 1];
881
- I && console.log(`First Texture LOD ${r.texture_lod} (${h.max_height}px) - ${t.name}`);
882
+ G && console.log(`First Texture LOD ${r.texture_lod} (${h.max_height}px) - ${t.name}`);
882
883
  }
883
884
  } else {
884
885
  const h = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
885
- let R = s.lastScreenCoverage * 4;
886
- (($ = this.context) == null ? void 0 : $.engine) === "model-viewer" && (R *= 1.5);
887
- const k = w / window.devicePixelRatio * R;
886
+ let k = s.lastScreenCoverage * 4;
887
+ ((F = this.context) == null ? void 0 : F.engine) === "model-viewer" && (k *= 1.5);
888
+ const I = w / window.devicePixelRatio * k;
888
889
  let A = !1;
889
- for (let N = p.lods.length - 1; N >= 0; N--) {
890
- let _ = p.lods[N];
891
- if (!(M && _.max_height >= 2048) && !(it() && _.max_height > 4096) && (_.max_height > k || !A && N === 0)) {
892
- if (A = !0, r.texture_lod = N, r.texture_lod < s.lastLodLevel_Texture) {
893
- const S = _.max_height;
894
- I && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${S}px
895
- Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${h.toFixed(1)}
890
+ for (let W = p.lods.length - 1; W >= 0; W--) {
891
+ let _ = p.lods[W];
892
+ if (!(D && _.max_height >= 2048) && !(at() && _.max_height > 4096) && (_.max_height > I || !A && W === 0)) {
893
+ if (A = !0, r.texture_lod = W, r.texture_lod < s.lastLodLevel_Texture) {
894
+ const b = _.max_height;
895
+ G && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${b}px
896
+ Screensize: ${I.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${h.toFixed(1)}
896
897
  ${t.name}`);
897
898
  }
898
899
  break;
@@ -903,66 +904,66 @@ ${t.name}`);
903
904
  r.texture_lod = 0;
904
905
  }
905
906
  };
906
- let B = P;
907
- C = new WeakMap(), W = new WeakMap(), ye = new WeakMap(), j = new WeakMap(), ee = new WeakMap(), me = new WeakMap(), q = new WeakMap(), /** 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.
907
+ let R = E;
908
+ C = new WeakMap(), K = new WeakMap(), ye = new WeakMap(), te = new WeakMap(), se = new WeakMap(), me = new WeakMap(), Y = new WeakMap(), /** 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.
908
909
  */
909
- d(B, "debugDrawLine"), d(B, "corner0", new z()), d(B, "corner1", new z()), d(B, "corner2", new z()), d(B, "corner3", new z()), d(B, "_tempPtInside", new z());
910
- class ft {
910
+ d(R, "debugDrawLine"), d(R, "corner0", new X()), d(R, "corner1", new X()), d(R, "corner2", new X()), d(R, "corner3", new X()), d(R, "_tempPtInside", new X());
911
+ class gt {
911
912
  constructor() {
912
913
  d(this, "frames", 0);
913
914
  d(this, "lastLodLevel_Mesh", -1);
914
915
  d(this, "lastLodLevel_Texture", -1);
915
916
  d(this, "lastScreenCoverage", 0);
916
- d(this, "lastScreenspaceVolume", new z());
917
+ d(this, "lastScreenspaceVolume", new X());
917
918
  d(this, "lastCentrality", 0);
918
919
  }
919
920
  }
920
- const Ce = Symbol("NEEDLE_mesh_lod"), he = Symbol("NEEDLE_texture_lod");
921
- let oe = null;
922
- function Ue() {
923
- const n = dt();
921
+ const Be = Symbol("NEEDLE_mesh_lod"), he = Symbol("NEEDLE_texture_lod");
922
+ let ne = null;
923
+ function Fe() {
924
+ const n = pt();
924
925
  n && (n.mapURLs(function(e) {
925
- return Be(), e;
926
- }), Be(), oe == null || oe.disconnect(), oe = new MutationObserver((e) => {
926
+ return Re(), e;
927
+ }), Re(), ne == null || ne.disconnect(), ne = new MutationObserver((e) => {
927
928
  e.forEach((t) => {
928
929
  t.addedNodes.forEach((s) => {
929
930
  s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Ne(s);
930
931
  });
931
932
  });
932
- }), oe.observe(document, { childList: !0, subtree: !0 }));
933
+ }), ne.observe(document, { childList: !0, subtree: !0 }));
933
934
  }
934
- function dt() {
935
+ function pt() {
935
936
  if (typeof customElements > "u")
936
937
  return null;
937
938
  const n = customElements.get("model-viewer");
938
939
  return n || (customElements.whenDefined("model-viewer").then(() => {
939
- console.debug("[gltf-progressive] model-viewer defined"), Ue();
940
+ console.debug("[gltf-progressive] model-viewer defined"), Fe();
940
941
  }), null);
941
942
  }
942
- function Be() {
943
+ function Re() {
943
944
  if (typeof document > "u")
944
945
  return;
945
946
  document.querySelectorAll("model-viewer").forEach((e) => {
946
947
  Ne(e);
947
948
  });
948
949
  }
949
- const Re = /* @__PURE__ */ new WeakSet();
950
- let ht = 0;
950
+ const ke = /* @__PURE__ */ new WeakSet();
951
+ let yt = 0;
951
952
  function Ne(n) {
952
- if (!n || Re.has(n))
953
+ if (!n || ke.has(n))
953
954
  return null;
954
- Re.add(n), console.debug("[gltf-progressive] found new model-viewer..." + ++ht + `
955
+ ke.add(n), console.debug("[gltf-progressive] found new model-viewer..." + ++yt + `
955
956
  `, n.getAttribute("src"));
956
957
  let e = null, t = null, s = null;
957
- for (let o = n; o != null; o = Object.getPrototypeOf(o)) {
958
- const r = Object.getOwnPropertySymbols(o), i = r.find((u) => u.toString() == "Symbol(renderer)"), a = r.find((u) => u.toString() == "Symbol(scene)"), l = r.find((u) => u.toString() == "Symbol(needsRender)");
959
- !e && i != null && (e = n[i].threeRenderer), !t && a != null && (t = n[a]), !s && l != null && (s = n[l]);
958
+ for (let i = n; i != null; i = Object.getPrototypeOf(i)) {
959
+ const r = Object.getOwnPropertySymbols(i), o = r.find((u) => u.toString() == "Symbol(renderer)"), a = r.find((u) => u.toString() == "Symbol(scene)"), l = r.find((u) => u.toString() == "Symbol(needsRender)");
960
+ !e && o != null && (e = n[o].threeRenderer), !t && a != null && (t = n[a]), !s && l != null && (s = n[l]);
960
961
  }
961
962
  if (e && t) {
962
- let o = function() {
963
+ let i = function() {
963
964
  if (s) {
964
- let i = 0, a = setInterval(() => {
965
- if (i++ > 5) {
965
+ let o = 0, a = setInterval(() => {
966
+ if (o++ > 5) {
966
967
  clearInterval(a);
967
968
  return;
968
969
  }
@@ -971,25 +972,25 @@ function Ne(n) {
971
972
  }
972
973
  };
973
974
  console.debug("[gltf-progressive] setup model-viewer");
974
- const r = B.get(e, { engine: "model-viewer" });
975
- return B.addPlugin(new gt()), r.enable(), r.addEventListener("changed", () => {
975
+ const r = R.get(e, { engine: "model-viewer" });
976
+ return R.addPlugin(new mt()), r.enable(), r.addEventListener("changed", () => {
976
977
  s == null || s.call(n);
977
- }), n.addEventListener("model-visibility", (i) => {
978
- i.detail.visible && (s == null || s.call(n));
978
+ }), n.addEventListener("model-visibility", (o) => {
979
+ o.detail.visible && (s == null || s.call(n));
979
980
  }), n.addEventListener("load", () => {
980
- o();
981
+ i();
981
982
  }), () => {
982
983
  r.disable();
983
984
  };
984
985
  }
985
986
  return null;
986
987
  }
987
- class gt {
988
+ class mt {
988
989
  constructor() {
989
990
  d(this, "_didWarnAboutMissingUrl", !1);
990
991
  }
991
- onBeforeUpdateLOD(e, t, s, o) {
992
- this.tryParseMeshLOD(t, o), this.tryParseTextureLOD(t, o);
992
+ onBeforeUpdateLOD(e, t, s, i) {
993
+ this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
993
994
  }
994
995
  getUrl(e) {
995
996
  if (!e)
@@ -1007,28 +1008,28 @@ class gt {
1007
1008
  if (t[he] == !0)
1008
1009
  return;
1009
1010
  t[he] = !0;
1010
- const s = this.tryGetCurrentGLTF(e), o = this.tryGetCurrentModelViewer(e), r = this.getUrl(o);
1011
+ const s = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), r = this.getUrl(i);
1011
1012
  if (r && s && t.material) {
1012
- let i = function(l) {
1013
+ let o = function(l) {
1013
1014
  var c, g, p;
1014
1015
  if (l[he] == !0)
1015
1016
  return;
1016
1017
  l[he] = !0, l.userData && (l.userData.LOD = -1);
1017
1018
  const u = Object.keys(l);
1018
- for (let D = 0; D < u.length; D++) {
1019
- const w = u[D], x = l[w];
1019
+ for (let M = 0; M < u.length; M++) {
1020
+ const w = u[M], x = l[w];
1020
1021
  if ((x == null ? void 0 : x.isTexture) === !0) {
1021
- const $ = (g = (c = x.userData) == null ? void 0 : c.associations) == null ? void 0 : g.textures;
1022
- if ($ == null)
1022
+ const F = (g = (c = x.userData) == null ? void 0 : c.associations) == null ? void 0 : g.textures;
1023
+ if (F == null)
1023
1024
  continue;
1024
- const M = s.parser.json.textures[$];
1025
- if (!M) {
1026
- console.warn("Texture data not found for texture index " + $);
1025
+ const D = s.parser.json.textures[F];
1026
+ if (!D) {
1027
+ console.warn("Texture data not found for texture index " + F);
1027
1028
  continue;
1028
1029
  }
1029
- if ((p = M == null ? void 0 : M.extensions) != null && p[V]) {
1030
- const h = M.extensions[V];
1031
- h && r && T.registerTexture(r, x, h.lods.length, $, h);
1030
+ if ((p = D == null ? void 0 : D.extensions) != null && p[q]) {
1031
+ const h = D.extensions[q];
1032
+ h && r && T.registerTexture(r, x, h.lods.length, F, h);
1032
1033
  }
1033
1034
  }
1034
1035
  }
@@ -1036,43 +1037,43 @@ class gt {
1036
1037
  const a = t.material;
1037
1038
  if (Array.isArray(a))
1038
1039
  for (const l of a)
1039
- i(l);
1040
+ o(l);
1040
1041
  else
1041
- i(a);
1042
+ o(a);
1042
1043
  }
1043
1044
  }
1044
1045
  tryParseMeshLOD(e, t) {
1045
- var i, a;
1046
- if (t[Ce] == !0)
1046
+ var o, a;
1047
+ if (t[Be] == !0)
1047
1048
  return;
1048
- t[Ce] = !0;
1049
- const s = this.tryGetCurrentModelViewer(e), o = this.getUrl(s);
1050
- if (!o)
1049
+ t[Be] = !0;
1050
+ const s = this.tryGetCurrentModelViewer(e), i = this.getUrl(s);
1051
+ if (!i)
1051
1052
  return;
1052
- const r = (a = (i = t.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[V];
1053
- if (r && o) {
1053
+ const r = (a = (o = t.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : a[q];
1054
+ if (r && i) {
1054
1055
  const l = t.uuid;
1055
- T.registerMesh(o, l, t, 0, r.lods.length, r);
1056
+ T.registerMesh(i, l, t, 0, r.lods.length, r);
1056
1057
  }
1057
1058
  }
1058
1059
  }
1059
- function pt(n, e, t, s) {
1060
- Ge(e), $e(t), Fe(t, {
1060
+ function Lt(n, e, t, s) {
1061
+ Ge(e), $e(t), Ue(t, {
1061
1062
  progressive: !0,
1062
1063
  ...s == null ? void 0 : s.hints
1063
1064
  }), t.register((r) => new T(r, n));
1064
- const o = B.get(e);
1065
- return (s == null ? void 0 : s.enableLODsManager) !== !1 && o.enable(), o;
1065
+ const i = R.get(e);
1066
+ return (s == null ? void 0 : s.enableLODsManager) !== !1 && i.enable(), i;
1066
1067
  }
1067
- Ue();
1068
- if (!ot) {
1068
+ Fe();
1069
+ if (!lt) {
1069
1070
  const n = {
1070
1071
  gltfProgressive: {
1071
- useNeedleProgressive: pt,
1072
- LODsManager: B,
1073
- configureLoader: Fe,
1072
+ useNeedleProgressive: Lt,
1073
+ LODsManager: R,
1074
+ configureLoader: Ue,
1074
1075
  getRaycastMesh: ce,
1075
- useRaycastMeshes: at
1076
+ useRaycastMeshes: ut
1076
1077
  }
1077
1078
  };
1078
1079
  if (!globalThis.Needle)
@@ -1082,18 +1083,18 @@ if (!ot) {
1082
1083
  globalThis.Needle[e] = n[e];
1083
1084
  }
1084
1085
  export {
1085
- V as EXTENSION_NAME,
1086
- B as LODsManager,
1086
+ q as EXTENSION_NAME,
1087
+ R as LODsManager,
1087
1088
  T as NEEDLE_progressive,
1088
- ke as VERSION,
1089
+ je as VERSION,
1089
1090
  $e as addDracoAndKTX2Loaders,
1090
- Fe as configureLoader,
1091
+ Ue as configureLoader,
1091
1092
  Ge as createLoaders,
1092
1093
  ce as getRaycastMesh,
1093
- Ue as patchModelViewer,
1094
- nt as registerRaycastMesh,
1095
- wt as setDracoDecoderLocation,
1096
- vt as setKTX2TranscoderLocation,
1097
- pt as useNeedleProgressive,
1098
- at as useRaycastMeshes
1094
+ Fe as patchModelViewer,
1095
+ ct as registerRaycastMesh,
1096
+ rt as setDracoDecoderLocation,
1097
+ ot as setKTX2TranscoderLocation,
1098
+ Lt as useNeedleProgressive,
1099
+ ut as useRaycastMeshes
1099
1100
  };