@needle-tools/engine 6.0.0-alpha.4 → 6.0.0-alpha.5

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +11 -1
  3. package/dist/{gltf-progressive-CcSfG2Ja.js → gltf-progressive-B7lOWdLe.js} +117 -115
  4. package/dist/gltf-progressive-BpT9M5Mt.umd.cjs +10 -0
  5. package/dist/gltf-progressive-D0rzvhNG.min.js +10 -0
  6. package/dist/{needle-engine.bundle-0tD9EcNs.js → needle-engine.bundle-4xlWxOTF.js} +592 -581
  7. package/dist/{needle-engine.bundle-BuUj9B4K.umd.cjs → needle-engine.bundle-D3nBMgfk.umd.cjs} +9 -9
  8. package/dist/{needle-engine.bundle-Bmcb5t3w.min.js → needle-engine.bundle-_kAszB-k.min.js} +27 -27
  9. package/dist/needle-engine.d.ts +13 -13
  10. package/dist/needle-engine.js +575 -575
  11. package/dist/needle-engine.min.js +1 -1
  12. package/dist/needle-engine.umd.cjs +1 -1
  13. package/lib/engine/api.d.ts +1 -1
  14. package/lib/engine/api.js +1 -1
  15. package/lib/engine/api.js.map +1 -1
  16. package/lib/engine/engine_init.js +2 -2
  17. package/lib/engine/engine_license.d.ts +7 -7
  18. package/lib/engine/engine_license.js +98 -78
  19. package/lib/engine/engine_license.js.map +1 -1
  20. package/lib/engine/engine_networking_blob.js +3 -3
  21. package/lib/engine/engine_networking_blob.js.map +1 -1
  22. package/lib/engine/engine_utils_qrcode.js +2 -2
  23. package/lib/engine/engine_utils_qrcode.js.map +1 -1
  24. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  25. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  26. package/lib/engine/webcomponents/needle menu/needle-menu.js +5 -5
  27. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  28. package/lib/engine/webcomponents/needle-engine.js +2 -2
  29. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  30. package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
  31. package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
  32. package/lib/engine/xr/TempXRContext.js +2 -2
  33. package/lib/engine/xr/TempXRContext.js.map +1 -1
  34. package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
  35. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  36. package/package.json +5 -2
  37. package/plugins/common/license.js +4 -4
  38. package/plugins/license/README.md +38 -0
  39. package/plugins/license/cli.js +43 -0
  40. package/plugins/license/index.js +24 -0
  41. package/plugins/vite/license.js +4 -4
  42. package/src/engine/api.ts +1 -1
  43. package/src/engine/engine_init.ts +2 -2
  44. package/src/engine/engine_license.ts +93 -76
  45. package/src/engine/engine_networking_blob.ts +3 -3
  46. package/src/engine/engine_utils_qrcode.ts +2 -2
  47. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
  48. package/src/engine/webcomponents/needle menu/needle-menu.ts +5 -5
  49. package/src/engine/webcomponents/needle-engine.loading.ts +2 -2
  50. package/src/engine/webcomponents/needle-engine.ts +2 -2
  51. package/src/engine/xr/TempXRContext.ts +2 -2
  52. package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
  53. package/dist/gltf-progressive-BYG9UH7O.min.js +0 -10
  54. package/dist/gltf-progressive-sK--FWg7.umd.cjs +0 -10
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [6.0.0-alpha.5] - 2026-10-05
8
+
9
+ - Added initial support for using Needle Engine with Angular.
10
+
7
11
  ## [6.0.0-alpha.4] - 2026-10-01
8
12
 
9
13
  - AR starts more reliably from iOS App Clips, and switching scenes keeps the camera view visible.
package/README.md CHANGED
@@ -17,6 +17,16 @@ npm install @needle-tools/engine
17
17
 
