@needle-tools/gltf-progressive 2.1.0-experimental.3 → 2.1.1

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