@needle-tools/engine 4.2.0 → 4.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/gltf-progressive.js +258 -257
  3. package/dist/gltf-progressive.light.js +258 -257
  4. package/dist/gltf-progressive.light.min.js +7 -7
  5. package/dist/gltf-progressive.light.umd.cjs +7 -7
  6. package/dist/gltf-progressive.min.js +7 -7
  7. package/dist/gltf-progressive.umd.cjs +7 -7
  8. package/dist/needle-engine.bundle.js +6660 -6588
  9. package/dist/needle-engine.bundle.light.js +6651 -6579
  10. package/dist/needle-engine.bundle.light.min.js +124 -120
  11. package/dist/needle-engine.bundle.light.umd.cjs +122 -118
  12. package/dist/needle-engine.bundle.min.js +124 -120
  13. package/dist/needle-engine.bundle.umd.cjs +122 -118
  14. package/dist/needle-engine.light.d.ts +9 -9
  15. package/lib/engine/engine_context.d.ts +1 -0
  16. package/lib/engine/engine_context.js +7 -3
  17. package/lib/engine/engine_context.js.map +1 -1
  18. package/lib/engine/engine_input.d.ts +14 -2
  19. package/lib/engine/engine_input.js +41 -6
  20. package/lib/engine/engine_input.js.map +1 -1
  21. package/lib/engine/engine_loaders.js +6 -12
  22. package/lib/engine/engine_loaders.js.map +1 -1
  23. package/lib/engine/engine_physics_rapier.js +1 -1
  24. package/lib/engine/engine_physics_rapier.js.map +1 -1
  25. package/lib/engine/engine_serialization_core.js +16 -3
  26. package/lib/engine/engine_serialization_core.js.map +1 -1
  27. package/lib/engine/engine_types.d.ts +5 -0
  28. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  29. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  30. package/lib/engine-components/Duplicatable.js +2 -2
  31. package/lib/engine-components/Duplicatable.js.map +1 -1
  32. package/lib/engine-components/EventTrigger.d.ts +2 -0
  33. package/lib/engine-components/EventTrigger.js +12 -0
  34. package/lib/engine-components/EventTrigger.js.map +1 -1
  35. package/lib/engine-components/OrbitControls.d.ts +9 -2
  36. package/lib/engine-components/OrbitControls.js +62 -19
  37. package/lib/engine-components/OrbitControls.js.map +1 -1
  38. package/lib/engine-components/Renderer.js +5 -0
  39. package/lib/engine-components/Renderer.js.map +1 -1
  40. package/lib/engine-components/ScreenCapture.js +2 -2
  41. package/lib/engine-components/ScreenCapture.js.map +1 -1
  42. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +0 -1
  43. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
  44. package/lib/engine-components/export/usdz/USDZExporter.js +2 -2
  45. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  46. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +19 -11
  47. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js.map +1 -1
  48. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +7 -2
  49. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +33 -11
  50. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
  51. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.d.ts +1 -0
  52. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js +5 -2
  53. package/lib/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.js.map +1 -1
  54. package/lib/engine-components/ui/Button.js +3 -3
  55. package/lib/engine-components/ui/Button.js.map +1 -1
  56. package/lib/engine-components/ui/EventSystem.d.ts +6 -10
  57. package/lib/engine-components/ui/EventSystem.js +35 -52
  58. package/lib/engine-components/ui/EventSystem.js.map +1 -1
  59. package/lib/engine-components/ui/InputField.d.ts +4 -1
  60. package/lib/engine-components/ui/InputField.js +19 -0
  61. package/lib/engine-components/ui/InputField.js.map +1 -1
  62. package/lib/engine-components/utils/OpenURL.js +2 -2
  63. package/lib/engine-components/utils/OpenURL.js.map +1 -1
  64. package/lib/engine-components/webxr/WebXRImageTracking.js +5 -1
  65. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  66. package/package.json +2 -2
  67. package/plugins/types/userconfig.d.ts +2 -2
  68. package/plugins/vite/pwa.js +33 -22
  69. package/src/engine/codegen/register_types.ts +2 -2
  70. package/src/engine/engine_context.ts +7 -3
  71. package/src/engine/engine_input.ts +47 -9
  72. package/src/engine/engine_loaders.ts +6 -10
  73. package/src/engine/engine_physics_rapier.ts +1 -1
  74. package/src/engine/engine_serialization_core.ts +13 -4
  75. package/src/engine/engine_types.ts +5 -0
  76. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
  77. package/src/engine-components/Duplicatable.ts +2 -2
  78. package/src/engine-components/EventTrigger.ts +14 -0
  79. package/src/engine-components/OrbitControls.ts +71 -21
  80. package/src/engine-components/Renderer.ts +5 -0
  81. package/src/engine-components/ScreenCapture.ts +2 -2
  82. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +0 -1
  83. package/src/engine-components/export/usdz/USDZExporter.ts +2 -2
  84. package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +17 -11
  85. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +41 -23
  86. package/src/engine-components/export/usdz/extensions/behavior/BehavioursBuilder.ts +5 -2
  87. package/src/engine-components/ui/Button.ts +3 -3
  88. package/src/engine-components/ui/EventSystem.ts +45 -62
  89. package/src/engine-components/ui/InputField.ts +18 -1
  90. package/src/engine-components/utils/OpenURL.ts +2 -2
  91. package/src/engine-components/webxr/WebXRImageTracking.ts +5 -1