18
18
  [Try it now on StackBlitz](https://engine.needle.tools/new) | [Getting Started Guide](https://docs.needle.tools/getting-started)
19
19
 
20
+ ### Angular CLI
21
+
22
+ Angular CLI projects can use the standard `ng serve` and `ng build` commands.
23
+ To include a signed license, generate a [license file](plugins/license/README.md)
24
+ before those commands. Needle Engine falls back to its runtime license check
25
+ when no signed license is available. Angular's `@angular/build:application` builder may need a
26
+ `.wasm` file loader and `node:module` listed under `externalDependencies` for
27
+ the current MaterialX package. Decoder assets, when needed, are managed by the
28
+ project.
29
+
20
30
  ## Code Examples
21
31
 
22
32
  ### Custom Component
@@ -167,4 +177,4 @@ Needle Engine works standalone with just npm — no editor required. For asset-h
167
177
  [Twitter](https://twitter.com/NeedleTools) •
168
178
  [Discord](https://discord.needle.tools) •
169
179
  [Forum](https://forum.needle.tools) •
170
- [Youtube](https://www.youtube.com/@needle-tools)
180
+ [Youtube](https://www.youtube.com/@needle-tools)
@@ -1,60 +1,62 @@
1
- import { RedFormat as je, RedIntegerFormat as He, RGFormat as Ke, RGIntegerFormat as Ye, RGBFormat as Qe, RGBAFormat as Je, RGBAIntegerFormat as Ze, BufferGeometry as K, Mesh as Y, Box3 as de, Vector3 as A, Sphere as $e, CompressedTexture as et, Texture as q, Matrix3 as tt, InterleavedBuffer as st, InterleavedBufferAttribute as rt, BufferAttribute as nt, TextureLoader as it, Matrix4 as Ge, THREE as ot, Color as Be } from "./three-core.js";
2
- import { DRACOLoader as at, KTX2Loader as lt, MeshoptDecoder as ut, GLTFLoader as _e } from "./three-examples.js";
3
- const ct = "";
4
- globalThis.GLTF_PROGRESSIVE_VERSION = ct;
1
+ import { RedFormat as Xe, RedIntegerFormat as je, RGFormat as He, RGIntegerFormat as Ke, RGBFormat as Ye, RGBAFormat as Qe, RGBAIntegerFormat as Je, BufferGeometry as K, Mesh as Y, Box3 as de, Vector3 as A, Sphere as $e, CompressedTexture as Ze, Texture as q, Matrix3 as et, InterleavedBuffer as tt, InterleavedBufferAttribute as st, BufferAttribute as rt, TextureLoader as nt, Matrix4 as Ge, THREE as it, Color as Be } from "./three-core.js";
2
+ import { DRACOLoader as ot, KTX2Loader as at, MeshoptDecoder as lt, GLTFLoader as _e } from "./three-examples.js";
3
+ const ut = "";
4
+ globalThis.GLTF_PROGRESSIVE_VERSION = ut;
5
5
  console.debug("[gltf-progressive] version -");
6
6
  let G = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", Q = "https://cdn.needle.tools/static/three/0.179.1/basis2/";
7
- const ft = G, dt = Q, qe = new URL(G + "draco_decoder.js");
8
- qe.searchParams.append("range", "true");
9
- fetch(qe, {
10
- method: "GET",
11
- headers: {
12
- Range: "bytes=0-1"
13
- }
14
- }).catch((i) => {
15
- console.debug(`Failed to fetch remote Draco decoder from ${G} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), G === ft && gt("./include/draco/"), Q === dt && pt("./include/ktx2/");
16
- }).finally(() => {
17
- Fe();
18
- });
19
- const ht = () => ({
7
+ const ct = G, ft = Q;
8
+ if (typeof window < "u") {
9
+ const i = new URL(G + "draco_decoder.js");
10
+ i.searchParams.append("range", "true"), fetch(i, {
11
+ method: "GET",
12
+ headers: {
13
+ Range: "bytes=0-1"
14
+ }
15
+ }).catch((t) => {
16
+ console.debug(`Failed to fetch remote Draco decoder from ${G} (offline: ${navigator.onLine})`), G === ct && ht("./include/draco/"), Q === ft && gt("./include/ktx2/");
17
+ }).finally(() => {
18
+ We();
19
+ });
20
+ }
21
+ const dt = () => ({
20
22
  dracoDecoderPath: G,
21
23
  ktx2TranscoderPath: Q
22
24
  });
23
- function gt(i) {
25
+ function ht(i) {
24
26
  G = i, k && k[Le] != G ? (console.debug("Updating Draco decoder path to " + i), k[Le] = G, k.setDecoderPath(G), k.preload()) : console.debug("Setting Draco decoder path to " + i);
25
27
  }
26
- function pt(i) {
28
+ function gt(i) {
27
29
  Q = i, B && B.transcoderPath != Q ? (console.debug("Updating KTX2 transcoder path to " + i), B.setTranscoderPath(Q), B.init()) : console.debug("Setting KTX2 transcoder path to " + i);
28
30
  }
29
31
  function be(i) {
30
- return Fe(), i ? B.detectSupport(i) : i !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: k, ktx2Loader: B, meshoptDecoder: ce };
32
+ return We(), i ? B.detectSupport(i) : i !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: k, ktx2Loader: B, meshoptDecoder: ce };
31
33
  }
32
- function We(i) {
34
+ function qe(i) {
33
35
  i.dracoLoader || i.setDRACOLoader(k), i.ktx2Loader || i.setKTX2Loader(B), i.meshoptDecoder || i.setMeshoptDecoder(ce);
34
36
  }
35
37
  const Le = /* @__PURE__ */ Symbol("dracoDecoderPath");
36
38
  let k, ce, B;
37
- function Fe() {
38
- k || (k = new at(), k[Le] = G, k.setDecoderPath(G), k.preload()), B || (B = new lt(), B.setTranscoderPath(Q), B.init()), ce || (ce = ut);
39
+ function We() {
40
+ k || (k = new ot(), k[Le] = G, k.setDecoderPath(G), k.preload()), B || (B = new at(), B.setTranscoderPath(Q), B.init()), ce || (ce = lt);
39
41
  }
40
42
  const we = /* @__PURE__ */ new WeakMap();
41
- function Ue(i, t) {
43
+ function Fe(i, t) {
42
44
  let e = we.get(i);
43
45
  e ? e = Object.assign(e, t) : e = t, we.set(i, e);
44
46
  }
45
- const mt = _e.prototype.load;
46
- function yt(...i) {
47
+ const pt = _e.prototype.load;
48
+ function mt(...i) {
47
49
  const t = we.get(this);
48
50
  let e = i[0];
49
- const s = xt(e);
51
+ const s = yt(e);
50
52
  if (s?.hostname.endsWith("needle.tools")) {
51
53
  const n = t?.progressive !== void 0 ? t.progressive : !0, o = t?.usecase ? t.usecase : "default";
52
54
  n ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${o}` : this.requestHeader.Accept = `*/*;usecase=${o}`, e = s.toString();
53
55
  }
54
- return i[0] = e, mt?.call(this, ...i);
56
+ return i[0] = e, pt?.call(this, ...i);
55
57
  }
56
- _e.prototype.load = yt;
57
- function xt(i) {
58
+ _e.prototype.load = mt;
59
+ function yt(i) {
58
60
  try {
59
61
  if (i instanceof URL)
60
62
  return i;
@@ -71,12 +73,12 @@ function ve(i) {
71
73
  const t = i.source?.data;
72
74
  return t != null && typeof t == "object" ? t : null;
73
75
  }
74
- function Lt(i) {
76
+ function xt(i) {
75
77
  const t = i.image;
76
78
  return t != null && typeof t == "object" ? t : null;
77
79
  }
78
80
  function De(i) {
79
- const t = Lt(i), e = ve(i);
81
+ const t = xt(i), e = ve(i);
80
82
  return {
81
83
  width: t?.width || e?.width || 0,
82
84
  height: t?.height || e?.height || 0
@@ -89,7 +91,7 @@ function V(i) {
89
91
  const s = new URL(t).searchParams.get(i);
90
92
  return s == null || s === "0" || s === "false" ? !1 : s === "" ? !0 : s;
91
93
  }
92
- function wt(i, t) {
94
+ function Lt(i, t) {
93
95
  if (t === void 0 || i === void 0 || t.startsWith("./") || t.startsWith("http") || t.startsWith("data:") || t.startsWith("blob:"))
94
96
  return t;
95
97
  const e = i.lastIndexOf("/");
@@ -106,13 +108,13 @@ function Oe() {
106
108
  return se = /iPhone|iPad|iPod|Android|IEMobile/i.test(i), V("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", se), se;
107
109
  }
108
110
  let se;
109
- function ze() {
111
+ function Ue() {
110
112
  const i = globalThis.location?.href;
111
113
  if (!i) return !1;
112
114
  const t = new URL(i), e = t.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t.hostname);
113
115
  return t.hostname === "127.0.0.1" || e;
114
116
  }
115
- class vt {
117
+ class wt {
116
118
  constructor(t, e = {}) {
117
119
  this.maxConcurrent = t, this.debug = e.debug ?? !1, typeof globalThis.requestAnimationFrame == "function" ? globalThis.requestAnimationFrame(this.tick) : setTimeout(this.tick, 0);
118
120
  }
@@ -147,29 +149,29 @@ class vt {
147
149
  }
148
150
  }
149
151
  }
150
- function Dt(i) {
151
- const t = i.image, e = t?.width ?? 0, s = t?.height ?? 0, r = t?.depth ?? 1, n = Math.floor(Math.log2(Math.max(e, s, r))) + 1, o = Mt(i);
152
+ function vt(i) {
153
+ const t = i.image, e = t?.width ?? 0, s = t?.height ?? 0, r = t?.depth ?? 1, n = Math.floor(Math.log2(Math.max(e, s, r))) + 1, o = Dt(i);
152
154
  return e * s * r * o * (1 - Math.pow(0.25, n)) / (1 - 0.25);
153
155
  }
154
- function Mt(i) {
156
+ function Dt(i) {
155
157
  let t = 4;
156
158
  const e = i.format;
157
- e === je || e === He ? t = 1 : e === Ke || e === Ye ? t = 2 : e === Qe || e === 1029 ? t = 3 : (e === Je || e === Ze) && (t = 4);
159
+ e === Xe || e === je ? t = 1 : e === He || e === Ke ? t = 2 : e === Ye || e === 1029 ? t = 3 : (e === Qe || e === Je) && (t = 4);
158
160
  let s = 1;
159
161
  const r = i.type;
160
162
  return r === 1009 || r === 1010 ? s = 1 : r === 1011 || r === 1012 ? s = 2 : r === 1013 || r === 1014 || r === 1015 ? s = 4 : r === 1016 && (s = 2), t * s;
161
163
  }
162
- const _t = typeof window > "u" && typeof document > "u", Me = /* @__PURE__ */ Symbol("needle:raycast-mesh");
164
+ const Mt = typeof window > "u" && typeof document > "u", Me = /* @__PURE__ */ Symbol("needle:raycast-mesh");
163
165
  function ae(i) {
164
166
  return i?.[Me] instanceof K ? i[Me] : null;
165
167
  }
166
- function bt(i, t) {
168
+ function _t(i, t) {
167
169
  if ((i.type === "Mesh" || i.type === "SkinnedMesh") && !ae(i)) {
168
- const s = Tt(t);
170
+ const s = Ot(t);
169
171
  s.userData = { isRaycastMesh: !0 }, i[Me] = s;
170
172
  }
171
173
  }
172
- function Ot(i = !0) {
174
+ function bt(i = !0) {
173
175
  if (i) {
174
176
  if (re) return;
175
177
  const t = re = Y.prototype.raycast;
@@ -184,7 +186,7 @@ function Ot(i = !0) {
184
186
  }
185
187
  }
186
188
  let re = null;
187
- function Tt(i) {
189
+ function Ot(i) {
188
190
  const t = new K();
189
191
  for (const e in i.attributes)
190
192
  t.setAttribute(e, i.getAttribute(e));
@@ -203,24 +205,24 @@ if (g && typeof window < "u") {
203
205
  !isNaN(s) && s >= 0 && (j = s, console.log(`Set LOD level to [${j}]`));
204
206
  });
205
207
  }
206
- function Ee(i) {
208
+ function ze(i) {
207
209
  if (g && oe !== void 0)
208
210
  if (Array.isArray(i))
209
211
  for (const t of i)
210
- Ee(t);
212
+ ze(t);
211
213
  else i && "wireframe" in i && (i.wireframe = oe === !0);
212
214
  }
213
215
  const ne = new Array();
214
- let St = 0;
215
- const Rt = Oe() ? 2 : 10;
216
- function Pt(i) {
217
- if (ne.length < Rt) {
216
+ let Tt = 0;
217
+ const St = Oe() ? 2 : 10;
218
+ function Rt(i) {
219
+ if (ne.length < St) {
218
220
  const s = ne.length;
219
221
  g && console.warn(`[Worker] Creating new worker #${s}`);
220
222
  const r = Te.createWorker(i || {});
221
223
  return ne.push(r), r;
222
224
  }
223
- const t = St++ % ne.length;
225
+ const t = Tt++ % ne.length;
224
226
  return ne[t];
225
227
  }
226
228
  class Te {
@@ -231,7 +233,7 @@ class Te {
231
233
  case "loaded-gltf":
232
234
  for (const n of this._running)
233
235
  if (n.url === r.result.url) {
234
- Ct(r.result), n.resolve(r.result);
236
+ Pt(r.result), n.resolve(r.result);
235
237
  const o = n.url;
236
238
  o.startsWith("blob:") && URL.revokeObjectURL(o);
237
239
  }
@@ -252,7 +254,7 @@ class Te {
252
254
  _running = [];
253
255
  _webglRenderer = null;
254
256
  async load(t, e) {
255
- const s = ht();
257
+ const s = dt();
256
258
  let r = e?.renderer;
257
259
  r || (this._webglRenderer ??= (async () => {
258
260
  const { WebGLRenderer: u } = await import("./three-core.js").then((d) => d.THREE);
@@ -283,7 +285,7 @@ class Te {
283
285
  }
284
286
  _debug = !1;
285
287
  }
286
- function Ct(i) {
288
+ function Pt(i) {
287
289
  for (const t of i.geometries) {
288
290
  const e = t.geometry, s = new K();
289
291
  if (s.name = e.name || "", e.index) {
@@ -324,7 +326,7 @@ function Ct(i) {
324
326
  let s = null;
325
327
  if (e.isCompressedTexture) {
326
328
  const r = e.mipmaps, { width: n, height: o } = De(e);
327
- s = new et(
329
+ s = new Ze(
328
330
  r,
329
331
  n,
330
332
  o,
@@ -350,7 +352,7 @@ function Ct(i) {
350
352
  e.type,
351
353
  e.anisotropy,
352
354
  e.colorSpace
353
- ), s.mipmaps = e.mipmaps, s.channel = e.channel, s.source.data = e.source.data, s.flipY = e.flipY, s.premultiplyAlpha = e.premultiplyAlpha, s.unpackAlignment = e.unpackAlignment, s.matrix = new tt(...e.matrix.elements);
355
+ ), s.mipmaps = e.mipmaps, s.channel = e.channel, s.source.data = e.source.data, s.flipY = e.flipY, s.premultiplyAlpha = e.premultiplyAlpha, s.unpackAlignment = e.unpackAlignment, s.matrix = new et(...e.matrix.elements);
354
356
  if (!s) {
355
357
  console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");
356
358
  continue;
@@ -362,12 +364,12 @@ function Ct(i) {
362
364
  function he(i) {
363
365
  let t = i;
364
366
  if ("isInterleavedBufferAttribute" in i && i.isInterleavedBufferAttribute) {
365
- const e = i.data, s = e.array, r = new st(s, e.stride);
366
- t = new rt(r, i.itemSize, s.byteOffset, i.normalized), t.offset = i.offset;
367
- } else "isBufferAttribute" in i && i.isBufferAttribute && (t = new nt(i.array, i.itemSize, i.normalized), t.usage = i.usage, t.gpuType = i.gpuType, t.updateRanges = i.updateRanges);
367
+ const e = i.data, s = e.array, r = new tt(s, e.stride);
368
+ t = new st(r, i.itemSize, s.byteOffset, i.normalized), t.offset = i.offset;
369
+ } else "isBufferAttribute" in i && i.isBufferAttribute && (t = new rt(i.array, i.itemSize, i.normalized), t.usage = i.usage, t.gpuType = i.gpuType, t.updateRanges = i.updateRanges);
368
370
  return t;
369
371
  }
370
- const kt = V("gltf-progressive-worker");
372
+ const Ct = V("gltf-progressive-worker");
371
373
  V("gltf-progressive-reduce-mipmaps");
372
374
  const ie = V("gltf-progressive-gc"), ge = /* @__PURE__ */ Symbol("needle-progressive-texture"), U = "NEEDLE_progressive";
373
375
  class p {
@@ -803,7 +805,7 @@ class p {
803
805
  }
804
806
  l.userData || (l.userData = {}), g && console.log("> Progressive: register mesh " + s.name, { index: n, uuid: s.uuid }, o, s), p.assignLODInformation(t, l, e, r, n), p.lodInfos.set(e, o);
805
807
  let u = p.lowresCache.get(e)?.deref();
806
- u ? u.push(s.geometry) : u = [s.geometry], p.lowresCache.set(e, new WeakRef(u)), r > 0 && !ae(s) && bt(s, l);
808
+ u ? u.push(s.geometry) : u = [s.geometry], p.lowresCache.set(e, new WeakRef(u)), r > 0 && !ae(s) && _t(s, l);
807
809
  for (const d of F)
808
810
  d.onRegisteredNewMesh?.(s, o);
809
811
  };
@@ -906,7 +908,7 @@ ${t}`), e instanceof WeakRef && (e.deref() || (p.cache.delete(t), (g || ie) && c
906
908
  let { width: a, height: u } = De(t);
907
909
  const d = a && u ? `${a}x${u}` : "N/A";
908
910
  let c = "N/A";
909
- a && u && (c = `~${(Dt(t) / (1024 * 1024)).toFixed(2)} MB`), console.log(`${o} — ${t.name} ${d} (${c}), refCount: ${s} → ${l}
911
+ a && u && (c = `~${(vt(t) / (1024 * 1024)).toFixed(2)} MB`), console.log(`${o} — ${t.name} ${d} (${c}), refCount: ${s} → ${l}
910
912
  ${e}`);
911
913
  }
912
914
  }
@@ -943,7 +945,7 @@ ${e}`);
943
945
  const d = Array.isArray(a.lods) ? a.lods[e]?.path : a.lods;
944
946
  if (!d)
945
947
  return g && !a["missing:uri"] && (a["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, a)), null;
946
- const c = wt(o.url, d);
948
+ const c = Lt(o.url, d);
947
949
  if (c.endsWith(".glb") || c.endsWith(".gltf")) {
948
950
  if (!a.guid)
949
951
  return console.warn("missing pointer for glb/gltf texture", a), null;
@@ -968,8 +970,8 @@ ${e}`);
968
970
  if (!D.use)
969
971
  return g && console.log(`LOD ${e} was aborted: ${c}`), null;
970
972
  const w = a, M = new Promise(async (y, T) => {
971
- if (kt) {
972
- const m = await (await Pt({})).load(c);
973
+ if (Ct) {
974
+ const m = await (await Rt({})).load(c);
973
975
  if (m.textures.length > 0)
974
976
  for (const v of m.textures) {
975
977
  let S = v.texture;
@@ -986,7 +988,7 @@ ${e}`);
986
988
  return y(null);
987
989
  }
988
990
  const I = new _e();
989
- We(I), g && (await new Promise((b) => setTimeout(b, 1e3)), n && console.warn("Start loading (delayed) " + c, w.guid));
991
+ qe(I), g && (await new Promise((b) => setTimeout(b, 1e3)), n && console.warn("Start loading (delayed) " + c, w.guid));
990
992
  let P = c;
991
993
  if (w && Array.isArray(w.lods)) {
992
994
  const b = w.lods[e];
@@ -1055,7 +1057,7 @@ ${e}`);
1055
1057
  if (s?.isCurrent?.() === !1)
1056
1058
  return n && console.log(`Skipping stale texture LOD ${e} request: ${c}`), null;
1057
1059
  n && console.log("Load texture from uri: " + c);
1058
- const h = await new it().loadAsync(c);
1060
+ const h = await new nt().loadAsync(c);
1059
1061
  return r !== this.cacheGeneration || s?.isCurrent?.() === !1 ? (h?.dispose(), null) : (h ? (h.guid = a.guid, h.flipY = !1, h.needsUpdate = !0, h.colorSpace = t.colorSpace, n && console.log(a, h)) : g && console.warn("failed loading", c), h);
1060
1062
  }
1061
1063
  }
@@ -1081,12 +1083,12 @@ ${e}`);
1081
1083
  }
1082
1084
  static _queue;
1083
1085
  static get queue() {
1084
- return this._queue ??= new vt(Oe() ? 20 : 50, { debug: g != !1 });
1086
+ return this._queue ??= new wt(Oe() ? 20 : 50, { debug: g != !1 });
1085
1087
  }
1086
1088
  static assignLODInformation(t, e, s, r, n) {
1087
1089
  if (!e) return;
1088
1090
  e.userData || (e.userData = {});
1089
- const o = new At(t, s, r, n);
1091
+ const o = new kt(t, s, r, n);
1090
1092
  e.userData.LODS = o, "source" in e && typeof e.source == "object" && (e.source.LODS = o);
1091
1093
  }
1092
1094
  static getAssignedLODInformation(t) {
@@ -1099,7 +1101,7 @@ ${e}`);
1099
1101
  `, 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;
1100
1102
  }
1101
1103
  }
1102
- class At {
1104
+ class kt {
1103
1105
  url;
1104
1106
  /** the key to lookup the LOD information */
1105
1107
  key;
@@ -1186,7 +1188,7 @@ class le {
1186
1188
  });
1187
1189
  }
1188
1190
  }
1189
- const $ = V("debugprogressive"), It = $ === "colors", $t = V("noprogressive"), pe = /* @__PURE__ */ Symbol("Needle:LODSManager"), me = /* @__PURE__ */ Symbol("Needle:LODState"), E = /* @__PURE__ */ Symbol("Needle:CurrentLOD"), Re = ot, R = { mesh_lod: -1, texture_lod: -1 }, Gt = new Be(), Pe = [
1191
+ const $ = V("debugprogressive"), At = $ === "colors", It = V("noprogressive"), pe = /* @__PURE__ */ Symbol("Needle:LODSManager"), me = /* @__PURE__ */ Symbol("Needle:LODState"), E = /* @__PURE__ */ Symbol("Needle:CurrentLOD"), Re = it, R = { mesh_lod: -1, texture_lod: -1 }, $t = new Be(), Pe = [
1190
1192
  3526751,
1191
1193
  11065402,
1192
1194
  15978811,
@@ -1220,16 +1222,16 @@ const $ = V("debugprogressive"), It = $ === "colors", $t = V("noprogressive"), p
1220
1222
  5083278,
1221
1223
  5592405
1222
1224
  ];
1223
- function Bt() {
1225
+ function Gt() {
1224
1226
  const i = Re.Timer || Re.Clock;
1225
1227
  return new i();
1226
1228
  }
1227
- const ye = new de(), N = new de(), Ce = new de(), qt = new A(), Wt = new A(), Ft = new Ge(), W = new A(), Z = new A(), ee = new A(), te = new A();
1228
- function Ut(i, t) {
1229
+ const ye = new de(), N = new de(), Ce = new de(), Bt = new A(), qt = new A(), Wt = new Ge(), W = new A(), Z = new A(), ee = new A(), te = new A();
1230
+ function Ft(i, t) {
1229
1231
  const e = i.min, s = i.max, r = (e.x + s.x) * 0.5, n = (e.y + s.y) * 0.5;
1230
1232
  return W.set(r, n, e.z).applyMatrix4(t).z < 0;
1231
1233
  }
1232
- function zt(i) {
1234
+ function Ut(i) {
1233
1235
  const {
1234
1236
  geometry: t,
1235
1237
  matrixWorld: e,
@@ -1251,7 +1253,7 @@ function zt(i) {
1251
1253
  h.level = l, h.primitiveIndex = f, h.screenCoverage = 0, h.screenspaceVolume.set(0, 0, 0), h.centrality = 1;
1252
1254
  let D = i.boundingBox ?? t.boundingBox;
1253
1255
  if (D || (t.computeBoundingBox(), D = t.boundingBox), !D) return h;
1254
- if (ye.copy(D).applyMatrix4(e), s.isPerspectiveCamera && Ut(ye, r))
1256
+ if (ye.copy(D).applyMatrix4(e), s.isPerspectiveCamera && Ft(ye, r))
1255
1257
  return h.level = 0, h.screenCoverage = 1 / 0, h.screenspaceVolume.set(1 / 0, 1 / 0, 1 / 0), h;
1256
1258
  if (N.copy(ye).applyMatrix4(r), a && s.isPerspectiveCamera && s.fov > 70) {
1257
1259
  const y = N.min, T = N.max;
@@ -1261,14 +1263,14 @@ function zt(i) {
1261
1263
  const S = I < 0 && _ > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(T.x)), X = P < 0 && z > 0 ? 0 : Math.min(Math.abs(y.y), Math.abs(T.y)), J = Math.max(S, X);
1262
1264
  h.centrality = (b - J) * (b - J) * (b - J);
1263
1265
  }
1264
- const L = N.getSize(qt);
1266
+ const L = N.getSize(Bt);
1265
1267
  L.multiplyScalar(0.5), globalThis.screen?.availHeight > 0 && o > 0 && L.multiplyScalar(o / globalThis.screen.availHeight), s.isPerspectiveCamera && (L.x *= s.aspect), Ce.copy(D).applyMatrix4(e).applyMatrix4(s.matrixWorldInverse);
1266
- const x = Ce.getSize(Wt), w = Math.max(L.x, L.y), M = Math.max(x.x, x.y);
1268
+ const x = Ce.getSize(qt), w = Math.max(L.x, L.y), M = Math.max(x.x, x.y);
1267
1269
  w !== 0 && M !== 0 && (L.z = x.z / M * w);
1268
1270
  const O = Math.max(L.x, L.y, L.z) * h.centrality;
1269
1271
  if (h.screenCoverage = O, h.screenspaceVolume.copy(L), O <= 0) return h;
1270
1272
  if (u) {
1271
- const y = Ft.copy(r);
1273
+ const y = Wt.copy(r);
1272
1274
  y.invert(), W.copy(N.min), Z.copy(N.max), Z.x = W.x, ee.copy(N.max), ee.y = W.y, te.copy(N.max);
1273
1275
  const T = (W.z + te.z) * 0.5;
1274
1276
  W.z = Z.z = ee.z = te.z = T, W.applyMatrix4(y), Z.applyMatrix4(y), ee.applyMatrix4(y), te.applyMatrix4(y), u(W, Z, 255), u(W, ee, 255), u(Z, te, 255), u(ee, te, 255);
@@ -1276,7 +1278,7 @@ function zt(i) {
1276
1278
  if (c?.length)
1277
1279
  for (let y = 0; y < c.length; y++) {
1278
1280
  const T = c[y], I = T.densities?.[f] || T.density || 1e-5;
1279
- if (f > 0 && d && ze() && !T.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (globalThis["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.")), I / O < n) {
1281
+ if (f > 0 && d && Ue() && !T.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (globalThis["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.")), I / O < n) {
1280
1282
  h.level = y;
1281
1283
  break;
1282
1284
  }
@@ -1392,7 +1394,7 @@ let fe = class H {
1392
1394
  const r = performance.now();
1393
1395
  return s.ready.finally(() => {
1394
1396
  const n = this._newPromiseGroups.indexOf(s);
1395
- n >= 0 && (this._newPromiseGroups.splice(n, 1), ze() && performance.measure("LODsManager:awaitLoading", {
1397
+ n >= 0 && (this._newPromiseGroups.splice(n, 1), Ue() && performance.measure("LODsManager:awaitLoading", {
1396
1398
  start: r,
1397
1399
  detail: { id: e, name: t?.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
1398
1400
  }));
@@ -1452,7 +1454,7 @@ let fe = class H {
1452
1454
  #n = 0;
1453
1455
  #o = 0;
1454
1456
  #s = 0;
1455
- #i = Bt();
1457
+ #i = Gt();
1456
1458
  _fpsBuffer = [60, 60, 60, 60, 60];
1457
1459
  /**
1458
1460
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
@@ -1502,7 +1504,7 @@ let fe = class H {
1502
1504
  (l.name === "EffectMaterial" || l.name === "CopyShader") && (o = !1);
1503
1505
  }
1504
1506
  if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (o = !1), o) {
1505
- if ($t || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1, $ && console.warn("↓ Reducing LOD updates", this.#e, this.#s.toFixed(0))) : this.#s >= 60 && this.#e > 1 && (this.#e -= 1, $ && console.warn("↑ Increasing LOD updates", this.#e, this.#s.toFixed(0))) : this.#e = this.updateInterval, this.#e > 0 && this.#r % this.#e != 0))
1507
+ if (It || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1, $ && console.warn("↓ Reducing LOD updates", this.#e, this.#s.toFixed(0))) : this.#s >= 60 && this.#e > 1 && (this.#e -= 1, $ && console.warn("↑ Increasing LOD updates", this.#e, this.#s.toFixed(0))) : this.#e = this.updateInterval, this.#e > 0 && this.#r % this.#e != 0))
1506
1508
  return;
1507
1509
  this.internalUpdate(t, e), this._postprocessPromiseGroups();
1508
1510
  }
@@ -1567,12 +1569,12 @@ let fe = class H {
1567
1569
  updateLODs(t, e, s, r) {
1568
1570
  s.userData || (s.userData = {});
1569
1571
  let n = s[me];
1570
- if (n || (n = new Et(), s[me] = n), n.frames++ < 2)
1572
+ if (n || (n = new zt(), s[me] = n), n.frames++ < 2)
1571
1573
  return;
1572
1574
  for (const l of F)
1573
1575
  l.onBeforeUpdateLOD?.(this.renderer, t, e, s);
1574
1576
  const o = this.overrideLodLevel !== void 0 ? this.overrideLodLevel : j;
1575
- o >= 0 ? (R.mesh_lod = o, R.texture_lod = o) : (this.calculateLodLevel(e, s, n, r, R), R.mesh_lod = Math.round(R.mesh_lod), R.texture_lod = Math.round(R.texture_lod)), R.mesh_lod >= 0 && this.loadProgressiveMeshes(s, R.mesh_lod), s.material && R.texture_lod >= 0 && this.loadProgressiveTextures(s.material, R.texture_lod, o), g && s.material && !s.isGizmo && Ee(s.material), It && s.material && !s.isGizmo && !s.isBatchedMesh && Ne(s.material, R.mesh_lod);
1577
+ o >= 0 ? (R.mesh_lod = o, R.texture_lod = o) : (this.calculateLodLevel(e, s, n, r, R), R.mesh_lod = Math.round(R.mesh_lod), R.texture_lod = Math.round(R.texture_lod)), R.mesh_lod >= 0 && this.loadProgressiveMeshes(s, R.mesh_lod), s.material && R.texture_lod >= 0 && this.loadProgressiveTextures(s.material, R.texture_lod, o), g && s.material && !s.isGizmo && ze(s.material), At && s.material && !s.isGizmo && !s.isBatchedMesh && Ee(s.material, R.mesh_lod);
1576
1578
  for (const l of F)
1577
1579
  l.onAfterUpdatedLOD?.(this.renderer, t, e, s, R);
1578
1580
  n.lastLodLevel_Mesh = R.mesh_lod, n.lastLodLevel_Texture = R.texture_lod;
@@ -1669,7 +1671,7 @@ let fe = class H {
1669
1671
  return;
1670
1672
  }
1671
1673
  }
1672
- const x = zt({
1674
+ const x = Ut({
1673
1675
  geometry: e.geometry,
1674
1676
  matrixWorld: e.matrixWorld,
1675
1677
  camera: t,
@@ -1722,7 +1724,7 @@ ${e.name}`);
1722
1724
  n.texture_lod = 0;
1723
1725
  }
1724
1726
  };
1725
- class Et {
1727
+ class zt {
1726
1728
  frames = 0;
1727
1729
  lastLodLevel_Mesh = -1;
1728
1730
  lastLodLevel_Texture = -1;
@@ -1730,53 +1732,53 @@ class Et {
1730
1732
  lastScreenspaceVolume = new A();
1731
1733
  lastCentrality = 0;
1732
1734
  }
1733
- function Ne(i, t) {
1735
+ function Ee(i, t) {
1734
1736
  if (!(t < 0)) {
1735
1737
  if (Array.isArray(i)) {
1736
1738
  for (const e of i)
1737
- Ne(e, t);
1739
+ Ee(e, t);
1738
1740
  return;
1739
1741
  }
1740
- "color" in i && i.color instanceof Be && (i.color.copy(Nt(t, Gt)), i.needsUpdate = !0);
1742
+ "color" in i && i.color instanceof Be && (i.color.copy(Et(t, $t)), i.needsUpdate = !0);
1741
1743
  }
1742
1744
  }
1743
- function Nt(i, t) {
1745
+ function Et(i, t) {
1744
1746
  const e = Math.max(0, Math.min(Pe.length - 1, Math.floor(i)));
1745
1747
  return t.setHex(Pe[e]);
1746
1748
  }
1747
1749
  const ke = /* @__PURE__ */ Symbol("NEEDLE_mesh_lod"), ue = /* @__PURE__ */ Symbol("NEEDLE_texture_lod");
1748
1750
  let xe = null;
1749
- function Ve() {
1750
- const i = Vt();
1751
+ function Ne() {
1752
+ const i = Nt();
1751
1753
  i && (i.mapURLs(function(t) {
1752
1754
  return Ae(), t;
1753
1755
  }), Ae(), xe?.disconnect(), xe = new MutationObserver((t) => {
1754
1756
  t.forEach((e) => {
1755
1757
  e.addedNodes.forEach((s) => {
1756
- s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Xe(s);
1758
+ s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Ve(s);
1757
1759
  });
1758
1760
  });
1759
1761
  }), xe.observe(document, { childList: !0, subtree: !0 }));
1760
1762
  }
1761
- function Vt() {
1763
+ function Nt() {
1762
1764
  if (typeof customElements > "u") return null;
1763
1765
  const i = customElements.get("model-viewer");
1764
1766
  return i || (customElements.whenDefined("model-viewer").then(() => {
1765
- console.debug("[gltf-progressive] model-viewer defined"), Ve();
1767
+ console.debug("[gltf-progressive] model-viewer defined"), Ne();
1766
1768
  }), null);
1767
1769
  }
1768
1770
  function Ae() {
1769
1771
  if (typeof document > "u") return;
1770
1772
  document.querySelectorAll("model-viewer").forEach((t) => {
1771
- Xe(t);
1773
+ Ve(t);
1772
1774
  });
1773
1775
  }
1774
1776
  const Ie = /* @__PURE__ */ new WeakSet();
1775
- let Xt = 0;
1776
- function Xe(i) {
1777
+ let Vt = 0;
1778
+ function Ve(i) {
1777
1779
  if (!i || Ie.has(i))
1778
1780
  return null;
1779
- Ie.add(i), console.debug("[gltf-progressive] found new model-viewer..." + ++Xt + `
1781
+ Ie.add(i), console.debug("[gltf-progressive] found new model-viewer..." + ++Vt + `
1780
1782
  `, i.getAttribute("src"));
1781
1783
  let t = null, e = null, s = null;
1782
1784
  for (let r = i; r != null; r = Object.getPrototypeOf(r)) {
@@ -1798,7 +1800,7 @@ function Xe(i) {
1798
1800
  };
1799
1801
  console.debug("[gltf-progressive] setup model-viewer");
1800
1802
  const n = fe.get(t, { engine: "model-viewer" });
1801
- return fe.addPlugin(new jt()), n.enable(), n.addEventListener("changed", () => {
1803
+ return fe.addPlugin(new Xt()), n.enable(), n.addEventListener("changed", () => {
1802
1804
  s?.call(i);
1803
1805
  }), i.addEventListener("model-visibility", (o) => {
1804
1806
  o.detail.visible && s?.call(i);
@@ -1810,7 +1812,7 @@ function Xe(i) {
1810
1812
  }
1811
1813
  return null;
1812
1814
  }
1813
- class jt {
1815
+ class Xt {
1814
1816
  _didWarnAboutMissingUrl = !1;
1815
1817
  onBeforeUpdateLOD(t, e, s, r) {
1816
1818
  this.tryParseMeshLOD(e, r), this.tryParseTextureLOD(e, r);
@@ -1871,7 +1873,7 @@ class jt {
1871
1873
  }
1872
1874
  }
1873
1875
  }
1874
- function Ht(...i) {
1876
+ function jt(...i) {
1875
1877
  let t, e, s, r;
1876
1878
  switch (i.length) {
1877
1879
  case 2:
@@ -1886,22 +1888,22 @@ function Ht(...i) {
1886
1888
  default:
1887
1889
  throw new Error("Invalid arguments");
1888
1890
  }
1889
- be(e), We(s), Ue(s, {
1891
+ be(e), qe(s), Fe(s, {
1890
1892
  progressive: !0,
1891
1893
  ...r?.hints
1892
1894
  }), s.register((o) => new p(o));
1893
1895
  const n = fe.get(e);
1894
1896
  return r?.enableLODsManager !== !1 && n.enable(), n;
1895
1897
  }
1896
- Ve();
1897
- if (!_t) {
1898
+ Ne();
1899
+ if (!Mt) {
1898
1900
  const i = {
1899
1901
  gltfProgressive: {
1900
- useNeedleProgressive: Ht,
1902
+ useNeedleProgressive: jt,
1901
1903
  LODsManager: fe,
1902
- configureLoader: Ue,
1904
+ configureLoader: Fe,
1903
1905
  getRaycastMesh: ae,
1904
- useRaycastMeshes: Ot
1906
+ useRaycastMeshes: bt
1905
1907
  }
1906
1908
  };
1907
1909
  if (!globalThis.Needle)
@@ -1913,12 +1915,12 @@ if (!_t) {
1913
1915
  export {
1914
1916
  fe as LODsManager,
1915
1917
  p as NEEDLE_progressive,
1916
- We as addDracoAndKTX2Loaders,
1917
- zt as calculateMeshLODLevel,
1918
- Ue as configureLoader,
1918
+ qe as addDracoAndKTX2Loaders,
1919
+ Ut as calculateMeshLODLevel,
1920
+ Fe as configureLoader,
1919
1921
  be as createLoaders,
1920
- Nt as getLODColor,
1922
+ Et as getLODColor,
1921
1923
  ae as getRaycastMesh,
1922
- gt as setDracoDecoderLocation,
1923
- pt as setKTX2TranscoderLocation
1924
+ ht as setDracoDecoderLocation,
1925
+ gt as setKTX2TranscoderLocation
1924
1926
  };