@needle-tools/gltf-progressive 3.0.0-alpha.1 → 3.0.0-alpha.3
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/gltf-progressive.js +290 -276
- package/gltf-progressive.min.js +7 -7
- package/gltf-progressive.umd.cjs +7 -7
- package/lib/lods.manager.d.ts +1 -1
- package/lib/lods.manager.js +3 -3
- package/lib/{lods.loading.d.ts → lods.promise.d.ts} +13 -2
- package/lib/{lods.loading.js → lods.promise.js} +24 -5
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/gltf-progressive.js
CHANGED
|
@@ -9,7 +9,7 @@ var p = (n, t, e) => (Ee(n, t, "read from private field"), e ? e.call(n) : t.get
|
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(n) : t.set(n, e);
|
|
11
11
|
}, V = (n, t, e, s) => (Ee(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e);
|
|
12
|
-
import { BufferGeometry as
|
|
12
|
+
import { BufferGeometry as xe, Mesh as se, Texture as ne, TextureLoader as je, Matrix4 as Ge, Clock as Je, MeshStandardMaterial as Qe, Sphere as Ze, Box3 as Ie, Vector3 as K } from "three";
|
|
13
13
|
import { GLTFLoader as Ce } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
14
14
|
import { MeshoptDecoder as et } from "three/examples/jsm/libs/meshopt_decoder.module.js";
|
|
15
15
|
import { DRACOLoader as tt } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
@@ -31,35 +31,35 @@ fetch($e, {
|
|
|
31
31
|
Fe();
|
|
32
32
|
});
|
|
33
33
|
function nt(n) {
|
|
34
|
-
W = n, B && B[
|
|
34
|
+
W = n, B && B[Pe] != W ? (console.debug("Updating Draco decoder path to " + n), B[Pe] = W, B.setDecoderPath(W), B.preload()) : console.debug("Setting Draco decoder path to " + n);
|
|
35
35
|
}
|
|
36
36
|
function at(n) {
|
|
37
37
|
re = n, U && U.transcoderPath != re ? (console.debug("Updating KTX2 transcoder path to " + n), U.setTranscoderPath(re), U.init()) : console.debug("Setting KTX2 transcoder path to " + n);
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
let B,
|
|
39
|
+
const Pe = Symbol("dracoDecoderPath");
|
|
40
|
+
let B, Le, U;
|
|
41
41
|
function Fe() {
|
|
42
|
-
B || (B = new tt(), B[
|
|
42
|
+
B || (B = new tt(), B[Pe] = W, B.setDecoderPath(W), B.setDecoderConfig({ type: "js" }), B.preload()), U || (U = new st(), U.setTranscoderPath(re), U.init()), Le || (Le = et);
|
|
43
43
|
}
|
|
44
44
|
function Ue(n) {
|
|
45
|
-
return Fe(), n ? U.detectSupport(n) : n !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: B, ktx2Loader: U, meshoptDecoder:
|
|
45
|
+
return Fe(), n ? U.detectSupport(n) : n !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: B, ktx2Loader: U, meshoptDecoder: Le };
|
|
46
46
|
}
|
|
47
47
|
function Ne(n) {
|
|
48
|
-
n.dracoLoader || n.setDRACOLoader(B), n.ktx2Loader || n.setKTX2Loader(U), n.meshoptDecoder || n.setMeshoptDecoder(
|
|
48
|
+
n.dracoLoader || n.setDRACOLoader(B), n.ktx2Loader || n.setKTX2Loader(U), n.meshoptDecoder || n.setMeshoptDecoder(Le);
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const Te = /* @__PURE__ */ new WeakMap();
|
|
51
51
|
function ze(n, t) {
|
|
52
|
-
let e =
|
|
53
|
-
e ? e = Object.assign(e, t) : e = t,
|
|
52
|
+
let e = Te.get(n);
|
|
53
|
+
e ? e = Object.assign(e, t) : e = t, Te.set(n, e);
|
|
54
54
|
}
|
|
55
55
|
const Me = Ce.prototype.load;
|
|
56
56
|
function lt(...n) {
|
|
57
|
-
const t =
|
|
57
|
+
const t = Te.get(this);
|
|
58
58
|
let e = n[0];
|
|
59
59
|
const s = new URL(e, window.location.href);
|
|
60
60
|
if (s.hostname.endsWith("needle.tools")) {
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const r = (t == null ? void 0 : t.progressive) !== void 0 ? t.progressive : !0, i = t != null && t.usecase ? t.usecase : "default";
|
|
62
|
+
r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${i}` : this.requestHeader.Accept = `*/*;usecase=${i}`, e = s.toString();
|
|
63
63
|
}
|
|
64
64
|
return n[0] = e, Me == null ? void 0 : Me.call(this, ...n);
|
|
65
65
|
}
|
|
@@ -95,7 +95,7 @@ function ct() {
|
|
|
95
95
|
}
|
|
96
96
|
const ft = typeof window > "u" && typeof document > "u", Ae = Symbol("needle:raycast-mesh");
|
|
97
97
|
function ce(n) {
|
|
98
|
-
return (n == null ? void 0 : n[Ae]) instanceof
|
|
98
|
+
return (n == null ? void 0 : n[Ae]) instanceof xe ? n[Ae] : null;
|
|
99
99
|
}
|
|
100
100
|
function ht(n, t) {
|
|
101
101
|
if ((n.type === "Mesh" || n.type === "SkinnedMesh") && !ce(n)) {
|
|
@@ -109,9 +109,9 @@ function gt(n = !0) {
|
|
|
109
109
|
return;
|
|
110
110
|
const t = le = se.prototype.raycast;
|
|
111
111
|
se.prototype.raycast = function(e, s) {
|
|
112
|
-
const o = this,
|
|
113
|
-
let
|
|
114
|
-
|
|
112
|
+
const o = this, r = ce(o);
|
|
113
|
+
let i;
|
|
114
|
+
r && o.isMesh && (i = o.geometry, o.geometry = r), t.call(this, e, s), i && (o.geometry = i);
|
|
115
115
|
};
|
|
116
116
|
} else {
|
|
117
117
|
if (!le)
|
|
@@ -121,14 +121,14 @@ function gt(n = !0) {
|
|
|
121
121
|
}
|
|
122
122
|
let le = null;
|
|
123
123
|
function pt(n) {
|
|
124
|
-
const t = new
|
|
124
|
+
const t = new xe();
|
|
125
125
|
for (const e in n.attributes)
|
|
126
126
|
t.setAttribute(e, n.getAttribute(e));
|
|
127
127
|
return t.setIndex(n.getIndex()), t;
|
|
128
128
|
}
|
|
129
|
-
const Z = new Array(),
|
|
129
|
+
const Z = new Array(), y = ue("debugprogressive");
|
|
130
130
|
let me, te = -1;
|
|
131
|
-
if (
|
|
131
|
+
if (y) {
|
|
132
132
|
let n = function() {
|
|
133
133
|
te += 1, te >= t && (te = -1), console.log(`Toggle LOD level [${te}]`);
|
|
134
134
|
}, t = 6;
|
|
@@ -139,7 +139,7 @@ if (L) {
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
function Ve(n) {
|
|
142
|
-
if (
|
|
142
|
+
if (y)
|
|
143
143
|
if (Array.isArray(n))
|
|
144
144
|
for (const t of n)
|
|
145
145
|
Ve(t);
|
|
@@ -156,12 +156,12 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
156
156
|
if (this._isLoadingMesh)
|
|
157
157
|
return null;
|
|
158
158
|
const e = (o = (s = this.parser.json.meshes[t]) == null ? void 0 : s.extensions) == null ? void 0 : o[Y];
|
|
159
|
-
return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((
|
|
160
|
-
var
|
|
161
|
-
return this._isLoadingMesh = !1,
|
|
159
|
+
return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((r) => {
|
|
160
|
+
var i;
|
|
161
|
+
return this._isLoadingMesh = !1, r && b.registerMesh(this.url, e.guid, r, (i = e.lods) == null ? void 0 : i.length, 0, e), r;
|
|
162
162
|
})) : null;
|
|
163
163
|
});
|
|
164
|
-
|
|
164
|
+
y && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
|
|
165
165
|
}
|
|
166
166
|
/** The name of the extension */
|
|
167
167
|
get name() {
|
|
@@ -177,9 +177,9 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
177
177
|
return e ?? -1;
|
|
178
178
|
}
|
|
179
179
|
static getMaterialMinMaxLODsCount(t, e) {
|
|
180
|
-
const s = this, o = "LODS:minmax",
|
|
181
|
-
if (
|
|
182
|
-
return
|
|
180
|
+
const s = this, o = "LODS:minmax", r = t[o];
|
|
181
|
+
if (r != null)
|
|
182
|
+
return r;
|
|
183
183
|
if (e || (e = {
|
|
184
184
|
min_count: 1 / 0,
|
|
185
185
|
max_count: 0,
|
|
@@ -189,19 +189,19 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
189
189
|
this.getMaterialMinMaxLODsCount(a, e);
|
|
190
190
|
return t[o] = e, e;
|
|
191
191
|
}
|
|
192
|
-
if (
|
|
192
|
+
if (y === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
|
|
193
193
|
const a = t;
|
|
194
194
|
for (const l of Object.keys(a.uniforms)) {
|
|
195
195
|
const c = a.uniforms[l].value;
|
|
196
|
-
(c == null ? void 0 : c.isTexture) === !0 &&
|
|
196
|
+
(c == null ? void 0 : c.isTexture) === !0 && i(c, e);
|
|
197
197
|
}
|
|
198
198
|
} else if (t.isMaterial)
|
|
199
199
|
for (const a of Object.keys(t)) {
|
|
200
200
|
const l = t[a];
|
|
201
|
-
(l == null ? void 0 : l.isTexture) === !0 &&
|
|
201
|
+
(l == null ? void 0 : l.isTexture) === !0 && i(l, e);
|
|
202
202
|
}
|
|
203
203
|
return t[o] = e, e;
|
|
204
|
-
function
|
|
204
|
+
function i(a, l) {
|
|
205
205
|
const c = s.getAssignedLODInformation(a);
|
|
206
206
|
if (c) {
|
|
207
207
|
const u = s.lodInfos.get(c.key);
|
|
@@ -221,29 +221,29 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
221
221
|
* @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
|
|
222
222
|
*/
|
|
223
223
|
static hasLODLevelAvailable(t, e) {
|
|
224
|
-
var
|
|
224
|
+
var r;
|
|
225
225
|
if (Array.isArray(t)) {
|
|
226
|
-
for (const
|
|
227
|
-
if (this.hasLODLevelAvailable(
|
|
226
|
+
for (const i of t)
|
|
227
|
+
if (this.hasLODLevelAvailable(i, e))
|
|
228
228
|
return !0;
|
|
229
229
|
return !1;
|
|
230
230
|
}
|
|
231
231
|
if (t.isMaterial === !0) {
|
|
232
|
-
for (const
|
|
233
|
-
const a = t[
|
|
232
|
+
for (const i of Object.keys(t)) {
|
|
233
|
+
const a = t[i];
|
|
234
234
|
if (a && a.isTexture && this.hasLODLevelAvailable(a, e))
|
|
235
235
|
return !0;
|
|
236
236
|
}
|
|
237
237
|
return !1;
|
|
238
238
|
} else if (t.isGroup === !0) {
|
|
239
|
-
for (const
|
|
240
|
-
if (
|
|
239
|
+
for (const i of t.children)
|
|
240
|
+
if (i.isMesh === !0 && this.hasLODLevelAvailable(i, e))
|
|
241
241
|
return !0;
|
|
242
242
|
}
|
|
243
243
|
let s, o;
|
|
244
|
-
if (t.isMesh ? s = t.geometry : (t.isBufferGeometry || t.isTexture) && (s = t), s && (
|
|
245
|
-
const
|
|
246
|
-
if (o = this.lodInfos.get(
|
|
244
|
+
if (t.isMesh ? s = t.geometry : (t.isBufferGeometry || t.isTexture) && (s = t), s && (r = s == null ? void 0 : s.userData) != null && r.LODS) {
|
|
245
|
+
const i = s.userData.LODS;
|
|
246
|
+
if (o = this.lodInfos.get(i.key), e === void 0)
|
|
247
247
|
return o != null;
|
|
248
248
|
if (o)
|
|
249
249
|
return Array.isArray(o.lods) ? e < o.lods.length : e === 0;
|
|
@@ -269,20 +269,20 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
269
269
|
if (!t)
|
|
270
270
|
return Promise.resolve(null);
|
|
271
271
|
if (t instanceof se || t.isMesh === !0) {
|
|
272
|
-
const o = t.geometry,
|
|
273
|
-
if (!
|
|
272
|
+
const o = t.geometry, r = this.getAssignedLODInformation(o);
|
|
273
|
+
if (!r)
|
|
274
274
|
return Promise.resolve(null);
|
|
275
|
-
for (const
|
|
276
|
-
(s =
|
|
277
|
-
return t["LOD:requested level"] = e, b.getOrLoadLOD(o, e).then((
|
|
278
|
-
if (Array.isArray(
|
|
279
|
-
const a =
|
|
280
|
-
|
|
275
|
+
for (const i of Z)
|
|
276
|
+
(s = i.onBeforeGetLODMesh) == null || s.call(i, t, e);
|
|
277
|
+
return t["LOD:requested level"] = e, b.getOrLoadLOD(o, e).then((i) => {
|
|
278
|
+
if (Array.isArray(i)) {
|
|
279
|
+
const a = r.index || 0;
|
|
280
|
+
i = i[a];
|
|
281
281
|
}
|
|
282
|
-
return t["LOD:requested level"] === e && (delete t["LOD:requested level"],
|
|
283
|
-
}).catch((
|
|
282
|
+
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], i && o != i && ((i == null ? void 0 : i.isBufferGeometry) ? t.geometry = i : y && console.error("Invalid LOD geometry", i))), i;
|
|
283
|
+
}).catch((i) => (console.error("Error loading mesh LOD", t, i), null));
|
|
284
284
|
} else
|
|
285
|
-
|
|
285
|
+
y && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
286
286
|
return Promise.resolve(null);
|
|
287
287
|
}
|
|
288
288
|
static assignTextureLOD(t, e = 0) {
|
|
@@ -292,42 +292,42 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
292
292
|
const s = t;
|
|
293
293
|
if (Array.isArray(s.material)) {
|
|
294
294
|
const o = new Array();
|
|
295
|
-
for (const
|
|
296
|
-
const
|
|
297
|
-
o.push(
|
|
295
|
+
for (const r of s.material) {
|
|
296
|
+
const i = this.assignTextureLOD(r, e);
|
|
297
|
+
o.push(i);
|
|
298
298
|
}
|
|
299
|
-
return Promise.all(o).then((
|
|
300
|
-
const
|
|
301
|
-
for (const a of
|
|
302
|
-
Array.isArray(a) &&
|
|
303
|
-
return
|
|
299
|
+
return Promise.all(o).then((r) => {
|
|
300
|
+
const i = new Array();
|
|
301
|
+
for (const a of r)
|
|
302
|
+
Array.isArray(a) && i.push(...a);
|
|
303
|
+
return i;
|
|
304
304
|
});
|
|
305
305
|
} else
|
|
306
306
|
return this.assignTextureLOD(s.material, e);
|
|
307
307
|
}
|
|
308
308
|
if (t.isMaterial === !0) {
|
|
309
|
-
const s = t, o = [],
|
|
309
|
+
const s = t, o = [], r = new Array();
|
|
310
310
|
if (s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
311
|
-
const
|
|
312
|
-
for (const a of Object.keys(
|
|
313
|
-
const l =
|
|
311
|
+
const i = s;
|
|
312
|
+
for (const a of Object.keys(i.uniforms)) {
|
|
313
|
+
const l = i.uniforms[a].value;
|
|
314
314
|
if ((l == null ? void 0 : l.isTexture) === !0) {
|
|
315
|
-
const c = this.assignTextureLODForSlot(l, e, s, a).then((u) => (u &&
|
|
316
|
-
o.push(c),
|
|
315
|
+
const c = this.assignTextureLODForSlot(l, e, s, a).then((u) => (u && i.uniforms[a].value != u && (i.uniforms[a].value = u, i.uniformsNeedUpdate = !0), u));
|
|
316
|
+
o.push(c), r.push(a);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
} else
|
|
320
|
-
for (const
|
|
321
|
-
const a = s[
|
|
320
|
+
for (const i of Object.keys(s)) {
|
|
321
|
+
const a = s[i];
|
|
322
322
|
if ((a == null ? void 0 : a.isTexture) === !0) {
|
|
323
|
-
const l = this.assignTextureLODForSlot(a, e, s,
|
|
324
|
-
o.push(l),
|
|
323
|
+
const l = this.assignTextureLODForSlot(a, e, s, i);
|
|
324
|
+
o.push(l), r.push(i);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
return Promise.all(o).then((
|
|
327
|
+
return Promise.all(o).then((i) => {
|
|
328
328
|
const a = new Array();
|
|
329
|
-
for (let l = 0; l <
|
|
330
|
-
const c =
|
|
329
|
+
for (let l = 0; l < i.length; l++) {
|
|
330
|
+
const c = i[l], u = r[l];
|
|
331
331
|
c && c.isTexture === !0 ? a.push({ material: s, slot: u, texture: c, level: e }) : a.push({ material: s, slot: u, texture: null, level: e });
|
|
332
332
|
}
|
|
333
333
|
return a;
|
|
@@ -340,56 +340,56 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
340
340
|
return Promise.resolve(null);
|
|
341
341
|
}
|
|
342
342
|
static assignTextureLODForSlot(t, e, s, o) {
|
|
343
|
-
return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : o === "glyphMap" ? Promise.resolve(t) : b.getOrLoadLOD(t, e).then((
|
|
344
|
-
if (Array.isArray(
|
|
343
|
+
return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : o === "glyphMap" ? Promise.resolve(t) : b.getOrLoadLOD(t, e).then((r) => {
|
|
344
|
+
if (Array.isArray(r))
|
|
345
345
|
return null;
|
|
346
|
-
if ((
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
if (
|
|
350
|
-
const a = this.getAssignedLODInformation(
|
|
346
|
+
if ((r == null ? void 0 : r.isTexture) === !0) {
|
|
347
|
+
if (r != t && s && o) {
|
|
348
|
+
const i = s[o];
|
|
349
|
+
if (i && !y) {
|
|
350
|
+
const a = this.getAssignedLODInformation(i);
|
|
351
351
|
if (a && (a == null ? void 0 : a.level) < e)
|
|
352
|
-
return
|
|
352
|
+
return y === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, e, s, i, r), null;
|
|
353
353
|
}
|
|
354
|
-
s[o] =
|
|
354
|
+
s[o] = r;
|
|
355
355
|
}
|
|
356
|
-
return
|
|
356
|
+
return r;
|
|
357
357
|
} else
|
|
358
|
-
|
|
358
|
+
y == "verbose" && console.warn("No LOD found for", t, e);
|
|
359
359
|
return null;
|
|
360
|
-
}).catch((
|
|
360
|
+
}).catch((r) => (console.error("Error loading LOD", t, r), null));
|
|
361
361
|
}
|
|
362
362
|
afterRoot(t) {
|
|
363
363
|
var e, s;
|
|
364
|
-
return
|
|
365
|
-
var
|
|
364
|
+
return y && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((o, r) => {
|
|
365
|
+
var i;
|
|
366
366
|
if (o != null && o.extensions) {
|
|
367
367
|
const a = o == null ? void 0 : o.extensions[Y];
|
|
368
368
|
if (a) {
|
|
369
369
|
if (!a.lods) {
|
|
370
|
-
|
|
370
|
+
y && console.warn("Texture has no LODs", a);
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
373
|
let l = !1;
|
|
374
374
|
for (const c of this.parser.associations.keys())
|
|
375
375
|
if (c.isTexture === !0) {
|
|
376
376
|
const u = this.parser.associations.get(c);
|
|
377
|
-
(u == null ? void 0 : u.textures) ===
|
|
377
|
+
(u == null ? void 0 : u.textures) === r && (l = !0, b.registerTexture(this.url, c, (i = a.lods) == null ? void 0 : i.length, r, a));
|
|
378
378
|
}
|
|
379
|
-
l || this.parser.getDependency("texture",
|
|
379
|
+
l || this.parser.getDependency("texture", r).then((c) => {
|
|
380
380
|
var u;
|
|
381
|
-
c && b.registerTexture(this.url, c, (u = a.lods) == null ? void 0 : u.length,
|
|
381
|
+
c && b.registerTexture(this.url, c, (u = a.lods) == null ? void 0 : u.length, r, a);
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
}), (s = this.parser.json.meshes) == null || s.forEach((o,
|
|
385
|
+
}), (s = this.parser.json.meshes) == null || s.forEach((o, r) => {
|
|
386
386
|
if (o != null && o.extensions) {
|
|
387
|
-
const
|
|
388
|
-
if (
|
|
387
|
+
const i = o == null ? void 0 : o.extensions[Y];
|
|
388
|
+
if (i && i.lods) {
|
|
389
389
|
for (const a of this.parser.associations.keys())
|
|
390
390
|
if (a.isMesh) {
|
|
391
391
|
const l = this.parser.associations.get(a);
|
|
392
|
-
(l == null ? void 0 : l.meshes) ===
|
|
392
|
+
(l == null ? void 0 : l.meshes) === r && b.registerMesh(this.url, i.guid, a, i.lods.length, l.primitives, i);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
}
|
|
@@ -397,43 +397,43 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
397
397
|
}
|
|
398
398
|
static async getOrLoadLOD(t, e) {
|
|
399
399
|
var a, l, c, u;
|
|
400
|
-
const s =
|
|
400
|
+
const s = y == "verbose", o = t.userData.LODS;
|
|
401
401
|
if (!o)
|
|
402
402
|
return null;
|
|
403
|
-
const
|
|
404
|
-
let
|
|
403
|
+
const r = o == null ? void 0 : o.key;
|
|
404
|
+
let i;
|
|
405
405
|
if (t.isTexture === !0) {
|
|
406
406
|
const h = t;
|
|
407
|
-
h.source && h.source[Oe] && (
|
|
407
|
+
h.source && h.source[Oe] && (i = h.source[Oe]);
|
|
408
408
|
}
|
|
409
|
-
if (
|
|
409
|
+
if (i || (i = b.lodInfos.get(r)), i) {
|
|
410
410
|
if (e > 0) {
|
|
411
|
-
let
|
|
412
|
-
const M = Array.isArray(
|
|
413
|
-
if (M && e >=
|
|
414
|
-
return this.lowresCache.get(
|
|
411
|
+
let _ = !1;
|
|
412
|
+
const M = Array.isArray(i.lods);
|
|
413
|
+
if (M && e >= i.lods.length ? _ = !0 : M || (_ = !0), _)
|
|
414
|
+
return this.lowresCache.get(r);
|
|
415
415
|
}
|
|
416
|
-
const h = Array.isArray(
|
|
416
|
+
const h = Array.isArray(i.lods) ? (a = i.lods[e]) == null ? void 0 : a.path : i.lods;
|
|
417
417
|
if (!h)
|
|
418
|
-
return
|
|
418
|
+
return y && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
|
|
419
419
|
const g = dt(o.url, h);
|
|
420
420
|
if (g.endsWith(".glb") || g.endsWith(".gltf")) {
|
|
421
|
-
if (!
|
|
422
|
-
return console.warn("missing pointer for glb/gltf texture",
|
|
423
|
-
const
|
|
421
|
+
if (!i.guid)
|
|
422
|
+
return console.warn("missing pointer for glb/gltf texture", i), null;
|
|
423
|
+
const _ = g + "_" + i.guid, M = this.previouslyLoaded.get(_);
|
|
424
424
|
if (M !== void 0) {
|
|
425
|
-
s && console.log(`LOD ${e} was already loading/loaded: ${
|
|
426
|
-
let
|
|
425
|
+
s && console.log(`LOD ${e} was already loading/loaded: ${_}`);
|
|
426
|
+
let w = await M.catch((m) => (console.error(`Error loading LOD ${e} from ${g}
|
|
427
427
|
`, m), null)), D = !1;
|
|
428
|
-
if (
|
|
429
|
-
return
|
|
428
|
+
if (w == null || (w instanceof ne && t instanceof ne ? (l = w.image) != null && l.data || (c = w.source) != null && c.data ? w = this.copySettings(t, w) : (D = !0, this.previouslyLoaded.delete(_)) : w instanceof xe && t instanceof xe && ((u = w.attributes.position) != null && u.array || (D = !0, this.previouslyLoaded.delete(_)))), !D)
|
|
429
|
+
return w;
|
|
430
430
|
}
|
|
431
|
-
const
|
|
431
|
+
const L = i, N = new Promise(async (w, D) => {
|
|
432
432
|
const m = new Ce();
|
|
433
|
-
Ne(m),
|
|
433
|
+
Ne(m), y && (await new Promise((O) => setTimeout(O, 1e3)), s && console.warn("Start loading (delayed) " + g, L.guid));
|
|
434
434
|
let q = g;
|
|
435
|
-
if (
|
|
436
|
-
const O =
|
|
435
|
+
if (L && Array.isArray(L.lods)) {
|
|
436
|
+
const O = L.lods[e];
|
|
437
437
|
O.hash && (q += "?v=" + O.hash);
|
|
438
438
|
}
|
|
439
439
|
const A = await m.loadAsync(q).catch((O) => (console.error(`Error loading LOD ${e} from ${g}
|
|
@@ -441,14 +441,14 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
441
441
|
if (!A)
|
|
442
442
|
return null;
|
|
443
443
|
const k = A.parser;
|
|
444
|
-
s && console.log("Loading finished " + g,
|
|
444
|
+
s && console.log("Loading finished " + g, L.guid);
|
|
445
445
|
let R = 0;
|
|
446
446
|
if (A.parser.json.textures) {
|
|
447
447
|
let O = !1;
|
|
448
448
|
for (const f of A.parser.json.textures) {
|
|
449
449
|
if (f != null && f.extensions) {
|
|
450
450
|
const S = f == null ? void 0 : f.extensions[Y];
|
|
451
|
-
if (S != null && S.guid && S.guid ===
|
|
451
|
+
if (S != null && S.guid && S.guid === L.guid) {
|
|
452
452
|
O = !0;
|
|
453
453
|
break;
|
|
454
454
|
}
|
|
@@ -457,16 +457,16 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
457
457
|
}
|
|
458
458
|
if (O) {
|
|
459
459
|
let f = await k.getDependency("texture", R);
|
|
460
|
-
return f && b.assignLODInformation(o.url, f,
|
|
460
|
+
return f && b.assignLODInformation(o.url, f, r, e, void 0), s && console.log('change "' + t.name + '" → "' + f.name + '"', g, R, f, _), t instanceof ne && (f = this.copySettings(t, f)), f && (f.guid = L.guid), w(f);
|
|
461
461
|
} else
|
|
462
|
-
|
|
462
|
+
y && console.warn("Could not find texture with guid", L.guid, A.parser.json);
|
|
463
463
|
}
|
|
464
464
|
if (R = 0, A.parser.json.meshes) {
|
|
465
465
|
let O = !1;
|
|
466
466
|
for (const f of A.parser.json.meshes) {
|
|
467
467
|
if (f != null && f.extensions) {
|
|
468
468
|
const S = f == null ? void 0 : f.extensions[Y];
|
|
469
|
-
if (S != null && S.guid && S.guid ===
|
|
469
|
+
if (S != null && S.guid && S.guid === L.guid) {
|
|
470
470
|
O = !0;
|
|
471
471
|
break;
|
|
472
472
|
}
|
|
@@ -475,41 +475,41 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
475
475
|
}
|
|
476
476
|
if (O) {
|
|
477
477
|
const f = await k.getDependency("mesh", R);
|
|
478
|
-
if (s && console.log(`Loaded Mesh "${f.name}"`, g, R, f,
|
|
478
|
+
if (s && console.log(`Loaded Mesh "${f.name}"`, g, R, f, _), f.isMesh === !0) {
|
|
479
479
|
const S = f.geometry;
|
|
480
|
-
return b.assignLODInformation(o.url, S,
|
|
480
|
+
return b.assignLODInformation(o.url, S, r, e, 0), w(S);
|
|
481
481
|
} else {
|
|
482
482
|
const S = new Array();
|
|
483
|
-
for (let
|
|
484
|
-
const v = f.children[
|
|
483
|
+
for (let x = 0; x < f.children.length; x++) {
|
|
484
|
+
const v = f.children[x];
|
|
485
485
|
if (v.isMesh === !0) {
|
|
486
486
|
const C = v.geometry;
|
|
487
|
-
b.assignLODInformation(o.url, C,
|
|
487
|
+
b.assignLODInformation(o.url, C, r, e, x), S.push(C);
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
|
-
return
|
|
490
|
+
return w(S);
|
|
491
491
|
}
|
|
492
492
|
} else
|
|
493
|
-
|
|
493
|
+
y && console.warn("Could not find mesh with guid", L.guid, A.parser.json);
|
|
494
494
|
}
|
|
495
|
-
return
|
|
495
|
+
return w(null);
|
|
496
496
|
});
|
|
497
|
-
return this.previouslyLoaded.set(
|
|
497
|
+
return this.previouslyLoaded.set(_, N), await N;
|
|
498
498
|
} else if (t instanceof ne) {
|
|
499
499
|
s && console.log("Load texture from uri: " + g);
|
|
500
500
|
const M = await new je().loadAsync(g);
|
|
501
|
-
return M ? (M.guid =
|
|
501
|
+
return M ? (M.guid = i.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = t.colorSpace, s && console.log(i, M)) : y && console.warn("failed loading", g), M;
|
|
502
502
|
}
|
|
503
503
|
} else
|
|
504
|
-
|
|
504
|
+
y && console.warn(`Can not load LOD ${e}: no LOD info found for "${r}" ${t.name}`, t.type);
|
|
505
505
|
return null;
|
|
506
506
|
}
|
|
507
|
-
static assignLODInformation(t, e, s, o,
|
|
507
|
+
static assignLODInformation(t, e, s, o, r) {
|
|
508
508
|
if (!e)
|
|
509
509
|
return;
|
|
510
510
|
e.userData || (e.userData = {});
|
|
511
|
-
const
|
|
512
|
-
e.userData.LODS =
|
|
511
|
+
const i = new mt(t, s, o, r);
|
|
512
|
+
e.userData.LODS = i;
|
|
513
513
|
}
|
|
514
514
|
static getAssignedLODInformation(t) {
|
|
515
515
|
var e;
|
|
@@ -517,42 +517,42 @@ const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = c
|
|
|
517
517
|
}
|
|
518
518
|
// private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
|
|
519
519
|
static copySettings(t, e) {
|
|
520
|
-
return e ? (
|
|
520
|
+
return e ? (y && console.warn(`Copy texture settings
|
|
521
521
|
`, t.uuid, `
|
|
522
522
|
`, e.uuid), e = e.clone(), e.offset = t.offset, e.repeat = t.repeat, e.colorSpace = t.colorSpace, e.magFilter = t.magFilter, e.minFilter = t.minFilter, e.wrapS = t.wrapS, e.wrapT = t.wrapT, e.flipY = t.flipY, e.anisotropy = t.anisotropy, e.mipmaps || (e.generateMipmaps = t.generateMipmaps), e) : t;
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
|
-
let
|
|
525
|
+
let T = b;
|
|
526
526
|
/**
|
|
527
527
|
* Register a texture with LOD information
|
|
528
528
|
*/
|
|
529
|
-
d(
|
|
530
|
-
if (
|
|
531
|
-
|
|
529
|
+
d(T, "registerTexture", (t, e, s, o, r) => {
|
|
530
|
+
if (y && console.log("> Progressive: register texture", o, e.name, e.uuid, e, r), !e) {
|
|
531
|
+
y && console.error("gltf-progressive: Register texture without texture");
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
|
-
e.source && (e.source[Oe] =
|
|
535
|
-
const
|
|
536
|
-
b.assignLODInformation(t, e,
|
|
534
|
+
e.source && (e.source[Oe] = r);
|
|
535
|
+
const i = r.guid;
|
|
536
|
+
b.assignLODInformation(t, e, i, s, o), b.lodInfos.set(i, r), b.lowresCache.set(i, e);
|
|
537
537
|
}), /**
|
|
538
538
|
* Register a mesh with LOD information
|
|
539
539
|
*/
|
|
540
|
-
d(
|
|
540
|
+
d(T, "registerMesh", (t, e, s, o, r, i) => {
|
|
541
541
|
var c;
|
|
542
542
|
const a = s.geometry;
|
|
543
543
|
if (!a) {
|
|
544
|
-
|
|
544
|
+
y && console.warn("gltf-progressive: Register mesh without geometry");
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
a.userData || (a.userData = {}),
|
|
547
|
+
a.userData || (a.userData = {}), y && console.log("> Progressive: register mesh " + s.name, { index: r, uuid: s.uuid }, i, s), b.assignLODInformation(t, a, e, o, r), b.lodInfos.set(e, i);
|
|
548
548
|
let l = b.lowresCache.get(e);
|
|
549
549
|
l ? l.push(s.geometry) : l = [s.geometry], b.lowresCache.set(e, l), o > 0 && !ce(s) && ht(s, a);
|
|
550
550
|
for (const u of Z)
|
|
551
|
-
(c = u.onRegisteredNewMesh) == null || c.call(u, s,
|
|
551
|
+
(c = u.onRegisteredNewMesh) == null || c.call(u, s, i);
|
|
552
552
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
553
|
-
d(
|
|
554
|
-
d(
|
|
555
|
-
d(
|
|
553
|
+
d(T, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
|
|
554
|
+
d(T, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
|
|
555
|
+
d(T, "lowresCache", /* @__PURE__ */ new Map());
|
|
556
556
|
class mt {
|
|
557
557
|
constructor(t, e, s, o) {
|
|
558
558
|
d(this, "url");
|
|
@@ -576,16 +576,18 @@ class ye {
|
|
|
576
576
|
d(this, "_resolvedCount", 0);
|
|
577
577
|
/** These promises are currently being awaited */
|
|
578
578
|
d(this, "_awaiting", []);
|
|
579
|
+
d(this, "_maxPromisesPerObject", 1);
|
|
579
580
|
d(this, "_currentFrame", 0);
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
581
|
+
d(this, "_seen", /* @__PURE__ */ new WeakMap());
|
|
582
|
+
var r;
|
|
583
|
+
const o = Math.max(e.frames ?? 2, 2);
|
|
584
|
+
this.frame_start = t, this.frame_capture_end = t + o, this.ready = new Promise((i) => {
|
|
585
|
+
this._resolve = i;
|
|
584
586
|
}), this.ready.finally(() => {
|
|
585
587
|
this._resolved = !0, this._awaiting.length = 0;
|
|
586
|
-
}), this._signal = e.signal, (
|
|
588
|
+
}), this._signal = e.signal, (r = this._signal) == null || r.addEventListener("abort", () => {
|
|
587
589
|
this.resolveNow();
|
|
588
|
-
});
|
|
590
|
+
}), this._maxPromisesPerObject = Math.max(1, e.maxPromisesPerObject ?? 1);
|
|
589
591
|
}
|
|
590
592
|
/**
|
|
591
593
|
* The number of promises that have been added to this group so far.
|
|
@@ -603,14 +605,26 @@ class ye {
|
|
|
603
605
|
var e;
|
|
604
606
|
this._currentFrame = t, ((e = this._signal) != null && e.aborted || this._currentFrame > this.frame_capture_end && this._awaiting.length === 0) && this.resolveNow();
|
|
605
607
|
}
|
|
606
|
-
add(t, e) {
|
|
608
|
+
add(t, e, s) {
|
|
607
609
|
if (this._resolved) {
|
|
608
|
-
console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
|
|
610
|
+
y && console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
|
|
609
611
|
return;
|
|
610
612
|
}
|
|
611
|
-
this._currentFrame > this.frame_capture_end
|
|
612
|
-
|
|
613
|
-
|
|
613
|
+
if (!(this._currentFrame > this.frame_capture_end)) {
|
|
614
|
+
if (this._maxPromisesPerObject >= 1)
|
|
615
|
+
if (this._seen.has(e)) {
|
|
616
|
+
let o = this._seen.get(e);
|
|
617
|
+
if (o >= this._maxPromisesPerObject) {
|
|
618
|
+
y && console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
this._seen.set(e, o + 1);
|
|
622
|
+
} else
|
|
623
|
+
this._seen.set(e, 1);
|
|
624
|
+
this._awaiting.push(s), this._addedCount++, s.finally(() => {
|
|
625
|
+
this._resolvedCount++, this._awaiting.splice(this._awaiting.indexOf(s), 1);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
614
628
|
}
|
|
615
629
|
resolveNow() {
|
|
616
630
|
var t, e;
|
|
@@ -621,14 +635,14 @@ class ye {
|
|
|
621
635
|
});
|
|
622
636
|
}
|
|
623
637
|
}
|
|
624
|
-
d(ye, "addPromise", (t, e, s) => {
|
|
625
|
-
|
|
626
|
-
|
|
638
|
+
d(ye, "addPromise", (t, e, s, o) => {
|
|
639
|
+
o.forEach((r) => {
|
|
640
|
+
r.add(t, e, s);
|
|
627
641
|
});
|
|
628
642
|
});
|
|
629
643
|
const F = ue("debugprogressive"), yt = ue("noprogressive"), be = Symbol("Needle:LODSManager"), Se = Symbol("Needle:LODState"), Q = Symbol("Needle:CurrentLOD"), E = { mesh_lod: -1, texture_lod: -1 };
|
|
630
|
-
var G, H,
|
|
631
|
-
const
|
|
644
|
+
var G, H, _e, ee, ie, we, j;
|
|
645
|
+
const P = class {
|
|
632
646
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
633
647
|
constructor(t, e) {
|
|
634
648
|
d(this, "renderer");
|
|
@@ -666,10 +680,10 @@ const T = class {
|
|
|
666
680
|
d(this, "_promiseGroupIds", 0);
|
|
667
681
|
d(this, "_lodchangedlisteners", []);
|
|
668
682
|
J(this, H, void 0);
|
|
669
|
-
J(this,
|
|
683
|
+
J(this, _e, new Je());
|
|
670
684
|
J(this, ee, 0);
|
|
671
685
|
J(this, ie, 0);
|
|
672
|
-
J(this,
|
|
686
|
+
J(this, we, 0);
|
|
673
687
|
J(this, j, 0);
|
|
674
688
|
d(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
|
|
675
689
|
// private testIfLODLevelsAreAvailable() {
|
|
@@ -701,7 +715,7 @@ const T = class {
|
|
|
701
715
|
static get(t, e) {
|
|
702
716
|
if (t[be])
|
|
703
717
|
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[be];
|
|
704
|
-
const s = new
|
|
718
|
+
const s = new P(t, {
|
|
705
719
|
engine: "unknown",
|
|
706
720
|
...e
|
|
707
721
|
});
|
|
@@ -719,8 +733,8 @@ const T = class {
|
|
|
719
733
|
this._newPromiseGroups.push(s);
|
|
720
734
|
const o = performance.now();
|
|
721
735
|
return s.ready.finally(() => {
|
|
722
|
-
const
|
|
723
|
-
|
|
736
|
+
const r = this._newPromiseGroups.indexOf(s);
|
|
737
|
+
r >= 0 && (this._newPromiseGroups.splice(r, 1), ct() && performance.measure("LODsManager:awaitLoading", {
|
|
724
738
|
start: o,
|
|
725
739
|
detail: { id: e, name: t == null ? void 0 : t.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
|
|
726
740
|
}));
|
|
@@ -751,10 +765,10 @@ const T = class {
|
|
|
751
765
|
V(this, H, this.renderer.render);
|
|
752
766
|
const e = this;
|
|
753
767
|
Ue(this.renderer), this.renderer.render = function(s, o) {
|
|
754
|
-
const
|
|
755
|
-
(
|
|
756
|
-
const
|
|
757
|
-
p(e, H).call(this, s, o), e.onAfterRender(s, o,
|
|
768
|
+
const r = e.renderer.getRenderTarget();
|
|
769
|
+
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (t = 0, V(e, ee, p(e, ee) + 1), V(e, ie, p(e, _e).getDelta()), V(e, we, p(e, we) + p(e, ie)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / p(e, ie)), V(e, j, e._fpsBuffer.reduce((a, l) => a + l) / e._fpsBuffer.length), F && p(e, ee) % 200 === 0 && console.log("FPS", Math.round(p(e, j)), "Interval:", p(e, G)));
|
|
770
|
+
const i = t++;
|
|
771
|
+
p(e, H).call(this, s, o), e.onAfterRender(s, o, i);
|
|
758
772
|
};
|
|
759
773
|
}
|
|
760
774
|
disable() {
|
|
@@ -766,13 +780,13 @@ const T = class {
|
|
|
766
780
|
onAfterRender(t, e, s) {
|
|
767
781
|
if (this.pause)
|
|
768
782
|
return;
|
|
769
|
-
const
|
|
770
|
-
let
|
|
771
|
-
if (
|
|
772
|
-
const a =
|
|
773
|
-
(a.name === "EffectMaterial" || a.name === "CopyShader") && (
|
|
783
|
+
const r = this.renderer.renderLists.get(t, 0).opaque;
|
|
784
|
+
let i = !0;
|
|
785
|
+
if (r.length === 1) {
|
|
786
|
+
const a = r[0].material;
|
|
787
|
+
(a.name === "EffectMaterial" || a.name === "CopyShader") && (i = !1);
|
|
774
788
|
}
|
|
775
|
-
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (
|
|
789
|
+
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
|
|
776
790
|
if (yt || (this.updateInterval === "auto" ? p(this, j) < 40 && p(this, G) < 10 ? (V(this, G, p(this, G) + 1), F && console.warn("↓ Reducing LOD updates", p(this, G), p(this, j).toFixed(0))) : p(this, j) >= 60 && p(this, G) > 1 && (V(this, G, p(this, G) - 1), F && console.warn("↑ Increasing LOD updates", p(this, G), p(this, j).toFixed(0))) : V(this, G, this.updateInterval), p(this, G) > 0 && p(this, ee) % p(this, G) != 0))
|
|
777
791
|
return;
|
|
778
792
|
this.internalUpdate(t, e), this._postprocessPromiseGroups();
|
|
@@ -785,7 +799,7 @@ const T = class {
|
|
|
785
799
|
var l, c;
|
|
786
800
|
const s = this.renderer.renderLists.get(t, 0), o = s.opaque;
|
|
787
801
|
this.projectionScreenMatrix.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse);
|
|
788
|
-
const
|
|
802
|
+
const r = this.targetTriangleDensity;
|
|
789
803
|
for (const u of o) {
|
|
790
804
|
if (u.material && (((l = u.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((c = u.geometry) == null ? void 0 : c.type) === "BufferGeometry") && (u.material.name === "SphericalGaussianBlur" || u.material.name == "BackgroundCubeMaterial" || u.material.name === "CubemapFromEquirect" || u.material.name === "EquirectangularToCubeUV")) {
|
|
791
805
|
F && (u.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (u.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", u, u.material.name, u.material.type)));
|
|
@@ -802,37 +816,37 @@ const T = class {
|
|
|
802
816
|
}
|
|
803
817
|
if (F === "color" && u.material && !u.object.progressive_debug_color) {
|
|
804
818
|
u.object.progressive_debug_color = !0;
|
|
805
|
-
const g = Math.random() * 16777215,
|
|
806
|
-
u.object.material =
|
|
819
|
+
const g = Math.random() * 16777215, _ = new Qe({ color: g });
|
|
820
|
+
u.object.material = _;
|
|
807
821
|
}
|
|
808
822
|
const h = u.object;
|
|
809
|
-
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h,
|
|
823
|
+
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
|
|
810
824
|
}
|
|
811
|
-
const
|
|
812
|
-
for (const u of
|
|
825
|
+
const i = s.transparent;
|
|
826
|
+
for (const u of i) {
|
|
813
827
|
const h = u.object;
|
|
814
|
-
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h,
|
|
828
|
+
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
|
|
815
829
|
}
|
|
816
830
|
const a = s.transmissive;
|
|
817
831
|
for (const u of a) {
|
|
818
832
|
const h = u.object;
|
|
819
|
-
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h,
|
|
833
|
+
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h, r);
|
|
820
834
|
}
|
|
821
835
|
}
|
|
822
836
|
/** Update the LOD levels for the renderer. */
|
|
823
837
|
updateLODs(t, e, s, o) {
|
|
824
838
|
var a, l;
|
|
825
839
|
s.userData || (s.userData = {});
|
|
826
|
-
let
|
|
827
|
-
if (
|
|
840
|
+
let r = s[Se];
|
|
841
|
+
if (r || (r = new xt(), s[Se] = r), r.frames++ < 2)
|
|
828
842
|
return;
|
|
829
843
|
for (const c of Z)
|
|
830
844
|
(a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, t, e, s);
|
|
831
|
-
const
|
|
832
|
-
|
|
845
|
+
const i = P.overrideGlobalLodLevel !== void 0 ? P.overrideGlobalLodLevel : te;
|
|
846
|
+
i >= 0 ? (E.mesh_lod = i, E.texture_lod = i) : (this.calculateLodLevel(e, s, r, o, E), E.mesh_lod = Math.round(E.mesh_lod), E.texture_lod = Math.round(E.texture_lod)), E.mesh_lod >= 0 && this.loadProgressiveMeshes(s, E.mesh_lod), s.material && E.texture_lod >= 0 && this.loadProgressiveTextures(s.material, E.texture_lod), y && s.material && !s.isGizmo && Ve(s.material);
|
|
833
847
|
for (const c of Z)
|
|
834
848
|
(l = c.onAfterUpdatedLOD) == null || l.call(c, this.renderer, t, e, s, E);
|
|
835
|
-
|
|
849
|
+
r.lastLodLevel_Mesh = E.mesh_lod, r.lastLodLevel_Texture = E.texture_lod;
|
|
836
850
|
}
|
|
837
851
|
/** Load progressive textures for the given material
|
|
838
852
|
* @param material the material to load the textures for
|
|
@@ -843,8 +857,8 @@ const T = class {
|
|
|
843
857
|
if (!t)
|
|
844
858
|
return;
|
|
845
859
|
if (Array.isArray(t)) {
|
|
846
|
-
for (const
|
|
847
|
-
this.loadProgressiveTextures(
|
|
860
|
+
for (const r of t)
|
|
861
|
+
this.loadProgressiveTextures(r, e);
|
|
848
862
|
return;
|
|
849
863
|
}
|
|
850
864
|
let s = !1;
|
|
@@ -852,10 +866,10 @@ const T = class {
|
|
|
852
866
|
const o = t["DEBUG:LOD"];
|
|
853
867
|
if (o != null && (s = t[Q] != o, e = o), s) {
|
|
854
868
|
t[Q] = e;
|
|
855
|
-
const
|
|
869
|
+
const r = T.assignTextureLOD(t, e).then((i) => {
|
|
856
870
|
this._lodchangedlisteners.forEach((a) => a({ type: "texture", level: e, object: t }));
|
|
857
871
|
});
|
|
858
|
-
ye.addPromise("texture",
|
|
872
|
+
ye.addPromise("texture", t, r, this._newPromiseGroups);
|
|
859
873
|
}
|
|
860
874
|
}
|
|
861
875
|
/** Load progressive meshes for the given mesh
|
|
@@ -871,36 +885,36 @@ const T = class {
|
|
|
871
885
|
const o = t["DEBUG:LOD"];
|
|
872
886
|
if (o != null && (s = t[Q] != o, e = o), s) {
|
|
873
887
|
t[Q] = e;
|
|
874
|
-
const
|
|
875
|
-
return ye.addPromise("mesh",
|
|
888
|
+
const r = t.geometry, i = T.assignMeshLOD(t, e).then((a) => (a && t[Q] == e && r != t.geometry && this._lodchangedlisteners.forEach((l) => l({ type: "mesh", level: e, object: t })), a));
|
|
889
|
+
return ye.addPromise("mesh", t, i, this._newPromiseGroups), i;
|
|
876
890
|
}
|
|
877
891
|
return Promise.resolve(null);
|
|
878
892
|
}
|
|
879
893
|
static isInside(t, e) {
|
|
880
|
-
const s = t.min, o = t.max,
|
|
881
|
-
return this._tempPtInside.set(
|
|
894
|
+
const s = t.min, o = t.max, r = (s.x + o.x) * 0.5, i = (s.y + o.y) * 0.5;
|
|
895
|
+
return this._tempPtInside.set(r, i, s.z).applyMatrix4(e).z < 0;
|
|
882
896
|
}
|
|
883
|
-
calculateLodLevel(t, e, s, o,
|
|
884
|
-
var N, X,
|
|
897
|
+
calculateLodLevel(t, e, s, o, r) {
|
|
898
|
+
var N, X, w;
|
|
885
899
|
if (!e) {
|
|
886
|
-
|
|
900
|
+
r.mesh_lod = -1, r.texture_lod = -1;
|
|
887
901
|
return;
|
|
888
902
|
}
|
|
889
903
|
if (!t) {
|
|
890
|
-
|
|
904
|
+
r.mesh_lod = -1, r.texture_lod = -1;
|
|
891
905
|
return;
|
|
892
906
|
}
|
|
893
907
|
let a = 10 + 1, l = !1;
|
|
894
908
|
if (F && e["DEBUG:LOD"] != null)
|
|
895
909
|
return e["DEBUG:LOD"];
|
|
896
|
-
const c = (N =
|
|
897
|
-
if (!h && !
|
|
898
|
-
|
|
910
|
+
const c = (N = T.getMeshLODExtension(e.geometry)) == null ? void 0 : N.lods, u = T.getPrimitiveIndex(e.geometry), h = c && c.length > 0, g = T.getMaterialMinMaxLODsCount(e.material), _ = (g == null ? void 0 : g.min_count) != 1 / 0 && g.min_count > 0 && g.max_count > 0;
|
|
911
|
+
if (!h && !_) {
|
|
912
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
899
913
|
return;
|
|
900
914
|
}
|
|
901
915
|
h || (l = !0, a = 0);
|
|
902
916
|
const M = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
903
|
-
let
|
|
917
|
+
let L = e.geometry.boundingBox;
|
|
904
918
|
if (e.type === "SkinnedMesh") {
|
|
905
919
|
const D = e;
|
|
906
920
|
if (!D.boundingBox)
|
|
@@ -909,78 +923,78 @@ const T = class {
|
|
|
909
923
|
const m = ce(D), q = D.geometry;
|
|
910
924
|
m && (D.geometry = m), D.computeBoundingBox(), D.geometry = q;
|
|
911
925
|
}
|
|
912
|
-
|
|
926
|
+
L = D.boundingBox;
|
|
913
927
|
}
|
|
914
|
-
if (
|
|
928
|
+
if (L) {
|
|
915
929
|
const D = t;
|
|
916
930
|
if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
|
|
917
931
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
918
|
-
const
|
|
919
|
-
if (this._sphere.containsPoint(
|
|
920
|
-
|
|
932
|
+
const x = t.getWorldPosition(this._tempWorldPosition);
|
|
933
|
+
if (this._sphere.containsPoint(x)) {
|
|
934
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
921
935
|
return;
|
|
922
936
|
}
|
|
923
937
|
}
|
|
924
|
-
if (this._tempBox.copy(
|
|
925
|
-
|
|
938
|
+
if (this._tempBox.copy(L), this._tempBox.applyMatrix4(e.matrixWorld), D.isPerspectiveCamera && P.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
939
|
+
r.mesh_lod = 0, r.texture_lod = 0;
|
|
926
940
|
return;
|
|
927
941
|
}
|
|
928
942
|
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && D.isPerspectiveCamera && D.fov > 70) {
|
|
929
|
-
const
|
|
930
|
-
let C =
|
|
931
|
-
const fe = 2, ve = 1.5, he = (
|
|
943
|
+
const x = this._tempBox.min, v = this._tempBox.max;
|
|
944
|
+
let C = x.x, $ = x.y, z = v.x, oe = v.y;
|
|
945
|
+
const fe = 2, ve = 1.5, he = (x.x + v.x) * 0.5, ge = (x.y + v.y) * 0.5;
|
|
932
946
|
C = (C - he) * fe + he, $ = ($ - ge) * fe + ge, z = (z - he) * fe + he, oe = (oe - ge) * fe + ge;
|
|
933
|
-
const qe = C < 0 && z > 0 ? 0 : Math.min(Math.abs(
|
|
947
|
+
const qe = C < 0 && z > 0 ? 0 : Math.min(Math.abs(x.x), Math.abs(v.x)), Ke = $ < 0 && oe > 0 ? 0 : Math.min(Math.abs(x.y), Math.abs(v.y)), De = Math.max(qe, Ke);
|
|
934
948
|
s.lastCentrality = (ve - De) * (ve - De) * (ve - De);
|
|
935
949
|
} else
|
|
936
950
|
s.lastCentrality = 1;
|
|
937
951
|
const m = this._tempBox.getSize(this._tempBoxSize);
|
|
938
952
|
m.multiplyScalar(0.5), screen.availHeight > 0 && M > 0 && m.multiplyScalar(M / screen.availHeight), t.isPerspectiveCamera ? m.x *= t.aspect : t.isOrthographicCamera;
|
|
939
953
|
const q = t.matrixWorldInverse, A = this._tempBox2;
|
|
940
|
-
A.copy(
|
|
954
|
+
A.copy(L), A.applyMatrix4(e.matrixWorld), A.applyMatrix4(q);
|
|
941
955
|
const k = A.getSize(this._tempBox2Size), R = Math.max(k.x, k.y);
|
|
942
|
-
if (Math.max(m.x, m.y) != 0 && R != 0 && (m.z = k.z / Math.max(k.x, k.y) * Math.max(m.x, m.y)), s.lastScreenCoverage = Math.max(m.x, m.y, m.z), s.lastScreenspaceVolume.copy(m), s.lastScreenCoverage *= s.lastCentrality, F &&
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
const v =
|
|
956
|
+
if (Math.max(m.x, m.y) != 0 && R != 0 && (m.z = k.z / Math.max(k.x, k.y) * Math.max(m.x, m.y)), s.lastScreenCoverage = Math.max(m.x, m.y, m.z), s.lastScreenspaceVolume.copy(m), s.lastScreenCoverage *= s.lastCentrality, F && P.debugDrawLine) {
|
|
957
|
+
const x = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
958
|
+
x.invert();
|
|
959
|
+
const v = P.corner0, C = P.corner1, $ = P.corner2, z = P.corner3;
|
|
946
960
|
v.copy(this._tempBox.min), C.copy(this._tempBox.max), C.x = v.x, $.copy(this._tempBox.max), $.y = v.y, z.copy(this._tempBox.max);
|
|
947
961
|
const oe = (v.z + z.z) * 0.5;
|
|
948
|
-
v.z = C.z = $.z = z.z = oe, v.applyMatrix4(
|
|
962
|
+
v.z = C.z = $.z = z.z = oe, v.applyMatrix4(x), C.applyMatrix4(x), $.applyMatrix4(x), z.applyMatrix4(x), P.debugDrawLine(v, C, 255), P.debugDrawLine(v, $, 255), P.debugDrawLine(C, z, 255), P.debugDrawLine($, z, 255);
|
|
949
963
|
}
|
|
950
964
|
let f = 999;
|
|
951
965
|
if (c && s.lastScreenCoverage > 0)
|
|
952
|
-
for (let
|
|
953
|
-
const v = c[
|
|
966
|
+
for (let x = 0; x < c.length; x++) {
|
|
967
|
+
const v = c[x];
|
|
954
968
|
if ((((X = v.densities) == null ? void 0 : X[u]) || v.density || 1e-5) / s.lastScreenCoverage < o) {
|
|
955
|
-
f =
|
|
969
|
+
f = x;
|
|
956
970
|
break;
|
|
957
971
|
}
|
|
958
972
|
}
|
|
959
973
|
f < a && (a = f, l = !0);
|
|
960
974
|
}
|
|
961
|
-
if (l ?
|
|
962
|
-
const m = c == null ? void 0 : c[
|
|
963
|
-
m && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${
|
|
975
|
+
if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, F && r.mesh_lod != s.lastLodLevel_Mesh) {
|
|
976
|
+
const m = c == null ? void 0 : c[r.mesh_lod];
|
|
977
|
+
m && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${m.density.toFixed(0)}) - ${e.name}`);
|
|
964
978
|
}
|
|
965
|
-
if (
|
|
979
|
+
if (_) {
|
|
966
980
|
const D = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
967
981
|
if (s.lastLodLevel_Texture < 0) {
|
|
968
|
-
if (
|
|
982
|
+
if (r.texture_lod = g.max_count - 1, F) {
|
|
969
983
|
const m = g.lods[g.max_count - 1];
|
|
970
|
-
F && console.log(`First Texture LOD ${
|
|
984
|
+
F && console.log(`First Texture LOD ${r.texture_lod} (${m.max_height}px) - ${e.name}`);
|
|
971
985
|
}
|
|
972
986
|
} else {
|
|
973
987
|
const m = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
974
988
|
let q = s.lastScreenCoverage * 4;
|
|
975
|
-
((
|
|
989
|
+
((w = this.context) == null ? void 0 : w.engine) === "model-viewer" && (q *= 1.5);
|
|
976
990
|
const k = M / window.devicePixelRatio * q;
|
|
977
991
|
let R = !1;
|
|
978
992
|
for (let O = g.lods.length - 1; O >= 0; O--) {
|
|
979
993
|
const f = g.lods[O];
|
|
980
994
|
if (!(D && f.max_height >= 2048) && !(ut() && f.max_height > 4096) && (f.max_height > k || !R && O === 0)) {
|
|
981
|
-
if (R = !0,
|
|
995
|
+
if (R = !0, r.texture_lod = O, r.texture_lod < s.lastLodLevel_Texture) {
|
|
982
996
|
const S = f.max_height;
|
|
983
|
-
F && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${
|
|
997
|
+
F && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${S}px
|
|
984
998
|
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${m.toFixed(1)}
|
|
985
999
|
${e.name}`);
|
|
986
1000
|
}
|
|
@@ -989,18 +1003,18 @@ ${e.name}`);
|
|
|
989
1003
|
}
|
|
990
1004
|
}
|
|
991
1005
|
} else
|
|
992
|
-
|
|
1006
|
+
r.texture_lod = 0;
|
|
993
1007
|
}
|
|
994
1008
|
};
|
|
995
|
-
let I =
|
|
996
|
-
G = new WeakMap(), H = new WeakMap(),
|
|
1009
|
+
let I = P;
|
|
1010
|
+
G = new WeakMap(), H = new WeakMap(), _e = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), we = new WeakMap(), j = new WeakMap(), /**
|
|
997
1011
|
* 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.
|
|
998
1012
|
*/
|
|
999
1013
|
d(I, "debugDrawLine"), /**
|
|
1000
1014
|
* Force override the LOD level for all objects in the scene
|
|
1001
1015
|
*/
|
|
1002
1016
|
d(I, "overrideGlobalLodLevel"), d(I, "corner0", new K()), d(I, "corner1", new K()), d(I, "corner2", new K()), d(I, "corner3", new K()), d(I, "_tempPtInside", new K());
|
|
1003
|
-
class
|
|
1017
|
+
class xt {
|
|
1004
1018
|
constructor() {
|
|
1005
1019
|
d(this, "frames", 0);
|
|
1006
1020
|
d(this, "lastLodLevel_Mesh", -1);
|
|
@@ -1013,7 +1027,7 @@ class Lt {
|
|
|
1013
1027
|
const Be = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
|
|
1014
1028
|
let de = null;
|
|
1015
1029
|
function We() {
|
|
1016
|
-
const n =
|
|
1030
|
+
const n = Lt();
|
|
1017
1031
|
n && (n.mapURLs(function(t) {
|
|
1018
1032
|
return Re(), t;
|
|
1019
1033
|
}), Re(), de == null || de.disconnect(), de = new MutationObserver((t) => {
|
|
@@ -1024,7 +1038,7 @@ function We() {
|
|
|
1024
1038
|
});
|
|
1025
1039
|
}), de.observe(document, { childList: !0, subtree: !0 }));
|
|
1026
1040
|
}
|
|
1027
|
-
function
|
|
1041
|
+
function Lt() {
|
|
1028
1042
|
if (typeof customElements > "u")
|
|
1029
1043
|
return null;
|
|
1030
1044
|
const n = customElements.get("model-viewer");
|
|
@@ -1040,22 +1054,22 @@ function Re() {
|
|
|
1040
1054
|
});
|
|
1041
1055
|
}
|
|
1042
1056
|
const ke = /* @__PURE__ */ new WeakSet();
|
|
1043
|
-
let
|
|
1057
|
+
let _t = 0;
|
|
1044
1058
|
function Xe(n) {
|
|
1045
1059
|
if (!n || ke.has(n))
|
|
1046
1060
|
return null;
|
|
1047
|
-
ke.add(n), console.debug("[gltf-progressive] found new model-viewer..." + ++
|
|
1061
|
+
ke.add(n), console.debug("[gltf-progressive] found new model-viewer..." + ++_t + `
|
|
1048
1062
|
`, n.getAttribute("src"));
|
|
1049
1063
|
let t = null, e = null, s = null;
|
|
1050
1064
|
for (let o = n; o != null; o = Object.getPrototypeOf(o)) {
|
|
1051
|
-
const
|
|
1052
|
-
!t &&
|
|
1065
|
+
const r = Object.getOwnPropertySymbols(o), i = r.find((c) => c.toString() == "Symbol(renderer)"), a = r.find((c) => c.toString() == "Symbol(scene)"), l = r.find((c) => c.toString() == "Symbol(needsRender)");
|
|
1066
|
+
!t && i != null && (t = n[i].threeRenderer), !e && a != null && (e = n[a]), !s && l != null && (s = n[l]);
|
|
1053
1067
|
}
|
|
1054
1068
|
if (t && e) {
|
|
1055
1069
|
let o = function() {
|
|
1056
1070
|
if (s) {
|
|
1057
|
-
let
|
|
1058
|
-
if (
|
|
1071
|
+
let i = 0, a = setInterval(() => {
|
|
1072
|
+
if (i++ > 5) {
|
|
1059
1073
|
clearInterval(a);
|
|
1060
1074
|
return;
|
|
1061
1075
|
}
|
|
@@ -1064,20 +1078,20 @@ function Xe(n) {
|
|
|
1064
1078
|
}
|
|
1065
1079
|
};
|
|
1066
1080
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
1067
|
-
const
|
|
1068
|
-
return I.addPlugin(new
|
|
1081
|
+
const r = I.get(t, { engine: "model-viewer" });
|
|
1082
|
+
return I.addPlugin(new wt()), r.enable(), r.addEventListener("changed", () => {
|
|
1069
1083
|
s == null || s.call(n);
|
|
1070
|
-
}), n.addEventListener("model-visibility", (
|
|
1071
|
-
|
|
1084
|
+
}), n.addEventListener("model-visibility", (i) => {
|
|
1085
|
+
i.detail.visible && (s == null || s.call(n));
|
|
1072
1086
|
}), n.addEventListener("load", () => {
|
|
1073
1087
|
o();
|
|
1074
1088
|
}), () => {
|
|
1075
|
-
|
|
1089
|
+
r.disable();
|
|
1076
1090
|
};
|
|
1077
1091
|
}
|
|
1078
1092
|
return null;
|
|
1079
1093
|
}
|
|
1080
|
-
class
|
|
1094
|
+
class wt {
|
|
1081
1095
|
constructor() {
|
|
1082
1096
|
d(this, "_didWarnAboutMissingUrl", !1);
|
|
1083
1097
|
}
|
|
@@ -1100,18 +1114,18 @@ class _t {
|
|
|
1100
1114
|
if (e[pe] == !0)
|
|
1101
1115
|
return;
|
|
1102
1116
|
e[pe] = !0;
|
|
1103
|
-
const s = this.tryGetCurrentGLTF(t), o = this.tryGetCurrentModelViewer(t),
|
|
1104
|
-
if (
|
|
1105
|
-
let
|
|
1117
|
+
const s = this.tryGetCurrentGLTF(t), o = this.tryGetCurrentModelViewer(t), r = this.getUrl(o);
|
|
1118
|
+
if (r && s && e.material) {
|
|
1119
|
+
let i = function(l) {
|
|
1106
1120
|
var u, h, g;
|
|
1107
1121
|
if (l[pe] == !0)
|
|
1108
1122
|
return;
|
|
1109
1123
|
l[pe] = !0, l.userData && (l.userData.LOD = -1);
|
|
1110
1124
|
const c = Object.keys(l);
|
|
1111
|
-
for (let
|
|
1112
|
-
const M = c[
|
|
1113
|
-
if ((
|
|
1114
|
-
const N = (h = (u =
|
|
1125
|
+
for (let _ = 0; _ < c.length; _++) {
|
|
1126
|
+
const M = c[_], L = l[M];
|
|
1127
|
+
if ((L == null ? void 0 : L.isTexture) === !0) {
|
|
1128
|
+
const N = (h = (u = L.userData) == null ? void 0 : u.associations) == null ? void 0 : h.textures;
|
|
1115
1129
|
if (N == null)
|
|
1116
1130
|
continue;
|
|
1117
1131
|
const X = s.parser.json.textures[N];
|
|
@@ -1120,8 +1134,8 @@ class _t {
|
|
|
1120
1134
|
continue;
|
|
1121
1135
|
}
|
|
1122
1136
|
if ((g = X == null ? void 0 : X.extensions) != null && g[Y]) {
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1137
|
+
const w = X.extensions[Y];
|
|
1138
|
+
w && r && T.registerTexture(r, L, w.lods.length, N, w);
|
|
1125
1139
|
}
|
|
1126
1140
|
}
|
|
1127
1141
|
}
|
|
@@ -1129,23 +1143,23 @@ class _t {
|
|
|
1129
1143
|
const a = e.material;
|
|
1130
1144
|
if (Array.isArray(a))
|
|
1131
1145
|
for (const l of a)
|
|
1132
|
-
|
|
1146
|
+
i(l);
|
|
1133
1147
|
else
|
|
1134
|
-
|
|
1148
|
+
i(a);
|
|
1135
1149
|
}
|
|
1136
1150
|
}
|
|
1137
1151
|
tryParseMeshLOD(t, e) {
|
|
1138
|
-
var
|
|
1152
|
+
var i, a;
|
|
1139
1153
|
if (e[Be] == !0)
|
|
1140
1154
|
return;
|
|
1141
1155
|
e[Be] = !0;
|
|
1142
1156
|
const s = this.tryGetCurrentModelViewer(t), o = this.getUrl(s);
|
|
1143
1157
|
if (!o)
|
|
1144
1158
|
return;
|
|
1145
|
-
const
|
|
1146
|
-
if (
|
|
1159
|
+
const r = (a = (i = e.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[Y];
|
|
1160
|
+
if (r && o) {
|
|
1147
1161
|
const l = e.uuid;
|
|
1148
|
-
|
|
1162
|
+
T.registerMesh(o, l, e, 0, r.lods.length, r);
|
|
1149
1163
|
}
|
|
1150
1164
|
}
|
|
1151
1165
|
}
|
|
@@ -1153,7 +1167,7 @@ function vt(n, t, e, s) {
|
|
|
1153
1167
|
Ue(t), Ne(e), ze(e, {
|
|
1154
1168
|
progressive: !0,
|
|
1155
1169
|
...s == null ? void 0 : s.hints
|
|
1156
|
-
}), e.register((
|
|
1170
|
+
}), e.register((r) => new T(r, n));
|
|
1157
1171
|
const o = I.get(t);
|
|
1158
1172
|
return (s == null ? void 0 : s.enableLODsManager) !== !1 && o.enable(), o;
|
|
1159
1173
|
}
|
|
@@ -1177,7 +1191,7 @@ if (!ft) {
|
|
|
1177
1191
|
export {
|
|
1178
1192
|
Y as EXTENSION_NAME,
|
|
1179
1193
|
I as LODsManager,
|
|
1180
|
-
|
|
1194
|
+
T as NEEDLE_progressive,
|
|
1181
1195
|
rt as VERSION,
|
|
1182
1196
|
Ne as addDracoAndKTX2Loaders,
|
|
1183
1197
|
ze as configureLoader,
|