@needle-tools/engine 4.1.0-beta.3 → 4.1.0-beta.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.
- package/CHANGELOG.md +29 -18
- package/components.needle.json +1 -1
- package/dist/gltf-progressive.js +59 -59
- package/dist/gltf-progressive.light.js +59 -59
- package/dist/gltf-progressive.light.min.js +6 -6
- package/dist/gltf-progressive.light.umd.cjs +5 -5
- package/dist/gltf-progressive.min.js +6 -6
- package/dist/gltf-progressive.umd.cjs +5 -5
- package/dist/needle-engine.bundle.js +2774 -2753
- package/dist/needle-engine.bundle.light.js +2773 -2752
- package/dist/needle-engine.bundle.light.min.js +110 -110
- package/dist/needle-engine.bundle.light.umd.cjs +101 -101
- package/dist/needle-engine.bundle.min.js +110 -110
- package/dist/needle-engine.bundle.umd.cjs +113 -113
- package/dist/needle-engine.js +202 -201
- package/dist/needle-engine.light.d.ts +14263 -0
- package/dist/needle-engine.light.js +202 -201
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.light.umd.cjs +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three-examples.js +2795 -2436
- package/dist/three-examples.light.js +2795 -2436
- package/dist/three-examples.light.min.js +47 -15
- package/dist/three-examples.light.umd.cjs +47 -15
- package/dist/three-examples.min.js +47 -15
- package/dist/three-examples.umd.cjs +47 -15
- package/dist/three.js +67 -62
- package/dist/three.light.js +67 -62
- package/dist/three.light.min.js +170 -170
- package/dist/three.light.umd.cjs +170 -170
- package/dist/three.min.js +170 -170
- package/dist/three.umd.cjs +170 -170
- package/dist/vendor.js +1 -1
- package/dist/vendor.light.js +1 -1
- package/dist/vendor.light.min.js +1 -1
- package/dist/vendor.min.js +1 -1
- package/lib/engine/engine_context.d.ts +3 -2
- package/lib/engine/engine_context.js +26 -4
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +1 -1
- package/lib/engine/engine_physics_rapier.js +17 -12
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_types.d.ts +1 -1
- package/lib/engine-components/Camera.d.ts +7 -4
- package/lib/engine-components/Camera.js +13 -10
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/Collider.js +4 -5
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +1 -1
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/RigidBody.js +2 -2
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +1 -1
- package/lib/engine-components/export/usdz/index.d.ts +1 -1
- package/lib/engine-components/export/usdz/index.js +1 -1
- package/lib/engine-components/export/usdz/index.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystem.d.ts +5 -6
- package/lib/engine-components/particlesystem/ParticleSystem.js +23 -9
- package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
- package/lib/engine-components/particlesystem/ParticleSystemModules.js +7 -1
- package/lib/engine-components/particlesystem/ParticleSystemModules.js.map +1 -1
- package/package.json +4 -3
- package/src/engine/engine_context.ts +31 -8
- package/src/engine/engine_physics_rapier.ts +20 -10
- package/src/engine/engine_types.ts +1 -1
- package/src/engine-components/Camera.ts +14 -11
- package/src/engine-components/Collider.ts +4 -4
- package/src/engine-components/OrbitControls.ts +1 -1
- package/src/engine-components/RigidBody.ts +2 -2
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +1 -1
- package/src/engine-components/export/usdz/index.ts +1 -1
- package/src/engine-components/particlesystem/ParticleSystem.ts +26 -10
- package/src/engine-components/particlesystem/ParticleSystemModules.ts +9 -2
package/dist/gltf-progressive.js
CHANGED
|
@@ -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(), $ = "NEEDLE_progressive", y = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(),
|
|
107
|
+
const q = new Array(), $ = "NEEDLE_progressive", y = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(), ve = /* @__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) => {
|
|
@@ -123,7 +123,7 @@ if (y) {
|
|
|
123
123
|
}), e >= s && (e = -1);
|
|
124
124
|
}, e = -1, s = 2, n = !1;
|
|
125
125
|
window.addEventListener("keyup", (i) => {
|
|
126
|
-
i.key === "p" && t(), i.key === "w" && (n = !n,
|
|
126
|
+
i.key === "p" && t(), i.key === "w" && (n = !n, ve && ve.forEach((r) => {
|
|
127
127
|
r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = n);
|
|
128
128
|
}));
|
|
129
129
|
});
|
|
@@ -288,7 +288,7 @@ const D = class {
|
|
|
288
288
|
}
|
|
289
289
|
if (t instanceof We || t.isMaterial === !0) {
|
|
290
290
|
const s = t, n = [], i = new Array();
|
|
291
|
-
if (y &&
|
|
291
|
+
if (y && ve.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
292
292
|
const r = s;
|
|
293
293
|
for (const o of Object.keys(r.uniforms)) {
|
|
294
294
|
const a = r.uniforms[o].value;
|
|
@@ -395,9 +395,9 @@ const D = class {
|
|
|
395
395
|
}
|
|
396
396
|
if (r || (r = D.lodInfos.get(i)), r) {
|
|
397
397
|
if (e > 0) {
|
|
398
|
-
let
|
|
398
|
+
let x = !1;
|
|
399
399
|
const L = Array.isArray(r.lods);
|
|
400
|
-
if (L && e >= r.lods.length ?
|
|
400
|
+
if (L && e >= r.lods.length ? x = !0 : L || (x = !0), x)
|
|
401
401
|
return this.lowresCache.get(i);
|
|
402
402
|
}
|
|
403
403
|
const d = Array.isArray(r.lods) ? (o = r.lods[e]) == null ? void 0 : o.path : r.lods;
|
|
@@ -407,15 +407,15 @@ const D = class {
|
|
|
407
407
|
if (h.endsWith(".glb") || h.endsWith(".gltf")) {
|
|
408
408
|
if (!r.guid)
|
|
409
409
|
return console.warn("missing pointer for glb/gltf texture", r), null;
|
|
410
|
-
const
|
|
410
|
+
const x = h + "_" + r.guid, L = this.previouslyLoaded.get(x);
|
|
411
411
|
if (L !== void 0) {
|
|
412
|
-
s && console.log(`LOD ${e} was already loading/loaded: ${
|
|
412
|
+
s && console.log(`LOD ${e} was already loading/loaded: ${x}`);
|
|
413
413
|
let f = await L.catch((I) => (console.error(`Error loading LOD ${e} from ${h}
|
|
414
|
-
`, I), null)),
|
|
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) : (
|
|
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(x)) : f instanceof he && t instanceof he && ((l = f.attributes.position) != null && l.array || (w = !0, this.previouslyLoaded.delete(x)))), !w)
|
|
416
416
|
return f;
|
|
417
417
|
}
|
|
418
|
-
const M = r, P = new Promise(async (f,
|
|
418
|
+
const M = r, P = new Promise(async (f, w) => {
|
|
419
419
|
const I = new Oe();
|
|
420
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;
|
|
@@ -429,7 +429,7 @@ const D = class {
|
|
|
429
429
|
return null;
|
|
430
430
|
const G = T.parser;
|
|
431
431
|
s && console.log("Loading finished " + h, M.guid);
|
|
432
|
-
let
|
|
432
|
+
let v = 0;
|
|
433
433
|
if (T.parser.json.textures) {
|
|
434
434
|
let O = !1;
|
|
435
435
|
for (const u of T.parser.json.textures) {
|
|
@@ -440,15 +440,15 @@ const D = class {
|
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
|
|
443
|
+
v++;
|
|
444
444
|
}
|
|
445
445
|
if (O) {
|
|
446
|
-
let u = await G.getDependency("texture",
|
|
447
|
-
return u && D.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h,
|
|
446
|
+
let u = await G.getDependency("texture", v);
|
|
447
|
+
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);
|
|
448
448
|
} else
|
|
449
449
|
y && console.warn("Could not find texture with guid", M.guid, T.parser.json);
|
|
450
450
|
}
|
|
451
|
-
if (
|
|
451
|
+
if (v = 0, T.parser.json.meshes) {
|
|
452
452
|
let O = !1;
|
|
453
453
|
for (const u of T.parser.json.meshes) {
|
|
454
454
|
if (u != null && u.extensions) {
|
|
@@ -458,11 +458,11 @@ const D = class {
|
|
|
458
458
|
break;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
|
|
461
|
+
v++;
|
|
462
462
|
}
|
|
463
463
|
if (O) {
|
|
464
|
-
const u = await G.getDependency("mesh",
|
|
465
|
-
if (s && console.log(`Loaded Mesh "${u.name}"`, h,
|
|
464
|
+
const u = await G.getDependency("mesh", v), g = M;
|
|
465
|
+
if (s && console.log(`Loaded Mesh "${u.name}"`, h, v, u, x), 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 {
|
|
@@ -481,7 +481,7 @@ const D = class {
|
|
|
481
481
|
}
|
|
482
482
|
return f(null);
|
|
483
483
|
});
|
|
484
|
-
return this.previouslyLoaded.set(
|
|
484
|
+
return this.previouslyLoaded.set(x, P), await P;
|
|
485
485
|
} else if (t instanceof j) {
|
|
486
486
|
s && console.log("Load texture from uri: " + h);
|
|
487
487
|
const L = await new ze().loadAsync(h);
|
|
@@ -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
|
-
}, N = (t, e, s, n) => (Ge(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), E, z,
|
|
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, we, 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, E, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], K(this, z, void 0), K(this,
|
|
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, we, 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) {
|
|
@@ -604,7 +604,7 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
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, N(e, Q, p(e, Q) + 1), N(e, re, p(e,
|
|
607
|
+
(i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, N(e, Q, p(e, Q) + 1), N(e, re, p(e, we).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
|
};
|
|
@@ -654,8 +654,8 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
654
654
|
}
|
|
655
655
|
if (B === "color" && l.material && !l.object.progressive_debug_color) {
|
|
656
656
|
l.object.progressive_debug_color = !0;
|
|
657
|
-
const h = Math.random() * 16777215,
|
|
658
|
-
l.object.material =
|
|
657
|
+
const h = Math.random() * 16777215, x = new qe({ color: h });
|
|
658
|
+
l.object.material = x;
|
|
659
659
|
}
|
|
660
660
|
const d = l.object;
|
|
661
661
|
(d instanceof H || d.isMesh) && this.updateLODs(t, e, d, i);
|
|
@@ -741,8 +741,8 @@ 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 = b.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = b.getMaterialMinMaxLODsCount(e.material),
|
|
745
|
-
if (!d && !
|
|
744
|
+
const c = b.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = b.getMaterialMinMaxLODsCount(e.material), x = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
|
|
745
|
+
if (!d && !x) {
|
|
746
746
|
i.mesh_lod = 0, i.texture_lod = 0;
|
|
747
747
|
return;
|
|
748
748
|
}
|
|
@@ -750,17 +750,17 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
750
750
|
const L = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
751
751
|
let M = e.geometry.boundingBox;
|
|
752
752
|
if (e.type === "SkinnedMesh") {
|
|
753
|
-
const
|
|
754
|
-
if (!
|
|
755
|
-
|
|
753
|
+
const m = e;
|
|
754
|
+
if (!m.boundingBox)
|
|
755
|
+
m.computeBoundingBox();
|
|
756
756
|
else if (s.frames % 30 === 0) {
|
|
757
|
-
const f = ae(
|
|
758
|
-
f && (
|
|
757
|
+
const f = ae(m), w = m.geometry;
|
|
758
|
+
f && (m.geometry = f), m.computeBoundingBox(), m.geometry = w;
|
|
759
759
|
}
|
|
760
|
-
M =
|
|
760
|
+
M = m.boundingBox;
|
|
761
761
|
}
|
|
762
|
-
if (M
|
|
763
|
-
const
|
|
762
|
+
if (M) {
|
|
763
|
+
const m = t;
|
|
764
764
|
if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
|
|
765
765
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
766
766
|
const u = t.getWorldPosition(this._tempWorldPosition);
|
|
@@ -769,11 +769,11 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
if (this._tempBox.copy(M), this._tempBox.applyMatrix4(e.matrixWorld), C.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
772
|
+
if (this._tempBox.copy(M), this._tempBox.applyMatrix4(e.matrixWorld), m.isPerspectiveCamera && C.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
773
773
|
i.mesh_lod = 0, i.texture_lod = 0;
|
|
774
774
|
return;
|
|
775
775
|
}
|
|
776
|
-
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled &&
|
|
776
|
+
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && m.isPerspectiveCamera && m.fov > 70) {
|
|
777
777
|
const u = this._tempBox.min, g = this._tempBox.max;
|
|
778
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;
|
|
@@ -783,9 +783,9 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
783
783
|
} else
|
|
784
784
|
s.lastCentrality = 1;
|
|
785
785
|
const f = this._tempBox.getSize(this._tempBoxSize);
|
|
786
|
-
f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), f.x *=
|
|
787
|
-
const
|
|
788
|
-
I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(
|
|
786
|
+
f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), t.isPerspectiveCamera ? f.x *= t.aspect : t.isOrthographicCamera;
|
|
787
|
+
const w = t.matrixWorldInverse, I = this._tempBox2;
|
|
788
|
+
I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(w);
|
|
789
789
|
const k = I.getSize(this._tempBox2Size), T = Math.max(k.x, k.y);
|
|
790
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);
|
|
@@ -795,22 +795,22 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
795
795
|
const W = (g.z + A.z) * 0.5;
|
|
796
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
|
|
798
|
+
let v = 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
|
-
|
|
802
|
+
v = u;
|
|
803
803
|
break;
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
|
-
|
|
806
|
+
v < o && (o = v, 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];
|
|
810
810
|
f && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${i.mesh_lod} (${f.density.toFixed(0)}) - ${e.name}`);
|
|
811
811
|
}
|
|
812
|
-
if (
|
|
813
|
-
const
|
|
812
|
+
if (x) {
|
|
813
|
+
const m = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
814
814
|
if (s.lastLodLevel_Texture < 0) {
|
|
815
815
|
if (i.texture_lod = h.max_count - 1, B) {
|
|
816
816
|
const f = h.lods[h.max_count - 1];
|
|
@@ -818,15 +818,15 @@ 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
|
|
822
|
-
((P = this.context) == null ? void 0 : P.engine) === "model-viewer" && (
|
|
823
|
-
const k = L / window.devicePixelRatio *
|
|
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
824
|
let T = !1;
|
|
825
825
|
for (let G = h.lods.length - 1; G >= 0; G--) {
|
|
826
|
-
let
|
|
827
|
-
if (!(
|
|
826
|
+
let v = h.lods[G];
|
|
827
|
+
if (!(m && v.max_height >= 2048) && !(tt() && v.max_height > 4096) && (v.max_height > k || !T && G === 0)) {
|
|
828
828
|
if (T = !0, i.texture_lod = G, i.texture_lod < s.lastLodLevel_Texture) {
|
|
829
|
-
const O =
|
|
829
|
+
const O = v.max_height;
|
|
830
830
|
B && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
|
|
831
831
|
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${f.toFixed(1)}
|
|
832
832
|
${e.name}`);
|
|
@@ -842,7 +842,7 @@ ${e.name}`);
|
|
|
842
842
|
let U = C;
|
|
843
843
|
E = /* @__PURE__ */ new WeakMap();
|
|
844
844
|
z = /* @__PURE__ */ new WeakMap();
|
|
845
|
-
|
|
845
|
+
we = /* @__PURE__ */ new WeakMap();
|
|
846
846
|
Q = /* @__PURE__ */ new WeakMap();
|
|
847
847
|
re = /* @__PURE__ */ new WeakMap();
|
|
848
848
|
de = /* @__PURE__ */ new WeakMap();
|
|
@@ -950,7 +950,7 @@ class ft {
|
|
|
950
950
|
const n = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), r = this.getUrl(i);
|
|
951
951
|
if (r && n && s.material) {
|
|
952
952
|
let o = function(c) {
|
|
953
|
-
var d, h,
|
|
953
|
+
var d, h, x;
|
|
954
954
|
if (c[fe] == !0)
|
|
955
955
|
return;
|
|
956
956
|
c[fe] = !0, c.userData && (c.userData.LOD = -1);
|
|
@@ -958,17 +958,17 @@ class ft {
|
|
|
958
958
|
for (let L = 0; L < l.length; L++) {
|
|
959
959
|
const M = l[L], P = c[M];
|
|
960
960
|
if ((P == null ? void 0 : P.isTexture) === !0) {
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
961
|
+
const m = (h = (d = P.userData) == null ? void 0 : d.associations) == null ? void 0 : h.textures;
|
|
962
|
+
if (m == null)
|
|
963
963
|
continue;
|
|
964
|
-
const f = n.parser.json.textures[
|
|
964
|
+
const f = n.parser.json.textures[m];
|
|
965
965
|
if (!f) {
|
|
966
|
-
console.warn("Texture data not found for texture index " +
|
|
966
|
+
console.warn("Texture data not found for texture index " + m);
|
|
967
967
|
continue;
|
|
968
968
|
}
|
|
969
|
-
if ((
|
|
970
|
-
const
|
|
971
|
-
|
|
969
|
+
if ((x = f == null ? void 0 : f.extensions) != null && x[$]) {
|
|
970
|
+
const w = f.extensions[$];
|
|
971
|
+
w && r && b.registerTexture(r, P, w.lods.length, m, w);
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
}
|
|
@@ -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(), $ = "NEEDLE_progressive", y = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(),
|
|
107
|
+
const q = new Array(), $ = "NEEDLE_progressive", y = oe("debugprogressive"), _e = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(), ve = /* @__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) => {
|
|
@@ -123,7 +123,7 @@ if (y) {
|
|
|
123
123
|
}), e >= s && (e = -1);
|
|
124
124
|
}, e = -1, s = 2, n = !1;
|
|
125
125
|
window.addEventListener("keyup", (i) => {
|
|
126
|
-
i.key === "p" && t(), i.key === "w" && (n = !n,
|
|
126
|
+
i.key === "p" && t(), i.key === "w" && (n = !n, ve && ve.forEach((r) => {
|
|
127
127
|
r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = n);
|
|
128
128
|
}));
|
|
129
129
|
});
|
|
@@ -288,7 +288,7 @@ const D = class {
|
|
|
288
288
|
}
|
|
289
289
|
if (t instanceof We || t.isMaterial === !0) {
|
|
290
290
|
const s = t, n = [], i = new Array();
|
|
291
|
-
if (y &&
|
|
291
|
+
if (y && ve.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
292
292
|
const r = s;
|
|
293
293
|
for (const o of Object.keys(r.uniforms)) {
|
|
294
294
|
const a = r.uniforms[o].value;
|
|
@@ -395,9 +395,9 @@ const D = class {
|
|
|
395
395
|
}
|
|
396
396
|
if (r || (r = D.lodInfos.get(i)), r) {
|
|
397
397
|
if (e > 0) {
|
|
398
|
-
let
|
|
398
|
+
let x = !1;
|
|
399
399
|
const L = Array.isArray(r.lods);
|
|
400
|
-
if (L && e >= r.lods.length ?
|
|
400
|
+
if (L && e >= r.lods.length ? x = !0 : L || (x = !0), x)
|
|
401
401
|
return this.lowresCache.get(i);
|
|
402
402
|
}
|
|
403
403
|
const d = Array.isArray(r.lods) ? (o = r.lods[e]) == null ? void 0 : o.path : r.lods;
|
|
@@ -407,15 +407,15 @@ const D = class {
|
|
|
407
407
|
if (h.endsWith(".glb") || h.endsWith(".gltf")) {
|
|
408
408
|
if (!r.guid)
|
|
409
409
|
return console.warn("missing pointer for glb/gltf texture", r), null;
|
|
410
|
-
const
|
|
410
|
+
const x = h + "_" + r.guid, L = this.previouslyLoaded.get(x);
|
|
411
411
|
if (L !== void 0) {
|
|
412
|
-
s && console.log(`LOD ${e} was already loading/loaded: ${
|
|
412
|
+
s && console.log(`LOD ${e} was already loading/loaded: ${x}`);
|
|
413
413
|
let f = await L.catch((I) => (console.error(`Error loading LOD ${e} from ${h}
|
|
414
|
-
`, I), null)),
|
|
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) : (
|
|
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(x)) : f instanceof he && t instanceof he && ((l = f.attributes.position) != null && l.array || (w = !0, this.previouslyLoaded.delete(x)))), !w)
|
|
416
416
|
return f;
|
|
417
417
|
}
|
|
418
|
-
const M = r, P = new Promise(async (f,
|
|
418
|
+
const M = r, P = new Promise(async (f, w) => {
|
|
419
419
|
const I = new Oe();
|
|
420
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;
|
|
@@ -429,7 +429,7 @@ const D = class {
|
|
|
429
429
|
return null;
|
|
430
430
|
const G = T.parser;
|
|
431
431
|
s && console.log("Loading finished " + h, M.guid);
|
|
432
|
-
let
|
|
432
|
+
let v = 0;
|
|
433
433
|
if (T.parser.json.textures) {
|
|
434
434
|
let O = !1;
|
|
435
435
|
for (const u of T.parser.json.textures) {
|
|
@@ -440,15 +440,15 @@ const D = class {
|
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
|
|
443
|
+
v++;
|
|
444
444
|
}
|
|
445
445
|
if (O) {
|
|
446
|
-
let u = await G.getDependency("texture",
|
|
447
|
-
return u && D.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h,
|
|
446
|
+
let u = await G.getDependency("texture", v);
|
|
447
|
+
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);
|
|
448
448
|
} else
|
|
449
449
|
y && console.warn("Could not find texture with guid", M.guid, T.parser.json);
|
|
450
450
|
}
|
|
451
|
-
if (
|
|
451
|
+
if (v = 0, T.parser.json.meshes) {
|
|
452
452
|
let O = !1;
|
|
453
453
|
for (const u of T.parser.json.meshes) {
|
|
454
454
|
if (u != null && u.extensions) {
|
|
@@ -458,11 +458,11 @@ const D = class {
|
|
|
458
458
|
break;
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
|
|
461
|
+
v++;
|
|
462
462
|
}
|
|
463
463
|
if (O) {
|
|
464
|
-
const u = await G.getDependency("mesh",
|
|
465
|
-
if (s && console.log(`Loaded Mesh "${u.name}"`, h,
|
|
464
|
+
const u = await G.getDependency("mesh", v), g = M;
|
|
465
|
+
if (s && console.log(`Loaded Mesh "${u.name}"`, h, v, u, x), 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 {
|
|
@@ -481,7 +481,7 @@ const D = class {
|
|
|
481
481
|
}
|
|
482
482
|
return f(null);
|
|
483
483
|
});
|
|
484
|
-
return this.previouslyLoaded.set(
|
|
484
|
+
return this.previouslyLoaded.set(x, P), await P;
|
|
485
485
|
} else if (t instanceof j) {
|
|
486
486
|
s && console.log("Load texture from uri: " + h);
|
|
487
487
|
const L = await new ze().loadAsync(h);
|
|
@@ -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
|
-
}, N = (t, e, s, n) => (Ge(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), E, z,
|
|
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, we, 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, E, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], K(this, z, void 0), K(this,
|
|
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, we, 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) {
|
|
@@ -604,7 +604,7 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
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, N(e, Q, p(e, Q) + 1), N(e, re, p(e,
|
|
607
|
+
(i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, N(e, Q, p(e, Q) + 1), N(e, re, p(e, we).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
|
};
|
|
@@ -654,8 +654,8 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
654
654
|
}
|
|
655
655
|
if (B === "color" && l.material && !l.object.progressive_debug_color) {
|
|
656
656
|
l.object.progressive_debug_color = !0;
|
|
657
|
-
const h = Math.random() * 16777215,
|
|
658
|
-
l.object.material =
|
|
657
|
+
const h = Math.random() * 16777215, x = new qe({ color: h });
|
|
658
|
+
l.object.material = x;
|
|
659
659
|
}
|
|
660
660
|
const d = l.object;
|
|
661
661
|
(d instanceof H || d.isMesh) && this.updateLODs(t, e, d, i);
|
|
@@ -741,8 +741,8 @@ 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 = b.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = b.getMaterialMinMaxLODsCount(e.material),
|
|
745
|
-
if (!d && !
|
|
744
|
+
const c = b.getMeshLODInformation(e.geometry), l = c == null ? void 0 : c.lods, d = l && l.length > 0, h = b.getMaterialMinMaxLODsCount(e.material), x = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
|
|
745
|
+
if (!d && !x) {
|
|
746
746
|
i.mesh_lod = 0, i.texture_lod = 0;
|
|
747
747
|
return;
|
|
748
748
|
}
|
|
@@ -750,17 +750,17 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
750
750
|
const L = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
751
751
|
let M = e.geometry.boundingBox;
|
|
752
752
|
if (e.type === "SkinnedMesh") {
|
|
753
|
-
const
|
|
754
|
-
if (!
|
|
755
|
-
|
|
753
|
+
const m = e;
|
|
754
|
+
if (!m.boundingBox)
|
|
755
|
+
m.computeBoundingBox();
|
|
756
756
|
else if (s.frames % 30 === 0) {
|
|
757
|
-
const f = ae(
|
|
758
|
-
f && (
|
|
757
|
+
const f = ae(m), w = m.geometry;
|
|
758
|
+
f && (m.geometry = f), m.computeBoundingBox(), m.geometry = w;
|
|
759
759
|
}
|
|
760
|
-
M =
|
|
760
|
+
M = m.boundingBox;
|
|
761
761
|
}
|
|
762
|
-
if (M
|
|
763
|
-
const
|
|
762
|
+
if (M) {
|
|
763
|
+
const m = t;
|
|
764
764
|
if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
|
|
765
765
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
766
766
|
const u = t.getWorldPosition(this._tempWorldPosition);
|
|
@@ -769,11 +769,11 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
if (this._tempBox.copy(M), this._tempBox.applyMatrix4(e.matrixWorld), C.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
772
|
+
if (this._tempBox.copy(M), this._tempBox.applyMatrix4(e.matrixWorld), m.isPerspectiveCamera && C.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
773
773
|
i.mesh_lod = 0, i.texture_lod = 0;
|
|
774
774
|
return;
|
|
775
775
|
}
|
|
776
|
-
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled &&
|
|
776
|
+
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && m.isPerspectiveCamera && m.fov > 70) {
|
|
777
777
|
const u = this._tempBox.min, g = this._tempBox.max;
|
|
778
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;
|
|
@@ -783,9 +783,9 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
783
783
|
} else
|
|
784
784
|
s.lastCentrality = 1;
|
|
785
785
|
const f = this._tempBox.getSize(this._tempBoxSize);
|
|
786
|
-
f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), f.x *=
|
|
787
|
-
const
|
|
788
|
-
I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(
|
|
786
|
+
f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), t.isPerspectiveCamera ? f.x *= t.aspect : t.isOrthographicCamera;
|
|
787
|
+
const w = t.matrixWorldInverse, I = this._tempBox2;
|
|
788
|
+
I.copy(M), I.applyMatrix4(e.matrixWorld), I.applyMatrix4(w);
|
|
789
789
|
const k = I.getSize(this._tempBox2Size), T = Math.max(k.x, k.y);
|
|
790
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);
|
|
@@ -795,22 +795,22 @@ const B = oe("debugprogressive"), at = oe("noprogressive"), me = Symbol("Needle:
|
|
|
795
795
|
const W = (g.z + A.z) * 0.5;
|
|
796
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
|
|
798
|
+
let v = 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
|
-
|
|
802
|
+
v = u;
|
|
803
803
|
break;
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
|
-
|
|
806
|
+
v < o && (o = v, 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];
|
|
810
810
|
f && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${i.mesh_lod} (${f.density.toFixed(0)}) - ${e.name}`);
|
|
811
811
|
}
|
|
812
|
-
if (
|
|
813
|
-
const
|
|
812
|
+
if (x) {
|
|
813
|
+
const m = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
814
814
|
if (s.lastLodLevel_Texture < 0) {
|
|
815
815
|
if (i.texture_lod = h.max_count - 1, B) {
|
|
816
816
|
const f = h.lods[h.max_count - 1];
|
|
@@ -818,15 +818,15 @@ 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
|
|
822
|
-
((P = this.context) == null ? void 0 : P.engine) === "model-viewer" && (
|
|
823
|
-
const k = L / window.devicePixelRatio *
|
|
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
824
|
let T = !1;
|
|
825
825
|
for (let G = h.lods.length - 1; G >= 0; G--) {
|
|
826
|
-
let
|
|
827
|
-
if (!(
|
|
826
|
+
let v = h.lods[G];
|
|
827
|
+
if (!(m && v.max_height >= 2048) && !(tt() && v.max_height > 4096) && (v.max_height > k || !T && G === 0)) {
|
|
828
828
|
if (T = !0, i.texture_lod = G, i.texture_lod < s.lastLodLevel_Texture) {
|
|
829
|
-
const O =
|
|
829
|
+
const O = v.max_height;
|
|
830
830
|
B && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
|
|
831
831
|
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${f.toFixed(1)}
|
|
832
832
|
${e.name}`);
|
|
@@ -842,7 +842,7 @@ ${e.name}`);
|
|
|
842
842
|
let U = C;
|
|
843
843
|
E = /* @__PURE__ */ new WeakMap();
|
|
844
844
|
z = /* @__PURE__ */ new WeakMap();
|
|
845
|
-
|
|
845
|
+
we = /* @__PURE__ */ new WeakMap();
|
|
846
846
|
Q = /* @__PURE__ */ new WeakMap();
|
|
847
847
|
re = /* @__PURE__ */ new WeakMap();
|
|
848
848
|
de = /* @__PURE__ */ new WeakMap();
|
|
@@ -950,7 +950,7 @@ class ft {
|
|
|
950
950
|
const n = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), r = this.getUrl(i);
|
|
951
951
|
if (r && n && s.material) {
|
|
952
952
|
let o = function(c) {
|
|
953
|
-
var d, h,
|
|
953
|
+
var d, h, x;
|
|
954
954
|
if (c[fe] == !0)
|
|
955
955
|
return;
|
|
956
956
|
c[fe] = !0, c.userData && (c.userData.LOD = -1);
|
|
@@ -958,17 +958,17 @@ class ft {
|
|
|
958
958
|
for (let L = 0; L < l.length; L++) {
|
|
959
959
|
const M = l[L], P = c[M];
|
|
960
960
|
if ((P == null ? void 0 : P.isTexture) === !0) {
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
961
|
+
const m = (h = (d = P.userData) == null ? void 0 : d.associations) == null ? void 0 : h.textures;
|
|
962
|
+
if (m == null)
|
|
963
963
|
continue;
|
|
964
|
-
const f = n.parser.json.textures[
|
|
964
|
+
const f = n.parser.json.textures[m];
|
|
965
965
|
if (!f) {
|
|
966
|
-
console.warn("Texture data not found for texture index " +
|
|
966
|
+
console.warn("Texture data not found for texture index " + m);
|
|
967
967
|
continue;
|
|
968
968
|
}
|
|
969
|
-
if ((
|
|
970
|
-
const
|
|
971
|
-
|
|
969
|
+
if ((x = f == null ? void 0 : f.extensions) != null && x[$]) {
|
|
970
|
+
const w = f.extensions[$];
|
|
971
|
+
w && r && b.registerTexture(r, P, w.lods.length, m, w);
|
|
972
972
|
}
|
|
973
973
|
}
|
|
974
974
|
}
|