@@ -1,43 +1,44 @@
1
- import { B as he, M as J, T as j, a as We, V as F, b as Se, S as ze, c as be, d as Ve, C as qe } from "./three.js";
2
- import { D as Ke, K as Xe, G as Oe, M as Ye } from "./three-examples.js";
3
- const Pe = "";
4
- globalThis.GLTF_PROGRESSIVE_VERSION = Pe;
5
- console.debug(`[gltf-progressive] version ${Pe}`);
6
- let Z = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", ne = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
7
- const He = Z, Je = ne, Qe = new URL(Z + "draco_decoder.js");
8
- fetch(Qe, {
1
+ import { B as he, M as Q, T as ee, a as We, V as z, b as be, S as ze, c as Te, d as Ve, C as Ke } from "./three.js";
2
+ import { D as Xe, K as qe, G as Se, M as Ye } from "./three-examples.js";
3
+ const He = "";
4
+ globalThis.GLTF_PROGRESSIVE_VERSION = He;
5
+ console.debug("[gltf-progressive] version -");
6
+ let N = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", j = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
7
+ const Je = N, Qe = j, Ze = new URL(N + "draco_decoder.js");
8
+ fetch(Ze, {
9
9
  method: "GET",
10
10
  headers: {
11
11
  Range: "bytes=0-1"
12
12
  }
13
13
  }).catch((t) => {
14
- Z === He && (Z = "./include/draco/"), ne === Je && (ne = "./include/ktx2/");
14
+ console.debug(`Failed to fetch remote Draco decoder from ${N} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), N === Je && je("./include/draco/"), j === Qe && et("./include/ktx2/");
15
15
  }).finally(() => {
16
16
  ke();
17
17
  });
18
- function gt(t) {
19
- Z = t;
18
+ function je(t) {
19
+ N = t, A && A[De] != N ? (console.debug("Updating Draco decoder path to " + t), A[De] = N, A.setDecoderPath(N), A.preload()) : console.debug("Setting Draco decoder path to " + t);
20
20
  }
21
- function pt(t) {
22
- ne = t;
21
+ function et(t) {
22
+ j = t, G && G.transcoderPath != j ? (console.debug("Updating KTX2 transcoder path to " + t), G.setTranscoderPath(j), G.init()) : console.debug("Setting KTX2 transcoder path to " + t);
23
23
  }
24
- let Y, ge, H;
24
+ const De = Symbol("dracoDecoderPath");
25
+ let A, ge, G;
25
26
  function ke() {
26
- Y || (Y = new Ke(), Y.setDecoderPath(Z), Y.setDecoderConfig({ type: "js" }), Y.preload()), H || (H = new Xe(), H.setTranscoderPath(ne), H.init()), ge || (ge = Ye);
27
+ A || (A = new Xe(), A[De] = N, A.setDecoderPath(N), A.setDecoderConfig({ type: "js" }), A.preload()), G || (G = new qe(), G.setTranscoderPath(j), G.init()), ge || (ge = Ye);
27
28
  }
28
29
  function Be(t) {
29
- return ke(), t ? H.detectSupport(t) : t !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: Y, ktx2Loader: H, meshoptDecoder: ge };
30
+ return ke(), t ? G.detectSupport(t) : t !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: A, ktx2Loader: G, meshoptDecoder: ge };
30
31
  }
31
32
  function Re(t) {
32
- t.dracoLoader || t.setDRACOLoader(Y), t.ktx2Loader || t.setKTX2Loader(H), t.meshoptDecoder || t.setMeshoptDecoder(ge);
33
+ t.dracoLoader || t.setDRACOLoader(A), t.ktx2Loader || t.setKTX2Loader(G), t.meshoptDecoder || t.setMeshoptDecoder(ge);
33
34
  }
34
35
  const Me = /* @__PURE__ */ new WeakMap();
35
36
  function Ie(t, e) {
36
37
  let s = Me.get(t);
37
38
  s ? s = Object.assign(s, e) : s = e, Me.set(t, s);
38
39
  }
39
- const Le = Oe.prototype.load;
40
- function Ze(...t) {
40
+ const Le = Se.prototype.load;
41
+ function tt(...t) {
41
42
  const e = Me.get(this);
42
43
  let s = t[0];
43
44
  const n = new URL(s, window.location.href);
@@ -47,7 +48,7 @@ function Ze(...t) {
47
48
  }
48
49
  return t[0] = s, Le == null ? void 0 : Le.call(this, ...t);
49
50
  }
50
- Oe.prototype.load = Ze;
51
+ Se.prototype.load = tt;
51
52
  oe("debugprogressive");
52
53
  function oe(t) {
53
54
  if (typeof window > "u")
@@ -55,7 +56,7 @@ function oe(t) {
55
56
  const s = new URL(window.location.href).searchParams.get(t);
56
57
  return s == null || s === "0" || s === "false" ? !1 : s === "" ? !0 : s;
57
58
  }
58
- function je(t, e) {
59
+ function st(t, e) {
59
60
  if (e === void 0 || e.startsWith("./") || e.startsWith("http") || t === void 0)
60
61
  return e;
61
62
  const s = t.lastIndexOf("/");
@@ -67,52 +68,52 @@ function je(t, e) {
67
68
  }
68
69
  return e;
69
70
  }
70
- let ee;
71
- function et() {
72
- return ee !== void 0 || (ee = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), oe("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", ee)), ee;
71
+ let te;
72
+ function rt() {
73
+ return te !== void 0 || (te = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), oe("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", te)), te;
73
74
  }
74
- const tt = typeof window > "u" && typeof document > "u", De = Symbol("needle:raycast-mesh");
75
+ const it = typeof window > "u" && typeof document > "u", _e = Symbol("needle:raycast-mesh");
75
76
  function ae(t) {
76
- return (t == null ? void 0 : t[De]) instanceof he ? t[De] : null;
77
+ return (t == null ? void 0 : t[_e]) instanceof he ? t[_e] : null;
77
78
  }
78
- function st(t, e) {
79
+ function nt(t, e) {
79
80
  if ((t.type === "Mesh" || t.type === "SkinnedMesh") && !ae(t)) {
80
- const n = it(e);
81
- n.userData = { isRaycastMesh: !0 }, t[De] = n;
81
+ const n = at(e);
82
+ n.userData = { isRaycastMesh: !0 }, t[_e] = n;
82
83
  }
83
84
  }
84
- function rt(t = !0) {
85
+ function ot(t = !0) {
85
86
  if (t) {
86
- if (te)
87
+ if (se)
87
88
  return;
88
- const e = te = J.prototype.raycast;
89
- J.prototype.raycast = function(s, n) {
89
+ const e = se = Q.prototype.raycast;
90
+ Q.prototype.raycast = function(s, n) {
90
91
  const i = this, r = ae(i);
91
92
  let o;
92
93
  r && i.isMesh && (o = i.geometry, i.geometry = r), e.call(this, s, n), o && (i.geometry = o);
93
94
  };
94
95
  } else {
95
- if (!te)
96
+ if (!se)
96
97
  return;
97
- J.prototype.raycast = te, te = null;
98
+ Q.prototype.raycast = se, se = null;
98
99
  }
99
100
  }
100
- let te = null;
101
- function it(t) {
101
+ let se = null;
102
+ function at(t) {
102
103
  const e = new he();
103
104
  for (const s in t.attributes)
104
105
  e.setAttribute(s, t.getAttribute(s));
105
106
  return e.setIndex(t.getIndex()), e;
106
107
  }
107
- const K = new Array(), $ = "NEEDLE_progressive", p = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Set();
108
+ const H = new Array(), W = "NEEDLE_progressive", p = oe("debugprogressive"), ve = Symbol("needle-progressive-texture"), ne = /* @__PURE__ */ new Map(), we = /* @__PURE__ */ new Set();
108
109
  if (p) {
109
110
  let t = function() {
110
- e += 1, console.log("Toggle LOD level", e, ie), ie.forEach((i, r) => {
111
+ e += 1, console.log("Toggle LOD level", e, ne), ne.forEach((i, r) => {
111
112
  for (const o of i.keys) {
112
113
  const a = r[o];
113
114
  if (a != null)
114
115
  if (a.isBufferGeometry === !0) {
115
- const c = A.getMeshLODInformation(a), l = c ? Math.min(e, c.lods.length) : 0;
116
+ const c = P.getMeshLODInformation(a), l = c ? Math.min(e, c.lods.length) : 0;
116
117
  r["DEBUG:LOD"] = l, c && (s = Math.max(s, c.lods.length - 1));
117
118
  } else
118
119
  r.isMaterial === !0 && (r["DEBUG:LOD"] = e);
@@ -120,7 +121,7 @@ if (p) {
120
121
  }), e >= s && (e = -1);
121
122
  }, e = -1, s = 2, n = !1;
122
123
  window.addEventListener("keyup", (i) => {
123
- i.key === "p" && t(), i.key === "w" && (n = !n, ve && ve.forEach((r) => {
124
+ i.key === "p" && t(), i.key === "w" && (n = !n, we && we.forEach((r) => {
124
125
  r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = n);
125
126
  }));
126
127
  });
@@ -129,26 +130,26 @@ function Ee(t, e, s) {
129
130
  var i;
130
131
  if (!p)
131
132
  return;
132
- ie.has(t) || ie.set(t, { keys: [], sourceId: s });
133
- const n = ie.get(t);
133
+ ne.has(t) || ne.set(t, { keys: [], sourceId: s });
134
+ const n = ne.get(t);
134
135
  ((i = n == null ? void 0 : n.keys) == null ? void 0 : i.includes(e)) == !1 && n.keys.push(e);
135
136
  }
136
- const D = class {
137
+ const M = class {
137
138
  constructor(t, e) {
138
139
  this.loadMesh = (s) => {
139
140
  var i, r;
140
141
  if (this._isLoadingMesh)
141
142
  return null;
142
- const n = (r = (i = this.parser.json.meshes[s]) == null ? void 0 : i.extensions) == null ? void 0 : r[$];
143
+ const n = (r = (i = this.parser.json.meshes[s]) == null ? void 0 : i.extensions) == null ? void 0 : r[W];
143
144
  return n ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", s).then((o) => {
144
145
  var a;
145
- return this._isLoadingMesh = !1, o && D.registerMesh(this.url, n.guid, o, (a = n.lods) == null ? void 0 : a.length, void 0, n), o;
146
+ return this._isLoadingMesh = !1, o && M.registerMesh(this.url, n.guid, o, (a = n.lods) == null ? void 0 : a.length, void 0, n), o;
146
147
  })) : null;
147
148
  }, p && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
148
149
  }
149
150
  /** The name of the extension */
150
151
  get name() {
151
- return $;
152
+ return W;
152
153
  }
153
154
  static getMeshLODInformation(t) {
154
155
  const e = this.getAssignedLODInformation(t);
@@ -246,13 +247,13 @@ const D = class {
246
247
  var s;
247
248
  if (!t)
248
249
  return Promise.resolve(null);
249
- if (t instanceof J || t.isMesh === !0) {
250
+ if (t instanceof Q || t.isMesh === !0) {
250
251
  const n = t.geometry, i = this.getAssignedLODInformation(n);
251
252
  if (!i)
252
253
  return Promise.resolve(null);
253
- for (const r of K)
254
+ for (const r of H)
254
255
  (s = r.onBeforeGetLODMesh) == null || s.call(r, t, e);
255
- return t["LOD:requested level"] = e, D.getOrLoadLOD(n, e).then((r) => {
256
+ return t["LOD:requested level"] = e, M.getOrLoadLOD(n, e).then((r) => {
256
257
  if (Array.isArray(r)) {
257
258
  const o = i.index || 0;
258
259
  r = r[o];
@@ -285,7 +286,7 @@ const D = class {
285
286
  }
286
287
  if (t.isMaterial === !0) {
287
288
  const s = t, n = [], i = new Array();
288
- if (p && ve.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
289
+ if (p && we.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
289
290
  const r = s;
290
291
  for (const o of Object.keys(r.uniforms)) {
291
292
  const a = r.uniforms[o].value;
@@ -311,14 +312,14 @@ const D = class {
311
312
  return o;
312
313
  });
313
314
  }
314
- if (t instanceof j || t.isTexture === !0) {
315
+ if (t instanceof ee || t.isTexture === !0) {
315
316
  const s = t;
316
317
  return this.assignTextureLODForSlot(s, e, null, null);
317
318
  }
318
319
  return Promise.resolve(null);
319
320
  }
320
321
  static assignTextureLODForSlot(t, e, s, n) {
321
- return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : D.getOrLoadLOD(t, e).then((i) => {
322
+ return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : M.getOrLoadLOD(t, e).then((i) => {
322
323
  if (Array.isArray(i))
323
324
  return null;
324
325
  if ((i == null ? void 0 : i.isTexture) === !0) {
@@ -348,7 +349,7 @@ const D = class {
348
349
  return p && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, i) => {
349
350
  var r;
350
351
  if (n != null && n.extensions) {
351
- const o = n == null ? void 0 : n.extensions[$];
352
+ const o = n == null ? void 0 : n.extensions[W];
352
353
  if (o) {
353
354
  if (!o.lods) {
354
355
  p && console.warn("Texture has no LODs", o);
@@ -358,22 +359,22 @@ const D = class {
358
359
  for (const c of this.parser.associations.keys())
359
360
  if (c.isTexture === !0) {
360
361
  const l = this.parser.associations.get(c);
361
- (l == null ? void 0 : l.textures) === i && (a = !0, D.registerTexture(this.url, c, (r = o.lods) == null ? void 0 : r.length, i, o));
362
+ (l == null ? void 0 : l.textures) === i && (a = !0, M.registerTexture(this.url, c, (r = o.lods) == null ? void 0 : r.length, i, o));
362
363
  }
363
364
  a || this.parser.getDependency("texture", i).then((c) => {
364
365
  var l;
365
- c && D.registerTexture(this.url, c, (l = o.lods) == null ? void 0 : l.length, i, o);
366
+ c && M.registerTexture(this.url, c, (l = o.lods) == null ? void 0 : l.length, i, o);
366
367
  });
367
368
  }
368
369
  }
369
370
  }), (s = this.parser.json.meshes) == null || s.forEach((n, i) => {
370
371
  if (n != null && n.extensions) {
371
- const r = n == null ? void 0 : n.extensions[$];
372
+ const r = n == null ? void 0 : n.extensions[W];
372
373
  if (r && r.lods) {
373
374
  for (const o of this.parser.associations.keys())
374
375
  if (o.isMesh) {
375
376
  const a = this.parser.associations.get(o);
376
- (a == null ? void 0 : a.meshes) === i && D.registerMesh(this.url, r.guid, o, r.lods.length, a.primitives, r);
377
+ (a == null ? void 0 : a.meshes) === i && M.registerMesh(this.url, r.guid, o, r.lods.length, a.primitives, r);
377
378
  }
378
379
  }
379
380
  }
@@ -388,9 +389,9 @@ const D = class {
388
389
  let r;
389
390
  if (t.isTexture === !0) {
390
391
  const d = t;
391
- d.source && d.source[_e] && (r = d.source[_e]);
392
+ d.source && d.source[ve] && (r = d.source[ve]);
392
393
  }
393
- if (r || (r = D.lodInfos.get(i)), r) {
394
+ if (r || (r = M.lodInfos.get(i)), r) {
394
395
  if (e > 0) {
395
396
  let x = !1;
396
397
  const L = Array.isArray(r.lods);
@@ -400,39 +401,39 @@ const D = class {
400
401
  const d = Array.isArray(r.lods) ? (o = r.lods[e]) == null ? void 0 : o.path : r.lods;
401
402
  if (!d)
402
403
  return p && !r["missing:uri"] && (r["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, r)), null;
403
- const h = je(n.url, d);
404
+ const h = st(n.url, d);
404
405
  if (h.endsWith(".glb") || h.endsWith(".gltf")) {
405
406
  if (!r.guid)
406
407
  return console.warn("missing pointer for glb/gltf texture", r), null;
407
408
  const x = h + "_" + r.guid, L = this.previouslyLoaded.get(x);
408
409
  if (L !== void 0) {
409
410
  s && console.log(`LOD ${e} was already loading/loaded: ${x}`);
410
- let f = await L.catch((I) => (console.error(`Error loading LOD ${e} from ${h}
411
- `, I), null)), w = !1;
412
- if (f == null || (f instanceof j && t instanceof j ? (a = f.image) != null && a.data || (c = f.source) != null && c.data ? f = this.copySettings(t, f) : (w = !0, this.previouslyLoaded.delete(x)) : f instanceof he && t instanceof he && ((l = f.attributes.position) != null && l.array || (w = !0, this.previouslyLoaded.delete(x)))), !w)
413
- return f;
411
+ let u = await L.catch(($) => (console.error(`Error loading LOD ${e} from ${h}
412
+ `, $), null)), w = !1;
413
+ if (u == null || (u instanceof ee && t instanceof ee ? (a = u.image) != null && a.data || (c = u.source) != null && c.data ? u = this.copySettings(t, u) : (w = !0, this.previouslyLoaded.delete(x)) : u instanceof he && t instanceof he && ((l = u.attributes.position) != null && l.array || (w = !0, this.previouslyLoaded.delete(x)))), !w)
414
+ return u;
414
415
  }
415
- const M = r, P = new Promise(async (f, w) => {
416
- const I = new Oe();
417
- Re(I), p && (await new Promise((O) => setTimeout(O, 1e3)), s && console.warn("Start loading (delayed) " + h, M.guid));
418
- let k = h;
419
- if (M && Array.isArray(M.lods)) {
420
- const O = M.lods[e];
421
- O.hash && (k += "?v=" + O.hash);
416
+ const D = r, k = new Promise(async (u, w) => {
417
+ const $ = new Se();
418
+ Re($), p && (await new Promise((O) => setTimeout(O, 1e3)), s && console.warn("Start loading (delayed) " + h, D.guid));
419
+ let B = h;
420
+ if (D && Array.isArray(D.lods)) {
421
+ const O = D.lods[e];
422
+ O.hash && (B += "?v=" + O.hash);
422
423
  }
423
- const E = await I.loadAsync(k).catch((O) => (console.error(`Error loading LOD ${e} from ${h}
424
+ const T = await $.loadAsync(B).catch((O) => (console.error(`Error loading LOD ${e} from ${h}
424
425
  `, O), null));
425
- if (!E)
426
+ if (!T)
426
427
  return null;
427
- const G = E.parser;
428
- s && console.log("Loading finished " + h, M.guid);
428
+ const U = T.parser;
429
+ s && console.log("Loading finished " + h, D.guid);
429
430
  let v = 0;
430
- if (E.parser.json.textures) {
431
+ if (T.parser.json.textures) {
431
432
  let O = !1;
432
- for (const u of E.parser.json.textures) {
433
- if (u != null && u.extensions) {
434
- const g = u == null ? void 0 : u.extensions[$];
435
- if (g != null && g.guid && g.guid === M.guid) {
433
+ for (const f of T.parser.json.textures) {
434
+ if (f != null && f.extensions) {
435
+ const g = f == null ? void 0 : f.extensions[W];
436
+ if (g != null && g.guid && g.guid === D.guid) {
436
437
  O = !0;
437
438
  break;
438
439
  }
@@ -440,17 +441,17 @@ const D = class {
440
441
  v++;
441
442
  }
442
443
  if (O) {
443
- let u = await G.getDependency("texture", v);
444
- return u && D.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h, v, u, x), t instanceof j && (u = this.copySettings(t, u)), u && (u.guid = M.guid), f(u);
444
+ let f = await U.getDependency("texture", v);
445
+ return f && M.assignLODInformation(n.url, f, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + f.name + '"', h, v, f, x), t instanceof ee && (f = this.copySettings(t, f)), f && (f.guid = D.guid), u(f);
445
446
  } else
446
- p && console.warn("Could not find texture with guid", M.guid, E.parser.json);
447
+ p && console.warn("Could not find texture with guid", D.guid, T.parser.json);
447
448
  }
448
- if (v = 0, E.parser.json.meshes) {
449
+ if (v = 0, T.parser.json.meshes) {
449
450
  let O = !1;
450
- for (const u of E.parser.json.meshes) {
451
- if (u != null && u.extensions) {
452
- const g = u == null ? void 0 : u.extensions[$];
453
- if (g != null && g.guid && g.guid === M.guid) {
451
+ for (const f of T.parser.json.meshes) {
452
+ if (f != null && f.extensions) {
453
+ const g = f == null ? void 0 : f.extensions[W];
454
+ if (g != null && g.guid && g.guid === D.guid) {
454
455
  O = !0;
455
456
  break;
456
457
  }
@@ -458,28 +459,28 @@ const D = class {
458
459
  v++;
459
460
  }
460
461
  if (O) {
461
- const u = await G.getDependency("mesh", v), g = M;
462
- if (s && console.log(`Loaded Mesh "${u.name}"`, h, v, u, x), u.isMesh === !0) {
463
- const _ = u.geometry;
464
- return D.assignLODInformation(n.url, _, i, e, void 0, g.density), f(_);
462
+ const f = await U.getDependency("mesh", v), g = D;
463
+ if (s && console.log(`Loaded Mesh "${f.name}"`, h, v, f, x), f.isMesh === !0) {
464
+ const _ = f.geometry;
465
+ return M.assignLODInformation(n.url, _, i, e, void 0, g.density), u(_);
465
466
  } else {
466
467
  const _ = new Array();
467
- for (let S = 0; S < u.children.length; S++) {
468
- const T = u.children[S];
469
- if (T.isMesh === !0) {
470
- const W = T.geometry;
471
- D.assignLODInformation(n.url, W, i, e, S, g.density), _.push(W);
468
+ for (let S = 0; S < f.children.length; S++) {
469
+ const E = f.children[S];
470
+ if (E.isMesh === !0) {
471
+ const K = E.geometry;
472
+ M.assignLODInformation(n.url, K, i, e, S, g.density), _.push(K);
472
473
  }
473
474
  }
474
- return f(_);
475
+ return u(_);
475
476
  }
476
477
  } else
477
- p && console.warn("Could not find mesh with guid", M.guid, E.parser.json);
478
+ p && console.warn("Could not find mesh with guid", D.guid, T.parser.json);
478
479
  }
479
- return f(null);
480
+ return u(null);
480
481
  });
481
- return this.previouslyLoaded.set(x, P), await P;
482
- } else if (t instanceof j) {
482
+ return this.previouslyLoaded.set(x, k), await k;
483
+ } else if (t instanceof ee) {
483
484
  s && console.log("Load texture from uri: " + h);
484
485
  const L = await new We().loadAsync(h);
485
486
  return L ? (L.guid = r.guid, L.flipY = !1, L.needsUpdate = !0, L.colorSpace = t.colorSpace, s && console.log(r, L)) : p && console.warn("failed loading", h), L;
@@ -492,7 +493,7 @@ const D = class {
492
493
  if (!e)
493
494
  return;
494
495
  e.userData || (e.userData = {});
495
- const o = new nt(t, s, n, i, r);
496
+ const o = new lt(t, s, n, i, r);
496
497
  e.userData.LODS = o;
497
498
  }
498
499
  static getAssignedLODInformation(t) {
@@ -501,22 +502,22 @@ const D = class {
501
502
  }
502
503
  // private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
503
504
  static copySettings(t, e) {
504
- return p && console.warn(`Copy texture settings
505
+ return e ? (p && console.warn(`Copy texture settings
505
506
  `, t.uuid, `
506
- `, 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;
507
+ `, 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;
507
508
  }
508
509
  };
509
- let A = D;
510
- A.registerTexture = (t, e, s, n, i) => {
510
+ let P = M;
511
+ P.registerTexture = (t, e, s, n, i) => {
511
512
  if (p && console.log("> Progressive: register texture", n, e.name, e.uuid, e, i), !e) {
512
513
  p && console.error("gltf-progressive: Register texture without texture");
513
514
  return;
514
515
  }
515
- e.source && (e.source[_e] = i);
516
+ e.source && (e.source[ve] = i);
516
517
  const r = i.guid;
517
- D.assignLODInformation(t, e, r, s, n, void 0), D.lodInfos.set(r, i), D.lowresCache.set(r, e);
518
+ M.assignLODInformation(t, e, r, s, n, void 0), M.lodInfos.set(r, i), M.lowresCache.set(r, e);
518
519
  };
519
- A.registerMesh = (t, e, s, n, i, r) => {
520
+ P.registerMesh = (t, e, s, n, i, r) => {
520
521
  var c;
521
522
  p && console.log("> Progressive: register mesh", i, s.name, r, s.uuid, s);
522
523
  const o = s.geometry;
@@ -524,16 +525,16 @@ A.registerMesh = (t, e, s, n, i, r) => {
524
525
  p && console.warn("gltf-progressive: Register mesh without geometry");
525
526
  return;
526
527
  }
527
- o.userData || (o.userData = {}), D.assignLODInformation(t, o, e, n, i, r.density), D.lodInfos.set(e, r);
528
- let a = D.lowresCache.get(e);
529
- a ? a.push(s.geometry) : a = [s.geometry], D.lowresCache.set(e, a), n > 0 && !ae(s) && st(s, o);
530
- for (const l of K)
528
+ o.userData || (o.userData = {}), M.assignLODInformation(t, o, e, n, i, r.density), M.lodInfos.set(e, r);
529
+ let a = M.lowresCache.get(e);
530
+ a ? a.push(s.geometry) : a = [s.geometry], M.lowresCache.set(e, a), n > 0 && !ae(s) && nt(s, o);
531
+ for (const l of H)
531
532
  (c = l.onRegisteredNewMesh) == null || c.call(l, s, r);
532
533
  };
533
- A.lodInfos = /* @__PURE__ */ new Map();
534
- A.previouslyLoaded = /* @__PURE__ */ new Map();
535
- A.lowresCache = /* @__PURE__ */ new Map();
536
- class nt {
534
+ P.lodInfos = /* @__PURE__ */ new Map();
535
+ P.previouslyLoaded = /* @__PURE__ */ new Map();
536
+ P.lowresCache = /* @__PURE__ */ new Map();
537
+ class lt {
537
538
  constructor(e, s, n, i, r) {
538
539
  this.url = e, this.key = s, this.level = n, i != null && (this.index = i), r != null && (this.density = r);
539
540
  }
@@ -541,26 +542,26 @@ class nt {
541
542
  var Ge = (t, e, s) => {
542
543
  if (!e.has(t))
543
544
  throw TypeError("Cannot " + s);
544
- }, y = (t, e, s) => (Ge(t, e, "read from private field"), s ? s.call(t) : e.get(t)), X = (t, e, s) => {
545
+ }, y = (t, e, s) => (Ge(t, e, "read from private field"), s ? s.call(t) : e.get(t)), J = (t, e, s) => {
545
546
  if (e.has(t))
546
547
  throw TypeError("Cannot add the same private member more than once");
547
548
  e instanceof WeakSet ? e.add(t) : e.set(t, s);
548
- }, N = (t, e, s, n) => (Ge(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b, V, we, Q, re, de, q;
549
- const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"), z = Symbol("Needle:CurrentLOD"), R = { mesh_lod: -1, texture_lod: -1 }, C = class {
549
+ }, F = (t, e, s, n) => (Ge(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b, q, Oe, Z, ie, de, Y;
550
+ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"), X = Symbol("Needle:CurrentLOD"), I = { mesh_lod: -1, texture_lod: -1 }, C = class {
550
551
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
551
552
  constructor(t, e) {
552
- this.projectionScreenMatrix = new Se(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", X(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], X(this, V, void 0), X(this, we, new qe()), X(this, Q, 0), X(this, re, 0), X(this, de, 0), X(this, q, 0), this._fpsBuffer = [60, 60, 60, 60, 60], this._sphere = new ze(), this._tempBox = new be(), this._tempBox2 = new be(), this.tempMatrix = new Se(), this._tempWorldPosition = new F(), this._tempBoxSize = new F(), this._tempBox2Size = new F(), this.renderer = t, this.context = { ...e };
553
+ this.projectionScreenMatrix = new be(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", J(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], J(this, q, void 0), J(this, Oe, new Ke()), J(this, Z, 0), J(this, ie, 0), J(this, de, 0), J(this, Y, 0), this._fpsBuffer = [60, 60, 60, 60, 60], this._sphere = new ze(), this._tempBox = new Te(), this._tempBox2 = new Te(), this.tempMatrix = new be(), this._tempWorldPosition = new z(), this._tempBoxSize = new z(), this._tempBox2Size = new z(), this.renderer = t, this.context = { ...e };
553
554
  }
554
555
  /** @internal */
555
556
  static getObjectLODState(t) {
556
557
  return t[xe];
557
558
  }
558
559
  static addPlugin(t) {
559
- K.push(t);
560
+ H.push(t);
560
561
  }
561
562
  static removePlugin(t) {
562
- const e = K.indexOf(t);
563
- e >= 0 && K.splice(e, 1);
563
+ const e = H.indexOf(t);
564
+ e >= 0 && H.splice(e, 1);
564
565
  }
565
566
  /**
566
567
  * Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
@@ -578,7 +579,7 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
578
579
  }
579
580
  /** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
580
581
  get plugins() {
581
- return K;
582
+ return H;
582
583
  }
583
584
  addEventListener(t, e) {
584
585
  t === "changed" && this._lodchangedlisteners.push(e);
@@ -593,21 +594,21 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
593
594
  * Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
594
595
  */
595
596
  enable() {
596
- if (y(this, V))
597
+ if (y(this, q))
597
598
  return;
598
599
  console.debug("[gltf-progressive] Enabling LODsManager for renderer");
599
600
  let t = 0;
600
- N(this, V, this.renderer.render);
601
+ F(this, q, this.renderer.render);
601
602
  const e = this;
602
603
  Be(this.renderer), this.renderer.render = function(s, n) {
603
604
  const i = e.renderer.getRenderTarget();
604
- (i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, N(e, Q, y(e, Q) + 1), N(e, re, y(e, we).getDelta()), N(e, de, y(e, de) + y(e, re)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / y(e, re)), N(e, q, e._fpsBuffer.reduce((o, a) => o + a) / e._fpsBuffer.length), B && y(e, Q) % 200 === 0 && console.log("FPS", Math.round(y(e, q)), "Interval:", y(e, b)));
605
+ (i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, F(e, Z, y(e, Z) + 1), F(e, ie, y(e, Oe).getDelta()), F(e, de, y(e, de) + y(e, ie)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / y(e, ie)), F(e, Y, e._fpsBuffer.reduce((o, a) => o + a) / e._fpsBuffer.length), R && y(e, Z) % 200 === 0 && console.log("FPS", Math.round(y(e, Y)), "Interval:", y(e, b)));
605
606
  const r = t++;
606
- y(e, V).call(this, s, n), e.onAfterRender(s, n, r);
607
+ y(e, q).call(this, s, n), e.onAfterRender(s, n, r);
607
608
  };
608
609
  }
609
610
  disable() {
610
- y(this, V) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, V), N(this, V, void 0));
611
+ y(this, q) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, q), F(this, q, void 0));
611
612
  }
612
613
  update(t, e) {
613
614
  this.internalUpdate(t, e);
@@ -622,7 +623,7 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
622
623
  (o.name === "EffectMaterial" || o.name === "CopyShader") && (r = !1);
623
624
  }
624
625
  if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (r = !1), r) {
625
- if (ot || (this.updateInterval === "auto" ? y(this, q) < 40 && y(this, b) < 10 ? (N(this, b, y(this, b) + 1), B && console.warn("↓ Reducing LOD updates", y(this, b), y(this, q).toFixed(0))) : y(this, q) >= 60 && y(this, b) > 1 && (N(this, b, y(this, b) - 1), B && console.warn("↑ Increasing LOD updates", y(this, b), y(this, q).toFixed(0))) : N(this, b, this.updateInterval), y(this, b) > 0 && y(this, Q) % y(this, b) != 0))
626
+ if (ct || (this.updateInterval === "auto" ? y(this, Y) < 40 && y(this, b) < 10 ? (F(this, b, y(this, b) + 1), R && console.warn("↓ Reducing LOD updates", y(this, b), y(this, Y).toFixed(0))) : y(this, Y) >= 60 && y(this, b) > 1 && (F(this, b, y(this, b) - 1), R && console.warn("↑ Increasing LOD updates", y(this, b), y(this, Y).toFixed(0))) : F(this, b, this.updateInterval), y(this, b) > 0 && y(this, Z) % y(this, b) != 0))
626
627
  return;
627
628
  this.internalUpdate(t, e);
628
629
  }
@@ -637,7 +638,7 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
637
638
  const i = this.targetTriangleDensity;
638
639
  for (const l of n) {
639
640
  if (l.material && (((a = l.geometry) == null ? void 0 : a.type) === "BoxGeometry" || ((c = l.geometry) == null ? void 0 : c.type) === "BufferGeometry") && (l.material.name === "SphericalGaussianBlur" || l.material.name == "BackgroundCubeMaterial" || l.material.name === "CubemapFromEquirect" || l.material.name === "EquirectangularToCubeUV")) {
640
- B && (l.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (l.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", l, l.material.name, l.material.type)));
641
+ R && (l.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (l.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", l, l.material.name, l.material.type)));
641
642
  continue;
642
643
  }
643
644
  switch (l.material.type) {
@@ -649,23 +650,23 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
649
650
  case "MeshDepthMaterial":
650
651
  continue;
651
652
  }
652
- if (B === "color" && l.material && !l.object.progressive_debug_color) {
653
+ if (R === "color" && l.material && !l.object.progressive_debug_color) {
653
654
  l.object.progressive_debug_color = !0;
654
655
  const h = Math.random() * 16777215, x = new Ve({ color: h });
655
656
  l.object.material = x;
656
657
  }
657
658
  const d = l.object;
658
- (d instanceof J || d.isMesh) && this.updateLODs(t, e, d, i);
659
+ (d instanceof Q || d.isMesh) && this.updateLODs(t, e, d, i);
659
660
  }
660
661
  const r = s.transparent;
661
662
  for (const l of r) {
662
663
  const d = l.object;
663
- (d instanceof J || d.isMesh) && this.updateLODs(t, e, d, i);
664
+ (d instanceof Q || d.isMesh) && this.updateLODs(t, e, d, i);
664
665
  }
665
666
  const o = s.transmissive;
666
667
  for (const l of o) {
667
668
  const d = l.object;
668
- (d instanceof J || d.isMesh) && this.updateLODs(t, e, d, i);
669
+ (d instanceof Q || d.isMesh) && this.updateLODs(t, e, d, i);
669
670
  }
670
671
  }
671
672
  /** Update the LOD levels for the renderer. */
@@ -673,16 +674,16 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
673
674
  var o, a;
674
675
  s.userData || (s.userData = {});
675
676
  let i = s[xe];
676
- if (i || (i = new at(), s[xe] = i), i.frames++ < 2)
677
+ if (i || (i = new ft(), s[xe] = i), i.frames++ < 2)
677
678
  return;
678
- for (const c of K)
679
+ for (const c of H)
679
680
  (o = c.onBeforeUpdateLOD) == null || o.call(c, this.renderer, t, e, s);
680
- this.calculateLodLevel(e, s, i, n, R), R.mesh_lod = Math.round(R.mesh_lod), R.texture_lod = Math.round(R.texture_lod), R.mesh_lod >= 0 && this.loadProgressiveMeshes(s, R.mesh_lod);
681
- let r = R.texture_lod;
681
+ this.calculateLodLevel(e, s, i, n, I), I.mesh_lod = Math.round(I.mesh_lod), I.texture_lod = Math.round(I.texture_lod), I.mesh_lod >= 0 && this.loadProgressiveMeshes(s, I.mesh_lod);
682
+ let r = I.texture_lod;
682
683
  s.material && r >= 0 && this.loadProgressiveTextures(s.material, r);
683
- for (const c of K)
684
- (a = c.onAfterUpdatedLOD) == null || a.call(c, this.renderer, t, e, s, R);
685
- i.lastLodLevel_Mesh = R.mesh_lod, i.lastLodLevel_Texture = R.texture_lod;
684
+ for (const c of H)
685
+ (a = c.onAfterUpdatedLOD) == null || a.call(c, this.renderer, t, e, s, I);
686
+ i.lastLodLevel_Mesh = I.mesh_lod, i.lastLodLevel_Texture = I.texture_lod;
686
687
  }
687
688
  /** Load progressive textures for the given material
688
689
  * @param material the material to load the textures for
@@ -698,9 +699,9 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
698
699
  return;
699
700
  }
700
701
  let s = !1;
701
- (t[z] === void 0 || e < t[z]) && (s = !0);
702
+ (t[X] === void 0 || e < t[X]) && (s = !0);
702
703
  const n = t["DEBUG:LOD"];
703
- n != null && (s = t[z] != n, e = n), s && (t[z] = e, A.assignTextureLOD(t, e).then((i) => {
704
+ n != null && (s = t[X] != n, e = n), s && (t[X] = e, P.assignTextureLOD(t, e).then((i) => {
704
705
  this._lodchangedlisteners.forEach((r) => r({ type: "texture", level: e, object: t }));
705
706
  }));
706
707
  }
@@ -713,12 +714,12 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
713
714
  loadProgressiveMeshes(t, e) {
714
715
  if (!t)
715
716
  return Promise.resolve(null);
716
- let s = t[z] !== e;
717
+ let s = t[X] !== e;
717
718
  const n = t["DEBUG:LOD"];
718
- if (n != null && (s = t[z] != n, e = n), s) {
719
- t[z] = e;
719
+ if (n != null && (s = t[X] != n, e = n), s) {
720
+ t[X] = e;
720
721
  const i = t.geometry;
721
- return A.assignMeshLOD(t, e).then((r) => (r && t[z] == e && i != t.geometry && this._lodchangedlisteners.forEach((o) => o({ type: "mesh", level: e, object: t })), r));
722
+ return P.assignMeshLOD(t, e).then((r) => (r && t[X] == e && i != t.geometry && this._lodchangedlisteners.forEach((o) => o({ type: "mesh", level: e, object: t })), r));
722
723
  }
723
724
  return Promise.resolve(null);
724
725
  }
@@ -727,7 +728,7 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
727
728
  return this._tempPtInside.set(i, r, s.z).applyMatrix4(e).z < 0;
728
729
  }
729
730
  calculateLodLevel(t, e, s, n, i) {
730
- var P;
731
+ var k;
731
732
  if (!e) {
732
733
  i.mesh_lod = -1, i.texture_lod = -1;
733
734
  return;
@@ -737,96 +738,96 @@ const B = oe("debugprogressive"), ot = oe("noprogressive"), me = Symbol("Needle:
737
738
  return;
738
739
  }
739
740
  let o = 10 + 1, a = !1;
740
- if (B && e["DEBUG:LOD"] != null)
741
+ if (R && e["DEBUG:LOD"] != null)
741
742
  return e["DEBUG:LOD"];
742
- const c = A.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = A.getMaterialMinMaxLODsCount(e.material), x = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
743
+ const c = P.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = P.getMaterialMinMaxLODsCount(e.material), x = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
743
744
  if (!d && !x) {
744
745
  i.mesh_lod = 0, i.texture_lod = 0;
745
746
  return;
746
747
  }
747
748
  d || (a = !0, o = 0);
748
749
  const L = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
749
- let M = e.geometry.boundingBox;
750
+ let D = e.geometry.boundingBox;
750
751
  if (e.type === "SkinnedMesh") {
751
752
  const m = e;
752
753
  if (!m.boundingBox)
753
754
  m.computeBoundingBox();
754
755
  else if (s.frames % 30 === 0) {
755
- const f = ae(m), w = m.geometry;
756
- f && (m.geometry = f), m.computeBoundingBox(), m.geometry = w;
756
+ const u = ae(m), w = m.geometry;
757
+ u && (m.geometry = u), m.computeBoundingBox(), m.geometry = w;
757
758
  }
758
- M = m.boundingBox;
759
+ D = m.boundingBox;
759
760
  }
760
- if (M) {
761
+ if (D) {
761
762
  const m = t;
762
763
  if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
763
764
  this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
764
- const u = t.getWorldPosition(this._tempWorldPosition);
765
- if (this._sphere.containsPoint(u)) {
765
+ const f = t.getWorldPosition(this._tempWorldPosition);
766
+ if (this._sphere.containsPoint(f)) {
766
767
  i.mesh_lod = 0, i.texture_lod = 0;
767
768
  return;
768
769
  }
769
770
  }
770
- if (this._tempBox.copy(M), this._tempBox.applyMatrix4(e.matrixWorld), m.isPerspectiveCamera && C.isInside(this._tempBox, this.projectionScreenMatrix)) {
771
+ if (this._tempBox.copy(D), this._tempBox.applyMatrix4(e.matrixWorld), m.isPerspectiveCamera && C.isInside(this._tempBox, this.projectionScreenMatrix)) {
771
772
  i.mesh_lod = 0, i.texture_lod = 0;
772
773
  return;
773
774
  }
774
775
  if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && m.isPerspectiveCamera && m.fov > 70) {
775
- const u = this._tempBox.min, g = this._tempBox.max;
776
- let _ = u.x, S = u.y, T = g.x, W = g.y;
777
- const le = 2, pe = 1.5, ce = (u.x + g.x) * 0.5, ue = (u.y + g.y) * 0.5;
778
- _ = (_ - ce) * le + ce, S = (S - ue) * le + ue, T = (T - ce) * le + ce, W = (W - ue) * le + ue;
779
- const Fe = _ < 0 && T > 0 ? 0 : Math.min(Math.abs(u.x), Math.abs(g.x)), Ue = S < 0 && W > 0 ? 0 : Math.min(Math.abs(u.y), Math.abs(g.y)), ye = Math.max(Fe, Ue);
776
+ const f = this._tempBox.min, g = this._tempBox.max;
777
+ let _ = f.x, S = f.y, E = g.x, K = g.y;
778
+ const le = 2, pe = 1.5, ce = (f.x + g.x) * 0.5, fe = (f.y + g.y) * 0.5;
779
+ _ = (_ - ce) * le + ce, S = (S - fe) * le + fe, E = (E - ce) * le + ce, K = (K - fe) * le + fe;
780
+ const Ue = _ < 0 && E > 0 ? 0 : Math.min(Math.abs(f.x), Math.abs(g.x)), Fe = S < 0 && K > 0 ? 0 : Math.min(Math.abs(f.y), Math.abs(g.y)), ye = Math.max(Ue, Fe);
780
781
  s.lastCentrality = (pe - ye) * (pe - ye) * (pe - ye);
781
782
  } else
782
783
  s.lastCentrality = 1;
783
- const f = this._tempBox.getSize(this._tempBoxSize);
784
- f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), t.isPerspectiveCamera ? f.x *= t.aspect : t.isOrthographicCamera;
785
- const w = t.matrixWorldInverse, I = this._tempBox2;
786
- I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(w);
787
- const k = I.getSize(this._tempBox2Size), E = Math.max(k.x, k.y);
788
- if (Math.max(f.x, f.y) != 0 && E != 0 && (f.z = k.z / Math.max(k.x, k.y) * Math.max(f.x, f.y)), s.lastScreenCoverage = Math.max(f.x, f.y, f.z), s.lastScreenspaceVolume.copy(f), s.lastScreenCoverage *= s.lastCentrality, B && C.debugDrawLine) {
789
- const u = this.tempMatrix.copy(this.projectionScreenMatrix);
790
- u.invert();
791
- const g = C.corner0, _ = C.corner1, S = C.corner2, T = C.corner3;
792
- g.copy(this._tempBox.min), _.copy(this._tempBox.max), _.x = g.x, S.copy(this._tempBox.max), S.y = g.y, T.copy(this._tempBox.max);
793
- const W = (g.z + T.z) * 0.5;
794
- g.z = _.z = S.z = T.z = W, g.applyMatrix4(u), _.applyMatrix4(u), S.applyMatrix4(u), T.applyMatrix4(u), C.debugDrawLine(g, _, 255), C.debugDrawLine(g, S, 255), C.debugDrawLine(_, T, 255), C.debugDrawLine(S, T, 255);
784
+ const u = this._tempBox.getSize(this._tempBoxSize);
785
+ u.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && u.multiplyScalar(L / screen.availHeight), t.isPerspectiveCamera ? u.x *= t.aspect : t.isOrthographicCamera;
786
+ const w = t.matrixWorldInverse, $ = this._tempBox2;
787
+ $.copy(D), $.applyMatrix4(e.matrixWorld), $.applyMatrix4(w);
788
+ const B = $.getSize(this._tempBox2Size), T = Math.max(B.x, B.y);
789
+ if (Math.max(u.x, u.y) != 0 && T != 0 && (u.z = B.z / Math.max(B.x, B.y) * Math.max(u.x, u.y)), s.lastScreenCoverage = Math.max(u.x, u.y, u.z), s.lastScreenspaceVolume.copy(u), s.lastScreenCoverage *= s.lastCentrality, R && C.debugDrawLine) {
790
+ const f = this.tempMatrix.copy(this.projectionScreenMatrix);
791
+ f.invert();
792
+ const g = C.corner0, _ = C.corner1, S = C.corner2, E = C.corner3;
793
+ g.copy(this._tempBox.min), _.copy(this._tempBox.max), _.x = g.x, S.copy(this._tempBox.max), S.y = g.y, E.copy(this._tempBox.max);
794
+ const K = (g.z + E.z) * 0.5;
795
+ g.z = _.z = S.z = E.z = K, g.applyMatrix4(f), _.applyMatrix4(f), S.applyMatrix4(f), E.applyMatrix4(f), C.debugDrawLine(g, _, 255), C.debugDrawLine(g, S, 255), C.debugDrawLine(_, E, 255), C.debugDrawLine(S, E, 255);
795
796
  }
796
797
  let v = 999;
797
798
  if (l && s.lastScreenCoverage > 0) {
798
- for (let u = 0; u < l.length; u++)
799
- if (l[u].density / s.lastScreenCoverage < n) {
800
- v = u;
799
+ for (let f = 0; f < l.length; f++)
800
+ if (l[f].density / s.lastScreenCoverage < n) {
801
+ v = f;
801
802
  break;
802
803
  }
803
804
  }
804
805
  v < o && (o = v, a = !0);
805
806
  }
806
- if (a ? i.mesh_lod = o : i.mesh_lod = s.lastLodLevel_Mesh, B && i.mesh_lod != s.lastLodLevel_Mesh) {
807
- const f = l == null ? void 0 : l[i.mesh_lod];
808
- f && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${i.mesh_lod} (${f.density.toFixed(0)}) - ${e.name}`);
807
+ if (a ? i.mesh_lod = o : i.mesh_lod = s.lastLodLevel_Mesh, R && i.mesh_lod != s.lastLodLevel_Mesh) {
808
+ const u = l == null ? void 0 : l[i.mesh_lod];
809
+ u && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${i.mesh_lod} (${u.density.toFixed(0)}) - ${e.name}`);
809
810
  }
810
811
  if (x) {
811
812
  const m = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
812
813
  if (s.lastLodLevel_Texture < 0) {
813
- if (i.texture_lod = h.max_count - 1, B) {
814
- const f = h.lods[h.max_count - 1];
815
- B && console.log(`First Texture LOD ${i.texture_lod} (${f.max_height}px) - ${e.name}`);
814
+ if (i.texture_lod = h.max_count - 1, R) {
815
+ const u = h.lods[h.max_count - 1];
816
+ R && console.log(`First Texture LOD ${i.texture_lod} (${u.max_height}px) - ${e.name}`);
816
817
  }
817
818
  } else {
818
- const f = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
819
+ const u = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
819
820
  let w = s.lastScreenCoverage * 4;
820
- ((P = this.context) == null ? void 0 : P.engine) === "model-viewer" && (w *= 1.5);
821
- const k = L / window.devicePixelRatio * w;
822
- let E = !1;
823
- for (let G = h.lods.length - 1; G >= 0; G--) {
824
- let v = h.lods[G];
825
- if (!(m && v.max_height >= 2048) && !(et() && v.max_height > 4096) && (v.max_height > k || !E && G === 0)) {
826
- if (E = !0, i.texture_lod = G, i.texture_lod < s.lastLodLevel_Texture) {
821
+ ((k = this.context) == null ? void 0 : k.engine) === "model-viewer" && (w *= 1.5);
822
+ const B = L / window.devicePixelRatio * w;
823
+ let T = !1;
824
+ for (let U = h.lods.length - 1; U >= 0; U--) {
825
+ let v = h.lods[U];
826
+ if (!(m && v.max_height >= 2048) && !(rt() && v.max_height > 4096) && (v.max_height > B || !T && U === 0)) {
827
+ if (T = !0, i.texture_lod = U, i.texture_lod < s.lastLodLevel_Texture) {
827
828
  const O = v.max_height;
828
- B && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
829
- Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${f.toFixed(1)}
829
+ R && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
830
+ Screensize: ${B.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${u.toFixed(1)}
830
831
  ${e.name}`);
831
832
  }
832
833
  break;
@@ -837,59 +838,59 @@ ${e.name}`);
837
838
  i.texture_lod = 0;
838
839
  }
839
840
  };
840
- let U = C;
841
+ let V = C;
841
842
  b = /* @__PURE__ */ new WeakMap();
842
- V = /* @__PURE__ */ new WeakMap();
843
- we = /* @__PURE__ */ new WeakMap();
844
- Q = /* @__PURE__ */ new WeakMap();
845
- re = /* @__PURE__ */ new WeakMap();
846
- de = /* @__PURE__ */ new WeakMap();
847
843
  q = /* @__PURE__ */ new WeakMap();
848
- U.corner0 = new F();
849
- U.corner1 = new F();
850
- U.corner2 = new F();
851
- U.corner3 = new F();
852
- U._tempPtInside = new F();
853
- class at {
844
+ Oe = /* @__PURE__ */ new WeakMap();
845
+ Z = /* @__PURE__ */ new WeakMap();
846
+ ie = /* @__PURE__ */ new WeakMap();
847
+ de = /* @__PURE__ */ new WeakMap();
848
+ Y = /* @__PURE__ */ new WeakMap();
849
+ V.corner0 = new z();
850
+ V.corner1 = new z();
851
+ V.corner2 = new z();
852
+ V.corner3 = new z();
853
+ V._tempPtInside = new z();
854
+ class ft {
854
855
  constructor() {
855
- this.frames = 0, this.lastLodLevel_Mesh = -1, this.lastLodLevel_Texture = -1, this.lastScreenCoverage = 0, this.lastScreenspaceVolume = new F(), this.lastCentrality = 0;
856
+ this.frames = 0, this.lastLodLevel_Mesh = -1, this.lastLodLevel_Texture = -1, this.lastScreenCoverage = 0, this.lastScreenspaceVolume = new z(), this.lastCentrality = 0;
856
857
  }
857
858
  }
858
- const Te = Symbol("NEEDLE_mesh_lod"), fe = Symbol("NEEDLE_texture_lod");
859
- let se = null;
860
- function Ne() {
861
- const t = lt();
859
+ const Ae = Symbol("NEEDLE_mesh_lod"), ue = Symbol("NEEDLE_texture_lod");
860
+ let re = null;
861
+ function $e() {
862
+ const t = ut();
862
863
  t && (t.mapURLs(function(e) {
863
- return Ae(), e;
864
- }), Ae(), se == null || se.disconnect(), se = new MutationObserver((e) => {
864
+ return Pe(), e;
865
+ }), Pe(), re == null || re.disconnect(), re = new MutationObserver((e) => {
865
866
  e.forEach((s) => {
866
867
  s.addedNodes.forEach((n) => {
867
- n instanceof HTMLElement && n.tagName.toLowerCase() === "model-viewer" && $e(n);
868
+ n instanceof HTMLElement && n.tagName.toLowerCase() === "model-viewer" && Ne(n);
868
869
  });
869
870
  });
870
- }), se.observe(document, { childList: !0, subtree: !0 }));
871
+ }), re.observe(document, { childList: !0, subtree: !0 }));
871
872
  }
872
- function lt() {
873
+ function ut() {
873
874
  if (typeof customElements > "u")
874
875
  return null;
875
876
  const t = customElements.get("model-viewer");
876
877
  return t || (customElements.whenDefined("model-viewer").then(() => {
877
- console.debug("[gltf-progressive] model-viewer defined"), Ne();
878
+ console.debug("[gltf-progressive] model-viewer defined"), $e();
878
879
  }), null);
879
880
  }
880
- function Ae() {
881
+ function Pe() {
881
882
  if (typeof document > "u")
882
883
  return;
883
884
  document.querySelectorAll("model-viewer").forEach((e) => {
884
- $e(e);
885
+ Ne(e);
885
886
  });
886
887
  }
887
888
  const Ce = /* @__PURE__ */ new WeakSet();
888
- let ct = 0;
889
- function $e(t) {
889
+ let dt = 0;
890
+ function Ne(t) {
890
891
  if (!t || Ce.has(t))
891
892
  return null;
892
- Ce.add(t), console.debug("[gltf-progressive] found new model-viewer..." + ++ct + `
893
+ Ce.add(t), console.debug("[gltf-progressive] found new model-viewer..." + ++dt + `
893
894
  `, t.getAttribute("src"));
894
895
  let e = null, s = null, n = null;
895
896
  for (let i = t; i != null; i = Object.getPrototypeOf(i)) {
@@ -909,8 +910,8 @@ function $e(t) {
909
910
  }
910
911
  };
911
912
  console.debug("[gltf-progressive] setup model-viewer");
912
- const r = U.get(e, { engine: "model-viewer" });
913
- return U.addPlugin(new ut()), r.enable(), r.addEventListener("changed", () => {
913
+ const r = V.get(e, { engine: "model-viewer" });
914
+ return V.addPlugin(new ht()), r.enable(), r.addEventListener("changed", () => {
914
915
  n == null || n.call(t);
915
916
  }), t.addEventListener("model-visibility", (o) => {
916
917
  o.detail.visible && (n == null || n.call(t));
@@ -922,7 +923,7 @@ function $e(t) {
922
923
  }
923
924
  return null;
924
925
  }
925
- class ut {
926
+ class ht {
926
927
  constructor() {
927
928
  this._didWarnAboutMissingUrl = !1;
928
929
  }
@@ -942,31 +943,31 @@ class ut {
942
943
  return e.element;
943
944
  }
944
945
  tryParseTextureLOD(e, s) {
945
- if (s[fe] == !0)
946
+ if (s[ue] == !0)
946
947
  return;
947
- s[fe] = !0;
948
+ s[ue] = !0;
948
949
  const n = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), r = this.getUrl(i);
949
950
  if (r && n && s.material) {
950
951
  let o = function(c) {
951
952
  var d, h, x;
952
- if (c[fe] == !0)
953
+ if (c[ue] == !0)
953
954
  return;
954
- c[fe] = !0, c.userData && (c.userData.LOD = -1);
955
+ c[ue] = !0, c.userData && (c.userData.LOD = -1);
955
956
  const l = Object.keys(c);
956
957
  for (let L = 0; L < l.length; L++) {
957
- const M = l[L], P = c[M];
958
- if ((P == null ? void 0 : P.isTexture) === !0) {
959
- const m = (h = (d = P.userData) == null ? void 0 : d.associations) == null ? void 0 : h.textures;
958
+ const D = l[L], k = c[D];
959
+ if ((k == null ? void 0 : k.isTexture) === !0) {
960
+ const m = (h = (d = k.userData) == null ? void 0 : d.associations) == null ? void 0 : h.textures;
960
961
  if (m == null)
961
962
  continue;
962
- const f = n.parser.json.textures[m];
963
- if (!f) {
963
+ const u = n.parser.json.textures[m];
964
+ if (!u) {
964
965
  console.warn("Texture data not found for texture index " + m);
965
966
  continue;
966
967
  }
967
- if ((x = f == null ? void 0 : f.extensions) != null && x[$]) {
968
- const w = f.extensions[$];
969
- w && r && A.registerTexture(r, P, w.lods.length, m, w);
968
+ if ((x = u == null ? void 0 : u.extensions) != null && x[W]) {
969
+ const w = u.extensions[W];
970
+ w && r && P.registerTexture(r, k, w.lods.length, m, w);
970
971
  }
971
972
  }
972
973
  }
@@ -981,36 +982,36 @@ class ut {
981
982
  }
982
983
  tryParseMeshLOD(e, s) {
983
984
  var o, a;
984
- if (s[Te] == !0)
985
+ if (s[Ae] == !0)
985
986
  return;
986
- s[Te] = !0;
987
+ s[Ae] = !0;
987
988
  const n = this.tryGetCurrentModelViewer(e), i = this.getUrl(n);
988
989
  if (!i)
989
990
  return;
990
- const r = (a = (o = s.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : a[$];
991
+ const r = (a = (o = s.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : a[W];
991
992
  if (r && i) {
992
993
  const c = s.uuid;
993
- A.registerMesh(i, c, s, 0, r.lods.length, r);
994
+ P.registerMesh(i, c, s, 0, r.lods.length, r);
994
995
  }
995
996
  }
996
997
  }
997
- function ft(t, e, s, n) {
998
+ function gt(t, e, s, n) {
998
999
  Be(e), Re(s), Ie(s, {
999
1000
  progressive: !0,
1000
1001
  ...n == null ? void 0 : n.hints
1001
- }), s.register((r) => new A(r, t));
1002
- const i = U.get(e);
1002
+ }), s.register((r) => new P(r, t));
1003
+ const i = V.get(e);
1003
1004
  return (n == null ? void 0 : n.enableLODsManager) !== !1 && i.enable(), i;
1004
1005
  }
1005
- Ne();
1006
- if (!tt) {
1006
+ $e();
1007
+ if (!it) {
1007
1008
  const t = {
1008
1009
  gltfProgressive: {
1009
- useNeedleProgressive: ft,
1010
- LODsManager: U,
1010
+ useNeedleProgressive: gt,
1011
+ LODsManager: V,
1011
1012
  configureLoader: Ie,
1012
1013
  getRaycastMesh: ae,
1013
- useRaycastMeshes: rt
1014
+ useRaycastMeshes: ot
1014
1015
  }
1015
1016
  };
1016
1017
  if (!globalThis.Needle)
@@ -1020,12 +1021,12 @@ if (!tt) {
1020
1021
  globalThis.Needle[e] = t[e];
1021
1022
  }
1022
1023
  export {
1023
- U as L,
1024
- A as N,
1024
+ V as L,
1025
+ P as N,
1025
1026
  Re as a,
1026
1027
  Ie as b,
1027
1028
  Be as c,
1028
- pt as d,
1029
+ et as d,
1029
1030
  ae as g,
1030
- gt as s
1031
+ je as s
1031
1032
  };