@needle-tools/gltf-progressive 1.0.0-alpha.6 → 1.0.0-alpha.8

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,24 +1,24 @@
1
- var ne = Object.defineProperty;
2
- var ae = (l, e, t) => e in l ? ne(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
1
+ var oe = Object.defineProperty;
2
+ var ae = (l, e, t) => e in l ? oe(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
3
  var u = (l, e, t) => (ae(l, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { Mesh as Y, BufferGeometry as X, Material as le, RawShaderMaterial as ue, Texture as z, TextureLoader as ce, Matrix4 as Z, Frustum as fe, Sphere as de, Box3 as j, Vector3 as C } from "three";
4
+ import { Mesh as q, BufferGeometry as X, Material as le, RawShaderMaterial as ue, Texture as U, TextureLoader as ce, Matrix4 as j, Frustum as fe, Sphere as de, Box3 as ee, Vector3 as k } from "three";
5
5
  import { GLTFLoader as ge } from "three/examples/jsm/loaders/GLTFLoader.js";
6
6
  import { MeshoptDecoder as he } from "three/examples/jsm/libs/meshopt_decoder.module.js";
7
7
  import { DRACOLoader as pe } from "three/examples/jsm/loaders/DRACOLoader.js";
8
8
  import { KTX2Loader as ye } from "three/examples/jsm/loaders/KTX2Loader.js";
9
- const Le = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", De = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
10
- let U, V, I;
9
+ const me = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", Le = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
10
+ let F, H, W;
11
11
  function se(l) {
12
- U || (U = new pe(), U.setDecoderPath(Le), U.setDecoderConfig({ type: "js" })), I || (I = new ye(), I.setTranscoderPath(De)), V || (V = he), l ? I.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
12
+ F || (F = new pe(), F.setDecoderPath(me), F.setDecoderConfig({ type: "js" })), W || (W = new ye(), W.setTranscoderPath(Le)), H || (H = he), l ? W.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
13
13
  }
14
14
  function ie(l) {
15
- l.dracoLoader || l.setDRACOLoader(U), l.ktx2Loader || l.setKTX2Loader(I), l.meshoptDecoder || l.setMeshoptDecoder(V);
15
+ l.dracoLoader || l.setDRACOLoader(F), l.ktx2Loader || l.setKTX2Loader(W), l.meshoptDecoder || l.setMeshoptDecoder(H);
16
16
  }
17
- function Q(l) {
17
+ function Z(l) {
18
18
  const t = new URL(window.location.href).searchParams.get(l);
19
19
  return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
20
20
  }
21
- function me(l, e) {
21
+ function De(l, e) {
22
22
  if (e === void 0 || e.startsWith("./") || e.startsWith("http") || l === void 0)
23
23
  return e;
24
24
  const t = l.lastIndexOf("/");
@@ -30,41 +30,41 @@ function me(l, e) {
30
30
  }
31
31
  return e;
32
32
  }
33
- const H = new Array();
34
- function ke(l) {
35
- H.push(l);
33
+ const J = new Array();
34
+ function Be(l) {
35
+ J.push(l);
36
36
  }
37
- const R = "NEEDLE_progressive", S = Q("debugprogressive"), q = Symbol("needle-progressive-texture"), W = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Set();
37
+ const R = "NEEDLE_progressive", S = Z("debugprogressive"), V = Symbol("needle-progressive-texture"), z = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Set();
38
38
  if (S) {
39
39
  let l = function() {
40
- e += 1, console.log("Toggle LOD level", e, W), W.forEach((i, o) => {
40
+ e += 1, console.log("Toggle LOD level", e, z), z.forEach((i, n) => {
41
41
  for (const s of i.keys) {
42
- const n = o[s];
43
- if (n.isBufferGeometry === !0) {
44
- const a = M.getMeshLODInformation(n), g = a ? Math.min(e, a.lods.length) : 0;
45
- o["DEBUG:LOD"] = e, M.assignMeshLOD(o, g), a && (t = Math.max(t, a.lods.length - 1));
46
- } else if (o.isMaterial === !0) {
47
- o["DEBUG:LOD"] = e, M.assignTextureLOD(o, e);
42
+ const o = n[s];
43
+ if (o.isBufferGeometry === !0) {
44
+ const a = v.getMeshLODInformation(o), h = a ? Math.min(e, a.lods.length) : 0;
45
+ n["DEBUG:LOD"] = e, v.assignMeshLOD(n, h), a && (t = Math.max(t, a.lods.length - 1));
46
+ } else if (n.isMaterial === !0) {
47
+ n["DEBUG:LOD"] = e, v.assignTextureLOD(n, e);
48
48
  break;
49
49
  }
50
50
  }
51
51
  }), e >= t && (e = -1);
52
52
  }, e = -1, t = 2, r = !1;
53
53
  window.addEventListener("keyup", (i) => {
54
- i.key === "p" && l(), i.key === "w" && (r = !r, J && J.forEach((o) => {
55
- o.name != "BackgroundCubeMaterial" && "wireframe" in o && (o.wireframe = r);
54
+ i.key === "p" && l(), i.key === "w" && (r = !r, Q && Q.forEach((n) => {
55
+ n.name != "BackgroundCubeMaterial" && "wireframe" in n && (n.wireframe = r);
56
56
  }));
57
57
  });
58
58
  }
59
- function ee(l, e, t) {
59
+ function te(l, e, t) {
60
60
  var i;
61
61
  if (!S)
62
62
  return;
63
- W.has(l) || W.set(l, { keys: [], sourceId: t });
64
- const r = W.get(l);
63
+ z.has(l) || z.set(l, { keys: [], sourceId: t });
64
+ const r = z.get(l);
65
65
  ((i = r == null ? void 0 : r.keys) == null ? void 0 : i.includes(e)) == !1 && r.keys.push(e);
66
66
  }
67
- const v = class {
67
+ const M = class {
68
68
  constructor(e, t) {
69
69
  u(this, "parser");
70
70
  u(this, "url");
@@ -84,11 +84,11 @@ const v = class {
84
84
  * @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
85
85
  */
86
86
  static hasLODLevelAvailable(e, t) {
87
- var o;
87
+ var n;
88
88
  if (e.isMaterial === !0) {
89
89
  for (const s of Object.keys(e)) {
90
- const n = e[s];
91
- if (n.isTexture && this.hasLODLevelAvailable(n, t))
90
+ const o = e[s];
91
+ if (o.isTexture && this.hasLODLevelAvailable(o, t))
92
92
  return !0;
93
93
  }
94
94
  return !1;
@@ -98,7 +98,7 @@ const v = class {
98
98
  return !0;
99
99
  }
100
100
  let r, i;
101
- if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (o = r == null ? void 0 : r.userData) != null && o.LODS) {
101
+ if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (n = r == null ? void 0 : r.userData) != null && n.LODS) {
102
102
  const s = r.userData.LODS;
103
103
  if (i = this.lodInfos.get(s.key), t === void 0)
104
104
  return i != null;
@@ -125,19 +125,19 @@ const v = class {
125
125
  var r;
126
126
  if (!e)
127
127
  return Promise.resolve(null);
128
- if (e instanceof Y || e.isMesh === !0) {
129
- const i = e.geometry, o = this.getAssignedLODInformation(i);
130
- if (!o)
128
+ if (e instanceof q || e.isMesh === !0) {
129
+ const i = e.geometry, n = this.getAssignedLODInformation(i);
130
+ if (!n)
131
131
  return Promise.resolve(null);
132
- for (const s of H)
132
+ for (const s of J)
133
133
  (r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
134
- return e["LOD:requested level"] = t, v.getOrLoadLOD(i, t).then((s) => {
134
+ return e["LOD:requested level"] = t, M.getOrLoadLOD(i, t).then((s) => {
135
135
  if (e["LOD:requested level"] === t) {
136
136
  if (delete e["LOD:requested level"], Array.isArray(s)) {
137
- const n = o.index || 0;
138
- s = s[n];
137
+ const o = n.index || 0;
138
+ s = s[o];
139
139
  }
140
- s && i != s && s instanceof X && (e.geometry = s, S && ee(e, "geometry", o.url));
140
+ s && i != s && s instanceof X && (e.geometry = s, S && te(e, "geometry", n.url));
141
141
  }
142
142
  return s;
143
143
  }).catch((s) => (console.error("Error loading mesh LOD", e, s), null));
@@ -156,193 +156,193 @@ const v = class {
156
156
  if (!e)
157
157
  return Promise.resolve(null);
158
158
  if (e instanceof le || e.isMaterial === !0) {
159
- const r = e, i = [], o = new Array();
160
- if (S && J.add(r), r instanceof ue)
159
+ const r = e, i = [], n = new Array();
160
+ if (S && Q.add(r), r instanceof ue)
161
161
  for (const s of Object.keys(r.uniforms)) {
162
- const n = r.uniforms[s].value;
163
- if ((n == null ? void 0 : n.isTexture) === !0) {
164
- const a = this.assignTextureLODForSlot(n, t, r, s);
165
- i.push(a), o.push(s);
162
+ const o = r.uniforms[s].value;
163
+ if ((o == null ? void 0 : o.isTexture) === !0) {
164
+ const a = this.assignTextureLODForSlot(o, t, r, s);
165
+ i.push(a), n.push(s);
166
166
  }
167
167
  }
168
168
  else
169
169
  for (const s of Object.keys(r)) {
170
- const n = r[s];
171
- if ((n == null ? void 0 : n.isTexture) === !0) {
172
- const a = this.assignTextureLODForSlot(n, t, r, s);
173
- i.push(a), o.push(s);
170
+ const o = r[s];
171
+ if ((o == null ? void 0 : o.isTexture) === !0) {
172
+ const a = this.assignTextureLODForSlot(o, t, r, s);
173
+ i.push(a), n.push(s);
174
174
  }
175
175
  }
176
176
  return Promise.all(i).then((s) => {
177
- const n = new Array();
177
+ const o = new Array();
178
178
  for (let a = 0; a < s.length; a++) {
179
- const g = s[a], f = o[a];
180
- g && g.isTexture === !0 ? n.push({ material: r, slot: f, texture: g, level: t }) : n.push({ material: r, slot: f, texture: null, level: t });
179
+ const h = s[a], d = n[a];
180
+ h && h.isTexture === !0 ? o.push({ material: r, slot: d, texture: h, level: t }) : o.push({ material: r, slot: d, texture: null, level: t });
181
181
  }
182
- return n;
182
+ return o;
183
183
  });
184
184
  }
185
- if (e instanceof z || e.isTexture === !0) {
185
+ if (e instanceof U || e.isTexture === !0) {
186
186
  const r = e;
187
187
  return this.assignTextureLODForSlot(r, t, null, null);
188
188
  }
189
189
  return Promise.resolve(null);
190
190
  }
191
191
  static assignTextureLODForSlot(e, t, r, i) {
192
- return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : v.getOrLoadLOD(e, t).then((o) => {
193
- if (Array.isArray(o))
192
+ return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : M.getOrLoadLOD(e, t).then((n) => {
193
+ if (Array.isArray(n))
194
194
  return null;
195
- if ((o == null ? void 0 : o.isTexture) === !0) {
196
- if (o != e && (r && i && (r[i] = o), S && i && r)) {
195
+ if ((n == null ? void 0 : n.isTexture) === !0) {
196
+ if (n != e && (r && i && (r[i] = n), S && i && r)) {
197
197
  const s = this.getAssignedLODInformation(e);
198
- s && ee(r, i, s.url);
198
+ s && te(r, i, s.url);
199
199
  }
200
- return o;
200
+ return n;
201
201
  } else
202
202
  S == "verbose" && console.warn("No LOD found for", e, t);
203
203
  return null;
204
- }).catch((o) => (console.error("Error loading LOD", e, o), null));
204
+ }).catch((n) => (console.error("Error loading LOD", e, n), null));
205
205
  }
206
206
  afterRoot(e) {
207
207
  var t, r;
208
- return S && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, o) => {
208
+ return S && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
209
209
  if (i != null && i.extensions) {
210
210
  const s = i == null ? void 0 : i.extensions[R];
211
211
  if (s) {
212
- let n = !1;
212
+ let o = !1;
213
213
  for (const a of this.parser.associations.keys())
214
- a.isTexture === !0 && this.parser.associations.get(a).textures === o && (n = !0, v.registerTexture(this.url, a, o, s));
215
- n || this.parser.getDependency("texture", o).then((a) => {
216
- a && v.registerTexture(this.url, a, o, s);
214
+ a.isTexture === !0 && this.parser.associations.get(a).textures === n && (o = !0, M.registerTexture(this.url, a, n, s));
215
+ o || this.parser.getDependency("texture", n).then((a) => {
216
+ a && M.registerTexture(this.url, a, n, s);
217
217
  });
218
218
  }
219
219
  }
220
- }), (r = this.parser.json.meshes) == null || r.forEach((i, o) => {
220
+ }), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
221
221
  if (i != null && i.extensions) {
222
222
  const s = i == null ? void 0 : i.extensions[R];
223
223
  if (s && s.lods) {
224
- for (const n of this.parser.associations.keys())
225
- if (n.isMesh) {
226
- const a = this.parser.associations.get(n);
227
- a.meshes === o && v.registerMesh(this.url, s.guid, n, s.lods.length, a.primitives, s);
224
+ for (const o of this.parser.associations.keys())
225
+ if (o.isMesh) {
226
+ const a = this.parser.associations.get(o);
227
+ a.meshes === n && M.registerMesh(this.url, s.guid, o, s.lods.length, a.primitives, s);
228
228
  }
229
229
  }
230
230
  }
231
231
  }), null;
232
232
  }
233
233
  static async getOrLoadLOD(e, t) {
234
- var n, a, g;
234
+ var o, a, h;
235
235
  const r = S == "verbose", i = e.userData.LODS;
236
236
  if (!i)
237
237
  return null;
238
- const o = i == null ? void 0 : i.key;
238
+ const n = i == null ? void 0 : i.key;
239
239
  let s;
240
240
  if (e.isTexture === !0) {
241
- const f = e;
242
- f.source && f.source[q] && (s = f.source[q]);
241
+ const d = e;
242
+ d.source && d.source[V] && (s = d.source[V]);
243
243
  }
244
- if (s || (s = v.lodInfos.get(o)), s) {
244
+ if (s || (s = M.lodInfos.get(n)), s) {
245
245
  if (t > 0) {
246
- let d = !1;
246
+ let f = !1;
247
247
  const w = Array.isArray(s.lods);
248
- if (w && t >= s.lods.length ? d = !0 : w || (d = !0), d)
249
- return this.lowresCache.get(o);
248
+ if (w && t >= s.lods.length ? f = !0 : w || (f = !0), f)
249
+ return this.lowresCache.get(n);
250
250
  }
251
- const f = Array.isArray(s.lods) ? s.lods[t].path : s.lods;
252
- if (!f)
251
+ const d = Array.isArray(s.lods) ? s.lods[t].path : s.lods;
252
+ if (!d)
253
253
  return S && !s["missing:uri"] && (s["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, s)), null;
254
- const L = me(i.url, f);
255
- if (L.endsWith(".glb") || L.endsWith(".gltf")) {
254
+ const c = De(i.url, d);
255
+ if (c.endsWith(".glb") || c.endsWith(".gltf")) {
256
256
  if (!s.guid)
257
257
  return console.warn("missing pointer for glb/gltf texture", s), null;
258
- const d = L + "_" + s.guid, w = this.previouslyLoaded.get(d);
258
+ const f = c + "_" + s.guid, w = this.previouslyLoaded.get(f);
259
259
  if (w !== void 0) {
260
- r && console.log(`LOD ${t} was already loading/loaded: ${d}`);
261
- let m = await w.catch((G) => (console.error(`Error loading LOD ${t} from ${L}
262
- `, G), null)), B = !1;
263
- if (m == null || (m instanceof z && e instanceof z ? (n = m.image) != null && n.data || (a = m.source) != null && a.data ? m = this.copySettings(e, m) : (B = !0, this.previouslyLoaded.delete(d)) : m instanceof X && e instanceof X && ((g = m.attributes.position) != null && g.array || (B = !0, this.previouslyLoaded.delete(d)))), !B)
264
- return m;
260
+ r && console.log(`LOD ${t} was already loading/loaded: ${f}`);
261
+ let D = await w.catch((I) => (console.error(`Error loading LOD ${t} from ${c}
262
+ `, I), null)), C = !1;
263
+ if (D == null || (D instanceof U && e instanceof U ? (o = D.image) != null && o.data || (a = D.source) != null && a.data ? D = this.copySettings(e, D) : (C = !0, this.previouslyLoaded.delete(f)) : D instanceof X && e instanceof X && ((h = D.attributes.position) != null && h.array || (C = !0, this.previouslyLoaded.delete(f)))), !C)
264
+ return D;
265
265
  }
266
- const D = s, A = new Promise(async (m, B) => {
267
- const G = new ge();
268
- ie(G), S && (await new Promise((p) => setTimeout(p, 1e3)), r && console.warn("Start loading (delayed) " + L, D.guid));
269
- let y = L;
270
- if (D && Array.isArray(D.lods)) {
271
- const p = D.lods[t];
272
- p.hash && (y += "?v=" + p.hash);
266
+ const L = s, A = new Promise(async (D, C) => {
267
+ const I = new ge();
268
+ ie(I), S && (await new Promise((y) => setTimeout(y, 1e3)), r && console.warn("Start loading (delayed) " + c, L.guid));
269
+ let m = c;
270
+ if (L && Array.isArray(L.lods)) {
271
+ const y = L.lods[t];
272
+ y.hash && (m += "?v=" + y.hash);
273
273
  }
274
- const h = await G.loadAsync(y).catch((p) => (console.error(`Error loading LOD ${t} from ${L}
275
- `, p), null));
276
- if (!h)
274
+ const p = await I.loadAsync(m).catch((y) => (console.error(`Error loading LOD ${t} from ${c}
275
+ `, y), null));
276
+ if (!p)
277
277
  return null;
278
- const T = h.parser;
279
- r && console.log("Loading finished " + L, D.guid);
278
+ const b = p.parser;
279
+ r && console.log("Loading finished " + c, L.guid);
280
280
  let x = 0;
281
- if (h.parser.json.textures) {
282
- let p = !1;
283
- for (const c of h.parser.json.textures) {
284
- if (c != null && c.extensions) {
285
- const O = c == null ? void 0 : c.extensions[R];
286
- if (O != null && O.guid && O.guid === D.guid) {
287
- p = !0;
281
+ if (p.parser.json.textures) {
282
+ let y = !1;
283
+ for (const g of p.parser.json.textures) {
284
+ if (g != null && g.extensions) {
285
+ const O = g == null ? void 0 : g.extensions[R];
286
+ if (O != null && O.guid && O.guid === L.guid) {
287
+ y = !0;
288
288
  break;
289
289
  }
290
290
  }
291
291
  x++;
292
292
  }
293
- if (p) {
294
- let c = await T.getDependency("texture", x);
295
- return r && console.log('change "' + e.name + '" → "' + c.name + '"', L, x, c, d), e instanceof z && (c = this.copySettings(e, c)), c && (c.guid = D.guid), m(c);
293
+ if (y) {
294
+ let g = await b.getDependency("texture", x);
295
+ return r && console.log('change "' + e.name + '" → "' + g.name + '"', c, x, g, f), e instanceof U && (g = this.copySettings(e, g)), g && (g.guid = L.guid), D(g);
296
296
  }
297
297
  }
298
- if (x = 0, h.parser.json.meshes) {
299
- let p = !1;
300
- for (const c of h.parser.json.meshes) {
301
- if (c != null && c.extensions) {
302
- const O = c == null ? void 0 : c.extensions[R];
303
- if (O != null && O.guid && O.guid === D.guid) {
304
- p = !0;
298
+ if (x = 0, p.parser.json.meshes) {
299
+ let y = !1;
300
+ for (const g of p.parser.json.meshes) {
301
+ if (g != null && g.extensions) {
302
+ const O = g == null ? void 0 : g.extensions[R];
303
+ if (O != null && O.guid && O.guid === L.guid) {
304
+ y = !0;
305
305
  break;
306
306
  }
307
307
  }
308
308
  x++;
309
309
  }
310
- if (p) {
311
- const c = await T.getDependency("mesh", x), O = D;
312
- if (r && console.log(`Loaded Mesh "${c.name}"`, L, x, c, d), c.isMesh === !0) {
313
- const b = c.geometry;
314
- return v.assignLODInformation(i.url, b, o, t, void 0, O.density), m(b);
310
+ if (y) {
311
+ const g = await b.getDependency("mesh", x), O = L;
312
+ if (r && console.log(`Loaded Mesh "${g.name}"`, c, x, g, f), g.isMesh === !0) {
313
+ const P = g.geometry;
314
+ return M.assignLODInformation(i.url, P, n, t, void 0, O.density), D(P);
315
315
  } else {
316
- const b = new Array();
317
- for (let _ = 0; _ < c.children.length; _++) {
318
- const F = c.children[_];
319
- if (F instanceof Y) {
320
- const $ = F.geometry;
321
- v.assignLODInformation(i.url, $, o, t, _, O.density), b.push($);
316
+ const P = new Array();
317
+ for (let _ = 0; _ < g.children.length; _++) {
318
+ const E = g.children[_];
319
+ if (E instanceof q) {
320
+ const N = E.geometry;
321
+ M.assignLODInformation(i.url, N, n, t, _, O.density), P.push(N);
322
322
  }
323
323
  }
324
- return m(b);
324
+ return D(P);
325
325
  }
326
326
  }
327
327
  }
328
- return m(null);
328
+ return D(null);
329
329
  });
330
- return this.previouslyLoaded.set(d, A), await A;
331
- } else if (e instanceof z) {
332
- r && console.log("Load texture from uri: " + L);
333
- const w = await new ce().loadAsync(L);
334
- return w ? (w.guid = s.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, r && console.log(s, w)) : S && console.warn("failed loading", L), w;
330
+ return this.previouslyLoaded.set(f, A), await A;
331
+ } else if (e instanceof U) {
332
+ r && console.log("Load texture from uri: " + c);
333
+ const w = await new ce().loadAsync(c);
334
+ return w ? (w.guid = s.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, r && console.log(s, w)) : S && console.warn("failed loading", c), w;
335
335
  }
336
336
  } else
337
- S && console.warn(`Can not load LOD ${t}: no LOD info found for "${o}" ${e.name}`, e.type);
337
+ S && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
338
338
  return null;
339
339
  }
340
- static assignLODInformation(e, t, r, i, o, s) {
340
+ static assignLODInformation(e, t, r, i, n, s) {
341
341
  if (!t)
342
342
  return;
343
343
  t.userData || (t.userData = {});
344
- const n = new xe(e, r, i, o, s);
345
- t.userData.LODS = n, t.userData.LOD = i;
344
+ const o = new xe(e, r, i, n, s);
345
+ t.userData.LODS = o, t.userData.LOD = i;
346
346
  }
347
347
  static getAssignedLODInformation(e) {
348
348
  var t;
@@ -353,32 +353,32 @@ const v = class {
353
353
  return r || (t = t.clone(), this._copiedTextures.set(e, t), t.offset = e.offset, t.repeat = e.repeat, t.colorSpace = e.colorSpace, t);
354
354
  }
355
355
  };
356
- let M = v;
356
+ let v = M;
357
357
  /**
358
358
  * Register a texture with LOD information
359
359
  */
360
- u(M, "registerTexture", (e, t, r, i) => {
361
- S && console.log("> Progressive: register texture", r, t.name, t.uuid, t, i), t.source && (t.source[q] = i);
362
- const o = i.guid;
363
- v.assignLODInformation(e, t, o, 0, 0, void 0), v.lodInfos.set(o, i), v.lowresCache.set(o, t);
360
+ u(v, "registerTexture", (e, t, r, i) => {
361
+ S && console.log("> Progressive: register texture", r, t.name, t.uuid, t, i), t.source && (t.source[V] = i);
362
+ const n = i.guid;
363
+ M.assignLODInformation(e, t, n, 0, 0, void 0), M.lodInfos.set(n, i), M.lowresCache.set(n, t);
364
364
  }), /**
365
365
  * Register a mesh with LOD information
366
366
  */
367
- u(M, "registerMesh", (e, t, r, i, o, s) => {
368
- var g;
369
- S && console.log("> Progressive: register mesh", o, r.name, s, r.uuid, r);
370
- const n = r.geometry;
371
- n.userData || (n.userData = {}), v.assignLODInformation(e, n, t, i, o, s.density), v.lodInfos.set(t, s);
372
- let a = v.lowresCache.get(t);
373
- a ? a.push(r.geometry) : a = [r.geometry], v.lowresCache.set(t, a);
374
- for (const f of H)
375
- (g = f.onRegisteredNewMesh) == null || g.call(f, r, s);
367
+ u(v, "registerMesh", (e, t, r, i, n, s) => {
368
+ var h;
369
+ S && console.log("> Progressive: register mesh", n, r.name, s, r.uuid, r);
370
+ const o = r.geometry;
371
+ o.userData || (o.userData = {}), M.assignLODInformation(e, o, t, i, n, s.density), M.lodInfos.set(t, s);
372
+ let a = M.lowresCache.get(t);
373
+ a ? a.push(r.geometry) : a = [r.geometry], M.lowresCache.set(t, a);
374
+ for (const d of J)
375
+ (h = d.onRegisteredNewMesh) == null || h.call(d, r, s);
376
376
  }), /** A map of key = asset uuid and value = LOD information */
377
- u(M, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
378
- u(M, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
379
- u(M, "lowresCache", /* @__PURE__ */ new Map()), u(M, "_copiedTextures", /* @__PURE__ */ new Map());
377
+ u(v, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
378
+ u(v, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
379
+ u(v, "lowresCache", /* @__PURE__ */ new Map()), u(v, "_copiedTextures", /* @__PURE__ */ new Map());
380
380
  class xe {
381
- constructor(e, t, r, i, o) {
381
+ constructor(e, t, r, i, n) {
382
382
  u(this, "url");
383
383
  /** the key to lookup the LOD information */
384
384
  u(this, "key");
@@ -387,13 +387,13 @@ class xe {
387
387
  u(this, "index");
388
388
  /** the mesh density */
389
389
  u(this, "density");
390
- this.url = e, this.key = t, this.level = r, i != null && (this.index = i), o != null && (this.density = o);
390
+ this.url = e, this.key = t, this.level = r, i != null && (this.index = i), n != null && (this.density = n);
391
391
  }
392
392
  }
393
- const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
393
+ const Y = Z("debugprogressive"), we = Z("noprogressive"), T = class {
394
394
  constructor(e) {
395
395
  u(this, "renderer");
396
- u(this, "projectionScreenMatrix", new Z());
396
+ u(this, "projectionScreenMatrix", new j());
397
397
  u(this, "cameraFrustrum", new fe());
398
398
  /**
399
399
  * The update interval in frames. If set to 0, the LODs will be updated every frame. If set to 1, the LODs will be updated every second frame, etc.
@@ -407,11 +407,11 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
407
407
  u(this, "_originalRender");
408
408
  // private testIfLODLevelsAreAvailable() {
409
409
  u(this, "_sphere", new de());
410
- u(this, "_tempBox", new j());
411
- u(this, "tempMatrix", new Z());
412
- u(this, "_tempWorldPosition", new C());
413
- u(this, "_tempBoxSize", new C());
414
- u(this, "_tempBox2Size", new C());
410
+ u(this, "_tempBox", new ee());
411
+ u(this, "tempMatrix", new j());
412
+ u(this, "_tempWorldPosition", new k());
413
+ u(this, "_tempBoxSize", new k());
414
+ u(this, "_tempBox2Size", new k());
415
415
  this.renderer = e;
416
416
  }
417
417
  /** @internal */
@@ -429,9 +429,9 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
429
429
  this._originalRender = this.renderer.render;
430
430
  const t = this;
431
431
  let r = 0;
432
- se(this.renderer), this.renderer.render = function(i, o) {
433
- const s = r++, n = e++;
434
- t.onBeforeRender(i, o, n, s), t._originalRender.call(this, i, o), t.onAfterRender(i, o, n, s), e--;
432
+ se(this.renderer), this.renderer.render = function(i, n) {
433
+ const s = r++, o = e++;
434
+ t.onBeforeRender(i, n, o, s), t._originalRender.call(this, i, n), t.onAfterRender(i, n, o, s), e--;
435
435
  };
436
436
  }
437
437
  disable() {
@@ -440,36 +440,46 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
440
440
  onBeforeRender(e, t, r, i) {
441
441
  }
442
442
  onAfterRender(e, t, r, i) {
443
+ var h, d;
443
444
  if (we || this.pause || this.updateInterval > 0 && i % this.updateInterval != 0)
444
445
  return;
445
446
  this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this.cameraFrustrum.setFromProjectionMatrix(this.projectionScreenMatrix, this.renderer.coordinateSystem);
446
- const o = 1e5, n = this.renderer.renderLists.get(e, r).opaque;
447
- for (const a of n) {
448
- const g = a.object;
449
- (g instanceof Y || g.isMesh) && this.updateLODs(e, t, g, o);
447
+ const n = 1e5, s = this.renderer.renderLists.get(e, r), o = s.opaque;
448
+ for (const c of o) {
449
+ if (c.material && (((h = c.geometry) == null ? void 0 : h.type) === "BoxGeometry" || ((d = c.geometry) == null ? void 0 : d.type) === "BufferGeometry") && (c.material.name === "SphericalGaussianBlur" || c.material.name == "BackgroundCubeMaterial" || c.material.name === "CubemapFromEquirect" || c.material.name === "EquirectangularToCubeUV")) {
450
+ Y && (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)));
451
+ continue;
452
+ }
453
+ const f = c.object;
454
+ (f instanceof q || f.isMesh) && this.updateLODs(e, t, f, n);
455
+ }
456
+ const a = s.transparent;
457
+ for (const c of a) {
458
+ const f = c.object;
459
+ (f instanceof q || f.isMesh) && this.updateLODs(e, t, f, n);
450
460
  }
451
461
  }
452
462
  /** Update the LOD levels for the renderer. */
453
463
  updateLODs(e, t, r, i) {
454
- var a, g;
455
- for (const f of this.plugins)
456
- (a = f.onBeforeUpdateLOD) == null || a.call(f, this.renderer, e, t, r);
457
- let o = r.userData.LOD_state;
458
- o || (o = new Oe(), r.userData.LOD_state = o);
459
- let s = this.calculateLodLevel(t, r, o, i);
464
+ var a, h;
465
+ for (const d of this.plugins)
466
+ (a = d.onBeforeUpdateLOD) == null || a.call(d, this.renderer, e, t, r);
467
+ let n = r.userData.LOD_state;
468
+ n || (n = new Oe(), r.userData.LOD_state = n);
469
+ let s = this.calculateLodLevel(t, r, n, i);
460
470
  s = Math.round(s), s >= 0 && this.loadProgressiveMeshes(r, s);
461
- let n = 0;
471
+ let o = 0;
462
472
  if (r.material) {
463
- const f = r["DEBUG:LOD"];
464
- if (f != null && (n = f), Array.isArray(r.material))
465
- for (const L of r.material)
466
- this.loadProgressiveTextures(L, n);
473
+ const d = r["DEBUG:LOD"];
474
+ if (d != null && (o = d), Array.isArray(r.material))
475
+ for (const c of r.material)
476
+ this.loadProgressiveTextures(c, o);
467
477
  else
468
- this.loadProgressiveTextures(r.material, n);
478
+ this.loadProgressiveTextures(r.material, o);
469
479
  }
470
- for (const f of this.plugins)
471
- (g = f.onAfterUpdatedLOD) == null || g.call(f, this.renderer, e, t, r, s);
472
- o.lastLodLevel = s;
480
+ for (const d of this.plugins)
481
+ (h = d.onAfterUpdatedLOD) == null || h.call(d, this.renderer, e, t, r, s);
482
+ n.lastLodLevel = s;
473
483
  }
474
484
  /** Load progressive textures for the given material
475
485
  * @param material the material to load the textures for
@@ -477,7 +487,7 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
477
487
  * @returns Promise with true if the LOD was loaded, false if not
478
488
  */
479
489
  loadProgressiveTextures(e, t) {
480
- return e && e.userData && e.userData.LOD !== t ? (e.userData.LOD = t, M.assignTextureLOD(e, t)) : Promise.resolve(null);
490
+ return e && e.userData && e.userData.LOD !== t ? (e.userData.LOD = t, v.assignTextureLOD(e, t)) : Promise.resolve(null);
481
491
  }
482
492
  /** Load progressive meshes for the given mesh
483
493
  * @param mesh the mesh to load the LOD for
@@ -491,92 +501,92 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
491
501
  if (e.userData || (e.userData = {}), e.userData.LOD !== t) {
492
502
  e.userData.LOD = t;
493
503
  const r = e.geometry;
494
- return M.assignMeshLOD(e, t).then((i) => (i && e.userData.LOD == t && r != e.geometry, i));
504
+ return v.assignMeshLOD(e, t).then((i) => (i && e.userData.LOD == t && r != e.geometry, i));
495
505
  }
496
506
  return Promise.resolve(null);
497
507
  }
498
508
  calculateLodLevel(e, t, r, i) {
499
- var n;
509
+ var o;
500
510
  if (!t)
501
511
  return -1;
502
512
  let s = 10 + 1;
503
513
  if (e) {
504
- if (te && t["DEBUG:LOD"] != null)
514
+ if (Y && t["DEBUG:LOD"] != null)
505
515
  return t["DEBUG:LOD"];
506
- const a = M.getMeshLODInformation(t.geometry), g = a == null ? void 0 : a.lods;
507
- if (!g || g.length <= 0 || !((n = this.cameraFrustrum) != null && n.intersectsObject(t)))
516
+ const a = v.getMeshLODInformation(t.geometry), h = a == null ? void 0 : a.lods;
517
+ if (!h || h.length <= 0 || !((o = this.cameraFrustrum) != null && o.intersectsObject(t)))
508
518
  return 99;
509
- const f = t.geometry.boundingBox;
510
- if (f && e.isPerspectiveCamera) {
511
- const L = e;
519
+ const d = t.geometry.boundingBox;
520
+ if (d && e.isPerspectiveCamera) {
521
+ const c = e;
512
522
  if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
513
523
  this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
514
- const y = e.getWorldPosition(this._tempWorldPosition);
515
- if (this._sphere.containsPoint(y))
524
+ const m = e.getWorldPosition(this._tempWorldPosition);
525
+ if (this._sphere.containsPoint(m))
516
526
  return 0;
517
527
  }
518
- if (this._tempBox.copy(f), this._tempBox.applyMatrix4(t.matrixWorld), this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && L.fov > 70) {
519
- const y = this._tempBox.min, h = this._tempBox.max;
520
- let T = y.x, x = y.y, p = h.x, c = h.y;
521
- const O = 2, b = 1.5, _ = (y.x + h.x) * 0.5, F = (y.y + h.y) * 0.5;
522
- T = (T - _) * O + _, x = (x - F) * O + F, p = (p - _) * O + _, c = (c - F) * O + F;
523
- const $ = T < 0 && p > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(h.x)), oe = x < 0 && c > 0 ? 0 : Math.min(Math.abs(y.y), Math.abs(h.y)), N = Math.max($, oe);
524
- r.lastCentrality = (b - N) * (b - N) * (b - N);
528
+ if (this._tempBox.copy(d), this._tempBox.applyMatrix4(t.matrixWorld), this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && c.fov > 70) {
529
+ const m = this._tempBox.min, p = this._tempBox.max;
530
+ let b = m.x, x = m.y, y = p.x, g = p.y;
531
+ const O = 2, P = 1.5, _ = (m.x + p.x) * 0.5, E = (m.y + p.y) * 0.5;
532
+ b = (b - _) * O + _, x = (x - E) * O + E, y = (y - _) * O + _, g = (g - E) * O + E;
533
+ const N = b < 0 && y > 0 ? 0 : Math.min(Math.abs(m.x), Math.abs(p.x)), ne = x < 0 && g > 0 ? 0 : Math.min(Math.abs(m.y), Math.abs(p.y)), K = Math.max(N, ne);
534
+ r.lastCentrality = (P - K) * (P - K) * (P - K);
525
535
  } else
526
536
  r.lastCentrality = 1;
527
- const d = this._tempBox.getSize(this._tempBoxSize);
528
- d.multiplyScalar(0.5), screen.availHeight > 0 && d.multiplyScalar(this.renderer.domElement.clientHeight / screen.availHeight), d.x *= L.aspect;
529
- const w = e.matrixWorldInverse, D = new j();
530
- D.copy(f), D.applyMatrix4(t.matrixWorld), D.applyMatrix4(w);
531
- const A = D.getSize(this._tempBox2Size), E = Math.max(A.x, A.y);
532
- if (Math.max(d.x, d.y) != 0 && E != 0 && (d.z = A.z / Math.max(A.x, A.y) * Math.max(d.x, d.y)), r.lastScreenCoverage = Math.max(d.x, d.y, d.z), r.lastScreenspaceVolume.copy(d), r.lastScreenCoverage *= r.lastCentrality, te && P.debugDrawLine) {
533
- const y = this.tempMatrix.copy(this.projectionScreenMatrix);
534
- y.invert();
535
- const h = P.corner0, T = P.corner1, x = P.corner2, p = P.corner3;
536
- h.copy(this._tempBox.min), T.copy(this._tempBox.max), T.x = h.x, x.copy(this._tempBox.max), x.y = h.y, p.copy(this._tempBox.max);
537
- const c = (h.z + p.z) * 0.5;
538
- h.z = T.z = x.z = p.z = c, h.applyMatrix4(y), T.applyMatrix4(y), x.applyMatrix4(y), p.applyMatrix4(y), P.debugDrawLine(h, T, 255), P.debugDrawLine(h, x, 255), P.debugDrawLine(T, p, 255), P.debugDrawLine(x, p, 255);
537
+ const f = this._tempBox.getSize(this._tempBoxSize);
538
+ f.multiplyScalar(0.5), screen.availHeight > 0 && f.multiplyScalar(this.renderer.domElement.clientHeight / screen.availHeight), f.x *= c.aspect;
539
+ const w = e.matrixWorldInverse, L = new ee();
540
+ L.copy(d), L.applyMatrix4(t.matrixWorld), L.applyMatrix4(w);
541
+ const A = L.getSize(this._tempBox2Size), G = Math.max(A.x, A.y);
542
+ if (Math.max(f.x, f.y) != 0 && G != 0 && (f.z = A.z / Math.max(A.x, A.y) * Math.max(f.x, f.y)), r.lastScreenCoverage = Math.max(f.x, f.y, f.z), r.lastScreenspaceVolume.copy(f), r.lastScreenCoverage *= r.lastCentrality, Y && T.debugDrawLine) {
543
+ const m = this.tempMatrix.copy(this.projectionScreenMatrix);
544
+ m.invert();
545
+ const p = T.corner0, b = T.corner1, x = T.corner2, y = T.corner3;
546
+ p.copy(this._tempBox.min), b.copy(this._tempBox.max), b.x = p.x, x.copy(this._tempBox.max), x.y = p.y, y.copy(this._tempBox.max);
547
+ const g = (p.z + y.z) * 0.5;
548
+ p.z = b.z = x.z = y.z = g, p.applyMatrix4(m), b.applyMatrix4(m), x.applyMatrix4(m), y.applyMatrix4(m), T.debugDrawLine(p, b, 255), T.debugDrawLine(p, x, 255), T.debugDrawLine(b, y, 255), T.debugDrawLine(x, y, 255);
539
549
  }
540
- let B = 999;
541
- if (g && r.lastScreenCoverage > 0) {
542
- for (let y = 0; y < g.length; y++)
543
- if (g[y].density / r.lastScreenCoverage < i) {
544
- B = y;
550
+ let C = 999;
551
+ if (h && r.lastScreenCoverage > 0) {
552
+ for (let m = 0; m < h.length; m++)
553
+ if (h[m].density / r.lastScreenCoverage < i) {
554
+ C = m;
545
555
  break;
546
556
  }
547
557
  }
548
- B < s && (s = B);
558
+ C < s && (s = C);
549
559
  }
550
560
  }
551
561
  return s;
552
562
  }
553
563
  };
554
- let k = P;
564
+ let B = T;
555
565
  /** 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.
556
566
  */
557
- u(k, "debugDrawLine"), u(k, "corner0", new C()), u(k, "corner1", new C()), u(k, "corner2", new C()), u(k, "corner3", new C());
567
+ u(B, "debugDrawLine"), u(B, "corner0", new k()), u(B, "corner1", new k()), u(B, "corner2", new k()), u(B, "corner3", new k());
558
568
  class Oe {
559
569
  constructor() {
560
570
  u(this, "lastLodLevel", 0);
561
571
  u(this, "lastScreenCoverage", 0);
562
- u(this, "lastScreenspaceVolume", new C());
572
+ u(this, "lastScreenspaceVolume", new k());
563
573
  u(this, "lastCentrality", 0);
564
574
  }
565
575
  }
566
- const re = Symbol("NEEDLE_mesh_lod"), K = Symbol("NEEDLE_texture_lod");
567
- function ve(l) {
576
+ const re = Symbol("NEEDLE_mesh_lod"), $ = Symbol("NEEDLE_texture_lod");
577
+ function Me(l) {
568
578
  if (!l)
569
579
  return null;
570
580
  let e = null, t = null;
571
581
  for (let r = l; r != null; r = Object.getPrototypeOf(r)) {
572
- const i = Object.getOwnPropertySymbols(r), o = i.find((n) => n.toString() == "Symbol(renderer)"), s = i.find((n) => n.toString() == "Symbol(scene)");
573
- !e && o != null && (e = l[o].threeRenderer), !t && s != null && (t = l[s]);
582
+ const i = Object.getOwnPropertySymbols(r), n = i.find((o) => o.toString() == "Symbol(renderer)"), s = i.find((o) => o.toString() == "Symbol(scene)");
583
+ !e && n != null && (e = l[n].threeRenderer), !t && s != null && (t = l[s]);
574
584
  }
575
585
  if (e) {
576
586
  console.log("Adding Needle LODs to modelviewer");
577
- const r = new k(e);
578
- if (r.plugins.push(new Me(l)), r.enable(), t) {
579
- const i = t.camera || t.traverse((o) => o.type == "PerspectiveCamera")[0];
587
+ const r = new B(e);
588
+ if (r.plugins.push(new ve(l)), r.enable(), t) {
589
+ const i = t.camera || t.traverse((n) => n.type == "PerspectiveCamera")[0];
580
590
  i && e.render(t, i);
581
591
  }
582
592
  return () => {
@@ -585,85 +595,81 @@ function ve(l) {
585
595
  }
586
596
  return null;
587
597
  }
588
- class Me {
598
+ class ve {
589
599
  constructor(e) {
590
600
  u(this, "modelviewer");
601
+ u(this, "_didWarnAboutMissingUrl", !1);
591
602
  this.modelviewer = e;
592
603
  }
593
604
  onBeforeUpdateLOD(e, t, r, i) {
594
605
  this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
595
606
  }
596
607
  getUrl() {
597
- return this.modelviewer.getAttribute("src");
608
+ let e = this.modelviewer.getAttribute("src");
609
+ return e || (e = this.modelviewer.src), e || (this._didWarnAboutMissingUrl || console.warn("No url found in modelviewer", this.modelviewer), this._didWarnAboutMissingUrl = !0), e;
598
610
  }
599
611
  tryGetCurrentGLTF(e) {
600
612
  return e._currentGLTF;
601
613
  }
602
614
  tryParseTextureLOD(e, t) {
603
- if (t[K] == !0)
615
+ if (t[$] == !0)
604
616
  return;
605
- t[K] = !0;
617
+ t[$] = !0;
606
618
  const r = this.tryGetCurrentGLTF(e), i = this.getUrl();
607
- if (!i) {
608
- console.error("No url found in modelviewer");
609
- return;
610
- }
611
- if (r && t.material) {
612
- let o = function(n) {
613
- var g, f, L;
614
- if (n[K] == !0)
619
+ if (i && r && t.material) {
620
+ let n = function(o) {
621
+ var h, d, c;
622
+ if (o[$] == !0)
615
623
  return;
616
- n[K] = !0, n.userData && (n.userData.LOD = -1);
617
- const a = Object.keys(n);
618
- for (let d = 0; d < a.length; d++) {
619
- const w = a[d], D = n[w];
620
- if ((D == null ? void 0 : D.isTexture) === !0) {
621
- const A = (f = (g = D.userData) == null ? void 0 : g.associations) == null ? void 0 : f.textures, E = r.parser.json.textures[A];
622
- if ((L = E.extensions) != null && L[R]) {
623
- const m = E.extensions[R];
624
- m && i && M.registerTexture(i, D, m.lods.length, m);
624
+ o[$] = !0, o.userData && (o.userData.LOD = -1);
625
+ const a = Object.keys(o);
626
+ for (let f = 0; f < a.length; f++) {
627
+ const w = a[f], L = o[w];
628
+ if ((L == null ? void 0 : L.isTexture) === !0) {
629
+ const A = (d = (h = L.userData) == null ? void 0 : h.associations) == null ? void 0 : d.textures, G = r.parser.json.textures[A];
630
+ if ((c = G.extensions) != null && c[R]) {
631
+ const D = G.extensions[R];
632
+ D && i && v.registerTexture(i, L, D.lods.length, D);
625
633
  }
626
634
  }
627
635
  }
628
636
  };
629
637
  const s = t.material;
630
638
  if (Array.isArray(s))
631
- for (const n of s)
632
- o(n);
639
+ for (const o of s)
640
+ n(o);
633
641
  else
634
- o(s);
642
+ n(s);
635
643
  }
636
644
  }
637
645
  tryParseMeshLOD(e, t) {
638
- var o, s;
646
+ var n, s;
639
647
  if (t[re] == !0)
640
648
  return;
641
649
  t[re] = !0;
642
650
  const r = this.getUrl();
643
- if (!r) {
644
- console.error("No url found in modelviewer");
651
+ if (!r)
645
652
  return;
646
- }
647
- const i = (s = (o = t.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : s[R];
653
+ const i = (s = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : s[R];
648
654
  if (i && r) {
649
- const n = t.uuid;
650
- M.registerMesh(r, n, t, 0, i.lods.length, i);
655
+ const o = t.uuid;
656
+ v.registerMesh(r, o, t, 0, i.lods.length, i);
651
657
  }
652
658
  }
653
659
  }
654
- function Be(l, e, t, r) {
655
- se(e), ie(t), t.register((o) => new M(o, l));
656
- const i = new k(e);
660
+ function Ce(l, e, t, r) {
661
+ se(e), ie(t), t.register((n) => new v(n, l));
662
+ const i = new B(e);
657
663
  return (r == null ? void 0 : r.enableLODsManager) !== !1 && i.enable(), i;
658
664
  }
659
665
  document.addEventListener("DOMContentLoaded", () => {
660
- ve(document.querySelector("model-viewer"));
666
+ Me(document.querySelector("model-viewer"));
661
667
  });
662
668
  export {
663
669
  R as EXTENSION_NAME,
664
- k as LODsManager,
665
- M as NEEDLE_progressive,
666
- ve as patchModelViewer,
667
- ke as registerPlugin,
668
- Be as useNeedleProgressive
670
+ B as LODsManager,
671
+ v as NEEDLE_progressive,
672
+ Me as patchModelViewer,
673
+ Be as registerPlugin,
674
+ Ce as useNeedleProgressive
669
675
  };