@needle-tools/engine 6.0.0-alpha.5 → 6.0.0-alpha.7
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 +9 -0
- package/dist/gltf-progressive-CRdzVlSY.umd.cjs +10 -0
- package/dist/gltf-progressive-OBdIERAY.min.js +10 -0
- package/dist/{gltf-progressive-B7lOWdLe.js → gltf-progressive-ZuAsp3FE.js} +237 -231
- package/dist/{materialx-CTPhpPxI.min.js → materialx-Bd0NThHa.min.js} +1 -1
- package/dist/{materialx-BwYvA-4x.umd.cjs → materialx-Clep-Dc8.umd.cjs} +2 -2
- package/dist/{materialx-B3qY8vPU.js → materialx-m9EM4lhZ.js} +1 -1
- package/dist/{needle-engine.bundle-_kAszB-k.min.js → needle-engine.bundle-B2_-yVCX.min.js} +148 -148
- package/dist/{needle-engine.bundle-D3nBMgfk.umd.cjs → needle-engine.bundle-BOs3iHUC.umd.cjs} +147 -147
- package/dist/{needle-engine.bundle-4xlWxOTF.js → needle-engine.bundle-hBHg3HuX.js} +7092 -7023
- package/dist/needle-engine.d.ts +49 -28
- package/dist/needle-engine.js +604 -603
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{vendor-BJviq-Oq.umd.cjs → vendor-Bb_SUKxZ.umd.cjs} +92 -92
- package/dist/{vendor-CdNldo8c.min.js → vendor-D1vc0sOe.min.js} +100 -100
- package/dist/{vendor-BQUQwut5.js → vendor-ipoLrKAE.js} +3466 -3320
- package/lib/engine/api.d.ts +2 -1
- package/lib/engine/api.js +2 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_context.d.ts +2 -0
- package/lib/engine/engine_context.js +14 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_init.js +2 -2
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_license.d.ts +7 -7
- package/lib/engine/engine_license.js +73 -73
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_loaders.gltf.d.ts +3 -1
- package/lib/engine/engine_loaders.gltf.js +6 -1
- package/lib/engine/engine_loaders.gltf.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +3 -3
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +2 -0
- package/lib/engine/engine_physics.js +23 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/project-document/engine_document_extensions.d.ts +16 -0
- package/lib/engine/project-document/engine_document_extensions.js +29 -0
- package/lib/engine/project-document/engine_document_extensions.js.map +1 -0
- package/lib/engine/project-document/engine_document_runtime.js +1 -1
- package/lib/engine/project-document/engine_document_runtime.js.map +1 -1
- package/lib/engine/project-document/engine_project_document.js +39 -3
- package/lib/engine/project-document/engine_project_document.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +5 -5
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +2 -2
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -1
- package/lib/engine-components/Renderer.js +2 -11
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/package.json +4 -4
- package/plugins/common/license.js +4 -4
- package/plugins/license/cli.js +7 -4
- package/plugins/vite/build-pipeline.js +6 -1
- package/plugins/vite/license.js +4 -4
- package/plugins/vite/logger.client.js +21 -8
- package/src/engine/api.ts +2 -1
- package/src/engine/engine_context.ts +11 -0
- package/src/engine/engine_init.ts +2 -2
- package/src/engine/engine_license.ts +70 -70
- package/src/engine/engine_loaders.gltf.ts +8 -2
- package/src/engine/engine_networking_blob.ts +3 -3
- package/src/engine/engine_physics.ts +22 -1
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/project-document/engine_document_extensions.ts +39 -0
- package/src/engine/project-document/engine_document_runtime.ts +1 -1
- package/src/engine/project-document/engine_project_document.ts +46 -3
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +5 -5
- package/src/engine/webcomponents/needle-engine.loading.ts +2 -2
- package/src/engine/webcomponents/needle-engine.ts +2 -2
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine-components/Renderer.ts +4 -13
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
- package/dist/gltf-progressive-BpT9M5Mt.umd.cjs +0 -10
- package/dist/gltf-progressive-D0rzvhNG.min.js +0 -10
|
@@ -1,62 +1,68 @@
|
|
|
1
|
-
import { RedFormat as
|
|
2
|
-
import { DRACOLoader as
|
|
3
|
-
const
|
|
4
|
-
globalThis.GLTF_PROGRESSIVE_VERSION =
|
|
1
|
+
import { RedFormat as je, RedIntegerFormat as He, RGFormat as Ke, RGIntegerFormat as Ye, RGBFormat as Qe, RGBAFormat as Je, RGBAIntegerFormat as Ze, BufferGeometry as K, Mesh as Y, Box3 as de, Vector3 as A, Sphere as Be, CompressedTexture as et, Texture as q, Matrix3 as tt, InterleavedBuffer as st, InterleavedBufferAttribute as rt, BufferAttribute as nt, TextureLoader as it, Matrix4 as qe, THREE as ot, Color as We } from "./three-core.js";
|
|
2
|
+
import { DRACOLoader as at, KTX2Loader as lt, MeshoptDecoder as ut, GLTFLoader as _e } from "./three-examples.js";
|
|
3
|
+
const ct = "";
|
|
4
|
+
globalThis.GLTF_PROGRESSIVE_VERSION = ct;
|
|
5
5
|
console.debug("[gltf-progressive] version -");
|
|
6
|
-
let
|
|
7
|
-
const
|
|
6
|
+
let B = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", Q = "https://cdn.needle.tools/static/three/0.179.1/basis2/";
|
|
7
|
+
const dt = B, ft = Q;
|
|
8
8
|
if (typeof window < "u") {
|
|
9
|
-
const i = new URL(
|
|
9
|
+
const i = new URL(B + "draco_decoder.js");
|
|
10
10
|
i.searchParams.append("range", "true"), fetch(i, {
|
|
11
11
|
method: "GET",
|
|
12
12
|
headers: {
|
|
13
13
|
Range: "bytes=0-1"
|
|
14
14
|
}
|
|
15
15
|
}).catch((t) => {
|
|
16
|
-
console.debug(`Failed to fetch remote Draco decoder from ${
|
|
16
|
+
console.debug(`Failed to fetch remote Draco decoder from ${B} (offline: ${navigator.onLine})`), B === dt && gt("./include/draco/"), Q === ft && pt("./include/ktx2/");
|
|
17
17
|
}).finally(() => {
|
|
18
|
-
|
|
18
|
+
be && Te();
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
dracoDecoderPath:
|
|
21
|
+
const ht = () => ({
|
|
22
|
+
dracoDecoderPath: B,
|
|
23
23
|
ktx2TranscoderPath: Q
|
|
24
24
|
});
|
|
25
|
-
function ht(i) {
|
|
26
|
-
G = i, k && k[Le] != G ? (console.debug("Updating Draco decoder path to " + i), k[Le] = G, k.setDecoderPath(G), k.preload()) : console.debug("Setting Draco decoder path to " + i);
|
|
27
|
-
}
|
|
28
25
|
function gt(i) {
|
|
29
|
-
|
|
26
|
+
B = i, P && P[Le] != B ? (console.debug("Updating Draco decoder path to " + i), P[Le] = B, P.setDecoderPath(B), P.preload()) : console.debug("Setting Draco decoder path to " + i);
|
|
27
|
+
}
|
|
28
|
+
function pt(i) {
|
|
29
|
+
Q = i, G && G.transcoderPath != Q ? (console.debug("Updating KTX2 transcoder path to " + i), G.setTranscoderPath(Q), G.init()) : console.debug("Setting KTX2 transcoder path to " + i);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
31
|
+
function Oe(i) {
|
|
32
|
+
be = !0;
|
|
33
|
+
const t = Te();
|
|
34
|
+
return i ? t.ktx2Loader.detectSupport(i) : i !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), t;
|
|
33
35
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
+
function Qt() {
|
|
37
|
+
be = !1, P?.dispose(), G?.dispose(), P = void 0, G = void 0;
|
|
38
|
+
}
|
|
39
|
+
function Fe(i) {
|
|
40
|
+
const { dracoLoader: t, ktx2Loader: e, meshoptDecoder: s } = Te();
|
|
41
|
+
i.dracoLoader || i.setDRACOLoader(t), i.ktx2Loader || i.setKTX2Loader(e), i.meshoptDecoder || i.setMeshoptDecoder(s);
|
|
36
42
|
}
|
|
37
43
|
const Le = /* @__PURE__ */ Symbol("dracoDecoderPath");
|
|
38
|
-
let
|
|
39
|
-
function
|
|
40
|
-
|
|
44
|
+
let be = !0, P, fe, G;
|
|
45
|
+
function Te() {
|
|
46
|
+
return P || (P = new at(), P[Le] = B, P.setDecoderPath(B), P.preload()), G || (G = new lt(), G.setTranscoderPath(Q), G.init()), fe || (fe = ut), { dracoLoader: P, ktx2Loader: G, meshoptDecoder: fe };
|
|
41
47
|
}
|
|
42
48
|
const we = /* @__PURE__ */ new WeakMap();
|
|
43
|
-
function
|
|
49
|
+
function Ue(i, t) {
|
|
44
50
|
let e = we.get(i);
|
|
45
51
|
e ? e = Object.assign(e, t) : e = t, we.set(i, e);
|
|
46
52
|
}
|
|
47
|
-
const
|
|
48
|
-
function
|
|
53
|
+
const mt = _e.prototype.load;
|
|
54
|
+
function yt(...i) {
|
|
49
55
|
const t = we.get(this);
|
|
50
56
|
let e = i[0];
|
|
51
|
-
const s =
|
|
57
|
+
const s = xt(e);
|
|
52
58
|
if (s?.hostname.endsWith("needle.tools")) {
|
|
53
59
|
const n = t?.progressive !== void 0 ? t.progressive : !0, o = t?.usecase ? t.usecase : "default";
|
|
54
60
|
n ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${o}` : this.requestHeader.Accept = `*/*;usecase=${o}`, e = s.toString();
|
|
55
61
|
}
|
|
56
|
-
return i[0] = e,
|
|
62
|
+
return i[0] = e, mt?.call(this, ...i);
|
|
57
63
|
}
|
|
58
|
-
_e.prototype.load =
|
|
59
|
-
function
|
|
64
|
+
_e.prototype.load = yt;
|
|
65
|
+
function xt(i) {
|
|
60
66
|
try {
|
|
61
67
|
if (i instanceof URL)
|
|
62
68
|
return i;
|
|
@@ -66,19 +72,19 @@ function yt(i) {
|
|
|
66
72
|
return null;
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
|
-
function
|
|
75
|
+
function Pe(i) {
|
|
70
76
|
return i != null && i.data != null;
|
|
71
77
|
}
|
|
72
78
|
function ve(i) {
|
|
73
79
|
const t = i.source?.data;
|
|
74
80
|
return t != null && typeof t == "object" ? t : null;
|
|
75
81
|
}
|
|
76
|
-
function
|
|
82
|
+
function Lt(i) {
|
|
77
83
|
const t = i.image;
|
|
78
84
|
return t != null && typeof t == "object" ? t : null;
|
|
79
85
|
}
|
|
80
86
|
function De(i) {
|
|
81
|
-
const t =
|
|
87
|
+
const t = Lt(i), e = ve(i);
|
|
82
88
|
return {
|
|
83
89
|
width: t?.width || e?.width || 0,
|
|
84
90
|
height: t?.height || e?.height || 0
|
|
@@ -91,7 +97,7 @@ function V(i) {
|
|
|
91
97
|
const s = new URL(t).searchParams.get(i);
|
|
92
98
|
return s == null || s === "0" || s === "false" ? !1 : s === "" ? !0 : s;
|
|
93
99
|
}
|
|
94
|
-
function
|
|
100
|
+
function wt(i, t) {
|
|
95
101
|
if (t === void 0 || i === void 0 || t.startsWith("./") || t.startsWith("http") || t.startsWith("data:") || t.startsWith("blob:"))
|
|
96
102
|
return t;
|
|
97
103
|
const e = i.lastIndexOf("/");
|
|
@@ -102,21 +108,21 @@ function Lt(i, t) {
|
|
|
102
108
|
}
|
|
103
109
|
return t;
|
|
104
110
|
}
|
|
105
|
-
function
|
|
111
|
+
function Se() {
|
|
106
112
|
if (se !== void 0) return se;
|
|
107
113
|
const i = globalThis.navigator?.userAgent || "";
|
|
108
114
|
return se = /iPhone|iPad|iPod|Android|IEMobile/i.test(i), V("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", se), se;
|
|
109
115
|
}
|
|
110
116
|
let se;
|
|
111
|
-
function
|
|
117
|
+
function ze() {
|
|
112
118
|
const i = globalThis.location?.href;
|
|
113
119
|
if (!i) return !1;
|
|
114
120
|
const t = new URL(i), e = t.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t.hostname);
|
|
115
121
|
return t.hostname === "127.0.0.1" || e;
|
|
116
122
|
}
|
|
117
|
-
class
|
|
123
|
+
class vt {
|
|
118
124
|
constructor(t, e = {}) {
|
|
119
|
-
this.maxConcurrent = t, this.debug = e.debug ?? !1,
|
|
125
|
+
this.maxConcurrent = t, this.debug = e.debug ?? !1, setTimeout(this.tick, 0);
|
|
120
126
|
}
|
|
121
127
|
maxConcurrent;
|
|
122
128
|
_running = /* @__PURE__ */ new Map();
|
|
@@ -149,25 +155,25 @@ class wt {
|
|
|
149
155
|
}
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
|
-
function
|
|
153
|
-
const t = i.image, e = t?.width ?? 0, s = t?.height ?? 0, r = t?.depth ?? 1, n = Math.floor(Math.log2(Math.max(e, s, r))) + 1, o =
|
|
158
|
+
function Dt(i) {
|
|
159
|
+
const t = i.image, e = t?.width ?? 0, s = t?.height ?? 0, r = t?.depth ?? 1, n = Math.floor(Math.log2(Math.max(e, s, r))) + 1, o = Mt(i);
|
|
154
160
|
return e * s * r * o * (1 - Math.pow(0.25, n)) / (1 - 0.25);
|
|
155
161
|
}
|
|
156
|
-
function
|
|
162
|
+
function Mt(i) {
|
|
157
163
|
let t = 4;
|
|
158
164
|
const e = i.format;
|
|
159
|
-
e ===
|
|
165
|
+
e === je || e === He ? t = 1 : e === Ke || e === Ye ? t = 2 : e === Qe || e === 1029 ? t = 3 : (e === Je || e === Ze) && (t = 4);
|
|
160
166
|
let s = 1;
|
|
161
167
|
const r = i.type;
|
|
162
168
|
return r === 1009 || r === 1010 ? s = 1 : r === 1011 || r === 1012 ? s = 2 : r === 1013 || r === 1014 || r === 1015 ? s = 4 : r === 1016 && (s = 2), t * s;
|
|
163
169
|
}
|
|
164
|
-
const
|
|
170
|
+
const _t = typeof window > "u" && typeof document > "u", Me = /* @__PURE__ */ Symbol("needle:raycast-mesh");
|
|
165
171
|
function ae(i) {
|
|
166
172
|
return i?.[Me] instanceof K ? i[Me] : null;
|
|
167
173
|
}
|
|
168
|
-
function
|
|
174
|
+
function Ot(i, t) {
|
|
169
175
|
if ((i.type === "Mesh" || i.type === "SkinnedMesh") && !ae(i)) {
|
|
170
|
-
const s =
|
|
176
|
+
const s = Tt(t);
|
|
171
177
|
s.userData = { isRaycastMesh: !0 }, i[Me] = s;
|
|
172
178
|
}
|
|
173
179
|
}
|
|
@@ -186,7 +192,7 @@ function bt(i = !0) {
|
|
|
186
192
|
}
|
|
187
193
|
}
|
|
188
194
|
let re = null;
|
|
189
|
-
function
|
|
195
|
+
function Tt(i) {
|
|
190
196
|
const t = new K();
|
|
191
197
|
for (const e in i.attributes)
|
|
192
198
|
t.setAttribute(e, i.getAttribute(e));
|
|
@@ -205,27 +211,27 @@ if (g && typeof window < "u") {
|
|
|
205
211
|
!isNaN(s) && s >= 0 && (j = s, console.log(`Set LOD level to [${j}]`));
|
|
206
212
|
});
|
|
207
213
|
}
|
|
208
|
-
function
|
|
214
|
+
function Ee(i) {
|
|
209
215
|
if (g && oe !== void 0)
|
|
210
216
|
if (Array.isArray(i))
|
|
211
217
|
for (const t of i)
|
|
212
|
-
|
|
218
|
+
Ee(t);
|
|
213
219
|
else i && "wireframe" in i && (i.wireframe = oe === !0);
|
|
214
220
|
}
|
|
215
221
|
const ne = new Array();
|
|
216
|
-
let
|
|
217
|
-
const
|
|
218
|
-
function
|
|
219
|
-
if (ne.length <
|
|
222
|
+
let St = 0;
|
|
223
|
+
const Rt = Se() ? 2 : 10;
|
|
224
|
+
function Pt(i) {
|
|
225
|
+
if (ne.length < Rt) {
|
|
220
226
|
const s = ne.length;
|
|
221
227
|
g && console.warn(`[Worker] Creating new worker #${s}`);
|
|
222
|
-
const r =
|
|
228
|
+
const r = Re.createWorker(i || {});
|
|
223
229
|
return ne.push(r), r;
|
|
224
230
|
}
|
|
225
|
-
const t =
|
|
231
|
+
const t = St++ % ne.length;
|
|
226
232
|
return ne[t];
|
|
227
233
|
}
|
|
228
|
-
class
|
|
234
|
+
class Re {
|
|
229
235
|
constructor(t, e) {
|
|
230
236
|
this.worker = t, this._debug = e.debug ?? !1, t.onmessage = (s) => {
|
|
231
237
|
const r = s.data;
|
|
@@ -233,7 +239,7 @@ class Te {
|
|
|
233
239
|
case "loaded-gltf":
|
|
234
240
|
for (const n of this._running)
|
|
235
241
|
if (n.url === r.result.url) {
|
|
236
|
-
|
|
242
|
+
Ct(r.result), n.resolve(r.result);
|
|
237
243
|
const o = n.url;
|
|
238
244
|
o.startsWith("blob:") && URL.revokeObjectURL(o);
|
|
239
245
|
}
|
|
@@ -249,18 +255,18 @@ class Te {
|
|
|
249
255
|
const e = /* new-worker */ new Worker(URL.createObjectURL(new Blob(["import '" + `${new URL('./gltf-progressive.worker-DvoMaVdx.js', import.meta.url).toString()}` + "';"], { type: 'text/javascript' })), {
|
|
250
256
|
type: "module"
|
|
251
257
|
});
|
|
252
|
-
return new
|
|
258
|
+
return new Re(e, t);
|
|
253
259
|
}
|
|
254
260
|
_running = [];
|
|
255
261
|
_webglRenderer = null;
|
|
256
262
|
async load(t, e) {
|
|
257
|
-
const s =
|
|
263
|
+
const s = ht();
|
|
258
264
|
let r = e?.renderer;
|
|
259
265
|
r || (this._webglRenderer ??= (async () => {
|
|
260
|
-
const { WebGLRenderer: u } = await import("./three-core.js").then((
|
|
266
|
+
const { WebGLRenderer: u } = await import("./three-core.js").then((f) => f.THREE);
|
|
261
267
|
return new u();
|
|
262
268
|
})(), r = await this._webglRenderer);
|
|
263
|
-
const l =
|
|
269
|
+
const l = Oe(r).ktx2Loader.workerConfig;
|
|
264
270
|
if (t instanceof URL)
|
|
265
271
|
t = t.toString();
|
|
266
272
|
else if (t.startsWith("file:"))
|
|
@@ -285,7 +291,7 @@ class Te {
|
|
|
285
291
|
}
|
|
286
292
|
_debug = !1;
|
|
287
293
|
}
|
|
288
|
-
function
|
|
294
|
+
function Ct(i) {
|
|
289
295
|
for (const t of i.geometries) {
|
|
290
296
|
const e = t.geometry, s = new K();
|
|
291
297
|
if (s.name = e.name || "", e.index) {
|
|
@@ -309,7 +315,7 @@ function Pt(i) {
|
|
|
309
315
|
e.boundingBox?.max.x,
|
|
310
316
|
e.boundingBox?.max.y,
|
|
311
317
|
e.boundingBox?.max.z
|
|
312
|
-
), s.boundingSphere = new
|
|
318
|
+
), s.boundingSphere = new Be(
|
|
313
319
|
new A(
|
|
314
320
|
e.boundingSphere?.center.x,
|
|
315
321
|
e.boundingSphere?.center.y,
|
|
@@ -326,7 +332,7 @@ function Pt(i) {
|
|
|
326
332
|
let s = null;
|
|
327
333
|
if (e.isCompressedTexture) {
|
|
328
334
|
const r = e.mipmaps, { width: n, height: o } = De(e);
|
|
329
|
-
s = new
|
|
335
|
+
s = new et(
|
|
330
336
|
r,
|
|
331
337
|
n,
|
|
332
338
|
o,
|
|
@@ -352,7 +358,7 @@ function Pt(i) {
|
|
|
352
358
|
e.type,
|
|
353
359
|
e.anisotropy,
|
|
354
360
|
e.colorSpace
|
|
355
|
-
), s.mipmaps = e.mipmaps, s.channel = e.channel, s.source.data = e.source.data, s.flipY = e.flipY, s.premultiplyAlpha = e.premultiplyAlpha, s.unpackAlignment = e.unpackAlignment, s.matrix = new
|
|
361
|
+
), s.mipmaps = e.mipmaps, s.channel = e.channel, s.source.data = e.source.data, s.flipY = e.flipY, s.premultiplyAlpha = e.premultiplyAlpha, s.unpackAlignment = e.unpackAlignment, s.matrix = new tt(...e.matrix.elements);
|
|
356
362
|
if (!s) {
|
|
357
363
|
console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");
|
|
358
364
|
continue;
|
|
@@ -364,12 +370,12 @@ function Pt(i) {
|
|
|
364
370
|
function he(i) {
|
|
365
371
|
let t = i;
|
|
366
372
|
if ("isInterleavedBufferAttribute" in i && i.isInterleavedBufferAttribute) {
|
|
367
|
-
const e = i.data, s = e.array, r = new
|
|
368
|
-
t = new
|
|
369
|
-
} else "isBufferAttribute" in i && i.isBufferAttribute && (t = new
|
|
373
|
+
const e = i.data, s = e.array, r = new st(s, e.stride);
|
|
374
|
+
t = new rt(r, i.itemSize, s.byteOffset, i.normalized), t.offset = i.offset;
|
|
375
|
+
} else "isBufferAttribute" in i && i.isBufferAttribute && (t = new nt(i.array, i.itemSize, i.normalized), t.usage = i.usage, t.gpuType = i.gpuType, t.updateRanges = i.updateRanges);
|
|
370
376
|
return t;
|
|
371
377
|
}
|
|
372
|
-
const
|
|
378
|
+
const kt = V("gltf-progressive-worker");
|
|
373
379
|
V("gltf-progressive-reduce-mipmaps");
|
|
374
380
|
const ie = V("gltf-progressive-gc"), ge = /* @__PURE__ */ Symbol("needle-progressive-texture"), U = "NEEDLE_progressive";
|
|
375
381
|
class p {
|
|
@@ -438,12 +444,12 @@ class p {
|
|
|
438
444
|
function o(l, a) {
|
|
439
445
|
const u = s.getAssignedLODInformation(l);
|
|
440
446
|
if (u) {
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
a.min_count = Math.min(a.min_count,
|
|
444
|
-
for (let c = 0; c <
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
+
const f = s.lodInfos.get(u.key);
|
|
448
|
+
if (f && f.lods) {
|
|
449
|
+
a.min_count = Math.min(a.min_count, f.lods.length), a.max_count = Math.max(a.max_count, f.lods.length);
|
|
450
|
+
for (let c = 0; c < f.lods.length; c++) {
|
|
451
|
+
const d = f.lods[c];
|
|
452
|
+
d.width && (a.lods[c] = a.lods[c] || { min_height: 1 / 0, max_height: 0 }, a.lods[c].min_height = Math.min(a.lods[c].min_height, d.height), a.lods[c].max_height = Math.max(a.lods[c].max_height, d.height));
|
|
447
453
|
}
|
|
448
454
|
}
|
|
449
455
|
}
|
|
@@ -543,9 +549,9 @@ class p {
|
|
|
543
549
|
if (this.trackCurrentMaterialTextureSlots(n), n.uniforms && (n.isRawShaderMaterial || n.isShaderMaterial === !0)) {
|
|
544
550
|
const a = n;
|
|
545
551
|
for (const u of Object.keys(a.uniforms)) {
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
const c = this.assignTextureLODForSlot(
|
|
552
|
+
const f = a.uniforms[u].value;
|
|
553
|
+
if (f?.isTexture === !0) {
|
|
554
|
+
const c = this.assignTextureLODForSlot(f, e, n, u, r).then((d) => (d && a.uniforms[u].value != d && (a.uniforms[u].value = d, a.uniformsNeedUpdate = !0), d));
|
|
549
555
|
o.push(c), l.push(u);
|
|
550
556
|
}
|
|
551
557
|
}
|
|
@@ -553,15 +559,15 @@ class p {
|
|
|
553
559
|
for (const a of Object.keys(n)) {
|
|
554
560
|
const u = n[a];
|
|
555
561
|
if (u?.isTexture === !0) {
|
|
556
|
-
const
|
|
557
|
-
o.push(
|
|
562
|
+
const f = this.assignTextureLODForSlot(u, e, n, a, r);
|
|
563
|
+
o.push(f), l.push(a);
|
|
558
564
|
}
|
|
559
565
|
}
|
|
560
566
|
return Promise.all(o).then((a) => {
|
|
561
567
|
const u = new Array();
|
|
562
|
-
for (let
|
|
563
|
-
const c = a[
|
|
564
|
-
c && c.isTexture === !0 ? u.push({ material: n, slot:
|
|
568
|
+
for (let f = 0; f < a.length; f++) {
|
|
569
|
+
const c = a[f], d = l[f];
|
|
570
|
+
c && c.isTexture === !0 ? u.push({ material: n, slot: d, texture: c, level: e }) : u.push({ material: n, slot: d, texture: null, level: e });
|
|
565
571
|
}
|
|
566
572
|
return u;
|
|
567
573
|
});
|
|
@@ -596,7 +602,7 @@ class p {
|
|
|
596
602
|
if (c && c.level === e && c.force === n)
|
|
597
603
|
return c.promise;
|
|
598
604
|
}
|
|
599
|
-
const l = s && r ? this.nextTextureSlotRequestId(s, r, e, n) : 0, a = () => !s || !r || this.getLatestTextureSlotRequest(s, r)?.id === l, u = () => a() || this.shouldApplyStaleTextureSlotLOD(s, r, e, n),
|
|
605
|
+
const l = s && r ? this.nextTextureSlotRequestId(s, r, e, n) : 0, a = () => !s || !r || this.getLatestTextureSlotRequest(s, r)?.id === l, u = () => a() || this.shouldApplyStaleTextureSlotLOD(s, r, e, n), f = p.getOrLoadLOD(t, e, {
|
|
600
606
|
isCurrent: u
|
|
601
607
|
}).then((c) => {
|
|
602
608
|
if (!a() && !this.shouldApplyStaleTextureSlotLOD(s, r, e, n)) return null;
|
|
@@ -604,11 +610,11 @@ class p {
|
|
|
604
610
|
return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."), null;
|
|
605
611
|
if (c?.isTexture === !0) {
|
|
606
612
|
if (c != t && s && r) {
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
const h = this.getAssignedLODInformation(
|
|
613
|
+
const d = this.getMaterialTextureSlot(s, r) ?? t;
|
|
614
|
+
if (d && !n) {
|
|
615
|
+
const h = this.getAssignedLODInformation(d);
|
|
610
616
|
if (h && h?.level < e)
|
|
611
|
-
return g === "verbose" && console.warn("Assigned texture level is already higher: ", h.level, e, s,
|
|
617
|
+
return g === "verbose" && console.warn("Assigned texture level is already higher: ", h.level, e, s, d, c), null;
|
|
612
618
|
}
|
|
613
619
|
this.assignTrackedTextureSlot(s, r, c);
|
|
614
620
|
}
|
|
@@ -616,7 +622,7 @@ class p {
|
|
|
616
622
|
} else g == "verbose" && console.warn("No LOD found for", t, e);
|
|
617
623
|
return null;
|
|
618
624
|
}).catch((c) => (console.error("Error loading LOD", t, c), null));
|
|
619
|
-
return s && r && this.setPendingTextureSlotRequest(s, r, e, n, l,
|
|
625
|
+
return s && r && this.setPendingTextureSlotRequest(s, r, e, n, l, f), f;
|
|
620
626
|
}
|
|
621
627
|
// Track material slots, not just texture objects. A shared fallback texture can be
|
|
622
628
|
// referenced by many slots and should only be disposed after every slot moved away.
|
|
@@ -805,9 +811,9 @@ class p {
|
|
|
805
811
|
}
|
|
806
812
|
l.userData || (l.userData = {}), g && console.log("> Progressive: register mesh " + s.name, { index: n, uuid: s.uuid }, o, s), p.assignLODInformation(t, l, e, r, n), p.lodInfos.set(e, o);
|
|
807
813
|
let u = p.lowresCache.get(e)?.deref();
|
|
808
|
-
u ? u.push(s.geometry) : u = [s.geometry], p.lowresCache.set(e, new WeakRef(u)), r > 0 && !ae(s) &&
|
|
809
|
-
for (const
|
|
810
|
-
|
|
814
|
+
u ? u.push(s.geometry) : u = [s.geometry], p.lowresCache.set(e, new WeakRef(u)), r > 0 && !ae(s) && Ot(s, l);
|
|
815
|
+
for (const f of F)
|
|
816
|
+
f.onRegisteredNewMesh?.(s, o);
|
|
811
817
|
};
|
|
812
818
|
/**
|
|
813
819
|
* Dispose cached resources to free memory.
|
|
@@ -905,10 +911,9 @@ ${t}`), e instanceof WeakRef && (e.deref() || (p.cache.delete(t), (g || ie) && c
|
|
|
905
911
|
return this.textureRefCounts.delete(e), (g || ie) && n("[gltf-progressive] Memory: Dispose texture", r), t.dispose(), !0;
|
|
906
912
|
return this.textureRefCounts.set(e, r), g === "verbose" && n("[gltf-progressive] Memory: Untrack texture", r), !1;
|
|
907
913
|
function n(o, l) {
|
|
908
|
-
|
|
909
|
-
const d = a && u ? `${a}x${u}` : "N/A";
|
|
914
|
+
const { width: a, height: u } = De(t), f = a && u ? `${a}x${u}` : "N/A";
|
|
910
915
|
let c = "N/A";
|
|
911
|
-
a && u && (c = `~${(
|
|
916
|
+
a && u && (c = `~${(Dt(t) / (1024 * 1024)).toFixed(2)} MB`), console.log(`${o} — ${t.name} ${f} (${c}), refCount: ${s} → ${l}
|
|
912
917
|
${e}`);
|
|
913
918
|
}
|
|
914
919
|
}
|
|
@@ -923,16 +928,16 @@ ${e}`);
|
|
|
923
928
|
const l = o?.key;
|
|
924
929
|
let a;
|
|
925
930
|
if (t.isTexture === !0) {
|
|
926
|
-
const
|
|
927
|
-
|
|
931
|
+
const f = t;
|
|
932
|
+
f.source && f.source[ge] && (a = f.source[ge]);
|
|
928
933
|
}
|
|
929
934
|
if (a || (a = p.lodInfos.get(l)), !a)
|
|
930
935
|
g && console.warn(`Can not load LOD ${e}: no LOD info found for "${l}" ${t.name}`, t.type, p.lodInfos);
|
|
931
936
|
else {
|
|
932
937
|
if (e > 0) {
|
|
933
|
-
let
|
|
938
|
+
let d = !1;
|
|
934
939
|
const h = Array.isArray(a.lods);
|
|
935
|
-
if (h && e >= a.lods.length ?
|
|
940
|
+
if (h && e >= a.lods.length ? d = !0 : h || (d = !0), d) {
|
|
936
941
|
const D = this.lowresCache.get(l);
|
|
937
942
|
if (D) {
|
|
938
943
|
const L = D.deref();
|
|
@@ -942,14 +947,14 @@ ${e}`);
|
|
|
942
947
|
return null;
|
|
943
948
|
}
|
|
944
949
|
}
|
|
945
|
-
const
|
|
946
|
-
if (!
|
|
950
|
+
const f = Array.isArray(a.lods) ? a.lods[e]?.path : a.lods;
|
|
951
|
+
if (!f)
|
|
947
952
|
return g && !a["missing:uri"] && (a["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, a)), null;
|
|
948
|
-
const c =
|
|
953
|
+
const c = wt(o.url, f);
|
|
949
954
|
if (c.endsWith(".glb") || c.endsWith(".gltf")) {
|
|
950
955
|
if (!a.guid)
|
|
951
956
|
return console.warn("missing pointer for glb/gltf texture", a), null;
|
|
952
|
-
const
|
|
957
|
+
const d = c + "_" + a.guid, h = await this.tryResolveLODCacheEntry(this.cache.get(d), d, c, t, e, n);
|
|
953
958
|
if (r !== this.cacheGeneration) return null;
|
|
954
959
|
if (h.found) return h.value;
|
|
955
960
|
if (s?.isCurrent?.() === !1)
|
|
@@ -958,20 +963,20 @@ ${e}`);
|
|
|
958
963
|
if (r !== this.cacheGeneration) return null;
|
|
959
964
|
if (s?.isCurrent?.() === !1)
|
|
960
965
|
return n && console.log(`Skipping stale LOD ${e} request after queue: ${c}`), null;
|
|
961
|
-
const L = await this.tryResolveLODCacheEntry(this.cache.get(
|
|
966
|
+
const L = await this.tryResolveLODCacheEntry(this.cache.get(d), d, c, t, e, n);
|
|
962
967
|
if (r !== this.cacheGeneration) return null;
|
|
963
968
|
if (L.found) return L.value;
|
|
964
|
-
const x = this.cache.get(
|
|
969
|
+
const x = this.cache.get(d);
|
|
965
970
|
if (x !== void 0) {
|
|
966
|
-
const y = await this.tryResolveLODCacheEntry(x,
|
|
971
|
+
const y = await this.tryResolveLODCacheEntry(x, d, c, t, e, n);
|
|
967
972
|
if (r !== this.cacheGeneration) return null;
|
|
968
973
|
if (y.found) return y.value;
|
|
969
974
|
}
|
|
970
975
|
if (!D.use)
|
|
971
976
|
return g && console.log(`LOD ${e} was aborted: ${c}`), null;
|
|
972
977
|
const w = a, M = new Promise(async (y, T) => {
|
|
973
|
-
if (
|
|
974
|
-
const m = await (await
|
|
978
|
+
if (kt) {
|
|
979
|
+
const m = await (await Pt({})).load(c);
|
|
975
980
|
if (m.textures.length > 0)
|
|
976
981
|
for (const v of m.textures) {
|
|
977
982
|
let S = v.texture;
|
|
@@ -988,51 +993,51 @@ ${e}`);
|
|
|
988
993
|
return y(null);
|
|
989
994
|
}
|
|
990
995
|
const I = new _e();
|
|
991
|
-
|
|
992
|
-
let
|
|
996
|
+
Fe(I), g && (await new Promise((O) => setTimeout(O, 1e3)), n && console.warn("Start loading (delayed) " + c, w.guid));
|
|
997
|
+
let C = c;
|
|
993
998
|
if (w && Array.isArray(w.lods)) {
|
|
994
|
-
const
|
|
995
|
-
|
|
999
|
+
const O = w.lods[e];
|
|
1000
|
+
O.hash && (C += "?v=" + O.hash);
|
|
996
1001
|
}
|
|
997
|
-
const _ = await I.loadAsync(
|
|
998
|
-
`,
|
|
1002
|
+
const _ = await I.loadAsync(C).catch((O) => (console.error(`Error loading LOD ${e} from ${c}
|
|
1003
|
+
`, O), y(null)));
|
|
999
1004
|
if (!_)
|
|
1000
1005
|
return y(null);
|
|
1001
1006
|
const z = _.parser;
|
|
1002
1007
|
n && console.log("Loading finished " + c, w.guid);
|
|
1003
|
-
let
|
|
1008
|
+
let k = 0;
|
|
1004
1009
|
if (_.parser.json.textures) {
|
|
1005
|
-
let
|
|
1010
|
+
let O = !1;
|
|
1006
1011
|
for (const m of _.parser.json.textures) {
|
|
1007
1012
|
if (m?.extensions) {
|
|
1008
1013
|
const v = m?.extensions[U];
|
|
1009
1014
|
if (v?.guid && v.guid === w.guid) {
|
|
1010
|
-
|
|
1015
|
+
O = !0;
|
|
1011
1016
|
break;
|
|
1012
1017
|
}
|
|
1013
1018
|
}
|
|
1014
|
-
|
|
1019
|
+
k++;
|
|
1015
1020
|
}
|
|
1016
|
-
if (
|
|
1017
|
-
let m = await z.getDependency("texture",
|
|
1018
|
-
return m && p.assignLODInformation(o.url, m, l, e, void 0), n && console.log('change "' + t.name + '" → "' + m.name + '"', c,
|
|
1021
|
+
if (O) {
|
|
1022
|
+
let m = await z.getDependency("texture", k);
|
|
1023
|
+
return m && p.assignLODInformation(o.url, m, l, e, void 0), n && console.log('change "' + t.name + '" → "' + m.name + '"', c, k, m, d), t instanceof q && (m = this.copySettings(t, m)), m && (m.guid = w.guid), y(m);
|
|
1019
1024
|
} else g && console.warn("Could not find texture with guid", w.guid, _.parser.json);
|
|
1020
1025
|
}
|
|
1021
|
-
if (
|
|
1022
|
-
let
|
|
1026
|
+
if (k = 0, _.parser.json.meshes) {
|
|
1027
|
+
let O = !1;
|
|
1023
1028
|
for (const m of _.parser.json.meshes) {
|
|
1024
1029
|
if (m?.extensions) {
|
|
1025
1030
|
const v = m?.extensions[U];
|
|
1026
1031
|
if (v?.guid && v.guid === w.guid) {
|
|
1027
|
-
|
|
1032
|
+
O = !0;
|
|
1028
1033
|
break;
|
|
1029
1034
|
}
|
|
1030
1035
|
}
|
|
1031
|
-
|
|
1036
|
+
k++;
|
|
1032
1037
|
}
|
|
1033
|
-
if (
|
|
1034
|
-
const m = await z.getDependency("mesh",
|
|
1035
|
-
if (n && console.log(`Loaded Mesh "${m.name}"`, c,
|
|
1038
|
+
if (O) {
|
|
1039
|
+
const m = await z.getDependency("mesh", k);
|
|
1040
|
+
if (n && console.log(`Loaded Mesh "${m.name}"`, c, k, m, d), m.isMesh === !0) {
|
|
1036
1041
|
const v = m.geometry;
|
|
1037
1042
|
return p.assignLODInformation(o.url, v, l, e, 0), y(v);
|
|
1038
1043
|
} else {
|
|
@@ -1050,14 +1055,14 @@ ${e}`);
|
|
|
1050
1055
|
}
|
|
1051
1056
|
return y(null);
|
|
1052
1057
|
});
|
|
1053
|
-
this.cache.set(
|
|
1054
|
-
const
|
|
1055
|
-
return r !== this.cacheGeneration || this.cache.get(
|
|
1058
|
+
this.cache.set(d, M), D.use(M);
|
|
1059
|
+
const b = await M;
|
|
1060
|
+
return r !== this.cacheGeneration || this.cache.get(d) !== M ? null : (b != null ? b instanceof q ? (this.cache.set(d, new WeakRef(b)), p._resourceRegistry.register(b, d)) : Array.isArray(b) ? this.cache.set(d, Promise.resolve(b)) : this.cache.set(d, Promise.resolve(b)) : this.cache.set(d, Promise.resolve(null)), b);
|
|
1056
1061
|
} else if (t instanceof q) {
|
|
1057
1062
|
if (s?.isCurrent?.() === !1)
|
|
1058
1063
|
return n && console.log(`Skipping stale texture LOD ${e} request: ${c}`), null;
|
|
1059
1064
|
n && console.log("Load texture from uri: " + c);
|
|
1060
|
-
const h = await new
|
|
1065
|
+
const h = await new it().loadAsync(c);
|
|
1061
1066
|
return r !== this.cacheGeneration || s?.isCurrent?.() === !1 ? (h?.dispose(), null) : (h ? (h.guid = a.guid, h.flipY = !1, h.needsUpdate = !0, h.colorSpace = t.colorSpace, n && console.log(a, h)) : g && console.warn("failed loading", c), h);
|
|
1062
1067
|
}
|
|
1063
1068
|
}
|
|
@@ -1069,9 +1074,9 @@ ${e}`);
|
|
|
1069
1074
|
if (o && console.log(`LOD ${n} was already loading/loaded: ${e}`), t instanceof WeakRef) {
|
|
1070
1075
|
const u = t.deref();
|
|
1071
1076
|
if (u) {
|
|
1072
|
-
let
|
|
1073
|
-
if (
|
|
1074
|
-
return { found: !0, value:
|
|
1077
|
+
let f = u, c = !1;
|
|
1078
|
+
if (f instanceof q && r instanceof q ? Pe(f.image) || ve(f) ? f = this.copySettings(r, f) : c = !0 : f instanceof K && r instanceof K && (f.attributes.position?.array || (c = !0)), !c)
|
|
1079
|
+
return { found: !0, value: f };
|
|
1075
1080
|
}
|
|
1076
1081
|
return this.cache.delete(e), g && console.log(`[gltf-progressive] Re-loading GC'd/disposed resource: ${e}`), { found: !1 };
|
|
1077
1082
|
}
|
|
@@ -1079,16 +1084,16 @@ ${e}`);
|
|
|
1079
1084
|
`, u), null));
|
|
1080
1085
|
if (this.disposedRequests.has(t)) return { found: !0, value: null };
|
|
1081
1086
|
let a = !1;
|
|
1082
|
-
return l == null || (l instanceof q && r instanceof q ?
|
|
1087
|
+
return l == null || (l instanceof q && r instanceof q ? Pe(l.image) || ve(l) ? l = this.copySettings(r, l) : (a = !0, this.cache.delete(e)) : l instanceof K && r instanceof K && (l.attributes.position?.array || (a = !0, this.cache.delete(e)))), a ? { found: !1 } : { found: !0, value: l };
|
|
1083
1088
|
}
|
|
1084
1089
|
static _queue;
|
|
1085
1090
|
static get queue() {
|
|
1086
|
-
return this._queue ??= new
|
|
1091
|
+
return this._queue ??= new vt(Se() ? 20 : 50, { debug: g != !1 });
|
|
1087
1092
|
}
|
|
1088
1093
|
static assignLODInformation(t, e, s, r, n) {
|
|
1089
1094
|
if (!e) return;
|
|
1090
1095
|
e.userData || (e.userData = {});
|
|
1091
|
-
const o = new
|
|
1096
|
+
const o = new At(t, s, r, n);
|
|
1092
1097
|
e.userData.LODS = o, "source" in e && typeof e.source == "object" && (e.source.LODS = o);
|
|
1093
1098
|
}
|
|
1094
1099
|
static getAssignedLODInformation(t) {
|
|
@@ -1101,7 +1106,7 @@ ${e}`);
|
|
|
1101
1106
|
`, e.uuid), e = e.clone(), e.offset = t.offset, e.repeat = t.repeat, e.colorSpace = t.colorSpace, e.magFilter = t.magFilter, e.minFilter = t.minFilter, e.wrapS = t.wrapS, e.wrapT = t.wrapT, e.flipY = t.flipY, e.anisotropy = t.anisotropy, e.mipmaps || (e.generateMipmaps = t.generateMipmaps), e) : t;
|
|
1102
1107
|
}
|
|
1103
1108
|
}
|
|
1104
|
-
class
|
|
1109
|
+
class At {
|
|
1105
1110
|
url;
|
|
1106
1111
|
/** the key to lookup the LOD information */
|
|
1107
1112
|
key;
|
|
@@ -1188,7 +1193,7 @@ class le {
|
|
|
1188
1193
|
});
|
|
1189
1194
|
}
|
|
1190
1195
|
}
|
|
1191
|
-
const $ = V("debugprogressive"),
|
|
1196
|
+
const $ = V("debugprogressive"), It = $ === "colors", $t = V("noprogressive"), pe = /* @__PURE__ */ Symbol("Needle:LODSManager"), me = /* @__PURE__ */ Symbol("Needle:LODState"), E = /* @__PURE__ */ Symbol("Needle:CurrentLOD"), Ce = ot, R = { mesh_lod: -1, texture_lod: -1 }, Gt = new We(), ke = [
|
|
1192
1197
|
3526751,
|
|
1193
1198
|
11065402,
|
|
1194
1199
|
15978811,
|
|
@@ -1222,16 +1227,16 @@ const $ = V("debugprogressive"), At = $ === "colors", It = V("noprogressive"), p
|
|
|
1222
1227
|
5083278,
|
|
1223
1228
|
5592405
|
|
1224
1229
|
];
|
|
1225
|
-
function
|
|
1226
|
-
const i =
|
|
1230
|
+
function Bt() {
|
|
1231
|
+
const i = Ce.Timer || Ce.Clock;
|
|
1227
1232
|
return new i();
|
|
1228
1233
|
}
|
|
1229
|
-
const ye = new de(), N = new de(),
|
|
1230
|
-
function
|
|
1234
|
+
const ye = new de(), N = new de(), Ae = new de(), qt = new A(), Wt = new A(), Ft = new qe(), W = new A(), Z = new A(), ee = new A(), te = new A();
|
|
1235
|
+
function Ut(i, t) {
|
|
1231
1236
|
const e = i.min, s = i.max, r = (e.x + s.x) * 0.5, n = (e.y + s.y) * 0.5;
|
|
1232
1237
|
return W.set(r, n, e.z).applyMatrix4(t).z < 0;
|
|
1233
1238
|
}
|
|
1234
|
-
function
|
|
1239
|
+
function zt(i) {
|
|
1235
1240
|
const {
|
|
1236
1241
|
geometry: t,
|
|
1237
1242
|
matrixWorld: e,
|
|
@@ -1242,50 +1247,50 @@ function Ut(i) {
|
|
|
1242
1247
|
currentLevel: l = -1,
|
|
1243
1248
|
xrEnabled: a = !1,
|
|
1244
1249
|
debugDrawLine: u,
|
|
1245
|
-
warnMissingPrimitiveDensities:
|
|
1246
|
-
} = i, c = p.getMeshLODExtension(t)?.lods,
|
|
1250
|
+
warnMissingPrimitiveDensities: f = !1
|
|
1251
|
+
} = i, c = p.getMeshLODExtension(t)?.lods, d = p.getPrimitiveIndex(t), h = i.target ?? {
|
|
1247
1252
|
level: l,
|
|
1248
|
-
primitiveIndex:
|
|
1253
|
+
primitiveIndex: d,
|
|
1249
1254
|
screenCoverage: 0,
|
|
1250
1255
|
screenspaceVolume: new A(),
|
|
1251
1256
|
centrality: 1
|
|
1252
1257
|
};
|
|
1253
|
-
h.level = l, h.primitiveIndex =
|
|
1258
|
+
h.level = l, h.primitiveIndex = d, h.screenCoverage = 0, h.screenspaceVolume.set(0, 0, 0), h.centrality = 1;
|
|
1254
1259
|
let D = i.boundingBox ?? t.boundingBox;
|
|
1255
1260
|
if (D || (t.computeBoundingBox(), D = t.boundingBox), !D) return h;
|
|
1256
|
-
if (ye.copy(D).applyMatrix4(e), s.isPerspectiveCamera &&
|
|
1261
|
+
if (ye.copy(D).applyMatrix4(e), s.isPerspectiveCamera && Ut(ye, r))
|
|
1257
1262
|
return h.level = 0, h.screenCoverage = 1 / 0, h.screenspaceVolume.set(1 / 0, 1 / 0, 1 / 0), h;
|
|
1258
1263
|
if (N.copy(ye).applyMatrix4(r), a && s.isPerspectiveCamera && s.fov > 70) {
|
|
1259
1264
|
const y = N.min, T = N.max;
|
|
1260
|
-
let I = y.x,
|
|
1261
|
-
const
|
|
1262
|
-
I = (I - m) *
|
|
1263
|
-
const S = I < 0 && _ > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(T.x)), X =
|
|
1264
|
-
h.centrality = (
|
|
1265
|
-
}
|
|
1266
|
-
const L = N.getSize(
|
|
1267
|
-
L.multiplyScalar(0.5), globalThis.screen?.availHeight > 0 && o > 0 && L.multiplyScalar(o / globalThis.screen.availHeight), s.isPerspectiveCamera && (L.x *= s.aspect),
|
|
1268
|
-
const x =
|
|
1265
|
+
let I = y.x, C = y.y, _ = T.x, z = T.y;
|
|
1266
|
+
const k = 2, O = 1.5, m = (y.x + T.x) * 0.5, v = (y.y + T.y) * 0.5;
|
|
1267
|
+
I = (I - m) * k + m, C = (C - v) * k + v, _ = (_ - m) * k + m, z = (z - v) * k + v;
|
|
1268
|
+
const S = I < 0 && _ > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(T.x)), X = C < 0 && z > 0 ? 0 : Math.min(Math.abs(y.y), Math.abs(T.y)), J = Math.max(S, X);
|
|
1269
|
+
h.centrality = (O - J) * (O - J) * (O - J);
|
|
1270
|
+
}
|
|
1271
|
+
const L = N.getSize(qt);
|
|
1272
|
+
L.multiplyScalar(0.5), globalThis.screen?.availHeight > 0 && o > 0 && L.multiplyScalar(o / globalThis.screen.availHeight), s.isPerspectiveCamera && (L.x *= s.aspect), Ae.copy(D).applyMatrix4(e).applyMatrix4(s.matrixWorldInverse);
|
|
1273
|
+
const x = Ae.getSize(Wt), w = Math.max(L.x, L.y), M = Math.max(x.x, x.y);
|
|
1269
1274
|
w !== 0 && M !== 0 && (L.z = x.z / M * w);
|
|
1270
|
-
const
|
|
1271
|
-
if (h.screenCoverage =
|
|
1275
|
+
const b = Math.max(L.x, L.y, L.z) * h.centrality;
|
|
1276
|
+
if (h.screenCoverage = b, h.screenspaceVolume.copy(L), b <= 0) return h;
|
|
1272
1277
|
if (u) {
|
|
1273
|
-
const y =
|
|
1278
|
+
const y = Ft.copy(r);
|
|
1274
1279
|
y.invert(), W.copy(N.min), Z.copy(N.max), Z.x = W.x, ee.copy(N.max), ee.y = W.y, te.copy(N.max);
|
|
1275
1280
|
const T = (W.z + te.z) * 0.5;
|
|
1276
1281
|
W.z = Z.z = ee.z = te.z = T, W.applyMatrix4(y), Z.applyMatrix4(y), ee.applyMatrix4(y), te.applyMatrix4(y), u(W, Z, 255), u(W, ee, 255), u(Z, te, 255), u(ee, te, 255);
|
|
1277
1282
|
}
|
|
1278
1283
|
if (c?.length)
|
|
1279
1284
|
for (let y = 0; y < c.length; y++) {
|
|
1280
|
-
const T = c[y], I = T.densities?.[
|
|
1281
|
-
if (
|
|
1285
|
+
const T = c[y], I = T.densities?.[d] || T.density || 1e-5;
|
|
1286
|
+
if (d > 0 && f && ze() && !T.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] = !0, console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")), I / b < n) {
|
|
1282
1287
|
h.level = y;
|
|
1283
1288
|
break;
|
|
1284
1289
|
}
|
|
1285
1290
|
}
|
|
1286
1291
|
return h;
|
|
1287
1292
|
}
|
|
1288
|
-
let
|
|
1293
|
+
let ce = class H {
|
|
1289
1294
|
/**
|
|
1290
1295
|
* Assign a function to draw debug lines for the LODs. This function will be called with the start and end position of the line and the color of the line when the `debugprogressive` query parameter is set.
|
|
1291
1296
|
*/
|
|
@@ -1321,7 +1326,7 @@ let fe = class H {
|
|
|
1321
1326
|
}
|
|
1322
1327
|
renderer;
|
|
1323
1328
|
context;
|
|
1324
|
-
projectionScreenMatrix = new
|
|
1329
|
+
projectionScreenMatrix = new qe();
|
|
1325
1330
|
/** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
|
|
1326
1331
|
get plugins() {
|
|
1327
1332
|
return F;
|
|
@@ -1394,7 +1399,7 @@ let fe = class H {
|
|
|
1394
1399
|
const r = performance.now();
|
|
1395
1400
|
return s.ready.finally(() => {
|
|
1396
1401
|
const n = this._newPromiseGroups.indexOf(s);
|
|
1397
|
-
n >= 0 && (this._newPromiseGroups.splice(n, 1),
|
|
1402
|
+
n >= 0 && (this._newPromiseGroups.splice(n, 1), ze() && performance.measure("LODsManager:awaitLoading", {
|
|
1398
1403
|
start: r,
|
|
1399
1404
|
detail: { id: e, name: t?.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
|
|
1400
1405
|
}));
|
|
@@ -1454,7 +1459,7 @@ let fe = class H {
|
|
|
1454
1459
|
#n = 0;
|
|
1455
1460
|
#o = 0;
|
|
1456
1461
|
#s = 0;
|
|
1457
|
-
#i =
|
|
1462
|
+
#i = Bt();
|
|
1458
1463
|
_fpsBuffer = [60, 60, 60, 60, 60];
|
|
1459
1464
|
/**
|
|
1460
1465
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
@@ -1465,7 +1470,7 @@ let fe = class H {
|
|
|
1465
1470
|
let t = 0;
|
|
1466
1471
|
this.#t = this.renderer.render;
|
|
1467
1472
|
const e = this;
|
|
1468
|
-
|
|
1473
|
+
Oe(this.renderer), this.renderer.render = function(s, r) {
|
|
1469
1474
|
const n = e.renderer.getRenderTarget();
|
|
1470
1475
|
(n == null || "isXRRenderTarget" in n && n.isXRRenderTarget) && (t = 0, e.#r += 1, e.#i.update?.(), e.#n = Math.max(e.#i.getDelta(), 1 / 1e3), e.#o += e.#n, e._fpsBuffer.shift(), e._fpsBuffer.push(1 / e.#n), e.#s = e._fpsBuffer.reduce((l, a) => l + a) / e._fpsBuffer.length, $ && e.#r % 200 === 0 && console.log("FPS", Math.round(e.#s), "Interval:", e.#e));
|
|
1471
1476
|
const o = t++;
|
|
@@ -1504,7 +1509,7 @@ let fe = class H {
|
|
|
1504
1509
|
(l.name === "EffectMaterial" || l.name === "CopyShader") && (o = !1);
|
|
1505
1510
|
}
|
|
1506
1511
|
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (o = !1), o) {
|
|
1507
|
-
if (
|
|
1512
|
+
if ($t || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1, $ && console.warn("↓ Reducing LOD updates", this.#e, this.#s.toFixed(0))) : this.#s >= 60 && this.#e > 1 && (this.#e -= 1, $ && console.warn("↑ Increasing LOD updates", this.#e, this.#s.toFixed(0))) : this.#e = this.updateInterval, this.#e > 0 && this.#r % this.#e != 0))
|
|
1508
1513
|
return;
|
|
1509
1514
|
this.internalUpdate(t, e), this._postprocessPromiseGroups();
|
|
1510
1515
|
}
|
|
@@ -1569,12 +1574,12 @@ let fe = class H {
|
|
|
1569
1574
|
updateLODs(t, e, s, r) {
|
|
1570
1575
|
s.userData || (s.userData = {});
|
|
1571
1576
|
let n = s[me];
|
|
1572
|
-
if (n || (n = new
|
|
1577
|
+
if (n || (n = new Et(), s[me] = n), n.frames++ < 2)
|
|
1573
1578
|
return;
|
|
1574
1579
|
for (const l of F)
|
|
1575
1580
|
l.onBeforeUpdateLOD?.(this.renderer, t, e, s);
|
|
1576
1581
|
const o = this.overrideLodLevel !== void 0 ? this.overrideLodLevel : j;
|
|
1577
|
-
o >= 0 ? (R.mesh_lod = o, R.texture_lod = o) : (this.calculateLodLevel(e, s, n, r, 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), s.material && R.texture_lod >= 0 && this.loadProgressiveTextures(s.material, R.texture_lod, o), g && s.material && !s.isGizmo &&
|
|
1582
|
+
o >= 0 ? (R.mesh_lod = o, R.texture_lod = o) : (this.calculateLodLevel(e, s, n, r, 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), s.material && R.texture_lod >= 0 && this.loadProgressiveTextures(s.material, R.texture_lod, o), g && s.material && !s.isGizmo && Ee(s.material), It && s.material && !s.isGizmo && !s.isBatchedMesh && Ne(s.material, R.mesh_lod);
|
|
1578
1583
|
for (const l of F)
|
|
1579
1584
|
l.onAfterUpdatedLOD?.(this.renderer, t, e, s, R);
|
|
1580
1585
|
n.lastLodLevel_Mesh = R.mesh_lod, n.lastLodLevel_Texture = R.texture_lod;
|
|
@@ -1620,7 +1625,7 @@ let fe = class H {
|
|
|
1620
1625
|
return Promise.resolve(null);
|
|
1621
1626
|
}
|
|
1622
1627
|
// private testIfLODLevelsAreAvailable() {
|
|
1623
|
-
_sphere = new
|
|
1628
|
+
_sphere = new Be();
|
|
1624
1629
|
_tempWorldPosition = new A();
|
|
1625
1630
|
static skinnedMeshBoundsFrameOffsetCounter = 0;
|
|
1626
1631
|
static $skinnedMeshBoundsOffset = /* @__PURE__ */ Symbol("gltf-progressive-skinnedMeshBoundsOffset");
|
|
@@ -1637,7 +1642,7 @@ let fe = class H {
|
|
|
1637
1642
|
let l = 10 + 1, a = !1;
|
|
1638
1643
|
if ($ && e["DEBUG:LOD"] != null)
|
|
1639
1644
|
return e["DEBUG:LOD"];
|
|
1640
|
-
const u = p.getMeshLODExtension(e.geometry)?.lods,
|
|
1645
|
+
const u = p.getMeshLODExtension(e.geometry)?.lods, f = p.getPrimitiveIndex(e.geometry), c = u && u.length > 0, d = p.getMaterialMinMaxLODsCount(e.material), h = d.min_count !== 1 / 0 && d.min_count >= 0 && d.max_count >= 0;
|
|
1641
1646
|
if (!c && !h) {
|
|
1642
1647
|
n.mesh_lod = 0, n.texture_lod = 0;
|
|
1643
1648
|
return;
|
|
@@ -1656,8 +1661,8 @@ let fe = class H {
|
|
|
1656
1661
|
}
|
|
1657
1662
|
const w = x[H.$skinnedMeshBoundsOffset];
|
|
1658
1663
|
if ((s.frames + w) % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
|
|
1659
|
-
const M = ae(x),
|
|
1660
|
-
M && (x.geometry = M), x.computeBoundingBox(), x.geometry =
|
|
1664
|
+
const M = ae(x), b = x.geometry;
|
|
1665
|
+
M && (x.geometry = M), x.computeBoundingBox(), x.geometry = b;
|
|
1661
1666
|
}
|
|
1662
1667
|
}
|
|
1663
1668
|
L = x.boundingBox;
|
|
@@ -1671,7 +1676,7 @@ let fe = class H {
|
|
|
1671
1676
|
return;
|
|
1672
1677
|
}
|
|
1673
1678
|
}
|
|
1674
|
-
const x =
|
|
1679
|
+
const x = zt({
|
|
1675
1680
|
geometry: e.geometry,
|
|
1676
1681
|
matrixWorld: e.matrixWorld,
|
|
1677
1682
|
camera: t,
|
|
@@ -1692,25 +1697,25 @@ let fe = class H {
|
|
|
1692
1697
|
}
|
|
1693
1698
|
if (a ? n.mesh_lod = l : n.mesh_lod = s.lastLodLevel_Mesh, $ && n.mesh_lod != s.lastLodLevel_Mesh) {
|
|
1694
1699
|
const w = u?.[n.mesh_lod];
|
|
1695
|
-
w && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${n.mesh_lod} (density: ${w.densities?.[
|
|
1700
|
+
w && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${n.mesh_lod} (density: ${w.densities?.[f].toFixed(0)}) | ${e.name}`);
|
|
1696
1701
|
}
|
|
1697
1702
|
if (h) {
|
|
1698
1703
|
const x = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
1699
1704
|
if (s.lastLodLevel_Texture < 0) {
|
|
1700
|
-
if (n.texture_lod =
|
|
1701
|
-
const w =
|
|
1705
|
+
if (n.texture_lod = d.max_count - 1, $) {
|
|
1706
|
+
const w = d.lods[d.max_count - 1];
|
|
1702
1707
|
$ && console.log(`First Texture LOD ${n.texture_lod} (${w.max_height}px) - ${e.name}`);
|
|
1703
1708
|
}
|
|
1704
1709
|
} else {
|
|
1705
1710
|
const w = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
1706
1711
|
let M = s.lastScreenCoverage * 4;
|
|
1707
1712
|
this.context?.engine === "model-viewer" && (M *= 1.5);
|
|
1708
|
-
const
|
|
1713
|
+
const b = this.renderer.getPixelRatio?.() || globalThis.devicePixelRatio || 1, T = D / b * M;
|
|
1709
1714
|
let I = !1;
|
|
1710
|
-
for (let
|
|
1711
|
-
const _ =
|
|
1712
|
-
if (!(x && _.max_height >= 2048) && !(
|
|
1713
|
-
if (I = !0, n.texture_lod =
|
|
1715
|
+
for (let C = d.lods.length - 1; C >= 0; C--) {
|
|
1716
|
+
const _ = d.lods[C];
|
|
1717
|
+
if (!(x && _.max_height >= 2048) && !(Se() && _.max_height > 4096) && (_.max_height > T || !I && C === 0)) {
|
|
1718
|
+
if (I = !0, n.texture_lod = C, $ && n.texture_lod < s.lastLodLevel_Texture) {
|
|
1714
1719
|
const z = _.max_height;
|
|
1715
1720
|
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${n.texture_lod} = ${z}px
|
|
1716
1721
|
Screensize: ${T.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${w.toFixed(1)}
|
|
@@ -1724,7 +1729,7 @@ ${e.name}`);
|
|
|
1724
1729
|
n.texture_lod = 0;
|
|
1725
1730
|
}
|
|
1726
1731
|
};
|
|
1727
|
-
class
|
|
1732
|
+
class Et {
|
|
1728
1733
|
frames = 0;
|
|
1729
1734
|
lastLodLevel_Mesh = -1;
|
|
1730
1735
|
lastLodLevel_Texture = -1;
|
|
@@ -1732,53 +1737,53 @@ class zt {
|
|
|
1732
1737
|
lastScreenspaceVolume = new A();
|
|
1733
1738
|
lastCentrality = 0;
|
|
1734
1739
|
}
|
|
1735
|
-
function
|
|
1740
|
+
function Ne(i, t) {
|
|
1736
1741
|
if (!(t < 0)) {
|
|
1737
1742
|
if (Array.isArray(i)) {
|
|
1738
1743
|
for (const e of i)
|
|
1739
|
-
|
|
1744
|
+
Ne(e, t);
|
|
1740
1745
|
return;
|
|
1741
1746
|
}
|
|
1742
|
-
"color" in i && i.color instanceof
|
|
1747
|
+
"color" in i && i.color instanceof We && (i.color.copy(Nt(t, Gt)), i.needsUpdate = !0);
|
|
1743
1748
|
}
|
|
1744
1749
|
}
|
|
1745
|
-
function
|
|
1746
|
-
const e = Math.max(0, Math.min(
|
|
1747
|
-
return t.setHex(
|
|
1750
|
+
function Nt(i, t) {
|
|
1751
|
+
const e = Math.max(0, Math.min(ke.length - 1, Math.floor(i)));
|
|
1752
|
+
return t.setHex(ke[e]);
|
|
1748
1753
|
}
|
|
1749
|
-
const
|
|
1754
|
+
const Ie = /* @__PURE__ */ Symbol("NEEDLE_mesh_lod"), ue = /* @__PURE__ */ Symbol("NEEDLE_texture_lod");
|
|
1750
1755
|
let xe = null;
|
|
1751
|
-
function
|
|
1752
|
-
const i =
|
|
1756
|
+
function Ve() {
|
|
1757
|
+
const i = Vt();
|
|
1753
1758
|
i && (i.mapURLs(function(t) {
|
|
1754
|
-
return
|
|
1755
|
-
}),
|
|
1759
|
+
return $e(), t;
|
|
1760
|
+
}), $e(), xe?.disconnect(), xe = new MutationObserver((t) => {
|
|
1756
1761
|
t.forEach((e) => {
|
|
1757
1762
|
e.addedNodes.forEach((s) => {
|
|
1758
|
-
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" &&
|
|
1763
|
+
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Xe(s);
|
|
1759
1764
|
});
|
|
1760
1765
|
});
|
|
1761
1766
|
}), xe.observe(document, { childList: !0, subtree: !0 }));
|
|
1762
1767
|
}
|
|
1763
|
-
function
|
|
1768
|
+
function Vt() {
|
|
1764
1769
|
if (typeof customElements > "u") return null;
|
|
1765
1770
|
const i = customElements.get("model-viewer");
|
|
1766
1771
|
return i || (customElements.whenDefined("model-viewer").then(() => {
|
|
1767
|
-
console.debug("[gltf-progressive] model-viewer defined"),
|
|
1772
|
+
console.debug("[gltf-progressive] model-viewer defined"), Ve();
|
|
1768
1773
|
}), null);
|
|
1769
1774
|
}
|
|
1770
|
-
function
|
|
1775
|
+
function $e() {
|
|
1771
1776
|
if (typeof document > "u") return;
|
|
1772
1777
|
document.querySelectorAll("model-viewer").forEach((t) => {
|
|
1773
|
-
|
|
1778
|
+
Xe(t);
|
|
1774
1779
|
});
|
|
1775
1780
|
}
|
|
1776
|
-
const
|
|
1777
|
-
let
|
|
1778
|
-
function
|
|
1779
|
-
if (!i ||
|
|
1781
|
+
const Ge = /* @__PURE__ */ new WeakSet();
|
|
1782
|
+
let Xt = 0;
|
|
1783
|
+
function Xe(i) {
|
|
1784
|
+
if (!i || Ge.has(i))
|
|
1780
1785
|
return null;
|
|
1781
|
-
|
|
1786
|
+
Ge.add(i), console.debug("[gltf-progressive] found new model-viewer..." + ++Xt + `
|
|
1782
1787
|
`, i.getAttribute("src"));
|
|
1783
1788
|
let t = null, e = null, s = null;
|
|
1784
1789
|
for (let r = i; r != null; r = Object.getPrototypeOf(r)) {
|
|
@@ -1799,8 +1804,8 @@ function Ve(i) {
|
|
|
1799
1804
|
}
|
|
1800
1805
|
};
|
|
1801
1806
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
1802
|
-
const n =
|
|
1803
|
-
return
|
|
1807
|
+
const n = ce.get(t, { engine: "model-viewer" });
|
|
1808
|
+
return ce.addPlugin(new jt()), n.enable(), n.addEventListener("changed", () => {
|
|
1804
1809
|
s?.call(i);
|
|
1805
1810
|
}), i.addEventListener("model-visibility", (o) => {
|
|
1806
1811
|
o.detail.visible && s?.call(i);
|
|
@@ -1812,7 +1817,7 @@ function Ve(i) {
|
|
|
1812
1817
|
}
|
|
1813
1818
|
return null;
|
|
1814
1819
|
}
|
|
1815
|
-
class
|
|
1820
|
+
class jt {
|
|
1816
1821
|
_didWarnAboutMissingUrl = !1;
|
|
1817
1822
|
onBeforeUpdateLOD(t, e, s, r) {
|
|
1818
1823
|
this.tryParseMeshLOD(e, r), this.tryParseTextureLOD(e, r);
|
|
@@ -1838,10 +1843,10 @@ class Xt {
|
|
|
1838
1843
|
if (a[ue] == !0) return;
|
|
1839
1844
|
a[ue] = !0, a.userData && (a.userData.LOD = -1);
|
|
1840
1845
|
const u = Object.keys(a);
|
|
1841
|
-
for (let
|
|
1842
|
-
const c = u[
|
|
1843
|
-
if (
|
|
1844
|
-
const h =
|
|
1846
|
+
for (let f = 0; f < u.length; f++) {
|
|
1847
|
+
const c = u[f], d = a[c];
|
|
1848
|
+
if (d?.isTexture === !0) {
|
|
1849
|
+
const h = d.userData?.associations?.textures;
|
|
1845
1850
|
if (h == null) continue;
|
|
1846
1851
|
const D = s.parser.json.textures[h];
|
|
1847
1852
|
if (!D) {
|
|
@@ -1850,7 +1855,7 @@ class Xt {
|
|
|
1850
1855
|
}
|
|
1851
1856
|
if (D?.extensions?.[U]) {
|
|
1852
1857
|
const L = D.extensions[U];
|
|
1853
|
-
L && n && p.registerTexture(n,
|
|
1858
|
+
L && n && p.registerTexture(n, d, L.lods.length, h, L);
|
|
1854
1859
|
}
|
|
1855
1860
|
}
|
|
1856
1861
|
}
|
|
@@ -1861,8 +1866,8 @@ class Xt {
|
|
|
1861
1866
|
}
|
|
1862
1867
|
}
|
|
1863
1868
|
tryParseMeshLOD(t, e) {
|
|
1864
|
-
if (e[
|
|
1865
|
-
e[
|
|
1869
|
+
if (e[Ie] == !0) return;
|
|
1870
|
+
e[Ie] = !0;
|
|
1866
1871
|
const s = this.tryGetCurrentModelViewer(t), r = this.getUrl(s);
|
|
1867
1872
|
if (!r)
|
|
1868
1873
|
return;
|
|
@@ -1873,7 +1878,7 @@ class Xt {
|
|
|
1873
1878
|
}
|
|
1874
1879
|
}
|
|
1875
1880
|
}
|
|
1876
|
-
function
|
|
1881
|
+
function Ht(...i) {
|
|
1877
1882
|
let t, e, s, r;
|
|
1878
1883
|
switch (i.length) {
|
|
1879
1884
|
case 2:
|
|
@@ -1888,20 +1893,20 @@ function jt(...i) {
|
|
|
1888
1893
|
default:
|
|
1889
1894
|
throw new Error("Invalid arguments");
|
|
1890
1895
|
}
|
|
1891
|
-
|
|
1896
|
+
Oe(e), Fe(s), Ue(s, {
|
|
1892
1897
|
progressive: !0,
|
|
1893
1898
|
...r?.hints
|
|
1894
1899
|
}), s.register((o) => new p(o));
|
|
1895
|
-
const n =
|
|
1900
|
+
const n = ce.get(e);
|
|
1896
1901
|
return r?.enableLODsManager !== !1 && n.enable(), n;
|
|
1897
1902
|
}
|
|
1898
|
-
|
|
1899
|
-
if (!
|
|
1903
|
+
Ve();
|
|
1904
|
+
if (!_t) {
|
|
1900
1905
|
const i = {
|
|
1901
1906
|
gltfProgressive: {
|
|
1902
|
-
useNeedleProgressive:
|
|
1903
|
-
LODsManager:
|
|
1904
|
-
configureLoader:
|
|
1907
|
+
useNeedleProgressive: Ht,
|
|
1908
|
+
LODsManager: ce,
|
|
1909
|
+
configureLoader: Ue,
|
|
1905
1910
|
getRaycastMesh: ae,
|
|
1906
1911
|
useRaycastMeshes: bt
|
|
1907
1912
|
}
|
|
@@ -1913,14 +1918,15 @@ if (!Mt) {
|
|
|
1913
1918
|
globalThis.Needle[t] = i[t];
|
|
1914
1919
|
}
|
|
1915
1920
|
export {
|
|
1916
|
-
|
|
1921
|
+
ce as LODsManager,
|
|
1917
1922
|
p as NEEDLE_progressive,
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
+
Fe as addDracoAndKTX2Loaders,
|
|
1924
|
+
zt as calculateMeshLODLevel,
|
|
1925
|
+
Ue as configureLoader,
|
|
1926
|
+
Oe as createLoaders,
|
|
1927
|
+
Qt as disposeLoaders,
|
|
1928
|
+
Nt as getLODColor,
|
|
1923
1929
|
ae as getRaycastMesh,
|
|
1924
|
-
|
|
1925
|
-
|
|
1930
|
+
gt as setDracoDecoderLocation,
|
|
1931
|
+
pt as setKTX2TranscoderLocation
|
|
1926
1932
|
};
|