@needle-tools/gltf-progressive 1.1.0-alpha.1 → 1.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  var ge = Object.defineProperty;
2
2
  var pe = (a, e, t) => e in a ? ge(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var f = (a, e, t) => (pe(a, typeof e != "symbol" ? e + "" : e, t), t);
3
+ var u = (a, e, t) => (pe(a, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import { MeshoptDecoder as ye } from "three/examples/jsm/libs/meshopt_decoder.module.js";
5
5
  import { DRACOLoader as me } from "three/examples/jsm/loaders/DRACOLoader.js";
6
6
  import { KTX2Loader as Le } from "three/examples/jsm/loaders/KTX2Loader.js";
@@ -17,10 +17,10 @@ function Ne(a) {
17
17
  se = a;
18
18
  }
19
19
  let z, te, W;
20
- function fe(a) {
20
+ function ce(a) {
21
21
  z || (z = new me(), z.setDecoderPath(H), z.setDecoderConfig({ type: "js" })), W || (W = new Le(), W.setTranscoderPath(se)), te || (te = ye), a ? W.detectSupport(a) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
22
22
  }
23
- function ue(a) {
23
+ function fe(a) {
24
24
  a.dracoLoader || a.setDRACOLoader(z), a.ktx2Loader || a.setKTX2Loader(W), a.meshoptDecoder || a.setMeshoptDecoder(te);
25
25
  }
26
26
  function ie(a) {
@@ -39,52 +39,60 @@ function ve(a, e) {
39
39
  }
40
40
  return e;
41
41
  }
42
- function Se(a) {
42
+ function _e(a) {
43
43
  var e;
44
44
  return ((e = a.userData) == null ? void 0 : e["needle:raycast-mesh"]) instanceof Y ? a.userData["needle:raycast-mesh"] : null;
45
45
  }
46
- function _e(a, e) {
46
+ function Se(a, e) {
47
47
  (a.type === "Mesh" || a.type === "SkinnedMesh") && (a.userData || (a.userData = {}), a.userData["needle:raycast-mesh"] = e);
48
48
  }
49
- const B = new Array(), R = "NEEDLE_progressive", w = ie("debugprogressive"), j = Symbol("needle-progressive-texture"), $ = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Set();
50
- if (w) {
49
+ const R = new Array(), B = "NEEDLE_progressive", v = ie("debugprogressive"), j = Symbol("needle-progressive-texture"), $ = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Set();
50
+ if (v) {
51
51
  let a = function() {
52
- e += 1, console.log("Toggle LOD level", e, $), $.forEach((i, n) => {
53
- for (const s of i.keys) {
54
- const o = n[s];
52
+ e += 1, console.log("Toggle LOD level", e, $), $.forEach((s, n) => {
53
+ for (const i of s.keys) {
54
+ const o = n[i];
55
55
  if (o.isBufferGeometry === !0) {
56
- const l = S.getMeshLODInformation(o), d = l ? Math.min(e, l.lods.length) : 0;
57
- n["DEBUG:LOD"] = e, S.assignMeshLOD(n, d), l && (t = Math.max(t, l.lods.length - 1));
56
+ const l = _.getMeshLODInformation(o), d = l ? Math.min(e, l.lods.length) : 0;
57
+ n["DEBUG:LOD"] = e, _.assignMeshLOD(n, d), l && (t = Math.max(t, l.lods.length - 1));
58
58
  } else if (n.isMaterial === !0) {
59
- n["DEBUG:LOD"] = e, S.assignTextureLOD(n, e);
59
+ n["DEBUG:LOD"] = e, _.assignTextureLOD(n, e);
60
60
  break;
61
61
  }
62
62
  }
63
63
  }), e >= t && (e = -1);
64
64
  }, e = -1, t = 2, r = !1;
65
- window.addEventListener("keyup", (i) => {
66
- i.key === "p" && a(), i.key === "w" && (r = !r, re && re.forEach((n) => {
65
+ window.addEventListener("keyup", (s) => {
66
+ s.key === "p" && a(), s.key === "w" && (r = !r, re && re.forEach((n) => {
67
67
  n.name != "BackgroundCubeMaterial" && "wireframe" in n && (n.wireframe = r);
68
68
  }));
69
69
  });
70
70
  }
71
71
  function ae(a, e, t) {
72
- var i;
73
- if (!w)
72
+ var s;
73
+ if (!v)
74
74
  return;
75
75
  $.has(a) || $.set(a, { keys: [], sourceId: t });
76
76
  const r = $.get(a);
77
- ((i = r == null ? void 0 : r.keys) == null ? void 0 : i.includes(e)) == !1 && r.keys.push(e);
77
+ ((s = r == null ? void 0 : r.keys) == null ? void 0 : s.includes(e)) == !1 && r.keys.push(e);
78
78
  }
79
- const v = class {
79
+ const w = class {
80
80
  constructor(e, t) {
81
- f(this, "parser");
82
- f(this, "url");
83
- w && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
81
+ u(this, "parser");
82
+ u(this, "url");
83
+ u(this, "_isLoadingMesh");
84
+ u(this, "loadMesh", (e) => {
85
+ var r, s;
86
+ if (this._isLoadingMesh)
87
+ return null;
88
+ const t = (s = (r = this.parser.json.meshes[e]) == null ? void 0 : r.extensions) == null ? void 0 : s[B];
89
+ return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((n) => (this._isLoadingMesh = !1, n && w.registerMesh(this.url, t.guid, n, t.lods.length, void 0, t), n))) : null;
90
+ });
91
+ v && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
84
92
  }
85
93
  /** The name of the extension */
86
94
  get name() {
87
- return R;
95
+ return B;
88
96
  }
89
97
  static getMeshLODInformation(e) {
90
98
  const t = this.getAssignedLODInformation(e);
@@ -96,31 +104,31 @@ const v = class {
96
104
  this.getMaterialMinMaxLODsCount(n, t);
97
105
  return t;
98
106
  }
99
- let r = t.min, i = t.max;
107
+ let r = t.min, s = t.max;
100
108
  if (e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
101
109
  const n = e;
102
- for (const s of Object.keys(n.uniforms)) {
103
- const o = n.uniforms[s].value;
110
+ for (const i of Object.keys(n.uniforms)) {
111
+ const o = n.uniforms[i].value;
104
112
  if ((o == null ? void 0 : o.isTexture) === !0) {
105
113
  const l = this.getAssignedLODInformation(o);
106
114
  if (l) {
107
115
  const d = this.lodInfos.get(l.key);
108
- d && d.lods && (r = Math.min(r, d.lods.length), i = Math.max(i, d.lods.length));
116
+ d && d.lods && (r = Math.min(r, d.lods.length), s = Math.max(s, d.lods.length));
109
117
  }
110
118
  }
111
119
  }
112
120
  } else if (e.isMaterial)
113
121
  for (const n of Object.keys(e)) {
114
- const s = e[n];
115
- if ((s == null ? void 0 : s.isTexture) === !0) {
116
- const o = this.getAssignedLODInformation(s);
122
+ const i = e[n];
123
+ if ((i == null ? void 0 : i.isTexture) === !0) {
124
+ const o = this.getAssignedLODInformation(i);
117
125
  if (o) {
118
126
  const l = this.lodInfos.get(o.key);
119
- l && l.lods && (r = Math.min(r, l.lods.length), i = Math.max(i, l.lods.length));
127
+ l && l.lods && (r = Math.min(r, l.lods.length), s = Math.max(s, l.lods.length));
120
128
  }
121
129
  }
122
130
  }
123
- return t.min = r, t.max = i, t;
131
+ return t.min = r, t.max = s, t;
124
132
  }
125
133
  /** Check if a LOD level is available for a mesh or a texture
126
134
  * @param obj the mesh or texture to check
@@ -130,30 +138,30 @@ const v = class {
130
138
  static hasLODLevelAvailable(e, t) {
131
139
  var n;
132
140
  if (Array.isArray(e)) {
133
- for (const s of e)
134
- if (this.hasLODLevelAvailable(s, t))
141
+ for (const i of e)
142
+ if (this.hasLODLevelAvailable(i, t))
135
143
  return !0;
136
144
  return !1;
137
145
  }
138
146
  if (e.isMaterial === !0) {
139
- for (const s of Object.keys(e)) {
140
- const o = e[s];
147
+ for (const i of Object.keys(e)) {
148
+ const o = e[i];
141
149
  if (o && o.isTexture && this.hasLODLevelAvailable(o, t))
142
150
  return !0;
143
151
  }
144
152
  return !1;
145
153
  } else if (e.isGroup === !0) {
146
- for (const s of e.children)
147
- if (s.isMesh === !0 && this.hasLODLevelAvailable(s, t))
154
+ for (const i of e.children)
155
+ if (i.isMesh === !0 && this.hasLODLevelAvailable(i, t))
148
156
  return !0;
149
157
  }
150
- let r, i;
158
+ let r, s;
151
159
  if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (n = r == null ? void 0 : r.userData) != null && n.LODS) {
152
- const s = r.userData.LODS;
153
- if (i = this.lodInfos.get(s.key), t === void 0)
154
- return i != null;
155
- if (i)
156
- return Array.isArray(i.lods) ? t < i.lods.length : t === 0;
160
+ const i = r.userData.LODS;
161
+ if (s = this.lodInfos.get(i.key), t === void 0)
162
+ return s != null;
163
+ if (s)
164
+ return Array.isArray(s.lods) ? t < s.lods.length : t === 0;
157
165
  }
158
166
  return !1;
159
167
  }
@@ -176,23 +184,23 @@ const v = class {
176
184
  if (!e)
177
185
  return Promise.resolve(null);
178
186
  if (e instanceof V || e.isMesh === !0) {
179
- const i = e.geometry, n = this.getAssignedLODInformation(i);
187
+ const s = e.geometry, n = this.getAssignedLODInformation(s);
180
188
  if (!n)
181
189
  return Promise.resolve(null);
182
- for (const s of B)
183
- (r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
184
- return e["LOD:requested level"] = t, v.getOrLoadLOD(i, t).then((s) => {
190
+ for (const i of R)
191
+ (r = i.onBeforeGetLODMesh) == null || r.call(i, e, t);
192
+ return e["LOD:requested level"] = t, w.getOrLoadLOD(s, t).then((i) => {
185
193
  if (e["LOD:requested level"] === t) {
186
- if (delete e["LOD:requested level"], Array.isArray(s)) {
194
+ if (delete e["LOD:requested level"], Array.isArray(i)) {
187
195
  const o = n.index || 0;
188
- s = s[o];
196
+ i = i[o];
189
197
  }
190
- s && i != s && s instanceof Y && (e.geometry = s, w && ae(e, "geometry", n.url));
198
+ i && s != i && i instanceof Y && (e.geometry = i, v && ae(e, "geometry", n.url));
191
199
  }
192
- return s;
193
- }).catch((s) => (console.error("Error loading mesh LOD", e, s), null));
200
+ return i;
201
+ }).catch((i) => (console.error("Error loading mesh LOD", e, i), null));
194
202
  } else
195
- w && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
203
+ v && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
196
204
  return Promise.resolve(null);
197
205
  }
198
206
  /** Load a different resolution of a texture (if available)
@@ -206,28 +214,28 @@ const v = class {
206
214
  if (!e)
207
215
  return Promise.resolve(null);
208
216
  if (e instanceof xe || e.isMaterial === !0) {
209
- const r = e, i = [], n = new Array();
210
- if (w && re.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
211
- const s = r;
212
- for (const o of Object.keys(s.uniforms)) {
213
- const l = s.uniforms[o].value;
217
+ const r = e, s = [], n = new Array();
218
+ if (v && re.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
219
+ const i = r;
220
+ for (const o of Object.keys(i.uniforms)) {
221
+ const l = i.uniforms[o].value;
214
222
  if ((l == null ? void 0 : l.isTexture) === !0) {
215
223
  const d = this.assignTextureLODForSlot(l, t, r, o);
216
- i.push(d), n.push(o);
224
+ s.push(d), n.push(o);
217
225
  }
218
226
  }
219
227
  } else
220
- for (const s of Object.keys(r)) {
221
- const o = r[s];
228
+ for (const i of Object.keys(r)) {
229
+ const o = r[i];
222
230
  if ((o == null ? void 0 : o.isTexture) === !0) {
223
- const l = this.assignTextureLODForSlot(o, t, r, s);
224
- i.push(l), n.push(s);
231
+ const l = this.assignTextureLODForSlot(o, t, r, i);
232
+ s.push(l), n.push(i);
225
233
  }
226
234
  }
227
- return Promise.all(i).then((s) => {
235
+ return Promise.all(s).then((i) => {
228
236
  const o = new Array();
229
- for (let l = 0; l < s.length; l++) {
230
- const d = s[l], h = n[l];
237
+ for (let l = 0; l < i.length; l++) {
238
+ const d = i[l], h = n[l];
231
239
  d && d.isTexture === !0 ? o.push({ material: r, slot: h, texture: d, level: t }) : o.push({ material: r, slot: h, texture: null, level: t });
232
240
  }
233
241
  return o;
@@ -239,48 +247,48 @@ const v = class {
239
247
  }
240
248
  return Promise.resolve(null);
241
249
  }
242
- static assignTextureLODForSlot(e, t, r, i) {
250
+ static assignTextureLODForSlot(e, t, r, s) {
243
251
  if ((e == null ? void 0 : e.isTexture) !== !0)
244
252
  return Promise.resolve(null);
245
- if (i === "glyphMap")
253
+ if (s === "glyphMap")
246
254
  return Promise.resolve(e);
247
- const n = "LOD:requested level:" + i;
248
- return r && (r[n] = t), v.getOrLoadLOD(e, t).then((s) => {
249
- if (r && r[n] != t || Array.isArray(s))
255
+ const n = "LOD:requested level:" + s;
256
+ return r && (r[n] = t), w.getOrLoadLOD(e, t).then((i) => {
257
+ if (r && r[n] != t || Array.isArray(i))
250
258
  return null;
251
- if ((s == null ? void 0 : s.isTexture) === !0) {
252
- if (s != e && (r && i && (r[i] = s), w && i && r)) {
259
+ if ((i == null ? void 0 : i.isTexture) === !0) {
260
+ if (i != e && (r && s && (r[s] = i), v && s && r)) {
253
261
  const o = this.getAssignedLODInformation(e);
254
- o && ae(r, i, o.url);
262
+ o && ae(r, s, o.url);
255
263
  }
256
- return s;
264
+ return i;
257
265
  } else
258
- w == "verbose" && console.warn("No LOD found for", e, t);
266
+ v == "verbose" && console.warn("No LOD found for", e, t);
259
267
  return null;
260
- }).catch((s) => (console.error("Error loading LOD", e, s), null));
268
+ }).catch((i) => (console.error("Error loading LOD", e, i), null));
261
269
  }
262
270
  afterRoot(e) {
263
271
  var t, r;
264
- return w && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
265
- if (i != null && i.extensions) {
266
- const s = i == null ? void 0 : i.extensions[R];
267
- if (s) {
272
+ return v && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((s, n) => {
273
+ if (s != null && s.extensions) {
274
+ const i = s == null ? void 0 : s.extensions[B];
275
+ if (i) {
268
276
  let o = !1;
269
277
  for (const l of this.parser.associations.keys())
270
- l.isTexture === !0 && this.parser.associations.get(l).textures === n && (o = !0, v.registerTexture(this.url, l, n, s));
278
+ l.isTexture === !0 && this.parser.associations.get(l).textures === n && (o = !0, w.registerTexture(this.url, l, n, i));
271
279
  o || this.parser.getDependency("texture", n).then((l) => {
272
- l && v.registerTexture(this.url, l, n, s);
280
+ l && w.registerTexture(this.url, l, n, i);
273
281
  });
274
282
  }
275
283
  }
276
- }), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
277
- if (i != null && i.extensions) {
278
- const s = i == null ? void 0 : i.extensions[R];
279
- if (s && s.lods) {
284
+ }), (r = this.parser.json.meshes) == null || r.forEach((s, n) => {
285
+ if (s != null && s.extensions) {
286
+ const i = s == null ? void 0 : s.extensions[B];
287
+ if (i && i.lods) {
280
288
  for (const o of this.parser.associations.keys())
281
289
  if (o.isMesh) {
282
290
  const l = this.parser.associations.get(o);
283
- l.meshes === n && v.registerMesh(this.url, s.guid, o, s.lods.length, l.primitives, s);
291
+ l.meshes === n && w.registerMesh(this.url, i.guid, o, i.lods.length, l.primitives, i);
284
292
  }
285
293
  }
286
294
  }
@@ -288,57 +296,57 @@ const v = class {
288
296
  }
289
297
  static async getOrLoadLOD(e, t) {
290
298
  var o, l, d, h;
291
- const r = w == "verbose", i = e.userData.LODS;
292
- if (!i)
299
+ const r = v == "verbose", s = e.userData.LODS;
300
+ if (!s)
293
301
  return null;
294
- const n = i == null ? void 0 : i.key;
295
- let s;
302
+ const n = s == null ? void 0 : s.key;
303
+ let i;
296
304
  if (e.isTexture === !0) {
297
305
  const m = e;
298
- m.source && m.source[j] && (s = m.source[j]);
306
+ m.source && m.source[j] && (i = m.source[j]);
299
307
  }
300
- if (s || (s = v.lodInfos.get(n)), s) {
308
+ if (i || (i = w.lodInfos.get(n)), i) {
301
309
  if (t > 0) {
302
310
  let y = !1;
303
- const x = Array.isArray(s.lods);
304
- if (x && t >= s.lods.length ? y = !0 : x || (y = !0), y)
311
+ const x = Array.isArray(i.lods);
312
+ if (x && t >= i.lods.length ? y = !0 : x || (y = !0), y)
305
313
  return this.lowresCache.get(n);
306
314
  }
307
- const m = Array.isArray(s.lods) ? (o = s.lods[t]) == null ? void 0 : o.path : s.lods;
315
+ const m = Array.isArray(i.lods) ? (o = i.lods[t]) == null ? void 0 : o.path : i.lods;
308
316
  if (!m)
309
- return w && !s["missing:uri"] && (s["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, s)), null;
310
- const u = ve(i.url, m);
311
- if (u.endsWith(".glb") || u.endsWith(".gltf")) {
312
- if (!s.guid)
313
- return console.warn("missing pointer for glb/gltf texture", s), null;
314
- const y = u + "_" + s.guid, x = this.previouslyLoaded.get(y);
317
+ return v && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, i)), null;
318
+ const f = ve(s.url, m);
319
+ if (f.endsWith(".glb") || f.endsWith(".gltf")) {
320
+ if (!i.guid)
321
+ return console.warn("missing pointer for glb/gltf texture", i), null;
322
+ const y = f + "_" + i.guid, x = this.previouslyLoaded.get(y);
315
323
  if (x !== void 0) {
316
324
  r && console.log(`LOD ${t} was already loading/loaded: ${y}`);
317
- let O = await x.catch((F) => (console.error(`Error loading LOD ${t} from ${u}
325
+ let O = await x.catch((F) => (console.error(`Error loading LOD ${t} from ${f}
318
326
  `, F), null)), P = !1;
319
327
  if (O == null || (O instanceof N && e instanceof N ? (l = O.image) != null && l.data || (d = O.source) != null && d.data ? O = this.copySettings(e, O) : (P = !0, this.previouslyLoaded.delete(y)) : O instanceof Y && e instanceof Y && ((h = O.attributes.position) != null && h.array || (P = !0, this.previouslyLoaded.delete(y)))), !P)
320
328
  return O;
321
329
  }
322
- const M = s, D = new Promise(async (O, P) => {
330
+ const M = i, D = new Promise(async (O, P) => {
323
331
  const F = new we();
324
- ue(F), w && (await new Promise((g) => setTimeout(g, 1e3)), r && console.warn("Start loading (delayed) " + u, M.guid));
325
- let J = u;
332
+ fe(F), v && (await new Promise((g) => setTimeout(g, 1e3)), r && console.warn("Start loading (delayed) " + f, M.guid));
333
+ let J = f;
326
334
  if (M && Array.isArray(M.lods)) {
327
335
  const g = M.lods[t];
328
336
  g.hash && (J += "?v=" + g.hash);
329
337
  }
330
- const E = await F.loadAsync(J).catch((g) => (console.error(`Error loading LOD ${t} from ${u}
338
+ const E = await F.loadAsync(J).catch((g) => (console.error(`Error loading LOD ${t} from ${f}
331
339
  `, g), null));
332
340
  if (!E)
333
341
  return null;
334
342
  const Q = E.parser;
335
- r && console.log("Loading finished " + u, M.guid);
343
+ r && console.log("Loading finished " + f, M.guid);
336
344
  let p = 0;
337
345
  if (E.parser.json.textures) {
338
346
  let g = !1;
339
347
  for (const c of E.parser.json.textures) {
340
348
  if (c != null && c.extensions) {
341
- const L = c == null ? void 0 : c.extensions[R];
349
+ const L = c == null ? void 0 : c.extensions[B];
342
350
  if (L != null && L.guid && L.guid === M.guid) {
343
351
  g = !0;
344
352
  break;
@@ -348,15 +356,15 @@ const v = class {
348
356
  }
349
357
  if (g) {
350
358
  let c = await Q.getDependency("texture", p);
351
- return c && v.assignLODInformation(i.url, c, n, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + c.name + '"', u, p, c, y), e instanceof N && (c = this.copySettings(e, c)), c && (c.guid = M.guid), O(c);
359
+ return c && w.assignLODInformation(s.url, c, n, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + c.name + '"', f, p, c, y), e instanceof N && (c = this.copySettings(e, c)), c && (c.guid = M.guid), O(c);
352
360
  } else
353
- w && console.warn("Could not find texture with guid", M.guid);
361
+ v && console.warn("Could not find texture with guid", M.guid);
354
362
  }
355
363
  if (p = 0, E.parser.json.meshes) {
356
364
  let g = !1;
357
365
  for (const c of E.parser.json.meshes) {
358
366
  if (c != null && c.extensions) {
359
- const L = c == null ? void 0 : c.extensions[R];
367
+ const L = c == null ? void 0 : c.extensions[B];
360
368
  if (L != null && L.guid && L.guid === M.guid) {
361
369
  g = !0;
362
370
  break;
@@ -366,19 +374,19 @@ const v = class {
366
374
  }
367
375
  if (g) {
368
376
  const c = await Q.getDependency("mesh", p), L = M;
369
- if (r && console.log(`Loaded Mesh "${c.name}"`, u, p, c, y), c.isMesh === !0) {
370
- const _ = c.geometry;
371
- return v.assignLODInformation(i.url, _, n, t, void 0, L.density), O(_);
377
+ if (r && console.log(`Loaded Mesh "${c.name}"`, f, p, c, y), c.isMesh === !0) {
378
+ const S = c.geometry;
379
+ return w.assignLODInformation(s.url, S, n, t, void 0, L.density), O(S);
372
380
  } else {
373
- const _ = new Array();
381
+ const S = new Array();
374
382
  for (let C = 0; C < c.children.length; C++) {
375
383
  const I = c.children[C];
376
384
  if (I instanceof V) {
377
385
  const U = I.geometry;
378
- v.assignLODInformation(i.url, U, n, t, C, L.density), _.push(U);
386
+ w.assignLODInformation(s.url, U, n, t, C, L.density), S.push(U);
379
387
  }
380
388
  }
381
- return O(_);
389
+ return O(S);
382
390
  }
383
391
  }
384
392
  }
@@ -386,20 +394,20 @@ const v = class {
386
394
  });
387
395
  return this.previouslyLoaded.set(y, D), await D;
388
396
  } else if (e instanceof N) {
389
- r && console.log("Load texture from uri: " + u);
390
- const x = await new De().loadAsync(u);
391
- return x ? (x.guid = s.guid, x.flipY = !1, x.needsUpdate = !0, x.colorSpace = e.colorSpace, r && console.log(s, x)) : w && console.warn("failed loading", u), x;
397
+ r && console.log("Load texture from uri: " + f);
398
+ const x = await new De().loadAsync(f);
399
+ return x ? (x.guid = i.guid, x.flipY = !1, x.needsUpdate = !0, x.colorSpace = e.colorSpace, r && console.log(i, x)) : v && console.warn("failed loading", f), x;
392
400
  }
393
401
  } else
394
- w && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
402
+ v && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
395
403
  return null;
396
404
  }
397
- static assignLODInformation(e, t, r, i, n, s) {
405
+ static assignLODInformation(e, t, r, s, n, i) {
398
406
  if (!t)
399
407
  return;
400
408
  t.userData || (t.userData = {});
401
- const o = new Te(e, r, i, n, s);
402
- t.userData.LODS = o, t.userData.LOD = i;
409
+ const o = new Te(e, r, s, n, i);
410
+ t.userData.LODS = o, t.userData.LOD = s;
403
411
  }
404
412
  static getAssignedLODInformation(e) {
405
413
  var t;
@@ -407,77 +415,77 @@ const v = class {
407
415
  }
408
416
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
409
417
  static copySettings(e, t) {
410
- return t = t.clone(), w && console.warn(`Copying texture settings
418
+ return t = t.clone(), v && console.warn(`Copying texture settings
411
419
  `, e.uuid, `
412
420
  `, 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;
413
421
  }
414
422
  };
415
- let S = v;
423
+ let _ = w;
416
424
  /**
417
425
  * Register a texture with LOD information
418
426
  */
419
- f(S, "registerTexture", (e, t, r, i) => {
420
- w && console.log("> Progressive: register texture", r, t.name, t.uuid, t, i), t.source && (t.source[j] = i);
421
- const n = i.guid;
422
- v.assignLODInformation(e, t, n, 0, 0, void 0), v.lodInfos.set(n, i), v.lowresCache.set(n, t);
427
+ u(_, "registerTexture", (e, t, r, s) => {
428
+ v && console.log("> Progressive: register texture", r, t.name, t.uuid, t, s), t.source && (t.source[j] = s);
429
+ const n = s.guid;
430
+ w.assignLODInformation(e, t, n, 0, 0, void 0), w.lodInfos.set(n, s), w.lowresCache.set(n, t);
423
431
  }), /**
424
432
  * Register a mesh with LOD information
425
433
  */
426
- f(S, "registerMesh", (e, t, r, i, n, s) => {
434
+ u(_, "registerMesh", (e, t, r, s, n, i) => {
427
435
  var d;
428
- w && console.log("> Progressive: register mesh", n, r.name, s, r.uuid, r);
436
+ v && console.log("> Progressive: register mesh", n, r.name, i, r.uuid, r);
429
437
  const o = r.geometry;
430
- o.userData || (o.userData = {}), v.assignLODInformation(e, o, t, i, n, s.density), v.lodInfos.set(t, s);
431
- let l = v.lowresCache.get(t);
432
- l ? l.push(r.geometry) : l = [r.geometry], v.lowresCache.set(t, l), i > 0 && !Se(r) && _e(r, o);
433
- for (const h of B)
434
- (d = h.onRegisteredNewMesh) == null || d.call(h, r, s);
438
+ o.userData || (o.userData = {}), w.assignLODInformation(e, o, t, s, n, i.density), w.lodInfos.set(t, i);
439
+ let l = w.lowresCache.get(t);
440
+ l ? l.push(r.geometry) : l = [r.geometry], w.lowresCache.set(t, l), s > 0 && !_e(r) && Se(r, o);
441
+ for (const h of R)
442
+ (d = h.onRegisteredNewMesh) == null || d.call(h, r, i);
435
443
  }), /** A map of key = asset uuid and value = LOD information */
436
- f(S, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
437
- f(S, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
438
- f(S, "lowresCache", /* @__PURE__ */ new Map());
444
+ u(_, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
445
+ u(_, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
446
+ u(_, "lowresCache", /* @__PURE__ */ new Map());
439
447
  class Te {
440
- constructor(e, t, r, i, n) {
441
- f(this, "url");
448
+ constructor(e, t, r, s, n) {
449
+ u(this, "url");
442
450
  /** the key to lookup the LOD information */
443
- f(this, "key");
444
- f(this, "level");
451
+ u(this, "key");
452
+ u(this, "level");
445
453
  /** For multi objects (e.g. a group of meshes) this is the index of the object */
446
- f(this, "index");
454
+ u(this, "index");
447
455
  /** the mesh density */
448
- f(this, "density");
449
- this.url = e, this.key = t, this.level = r, i != null && (this.index = i), n != null && (this.density = n);
456
+ u(this, "density");
457
+ this.url = e, this.key = t, this.level = r, s != null && (this.index = s), n != null && (this.density = n);
450
458
  }
451
459
  }
452
460
  const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle:LODSManager"), A = { mesh_lod: -1, texture_lod: -1 }, T = class {
453
461
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
454
462
  constructor(e) {
455
- f(this, "renderer");
456
- f(this, "projectionScreenMatrix", new ne());
457
- f(this, "cameraFrustrum", new Me());
463
+ u(this, "renderer");
464
+ u(this, "projectionScreenMatrix", new ne());
465
+ u(this, "cameraFrustrum", new Me());
458
466
  /**
459
467
  * The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
460
468
  * @default 200_000
461
469
  */
462
- f(this, "targetTriangleDensity", 2e5);
470
+ u(this, "targetTriangleDensity", 2e5);
463
471
  /**
464
472
  * 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.
465
473
  */
466
- f(this, "updateInterval", 0);
474
+ u(this, "updateInterval", 0);
467
475
  /**
468
476
  * If set to true, the LODsManager will not update the LODs.
469
477
  */
470
- f(this, "pause", !1);
471
- f(this, "_frame", 0);
472
- f(this, "_originalRender");
478
+ u(this, "pause", !1);
479
+ u(this, "_frame", 0);
480
+ u(this, "_originalRender");
473
481
  // private testIfLODLevelsAreAvailable() {
474
- f(this, "_sphere", new Oe());
475
- f(this, "_tempBox", new oe());
476
- f(this, "_tempBox2", new oe());
477
- f(this, "tempMatrix", new ne());
478
- f(this, "_tempWorldPosition", new k());
479
- f(this, "_tempBoxSize", new k());
480
- f(this, "_tempBox2Size", new k());
482
+ u(this, "_sphere", new Oe());
483
+ u(this, "_tempBox", new oe());
484
+ u(this, "_tempBox2", new oe());
485
+ u(this, "tempMatrix", new ne());
486
+ u(this, "_tempWorldPosition", new k());
487
+ u(this, "_tempBoxSize", new k());
488
+ u(this, "_tempBox2Size", new k());
481
489
  this.renderer = e;
482
490
  }
483
491
  /** @internal */
@@ -486,11 +494,11 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
486
494
  return (t = e.userData) == null ? void 0 : t.LOD_state;
487
495
  }
488
496
  static addPlugin(e) {
489
- B.push(e);
497
+ R.push(e);
490
498
  }
491
499
  static removePlugin(e) {
492
- const t = B.indexOf(e);
493
- t >= 0 && B.splice(t, 1);
500
+ const t = R.indexOf(e);
501
+ t >= 0 && R.splice(t, 1);
494
502
  }
495
503
  /**
496
504
  * Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
@@ -502,7 +510,7 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
502
510
  }
503
511
  /** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
504
512
  get plugins() {
505
- return B;
513
+ return R;
506
514
  }
507
515
  /**
508
516
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
@@ -513,38 +521,38 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
513
521
  let e = 0;
514
522
  this._originalRender = this.renderer.render;
515
523
  const t = this;
516
- fe(this.renderer), this.renderer.render = function(r, i) {
524
+ ce(this.renderer), this.renderer.render = function(r, s) {
517
525
  t.renderer.getRenderTarget() == null && (e = 0, t._frame += 1);
518
- const s = t._frame, o = e++;
519
- t.onBeforeRender(r, i, o, s), t._originalRender.call(this, r, i), t.onAfterRender(r, i, o, s);
526
+ const i = t._frame, o = e++;
527
+ t.onBeforeRender(r, s, o, i), t._originalRender.call(this, r, s), t.onAfterRender(r, s, o, i);
520
528
  };
521
529
  }
522
530
  disable() {
523
531
  this._originalRender && (this.renderer.render = this._originalRender, this._originalRender = void 0);
524
532
  }
525
- onBeforeRender(e, t, r, i) {
533
+ onBeforeRender(e, t, r, s) {
526
534
  }
527
- onAfterRender(e, t, r, i) {
535
+ onAfterRender(e, t, r, s) {
528
536
  var l, d;
529
537
  if (this.pause)
530
538
  return;
531
- const n = this.renderer.renderLists.get(e, 0), s = n.opaque;
539
+ const n = this.renderer.renderLists.get(e, 0), i = n.opaque;
532
540
  let o = !0;
533
- if (s.length === 1) {
534
- const h = s[0].material;
541
+ if (i.length === 1) {
542
+ const h = i[0].material;
535
543
  (h.name === "EffectMaterial" || h.name === "CopyShader") && (o = !1);
536
544
  }
537
545
  if (t.parent && t.parent.type === "CubeCamera" && (o = !1), o) {
538
- if (Ae || this.updateInterval > 0 && i % this.updateInterval != 0)
546
+ if (Ae || this.updateInterval > 0 && s % this.updateInterval != 0)
539
547
  return;
540
548
  this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this.cameraFrustrum.setFromProjectionMatrix(this.projectionScreenMatrix, this.renderer.coordinateSystem);
541
549
  const h = this.targetTriangleDensity;
542
- for (const u of s) {
543
- if (u.material && (((l = u.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((d = u.geometry) == null ? void 0 : d.type) === "BufferGeometry") && (u.material.name === "SphericalGaussianBlur" || u.material.name == "BackgroundCubeMaterial" || u.material.name === "CubemapFromEquirect" || u.material.name === "EquirectangularToCubeUV")) {
544
- ee && (u.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (u.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", u, u.material.name, u.material.type)));
550
+ for (const f of i) {
551
+ if (f.material && (((l = f.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((d = f.geometry) == null ? void 0 : d.type) === "BufferGeometry") && (f.material.name === "SphericalGaussianBlur" || f.material.name == "BackgroundCubeMaterial" || f.material.name === "CubemapFromEquirect" || f.material.name === "EquirectangularToCubeUV")) {
552
+ ee && (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)));
545
553
  continue;
546
554
  }
547
- switch (u.material.type) {
555
+ switch (f.material.type) {
548
556
  case "LineBasicMaterial":
549
557
  case "LineDashedMaterial":
550
558
  case "PointsMaterial":
@@ -553,33 +561,33 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
553
561
  case "MeshDepthMaterial":
554
562
  continue;
555
563
  }
556
- const y = u.object;
557
- (y instanceof V || y.isMesh) && this.updateLODs(e, t, y, h, i);
564
+ const y = f.object;
565
+ (y instanceof V || y.isMesh) && this.updateLODs(e, t, y, h, s);
558
566
  }
559
567
  const m = n.transparent;
560
- for (const u of m) {
561
- const y = u.object;
562
- (y instanceof V || y.isMesh) && this.updateLODs(e, t, y, h, i);
568
+ for (const f of m) {
569
+ const y = f.object;
570
+ (y instanceof V || y.isMesh) && this.updateLODs(e, t, y, h, s);
563
571
  }
564
572
  }
565
573
  }
566
574
  /** Update the LOD levels for the renderer. */
567
- updateLODs(e, t, r, i, n) {
575
+ updateLODs(e, t, r, s, n) {
568
576
  var l, d;
569
- let s = r.userData.LOD_state;
570
- if (s || (s = new Pe(), r.userData.LOD_state = s), s.frames++ < 2)
577
+ let i = r.userData.LOD_state;
578
+ if (i || (i = new Pe(), r.userData.LOD_state = i), i.frames++ < 2)
571
579
  return;
572
- for (const h of B)
580
+ for (const h of R)
573
581
  (l = h.onBeforeUpdateLOD) == null || l.call(h, this.renderer, e, t, r);
574
- this.calculateLodLevel(t, r, s, i, A), A.mesh_lod = Math.round(A.mesh_lod), A.texture_lod = Math.round(A.texture_lod), A.mesh_lod >= 0 && this.loadProgressiveMeshes(r, A.mesh_lod);
582
+ this.calculateLodLevel(t, r, i, s, A), A.mesh_lod = Math.round(A.mesh_lod), A.texture_lod = Math.round(A.texture_lod), A.mesh_lod >= 0 && this.loadProgressiveMeshes(r, A.mesh_lod);
575
583
  let o = A.texture_lod;
576
584
  if (r.material && o >= 0) {
577
585
  const h = r["DEBUG:LOD"];
578
586
  h != null && (o = h), this.loadProgressiveTextures(r.material, o);
579
587
  }
580
- for (const h of B)
588
+ for (const h of R)
581
589
  (d = h.onAfterUpdatedLOD) == null || d.call(h, this.renderer, e, t, r, A);
582
- s.lastLodLevel_Mesh = A.mesh_lod, s.lasLodLevel_Texture = A.texture_lod;
590
+ i.lastLodLevel_Mesh = A.mesh_lod, i.lasLodLevel_Texture = A.texture_lod;
583
591
  }
584
592
  /** Load progressive textures for the given material
585
593
  * @param material the material to load the textures for
@@ -595,8 +603,8 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
595
603
  return;
596
604
  }
597
605
  const r = e;
598
- let i = !1;
599
- (r.NEEDLE_LOD == null || t < r.NEEDLE_LOD) && (i = !0), i && (r.NEEDLE_LOD = t, S.assignTextureLOD(e, t));
606
+ let s = !1;
607
+ (r.NEEDLE_LOD == null || t < r.NEEDLE_LOD) && (s = !0), s && (r.NEEDLE_LOD = t, _.assignTextureLOD(e, t));
600
608
  }
601
609
  /** Load progressive meshes for the given mesh
602
610
  * @param mesh the mesh to load the LOD for
@@ -610,15 +618,15 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
610
618
  if (e.userData || (e.userData = {}), e.userData.LOD !== t) {
611
619
  e.userData.LOD = t;
612
620
  const r = e.geometry;
613
- return S.assignMeshLOD(e, t).then((i) => (i && e.userData.LOD == t && r != e.geometry, i));
621
+ return _.assignMeshLOD(e, t).then((s) => (s && e.userData.LOD == t && r != e.geometry, s));
614
622
  }
615
623
  return Promise.resolve(null);
616
624
  }
617
625
  static isInside(e, t) {
618
- const r = e.min, i = e.max, n = (r.x + i.x) * 0.5, s = (r.y + i.y) * 0.5;
619
- return this._tempPtInside.set(n, s, r.z).applyMatrix4(t).z < 0;
626
+ const r = e.min, s = e.max, n = (r.x + s.x) * 0.5, i = (r.y + s.y) * 0.5;
627
+ return this._tempPtInside.set(n, i, r.z).applyMatrix4(t).z < 0;
620
628
  }
621
- calculateLodLevel(e, t, r, i, n) {
629
+ calculateLodLevel(e, t, r, s, n) {
622
630
  var x;
623
631
  if (!t) {
624
632
  n.mesh_lod = -1, n.texture_lod = -1;
@@ -631,8 +639,8 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
631
639
  let o = 10 + 1;
632
640
  if (ee && t["DEBUG:LOD"] != null)
633
641
  return t["DEBUG:LOD"];
634
- const l = S.getMeshLODInformation(t.geometry), d = l == null ? void 0 : l.lods, h = d && d.length > 0, m = S.getMaterialMinMaxLODsCount(t.material), u = (m == null ? void 0 : m.min) != 1 / 0 && m.min > 0 && m.max > 0;
635
- if (!h && !u) {
642
+ const l = _.getMeshLODInformation(t.geometry), d = l == null ? void 0 : l.lods, h = d && d.length > 0, m = _.getMaterialMinMaxLODsCount(t.material), f = (m == null ? void 0 : m.min) != 1 / 0 && m.min > 0 && m.max > 0;
643
+ if (!h && !f) {
636
644
  n.mesh_lod = 0, n.texture_lod = 0;
637
645
  return;
638
646
  }
@@ -657,10 +665,10 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
657
665
  }
658
666
  if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && M.fov > 70) {
659
667
  const p = this._tempBox.min, g = this._tempBox.max;
660
- let c = p.x, L = p.y, _ = g.x, C = g.y;
668
+ let c = p.x, L = p.y, S = g.x, C = g.y;
661
669
  const I = 2, U = 1.5, q = (p.x + g.x) * 0.5, K = (p.y + g.y) * 0.5;
662
- c = (c - q) * I + q, L = (L - K) * I + K, _ = (_ - q) * I + q, C = (C - K) * I + K;
663
- const de = c < 0 && _ > 0 ? 0 : Math.min(Math.abs(p.x), Math.abs(g.x)), he = L < 0 && C > 0 ? 0 : Math.min(Math.abs(p.y), Math.abs(g.y)), Z = Math.max(de, he);
670
+ c = (c - q) * I + q, L = (L - K) * I + K, S = (S - q) * I + q, C = (C - K) * I + K;
671
+ const de = c < 0 && S > 0 ? 0 : Math.min(Math.abs(p.x), Math.abs(g.x)), he = L < 0 && C > 0 ? 0 : Math.min(Math.abs(p.y), Math.abs(g.y)), Z = Math.max(de, he);
664
672
  r.lastCentrality = (U - Z) * (U - Z) * (U - Z);
665
673
  } else
666
674
  r.lastCentrality = 1;
@@ -672,15 +680,15 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
672
680
  if (Math.max(D.x, D.y) != 0 && F != 0 && (D.z = P.z / Math.max(P.x, P.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, ee && T.debugDrawLine) {
673
681
  const p = this.tempMatrix.copy(this.projectionScreenMatrix);
674
682
  p.invert();
675
- const g = T.corner0, c = T.corner1, L = T.corner2, _ = T.corner3;
676
- g.copy(this._tempBox.min), c.copy(this._tempBox.max), c.x = g.x, L.copy(this._tempBox.max), L.y = g.y, _.copy(this._tempBox.max);
677
- const C = (g.z + _.z) * 0.5;
678
- g.z = c.z = L.z = _.z = C, g.applyMatrix4(p), c.applyMatrix4(p), L.applyMatrix4(p), _.applyMatrix4(p), T.debugDrawLine(g, c, 255), T.debugDrawLine(g, L, 255), T.debugDrawLine(c, _, 255), T.debugDrawLine(L, _, 255);
683
+ const g = T.corner0, c = T.corner1, L = T.corner2, S = T.corner3;
684
+ g.copy(this._tempBox.min), c.copy(this._tempBox.max), c.x = g.x, L.copy(this._tempBox.max), L.y = g.y, S.copy(this._tempBox.max);
685
+ const C = (g.z + S.z) * 0.5;
686
+ g.z = c.z = L.z = S.z = C, g.applyMatrix4(p), c.applyMatrix4(p), L.applyMatrix4(p), S.applyMatrix4(p), T.debugDrawLine(g, c, 255), T.debugDrawLine(g, L, 255), T.debugDrawLine(c, S, 255), T.debugDrawLine(L, S, 255);
679
687
  }
680
688
  let E = 999;
681
689
  if (d && r.lastScreenCoverage > 0) {
682
690
  for (let p = 0; p < d.length; p++)
683
- if (d[p].density / r.lastScreenCoverage < i) {
691
+ if (d[p].density / r.lastScreenCoverage < s) {
684
692
  E = p;
685
693
  break;
686
694
  }
@@ -697,35 +705,35 @@ const ee = ie("debugprogressive"), Ae = ie("noprogressive"), le = Symbol("Needle
697
705
  let b = T;
698
706
  /** 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.
699
707
  */
700
- f(b, "debugDrawLine"), f(b, "corner0", new k()), f(b, "corner1", new k()), f(b, "corner2", new k()), f(b, "corner3", new k()), f(b, "_tempPtInside", new k());
708
+ u(b, "debugDrawLine"), u(b, "corner0", new k()), u(b, "corner1", new k()), u(b, "corner2", new k()), u(b, "corner3", new k()), u(b, "_tempPtInside", new k());
701
709
  function be(a, e, t) {
702
710
  return a + (e - a) * t;
703
711
  }
704
712
  class Pe {
705
713
  constructor() {
706
- f(this, "frames", 0);
707
- f(this, "lastLodLevel_Mesh", 0);
708
- f(this, "lasLodLevel_Texture", 0);
709
- f(this, "lastScreenCoverage", 0);
710
- f(this, "lastScreenspaceVolume", new k());
711
- f(this, "lastCentrality", 0);
714
+ u(this, "frames", 0);
715
+ u(this, "lastLodLevel_Mesh", 0);
716
+ u(this, "lasLodLevel_Texture", 0);
717
+ u(this, "lastScreenCoverage", 0);
718
+ u(this, "lastScreenspaceVolume", new k());
719
+ u(this, "lastCentrality", 0);
712
720
  }
713
721
  }
714
- const ce = Symbol("NEEDLE_mesh_lod"), X = Symbol("NEEDLE_texture_lod");
722
+ const ue = Symbol("NEEDLE_mesh_lod"), X = Symbol("NEEDLE_texture_lod");
715
723
  function Ee(a) {
716
724
  if (!a)
717
725
  return null;
718
726
  let e = null, t = null;
719
727
  for (let r = a; r != null; r = Object.getPrototypeOf(r)) {
720
- const i = Object.getOwnPropertySymbols(r), n = i.find((o) => o.toString() == "Symbol(renderer)"), s = i.find((o) => o.toString() == "Symbol(scene)");
721
- !e && n != null && (e = a[n].threeRenderer), !t && s != null && (t = a[s]);
728
+ const s = Object.getOwnPropertySymbols(r), n = s.find((o) => o.toString() == "Symbol(renderer)"), i = s.find((o) => o.toString() == "Symbol(scene)");
729
+ !e && n != null && (e = a[n].threeRenderer), !t && i != null && (t = a[i]);
722
730
  }
723
731
  if (e) {
724
732
  console.log("Adding Needle LODs to modelviewer");
725
733
  const r = b.get(e);
726
734
  if (b.addPlugin(new Ce(a)), r.enable(), t) {
727
- const i = t.camera || t.traverse((n) => n.type == "PerspectiveCamera")[0];
728
- i && e.render(t, i);
735
+ const s = t.camera || t.traverse((n) => n.type == "PerspectiveCamera")[0];
736
+ s && e.render(t, s);
729
737
  }
730
738
  return () => {
731
739
  r.disable();
@@ -735,12 +743,12 @@ function Ee(a) {
735
743
  }
736
744
  class Ce {
737
745
  constructor(e) {
738
- f(this, "modelviewer");
739
- f(this, "_didWarnAboutMissingUrl", !1);
746
+ u(this, "modelviewer");
747
+ u(this, "_didWarnAboutMissingUrl", !1);
740
748
  this.modelviewer = e;
741
749
  }
742
- onBeforeUpdateLOD(e, t, r, i) {
743
- this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
750
+ onBeforeUpdateLOD(e, t, r, s) {
751
+ this.tryParseMeshLOD(t, s), this.tryParseTextureLOD(t, s);
744
752
  }
745
753
  getUrl() {
746
754
  let e = this.modelviewer.getAttribute("src");
@@ -753,70 +761,70 @@ class Ce {
753
761
  if (t[X] == !0)
754
762
  return;
755
763
  t[X] = !0;
756
- const r = this.tryGetCurrentGLTF(e), i = this.getUrl();
757
- if (i && r && t.material) {
764
+ const r = this.tryGetCurrentGLTF(e), s = this.getUrl();
765
+ if (s && r && t.material) {
758
766
  let n = function(o) {
759
767
  var d, h, m;
760
768
  if (o[X] == !0)
761
769
  return;
762
770
  o[X] = !0, o.userData && (o.userData.LOD = -1);
763
771
  const l = Object.keys(o);
764
- for (let u = 0; u < l.length; u++) {
765
- const y = l[u], x = o[y];
772
+ for (let f = 0; f < l.length; f++) {
773
+ const y = l[f], x = o[y];
766
774
  if ((x == null ? void 0 : x.isTexture) === !0) {
767
775
  const M = (h = (d = x.userData) == null ? void 0 : d.associations) == null ? void 0 : h.textures, D = r.parser.json.textures[M];
768
776
  if (!D) {
769
777
  console.warn("Texture data not found for texture index " + M);
770
778
  continue;
771
779
  }
772
- if ((m = D == null ? void 0 : D.extensions) != null && m[R]) {
773
- const G = D.extensions[R];
774
- G && i && S.registerTexture(i, x, G.lods.length, G);
780
+ if ((m = D == null ? void 0 : D.extensions) != null && m[B]) {
781
+ const G = D.extensions[B];
782
+ G && s && _.registerTexture(s, x, G.lods.length, G);
775
783
  }
776
784
  }
777
785
  }
778
786
  };
779
- const s = t.material;
780
- if (Array.isArray(s))
781
- for (const o of s)
787
+ const i = t.material;
788
+ if (Array.isArray(i))
789
+ for (const o of i)
782
790
  n(o);
783
791
  else
784
- n(s);
792
+ n(i);
785
793
  }
786
794
  }
787
795
  tryParseMeshLOD(e, t) {
788
- var n, s;
789
- if (t[ce] == !0)
796
+ var n, i;
797
+ if (t[ue] == !0)
790
798
  return;
791
- t[ce] = !0;
799
+ t[ue] = !0;
792
800
  const r = this.getUrl();
793
801
  if (!r)
794
802
  return;
795
- const i = (s = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : s[R];
796
- if (i && r) {
803
+ const s = (i = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : i[B];
804
+ if (s && r) {
797
805
  const o = t.uuid;
798
- S.registerMesh(r, o, t, 0, i.lods.length, i);
806
+ _.registerMesh(r, o, t, 0, s.lods.length, s);
799
807
  }
800
808
  }
801
809
  }
802
810
  function ze(a, e, t, r) {
803
- fe(e), ue(t), t.register((n) => new S(n, a));
804
- const i = b.get(e);
805
- return (r == null ? void 0 : r.enableLODsManager) !== !1 && i.enable(), i;
811
+ ce(e), fe(t), t.register((n) => new _(n, a));
812
+ const s = b.get(e);
813
+ return (r == null ? void 0 : r.enableLODsManager) !== !1 && s.enable(), s;
806
814
  }
807
815
  document.addEventListener("DOMContentLoaded", () => {
808
816
  Ee(document.querySelector("model-viewer"));
809
817
  });
810
818
  export {
811
- R as EXTENSION_NAME,
819
+ B as EXTENSION_NAME,
812
820
  b as LODsManager,
813
- S as NEEDLE_progressive,
814
- ue as addDracoAndKTX2Loaders,
815
- fe as createLoaders,
816
- Se as getRaycastMesh,
821
+ _ as NEEDLE_progressive,
822
+ fe as addDracoAndKTX2Loaders,
823
+ ce as createLoaders,
824
+ _e as getRaycastMesh,
817
825
  Ee as patchModelViewer,
818
826
  Ue as setDracoDecoderLocation,
819
827
  Ne as setKTX2TranscoderLocation,
820
- _e as setRaycastMesh,
828
+ Se as setRaycastMesh,
821
829
  ze as useNeedleProgressive
822
830
  };