@needle-tools/engine 4.4.0-alpha.2 → 4.4.0-alpha.4
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 +4 -1
- package/dist/gltf-progressive.js +54 -54
- package/dist/gltf-progressive.light.js +54 -54
- package/dist/gltf-progressive.light.min.js +7 -7
- package/dist/gltf-progressive.min.js +7 -7
- package/dist/needle-engine.bundle.js +6614 -6556
- package/dist/needle-engine.bundle.light.js +6397 -6339
- package/dist/needle-engine.bundle.light.min.js +134 -130
- package/dist/needle-engine.bundle.light.umd.cjs +66 -62
- package/dist/needle-engine.bundle.min.js +134 -130
- package/dist/needle-engine.bundle.umd.cjs +67 -63
- package/dist/needle-engine.d.ts +9 -9
- package/dist/needle-engine.js +511 -511
- package/dist/needle-engine.light.d.ts +9 -9
- package/dist/needle-engine.light.js +511 -511
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/postprocessing.js +38 -38
- package/dist/postprocessing.light.js +38 -38
- package/dist/postprocessing.light.min.js +2 -2
- package/dist/postprocessing.min.js +2 -2
- package/dist/three-examples.js +1205 -1205
- package/dist/three-examples.light.js +1205 -1205
- package/dist/three-examples.light.min.js +15 -15
- package/dist/three-examples.min.js +15 -15
- package/dist/three-mesh-ui.js +9 -9
- package/dist/three-mesh-ui.light.js +9 -9
- package/dist/three-mesh-ui.light.min.js +9 -9
- package/dist/three-mesh-ui.min.js +9 -9
- package/dist/three.js +238 -238
- package/dist/three.light.js +238 -238
- package/dist/three.light.min.js +24 -24
- package/dist/three.min.js +24 -24
- package/dist/vendor.js +24 -24
- package/dist/vendor.light.js +24 -24
- package/dist/vendor.light.min.js +2 -2
- package/dist/vendor.min.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js +4 -0
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +1 -1
- package/lib/engine-components/Camera.js +13 -0
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.js +2 -1
- package/lib/engine-components/CameraUtils.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.js.map +1 -1
- package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +2 -0
- package/lib/engine-components/postprocessing/PostProcessingHandler.js +72 -4
- package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
- package/package.json +1 -1
- package/plugins/common/license.js +14 -5
- package/src/engine/webcomponents/needle menu/needle-menu.ts +4 -0
- package/src/engine-components/Camera.ts +16 -1
- package/src/engine-components/CameraUtils.ts +3 -2
- package/src/engine-components/postprocessing/Effects/Tonemapping.ts +2 -2
- package/src/engine-components/postprocessing/PostProcessingHandler.ts +82 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,12 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## [4.4.0-alpha.
|
|
7
|
+
## [4.4.0-alpha.3] - 2025-03-21
|
|
8
8
|
- Add: `ObjectUtils.createPrimitive()` now supports scale as array
|
|
9
9
|
e.g. `ObjectUtils.createPrimitive("Cube", { scale: [1, .25, 1] } );`
|
|
10
|
+
- Fix: Implicit camera did not automatically set to skybox when using `background-image`. E.g. `<needle-engine background-image="<url>">
|
|
11
|
+
- Fix: Tonemapping falsely set tonemappingEsposure to undefined causing a black screen
|
|
12
|
+
- Change: License check aborts now faster instead of retrying when connection is actively refused
|
|
10
13
|
|
|
11
14
|
## [4.3.2] - 2025-03-20
|
|
12
15
|
#### Added
|
package/dist/gltf-progressive.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BufferGeometry as he, Mesh as Q, Texture as ee, TextureLoader as ze, Vector3 as z, Matrix4 as be, Sphere as Ve, Box3 as Ee, MeshStandardMaterial as Xe, Clock as qe } from "./three.js";
|
|
2
|
+
import { DRACOLoader as Ke, KTX2Loader as Ye, GLTFLoader as Se, MeshoptDecoder as He } from "./three-examples.js";
|
|
3
3
|
const Je = "";
|
|
4
4
|
globalThis.GLTF_PROGRESSIVE_VERSION = Je;
|
|
5
5
|
console.debug("[gltf-progressive] version -");
|
|
@@ -25,7 +25,7 @@ function et(t) {
|
|
|
25
25
|
const De = Symbol("dracoDecoderPath");
|
|
26
26
|
let A, ge, G;
|
|
27
27
|
function Be() {
|
|
28
|
-
A || (A = new
|
|
28
|
+
A || (A = new Ke(), A[De] = N, A.setDecoderPath(N), A.setDecoderConfig({ type: "js" }), A.preload()), G || (G = new Ye(), G.setTranscoderPath(j), G.init()), ge || (ge = He);
|
|
29
29
|
}
|
|
30
30
|
function Re(t) {
|
|
31
31
|
return Be(), 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 };
|
|
@@ -127,7 +127,7 @@ if (p) {
|
|
|
127
127
|
}));
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Te(t, e, s) {
|
|
131
131
|
var i;
|
|
132
132
|
if (!p)
|
|
133
133
|
return;
|
|
@@ -259,7 +259,7 @@ const M = class {
|
|
|
259
259
|
const o = i.index || 0;
|
|
260
260
|
r = r[o];
|
|
261
261
|
}
|
|
262
|
-
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && n != r && ((r == null ? void 0 : r.isBufferGeometry) ? (t.geometry = r, p &&
|
|
262
|
+
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && n != r && ((r == null ? void 0 : r.isBufferGeometry) ? (t.geometry = r, p && Te(t, "geometry", i.url)) : p && console.error("Invalid LOD geometry", r))), r;
|
|
263
263
|
}).catch((r) => (console.error("Error loading mesh LOD", t, r), null));
|
|
264
264
|
} else
|
|
265
265
|
p && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
@@ -336,7 +336,7 @@ const M = class {
|
|
|
336
336
|
}
|
|
337
337
|
if (p && n && s) {
|
|
338
338
|
const r = this.getAssignedLODInformation(t);
|
|
339
|
-
r ?
|
|
339
|
+
r ? Te(s, n, r.url) : console.warn("No LOD info for texture", t);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
return i;
|
|
@@ -422,16 +422,16 @@ const M = class {
|
|
|
422
422
|
const O = D.lods[e];
|
|
423
423
|
O.hash && (B += "?v=" + O.hash);
|
|
424
424
|
}
|
|
425
|
-
const
|
|
425
|
+
const E = await $.loadAsync(B).catch((O) => (console.error(`Error loading LOD ${e} from ${h}
|
|
426
426
|
`, O), null));
|
|
427
|
-
if (!
|
|
427
|
+
if (!E)
|
|
428
428
|
return null;
|
|
429
|
-
const U =
|
|
429
|
+
const U = E.parser;
|
|
430
430
|
s && console.log("Loading finished " + h, D.guid);
|
|
431
431
|
let v = 0;
|
|
432
|
-
if (
|
|
432
|
+
if (E.parser.json.textures) {
|
|
433
433
|
let O = !1;
|
|
434
|
-
for (const u of
|
|
434
|
+
for (const u of E.parser.json.textures) {
|
|
435
435
|
if (u != null && u.extensions) {
|
|
436
436
|
const g = u == null ? void 0 : u.extensions[W];
|
|
437
437
|
if (g != null && g.guid && g.guid === D.guid) {
|
|
@@ -445,11 +445,11 @@ const M = class {
|
|
|
445
445
|
let u = await U.getDependency("texture", v);
|
|
446
446
|
return u && M.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h, v, u, x), t instanceof ee && (u = this.copySettings(t, u)), u && (u.guid = D.guid), f(u);
|
|
447
447
|
} else
|
|
448
|
-
p && console.warn("Could not find texture with guid", D.guid,
|
|
448
|
+
p && console.warn("Could not find texture with guid", D.guid, E.parser.json);
|
|
449
449
|
}
|
|
450
|
-
if (v = 0,
|
|
450
|
+
if (v = 0, E.parser.json.meshes) {
|
|
451
451
|
let O = !1;
|
|
452
|
-
for (const u of
|
|
452
|
+
for (const u of E.parser.json.meshes) {
|
|
453
453
|
if (u != null && u.extensions) {
|
|
454
454
|
const g = u == null ? void 0 : u.extensions[W];
|
|
455
455
|
if (g != null && g.guid && g.guid === D.guid) {
|
|
@@ -467,16 +467,16 @@ const M = class {
|
|
|
467
467
|
} else {
|
|
468
468
|
const _ = new Array();
|
|
469
469
|
for (let S = 0; S < u.children.length; S++) {
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
M.assignLODInformation(n.url,
|
|
470
|
+
const T = u.children[S];
|
|
471
|
+
if (T.isMesh === !0) {
|
|
472
|
+
const X = T.geometry;
|
|
473
|
+
M.assignLODInformation(n.url, X, i, e, S, g.density), _.push(X);
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
return f(_);
|
|
477
477
|
}
|
|
478
478
|
} else
|
|
479
|
-
p && console.warn("Could not find mesh with guid", D.guid,
|
|
479
|
+
p && console.warn("Could not find mesh with guid", D.guid, E.parser.json);
|
|
480
480
|
}
|
|
481
481
|
return f(null);
|
|
482
482
|
});
|
|
@@ -547,11 +547,11 @@ var $e = (t, e, s) => {
|
|
|
547
547
|
if (e.has(t))
|
|
548
548
|
throw TypeError("Cannot add the same private member more than once");
|
|
549
549
|
e instanceof WeakSet ? e.add(t) : e.set(t, s);
|
|
550
|
-
}, F = (t, e, s, n) => ($e(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b,
|
|
551
|
-
const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"),
|
|
550
|
+
}, F = (t, e, s, n) => ($e(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b, K, Oe, Z, ie, de, Y;
|
|
551
|
+
const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"), q = Symbol("Needle:CurrentLOD"), I = { mesh_lod: -1, texture_lod: -1 }, C = class {
|
|
552
552
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
553
553
|
constructor(t, e) {
|
|
554
|
-
this.projectionScreenMatrix = new be(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", J(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], J(this,
|
|
554
|
+
this.projectionScreenMatrix = new be(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", J(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], J(this, K, void 0), J(this, Oe, new qe()), 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 Ve(), this._tempBox = new Ee(), this._tempBox2 = new Ee(), this.tempMatrix = new be(), this._tempWorldPosition = new z(), this._tempBoxSize = new z(), this._tempBox2Size = new z(), this.renderer = t, this.context = { ...e };
|
|
555
555
|
}
|
|
556
556
|
/** @internal */
|
|
557
557
|
static getObjectLODState(t) {
|
|
@@ -595,21 +595,21 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
595
595
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
596
596
|
*/
|
|
597
597
|
enable() {
|
|
598
|
-
if (y(this,
|
|
598
|
+
if (y(this, K))
|
|
599
599
|
return;
|
|
600
600
|
console.debug("[gltf-progressive] Enabling LODsManager for renderer");
|
|
601
601
|
let t = 0;
|
|
602
|
-
F(this,
|
|
602
|
+
F(this, K, this.renderer.render);
|
|
603
603
|
const e = this;
|
|
604
604
|
Re(this.renderer), this.renderer.render = function(s, n) {
|
|
605
605
|
const i = e.renderer.getRenderTarget();
|
|
606
606
|
(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)));
|
|
607
607
|
const r = t++;
|
|
608
|
-
y(e,
|
|
608
|
+
y(e, K).call(this, s, n), e.onAfterRender(s, n, r);
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
611
|
disable() {
|
|
612
|
-
y(this,
|
|
612
|
+
y(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, K), F(this, K, void 0));
|
|
613
613
|
}
|
|
614
614
|
update(t, e) {
|
|
615
615
|
this.internalUpdate(t, e);
|
|
@@ -653,7 +653,7 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
653
653
|
}
|
|
654
654
|
if (R === "color" && l.material && !l.object.progressive_debug_color) {
|
|
655
655
|
l.object.progressive_debug_color = !0;
|
|
656
|
-
const h = Math.random() * 16777215, x = new
|
|
656
|
+
const h = Math.random() * 16777215, x = new Xe({ color: h });
|
|
657
657
|
l.object.material = x;
|
|
658
658
|
}
|
|
659
659
|
const d = l.object;
|
|
@@ -700,9 +700,9 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
700
700
|
return;
|
|
701
701
|
}
|
|
702
702
|
let s = !1;
|
|
703
|
-
(t[
|
|
703
|
+
(t[q] === void 0 || e < t[q]) && (s = !0);
|
|
704
704
|
const n = t["DEBUG:LOD"];
|
|
705
|
-
n != null && (s = t[
|
|
705
|
+
n != null && (s = t[q] != n, e = n), s && (t[q] = e, P.assignTextureLOD(t, e).then((i) => {
|
|
706
706
|
this._lodchangedlisteners.forEach((r) => r({ type: "texture", level: e, object: t }));
|
|
707
707
|
}));
|
|
708
708
|
}
|
|
@@ -715,12 +715,12 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
715
715
|
loadProgressiveMeshes(t, e) {
|
|
716
716
|
if (!t)
|
|
717
717
|
return Promise.resolve(null);
|
|
718
|
-
let s = t[
|
|
718
|
+
let s = t[q] !== e;
|
|
719
719
|
const n = t["DEBUG:LOD"];
|
|
720
|
-
if (n != null && (s = t[
|
|
721
|
-
t[
|
|
720
|
+
if (n != null && (s = t[q] != n, e = n), s) {
|
|
721
|
+
t[q] = e;
|
|
722
722
|
const i = t.geometry;
|
|
723
|
-
return P.assignMeshLOD(t, e).then((r) => (r && t[
|
|
723
|
+
return P.assignMeshLOD(t, e).then((r) => (r && t[q] == e && i != t.geometry && this._lodchangedlisteners.forEach((o) => o({ type: "mesh", level: e, object: t })), r));
|
|
724
724
|
}
|
|
725
725
|
return Promise.resolve(null);
|
|
726
726
|
}
|
|
@@ -775,10 +775,10 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
775
775
|
}
|
|
776
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
|
-
let _ = u.x, S = u.y,
|
|
778
|
+
let _ = u.x, S = u.y, T = g.x, X = 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, S = (S - ue) * le + ue,
|
|
781
|
-
const Fe = _ < 0 &&
|
|
780
|
+
_ = (_ - ce) * le + ce, S = (S - ue) * le + ue, T = (T - ce) * le + ce, X = (X - ue) * le + ue;
|
|
781
|
+
const Fe = _ < 0 && T > 0 ? 0 : Math.min(Math.abs(u.x), Math.abs(g.x)), We = S < 0 && X > 0 ? 0 : Math.min(Math.abs(u.y), Math.abs(g.y)), ye = Math.max(Fe, We);
|
|
782
782
|
s.lastCentrality = (pe - ye) * (pe - ye) * (pe - ye);
|
|
783
783
|
} else
|
|
784
784
|
s.lastCentrality = 1;
|
|
@@ -786,14 +786,14 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
786
786
|
f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), t.isPerspectiveCamera ? f.x *= t.aspect : t.isOrthographicCamera;
|
|
787
787
|
const w = t.matrixWorldInverse, $ = this._tempBox2;
|
|
788
788
|
$.copy(D), $.applyMatrix4(e.matrixWorld), $.applyMatrix4(w);
|
|
789
|
-
const B = $.getSize(this._tempBox2Size),
|
|
790
|
-
if (Math.max(f.x, f.y) != 0 &&
|
|
789
|
+
const B = $.getSize(this._tempBox2Size), E = Math.max(B.x, B.y);
|
|
790
|
+
if (Math.max(f.x, f.y) != 0 && E != 0 && (f.z = B.z / Math.max(B.x, B.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, R && C.debugDrawLine) {
|
|
791
791
|
const u = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
792
792
|
u.invert();
|
|
793
|
-
const g = C.corner0, _ = C.corner1, S = C.corner2,
|
|
794
|
-
g.copy(this._tempBox.min), _.copy(this._tempBox.max), _.x = g.x, S.copy(this._tempBox.max), S.y = g.y,
|
|
795
|
-
const
|
|
796
|
-
g.z = _.z = S.z =
|
|
793
|
+
const g = C.corner0, _ = C.corner1, S = C.corner2, T = C.corner3;
|
|
794
|
+
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);
|
|
795
|
+
const X = (g.z + T.z) * 0.5;
|
|
796
|
+
g.z = _.z = S.z = T.z = X, 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);
|
|
797
797
|
}
|
|
798
798
|
let v = 999;
|
|
799
799
|
if (l && s.lastScreenCoverage > 0) {
|
|
@@ -821,11 +821,11 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
821
821
|
let w = s.lastScreenCoverage * 4;
|
|
822
822
|
((k = this.context) == null ? void 0 : k.engine) === "model-viewer" && (w *= 1.5);
|
|
823
823
|
const B = L / window.devicePixelRatio * w;
|
|
824
|
-
let
|
|
824
|
+
let E = !1;
|
|
825
825
|
for (let U = h.lods.length - 1; U >= 0; U--) {
|
|
826
826
|
let v = h.lods[U];
|
|
827
|
-
if (!(m && v.max_height >= 2048) && !(rt() && v.max_height > 4096) && (v.max_height > B || !
|
|
828
|
-
if (
|
|
827
|
+
if (!(m && v.max_height >= 2048) && !(rt() && v.max_height > 4096) && (v.max_height > B || !E && U === 0)) {
|
|
828
|
+
if (E = !0, i.texture_lod = U, i.texture_lod < s.lastLodLevel_Texture) {
|
|
829
829
|
const O = v.max_height;
|
|
830
830
|
R && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
|
|
831
831
|
Screensize: ${B.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${f.toFixed(1)}
|
|
@@ -841,7 +841,7 @@ ${e.name}`);
|
|
|
841
841
|
};
|
|
842
842
|
let V = C;
|
|
843
843
|
b = /* @__PURE__ */ new WeakMap();
|
|
844
|
-
|
|
844
|
+
K = /* @__PURE__ */ new WeakMap();
|
|
845
845
|
Oe = /* @__PURE__ */ new WeakMap();
|
|
846
846
|
Z = /* @__PURE__ */ new WeakMap();
|
|
847
847
|
ie = /* @__PURE__ */ new WeakMap();
|
|
@@ -1022,12 +1022,12 @@ if (!it) {
|
|
|
1022
1022
|
globalThis.Needle[e] = t[e];
|
|
1023
1023
|
}
|
|
1024
1024
|
export {
|
|
1025
|
-
V as
|
|
1026
|
-
P as
|
|
1027
|
-
Ie as
|
|
1028
|
-
Ge as
|
|
1029
|
-
Re as
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1025
|
+
V as LODsManager,
|
|
1026
|
+
P as NEEDLE_progressive,
|
|
1027
|
+
Ie as addDracoAndKTX2Loaders,
|
|
1028
|
+
Ge as configureLoader,
|
|
1029
|
+
Re as createLoaders,
|
|
1030
|
+
ae as getRaycastMesh,
|
|
1031
|
+
je as setDracoDecoderLocation,
|
|
1032
|
+
et as setKTX2TranscoderLocation
|
|
1033
1033
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BufferGeometry as he, Mesh as Q, Texture as ee, TextureLoader as ze, Vector3 as z, Matrix4 as be, Sphere as Ve, Box3 as Ee, MeshStandardMaterial as Xe, Clock as qe } from "./three.light.js";
|
|
2
|
+
import { DRACOLoader as Ke, KTX2Loader as Ye, GLTFLoader as Se, MeshoptDecoder as He } from "./three-examples.light.js";
|
|
3
3
|
const Je = "";
|
|
4
4
|
globalThis.GLTF_PROGRESSIVE_VERSION = Je;
|
|
5
5
|
console.debug("[gltf-progressive] version -");
|
|
@@ -25,7 +25,7 @@ function et(t) {
|
|
|
25
25
|
const De = Symbol("dracoDecoderPath");
|
|
26
26
|
let A, ge, G;
|
|
27
27
|
function Be() {
|
|
28
|
-
A || (A = new
|
|
28
|
+
A || (A = new Ke(), A[De] = N, A.setDecoderPath(N), A.setDecoderConfig({ type: "js" }), A.preload()), G || (G = new Ye(), G.setTranscoderPath(j), G.init()), ge || (ge = He);
|
|
29
29
|
}
|
|
30
30
|
function Re(t) {
|
|
31
31
|
return Be(), 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 };
|
|
@@ -127,7 +127,7 @@ if (p) {
|
|
|
127
127
|
}));
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Te(t, e, s) {
|
|
131
131
|
var i;
|
|
132
132
|
if (!p)
|
|
133
133
|
return;
|
|
@@ -259,7 +259,7 @@ const M = class {
|
|
|
259
259
|
const o = i.index || 0;
|
|
260
260
|
r = r[o];
|
|
261
261
|
}
|
|
262
|
-
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && n != r && ((r == null ? void 0 : r.isBufferGeometry) ? (t.geometry = r, p &&
|
|
262
|
+
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && n != r && ((r == null ? void 0 : r.isBufferGeometry) ? (t.geometry = r, p && Te(t, "geometry", i.url)) : p && console.error("Invalid LOD geometry", r))), r;
|
|
263
263
|
}).catch((r) => (console.error("Error loading mesh LOD", t, r), null));
|
|
264
264
|
} else
|
|
265
265
|
p && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
@@ -336,7 +336,7 @@ const M = class {
|
|
|
336
336
|
}
|
|
337
337
|
if (p && n && s) {
|
|
338
338
|
const r = this.getAssignedLODInformation(t);
|
|
339
|
-
r ?
|
|
339
|
+
r ? Te(s, n, r.url) : console.warn("No LOD info for texture", t);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
return i;
|
|
@@ -422,16 +422,16 @@ const M = class {
|
|
|
422
422
|
const O = D.lods[e];
|
|
423
423
|
O.hash && (B += "?v=" + O.hash);
|
|
424
424
|
}
|
|
425
|
-
const
|
|
425
|
+
const E = await $.loadAsync(B).catch((O) => (console.error(`Error loading LOD ${e} from ${h}
|
|
426
426
|
`, O), null));
|
|
427
|
-
if (!
|
|
427
|
+
if (!E)
|
|
428
428
|
return null;
|
|
429
|
-
const U =
|
|
429
|
+
const U = E.parser;
|
|
430
430
|
s && console.log("Loading finished " + h, D.guid);
|
|
431
431
|
let v = 0;
|
|
432
|
-
if (
|
|
432
|
+
if (E.parser.json.textures) {
|
|
433
433
|
let O = !1;
|
|
434
|
-
for (const u of
|
|
434
|
+
for (const u of E.parser.json.textures) {
|
|
435
435
|
if (u != null && u.extensions) {
|
|
436
436
|
const g = u == null ? void 0 : u.extensions[W];
|
|
437
437
|
if (g != null && g.guid && g.guid === D.guid) {
|
|
@@ -445,11 +445,11 @@ const M = class {
|
|
|
445
445
|
let u = await U.getDependency("texture", v);
|
|
446
446
|
return u && M.assignLODInformation(n.url, u, i, e, void 0, void 0), s && console.log('change "' + t.name + '" → "' + u.name + '"', h, v, u, x), t instanceof ee && (u = this.copySettings(t, u)), u && (u.guid = D.guid), f(u);
|
|
447
447
|
} else
|
|
448
|
-
p && console.warn("Could not find texture with guid", D.guid,
|
|
448
|
+
p && console.warn("Could not find texture with guid", D.guid, E.parser.json);
|
|
449
449
|
}
|
|
450
|
-
if (v = 0,
|
|
450
|
+
if (v = 0, E.parser.json.meshes) {
|
|
451
451
|
let O = !1;
|
|
452
|
-
for (const u of
|
|
452
|
+
for (const u of E.parser.json.meshes) {
|
|
453
453
|
if (u != null && u.extensions) {
|
|
454
454
|
const g = u == null ? void 0 : u.extensions[W];
|
|
455
455
|
if (g != null && g.guid && g.guid === D.guid) {
|
|
@@ -467,16 +467,16 @@ const M = class {
|
|
|
467
467
|
} else {
|
|
468
468
|
const _ = new Array();
|
|
469
469
|
for (let S = 0; S < u.children.length; S++) {
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
M.assignLODInformation(n.url,
|
|
470
|
+
const T = u.children[S];
|
|
471
|
+
if (T.isMesh === !0) {
|
|
472
|
+
const X = T.geometry;
|
|
473
|
+
M.assignLODInformation(n.url, X, i, e, S, g.density), _.push(X);
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
return f(_);
|
|
477
477
|
}
|
|
478
478
|
} else
|
|
479
|
-
p && console.warn("Could not find mesh with guid", D.guid,
|
|
479
|
+
p && console.warn("Could not find mesh with guid", D.guid, E.parser.json);
|
|
480
480
|
}
|
|
481
481
|
return f(null);
|
|
482
482
|
});
|
|
@@ -547,11 +547,11 @@ var $e = (t, e, s) => {
|
|
|
547
547
|
if (e.has(t))
|
|
548
548
|
throw TypeError("Cannot add the same private member more than once");
|
|
549
549
|
e instanceof WeakSet ? e.add(t) : e.set(t, s);
|
|
550
|
-
}, F = (t, e, s, n) => ($e(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b,
|
|
551
|
-
const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"),
|
|
550
|
+
}, F = (t, e, s, n) => ($e(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b, K, Oe, Z, ie, de, Y;
|
|
551
|
+
const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:LODSManager"), xe = Symbol("Needle:LODState"), q = Symbol("Needle:CurrentLOD"), I = { mesh_lod: -1, texture_lod: -1 }, C = class {
|
|
552
552
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
553
553
|
constructor(t, e) {
|
|
554
|
-
this.projectionScreenMatrix = new be(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", J(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], J(this,
|
|
554
|
+
this.projectionScreenMatrix = new be(), this.targetTriangleDensity = 2e5, this.updateInterval = "auto", J(this, b, 1), this.pause = !1, this.manual = !1, this._lodchangedlisteners = [], J(this, K, void 0), J(this, Oe, new qe()), 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 Ve(), this._tempBox = new Ee(), this._tempBox2 = new Ee(), this.tempMatrix = new be(), this._tempWorldPosition = new z(), this._tempBoxSize = new z(), this._tempBox2Size = new z(), this.renderer = t, this.context = { ...e };
|
|
555
555
|
}
|
|
556
556
|
/** @internal */
|
|
557
557
|
static getObjectLODState(t) {
|
|
@@ -595,21 +595,21 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
595
595
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
596
596
|
*/
|
|
597
597
|
enable() {
|
|
598
|
-
if (y(this,
|
|
598
|
+
if (y(this, K))
|
|
599
599
|
return;
|
|
600
600
|
console.debug("[gltf-progressive] Enabling LODsManager for renderer");
|
|
601
601
|
let t = 0;
|
|
602
|
-
F(this,
|
|
602
|
+
F(this, K, this.renderer.render);
|
|
603
603
|
const e = this;
|
|
604
604
|
Re(this.renderer), this.renderer.render = function(s, n) {
|
|
605
605
|
const i = e.renderer.getRenderTarget();
|
|
606
606
|
(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)));
|
|
607
607
|
const r = t++;
|
|
608
|
-
y(e,
|
|
608
|
+
y(e, K).call(this, s, n), e.onAfterRender(s, n, r);
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
611
|
disable() {
|
|
612
|
-
y(this,
|
|
612
|
+
y(this, K) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = y(this, K), F(this, K, void 0));
|
|
613
613
|
}
|
|
614
614
|
update(t, e) {
|
|
615
615
|
this.internalUpdate(t, e);
|
|
@@ -653,7 +653,7 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
653
653
|
}
|
|
654
654
|
if (R === "color" && l.material && !l.object.progressive_debug_color) {
|
|
655
655
|
l.object.progressive_debug_color = !0;
|
|
656
|
-
const h = Math.random() * 16777215, x = new
|
|
656
|
+
const h = Math.random() * 16777215, x = new Xe({ color: h });
|
|
657
657
|
l.object.material = x;
|
|
658
658
|
}
|
|
659
659
|
const d = l.object;
|
|
@@ -700,9 +700,9 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
700
700
|
return;
|
|
701
701
|
}
|
|
702
702
|
let s = !1;
|
|
703
|
-
(t[
|
|
703
|
+
(t[q] === void 0 || e < t[q]) && (s = !0);
|
|
704
704
|
const n = t["DEBUG:LOD"];
|
|
705
|
-
n != null && (s = t[
|
|
705
|
+
n != null && (s = t[q] != n, e = n), s && (t[q] = e, P.assignTextureLOD(t, e).then((i) => {
|
|
706
706
|
this._lodchangedlisteners.forEach((r) => r({ type: "texture", level: e, object: t }));
|
|
707
707
|
}));
|
|
708
708
|
}
|
|
@@ -715,12 +715,12 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
715
715
|
loadProgressiveMeshes(t, e) {
|
|
716
716
|
if (!t)
|
|
717
717
|
return Promise.resolve(null);
|
|
718
|
-
let s = t[
|
|
718
|
+
let s = t[q] !== e;
|
|
719
719
|
const n = t["DEBUG:LOD"];
|
|
720
|
-
if (n != null && (s = t[
|
|
721
|
-
t[
|
|
720
|
+
if (n != null && (s = t[q] != n, e = n), s) {
|
|
721
|
+
t[q] = e;
|
|
722
722
|
const i = t.geometry;
|
|
723
|
-
return P.assignMeshLOD(t, e).then((r) => (r && t[
|
|
723
|
+
return P.assignMeshLOD(t, e).then((r) => (r && t[q] == e && i != t.geometry && this._lodchangedlisteners.forEach((o) => o({ type: "mesh", level: e, object: t })), r));
|
|
724
724
|
}
|
|
725
725
|
return Promise.resolve(null);
|
|
726
726
|
}
|
|
@@ -775,10 +775,10 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
775
775
|
}
|
|
776
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
|
-
let _ = u.x, S = u.y,
|
|
778
|
+
let _ = u.x, S = u.y, T = g.x, X = 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, S = (S - ue) * le + ue,
|
|
781
|
-
const Fe = _ < 0 &&
|
|
780
|
+
_ = (_ - ce) * le + ce, S = (S - ue) * le + ue, T = (T - ce) * le + ce, X = (X - ue) * le + ue;
|
|
781
|
+
const Fe = _ < 0 && T > 0 ? 0 : Math.min(Math.abs(u.x), Math.abs(g.x)), We = S < 0 && X > 0 ? 0 : Math.min(Math.abs(u.y), Math.abs(g.y)), ye = Math.max(Fe, We);
|
|
782
782
|
s.lastCentrality = (pe - ye) * (pe - ye) * (pe - ye);
|
|
783
783
|
} else
|
|
784
784
|
s.lastCentrality = 1;
|
|
@@ -786,14 +786,14 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
786
786
|
f.multiplyScalar(0.5), screen.availHeight > 0 && L > 0 && f.multiplyScalar(L / screen.availHeight), t.isPerspectiveCamera ? f.x *= t.aspect : t.isOrthographicCamera;
|
|
787
787
|
const w = t.matrixWorldInverse, $ = this._tempBox2;
|
|
788
788
|
$.copy(D), $.applyMatrix4(e.matrixWorld), $.applyMatrix4(w);
|
|
789
|
-
const B = $.getSize(this._tempBox2Size),
|
|
790
|
-
if (Math.max(f.x, f.y) != 0 &&
|
|
789
|
+
const B = $.getSize(this._tempBox2Size), E = Math.max(B.x, B.y);
|
|
790
|
+
if (Math.max(f.x, f.y) != 0 && E != 0 && (f.z = B.z / Math.max(B.x, B.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, R && C.debugDrawLine) {
|
|
791
791
|
const u = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
792
792
|
u.invert();
|
|
793
|
-
const g = C.corner0, _ = C.corner1, S = C.corner2,
|
|
794
|
-
g.copy(this._tempBox.min), _.copy(this._tempBox.max), _.x = g.x, S.copy(this._tempBox.max), S.y = g.y,
|
|
795
|
-
const
|
|
796
|
-
g.z = _.z = S.z =
|
|
793
|
+
const g = C.corner0, _ = C.corner1, S = C.corner2, T = C.corner3;
|
|
794
|
+
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);
|
|
795
|
+
const X = (g.z + T.z) * 0.5;
|
|
796
|
+
g.z = _.z = S.z = T.z = X, 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);
|
|
797
797
|
}
|
|
798
798
|
let v = 999;
|
|
799
799
|
if (l && s.lastScreenCoverage > 0) {
|
|
@@ -821,11 +821,11 @@ const R = oe("debugprogressive"), ct = oe("noprogressive"), me = Symbol("Needle:
|
|
|
821
821
|
let w = s.lastScreenCoverage * 4;
|
|
822
822
|
((k = this.context) == null ? void 0 : k.engine) === "model-viewer" && (w *= 1.5);
|
|
823
823
|
const B = L / window.devicePixelRatio * w;
|
|
824
|
-
let
|
|
824
|
+
let E = !1;
|
|
825
825
|
for (let U = h.lods.length - 1; U >= 0; U--) {
|
|
826
826
|
let v = h.lods[U];
|
|
827
|
-
if (!(m && v.max_height >= 2048) && !(rt() && v.max_height > 4096) && (v.max_height > B || !
|
|
828
|
-
if (
|
|
827
|
+
if (!(m && v.max_height >= 2048) && !(rt() && v.max_height > 4096) && (v.max_height > B || !E && U === 0)) {
|
|
828
|
+
if (E = !0, i.texture_lod = U, i.texture_lod < s.lastLodLevel_Texture) {
|
|
829
829
|
const O = v.max_height;
|
|
830
830
|
R && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${O}px
|
|
831
831
|
Screensize: ${B.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${f.toFixed(1)}
|
|
@@ -841,7 +841,7 @@ ${e.name}`);
|
|
|
841
841
|
};
|
|
842
842
|
let V = C;
|
|
843
843
|
b = /* @__PURE__ */ new WeakMap();
|
|
844
|
-
|
|
844
|
+
K = /* @__PURE__ */ new WeakMap();
|
|
845
845
|
Oe = /* @__PURE__ */ new WeakMap();
|
|
846
846
|
Z = /* @__PURE__ */ new WeakMap();
|
|
847
847
|
ie = /* @__PURE__ */ new WeakMap();
|
|
@@ -1022,12 +1022,12 @@ if (!it) {
|
|
|
1022
1022
|
globalThis.Needle[e] = t[e];
|
|
1023
1023
|
}
|
|
1024
1024
|
export {
|
|
1025
|
-
V as
|
|
1026
|
-
P as
|
|
1027
|
-
Ie as
|
|
1028
|
-
Ge as
|
|
1029
|
-
Re as
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1025
|
+
V as LODsManager,
|
|
1026
|
+
P as NEEDLE_progressive,
|
|
1027
|
+
Ie as addDracoAndKTX2Loaders,
|
|
1028
|
+
Ge as configureLoader,
|
|
1029
|
+
Re as createLoaders,
|
|
1030
|
+
ae as getRaycastMesh,
|
|
1031
|
+
je as setDracoDecoderLocation,
|
|
1032
|
+
et as setKTX2TranscoderLocation
|
|
1033
1033
|
};
|