@needle-tools/gltf-progressive 1.2.0-alpha.4 → 1.2.0-alpha.6

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,10 +1,10 @@
1
1
  var me = Object.defineProperty;
2
- var Le = (l, e, t) => e in l ? me(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var c = (l, e, t) => (Le(l, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { MeshoptDecoder as xe } from "three/examples/jsm/libs/meshopt_decoder.module.js";
2
+ var xe = (l, e, t) => e in l ? me(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var c = (l, e, t) => (xe(l, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { MeshoptDecoder as Le } from "three/examples/jsm/libs/meshopt_decoder.module.js";
5
5
  import { DRACOLoader as De } from "three/examples/jsm/loaders/DRACOLoader.js";
6
6
  import { KTX2Loader as Me } from "three/examples/jsm/loaders/KTX2Loader.js";
7
- import { BufferGeometry as Y, Mesh as F, Material as Oe, Texture as N, TextureLoader as we, Matrix4 as le, Frustum as _e, Sphere as ve, Box3 as ce, Vector3 as B } from "three";
7
+ import { BufferGeometry as Y, Mesh as F, Material as we, Texture as N, TextureLoader as Oe, Matrix4 as le, Frustum as _e, Sphere as ve, Box3 as ce, Vector3 as k } from "three";
8
8
  import { GLTFLoader as Se } from "three/examples/jsm/loaders/GLTFLoader.js";
9
9
  let Z = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", oe = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
10
10
  fetch(Z + "draco_decoder.js", { method: "head" }).catch((l) => {
@@ -18,7 +18,7 @@ function We(l) {
18
18
  }
19
19
  let q, ie, X;
20
20
  function he(l) {
21
- q || (q = new De(), q.setDecoderPath(Z), q.setDecoderConfig({ type: "js" })), X || (X = new Me(), X.setTranscoderPath(oe)), ie || (ie = xe), l ? X.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
21
+ q || (q = new De(), q.setDecoderPath(Z), q.setDecoderConfig({ type: "js" })), X || (X = new Me(), X.setTranscoderPath(oe)), ie || (ie = Le), l ? X.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
22
22
  }
23
23
  function ge(l) {
24
24
  l.dracoLoader || l.setDRACOLoader(q), l.ktx2Loader || l.setKTX2Loader(X), l.meshoptDecoder || l.setMeshoptDecoder(ie);
@@ -59,9 +59,9 @@ function Ke(l = !0) {
59
59
  return;
60
60
  const e = K = F.prototype.raycast;
61
61
  F.prototype.raycast = function(t, r) {
62
- const s = this, n = ae(s);
63
- let i;
64
- n && s.isMesh && (i = s.geometry, s.geometry = n), e.call(this, t, r), i && (s.geometry = i);
62
+ const i = this, n = ae(i);
63
+ let s;
64
+ n && i.isMesh && (s = i.geometry, i.geometry = n), e.call(this, t, r), s && (i.geometry = s);
65
65
  };
66
66
  } else {
67
67
  if (!K)
@@ -76,12 +76,12 @@ function Pe(l) {
76
76
  e.setAttribute(t, l.getAttribute(t));
77
77
  return e.setIndex(l.getIndex()), e;
78
78
  }
79
- const I = new Array(), R = "NEEDLE_progressive", w = j("debugprogressive"), se = Symbol("needle-progressive-texture"), V = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Set();
80
- if (w) {
79
+ const I = new Array(), B = "NEEDLE_progressive", D = j("debugprogressive"), se = Symbol("needle-progressive-texture"), V = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Set();
80
+ if (D) {
81
81
  let l = function() {
82
- e += 1, console.log("Toggle LOD level", e, V), V.forEach((s, n) => {
83
- for (const i of s.keys) {
84
- const o = n[i];
82
+ e += 1, console.log("Toggle LOD level", e, V), V.forEach((i, n) => {
83
+ for (const s of i.keys) {
84
+ const o = n[s];
85
85
  if (o.isBufferGeometry === !0) {
86
86
  const a = v.getMeshLODInformation(o), h = a ? Math.min(e, a.lods.length) : 0;
87
87
  n["DEBUG:LOD"] = e, v.assignMeshLOD(n, h), a && (t = Math.max(t, a.lods.length - 1));
@@ -92,19 +92,19 @@ if (w) {
92
92
  }
93
93
  }), e >= t && (e = -1);
94
94
  }, e = -1, t = 2, r = !1;
95
- window.addEventListener("keyup", (s) => {
96
- s.key === "p" && l(), s.key === "w" && (r = !r, ne && ne.forEach((n) => {
95
+ window.addEventListener("keyup", (i) => {
96
+ i.key === "p" && l(), i.key === "w" && (r = !r, ne && ne.forEach((n) => {
97
97
  n.name != "BackgroundCubeMaterial" && "wireframe" in n && (n.wireframe = r);
98
98
  }));
99
99
  });
100
100
  }
101
101
  function ue(l, e, t) {
102
- var s;
103
- if (!w)
102
+ var i;
103
+ if (!D)
104
104
  return;
105
105
  V.has(l) || V.set(l, { keys: [], sourceId: t });
106
106
  const r = V.get(l);
107
- ((s = r == null ? void 0 : r.keys) == null ? void 0 : s.includes(e)) == !1 && r.keys.push(e);
107
+ ((i = r == null ? void 0 : r.keys) == null ? void 0 : i.includes(e)) == !1 && r.keys.push(e);
108
108
  }
109
109
  const _ = class {
110
110
  constructor(e, t) {
@@ -112,24 +112,24 @@ const _ = class {
112
112
  c(this, "url");
113
113
  c(this, "_isLoadingMesh");
114
114
  c(this, "loadMesh", (e) => {
115
- var r, s;
115
+ var r, i;
116
116
  if (this._isLoadingMesh)
117
117
  return null;
118
- const t = (s = (r = this.parser.json.meshes[e]) == null ? void 0 : r.extensions) == null ? void 0 : s[R];
118
+ const t = (i = (r = this.parser.json.meshes[e]) == null ? void 0 : r.extensions) == null ? void 0 : i[B];
119
119
  return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((n) => (this._isLoadingMesh = !1, n && _.registerMesh(this.url, t.guid, n, t.lods.length, void 0, t), n))) : null;
120
120
  });
121
- w && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
121
+ D && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
122
122
  }
123
123
  /** The name of the extension */
124
124
  get name() {
125
- return R;
125
+ return B;
126
126
  }
127
127
  static getMeshLODInformation(e) {
128
128
  const t = this.getAssignedLODInformation(e);
129
129
  return t != null && t.key ? this.lodInfos.get(t.key) : null;
130
130
  }
131
131
  static getMaterialMinMaxLODsCount(e, t) {
132
- const r = this, s = "LODS:minmax", n = e[s];
132
+ const r = this, i = "LODS:minmax", n = e[i];
133
133
  if (n != null)
134
134
  return n;
135
135
  if (t || (t = {
@@ -139,21 +139,21 @@ const _ = class {
139
139
  }), Array.isArray(e)) {
140
140
  for (const o of e)
141
141
  this.getMaterialMinMaxLODsCount(o, t);
142
- return e[s] = t, t;
142
+ return e[i] = t, t;
143
143
  }
144
- if (w === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
144
+ if (D === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
145
145
  const o = e;
146
146
  for (const a of Object.keys(o.uniforms)) {
147
147
  const h = o.uniforms[a].value;
148
- (h == null ? void 0 : h.isTexture) === !0 && i(h, t);
148
+ (h == null ? void 0 : h.isTexture) === !0 && s(h, t);
149
149
  }
150
150
  } else if (e.isMaterial)
151
151
  for (const o of Object.keys(e)) {
152
152
  const a = e[o];
153
- (a == null ? void 0 : a.isTexture) === !0 && i(a, t);
153
+ (a == null ? void 0 : a.isTexture) === !0 && s(a, t);
154
154
  }
155
- return e[s] = t, t;
156
- function i(o, a) {
155
+ return e[i] = t, t;
156
+ function s(o, a) {
157
157
  const h = r.getAssignedLODInformation(o);
158
158
  if (h) {
159
159
  const d = r.lodInfos.get(h.key);
@@ -175,30 +175,30 @@ const _ = class {
175
175
  static hasLODLevelAvailable(e, t) {
176
176
  var n;
177
177
  if (Array.isArray(e)) {
178
- for (const i of e)
179
- if (this.hasLODLevelAvailable(i, t))
178
+ for (const s of e)
179
+ if (this.hasLODLevelAvailable(s, t))
180
180
  return !0;
181
181
  return !1;
182
182
  }
183
183
  if (e.isMaterial === !0) {
184
- for (const i of Object.keys(e)) {
185
- const o = e[i];
184
+ for (const s of Object.keys(e)) {
185
+ const o = e[s];
186
186
  if (o && o.isTexture && this.hasLODLevelAvailable(o, t))
187
187
  return !0;
188
188
  }
189
189
  return !1;
190
190
  } else if (e.isGroup === !0) {
191
- for (const i of e.children)
192
- if (i.isMesh === !0 && this.hasLODLevelAvailable(i, t))
191
+ for (const s of e.children)
192
+ if (s.isMesh === !0 && this.hasLODLevelAvailable(s, t))
193
193
  return !0;
194
194
  }
195
- let r, s;
195
+ let r, i;
196
196
  if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (n = r == null ? void 0 : r.userData) != null && n.LODS) {
197
- const i = r.userData.LODS;
198
- if (s = this.lodInfos.get(i.key), t === void 0)
199
- return s != null;
200
- if (s)
201
- return Array.isArray(s.lods) ? t < s.lods.length : t === 0;
197
+ const s = r.userData.LODS;
198
+ if (i = this.lodInfos.get(s.key), t === void 0)
199
+ return i != null;
200
+ if (i)
201
+ return Array.isArray(i.lods) ? t < i.lods.length : t === 0;
202
202
  }
203
203
  return !1;
204
204
  }
@@ -221,23 +221,23 @@ const _ = class {
221
221
  if (!e)
222
222
  return Promise.resolve(null);
223
223
  if (e instanceof F || e.isMesh === !0) {
224
- const s = e.geometry, n = this.getAssignedLODInformation(s);
224
+ const i = e.geometry, n = this.getAssignedLODInformation(i);
225
225
  if (!n)
226
226
  return Promise.resolve(null);
227
- for (const i of I)
228
- (r = i.onBeforeGetLODMesh) == null || r.call(i, e, t);
229
- return e["LOD:requested level"] = t, _.getOrLoadLOD(s, t).then((i) => {
227
+ for (const s of I)
228
+ (r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
229
+ return e["LOD:requested level"] = t, _.getOrLoadLOD(i, t).then((s) => {
230
230
  if (e["LOD:requested level"] === t) {
231
- if (delete e["LOD:requested level"], Array.isArray(i)) {
231
+ if (delete e["LOD:requested level"], Array.isArray(s)) {
232
232
  const o = n.index || 0;
233
- i = i[o];
233
+ s = s[o];
234
234
  }
235
- i && s != i && i instanceof Y && (e.geometry = i, w && ue(e, "geometry", n.url));
235
+ s && i != s && s instanceof Y && (e.geometry = s, D && ue(e, "geometry", n.url));
236
236
  }
237
- return i;
238
- }).catch((i) => (console.error("Error loading mesh LOD", e, i), null));
237
+ return s;
238
+ }).catch((s) => (console.error("Error loading mesh LOD", e, s), null));
239
239
  } else
240
- w && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
240
+ D && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
241
241
  return Promise.resolve(null);
242
242
  }
243
243
  /** Load a different resolution of a texture (if available)
@@ -250,29 +250,29 @@ const _ = class {
250
250
  static assignTextureLOD(e, t = 0) {
251
251
  if (!e)
252
252
  return Promise.resolve(null);
253
- if (e instanceof Oe || e.isMaterial === !0) {
254
- const r = e, s = [], n = new Array();
255
- if (w && ne.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
256
- const i = r;
257
- for (const o of Object.keys(i.uniforms)) {
258
- const a = i.uniforms[o].value;
253
+ if (e instanceof we || e.isMaterial === !0) {
254
+ const r = e, i = [], n = new Array();
255
+ if (D && ne.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
256
+ const s = r;
257
+ for (const o of Object.keys(s.uniforms)) {
258
+ const a = s.uniforms[o].value;
259
259
  if ((a == null ? void 0 : a.isTexture) === !0) {
260
260
  const h = this.assignTextureLODForSlot(a, t, r, o);
261
- s.push(h), n.push(o);
261
+ i.push(h), n.push(o);
262
262
  }
263
263
  }
264
264
  } else
265
- for (const i of Object.keys(r)) {
266
- const o = r[i];
265
+ for (const s of Object.keys(r)) {
266
+ const o = r[s];
267
267
  if ((o == null ? void 0 : o.isTexture) === !0) {
268
- const a = this.assignTextureLODForSlot(o, t, r, i);
269
- s.push(a), n.push(i);
268
+ const a = this.assignTextureLODForSlot(o, t, r, s);
269
+ i.push(a), n.push(s);
270
270
  }
271
271
  }
272
- return Promise.all(s).then((i) => {
272
+ return Promise.all(i).then((s) => {
273
273
  const o = new Array();
274
- for (let a = 0; a < i.length; a++) {
275
- const h = i[a], d = n[a];
274
+ for (let a = 0; a < s.length; a++) {
275
+ const h = s[a], d = n[a];
276
276
  h && h.isTexture === !0 ? o.push({ material: r, slot: d, texture: h, level: t }) : o.push({ material: r, slot: d, texture: null, level: t });
277
277
  }
278
278
  return o;
@@ -284,54 +284,58 @@ const _ = class {
284
284
  }
285
285
  return Promise.resolve(null);
286
286
  }
287
- static assignTextureLODForSlot(e, t, r, s) {
288
- return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : s === "glyphMap" ? Promise.resolve(e) : _.getOrLoadLOD(e, t).then((n) => {
287
+ static assignTextureLODForSlot(e, t, r, i) {
288
+ return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : i === "glyphMap" ? Promise.resolve(e) : _.getOrLoadLOD(e, t).then((n) => {
289
289
  if (Array.isArray(n))
290
290
  return null;
291
291
  if ((n == null ? void 0 : n.isTexture) === !0) {
292
292
  if (n != e) {
293
- if (r && s) {
294
- const i = r[s];
295
- if (i) {
296
- const o = this.getAssignedLODInformation(i);
293
+ if (r && i) {
294
+ const s = r[i];
295
+ if (s) {
296
+ const o = this.getAssignedLODInformation(s);
297
297
  if (o && (o == null ? void 0 : o.level) < t)
298
- return w === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, t, r, i, n), null;
298
+ return D === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, t, r, s, n), null;
299
299
  }
300
- r[s] = n;
300
+ r[i] = n;
301
301
  }
302
- if (w && s && r) {
303
- const i = this.getAssignedLODInformation(e);
304
- i && ue(r, s, i.url);
302
+ if (D && i && r) {
303
+ const s = this.getAssignedLODInformation(e);
304
+ s && ue(r, i, s.url);
305
305
  }
306
306
  }
307
307
  return n;
308
308
  } else
309
- w == "verbose" && console.warn("No LOD found for", e, t);
309
+ D == "verbose" && console.warn("No LOD found for", e, t);
310
310
  return null;
311
311
  }).catch((n) => (console.error("Error loading LOD", e, n), null));
312
312
  }
313
313
  afterRoot(e) {
314
314
  var t, r;
315
- return w && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((s, n) => {
316
- if (s != null && s.extensions) {
317
- const i = s == null ? void 0 : s.extensions[R];
318
- if (i) {
315
+ return D && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
316
+ if (i != null && i.extensions) {
317
+ const s = i == null ? void 0 : i.extensions[B];
318
+ if (s) {
319
+ if (!s.lods) {
320
+ D && console.warn("Texture has no LODs", s);
321
+ return;
322
+ }
319
323
  let o = !1;
320
324
  for (const a of this.parser.associations.keys())
321
- a.isTexture === !0 && this.parser.associations.get(a).textures === n && (o = !0, _.registerTexture(this.url, a, i.lods.length, n, i));
325
+ a.isTexture === !0 && this.parser.associations.get(a).textures === n && (o = !0, _.registerTexture(this.url, a, s.lods.length, n, s));
322
326
  o || this.parser.getDependency("texture", n).then((a) => {
323
- a && _.registerTexture(this.url, a, i.lods.length, n, i);
327
+ a && _.registerTexture(this.url, a, s.lods.length, n, s);
324
328
  });
325
329
  }
326
330
  }
327
- }), (r = this.parser.json.meshes) == null || r.forEach((s, n) => {
328
- if (s != null && s.extensions) {
329
- const i = s == null ? void 0 : s.extensions[R];
330
- if (i && i.lods) {
331
+ }), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
332
+ if (i != null && i.extensions) {
333
+ const s = i == null ? void 0 : i.extensions[B];
334
+ if (s && s.lods) {
331
335
  for (const o of this.parser.associations.keys())
332
336
  if (o.isMesh) {
333
337
  const a = this.parser.associations.get(o);
334
- a.meshes === n && _.registerMesh(this.url, i.guid, o, i.lods.length, a.primitives, i);
338
+ a.meshes === n && _.registerMesh(this.url, s.guid, o, s.lods.length, a.primitives, s);
335
339
  }
336
340
  }
337
341
  }
@@ -339,43 +343,43 @@ const _ = class {
339
343
  }
340
344
  static async getOrLoadLOD(e, t) {
341
345
  var o, a, h, d;
342
- const r = w == "verbose", s = e.userData.LODS;
343
- if (!s)
346
+ const r = D == "verbose", i = e.userData.LODS;
347
+ if (!i)
344
348
  return null;
345
- const n = s == null ? void 0 : s.key;
346
- let i;
349
+ const n = i == null ? void 0 : i.key;
350
+ let s;
347
351
  if (e.isTexture === !0) {
348
352
  const g = e;
349
- g.source && g.source[se] && (i = g.source[se]);
353
+ g.source && g.source[se] && (s = g.source[se]);
350
354
  }
351
- if (i || (i = _.lodInfos.get(n)), i) {
355
+ if (s || (s = _.lodInfos.get(n)), s) {
352
356
  if (t > 0) {
353
357
  let m = !1;
354
- const D = Array.isArray(i.lods);
355
- if (D && t >= i.lods.length ? m = !0 : D || (m = !0), m)
358
+ const M = Array.isArray(s.lods);
359
+ if (M && t >= s.lods.length ? m = !0 : M || (m = !0), m)
356
360
  return this.lowresCache.get(n);
357
361
  }
358
- const g = Array.isArray(i.lods) ? (o = i.lods[t]) == null ? void 0 : o.path : i.lods;
362
+ const g = Array.isArray(s.lods) ? (o = s.lods[t]) == null ? void 0 : o.path : s.lods;
359
363
  if (!g)
360
- return w && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, i)), null;
361
- const f = Te(s.url, g);
364
+ return D && !s["missing:uri"] && (s["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, s)), null;
365
+ const f = Te(i.url, g);
362
366
  if (f.endsWith(".glb") || f.endsWith(".gltf")) {
363
- if (!i.guid)
364
- return console.warn("missing pointer for glb/gltf texture", i), null;
365
- const m = f + "_" + i.guid, D = this.previouslyLoaded.get(m);
366
- if (D !== void 0) {
367
+ if (!s.guid)
368
+ return console.warn("missing pointer for glb/gltf texture", s), null;
369
+ const m = f + "_" + s.guid, M = this.previouslyLoaded.get(m);
370
+ if (M !== void 0) {
367
371
  r && console.log(`LOD ${t} was already loading/loaded: ${m}`);
368
- let L = await D.catch((z) => (console.error(`Error loading LOD ${t} from ${f}
372
+ let x = await M.catch((z) => (console.error(`Error loading LOD ${t} from ${f}
369
373
  `, z), null)), T = !1;
370
- if (L == null || (L instanceof N && e instanceof N ? (a = L.image) != null && a.data || (h = L.source) != null && h.data ? L = this.copySettings(e, L) : (T = !0, this.previouslyLoaded.delete(m)) : L instanceof Y && e instanceof Y && ((d = L.attributes.position) != null && d.array || (T = !0, this.previouslyLoaded.delete(m)))), !T)
371
- return L;
374
+ if (x == null || (x instanceof N && e instanceof N ? (a = x.image) != null && a.data || (h = x.source) != null && h.data ? x = this.copySettings(e, x) : (T = !0, this.previouslyLoaded.delete(m)) : x instanceof Y && e instanceof Y && ((d = x.attributes.position) != null && d.array || (T = !0, this.previouslyLoaded.delete(m)))), !T)
375
+ return x;
372
376
  }
373
- const M = i, O = new Promise(async (L, T) => {
377
+ const w = s, O = new Promise(async (x, T) => {
374
378
  const z = new Se();
375
- ge(z), w && (await new Promise((p) => setTimeout(p, 1e3)), r && console.warn("Start loading (delayed) " + f, M.guid));
379
+ ge(z), D && (await new Promise((p) => setTimeout(p, 1e3)), r && console.warn("Start loading (delayed) " + f, w.guid));
376
380
  let ee = f;
377
- if (M && Array.isArray(M.lods)) {
378
- const p = M.lods[t];
381
+ if (w && Array.isArray(w.lods)) {
382
+ const p = w.lods[t];
379
383
  p.hash && (ee += "?v=" + p.hash);
380
384
  }
381
385
  const E = await z.loadAsync(ee).catch((p) => (console.error(`Error loading LOD ${t} from ${f}
@@ -383,14 +387,14 @@ const _ = class {
383
387
  if (!E)
384
388
  return null;
385
389
  const te = E.parser;
386
- r && console.log("Loading finished " + f, M.guid);
390
+ r && console.log("Loading finished " + f, w.guid);
387
391
  let y = 0;
388
392
  if (E.parser.json.textures) {
389
393
  let p = !1;
390
394
  for (const u of E.parser.json.textures) {
391
395
  if (u != null && u.extensions) {
392
- const x = u == null ? void 0 : u.extensions[R];
393
- if (x != null && x.guid && x.guid === M.guid) {
396
+ const L = u == null ? void 0 : u.extensions[B];
397
+ if (L != null && L.guid && L.guid === w.guid) {
394
398
  p = !0;
395
399
  break;
396
400
  }
@@ -399,16 +403,16 @@ const _ = class {
399
403
  }
400
404
  if (p) {
401
405
  let u = await te.getDependency("texture", y);
402
- return u && _.assignLODInformation(s.url, u, n, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + u.name + '"', f, y, u, m), e instanceof N && (u = this.copySettings(e, u)), u && (u.guid = M.guid), L(u);
406
+ return u && _.assignLODInformation(i.url, u, n, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + u.name + '"', f, y, u, m), e instanceof N && (u = this.copySettings(e, u)), u && (u.guid = w.guid), x(u);
403
407
  } else
404
- w && console.warn("Could not find texture with guid", M.guid);
408
+ D && console.warn("Could not find texture with guid", w.guid);
405
409
  }
406
410
  if (y = 0, E.parser.json.meshes) {
407
411
  let p = !1;
408
412
  for (const u of E.parser.json.meshes) {
409
413
  if (u != null && u.extensions) {
410
- const x = u == null ? void 0 : u.extensions[R];
411
- if (x != null && x.guid && x.guid === M.guid) {
414
+ const L = u == null ? void 0 : u.extensions[B];
415
+ if (L != null && L.guid && L.guid === w.guid) {
412
416
  p = !0;
413
417
  break;
414
418
  }
@@ -416,41 +420,41 @@ const _ = class {
416
420
  y++;
417
421
  }
418
422
  if (p) {
419
- const u = await te.getDependency("mesh", y), x = M;
423
+ const u = await te.getDependency("mesh", y), L = w;
420
424
  if (r && console.log(`Loaded Mesh "${u.name}"`, f, y, u, m), u.isMesh === !0) {
421
425
  const S = u.geometry;
422
- return _.assignLODInformation(s.url, S, n, t, void 0, x.density), L(S);
426
+ return _.assignLODInformation(i.url, S, n, t, void 0, L.density), x(S);
423
427
  } else {
424
428
  const S = new Array();
425
429
  for (let C = 0; C < u.children.length; C++) {
426
430
  const G = u.children[C];
427
431
  if (G instanceof F) {
428
432
  const $ = G.geometry;
429
- _.assignLODInformation(s.url, $, n, t, C, x.density), S.push($);
433
+ _.assignLODInformation(i.url, $, n, t, C, L.density), S.push($);
430
434
  }
431
435
  }
432
- return L(S);
436
+ return x(S);
433
437
  }
434
438
  }
435
439
  }
436
- return L(null);
440
+ return x(null);
437
441
  });
438
442
  return this.previouslyLoaded.set(m, O), await O;
439
443
  } else if (e instanceof N) {
440
444
  r && console.log("Load texture from uri: " + f);
441
- const D = await new we().loadAsync(f);
442
- return D ? (D.guid = i.guid, D.flipY = !1, D.needsUpdate = !0, D.colorSpace = e.colorSpace, r && console.log(i, D)) : w && console.warn("failed loading", f), D;
445
+ const M = await new Oe().loadAsync(f);
446
+ return M ? (M.guid = s.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = e.colorSpace, r && console.log(s, M)) : D && console.warn("failed loading", f), M;
443
447
  }
444
448
  } else
445
- w && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
449
+ D && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
446
450
  return null;
447
451
  }
448
- static assignLODInformation(e, t, r, s, n, i) {
452
+ static assignLODInformation(e, t, r, i, n, s) {
449
453
  if (!t)
450
454
  return;
451
455
  t.userData || (t.userData = {});
452
- const o = new Ee(e, r, s, n, i);
453
- t.userData.LODS = o, t.userData.LOD = s;
456
+ const o = new Ee(e, r, i, n, s);
457
+ t.userData.LODS = o, t.userData.LOD = i;
454
458
  }
455
459
  static getAssignedLODInformation(e) {
456
460
  var t;
@@ -458,7 +462,7 @@ const _ = class {
458
462
  }
459
463
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
460
464
  static copySettings(e, t) {
461
- return t = t.clone(), w && console.warn(`Copying texture settings
465
+ return t = t.clone(), D && console.warn(`Copying texture settings
462
466
  `, e.uuid, `
463
467
  `, 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;
464
468
  }
@@ -467,28 +471,36 @@ let v = _;
467
471
  /**
468
472
  * Register a texture with LOD information
469
473
  */
470
- c(v, "registerTexture", (e, t, r, s, n) => {
471
- w && console.log("> Progressive: register texture", s, t.name, t.uuid, t, n), t.source && (t.source[se] = n);
472
- const i = n.guid;
473
- _.assignLODInformation(e, t, i, r, s, void 0), _.lodInfos.set(i, n), _.lowresCache.set(i, t);
474
+ c(v, "registerTexture", (e, t, r, i, n) => {
475
+ if (D && console.log("> Progressive: register texture", i, t.name, t.uuid, t, n), !t) {
476
+ D && console.error("gltf-progressive: Register texture without texture");
477
+ return;
478
+ }
479
+ t.source && (t.source[se] = n);
480
+ const s = n.guid;
481
+ _.assignLODInformation(e, t, s, r, i, void 0), _.lodInfos.set(s, n), _.lowresCache.set(s, t);
474
482
  }), /**
475
483
  * Register a mesh with LOD information
476
484
  */
477
- c(v, "registerMesh", (e, t, r, s, n, i) => {
485
+ c(v, "registerMesh", (e, t, r, i, n, s) => {
478
486
  var h;
479
- w && console.log("> Progressive: register mesh", n, r.name, i, r.uuid, r);
487
+ D && console.log("> Progressive: register mesh", n, r.name, s, r.uuid, r);
480
488
  const o = r.geometry;
481
- o.userData || (o.userData = {}), _.assignLODInformation(e, o, t, s, n, i.density), _.lodInfos.set(t, i);
489
+ if (!o) {
490
+ D && console.warn("gltf-progressive: Register mesh without geometry");
491
+ return;
492
+ }
493
+ o.userData || (o.userData = {}), _.assignLODInformation(e, o, t, i, n, s.density), _.lodInfos.set(t, s);
482
494
  let a = _.lowresCache.get(t);
483
- a ? a.push(r.geometry) : a = [r.geometry], _.lowresCache.set(t, a), s > 0 && !ae(r) && be(r, o);
495
+ a ? a.push(r.geometry) : a = [r.geometry], _.lowresCache.set(t, a), i > 0 && !ae(r) && be(r, o);
484
496
  for (const d of I)
485
- (h = d.onRegisteredNewMesh) == null || h.call(d, r, i);
497
+ (h = d.onRegisteredNewMesh) == null || h.call(d, r, s);
486
498
  }), /** A map of key = asset uuid and value = LOD information */
487
499
  c(v, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
488
500
  c(v, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
489
501
  c(v, "lowresCache", /* @__PURE__ */ new Map());
490
502
  class Ee {
491
- constructor(e, t, r, s, n) {
503
+ constructor(e, t, r, i, n) {
492
504
  c(this, "url");
493
505
  /** the key to lookup the LOD information */
494
506
  c(this, "key");
@@ -497,7 +509,7 @@ class Ee {
497
509
  c(this, "index");
498
510
  /** the mesh density */
499
511
  c(this, "density");
500
- this.url = e, this.key = t, this.level = r, s != null && (this.index = s), n != null && (this.density = n);
512
+ this.url = e, this.key = t, this.level = r, i != null && (this.index = i), n != null && (this.density = n);
501
513
  }
502
514
  }
503
515
  const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LODSManager"), b = { mesh_lod: -1, texture_lod: -1 }, A = class {
@@ -526,9 +538,9 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
526
538
  c(this, "_tempBox", new ce());
527
539
  c(this, "_tempBox2", new ce());
528
540
  c(this, "tempMatrix", new le());
529
- c(this, "_tempWorldPosition", new B());
530
- c(this, "_tempBoxSize", new B());
531
- c(this, "_tempBox2Size", new B());
541
+ c(this, "_tempWorldPosition", new k());
542
+ c(this, "_tempBoxSize", new k());
543
+ c(this, "_tempBox2Size", new k());
532
544
  this.renderer = e;
533
545
  }
534
546
  /** @internal */
@@ -564,33 +576,33 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
564
576
  let e = 0;
565
577
  this._originalRender = this.renderer.render;
566
578
  const t = this;
567
- he(this.renderer), this.renderer.render = function(r, s) {
579
+ he(this.renderer), this.renderer.render = function(r, i) {
568
580
  t.renderer.getRenderTarget() == null && (e = 0, t._frame += 1);
569
- const i = t._frame, o = e++;
570
- t.onBeforeRender(r, s, o, i), t._originalRender.call(this, r, s), t.onAfterRender(r, s, o, i);
581
+ const s = t._frame, o = e++;
582
+ t.onBeforeRender(r, i, o, s), t._originalRender.call(this, r, i), t.onAfterRender(r, i, o, s);
571
583
  };
572
584
  }
573
585
  disable() {
574
586
  this._originalRender && (this.renderer.render = this._originalRender, this._originalRender = void 0);
575
587
  }
576
- onBeforeRender(e, t, r, s) {
588
+ onBeforeRender(e, t, r, i) {
577
589
  }
578
- onAfterRender(e, t, r, s) {
590
+ onAfterRender(e, t, r, i) {
579
591
  var a, h;
580
592
  if (this.pause)
581
593
  return;
582
- const n = this.renderer.renderLists.get(e, 0), i = n.opaque;
594
+ const n = this.renderer.renderLists.get(e, 0), s = n.opaque;
583
595
  let o = !0;
584
- if (i.length === 1) {
585
- const d = i[0].material;
596
+ if (s.length === 1) {
597
+ const d = s[0].material;
586
598
  (d.name === "EffectMaterial" || d.name === "CopyShader") && (o = !1);
587
599
  }
588
600
  if (t.parent && t.parent.type === "CubeCamera" && (o = !1), o) {
589
- if (Ce || this.updateInterval > 0 && s % this.updateInterval != 0)
601
+ if (Ce || this.updateInterval > 0 && i % this.updateInterval != 0)
590
602
  return;
591
603
  this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this.cameraFrustrum.setFromProjectionMatrix(this.projectionScreenMatrix, this.renderer.coordinateSystem);
592
604
  const d = this.targetTriangleDensity;
593
- for (const f of i) {
605
+ for (const f of s) {
594
606
  if (f.material && (((a = f.geometry) == null ? void 0 : a.type) === "BoxGeometry" || ((h = f.geometry) == null ? void 0 : h.type) === "BufferGeometry") && (f.material.name === "SphericalGaussianBlur" || f.material.name == "BackgroundCubeMaterial" || f.material.name === "CubemapFromEquirect" || f.material.name === "EquirectangularToCubeUV")) {
595
607
  U && (f.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (f.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", f, f.material.name, f.material.type)));
596
608
  continue;
@@ -605,25 +617,25 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
605
617
  continue;
606
618
  }
607
619
  const m = f.object;
608
- (m instanceof F || m.isMesh) && this.updateLODs(e, t, m, d, s);
620
+ (m instanceof F || m.isMesh) && this.updateLODs(e, t, m, d, i);
609
621
  }
610
622
  const g = n.transparent;
611
623
  for (const f of g) {
612
624
  const m = f.object;
613
- (m instanceof F || m.isMesh) && this.updateLODs(e, t, m, d, s);
625
+ (m instanceof F || m.isMesh) && this.updateLODs(e, t, m, d, i);
614
626
  }
615
627
  }
616
628
  }
617
629
  /** Update the LOD levels for the renderer. */
618
- updateLODs(e, t, r, s, n) {
630
+ updateLODs(e, t, r, i, n) {
619
631
  var a, h;
620
632
  r.userData || (r.userData = {});
621
- let i = r.userData.LOD_state;
622
- if (i || (i = new ke(), r.userData.LOD_state = i), i.frames++ < 2)
633
+ let s = r.userData.LOD_state;
634
+ if (s || (s = new Re(), r.userData.LOD_state = s), s.frames++ < 2)
623
635
  return;
624
636
  for (const d of I)
625
637
  (a = d.onBeforeUpdateLOD) == null || a.call(d, this.renderer, e, t, r);
626
- this.calculateLodLevel(t, r, i, s, b), b.mesh_lod = Math.round(b.mesh_lod), b.texture_lod = Math.round(b.texture_lod), b.mesh_lod >= 0 && this.loadProgressiveMeshes(r, b.mesh_lod);
638
+ this.calculateLodLevel(t, r, s, i, b), b.mesh_lod = Math.round(b.mesh_lod), b.texture_lod = Math.round(b.texture_lod), b.mesh_lod >= 0 && this.loadProgressiveMeshes(r, b.mesh_lod);
627
639
  let o = b.texture_lod;
628
640
  if (r.material && o >= 0) {
629
641
  const d = r["DEBUG:LOD"];
@@ -631,7 +643,7 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
631
643
  }
632
644
  for (const d of I)
633
645
  (h = d.onAfterUpdatedLOD) == null || h.call(d, this.renderer, e, t, r, b);
634
- i.lastLodLevel_Mesh = b.mesh_lod, i.lastLodLevel_Texture = b.texture_lod;
646
+ s.lastLodLevel_Mesh = b.mesh_lod, s.lastLodLevel_Texture = b.texture_lod;
635
647
  }
636
648
  /** Load progressive textures for the given material
637
649
  * @param material the material to load the textures for
@@ -647,8 +659,8 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
647
659
  return;
648
660
  }
649
661
  const r = e;
650
- let s = !1;
651
- (r.NEEDLE_LOD == null || t < r.NEEDLE_LOD) && (s = !0), s && (r.NEEDLE_LOD = t, v.assignTextureLOD(e, t));
662
+ let i = !1;
663
+ (r.NEEDLE_LOD == null || t < r.NEEDLE_LOD) && (i = !0), i && (r.NEEDLE_LOD = t, v.assignTextureLOD(e, t));
652
664
  }
653
665
  /** Load progressive meshes for the given mesh
654
666
  * @param mesh the mesh to load the LOD for
@@ -662,16 +674,16 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
662
674
  if (e.userData || (e.userData = {}), e.userData.LOD !== t) {
663
675
  e.userData.LOD = t;
664
676
  const r = e.geometry;
665
- return v.assignMeshLOD(e, t).then((s) => (s && e.userData.LOD == t && r != e.geometry, s));
677
+ return v.assignMeshLOD(e, t).then((i) => (i && e.userData.LOD == t && r != e.geometry, i));
666
678
  }
667
679
  return Promise.resolve(null);
668
680
  }
669
681
  static isInside(e, t) {
670
- const r = e.min, s = e.max, n = (r.x + s.x) * 0.5, i = (r.y + s.y) * 0.5;
671
- return this._tempPtInside.set(n, i, r.z).applyMatrix4(t).z < 0;
682
+ const r = e.min, i = e.max, n = (r.x + i.x) * 0.5, s = (r.y + i.y) * 0.5;
683
+ return this._tempPtInside.set(n, s, r.z).applyMatrix4(t).z < 0;
672
684
  }
673
- calculateLodLevel(e, t, r, s, n) {
674
- var D;
685
+ calculateLodLevel(e, t, r, i, n) {
686
+ var M;
675
687
  if (!t) {
676
688
  n.mesh_lod = -1, n.texture_lod = -1;
677
689
  return;
@@ -688,13 +700,13 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
688
700
  n.mesh_lod = 0, n.texture_lod = 0;
689
701
  return;
690
702
  }
691
- if (d || (o = 0), !((D = this.cameraFrustrum) != null && D.intersectsObject(t))) {
703
+ if (d || (o = 0), !((M = this.cameraFrustrum) != null && M.intersectsObject(t))) {
692
704
  n.mesh_lod = 99, n.texture_lod = 99;
693
705
  return;
694
706
  }
695
707
  const m = t.geometry.boundingBox;
696
708
  if (m && e.isPerspectiveCamera) {
697
- const M = e;
709
+ const w = e;
698
710
  if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
699
711
  this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
700
712
  const y = e.getWorldPosition(this._tempWorldPosition);
@@ -707,32 +719,32 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
707
719
  n.mesh_lod = 0, n.texture_lod = 0;
708
720
  return;
709
721
  }
710
- if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && M.fov > 70) {
722
+ if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && w.fov > 70) {
711
723
  const y = this._tempBox.min, p = this._tempBox.max;
712
- let u = y.x, x = y.y, S = p.x, C = p.y;
724
+ let u = y.x, L = y.y, S = p.x, C = p.y;
713
725
  const G = 2, $ = 1.5, H = (y.x + p.x) * 0.5, J = (y.y + p.y) * 0.5;
714
- u = (u - H) * G + H, x = (x - J) * G + J, S = (S - H) * G + H, C = (C - J) * G + J;
715
- const pe = u < 0 && S > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(p.x)), ye = x < 0 && C > 0 ? 0 : Math.min(Math.abs(y.y), Math.abs(p.y)), re = Math.max(pe, ye);
726
+ u = (u - H) * G + H, L = (L - J) * G + J, S = (S - H) * G + H, C = (C - J) * G + J;
727
+ const pe = u < 0 && S > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(p.x)), ye = L < 0 && C > 0 ? 0 : Math.min(Math.abs(y.y), Math.abs(p.y)), re = Math.max(pe, ye);
716
728
  r.lastCentrality = ($ - re) * ($ - re) * ($ - re);
717
729
  } else
718
730
  r.lastCentrality = 1;
719
731
  const O = this._tempBox.getSize(this._tempBoxSize);
720
- O.multiplyScalar(0.5), screen.availHeight > 0 && O.multiplyScalar(this.renderer.domElement.clientHeight / screen.availHeight), O.x *= M.aspect;
721
- const k = e.matrixWorldInverse, L = this._tempBox2;
722
- L.copy(m), L.applyMatrix4(t.matrixWorld), L.applyMatrix4(k);
723
- const T = L.getSize(this._tempBox2Size), z = Math.max(T.x, T.y);
732
+ O.multiplyScalar(0.5), screen.availHeight > 0 && O.multiplyScalar(this.renderer.domElement.clientHeight / screen.availHeight), O.x *= w.aspect;
733
+ const R = e.matrixWorldInverse, x = this._tempBox2;
734
+ x.copy(m), x.applyMatrix4(t.matrixWorld), x.applyMatrix4(R);
735
+ const T = x.getSize(this._tempBox2Size), z = Math.max(T.x, T.y);
724
736
  if (Math.max(O.x, O.y) != 0 && z != 0 && (O.z = T.z / Math.max(T.x, T.y) * Math.max(O.x, O.y)), r.lastScreenCoverage = Math.max(O.x, O.y, O.z), r.lastScreenspaceVolume.copy(O), r.lastScreenCoverage *= r.lastCentrality, U && A.debugDrawLine) {
725
737
  const y = this.tempMatrix.copy(this.projectionScreenMatrix);
726
738
  y.invert();
727
- const p = A.corner0, u = A.corner1, x = A.corner2, S = A.corner3;
728
- p.copy(this._tempBox.min), u.copy(this._tempBox.max), u.x = p.x, x.copy(this._tempBox.max), x.y = p.y, S.copy(this._tempBox.max);
739
+ const p = A.corner0, u = A.corner1, L = A.corner2, S = A.corner3;
740
+ p.copy(this._tempBox.min), u.copy(this._tempBox.max), u.x = p.x, L.copy(this._tempBox.max), L.y = p.y, S.copy(this._tempBox.max);
729
741
  const C = (p.z + S.z) * 0.5;
730
- p.z = u.z = x.z = S.z = C, p.applyMatrix4(y), u.applyMatrix4(y), x.applyMatrix4(y), S.applyMatrix4(y), A.debugDrawLine(p, u, 255), A.debugDrawLine(p, x, 255), A.debugDrawLine(u, S, 255), A.debugDrawLine(x, S, 255);
742
+ p.z = u.z = L.z = S.z = C, p.applyMatrix4(y), u.applyMatrix4(y), L.applyMatrix4(y), S.applyMatrix4(y), A.debugDrawLine(p, u, 255), A.debugDrawLine(p, L, 255), A.debugDrawLine(u, S, 255), A.debugDrawLine(L, S, 255);
731
743
  }
732
744
  let E = 999;
733
745
  if (h && r.lastScreenCoverage > 0) {
734
746
  for (let y = 0; y < h.length; y++)
735
- if (h[y].density / r.lastScreenCoverage < s) {
747
+ if (h[y].density / r.lastScreenCoverage < i) {
736
748
  E = y;
737
749
  break;
738
750
  }
@@ -742,15 +754,15 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
742
754
  if (n.mesh_lod = o, f)
743
755
  if (r.lastLodLevel_Texture < 0) {
744
756
  if (n.texture_lod = g.max_count - 1, U) {
745
- const M = g.lods[g.max_count - 1];
746
- U && console.log(`First Texture LOD ${n.texture_lod} (${M.max_height}px) - ${t.name}`);
757
+ const w = g.lods[g.max_count - 1];
758
+ U && console.log(`First Texture LOD ${n.texture_lod} (${w.max_height}px) - ${t.name}`);
747
759
  }
748
760
  } else {
749
- const M = r.lastScreenCoverage * 1.5, k = this.renderer.domElement.clientHeight / window.devicePixelRatio * M;
750
- for (let L = g.lods.length - 1; L >= 0; L--) {
751
- const T = g.lods[L];
752
- if (!(Ae() && T.max_height > 4096) && T.max_height > k) {
753
- n.texture_lod = L, n.texture_lod < r.lastLodLevel_Texture && U && console.log(`Texture LOD changed ${r.lastLodLevel_Texture} → ${n.texture_lod} (${T.max_height}px: ${(100 * r.lastScreenCoverage).toFixed(2)} % = ${k.toFixed(0)}px) - ${t.name}`);
761
+ const w = r.lastScreenCoverage * 1.5, R = this.renderer.domElement.clientHeight / window.devicePixelRatio * w;
762
+ for (let x = g.lods.length - 1; x >= 0; x--) {
763
+ const T = g.lods[x];
764
+ if (!(Ae() && T.max_height > 4096) && T.max_height > R) {
765
+ n.texture_lod = x, n.texture_lod < r.lastLodLevel_Texture && U && console.log(`Texture LOD changed ${r.lastLodLevel_Texture} → ${n.texture_lod} (${T.max_height}px: ${(100 * r.lastScreenCoverage).toFixed(2)} % = ${R.toFixed(0)}px) - ${t.name}`);
754
766
  break;
755
767
  }
756
768
  }
@@ -762,32 +774,32 @@ const U = j("debugprogressive"), Ce = j("noprogressive"), fe = Symbol("Needle:LO
762
774
  let P = A;
763
775
  /** 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.
764
776
  */
765
- c(P, "debugDrawLine"), c(P, "corner0", new B()), c(P, "corner1", new B()), c(P, "corner2", new B()), c(P, "corner3", new B()), c(P, "_tempPtInside", new B());
766
- class ke {
777
+ c(P, "debugDrawLine"), c(P, "corner0", new k()), c(P, "corner1", new k()), c(P, "corner2", new k()), c(P, "corner3", new k()), c(P, "_tempPtInside", new k());
778
+ class Re {
767
779
  constructor() {
768
780
  c(this, "frames", 0);
769
781
  c(this, "lastLodLevel_Mesh", -1);
770
782
  c(this, "lastLodLevel_Texture", -1);
771
783
  c(this, "lastScreenCoverage", 0);
772
- c(this, "lastScreenspaceVolume", new B());
784
+ c(this, "lastScreenspaceVolume", new k());
773
785
  c(this, "lastCentrality", 0);
774
786
  }
775
787
  }
776
788
  const de = Symbol("NEEDLE_mesh_lod"), Q = Symbol("NEEDLE_texture_lod");
777
- function Be(l) {
789
+ function ke(l) {
778
790
  if (!l)
779
791
  return null;
780
792
  let e = null, t = null;
781
793
  for (let r = l; r != null; r = Object.getPrototypeOf(r)) {
782
- const s = Object.getOwnPropertySymbols(r), n = s.find((o) => o.toString() == "Symbol(renderer)"), i = s.find((o) => o.toString() == "Symbol(scene)");
783
- !e && n != null && (e = l[n].threeRenderer), !t && i != null && (t = l[i]);
794
+ const i = Object.getOwnPropertySymbols(r), n = i.find((o) => o.toString() == "Symbol(renderer)"), s = i.find((o) => o.toString() == "Symbol(scene)");
795
+ !e && n != null && (e = l[n].threeRenderer), !t && s != null && (t = l[s]);
784
796
  }
785
797
  if (e) {
786
798
  console.log("Adding Needle LODs to modelviewer");
787
799
  const r = P.get(e);
788
- if (P.addPlugin(new Re(l)), r.enable(), t) {
789
- const s = t.camera || t.traverse((n) => n.type == "PerspectiveCamera")[0];
790
- s && e.render(t, s);
800
+ if (P.addPlugin(new Be(l)), r.enable(), t) {
801
+ const i = t.camera || t.traverse((n) => n.type == "PerspectiveCamera")[0];
802
+ i && e.render(t, i);
791
803
  }
792
804
  return () => {
793
805
  r.disable();
@@ -795,14 +807,14 @@ function Be(l) {
795
807
  }
796
808
  return null;
797
809
  }
798
- class Re {
810
+ class Be {
799
811
  constructor(e) {
800
812
  c(this, "modelviewer");
801
813
  c(this, "_didWarnAboutMissingUrl", !1);
802
814
  this.modelviewer = e;
803
815
  }
804
- onBeforeUpdateLOD(e, t, r, s) {
805
- this.tryParseMeshLOD(t, s), this.tryParseTextureLOD(t, s);
816
+ onBeforeUpdateLOD(e, t, r, i) {
817
+ this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
806
818
  }
807
819
  getUrl() {
808
820
  let e = this.modelviewer.getAttribute("src");
@@ -815,8 +827,8 @@ class Re {
815
827
  if (t[Q] == !0)
816
828
  return;
817
829
  t[Q] = !0;
818
- const r = this.tryGetCurrentGLTF(e), s = this.getUrl();
819
- if (s && r && t.material) {
830
+ const r = this.tryGetCurrentGLTF(e), i = this.getUrl();
831
+ if (i && r && t.material) {
820
832
  let n = function(o) {
821
833
  var h, d, g;
822
834
  if (o[Q] == !0)
@@ -824,59 +836,59 @@ class Re {
824
836
  o[Q] = !0, o.userData && (o.userData.LOD = -1);
825
837
  const a = Object.keys(o);
826
838
  for (let f = 0; f < a.length; f++) {
827
- const m = a[f], D = o[m];
828
- if ((D == null ? void 0 : D.isTexture) === !0) {
829
- const M = (d = (h = D.userData) == null ? void 0 : h.associations) == null ? void 0 : d.textures, O = r.parser.json.textures[M];
839
+ const m = a[f], M = o[m];
840
+ if ((M == null ? void 0 : M.isTexture) === !0) {
841
+ const w = (d = (h = M.userData) == null ? void 0 : h.associations) == null ? void 0 : d.textures, O = r.parser.json.textures[w];
830
842
  if (!O) {
831
- console.warn("Texture data not found for texture index " + M);
843
+ console.warn("Texture data not found for texture index " + w);
832
844
  continue;
833
845
  }
834
- if ((g = O == null ? void 0 : O.extensions) != null && g[R]) {
835
- const k = O.extensions[R];
836
- k && s && v.registerTexture(s, D, k.lods.length, M, k);
846
+ if ((g = O == null ? void 0 : O.extensions) != null && g[B]) {
847
+ const R = O.extensions[B];
848
+ R && i && v.registerTexture(i, M, R.lods.length, w, R);
837
849
  }
838
850
  }
839
851
  }
840
852
  };
841
- const i = t.material;
842
- if (Array.isArray(i))
843
- for (const o of i)
853
+ const s = t.material;
854
+ if (Array.isArray(s))
855
+ for (const o of s)
844
856
  n(o);
845
857
  else
846
- n(i);
858
+ n(s);
847
859
  }
848
860
  }
849
861
  tryParseMeshLOD(e, t) {
850
- var n, i;
862
+ var n, s;
851
863
  if (t[de] == !0)
852
864
  return;
853
865
  t[de] = !0;
854
866
  const r = this.getUrl();
855
867
  if (!r)
856
868
  return;
857
- const s = (i = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : i[R];
858
- if (s && r) {
869
+ const i = (s = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : s[B];
870
+ if (i && r) {
859
871
  const o = t.uuid;
860
- v.registerMesh(r, o, t, 0, s.lods.length, s);
872
+ v.registerMesh(r, o, t, 0, i.lods.length, i);
861
873
  }
862
874
  }
863
875
  }
864
876
  function qe(l, e, t, r) {
865
877
  he(e), ge(t), t.register((n) => new v(n, l));
866
- const s = P.get(e);
867
- return (r == null ? void 0 : r.enableLODsManager) !== !1 && s.enable(), s;
878
+ const i = P.get(e);
879
+ return (r == null ? void 0 : r.enableLODsManager) !== !1 && i.enable(), i;
868
880
  }
869
881
  document.addEventListener("DOMContentLoaded", () => {
870
- Be(document.querySelector("model-viewer"));
882
+ ke(document.querySelector("model-viewer"));
871
883
  });
872
884
  export {
873
- R as EXTENSION_NAME,
885
+ B as EXTENSION_NAME,
874
886
  P as LODsManager,
875
887
  v as NEEDLE_progressive,
876
888
  ge as addDracoAndKTX2Loaders,
877
889
  he as createLoaders,
878
890
  ae as getRaycastMesh,
879
- Be as patchModelViewer,
891
+ ke as patchModelViewer,
880
892
  Ne as setDracoDecoderLocation,
881
893
  We as setKTX2TranscoderLocation,
882
894
  be as setRaycastMesh,