@needle-tools/engine 4.8.3 → 4.8.4-next.5c03fe1
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/dist/{gltf-progressive-Do1XJNMG.js → gltf-progressive-B3JW4cAu.js} +247 -248
- package/dist/gltf-progressive-DorC035H.min.js +8 -0
- package/dist/{gltf-progressive-CHV7_60B.umd.cjs → gltf-progressive-PB_58h1b.umd.cjs} +6 -6
- package/dist/{needle-engine.bundle-d8rUkpZi.umd.cjs → needle-engine.bundle-BDQm33td.umd.cjs} +36 -26
- package/dist/{needle-engine.bundle-CiIS3tNq.js → needle-engine.bundle-BecMzBfA.js} +219 -205
- package/dist/{needle-engine.bundle-Drb5H9t2.min.js → needle-engine.bundle-C3oFZgvW.min.js} +43 -33
- package/dist/needle-engine.js +3 -3
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{vendor-CGONwIc0.js → vendor-B_ytQUuR.js} +6 -6
- package/dist/{vendor-BlSxe9JJ.min.js → vendor-C31T0mYm.min.js} +2 -2
- package/dist/{vendor-Cty8Dnri.umd.cjs → vendor-D51IT5ns.umd.cjs} +9 -9
- package/lib/engine/engine_context.d.ts +1 -1
- package/lib/engine/engine_context.js +5 -12
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_networking_streams.js +13 -2
- package/lib/engine/engine_networking_streams.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/OrbitControls.d.ts +1 -0
- package/lib/engine-components/OrbitControls.js +6 -0
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/package.json +4 -4
- package/plugins/vite/peer.js +60 -2
- package/plugins/vite/poster-client.js +35 -51
- package/plugins/vite/poster.js +2 -3
- package/src/engine/engine_context.ts +7 -12
- package/src/engine/engine_networking_streams.ts +17 -8
- 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/OrbitControls.ts +5 -0
- package/dist/gltf-progressive-B--ZfCTJ.min.js +0 -8
|
@@ -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];
|
|
@@ -186,11 +186,7 @@ function dt(o) {
|
|
|
186
186
|
class Le {
|
|
187
187
|
worker;
|
|
188
188
|
static async createWorker(t) {
|
|
189
|
-
const e = new Worker(new URL(
|
|
190
|
-
/* @vite-ignore */
|
|
191
|
-
"/loader.worker-CrU5fNbR.js",
|
|
192
|
-
import.meta.url
|
|
193
|
-
), {
|
|
189
|
+
const e = new Worker(URL.createObjectURL(new Blob(["import '" + `${new URL('./loader.worker-CrU5fNbR.js', import.meta.url).toString()}` + "';"], { type: 'text/javascript' })), {
|
|
194
190
|
type: "module"
|
|
195
191
|
});
|
|
196
192
|
return new Le(e, t);
|
|
@@ -199,12 +195,12 @@ class Le {
|
|
|
199
195
|
_webglRenderer = null;
|
|
200
196
|
async load(t, e) {
|
|
201
197
|
const s = Qe();
|
|
202
|
-
let
|
|
203
|
-
|
|
198
|
+
let n = e?.renderer;
|
|
199
|
+
n || (this._webglRenderer ??= (async () => {
|
|
204
200
|
const { WebGLRenderer: u } = await import("./three-DrqIzZTH.js").then((d) => d.THREE);
|
|
205
201
|
return new u();
|
|
206
|
-
})(),
|
|
207
|
-
const l = we(
|
|
202
|
+
})(), n = await this._webglRenderer);
|
|
203
|
+
const l = we(n).ktx2Loader.workerConfig;
|
|
208
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());
|
|
209
205
|
const a = {
|
|
210
206
|
type: "load",
|
|
@@ -223,13 +219,13 @@ class Le {
|
|
|
223
219
|
_debug = !1;
|
|
224
220
|
constructor(t, e) {
|
|
225
221
|
this.worker = t, this._debug = e.debug ?? !1, t.onmessage = (s) => {
|
|
226
|
-
const
|
|
227
|
-
switch (this._debug && console.log("[Worker] EVENT",
|
|
222
|
+
const n = s.data;
|
|
223
|
+
switch (this._debug && console.log("[Worker] EVENT", n), n.type) {
|
|
228
224
|
case "loaded-gltf":
|
|
229
|
-
for (const
|
|
230
|
-
if (
|
|
231
|
-
ct(
|
|
232
|
-
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;
|
|
233
229
|
i.startsWith("blob:") && URL.revokeObjectURL(i);
|
|
234
230
|
}
|
|
235
231
|
}
|
|
@@ -244,29 +240,29 @@ function ct(o) {
|
|
|
244
240
|
for (const t of o.geometries) {
|
|
245
241
|
const e = t.geometry, s = new Q();
|
|
246
242
|
if (s.name = e.name || "", e.index) {
|
|
247
|
-
const
|
|
248
|
-
s.setIndex(le(
|
|
243
|
+
const n = e.index;
|
|
244
|
+
s.setIndex(le(n));
|
|
249
245
|
}
|
|
250
|
-
for (const
|
|
251
|
-
const
|
|
252
|
-
s.setAttribute(
|
|
246
|
+
for (const n in e.attributes) {
|
|
247
|
+
const r = e.attributes[n], i = le(r);
|
|
248
|
+
s.setAttribute(n, i);
|
|
253
249
|
}
|
|
254
250
|
if (e.morphAttributes)
|
|
255
|
-
for (const
|
|
256
|
-
const i = e.morphAttributes[
|
|
257
|
-
s.morphAttributes[
|
|
251
|
+
for (const n in e.morphAttributes) {
|
|
252
|
+
const i = e.morphAttributes[n].map((l) => le(l));
|
|
253
|
+
s.morphAttributes[n] = i;
|
|
258
254
|
}
|
|
259
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)
|
|
260
|
-
for (const
|
|
261
|
-
s.addGroup(
|
|
256
|
+
for (const n of e.groups)
|
|
257
|
+
s.addGroup(n.start, n.count, n.materialIndex);
|
|
262
258
|
e.userData && (s.userData = e.userData), t.geometry = s;
|
|
263
259
|
}
|
|
264
260
|
for (const t of o.textures) {
|
|
265
261
|
const e = t.texture;
|
|
266
262
|
let s = null;
|
|
267
263
|
if (e.isCompressedTexture) {
|
|
268
|
-
const
|
|
269
|
-
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);
|
|
270
266
|
} else
|
|
271
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);
|
|
272
268
|
if (!s) {
|
|
@@ -280,8 +276,8 @@ function ct(o) {
|
|
|
280
276
|
function le(o) {
|
|
281
277
|
let t = o;
|
|
282
278
|
if ("isInterleavedBufferAttribute" in o && o.isInterleavedBufferAttribute) {
|
|
283
|
-
const e = o.data, s = e.array,
|
|
284
|
-
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;
|
|
285
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);
|
|
286
282
|
return t;
|
|
287
283
|
}
|
|
@@ -300,9 +296,9 @@ class y {
|
|
|
300
296
|
return e ?? -1;
|
|
301
297
|
}
|
|
302
298
|
static getMaterialMinMaxLODsCount(t, e) {
|
|
303
|
-
const s = this,
|
|
304
|
-
if (
|
|
305
|
-
return
|
|
299
|
+
const s = this, n = "LODS:minmax", r = t[n];
|
|
300
|
+
if (r != null)
|
|
301
|
+
return r;
|
|
306
302
|
if (e || (e = {
|
|
307
303
|
min_count: 1 / 0,
|
|
308
304
|
max_count: 0,
|
|
@@ -310,7 +306,7 @@ class y {
|
|
|
310
306
|
}), Array.isArray(t)) {
|
|
311
307
|
for (const l of t)
|
|
312
308
|
this.getMaterialMinMaxLODsCount(l, e);
|
|
313
|
-
return t[
|
|
309
|
+
return t[n] = e, e;
|
|
314
310
|
}
|
|
315
311
|
if (g === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
|
|
316
312
|
const l = t;
|
|
@@ -325,7 +321,7 @@ class y {
|
|
|
325
321
|
}
|
|
326
322
|
else
|
|
327
323
|
g && console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${t.type}`);
|
|
328
|
-
return t[
|
|
324
|
+
return t[n] = e, e;
|
|
329
325
|
function i(l, a) {
|
|
330
326
|
const u = s.getAssignedLODInformation(l);
|
|
331
327
|
if (u) {
|
|
@@ -347,30 +343,30 @@ class y {
|
|
|
347
343
|
*/
|
|
348
344
|
static hasLODLevelAvailable(t, e) {
|
|
349
345
|
if (Array.isArray(t)) {
|
|
350
|
-
for (const
|
|
351
|
-
if (this.hasLODLevelAvailable(
|
|
346
|
+
for (const r of t)
|
|
347
|
+
if (this.hasLODLevelAvailable(r, e))
|
|
352
348
|
return !0;
|
|
353
349
|
return !1;
|
|
354
350
|
}
|
|
355
351
|
if (t.isMaterial === !0) {
|
|
356
|
-
for (const
|
|
357
|
-
const i = t[
|
|
352
|
+
for (const r of Object.keys(t)) {
|
|
353
|
+
const i = t[r];
|
|
358
354
|
if (i && i.isTexture && this.hasLODLevelAvailable(i, e))
|
|
359
355
|
return !0;
|
|
360
356
|
}
|
|
361
357
|
return !1;
|
|
362
358
|
} else if (t.isGroup === !0) {
|
|
363
|
-
for (const
|
|
364
|
-
if (
|
|
359
|
+
for (const r of t.children)
|
|
360
|
+
if (r.isMesh === !0 && this.hasLODLevelAvailable(r, e))
|
|
365
361
|
return !0;
|
|
366
362
|
}
|
|
367
|
-
let s,
|
|
363
|
+
let s, n;
|
|
368
364
|
if (t.isMesh ? s = t.geometry : (t.isBufferGeometry || t.isTexture) && (s = t), s && s?.userData?.LODS) {
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
return
|
|
372
|
-
if (
|
|
373
|
-
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;
|
|
374
370
|
}
|
|
375
371
|
return !1;
|
|
376
372
|
}
|
|
@@ -392,18 +388,18 @@ class y {
|
|
|
392
388
|
if (!t)
|
|
393
389
|
return Promise.resolve(null);
|
|
394
390
|
if (t instanceof q || t.isMesh === !0) {
|
|
395
|
-
const s = t.geometry,
|
|
396
|
-
if (!
|
|
391
|
+
const s = t.geometry, n = this.getAssignedLODInformation(s);
|
|
392
|
+
if (!n)
|
|
397
393
|
return Promise.resolve(null);
|
|
398
|
-
for (const
|
|
399
|
-
|
|
400
|
-
return t["LOD:requested level"] = e, y.getOrLoadLOD(s, e).then((
|
|
401
|
-
if (Array.isArray(
|
|
402
|
-
const i =
|
|
403
|
-
|
|
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];
|
|
404
400
|
}
|
|
405
|
-
return t["LOD:requested level"] === e && (delete t["LOD:requested level"],
|
|
406
|
-
}).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));
|
|
407
403
|
} else g && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
408
404
|
return Promise.resolve(null);
|
|
409
405
|
}
|
|
@@ -413,14 +409,14 @@ class y {
|
|
|
413
409
|
if (t.isMesh === !0) {
|
|
414
410
|
const s = t;
|
|
415
411
|
if (Array.isArray(s.material)) {
|
|
416
|
-
const
|
|
417
|
-
for (const
|
|
418
|
-
const i = this.assignTextureLOD(
|
|
419
|
-
|
|
412
|
+
const n = new Array();
|
|
413
|
+
for (const r of s.material) {
|
|
414
|
+
const i = this.assignTextureLOD(r, e);
|
|
415
|
+
n.push(i);
|
|
420
416
|
}
|
|
421
|
-
return Promise.all(
|
|
417
|
+
return Promise.all(n).then((r) => {
|
|
422
418
|
const i = new Array();
|
|
423
|
-
for (const l of
|
|
419
|
+
for (const l of r)
|
|
424
420
|
Array.isArray(l) && i.push(...l);
|
|
425
421
|
return i;
|
|
426
422
|
});
|
|
@@ -428,14 +424,14 @@ class y {
|
|
|
428
424
|
return this.assignTextureLOD(s.material, e);
|
|
429
425
|
}
|
|
430
426
|
if (t.isMaterial === !0) {
|
|
431
|
-
const s = t,
|
|
427
|
+
const s = t, n = [], r = new Array();
|
|
432
428
|
if (s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
433
429
|
const i = s;
|
|
434
430
|
for (const l of Object.keys(i.uniforms)) {
|
|
435
431
|
const a = i.uniforms[l].value;
|
|
436
432
|
if (a?.isTexture === !0) {
|
|
437
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));
|
|
438
|
-
|
|
434
|
+
n.push(u), r.push(l);
|
|
439
435
|
}
|
|
440
436
|
}
|
|
441
437
|
} else
|
|
@@ -443,13 +439,13 @@ class y {
|
|
|
443
439
|
const l = s[i];
|
|
444
440
|
if (l?.isTexture === !0) {
|
|
445
441
|
const a = this.assignTextureLODForSlot(l, e, s, i);
|
|
446
|
-
|
|
442
|
+
n.push(a), r.push(i);
|
|
447
443
|
}
|
|
448
444
|
}
|
|
449
|
-
return Promise.all(
|
|
445
|
+
return Promise.all(n).then((i) => {
|
|
450
446
|
const l = new Array();
|
|
451
447
|
for (let a = 0; a < i.length; a++) {
|
|
452
|
-
const u = i[a], d =
|
|
448
|
+
const u = i[a], d = r[a];
|
|
453
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 });
|
|
454
450
|
}
|
|
455
451
|
return l;
|
|
@@ -461,28 +457,28 @@ class y {
|
|
|
461
457
|
}
|
|
462
458
|
return Promise.resolve(null);
|
|
463
459
|
}
|
|
464
|
-
static assignTextureLODForSlot(t, e, s,
|
|
465
|
-
return t?.isTexture !== !0 ? Promise.resolve(null) :
|
|
466
|
-
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))
|
|
467
463
|
return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."), null;
|
|
468
|
-
if (
|
|
469
|
-
if (
|
|
470
|
-
const i = s[
|
|
464
|
+
if (r?.isTexture === !0) {
|
|
465
|
+
if (r != t && s && n) {
|
|
466
|
+
const i = s[n];
|
|
471
467
|
if (i && !g) {
|
|
472
468
|
const l = this.getAssignedLODInformation(i);
|
|
473
469
|
if (l && l?.level < e)
|
|
474
|
-
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;
|
|
475
471
|
}
|
|
476
|
-
if (ht &&
|
|
477
|
-
const l =
|
|
478
|
-
|
|
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}.`);
|
|
479
475
|
}
|
|
480
|
-
s[
|
|
476
|
+
s[n] = r;
|
|
481
477
|
}
|
|
482
|
-
return
|
|
478
|
+
return r;
|
|
483
479
|
} else g == "verbose" && console.warn("No LOD found for", t, e);
|
|
484
480
|
return null;
|
|
485
|
-
}).catch((
|
|
481
|
+
}).catch((r) => (console.error("Error loading LOD", t, r), null));
|
|
486
482
|
}
|
|
487
483
|
parser;
|
|
488
484
|
url;
|
|
@@ -514,28 +510,28 @@ class y {
|
|
|
514
510
|
afterRoot(t) {
|
|
515
511
|
return g && console.log("AFTER", this.url, t), this.parser.json.textures?.forEach((e, s) => {
|
|
516
512
|
if (e?.extensions) {
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
519
|
-
if (!
|
|
520
|
-
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);
|
|
521
517
|
return;
|
|
522
518
|
}
|
|
523
|
-
let
|
|
519
|
+
let r = !1;
|
|
524
520
|
for (const i of this.parser.associations.keys())
|
|
525
|
-
i.isTexture === !0 && this.parser.associations.get(i)?.textures === s && (
|
|
526
|
-
|
|
527
|
-
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);
|
|
528
524
|
});
|
|
529
525
|
}
|
|
530
526
|
}
|
|
531
527
|
}), this.parser.json.meshes?.forEach((e, s) => {
|
|
532
528
|
if (e?.extensions) {
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
for (const
|
|
536
|
-
if (
|
|
537
|
-
const i = this.parser.associations.get(
|
|
538
|
-
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);
|
|
539
535
|
}
|
|
540
536
|
}
|
|
541
537
|
}
|
|
@@ -544,31 +540,31 @@ class y {
|
|
|
544
540
|
/**
|
|
545
541
|
* Register a texture with LOD information
|
|
546
542
|
*/
|
|
547
|
-
static registerTexture = (t, e, s,
|
|
543
|
+
static registerTexture = (t, e, s, n, r) => {
|
|
548
544
|
if (!e) {
|
|
549
545
|
g && console.error("gltf-progressive: Called register texture without texture");
|
|
550
546
|
return;
|
|
551
547
|
}
|
|
552
548
|
if (g) {
|
|
553
549
|
const l = e.image?.width || e.source?.data?.width || 0, a = e.image?.height || e.source?.data?.height || 0;
|
|
554
|
-
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);
|
|
555
551
|
}
|
|
556
|
-
e.source && (e.source[ue] =
|
|
557
|
-
const i =
|
|
558
|
-
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);
|
|
559
555
|
};
|
|
560
556
|
/**
|
|
561
557
|
* Register a mesh with LOD information
|
|
562
558
|
*/
|
|
563
|
-
static registerMesh = (t, e, s,
|
|
559
|
+
static registerMesh = (t, e, s, n, r, i) => {
|
|
564
560
|
const l = s.geometry;
|
|
565
561
|
if (!l) {
|
|
566
562
|
g && console.warn("gltf-progressive: Register mesh without geometry");
|
|
567
563
|
return;
|
|
568
564
|
}
|
|
569
|
-
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);
|
|
570
566
|
let a = y.lowresCache.get(e);
|
|
571
|
-
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);
|
|
572
568
|
for (const u of W)
|
|
573
569
|
u.onRegisteredNewMesh?.(s, i);
|
|
574
570
|
};
|
|
@@ -581,26 +577,26 @@ class y {
|
|
|
581
577
|
static workers = [];
|
|
582
578
|
static _workersIndex = 0;
|
|
583
579
|
static async getOrLoadLOD(t, e) {
|
|
584
|
-
const s = g == "verbose",
|
|
585
|
-
if (!
|
|
580
|
+
const s = g == "verbose", n = this.getAssignedLODInformation(t);
|
|
581
|
+
if (!n)
|
|
586
582
|
return g && console.warn(`[gltf-progressive] No LOD information found: ${t.name}, uuid: ${t.uuid}, type: ${t.type}`, t), null;
|
|
587
|
-
const
|
|
583
|
+
const r = n?.key;
|
|
588
584
|
let i;
|
|
589
585
|
if (t.isTexture === !0) {
|
|
590
586
|
const a = t;
|
|
591
587
|
a.source && a.source[ue] && (i = a.source[ue]);
|
|
592
588
|
}
|
|
593
|
-
if (i || (i = y.lodInfos.get(
|
|
589
|
+
if (i || (i = y.lodInfos.get(r)), i) {
|
|
594
590
|
if (e > 0) {
|
|
595
591
|
let d = !1;
|
|
596
592
|
const p = Array.isArray(i.lods);
|
|
597
593
|
if (p && e >= i.lods.length ? d = !0 : p || (d = !0), d)
|
|
598
|
-
return this.lowresCache.get(
|
|
594
|
+
return this.lowresCache.get(r);
|
|
599
595
|
}
|
|
600
596
|
const a = Array.isArray(i.lods) ? i.lods[e]?.path : i.lods;
|
|
601
597
|
if (!a)
|
|
602
598
|
return g && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
|
|
603
|
-
const u = st(
|
|
599
|
+
const u = st(n.url, a);
|
|
604
600
|
if (u.endsWith(".glb") || u.endsWith(".gltf")) {
|
|
605
601
|
if (!i.guid)
|
|
606
602
|
return console.warn("missing pointer for glb/gltf texture", i), null;
|
|
@@ -620,13 +616,13 @@ class y {
|
|
|
620
616
|
if (m.textures.length > 0)
|
|
621
617
|
for (const f of m.textures) {
|
|
622
618
|
let h = f.texture;
|
|
623
|
-
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);
|
|
624
620
|
}
|
|
625
621
|
if (m.geometries.length > 0) {
|
|
626
622
|
const f = new Array();
|
|
627
623
|
for (const h of m.geometries) {
|
|
628
624
|
const D = h.geometry;
|
|
629
|
-
y.assignLODInformation(
|
|
625
|
+
y.assignLODInformation(n.url, D, r, e, h.primitiveIndex), f.push(D);
|
|
630
626
|
}
|
|
631
627
|
return c(f);
|
|
632
628
|
}
|
|
@@ -660,7 +656,7 @@ class y {
|
|
|
660
656
|
}
|
|
661
657
|
if (w) {
|
|
662
658
|
let m = await z.getDependency("texture", S);
|
|
663
|
-
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);
|
|
664
660
|
} else g && console.warn("Could not find texture with guid", _.guid, M.parser.json);
|
|
665
661
|
}
|
|
666
662
|
if (S = 0, M.parser.json.meshes) {
|
|
@@ -679,14 +675,14 @@ class y {
|
|
|
679
675
|
const m = await z.getDependency("mesh", S);
|
|
680
676
|
if (s && console.log(`Loaded Mesh "${m.name}"`, u, S, m, d), m.isMesh === !0) {
|
|
681
677
|
const f = m.geometry;
|
|
682
|
-
return y.assignLODInformation(
|
|
678
|
+
return y.assignLODInformation(n.url, f, r, e, 0), c(f);
|
|
683
679
|
} else {
|
|
684
680
|
const f = new Array();
|
|
685
681
|
for (let h = 0; h < m.children.length; h++) {
|
|
686
682
|
const D = m.children[h];
|
|
687
683
|
if (D.isMesh === !0) {
|
|
688
684
|
const v = D.geometry;
|
|
689
|
-
y.assignLODInformation(
|
|
685
|
+
y.assignLODInformation(n.url, v, r, e, h), f.push(v);
|
|
690
686
|
}
|
|
691
687
|
}
|
|
692
688
|
return c(f);
|
|
@@ -702,16 +698,16 @@ class y {
|
|
|
702
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;
|
|
703
699
|
}
|
|
704
700
|
} else
|
|
705
|
-
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);
|
|
706
702
|
return null;
|
|
707
703
|
}
|
|
708
704
|
static maxConcurrent = 50;
|
|
709
|
-
static queue = new
|
|
710
|
-
static assignLODInformation(t, e, s,
|
|
705
|
+
static queue = new rt(y.maxConcurrent, { debug: g != !1 });
|
|
706
|
+
static assignLODInformation(t, e, s, n, r) {
|
|
711
707
|
if (!e)
|
|
712
708
|
return;
|
|
713
709
|
e.userData || (e.userData = {});
|
|
714
|
-
const i = new gt(t, s,
|
|
710
|
+
const i = new gt(t, s, n, r);
|
|
715
711
|
e.userData.LODS = i, "source" in e && typeof e.source == "object" && (e.source.LODS = i);
|
|
716
712
|
}
|
|
717
713
|
static getAssignedLODInformation(t) {
|
|
@@ -731,33 +727,36 @@ class gt {
|
|
|
731
727
|
level;
|
|
732
728
|
/** For multi objects (e.g. a group of meshes) this is the index of the object */
|
|
733
729
|
index;
|
|
734
|
-
constructor(t, e, s,
|
|
735
|
-
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);
|
|
736
732
|
}
|
|
737
733
|
}
|
|
738
734
|
class de {
|
|
739
|
-
static addPromise = (t, e, s,
|
|
740
|
-
|
|
741
|
-
|
|
735
|
+
static addPromise = (t, e, s, n) => {
|
|
736
|
+
n.forEach((r) => {
|
|
737
|
+
r.add(t, e, s);
|
|
742
738
|
});
|
|
743
739
|
};
|
|
744
|
-
frame_start;
|
|
745
|
-
frame_capture_end;
|
|
746
740
|
ready;
|
|
747
|
-
|
|
748
|
-
_signal;
|
|
749
|
-
/**
|
|
750
|
-
* The number of promises that have been added to this group so far.
|
|
751
|
-
*/
|
|
741
|
+
/** The number of promises that have been added to this group so far */
|
|
752
742
|
get awaitedCount() {
|
|
753
743
|
return this._addedCount;
|
|
754
744
|
}
|
|
745
|
+
/** The number of promises that have been resolved */
|
|
755
746
|
get resolvedCount() {
|
|
756
747
|
return this._resolvedCount;
|
|
757
748
|
}
|
|
749
|
+
/** The number of promises that are in-flight */
|
|
758
750
|
get currentlyAwaiting() {
|
|
759
751
|
return this._awaiting.length;
|
|
760
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;
|
|
761
760
|
_resolved = !1;
|
|
762
761
|
_addedCount = 0;
|
|
763
762
|
_resolvedCount = 0;
|
|
@@ -765,9 +764,9 @@ class de {
|
|
|
765
764
|
_awaiting = [];
|
|
766
765
|
_maxPromisesPerObject = 1;
|
|
767
766
|
constructor(t, e) {
|
|
768
|
-
const
|
|
769
|
-
this.
|
|
770
|
-
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;
|
|
771
770
|
}), this.ready.finally(() => {
|
|
772
771
|
this._resolved = !0, this._awaiting.length = 0;
|
|
773
772
|
}), this._signal = e.signal, this._signal?.addEventListener("abort", () => {
|
|
@@ -776,7 +775,7 @@ class de {
|
|
|
776
775
|
}
|
|
777
776
|
_currentFrame = 0;
|
|
778
777
|
update(t) {
|
|
779
|
-
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();
|
|
780
779
|
}
|
|
781
780
|
_seen = /* @__PURE__ */ new WeakMap();
|
|
782
781
|
add(t, e, s) {
|
|
@@ -784,15 +783,15 @@ class de {
|
|
|
784
783
|
g && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
|
|
785
784
|
return;
|
|
786
785
|
}
|
|
787
|
-
if (!(this._currentFrame > this.
|
|
786
|
+
if (!(this._frame_start !== void 0 && this._currentFrame > this._frame_start + this._frames_to_capture)) {
|
|
788
787
|
if (this._maxPromisesPerObject >= 1)
|
|
789
788
|
if (this._seen.has(e)) {
|
|
790
|
-
let
|
|
791
|
-
if (
|
|
789
|
+
let n = this._seen.get(e);
|
|
790
|
+
if (n >= this._maxPromisesPerObject) {
|
|
792
791
|
g && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
|
|
793
792
|
return;
|
|
794
793
|
}
|
|
795
|
-
this._seen.set(e,
|
|
794
|
+
this._seen.set(e, n + 1);
|
|
796
795
|
} else
|
|
797
796
|
this._seen.set(e, 1);
|
|
798
797
|
this._awaiting.push(s), this._addedCount++, s.finally(() => {
|
|
@@ -808,7 +807,7 @@ class de {
|
|
|
808
807
|
});
|
|
809
808
|
}
|
|
810
809
|
}
|
|
811
|
-
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 };
|
|
812
811
|
let ie = class b {
|
|
813
812
|
/**
|
|
814
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.
|
|
@@ -885,13 +884,13 @@ let ie = class b {
|
|
|
885
884
|
* Call to await LODs loading during the next render cycle.
|
|
886
885
|
*/
|
|
887
886
|
awaitLoading(t) {
|
|
888
|
-
const e = this._promiseGroupIds++, s = new de(this.#
|
|
887
|
+
const e = this._promiseGroupIds++, s = new de(this.#r, { ...t });
|
|
889
888
|
this._newPromiseGroups.push(s);
|
|
890
|
-
const
|
|
889
|
+
const n = performance.now();
|
|
891
890
|
return s.ready.finally(() => {
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
start:
|
|
891
|
+
const r = this._newPromiseGroups.indexOf(s);
|
|
892
|
+
r >= 0 && (this._newPromiseGroups.splice(r, 1), Me() && performance.measure("LODsManager:awaitLoading", {
|
|
893
|
+
start: n,
|
|
895
894
|
detail: { id: e, name: t?.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
|
|
896
895
|
}));
|
|
897
896
|
}), s.ready;
|
|
@@ -899,7 +898,7 @@ let ie = class b {
|
|
|
899
898
|
_postprocessPromiseGroups() {
|
|
900
899
|
if (this._newPromiseGroups.length !== 0)
|
|
901
900
|
for (let t = this._newPromiseGroups.length - 1; t >= 0; t--)
|
|
902
|
-
this._newPromiseGroups[t].update(this.#
|
|
901
|
+
this._newPromiseGroups[t].update(this.#r);
|
|
903
902
|
}
|
|
904
903
|
_lodchangedlisteners = [];
|
|
905
904
|
addEventListener(t, e) {
|
|
@@ -917,8 +916,8 @@ let ie = class b {
|
|
|
917
916
|
}
|
|
918
917
|
#t;
|
|
919
918
|
#i = new qe();
|
|
920
|
-
#n = 0;
|
|
921
919
|
#r = 0;
|
|
920
|
+
#n = 0;
|
|
922
921
|
#o = 0;
|
|
923
922
|
#s = 0;
|
|
924
923
|
_fpsBuffer = [60, 60, 60, 60, 60];
|
|
@@ -932,11 +931,11 @@ let ie = class b {
|
|
|
932
931
|
let t = 0;
|
|
933
932
|
this.#t = this.renderer.render;
|
|
934
933
|
const e = this;
|
|
935
|
-
we(this.renderer), this.renderer.render = function(s,
|
|
936
|
-
const
|
|
937
|
-
(
|
|
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));
|
|
938
937
|
const i = t++;
|
|
939
|
-
e.#t.call(this, s,
|
|
938
|
+
e.#t.call(this, s, n), e.onAfterRender(s, n, i);
|
|
940
939
|
};
|
|
941
940
|
}
|
|
942
941
|
disable() {
|
|
@@ -948,14 +947,14 @@ let ie = class b {
|
|
|
948
947
|
onAfterRender(t, e, s) {
|
|
949
948
|
if (this.pause)
|
|
950
949
|
return;
|
|
951
|
-
const
|
|
950
|
+
const r = this.renderer.renderLists.get(t, 0).opaque;
|
|
952
951
|
let i = !0;
|
|
953
|
-
if (
|
|
954
|
-
const l =
|
|
952
|
+
if (r.length === 1) {
|
|
953
|
+
const l = r[0].material;
|
|
955
954
|
(l.name === "EffectMaterial" || l.name === "CopyShader") && (i = !1);
|
|
956
955
|
}
|
|
957
956
|
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
|
|
958
|
-
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))
|
|
959
958
|
return;
|
|
960
959
|
this.internalUpdate(t, e), this._postprocessPromiseGroups();
|
|
961
960
|
}
|
|
@@ -964,12 +963,12 @@ let ie = class b {
|
|
|
964
963
|
* Update LODs in a scene
|
|
965
964
|
*/
|
|
966
965
|
internalUpdate(t, e) {
|
|
967
|
-
const s = this.renderer.renderLists.get(t, 0),
|
|
966
|
+
const s = this.renderer.renderLists.get(t, 0), n = s.opaque;
|
|
968
967
|
this.projectionScreenMatrix.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse);
|
|
969
|
-
const
|
|
970
|
-
for (const a of
|
|
968
|
+
const r = this.targetTriangleDensity;
|
|
969
|
+
for (const a of n) {
|
|
971
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")) {
|
|
972
|
-
|
|
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)));
|
|
973
972
|
continue;
|
|
974
973
|
}
|
|
975
974
|
switch (a.material.type) {
|
|
@@ -981,38 +980,38 @@ let ie = class b {
|
|
|
981
980
|
case "MeshDepthMaterial":
|
|
982
981
|
continue;
|
|
983
982
|
}
|
|
984
|
-
if (
|
|
983
|
+
if (C === "color" && a.material && !a.object.progressive_debug_color) {
|
|
985
984
|
a.object.progressive_debug_color = !0;
|
|
986
985
|
const d = Math.random() * 16777215, p = new Ve({ color: d });
|
|
987
986
|
a.object.material = p;
|
|
988
987
|
}
|
|
989
988
|
const u = a.object;
|
|
990
|
-
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u,
|
|
989
|
+
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
991
990
|
}
|
|
992
991
|
const i = s.transparent;
|
|
993
992
|
for (const a of i) {
|
|
994
993
|
const u = a.object;
|
|
995
|
-
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u,
|
|
994
|
+
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
996
995
|
}
|
|
997
996
|
const l = s.transmissive;
|
|
998
997
|
for (const a of l) {
|
|
999
998
|
const u = a.object;
|
|
1000
|
-
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u,
|
|
999
|
+
(u instanceof q || u.isMesh) && this.updateLODs(t, e, u, r);
|
|
1001
1000
|
}
|
|
1002
1001
|
}
|
|
1003
1002
|
/** Update the LOD levels for the renderer. */
|
|
1004
|
-
updateLODs(t, e, s,
|
|
1003
|
+
updateLODs(t, e, s, n) {
|
|
1005
1004
|
s.userData || (s.userData = {});
|
|
1006
|
-
let
|
|
1007
|
-
if (
|
|
1005
|
+
let r = s[fe];
|
|
1006
|
+
if (r || (r = new mt(), s[fe] = r), r.frames++ < 2)
|
|
1008
1007
|
return;
|
|
1009
1008
|
for (const l of W)
|
|
1010
1009
|
l.onBeforeUpdateLOD?.(this.renderer, t, e, s);
|
|
1011
1010
|
const i = this.overrideLodLevel !== void 0 ? this.overrideLodLevel : N;
|
|
1012
|
-
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);
|
|
1013
1012
|
for (const l of W)
|
|
1014
1013
|
l.onAfterUpdatedLOD?.(this.renderer, t, e, s, P);
|
|
1015
|
-
|
|
1014
|
+
r.lastLodLevel_Mesh = P.mesh_lod, r.lastLodLevel_Texture = P.texture_lod;
|
|
1016
1015
|
}
|
|
1017
1016
|
/** Load progressive textures for the given material
|
|
1018
1017
|
* @param material the material to load the textures for
|
|
@@ -1023,17 +1022,17 @@ let ie = class b {
|
|
|
1023
1022
|
if (!t)
|
|
1024
1023
|
return;
|
|
1025
1024
|
if (Array.isArray(t)) {
|
|
1026
|
-
for (const
|
|
1027
|
-
this.loadProgressiveTextures(
|
|
1025
|
+
for (const r of t)
|
|
1026
|
+
this.loadProgressiveTextures(r, e);
|
|
1028
1027
|
return;
|
|
1029
1028
|
}
|
|
1030
|
-
let
|
|
1031
|
-
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) {
|
|
1032
1031
|
t[U] = e;
|
|
1033
|
-
const
|
|
1032
|
+
const r = y.assignTextureLOD(t, e).then((i) => {
|
|
1034
1033
|
this._lodchangedlisteners.forEach((l) => l({ type: "texture", level: e, object: t }));
|
|
1035
1034
|
});
|
|
1036
|
-
de.addPromise("texture", t,
|
|
1035
|
+
de.addPromise("texture", t, r, this._newPromiseGroups);
|
|
1037
1036
|
}
|
|
1038
1037
|
}
|
|
1039
1038
|
/** Load progressive meshes for the given mesh
|
|
@@ -1046,10 +1045,10 @@ let ie = class b {
|
|
|
1046
1045
|
if (!t)
|
|
1047
1046
|
return Promise.resolve(null);
|
|
1048
1047
|
let s = t[U] !== e;
|
|
1049
|
-
const
|
|
1050
|
-
if (
|
|
1048
|
+
const n = t["DEBUG:LOD"];
|
|
1049
|
+
if (n != null && (s = t[U] != n, e = n), s) {
|
|
1051
1050
|
t[U] = e;
|
|
1052
|
-
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));
|
|
1053
1052
|
return de.addPromise("mesh", t, i, this._newPromiseGroups), i;
|
|
1054
1053
|
}
|
|
1055
1054
|
return Promise.resolve(null);
|
|
@@ -1068,27 +1067,27 @@ let ie = class b {
|
|
|
1068
1067
|
static corner3 = new A();
|
|
1069
1068
|
static _tempPtInside = new A();
|
|
1070
1069
|
static isInside(t, e) {
|
|
1071
|
-
const s = t.min,
|
|
1072
|
-
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;
|
|
1073
1072
|
}
|
|
1074
1073
|
static skinnedMeshBoundsFrameOffsetCounter = 0;
|
|
1075
1074
|
static $skinnedMeshBoundsOffset = Symbol("gltf-progressive-skinnedMeshBoundsOffset");
|
|
1076
1075
|
// #region calculateLodLevel
|
|
1077
|
-
calculateLodLevel(t, e, s,
|
|
1076
|
+
calculateLodLevel(t, e, s, n, r) {
|
|
1078
1077
|
if (!e) {
|
|
1079
|
-
|
|
1078
|
+
r.mesh_lod = -1, r.texture_lod = -1;
|
|
1080
1079
|
return;
|
|
1081
1080
|
}
|
|
1082
1081
|
if (!t) {
|
|
1083
|
-
|
|
1082
|
+
r.mesh_lod = -1, r.texture_lod = -1;
|
|
1084
1083
|
return;
|
|
1085
1084
|
}
|
|
1086
1085
|
let l = 10 + 1, a = !1;
|
|
1087
|
-
if (
|
|
1086
|
+
if (C && e["DEBUG:LOD"] != null)
|
|
1088
1087
|
return e["DEBUG:LOD"];
|
|
1089
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;
|
|
1090
1089
|
if (!p && !_) {
|
|
1091
|
-
|
|
1090
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1092
1091
|
return;
|
|
1093
1092
|
}
|
|
1094
1093
|
p || (a = !0, l = 0);
|
|
@@ -1117,12 +1116,12 @@ let ie = class b {
|
|
|
1117
1116
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
1118
1117
|
const f = t.getWorldPosition(this._tempWorldPosition);
|
|
1119
1118
|
if (this._sphere.containsPoint(f)) {
|
|
1120
|
-
|
|
1119
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1121
1120
|
return;
|
|
1122
1121
|
}
|
|
1123
1122
|
}
|
|
1124
1123
|
if (this._tempBox.copy(G), this._tempBox.applyMatrix4(e.matrixWorld), c.isPerspectiveCamera && b.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
1125
|
-
|
|
1124
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
1126
1125
|
return;
|
|
1127
1126
|
}
|
|
1128
1127
|
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && c.isPerspectiveCamera && c.fov > 70) {
|
|
@@ -1139,7 +1138,7 @@ let ie = class b {
|
|
|
1139
1138
|
const O = t.matrixWorldInverse, B = this._tempBox2;
|
|
1140
1139
|
B.copy(G), B.applyMatrix4(e.matrixWorld), B.applyMatrix4(O);
|
|
1141
1140
|
const M = B.getSize(this._tempBox2Size), z = Math.max(M.x, M.y);
|
|
1142
|
-
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) {
|
|
1143
1142
|
const f = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
1144
1143
|
f.invert();
|
|
1145
1144
|
const h = b.corner0, D = b.corner1, v = b.corner2, $ = b.corner3;
|
|
@@ -1151,23 +1150,23 @@ let ie = class b {
|
|
|
1151
1150
|
if (u && s.lastScreenCoverage > 0)
|
|
1152
1151
|
for (let f = 0; f < u.length; f++) {
|
|
1153
1152
|
const h = u[f], v = (h.densities?.[d] || h.density || 1e-5) / s.lastScreenCoverage;
|
|
1154
|
-
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) {
|
|
1155
1154
|
w = f;
|
|
1156
1155
|
break;
|
|
1157
1156
|
}
|
|
1158
1157
|
}
|
|
1159
1158
|
w < l && (l = w, a = !0);
|
|
1160
1159
|
}
|
|
1161
|
-
if (a ?
|
|
1162
|
-
const x = u?.[
|
|
1163
|
-
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}`);
|
|
1164
1163
|
}
|
|
1165
1164
|
if (_) {
|
|
1166
1165
|
const c = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
1167
1166
|
if (s.lastLodLevel_Texture < 0) {
|
|
1168
|
-
if (
|
|
1167
|
+
if (r.texture_lod = L.max_count - 1, C) {
|
|
1169
1168
|
const x = L.lods[L.max_count - 1];
|
|
1170
|
-
|
|
1169
|
+
C && console.log(`First Texture LOD ${r.texture_lod} (${x.max_height}px) - ${e.name}`);
|
|
1171
1170
|
}
|
|
1172
1171
|
} else {
|
|
1173
1172
|
const x = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
@@ -1177,10 +1176,10 @@ let ie = class b {
|
|
|
1177
1176
|
let z = !1;
|
|
1178
1177
|
for (let S = L.lods.length - 1; S >= 0; S--) {
|
|
1179
1178
|
const w = L.lods[S];
|
|
1180
|
-
if (!(c && w.max_height >= 2048) && !(
|
|
1181
|
-
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) {
|
|
1182
1181
|
const m = w.max_height;
|
|
1183
|
-
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${
|
|
1182
|
+
console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${m}px
|
|
1184
1183
|
Screensize: ${M.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${x.toFixed(1)}
|
|
1185
1184
|
${e.name}`);
|
|
1186
1185
|
}
|
|
@@ -1189,7 +1188,7 @@ ${e.name}`);
|
|
|
1189
1188
|
}
|
|
1190
1189
|
}
|
|
1191
1190
|
} else
|
|
1192
|
-
|
|
1191
|
+
r.texture_lod = 0;
|
|
1193
1192
|
}
|
|
1194
1193
|
};
|
|
1195
1194
|
class mt {
|
|
@@ -1237,12 +1236,12 @@ function Be(o) {
|
|
|
1237
1236
|
ve.add(o), console.debug("[gltf-progressive] found new model-viewer..." + ++xt + `
|
|
1238
1237
|
`, o.getAttribute("src"));
|
|
1239
1238
|
let t = null, e = null, s = null;
|
|
1240
|
-
for (let
|
|
1241
|
-
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)");
|
|
1242
1241
|
!t && i != null && (t = o[i].threeRenderer), !e && l != null && (e = o[l]), !s && a != null && (s = o[a]);
|
|
1243
1242
|
}
|
|
1244
1243
|
if (t && e) {
|
|
1245
|
-
let
|
|
1244
|
+
let r = function() {
|
|
1246
1245
|
if (s) {
|
|
1247
1246
|
let i = 0, l = setInterval(() => {
|
|
1248
1247
|
if (i++ > 5) {
|
|
@@ -1254,23 +1253,23 @@ function Be(o) {
|
|
|
1254
1253
|
}
|
|
1255
1254
|
};
|
|
1256
1255
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
1257
|
-
const
|
|
1258
|
-
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", () => {
|
|
1259
1258
|
s?.call(o);
|
|
1260
1259
|
}), o.addEventListener("model-visibility", (i) => {
|
|
1261
1260
|
i.detail.visible && s?.call(o);
|
|
1262
1261
|
}), o.addEventListener("load", () => {
|
|
1263
|
-
|
|
1262
|
+
r();
|
|
1264
1263
|
}), () => {
|
|
1265
|
-
|
|
1264
|
+
n.disable();
|
|
1266
1265
|
};
|
|
1267
1266
|
}
|
|
1268
1267
|
return null;
|
|
1269
1268
|
}
|
|
1270
1269
|
class wt {
|
|
1271
1270
|
_didWarnAboutMissingUrl = !1;
|
|
1272
|
-
onBeforeUpdateLOD(t, e, s,
|
|
1273
|
-
this.tryParseMeshLOD(e,
|
|
1271
|
+
onBeforeUpdateLOD(t, e, s, n) {
|
|
1272
|
+
this.tryParseMeshLOD(e, n), this.tryParseTextureLOD(e, n);
|
|
1274
1273
|
}
|
|
1275
1274
|
getUrl(t) {
|
|
1276
1275
|
if (!t)
|
|
@@ -1288,8 +1287,8 @@ class wt {
|
|
|
1288
1287
|
if (e[se] == !0)
|
|
1289
1288
|
return;
|
|
1290
1289
|
e[se] = !0;
|
|
1291
|
-
const s = this.tryGetCurrentGLTF(t),
|
|
1292
|
-
if (
|
|
1290
|
+
const s = this.tryGetCurrentGLTF(t), n = this.tryGetCurrentModelViewer(t), r = this.getUrl(n);
|
|
1291
|
+
if (r && s && e.material) {
|
|
1293
1292
|
let l = function(a) {
|
|
1294
1293
|
if (a[se] == !0)
|
|
1295
1294
|
return;
|
|
@@ -1308,7 +1307,7 @@ class wt {
|
|
|
1308
1307
|
}
|
|
1309
1308
|
if (I?.extensions?.[F]) {
|
|
1310
1309
|
const G = I.extensions[F];
|
|
1311
|
-
G &&
|
|
1310
|
+
G && r && y.registerTexture(r, L, G.lods.length, _, G);
|
|
1312
1311
|
}
|
|
1313
1312
|
}
|
|
1314
1313
|
}
|
|
@@ -1325,40 +1324,40 @@ class wt {
|
|
|
1325
1324
|
if (e[De] == !0)
|
|
1326
1325
|
return;
|
|
1327
1326
|
e[De] = !0;
|
|
1328
|
-
const s = this.tryGetCurrentModelViewer(t),
|
|
1329
|
-
if (!
|
|
1327
|
+
const s = this.tryGetCurrentModelViewer(t), n = this.getUrl(s);
|
|
1328
|
+
if (!n)
|
|
1330
1329
|
return;
|
|
1331
|
-
const
|
|
1332
|
-
if (
|
|
1330
|
+
const r = e.userData?.gltfExtensions?.[F];
|
|
1331
|
+
if (r && n) {
|
|
1333
1332
|
const i = e.uuid;
|
|
1334
|
-
y.registerMesh(
|
|
1333
|
+
y.registerMesh(n, i, e, 0, r.lods.length, r);
|
|
1335
1334
|
}
|
|
1336
1335
|
}
|
|
1337
1336
|
}
|
|
1338
1337
|
function Lt(...o) {
|
|
1339
|
-
let t, e, s,
|
|
1338
|
+
let t, e, s, n;
|
|
1340
1339
|
switch (o.length) {
|
|
1341
1340
|
case 2:
|
|
1342
|
-
[s, e] = o,
|
|
1341
|
+
[s, e] = o, n = {};
|
|
1343
1342
|
break;
|
|
1344
1343
|
case 3:
|
|
1345
|
-
[s, e,
|
|
1344
|
+
[s, e, n] = o;
|
|
1346
1345
|
break;
|
|
1347
1346
|
case 4:
|
|
1348
|
-
[t, e, s,
|
|
1347
|
+
[t, e, s, n] = o;
|
|
1349
1348
|
break;
|
|
1350
1349
|
default:
|
|
1351
1350
|
throw new Error("Invalid arguments");
|
|
1352
1351
|
}
|
|
1353
1352
|
we(e), Te(s), Ie(s, {
|
|
1354
1353
|
progressive: !0,
|
|
1355
|
-
...
|
|
1354
|
+
...n?.hints
|
|
1356
1355
|
}), s.register((i) => new y(i));
|
|
1357
|
-
const
|
|
1358
|
-
return
|
|
1356
|
+
const r = ie.get(e);
|
|
1357
|
+
return n?.enableLODsManager !== !1 && r.enable(), r;
|
|
1359
1358
|
}
|
|
1360
1359
|
Re();
|
|
1361
|
-
if (!
|
|
1360
|
+
if (!nt) {
|
|
1362
1361
|
const o = {
|
|
1363
1362
|
gltfProgressive: {
|
|
1364
1363
|
useNeedleProgressive: Lt,
|