@needle-tools/gltf-progressive 2.1.0-alpha.2 → 2.1.0-experimental.3

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