@needle-tools/gltf-progressive 1.2.2-alpha.1 → 1.2.2-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,37 @@
1
- var _e = Object.defineProperty;
2
- var Se = (l, e, t) => e in l ? _e(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var h = (l, e, t) => (Se(l, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { BufferGeometry as re, Mesh as V, Material as be, Texture as K, TextureLoader as Te, Matrix4 as pe, Frustum as Ae, Sphere as Pe, Box3 as ye, Vector3 as I } from "three";
5
- import { GLTFLoader as Ce } from "three/examples/jsm/loaders/GLTFLoader.js";
6
- import { MeshoptDecoder as Re } from "three/examples/jsm/libs/meshopt_decoder.module.js";
7
- import { DRACOLoader as Be } from "three/examples/jsm/loaders/DRACOLoader.js";
8
- import { KTX2Loader as Ee } from "three/examples/jsm/loaders/KTX2Loader.js";
9
- const Me = "";
10
- globalThis.GLTF_PROGRESSIVE_VERSION = Me;
11
- console.debug(`[gltf-progressive] version ${Me}`);
12
- let se = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", he = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
13
- fetch(se + "draco_decoder.js", { method: "head" }).catch((l) => {
14
- se = "./include/draco/", he = "./include/ktx2/";
1
+ var Se = Object.defineProperty;
2
+ var be = (l, e, t) => e in l ? Se(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var f = (l, e, t) => (be(l, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { BufferGeometry as se, Mesh as W, Material as Te, Texture as q, TextureLoader as Ae, Matrix4 as ye, Frustum as Pe, Sphere as Ce, Box3 as me, Vector3 as G } from "three";
5
+ import { GLTFLoader as Ee } from "three/examples/jsm/loaders/GLTFLoader.js";
6
+ import { MeshoptDecoder as Be } from "three/examples/jsm/libs/meshopt_decoder.module.js";
7
+ import { DRACOLoader as ke } from "three/examples/jsm/loaders/DRACOLoader.js";
8
+ import { KTX2Loader as Re } from "three/examples/jsm/loaders/KTX2Loader.js";
9
+ const De = "";
10
+ globalThis.GLTF_PROGRESSIVE_VERSION = De;
11
+ console.debug(`[gltf-progressive] version ${De}`);
12
+ let ie = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", ge = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
13
+ fetch(ie + "draco_decoder.js", { method: "head" }).catch((l) => {
14
+ ie = "./include/draco/", ge = "./include/ktx2/";
15
15
  });
16
- function Qe(l) {
17
- se = l;
18
- }
19
16
  function Ze(l) {
20
- he = l;
17
+ ie = l;
21
18
  }
22
- let Y, ue, H;
23
- function De(l) {
24
- Y || (Y = new Be(), Y.setDecoderPath(se), Y.setDecoderConfig({ type: "js" })), H || (H = new Ee(), H.setTranscoderPath(he)), ue || (ue = Re), l ? H.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
19
+ function je(l) {
20
+ ge = l;
25
21
  }
22
+ let H, fe, J;
26
23
  function we(l) {
27
- l.dracoLoader || l.setDRACOLoader(Y), l.ktx2Loader || l.setKTX2Loader(H), l.meshoptDecoder || l.setMeshoptDecoder(ue);
24
+ H || (H = new ke(), H.setDecoderPath(ie), H.setDecoderConfig({ type: "js" })), J || (J = new Re(), J.setTranscoderPath(ge)), fe || (fe = Be), l ? J.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
25
+ }
26
+ function _e(l) {
27
+ l.dracoLoader || l.setDRACOLoader(H), l.ktx2Loader || l.setKTX2Loader(J), l.meshoptDecoder || l.setMeshoptDecoder(fe);
28
28
  }
29
- Q("debugprogressive");
30
- function Q(l) {
29
+ Z("debugprogressive");
30
+ function Z(l) {
31
31
  const t = new URL(window.location.href).searchParams.get(l);
32
32
  return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
33
33
  }
34
- function ke(l, e) {
34
+ function Ie(l, e) {
35
35
  if (e === void 0 || e.startsWith("./") || e.startsWith("http") || l === void 0)
36
36
  return e;
37
37
  const t = l.lastIndexOf("/");
@@ -43,104 +43,104 @@ function ke(l, e) {
43
43
  }
44
44
  return e;
45
45
  }
46
- let q;
47
- function Ie() {
48
- return q !== void 0 || (q = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), Q("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", q)), q;
46
+ let X;
47
+ function Ge() {
48
+ return X !== void 0 || (X = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), Z("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", X)), X;
49
49
  }
50
- const fe = Symbol("needle:raycast-mesh");
51
- function ge(l) {
52
- return (l == null ? void 0 : l[fe]) instanceof re ? l[fe] : null;
50
+ const de = Symbol("needle:raycast-mesh");
51
+ function pe(l) {
52
+ return (l == null ? void 0 : l[de]) instanceof se ? l[de] : null;
53
53
  }
54
- function Ge(l, e) {
55
- if ((l.type === "Mesh" || l.type === "SkinnedMesh") && !ge(l)) {
56
- const r = Fe(e);
57
- r.userData = { isRaycastMesh: !0 }, l[fe] = r;
54
+ function Fe(l, e) {
55
+ if ((l.type === "Mesh" || l.type === "SkinnedMesh") && !pe(l)) {
56
+ const r = $e(e);
57
+ r.userData = { isRaycastMesh: !0 }, l[de] = r;
58
58
  }
59
59
  }
60
- function je(l = !0) {
60
+ function et(l = !0) {
61
61
  if (l) {
62
- if (X)
62
+ if (Y)
63
63
  return;
64
- const e = X = V.prototype.raycast;
65
- V.prototype.raycast = function(t, r) {
66
- const n = this, i = ge(n);
64
+ const e = Y = W.prototype.raycast;
65
+ W.prototype.raycast = function(t, r) {
66
+ const i = this, n = pe(i);
67
67
  let s;
68
- i && n.isMesh && (s = n.geometry, n.geometry = i), e.call(this, t, r), s && (n.geometry = s);
68
+ n && i.isMesh && (s = i.geometry, i.geometry = n), e.call(this, t, r), s && (i.geometry = s);
69
69
  };
70
70
  } else {
71
- if (!X)
71
+ if (!Y)
72
72
  return;
73
- V.prototype.raycast = X, X = null;
73
+ W.prototype.raycast = Y, Y = null;
74
74
  }
75
75
  }
76
- let X = null;
77
- function Fe(l) {
78
- const e = new re();
76
+ let Y = null;
77
+ function $e(l) {
78
+ const e = new se();
79
79
  for (const t in l.attributes)
80
80
  e.setAttribute(t, l.getAttribute(t));
81
81
  return e.setIndex(l.getIndex()), e;
82
82
  }
83
- const $ = new Array(), G = "NEEDLE_progressive", m = Q("debugprogressive"), oe = Symbol("needle-progressive-texture"), J = /* @__PURE__ */ new Map(), de = /* @__PURE__ */ new Set();
83
+ const z = new Array(), F = "NEEDLE_progressive", m = Z("debugprogressive"), ae = Symbol("needle-progressive-texture"), Q = /* @__PURE__ */ new Map(), he = /* @__PURE__ */ new Set();
84
84
  if (m) {
85
85
  let l = function() {
86
- e += 1, console.log("Toggle LOD level", e, J), J.forEach((n, i) => {
87
- for (const s of n.keys) {
88
- const o = i[s];
86
+ e += 1, console.log("Toggle LOD level", e, Q), Q.forEach((i, n) => {
87
+ for (const s of i.keys) {
88
+ const o = n[s];
89
89
  if (o != null) {
90
90
  if (o.isBufferGeometry === !0) {
91
91
  const a = O.getMeshLODInformation(o), d = a ? Math.min(e, a.lods.length) : 0;
92
- i["DEBUG:LOD"] = e, O.assignMeshLOD(i, d), a && (t = Math.max(t, a.lods.length - 1));
93
- } else if (i.isMaterial === !0) {
94
- i["DEBUG:LOD"] = e, O.assignTextureLOD(i, e);
92
+ n["DEBUG:LOD"] = e, O.assignMeshLOD(n, d), a && (t = Math.max(t, a.lods.length - 1));
93
+ } else if (n.isMaterial === !0) {
94
+ n["DEBUG:LOD"] = e, O.assignTextureLOD(n, e);
95
95
  break;
96
96
  }
97
97
  }
98
98
  }
99
99
  }), e >= t && (e = -1);
100
100
  }, e = -1, t = 2, r = !1;
101
- window.addEventListener("keyup", (n) => {
102
- n.key === "p" && l(), n.key === "w" && (r = !r, de && de.forEach((i) => {
103
- i.name != "BackgroundCubeMaterial" && i.glyphMap == null && "wireframe" in i && (i.wireframe = r);
101
+ window.addEventListener("keyup", (i) => {
102
+ i.key === "p" && l(), i.key === "w" && (r = !r, he && he.forEach((n) => {
103
+ n.name != "BackgroundCubeMaterial" && n.glyphMap == null && "wireframe" in n && (n.wireframe = r);
104
104
  }));
105
105
  });
106
106
  }
107
- function me(l, e, t) {
108
- var n;
107
+ function xe(l, e, t) {
108
+ var i;
109
109
  if (!m)
110
110
  return;
111
- J.has(l) || J.set(l, { keys: [], sourceId: t });
112
- const r = J.get(l);
113
- ((n = r == null ? void 0 : r.keys) == null ? void 0 : n.includes(e)) == !1 && r.keys.push(e);
111
+ Q.has(l) || Q.set(l, { keys: [], sourceId: t });
112
+ const r = Q.get(l);
113
+ ((i = r == null ? void 0 : r.keys) == null ? void 0 : i.includes(e)) == !1 && r.keys.push(e);
114
114
  }
115
- const D = class {
115
+ const v = class {
116
116
  constructor(e, t) {
117
- h(this, "parser");
118
- h(this, "url");
119
- h(this, "_isLoadingMesh");
120
- h(this, "loadMesh", (e) => {
121
- var r, n;
117
+ f(this, "parser");
118
+ f(this, "url");
119
+ f(this, "_isLoadingMesh");
120
+ f(this, "loadMesh", (e) => {
121
+ var r, i;
122
122
  if (this._isLoadingMesh)
123
123
  return null;
124
- const t = (n = (r = this.parser.json.meshes[e]) == null ? void 0 : r.extensions) == null ? void 0 : n[G];
125
- return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((i) => {
124
+ const t = (i = (r = this.parser.json.meshes[e]) == null ? void 0 : r.extensions) == null ? void 0 : i[F];
125
+ return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((n) => {
126
126
  var s;
127
- return this._isLoadingMesh = !1, i && D.registerMesh(this.url, t.guid, i, (s = t.lods) == null ? void 0 : s.length, void 0, t), i;
127
+ return this._isLoadingMesh = !1, n && v.registerMesh(this.url, t.guid, n, (s = t.lods) == null ? void 0 : s.length, void 0, t), n;
128
128
  })) : null;
129
129
  });
130
130
  m && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
131
131
  }
132
132
  /** The name of the extension */
133
133
  get name() {
134
- return G;
134
+ return F;
135
135
  }
136
136
  static getMeshLODInformation(e) {
137
137
  const t = this.getAssignedLODInformation(e);
138
138
  return t != null && t.key ? this.lodInfos.get(t.key) : null;
139
139
  }
140
140
  static getMaterialMinMaxLODsCount(e, t) {
141
- const r = this, n = "LODS:minmax", i = e[n];
142
- if (i != null)
143
- return i;
141
+ const r = this, i = "LODS:minmax", n = e[i];
142
+ if (n != null)
143
+ return n;
144
144
  if (t || (t = {
145
145
  min_count: 1 / 0,
146
146
  max_count: 0,
@@ -148,7 +148,7 @@ const D = class {
148
148
  }), Array.isArray(e)) {
149
149
  for (const o of e)
150
150
  this.getMaterialMinMaxLODsCount(o, t);
151
- return e[n] = t, t;
151
+ return e[i] = t, t;
152
152
  }
153
153
  if (m === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
154
154
  const o = e;
@@ -161,7 +161,7 @@ const D = class {
161
161
  const a = e[o];
162
162
  (a == null ? void 0 : a.isTexture) === !0 && s(a, t);
163
163
  }
164
- return e[n] = t, t;
164
+ return e[i] = t, t;
165
165
  function s(o, a) {
166
166
  const d = r.getAssignedLODInformation(o);
167
167
  if (d) {
@@ -169,8 +169,8 @@ const D = class {
169
169
  if (c && c.lods) {
170
170
  a.min_count = Math.min(a.min_count, c.lods.length), a.max_count = Math.max(a.max_count, c.lods.length);
171
171
  for (let x = 0; x < c.lods.length; x++) {
172
- const f = c.lods[x];
173
- f.width && (a.lods[x] = a.lods[x] || { min_height: 1 / 0, max_height: 0 }, a.lods[x].min_height = Math.min(a.lods[x].min_height, f.height), a.lods[x].max_height = Math.max(a.lods[x].max_height, f.height));
172
+ const u = c.lods[x];
173
+ u.width && (a.lods[x] = a.lods[x] || { min_height: 1 / 0, max_height: 0 }, a.lods[x].min_height = Math.min(a.lods[x].min_height, u.height), a.lods[x].max_height = Math.max(a.lods[x].max_height, u.height));
174
174
  }
175
175
  }
176
176
  }
@@ -182,7 +182,7 @@ const D = class {
182
182
  * @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
183
183
  */
184
184
  static hasLODLevelAvailable(e, t) {
185
- var i;
185
+ var n;
186
186
  if (Array.isArray(e)) {
187
187
  for (const s of e)
188
188
  if (this.hasLODLevelAvailable(s, t))
@@ -201,13 +201,13 @@ const D = class {
201
201
  if (s.isMesh === !0 && this.hasLODLevelAvailable(s, t))
202
202
  return !0;
203
203
  }
204
- let r, n;
205
- if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (i = r == null ? void 0 : r.userData) != null && i.LODS) {
204
+ let r, i;
205
+ if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (n = r == null ? void 0 : r.userData) != null && n.LODS) {
206
206
  const s = r.userData.LODS;
207
- if (n = this.lodInfos.get(s.key), t === void 0)
208
- return n != null;
209
- if (n)
210
- return Array.isArray(n.lods) ? t < n.lods.length : t === 0;
207
+ if (i = this.lodInfos.get(s.key), t === void 0)
208
+ return i != null;
209
+ if (i)
210
+ return Array.isArray(i.lods) ? t < i.lods.length : t === 0;
211
211
  }
212
212
  return !1;
213
213
  }
@@ -229,19 +229,19 @@ const D = class {
229
229
  var r;
230
230
  if (!e)
231
231
  return Promise.resolve(null);
232
- if (e instanceof V || e.isMesh === !0) {
233
- const n = e.geometry, i = this.getAssignedLODInformation(n);
234
- if (!i)
232
+ if (e instanceof W || e.isMesh === !0) {
233
+ const i = e.geometry, n = this.getAssignedLODInformation(i);
234
+ if (!n)
235
235
  return Promise.resolve(null);
236
- for (const s of $)
236
+ for (const s of z)
237
237
  (r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
238
- return e["LOD:requested level"] = t, D.getOrLoadLOD(n, t).then((s) => {
238
+ return e["LOD:requested level"] = t, v.getOrLoadLOD(i, t).then((s) => {
239
239
  if (e["LOD:requested level"] === t) {
240
240
  if (delete e["LOD:requested level"], Array.isArray(s)) {
241
- const o = i.index || 0;
241
+ const o = n.index || 0;
242
242
  s = s[o];
243
243
  }
244
- s && n != s && ((s == null ? void 0 : s.isBufferGeometry) ? (e.geometry = s, m && me(e, "geometry", i.url)) : m && console.error("Invalid LOD geometry", s));
244
+ s && i != s && ((s == null ? void 0 : s.isBufferGeometry) ? (e.geometry = s, m && xe(e, "geometry", n.url)) : m && console.error("Invalid LOD geometry", s));
245
245
  }
246
246
  return s;
247
247
  }).catch((s) => (console.error("Error loading mesh LOD", e, s), null));
@@ -259,15 +259,15 @@ const D = class {
259
259
  static assignTextureLOD(e, t = 0) {
260
260
  if (!e)
261
261
  return Promise.resolve(null);
262
- if (e instanceof be || e.isMaterial === !0) {
263
- const r = e, n = [], i = new Array();
264
- if (m && de.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
262
+ if (e instanceof Te || e.isMaterial === !0) {
263
+ const r = e, i = [], n = new Array();
264
+ if (m && he.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
265
265
  const s = r;
266
266
  for (const o of Object.keys(s.uniforms)) {
267
267
  const a = s.uniforms[o].value;
268
268
  if ((a == null ? void 0 : a.isTexture) === !0) {
269
269
  const d = this.assignTextureLODForSlot(a, t, r, o);
270
- n.push(d), i.push(o);
270
+ i.push(d), n.push(o);
271
271
  }
272
272
  }
273
273
  } else
@@ -275,56 +275,56 @@ const D = class {
275
275
  const o = r[s];
276
276
  if ((o == null ? void 0 : o.isTexture) === !0) {
277
277
  const a = this.assignTextureLODForSlot(o, t, r, s);
278
- n.push(a), i.push(s);
278
+ i.push(a), n.push(s);
279
279
  }
280
280
  }
281
- return Promise.all(n).then((s) => {
281
+ return Promise.all(i).then((s) => {
282
282
  const o = new Array();
283
283
  for (let a = 0; a < s.length; a++) {
284
- const d = s[a], c = i[a];
284
+ const d = s[a], c = n[a];
285
285
  d && d.isTexture === !0 ? o.push({ material: r, slot: c, texture: d, level: t }) : o.push({ material: r, slot: c, texture: null, level: t });
286
286
  }
287
287
  return o;
288
288
  });
289
289
  }
290
- if (e instanceof K || e.isTexture === !0) {
290
+ if (e instanceof q || e.isTexture === !0) {
291
291
  const r = e;
292
292
  return this.assignTextureLODForSlot(r, t, null, null);
293
293
  }
294
294
  return Promise.resolve(null);
295
295
  }
296
- static assignTextureLODForSlot(e, t, r, n) {
297
- return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(e) : D.getOrLoadLOD(e, t).then((i) => {
298
- if (Array.isArray(i))
296
+ static assignTextureLODForSlot(e, t, r, i) {
297
+ return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : i === "glyphMap" ? Promise.resolve(e) : v.getOrLoadLOD(e, t).then((n) => {
298
+ if (Array.isArray(n))
299
299
  return null;
300
- if ((i == null ? void 0 : i.isTexture) === !0) {
301
- if (i != e) {
302
- if (r && n) {
303
- const s = r[n];
300
+ if ((n == null ? void 0 : n.isTexture) === !0) {
301
+ if (n != e) {
302
+ if (r && i) {
303
+ const s = r[i];
304
304
  if (s) {
305
305
  const o = this.getAssignedLODInformation(s);
306
306
  if (o && (o == null ? void 0 : o.level) < t)
307
- return m === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, t, r, s, i), null;
307
+ return m === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, t, r, s, n), null;
308
308
  }
309
- r[n] = i;
309
+ r[i] = n;
310
310
  }
311
- if (m && n && r) {
311
+ if (m && i && r) {
312
312
  const s = this.getAssignedLODInformation(e);
313
- s && me(r, n, s.url);
313
+ s && xe(r, i, s.url);
314
314
  }
315
315
  }
316
- return i;
316
+ return n;
317
317
  } else
318
318
  m == "verbose" && console.warn("No LOD found for", e, t);
319
319
  return null;
320
- }).catch((i) => (console.error("Error loading LOD", e, i), null));
320
+ }).catch((n) => (console.error("Error loading LOD", e, n), null));
321
321
  }
322
322
  afterRoot(e) {
323
323
  var t, r;
324
- return m && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((n, i) => {
324
+ return m && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
325
325
  var s;
326
- if (n != null && n.extensions) {
327
- const o = n == null ? void 0 : n.extensions[G];
326
+ if (i != null && i.extensions) {
327
+ const o = i == null ? void 0 : i.extensions[F];
328
328
  if (o) {
329
329
  if (!o.lods) {
330
330
  m && console.warn("Texture has no LODs", o);
@@ -332,21 +332,21 @@ const D = class {
332
332
  }
333
333
  let a = !1;
334
334
  for (const d of this.parser.associations.keys())
335
- d.isTexture === !0 && this.parser.associations.get(d).textures === i && (a = !0, D.registerTexture(this.url, d, (s = o.lods) == null ? void 0 : s.length, i, o));
336
- a || this.parser.getDependency("texture", i).then((d) => {
335
+ d.isTexture === !0 && this.parser.associations.get(d).textures === n && (a = !0, v.registerTexture(this.url, d, (s = o.lods) == null ? void 0 : s.length, n, o));
336
+ a || this.parser.getDependency("texture", n).then((d) => {
337
337
  var c;
338
- d && D.registerTexture(this.url, d, (c = o.lods) == null ? void 0 : c.length, i, o);
338
+ d && v.registerTexture(this.url, d, (c = o.lods) == null ? void 0 : c.length, n, o);
339
339
  });
340
340
  }
341
341
  }
342
- }), (r = this.parser.json.meshes) == null || r.forEach((n, i) => {
343
- if (n != null && n.extensions) {
344
- const s = n == null ? void 0 : n.extensions[G];
342
+ }), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
343
+ if (i != null && i.extensions) {
344
+ const s = i == null ? void 0 : i.extensions[F];
345
345
  if (s && s.lods) {
346
346
  for (const o of this.parser.associations.keys())
347
347
  if (o.isMesh) {
348
348
  const a = this.parser.associations.get(o);
349
- a.meshes === i && D.registerMesh(this.url, s.guid, o, s.lods.length, a.primitives, s);
349
+ a.meshes === n && v.registerMesh(this.url, s.guid, o, s.lods.length, a.primitives, s);
350
350
  }
351
351
  }
352
352
  }
@@ -354,118 +354,118 @@ const D = class {
354
354
  }
355
355
  static async getOrLoadLOD(e, t) {
356
356
  var o, a, d, c;
357
- const r = m == "verbose", n = e.userData.LODS;
358
- if (!n)
357
+ const r = m == "verbose", i = e.userData.LODS;
358
+ if (!i)
359
359
  return null;
360
- const i = n == null ? void 0 : n.key;
360
+ const n = i == null ? void 0 : i.key;
361
361
  let s;
362
362
  if (e.isTexture === !0) {
363
363
  const x = e;
364
- x.source && x.source[oe] && (s = x.source[oe]);
364
+ x.source && x.source[ae] && (s = x.source[ae]);
365
365
  }
366
- if (s || (s = D.lodInfos.get(i)), s) {
366
+ if (s || (s = v.lodInfos.get(n)), s) {
367
367
  if (t > 0) {
368
368
  let y = !1;
369
- const M = Array.isArray(s.lods);
370
- if (M && t >= s.lods.length ? y = !0 : M || (y = !0), y)
371
- return this.lowresCache.get(i);
369
+ const w = Array.isArray(s.lods);
370
+ if (w && t >= s.lods.length ? y = !0 : w || (y = !0), y)
371
+ return this.lowresCache.get(n);
372
372
  }
373
373
  const x = Array.isArray(s.lods) ? (o = s.lods[t]) == null ? void 0 : o.path : s.lods;
374
374
  if (!x)
375
375
  return m && !s["missing:uri"] && (s["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, s)), null;
376
- const f = ke(n.url, x);
377
- if (f.endsWith(".glb") || f.endsWith(".gltf")) {
376
+ const u = Ie(i.url, x);
377
+ if (u.endsWith(".glb") || u.endsWith(".gltf")) {
378
378
  if (!s.guid)
379
379
  return console.warn("missing pointer for glb/gltf texture", s), null;
380
- const y = f + "_" + s.guid, M = this.previouslyLoaded.get(y);
381
- if (M !== void 0) {
380
+ const y = u + "_" + s.guid, w = this.previouslyLoaded.get(y);
381
+ if (w !== void 0) {
382
382
  r && console.log(`LOD ${t} was already loading/loaded: ${y}`);
383
- let g = await M.catch((C) => (console.error(`Error loading LOD ${t} from ${f}
384
- `, C), null)), z = !1;
385
- if (g == null || (g instanceof K && e instanceof K ? (a = g.image) != null && a.data || (d = g.source) != null && d.data ? g = this.copySettings(e, g) : (z = !0, this.previouslyLoaded.delete(y)) : g instanceof re && e instanceof re && ((c = g.attributes.position) != null && c.array || (z = !0, this.previouslyLoaded.delete(y)))), !z)
386
- return g;
383
+ let p = await w.catch((U) => (console.error(`Error loading LOD ${t} from ${u}
384
+ `, U), null)), M = !1;
385
+ if (p == null || (p instanceof q && e instanceof q ? (a = p.image) != null && a.data || (d = p.source) != null && d.data ? p = this.copySettings(e, p) : (M = !0, this.previouslyLoaded.delete(y)) : p instanceof se && e instanceof se && ((c = p.attributes.position) != null && c.array || (M = !0, this.previouslyLoaded.delete(y)))), !M)
386
+ return p;
387
387
  }
388
- const L = s, k = new Promise(async (g, z) => {
389
- const C = new Ce();
390
- we(C), m && (await new Promise((T) => setTimeout(T, 1e3)), r && console.warn("Start loading (delayed) " + f, L.guid));
391
- let b = f;
388
+ const L = s, B = new Promise(async (p, M) => {
389
+ const U = new Ee();
390
+ _e(U), m && (await new Promise((S) => setTimeout(S, 1e3)), r && console.warn("Start loading (delayed) " + u, L.guid));
391
+ let k = u;
392
392
  if (L && Array.isArray(L.lods)) {
393
- const T = L.lods[t];
394
- T.hash && (b += "?v=" + T.hash);
393
+ const S = L.lods[t];
394
+ S.hash && (k += "?v=" + S.hash);
395
395
  }
396
- const S = await C.loadAsync(b).catch((T) => (console.error(`Error loading LOD ${t} from ${f}
397
- `, T), null));
398
- if (!S)
396
+ const _ = await U.loadAsync(k).catch((S) => (console.error(`Error loading LOD ${t} from ${u}
397
+ `, S), null));
398
+ if (!_)
399
399
  return null;
400
- const W = S.parser;
401
- r && console.log("Loading finished " + f, L.guid);
400
+ const $ = _.parser;
401
+ r && console.log("Loading finished " + u, L.guid);
402
402
  let R = 0;
403
- if (S.parser.json.textures) {
404
- let T = !1;
405
- for (const u of S.parser.json.textures) {
406
- if (u != null && u.extensions) {
407
- const p = u == null ? void 0 : u.extensions[G];
408
- if (p != null && p.guid && p.guid === L.guid) {
409
- T = !0;
403
+ if (_.parser.json.textures) {
404
+ let S = !1;
405
+ for (const g of _.parser.json.textures) {
406
+ if (g != null && g.extensions) {
407
+ const h = g == null ? void 0 : g.extensions[F];
408
+ if (h != null && h.guid && h.guid === L.guid) {
409
+ S = !0;
410
410
  break;
411
411
  }
412
412
  }
413
413
  R++;
414
414
  }
415
- if (T) {
416
- let u = await W.getDependency("texture", R);
417
- return u && D.assignLODInformation(n.url, u, i, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + u.name + '"', f, R, u, y), e instanceof K && (u = this.copySettings(e, u)), u && (u.guid = L.guid), g(u);
415
+ if (S) {
416
+ let g = await $.getDependency("texture", R);
417
+ return g && v.assignLODInformation(i.url, g, n, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + g.name + '"', u, R, g, y), e instanceof q && (g = this.copySettings(e, g)), g && (g.guid = L.guid), p(g);
418
418
  } else
419
- m && console.warn("Could not find texture with guid", L.guid, S.parser.json);
419
+ m && console.warn("Could not find texture with guid", L.guid, _.parser.json);
420
420
  }
421
- if (R = 0, S.parser.json.meshes) {
422
- let T = !1;
423
- for (const u of S.parser.json.meshes) {
424
- if (u != null && u.extensions) {
425
- const p = u == null ? void 0 : u.extensions[G];
426
- if (p != null && p.guid && p.guid === L.guid) {
427
- T = !0;
421
+ if (R = 0, _.parser.json.meshes) {
422
+ let S = !1;
423
+ for (const g of _.parser.json.meshes) {
424
+ if (g != null && g.extensions) {
425
+ const h = g == null ? void 0 : g.extensions[F];
426
+ if (h != null && h.guid && h.guid === L.guid) {
427
+ S = !0;
428
428
  break;
429
429
  }
430
430
  }
431
431
  R++;
432
432
  }
433
- if (T) {
434
- const u = await W.getDependency("mesh", R), p = L;
435
- if (r && console.log(`Loaded Mesh "${u.name}"`, f, R, u, y), u.isMesh === !0) {
436
- const v = u.geometry;
437
- return D.assignLODInformation(n.url, v, i, t, void 0, p.density), g(v);
433
+ if (S) {
434
+ const g = await $.getDependency("mesh", R), h = L;
435
+ if (r && console.log(`Loaded Mesh "${g.name}"`, u, R, g, y), g.isMesh === !0) {
436
+ const D = g.geometry;
437
+ return v.assignLODInformation(i.url, D, n, t, void 0, h.density), p(D);
438
438
  } else {
439
- const v = new Array();
440
- for (let _ = 0; _ < u.children.length; _++) {
441
- const A = u.children[_];
442
- if (A.isMesh === !0) {
443
- const F = A.geometry;
444
- D.assignLODInformation(n.url, F, i, t, _, p.density), v.push(F);
439
+ const D = new Array();
440
+ for (let b = 0; b < g.children.length; b++) {
441
+ const T = g.children[b];
442
+ if (T.isMesh === !0) {
443
+ const A = T.geometry;
444
+ v.assignLODInformation(i.url, A, n, t, b, h.density), D.push(A);
445
445
  }
446
446
  }
447
- return g(v);
447
+ return p(D);
448
448
  }
449
449
  } else
450
- m && console.warn("Could not find mesh with guid", L.guid, S.parser.json);
450
+ m && console.warn("Could not find mesh with guid", L.guid, _.parser.json);
451
451
  }
452
- return g(null);
452
+ return p(null);
453
453
  });
454
- return this.previouslyLoaded.set(y, k), await k;
455
- } else if (e instanceof K) {
456
- r && console.log("Load texture from uri: " + f);
457
- const M = await new Te().loadAsync(f);
458
- return M ? (M.guid = s.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = e.colorSpace, r && console.log(s, M)) : m && console.warn("failed loading", f), M;
454
+ return this.previouslyLoaded.set(y, B), await B;
455
+ } else if (e instanceof q) {
456
+ r && console.log("Load texture from uri: " + u);
457
+ const w = await new Ae().loadAsync(u);
458
+ return w ? (w.guid = s.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, r && console.log(s, w)) : m && console.warn("failed loading", u), w;
459
459
  }
460
460
  } else
461
- m && console.warn(`Can not load LOD ${t}: no LOD info found for "${i}" ${e.name}`, e.type);
461
+ m && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
462
462
  return null;
463
463
  }
464
- static assignLODInformation(e, t, r, n, i, s) {
464
+ static assignLODInformation(e, t, r, i, n, s) {
465
465
  if (!t)
466
466
  return;
467
467
  t.userData || (t.userData = {});
468
- const o = new $e(e, r, n, i, s);
468
+ const o = new ze(e, r, i, n, s);
469
469
  t.userData.LODS = o;
470
470
  }
471
471
  static getAssignedLODInformation(e) {
@@ -479,93 +479,94 @@ const D = class {
479
479
  `, 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;
480
480
  }
481
481
  };
482
- let O = D;
482
+ let O = v;
483
483
  /**
484
484
  * Register a texture with LOD information
485
485
  */
486
- h(O, "registerTexture", (e, t, r, n, i) => {
487
- if (m && console.log("> Progressive: register texture", n, t.name, t.uuid, t, i), !t) {
486
+ f(O, "registerTexture", (e, t, r, i, n) => {
487
+ if (m && console.log("> Progressive: register texture", i, t.name, t.uuid, t, n), !t) {
488
488
  m && console.error("gltf-progressive: Register texture without texture");
489
489
  return;
490
490
  }
491
- t.source && (t.source[oe] = i);
492
- const s = i.guid;
493
- D.assignLODInformation(e, t, s, r, n, void 0), D.lodInfos.set(s, i), D.lowresCache.set(s, t);
491
+ t.source && (t.source[ae] = n);
492
+ const s = n.guid;
493
+ v.assignLODInformation(e, t, s, r, i, void 0), v.lodInfos.set(s, n), v.lowresCache.set(s, t);
494
494
  }), /**
495
495
  * Register a mesh with LOD information
496
496
  */
497
- h(O, "registerMesh", (e, t, r, n, i, s) => {
497
+ f(O, "registerMesh", (e, t, r, i, n, s) => {
498
498
  var d;
499
- m && console.log("> Progressive: register mesh", i, r.name, s, r.uuid, r);
499
+ m && console.log("> Progressive: register mesh", n, r.name, s, r.uuid, r);
500
500
  const o = r.geometry;
501
501
  if (!o) {
502
502
  m && console.warn("gltf-progressive: Register mesh without geometry");
503
503
  return;
504
504
  }
505
- o.userData || (o.userData = {}), D.assignLODInformation(e, o, t, n, i, s.density), D.lodInfos.set(t, s);
506
- let a = D.lowresCache.get(t);
507
- a ? a.push(r.geometry) : a = [r.geometry], D.lowresCache.set(t, a), n > 0 && !ge(r) && Ge(r, o);
508
- for (const c of $)
505
+ o.userData || (o.userData = {}), v.assignLODInformation(e, o, t, i, n, s.density), v.lodInfos.set(t, s);
506
+ let a = v.lowresCache.get(t);
507
+ a ? a.push(r.geometry) : a = [r.geometry], v.lowresCache.set(t, a), i > 0 && !pe(r) && Fe(r, o);
508
+ for (const c of z)
509
509
  (d = c.onRegisteredNewMesh) == null || d.call(c, r, s);
510
510
  }), /** A map of key = asset uuid and value = LOD information */
511
- h(O, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
512
- h(O, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
513
- h(O, "lowresCache", /* @__PURE__ */ new Map());
514
- class $e {
515
- constructor(e, t, r, n, i) {
516
- h(this, "url");
511
+ f(O, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
512
+ f(O, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
513
+ f(O, "lowresCache", /* @__PURE__ */ new Map());
514
+ class ze {
515
+ constructor(e, t, r, i, n) {
516
+ f(this, "url");
517
517
  /** the key to lookup the LOD information */
518
- h(this, "key");
519
- h(this, "level");
518
+ f(this, "key");
519
+ f(this, "level");
520
520
  /** For multi objects (e.g. a group of meshes) this is the index of the object */
521
- h(this, "index");
521
+ f(this, "index");
522
522
  /** the mesh density */
523
- h(this, "density");
524
- this.url = e, this.key = t, this.level = r, n != null && (this.index = n), i != null && (this.density = i);
523
+ f(this, "density");
524
+ this.url = e, this.key = t, this.level = r, i != null && (this.index = i), n != null && (this.density = n);
525
525
  }
526
526
  }
527
- const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LODSManager"), le = Symbol("Needle:LODState"), N = Symbol("Needle:CurrentLOD"), B = { mesh_lod: -1, texture_lod: -1 }, P = class {
527
+ const N = Z("debugprogressive"), Ue = Z("noprogressive"), le = Symbol("Needle:LODSManager"), ce = Symbol("Needle:LODState"), V = Symbol("Needle:CurrentLOD"), C = { mesh_lod: -1, texture_lod: -1 }, P = class {
528
528
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
529
529
  constructor(e, t) {
530
- h(this, "context");
531
- h(this, "renderer");
532
- h(this, "projectionScreenMatrix", new pe());
533
- h(this, "cameraFrustrum", new Ae());
530
+ f(this, "context");
531
+ f(this, "renderer");
532
+ f(this, "projectionScreenMatrix", new ye());
533
+ f(this, "cameraFrustrum", new Pe());
534
534
  /**
535
535
  * The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
536
536
  * @default 200_000
537
537
  */
538
- h(this, "targetTriangleDensity", 2e5);
538
+ f(this, "targetTriangleDensity", 2e5);
539
539
  /**
540
540
  * 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.
541
541
  */
542
- h(this, "updateInterval", 0);
542
+ f(this, "updateInterval", 0);
543
543
  /**
544
544
  * If set to true, the LODsManager will not update the LODs.
545
545
  */
546
- h(this, "pause", !1);
547
- h(this, "_frame", 0);
548
- h(this, "_originalRender");
546
+ f(this, "pause", !1);
547
+ f(this, "_lodchangedlisteners", []);
548
+ f(this, "_frame", 0);
549
+ f(this, "_originalRender");
549
550
  // private testIfLODLevelsAreAvailable() {
550
- h(this, "_sphere", new Pe());
551
- h(this, "_tempBox", new ye());
552
- h(this, "_tempBox2", new ye());
553
- h(this, "tempMatrix", new pe());
554
- h(this, "_tempWorldPosition", new I());
555
- h(this, "_tempBoxSize", new I());
556
- h(this, "_tempBox2Size", new I());
551
+ f(this, "_sphere", new Ce());
552
+ f(this, "_tempBox", new me());
553
+ f(this, "_tempBox2", new me());
554
+ f(this, "tempMatrix", new ye());
555
+ f(this, "_tempWorldPosition", new G());
556
+ f(this, "_tempBoxSize", new G());
557
+ f(this, "_tempBox2Size", new G());
557
558
  this.renderer = e, this.context = { ...t };
558
559
  }
559
560
  /** @internal */
560
561
  static getObjectLODState(e) {
561
- return e[le];
562
+ return e[ce];
562
563
  }
563
564
  static addPlugin(e) {
564
- $.push(e);
565
+ z.push(e);
565
566
  }
566
567
  static removePlugin(e) {
567
- const t = $.indexOf(e);
568
- t >= 0 && $.splice(t, 1);
568
+ const t = z.indexOf(e);
569
+ t >= 0 && z.splice(t, 1);
569
570
  }
570
571
  /**
571
572
  * Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
@@ -573,17 +574,20 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
573
574
  * @returns The LODsManager instance.
574
575
  */
575
576
  static get(e, t) {
576
- if (e[ae])
577
- return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), e[ae];
577
+ if (e[le])
578
+ return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), e[le];
578
579
  const r = new P(e, {
579
580
  engine: "unknown",
580
581
  ...t
581
582
  });
582
- return e[ae] = r, r;
583
+ return e[le] = r, r;
583
584
  }
584
585
  /** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
585
586
  get plugins() {
586
- return $;
587
+ return z;
588
+ }
589
+ addEventListener(e, t) {
590
+ e === "changed" && this._lodchangedlisteners.push(t);
587
591
  }
588
592
  /**
589
593
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
@@ -595,38 +599,38 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
595
599
  let e = 0;
596
600
  this._originalRender = this.renderer.render;
597
601
  const t = this;
598
- De(this.renderer), this.renderer.render = function(r, n) {
602
+ we(this.renderer), this.renderer.render = function(r, i) {
599
603
  t.renderer.getRenderTarget() == null && (e = 0, t._frame += 1);
600
604
  const s = t._frame, o = e++;
601
- t.onBeforeRender(r, n, o, s), t._originalRender.call(this, r, n), t.onAfterRender(r, n, o, s);
605
+ t.onBeforeRender(r, i, o, s), t._originalRender.call(this, r, i), t.onAfterRender(r, i, o, s);
602
606
  };
603
607
  }
604
608
  disable() {
605
609
  this._originalRender && (this.renderer.render = this._originalRender, this._originalRender = void 0);
606
610
  }
607
- onBeforeRender(e, t, r, n) {
611
+ onBeforeRender(e, t, r, i) {
608
612
  }
609
- onAfterRender(e, t, r, n) {
613
+ onAfterRender(e, t, r, i) {
610
614
  var a, d;
611
615
  if (this.pause)
612
616
  return;
613
- const i = this.renderer.renderLists.get(e, 0), s = i.opaque;
617
+ const n = this.renderer.renderLists.get(e, 0), s = n.opaque;
614
618
  let o = !0;
615
619
  if (s.length === 1) {
616
620
  const c = s[0].material;
617
621
  (c.name === "EffectMaterial" || c.name === "CopyShader") && (o = !1);
618
622
  }
619
623
  if ((t.parent && t.parent.type === "CubeCamera" || r >= 1 && t.type === "OrthographicCamera") && (o = !1), o) {
620
- if (ze || this.updateInterval > 0 && n % this.updateInterval != 0)
624
+ if (Ue || this.updateInterval > 0 && i % this.updateInterval != 0)
621
625
  return;
622
626
  this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this.cameraFrustrum.setFromProjectionMatrix(this.projectionScreenMatrix, this.renderer.coordinateSystem);
623
627
  const c = this.targetTriangleDensity;
624
- for (const f of s) {
625
- if (f.material && (((a = f.geometry) == null ? void 0 : a.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")) {
626
- 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)));
628
+ for (const u of s) {
629
+ if (u.material && (((a = u.geometry) == null ? void 0 : a.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")) {
630
+ N && (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)));
627
631
  continue;
628
632
  }
629
- switch (f.material.type) {
633
+ switch (u.material.type) {
630
634
  case "LineBasicMaterial":
631
635
  case "LineDashedMaterial":
632
636
  case "PointsMaterial":
@@ -635,34 +639,34 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
635
639
  case "MeshDepthMaterial":
636
640
  continue;
637
641
  }
638
- const y = f.object;
639
- (y instanceof V || y.isMesh) && this.updateLODs(e, t, y, c, n);
642
+ const y = u.object;
643
+ (y instanceof W || y.isMesh) && this.updateLODs(e, t, y, c, i);
640
644
  }
641
- const x = i.transparent;
642
- for (const f of x) {
643
- const y = f.object;
644
- (y instanceof V || y.isMesh) && this.updateLODs(e, t, y, c, n);
645
+ const x = n.transparent;
646
+ for (const u of x) {
647
+ const y = u.object;
648
+ (y instanceof W || y.isMesh) && this.updateLODs(e, t, y, c, i);
645
649
  }
646
650
  }
647
651
  }
648
652
  /** Update the LOD levels for the renderer. */
649
- updateLODs(e, t, r, n, i) {
653
+ updateLODs(e, t, r, i, n) {
650
654
  var a, d;
651
655
  r.userData || (r.userData = {});
652
- let s = r[le];
653
- if (s || (s = new Ue(), r[le] = s), s.frames++ < 2)
656
+ let s = r[ce];
657
+ if (s || (s = new Ne(), r[ce] = s), s.frames++ < 2)
654
658
  return;
655
- for (const c of $)
659
+ for (const c of z)
656
660
  (a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, e, t, r);
657
- this.calculateLodLevel(t, r, s, n, 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);
658
- let o = B.texture_lod;
661
+ this.calculateLodLevel(t, r, s, i, C), C.mesh_lod = Math.round(C.mesh_lod), C.texture_lod = Math.round(C.texture_lod), C.mesh_lod >= 0 && this.loadProgressiveMeshes(r, C.mesh_lod);
662
+ let o = C.texture_lod;
659
663
  if (r.material && o >= 0) {
660
664
  const c = r["DEBUG:LOD"];
661
665
  c != null && (o = c), this.loadProgressiveTextures(r.material, o);
662
666
  }
663
- for (const c of $)
664
- (d = c.onAfterUpdatedLOD) == null || d.call(c, this.renderer, e, t, r, B);
665
- s.lastLodLevel_Mesh = B.mesh_lod, s.lastLodLevel_Texture = B.texture_lod;
667
+ for (const c of z)
668
+ (d = c.onAfterUpdatedLOD) == null || d.call(c, this.renderer, e, t, r, C);
669
+ s.lastLodLevel_Mesh = C.mesh_lod, s.lastLodLevel_Texture = C.texture_lod;
666
670
  }
667
671
  /** Load progressive textures for the given material
668
672
  * @param material the material to load the textures for
@@ -673,12 +677,14 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
673
677
  if (!e)
674
678
  return;
675
679
  if (Array.isArray(e)) {
676
- for (const n of e)
677
- this.loadProgressiveTextures(n, t);
680
+ for (const i of e)
681
+ this.loadProgressiveTextures(i, t);
678
682
  return;
679
683
  }
680
684
  let r = !1;
681
- (e[N] === void 0 || t < e[N]) && (r = !0), r && (e[N] = t, O.assignTextureLOD(e, t));
685
+ (e[V] === void 0 || t < e[V]) && (r = !0), r && (e[V] = t, O.assignTextureLOD(e, t).then((i) => {
686
+ this._lodchangedlisteners.forEach((n) => n({ type: "texture", level: t, object: e }));
687
+ }));
682
688
  }
683
689
  /** Load progressive meshes for the given mesh
684
690
  * @param mesh the mesh to load the LOD for
@@ -689,110 +695,113 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
689
695
  loadProgressiveMeshes(e, t) {
690
696
  if (!e)
691
697
  return Promise.resolve(null);
692
- if (e[N] !== t) {
693
- e[N] = t;
698
+ if (e[V] !== t) {
699
+ e[V] = t;
694
700
  const r = e.geometry;
695
- return O.assignMeshLOD(e, t).then((n) => (n && e[N] == t && r != e.geometry, n));
701
+ return O.assignMeshLOD(e, t).then((i) => (i && e[V] == t && r != e.geometry && this._lodchangedlisteners.forEach((n) => n({ type: "mesh", level: t, object: e })), i));
696
702
  }
697
703
  return Promise.resolve(null);
698
704
  }
699
705
  static isInside(e, t) {
700
- const r = e.min, n = e.max, i = (r.x + n.x) * 0.5, s = (r.y + n.y) * 0.5;
701
- return this._tempPtInside.set(i, s, r.z).applyMatrix4(t).z < 0;
706
+ const r = e.min, i = e.max, n = (r.x + i.x) * 0.5, s = (r.y + i.y) * 0.5;
707
+ return this._tempPtInside.set(n, s, r.z).applyMatrix4(t).z < 0;
702
708
  }
703
- calculateLodLevel(e, t, r, n, i) {
704
- var k;
709
+ calculateLodLevel(e, t, r, i, n) {
710
+ var B, I;
705
711
  if (!t) {
706
- i.mesh_lod = -1, i.texture_lod = -1;
712
+ n.mesh_lod = -1, n.texture_lod = -1;
707
713
  return;
708
714
  }
709
715
  if (!e) {
710
- i.mesh_lod = -1, i.texture_lod = -1;
716
+ n.mesh_lod = -1, n.texture_lod = -1;
711
717
  return;
712
718
  }
713
719
  let o = 10 + 1, a = !1;
714
- if (U && t["DEBUG:LOD"] != null)
720
+ if (N && t["DEBUG:LOD"] != null)
715
721
  return t["DEBUG:LOD"];
716
- const d = O.getMeshLODInformation(t.geometry), c = d == null ? void 0 : d.lods, x = c && c.length > 0, f = O.getMaterialMinMaxLODsCount(t.material), y = (f == null ? void 0 : f.min_count) != 1 / 0 && f.min_count > 0 && f.max_count > 0;
722
+ const d = O.getMeshLODInformation(t.geometry), c = d == null ? void 0 : d.lods, x = c && c.length > 0, u = O.getMaterialMinMaxLODsCount(t.material), y = (u == null ? void 0 : u.min_count) != 1 / 0 && u.min_count > 0 && u.max_count > 0;
717
723
  if (!x && !y) {
718
- i.mesh_lod = 0, i.texture_lod = 0;
724
+ n.mesh_lod = 0, n.texture_lod = 0;
719
725
  return;
720
726
  }
721
- if (x || (a = !0, o = 0), !((k = this.cameraFrustrum) != null && k.intersectsObject(t))) {
722
- i.mesh_lod = 99, i.texture_lod = 99;
727
+ if (x || (a = !0, o = 0), !((B = this.cameraFrustrum) != null && B.intersectsObject(t))) {
728
+ n.mesh_lod = 99, n.texture_lod = 99;
723
729
  return;
724
730
  }
725
- const M = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
731
+ const w = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
726
732
  let L = t.geometry.boundingBox;
727
733
  if (t.type === "SkinnedMesh") {
728
- const w = t;
729
- w.boundingBox || w.computeBoundingBox(), L = w.boundingBox;
734
+ const p = t;
735
+ p.boundingBox || p.computeBoundingBox(), L = p.boundingBox;
730
736
  }
731
737
  if (L && e.isPerspectiveCamera) {
732
- const w = e;
738
+ const p = e;
733
739
  if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
734
740
  this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
735
- const u = e.getWorldPosition(this._tempWorldPosition);
736
- if (this._sphere.containsPoint(u)) {
737
- i.mesh_lod = 0, i.texture_lod = 0;
741
+ const h = e.getWorldPosition(this._tempWorldPosition);
742
+ if (this._sphere.containsPoint(h)) {
743
+ n.mesh_lod = 0, n.texture_lod = 0;
738
744
  return;
739
745
  }
740
746
  }
741
747
  if (this._tempBox.copy(L), this._tempBox.applyMatrix4(t.matrixWorld), P.isInside(this._tempBox, this.projectionScreenMatrix)) {
742
- i.mesh_lod = 0, i.texture_lod = 0;
748
+ n.mesh_lod = 0, n.texture_lod = 0;
743
749
  return;
744
750
  }
745
- if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && w.fov > 70) {
746
- const u = this._tempBox.min, p = this._tempBox.max;
747
- let v = u.x, _ = u.y, A = p.x, F = p.y;
748
- const Z = 2, ie = 1.5, j = (u.x + p.x) * 0.5, ee = (u.y + p.y) * 0.5;
749
- v = (v - j) * Z + j, _ = (_ - ee) * Z + ee, A = (A - j) * Z + j, F = (F - ee) * Z + ee;
750
- const ve = v < 0 && A > 0 ? 0 : Math.min(Math.abs(u.x), Math.abs(p.x)), Oe = _ < 0 && F > 0 ? 0 : Math.min(Math.abs(u.y), Math.abs(p.y)), ne = Math.max(ve, Oe);
751
- r.lastCentrality = (ie - ne) * (ie - ne) * (ie - ne);
751
+ if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && p.fov > 70) {
752
+ const h = this._tempBox.min, D = this._tempBox.max;
753
+ let b = h.x, T = h.y, A = D.x, K = D.y;
754
+ const j = 2, ne = 1.5, ee = (h.x + D.x) * 0.5, te = (h.y + D.y) * 0.5;
755
+ b = (b - ee) * j + ee, T = (T - te) * j + te, A = (A - ee) * j + ee, K = (K - te) * j + te;
756
+ const ve = b < 0 && A > 0 ? 0 : Math.min(Math.abs(h.x), Math.abs(D.x)), Oe = T < 0 && K > 0 ? 0 : Math.min(Math.abs(h.y), Math.abs(D.y)), oe = Math.max(ve, Oe);
757
+ r.lastCentrality = (ne - oe) * (ne - oe) * (ne - oe);
752
758
  } else
753
759
  r.lastCentrality = 1;
754
- const g = this._tempBox.getSize(this._tempBoxSize);
755
- g.multiplyScalar(0.5), screen.availHeight > 0 && M > 0 && g.multiplyScalar(M / screen.availHeight), g.x *= w.aspect;
756
- const z = e.matrixWorldInverse, C = this._tempBox2;
757
- C.copy(L), C.applyMatrix4(t.matrixWorld), C.applyMatrix4(z);
758
- const b = C.getSize(this._tempBox2Size), S = Math.max(b.x, b.y);
759
- if (Math.max(g.x, g.y) != 0 && S != 0 && (g.z = b.z / Math.max(b.x, b.y) * Math.max(g.x, g.y)), r.lastScreenCoverage = Math.max(g.x, g.y, g.z), r.lastScreenspaceVolume.copy(g), r.lastScreenCoverage *= r.lastCentrality, U && P.debugDrawLine) {
760
- const u = this.tempMatrix.copy(this.projectionScreenMatrix);
761
- u.invert();
762
- const p = P.corner0, v = P.corner1, _ = P.corner2, A = P.corner3;
763
- p.copy(this._tempBox.min), v.copy(this._tempBox.max), v.x = p.x, _.copy(this._tempBox.max), _.y = p.y, A.copy(this._tempBox.max);
764
- const F = (p.z + A.z) * 0.5;
765
- p.z = v.z = _.z = A.z = F, p.applyMatrix4(u), v.applyMatrix4(u), _.applyMatrix4(u), A.applyMatrix4(u), P.debugDrawLine(p, v, 255), P.debugDrawLine(p, _, 255), P.debugDrawLine(v, A, 255), P.debugDrawLine(_, A, 255);
760
+ const M = this._tempBox.getSize(this._tempBoxSize);
761
+ M.multiplyScalar(0.5), screen.availHeight > 0 && w > 0 && M.multiplyScalar(w / screen.availHeight), M.x *= p.aspect;
762
+ const U = e.matrixWorldInverse, k = this._tempBox2;
763
+ k.copy(L), k.applyMatrix4(t.matrixWorld), k.applyMatrix4(U);
764
+ const _ = k.getSize(this._tempBox2Size), $ = Math.max(_.x, _.y);
765
+ if (Math.max(M.x, M.y) != 0 && $ != 0 && (M.z = _.z / Math.max(_.x, _.y) * Math.max(M.x, M.y)), r.lastScreenCoverage = Math.max(M.x, M.y, M.z), r.lastScreenspaceVolume.copy(M), r.lastScreenCoverage *= r.lastCentrality, N && P.debugDrawLine) {
766
+ const h = this.tempMatrix.copy(this.projectionScreenMatrix);
767
+ h.invert();
768
+ const D = P.corner0, b = P.corner1, T = P.corner2, A = P.corner3;
769
+ D.copy(this._tempBox.min), b.copy(this._tempBox.max), b.x = D.x, T.copy(this._tempBox.max), T.y = D.y, A.copy(this._tempBox.max);
770
+ const K = (D.z + A.z) * 0.5;
771
+ D.z = b.z = T.z = A.z = K, D.applyMatrix4(h), b.applyMatrix4(h), T.applyMatrix4(h), A.applyMatrix4(h), P.debugDrawLine(D, b, 255), P.debugDrawLine(D, T, 255), P.debugDrawLine(b, A, 255), P.debugDrawLine(T, A, 255);
766
772
  }
767
- let R = 999;
773
+ let S = 999;
768
774
  if (c && r.lastScreenCoverage > 0) {
769
- for (let u = 0; u < c.length; u++)
770
- if (c[u].density / r.lastScreenCoverage < n) {
771
- R = u;
775
+ for (let h = 0; h < c.length; h++)
776
+ if (c[h].density / r.lastScreenCoverage < i) {
777
+ S = h;
772
778
  break;
773
779
  }
774
780
  }
775
- R < o && (o = R, a = !0);
781
+ S < o && (o = S, a = !0);
776
782
  }
777
- if (a ? i.mesh_lod = o : i.mesh_lod = r.lastLodLevel_Mesh, U && i.mesh_lod != r.lastLodLevel_Mesh) {
778
- const g = c == null ? void 0 : c[i.mesh_lod];
779
- g && console.log(`Mesh LOD changed: ${r.lastLodLevel_Mesh} → ${i.mesh_lod} (${g.density.toFixed(0)}) - ${t.name}`);
783
+ if (a ? n.mesh_lod = o : n.mesh_lod = r.lastLodLevel_Mesh, N && n.mesh_lod != r.lastLodLevel_Mesh) {
784
+ const M = c == null ? void 0 : c[n.mesh_lod];
785
+ M && console.log(`Mesh LOD changed: ${r.lastLodLevel_Mesh} → ${n.mesh_lod} (${M.density.toFixed(0)}) - ${t.name}`);
780
786
  }
781
787
  if (y)
782
788
  if (r.lastLodLevel_Texture < 0) {
783
- if (i.texture_lod = f.max_count - 1, U) {
784
- const w = f.lods[f.max_count - 1];
785
- U && console.log(`First Texture LOD ${i.texture_lod} (${w.max_height}px) - ${t.name}`);
789
+ if (n.texture_lod = u.max_count - 1, N) {
790
+ const p = u.lods[u.max_count - 1];
791
+ N && console.log(`First Texture LOD ${n.texture_lod} (${p.max_height}px) - ${t.name}`);
786
792
  }
787
793
  } else {
788
- const w = r.lastScreenspaceVolume.x + r.lastScreenspaceVolume.y + r.lastScreenspaceVolume.z, g = r.lastScreenCoverage * 2, C = M / window.devicePixelRatio * g;
789
- for (let b = f.lods.length - 1; b >= 0; b--) {
790
- let S = f.lods[b];
791
- if (!(Ie() && S.max_height > 4096) && S.max_height > C) {
792
- if (i.texture_lod = b, i.texture_lod < r.lastLodLevel_Texture) {
793
- const W = S.max_height;
794
- U && console.log(`Texture LOD changed: ${r.lastLodLevel_Texture} ${i.texture_lod} = ${W}px
795
- Screensize: ${C.toFixed(0)}px, Coverage: ${(100 * r.lastScreenCoverage).toFixed(2)}%, Volume ${w.toFixed(1)}
794
+ const p = r.lastScreenspaceVolume.x + r.lastScreenspaceVolume.y + r.lastScreenspaceVolume.z;
795
+ let M = r.lastScreenCoverage * 2;
796
+ ((I = this.context) == null ? void 0 : I.engine) === "model-viewer" && (M *= 2);
797
+ const k = w / window.devicePixelRatio * M;
798
+ for (let _ = u.lods.length - 1; _ >= 0; _--) {
799
+ let $ = u.lods[_];
800
+ if (!(Ge() && $.max_height > 4096) && $.max_height > k) {
801
+ if (n.texture_lod = _, n.texture_lod < r.lastLodLevel_Texture) {
802
+ const R = $.max_height;
803
+ N && console.log(`Texture LOD changed: ${r.lastLodLevel_Texture} → ${n.texture_lod} = ${R}px
804
+ Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * r.lastScreenCoverage).toFixed(2)}%, Volume ${p.toFixed(1)}
796
805
  ${t.name}`);
797
806
  }
798
807
  break;
@@ -800,66 +809,74 @@ ${t.name}`);
800
809
  }
801
810
  }
802
811
  else
803
- i.texture_lod = 0;
812
+ n.texture_lod = 0;
804
813
  }
805
814
  };
806
815
  let E = P;
807
816
  /** 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.
808
817
  */
809
- h(E, "debugDrawLine"), h(E, "corner0", new I()), h(E, "corner1", new I()), h(E, "corner2", new I()), h(E, "corner3", new I()), h(E, "_tempPtInside", new I());
810
- class Ue {
818
+ f(E, "debugDrawLine"), f(E, "corner0", new G()), f(E, "corner1", new G()), f(E, "corner2", new G()), f(E, "corner3", new G()), f(E, "_tempPtInside", new G());
819
+ class Ne {
811
820
  constructor() {
812
- h(this, "frames", 0);
813
- h(this, "lastLodLevel_Mesh", -1);
814
- h(this, "lastLodLevel_Texture", -1);
815
- h(this, "lastScreenCoverage", 0);
816
- h(this, "lastScreenspaceVolume", new I());
817
- h(this, "lastCentrality", 0);
821
+ f(this, "frames", 0);
822
+ f(this, "lastLodLevel_Mesh", -1);
823
+ f(this, "lastLodLevel_Texture", -1);
824
+ f(this, "lastScreenCoverage", 0);
825
+ f(this, "lastScreenspaceVolume", new G());
826
+ f(this, "lastCentrality", 0);
818
827
  }
819
828
  }
820
- const xe = Symbol("NEEDLE_mesh_lod"), te = Symbol("NEEDLE_texture_lod");
821
- function Ne() {
822
- document.removeEventListener("DOMContentLoaded", ce), document.addEventListener("DOMContentLoaded", ce), ce();
829
+ const Le = Symbol("NEEDLE_mesh_lod"), re = Symbol("NEEDLE_texture_lod");
830
+ function Ve() {
831
+ document.removeEventListener("DOMContentLoaded", ue), document.addEventListener("DOMContentLoaded", ue), ue();
823
832
  }
824
- function ce() {
833
+ function ue() {
825
834
  document.querySelectorAll("model-viewer").forEach((e, t) => {
826
- Ve(e, t);
835
+ We(e, t);
827
836
  });
828
837
  }
829
- const Le = /* @__PURE__ */ new WeakSet();
830
- function Ve(l, e) {
831
- if (!l || Le.has(l))
838
+ const Me = /* @__PURE__ */ new WeakSet();
839
+ function We(l, e) {
840
+ if (!l || Me.has(l))
832
841
  return null;
833
- Le.add(l), console.debug("[gltf-progressive] found model-viewer..." + e);
834
- let t = null, r = null, n = null;
835
- for (let i = l; i != null; i = Object.getPrototypeOf(i)) {
836
- const s = Object.getOwnPropertySymbols(i), o = s.find((c) => c.toString() == "Symbol(renderer)"), a = s.find((c) => c.toString() == "Symbol(scene)"), d = s.find((c) => c.toString() == "Symbol(needsRender)");
837
- !t && o != null && (t = l[o].threeRenderer), !r && a != null && (r = l[a]), !n && d != null && (n = l[d]);
842
+ Me.add(l), console.debug("[gltf-progressive] found model-viewer..." + e);
843
+ let t = null, r = null, i = null;
844
+ for (let n = l; n != null; n = Object.getPrototypeOf(n)) {
845
+ const s = Object.getOwnPropertySymbols(n), o = s.find((c) => c.toString() == "Symbol(renderer)"), a = s.find((c) => c.toString() == "Symbol(scene)"), d = s.find((c) => c.toString() == "Symbol(needsRender)");
846
+ !t && o != null && (t = l[o].threeRenderer), !r && a != null && (r = l[a]), !i && d != null && (i = l[d]);
838
847
  }
839
848
  if (t && r) {
849
+ let n = function() {
850
+ if (i) {
851
+ let o = 0, a = setInterval(() => {
852
+ if (o++ > 5) {
853
+ clearInterval(a);
854
+ return;
855
+ }
856
+ i == null || i.call(l);
857
+ }, 300);
858
+ }
859
+ };
840
860
  console.debug("[gltf-progressive] setup model-viewer");
841
- const i = E.get(t, { engine: "model-viewer" });
842
- if (E.addPlugin(new We()), i.enable(), r && n) {
843
- let s = 0, o = setInterval(() => {
844
- if (s++ > 10) {
845
- clearInterval(o);
846
- return;
847
- }
848
- n == null || n.call(l);
849
- }, 150);
850
- }
851
- return () => {
852
- i.disable();
861
+ const s = E.get(t, { engine: "model-viewer" });
862
+ return E.addPlugin(new Ke()), s.enable(), s.addEventListener("changed", () => {
863
+ i == null || i.call(l);
864
+ }), l.addEventListener("model-visibility", (o) => {
865
+ o.detail.visible && (i == null || i.call(l));
866
+ }), l.addEventListener("load", () => {
867
+ n();
868
+ }), () => {
869
+ s.disable();
853
870
  };
854
871
  }
855
872
  return null;
856
873
  }
857
- class We {
874
+ class Ke {
858
875
  constructor() {
859
- h(this, "_didWarnAboutMissingUrl", !1);
876
+ f(this, "_didWarnAboutMissingUrl", !1);
860
877
  }
861
- onBeforeUpdateLOD(e, t, r, n) {
862
- this.tryParseMeshLOD(t, n), this.tryParseTextureLOD(t, n);
878
+ onBeforeUpdateLOD(e, t, r, i) {
879
+ this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
863
880
  }
864
881
  getUrl(e) {
865
882
  if (!e)
@@ -874,31 +891,31 @@ class We {
874
891
  return e.element;
875
892
  }
876
893
  tryParseTextureLOD(e, t) {
877
- if (t[te] == !0)
894
+ if (t[re] == !0)
878
895
  return;
879
- t[te] = !0;
880
- const r = this.tryGetCurrentGLTF(e), n = this.tryGetCurrentModelViewer(e), i = this.getUrl(n);
881
- if (i && r && t.material) {
896
+ t[re] = !0;
897
+ const r = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), n = this.getUrl(i);
898
+ if (n && r && t.material) {
882
899
  let s = function(a) {
883
- var c, x, f;
884
- if (a[te] == !0)
900
+ var c, x, u;
901
+ if (a[re] == !0)
885
902
  return;
886
- a[te] = !0, a.userData && (a.userData.LOD = -1);
903
+ a[re] = !0, a.userData && (a.userData.LOD = -1);
887
904
  const d = Object.keys(a);
888
905
  for (let y = 0; y < d.length; y++) {
889
- const M = d[y], L = a[M];
906
+ const w = d[y], L = a[w];
890
907
  if ((L == null ? void 0 : L.isTexture) === !0) {
891
- const k = (x = (c = L.userData) == null ? void 0 : c.associations) == null ? void 0 : x.textures;
892
- if (k == null)
908
+ const B = (x = (c = L.userData) == null ? void 0 : c.associations) == null ? void 0 : x.textures;
909
+ if (B == null)
893
910
  continue;
894
- const w = r.parser.json.textures[k];
895
- if (!w) {
896
- console.warn("Texture data not found for texture index " + k);
911
+ const I = r.parser.json.textures[B];
912
+ if (!I) {
913
+ console.warn("Texture data not found for texture index " + B);
897
914
  continue;
898
915
  }
899
- if ((f = w == null ? void 0 : w.extensions) != null && f[G]) {
900
- const g = w.extensions[G];
901
- g && i && O.registerTexture(i, L, g.lods.length, k, g);
916
+ if ((u = I == null ? void 0 : I.extensions) != null && u[F]) {
917
+ const p = I.extensions[F];
918
+ p && n && O.registerTexture(n, L, p.lods.length, B, p);
902
919
  }
903
920
  }
904
921
  }
@@ -913,37 +930,37 @@ class We {
913
930
  }
914
931
  tryParseMeshLOD(e, t) {
915
932
  var s, o;
916
- if (t[xe] == !0)
933
+ if (t[Le] == !0)
917
934
  return;
918
- t[xe] = !0;
919
- const r = this.tryGetCurrentModelViewer(e), n = this.getUrl(r);
920
- if (!n)
935
+ t[Le] = !0;
936
+ const r = this.tryGetCurrentModelViewer(e), i = this.getUrl(r);
937
+ if (!i)
921
938
  return;
922
- const i = (o = (s = t.userData) == null ? void 0 : s.gltfExtensions) == null ? void 0 : o[G];
923
- if (i && n) {
939
+ const n = (o = (s = t.userData) == null ? void 0 : s.gltfExtensions) == null ? void 0 : o[F];
940
+ if (n && i) {
924
941
  const a = t.uuid;
925
- O.registerMesh(n, a, t, 0, i.lods.length, i);
942
+ O.registerMesh(i, a, t, 0, n.lods.length, n);
926
943
  }
927
944
  }
928
945
  }
929
- Ne();
930
- function et(l, e, t, r) {
931
- De(e), we(t), t.register((i) => new O(i, l));
932
- const n = E.get(e);
933
- return (r == null ? void 0 : r.enableLODsManager) !== !1 && n.enable(), n;
946
+ Ve();
947
+ function tt(l, e, t, r) {
948
+ we(e), _e(t), t.register((n) => new O(n, l));
949
+ const i = E.get(e);
950
+ return (r == null ? void 0 : r.enableLODsManager) !== !1 && i.enable(), i;
934
951
  }
935
952
  export {
936
- G as EXTENSION_NAME,
953
+ F as EXTENSION_NAME,
937
954
  E as LODsManager,
938
955
  O as NEEDLE_progressive,
939
- Me as VERSION,
940
- we as addDracoAndKTX2Loaders,
941
- De as createLoaders,
942
- ge as getRaycastMesh,
943
- Ne as patchModelViewer,
944
- Qe as setDracoDecoderLocation,
945
- Ze as setKTX2TranscoderLocation,
946
- Ge as setRaycastMesh,
947
- et as useNeedleProgressive,
948
- je as useRaycastMeshes
956
+ De as VERSION,
957
+ _e as addDracoAndKTX2Loaders,
958
+ we as createLoaders,
959
+ pe as getRaycastMesh,
960
+ Ve as patchModelViewer,
961
+ Ze as setDracoDecoderLocation,
962
+ je as setKTX2TranscoderLocation,
963
+ Fe as setRaycastMesh,
964
+ tt as useNeedleProgressive,
965
+ et as useRaycastMeshes
949
966
  };