@needle-tools/gltf-progressive 3.1.0 → 3.1.1-next.26e0b81

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,249 +1,406 @@
1
- var Ye = Object.defineProperty;
2
- var He = (o, t, e) => t in o ? Ye(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var u = (o, t, e) => (He(o, typeof t != "symbol" ? t + "" : t, e), e), Be = (o, t, e) => {
4
- if (!t.has(o))
5
- throw TypeError("Cannot " + e);
1
+ var tt = Object.defineProperty;
2
+ var st = (o, e, t) => e in o ? tt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var d = (o, e, t) => (st(o, typeof e != "symbol" ? e + "" : e, t), t), Ee = (o, e, t) => {
4
+ if (!e.has(o))
5
+ throw TypeError("Cannot " + t);
6
6
  };
7
- var y = (o, t, e) => (Be(o, t, "read from private field"), e ? e.call(o) : t.get(o)), H = (o, t, e) => {
8
- if (t.has(o))
7
+ var D = (o, e, t) => (Ee(o, e, "read from private field"), t ? t.call(o) : e.get(o)), Q = (o, e, t) => {
8
+ if (e.has(o))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- t instanceof WeakSet ? t.add(o) : t.set(o, e);
11
- }, q = (o, t, e, s) => (Be(o, t, "write to private field"), s ? s.call(o, e) : t.set(o, e), e);
12
- import { BufferGeometry as xe, Mesh as se, Texture as oe, TextureLoader as Qe, Matrix4 as Ge, Clock as je, MeshStandardMaterial as Je, Sphere as Ze, Box3 as Ee, Vector3 as W } from "three";
13
- import { GLTFLoader as Ce } from "three/examples/jsm/loaders/GLTFLoader.js";
14
- import { MeshoptDecoder as et } from "three/examples/jsm/libs/meshopt_decoder.module.js";
15
- import { DRACOLoader as tt } from "three/examples/jsm/loaders/DRACOLoader.js";
16
- import { KTX2Loader as st } from "three/examples/jsm/loaders/KTX2Loader.js";
17
- const rt = "";
18
- globalThis.GLTF_PROGRESSIVE_VERSION = rt;
10
+ e instanceof WeakSet ? e.add(o) : e.set(o, t);
11
+ }, K = (o, e, t, s) => (Ee(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t);
12
+ import { BufferGeometry as he, Mesh as ne, Box3 as Ce, Vector3 as W, Sphere as qe, CompressedTexture as rt, Texture as se, Matrix3 as nt, InterleavedBuffer as it, InterleavedBufferAttribute as ot, BufferAttribute as at, TextureLoader as lt, Matrix4 as Fe, Clock as ut, MeshStandardMaterial as dt } from "three";
13
+ import { GLTFLoader as Re } from "three/examples/jsm/loaders/GLTFLoader.js";
14
+ import { MeshoptDecoder as ct } from "three/examples/jsm/libs/meshopt_decoder.module.js";
15
+ import { DRACOLoader as ft } from "three/examples/jsm/loaders/DRACOLoader.js";
16
+ import { KTX2Loader as ht } from "three/examples/jsm/loaders/KTX2Loader.js";
17
+ const gt = "";
18
+ globalThis.GLTF_PROGRESSIVE_VERSION = gt;
19
19
  console.debug("[gltf-progressive] version -");
20
- let V = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", re = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
21
- const it = V, nt = re, Re = new URL(V + "draco_decoder.js");
22
- Re.searchParams.append("range", "true");
23
- fetch(Re, {
20
+ let q = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", ie = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
21
+ const pt = q, mt = ie, Ve = new URL(q + "draco_decoder.js");
22
+ Ve.searchParams.append("range", "true");
23
+ fetch(Ve, {
24
24
  method: "GET",
25
25
  headers: {
26
26
  Range: "bytes=0-1"
27
27
  }
28
28
  }).catch((o) => {
29
- console.debug(`Failed to fetch remote Draco decoder from ${V} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), V === it && ot("./include/draco/"), re === nt && at("./include/ktx2/");
29
+ console.debug(`Failed to fetch remote Draco decoder from ${q} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), q === pt && xt("./include/draco/"), ie === mt && wt("./include/ktx2/");
30
30
  }).finally(() => {
31
- Fe();
31
+ Ke();
32
32
  });
33
- function ot(o) {
34
- V = o, I && I[Pe] != V ? (console.debug("Updating Draco decoder path to " + o), I[Pe] = V, I.setDecoderPath(V), I.preload()) : console.debug("Setting Draco decoder path to " + o);
33
+ const yt = () => ({
34
+ dracoDecoderPath: q,
35
+ ktx2TranscoderPath: ie
36
+ });
37
+ function xt(o) {
38
+ q = o, N && N[ke] != q ? (console.debug("Updating Draco decoder path to " + o), N[ke] = q, N.setDecoderPath(q), N.preload()) : console.debug("Setting Draco decoder path to " + o);
35
39
  }
36
- function at(o) {
37
- re = o, U && U.transcoderPath != re ? (console.debug("Updating KTX2 transcoder path to " + o), U.setTranscoderPath(re), U.init()) : console.debug("Setting KTX2 transcoder path to " + o);
40
+ function wt(o) {
41
+ ie = o, V && V.transcoderPath != ie ? (console.debug("Updating KTX2 transcoder path to " + o), V.setTranscoderPath(ie), V.init()) : console.debug("Setting KTX2 transcoder path to " + o);
38
42
  }
39
- const Pe = Symbol("dracoDecoderPath");
40
- let I, Le, U;
41
- function Fe() {
42
- I || (I = new tt(), I[Pe] = V, I.setDecoderPath(V), I.setDecoderConfig({ type: "js" }), I.preload()), U || (U = new st(), U.setTranscoderPath(re), U.init()), Le || (Le = et);
43
+ function $e(o) {
44
+ return Ke(), o ? V.detectSupport(o) : o !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: N, ktx2Loader: V, meshoptDecoder: _e };
43
45
  }
44
- function Ue(o) {
45
- return Fe(), o ? U.detectSupport(o) : o !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: I, ktx2Loader: U, meshoptDecoder: Le };
46
+ function Xe(o) {
47
+ o.dracoLoader || o.setDRACOLoader(N), o.ktx2Loader || o.setKTX2Loader(V), o.meshoptDecoder || o.setMeshoptDecoder(_e);
46
48
  }
47
- function Ne(o) {
48
- o.dracoLoader || o.setDRACOLoader(I), o.ktx2Loader || o.setKTX2Loader(U), o.meshoptDecoder || o.setMeshoptDecoder(Le);
49
+ const ke = Symbol("dracoDecoderPath");
50
+ let N, _e, V;
51
+ function Ke() {
52
+ N || (N = new ft(), N[ke] = q, N.setDecoderPath(q), N.setDecoderConfig({ type: "js" }), N.preload()), V || (V = new ht(), V.setTranscoderPath(ie), V.init()), _e || (_e = ct);
49
53
  }
50
- const Te = /* @__PURE__ */ new WeakMap();
51
- function ze(o, t) {
52
- let e = Te.get(o);
53
- e ? e = Object.assign(e, t) : e = t, Te.set(o, e);
54
+ const Ie = /* @__PURE__ */ new WeakMap();
55
+ function Ye(o, e) {
56
+ let t = Ie.get(o);
57
+ t ? t = Object.assign(t, e) : t = e, Ie.set(o, t);
54
58
  }
55
- const De = Ce.prototype.load;
56
- function lt(...o) {
57
- const t = Te.get(this);
58
- let e = o[0];
59
- const s = new URL(e, window.location.href);
59
+ const Oe = Re.prototype.load;
60
+ function Lt(...o) {
61
+ const e = Ie.get(this);
62
+ let t = o[0];
63
+ const s = new URL(t, window.location.href);
60
64
  if (s.hostname.endsWith("needle.tools")) {
61
- const r = (t == null ? void 0 : t.progressive) !== void 0 ? t.progressive : !0, i = t != null && t.usecase ? t.usecase : "default";
62
- r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${i}` : this.requestHeader.Accept = `*/*;usecase=${i}`, e = s.toString();
65
+ const r = (e == null ? void 0 : e.progressive) !== void 0 ? e.progressive : !0, n = e != null && e.usecase ? e.usecase : "default";
66
+ r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${n}` : this.requestHeader.Accept = `*/*;usecase=${n}`, t = s.toString();
63
67
  }
64
- return o[0] = e, De == null ? void 0 : De.call(this, ...o);
68
+ return o[0] = t, Oe == null ? void 0 : Oe.call(this, ...o);
65
69
  }
66
- Ce.prototype.load = lt;
67
- de("debugprogressive");
68
- function de(o) {
70
+ Re.prototype.load = Lt;
71
+ oe("debugprogressive");
72
+ function oe(o) {
69
73
  if (typeof window > "u")
70
74
  return !1;
71
- const e = new URL(window.location.href).searchParams.get(o);
72
- return e == null || e === "0" || e === "false" ? !1 : e === "" ? !0 : e;
75
+ const t = new URL(window.location.href).searchParams.get(o);
76
+ return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
73
77
  }
74
- function ut(o, t) {
75
- if (t === void 0 || t.startsWith("./") || t.startsWith("http") || o === void 0)
76
- return t;
77
- const e = o.lastIndexOf("/");
78
- if (e >= 0) {
79
- const s = o.substring(0, e + 1);
80
- for (; s.endsWith("/") && t.startsWith("/"); )
81
- t = t.substring(1);
82
- return s + t;
83
- }
84
- return t;
78
+ function _t(o, e) {
79
+ if (e === void 0 || e.startsWith("./") || e.startsWith("http") || o === void 0)
80
+ return e;
81
+ const t = o.lastIndexOf("/");
82
+ if (t >= 0) {
83
+ const s = o.substring(0, t + 1);
84
+ for (; s.endsWith("/") && e.startsWith("/"); )
85
+ e = e.substring(1);
86
+ return s + e;
87
+ }
88
+ return e;
85
89
  }
86
- let ae;
87
- function dt() {
88
- return ae !== void 0 || (ae = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), de("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", ae)), ae;
90
+ let ue;
91
+ function je() {
92
+ return ue !== void 0 || (ue = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), oe("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", ue)), ue;
89
93
  }
90
- function ct() {
94
+ function Ne() {
91
95
  if (typeof window > "u")
92
96
  return !1;
93
- const o = new URL(window.location.href), t = o.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);
94
- return o.hostname === "127.0.0.1" || t;
97
+ const o = new URL(window.location.href), e = o.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);
98
+ return o.hostname === "127.0.0.1" || e;
95
99
  }
96
- class ft {
97
- constructor(t = 100, e = {}) {
98
- u(this, "_running", /* @__PURE__ */ new Map());
99
- u(this, "_queue", []);
100
- u(this, "debug", !1);
101
- u(this, "tick", () => {
100
+ class Mt {
101
+ constructor(e = 100, t = {}) {
102
+ d(this, "_running", /* @__PURE__ */ new Map());
103
+ d(this, "_queue", []);
104
+ d(this, "debug", !1);
105
+ d(this, "tick", () => {
102
106
  this.internalUpdate(), setTimeout(this.tick, 10);
103
107
  });
104
- this.maxConcurrent = t, this.debug = e.debug ?? !1, window.requestAnimationFrame(this.tick);
108
+ this.maxConcurrent = e, this.debug = t.debug ?? !1, window.requestAnimationFrame(this.tick);
105
109
  }
106
110
  /**
107
111
  * Request a slot for a promise with a specific key. This function returns a promise with a `use` method that can be called to add the promise to the queue.
108
112
  */
109
- slot(t) {
110
- return this.debug && console.debug(`[PromiseQueue]: Requesting slot for key ${t}, running: ${this._running.size}, waiting: ${this._queue.length}`), new Promise((e) => {
111
- this._queue.push({ key: t, resolve: e });
113
+ slot(e) {
114
+ return this.debug && console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`), new Promise((t) => {
115
+ this._queue.push({ key: e, resolve: t });
112
116
  });
113
117
  }
114
- add(t, e) {
115
- this._running.has(t) || (this._running.set(t, e), e.finally(() => {
116
- this._running.delete(t), this.debug && console.debug(`[PromiseQueue]: Promise for key ${t} finished, running: ${this._running.size}, waiting: ${this._queue.length}`);
117
- }), this.debug && console.debug(`[PromiseQueue]: Adding promise for key ${t}, running: ${this._running.size}, waiting: ${this._queue.length}`));
118
+ add(e, t) {
119
+ this._running.has(e) || (this._running.set(e, t), t.finally(() => {
120
+ this._running.delete(e), this.debug && console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`);
121
+ }), this.debug && console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`));
118
122
  }
119
123
  internalUpdate() {
120
- const t = this.maxConcurrent - this._running.size;
121
- for (let e = 0; e < t && this._queue.length > 0; e++) {
124
+ const e = this.maxConcurrent - this._running.size;
125
+ for (let t = 0; t < e && this._queue.length > 0; t++) {
122
126
  this.debug && console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);
123
- const { key: s, resolve: n } = this._queue.shift();
124
- n({
127
+ const { key: s, resolve: i } = this._queue.shift();
128
+ i({
125
129
  use: (r) => this.add(s, r)
126
130
  });
127
131
  }
128
132
  }
129
133
  }
130
- const ht = typeof window > "u" && typeof document > "u", Ae = Symbol("needle:raycast-mesh");
131
- function ce(o) {
132
- return (o == null ? void 0 : o[Ae]) instanceof xe ? o[Ae] : null;
134
+ const vt = typeof window > "u" && typeof document > "u", Be = Symbol("needle:raycast-mesh");
135
+ function ge(o) {
136
+ return (o == null ? void 0 : o[Be]) instanceof he ? o[Be] : null;
133
137
  }
134
- function gt(o, t) {
135
- if ((o.type === "Mesh" || o.type === "SkinnedMesh") && !ce(o)) {
136
- const s = mt(t);
137
- s.userData = { isRaycastMesh: !0 }, o[Ae] = s;
138
+ function Dt(o, e) {
139
+ if ((o.type === "Mesh" || o.type === "SkinnedMesh") && !ge(o)) {
140
+ const s = Ot(e);
141
+ s.userData = { isRaycastMesh: !0 }, o[Be] = s;
138
142
  }
139
143
  }
140
- function pt(o = !0) {
144
+ function bt(o = !0) {
141
145
  if (o) {
142
- if (le)
146
+ if (de)
143
147
  return;
144
- const t = le = se.prototype.raycast;
145
- se.prototype.raycast = function(e, s) {
146
- const n = this, r = ce(n);
147
- let i;
148
- r && n.isMesh && (i = n.geometry, n.geometry = r), t.call(this, e, s), i && (n.geometry = i);
148
+ const e = de = ne.prototype.raycast;
149
+ ne.prototype.raycast = function(t, s) {
150
+ const i = this, r = ge(i);
151
+ let n;
152
+ r && i.isMesh && (n = i.geometry, i.geometry = r), e.call(this, t, s), n && (i.geometry = n);
149
153
  };
150
154
  } else {
151
- if (!le)
155
+ if (!de)
152
156
  return;
153
- se.prototype.raycast = le, le = null;
157
+ ne.prototype.raycast = de, de = null;
154
158
  }
155
159
  }
156
- let le = null;
157
- function mt(o) {
158
- const t = new xe();
159
- for (const e in o.attributes)
160
- t.setAttribute(e, o.getAttribute(e));
161
- return t.setIndex(o.getIndex()), t;
160
+ let de = null;
161
+ function Ot(o) {
162
+ const e = new he();
163
+ for (const t in o.attributes)
164
+ e.setAttribute(t, o.getAttribute(t));
165
+ return e.setIndex(o.getIndex()), e;
162
166
  }
163
- const j = new Array(), x = de("debugprogressive");
164
- let me, te = -1;
167
+ const Z = new Array(), x = oe("debugprogressive");
168
+ let we, re = -1;
165
169
  if (x) {
166
170
  let o = function() {
167
- te += 1, te >= t && (te = -1), console.log(`Toggle LOD level [${te}]`);
168
- }, t = 6;
169
- window.addEventListener("keyup", (e) => {
170
- e.key === "p" && o(), e.key === "w" && (me = !me, console.log(`Toggle wireframe [${me}]`));
171
- const s = parseInt(e.key);
172
- !isNaN(s) && s >= 0 && (te = s, console.log(`Set LOD level to [${te}]`));
171
+ re += 1, re >= e && (re = -1), console.log(`Toggle LOD level [${re}]`);
172
+ }, e = 6;
173
+ window.addEventListener("keyup", (t) => {
174
+ t.key === "p" && o(), t.key === "w" && (we = !we, console.log(`Toggle wireframe [${we}]`));
175
+ const s = parseInt(t.key);
176
+ !isNaN(s) && s >= 0 && (re = s, console.log(`Set LOD level to [${re}]`));
173
177
  });
174
178
  }
175
- function qe(o) {
179
+ function He(o) {
176
180
  if (x)
177
181
  if (Array.isArray(o))
178
- for (const t of o)
179
- qe(t);
182
+ for (const e of o)
183
+ He(e);
180
184
  else
181
- o && "wireframe" in o && (o.wireframe = me === !0);
185
+ o && "wireframe" in o && (o.wireframe = we === !0);
186
+ }
187
+ const ce = new Array();
188
+ let St = 0;
189
+ const Pt = je() ? 2 : 10;
190
+ function Tt(o) {
191
+ if (ce.length < Pt) {
192
+ const s = ce.length;
193
+ x && console.warn(`[Worker] Creating new worker #${s}`);
194
+ const i = Ge.createWorker(o || {});
195
+ return ce.push(i), i;
196
+ }
197
+ const e = St++ % ce.length;
198
+ return ce[e];
199
+ }
200
+ class Ge {
201
+ constructor(e, t) {
202
+ d(this, "_running", []);
203
+ d(this, "_webglRenderer", null);
204
+ d(this, "_debug", !1);
205
+ this.worker = e, this._debug = t.debug ?? !1, e.onmessage = (s) => {
206
+ const i = s.data;
207
+ switch (this._debug && console.log("[Worker] EVENT", i), i.type) {
208
+ case "loaded-gltf":
209
+ for (const r of this._running)
210
+ if (r.url === i.result.url) {
211
+ At(i.result), r.resolve(i.result);
212
+ const n = r.url;
213
+ n.startsWith("blob:") && URL.revokeObjectURL(n);
214
+ }
215
+ }
216
+ }, e.onerror = (s) => {
217
+ console.error("[Worker] Error in gltf-progressive worker:", s);
218
+ }, e.postMessage({
219
+ type: "init"
220
+ });
221
+ }
222
+ static async createWorker(e) {
223
+ const t = new Worker(new URL("/assets/loader.worker-c528e7f2.js", self.location), {
224
+ type: "module"
225
+ });
226
+ return new Ge(t, e);
227
+ }
228
+ async load(e, t) {
229
+ const s = yt();
230
+ let i = t == null ? void 0 : t.renderer;
231
+ i || (this._webglRenderer ?? (this._webglRenderer = (async () => {
232
+ const { WebGLRenderer: u } = await import("three");
233
+ return new u();
234
+ })()), i = await this._webglRenderer);
235
+ const a = $e(i).ktx2Loader.workerConfig;
236
+ e instanceof URL ? e = e.toString() : e.startsWith("file:") ? e = URL.createObjectURL(new Blob([e])) : !e.startsWith("blob:") && !e.startsWith("http:") && !e.startsWith("https:") && (e = new URL(e, window.location.href).toString());
237
+ const l = {
238
+ type: "load",
239
+ url: e,
240
+ dracoDecoderPath: s.dracoDecoderPath,
241
+ ktx2TranscoderPath: s.ktx2TranscoderPath,
242
+ ktx2LoaderConfig: a
243
+ };
244
+ return this._debug && console.debug("[Worker] Sending load request", l), this.worker.postMessage(l), new Promise((u) => {
245
+ this._running.push({
246
+ url: e.toString(),
247
+ resolve: u
248
+ });
249
+ });
250
+ }
251
+ }
252
+ function At(o) {
253
+ var e, t, s, i, r, n, a, l, u, f, m, _, w, O, M, B;
254
+ for (const b of o.geometries) {
255
+ const c = b.geometry, v = new he();
256
+ if (v.name = c.name || "", c.index) {
257
+ const h = c.index;
258
+ v.setIndex(Se(h));
259
+ }
260
+ for (const h in c.attributes) {
261
+ const L = c.attributes[h], T = Se(L);
262
+ v.setAttribute(h, T);
263
+ }
264
+ if (c.morphAttributes)
265
+ for (const h in c.morphAttributes) {
266
+ const T = c.morphAttributes[h].map((U) => Se(U));
267
+ v.morphAttributes[h] = T;
268
+ }
269
+ if (v.morphTargetsRelative = c.morphTargetsRelative ?? !1, v.boundingBox = new Ce(), v.boundingBox.min = new W(
270
+ (e = c.boundingBox) == null ? void 0 : e.min.x,
271
+ (t = c.boundingBox) == null ? void 0 : t.min.y,
272
+ (s = c.boundingBox) == null ? void 0 : s.min.z
273
+ ), v.boundingBox.max = new W(
274
+ (i = c.boundingBox) == null ? void 0 : i.max.x,
275
+ (r = c.boundingBox) == null ? void 0 : r.max.y,
276
+ (n = c.boundingBox) == null ? void 0 : n.max.z
277
+ ), v.boundingSphere = new qe(
278
+ new W(
279
+ (a = c.boundingSphere) == null ? void 0 : a.center.x,
280
+ (l = c.boundingSphere) == null ? void 0 : l.center.y,
281
+ (u = c.boundingSphere) == null ? void 0 : u.center.z
282
+ ),
283
+ (f = c.boundingSphere) == null ? void 0 : f.radius
284
+ ), c.groups)
285
+ for (const h of c.groups)
286
+ v.addGroup(h.start, h.count, h.materialIndex);
287
+ c.userData && (v.userData = c.userData), b.geometry = v;
288
+ }
289
+ for (const b of o.textures) {
290
+ const c = b.texture;
291
+ let v = null;
292
+ if (c.isCompressedTexture) {
293
+ const h = c.mipmaps, L = ((m = c.image) == null ? void 0 : m.width) || ((w = (_ = c.source) == null ? void 0 : _.data) == null ? void 0 : w.width) || -1, T = ((O = c.image) == null ? void 0 : O.height) || ((B = (M = c.source) == null ? void 0 : M.data) == null ? void 0 : B.height) || -1;
294
+ v = new rt(
295
+ h,
296
+ L,
297
+ T,
298
+ c.format,
299
+ c.type,
300
+ c.mapping,
301
+ c.wrapS,
302
+ c.wrapT,
303
+ c.magFilter,
304
+ c.minFilter,
305
+ c.anisotropy,
306
+ c.colorSpace
307
+ );
308
+ } else
309
+ v = new se(
310
+ c.image,
311
+ c.mapping,
312
+ c.wrapS,
313
+ c.wrapT,
314
+ c.magFilter,
315
+ c.minFilter,
316
+ c.format,
317
+ c.type,
318
+ c.anisotropy,
319
+ c.colorSpace
320
+ ), v.mipmaps = c.mipmaps, v.channel = c.channel, v.source.data = c.source.data, v.flipY = c.flipY, v.premultiplyAlpha = c.premultiplyAlpha, v.unpackAlignment = c.unpackAlignment, v.matrix = new nt(...c.matrix.elements);
321
+ if (!v) {
322
+ console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");
323
+ continue;
324
+ }
325
+ b.texture = v;
326
+ }
327
+ return o;
182
328
  }
183
- const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = class {
184
- constructor(t, e) {
185
- u(this, "parser");
186
- u(this, "url");
187
- u(this, "_isLoadingMesh");
188
- u(this, "loadMesh", (t) => {
189
- var s, n;
329
+ function Se(o) {
330
+ let e = o;
331
+ if ("isInterleavedBufferAttribute" in o && o.isInterleavedBufferAttribute) {
332
+ const t = o.data, s = t.array, i = new it(s, t.stride);
333
+ e = new ot(i, o.itemSize, s.byteOffset, o.normalized), e.offset = o.offset;
334
+ } else
335
+ "isBufferAttribute" in o && o.isBufferAttribute && (e = new at(o.array, o.itemSize, o.normalized), e.usage = o.usage, e.gpuType = o.gpuType, e.updateRanges = o.updateRanges);
336
+ return e;
337
+ }
338
+ const Ct = oe("gltf-progressive-worker"), kt = oe("gltf-progressive-reduce-mipmaps"), Pe = Symbol("needle-progressive-texture"), Y = "NEEDLE_progressive", P = class {
339
+ constructor(e, t) {
340
+ d(this, "parser");
341
+ d(this, "url");
342
+ d(this, "_isLoadingMesh");
343
+ d(this, "loadMesh", (e) => {
344
+ var s, i;
190
345
  if (this._isLoadingMesh)
191
346
  return null;
192
- const e = (n = (s = this.parser.json.meshes[t]) == null ? void 0 : s.extensions) == null ? void 0 : n[X];
193
- return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((r) => {
194
- var i;
195
- return this._isLoadingMesh = !1, r && D.registerMesh(this.url, e.guid, r, (i = e.lods) == null ? void 0 : i.length, 0, e), r;
347
+ const t = (i = (s = this.parser.json.meshes[e]) == null ? void 0 : s.extensions) == null ? void 0 : i[Y];
348
+ return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((r) => {
349
+ var n;
350
+ return this._isLoadingMesh = !1, r && P.registerMesh(this.url, t.guid, r, (n = t.lods) == null ? void 0 : n.length, 0, t), r;
196
351
  })) : null;
197
352
  });
198
- x && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
353
+ x && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
199
354
  }
200
355
  /** The name of the extension */
201
356
  get name() {
202
- return X;
357
+ return Y;
203
358
  }
204
- static getMeshLODExtension(t) {
205
- const e = this.getAssignedLODInformation(t);
206
- return e != null && e.key ? this.lodInfos.get(e.key) : null;
359
+ static getMeshLODExtension(e) {
360
+ const t = this.getAssignedLODInformation(e);
361
+ return t != null && t.key ? this.lodInfos.get(t.key) : null;
207
362
  }
208
- static getPrimitiveIndex(t) {
363
+ static getPrimitiveIndex(e) {
209
364
  var s;
210
- const e = (s = this.getAssignedLODInformation(t)) == null ? void 0 : s.index;
211
- return e ?? -1;
365
+ const t = (s = this.getAssignedLODInformation(e)) == null ? void 0 : s.index;
366
+ return t ?? -1;
212
367
  }
213
- static getMaterialMinMaxLODsCount(t, e) {
214
- const s = this, n = "LODS:minmax", r = t[n];
368
+ static getMaterialMinMaxLODsCount(e, t) {
369
+ const s = this, i = "LODS:minmax", r = e[i];
215
370
  if (r != null)
216
371
  return r;
217
- if (e || (e = {
372
+ if (t || (t = {
218
373
  min_count: 1 / 0,
219
374
  max_count: 0,
220
375
  lods: []
221
- }), Array.isArray(t)) {
222
- for (const a of t)
223
- this.getMaterialMinMaxLODsCount(a, e);
224
- return t[n] = e, e;
376
+ }), Array.isArray(e)) {
377
+ for (const a of e)
378
+ this.getMaterialMinMaxLODsCount(a, t);
379
+ return e[i] = t, t;
225
380
  }
226
- if (x === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
227
- const a = t;
381
+ if (x === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
382
+ const a = e;
228
383
  for (const l of Object.keys(a.uniforms)) {
229
- const c = a.uniforms[l].value;
230
- (c == null ? void 0 : c.isTexture) === !0 && i(c, e);
384
+ const u = a.uniforms[l].value;
385
+ (u == null ? void 0 : u.isTexture) === !0 && n(u, t);
231
386
  }
232
- } else if (t.isMaterial)
233
- for (const a of Object.keys(t)) {
234
- const l = t[a];
235
- (l == null ? void 0 : l.isTexture) === !0 && i(l, e);
387
+ } else if (e.isMaterial)
388
+ for (const a of Object.keys(e)) {
389
+ const l = e[a];
390
+ (l == null ? void 0 : l.isTexture) === !0 && n(l, t);
236
391
  }
237
- return t[n] = e, e;
238
- function i(a, l) {
239
- const c = s.getAssignedLODInformation(a);
240
- if (c) {
241
- const d = s.lodInfos.get(c.key);
242
- if (d && d.lods) {
243
- l.min_count = Math.min(l.min_count, d.lods.length), l.max_count = Math.max(l.max_count, d.lods.length);
244
- for (let p = 0; p < d.lods.length; p++) {
245
- const f = d.lods[p];
246
- f.width && (l.lods[p] = l.lods[p] || { min_height: 1 / 0, max_height: 0 }, l.lods[p].min_height = Math.min(l.lods[p].min_height, f.height), l.lods[p].max_height = Math.max(l.lods[p].max_height, f.height));
392
+ else
393
+ x && console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);
394
+ return e[i] = t, t;
395
+ function n(a, l) {
396
+ const u = s.getAssignedLODInformation(a);
397
+ if (u) {
398
+ const f = s.lodInfos.get(u.key);
399
+ if (f && f.lods) {
400
+ l.min_count = Math.min(l.min_count, f.lods.length), l.max_count = Math.max(l.max_count, f.lods.length);
401
+ for (let m = 0; m < f.lods.length; m++) {
402
+ const _ = f.lods[m];
403
+ _.width && (l.lods[m] = l.lods[m] || { min_height: 1 / 0, max_height: 0 }, l.lods[m].min_height = Math.min(l.lods[m].min_height, _.height), l.lods[m].max_height = Math.max(l.lods[m].max_height, _.height));
247
404
  }
248
405
  }
249
406
  }
@@ -254,33 +411,33 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
254
411
  * @param level the level of detail to check for (0 is the highest resolution). If undefined, the function checks if any LOD level is available
255
412
  * @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
256
413
  */
257
- static hasLODLevelAvailable(t, e) {
414
+ static hasLODLevelAvailable(e, t) {
258
415
  var r;
259
- if (Array.isArray(t)) {
260
- for (const i of t)
261
- if (this.hasLODLevelAvailable(i, e))
416
+ if (Array.isArray(e)) {
417
+ for (const n of e)
418
+ if (this.hasLODLevelAvailable(n, t))
262
419
  return !0;
263
420
  return !1;
264
421
  }
265
- if (t.isMaterial === !0) {
266
- for (const i of Object.keys(t)) {
267
- const a = t[i];
268
- if (a && a.isTexture && this.hasLODLevelAvailable(a, e))
422
+ if (e.isMaterial === !0) {
423
+ for (const n of Object.keys(e)) {
424
+ const a = e[n];
425
+ if (a && a.isTexture && this.hasLODLevelAvailable(a, t))
269
426
  return !0;
270
427
  }
271
428
  return !1;
272
- } else if (t.isGroup === !0) {
273
- for (const i of t.children)
274
- if (i.isMesh === !0 && this.hasLODLevelAvailable(i, e))
429
+ } else if (e.isGroup === !0) {
430
+ for (const n of e.children)
431
+ if (n.isMesh === !0 && this.hasLODLevelAvailable(n, t))
275
432
  return !0;
276
433
  }
277
- let s, n;
278
- if (t.isMesh ? s = t.geometry : (t.isBufferGeometry || t.isTexture) && (s = t), s && (r = s == null ? void 0 : s.userData) != null && r.LODS) {
279
- const i = s.userData.LODS;
280
- if (n = this.lodInfos.get(i.key), e === void 0)
281
- return n != null;
282
- if (n)
283
- return Array.isArray(n.lods) ? e < n.lods.length : e === 0;
434
+ let s, i;
435
+ if (e.isMesh ? s = e.geometry : (e.isBufferGeometry || e.isTexture) && (s = e), s && (r = s == null ? void 0 : s.userData) != null && r.LODS) {
436
+ const n = s.userData.LODS;
437
+ if (i = this.lodInfos.get(n.key), t === void 0)
438
+ return i != null;
439
+ if (i)
440
+ return Array.isArray(i.lods) ? t < i.lods.length : t === 0;
284
441
  }
285
442
  return !1;
286
443
  }
@@ -298,333 +455,373 @@ const X = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), D = c
298
455
  * });
299
456
  * ```
300
457
  */
301
- static assignMeshLOD(t, e) {
458
+ static assignMeshLOD(e, t) {
302
459
  var s;
303
- if (!t)
460
+ if (!e)
304
461
  return Promise.resolve(null);
305
- if (t instanceof se || t.isMesh === !0) {
306
- const n = t.geometry, r = this.getAssignedLODInformation(n);
462
+ if (e instanceof ne || e.isMesh === !0) {
463
+ const i = e.geometry, r = this.getAssignedLODInformation(i);
307
464
  if (!r)
308
465
  return Promise.resolve(null);
309
- for (const i of j)
310
- (s = i.onBeforeGetLODMesh) == null || s.call(i, t, e);
311
- return t["LOD:requested level"] = e, D.getOrLoadLOD(n, e).then((i) => {
312
- if (Array.isArray(i)) {
466
+ for (const n of Z)
467
+ (s = n.onBeforeGetLODMesh) == null || s.call(n, e, t);
468
+ return e["LOD:requested level"] = t, P.getOrLoadLOD(i, t).then((n) => {
469
+ if (Array.isArray(n)) {
313
470
  const a = r.index || 0;
314
- i = i[a];
471
+ n = n[a];
315
472
  }
316
- return t["LOD:requested level"] === e && (delete t["LOD:requested level"], i && n != i && ((i == null ? void 0 : i.isBufferGeometry) ? t.geometry = i : x && console.error("Invalid LOD geometry", i))), i;
317
- }).catch((i) => (console.error("Error loading mesh LOD", t, i), null));
473
+ return e["LOD:requested level"] === t && (delete e["LOD:requested level"], n && i != n && ((n == null ? void 0 : n.isBufferGeometry) ? e.geometry = n : x && console.error("Invalid LOD geometry", n))), n;
474
+ }).catch((n) => (console.error("Error loading mesh LOD", e, n), null));
318
475
  } else
319
- x && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
476
+ x && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
320
477
  return Promise.resolve(null);
321
478
  }
322
- static assignTextureLOD(t, e = 0) {
323
- if (!t)
479
+ static assignTextureLOD(e, t = 0) {
480
+ if (!e)
324
481
  return Promise.resolve(null);
325
- if (t.isMesh === !0) {
326
- const s = t;
482
+ if (e.isMesh === !0) {
483
+ const s = e;
327
484
  if (Array.isArray(s.material)) {
328
- const n = new Array();
485
+ const i = new Array();
329
486
  for (const r of s.material) {
330
- const i = this.assignTextureLOD(r, e);
331
- n.push(i);
487
+ const n = this.assignTextureLOD(r, t);
488
+ i.push(n);
332
489
  }
333
- return Promise.all(n).then((r) => {
334
- const i = new Array();
490
+ return Promise.all(i).then((r) => {
491
+ const n = new Array();
335
492
  for (const a of r)
336
- Array.isArray(a) && i.push(...a);
337
- return i;
493
+ Array.isArray(a) && n.push(...a);
494
+ return n;
338
495
  });
339
496
  } else
340
- return this.assignTextureLOD(s.material, e);
497
+ return this.assignTextureLOD(s.material, t);
341
498
  }
342
- if (t.isMaterial === !0) {
343
- const s = t, n = [], r = new Array();
499
+ if (e.isMaterial === !0) {
500
+ const s = e, i = [], r = new Array();
344
501
  if (s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
345
- const i = s;
346
- for (const a of Object.keys(i.uniforms)) {
347
- const l = i.uniforms[a].value;
502
+ const n = s;
503
+ for (const a of Object.keys(n.uniforms)) {
504
+ const l = n.uniforms[a].value;
348
505
  if ((l == null ? void 0 : l.isTexture) === !0) {
349
- const c = this.assignTextureLODForSlot(l, e, s, a).then((d) => (d && i.uniforms[a].value != d && (i.uniforms[a].value = d, i.uniformsNeedUpdate = !0), d));
350
- n.push(c), r.push(a);
506
+ const u = this.assignTextureLODForSlot(l, t, s, a).then((f) => (f && n.uniforms[a].value != f && (n.uniforms[a].value = f, n.uniformsNeedUpdate = !0), f));
507
+ i.push(u), r.push(a);
351
508
  }
352
509
  }
353
510
  } else
354
- for (const i of Object.keys(s)) {
355
- const a = s[i];
511
+ for (const n of Object.keys(s)) {
512
+ const a = s[n];
356
513
  if ((a == null ? void 0 : a.isTexture) === !0) {
357
- const l = this.assignTextureLODForSlot(a, e, s, i);
358
- n.push(l), r.push(i);
514
+ const l = this.assignTextureLODForSlot(a, t, s, n);
515
+ i.push(l), r.push(n);
359
516
  }
360
517
  }
361
- return Promise.all(n).then((i) => {
518
+ return Promise.all(i).then((n) => {
362
519
  const a = new Array();
363
- for (let l = 0; l < i.length; l++) {
364
- const c = i[l], d = r[l];
365
- c && c.isTexture === !0 ? a.push({ material: s, slot: d, texture: c, level: e }) : a.push({ material: s, slot: d, texture: null, level: e });
520
+ for (let l = 0; l < n.length; l++) {
521
+ const u = n[l], f = r[l];
522
+ u && u.isTexture === !0 ? a.push({ material: s, slot: f, texture: u, level: t }) : a.push({ material: s, slot: f, texture: null, level: t });
366
523
  }
367
524
  return a;
368
525
  });
369
526
  }
370
- if (t instanceof oe || t.isTexture === !0) {
371
- const s = t;
372
- return this.assignTextureLODForSlot(s, e, null, null);
527
+ if (e instanceof se || e.isTexture === !0) {
528
+ const s = e;
529
+ return this.assignTextureLODForSlot(s, t, null, null);
373
530
  }
374
531
  return Promise.resolve(null);
375
532
  }
376
- static assignTextureLODForSlot(t, e, s, n) {
377
- return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : D.getOrLoadLOD(t, e).then((r) => {
533
+ static assignTextureLODForSlot(e, t, s, i) {
534
+ return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : i === "glyphMap" ? Promise.resolve(e) : P.getOrLoadLOD(e, t).then((r) => {
535
+ var n, a;
378
536
  if (Array.isArray(r))
379
- return null;
537
+ return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."), null;
380
538
  if ((r == null ? void 0 : r.isTexture) === !0) {
381
- if (r != t && s && n) {
382
- const i = s[n];
383
- if (i && !x) {
384
- const a = this.getAssignedLODInformation(i);
385
- if (a && (a == null ? void 0 : a.level) < e)
386
- return x === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, e, s, i, r), null;
539
+ if (r != e && s && i) {
540
+ const l = s[i];
541
+ if (l && !x) {
542
+ const u = this.getAssignedLODInformation(l);
543
+ if (u && (u == null ? void 0 : u.level) < t)
544
+ return x === "verbose" && console.warn("Assigned texture level is already higher: ", u.level, t, s, l, r), null;
387
545
  }
388
- s[n] = r;
546
+ if (kt && r.mipmaps) {
547
+ const u = r.mipmaps.length;
548
+ r.mipmaps.length = Math.min(r.mipmaps.length, 3), u !== r.mipmaps.length && x && console.debug(`Reduced mipmap count from ${u} to ${r.mipmaps.length} for ${r.uuid}: ${(n = r.image) == null ? void 0 : n.width}x${(a = r.image) == null ? void 0 : a.height}.`);
549
+ }
550
+ s[i] = r;
389
551
  }
390
552
  return r;
391
553
  } else
392
- x == "verbose" && console.warn("No LOD found for", t, e);
554
+ x == "verbose" && console.warn("No LOD found for", e, t);
393
555
  return null;
394
- }).catch((r) => (console.error("Error loading LOD", t, r), null));
395
- }
396
- afterRoot(t) {
397
- var e, s;
398
- return x && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, r) => {
399
- var i;
400
- if (n != null && n.extensions) {
401
- const a = n == null ? void 0 : n.extensions[X];
556
+ }).catch((r) => (console.error("Error loading LOD", e, r), null));
557
+ }
558
+ // private _isLoadingTexture;
559
+ // loadTexture = (textureIndex: number) => {
560
+ // if (this._isLoadingTexture) return null;
561
+ // const ext = this.parser.json.textures[textureIndex]?.extensions?.[EXTENSION_NAME] as NEEDLE_ext_progressive_texture;
562
+ // if (!ext) return null;
563
+ // this._isLoadingTexture = true;
564
+ // return this.parser.getDependency("texture", textureIndex).then(tex => {
565
+ // this._isLoadingTexture = false;
566
+ // if (tex) {
567
+ // NEEDLE_progressive.registerTexture(this.url, tex as Texture, ext.lods?.length, textureIndex, ext);
568
+ // }
569
+ // return tex;
570
+ // });
571
+ // }
572
+ afterRoot(e) {
573
+ var t, s;
574
+ return x && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, r) => {
575
+ var n;
576
+ if (i != null && i.extensions) {
577
+ const a = i == null ? void 0 : i.extensions[Y];
402
578
  if (a) {
403
579
  if (!a.lods) {
404
580
  x && console.warn("Texture has no LODs", a);
405
581
  return;
406
582
  }
407
583
  let l = !1;
408
- for (const c of this.parser.associations.keys())
409
- if (c.isTexture === !0) {
410
- const d = this.parser.associations.get(c);
411
- (d == null ? void 0 : d.textures) === r && (l = !0, D.registerTexture(this.url, c, (i = a.lods) == null ? void 0 : i.length, r, a));
584
+ for (const u of this.parser.associations.keys())
585
+ if (u.isTexture === !0) {
586
+ const f = this.parser.associations.get(u);
587
+ (f == null ? void 0 : f.textures) === r && (l = !0, P.registerTexture(this.url, u, (n = a.lods) == null ? void 0 : n.length, r, a));
412
588
  }
413
- l || this.parser.getDependency("texture", r).then((c) => {
414
- var d;
415
- c && D.registerTexture(this.url, c, (d = a.lods) == null ? void 0 : d.length, r, a);
589
+ l || this.parser.getDependency("texture", r).then((u) => {
590
+ var f;
591
+ u && P.registerTexture(this.url, u, (f = a.lods) == null ? void 0 : f.length, r, a);
416
592
  });
417
593
  }
418
594
  }
419
- }), (s = this.parser.json.meshes) == null || s.forEach((n, r) => {
420
- if (n != null && n.extensions) {
421
- const i = n == null ? void 0 : n.extensions[X];
422
- if (i && i.lods) {
595
+ }), (s = this.parser.json.meshes) == null || s.forEach((i, r) => {
596
+ if (i != null && i.extensions) {
597
+ const n = i == null ? void 0 : i.extensions[Y];
598
+ if (n && n.lods) {
423
599
  for (const a of this.parser.associations.keys())
424
600
  if (a.isMesh) {
425
601
  const l = this.parser.associations.get(a);
426
- (l == null ? void 0 : l.meshes) === r && D.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
602
+ (l == null ? void 0 : l.meshes) === r && P.registerMesh(this.url, n.guid, a, n.lods.length, l.primitives, n);
427
603
  }
428
604
  }
429
605
  }
430
606
  }), null;
431
607
  }
432
- static async getOrLoadLOD(t, e) {
433
- var a, l, c, d;
434
- const s = x == "verbose", n = t.userData.LODS;
435
- if (!n)
436
- return null;
437
- const r = n == null ? void 0 : n.key;
438
- let i;
439
- if (t.isTexture === !0) {
440
- const p = t;
441
- p.source && p.source[Oe] && (i = p.source[Oe]);
608
+ static async getOrLoadLOD(e, t) {
609
+ var l, u, f, m;
610
+ const s = x == "verbose", i = this.getAssignedLODInformation(e);
611
+ if (!i)
612
+ return x && console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`, e), null;
613
+ const r = i == null ? void 0 : i.key;
614
+ let n;
615
+ if (e.isTexture === !0) {
616
+ const _ = e;
617
+ _.source && _.source[Pe] && (n = _.source[Pe]);
442
618
  }
443
- if (i || (i = D.lodInfos.get(r)), i) {
444
- if (e > 0) {
445
- let w = !1;
446
- const M = Array.isArray(i.lods);
447
- if (M && e >= i.lods.length ? w = !0 : M || (w = !0), w)
619
+ if (n || (n = P.lodInfos.get(r)), n) {
620
+ if (t > 0) {
621
+ let O = !1;
622
+ const M = Array.isArray(n.lods);
623
+ if (M && t >= n.lods.length ? O = !0 : M || (O = !0), O)
448
624
  return this.lowresCache.get(r);
449
625
  }
450
- const p = Array.isArray(i.lods) ? (a = i.lods[e]) == null ? void 0 : a.path : i.lods;
451
- if (!p)
452
- return x && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
453
- const f = ut(n.url, p);
454
- if (f.endsWith(".glb") || f.endsWith(".gltf")) {
455
- if (!i.guid)
456
- return console.warn("missing pointer for glb/gltf texture", i), null;
457
- const w = f + "_" + i.guid, M = this.previouslyLoaded.get(w);
458
- if (M !== void 0) {
459
- s && console.log(`LOD ${e} was already loading/loaded: ${w}`);
460
- let h = await M.catch((C) => (console.error(`Error loading LOD ${e} from ${f}
461
- `, C), null)), L = !1;
462
- if (h == null || (h instanceof oe && t instanceof oe ? (l = h.image) != null && l.data || (c = h.source) != null && c.data ? h = this.copySettings(t, h) : (L = !0, this.previouslyLoaded.delete(w)) : h instanceof xe && t instanceof xe && ((d = h.attributes.position) != null && d.array || (L = !0, this.previouslyLoaded.delete(w)))), !L)
626
+ const _ = Array.isArray(n.lods) ? (l = n.lods[t]) == null ? void 0 : l.path : n.lods;
627
+ if (!_)
628
+ return x && !n["missing:uri"] && (n["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, n)), null;
629
+ const w = _t(i.url, _);
630
+ if (w.endsWith(".glb") || w.endsWith(".gltf")) {
631
+ if (!n.guid)
632
+ return console.warn("missing pointer for glb/gltf texture", n), null;
633
+ const O = w + "_" + n.guid, M = await this.queue.slot(w), B = this.previouslyLoaded.get(O);
634
+ if (B !== void 0) {
635
+ s && console.log(`LOD ${t} was already loading/loaded: ${O}`);
636
+ let h = await B.catch((T) => (console.error(`Error loading LOD ${t} from ${w}
637
+ `, T), null)), L = !1;
638
+ if (h == null || (h instanceof se && e instanceof se ? (u = h.image) != null && u.data || (f = h.source) != null && f.data ? h = this.copySettings(e, h) : (L = !0, this.previouslyLoaded.delete(O)) : h instanceof he && e instanceof he && ((m = h.attributes.position) != null && m.array || (L = !0, this.previouslyLoaded.delete(O)))), !L)
463
639
  return h;
464
640
  }
465
- const A = await this.queue.slot(f);
466
- if (!A.use)
467
- return x && console.log(`LOD ${e} was aborted: ${f}`), null;
468
- const b = i, R = new Promise(async (h, L) => {
469
- const C = new Ce();
470
- Ne(C), x && (await new Promise((v) => setTimeout(v, 1e3)), s && console.warn("Start loading (delayed) " + f, b.guid));
471
- let N = f;
641
+ if (!M.use)
642
+ return x && console.log(`LOD ${t} was aborted: ${w}`), null;
643
+ const b = n, c = new Promise(async (h, L) => {
644
+ if (Ct) {
645
+ const p = await (await Tt({})).load(w);
646
+ if (p.textures.length > 0)
647
+ for (const g of p.textures) {
648
+ let y = g.texture;
649
+ return P.assignLODInformation(i.url, y, r, t, void 0), e instanceof se && (y = this.copySettings(e, y)), y && (y.guid = b.guid), h(y);
650
+ }
651
+ if (p.geometries.length > 0) {
652
+ const g = new Array();
653
+ for (const y of p.geometries) {
654
+ const I = y.geometry;
655
+ P.assignLODInformation(i.url, I, r, t, y.primitiveIndex), g.push(I);
656
+ }
657
+ return h(g);
658
+ }
659
+ return h(null);
660
+ }
661
+ const T = new Re();
662
+ Xe(T), x && (await new Promise((S) => setTimeout(S, 1e3)), s && console.warn("Start loading (delayed) " + w, b.guid));
663
+ let U = w;
472
664
  if (b && Array.isArray(b.lods)) {
473
- const v = b.lods[e];
474
- v.hash && (N += "?v=" + v.hash);
665
+ const S = b.lods[t];
666
+ S.hash && (U += "?v=" + S.hash);
475
667
  }
476
- const S = await C.loadAsync(N).catch((v) => (console.error(`Error loading LOD ${e} from ${f}
477
- `, v), h(null)));
478
- if (!S)
668
+ const k = await T.loadAsync(U).catch((S) => (console.error(`Error loading LOD ${t} from ${w}
669
+ `, S), h(null)));
670
+ if (!k)
479
671
  return h(null);
480
- const ee = S.parser;
481
- s && console.log("Loading finished " + f, b.guid);
482
- let B = 0;
483
- if (S.parser.json.textures) {
484
- let v = !1;
485
- for (const m of S.parser.json.textures) {
486
- if (m != null && m.extensions) {
487
- const g = m == null ? void 0 : m.extensions[X];
672
+ const te = k.parser;
673
+ s && console.log("Loading finished " + w, b.guid);
674
+ let G = 0;
675
+ if (k.parser.json.textures) {
676
+ let S = !1;
677
+ for (const p of k.parser.json.textures) {
678
+ if (p != null && p.extensions) {
679
+ const g = p == null ? void 0 : p.extensions[Y];
488
680
  if (g != null && g.guid && g.guid === b.guid) {
489
- v = !0;
681
+ S = !0;
490
682
  break;
491
683
  }
492
684
  }
493
- B++;
685
+ G++;
494
686
  }
495
- if (v) {
496
- let m = await ee.getDependency("texture", B);
497
- return m && D.assignLODInformation(n.url, m, r, e, void 0), s && console.log('change "' + t.name + '" → "' + m.name + '"', f, B, m, w), t instanceof oe && (m = this.copySettings(t, m)), m && (m.guid = b.guid), h(m);
687
+ if (S) {
688
+ let p = await te.getDependency("texture", G);
689
+ return p && P.assignLODInformation(i.url, p, r, t, void 0), s && console.log('change "' + e.name + '" → "' + p.name + '"', w, G, p, O), e instanceof se && (p = this.copySettings(e, p)), p && (p.guid = b.guid), h(p);
498
690
  } else
499
- x && console.warn("Could not find texture with guid", b.guid, S.parser.json);
691
+ x && console.warn("Could not find texture with guid", b.guid, k.parser.json);
500
692
  }
501
- if (B = 0, S.parser.json.meshes) {
502
- let v = !1;
503
- for (const m of S.parser.json.meshes) {
504
- if (m != null && m.extensions) {
505
- const g = m == null ? void 0 : m.extensions[X];
693
+ if (G = 0, k.parser.json.meshes) {
694
+ let S = !1;
695
+ for (const p of k.parser.json.meshes) {
696
+ if (p != null && p.extensions) {
697
+ const g = p == null ? void 0 : p.extensions[Y];
506
698
  if (g != null && g.guid && g.guid === b.guid) {
507
- v = !0;
699
+ S = !0;
508
700
  break;
509
701
  }
510
702
  }
511
- B++;
703
+ G++;
512
704
  }
513
- if (v) {
514
- const m = await ee.getDependency("mesh", B);
515
- if (s && console.log(`Loaded Mesh "${m.name}"`, f, B, m, w), m.isMesh === !0) {
516
- const g = m.geometry;
517
- return D.assignLODInformation(n.url, g, r, e, 0), h(g);
705
+ if (S) {
706
+ const p = await te.getDependency("mesh", G);
707
+ if (s && console.log(`Loaded Mesh "${p.name}"`, w, G, p, O), p.isMesh === !0) {
708
+ const g = p.geometry;
709
+ return P.assignLODInformation(i.url, g, r, t, 0), h(g);
518
710
  } else {
519
711
  const g = new Array();
520
- for (let _ = 0; _ < m.children.length; _++) {
521
- const G = m.children[_];
522
- if (G.isMesh === !0) {
523
- const E = G.geometry;
524
- D.assignLODInformation(n.url, E, r, e, _), g.push(E);
712
+ for (let y = 0; y < p.children.length; y++) {
713
+ const I = p.children[y];
714
+ if (I.isMesh === !0) {
715
+ const R = I.geometry;
716
+ P.assignLODInformation(i.url, R, r, t, y), g.push(R);
525
717
  }
526
718
  }
527
719
  return h(g);
528
720
  }
529
721
  } else
530
- x && console.warn("Could not find mesh with guid", b.guid, S.parser.json);
722
+ x && console.warn("Could not find mesh with guid", b.guid, k.parser.json);
531
723
  }
532
724
  return h(null);
533
725
  });
534
- return this.previouslyLoaded.set(w, R), A.use(R), await R;
535
- } else if (t instanceof oe) {
536
- s && console.log("Load texture from uri: " + f);
537
- const M = await new Qe().loadAsync(f);
538
- return M ? (M.guid = i.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = t.colorSpace, s && console.log(i, M)) : x && console.warn("failed loading", f), M;
726
+ return this.previouslyLoaded.set(O, c), M.use(c), await c;
727
+ } else if (e instanceof se) {
728
+ s && console.log("Load texture from uri: " + w);
729
+ const M = await new lt().loadAsync(w);
730
+ return M ? (M.guid = n.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = e.colorSpace, s && console.log(n, M)) : x && console.warn("failed loading", w), M;
539
731
  }
540
732
  } else
541
- x && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
733
+ x && console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`, e.type);
542
734
  return null;
543
735
  }
544
- static assignLODInformation(t, e, s, n, r) {
545
- if (!e)
736
+ static assignLODInformation(e, t, s, i, r) {
737
+ if (!t)
546
738
  return;
547
- e.userData || (e.userData = {});
548
- const i = new yt(t, s, n, r);
549
- e.userData.LODS = i;
739
+ t.userData || (t.userData = {});
740
+ const n = new It(e, s, i, r);
741
+ t.userData.LODS = n, "source" in t && typeof t.source == "object" && (t.source.LODS = n);
550
742
  }
551
- static getAssignedLODInformation(t) {
552
- var e;
553
- return ((e = t == null ? void 0 : t.userData) == null ? void 0 : e.LODS) || null;
743
+ static getAssignedLODInformation(e) {
744
+ var t, s;
745
+ return e ? (t = e.userData) != null && t.LODS ? e.userData.LODS : "source" in e && ((s = e.source) != null && s.LODS) ? e.source.LODS : null : null;
554
746
  }
555
747
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
556
- static copySettings(t, e) {
557
- return e ? (x && console.warn(`Copy texture settings
558
- `, t.uuid, `
559
- `, e.uuid), e = e.clone(), 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) : t;
748
+ static copySettings(e, t) {
749
+ return t ? (x === "verbose" && console.debug(`Copy texture settings
750
+ `, e.uuid, `
751
+ `, 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;
560
752
  }
561
753
  };
562
- let P = D;
754
+ let C = P;
563
755
  /**
564
756
  * Register a texture with LOD information
565
757
  */
566
- u(P, "registerTexture", (t, e, s, n, r) => {
567
- if (x && console.log("> Progressive: register texture", n, e.name, e.uuid, e, r), !e) {
568
- x && console.error("gltf-progressive: Register texture without texture");
758
+ d(C, "registerTexture", (e, t, s, i, r) => {
759
+ var a, l, u, f, m, _, w, O;
760
+ if (!t) {
761
+ x && console.error("gltf-progressive: Called register texture without texture");
569
762
  return;
570
763
  }
571
- e.source && (e.source[Oe] = r);
572
- const i = r.guid;
573
- D.assignLODInformation(t, e, i, s, n), D.lodInfos.set(i, r), D.lowresCache.set(i, e);
764
+ if (x) {
765
+ const M = ((a = t.image) == null ? void 0 : a.width) || ((u = (l = t.source) == null ? void 0 : l.data) == null ? void 0 : u.width) || 0, B = ((f = t.image) == null ? void 0 : f.height) || ((_ = (m = t.source) == null ? void 0 : m.data) == null ? void 0 : _.height) || 0;
766
+ console.log(`> Progressive: register texture[${i}] "${t.name || t.uuid}", Current: ${M}x${B}, Max: ${(w = r.lods[0]) == null ? void 0 : w.width}x${(O = r.lods[0]) == null ? void 0 : O.height}, uuid: ${t.uuid}`, r, t);
767
+ }
768
+ t.source && (t.source[Pe] = r);
769
+ const n = r.guid;
770
+ P.assignLODInformation(e, t, n, s, i), P.lodInfos.set(n, r), P.lowresCache.set(n, t);
574
771
  }), /**
575
772
  * Register a mesh with LOD information
576
773
  */
577
- u(P, "registerMesh", (t, e, s, n, r, i) => {
578
- var c;
774
+ d(C, "registerMesh", (e, t, s, i, r, n) => {
775
+ var u;
579
776
  const a = s.geometry;
580
777
  if (!a) {
581
778
  x && console.warn("gltf-progressive: Register mesh without geometry");
582
779
  return;
583
780
  }
584
- a.userData || (a.userData = {}), x && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, i, s), D.assignLODInformation(t, a, e, n, r), D.lodInfos.set(e, i);
585
- let l = D.lowresCache.get(e);
586
- l ? l.push(s.geometry) : l = [s.geometry], D.lowresCache.set(e, l), n > 0 && !ce(s) && gt(s, a);
587
- for (const d of j)
588
- (c = d.onRegisteredNewMesh) == null || c.call(d, s, i);
781
+ a.userData || (a.userData = {}), x && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, n, s), P.assignLODInformation(e, a, t, i, r), P.lodInfos.set(t, n);
782
+ let l = P.lowresCache.get(t);
783
+ l ? l.push(s.geometry) : l = [s.geometry], P.lowresCache.set(t, l), i > 0 && !ge(s) && Dt(s, a);
784
+ for (const f of Z)
785
+ (u = f.onRegisteredNewMesh) == null || u.call(f, s, n);
589
786
  }), /** A map of key = asset uuid and value = LOD information */
590
- u(P, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
591
- u(P, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
592
- u(P, "lowresCache", /* @__PURE__ */ new Map()), u(P, "queue", new ft(100, { debug: x != !1 }));
593
- class yt {
594
- constructor(t, e, s, n) {
595
- u(this, "url");
787
+ d(C, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
788
+ d(C, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
789
+ d(C, "lowresCache", /* @__PURE__ */ new Map()), d(C, "workers", []), d(C, "_workersIndex", 0), d(C, "maxConcurrent", 50), d(C, "queue", new Mt(P.maxConcurrent, { debug: x != !1 }));
790
+ class It {
791
+ constructor(e, t, s, i) {
792
+ d(this, "url");
596
793
  /** the key to lookup the LOD information */
597
- u(this, "key");
598
- u(this, "level");
794
+ d(this, "key");
795
+ d(this, "level");
599
796
  /** For multi objects (e.g. a group of meshes) this is the index of the object */
600
- u(this, "index");
601
- this.url = t, this.key = e, this.level = s, n != null && (this.index = n);
797
+ d(this, "index");
798
+ this.url = e, this.key = t, this.level = s, i != null && (this.index = i);
602
799
  }
603
800
  }
604
- class ye {
605
- constructor(t, e) {
606
- u(this, "frame_start");
607
- u(this, "frame_capture_end");
608
- u(this, "ready");
609
- u(this, "_resolve");
610
- u(this, "_signal");
611
- u(this, "_resolved", !1);
612
- u(this, "_addedCount", 0);
613
- u(this, "_resolvedCount", 0);
801
+ class Le {
802
+ constructor(e, t) {
803
+ d(this, "frame_start");
804
+ d(this, "frame_capture_end");
805
+ d(this, "ready");
806
+ d(this, "_resolve");
807
+ d(this, "_signal");
808
+ d(this, "_resolved", !1);
809
+ d(this, "_addedCount", 0);
810
+ d(this, "_resolvedCount", 0);
614
811
  /** These promises are currently being awaited */
615
- u(this, "_awaiting", []);
616
- u(this, "_maxPromisesPerObject", 1);
617
- u(this, "_currentFrame", 0);
618
- u(this, "_seen", /* @__PURE__ */ new WeakMap());
812
+ d(this, "_awaiting", []);
813
+ d(this, "_maxPromisesPerObject", 1);
814
+ d(this, "_currentFrame", 0);
815
+ d(this, "_seen", /* @__PURE__ */ new WeakMap());
619
816
  var r;
620
- const n = Math.max(e.frames ?? 2, 2);
621
- this.frame_start = t, this.frame_capture_end = t + n, this.ready = new Promise((i) => {
622
- this._resolve = i;
817
+ const i = Math.max(t.frames ?? 2, 2);
818
+ this.frame_start = e, this.frame_capture_end = e + i, this.ready = new Promise((n) => {
819
+ this._resolve = n;
623
820
  }), this.ready.finally(() => {
624
821
  this._resolved = !0, this._awaiting.length = 0;
625
- }), this._signal = e.signal, (r = this._signal) == null || r.addEventListener("abort", () => {
822
+ }), this._signal = t.signal, (r = this._signal) == null || r.addEventListener("abort", () => {
626
823
  this.resolveNow();
627
- }), this._maxPromisesPerObject = Math.max(1, e.maxPromisesPerObject ?? 1);
824
+ }), this._maxPromisesPerObject = Math.max(1, t.maxPromisesPerObject ?? 1);
628
825
  }
629
826
  /**
630
827
  * The number of promises that have been added to this group so far.
@@ -638,156 +835,156 @@ class ye {
638
835
  get currentlyAwaiting() {
639
836
  return this._awaiting.length;
640
837
  }
641
- update(t) {
642
- var e;
643
- this._currentFrame = t, ((e = this._signal) != null && e.aborted || this._currentFrame > this.frame_capture_end && this._awaiting.length === 0) && this.resolveNow();
838
+ update(e) {
839
+ var t;
840
+ this._currentFrame = e, ((t = this._signal) != null && t.aborted || this._currentFrame > this.frame_capture_end && this._awaiting.length === 0) && this.resolveNow();
644
841
  }
645
- add(t, e, s) {
842
+ add(e, t, s) {
646
843
  if (this._resolved) {
647
844
  x && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
648
845
  return;
649
846
  }
650
847
  if (!(this._currentFrame > this.frame_capture_end)) {
651
848
  if (this._maxPromisesPerObject >= 1)
652
- if (this._seen.has(e)) {
653
- let n = this._seen.get(e);
654
- if (n >= this._maxPromisesPerObject) {
849
+ if (this._seen.has(t)) {
850
+ let i = this._seen.get(t);
851
+ if (i >= this._maxPromisesPerObject) {
655
852
  x && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
656
853
  return;
657
854
  }
658
- this._seen.set(e, n + 1);
855
+ this._seen.set(t, i + 1);
659
856
  } else
660
- this._seen.set(e, 1);
857
+ this._seen.set(t, 1);
661
858
  this._awaiting.push(s), this._addedCount++, s.finally(() => {
662
859
  this._resolvedCount++, this._awaiting.splice(this._awaiting.indexOf(s), 1);
663
860
  });
664
861
  }
665
862
  }
666
863
  resolveNow() {
667
- var t, e;
668
- this._resolved || (e = this._resolve) == null || e.call(this, {
864
+ var e, t;
865
+ this._resolved || (t = this._resolve) == null || t.call(this, {
669
866
  awaited_count: this._addedCount,
670
867
  resolved_count: this._resolvedCount,
671
- cancelled: ((t = this._signal) == null ? void 0 : t.aborted) ?? !1
868
+ cancelled: ((e = this._signal) == null ? void 0 : e.aborted) ?? !1
672
869
  });
673
870
  }
674
871
  }
675
- u(ye, "addPromise", (t, e, s, n) => {
676
- n.forEach((r) => {
677
- r.add(t, e, s);
872
+ d(Le, "addPromise", (e, t, s, i) => {
873
+ i.forEach((r) => {
874
+ r.add(e, t, s);
678
875
  });
679
876
  });
680
- const F = de("debugprogressive"), xt = de("noprogressive"), be = Symbol("Needle:LODSManager"), Se = Symbol("Needle:LODState"), Q = Symbol("Needle:CurrentLOD"), $ = { mesh_lod: -1, texture_lod: -1 };
681
- var k, K, _e, J, ie, we, Y;
682
- const O = class {
877
+ const z = oe("debugprogressive"), Bt = oe("noprogressive"), Te = Symbol("Needle:LODSManager"), Ae = Symbol("Needle:LODState"), J = Symbol("Needle:CurrentLOD"), E = { mesh_lod: -1, texture_lod: -1 };
878
+ var F, j, Me, ee, ae, ve, H;
879
+ const A = class {
683
880
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
684
- constructor(t, e) {
685
- u(this, "renderer");
686
- u(this, "context");
687
- u(this, "projectionScreenMatrix", new Ge());
881
+ constructor(e, t) {
882
+ d(this, "renderer");
883
+ d(this, "context");
884
+ d(this, "projectionScreenMatrix", new Fe());
688
885
  /**
689
886
  * The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
690
887
  * @default 200_000
691
888
  */
692
- u(this, "targetTriangleDensity", 2e5);
889
+ d(this, "targetTriangleDensity", 2e5);
693
890
  /**
694
891
  * The interval in frames to automatically update the bounds of skinned meshes.
695
892
  * Set to 0 or a negative value to disable automatic bounds updates.
696
893
  * @default 30
697
894
  */
698
- u(this, "skinnedMeshAutoUpdateBoundsInterval", 30);
895
+ d(this, "skinnedMeshAutoUpdateBoundsInterval", 30);
699
896
  /**
700
897
  * 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.
701
898
  * @default "auto"
702
899
  */
703
- u(this, "updateInterval", "auto");
704
- H(this, k, 1);
900
+ d(this, "updateInterval", "auto");
901
+ Q(this, F, 1);
705
902
  /**
706
903
  * If set to true, the LODsManager will not update the LODs.
707
904
  * @default false
708
905
  */
709
- u(this, "pause", !1);
906
+ d(this, "pause", !1);
710
907
  /**
711
908
  * When set to true the LODsManager will not update the LODs. This can be used to manually update the LODs using the `update` method.
712
909
  * Otherwise the LODs will be updated automatically when the renderer renders the scene.
713
910
  * @default false
714
911
  */
715
- u(this, "manual", !1);
716
- u(this, "_newPromiseGroups", []);
717
- u(this, "_promiseGroupIds", 0);
718
- u(this, "_lodchangedlisteners", []);
719
- H(this, K, void 0);
720
- H(this, _e, new je());
721
- H(this, J, 0);
722
- H(this, ie, 0);
723
- H(this, we, 0);
724
- H(this, Y, 0);
725
- u(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
912
+ d(this, "manual", !1);
913
+ d(this, "_newPromiseGroups", []);
914
+ d(this, "_promiseGroupIds", 0);
915
+ d(this, "_lodchangedlisteners", []);
916
+ Q(this, j, void 0);
917
+ Q(this, Me, new ut());
918
+ Q(this, ee, 0);
919
+ Q(this, ae, 0);
920
+ Q(this, ve, 0);
921
+ Q(this, H, 0);
922
+ d(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
726
923
  // private testIfLODLevelsAreAvailable() {
727
- u(this, "_sphere", new Ze());
728
- u(this, "_tempBox", new Ee());
729
- u(this, "_tempBox2", new Ee());
730
- u(this, "tempMatrix", new Ge());
731
- u(this, "_tempWorldPosition", new W());
732
- u(this, "_tempBoxSize", new W());
733
- u(this, "_tempBox2Size", new W());
734
- this.renderer = t, this.context = { ...e };
924
+ d(this, "_sphere", new qe());
925
+ d(this, "_tempBox", new Ce());
926
+ d(this, "_tempBox2", new Ce());
927
+ d(this, "tempMatrix", new Fe());
928
+ d(this, "_tempWorldPosition", new W());
929
+ d(this, "_tempBoxSize", new W());
930
+ d(this, "_tempBox2Size", new W());
931
+ this.renderer = e, this.context = { ...t };
735
932
  }
736
933
  /** @internal */
737
- static getObjectLODState(t) {
738
- return t[Se];
934
+ static getObjectLODState(e) {
935
+ return e[Ae];
739
936
  }
740
- static addPlugin(t) {
741
- j.push(t);
937
+ static addPlugin(e) {
938
+ Z.push(e);
742
939
  }
743
- static removePlugin(t) {
744
- const e = j.indexOf(t);
745
- e >= 0 && j.splice(e, 1);
940
+ static removePlugin(e) {
941
+ const t = Z.indexOf(e);
942
+ t >= 0 && Z.splice(t, 1);
746
943
  }
747
944
  /**
748
945
  * Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
749
946
  * @param renderer The renderer to get the LODsManager for.
750
947
  * @returns The LODsManager instance.
751
948
  */
752
- static get(t, e) {
753
- if (t[be])
754
- return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[be];
755
- const s = new O(t, {
949
+ static get(e, t) {
950
+ if (e[Te])
951
+ return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), e[Te];
952
+ const s = new A(e, {
756
953
  engine: "unknown",
757
- ...e
954
+ ...t
758
955
  });
759
- return t[be] = s, s;
956
+ return e[Te] = s, s;
760
957
  }
761
958
  /** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
762
959
  get plugins() {
763
- return j;
960
+ return Z;
764
961
  }
765
962
  /**
766
963
  * Call to await LODs loading during the next render cycle.
767
964
  */
768
- awaitLoading(t) {
769
- const e = this._promiseGroupIds++, s = new ye(y(this, J), { ...t });
965
+ awaitLoading(e) {
966
+ const t = this._promiseGroupIds++, s = new Le(D(this, ee), { ...e });
770
967
  this._newPromiseGroups.push(s);
771
- const n = performance.now();
968
+ const i = performance.now();
772
969
  return s.ready.finally(() => {
773
970
  const r = this._newPromiseGroups.indexOf(s);
774
- r >= 0 && (this._newPromiseGroups.splice(r, 1), ct() && performance.measure("LODsManager:awaitLoading", {
775
- start: n,
776
- detail: { id: e, name: t == null ? void 0 : t.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
971
+ r >= 0 && (this._newPromiseGroups.splice(r, 1), Ne() && performance.measure("LODsManager:awaitLoading", {
972
+ start: i,
973
+ detail: { id: t, name: e == null ? void 0 : e.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
777
974
  }));
778
975
  }), s.ready;
779
976
  }
780
977
  _postprocessPromiseGroups() {
781
978
  if (this._newPromiseGroups.length !== 0)
782
- for (let t = this._newPromiseGroups.length - 1; t >= 0; t--)
783
- this._newPromiseGroups[t].update(y(this, J));
979
+ for (let e = this._newPromiseGroups.length - 1; e >= 0; e--)
980
+ this._newPromiseGroups[e].update(D(this, ee));
784
981
  }
785
- addEventListener(t, e) {
786
- t === "changed" && this._lodchangedlisteners.push(e);
982
+ addEventListener(e, t) {
983
+ e === "changed" && this._lodchangedlisteners.push(t);
787
984
  }
788
- removeEventListener(t, e) {
789
- if (t === "changed") {
790
- const s = this._lodchangedlisteners.indexOf(e);
985
+ removeEventListener(e, t) {
986
+ if (e === "changed") {
987
+ const s = this._lodchangedlisteners.indexOf(t);
791
988
  s >= 0 && this._lodchangedlisteners.splice(s, 1);
792
989
  }
793
990
  }
@@ -795,54 +992,54 @@ const O = class {
795
992
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
796
993
  */
797
994
  enable() {
798
- if (y(this, K))
995
+ if (D(this, j))
799
996
  return;
800
997
  console.debug("[gltf-progressive] Enabling LODsManager for renderer");
801
- let t = 0;
802
- q(this, K, this.renderer.render);
803
- const e = this;
804
- Ue(this.renderer), this.renderer.render = function(s, n) {
805
- const r = e.renderer.getRenderTarget();
806
- (r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, q(e, J, y(e, J) + 1), q(e, ie, y(e, _e).getDelta()), q(e, we, y(e, we) + y(e, ie)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / y(e, ie)), q(e, Y, e._fpsBuffer.reduce((a, l) => a + l) / e._fpsBuffer.length), F && y(e, J) % 200 === 0 && console.log("FPS", Math.round(y(e, Y)), "Interval:", y(e, k)));
807
- const i = t++;
808
- y(e, K).call(this, s, n), e.onAfterRender(s, n, i);
998
+ let e = 0;
999
+ K(this, j, this.renderer.render);
1000
+ const t = this;
1001
+ $e(this.renderer), this.renderer.render = function(s, i) {
1002
+ const r = t.renderer.getRenderTarget();
1003
+ (r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, K(t, ee, D(t, ee) + 1), K(t, ae, D(t, Me).getDelta()), K(t, ve, D(t, ve) + D(t, ae)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / D(t, ae)), K(t, H, t._fpsBuffer.reduce((a, l) => a + l) / t._fpsBuffer.length), z && D(t, ee) % 200 === 0 && console.log("FPS", Math.round(D(t, H)), "Interval:", D(t, F)));
1004
+ const n = e++;
1005
+ D(t, j).call(this, s, i), t.onAfterRender(s, i, n);
809
1006
  };
810
1007
  }
811
1008
  disable() {
812
- y(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, K), q(this, K, void 0));
1009
+ D(this, j) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = D(this, j), K(this, j, void 0));
813
1010
  }
814
- update(t, e) {
815
- this.internalUpdate(t, e);
1011
+ update(e, t) {
1012
+ this.internalUpdate(e, t);
816
1013
  }
817
- onAfterRender(t, e, s) {
1014
+ onAfterRender(e, t, s) {
818
1015
  if (this.pause)
819
1016
  return;
820
- const r = this.renderer.renderLists.get(t, 0).opaque;
821
- let i = !0;
1017
+ const r = this.renderer.renderLists.get(e, 0).opaque;
1018
+ let n = !0;
822
1019
  if (r.length === 1) {
823
1020
  const a = r[0].material;
824
- (a.name === "EffectMaterial" || a.name === "CopyShader") && (i = !1);
1021
+ (a.name === "EffectMaterial" || a.name === "CopyShader") && (n = !1);
825
1022
  }
826
- if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
827
- if (xt || (this.updateInterval === "auto" ? y(this, Y) < 40 && y(this, k) < 10 ? (q(this, k, y(this, k) + 1), F && console.warn("↓ Reducing LOD updates", y(this, k), y(this, Y).toFixed(0))) : y(this, Y) >= 60 && y(this, k) > 1 && (q(this, k, y(this, k) - 1), F && console.warn("↑ Increasing LOD updates", y(this, k), y(this, Y).toFixed(0))) : q(this, k, this.updateInterval), y(this, k) > 0 && y(this, J) % y(this, k) != 0))
1023
+ if ((t.parent && t.parent.type === "CubeCamera" || s >= 1 && t.type === "OrthographicCamera") && (n = !1), n) {
1024
+ if (Bt || (this.updateInterval === "auto" ? D(this, H) < 40 && D(this, F) < 10 ? (K(this, F, D(this, F) + 1), z && console.warn("↓ Reducing LOD updates", D(this, F), D(this, H).toFixed(0))) : D(this, H) >= 60 && D(this, F) > 1 && (K(this, F, D(this, F) - 1), z && console.warn("↑ Increasing LOD updates", D(this, F), D(this, H).toFixed(0))) : K(this, F, this.updateInterval), D(this, F) > 0 && D(this, ee) % D(this, F) != 0))
828
1025
  return;
829
- this.internalUpdate(t, e), this._postprocessPromiseGroups();
1026
+ this.internalUpdate(e, t), this._postprocessPromiseGroups();
830
1027
  }
831
1028
  }
832
1029
  /**
833
1030
  * Update LODs in a scene
834
1031
  */
835
- internalUpdate(t, e) {
836
- var l, c;
837
- const s = this.renderer.renderLists.get(t, 0), n = s.opaque;
838
- this.projectionScreenMatrix.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse);
1032
+ internalUpdate(e, t) {
1033
+ var l, u;
1034
+ const s = this.renderer.renderLists.get(e, 0), i = s.opaque;
1035
+ this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse);
839
1036
  const r = this.targetTriangleDensity;
840
- for (const d of n) {
841
- if (d.material && (((l = d.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((c = d.geometry) == null ? void 0 : c.type) === "BufferGeometry") && (d.material.name === "SphericalGaussianBlur" || d.material.name == "BackgroundCubeMaterial" || d.material.name === "CubemapFromEquirect" || d.material.name === "EquirectangularToCubeUV")) {
842
- F && (d.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (d.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", d, d.material.name, d.material.type)));
1037
+ for (const f of i) {
1038
+ if (f.material && (((l = f.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((u = f.geometry) == null ? void 0 : u.type) === "BufferGeometry") && (f.material.name === "SphericalGaussianBlur" || f.material.name == "BackgroundCubeMaterial" || f.material.name === "CubemapFromEquirect" || f.material.name === "EquirectangularToCubeUV")) {
1039
+ z && (f.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (f.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", f, f.material.name, f.material.type)));
843
1040
  continue;
844
1041
  }
845
- switch (d.material.type) {
1042
+ switch (f.material.type) {
846
1043
  case "LineBasicMaterial":
847
1044
  case "LineDashedMaterial":
848
1045
  case "PointsMaterial":
@@ -851,62 +1048,60 @@ const O = class {
851
1048
  case "MeshDepthMaterial":
852
1049
  continue;
853
1050
  }
854
- if (F === "color" && d.material && !d.object.progressive_debug_color) {
855
- d.object.progressive_debug_color = !0;
856
- const f = Math.random() * 16777215, w = new Je({ color: f });
857
- d.object.material = w;
1051
+ if (z === "color" && f.material && !f.object.progressive_debug_color) {
1052
+ f.object.progressive_debug_color = !0;
1053
+ const _ = Math.random() * 16777215, w = new dt({ color: _ });
1054
+ f.object.material = w;
858
1055
  }
859
- const p = d.object;
860
- (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
1056
+ const m = f.object;
1057
+ (m instanceof ne || m.isMesh) && this.updateLODs(e, t, m, r);
861
1058
  }
862
- const i = s.transparent;
863
- for (const d of i) {
864
- const p = d.object;
865
- (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
1059
+ const n = s.transparent;
1060
+ for (const f of n) {
1061
+ const m = f.object;
1062
+ (m instanceof ne || m.isMesh) && this.updateLODs(e, t, m, r);
866
1063
  }
867
1064
  const a = s.transmissive;
868
- for (const d of a) {
869
- const p = d.object;
870
- (p instanceof se || p.isMesh) && this.updateLODs(t, e, p, r);
1065
+ for (const f of a) {
1066
+ const m = f.object;
1067
+ (m instanceof ne || m.isMesh) && this.updateLODs(e, t, m, r);
871
1068
  }
872
1069
  }
873
1070
  /** Update the LOD levels for the renderer. */
874
- updateLODs(t, e, s, n) {
1071
+ updateLODs(e, t, s, i) {
875
1072
  var a, l;
876
1073
  s.userData || (s.userData = {});
877
- let r = s[Se];
878
- if (r || (r = new Lt(), s[Se] = r), r.frames++ < 2)
1074
+ let r = s[Ae];
1075
+ if (r || (r = new Rt(), s[Ae] = r), r.frames++ < 2)
879
1076
  return;
880
- for (const c of j)
881
- (a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, t, e, s);
882
- const i = O.overrideGlobalLodLevel !== void 0 ? O.overrideGlobalLodLevel : te;
883
- i >= 0 ? ($.mesh_lod = i, $.texture_lod = i) : (this.calculateLodLevel(e, s, r, n, $), $.mesh_lod = Math.round($.mesh_lod), $.texture_lod = Math.round($.texture_lod)), $.mesh_lod >= 0 && this.loadProgressiveMeshes(s, $.mesh_lod), s.material && $.texture_lod >= 0 && this.loadProgressiveTextures(s.material, $.texture_lod), x && s.material && !s.isGizmo && qe(s.material);
884
- for (const c of j)
885
- (l = c.onAfterUpdatedLOD) == null || l.call(c, this.renderer, t, e, s, $);
886
- r.lastLodLevel_Mesh = $.mesh_lod, r.lastLodLevel_Texture = $.texture_lod;
1077
+ for (const u of Z)
1078
+ (a = u.onBeforeUpdateLOD) == null || a.call(u, this.renderer, e, t, s);
1079
+ const n = A.overrideGlobalLodLevel !== void 0 ? A.overrideGlobalLodLevel : re;
1080
+ n >= 0 ? (E.mesh_lod = n, E.texture_lod = n) : (this.calculateLodLevel(t, s, r, i, E), E.mesh_lod = Math.round(E.mesh_lod), E.texture_lod = Math.round(E.texture_lod)), E.mesh_lod >= 0 && this.loadProgressiveMeshes(s, E.mesh_lod), s.material && E.texture_lod >= 0 && this.loadProgressiveTextures(s.material, E.texture_lod, n), x && s.material && !s.isGizmo && He(s.material);
1081
+ for (const u of Z)
1082
+ (l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, e, t, s, E);
1083
+ r.lastLodLevel_Mesh = E.mesh_lod, r.lastLodLevel_Texture = E.texture_lod;
887
1084
  }
888
1085
  /** Load progressive textures for the given material
889
1086
  * @param material the material to load the textures for
890
1087
  * @param level the LOD level to load. Level 0 is the best quality, higher levels are lower quality
891
1088
  * @returns Promise with true if the LOD was loaded, false if not
892
1089
  */
893
- loadProgressiveTextures(t, e) {
894
- if (!t)
1090
+ loadProgressiveTextures(e, t, s) {
1091
+ if (!e)
895
1092
  return;
896
- if (Array.isArray(t)) {
897
- for (const r of t)
898
- this.loadProgressiveTextures(r, e);
1093
+ if (Array.isArray(e)) {
1094
+ for (const r of e)
1095
+ this.loadProgressiveTextures(r, t);
899
1096
  return;
900
1097
  }
901
- let s = !1;
902
- (t[Q] === void 0 || e < t[Q]) && (s = !0);
903
- const n = t["DEBUG:LOD"];
904
- if (n != null && (s = t[Q] != n, e = n), s) {
905
- t[Q] = e;
906
- const r = P.assignTextureLOD(t, e).then((i) => {
907
- this._lodchangedlisteners.forEach((a) => a({ type: "texture", level: e, object: t }));
1098
+ let i = !1;
1099
+ if ((e[J] === void 0 || t < e[J]) && (i = !0), s !== void 0 && s >= 0 && (i = e[J] != s, t = s), i) {
1100
+ e[J] = t;
1101
+ const r = C.assignTextureLOD(e, t).then((n) => {
1102
+ this._lodchangedlisteners.forEach((a) => a({ type: "texture", level: t, object: e }));
908
1103
  });
909
- ye.addPromise("texture", t, r, this._newPromiseGroups);
1104
+ Le.addPromise("texture", e, r, this._newPromiseGroups);
910
1105
  }
911
1106
  }
912
1107
  /** Load progressive meshes for the given mesh
@@ -915,132 +1110,133 @@ const O = class {
915
1110
  * @param level the LOD level to load. Level 0 is the best quality, higher levels are lower quality
916
1111
  * @returns Promise with true if the LOD was loaded, false if not
917
1112
  */
918
- loadProgressiveMeshes(t, e) {
919
- if (!t)
1113
+ loadProgressiveMeshes(e, t) {
1114
+ if (!e)
920
1115
  return Promise.resolve(null);
921
- let s = t[Q] !== e;
922
- const n = t["DEBUG:LOD"];
923
- if (n != null && (s = t[Q] != n, e = n), s) {
924
- t[Q] = e;
925
- const r = t.geometry, i = P.assignMeshLOD(t, e).then((a) => (a && t[Q] == e && r != t.geometry && this._lodchangedlisteners.forEach((l) => l({ type: "mesh", level: e, object: t })), a));
926
- return ye.addPromise("mesh", t, i, this._newPromiseGroups), i;
1116
+ let s = e[J] !== t;
1117
+ const i = e["DEBUG:LOD"];
1118
+ if (i != null && (s = e[J] != i, t = i), s) {
1119
+ e[J] = t;
1120
+ const r = e.geometry, n = C.assignMeshLOD(e, t).then((a) => (a && e[J] == t && r != e.geometry && this._lodchangedlisteners.forEach((l) => l({ type: "mesh", level: t, object: e })), a));
1121
+ return Le.addPromise("mesh", e, n, this._newPromiseGroups), n;
927
1122
  }
928
1123
  return Promise.resolve(null);
929
1124
  }
930
- static isInside(t, e) {
931
- const s = t.min, n = t.max, r = (s.x + n.x) * 0.5, i = (s.y + n.y) * 0.5;
932
- return this._tempPtInside.set(r, i, s.z).applyMatrix4(e).z < 0;
1125
+ static isInside(e, t) {
1126
+ const s = e.min, i = e.max, r = (s.x + i.x) * 0.5, n = (s.y + i.y) * 0.5;
1127
+ return this._tempPtInside.set(r, n, s.z).applyMatrix4(t).z < 0;
933
1128
  }
934
- calculateLodLevel(t, e, s, n, r) {
935
- var b, R, Z;
936
- if (!e) {
1129
+ // #region calculateLodLevel
1130
+ calculateLodLevel(e, t, s, i, r) {
1131
+ var B, b, c, v;
1132
+ if (!t) {
937
1133
  r.mesh_lod = -1, r.texture_lod = -1;
938
1134
  return;
939
1135
  }
940
- if (!t) {
1136
+ if (!e) {
941
1137
  r.mesh_lod = -1, r.texture_lod = -1;
942
1138
  return;
943
1139
  }
944
1140
  let a = 10 + 1, l = !1;
945
- if (F && e["DEBUG:LOD"] != null)
946
- return e["DEBUG:LOD"];
947
- const c = (b = P.getMeshLODExtension(e.geometry)) == null ? void 0 : b.lods, d = P.getPrimitiveIndex(e.geometry), p = c && c.length > 0, f = P.getMaterialMinMaxLODsCount(e.material), w = (f == null ? void 0 : f.min_count) != 1 / 0 && f.min_count > 0 && f.max_count > 0;
948
- if (!p && !w) {
1141
+ if (z && t["DEBUG:LOD"] != null)
1142
+ return t["DEBUG:LOD"];
1143
+ const u = (B = C.getMeshLODExtension(t.geometry)) == null ? void 0 : B.lods, f = C.getPrimitiveIndex(t.geometry), m = u && u.length > 0, _ = C.getMaterialMinMaxLODsCount(t.material), w = _.min_count !== 1 / 0 && _.min_count >= 0 && _.max_count >= 0;
1144
+ if (!m && !w) {
949
1145
  r.mesh_lod = 0, r.texture_lod = 0;
950
1146
  return;
951
1147
  }
952
- p || (l = !0, a = 0);
953
- const M = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
954
- let A = e.geometry.boundingBox;
955
- if (e.type === "SkinnedMesh") {
956
- const h = e;
1148
+ m || (l = !0, a = 0);
1149
+ const O = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
1150
+ let M = t.geometry.boundingBox;
1151
+ if (t.type === "SkinnedMesh") {
1152
+ const h = t;
957
1153
  if (!h.boundingBox)
958
1154
  h.computeBoundingBox();
959
1155
  else if (this.skinnedMeshAutoUpdateBoundsInterval > 0) {
960
- if (!h[O.$skinnedMeshBoundsOffset]) {
961
- const C = O.skinnedMeshBoundsFrameOffsetCounter++;
962
- h[O.$skinnedMeshBoundsOffset] = C;
1156
+ if (!h[A.$skinnedMeshBoundsOffset]) {
1157
+ const T = A.skinnedMeshBoundsFrameOffsetCounter++;
1158
+ h[A.$skinnedMeshBoundsOffset] = T;
963
1159
  }
964
- const L = h[O.$skinnedMeshBoundsOffset];
1160
+ const L = h[A.$skinnedMeshBoundsOffset];
965
1161
  if ((s.frames + L) % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
966
- const C = ce(h), N = h.geometry;
967
- C && (h.geometry = C), h.computeBoundingBox(), h.geometry = N;
1162
+ const T = ge(h), U = h.geometry;
1163
+ T && (h.geometry = T), h.computeBoundingBox(), h.geometry = U;
968
1164
  }
969
1165
  }
970
- A = h.boundingBox;
1166
+ M = h.boundingBox;
971
1167
  }
972
- if (A) {
973
- const h = t;
974
- if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
975
- this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
976
- const g = t.getWorldPosition(this._tempWorldPosition);
1168
+ if (M) {
1169
+ const h = e;
1170
+ if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
1171
+ this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
1172
+ const g = e.getWorldPosition(this._tempWorldPosition);
977
1173
  if (this._sphere.containsPoint(g)) {
978
1174
  r.mesh_lod = 0, r.texture_lod = 0;
979
1175
  return;
980
1176
  }
981
1177
  }
982
- if (this._tempBox.copy(A), this._tempBox.applyMatrix4(e.matrixWorld), h.isPerspectiveCamera && O.isInside(this._tempBox, this.projectionScreenMatrix)) {
1178
+ if (this._tempBox.copy(M), this._tempBox.applyMatrix4(t.matrixWorld), h.isPerspectiveCamera && A.isInside(this._tempBox, this.projectionScreenMatrix)) {
983
1179
  r.mesh_lod = 0, r.texture_lod = 0;
984
1180
  return;
985
1181
  }
986
1182
  if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && h.isPerspectiveCamera && h.fov > 70) {
987
- const g = this._tempBox.min, _ = this._tempBox.max;
988
- let G = g.x, E = g.y, z = _.x, ne = _.y;
989
- const fe = 2, ve = 1.5, he = (g.x + _.x) * 0.5, ge = (g.y + _.y) * 0.5;
990
- G = (G - he) * fe + he, E = (E - ge) * fe + ge, z = (z - he) * fe + he, ne = (ne - ge) * fe + ge;
991
- const Xe = G < 0 && z > 0 ? 0 : Math.min(Math.abs(g.x), Math.abs(_.x)), Ke = E < 0 && ne > 0 ? 0 : Math.min(Math.abs(g.y), Math.abs(_.y)), Me = Math.max(Xe, Ke);
992
- s.lastCentrality = (ve - Me) * (ve - Me) * (ve - Me);
1183
+ const g = this._tempBox.min, y = this._tempBox.max;
1184
+ let I = g.x, R = g.y, X = y.x, le = y.y;
1185
+ const pe = 2, De = 1.5, me = (g.x + y.x) * 0.5, ye = (g.y + y.y) * 0.5;
1186
+ I = (I - me) * pe + me, R = (R - ye) * pe + ye, X = (X - me) * pe + me, le = (le - ye) * pe + ye;
1187
+ const Ze = I < 0 && X > 0 ? 0 : Math.min(Math.abs(g.x), Math.abs(y.x)), et = R < 0 && le > 0 ? 0 : Math.min(Math.abs(g.y), Math.abs(y.y)), be = Math.max(Ze, et);
1188
+ s.lastCentrality = (De - be) * (De - be) * (De - be);
993
1189
  } else
994
1190
  s.lastCentrality = 1;
995
1191
  const L = this._tempBox.getSize(this._tempBoxSize);
996
- L.multiplyScalar(0.5), screen.availHeight > 0 && M > 0 && L.multiplyScalar(M / screen.availHeight), t.isPerspectiveCamera ? L.x *= t.aspect : t.isOrthographicCamera;
997
- const C = t.matrixWorldInverse, N = this._tempBox2;
998
- N.copy(A), N.applyMatrix4(e.matrixWorld), N.applyMatrix4(C);
999
- const S = N.getSize(this._tempBox2Size), ee = Math.max(S.x, S.y);
1000
- if (Math.max(L.x, L.y) != 0 && ee != 0 && (L.z = S.z / Math.max(S.x, S.y) * Math.max(L.x, L.y)), s.lastScreenCoverage = Math.max(L.x, L.y, L.z), s.lastScreenspaceVolume.copy(L), s.lastScreenCoverage *= s.lastCentrality, F && O.debugDrawLine) {
1192
+ L.multiplyScalar(0.5), screen.availHeight > 0 && O > 0 && L.multiplyScalar(O / screen.availHeight), e.isPerspectiveCamera ? L.x *= e.aspect : e.isOrthographicCamera;
1193
+ const T = e.matrixWorldInverse, U = this._tempBox2;
1194
+ U.copy(M), U.applyMatrix4(t.matrixWorld), U.applyMatrix4(T);
1195
+ const k = U.getSize(this._tempBox2Size), te = Math.max(k.x, k.y);
1196
+ if (Math.max(L.x, L.y) != 0 && te != 0 && (L.z = k.z / Math.max(k.x, k.y) * Math.max(L.x, L.y)), s.lastScreenCoverage = Math.max(L.x, L.y, L.z), s.lastScreenspaceVolume.copy(L), s.lastScreenCoverage *= s.lastCentrality, z && A.debugDrawLine) {
1001
1197
  const g = this.tempMatrix.copy(this.projectionScreenMatrix);
1002
1198
  g.invert();
1003
- const _ = O.corner0, G = O.corner1, E = O.corner2, z = O.corner3;
1004
- _.copy(this._tempBox.min), G.copy(this._tempBox.max), G.x = _.x, E.copy(this._tempBox.max), E.y = _.y, z.copy(this._tempBox.max);
1005
- const ne = (_.z + z.z) * 0.5;
1006
- _.z = G.z = E.z = z.z = ne, _.applyMatrix4(g), G.applyMatrix4(g), E.applyMatrix4(g), z.applyMatrix4(g), O.debugDrawLine(_, G, 255), O.debugDrawLine(_, E, 255), O.debugDrawLine(G, z, 255), O.debugDrawLine(E, z, 255);
1199
+ const y = A.corner0, I = A.corner1, R = A.corner2, X = A.corner3;
1200
+ y.copy(this._tempBox.min), I.copy(this._tempBox.max), I.x = y.x, R.copy(this._tempBox.max), R.y = y.y, X.copy(this._tempBox.max);
1201
+ const le = (y.z + X.z) * 0.5;
1202
+ y.z = I.z = R.z = X.z = le, y.applyMatrix4(g), I.applyMatrix4(g), R.applyMatrix4(g), X.applyMatrix4(g), A.debugDrawLine(y, I, 255), A.debugDrawLine(y, R, 255), A.debugDrawLine(I, X, 255), A.debugDrawLine(R, X, 255);
1007
1203
  }
1008
- let v = 999;
1009
- if (c && s.lastScreenCoverage > 0)
1010
- for (let g = 0; g < c.length; g++) {
1011
- const _ = c[g];
1012
- if ((((R = _.densities) == null ? void 0 : R[d]) || _.density || 1e-5) / s.lastScreenCoverage < n) {
1013
- v = g;
1204
+ let S = 999;
1205
+ if (u && s.lastScreenCoverage > 0)
1206
+ for (let g = 0; g < u.length; g++) {
1207
+ const y = u[g], R = (((b = y.densities) == null ? void 0 : b[f]) || y.density || 1e-5) / s.lastScreenCoverage;
1208
+ if (f > 0 && Ne() && !y.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] = !0, console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")), R < i) {
1209
+ S = g;
1014
1210
  break;
1015
1211
  }
1016
1212
  }
1017
- v < a && (a = v, l = !0);
1213
+ S < a && (a = S, l = !0);
1018
1214
  }
1019
- if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, F && r.mesh_lod != s.lastLodLevel_Mesh) {
1020
- const L = c == null ? void 0 : c[r.mesh_lod];
1021
- L && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${L.density.toFixed(0)}) - ${e.name}`);
1215
+ if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, z && r.mesh_lod != s.lastLodLevel_Mesh) {
1216
+ const L = u == null ? void 0 : u[r.mesh_lod];
1217
+ L && console.debug(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (density: ${(c = L.densities) == null ? void 0 : c[f].toFixed(0)}) | ${t.name}`);
1022
1218
  }
1023
1219
  if (w) {
1024
1220
  const h = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
1025
1221
  if (s.lastLodLevel_Texture < 0) {
1026
- if (r.texture_lod = f.max_count - 1, F) {
1027
- const L = f.lods[f.max_count - 1];
1028
- F && console.log(`First Texture LOD ${r.texture_lod} (${L.max_height}px) - ${e.name}`);
1222
+ if (r.texture_lod = _.max_count - 1, z) {
1223
+ const L = _.lods[_.max_count - 1];
1224
+ z && console.log(`First Texture LOD ${r.texture_lod} (${L.max_height}px) - ${t.name}`);
1029
1225
  }
1030
1226
  } else {
1031
1227
  const L = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
1032
- let C = s.lastScreenCoverage * 4;
1033
- ((Z = this.context) == null ? void 0 : Z.engine) === "model-viewer" && (C *= 1.5);
1034
- const S = M / window.devicePixelRatio * C;
1035
- let ee = !1;
1036
- for (let B = f.lods.length - 1; B >= 0; B--) {
1037
- const v = f.lods[B];
1038
- if (!(h && v.max_height >= 2048) && !(dt() && v.max_height > 4096) && (v.max_height > S || !ee && B === 0)) {
1039
- if (ee = !0, r.texture_lod = B, r.texture_lod < s.lastLodLevel_Texture) {
1040
- const m = v.max_height;
1041
- F && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${m}px
1042
- Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${L.toFixed(1)}
1043
- ${e.name}`);
1228
+ let T = s.lastScreenCoverage * 4;
1229
+ ((v = this.context) == null ? void 0 : v.engine) === "model-viewer" && (T *= 1.5);
1230
+ const k = O / window.devicePixelRatio * T;
1231
+ let te = !1;
1232
+ for (let G = _.lods.length - 1; G >= 0; G--) {
1233
+ const S = _.lods[G];
1234
+ if (!(h && S.max_height >= 2048) && !(je() && S.max_height > 4096) && (S.max_height > k || !te && G === 0)) {
1235
+ if (te = !0, r.texture_lod = G, z && r.texture_lod < s.lastLodLevel_Texture) {
1236
+ const p = S.max_height;
1237
+ console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${p}px
1238
+ Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${L.toFixed(1)}
1239
+ ${t.name}`);
1044
1240
  }
1045
1241
  break;
1046
1242
  }
@@ -1050,70 +1246,70 @@ ${e.name}`);
1050
1246
  r.texture_lod = 0;
1051
1247
  }
1052
1248
  };
1053
- let T = O;
1054
- k = new WeakMap(), K = new WeakMap(), _e = new WeakMap(), J = new WeakMap(), ie = new WeakMap(), we = new WeakMap(), Y = new WeakMap(), /**
1249
+ let $ = A;
1250
+ F = new WeakMap(), j = new WeakMap(), Me = new WeakMap(), ee = new WeakMap(), ae = new WeakMap(), ve = new WeakMap(), H = new WeakMap(), /**
1055
1251
  * 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.
1056
1252
  */
1057
- u(T, "debugDrawLine"), /**
1253
+ d($, "debugDrawLine"), /**
1058
1254
  * Force override the LOD level for all objects in the scene
1059
1255
  */
1060
- u(T, "overrideGlobalLodLevel"), u(T, "corner0", new W()), u(T, "corner1", new W()), u(T, "corner2", new W()), u(T, "corner3", new W()), u(T, "_tempPtInside", new W()), u(T, "skinnedMeshBoundsFrameOffsetCounter", 0), u(T, "$skinnedMeshBoundsOffset", Symbol("gltf-progressive-skinnedMeshBoundsOffset"));
1061
- class Lt {
1256
+ d($, "overrideGlobalLodLevel"), d($, "corner0", new W()), d($, "corner1", new W()), d($, "corner2", new W()), d($, "corner3", new W()), d($, "_tempPtInside", new W()), d($, "skinnedMeshBoundsFrameOffsetCounter", 0), d($, "$skinnedMeshBoundsOffset", Symbol("gltf-progressive-skinnedMeshBoundsOffset"));
1257
+ class Rt {
1062
1258
  constructor() {
1063
- u(this, "frames", 0);
1064
- u(this, "lastLodLevel_Mesh", -1);
1065
- u(this, "lastLodLevel_Texture", -1);
1066
- u(this, "lastScreenCoverage", 0);
1067
- u(this, "lastScreenspaceVolume", new W());
1068
- u(this, "lastCentrality", 0);
1259
+ d(this, "frames", 0);
1260
+ d(this, "lastLodLevel_Mesh", -1);
1261
+ d(this, "lastLodLevel_Texture", -1);
1262
+ d(this, "lastScreenCoverage", 0);
1263
+ d(this, "lastScreenspaceVolume", new W());
1264
+ d(this, "lastCentrality", 0);
1069
1265
  }
1070
1266
  }
1071
- const $e = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
1072
- let ue = null;
1073
- function Ve() {
1074
- const o = _t();
1075
- o && (o.mapURLs(function(t) {
1076
- return ke(), t;
1077
- }), ke(), ue == null || ue.disconnect(), ue = new MutationObserver((t) => {
1078
- t.forEach((e) => {
1079
- e.addedNodes.forEach((s) => {
1080
- s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && We(s);
1267
+ const Ue = Symbol("NEEDLE_mesh_lod"), xe = Symbol("NEEDLE_texture_lod");
1268
+ let fe = null;
1269
+ function Qe() {
1270
+ const o = $t();
1271
+ o && (o.mapURLs(function(e) {
1272
+ return We(), e;
1273
+ }), We(), fe == null || fe.disconnect(), fe = new MutationObserver((e) => {
1274
+ e.forEach((t) => {
1275
+ t.addedNodes.forEach((s) => {
1276
+ s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Je(s);
1081
1277
  });
1082
1278
  });
1083
- }), ue.observe(document, { childList: !0, subtree: !0 }));
1279
+ }), fe.observe(document, { childList: !0, subtree: !0 }));
1084
1280
  }
1085
- function _t() {
1281
+ function $t() {
1086
1282
  if (typeof customElements > "u")
1087
1283
  return null;
1088
1284
  const o = customElements.get("model-viewer");
1089
1285
  return o || (customElements.whenDefined("model-viewer").then(() => {
1090
- console.debug("[gltf-progressive] model-viewer defined"), Ve();
1286
+ console.debug("[gltf-progressive] model-viewer defined"), Qe();
1091
1287
  }), null);
1092
1288
  }
1093
- function ke() {
1289
+ function We() {
1094
1290
  if (typeof document > "u")
1095
1291
  return;
1096
- document.querySelectorAll("model-viewer").forEach((t) => {
1097
- We(t);
1292
+ document.querySelectorAll("model-viewer").forEach((e) => {
1293
+ Je(e);
1098
1294
  });
1099
1295
  }
1100
- const Ie = /* @__PURE__ */ new WeakSet();
1101
- let wt = 0;
1102
- function We(o) {
1103
- if (!o || Ie.has(o))
1296
+ const ze = /* @__PURE__ */ new WeakSet();
1297
+ let Gt = 0;
1298
+ function Je(o) {
1299
+ if (!o || ze.has(o))
1104
1300
  return null;
1105
- Ie.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++wt + `
1301
+ ze.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++Gt + `
1106
1302
  `, o.getAttribute("src"));
1107
- let t = null, e = null, s = null;
1108
- for (let n = o; n != null; n = Object.getPrototypeOf(n)) {
1109
- const r = Object.getOwnPropertySymbols(n), i = r.find((c) => c.toString() == "Symbol(renderer)"), a = r.find((c) => c.toString() == "Symbol(scene)"), l = r.find((c) => c.toString() == "Symbol(needsRender)");
1110
- !t && i != null && (t = o[i].threeRenderer), !e && a != null && (e = o[a]), !s && l != null && (s = o[l]);
1303
+ let e = null, t = null, s = null;
1304
+ for (let i = o; i != null; i = Object.getPrototypeOf(i)) {
1305
+ const r = Object.getOwnPropertySymbols(i), n = r.find((u) => u.toString() == "Symbol(renderer)"), a = r.find((u) => u.toString() == "Symbol(scene)"), l = r.find((u) => u.toString() == "Symbol(needsRender)");
1306
+ !e && n != null && (e = o[n].threeRenderer), !t && a != null && (t = o[a]), !s && l != null && (s = o[l]);
1111
1307
  }
1112
- if (t && e) {
1113
- let n = function() {
1308
+ if (e && t) {
1309
+ let i = function() {
1114
1310
  if (s) {
1115
- let i = 0, a = setInterval(() => {
1116
- if (i++ > 5) {
1311
+ let n = 0, a = setInterval(() => {
1312
+ if (n++ > 5) {
1117
1313
  clearInterval(a);
1118
1314
  return;
1119
1315
  }
@@ -1122,129 +1318,129 @@ function We(o) {
1122
1318
  }
1123
1319
  };
1124
1320
  console.debug("[gltf-progressive] setup model-viewer");
1125
- const r = T.get(t, { engine: "model-viewer" });
1126
- return T.addPlugin(new vt()), r.enable(), r.addEventListener("changed", () => {
1321
+ const r = $.get(e, { engine: "model-viewer" });
1322
+ return $.addPlugin(new Et()), r.enable(), r.addEventListener("changed", () => {
1127
1323
  s == null || s.call(o);
1128
- }), o.addEventListener("model-visibility", (i) => {
1129
- i.detail.visible && (s == null || s.call(o));
1324
+ }), o.addEventListener("model-visibility", (n) => {
1325
+ n.detail.visible && (s == null || s.call(o));
1130
1326
  }), o.addEventListener("load", () => {
1131
- n();
1327
+ i();
1132
1328
  }), () => {
1133
1329
  r.disable();
1134
1330
  };
1135
1331
  }
1136
1332
  return null;
1137
1333
  }
1138
- class vt {
1334
+ class Et {
1139
1335
  constructor() {
1140
- u(this, "_didWarnAboutMissingUrl", !1);
1336
+ d(this, "_didWarnAboutMissingUrl", !1);
1141
1337
  }
1142
- onBeforeUpdateLOD(t, e, s, n) {
1143
- this.tryParseMeshLOD(e, n), this.tryParseTextureLOD(e, n);
1338
+ onBeforeUpdateLOD(e, t, s, i) {
1339
+ this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
1144
1340
  }
1145
- getUrl(t) {
1146
- if (!t)
1341
+ getUrl(e) {
1342
+ if (!e)
1147
1343
  return null;
1148
- let e = t.getAttribute("src");
1149
- return e || (e = t.src), e || (this._didWarnAboutMissingUrl || console.warn("No url found in modelviewer", t), this._didWarnAboutMissingUrl = !0), e;
1344
+ let t = e.getAttribute("src");
1345
+ return t || (t = e.src), t || (this._didWarnAboutMissingUrl || console.warn("No url found in modelviewer", e), this._didWarnAboutMissingUrl = !0), t;
1150
1346
  }
1151
- tryGetCurrentGLTF(t) {
1152
- return t._currentGLTF;
1347
+ tryGetCurrentGLTF(e) {
1348
+ return e._currentGLTF;
1153
1349
  }
1154
- tryGetCurrentModelViewer(t) {
1155
- return t.element;
1350
+ tryGetCurrentModelViewer(e) {
1351
+ return e.element;
1156
1352
  }
1157
- tryParseTextureLOD(t, e) {
1158
- if (e[pe] == !0)
1353
+ tryParseTextureLOD(e, t) {
1354
+ if (t[xe] == !0)
1159
1355
  return;
1160
- e[pe] = !0;
1161
- const s = this.tryGetCurrentGLTF(t), n = this.tryGetCurrentModelViewer(t), r = this.getUrl(n);
1162
- if (r && s && e.material) {
1163
- let i = function(l) {
1164
- var d, p, f;
1165
- if (l[pe] == !0)
1356
+ t[xe] = !0;
1357
+ const s = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), r = this.getUrl(i);
1358
+ if (r && s && t.material) {
1359
+ let n = function(l) {
1360
+ var f, m, _;
1361
+ if (l[xe] == !0)
1166
1362
  return;
1167
- l[pe] = !0, l.userData && (l.userData.LOD = -1);
1168
- const c = Object.keys(l);
1169
- for (let w = 0; w < c.length; w++) {
1170
- const M = c[w], A = l[M];
1171
- if ((A == null ? void 0 : A.isTexture) === !0) {
1172
- const b = (p = (d = A.userData) == null ? void 0 : d.associations) == null ? void 0 : p.textures;
1173
- if (b == null)
1363
+ l[xe] = !0, l.userData && (l.userData.LOD = -1);
1364
+ const u = Object.keys(l);
1365
+ for (let w = 0; w < u.length; w++) {
1366
+ const O = u[w], M = l[O];
1367
+ if ((M == null ? void 0 : M.isTexture) === !0) {
1368
+ const B = (m = (f = M.userData) == null ? void 0 : f.associations) == null ? void 0 : m.textures;
1369
+ if (B == null)
1174
1370
  continue;
1175
- const R = s.parser.json.textures[b];
1176
- if (!R) {
1177
- console.warn("Texture data not found for texture index " + b);
1371
+ const b = s.parser.json.textures[B];
1372
+ if (!b) {
1373
+ console.warn("Texture data not found for texture index " + B);
1178
1374
  continue;
1179
1375
  }
1180
- if ((f = R == null ? void 0 : R.extensions) != null && f[X]) {
1181
- const Z = R.extensions[X];
1182
- Z && r && P.registerTexture(r, A, Z.lods.length, b, Z);
1376
+ if ((_ = b == null ? void 0 : b.extensions) != null && _[Y]) {
1377
+ const c = b.extensions[Y];
1378
+ c && r && C.registerTexture(r, M, c.lods.length, B, c);
1183
1379
  }
1184
1380
  }
1185
1381
  }
1186
1382
  };
1187
- const a = e.material;
1383
+ const a = t.material;
1188
1384
  if (Array.isArray(a))
1189
1385
  for (const l of a)
1190
- i(l);
1386
+ n(l);
1191
1387
  else
1192
- i(a);
1388
+ n(a);
1193
1389
  }
1194
1390
  }
1195
- tryParseMeshLOD(t, e) {
1196
- var i, a;
1197
- if (e[$e] == !0)
1391
+ tryParseMeshLOD(e, t) {
1392
+ var n, a;
1393
+ if (t[Ue] == !0)
1198
1394
  return;
1199
- e[$e] = !0;
1200
- const s = this.tryGetCurrentModelViewer(t), n = this.getUrl(s);
1201
- if (!n)
1395
+ t[Ue] = !0;
1396
+ const s = this.tryGetCurrentModelViewer(e), i = this.getUrl(s);
1397
+ if (!i)
1202
1398
  return;
1203
- const r = (a = (i = e.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[X];
1204
- if (r && n) {
1205
- const l = e.uuid;
1206
- P.registerMesh(n, l, e, 0, r.lods.length, r);
1399
+ const r = (a = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : a[Y];
1400
+ if (r && i) {
1401
+ const l = t.uuid;
1402
+ C.registerMesh(i, l, t, 0, r.lods.length, r);
1207
1403
  }
1208
1404
  }
1209
1405
  }
1210
- function Mt(o, t, e, s) {
1211
- Ue(t), Ne(e), ze(e, {
1406
+ function Ft(o, e, t, s) {
1407
+ $e(e), Xe(t), Ye(t, {
1212
1408
  progressive: !0,
1213
1409
  ...s == null ? void 0 : s.hints
1214
- }), e.register((r) => new P(r, o));
1215
- const n = T.get(t);
1216
- return (s == null ? void 0 : s.enableLODsManager) !== !1 && n.enable(), n;
1410
+ }), t.register((r) => new C(r, o));
1411
+ const i = $.get(e);
1412
+ return (s == null ? void 0 : s.enableLODsManager) !== !1 && i.enable(), i;
1217
1413
  }
1218
- Ve();
1219
- if (!ht) {
1414
+ Qe();
1415
+ if (!vt) {
1220
1416
  const o = {
1221
1417
  gltfProgressive: {
1222
- useNeedleProgressive: Mt,
1223
- LODsManager: T,
1224
- configureLoader: ze,
1225
- getRaycastMesh: ce,
1226
- useRaycastMeshes: pt
1418
+ useNeedleProgressive: Ft,
1419
+ LODsManager: $,
1420
+ configureLoader: Ye,
1421
+ getRaycastMesh: ge,
1422
+ useRaycastMeshes: bt
1227
1423
  }
1228
1424
  };
1229
1425
  if (!globalThis.Needle)
1230
1426
  globalThis.Needle = o;
1231
1427
  else
1232
- for (const t in o)
1233
- globalThis.Needle[t] = o[t];
1428
+ for (const e in o)
1429
+ globalThis.Needle[e] = o[e];
1234
1430
  }
1235
1431
  export {
1236
- X as EXTENSION_NAME,
1237
- T as LODsManager,
1238
- P as NEEDLE_progressive,
1239
- rt as VERSION,
1240
- Ne as addDracoAndKTX2Loaders,
1241
- ze as configureLoader,
1242
- Ue as createLoaders,
1243
- ce as getRaycastMesh,
1244
- Ve as patchModelViewer,
1245
- gt as registerRaycastMesh,
1246
- ot as setDracoDecoderLocation,
1247
- at as setKTX2TranscoderLocation,
1248
- Mt as useNeedleProgressive,
1249
- pt as useRaycastMeshes
1432
+ Y as EXTENSION_NAME,
1433
+ $ as LODsManager,
1434
+ C as NEEDLE_progressive,
1435
+ gt as VERSION,
1436
+ Xe as addDracoAndKTX2Loaders,
1437
+ Ye as configureLoader,
1438
+ $e as createLoaders,
1439
+ ge as getRaycastMesh,
1440
+ Qe as patchModelViewer,
1441
+ Dt as registerRaycastMesh,
1442
+ xt as setDracoDecoderLocation,
1443
+ wt as setKTX2TranscoderLocation,
1444
+ Ft as useNeedleProgressive,
1445
+ bt as useRaycastMeshes
1250
1446
  };