@needle-tools/gltf-progressive 1.2.5-beta → 1.2.6

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