@needle-tools/engine 4.7.0-next.ef983f9 → 4.7.0-next.fe38209
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 +5 -0
- package/dist/{gltf-progressive-Bl4okF1b.min.js → gltf-progressive-60Qk5ebF.min.js} +6 -6
- package/dist/{gltf-progressive-DSpdn0QT.js → gltf-progressive-DM5ZiecW.js} +176 -170
- package/dist/gltf-progressive-wxtaVmio.umd.cjs +8 -0
- package/dist/{needle-engine.bundle-450ujan4.js → needle-engine.bundle-9cpwwMWz.js} +3451 -3439
- package/dist/{needle-engine.bundle-CbNroJbN.umd.cjs → needle-engine.bundle-B5YoLPqw.umd.cjs} +115 -115
- package/dist/{needle-engine.bundle-BDMr_I34.min.js → needle-engine.bundle-DlHpd9LP.min.js} +113 -113
- package/dist/needle-engine.js +3 -3
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_addressables.d.ts +1 -3
- package/lib/engine/engine_addressables.js +5 -12
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_lightdata.js +12 -2
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_lods.d.ts +4 -0
- package/lib/engine/engine_lods.js +19 -5
- package/lib/engine/engine_lods.js.map +1 -1
- package/package.json +2 -2
- package/plugins/common/logger.js +156 -51
- package/plugins/types/userconfig.d.ts +3 -1
- package/plugins/vite/logger.client.js +80 -24
- package/plugins/vite/logger.js +22 -6
- package/src/engine/engine_addressables.ts +6 -15
- package/src/engine/engine_lightdata.ts +10 -2
- package/src/engine/engine_lods.ts +23 -5
- package/dist/gltf-progressive-P8b8a0qY.umd.cjs +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var qe = Object.defineProperty;
|
|
2
|
-
var Ae = (
|
|
3
|
-
throw TypeError(
|
|
2
|
+
var Ae = (i) => {
|
|
3
|
+
throw TypeError(i);
|
|
4
4
|
};
|
|
5
|
-
var Ke = (
|
|
6
|
-
var d = (
|
|
7
|
-
var m = (
|
|
5
|
+
var Ke = (i, e, t) => e in i ? qe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
6
|
+
var d = (i, e, t) => Ke(i, typeof e != "symbol" ? e + "" : e, t), Pe = (i, e, t) => e.has(i) || Ae("Cannot " + t);
|
|
7
|
+
var m = (i, e, t) => (Pe(i, e, "read from private field"), t ? t.call(i) : e.get(i)), H = (i, e, t) => e.has(i) ? Ae("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), F = (i, e, t, s) => (Pe(i, e, "write to private field"), s ? s.call(i, t) : e.set(i, t), t);
|
|
8
8
|
import { BufferGeometry as he, Mesh as Z, Texture as se, TextureLoader as Ye, Matrix4 as Ee, Clock as He, MeshStandardMaterial as Je, Sphere as Qe, Box3 as Ce, Vector3 as W } from "./three-DrqIzZTH.js";
|
|
9
9
|
import { DRACOLoader as Ze, KTX2Loader as je, MeshoptDecoder as et, GLTFLoader as Te } from "./three-examples-B50TT3Iu.js";
|
|
10
10
|
const tt = "";
|
|
@@ -18,57 +18,57 @@ fetch(Ge, {
|
|
|
18
18
|
headers: {
|
|
19
19
|
Range: "bytes=0-1"
|
|
20
20
|
}
|
|
21
|
-
}).catch((
|
|
22
|
-
console.debug(`Failed to fetch remote Draco decoder from ${N} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), N === st && nt("./include/draco/"), j === rt &&
|
|
21
|
+
}).catch((i) => {
|
|
22
|
+
console.debug(`Failed to fetch remote Draco decoder from ${N} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), N === st && nt("./include/draco/"), j === rt && ot("./include/ktx2/");
|
|
23
23
|
}).finally(() => {
|
|
24
24
|
$e();
|
|
25
25
|
});
|
|
26
|
-
function nt(
|
|
27
|
-
N =
|
|
26
|
+
function nt(i) {
|
|
27
|
+
N = i, C && C[Oe] != N ? (console.debug("Updating Draco decoder path to " + i), C[Oe] = N, C.setDecoderPath(N), C.preload()) : console.debug("Setting Draco decoder path to " + i);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
j =
|
|
29
|
+
function ot(i) {
|
|
30
|
+
j = i, G && G.transcoderPath != j ? (console.debug("Updating KTX2 transcoder path to " + i), G.setTranscoderPath(j), G.init()) : console.debug("Setting KTX2 transcoder path to " + i);
|
|
31
31
|
}
|
|
32
32
|
const Oe = Symbol("dracoDecoderPath");
|
|
33
33
|
let C, ge, G;
|
|
34
34
|
function $e() {
|
|
35
35
|
C || (C = new Ze(), C[Oe] = N, C.setDecoderPath(N), C.setDecoderConfig({ type: "js" }), C.preload()), G || (G = new je(), G.setTranscoderPath(j), G.init()), ge || (ge = et);
|
|
36
36
|
}
|
|
37
|
-
function Ue(
|
|
38
|
-
return $e(),
|
|
37
|
+
function Ue(i) {
|
|
38
|
+
return $e(), i ? G.detectSupport(i) : i !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: C, ktx2Loader: G, meshoptDecoder: ge };
|
|
39
39
|
}
|
|
40
|
-
function Fe(
|
|
41
|
-
|
|
40
|
+
function Fe(i) {
|
|
41
|
+
i.dracoLoader || i.setDRACOLoader(C), i.ktx2Loader || i.setKTX2Loader(G), i.meshoptDecoder || i.setMeshoptDecoder(ge);
|
|
42
42
|
}
|
|
43
43
|
const _e = /* @__PURE__ */ new WeakMap();
|
|
44
|
-
function Ne(
|
|
45
|
-
let t = _e.get(
|
|
46
|
-
t ? t = Object.assign(t, e) : t = e, _e.set(
|
|
44
|
+
function Ne(i, e) {
|
|
45
|
+
let t = _e.get(i);
|
|
46
|
+
t ? t = Object.assign(t, e) : t = e, _e.set(i, t);
|
|
47
47
|
}
|
|
48
48
|
const De = Te.prototype.load;
|
|
49
|
-
function
|
|
49
|
+
function it(...i) {
|
|
50
50
|
const e = _e.get(this);
|
|
51
|
-
let t =
|
|
51
|
+
let t = i[0];
|
|
52
52
|
const s = new URL(t, window.location.href);
|
|
53
53
|
if (s.hostname.endsWith("needle.tools")) {
|
|
54
54
|
const r = (e == null ? void 0 : e.progressive) !== void 0 ? e.progressive : !0, n = e != null && e.usecase ? e.usecase : "default";
|
|
55
55
|
r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${n}` : this.requestHeader.Accept = `*/*;usecase=${n}`, t = s.toString();
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return i[0] = t, De == null ? void 0 : De.call(this, ...i);
|
|
58
58
|
}
|
|
59
|
-
Te.prototype.load =
|
|
59
|
+
Te.prototype.load = it;
|
|
60
60
|
ae("debugprogressive");
|
|
61
|
-
function ae(
|
|
61
|
+
function ae(i) {
|
|
62
62
|
if (typeof window > "u") return !1;
|
|
63
|
-
const t = new URL(window.location.href).searchParams.get(
|
|
63
|
+
const t = new URL(window.location.href).searchParams.get(i);
|
|
64
64
|
return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
|
|
65
65
|
}
|
|
66
|
-
function at(
|
|
67
|
-
if (e === void 0 || e.startsWith("./") || e.startsWith("http") ||
|
|
66
|
+
function at(i, e) {
|
|
67
|
+
if (e === void 0 || e.startsWith("./") || e.startsWith("http") || i === void 0)
|
|
68
68
|
return e;
|
|
69
|
-
const t =
|
|
69
|
+
const t = i.lastIndexOf("/");
|
|
70
70
|
if (t >= 0) {
|
|
71
|
-
const s =
|
|
71
|
+
const s = i.substring(0, t + 1);
|
|
72
72
|
for (; s.endsWith("/") && e.startsWith("/"); ) e = e.substring(1);
|
|
73
73
|
return s + e;
|
|
74
74
|
}
|
|
@@ -79,23 +79,23 @@ function lt() {
|
|
|
79
79
|
return re !== void 0 || (re = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), ae("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", re)), re;
|
|
80
80
|
}
|
|
81
81
|
const ct = typeof window > "u" && typeof document > "u", be = Symbol("needle:raycast-mesh");
|
|
82
|
-
function le(
|
|
83
|
-
return (
|
|
82
|
+
function le(i) {
|
|
83
|
+
return (i == null ? void 0 : i[be]) instanceof he ? i[be] : null;
|
|
84
84
|
}
|
|
85
|
-
function ut(
|
|
86
|
-
if ((
|
|
85
|
+
function ut(i, e) {
|
|
86
|
+
if ((i.type === "Mesh" || i.type === "SkinnedMesh") && !le(i)) {
|
|
87
87
|
const s = dt(e);
|
|
88
|
-
s.userData = { isRaycastMesh: !0 },
|
|
88
|
+
s.userData = { isRaycastMesh: !0 }, i[be] = s;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
function ft(
|
|
92
|
-
if (
|
|
91
|
+
function ft(i = !0) {
|
|
92
|
+
if (i) {
|
|
93
93
|
if (ne) return;
|
|
94
94
|
const e = ne = Z.prototype.raycast;
|
|
95
95
|
Z.prototype.raycast = function(t, s) {
|
|
96
|
-
const
|
|
96
|
+
const o = this, r = le(o);
|
|
97
97
|
let n;
|
|
98
|
-
r &&
|
|
98
|
+
r && o.isMesh && (n = o.geometry, o.geometry = r), e.call(this, t, s), n && (o.geometry = n);
|
|
99
99
|
};
|
|
100
100
|
} else {
|
|
101
101
|
if (!ne) return;
|
|
@@ -103,17 +103,17 @@ function ft(o = !0) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
let ne = null;
|
|
106
|
-
function dt(
|
|
106
|
+
function dt(i) {
|
|
107
107
|
const e = new he();
|
|
108
|
-
for (const t in
|
|
109
|
-
e.setAttribute(t,
|
|
110
|
-
return e.setIndex(
|
|
108
|
+
for (const t in i.attributes)
|
|
109
|
+
e.setAttribute(t, i.getAttribute(t));
|
|
110
|
+
return e.setIndex(i.getIndex()), e;
|
|
111
111
|
}
|
|
112
|
-
const Q = new Array(), X = "NEEDLE_progressive", L = ae("debugprogressive"), Me = Symbol("needle-progressive-texture"),
|
|
112
|
+
const Q = new Array(), X = "NEEDLE_progressive", L = ae("debugprogressive"), Me = Symbol("needle-progressive-texture"), ie = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Set();
|
|
113
113
|
if (L) {
|
|
114
|
-
let
|
|
115
|
-
e += 1, console.log("Toggle LOD level", e,
|
|
116
|
-
for (const n of
|
|
114
|
+
let i = function() {
|
|
115
|
+
e += 1, console.log("Toggle LOD level", e, ie), ie.forEach((o, r) => {
|
|
116
|
+
for (const n of o.keys) {
|
|
117
117
|
const a = r[n];
|
|
118
118
|
if (a != null)
|
|
119
119
|
if (a.isBufferGeometry === !0) {
|
|
@@ -123,18 +123,18 @@ if (L) {
|
|
|
123
123
|
}
|
|
124
124
|
}), e >= t && (e = -1);
|
|
125
125
|
}, e = -1, t = 2, s = !1;
|
|
126
|
-
window.addEventListener("keyup", (
|
|
127
|
-
|
|
126
|
+
window.addEventListener("keyup", (o) => {
|
|
127
|
+
o.key === "p" && i(), o.key === "w" && (s = !s, Se && Se.forEach((r) => {
|
|
128
128
|
r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = s);
|
|
129
129
|
}));
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
function Be(
|
|
133
|
-
var
|
|
132
|
+
function Be(i, e, t) {
|
|
133
|
+
var o;
|
|
134
134
|
if (!L) return;
|
|
135
|
-
|
|
136
|
-
const s =
|
|
137
|
-
((
|
|
135
|
+
ie.has(i) || ie.set(i, { keys: [], sourceId: t });
|
|
136
|
+
const s = ie.get(i);
|
|
137
|
+
((o = s == null ? void 0 : s.keys) == null ? void 0 : o.includes(e)) == !1 && s.keys.push(e);
|
|
138
138
|
}
|
|
139
139
|
const x = class x {
|
|
140
140
|
constructor(e, t) {
|
|
@@ -142,9 +142,9 @@ const x = class x {
|
|
|
142
142
|
d(this, "url");
|
|
143
143
|
d(this, "_isLoadingMesh");
|
|
144
144
|
d(this, "loadMesh", (e) => {
|
|
145
|
-
var s,
|
|
145
|
+
var s, o;
|
|
146
146
|
if (this._isLoadingMesh) return null;
|
|
147
|
-
const t = (
|
|
147
|
+
const t = (o = (s = this.parser.json.meshes[e]) == null ? void 0 : s.extensions) == null ? void 0 : o[X];
|
|
148
148
|
return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((r) => {
|
|
149
149
|
var n;
|
|
150
150
|
return this._isLoadingMesh = !1, r && x.registerMesh(this.url, t.guid, r, (n = t.lods) == null ? void 0 : n.length, void 0, t), r;
|
|
@@ -161,7 +161,7 @@ const x = class x {
|
|
|
161
161
|
return t != null && t.key ? this.lodInfos.get(t.key) : null;
|
|
162
162
|
}
|
|
163
163
|
static getMaterialMinMaxLODsCount(e, t) {
|
|
164
|
-
const s = this,
|
|
164
|
+
const s = this, o = "LODS:minmax", r = e[o];
|
|
165
165
|
if (r != null) return r;
|
|
166
166
|
if (t || (t = {
|
|
167
167
|
min_count: 1 / 0,
|
|
@@ -170,7 +170,7 @@ const x = class x {
|
|
|
170
170
|
}), Array.isArray(e)) {
|
|
171
171
|
for (const a of e)
|
|
172
172
|
this.getMaterialMinMaxLODsCount(a, t);
|
|
173
|
-
return e[
|
|
173
|
+
return e[o] = t, t;
|
|
174
174
|
}
|
|
175
175
|
if (L === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
|
|
176
176
|
const a = e;
|
|
@@ -183,7 +183,7 @@ const x = class x {
|
|
|
183
183
|
const l = e[a];
|
|
184
184
|
(l == null ? void 0 : l.isTexture) === !0 && n(l, t);
|
|
185
185
|
}
|
|
186
|
-
return e[
|
|
186
|
+
return e[o] = t, t;
|
|
187
187
|
function n(a, l) {
|
|
188
188
|
const u = s.getAssignedLODInformation(a);
|
|
189
189
|
if (u) {
|
|
@@ -222,12 +222,12 @@ const x = class x {
|
|
|
222
222
|
if (n.isMesh === !0 && this.hasLODLevelAvailable(n, t))
|
|
223
223
|
return !0;
|
|
224
224
|
}
|
|
225
|
-
let s,
|
|
225
|
+
let s, o;
|
|
226
226
|
if (e.isMesh ? s = e.geometry : (e.isBufferGeometry || e.isTexture) && (s = e), s && (r = s == null ? void 0 : s.userData) != null && r.LODS) {
|
|
227
227
|
const n = s.userData.LODS;
|
|
228
|
-
if (
|
|
229
|
-
if (
|
|
230
|
-
return Array.isArray(
|
|
228
|
+
if (o = this.lodInfos.get(n.key), t === void 0) return o != null;
|
|
229
|
+
if (o)
|
|
230
|
+
return Array.isArray(o.lods) ? t < o.lods.length : t === 0;
|
|
231
231
|
}
|
|
232
232
|
return !1;
|
|
233
233
|
}
|
|
@@ -249,17 +249,17 @@ const x = class x {
|
|
|
249
249
|
var s;
|
|
250
250
|
if (!e) return Promise.resolve(null);
|
|
251
251
|
if (e instanceof Z || e.isMesh === !0) {
|
|
252
|
-
const
|
|
252
|
+
const o = e.geometry, r = this.getAssignedLODInformation(o);
|
|
253
253
|
if (!r)
|
|
254
254
|
return Promise.resolve(null);
|
|
255
255
|
for (const n of Q)
|
|
256
256
|
(s = n.onBeforeGetLODMesh) == null || s.call(n, e, t);
|
|
257
|
-
return e["LOD:requested level"] = t, x.getOrLoadLOD(
|
|
257
|
+
return e["LOD:requested level"] = t, x.getOrLoadLOD(o, t).then((n) => {
|
|
258
258
|
if (Array.isArray(n)) {
|
|
259
259
|
const a = r.index || 0;
|
|
260
260
|
n = n[a];
|
|
261
261
|
}
|
|
262
|
-
return e["LOD:requested level"] === t && (delete e["LOD:requested level"], n &&
|
|
262
|
+
return e["LOD:requested level"] === t && (delete e["LOD:requested level"], n && o != n && ((n == null ? void 0 : n.isBufferGeometry) ? (e.geometry = n, L && Be(e, "geometry", r.url)) : L && console.error("Invalid LOD geometry", n))), n;
|
|
263
263
|
}).catch((n) => (console.error("Error loading mesh LOD", e, n), null));
|
|
264
264
|
} else L && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
|
|
265
265
|
return Promise.resolve(null);
|
|
@@ -269,12 +269,12 @@ const x = class x {
|
|
|
269
269
|
if (e.isMesh === !0) {
|
|
270
270
|
const s = e;
|
|
271
271
|
if (Array.isArray(s.material)) {
|
|
272
|
-
const
|
|
272
|
+
const o = new Array();
|
|
273
273
|
for (const r of s.material) {
|
|
274
274
|
const n = this.assignTextureLOD(r, t);
|
|
275
|
-
|
|
275
|
+
o.push(n);
|
|
276
276
|
}
|
|
277
|
-
return Promise.all(
|
|
277
|
+
return Promise.all(o).then((r) => {
|
|
278
278
|
const n = new Array();
|
|
279
279
|
for (const a of r)
|
|
280
280
|
Array.isArray(a) && n.push(...a);
|
|
@@ -284,14 +284,14 @@ const x = class x {
|
|
|
284
284
|
return this.assignTextureLOD(s.material, t);
|
|
285
285
|
}
|
|
286
286
|
if (e.isMaterial === !0) {
|
|
287
|
-
const s = e,
|
|
287
|
+
const s = e, o = [], r = new Array();
|
|
288
288
|
if (L && Se.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
289
289
|
const n = s;
|
|
290
290
|
for (const a of Object.keys(n.uniforms)) {
|
|
291
291
|
const l = n.uniforms[a].value;
|
|
292
292
|
if ((l == null ? void 0 : l.isTexture) === !0) {
|
|
293
293
|
const u = this.assignTextureLODForSlot(l, t, s, a).then((c) => (c && n.uniforms[a].value != c && (n.uniforms[a].value = c, n.uniformsNeedUpdate = !0), c));
|
|
294
|
-
|
|
294
|
+
o.push(u), r.push(a);
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
} else
|
|
@@ -299,10 +299,10 @@ const x = class x {
|
|
|
299
299
|
const a = s[n];
|
|
300
300
|
if ((a == null ? void 0 : a.isTexture) === !0) {
|
|
301
301
|
const l = this.assignTextureLODForSlot(a, t, s, n);
|
|
302
|
-
|
|
302
|
+
o.push(l), r.push(n);
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
return Promise.all(
|
|
305
|
+
return Promise.all(o).then((n) => {
|
|
306
306
|
const a = new Array();
|
|
307
307
|
for (let l = 0; l < n.length; l++) {
|
|
308
308
|
const u = n[l], c = r[l];
|
|
@@ -317,23 +317,23 @@ const x = class x {
|
|
|
317
317
|
}
|
|
318
318
|
return Promise.resolve(null);
|
|
319
319
|
}
|
|
320
|
-
static assignTextureLODForSlot(e, t, s,
|
|
321
|
-
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) :
|
|
320
|
+
static assignTextureLODForSlot(e, t, s, o) {
|
|
321
|
+
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : o === "glyphMap" ? Promise.resolve(e) : x.getOrLoadLOD(e, t).then((r) => {
|
|
322
322
|
if (Array.isArray(r)) return null;
|
|
323
323
|
if ((r == null ? void 0 : r.isTexture) === !0) {
|
|
324
324
|
if (r != e) {
|
|
325
|
-
if (s &&
|
|
326
|
-
const n = s[
|
|
325
|
+
if (s && o) {
|
|
326
|
+
const n = s[o];
|
|
327
327
|
if (n && !L) {
|
|
328
328
|
const a = this.getAssignedLODInformation(n);
|
|
329
329
|
if (a && (a == null ? void 0 : a.level) < t)
|
|
330
330
|
return L === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, t, s, n, r), null;
|
|
331
331
|
}
|
|
332
|
-
s[
|
|
332
|
+
s[o] = r;
|
|
333
333
|
}
|
|
334
|
-
if (L &&
|
|
334
|
+
if (L && o && s) {
|
|
335
335
|
const n = this.getAssignedLODInformation(e);
|
|
336
|
-
n ? Be(s,
|
|
336
|
+
n ? Be(s, o, n.url) : console.warn("No LOD info for texture", e);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
return r;
|
|
@@ -343,10 +343,10 @@ const x = class x {
|
|
|
343
343
|
}
|
|
344
344
|
afterRoot(e) {
|
|
345
345
|
var t, s;
|
|
346
|
-
return L && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((
|
|
346
|
+
return L && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((o, r) => {
|
|
347
347
|
var n;
|
|
348
|
-
if (
|
|
349
|
-
const a =
|
|
348
|
+
if (o != null && o.extensions) {
|
|
349
|
+
const a = o == null ? void 0 : o.extensions[X];
|
|
350
350
|
if (a) {
|
|
351
351
|
if (!a.lods) {
|
|
352
352
|
L && console.warn("Texture has no LODs", a);
|
|
@@ -364,9 +364,9 @@ const x = class x {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
}), (s = this.parser.json.meshes) == null || s.forEach((
|
|
368
|
-
if (
|
|
369
|
-
const n =
|
|
367
|
+
}), (s = this.parser.json.meshes) == null || s.forEach((o, r) => {
|
|
368
|
+
if (o != null && o.extensions) {
|
|
369
|
+
const n = o == null ? void 0 : o.extensions[X];
|
|
370
370
|
if (n && n.lods) {
|
|
371
371
|
for (const a of this.parser.associations.keys())
|
|
372
372
|
if (a.isMesh) {
|
|
@@ -379,10 +379,10 @@ const x = class x {
|
|
|
379
379
|
}
|
|
380
380
|
static async getOrLoadLOD(e, t) {
|
|
381
381
|
var a, l, u, c;
|
|
382
|
-
const s = L == "verbose",
|
|
383
|
-
if (!
|
|
382
|
+
const s = L == "verbose", o = e.userData.LODS;
|
|
383
|
+
if (!o)
|
|
384
384
|
return null;
|
|
385
|
-
const r =
|
|
385
|
+
const r = o == null ? void 0 : o.key;
|
|
386
386
|
let n;
|
|
387
387
|
if (e.isTexture === !0) {
|
|
388
388
|
const g = e;
|
|
@@ -398,7 +398,7 @@ const x = class x {
|
|
|
398
398
|
const g = Array.isArray(n.lods) ? (a = n.lods[t]) == null ? void 0 : a.path : n.lods;
|
|
399
399
|
if (!g)
|
|
400
400
|
return L && !n["missing:uri"] && (n["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, n)), null;
|
|
401
|
-
const p = at(
|
|
401
|
+
const p = at(o.url, g);
|
|
402
402
|
if (p.endsWith(".glb") || p.endsWith(".gltf")) {
|
|
403
403
|
if (!n.guid)
|
|
404
404
|
return console.warn("missing pointer for glb/gltf texture", n), null;
|
|
@@ -438,7 +438,7 @@ const x = class x {
|
|
|
438
438
|
}
|
|
439
439
|
if (S) {
|
|
440
440
|
let f = await V.getDependency("texture", b);
|
|
441
|
-
return f && x.assignLODInformation(
|
|
441
|
+
return f && x.assignLODInformation(o.url, f, r, t, void 0, void 0), s && console.log('change "' + e.name + '" → "' + f.name + '"', p, b, f, v), e instanceof se && (f = this.copySettings(e, f)), f && (f.guid = D.guid), h(f);
|
|
442
442
|
} else L && console.warn("Could not find texture with guid", D.guid, A.parser.json);
|
|
443
443
|
}
|
|
444
444
|
if (b = 0, A.parser.json.meshes) {
|
|
@@ -457,14 +457,14 @@ const x = class x {
|
|
|
457
457
|
const f = await V.getDependency("mesh", b), y = D;
|
|
458
458
|
if (s && console.log(`Loaded Mesh "${f.name}"`, p, b, f, v), f.isMesh === !0) {
|
|
459
459
|
const _ = f.geometry;
|
|
460
|
-
return x.assignLODInformation(
|
|
460
|
+
return x.assignLODInformation(o.url, _, r, t, void 0, y.density), h(_);
|
|
461
461
|
} else {
|
|
462
462
|
const _ = new Array();
|
|
463
463
|
for (let T = 0; T < f.children.length; T++) {
|
|
464
464
|
const P = f.children[T];
|
|
465
465
|
if (P.isMesh === !0) {
|
|
466
466
|
const Y = P.geometry;
|
|
467
|
-
x.assignLODInformation(
|
|
467
|
+
x.assignLODInformation(o.url, Y, r, t, T, y.density), _.push(Y);
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
return h(_);
|
|
@@ -483,10 +483,10 @@ const x = class x {
|
|
|
483
483
|
L && console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`, e.type);
|
|
484
484
|
return null;
|
|
485
485
|
}
|
|
486
|
-
static assignLODInformation(e, t, s,
|
|
486
|
+
static assignLODInformation(e, t, s, o, r, n) {
|
|
487
487
|
if (!t) return;
|
|
488
488
|
t.userData || (t.userData = {});
|
|
489
|
-
const a = new ht(e, s,
|
|
489
|
+
const a = new ht(e, s, o, r, n);
|
|
490
490
|
t.userData.LODS = a;
|
|
491
491
|
}
|
|
492
492
|
static getAssignedLODInformation(e) {
|
|
@@ -503,18 +503,18 @@ const x = class x {
|
|
|
503
503
|
/**
|
|
504
504
|
* Register a texture with LOD information
|
|
505
505
|
*/
|
|
506
|
-
d(x, "registerTexture", (e, t, s,
|
|
507
|
-
if (L && console.log("> Progressive: register texture",
|
|
506
|
+
d(x, "registerTexture", (e, t, s, o, r) => {
|
|
507
|
+
if (L && console.log("> Progressive: register texture", o, t.name, t.uuid, t, r), !t) {
|
|
508
508
|
L && console.error("gltf-progressive: Register texture without texture");
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
511
|
t.source && (t.source[Me] = r);
|
|
512
512
|
const n = r.guid;
|
|
513
|
-
x.assignLODInformation(e, t, n, s,
|
|
513
|
+
x.assignLODInformation(e, t, n, s, o, void 0), x.lodInfos.set(n, r), x.lowresCache.set(n, t);
|
|
514
514
|
}), /**
|
|
515
515
|
* Register a mesh with LOD information
|
|
516
516
|
*/
|
|
517
|
-
d(x, "registerMesh", (e, t, s,
|
|
517
|
+
d(x, "registerMesh", (e, t, s, o, r, n) => {
|
|
518
518
|
var u;
|
|
519
519
|
L && console.log("> Progressive: register mesh", r, s.name, n, s.uuid, s);
|
|
520
520
|
const a = s.geometry;
|
|
@@ -522,9 +522,9 @@ d(x, "registerMesh", (e, t, s, i, r, n) => {
|
|
|
522
522
|
L && console.warn("gltf-progressive: Register mesh without geometry");
|
|
523
523
|
return;
|
|
524
524
|
}
|
|
525
|
-
a.userData || (a.userData = {}), x.assignLODInformation(e, a, t,
|
|
525
|
+
a.userData || (a.userData = {}), x.assignLODInformation(e, a, t, o, r, n.density), x.lodInfos.set(t, n);
|
|
526
526
|
let l = x.lowresCache.get(t);
|
|
527
|
-
l ? l.push(s.geometry) : l = [s.geometry], x.lowresCache.set(t, l),
|
|
527
|
+
l ? l.push(s.geometry) : l = [s.geometry], x.lowresCache.set(t, l), o > 0 && !le(s) && ut(s, a);
|
|
528
528
|
for (const c of Q)
|
|
529
529
|
(u = c.onRegisteredNewMesh) == null || u.call(c, s, n);
|
|
530
530
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
@@ -533,7 +533,7 @@ d(x, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geome
|
|
|
533
533
|
d(x, "lowresCache", /* @__PURE__ */ new Map());
|
|
534
534
|
let z = x;
|
|
535
535
|
class ht {
|
|
536
|
-
constructor(e, t, s,
|
|
536
|
+
constructor(e, t, s, o, r) {
|
|
537
537
|
d(this, "url");
|
|
538
538
|
/** the key to lookup the LOD information */
|
|
539
539
|
d(this, "key");
|
|
@@ -542,10 +542,10 @@ class ht {
|
|
|
542
542
|
d(this, "index");
|
|
543
543
|
/** the mesh density */
|
|
544
544
|
d(this, "density");
|
|
545
|
-
this.url = e, this.key = t, this.level = s,
|
|
545
|
+
this.url = e, this.key = t, this.level = s, o != null && (this.index = o), r != null && (this.density = r);
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
-
const
|
|
548
|
+
const I = ae("debugprogressive"), gt = ae("noprogressive"), we = Symbol("Needle:LODSManager"), ve = Symbol("Needle:LODState"), J = Symbol("Needle:CurrentLOD"), R = { mesh_lod: -1, texture_lod: -1 };
|
|
549
549
|
var w, E, q, ye, ee, te, me, K;
|
|
550
550
|
let pe = (w = class {
|
|
551
551
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
@@ -558,6 +558,12 @@ let pe = (w = class {
|
|
|
558
558
|
* @default 200_000
|
|
559
559
|
*/
|
|
560
560
|
d(this, "targetTriangleDensity", 2e5);
|
|
561
|
+
/**
|
|
562
|
+
* The interval in frames to automatically update the bounds of skinned meshes.
|
|
563
|
+
* Set to 0 or a negative value to disable automatic bounds updates.
|
|
564
|
+
* @default 30
|
|
565
|
+
*/
|
|
566
|
+
d(this, "skinnedMeshAutoUpdateBoundsInterval", 30);
|
|
561
567
|
/**
|
|
562
568
|
* The update interval in frames. If set to 0, the LODs will be updated every frame. If set to 2, the LODs will be updated every second frame, etc.
|
|
563
569
|
* @default "auto"
|
|
@@ -640,11 +646,11 @@ let pe = (w = class {
|
|
|
640
646
|
let e = 0;
|
|
641
647
|
F(this, q, this.renderer.render);
|
|
642
648
|
const t = this;
|
|
643
|
-
Ue(this.renderer), this.renderer.render = function(s,
|
|
649
|
+
Ue(this.renderer), this.renderer.render = function(s, o) {
|
|
644
650
|
const r = t.renderer.getRenderTarget();
|
|
645
|
-
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, F(t, ee, m(t, ee) + 1), F(t, te, m(t, ye).getDelta()), F(t, me, m(t, me) + m(t, te)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / m(t, te)), F(t, K, t._fpsBuffer.reduce((a, l) => a + l) / t._fpsBuffer.length),
|
|
651
|
+
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, F(t, ee, m(t, ee) + 1), F(t, te, m(t, ye).getDelta()), F(t, me, m(t, me) + m(t, te)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / m(t, te)), F(t, K, t._fpsBuffer.reduce((a, l) => a + l) / t._fpsBuffer.length), I && m(t, ee) % 200 === 0 && console.log("FPS", Math.round(m(t, K)), "Interval:", m(t, E)));
|
|
646
652
|
const n = e++;
|
|
647
|
-
m(t, q).call(this, s,
|
|
653
|
+
m(t, q).call(this, s, o), t.onAfterRender(s, o, n);
|
|
648
654
|
};
|
|
649
655
|
}
|
|
650
656
|
disable() {
|
|
@@ -662,7 +668,7 @@ let pe = (w = class {
|
|
|
662
668
|
(a.name === "EffectMaterial" || a.name === "CopyShader") && (n = !1);
|
|
663
669
|
}
|
|
664
670
|
if ((t.parent && t.parent.type === "CubeCamera" || s >= 1 && t.type === "OrthographicCamera") && (n = !1), n) {
|
|
665
|
-
if (gt || (this.updateInterval === "auto" ? m(this, K) < 40 && m(this, E) < 10 ? (F(this, E, m(this, E) + 1),
|
|
671
|
+
if (gt || (this.updateInterval === "auto" ? m(this, K) < 40 && m(this, E) < 10 ? (F(this, E, m(this, E) + 1), I && console.warn("↓ Reducing LOD updates", m(this, E), m(this, K).toFixed(0))) : m(this, K) >= 60 && m(this, E) > 1 && (F(this, E, m(this, E) - 1), I && console.warn("↑ Increasing LOD updates", m(this, E), m(this, K).toFixed(0))) : F(this, E, this.updateInterval), m(this, E) > 0 && m(this, ee) % m(this, E) != 0))
|
|
666
672
|
return;
|
|
667
673
|
this.internalUpdate(e, t);
|
|
668
674
|
}
|
|
@@ -672,12 +678,12 @@ let pe = (w = class {
|
|
|
672
678
|
*/
|
|
673
679
|
internalUpdate(e, t) {
|
|
674
680
|
var l, u;
|
|
675
|
-
const s = this.renderer.renderLists.get(e, 0),
|
|
681
|
+
const s = this.renderer.renderLists.get(e, 0), o = s.opaque;
|
|
676
682
|
this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse);
|
|
677
683
|
const r = this.targetTriangleDensity;
|
|
678
|
-
for (const c of
|
|
684
|
+
for (const c of o) {
|
|
679
685
|
if (c.material && (((l = c.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((u = c.geometry) == null ? void 0 : u.type) === "BufferGeometry") && (c.material.name === "SphericalGaussianBlur" || c.material.name == "BackgroundCubeMaterial" || c.material.name === "CubemapFromEquirect" || c.material.name === "EquirectangularToCubeUV")) {
|
|
680
|
-
|
|
686
|
+
I && (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", c, c.material.name, c.material.type)));
|
|
681
687
|
continue;
|
|
682
688
|
}
|
|
683
689
|
switch (c.material.type) {
|
|
@@ -689,7 +695,7 @@ let pe = (w = class {
|
|
|
689
695
|
case "MeshDepthMaterial":
|
|
690
696
|
continue;
|
|
691
697
|
}
|
|
692
|
-
if (
|
|
698
|
+
if (I === "color" && c.material && !c.object.progressive_debug_color) {
|
|
693
699
|
c.object.progressive_debug_color = !0;
|
|
694
700
|
const p = Math.random() * 16777215, v = new Je({ color: p });
|
|
695
701
|
c.object.material = v;
|
|
@@ -709,7 +715,7 @@ let pe = (w = class {
|
|
|
709
715
|
}
|
|
710
716
|
}
|
|
711
717
|
/** Update the LOD levels for the renderer. */
|
|
712
|
-
updateLODs(e, t, s,
|
|
718
|
+
updateLODs(e, t, s, o) {
|
|
713
719
|
var a, l;
|
|
714
720
|
s.userData || (s.userData = {});
|
|
715
721
|
let r = s[ve];
|
|
@@ -717,12 +723,12 @@ let pe = (w = class {
|
|
|
717
723
|
return;
|
|
718
724
|
for (const u of Q)
|
|
719
725
|
(a = u.onBeforeUpdateLOD) == null || a.call(u, this.renderer, e, t, s);
|
|
720
|
-
this.calculateLodLevel(t, s, r,
|
|
721
|
-
let n =
|
|
726
|
+
this.calculateLodLevel(t, s, r, o, R), R.mesh_lod = Math.round(R.mesh_lod), R.texture_lod = Math.round(R.texture_lod), R.mesh_lod >= 0 && this.loadProgressiveMeshes(s, R.mesh_lod);
|
|
727
|
+
let n = R.texture_lod;
|
|
722
728
|
s.material && n >= 0 && this.loadProgressiveTextures(s.material, n);
|
|
723
729
|
for (const u of Q)
|
|
724
|
-
(l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, e, t, s,
|
|
725
|
-
r.lastLodLevel_Mesh =
|
|
730
|
+
(l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, e, t, s, R);
|
|
731
|
+
r.lastLodLevel_Mesh = R.mesh_lod, r.lastLodLevel_Texture = R.texture_lod;
|
|
726
732
|
}
|
|
727
733
|
/** Load progressive textures for the given material
|
|
728
734
|
* @param material the material to load the textures for
|
|
@@ -738,8 +744,8 @@ let pe = (w = class {
|
|
|
738
744
|
}
|
|
739
745
|
let s = !1;
|
|
740
746
|
(e[J] === void 0 || t < e[J]) && (s = !0);
|
|
741
|
-
const
|
|
742
|
-
|
|
747
|
+
const o = e["DEBUG:LOD"];
|
|
748
|
+
o != null && (s = e[J] != o, t = o), s && (e[J] = t, z.assignTextureLOD(e, t).then((r) => {
|
|
743
749
|
this._lodchangedlisteners.forEach((n) => n({ type: "texture", level: t, object: e }));
|
|
744
750
|
}));
|
|
745
751
|
}
|
|
@@ -752,8 +758,8 @@ let pe = (w = class {
|
|
|
752
758
|
loadProgressiveMeshes(e, t) {
|
|
753
759
|
if (!e) return Promise.resolve(null);
|
|
754
760
|
let s = e[J] !== t;
|
|
755
|
-
const
|
|
756
|
-
if (
|
|
761
|
+
const o = e["DEBUG:LOD"];
|
|
762
|
+
if (o != null && (s = e[J] != o, t = o), s) {
|
|
757
763
|
e[J] = t;
|
|
758
764
|
const r = e.geometry;
|
|
759
765
|
return z.assignMeshLOD(e, t).then((n) => (n && e[J] == t && r != e.geometry && this._lodchangedlisteners.forEach((a) => a({ type: "mesh", level: t, object: e })), n));
|
|
@@ -761,10 +767,10 @@ let pe = (w = class {
|
|
|
761
767
|
return Promise.resolve(null);
|
|
762
768
|
}
|
|
763
769
|
static isInside(e, t) {
|
|
764
|
-
const s = e.min,
|
|
770
|
+
const s = e.min, o = e.max, r = (s.x + o.x) * 0.5, n = (s.y + o.y) * 0.5;
|
|
765
771
|
return this._tempPtInside.set(r, n, s.z).applyMatrix4(t).z < 0;
|
|
766
772
|
}
|
|
767
|
-
calculateLodLevel(e, t, s,
|
|
773
|
+
calculateLodLevel(e, t, s, o, r) {
|
|
768
774
|
var $;
|
|
769
775
|
if (!t) {
|
|
770
776
|
r.mesh_lod = -1, r.texture_lod = -1;
|
|
@@ -775,7 +781,7 @@ let pe = (w = class {
|
|
|
775
781
|
return;
|
|
776
782
|
}
|
|
777
783
|
let a = 10 + 1, l = !1;
|
|
778
|
-
if (
|
|
784
|
+
if (I && t["DEBUG:LOD"] != null)
|
|
779
785
|
return t["DEBUG:LOD"];
|
|
780
786
|
const u = z.getMeshLODInformation(t.geometry), c = u == null ? void 0 : u.lods, g = c && c.length > 0, p = z.getMaterialMinMaxLODsCount(t.material), v = (p == null ? void 0 : p.min_count) != 1 / 0 && p.min_count > 0 && p.max_count > 0;
|
|
781
787
|
if (!g && !v) {
|
|
@@ -789,7 +795,7 @@ let pe = (w = class {
|
|
|
789
795
|
const M = t;
|
|
790
796
|
if (!M.boundingBox)
|
|
791
797
|
M.computeBoundingBox();
|
|
792
|
-
else if (s.frames %
|
|
798
|
+
else if (this.skinnedMeshAutoUpdateBoundsInterval > 0 && s.frames % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
|
|
793
799
|
const h = le(M), B = M.geometry;
|
|
794
800
|
h && (M.geometry = h), M.computeBoundingBox(), M.geometry = B;
|
|
795
801
|
}
|
|
@@ -823,7 +829,7 @@ let pe = (w = class {
|
|
|
823
829
|
const B = e.matrixWorldInverse, U = this._tempBox2;
|
|
824
830
|
U.copy(D), U.applyMatrix4(t.matrixWorld), U.applyMatrix4(B);
|
|
825
831
|
const k = U.getSize(this._tempBox2Size), A = Math.max(k.x, k.y);
|
|
826
|
-
if (Math.max(h.x, h.y) != 0 && A != 0 && (h.z = k.z / Math.max(k.x, k.y) * Math.max(h.x, h.y)), s.lastScreenCoverage = Math.max(h.x, h.y, h.z), s.lastScreenspaceVolume.copy(h), s.lastScreenCoverage *= s.lastCentrality,
|
|
832
|
+
if (Math.max(h.x, h.y) != 0 && A != 0 && (h.z = k.z / Math.max(k.x, k.y) * Math.max(h.x, h.y)), s.lastScreenCoverage = Math.max(h.x, h.y, h.z), s.lastScreenspaceVolume.copy(h), s.lastScreenCoverage *= s.lastCentrality, I && w.debugDrawLine) {
|
|
827
833
|
const f = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
828
834
|
f.invert();
|
|
829
835
|
const y = w.corner0, _ = w.corner1, T = w.corner2, P = w.corner3;
|
|
@@ -834,23 +840,23 @@ let pe = (w = class {
|
|
|
834
840
|
let b = 999;
|
|
835
841
|
if (c && s.lastScreenCoverage > 0) {
|
|
836
842
|
for (let f = 0; f < c.length; f++)
|
|
837
|
-
if (c[f].density / s.lastScreenCoverage <
|
|
843
|
+
if (c[f].density / s.lastScreenCoverage < o) {
|
|
838
844
|
b = f;
|
|
839
845
|
break;
|
|
840
846
|
}
|
|
841
847
|
}
|
|
842
848
|
b < a && (a = b, l = !0);
|
|
843
849
|
}
|
|
844
|
-
if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh,
|
|
850
|
+
if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, I && r.mesh_lod != s.lastLodLevel_Mesh) {
|
|
845
851
|
const h = c == null ? void 0 : c[r.mesh_lod];
|
|
846
852
|
h && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${h.density.toFixed(0)}) - ${t.name}`);
|
|
847
853
|
}
|
|
848
854
|
if (v) {
|
|
849
855
|
const M = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
850
856
|
if (s.lastLodLevel_Texture < 0) {
|
|
851
|
-
if (r.texture_lod = p.max_count - 1,
|
|
857
|
+
if (r.texture_lod = p.max_count - 1, I) {
|
|
852
858
|
const h = p.lods[p.max_count - 1];
|
|
853
|
-
|
|
859
|
+
I && console.log(`First Texture LOD ${r.texture_lod} (${h.max_height}px) - ${t.name}`);
|
|
854
860
|
}
|
|
855
861
|
} else {
|
|
856
862
|
const h = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
@@ -859,11 +865,11 @@ let pe = (w = class {
|
|
|
859
865
|
const k = O / window.devicePixelRatio * B;
|
|
860
866
|
let A = !1;
|
|
861
867
|
for (let V = p.lods.length - 1; V >= 0; V--) {
|
|
862
|
-
|
|
868
|
+
const b = p.lods[V];
|
|
863
869
|
if (!(M && b.max_height >= 2048) && !(lt() && b.max_height > 4096) && (b.max_height > k || !A && V === 0)) {
|
|
864
870
|
if (A = !0, r.texture_lod = V, r.texture_lod < s.lastLodLevel_Texture) {
|
|
865
871
|
const S = b.max_height;
|
|
866
|
-
|
|
872
|
+
I && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${S}px
|
|
867
873
|
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${h.toFixed(1)}
|
|
868
874
|
${t.name}`);
|
|
869
875
|
}
|
|
@@ -888,64 +894,64 @@ class pt {
|
|
|
888
894
|
}
|
|
889
895
|
}
|
|
890
896
|
const ke = Symbol("NEEDLE_mesh_lod"), de = Symbol("NEEDLE_texture_lod");
|
|
891
|
-
let
|
|
897
|
+
let oe = null;
|
|
892
898
|
function ze() {
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
return
|
|
896
|
-
}),
|
|
899
|
+
const i = yt();
|
|
900
|
+
i && (i.mapURLs(function(e) {
|
|
901
|
+
return Ie(), e;
|
|
902
|
+
}), Ie(), oe == null || oe.disconnect(), oe = new MutationObserver((e) => {
|
|
897
903
|
e.forEach((t) => {
|
|
898
904
|
t.addedNodes.forEach((s) => {
|
|
899
905
|
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Ve(s);
|
|
900
906
|
});
|
|
901
907
|
});
|
|
902
|
-
}),
|
|
908
|
+
}), oe.observe(document, { childList: !0, subtree: !0 }));
|
|
903
909
|
}
|
|
904
910
|
function yt() {
|
|
905
911
|
if (typeof customElements > "u") return null;
|
|
906
|
-
const
|
|
907
|
-
return
|
|
912
|
+
const i = customElements.get("model-viewer");
|
|
913
|
+
return i || (customElements.whenDefined("model-viewer").then(() => {
|
|
908
914
|
console.debug("[gltf-progressive] model-viewer defined"), ze();
|
|
909
915
|
}), null);
|
|
910
916
|
}
|
|
911
|
-
function
|
|
917
|
+
function Ie() {
|
|
912
918
|
if (typeof document > "u") return;
|
|
913
919
|
document.querySelectorAll("model-viewer").forEach((e) => {
|
|
914
920
|
Ve(e);
|
|
915
921
|
});
|
|
916
922
|
}
|
|
917
|
-
const
|
|
923
|
+
const Re = /* @__PURE__ */ new WeakSet();
|
|
918
924
|
let mt = 0;
|
|
919
|
-
function Ve(
|
|
920
|
-
if (!
|
|
925
|
+
function Ve(i) {
|
|
926
|
+
if (!i || Re.has(i))
|
|
921
927
|
return null;
|
|
922
|
-
|
|
923
|
-
`,
|
|
928
|
+
Re.add(i), console.debug("[gltf-progressive] found new model-viewer..." + ++mt + `
|
|
929
|
+
`, i.getAttribute("src"));
|
|
924
930
|
let e = null, t = null, s = null;
|
|
925
|
-
for (let
|
|
926
|
-
const r = Object.getOwnPropertySymbols(
|
|
927
|
-
!e && n != null && (e =
|
|
931
|
+
for (let o = i; o != null; o = Object.getPrototypeOf(o)) {
|
|
932
|
+
const r = Object.getOwnPropertySymbols(o), n = r.find((u) => u.toString() == "Symbol(renderer)"), a = r.find((u) => u.toString() == "Symbol(scene)"), l = r.find((u) => u.toString() == "Symbol(needsRender)");
|
|
933
|
+
!e && n != null && (e = i[n].threeRenderer), !t && a != null && (t = i[a]), !s && l != null && (s = i[l]);
|
|
928
934
|
}
|
|
929
935
|
if (e && t) {
|
|
930
|
-
let
|
|
936
|
+
let o = function() {
|
|
931
937
|
if (s) {
|
|
932
938
|
let n = 0, a = setInterval(() => {
|
|
933
939
|
if (n++ > 5) {
|
|
934
940
|
clearInterval(a);
|
|
935
941
|
return;
|
|
936
942
|
}
|
|
937
|
-
s == null || s.call(
|
|
943
|
+
s == null || s.call(i);
|
|
938
944
|
}, 300);
|
|
939
945
|
}
|
|
940
946
|
};
|
|
941
947
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
942
948
|
const r = pe.get(e, { engine: "model-viewer" });
|
|
943
949
|
return pe.addPlugin(new Lt()), r.enable(), r.addEventListener("changed", () => {
|
|
944
|
-
s == null || s.call(
|
|
945
|
-
}),
|
|
946
|
-
n.detail.visible && (s == null || s.call(
|
|
947
|
-
}),
|
|
948
|
-
|
|
950
|
+
s == null || s.call(i);
|
|
951
|
+
}), i.addEventListener("model-visibility", (n) => {
|
|
952
|
+
n.detail.visible && (s == null || s.call(i));
|
|
953
|
+
}), i.addEventListener("load", () => {
|
|
954
|
+
o();
|
|
949
955
|
}), () => {
|
|
950
956
|
r.disable();
|
|
951
957
|
};
|
|
@@ -956,8 +962,8 @@ class Lt {
|
|
|
956
962
|
constructor() {
|
|
957
963
|
d(this, "_didWarnAboutMissingUrl", !1);
|
|
958
964
|
}
|
|
959
|
-
onBeforeUpdateLOD(e, t, s,
|
|
960
|
-
this.tryParseMeshLOD(t,
|
|
965
|
+
onBeforeUpdateLOD(e, t, s, o) {
|
|
966
|
+
this.tryParseMeshLOD(t, o), this.tryParseTextureLOD(t, o);
|
|
961
967
|
}
|
|
962
968
|
getUrl(e) {
|
|
963
969
|
if (!e)
|
|
@@ -974,7 +980,7 @@ class Lt {
|
|
|
974
980
|
tryParseTextureLOD(e, t) {
|
|
975
981
|
if (t[de] == !0) return;
|
|
976
982
|
t[de] = !0;
|
|
977
|
-
const s = this.tryGetCurrentGLTF(e),
|
|
983
|
+
const s = this.tryGetCurrentGLTF(e), o = this.tryGetCurrentModelViewer(e), r = this.getUrl(o);
|
|
978
984
|
if (r && s && t.material) {
|
|
979
985
|
let n = function(l) {
|
|
980
986
|
var c, g, p;
|
|
@@ -1007,27 +1013,27 @@ class Lt {
|
|
|
1007
1013
|
var n, a;
|
|
1008
1014
|
if (t[ke] == !0) return;
|
|
1009
1015
|
t[ke] = !0;
|
|
1010
|
-
const s = this.tryGetCurrentModelViewer(e),
|
|
1011
|
-
if (!
|
|
1016
|
+
const s = this.tryGetCurrentModelViewer(e), o = this.getUrl(s);
|
|
1017
|
+
if (!o)
|
|
1012
1018
|
return;
|
|
1013
1019
|
const r = (a = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : a[X];
|
|
1014
|
-
if (r &&
|
|
1020
|
+
if (r && o) {
|
|
1015
1021
|
const l = t.uuid;
|
|
1016
|
-
z.registerMesh(
|
|
1022
|
+
z.registerMesh(o, l, t, 0, r.lods.length, r);
|
|
1017
1023
|
}
|
|
1018
1024
|
}
|
|
1019
1025
|
}
|
|
1020
|
-
function xt(
|
|
1026
|
+
function xt(i, e, t, s) {
|
|
1021
1027
|
Ue(e), Fe(t), Ne(t, {
|
|
1022
1028
|
progressive: !0,
|
|
1023
1029
|
...s == null ? void 0 : s.hints
|
|
1024
|
-
}), t.register((r) => new z(r,
|
|
1025
|
-
const
|
|
1026
|
-
return (s == null ? void 0 : s.enableLODsManager) !== !1 &&
|
|
1030
|
+
}), t.register((r) => new z(r, i));
|
|
1031
|
+
const o = pe.get(e);
|
|
1032
|
+
return (s == null ? void 0 : s.enableLODsManager) !== !1 && o.enable(), o;
|
|
1027
1033
|
}
|
|
1028
1034
|
ze();
|
|
1029
1035
|
if (!ct) {
|
|
1030
|
-
const
|
|
1036
|
+
const i = {
|
|
1031
1037
|
gltfProgressive: {
|
|
1032
1038
|
useNeedleProgressive: xt,
|
|
1033
1039
|
LODsManager: pe,
|
|
@@ -1037,10 +1043,10 @@ if (!ct) {
|
|
|
1037
1043
|
}
|
|
1038
1044
|
};
|
|
1039
1045
|
if (!globalThis.Needle)
|
|
1040
|
-
globalThis.Needle =
|
|
1046
|
+
globalThis.Needle = i;
|
|
1041
1047
|
else
|
|
1042
|
-
for (const e in
|
|
1043
|
-
globalThis.Needle[e] =
|
|
1048
|
+
for (const e in i)
|
|
1049
|
+
globalThis.Needle[e] = i[e];
|
|
1044
1050
|
}
|
|
1045
1051
|
export {
|
|
1046
1052
|
pe as LODsManager,
|
|
@@ -1050,5 +1056,5 @@ export {
|
|
|
1050
1056
|
Ue as createLoaders,
|
|
1051
1057
|
le as getRaycastMesh,
|
|
1052
1058
|
nt as setDracoDecoderLocation,
|
|
1053
|
-
|
|
1059
|
+
ot as setKTX2TranscoderLocation
|
|
1054
1060
|
};
|