@needle-tools/engine 4.8.3-next.bc4f9a4 → 4.8.4-experimental.c93e134
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 +10 -0
- package/README.md +5 -0
- package/components.needle.json +1 -1
- package/dist/{gltf-progressive-DVx_cW0s.js → gltf-progressive-B3JW4cAu.js} +246 -243
- package/dist/{gltf-progressive-DLhfUtEV.min.js → gltf-progressive-DorC035H.min.js} +5 -5
- package/dist/{gltf-progressive-CHV7_60B.umd.cjs → gltf-progressive-PB_58h1b.umd.cjs} +6 -6
- package/dist/{needle-engine.bundle-CwXTBzUe.min.js → needle-engine.bundle-BLVnT5UY.min.js} +137 -127
- package/dist/{needle-engine.bundle-CLdEfO-e.js → needle-engine.bundle-Bx5wfOs0.js} +4761 -4529
- package/dist/{needle-engine.bundle-Bn8kOFud.umd.cjs → needle-engine.bundle-DhD3EKds.umd.cjs} +133 -123
- package/dist/needle-engine.d.ts +15 -15
- package/dist/needle-engine.js +411 -409
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/extensions/KHR_materials_variants.d.ts +25 -0
- package/lib/engine/extensions/KHR_materials_variants.js +113 -0
- package/lib/engine/extensions/KHR_materials_variants.js.map +1 -0
- package/lib/engine/extensions/extensions.js +2 -0
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/extensions/index.d.ts +1 -0
- package/lib/engine/extensions/index.js +1 -0
- package/lib/engine/extensions/index.js.map +1 -1
- package/lib/engine/webcomponents/buttons.js +6 -2
- package/lib/engine/webcomponents/buttons.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +10 -0
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine-components/MaterialVariants.d.ts +52 -0
- package/lib/engine-components/MaterialVariants.js +210 -0
- package/lib/engine-components/MaterialVariants.js.map +1 -0
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/package.json +3 -3
- package/plugins/vite/poster-client.js +1 -1
- package/src/engine/extensions/KHR_materials_variants.ts +179 -0
- package/src/engine/extensions/extensions.ts +2 -0
- package/src/engine/extensions/index.ts +1 -0
- package/src/engine/webcomponents/buttons.ts +6 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +10 -0
- package/src/engine/webcomponents/needle-engine.loading.ts +1 -1
- package/src/engine-components/MaterialVariants.ts +231 -0
- package/src/engine-components/codegen/components.ts +1 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BufferGeometry as Q, Mesh as q, Box3 as ge, Vector3 as A, Sphere as Oe, CompressedTexture as Fe, Texture as E, Matrix3 as Ue, InterleavedBuffer as We, InterleavedBufferAttribute as ze, BufferAttribute as Ee, TextureLoader as Ne, Matrix4 as _e, Clock as qe, MeshStandardMaterial as Ve } from "./three-DrqIzZTH.js";
|
|
2
2
|
import { DRACOLoader as Xe, KTX2Loader as Ke, MeshoptDecoder as je, GLTFLoader as xe } from "./three-examples-BIuXQPSf.js";
|
|
3
|
-
const Se = "3.3.
|
|
3
|
+
const Se = "3.3.1";
|
|
4
4
|
globalThis.GLTF_PROGRESSIVE_VERSION = Se;
|
|
5
5
|
console.debug(`[gltf-progressive] version ${Se}`);
|
|
6
|
-
let
|
|
7
|
-
const Ye =
|
|
6
|
+
let k = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", V = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
|
|
7
|
+
const Ye = k, He = V, Pe = new URL(k + "draco_decoder.js");
|
|
8
8
|
Pe.searchParams.append("range", "true");
|
|
9
9
|
fetch(Pe, {
|
|
10
10
|
method: "GET",
|
|
@@ -12,30 +12,30 @@ fetch(Pe, {
|
|
|
12
12
|
Range: "bytes=0-1"
|
|
13
13
|
}
|
|
14
14
|
}).catch((o) => {
|
|
15
|
-
console.debug(`Failed to fetch remote Draco decoder from ${
|
|
15
|
+
console.debug(`Failed to fetch remote Draco decoder from ${k} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), k === Ye && Je("./include/draco/"), V === He && Ze("./include/ktx2/");
|
|
16
16
|
}).finally(() => {
|
|
17
17
|
Ae();
|
|
18
18
|
});
|
|
19
19
|
const Qe = () => ({
|
|
20
|
-
dracoDecoderPath:
|
|
20
|
+
dracoDecoderPath: k,
|
|
21
21
|
ktx2TranscoderPath: V
|
|
22
22
|
});
|
|
23
23
|
function Je(o) {
|
|
24
|
-
|
|
24
|
+
k = o, T && T[pe] != k ? (console.debug("Updating Draco decoder path to " + o), T[pe] = k, T.setDecoderPath(k), T.preload()) : console.debug("Setting Draco decoder path to " + o);
|
|
25
25
|
}
|
|
26
26
|
function Ze(o) {
|
|
27
27
|
V = o, R && R.transcoderPath != V ? (console.debug("Updating KTX2 transcoder path to " + o), R.setTranscoderPath(V), R.init()) : console.debug("Setting KTX2 transcoder path to " + o);
|
|
28
28
|
}
|
|
29
29
|
function we(o) {
|
|
30
|
-
return Ae(), o ? R.detectSupport(o) : o !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: T, ktx2Loader: R, meshoptDecoder:
|
|
30
|
+
return Ae(), o ? R.detectSupport(o) : o !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: T, ktx2Loader: R, meshoptDecoder: ne };
|
|
31
31
|
}
|
|
32
32
|
function Te(o) {
|
|
33
|
-
o.dracoLoader || o.setDRACOLoader(T), o.ktx2Loader || o.setKTX2Loader(R), o.meshoptDecoder || o.setMeshoptDecoder(
|
|
33
|
+
o.dracoLoader || o.setDRACOLoader(T), o.ktx2Loader || o.setKTX2Loader(R), o.meshoptDecoder || o.setMeshoptDecoder(ne);
|
|
34
34
|
}
|
|
35
35
|
const pe = Symbol("dracoDecoderPath");
|
|
36
|
-
let T,
|
|
36
|
+
let T, ne, R;
|
|
37
37
|
function Ae() {
|
|
38
|
-
T || (T = new Xe(), T[pe] =
|
|
38
|
+
T || (T = new Xe(), T[pe] = k, T.setDecoderPath(k), T.setDecoderConfig({ type: "js" }), T.preload()), R || (R = new Ke(), R.setTranscoderPath(V), R.init()), ne || (ne = je);
|
|
39
39
|
}
|
|
40
40
|
const me = /* @__PURE__ */ new WeakMap();
|
|
41
41
|
function Ie(o, t) {
|
|
@@ -48,8 +48,8 @@ function tt(...o) {
|
|
|
48
48
|
let e = o[0];
|
|
49
49
|
const s = new URL(e, window.location.href);
|
|
50
50
|
if (s.hostname.endsWith("needle.tools")) {
|
|
51
|
-
const
|
|
52
|
-
|
|
51
|
+
const r = t?.progressive !== void 0 ? t.progressive : !0, i = t?.usecase ? t.usecase : "default";
|
|
52
|
+
r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${i}` : this.requestHeader.Accept = `*/*;usecase=${i}`, e = s.toString();
|
|
53
53
|
}
|
|
54
54
|
return o[0] = e, et?.call(this, ...o);
|
|
55
55
|
}
|
|
@@ -74,7 +74,7 @@ function st(o, t) {
|
|
|
74
74
|
return t;
|
|
75
75
|
}
|
|
76
76
|
let j;
|
|
77
|
-
function
|
|
77
|
+
function Ce() {
|
|
78
78
|
return j !== void 0 || (j = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), X("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", j)), j;
|
|
79
79
|
}
|
|
80
80
|
function Me() {
|
|
@@ -83,7 +83,7 @@ function Me() {
|
|
|
83
83
|
const o = new URL(window.location.href), t = o.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);
|
|
84
84
|
return o.hostname === "127.0.0.1" || t;
|
|
85
85
|
}
|
|
86
|
-
class
|
|
86
|
+
class rt {
|
|
87
87
|
maxConcurrent;
|
|
88
88
|
_running = /* @__PURE__ */ new Map();
|
|
89
89
|
_queue = [];
|
|
@@ -111,14 +111,14 @@ class nt {
|
|
|
111
111
|
const t = this.maxConcurrent - this._running.size;
|
|
112
112
|
for (let e = 0; e < t && this._queue.length > 0; e++) {
|
|
113
113
|
this.debug && console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);
|
|
114
|
-
const { key: s, resolve:
|
|
115
|
-
|
|
116
|
-
use: (
|
|
114
|
+
const { key: s, resolve: n } = this._queue.shift();
|
|
115
|
+
n({
|
|
116
|
+
use: (r) => this.add(s, r)
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
const
|
|
121
|
+
const nt = typeof window > "u" && typeof document > "u", ye = Symbol("needle:raycast-mesh");
|
|
122
122
|
function J(o) {
|
|
123
123
|
return o?.[ye] instanceof Q ? o[ye] : null;
|
|
124
124
|
}
|
|
@@ -134,9 +134,9 @@ function ot(o = !0) {
|
|
|
134
134
|
return;
|
|
135
135
|
const t = Y = q.prototype.raycast;
|
|
136
136
|
q.prototype.raycast = function(e, s) {
|
|
137
|
-
const
|
|
137
|
+
const n = this, r = J(n);
|
|
138
138
|
let i;
|
|
139
|
-
|
|
139
|
+
r && n.isMesh && (i = n.geometry, n.geometry = r), t.call(this, e, s), i && (n.geometry = i);
|
|
140
140
|
};
|
|
141
141
|
} else {
|
|
142
142
|
if (!Y)
|
|
@@ -152,33 +152,33 @@ function at(o) {
|
|
|
152
152
|
return t.setIndex(o.getIndex()), t;
|
|
153
153
|
}
|
|
154
154
|
const W = new Array(), g = X("debugprogressive");
|
|
155
|
-
let
|
|
155
|
+
let re, N = -1;
|
|
156
156
|
if (g) {
|
|
157
157
|
let t = function() {
|
|
158
158
|
N += 1, N >= o && (N = -1), console.log(`Toggle LOD level [${N}]`);
|
|
159
159
|
}, o = 6;
|
|
160
160
|
window.addEventListener("keyup", (e) => {
|
|
161
|
-
e.key === "p" && t(), e.key === "w" && (
|
|
161
|
+
e.key === "p" && t(), e.key === "w" && (re = !re, console.log(`Toggle wireframe [${re}]`));
|
|
162
162
|
const s = parseInt(e.key);
|
|
163
163
|
!isNaN(s) && s >= 0 && (N = s, console.log(`Set LOD level to [${N}]`));
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function ke(o) {
|
|
167
167
|
if (g)
|
|
168
168
|
if (Array.isArray(o))
|
|
169
169
|
for (const t of o)
|
|
170
|
-
|
|
171
|
-
else o && "wireframe" in o && (o.wireframe =
|
|
170
|
+
ke(t);
|
|
171
|
+
else o && "wireframe" in o && (o.wireframe = re === !0);
|
|
172
172
|
}
|
|
173
173
|
const H = new Array();
|
|
174
174
|
let lt = 0;
|
|
175
|
-
const ut =
|
|
175
|
+
const ut = Ce() ? 2 : 10;
|
|
176
176
|
function dt(o) {
|
|
177
177
|
if (H.length < ut) {
|
|
178
178
|
const s = H.length;
|
|
179
179
|
g && console.warn(`[Worker] Creating new worker #${s}`);
|
|
180
|
-
const
|
|
181
|
-
return H.push(
|
|
180
|
+
const n = Le.createWorker(o || {});
|
|
181
|
+
return H.push(n), n;
|
|
182
182
|
}
|
|
183
183
|
const t = lt++ % H.length;
|
|
184
184
|
return H[t];
|
|
@@ -195,12 +195,12 @@ class Le {
|
|
|
195
195
|
_webglRenderer = null;
|
|
196
196
|
async load(t, e) {
|
|
197
197
|
const s = Qe();
|
|
198
|
-
let
|
|
199
|
-
|
|
198
|
+
let n = e?.renderer;
|
|
199
|
+
n || (this._webglRenderer ??= (async () => {
|
|
200
200
|
const { WebGLRenderer: u } = await import("./three-DrqIzZTH.js").then((d) => d.THREE);
|
|
201
201
|
return new u();
|
|
202
|
-
})(),
|
|
203
|
-
const l = we(
|
|
202
|
+
})(), n = await this._webglRenderer);
|
|
203
|
+
const l = we(n).ktx2Loader.workerConfig;
|
|
204
204
|
t instanceof URL ? t = t.toString() : t.startsWith("file:") ? t = URL.createObjectURL(new Blob([t])) : !t.startsWith("blob:") && !t.startsWith("http:") && !t.startsWith("https:") && (t = new URL(t, window.location.href).toString());
|
|
205
205
|
const a = {
|
|
206
206
|
type: "load",
|
|
@@ -219,13 +219,13 @@ class Le {
|
|
|
219
219
|
_debug = !1;
|
|
220
220
|
constructor(t, e) {
|
|
221
221
|
this.worker = t, this._debug = e.debug ?? !1, t.onmessage = (s) => {
|
|
222
|
-
const
|
|
223
|
-
switch (this._debug && console.log("[Worker] EVENT",
|
|
222
|
+
const n = s.data;
|
|
223
|
+
switch (this._debug && console.log("[Worker] EVENT", n), n.type) {
|
|
224
224
|
case "loaded-gltf":
|
|
225
|
-
for (const
|
|
226
|
-
if (
|
|
227
|
-
ct(
|
|
228
|
-
const i =
|
|
225
|
+
for (const r of this._running)
|
|
226
|
+
if (r.url === n.result.url) {
|
|
227
|
+
ct(n.result), r.resolve(n.result);
|
|
228
|
+
const i = r.url;
|
|
229
229
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
@@ -240,29 +240,29 @@ function ct(o) {
|
|
|
240
240
|
for (const t of o.geometries) {
|
|
241
241
|
const e = t.geometry, s = new Q();
|
|
242
242
|
if (s.name = e.name || "", e.index) {
|
|
243
|
-
const
|
|
244
|
-
s.setIndex(le(
|
|
243
|
+
const n = e.index;
|
|
244
|
+
s.setIndex(le(n));
|
|
245
245
|
}
|
|
246
|
-
for (const
|
|
247
|
-
const
|
|
248
|
-
s.setAttribute(
|
|
246
|
+
for (const n in e.attributes) {
|
|
247
|
+
const r = e.attributes[n], i = le(r);
|
|
248
|
+
s.setAttribute(n, i);
|
|
249
249
|
}
|
|
250
250
|
if (e.morphAttributes)
|
|
251
|
-
for (const
|
|
252
|
-
const i = e.morphAttributes[
|
|
253
|
-
s.morphAttributes[
|
|
251
|
+
for (const n in e.morphAttributes) {
|
|
252
|
+
const i = e.morphAttributes[n].map((l) => le(l));
|
|
253
|
+
s.morphAttributes[n] = i;
|
|
254
254
|
}
|
|
255
255
|
if (s.morphTargetsRelative = e.morphTargetsRelative ?? !1, s.boundingBox = new ge(), s.boundingBox.min = new A(e.boundingBox?.min.x, e.boundingBox?.min.y, e.boundingBox?.min.z), s.boundingBox.max = new A(e.boundingBox?.max.x, e.boundingBox?.max.y, e.boundingBox?.max.z), s.boundingSphere = new Oe(new A(e.boundingSphere?.center.x, e.boundingSphere?.center.y, e.boundingSphere?.center.z), e.boundingSphere?.radius), e.groups)
|
|
256
|
-
for (const
|
|
257
|
-
s.addGroup(
|
|
256
|
+
for (const n of e.groups)
|
|
257
|
+
s.addGroup(n.start, n.count, n.materialIndex);
|
|
258
258
|
e.userData && (s.userData = e.userData), t.geometry = s;
|
|
259
259
|
}
|
|
260
260
|
for (const t of o.textures) {
|
|
261
261
|
const e = t.texture;
|
|
262
262
|
let s = null;
|
|
263
263
|
if (e.isCompressedTexture) {
|
|
264
|
-
const
|
|
265
|
-
s = new Fe(
|
|
264
|
+
const n = e.mipmaps, r = e.image?.width || e.source?.data?.width || -1, i = e.image?.height || e.source?.data?.height || -1;
|
|
265
|
+
s = new Fe(n, r, i, e.format, e.type, e.mapping, e.wrapS, e.wrapT, e.magFilter, e.minFilter, e.anisotropy, e.colorSpace);
|
|
266
266
|
} else
|
|
267
267
|
s = new E(e.image, e.mapping, e.wrapS, e.wrapT, e.magFilter, e.minFilter, e.format, e.type, e.anisotropy, e.colorSpace), 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 Ue(...e.matrix.elements);
|
|
268
268
|
if (!s) {
|
|
@@ -276,8 +276,8 @@ function ct(o) {
|
|
|
276
276
|
function le(o) {
|
|
277
277
|
let t = o;
|
|
278
278
|
if ("isInterleavedBufferAttribute" in o && o.isInterleavedBufferAttribute) {
|
|
279
|
-
const e = o.data, s = e.array,
|
|
280
|
-
t = new ze(
|
|
279
|
+
const e = o.data, s = e.array, n = new We(s, e.stride);
|
|
280
|
+
t = new ze(n, o.itemSize, s.byteOffset, o.normalized), t.offset = o.offset;
|
|
281
281
|
} else "isBufferAttribute" in o && o.isBufferAttribute && (t = new Ee(o.array, o.itemSize, o.normalized), t.usage = o.usage, t.gpuType = o.gpuType, t.updateRanges = o.updateRanges);
|
|
282
282
|
return t;
|
|
283
283
|
}
|
|
@@ -296,9 +296,9 @@ class y {
|
|
|
296
296
|
return e ?? -1;
|
|
297
297
|
}
|
|
298
298
|
static getMaterialMinMaxLODsCount(t, e) {
|
|
299
|
-
const s = this,
|
|
300
|
-
if (
|
|
301
|
-
return
|
|
299
|
+
const s = this, n = "LODS:minmax", r = t[n];
|
|
300
|
+
if (r != null)
|
|
301
|
+
return r;
|
|
302
302
|
if (e || (e = {
|
|
303
303
|
min_count: 1 / 0,
|
|
304
304
|
max_count: 0,
|
|
@@ -306,7 +306,7 @@ class y {
|
|
|
306
306
|
}), Array.isArray(t)) {
|
|
307
307
|
for (const l of t)
|
|
308
308
|
this.getMaterialMinMaxLODsCount(l, e);
|
|
309
|
-
return t[
|
|
309
|
+
return t[n] = e, e;
|
|
310
310
|
}
|
|
311
311
|
if (g === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
|
|
312
312
|
const l = t;
|
|
@@ -321,7 +321,7 @@ class y {
|
|
|
321
321
|
}
|
|
322
322
|
else
|
|
323
323
|
g && console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${t.type}`);
|
|
324
|
-
return t[
|
|
324
|
+
return t[n] = e, e;
|
|
325
325
|
function i(l, a) {
|
|
326
326
|
const u = s.getAssignedLODInformation(l);
|
|
327
327
|
if (u) {
|
|
@@ -343,30 +343,30 @@ class y {
|
|
|
343
343
|
*/
|
|
344
344
|
static hasLODLevelAvailable(t, e) {
|
|
345
345
|
if (Array.isArray(t)) {
|
|
346
|
-
for (const
|
|
347
|
-
if (this.hasLODLevelAvailable(
|
|
346
|
+
for (const r of t)
|
|
347
|
+
if (this.hasLODLevelAvailable(r, e))
|
|
348
348
|
return !0;
|
|
349
349
|
return !1;
|
|
350
350
|
}
|
|
351
351
|
if (t.isMaterial === !0) {
|
|
352
|
-
for (const
|
|
353
|
-
const i = t[
|
|
352
|
+
for (const r of Object.keys(t)) {
|
|
353
|
+
const i = t[r];
|
|
354
354
|
if (i && i.isTexture && this.hasLODLevelAvailable(i, e))
|
|
355
355
|
return !0;
|
|
356
356
|
}
|
|
357
357
|
return !1;
|
|
358
358
|
} else if (t.isGroup === !0) {
|
|
359
|
-
for (const
|
|
360
|
-
if (
|
|
359
|
+
for (const r of t.children)
|
|
360
|
+
if (r.isMesh === !0 && this.hasLODLevelAvailable(r, e))
|
|
361
361
|
return !0;
|
|
362
362
|
}
|
|
363
|
-
let s,
|
|
363
|
+
let s, n;
|
|
364
364
|
if (t.isMesh ? s = t.geometry : (t.isBufferGeometry || t.isTexture) && (s = t), s && s?.userData?.LODS) {
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
return
|
|
368
|
-
if (
|
|
369
|
-
return Array.isArray(
|
|
365
|
+
const r = s.userData.LODS;
|
|
366
|
+
if (n = this.lodInfos.get(r.key), e === void 0)
|
|
367
|
+
return n != null;
|
|
368
|
+
if (n)
|
|
369
|
+
return Array.isArray(n.lods) ? e < n.lods.length : e === 0;
|
|
370
370
|
}
|
|
371
371
|
return !1;
|
|
372
372
|
}
|
|
@@ -388,18 +388,18 @@ class y {
|
|
|
388
388
|
if (!t)
|
|
389
389
|
return Promise.resolve(null);
|
|
390
390
|
if (t instanceof q || t.isMesh === !0) {
|
|
391
|
-
const s = t.geometry,
|
|
392
|
-
if (!
|
|
391
|
+
const s = t.geometry, n = this.getAssignedLODInformation(s);
|
|
392
|
+
if (!n)
|
|
393
393
|
return Promise.resolve(null);
|
|
394
|
-
for (const
|
|
395
|
-
|
|
396
|
-
return t["LOD:requested level"] = e, y.getOrLoadLOD(s, e).then((
|
|
397
|
-
if (Array.isArray(
|
|
398
|
-
const i =
|
|
399
|
-
|
|
394
|
+
for (const r of W)
|
|
395
|
+
r.onBeforeGetLODMesh?.(t, e);
|
|
396
|
+
return t["LOD:requested level"] = e, y.getOrLoadLOD(s, e).then((r) => {
|
|
397
|
+
if (Array.isArray(r)) {
|
|
398
|
+
const i = n.index || 0;
|
|
399
|
+
r = r[i];
|
|
400
400
|
}
|
|
401
|
-
return t["LOD:requested level"] === e && (delete t["LOD:requested level"],
|
|
402
|
-
}).catch((
|
|
401
|
+
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && s != r && (r?.isBufferGeometry ? t.geometry = r : g && console.error("Invalid LOD geometry", r))), r;
|
|
402
|
+
}).catch((r) => (console.error("Error loading mesh LOD", t, r), null));
|
|
403
403
|
} else g && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
404
404
|
return Promise.resolve(null);
|
|
405
405
|
}
|
|
@@ -409,14 +409,14 @@ class y {
|
|
|
409
409
|
if (t.isMesh === !0) {
|
|
410
410
|
const s = t;
|
|
411
411
|
if (Array.isArray(s.material)) {
|
|
412
|
-
const
|
|
413
|
-
for (const
|
|
414
|
-
const i = this.assignTextureLOD(
|
|
415
|
-
|
|
412
|
+
const n = new Array();
|
|
413
|
+
for (const r of s.material) {
|
|
414
|
+
const i = this.assignTextureLOD(r, e);
|
|
415
|
+
n.push(i);
|
|
416
416
|
}
|
|
417
|
-
return Promise.all(
|
|
417
|
+
return Promise.all(n).then((r) => {
|
|
418
418
|
const i = new Array();
|
|
419
|
-
for (const l of
|
|
419
|
+
for (const l of r)
|
|
420
420
|
Array.isArray(l) && i.push(...l);
|
|
421
421
|
return i;
|
|
422
422
|
});
|
|
@@ -424,14 +424,14 @@ class y {
|
|
|
424
424
|
return this.assignTextureLOD(s.material, e);
|
|
425
425
|
}
|
|
426
426
|
if (t.isMaterial === !0) {
|
|
427
|
-
const s = t,
|
|
427
|
+
const s = t, n = [], r = new Array();
|
|
428
428
|
if (s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
429
429
|
const i = s;
|
|
430
430
|
for (const l of Object.keys(i.uniforms)) {
|
|
431
431
|
const a = i.uniforms[l].value;
|
|
432
432
|
if (a?.isTexture === !0) {
|
|
433
433
|
const u = this.assignTextureLODForSlot(a, e, s, l).then((d) => (d && i.uniforms[l].value != d && (i.uniforms[l].value = d, i.uniformsNeedUpdate = !0), d));
|
|
434
|
-
|
|
434
|
+
n.push(u), r.push(l);
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
} else
|
|
@@ -439,13 +439,13 @@ class y {
|
|
|
439
439
|
const l = s[i];
|
|
440
440
|
if (l?.isTexture === !0) {
|
|
441
441
|
const a = this.assignTextureLODForSlot(l, e, s, i);
|
|
442
|
-
|
|
442
|
+
n.push(a), r.push(i);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
return Promise.all(
|
|
445
|
+
return Promise.all(n).then((i) => {
|
|
446
446
|
const l = new Array();
|
|
447
447
|
for (let a = 0; a < i.length; a++) {
|
|
448
|
-
const u = i[a], d =
|
|
448
|
+
const u = i[a], d = r[a];
|
|
449
449
|
u && u.isTexture === !0 ? l.push({ material: s, slot: d, texture: u, level: e }) : l.push({ material: s, slot: d, texture: null, level: e });
|
|
450
450
|
}
|
|
451
451
|
return l;
|
|
@@ -457,28 +457,28 @@ class y {
|
|
|
457
457
|
}
|
|
458
458
|
return Promise.resolve(null);
|
|
459
459
|
}
|
|
460
|
-
static assignTextureLODForSlot(t, e, s,
|
|
461
|
-
return t?.isTexture !== !0 ? Promise.resolve(null) :
|
|
462
|
-
if (Array.isArray(
|
|
460
|
+
static assignTextureLODForSlot(t, e, s, n) {
|
|
461
|
+
return t?.isTexture !== !0 ? Promise.resolve(null) : n === "glyphMap" ? Promise.resolve(t) : y.getOrLoadLOD(t, e).then((r) => {
|
|
462
|
+
if (Array.isArray(r))
|
|
463
463
|
return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."), null;
|
|
464
|
-
if (
|
|
465
|
-
if (
|
|
466
|
-
const i = s[
|
|
464
|
+
if (r?.isTexture === !0) {
|
|
465
|
+
if (r != t && s && n) {
|
|
466
|
+
const i = s[n];
|
|
467
467
|
if (i && !g) {
|
|
468
468
|
const l = this.getAssignedLODInformation(i);
|
|
469
469
|
if (l && l?.level < e)
|
|
470
|
-
return g === "verbose" && console.warn("Assigned texture level is already higher: ", l.level, e, s, i,
|
|
470
|
+
return g === "verbose" && console.warn("Assigned texture level is already higher: ", l.level, e, s, i, r), null;
|
|
471
471
|
}
|
|
472
|
-
if (ht &&
|
|
473
|
-
const l =
|
|
474
|
-
|
|
472
|
+
if (ht && r.mipmaps) {
|
|
473
|
+
const l = r.mipmaps.length;
|
|
474
|
+
r.mipmaps.length = Math.min(r.mipmaps.length, 3), l !== r.mipmaps.length && g && console.debug(`Reduced mipmap count from ${l} to ${r.mipmaps.length} for ${r.uuid}: ${r.image?.width}x${r.image?.height}.`);
|
|
475
475
|
}
|
|
476
|
-
s[
|
|
476
|
+
s[n] = r;
|
|
477
477
|
}
|
|
478
|
-
return
|
|
478
|
+
return r;
|
|
479
479
|
} else g == "verbose" && console.warn("No LOD found for", t, e);
|
|
480
480
|
return null;
|
|
481
|
-
}).catch((
|
|
481
|
+
}).catch((r) => (console.error("Error loading LOD", t, r), null));
|
|
482
482
|
}
|
|
483
483
|
parser;
|
|
484
484
|
url;
|
|
@@ -510,28 +510,28 @@ class y {
|
|
|
510
510
|
afterRoot(t) {
|
|
511
511
|
return g && console.log("AFTER", this.url, t), this.parser.json.textures?.forEach((e, s) => {
|
|
512
512
|
if (e?.extensions) {
|
|
513
|
-
const
|
|
514
|
-
if (
|
|
515
|
-
if (!
|
|
516
|
-
g && console.warn("Texture has no LODs",
|
|
513
|
+
const n = e?.extensions[F];
|
|
514
|
+
if (n) {
|
|
515
|
+
if (!n.lods) {
|
|
516
|
+
g && console.warn("Texture has no LODs", n);
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
let
|
|
519
|
+
let r = !1;
|
|
520
520
|
for (const i of this.parser.associations.keys())
|
|
521
|
-
i.isTexture === !0 && this.parser.associations.get(i)?.textures === s && (
|
|
522
|
-
|
|
523
|
-
i && y.registerTexture(this.url, i,
|
|
521
|
+
i.isTexture === !0 && this.parser.associations.get(i)?.textures === s && (r = !0, y.registerTexture(this.url, i, n.lods?.length, s, n));
|
|
522
|
+
r || this.parser.getDependency("texture", s).then((i) => {
|
|
523
|
+
i && y.registerTexture(this.url, i, n.lods?.length, s, n);
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
}), this.parser.json.meshes?.forEach((e, s) => {
|
|
528
528
|
if (e?.extensions) {
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
for (const
|
|
532
|
-
if (
|
|
533
|
-
const i = this.parser.associations.get(
|
|
534
|
-
i?.meshes === s && y.registerMesh(this.url,
|
|
529
|
+
const n = e?.extensions[F];
|
|
530
|
+
if (n && n.lods) {
|
|
531
|
+
for (const r of this.parser.associations.keys())
|
|
532
|
+
if (r.isMesh) {
|
|
533
|
+
const i = this.parser.associations.get(r);
|
|
534
|
+
i?.meshes === s && y.registerMesh(this.url, n.guid, r, n.lods.length, i.primitives, n);
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
}
|
|
@@ -540,31 +540,31 @@ class y {
|
|
|
540
540
|
/**
|
|
541
541
|
* Register a texture with LOD information
|
|
542
542
|
*/
|
|
543
|
-
static registerTexture = (t, e, s,
|
|
543
|
+
static registerTexture = (t, e, s, n, r) => {
|
|
544
544
|
if (!e) {
|
|
545
545
|
g && console.error("gltf-progressive: Called register texture without texture");
|
|
546
546
|
return;
|
|
547
547
|
}
|
|
548
548
|
if (g) {
|
|
549
549
|
const l = e.image?.width || e.source?.data?.width || 0, a = e.image?.height || e.source?.data?.height || 0;
|
|
550
|
-
console.log(`> Progressive: register texture[${
|
|
550
|
+
console.log(`> Progressive: register texture[${n}] "${e.name || e.uuid}", Current: ${l}x${a}, Max: ${r.lods[0]?.width}x${r.lods[0]?.height}, uuid: ${e.uuid}`, r, e);
|
|
551
551
|
}
|
|
552
|
-
e.source && (e.source[ue] =
|
|
553
|
-
const i =
|
|
554
|
-
y.assignLODInformation(t, e, i, s,
|
|
552
|
+
e.source && (e.source[ue] = r);
|
|
553
|
+
const i = r.guid;
|
|
554
|
+
y.assignLODInformation(t, e, i, s, n), y.lodInfos.set(i, r), y.lowresCache.set(i, e);
|
|
555
555
|
};
|
|
556
556
|
/**
|
|
557
557
|
* Register a mesh with LOD information
|
|
558
558
|
*/
|
|
559
|
-
static registerMesh = (t, e, s,
|
|
559
|
+
static registerMesh = (t, e, s, n, r, i) => {
|
|
560
560
|
const l = s.geometry;
|
|
561
561
|
if (!l) {
|
|
562
562
|
g && console.warn("gltf-progressive: Register mesh without geometry");
|
|
563
563
|
return;
|
|
564
564
|
}
|
|
565
|
-
l.userData || (l.userData = {}), g && console.log("> Progressive: register mesh " + s.name, { index:
|
|
565
|
+
l.userData || (l.userData = {}), g && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, i, s), y.assignLODInformation(t, l, e, n, r), y.lodInfos.set(e, i);
|
|
566
566
|
let a = y.lowresCache.get(e);
|
|
567
|
-
a ? a.push(s.geometry) : a = [s.geometry], y.lowresCache.set(e, a),
|
|
567
|
+
a ? a.push(s.geometry) : a = [s.geometry], y.lowresCache.set(e, a), n > 0 && !J(s) && it(s, l);
|
|
568
568
|
for (const u of W)
|
|
569
569
|
u.onRegisteredNewMesh?.(s, i);
|
|
570
570
|
};
|
|
@@ -577,26 +577,26 @@ class y {
|
|
|
577
577
|
static workers = [];
|
|
578
578
|
static _workersIndex = 0;
|
|
579
579
|
static async getOrLoadLOD(t, e) {
|
|
580
|
-
const s = g == "verbose",
|
|
581
|
-
if (!
|
|
580
|
+
const s = g == "verbose", n = this.getAssignedLODInformation(t);
|
|
581
|
+
if (!n)
|
|
582
582
|
return g && console.warn(`[gltf-progressive] No LOD information found: ${t.name}, uuid: ${t.uuid}, type: ${t.type}`, t), null;
|
|
583
|
-
const
|
|
583
|
+
const r = n?.key;
|
|
584
584
|
let i;
|
|
585
585
|
if (t.isTexture === !0) {
|
|
586
586
|
const a = t;
|
|
587
587
|
a.source && a.source[ue] && (i = a.source[ue]);
|
|
588
588
|
}
|
|
589
|
-
if (i || (i = y.lodInfos.get(
|
|
589
|
+
if (i || (i = y.lodInfos.get(r)), i) {
|
|
590
590
|
if (e > 0) {
|
|
591
591
|
let d = !1;
|
|
592
592
|
const p = Array.isArray(i.lods);
|
|
593
593
|
if (p && e >= i.lods.length ? d = !0 : p || (d = !0), d)
|
|
594
|
-
return this.lowresCache.get(
|
|
594
|
+
return this.lowresCache.get(r);
|
|
595
595
|
}
|
|
596
596
|
const a = Array.isArray(i.lods) ? i.lods[e]?.path : i.lods;
|
|
597
597
|
if (!a)
|
|
598
598
|
return g && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
|
|
599
|
-
const u = st(
|
|
599
|
+
const u = st(n.url, a);
|
|
600
600
|
if (u.endsWith(".glb") || u.endsWith(".gltf")) {
|
|
601
601
|
if (!i.guid)
|
|
602
602
|
return console.warn("missing pointer for glb/gltf texture", i), null;
|
|
@@ -616,13 +616,13 @@ class y {
|
|
|
616
616
|
if (m.textures.length > 0)
|
|
617
617
|
for (const f of m.textures) {
|
|
618
618
|
let h = f.texture;
|
|
619
|
-
return y.assignLODInformation(
|
|
619
|
+
return y.assignLODInformation(n.url, h, r, e, void 0), t instanceof E && (h = this.copySettings(t, h)), h && (h.guid = _.guid), c(h);
|
|
620
620
|
}
|
|
621
621
|
if (m.geometries.length > 0) {
|
|
622
622
|
const f = new Array();
|
|
623
623
|
for (const h of m.geometries) {
|
|
624
624
|
const D = h.geometry;
|
|
625
|
-
y.assignLODInformation(
|
|
625
|
+
y.assignLODInformation(n.url, D, r, e, h.primitiveIndex), f.push(D);
|
|
626
626
|
}
|
|
627
627
|
return c(f);
|
|
628
628
|
}
|
|
@@ -656,7 +656,7 @@ class y {
|
|
|
656
656
|
}
|
|
657
657
|
if (w) {
|
|
658
658
|
let m = await z.getDependency("texture", S);
|
|
659
|
-
return m && y.assignLODInformation(
|
|
659
|
+
return m && y.assignLODInformation(n.url, m, r, e, void 0), s && console.log('change "' + t.name + '" → "' + m.name + '"', u, S, m, d), t instanceof E && (m = this.copySettings(t, m)), m && (m.guid = _.guid), c(m);
|
|
660
660
|
} else g && console.warn("Could not find texture with guid", _.guid, M.parser.json);
|
|
661
661
|
}
|
|
662
662
|
if (S = 0, M.parser.json.meshes) {
|
|
@@ -675,14 +675,14 @@ class y {
|
|
|
675
675
|
const m = await z.getDependency("mesh", S);
|
|
676
676
|
if (s && console.log(`Loaded Mesh "${m.name}"`, u, S, m, d), m.isMesh === !0) {
|
|
677
677
|
const f = m.geometry;
|
|
678
|
-
return y.assignLODInformation(
|
|
678
|
+
return y.assignLODInformation(n.url, f, r, e, 0), c(f);
|
|
679
679
|
} else {
|
|
680
680
|
const f = new Array();
|
|
681
681
|
for (let h = 0; h < m.children.length; h++) {
|
|
682
682
|
const D = m.children[h];
|
|
683
683
|
if (D.isMesh === !0) {
|
|
684
684
|
const v = D.geometry;
|
|
685
|
-
y.assignLODInformation(
|
|
685
|
+
y.assignLODInformation(n.url, v, r, e, h), f.push(v);
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
return c(f);
|
|
@@ -698,16 +698,16 @@ class y {
|
|
|
698
698
|
return p ? (p.guid = i.guid, p.flipY = !1, p.needsUpdate = !0, p.colorSpace = t.colorSpace, s && console.log(i, p)) : g && console.warn("failed loading", u), p;
|
|
699
699
|
}
|
|
700
700
|
} else
|
|
701
|
-
g && console.warn(`Can not load LOD ${e}: no LOD info found for "${
|
|
701
|
+
g && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
|
|
702
702
|
return null;
|
|
703
703
|
}
|
|
704
704
|
static maxConcurrent = 50;
|
|
705
|
-
static queue = new
|
|
706
|
-
static assignLODInformation(t, e, s,
|
|
705
|
+
static queue = new rt(y.maxConcurrent, { debug: g != !1 });
|
|
706
|
+
static assignLODInformation(t, e, s, n, r) {
|
|
707
707
|
if (!e)
|
|
708
708
|
return;
|
|
709
709
|
e.userData || (e.userData = {});
|
|
710
|
-
const i = new gt(t, s,
|
|
710
|
+
const i = new gt(t, s, n, r);
|
|
711
711
|
e.userData.LODS = i, "source" in e && typeof e.source == "object" && (e.source.LODS = i);
|
|
712
712
|
}
|
|
713
713
|
static getAssignedLODInformation(t) {
|
|
@@ -727,33 +727,36 @@ class gt {
|
|
|
727
727
|
level;
|
|
728
728
|
/** For multi objects (e.g. a group of meshes) this is the index of the object */
|
|
729
729
|
index;
|
|
730
|
-
constructor(t, e, s,
|
|
731
|
-
this.url = t, this.key = e, this.level = s,
|
|
730
|
+
constructor(t, e, s, n) {
|
|
731
|
+
this.url = t, this.key = e, this.level = s, n != null && (this.index = n);
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
class de {
|
|
735
|
-
static addPromise = (t, e, s,
|
|
736
|
-
|
|
737
|
-
|
|
735
|
+
static addPromise = (t, e, s, n) => {
|
|
736
|
+
n.forEach((r) => {
|
|
737
|
+
r.add(t, e, s);
|
|
738
738
|
});
|
|
739
739
|
};
|
|
740
|
-
frame_start;
|
|
741
|
-
frame_capture_end;
|
|
742
740
|
ready;
|
|
743
|
-
|
|
744
|
-
_signal;
|
|
745
|
-
/**
|
|
746
|
-
* The number of promises that have been added to this group so far.
|
|
747
|
-
*/
|
|
741
|
+
/** The number of promises that have been added to this group so far */
|
|
748
742
|
get awaitedCount() {
|
|
749
743
|
return this._addedCount;
|
|
750
744
|
}
|
|
745
|
+
/** The number of promises that have been resolved */
|
|
751
746
|
get resolvedCount() {
|
|
752
747
|
return this._resolvedCount;
|
|
753
748
|
}
|
|
749
|
+
/** The number of promises that are in-flight */
|
|
754
750
|
get currentlyAwaiting() {
|
|
755
751
|
return this._awaiting.length;
|
|
756
752
|
}
|
|
753
|
+
_resolve;
|
|
754
|
+
_signal;
|
|
755
|
+
/** start frame can be undefined if the user configured this group to wait for the first promise.
|
|
756
|
+
* Then the start frame will be set when the first promise has been added to the group */
|
|
757
|
+
_frame_start;
|
|
758
|
+
/** How many frames to capture since the start frame */
|
|
759
|
+
_frames_to_capture;
|
|
757
760
|
_resolved = !1;
|
|
758
761
|
_addedCount = 0;
|
|
759
762
|
_resolvedCount = 0;
|
|
@@ -761,9 +764,9 @@ class de {
|
|
|
761
764
|
_awaiting = [];
|
|
762
765
|
_maxPromisesPerObject = 1;
|
|
763
766
|
constructor(t, e) {
|
|
764
|
-
const
|
|
765
|
-
this.
|
|
766
|
-
this._resolve =
|
|
767
|
+
const n = Math.max(e.frames ?? 2, 2);
|
|
768
|
+
this._frame_start = e.waitForFirstCapture ? void 0 : t, this._frames_to_capture = n, this.ready = new Promise((r) => {
|
|
769
|
+
this._resolve = r;
|
|
767
770
|
}), this.ready.finally(() => {
|
|
768
771
|
this._resolved = !0, this._awaiting.length = 0;
|
|
769
772
|
}), this._signal = e.signal, this._signal?.addEventListener("abort", () => {
|
|
@@ -772,7 +775,7 @@ class de {
|
|
|
772
775
|
}
|
|
773
776
|
_currentFrame = 0;
|
|
774
777
|
update(t) {
|
|
775
|
-
this._currentFrame = t, (this._signal?.aborted || this.
|
|
778
|
+
this._currentFrame = t, this._frame_start === void 0 && this._addedCount > 0 && (this._frame_start = t), (this._signal?.aborted || this._awaiting.length === 0 && this._frame_start !== void 0 && t > this._frame_start + this._frames_to_capture) && this.resolveNow();
|
|
776
779
|
}
|
|
777
780
|
_seen = /* @__PURE__ */ new WeakMap();
|
|
778
781
|
add(t, e, s) {
|
|
@@ -780,15 +783,15 @@ class de {
|
|
|
780
783
|
g && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
|
|
781
784
|
return;
|
|
782
785
|
}
|
|
783
|
-
if (!(this._currentFrame > this.
|
|
786
|
+
if (!(this._frame_start !== void 0 && this._currentFrame > this._frame_start + this._frames_to_capture)) {
|
|
784
787
|
if (this._maxPromisesPerObject >= 1)
|
|
785
788
|
if (this._seen.has(e)) {
|
|
786
|
-
let
|
|
787
|
-
if (
|
|
789
|
+
let n = this._seen.get(e);
|
|
790
|
+
if (n >= this._maxPromisesPerObject) {
|
|
788
791
|
g && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
|
|
789
792
|
return;
|
|
790
793
|
}
|
|
791
|
-
this._seen.set(e,
|
|
794
|
+
this._seen.set(e, n + 1);
|
|
792
795
|
} else
|
|
793
796
|
this._seen.set(e, 1);
|
|
794
797
|
this._awaiting.push(s), this._addedCount++, s.finally(() => {
|
|
@@ -804,7 +807,7 @@ class de {
|
|
|
804
807
|
});
|
|
805
808
|
}
|
|
806
809
|
}
|
|
807
|
-
const
|
|
810
|
+
const C = X("debugprogressive"), pt = X("noprogressive"), ce = Symbol("Needle:LODSManager"), fe = Symbol("Needle:LODState"), U = Symbol("Needle:CurrentLOD"), P = { mesh_lod: -1, texture_lod: -1 };
|
|
808
811
|
let ie = class b {
|
|
809
812
|
/**
|
|
810
813
|
* 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.
|
|
@@ -881,13 +884,13 @@ let ie = class b {
|
|
|
881
884
|
* Call to await LODs loading during the next render cycle.
|
|
882
885
|
*/
|
|
883
886
|
awaitLoading(t) {
|
|
884
|
-
const e = this._promiseGroupIds++, s = new de(this.#
|
|
887
|
+
const e = this._promiseGroupIds++, s = new de(this.#r, { ...t });
|
|
885
888
|
this._newPromiseGroups.push(s);
|
|
886
|
-
const
|
|
889
|
+
const n = performance.now();
|
|
887
890
|
return s.ready.finally(() => {
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
start:
|
|
891
|
+
const r = this._newPromiseGroups.indexOf(s);
|
|
892
|
+
r >= 0 && (this._newPromiseGroups.splice(r, 1), Me() && performance.measure("LODsManager:awaitLoading", {
|
|
893
|
+
start: n,
|
|
891
894
|
detail: { id: e, name: t?.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
|
|
892
895
|
}));
|
|
893
896
|
}), s.ready;
|
|
@@ -895,7 +898,7 @@ let ie = class b {
|
|
|
895
898
|
_postprocessPromiseGroups() {
|
|
896
899
|
if (this._newPromiseGroups.length !== 0)
|
|
897
900
|
for (let t = this._newPromiseGroups.length - 1; t >= 0; t--)
|
|
898
|
-
this._newPromiseGroups[t].update(this.#
|
|
901
|
+
this._newPromiseGroups[t].update(this.#r);
|
|
899
902
|
}
|
|
900
903
|
_lodchangedlisteners = [];
|
|
901
904
|
addEventListener(t, e) {
|
|
@@ -913,8 +916,8 @@ let ie = class b {
|
|
|
913
916
|
}
|
|
914
917
|
#t;
|
|
915
918
|
#i = new qe();
|
|
916
|
-
#n = 0;
|
|
917
919
|
#r = 0;
|
|
920
|
+
#n = 0;
|
|
918
921
|
#o = 0;
|
|
919
922
|
#s = 0;
|
|
920
923
|
_fpsBuffer = [60, 60, 60, 60, 60];
|
|
@@ -928,11 +931,11 @@ let ie = class b {
|
|
|
928
931
|
let t = 0;
|
|
929
932
|
this.#t = this.renderer.render;
|
|
930
933
|
const e = this;
|
|
931
|
-
we(this.renderer), this.renderer.render = function(s,
|
|
932
|
-
const
|
|
933
|
-
(
|
|
934
|
+
we(this.renderer), this.renderer.render = function(s, n) {
|
|
935
|
+
const r = e.renderer.getRenderTarget();
|
|
936
|
+
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, e.#r += 1, e.#n = e.#i.getDelta(), 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, C && e.#r % 200 === 0 && console.log("FPS", Math.round(e.#s), "Interval:", e.#e));
|
|
934
937
|
const i = t++;
|
|
935
|
-
e.#t.call(this, s,
|
|
938
|
+
e.#t.call(this, s, n), e.onAfterRender(s, n, i);
|
|
936
939
|
};
|
|
937
940
|
}
|
|
938
941
|
disable() {
|
|
@@ -944,14 +947,14 @@ let ie = class b {
|
|
|
944
947
|
onAfterRender(t, e, s) {
|
|
945
948
|
if (this.pause)
|
|
946
949
|
return;
|
|
947
|
-
const
|
|
950
|
+
const r = this.renderer.renderLists.get(t, 0).opaque;
|
|
948
951
|
let i = !0;
|
|
949
|
-
if (
|
|
950
|
-
const l =
|
|
952
|
+
if (r.length === 1) {
|
|
953
|
+
const l = r[0].material;
|
|
951
954
|
(l.name === "EffectMaterial" || l.name === "CopyShader") && (i = !1);
|
|
952
955
|
}
|
|
953
956
|
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
|
|
954
|
-
if (pt || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1,
|
|
957
|
+
if (pt || (this.updateInterval === "auto" ? this.#s < 40 && this.#e < 10 ? (this.#e += 1, C && console.warn("↓ Reducing LOD updates", this.#e, this.#s.toFixed(0))) : this.#s >= 60 && this.#e > 1 && (this.#e -= 1, C && console.warn("↑ Increasing LOD updates", this.#e, this.#s.toFixed(0))) : this.#e = this.updateInterval, this.#e > 0 && this.#r % this.#e != 0))
|
|
955
958
|
return;
|
|
956
959
|
this.internalUpdate(t, e), this._postprocessPromiseGroups();
|
|
957
960
|
}
|
|
@@ -960,12 +963,12 @@ let ie = class b {
|
|
|
960
963
|
* Update LODs in a scene
|
|
961
964
|
*/
|
|
962
965
|
internalUpdate(t, e) {
|
|
963
|
-
const s = this.renderer.renderLists.get(t, 0),
|
|
966
|
+
const s = this.renderer.renderLists.get(t, 0), n = s.opaque;
|
|
964
967
|
this.projectionScreenMatrix.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse);
|
|
965
|
-
const
|
|
966
|
-
for (const a of
|
|
968
|
+
const r = this.targetTriangleDensity;
|
|
969
|
+
for (const a of n) {
|
|
967
970
|
if (a.material && (a.geometry?.type === "BoxGeometry" || a.geometry?.type === "BufferGeometry") && (a.material.name === "SphericalGaussianBlur" || a.material.name == "BackgroundCubeMaterial" || a.material.name === "CubemapFromEquirect" || a.material.name === "EquirectangularToCubeUV")) {
|
|
968
|
-
|
|
971
|
+
C && (a.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (a.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", a, a.material.name, a.material.type)));
|
|
969
972
|
continue;
|
|
970
973
|
}
|
|
971
974
|
switch (a.material.type) {
|
|
@@ -977,38 +980,38 @@ let ie = class b {
|
|
|
977
980
|
case "MeshDepthMaterial":
|
|
978
981
|
continue;
|
|
979
982
|
}
|
|
980
|
-
if (
|
|
983
|
+
if (C === "color" && a.material && !a.object.progressive_debug_color) {
|
|
981
984
|
a.object.progressive_debug_color = !0;
|
|
982
985
|
const d = Math.random() * 16777215, p = new Ve({ color: d });
|
|
983
986
|
a.object.material = p;
|
|
984
987
|
}
|
|
985
988
|
const u = a.object;
|
|
986
|
-
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u,
|
|
989
|
+
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
987
990
|
}
|
|
988
991
|
const i = s.transparent;
|
|
989
992
|
for (const a of i) {
|
|
990
993
|
const u = a.object;
|
|
991
|
-
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u,
|
|
994
|
+
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
992
995
|
}
|
|
993
996
|
const l = s.transmissive;
|
|
994
997
|
for (const a of l) {
|
|
995
998
|
const u = a.object;
|
|
996
|
-
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u,
|
|
999
|
+
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
997
1000
|
}
|
|
998
1001
|
}
|
|
999
1002
|
/** Update the LOD levels for the renderer. */
|
|
1000
|
-
updateLODs(t, e, s,
|
|
1003
|
+
updateLODs(t, e, s, n) {
|
|
1001
1004
|
s.userData || (s.userData = {});
|
|
1002
|
-
let
|
|
1003
|
-
if (
|
|
1005
|
+
let r = s[fe];
|
|
1006
|
+
if (r || (r = new mt(), s[fe] = r), r.frames++ < 2)
|
|
1004
1007
|
return;
|
|
1005
1008
|
for (const l of W)
|
|
1006
1009
|
l.onBeforeUpdateLOD?.(this.renderer, t, e, s);
|
|
1007
1010
|
const i = this.overrideLodLevel !== void 0 ? this.overrideLodLevel : N;
|
|
1008
|
-
i >= 0 ? (P.mesh_lod = i, P.texture_lod = i) : (this.calculateLodLevel(e, s,
|
|
1011
|
+
i >= 0 ? (P.mesh_lod = i, P.texture_lod = i) : (this.calculateLodLevel(e, s, r, n, P), P.mesh_lod = Math.round(P.mesh_lod), P.texture_lod = Math.round(P.texture_lod)), P.mesh_lod >= 0 && this.loadProgressiveMeshes(s, P.mesh_lod), s.material && P.texture_lod >= 0 && this.loadProgressiveTextures(s.material, P.texture_lod, i), g && s.material && !s.isGizmo && ke(s.material);
|
|
1009
1012
|
for (const l of W)
|
|
1010
1013
|
l.onAfterUpdatedLOD?.(this.renderer, t, e, s, P);
|
|
1011
|
-
|
|
1014
|
+
r.lastLodLevel_Mesh = P.mesh_lod, r.lastLodLevel_Texture = P.texture_lod;
|
|
1012
1015
|
}
|
|
1013
1016
|
/** Load progressive textures for the given material
|
|
1014
1017
|
* @param material the material to load the textures for
|
|
@@ -1019,17 +1022,17 @@ let ie = class b {
|
|
|
1019
1022
|
if (!t)
|
|
1020
1023
|
return;
|
|
1021
1024
|
if (Array.isArray(t)) {
|
|
1022
|
-
for (const
|
|
1023
|
-
this.loadProgressiveTextures(
|
|
1025
|
+
for (const r of t)
|
|
1026
|
+
this.loadProgressiveTextures(r, e);
|
|
1024
1027
|
return;
|
|
1025
1028
|
}
|
|
1026
|
-
let
|
|
1027
|
-
if ((t[U] === void 0 || e < t[U]) && (
|
|
1029
|
+
let n = !1;
|
|
1030
|
+
if ((t[U] === void 0 || e < t[U]) && (n = !0), s !== void 0 && s >= 0 && (n = t[U] != s, e = s), n) {
|
|
1028
1031
|
t[U] = e;
|
|
1029
|
-
const
|
|
1032
|
+
const r = y.assignTextureLOD(t, e).then((i) => {
|
|
1030
1033
|
this._lodchangedlisteners.forEach((l) => l({ type: "texture", level: e, object: t }));
|
|
1031
1034
|
});
|
|
1032
|
-
de.addPromise("texture", t,
|
|
1035
|
+
de.addPromise("texture", t, r, this._newPromiseGroups);
|
|
1033
1036
|
}
|
|
1034
1037
|
}
|
|
1035
1038
|
/** Load progressive meshes for the given mesh
|
|
@@ -1042,10 +1045,10 @@ let ie = class b {
|
|
|
1042
1045
|
if (!t)
|
|
1043
1046
|
return Promise.resolve(null);
|
|
1044
1047
|
let s = t[U] !== e;
|
|
1045
|
-
const
|
|
1046
|
-
if (
|
|
1048
|
+
const n = t["DEBUG:LOD"];
|
|
1049
|
+
if (n != null && (s = t[U] != n, e = n), s) {
|
|
1047
1050
|
t[U] = e;
|
|
1048
|
-
const
|
|
1051
|
+
const r = t.geometry, i = y.assignMeshLOD(t, e).then((l) => (l && t[U] == e && r != t.geometry && this._lodchangedlisteners.forEach((a) => a({ type: "mesh", level: e, object: t })), l));
|
|
1049
1052
|
return de.addPromise("mesh", t, i, this._newPromiseGroups), i;
|
|
1050
1053
|
}
|
|
1051
1054
|
return Promise.resolve(null);
|
|
@@ -1064,27 +1067,27 @@ let ie = class b {
|
|
|
1064
1067
|
static corner3 = new A();
|
|
1065
1068
|
static _tempPtInside = new A();
|
|
1066
1069
|
static isInside(t, e) {
|
|
1067
|
-
const s = t.min,
|
|
1068
|
-
return this._tempPtInside.set(
|
|
1070
|
+
const s = t.min, n = t.max, r = (s.x + n.x) * 0.5, i = (s.y + n.y) * 0.5;
|
|
1071
|
+
return this._tempPtInside.set(r, i, s.z).applyMatrix4(e).z < 0;
|
|
1069
1072
|
}
|
|
1070
1073
|
static skinnedMeshBoundsFrameOffsetCounter = 0;
|
|
1071
1074
|
static $skinnedMeshBoundsOffset = Symbol("gltf-progressive-skinnedMeshBoundsOffset");
|
|
1072
1075
|
// #region calculateLodLevel
|
|
1073
|
-
calculateLodLevel(t, e, s,
|
|
1076
|
+
calculateLodLevel(t, e, s, n, r) {
|
|
1074
1077
|
if (!e) {
|
|
1075
|
-
|
|
1078
|
+
r.mesh_lod = -1, r.texture_lod = -1;
|
|
1076
1079
|
return;
|
|
1077
1080
|
}
|
|
1078
1081
|
if (!t) {
|
|
1079
|
-
|
|
1082
|
+
r.mesh_lod = -1, r.texture_lod = -1;
|
|
1080
1083
|
return;
|
|
1081
1084
|
}
|
|
1082
1085
|
let l = 10 + 1, a = !1;
|
|
1083
|
-
if (
|
|
1086
|
+
if (C && e["DEBUG:LOD"] != null)
|
|
1084
1087
|
return e["DEBUG:LOD"];
|
|
1085
1088
|
const u = y.getMeshLODExtension(e.geometry)?.lods, d = y.getPrimitiveIndex(e.geometry), p = u && u.length > 0, L = y.getMaterialMinMaxLODsCount(e.material), _ = L.min_count !== 1 / 0 && L.min_count >= 0 && L.max_count >= 0;
|
|
1086
1089
|
if (!p && !_) {
|
|
1087
|
-
|
|
1090
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1088
1091
|
return;
|
|
1089
1092
|
}
|
|
1090
1093
|
p || (a = !0, l = 0);
|
|
@@ -1113,12 +1116,12 @@ let ie = class b {
|
|
|
1113
1116
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
1114
1117
|
const f = t.getWorldPosition(this._tempWorldPosition);
|
|
1115
1118
|
if (this._sphere.containsPoint(f)) {
|
|
1116
|
-
|
|
1119
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1117
1120
|
return;
|
|
1118
1121
|
}
|
|
1119
1122
|
}
|
|
1120
1123
|
if (this._tempBox.copy(G), this._tempBox.applyMatrix4(e.matrixWorld), c.isPerspectiveCamera && b.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
1121
|
-
|
|
1124
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1122
1125
|
return;
|
|
1123
1126
|
}
|
|
1124
1127
|
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && c.isPerspectiveCamera && c.fov > 70) {
|
|
@@ -1135,7 +1138,7 @@ let ie = class b {
|
|
|
1135
1138
|
const O = t.matrixWorldInverse, B = this._tempBox2;
|
|
1136
1139
|
B.copy(G), B.applyMatrix4(e.matrixWorld), B.applyMatrix4(O);
|
|
1137
1140
|
const M = B.getSize(this._tempBox2Size), z = Math.max(M.x, M.y);
|
|
1138
|
-
if (Math.max(x.x, x.y) != 0 && z != 0 && (x.z = M.z / Math.max(M.x, M.y) * Math.max(x.x, x.y)), s.lastScreenCoverage = Math.max(x.x, x.y, x.z), s.lastScreenspaceVolume.copy(x), s.lastScreenCoverage *= s.lastCentrality,
|
|
1141
|
+
if (Math.max(x.x, x.y) != 0 && z != 0 && (x.z = M.z / Math.max(M.x, M.y) * Math.max(x.x, x.y)), s.lastScreenCoverage = Math.max(x.x, x.y, x.z), s.lastScreenspaceVolume.copy(x), s.lastScreenCoverage *= s.lastCentrality, C && b.debugDrawLine) {
|
|
1139
1142
|
const f = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
1140
1143
|
f.invert();
|
|
1141
1144
|
const h = b.corner0, D = b.corner1, v = b.corner2, $ = b.corner3;
|
|
@@ -1147,23 +1150,23 @@ let ie = class b {
|
|
|
1147
1150
|
if (u && s.lastScreenCoverage > 0)
|
|
1148
1151
|
for (let f = 0; f < u.length; f++) {
|
|
1149
1152
|
const h = u[f], v = (h.densities?.[d] || h.density || 1e-5) / s.lastScreenCoverage;
|
|
1150
|
-
if (d > 0 && Me() && !h.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (window["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.")), v <
|
|
1153
|
+
if (d > 0 && Me() && !h.densities && !globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"] && (window["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.")), v < n) {
|
|
1151
1154
|
w = f;
|
|
1152
1155
|
break;
|
|
1153
1156
|
}
|
|
1154
1157
|
}
|
|
1155
1158
|
w < l && (l = w, a = !0);
|
|
1156
1159
|
}
|
|
1157
|
-
if (a ?
|
|
1158
|
-
const x = u?.[
|
|
1159
|
-
x && console.debug(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${
|
|
1160
|
+
if (a ? r.mesh_lod = l : r.mesh_lod = s.lastLodLevel_Mesh, C && r.mesh_lod != s.lastLodLevel_Mesh) {
|
|
1161
|
+
const x = u?.[r.mesh_lod];
|
|
1162
|
+
x && console.debug(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (density: ${x.densities?.[d].toFixed(0)}) | ${e.name}`);
|
|
1160
1163
|
}
|
|
1161
1164
|
if (_) {
|
|
1162
1165
|
const c = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
1163
1166
|
if (s.lastLodLevel_Texture < 0) {
|
|
1164
|
-
if (
|
|
1167
|
+
if (r.texture_lod = L.max_count - 1, C) {
|
|
1165
1168
|
const x = L.lods[L.max_count - 1];
|
|
1166
|
-
|
|
1169
|
+
C && console.log(`First Texture LOD ${r.texture_lod} (${x.max_height}px) - ${e.name}`);
|
|
1167
1170
|
}
|
|
1168
1171
|
} else {
|
|
1169
1172
|
const x = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
@@ -1173,10 +1176,10 @@ let ie = class b {
|
|
|
1173
1176
|
let z = !1;
|
|
1174
1177
|
for (let S = L.lods.length - 1; S >= 0; S--) {
|
|
1175
1178
|
const w = L.lods[S];
|
|
1176
|
-
if (!(c && w.max_height >= 2048) && !(
|
|
1177
|
-
if (z = !0,
|
|
1179
|
+
if (!(c && w.max_height >= 2048) && !(Ce() && w.max_height > 4096) && (w.max_height > M || !z && S === 0)) {
|
|
1180
|
+
if (z = !0, r.texture_lod = S, C && r.texture_lod < s.lastLodLevel_Texture) {
|
|
1178
1181
|
const m = w.max_height;
|
|
1179
|
-
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${
|
|
1182
|
+
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${m}px
|
|
1180
1183
|
Screensize: ${M.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${x.toFixed(1)}
|
|
1181
1184
|
${e.name}`);
|
|
1182
1185
|
}
|
|
@@ -1185,7 +1188,7 @@ ${e.name}`);
|
|
|
1185
1188
|
}
|
|
1186
1189
|
}
|
|
1187
1190
|
} else
|
|
1188
|
-
|
|
1191
|
+
r.texture_lod = 0;
|
|
1189
1192
|
}
|
|
1190
1193
|
};
|
|
1191
1194
|
class mt {
|
|
@@ -1233,12 +1236,12 @@ function Be(o) {
|
|
|
1233
1236
|
ve.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++xt + `
|
|
1234
1237
|
`, o.getAttribute("src"));
|
|
1235
1238
|
let t = null, e = null, s = null;
|
|
1236
|
-
for (let
|
|
1237
|
-
const
|
|
1239
|
+
for (let n = o; n != null; n = Object.getPrototypeOf(n)) {
|
|
1240
|
+
const r = Object.getOwnPropertySymbols(n), i = r.find((u) => u.toString() == "Symbol(renderer)"), l = r.find((u) => u.toString() == "Symbol(scene)"), a = r.find((u) => u.toString() == "Symbol(needsRender)");
|
|
1238
1241
|
!t && i != null && (t = o[i].threeRenderer), !e && l != null && (e = o[l]), !s && a != null && (s = o[a]);
|
|
1239
1242
|
}
|
|
1240
1243
|
if (t && e) {
|
|
1241
|
-
let
|
|
1244
|
+
let r = function() {
|
|
1242
1245
|
if (s) {
|
|
1243
1246
|
let i = 0, l = setInterval(() => {
|
|
1244
1247
|
if (i++ > 5) {
|
|
@@ -1250,23 +1253,23 @@ function Be(o) {
|
|
|
1250
1253
|
}
|
|
1251
1254
|
};
|
|
1252
1255
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
1253
|
-
const
|
|
1254
|
-
return ie.addPlugin(new wt()),
|
|
1256
|
+
const n = ie.get(t, { engine: "model-viewer" });
|
|
1257
|
+
return ie.addPlugin(new wt()), n.enable(), n.addEventListener("changed", () => {
|
|
1255
1258
|
s?.call(o);
|
|
1256
1259
|
}), o.addEventListener("model-visibility", (i) => {
|
|
1257
1260
|
i.detail.visible && s?.call(o);
|
|
1258
1261
|
}), o.addEventListener("load", () => {
|
|
1259
|
-
|
|
1262
|
+
r();
|
|
1260
1263
|
}), () => {
|
|
1261
|
-
|
|
1264
|
+
n.disable();
|
|
1262
1265
|
};
|
|
1263
1266
|
}
|
|
1264
1267
|
return null;
|
|
1265
1268
|
}
|
|
1266
1269
|
class wt {
|
|
1267
1270
|
_didWarnAboutMissingUrl = !1;
|
|
1268
|
-
onBeforeUpdateLOD(t, e, s,
|
|
1269
|
-
this.tryParseMeshLOD(e,
|
|
1271
|
+
onBeforeUpdateLOD(t, e, s, n) {
|
|
1272
|
+
this.tryParseMeshLOD(e, n), this.tryParseTextureLOD(e, n);
|
|
1270
1273
|
}
|
|
1271
1274
|
getUrl(t) {
|
|
1272
1275
|
if (!t)
|
|
@@ -1284,8 +1287,8 @@ class wt {
|
|
|
1284
1287
|
if (e[se] == !0)
|
|
1285
1288
|
return;
|
|
1286
1289
|
e[se] = !0;
|
|
1287
|
-
const s = this.tryGetCurrentGLTF(t),
|
|
1288
|
-
if (
|
|
1290
|
+
const s = this.tryGetCurrentGLTF(t), n = this.tryGetCurrentModelViewer(t), r = this.getUrl(n);
|
|
1291
|
+
if (r && s && e.material) {
|
|
1289
1292
|
let l = function(a) {
|
|
1290
1293
|
if (a[se] == !0)
|
|
1291
1294
|
return;
|
|
@@ -1304,7 +1307,7 @@ class wt {
|
|
|
1304
1307
|
}
|
|
1305
1308
|
if (I?.extensions?.[F]) {
|
|
1306
1309
|
const G = I.extensions[F];
|
|
1307
|
-
G &&
|
|
1310
|
+
G && r && y.registerTexture(r, L, G.lods.length, _, G);
|
|
1308
1311
|
}
|
|
1309
1312
|
}
|
|
1310
1313
|
}
|
|
@@ -1321,40 +1324,40 @@ class wt {
|
|
|
1321
1324
|
if (e[De] == !0)
|
|
1322
1325
|
return;
|
|
1323
1326
|
e[De] = !0;
|
|
1324
|
-
const s = this.tryGetCurrentModelViewer(t),
|
|
1325
|
-
if (!
|
|
1327
|
+
const s = this.tryGetCurrentModelViewer(t), n = this.getUrl(s);
|
|
1328
|
+
if (!n)
|
|
1326
1329
|
return;
|
|
1327
|
-
const
|
|
1328
|
-
if (
|
|
1330
|
+
const r = e.userData?.gltfExtensions?.[F];
|
|
1331
|
+
if (r && n) {
|
|
1329
1332
|
const i = e.uuid;
|
|
1330
|
-
y.registerMesh(
|
|
1333
|
+
y.registerMesh(n, i, e, 0, r.lods.length, r);
|
|
1331
1334
|
}
|
|
1332
1335
|
}
|
|
1333
1336
|
}
|
|
1334
1337
|
function Lt(...o) {
|
|
1335
|
-
let t, e, s,
|
|
1338
|
+
let t, e, s, n;
|
|
1336
1339
|
switch (o.length) {
|
|
1337
1340
|
case 2:
|
|
1338
|
-
[s, e] = o,
|
|
1341
|
+
[s, e] = o, n = {};
|
|
1339
1342
|
break;
|
|
1340
1343
|
case 3:
|
|
1341
|
-
[s, e,
|
|
1344
|
+
[s, e, n] = o;
|
|
1342
1345
|
break;
|
|
1343
1346
|
case 4:
|
|
1344
|
-
[t, e, s,
|
|
1347
|
+
[t, e, s, n] = o;
|
|
1345
1348
|
break;
|
|
1346
1349
|
default:
|
|
1347
1350
|
throw new Error("Invalid arguments");
|
|
1348
1351
|
}
|
|
1349
1352
|
we(e), Te(s), Ie(s, {
|
|
1350
1353
|
progressive: !0,
|
|
1351
|
-
...
|
|
1354
|
+
...n?.hints
|
|
1352
1355
|
}), s.register((i) => new y(i));
|
|
1353
|
-
const
|
|
1354
|
-
return
|
|
1356
|
+
const r = ie.get(e);
|
|
1357
|
+
return n?.enableLODsManager !== !1 && r.enable(), r;
|
|
1355
1358
|
}
|
|
1356
1359
|
Re();
|
|
1357
|
-
if (!
|
|
1360
|
+
if (!nt) {
|
|
1358
1361
|
const o = {
|
|
1359
1362
|
gltfProgressive: {
|
|
1360
1363
|
useNeedleProgressive: Lt,
|