@needle-tools/engine 4.1.0-beta → 4.1.0-beta.2

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 (85) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/components.needle.json +1 -1
  3. package/dist/gltf-progressive.js +103 -102
  4. package/dist/gltf-progressive.light.js +103 -102
  5. package/dist/gltf-progressive.light.min.js +6 -6
  6. package/dist/gltf-progressive.light.umd.cjs +6 -6
  7. package/dist/gltf-progressive.min.js +6 -6
  8. package/dist/gltf-progressive.umd.cjs +6 -6
  9. package/dist/needle-engine.bundle.js +7820 -7561
  10. package/dist/needle-engine.bundle.light.js +7773 -7514
  11. package/dist/needle-engine.bundle.light.min.js +131 -132
  12. package/dist/needle-engine.bundle.light.umd.cjs +134 -135
  13. package/dist/needle-engine.bundle.min.js +131 -132
  14. package/dist/needle-engine.bundle.umd.cjs +134 -135
  15. package/dist/needle-engine.js +596 -590
  16. package/dist/needle-engine.light.js +596 -590
  17. package/dist/needle-engine.light.min.js +1 -1
  18. package/dist/needle-engine.light.umd.cjs +1 -1
  19. package/dist/needle-engine.min.js +1 -1
  20. package/dist/needle-engine.umd.cjs +1 -1
  21. package/dist/three-examples.js +26 -26
  22. package/dist/three-examples.light.js +26 -26
  23. package/dist/three-examples.light.min.js +1 -1
  24. package/dist/three-examples.light.umd.cjs +1 -1
  25. package/dist/three-examples.min.js +1 -1
  26. package/dist/three-examples.umd.cjs +1 -1
  27. package/dist/vendor.js +0 -2
  28. package/dist/vendor.light.js +0 -2
  29. package/dist/vendor.light.min.js +2 -2
  30. package/dist/vendor.light.umd.cjs +2 -2
  31. package/dist/vendor.min.js +2 -2
  32. package/dist/vendor.umd.cjs +2 -2
  33. package/lib/engine/engine.d.ts +4 -0
  34. package/lib/engine/engine.js +12 -0
  35. package/lib/engine/engine.js.map +1 -0
  36. package/lib/engine/engine_web_api.d.ts +12 -0
  37. package/lib/engine/engine_web_api.js +113 -0
  38. package/lib/engine/engine_web_api.js.map +1 -0
  39. package/lib/engine/xr/NeedleXRSession.js +3 -0
  40. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  41. package/lib/engine-components/FlyControls.d.ts +10 -0
  42. package/lib/engine-components/FlyControls.js +29 -0
  43. package/lib/engine-components/FlyControls.js.map +1 -0
  44. package/lib/engine-components/GroundProjection.d.ts +1 -1
  45. package/lib/engine-components/GroundProjection.js +39 -32
  46. package/lib/engine-components/GroundProjection.js.map +1 -1
  47. package/lib/engine-components/OrbitControls.js +8 -0
  48. package/lib/engine-components/OrbitControls.js.map +1 -1
  49. package/lib/engine-components/RigidBody.js +10 -4
  50. package/lib/engine-components/RigidBody.js.map +1 -1
  51. package/lib/engine-components/SpatialTrigger.d.ts +2 -2
  52. package/lib/engine-components/SpatialTrigger.js +4 -4
  53. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  54. package/lib/engine-components/TransformGizmo.d.ts +7 -1
  55. package/lib/engine-components/TransformGizmo.js +39 -32
  56. package/lib/engine-components/TransformGizmo.js.map +1 -1
  57. package/lib/engine-components/VideoPlayer.js +0 -1
  58. package/lib/engine-components/VideoPlayer.js.map +1 -1
  59. package/lib/engine-components/particlesystem/ParticleSystemModules.js +1 -1
  60. package/lib/engine-components/particlesystem/ParticleSystemModules.js.map +1 -1
  61. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +2 -0
  62. package/lib/engine-components/postprocessing/Effects/Sharpening.js +15 -6
  63. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  64. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +4 -0
  65. package/lib/engine-components/webxr/WebXRImageTracking.js +14 -4
  66. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  67. package/lib/engine-components/webxr/WebXRRig.d.ts +11 -1
  68. package/lib/engine-components/webxr/WebXRRig.js +13 -1
  69. package/lib/engine-components/webxr/WebXRRig.js.map +1 -1
  70. package/lib/needle-engine.js +5 -5
  71. package/lib/needle-engine.js.map +1 -1
  72. package/package.json +3 -3
  73. package/src/engine/codegen/register_types.ts +2 -2
  74. package/src/engine/xr/NeedleXRSession.ts +3 -0
  75. package/src/engine-components/GroundProjection.ts +46 -38
  76. package/src/engine-components/OrbitControls.ts +8 -0
  77. package/src/engine-components/RigidBody.ts +11 -5
  78. package/src/engine-components/SpatialTrigger.ts +6 -6
  79. package/src/engine-components/TransformGizmo.ts +41 -33
  80. package/src/engine-components/VideoPlayer.ts +0 -1
  81. package/src/engine-components/particlesystem/ParticleSystemModules.ts +1 -1
  82. package/src/engine-components/postprocessing/Effects/Sharpening.ts +16 -7
  83. package/src/engine-components/webxr/WebXRImageTracking.ts +18 -4
  84. package/src/engine-components/webxr/WebXRRig.ts +15 -2
  85. package/src/needle-engine.ts +5 -5
@@ -1,4 +1,4 @@
1
- import { B as he, M as H, a as We, T as j, b as ze, V as $, c as Se, S as Ve, d as be, e as qe, C as Ke } from "./three.js";
1
+ import { B as he, M as H, a as We, T as j, b as ze, V as F, c as Se, S as Ve, d as be, e as qe, C as Ke } from "./three.js";
2
2
  import { D as Xe, K as Ye, G as Oe, M as He } from "./three-examples.js";
3
3
  const Pe = "";
4
4
  globalThis.GLTF_PROGRESSIVE_VERSION = Pe;
@@ -104,7 +104,7 @@ function nt(t) {
104
104
  e.setAttribute(s, t.getAttribute(s));
105
105
  return e.setIndex(t.getIndex()), e;
106
106
  }
107
- const q = new Array(), N = "NEEDLE_progressive", y = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(), we = /* @__PURE__ */ new Set();
107
+ const q = new Array(), $ = "NEEDLE_progressive", y = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(), we = /* @__PURE__ */ new Set();
108
108
  if (y) {
109
109
  let t = function() {
110
110
  e += 1, console.log("Toggle LOD level", e, ie), ie.forEach((i, r) => {
@@ -112,10 +112,10 @@ if (y) {
112
112
  const a = r[o];
113
113
  if (a != null) {
114
114
  if (a.isBufferGeometry === !0) {
115
- const c = S.getMeshLODInformation(a), l = c ? Math.min(e, c.lods.length) : 0;
116
- r["DEBUG:LOD"] = e, S.assignMeshLOD(r, l), c && (s = Math.max(s, c.lods.length - 1));
115
+ const c = b.getMeshLODInformation(a), l = c ? Math.min(e, c.lods.length) : 0;
116
+ r["DEBUG:LOD"] = e, b.assignMeshLOD(r, l), c && (s = Math.max(s, c.lods.length - 1));
117
117
  } else if (r.isMaterial === !0) {
118
- r["DEBUG:LOD"] = e, S.assignTextureLOD(r, e);
118
+ r["DEBUG:LOD"] = e, b.assignTextureLOD(r, e);
119
119
  break;
120
120
  }
121
121
  }
@@ -142,7 +142,7 @@ const D = class {
142
142
  var i, r;
143
143
  if (this._isLoadingMesh)
144
144
  return null;
145
- const n = (r = (i = this.parser.json.meshes[s]) == null ? void 0 : i.extensions) == null ? void 0 : r[N];
145
+ const n = (r = (i = this.parser.json.meshes[s]) == null ? void 0 : i.extensions) == null ? void 0 : r[$];
146
146
  return n ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", s).then((o) => {
147
147
  var a;
148
148
  return this._isLoadingMesh = !1, o && D.registerMesh(this.url, n.guid, o, (a = n.lods) == null ? void 0 : a.length, void 0, n), o;
@@ -151,7 +151,7 @@ const D = class {
151
151
  }
152
152
  /** The name of the extension */
153
153
  get name() {
154
- return N;
154
+ return $;
155
155
  }
156
156
  static getMeshLODInformation(t) {
157
157
  const e = this.getAssignedLODInformation(t);
@@ -351,7 +351,7 @@ const D = class {
351
351
  return y && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, i) => {
352
352
  var r;
353
353
  if (n != null && n.extensions) {
354
- const o = n == null ? void 0 : n.extensions[N];
354
+ const o = n == null ? void 0 : n.extensions[$];
355
355
  if (o) {
356
356
  if (!o.lods) {
357
357
  y && console.warn("Texture has no LODs", o);
@@ -371,7 +371,7 @@ const D = class {
371
371
  }
372
372
  }), (s = this.parser.json.meshes) == null || s.forEach((n, i) => {
373
373
  if (n != null && n.extensions) {
374
- const r = n == null ? void 0 : n.extensions[N];
374
+ const r = n == null ? void 0 : n.extensions[$];
375
375
  if (r && r.lods) {
376
376
  for (const o of this.parser.associations.keys())
377
377
  if (o.isMesh) {
@@ -411,73 +411,73 @@ const D = class {
411
411
  if (L !== void 0) {
412
412
  s && console.log(`LOD ${e} was already loading/loaded: ${m}`);
413
413
  let f = await L.catch((I) => (console.error(`Error loading LOD ${e} from ${h}
414
- `, I), null)), w = !1;
415
- 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(m)) : f instanceof he && t instanceof he && ((l = f.attributes.position) != null && l.array || (w = !0, this.previouslyLoaded.delete(m)))), !w)
414
+ `, I), null)), v = !1;
415
+ 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) : (v = !0, this.previouslyLoaded.delete(m)) : f instanceof he && t instanceof he && ((l = f.attributes.position) != null && l.array || (v = !0, this.previouslyLoaded.delete(m)))), !v)
416
416
  return f;
417
417
  }
418
- const M = r, P = new Promise(async (f, w) => {
418
+ const M = r, P = new Promise(async (f, v) => {
419
419
  const I = new Oe();
420
- Re(I), y && (await new Promise((T) => setTimeout(T, 1e3)), s && console.warn("Start loading (delayed) " + h, M.guid));
420
+ Re(I), y && (await new Promise((O) => setTimeout(O, 1e3)), s && console.warn("Start loading (delayed) " + h, M.guid));
421
421
  let k = h;
422
422
  if (M && Array.isArray(M.lods)) {
423
- const T = M.lods[e];
424
- T.hash && (k += "?v=" + T.hash);
423
+ const O = M.lods[e];
424
+ O.hash && (k += "?v=" + O.hash);
425
425
  }
426
- const v = await I.loadAsync(k).catch((T) => (console.error(`Error loading LOD ${e} from ${h}
427
- `, T), null));
428
- if (!v)
426
+ const T = await I.loadAsync(k).catch((O) => (console.error(`Error loading LOD ${e} from ${h}
427
+ `, O), null));
428
+ if (!T)
429
429
  return null;
430
- const U = v.parser;
430
+ const G = T.parser;
431
431
  s && console.log("Loading finished " + h, M.guid);
432
- let E = 0;
433
- if (v.parser.json.textures) {
434
- let T = !1;
435
- for (const u of v.parser.json.textures) {
432
+ let w = 0;
433
+ if (T.parser.json.textures) {
434
+ let O = !1;
435
+ for (const u of T.parser.json.textures) {
436
436
  if (u != null && u.extensions) {
437
- const g = u == null ? void 0 : u.extensions[N];
437
+ const g = u == null ? void 0 : u.extensions[$];
438
438
  if (g != null && g.guid && g.guid === M.guid) {
439
- T = !0;
439
+ O = !0;
440
440
  break;
441
441
  }
442
442
  }
443
- E++;
443
+ w++;
444
444
  }
445
- if (T) {
446
- let u = await U.getDependency("texture", E);
447
- return u && D.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h, E, u, m), t instanceof j && (u = this.copySettings(t, u)), u && (u.guid = M.guid), f(u);
445
+ if (O) {
446
+ let u = await G.getDependency("texture", w);
447
+ return u && D.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h, w, u, m), t instanceof j && (u = this.copySettings(t, u)), u && (u.guid = M.guid), f(u);
448
448
  } else
449
- y && console.warn("Could not find texture with guid", M.guid, v.parser.json);
449
+ y && console.warn("Could not find texture with guid", M.guid, T.parser.json);
450
450
  }
451
- if (E = 0, v.parser.json.meshes) {
452
- let T = !1;
453
- for (const u of v.parser.json.meshes) {
451
+ if (w = 0, T.parser.json.meshes) {
452
+ let O = !1;
453
+ for (const u of T.parser.json.meshes) {
454
454
  if (u != null && u.extensions) {
455
- const g = u == null ? void 0 : u.extensions[N];
455
+ const g = u == null ? void 0 : u.extensions[$];
456
456
  if (g != null && g.guid && g.guid === M.guid) {
457
- T = !0;
457
+ O = !0;
458
458
  break;
459
459
  }
460
460
  }
461
- E++;
461
+ w++;
462
462
  }
463
- if (T) {
464
- const u = await U.getDependency("mesh", E), g = M;
465
- if (s && console.log(`Loaded Mesh "${u.name}"`, h, E, u, m), u.isMesh === !0) {
463
+ if (O) {
464
+ const u = await G.getDependency("mesh", w), g = M;
465
+ if (s && console.log(`Loaded Mesh "${u.name}"`, h, w, u, m), u.isMesh === !0) {
466
466
  const _ = u.geometry;
467
467
  return D.assignLODInformation(n.url, _, i, e, void 0, g.density), f(_);
468
468
  } else {
469
469
  const _ = new Array();
470
- for (let O = 0; O < u.children.length; O++) {
471
- const A = u.children[O];
470
+ for (let S = 0; S < u.children.length; S++) {
471
+ const A = u.children[S];
472
472
  if (A.isMesh === !0) {
473
473
  const W = A.geometry;
474
- D.assignLODInformation(n.url, W, i, e, O, g.density), _.push(W);
474
+ D.assignLODInformation(n.url, W, i, e, S, g.density), _.push(W);
475
475
  }
476
476
  }
477
477
  return f(_);
478
478
  }
479
479
  } else
480
- y && console.warn("Could not find mesh with guid", M.guid, v.parser.json);
480
+ y && console.warn("Could not find mesh with guid", M.guid, T.parser.json);
481
481
  }
482
482
  return f(null);
483
483
  });
@@ -509,8 +509,8 @@ const D = class {
509
509
  `, e.uuid), e.offset = t.offset, e.repeat = t.repeat, e.colorSpace = t.colorSpace, e.magFilter = t.magFilter, e.minFilter = t.minFilter, e.wrapS = t.wrapS, e.wrapT = t.wrapT, e.flipY = t.flipY, e.anisotropy = t.anisotropy, e.mipmaps || (e.generateMipmaps = t.generateMipmaps), e;
510
510
  }
511
511
  };
512
- let S = D;
513
- S.registerTexture = (t, e, s, n, i) => {
512
+ let b = D;
513
+ b.registerTexture = (t, e, s, n, i) => {
514
514
  if (y && console.log("> Progressive: register texture", n, e.name, e.uuid, e, i), !e) {
515
515
  y && console.error("gltf-progressive: Register texture without texture");
516
516
  return;
@@ -519,7 +519,7 @@ S.registerTexture = (t, e, s, n, i) => {
519
519
  const r = i.guid;
520
520
  D.assignLODInformation(t, e, r, s, n, void 0), D.lodInfos.set(r, i), D.lowresCache.set(r, e);
521
521
  };
522
- S.registerMesh = (t, e, s, n, i, r) => {
522
+ b.registerMesh = (t, e, s, n, i, r) => {
523
523
  var c;
524
524
  y && console.log("> Progressive: register mesh", i, s.name, r, s.uuid, s);
525
525
  const o = s.geometry;
@@ -533,9 +533,9 @@ S.registerMesh = (t, e, s, n, i, r) => {
533
533
  for (const l of q)
534
534
  (c = l.onRegisteredNewMesh) == null || c.call(l, s, r);
535
535
  };
536
- S.lodInfos = /* @__PURE__ */ new Map();
537
- S.previouslyLoaded = /* @__PURE__ */ new Map();
538
- S.lowresCache = /* @__PURE__ */ new Map();
536
+ b.lodInfos = /* @__PURE__ */ new Map();
537
+ b.previouslyLoaded = /* @__PURE__ */ new Map();
538
+ b.lowresCache = /* @__PURE__ */ new Map();
539
539
  class ot {
540
540
  constructor(e, s, n, i, r) {
541
541
  this.url = e, this.key = s, this.level = n, i != null && (this.index = i), r != null && (this.density = r);
@@ -548,11 +548,11 @@ var Ge = (t, e, s) => {
548
548
  if (e.has(t))
549
549
  throw TypeError("Cannot add the same private member more than once");
550
550
  e instanceof WeakSet ? e.add(t) : e.set(t, s);
551
- }, G = (t, e, s, n) => (Ge(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b, z, ve, Q, re, de, V;
551
+ }, N = (t, e, s, n) => (Ge(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), E, z, ve, Q, re, de, V;
552
552
  const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"), J = Symbol("Needle:CurrentLOD"), R = { mesh_lod: -1, texture_lod: -1 }, C = class {
553
553
  // readonly plugins: NEEDLE_progressive_plugin[] = [];
554
554
  constructor(t, e) {
555
- this.projectionScreenMatrix = new Se(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", K(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], K(this, z, void 0), K(this, ve, new Ke()), K(this, Q, 0), K(this, re, 0), K(this, de, 0), K(this, V, 0), this._fpsBuffer = [60, 60, 60, 60, 60], this._sphere = new Ve(), this._tempBox = new be(), this._tempBox2 = new be(), this.tempMatrix = new Se(), this._tempWorldPosition = new $(), this._tempBoxSize = new $(), this._tempBox2Size = new $(), this.renderer = t, this.context = { ...e };
555
+ this.projectionScreenMatrix = new Se(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", K(this, E, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], K(this, z, void 0), K(this, ve, new Ke()), K(this, Q, 0), K(this, re, 0), K(this, de, 0), K(this, V, 0), this._fpsBuffer = [60, 60, 60, 60, 60], this._sphere = new Ve(), 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 };
556
556
  }
557
557
  /** @internal */
558
558
  static getObjectLODState(t) {
@@ -600,17 +600,17 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
600
600
  return;
601
601
  console.debug("[gltf-progressive] Enabling LODsManager for renderer");
602
602
  let t = 0;
603
- G(this, z, this.renderer.render);
603
+ N(this, z, this.renderer.render);
604
604
  const e = this;
605
605
  Be(this.renderer), this.renderer.render = function(s, n) {
606
606
  const i = e.renderer.getRenderTarget();
607
- (i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, G(e, Q, p(e, Q) + 1), G(e, re, p(e, ve).getDelta()), G(e, de, p(e, de) + p(e, re)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / p(e, re)), G(e, V, e._fpsBuffer.reduce((o, a) => o + a) / e._fpsBuffer.length), B && p(e, Q) % 200 === 0 && console.log("FPS", Math.round(p(e, V)), "Interval:", p(e, b)));
607
+ (i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, N(e, Q, p(e, Q) + 1), N(e, re, p(e, ve).getDelta()), N(e, de, p(e, de) + p(e, re)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / p(e, re)), N(e, V, e._fpsBuffer.reduce((o, a) => o + a) / e._fpsBuffer.length), B && p(e, Q) % 200 === 0 && console.log("FPS", Math.round(p(e, V)), "Interval:", p(e, E)));
608
608
  const r = t++;
609
609
  p(e, z).call(this, s, n), e.onAfterRender(s, n, r);
610
610
  };
611
611
  }
612
612
  disable() {
613
- p(this, z) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = p(this, z), G(this, z, void 0));
613
+ p(this, z) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = p(this, z), N(this, z, void 0));
614
614
  }
615
615
  update(t, e) {
616
616
  this.internalUpdate(t, e);
@@ -625,7 +625,7 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
625
625
  (o.name === "EffectMaterial" || o.name === "CopyShader") && (r = !1);
626
626
  }
627
627
  if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (r = !1), r) {
628
- if (at || (this.updateInterval === "auto" ? p(this, V) < 40 && p(this, b) < 10 ? (G(this, b, p(this, b) + 1), B && console.warn("↓ Reducing LOD updates", p(this, b), p(this, V).toFixed(0))) : p(this, V) >= 60 && p(this, b) > 1 && (G(this, b, p(this, b) - 1), B && console.warn("↑ Increasing LOD updates", p(this, b), p(this, V).toFixed(0))) : G(this, b, this.updateInterval), p(this, b) > 0 && p(this, Q) % p(this, b) != 0))
628
+ if (at || (this.updateInterval === "auto" ? p(this, V) < 40 && p(this, E) < 10 ? (N(this, E, p(this, E) + 1), B && console.warn("↓ Reducing LOD updates", p(this, E), p(this, V).toFixed(0))) : p(this, V) >= 60 && p(this, E) > 1 && (N(this, E, p(this, E) - 1), B && console.warn("↑ Increasing LOD updates", p(this, E), p(this, V).toFixed(0))) : N(this, E, this.updateInterval), p(this, E) > 0 && p(this, Q) % p(this, E) != 0))
629
629
  return;
630
630
  this.internalUpdate(t, e);
631
631
  }
@@ -704,7 +704,7 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
704
704
  return;
705
705
  }
706
706
  let s = !1;
707
- (t[J] === void 0 || e < t[J]) && (s = !0), s && (t[J] = e, S.assignTextureLOD(t, e).then((n) => {
707
+ (t[J] === void 0 || e < t[J]) && (s = !0), s && (t[J] = e, b.assignTextureLOD(t, e).then((n) => {
708
708
  this._lodchangedlisteners.forEach((i) => i({ type: "texture", level: e, object: t }));
709
709
  }));
710
710
  }
@@ -720,7 +720,7 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
720
720
  if (t[J] !== e) {
721
721
  t[J] = e;
722
722
  const s = t.geometry;
723
- return S.assignMeshLOD(t, e).then((n) => (n && t[J] == e && s != t.geometry && this._lodchangedlisteners.forEach((i) => i({ type: "mesh", level: e, object: t })), n));
723
+ return b.assignMeshLOD(t, e).then((n) => (n && t[J] == e && s != t.geometry && this._lodchangedlisteners.forEach((i) => i({ type: "mesh", level: e, object: t })), n));
724
724
  }
725
725
  return Promise.resolve(null);
726
726
  }
@@ -741,7 +741,7 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
741
741
  let o = 10 + 1, a = !1;
742
742
  if (B && e["DEBUG:LOD"] != null)
743
743
  return e["DEBUG:LOD"];
744
- const c = S.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = S.getMaterialMinMaxLODsCount(e.material), m = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
744
+ const c = b.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = b.getMaterialMinMaxLODsCount(e.material), m = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
745
745
  if (!d && !m) {
746
746
  i.mesh_lod = 0, i.texture_lod = 0;
747
747
  return;
@@ -754,8 +754,8 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
754
754
  if (!x.boundingBox)
755
755
  x.computeBoundingBox();
756
756
  else if (s.frames % 30 === 0) {
757
- const f = ae(x), w = x.geometry;
758
- f && (x.geometry = f), x.computeBoundingBox(), x.geometry = w;
757
+ const f = ae(x), v = x.geometry;
758
+ f && (x.geometry = f), x.computeBoundingBox(), x.geometry = v;
759
759
  }
760
760
  M = x.boundingBox;
761
761
  }
@@ -775,35 +775,35 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
775
775
  }
776
776
  if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && x.fov > 70) {
777
777
  const u = this._tempBox.min, g = this._tempBox.max;
778
- let _ = u.x, O = u.y, A = g.x, W = g.y;
778
+ let _ = u.x, S = u.y, A = g.x, W = g.y;
779
779
  const le = 2, pe = 1.5, ce = (u.x + g.x) * 0.5, ue = (u.y + g.y) * 0.5;
780
- _ = (_ - ce) * le + ce, O = (O - ue) * le + ue, A = (A - ce) * le + ce, W = (W - ue) * le + ue;
781
- const Fe = _ < 0 && A > 0 ? 0 : Math.min(Math.abs(u.x), Math.abs(g.x)), Ue = O < 0 && W > 0 ? 0 : Math.min(Math.abs(u.y), Math.abs(g.y)), ye = Math.max(Fe, Ue);
780
+ _ = (_ - ce) * le + ce, S = (S - ue) * le + ue, A = (A - ce) * le + ce, W = (W - ue) * le + ue;
781
+ const Fe = _ < 0 && A > 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);
782
782
  s.lastCentrality = (pe - ye) * (pe - ye) * (pe - ye);
783
783
  } else
784
784
  s.lastCentrality = 1;
785
785
  const f = this._tempBox.getSize(this._tempBoxSize);
786
786
  f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), f.x *= x.aspect;
787
- const w = t.matrixWorldInverse, I = this._tempBox2;
788
- I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(w);
789
- const k = I.getSize(this._tempBox2Size), v = Math.max(k.x, k.y);
790
- if (Math.max(f.x, f.y) != 0 && v != 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) {
787
+ const v = t.matrixWorldInverse, I = this._tempBox2;
788
+ I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(v);
789
+ const k = I.getSize(this._tempBox2Size), T = Math.max(k.x, k.y);
790
+ if (Math.max(f.x, f.y) != 0 && T != 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) {
791
791
  const u = this.tempMatrix.copy(this.projectionScreenMatrix);
792
792
  u.invert();
793
- const g = C.corner0, _ = C.corner1, O = C.corner2, A = C.corner3;
794
- g.copy(this._tempBox.min), _.copy(this._tempBox.max), _.x = g.x, O.copy(this._tempBox.max), O.y = g.y, A.copy(this._tempBox.max);
793
+ const g = C.corner0, _ = C.corner1, S = C.corner2, A = C.corner3;
794
+ g.copy(this._tempBox.min), _.copy(this._tempBox.max), _.x = g.x, S.copy(this._tempBox.max), S.y = g.y, A.copy(this._tempBox.max);
795
795
  const W = (g.z + A.z) * 0.5;
796
- g.z = _.z = O.z = A.z = W, g.applyMatrix4(u), _.applyMatrix4(u), O.applyMatrix4(u), A.applyMatrix4(u), C.debugDrawLine(g, _, 255), C.debugDrawLine(g, O, 255), C.debugDrawLine(_, A, 255), C.debugDrawLine(O, A, 255);
796
+ g.z = _.z = S.z = A.z = W, g.applyMatrix4(u), _.applyMatrix4(u), S.applyMatrix4(u), A.applyMatrix4(u), C.debugDrawLine(g, _, 255), C.debugDrawLine(g, S, 255), C.debugDrawLine(_, A, 255), C.debugDrawLine(S, A, 255);
797
797
  }
798
- let E = 999;
798
+ let w = 999;
799
799
  if (l && s.lastScreenCoverage > 0) {
800
800
  for (let u = 0; u < l.length; u++)
801
801
  if (l[u].density / s.lastScreenCoverage < n) {
802
- E = u;
802
+ w = u;
803
803
  break;
804
804
  }
805
805
  }
806
- E < o && (o = E, a = !0);
806
+ w < o && (o = w, a = !0);
807
807
  }
808
808
  if (a ? i.mesh_lod = o : i.mesh_lod = s.lastLodLevel_Mesh, B && i.mesh_lod != s.lastLodLevel_Mesh) {
809
809
  const f = l == null ? void 0 : l[i.mesh_lod];
@@ -818,15 +818,16 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
818
818
  }
819
819
  } else {
820
820
  const f = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
821
- let w = s.lastScreenCoverage * 4;
822
- ((P = this.context) == null ? void 0 : P.engine) === "model-viewer" && (w *= 1.5);
823
- const k = L / window.devicePixelRatio * w;
824
- for (let v = h.lods.length - 1; v >= 0; v--) {
825
- let U = h.lods[v];
826
- if (!(x && U.max_height >= 2048) && !(tt() && U.max_height > 4096) && U.max_height > k) {
827
- if (i.texture_lod = v, i.texture_lod < s.lastLodLevel_Texture) {
828
- const E = U.max_height;
829
- B && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${E}px
821
+ let v = s.lastScreenCoverage * 4;
822
+ ((P = this.context) == null ? void 0 : P.engine) === "model-viewer" && (v *= 1.5);
823
+ const k = L / window.devicePixelRatio * v;
824
+ let T = !1;
825
+ for (let G = h.lods.length - 1; G >= 0; G--) {
826
+ let w = h.lods[G];
827
+ if (!(x && w.max_height >= 2048) && !(tt() && w.max_height > 4096) && (w.max_height > k || !T && G === 0)) {
828
+ if (T = !0, i.texture_lod = G, i.texture_lod < s.lastLodLevel_Texture) {
829
+ const O = w.max_height;
830
+ B && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
830
831
  Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${f.toFixed(1)}
831
832
  ${e.name}`);
832
833
  }
@@ -838,22 +839,22 @@ ${e.name}`);
838
839
  i.texture_lod = 0;
839
840
  }
840
841
  };
841
- let F = C;
842
- b = /* @__PURE__ */ new WeakMap();
842
+ let U = C;
843
+ E = /* @__PURE__ */ new WeakMap();
843
844
  z = /* @__PURE__ */ new WeakMap();
844
845
  ve = /* @__PURE__ */ new WeakMap();
845
846
  Q = /* @__PURE__ */ new WeakMap();
846
847
  re = /* @__PURE__ */ new WeakMap();
847
848
  de = /* @__PURE__ */ new WeakMap();
848
849
  V = /* @__PURE__ */ new WeakMap();
849
- F.corner0 = new $();
850
- F.corner1 = new $();
851
- F.corner2 = new $();
852
- F.corner3 = new $();
853
- F._tempPtInside = new $();
850
+ U.corner0 = new F();
851
+ U.corner1 = new F();
852
+ U.corner2 = new F();
853
+ U.corner3 = new F();
854
+ U._tempPtInside = new F();
854
855
  class lt {
855
856
  constructor() {
856
- this.frames = 0, this.lastLodLevel_Mesh = -1, this.lastLodLevel_Texture = -1, this.lastScreenCoverage = 0, this.lastScreenspaceVolume = new $(), this.lastCentrality = 0;
857
+ this.frames = 0, this.lastLodLevel_Mesh = -1, this.lastLodLevel_Texture = -1, this.lastScreenCoverage = 0, this.lastScreenspaceVolume = new F(), this.lastCentrality = 0;
857
858
  }
858
859
  }
859
860
  const Te = Symbol("NEEDLE_mesh_lod"), fe = Symbol("NEEDLE_texture_lod");
@@ -910,8 +911,8 @@ function $e(t) {
910
911
  }
911
912
  };
912
913
  console.debug("[gltf-progressive] setup model-viewer");
913
- const r = F.get(e, { engine: "model-viewer" });
914
- return F.addPlugin(new ft()), r.enable(), r.addEventListener("changed", () => {
914
+ const r = U.get(e, { engine: "model-viewer" });
915
+ return U.addPlugin(new ft()), r.enable(), r.addEventListener("changed", () => {
915
916
  n == null || n.call(t);
916
917
  }), t.addEventListener("model-visibility", (o) => {
917
918
  o.detail.visible && (n == null || n.call(t));
@@ -965,9 +966,9 @@ class ft {
965
966
  console.warn("Texture data not found for texture index " + x);
966
967
  continue;
967
968
  }
968
- if ((m = f == null ? void 0 : f.extensions) != null && m[N]) {
969
- const w = f.extensions[N];
970
- w && r && S.registerTexture(r, P, w.lods.length, x, w);
969
+ if ((m = f == null ? void 0 : f.extensions) != null && m[$]) {
970
+ const v = f.extensions[$];
971
+ v && r && b.registerTexture(r, P, v.lods.length, x, v);
971
972
  }
972
973
  }
973
974
  }
@@ -988,10 +989,10 @@ class ft {
988
989
  const n = this.tryGetCurrentModelViewer(e), i = this.getUrl(n);
989
990
  if (!i)
990
991
  return;
991
- const r = (a = (o = s.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : a[N];
992
+ const r = (a = (o = s.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : a[$];
992
993
  if (r && i) {
993
994
  const c = s.uuid;
994
- S.registerMesh(i, c, s, 0, r.lods.length, r);
995
+ b.registerMesh(i, c, s, 0, r.lods.length, r);
995
996
  }
996
997
  }
997
998
  }
@@ -999,8 +1000,8 @@ function dt(t, e, s, n) {
999
1000
  Be(e), Re(s), Ie(s, {
1000
1001
  progressive: !0,
1001
1002
  ...n == null ? void 0 : n.hints
1002
- }), s.register((r) => new S(r, t));
1003
- const i = F.get(e);
1003
+ }), s.register((r) => new b(r, t));
1004
+ const i = U.get(e);
1004
1005
  return (n == null ? void 0 : n.enableLODsManager) !== !1 && i.enable(), i;
1005
1006
  }
1006
1007
  Ne();
@@ -1008,7 +1009,7 @@ if (!st) {
1008
1009
  const t = {
1009
1010
  gltfProgressive: {
1010
1011
  useNeedleProgressive: dt,
1011
- LODsManager: F,
1012
+ LODsManager: U,
1012
1013
  configureLoader: Ie,
1013
1014
  getRaycastMesh: ae,
1014
1015
  useRaycastMeshes: it
@@ -1021,8 +1022,8 @@ if (!st) {
1021
1022
  globalThis.Needle[e] = t[e];
1022
1023
  }
1023
1024
  export {
1024
- F as L,
1025
- S as N,
1025
+ U as L,
1026
+ b as N,
1026
1027
  Re as a,
1027
1028
  Ie as b,
1028
1029
  Be as c,