@needle-tools/gltf-progressive 1.2.4-beta.1 → 1.2.5
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 +6 -0
- package/README.md +1 -0
- package/dist/CHANGELOG.md +139 -0
- package/dist/README.md +125 -0
- package/dist/examples/modelviewer-multiple.html +125 -0
- package/dist/examples/modelviewer.html +33 -0
- package/dist/examples/react-three-fiber/.prettierrc +10 -0
- package/dist/examples/react-three-fiber/favicon.png +0 -0
- package/dist/examples/react-three-fiber/index.html +24 -0
- package/dist/examples/react-three-fiber/package-lock.json +4023 -0
- package/dist/examples/react-three-fiber/package.json +34 -0
- package/dist/examples/react-three-fiber/tsconfig.json +22 -0
- package/dist/examples/react-three-fiber/vite.config.js +39 -0
- package/dist/examples/threejs/index.html +51 -0
- package/dist/examples/threejs/main.js +181 -0
- package/{gltf-progressive.js → dist/gltf-progressive.js} +166 -154
- package/{gltf-progressive.min.js → dist/gltf-progressive.min.js} +6 -6
- package/{gltf-progressive.umd.cjs → dist/gltf-progressive.umd.cjs} +7 -7
- package/{lib → dist/lib}/lods_manager.d.ts +1 -0
- package/{lib → dist/lib}/lods_manager.js +21 -2
- package/{lib → dist/lib}/version.js +1 -1
- package/dist/package.json +60 -0
- package/examples/modelviewer-multiple.html +1 -1
- package/examples/modelviewer.html +1 -1
- package/package.json +73 -59
- package/tsconfig.json +42 -0
- /package/{lib → dist/lib}/extension.d.ts +0 -0
- /package/{lib → dist/lib}/extension.js +0 -0
- /package/{lib → dist/lib}/index.d.ts +0 -0
- /package/{lib → dist/lib}/index.js +0 -0
- /package/{lib → dist/lib}/loaders.d.ts +0 -0
- /package/{lib → dist/lib}/loaders.js +0 -0
- /package/{lib → dist/lib}/plugins/index.d.ts +0 -0
- /package/{lib → dist/lib}/plugins/index.js +0 -0
- /package/{lib → dist/lib}/plugins/modelviewer.d.ts +0 -0
- /package/{lib → dist/lib}/plugins/modelviewer.js +0 -0
- /package/{lib → dist/lib}/plugins/plugin.d.ts +0 -0
- /package/{lib → dist/lib}/plugins/plugin.js +0 -0
- /package/{lib → dist/lib}/utils.d.ts +0 -0
- /package/{lib → dist/lib}/utils.internal.d.ts +0 -0
- /package/{lib → dist/lib}/utils.internal.js +0 -0
- /package/{lib → dist/lib}/utils.js +0 -0
- /package/{lib → dist/lib}/version.d.ts +0 -0
|
@@ -4,11 +4,11 @@ var f = (a, t, e) => (ze(a, typeof t != "symbol" ? t + "" : t, e), e), Se = (a,
|
|
|
4
4
|
if (!t.has(a))
|
|
5
5
|
throw TypeError("Cannot " + e);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var x = (a, t, e) => (Se(a, t, "read from private field"), e ? e.call(a) : t.get(a)), K = (a, t, e) => {
|
|
8
8
|
if (t.has(a))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(a) : t.set(a, e);
|
|
11
|
-
},
|
|
11
|
+
}, $ = (a, t, e, r) => (Se(a, t, "write to private field"), r ? r.call(a, e) : t.set(a, e), e);
|
|
12
12
|
import { BufferGeometry as he, Mesh as H, Material as Ve, Texture as re, TextureLoader as Ne, Matrix4 as be, Frustum as We, Clock as qe, MeshStandardMaterial as Xe, Sphere as Ke, Box3 as Te, Vector3 as V } from "three";
|
|
13
13
|
import { GLTFLoader as Ye } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
14
14
|
import { MeshoptDecoder as He } from "three/examples/jsm/libs/meshopt_decoder.module.js";
|
|
@@ -17,19 +17,19 @@ import { KTX2Loader as Qe } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
|
17
17
|
const Be = "";
|
|
18
18
|
globalThis.GLTF_PROGRESSIVE_VERSION = Be;
|
|
19
19
|
console.debug(`[gltf-progressive] version ${Be}`);
|
|
20
|
-
let ge = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/",
|
|
20
|
+
let ge = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", _e = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
|
|
21
21
|
fetch(ge + "draco_decoder.js", { method: "head" }).catch((a) => {
|
|
22
|
-
ge = "./include/draco/",
|
|
22
|
+
ge = "./include/draco/", _e = "./include/ktx2/";
|
|
23
23
|
});
|
|
24
24
|
function gt(a) {
|
|
25
25
|
ge = a;
|
|
26
26
|
}
|
|
27
27
|
function pt(a) {
|
|
28
|
-
|
|
28
|
+
_e = a;
|
|
29
29
|
}
|
|
30
30
|
let Q, de, Z;
|
|
31
31
|
function Ie(a) {
|
|
32
|
-
return Q || (Q = new Je(), Q.setDecoderPath(ge), Q.setDecoderConfig({ type: "js" })), Z || (Z = new Qe(), Z.setTranscoderPath(
|
|
32
|
+
return Q || (Q = new Je(), Q.setDecoderPath(ge), Q.setDecoderConfig({ type: "js" })), Z || (Z = new Qe(), Z.setTranscoderPath(_e)), de || (de = He), a ? Z.detectSupport(a) : a !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: Q, ktx2Loader: Z, meshoptDecoder: de };
|
|
33
33
|
}
|
|
34
34
|
function ke(a) {
|
|
35
35
|
a.dracoLoader || a.setDRACOLoader(Q), a.ktx2Loader || a.setKTX2Loader(Z), a.meshoptDecoder || a.setMeshoptDecoder(de);
|
|
@@ -55,14 +55,14 @@ let se;
|
|
|
55
55
|
function je() {
|
|
56
56
|
return se !== void 0 || (se = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), ae("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", se)), se;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
return (a == null ? void 0 : a[
|
|
58
|
+
const ve = Symbol("needle:raycast-mesh");
|
|
59
|
+
function me(a) {
|
|
60
|
+
return (a == null ? void 0 : a[ve]) instanceof he ? a[ve] : null;
|
|
61
61
|
}
|
|
62
62
|
function et(a, t) {
|
|
63
|
-
if ((a.type === "Mesh" || a.type === "SkinnedMesh") && !
|
|
63
|
+
if ((a.type === "Mesh" || a.type === "SkinnedMesh") && !me(a)) {
|
|
64
64
|
const r = tt(t);
|
|
65
|
-
r.userData = { isRaycastMesh: !0 }, a[
|
|
65
|
+
r.userData = { isRaycastMesh: !0 }, a[ve] = r;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
function yt(a = !0) {
|
|
@@ -71,7 +71,7 @@ function yt(a = !0) {
|
|
|
71
71
|
return;
|
|
72
72
|
const t = ie = H.prototype.raycast;
|
|
73
73
|
H.prototype.raycast = function(e, r) {
|
|
74
|
-
const n = this, s =
|
|
74
|
+
const n = this, s = me(n);
|
|
75
75
|
let i;
|
|
76
76
|
s && n.isMesh && (i = n.geometry, n.geometry = s), t.call(this, e, r), i && (n.geometry = i);
|
|
77
77
|
};
|
|
@@ -88,8 +88,8 @@ function tt(a) {
|
|
|
88
88
|
t.setAttribute(e, a.getAttribute(e));
|
|
89
89
|
return t.setIndex(a.getIndex()), t;
|
|
90
90
|
}
|
|
91
|
-
const Y = new Array(), N = "NEEDLE_progressive",
|
|
92
|
-
if (
|
|
91
|
+
const Y = new Array(), N = "NEEDLE_progressive", L = ae("debugprogressive"), Me = Symbol("needle-progressive-texture"), oe = /* @__PURE__ */ new Map(), Oe = /* @__PURE__ */ new Set();
|
|
92
|
+
if (L) {
|
|
93
93
|
let a = function() {
|
|
94
94
|
t += 1, console.log("Toggle LOD level", t, oe), oe.forEach((n, s) => {
|
|
95
95
|
for (const i of n.keys) {
|
|
@@ -107,14 +107,14 @@ if (x) {
|
|
|
107
107
|
}), t >= e && (t = -1);
|
|
108
108
|
}, t = -1, e = 2, r = !1;
|
|
109
109
|
window.addEventListener("keyup", (n) => {
|
|
110
|
-
n.key === "p" && a(), n.key === "w" && (r = !r,
|
|
110
|
+
n.key === "p" && a(), n.key === "w" && (r = !r, Oe && Oe.forEach((s) => {
|
|
111
111
|
s.name != "BackgroundCubeMaterial" && s.glyphMap == null && "wireframe" in s && (s.wireframe = r);
|
|
112
112
|
}));
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
function Ae(a, t, e) {
|
|
116
116
|
var n;
|
|
117
|
-
if (!
|
|
117
|
+
if (!L)
|
|
118
118
|
return;
|
|
119
119
|
oe.has(a) || oe.set(a, { keys: [], sourceId: e });
|
|
120
120
|
const r = oe.get(a);
|
|
@@ -135,7 +135,7 @@ const O = class {
|
|
|
135
135
|
return this._isLoadingMesh = !1, s && O.registerMesh(this.url, e.guid, s, (i = e.lods) == null ? void 0 : i.length, void 0, e), s;
|
|
136
136
|
})) : null;
|
|
137
137
|
});
|
|
138
|
-
|
|
138
|
+
L && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
|
|
139
139
|
}
|
|
140
140
|
/** The name of the extension */
|
|
141
141
|
get name() {
|
|
@@ -158,7 +158,7 @@ const O = class {
|
|
|
158
158
|
this.getMaterialMinMaxLODsCount(o, e);
|
|
159
159
|
return t[n] = e, e;
|
|
160
160
|
}
|
|
161
|
-
if (
|
|
161
|
+
if (L === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
|
|
162
162
|
const o = t;
|
|
163
163
|
for (const l of Object.keys(o.uniforms)) {
|
|
164
164
|
const u = o.uniforms[l].value;
|
|
@@ -249,12 +249,12 @@ const O = class {
|
|
|
249
249
|
const o = s.index || 0;
|
|
250
250
|
i = i[o];
|
|
251
251
|
}
|
|
252
|
-
i && n != i && ((i == null ? void 0 : i.isBufferGeometry) ? (t.geometry = i,
|
|
252
|
+
i && n != i && ((i == null ? void 0 : i.isBufferGeometry) ? (t.geometry = i, L && Ae(t, "geometry", s.url)) : L && console.error("Invalid LOD geometry", i));
|
|
253
253
|
}
|
|
254
254
|
return i;
|
|
255
255
|
}).catch((i) => (console.error("Error loading mesh LOD", t, i), null));
|
|
256
256
|
} else
|
|
257
|
-
|
|
257
|
+
L && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
258
258
|
return Promise.resolve(null);
|
|
259
259
|
}
|
|
260
260
|
/** Load a different resolution of a texture (if available)
|
|
@@ -269,7 +269,7 @@ const O = class {
|
|
|
269
269
|
return Promise.resolve(null);
|
|
270
270
|
if (t instanceof Ve || t.isMaterial === !0) {
|
|
271
271
|
const r = t, n = [], s = new Array();
|
|
272
|
-
if (
|
|
272
|
+
if (L && Oe.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
|
|
273
273
|
const i = r;
|
|
274
274
|
for (const o of Object.keys(i.uniforms)) {
|
|
275
275
|
const l = i.uniforms[o].value;
|
|
@@ -312,30 +312,30 @@ const O = class {
|
|
|
312
312
|
if (i) {
|
|
313
313
|
const o = this.getAssignedLODInformation(i);
|
|
314
314
|
if (o && (o == null ? void 0 : o.level) < e)
|
|
315
|
-
return
|
|
315
|
+
return L === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, e, r, i, s), null;
|
|
316
316
|
}
|
|
317
317
|
r[n] = s;
|
|
318
318
|
}
|
|
319
|
-
if (
|
|
319
|
+
if (L && n && r) {
|
|
320
320
|
const i = this.getAssignedLODInformation(t);
|
|
321
321
|
i && Ae(r, n, i.url);
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
return s;
|
|
325
325
|
} else
|
|
326
|
-
|
|
326
|
+
L == "verbose" && console.warn("No LOD found for", t, e);
|
|
327
327
|
return null;
|
|
328
328
|
}).catch((s) => (console.error("Error loading LOD", t, s), null));
|
|
329
329
|
}
|
|
330
330
|
afterRoot(t) {
|
|
331
331
|
var e, r;
|
|
332
|
-
return
|
|
332
|
+
return L && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((n, s) => {
|
|
333
333
|
var i;
|
|
334
334
|
if (n != null && n.extensions) {
|
|
335
335
|
const o = n == null ? void 0 : n.extensions[N];
|
|
336
336
|
if (o) {
|
|
337
337
|
if (!o.lods) {
|
|
338
|
-
|
|
338
|
+
L && console.warn("Texture has no LODs", o);
|
|
339
339
|
return;
|
|
340
340
|
}
|
|
341
341
|
let l = !1;
|
|
@@ -365,14 +365,14 @@ const O = class {
|
|
|
365
365
|
}
|
|
366
366
|
static async getOrLoadLOD(t, e) {
|
|
367
367
|
var o, l, u, c;
|
|
368
|
-
const r =
|
|
368
|
+
const r = L == "verbose", n = t.userData.LODS;
|
|
369
369
|
if (!n)
|
|
370
370
|
return null;
|
|
371
371
|
const s = n == null ? void 0 : n.key;
|
|
372
372
|
let i;
|
|
373
373
|
if (t.isTexture === !0) {
|
|
374
374
|
const d = t;
|
|
375
|
-
d.source && d.source[
|
|
375
|
+
d.source && d.source[Me] && (i = d.source[Me]);
|
|
376
376
|
}
|
|
377
377
|
if (i || (i = O.lodInfos.get(s)), i) {
|
|
378
378
|
if (e > 0) {
|
|
@@ -383,7 +383,7 @@ const O = class {
|
|
|
383
383
|
}
|
|
384
384
|
const d = Array.isArray(i.lods) ? (o = i.lods[e]) == null ? void 0 : o.path : i.lods;
|
|
385
385
|
if (!d)
|
|
386
|
-
return
|
|
386
|
+
return L && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, i)), null;
|
|
387
387
|
const h = Ze(n.url, d);
|
|
388
388
|
if (h.endsWith(".glb") || h.endsWith(".gltf")) {
|
|
389
389
|
if (!i.guid)
|
|
@@ -391,20 +391,20 @@ const O = class {
|
|
|
391
391
|
const w = h + "_" + i.guid, v = this.previouslyLoaded.get(w);
|
|
392
392
|
if (v !== void 0) {
|
|
393
393
|
r && console.log(`LOD ${e} was already loading/loaded: ${w}`);
|
|
394
|
-
let
|
|
395
|
-
`,
|
|
396
|
-
if (
|
|
397
|
-
return
|
|
394
|
+
let g = await v.catch((I) => (console.error(`Error loading LOD ${e} from ${h}
|
|
395
|
+
`, I), null)), m = !1;
|
|
396
|
+
if (g == null || (g instanceof re && t instanceof re ? (l = g.image) != null && l.data || (u = g.source) != null && u.data ? g = this.copySettings(t, g) : (m = !0, this.previouslyLoaded.delete(w)) : g instanceof he && t instanceof he && ((c = g.attributes.position) != null && c.array || (m = !0, this.previouslyLoaded.delete(w)))), !m)
|
|
397
|
+
return g;
|
|
398
398
|
}
|
|
399
|
-
const M = i,
|
|
400
|
-
const
|
|
401
|
-
ke(
|
|
399
|
+
const M = i, F = new Promise(async (g, m) => {
|
|
400
|
+
const I = new Ye();
|
|
401
|
+
ke(I), L && (await new Promise((_) => setTimeout(_, 1e3)), r && console.warn("Start loading (delayed) " + h, M.guid));
|
|
402
402
|
let X = h;
|
|
403
403
|
if (M && Array.isArray(M.lods)) {
|
|
404
404
|
const _ = M.lods[e];
|
|
405
405
|
_.hash && (X += "?v=" + _.hash);
|
|
406
406
|
}
|
|
407
|
-
const S = await
|
|
407
|
+
const S = await I.loadAsync(X).catch((_) => (console.error(`Error loading LOD ${e} from ${h}
|
|
408
408
|
`, _), null));
|
|
409
409
|
if (!S)
|
|
410
410
|
return null;
|
|
@@ -413,10 +413,10 @@ const O = class {
|
|
|
413
413
|
let A = 0;
|
|
414
414
|
if (S.parser.json.textures) {
|
|
415
415
|
let _ = !1;
|
|
416
|
-
for (const
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
416
|
+
for (const y of S.parser.json.textures) {
|
|
417
|
+
if (y != null && y.extensions) {
|
|
418
|
+
const p = y == null ? void 0 : y.extensions[N];
|
|
419
|
+
if (p != null && p.guid && p.guid === M.guid) {
|
|
420
420
|
_ = !0;
|
|
421
421
|
break;
|
|
422
422
|
}
|
|
@@ -424,17 +424,17 @@ const O = class {
|
|
|
424
424
|
A++;
|
|
425
425
|
}
|
|
426
426
|
if (_) {
|
|
427
|
-
let
|
|
428
|
-
return
|
|
427
|
+
let y = await z.getDependency("texture", A);
|
|
428
|
+
return y && O.assignLODInformation(n.url, y, s, e, void 0, void 0), r && console.log('change "' + t.name + '" → "' + y.name + '"', h, A, y, w), t instanceof re && (y = this.copySettings(t, y)), y && (y.guid = M.guid), g(y);
|
|
429
429
|
} else
|
|
430
|
-
|
|
430
|
+
L && console.warn("Could not find texture with guid", M.guid, S.parser.json);
|
|
431
431
|
}
|
|
432
432
|
if (A = 0, S.parser.json.meshes) {
|
|
433
433
|
let _ = !1;
|
|
434
|
-
for (const
|
|
435
|
-
if (
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
434
|
+
for (const y of S.parser.json.meshes) {
|
|
435
|
+
if (y != null && y.extensions) {
|
|
436
|
+
const p = y == null ? void 0 : y.extensions[N];
|
|
437
|
+
if (p != null && p.guid && p.guid === M.guid) {
|
|
438
438
|
_ = !0;
|
|
439
439
|
break;
|
|
440
440
|
}
|
|
@@ -442,34 +442,34 @@ const O = class {
|
|
|
442
442
|
A++;
|
|
443
443
|
}
|
|
444
444
|
if (_) {
|
|
445
|
-
const
|
|
446
|
-
if (r && console.log(`Loaded Mesh "${
|
|
447
|
-
const D =
|
|
448
|
-
return O.assignLODInformation(n.url, D, s, e, void 0,
|
|
445
|
+
const y = await z.getDependency("mesh", A), p = M;
|
|
446
|
+
if (r && console.log(`Loaded Mesh "${y.name}"`, h, A, y, w), y.isMesh === !0) {
|
|
447
|
+
const D = y.geometry;
|
|
448
|
+
return O.assignLODInformation(n.url, D, s, e, void 0, p.density), g(D);
|
|
449
449
|
} else {
|
|
450
450
|
const D = new Array();
|
|
451
|
-
for (let T = 0; T <
|
|
452
|
-
const
|
|
453
|
-
if (
|
|
454
|
-
const
|
|
455
|
-
O.assignLODInformation(n.url,
|
|
451
|
+
for (let T = 0; T < y.children.length; T++) {
|
|
452
|
+
const E = y.children[T];
|
|
453
|
+
if (E.isMesh === !0) {
|
|
454
|
+
const P = E.geometry;
|
|
455
|
+
O.assignLODInformation(n.url, P, s, e, T, p.density), D.push(P);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
return
|
|
458
|
+
return g(D);
|
|
459
459
|
}
|
|
460
460
|
} else
|
|
461
|
-
|
|
461
|
+
L && console.warn("Could not find mesh with guid", M.guid, S.parser.json);
|
|
462
462
|
}
|
|
463
|
-
return
|
|
463
|
+
return g(null);
|
|
464
464
|
});
|
|
465
|
-
return this.previouslyLoaded.set(w,
|
|
465
|
+
return this.previouslyLoaded.set(w, F), await F;
|
|
466
466
|
} else if (t instanceof re) {
|
|
467
467
|
r && console.log("Load texture from uri: " + h);
|
|
468
468
|
const v = await new Ne().loadAsync(h);
|
|
469
|
-
return v ? (v.guid = i.guid, v.flipY = !1, v.needsUpdate = !0, v.colorSpace = t.colorSpace, r && console.log(i, v)) :
|
|
469
|
+
return v ? (v.guid = i.guid, v.flipY = !1, v.needsUpdate = !0, v.colorSpace = t.colorSpace, r && console.log(i, v)) : L && console.warn("failed loading", h), v;
|
|
470
470
|
}
|
|
471
471
|
} else
|
|
472
|
-
|
|
472
|
+
L && console.warn(`Can not load LOD ${e}: no LOD info found for "${s}" ${t.name}`, t.type);
|
|
473
473
|
return null;
|
|
474
474
|
}
|
|
475
475
|
static assignLODInformation(t, e, r, n, s, i) {
|
|
@@ -485,7 +485,7 @@ const O = class {
|
|
|
485
485
|
}
|
|
486
486
|
// private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
|
|
487
487
|
static copySettings(t, e) {
|
|
488
|
-
return e = e.clone(),
|
|
488
|
+
return e = e.clone(), L && console.warn(`Copying texture settings
|
|
489
489
|
`, t.uuid, `
|
|
490
490
|
`, e.uuid), 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;
|
|
491
491
|
}
|
|
@@ -495,11 +495,11 @@ let b = O;
|
|
|
495
495
|
* Register a texture with LOD information
|
|
496
496
|
*/
|
|
497
497
|
f(b, "registerTexture", (t, e, r, n, s) => {
|
|
498
|
-
if (
|
|
499
|
-
|
|
498
|
+
if (L && console.log("> Progressive: register texture", n, e.name, e.uuid, e, s), !e) {
|
|
499
|
+
L && console.error("gltf-progressive: Register texture without texture");
|
|
500
500
|
return;
|
|
501
501
|
}
|
|
502
|
-
e.source && (e.source[
|
|
502
|
+
e.source && (e.source[Me] = s);
|
|
503
503
|
const i = s.guid;
|
|
504
504
|
O.assignLODInformation(t, e, i, r, n, void 0), O.lodInfos.set(i, s), O.lowresCache.set(i, e);
|
|
505
505
|
}), /**
|
|
@@ -507,15 +507,15 @@ f(b, "registerTexture", (t, e, r, n, s) => {
|
|
|
507
507
|
*/
|
|
508
508
|
f(b, "registerMesh", (t, e, r, n, s, i) => {
|
|
509
509
|
var u;
|
|
510
|
-
|
|
510
|
+
L && console.log("> Progressive: register mesh", s, r.name, i, r.uuid, r);
|
|
511
511
|
const o = r.geometry;
|
|
512
512
|
if (!o) {
|
|
513
|
-
|
|
513
|
+
L && console.warn("gltf-progressive: Register mesh without geometry");
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
516
516
|
o.userData || (o.userData = {}), O.assignLODInformation(t, o, e, n, s, i.density), O.lodInfos.set(e, i);
|
|
517
517
|
let l = O.lowresCache.get(e);
|
|
518
|
-
l ? l.push(r.geometry) : l = [r.geometry], O.lowresCache.set(e, l), n > 0 && !
|
|
518
|
+
l ? l.push(r.geometry) : l = [r.geometry], O.lowresCache.set(e, l), n > 0 && !me(r) && et(r, o);
|
|
519
519
|
for (const c of Y)
|
|
520
520
|
(u = c.onRegisteredNewMesh) == null || u.call(c, r, i);
|
|
521
521
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
@@ -535,7 +535,7 @@ class rt {
|
|
|
535
535
|
this.url = t, this.key = e, this.level = r, n != null && (this.index = n), s != null && (this.density = s);
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
|
-
const
|
|
538
|
+
const k = ae("debugprogressive"), st = ae("noprogressive"), De = Symbol("Needle:LODSManager"), we = Symbol("Needle:LODState"), J = Symbol("Needle:CurrentLOD"), R = { mesh_lod: -1, texture_lod: -1 };
|
|
539
539
|
var B, W, pe, j, ee, ye, q;
|
|
540
540
|
const C = class {
|
|
541
541
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
@@ -586,7 +586,7 @@ const C = class {
|
|
|
586
586
|
}
|
|
587
587
|
/** @internal */
|
|
588
588
|
static getObjectLODState(t) {
|
|
589
|
-
return t[
|
|
589
|
+
return t[we];
|
|
590
590
|
}
|
|
591
591
|
static addPlugin(t) {
|
|
592
592
|
Y.push(t);
|
|
@@ -601,13 +601,13 @@ const C = class {
|
|
|
601
601
|
* @returns The LODsManager instance.
|
|
602
602
|
*/
|
|
603
603
|
static get(t, e) {
|
|
604
|
-
if (t[
|
|
605
|
-
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[
|
|
604
|
+
if (t[De])
|
|
605
|
+
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[De];
|
|
606
606
|
const r = new C(t, {
|
|
607
607
|
engine: "unknown",
|
|
608
608
|
...e
|
|
609
609
|
});
|
|
610
|
-
return t[
|
|
610
|
+
return t[De] = r, r;
|
|
611
611
|
}
|
|
612
612
|
/** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
|
|
613
613
|
get plugins() {
|
|
@@ -616,25 +616,31 @@ const C = class {
|
|
|
616
616
|
addEventListener(t, e) {
|
|
617
617
|
t === "changed" && this._lodchangedlisteners.push(e);
|
|
618
618
|
}
|
|
619
|
+
removeEventListener(t, e) {
|
|
620
|
+
if (t === "changed") {
|
|
621
|
+
const r = this._lodchangedlisteners.indexOf(e);
|
|
622
|
+
r >= 0 && this._lodchangedlisteners.splice(r, 1);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
619
625
|
/**
|
|
620
626
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
621
627
|
*/
|
|
622
628
|
enable() {
|
|
623
|
-
if (
|
|
629
|
+
if (x(this, W))
|
|
624
630
|
return;
|
|
625
631
|
console.debug("[gltf-progressive] Enabling LODsManager for renderer");
|
|
626
632
|
let t = 0;
|
|
627
|
-
|
|
633
|
+
$(this, W, this.renderer.render);
|
|
628
634
|
const e = this;
|
|
629
635
|
Ie(this.renderer), this.renderer.render = function(r, n) {
|
|
630
636
|
const s = e.renderer.getRenderTarget();
|
|
631
|
-
(s == null || "isXRRenderTarget" in s && s.isXRRenderTarget) && (t = 0,
|
|
637
|
+
(s == null || "isXRRenderTarget" in s && s.isXRRenderTarget) && (t = 0, $(e, j, x(e, j) + 1), $(e, ee, x(e, pe).getDelta()), $(e, ye, x(e, ye) + x(e, ee)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / x(e, ee)), $(e, q, e._fpsBuffer.reduce((o, l) => o + l) / e._fpsBuffer.length), k && x(e, j) % 30 === 0 && console.log("FPS", Math.round(x(e, q)), "Interval:", x(e, B)));
|
|
632
638
|
const i = t++;
|
|
633
|
-
|
|
639
|
+
x(e, W).call(this, r, n), e.onAfterRender(r, n, i);
|
|
634
640
|
};
|
|
635
641
|
}
|
|
636
642
|
disable() {
|
|
637
|
-
|
|
643
|
+
x(this, W) && (this.renderer.render = x(this, W), $(this, W, void 0));
|
|
638
644
|
}
|
|
639
645
|
update(t, e) {
|
|
640
646
|
this.internalUpdate(t, e);
|
|
@@ -649,7 +655,7 @@ const C = class {
|
|
|
649
655
|
(o.name === "EffectMaterial" || o.name === "CopyShader") && (i = !1);
|
|
650
656
|
}
|
|
651
657
|
if ((e.parent && e.parent.type === "CubeCamera" || r >= 1 && e.type === "OrthographicCamera") && (i = !1), i) {
|
|
652
|
-
if (st || (this.updateInterval === "auto" ?
|
|
658
|
+
if (st || (this.updateInterval === "auto" ? x(this, q) < 40 && x(this, B) < 10 ? ($(this, B, x(this, B) + 1), k && console.warn("↓ Reducing LOD updates", x(this, B), x(this, q).toFixed(0))) : x(this, q) >= 60 && x(this, B) > 1 && ($(this, B, x(this, B) - 1), k && console.warn("↑ Increasing LOD updates", x(this, B), x(this, q).toFixed(0))) : $(this, B, this.updateInterval), x(this, B) > 0 && x(this, j) % x(this, B) != 0))
|
|
653
659
|
return;
|
|
654
660
|
this.internalUpdate(t, e);
|
|
655
661
|
}
|
|
@@ -664,7 +670,7 @@ const C = class {
|
|
|
664
670
|
const s = this.targetTriangleDensity;
|
|
665
671
|
for (const c of n) {
|
|
666
672
|
if (c.material && (((l = c.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((u = c.geometry) == null ? void 0 : u.type) === "BufferGeometry") && (c.material.name === "SphericalGaussianBlur" || c.material.name == "BackgroundCubeMaterial" || c.material.name === "CubemapFromEquirect" || c.material.name === "EquirectangularToCubeUV")) {
|
|
667
|
-
|
|
673
|
+
k && (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (c.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", c, c.material.name, c.material.type)));
|
|
668
674
|
continue;
|
|
669
675
|
}
|
|
670
676
|
switch (c.material.type) {
|
|
@@ -676,7 +682,7 @@ const C = class {
|
|
|
676
682
|
case "MeshDepthMaterial":
|
|
677
683
|
continue;
|
|
678
684
|
}
|
|
679
|
-
if (
|
|
685
|
+
if (k === "color" && c.material && !c.object.progressive_debug_color) {
|
|
680
686
|
c.object.progressive_debug_color = !0;
|
|
681
687
|
const h = Math.random() * 16777215, w = new Xe({ color: h });
|
|
682
688
|
c.object.material = w;
|
|
@@ -699,20 +705,20 @@ const C = class {
|
|
|
699
705
|
updateLODs(t, e, r, n) {
|
|
700
706
|
var o, l;
|
|
701
707
|
r.userData || (r.userData = {});
|
|
702
|
-
let s = r[
|
|
703
|
-
if (s || (s = new it(), r[
|
|
708
|
+
let s = r[we];
|
|
709
|
+
if (s || (s = new it(), r[we] = s), s.frames++ < 2)
|
|
704
710
|
return;
|
|
705
711
|
for (const u of Y)
|
|
706
712
|
(o = u.onBeforeUpdateLOD) == null || o.call(u, this.renderer, t, e, r);
|
|
707
|
-
this.calculateLodLevel(e, r, s, n,
|
|
708
|
-
let i =
|
|
713
|
+
this.calculateLodLevel(e, r, s, n, R), R.mesh_lod = Math.round(R.mesh_lod), R.texture_lod = Math.round(R.texture_lod), R.mesh_lod >= 0 && this.loadProgressiveMeshes(r, R.mesh_lod);
|
|
714
|
+
let i = R.texture_lod;
|
|
709
715
|
if (r.material && i >= 0) {
|
|
710
716
|
const u = r["DEBUG:LOD"];
|
|
711
717
|
u != null && (i = u), this.loadProgressiveTextures(r.material, i);
|
|
712
718
|
}
|
|
713
719
|
for (const u of Y)
|
|
714
|
-
(l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, t, e, r,
|
|
715
|
-
s.lastLodLevel_Mesh =
|
|
720
|
+
(l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, t, e, r, R);
|
|
721
|
+
s.lastLodLevel_Mesh = R.mesh_lod, s.lastLodLevel_Texture = R.texture_lod;
|
|
716
722
|
}
|
|
717
723
|
/** Load progressive textures for the given material
|
|
718
724
|
* @param material the material to load the textures for
|
|
@@ -753,7 +759,7 @@ const C = class {
|
|
|
753
759
|
return this._tempPtInside.set(s, i, r.z).applyMatrix4(e).z < 0;
|
|
754
760
|
}
|
|
755
761
|
calculateLodLevel(t, e, r, n, s) {
|
|
756
|
-
var
|
|
762
|
+
var F, U;
|
|
757
763
|
if (!e) {
|
|
758
764
|
s.mesh_lod = -1, s.texture_lod = -1;
|
|
759
765
|
return;
|
|
@@ -763,29 +769,35 @@ const C = class {
|
|
|
763
769
|
return;
|
|
764
770
|
}
|
|
765
771
|
let o = 10 + 1, l = !1;
|
|
766
|
-
if (
|
|
772
|
+
if (k && e["DEBUG:LOD"] != null)
|
|
767
773
|
return e["DEBUG:LOD"];
|
|
768
774
|
const u = b.getMeshLODInformation(e.geometry), c = u == null ? void 0 : u.lods, d = c && c.length > 0, h = b.getMaterialMinMaxLODsCount(e.material), w = (h == null ? void 0 : h.min_count) != 1 / 0 && h.min_count > 0 && h.max_count > 0;
|
|
769
775
|
if (!d && !w) {
|
|
770
776
|
s.mesh_lod = 0, s.texture_lod = 0;
|
|
771
777
|
return;
|
|
772
778
|
}
|
|
773
|
-
if (d || (l = !0, o = 0), !((
|
|
774
|
-
s.mesh_lod =
|
|
779
|
+
if (d || (l = !0, o = 0), !((F = this.cameraFrustrum) != null && F.intersectsObject(e))) {
|
|
780
|
+
s.mesh_lod = 100, s.texture_lod = 100;
|
|
775
781
|
return;
|
|
776
782
|
}
|
|
777
783
|
const v = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
778
784
|
let M = e.geometry.boundingBox;
|
|
779
785
|
if (e.type === "SkinnedMesh") {
|
|
780
|
-
const
|
|
781
|
-
|
|
786
|
+
const g = e;
|
|
787
|
+
if (!g.boundingBox)
|
|
788
|
+
g.computeBoundingBox();
|
|
789
|
+
else if (r.frames % 30 === 0) {
|
|
790
|
+
const m = me(g), I = g.geometry;
|
|
791
|
+
m && (g.geometry = m), g.computeBoundingBox(), g.geometry = I;
|
|
792
|
+
}
|
|
793
|
+
M = g.boundingBox;
|
|
782
794
|
}
|
|
783
795
|
if (M && t.isPerspectiveCamera) {
|
|
784
|
-
const
|
|
796
|
+
const g = t;
|
|
785
797
|
if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
|
|
786
798
|
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
787
|
-
const
|
|
788
|
-
if (this._sphere.containsPoint(
|
|
799
|
+
const p = t.getWorldPosition(this._tempWorldPosition);
|
|
800
|
+
if (this._sphere.containsPoint(p)) {
|
|
789
801
|
s.mesh_lod = 0, s.texture_lod = 0;
|
|
790
802
|
return;
|
|
791
803
|
}
|
|
@@ -794,61 +806,61 @@ const C = class {
|
|
|
794
806
|
s.mesh_lod = 0, s.texture_lod = 0;
|
|
795
807
|
return;
|
|
796
808
|
}
|
|
797
|
-
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled &&
|
|
798
|
-
const
|
|
799
|
-
let T =
|
|
800
|
-
const le = 2,
|
|
801
|
-
T = (T - ce) * le + ce,
|
|
802
|
-
const Fe = T < 0 &&
|
|
803
|
-
r.lastCentrality = (
|
|
809
|
+
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && g.fov > 70) {
|
|
810
|
+
const p = this._tempBox.min, D = this._tempBox.max;
|
|
811
|
+
let T = p.x, E = p.y, P = D.x, te = D.y;
|
|
812
|
+
const le = 2, xe = 1.5, ce = (p.x + D.x) * 0.5, ue = (p.y + D.y) * 0.5;
|
|
813
|
+
T = (T - ce) * le + ce, E = (E - ue) * le + ue, P = (P - ce) * le + ce, te = (te - ue) * le + ue;
|
|
814
|
+
const Fe = T < 0 && P > 0 ? 0 : Math.min(Math.abs(p.x), Math.abs(D.x)), $e = E < 0 && te > 0 ? 0 : Math.min(Math.abs(p.y), Math.abs(D.y)), Le = Math.max(Fe, $e);
|
|
815
|
+
r.lastCentrality = (xe - Le) * (xe - Le) * (xe - Le);
|
|
804
816
|
} else
|
|
805
817
|
r.lastCentrality = 1;
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
X.copy(M), X.applyMatrix4(e.matrixWorld), X.applyMatrix4(
|
|
818
|
+
const m = this._tempBox.getSize(this._tempBoxSize);
|
|
819
|
+
m.multiplyScalar(0.5), screen.availHeight > 0 && v > 0 && m.multiplyScalar(v / screen.availHeight), m.x *= g.aspect;
|
|
820
|
+
const I = t.matrixWorldInverse, X = this._tempBox2;
|
|
821
|
+
X.copy(M), X.applyMatrix4(e.matrixWorld), X.applyMatrix4(I);
|
|
810
822
|
const S = X.getSize(this._tempBox2Size), z = Math.max(S.x, S.y);
|
|
811
|
-
if (Math.max(
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
const D = C.corner0, T = C.corner1,
|
|
815
|
-
D.copy(this._tempBox.min), T.copy(this._tempBox.max), T.x = D.x,
|
|
816
|
-
const te = (D.z +
|
|
817
|
-
D.z = T.z =
|
|
823
|
+
if (Math.max(m.x, m.y) != 0 && z != 0 && (m.z = S.z / Math.max(S.x, S.y) * Math.max(m.x, m.y)), r.lastScreenCoverage = Math.max(m.x, m.y, m.z), r.lastScreenspaceVolume.copy(m), r.lastScreenCoverage *= r.lastCentrality, k && C.debugDrawLine) {
|
|
824
|
+
const p = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
825
|
+
p.invert();
|
|
826
|
+
const D = C.corner0, T = C.corner1, E = C.corner2, P = C.corner3;
|
|
827
|
+
D.copy(this._tempBox.min), T.copy(this._tempBox.max), T.x = D.x, E.copy(this._tempBox.max), E.y = D.y, P.copy(this._tempBox.max);
|
|
828
|
+
const te = (D.z + P.z) * 0.5;
|
|
829
|
+
D.z = T.z = E.z = P.z = te, D.applyMatrix4(p), T.applyMatrix4(p), E.applyMatrix4(p), P.applyMatrix4(p), C.debugDrawLine(D, T, 255), C.debugDrawLine(D, E, 255), C.debugDrawLine(T, P, 255), C.debugDrawLine(E, P, 255);
|
|
818
830
|
}
|
|
819
831
|
let _ = 999;
|
|
820
832
|
if (c && r.lastScreenCoverage > 0) {
|
|
821
|
-
for (let
|
|
822
|
-
if (c[
|
|
823
|
-
_ =
|
|
833
|
+
for (let p = 0; p < c.length; p++)
|
|
834
|
+
if (c[p].density / r.lastScreenCoverage < n) {
|
|
835
|
+
_ = p;
|
|
824
836
|
break;
|
|
825
837
|
}
|
|
826
838
|
}
|
|
827
839
|
_ < o && (o = _, l = !0);
|
|
828
840
|
}
|
|
829
|
-
if (l ? s.mesh_lod = o : s.mesh_lod = r.lastLodLevel_Mesh,
|
|
830
|
-
const
|
|
831
|
-
|
|
841
|
+
if (l ? s.mesh_lod = o : s.mesh_lod = r.lastLodLevel_Mesh, k && s.mesh_lod != r.lastLodLevel_Mesh) {
|
|
842
|
+
const m = c == null ? void 0 : c[s.mesh_lod];
|
|
843
|
+
m && console.log(`Mesh LOD changed: ${r.lastLodLevel_Mesh} → ${s.mesh_lod} (${m.density.toFixed(0)}) - ${e.name}`);
|
|
832
844
|
}
|
|
833
845
|
if (w) {
|
|
834
|
-
const
|
|
846
|
+
const g = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
835
847
|
if (r.lastLodLevel_Texture < 0) {
|
|
836
|
-
if (s.texture_lod = h.max_count - 1,
|
|
837
|
-
const
|
|
838
|
-
|
|
848
|
+
if (s.texture_lod = h.max_count - 1, k) {
|
|
849
|
+
const m = h.lods[h.max_count - 1];
|
|
850
|
+
k && console.log(`First Texture LOD ${s.texture_lod} (${m.max_height}px) - ${e.name}`);
|
|
839
851
|
}
|
|
840
852
|
} else {
|
|
841
|
-
const
|
|
842
|
-
let
|
|
843
|
-
((
|
|
844
|
-
const S = v / window.devicePixelRatio *
|
|
853
|
+
const m = r.lastScreenspaceVolume.x + r.lastScreenspaceVolume.y + r.lastScreenspaceVolume.z;
|
|
854
|
+
let I = r.lastScreenCoverage * 2;
|
|
855
|
+
((U = this.context) == null ? void 0 : U.engine) === "model-viewer" && (I *= 2);
|
|
856
|
+
const S = v / window.devicePixelRatio * I;
|
|
845
857
|
for (let z = h.lods.length - 1; z >= 0; z--) {
|
|
846
858
|
let A = h.lods[z];
|
|
847
|
-
if (!(
|
|
859
|
+
if (!(g && A.max_height >= 2048) && !(je() && A.max_height > 4096) && A.max_height > S) {
|
|
848
860
|
if (s.texture_lod = z, s.texture_lod < r.lastLodLevel_Texture) {
|
|
849
861
|
const _ = A.max_height;
|
|
850
|
-
|
|
851
|
-
Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * r.lastScreenCoverage).toFixed(2)}%, Volume ${
|
|
862
|
+
k && console.log(`Texture LOD changed: ${r.lastLodLevel_Texture} → ${s.texture_lod} = ${_}px
|
|
863
|
+
Screensize: ${S.toFixed(0)}px, Coverage: ${(100 * r.lastScreenCoverage).toFixed(2)}%, Volume ${m.toFixed(1)}
|
|
852
864
|
${e.name}`);
|
|
853
865
|
}
|
|
854
866
|
break;
|
|
@@ -859,10 +871,10 @@ ${e.name}`);
|
|
|
859
871
|
s.texture_lod = 0;
|
|
860
872
|
}
|
|
861
873
|
};
|
|
862
|
-
let
|
|
874
|
+
let G = C;
|
|
863
875
|
B = new WeakMap(), W = new WeakMap(), pe = new WeakMap(), j = new WeakMap(), ee = new WeakMap(), ye = new WeakMap(), q = new WeakMap(), /** 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.
|
|
864
876
|
*/
|
|
865
|
-
f(
|
|
877
|
+
f(G, "debugDrawLine"), f(G, "corner0", new V()), f(G, "corner1", new V()), f(G, "corner2", new V()), f(G, "corner3", new V()), f(G, "_tempPtInside", new V());
|
|
866
878
|
class it {
|
|
867
879
|
constructor() {
|
|
868
880
|
f(this, "frames", 0);
|
|
@@ -873,13 +885,13 @@ class it {
|
|
|
873
885
|
f(this, "lastCentrality", 0);
|
|
874
886
|
}
|
|
875
887
|
}
|
|
876
|
-
const
|
|
888
|
+
const Ee = Symbol("NEEDLE_mesh_lod"), fe = Symbol("NEEDLE_texture_lod");
|
|
877
889
|
let ne = null;
|
|
878
890
|
function Re() {
|
|
879
891
|
const a = nt();
|
|
880
892
|
a && (a.mapURLs(function(t) {
|
|
881
|
-
return
|
|
882
|
-
}),
|
|
893
|
+
return Pe(), t;
|
|
894
|
+
}), Pe(), ne == null || ne.disconnect(), ne = new MutationObserver((t) => {
|
|
883
895
|
t.forEach((e) => {
|
|
884
896
|
e.addedNodes.forEach((r) => {
|
|
885
897
|
r instanceof HTMLElement && r.tagName.toLowerCase() === "model-viewer" && Ge(r);
|
|
@@ -893,7 +905,7 @@ function nt() {
|
|
|
893
905
|
console.debug("[gltf-progressive] model-viewer defined"), Re();
|
|
894
906
|
}), null);
|
|
895
907
|
}
|
|
896
|
-
function
|
|
908
|
+
function Pe() {
|
|
897
909
|
document.querySelectorAll("model-viewer").forEach((t) => {
|
|
898
910
|
Ge(t);
|
|
899
911
|
});
|
|
@@ -923,8 +935,8 @@ function Ge(a) {
|
|
|
923
935
|
}
|
|
924
936
|
};
|
|
925
937
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
926
|
-
const s =
|
|
927
|
-
return
|
|
938
|
+
const s = G.get(t, { engine: "model-viewer" });
|
|
939
|
+
return G.addPlugin(new at()), s.enable(), s.addEventListener("changed", () => {
|
|
928
940
|
r == null || r.call(a);
|
|
929
941
|
}), a.addEventListener("model-visibility", (i) => {
|
|
930
942
|
i.detail.visible && (r == null || r.call(a));
|
|
@@ -970,17 +982,17 @@ class at {
|
|
|
970
982
|
for (let w = 0; w < u.length; w++) {
|
|
971
983
|
const v = u[w], M = l[v];
|
|
972
984
|
if ((M == null ? void 0 : M.isTexture) === !0) {
|
|
973
|
-
const
|
|
974
|
-
if (
|
|
985
|
+
const F = (d = (c = M.userData) == null ? void 0 : c.associations) == null ? void 0 : d.textures;
|
|
986
|
+
if (F == null)
|
|
975
987
|
continue;
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
console.warn("Texture data not found for texture index " +
|
|
988
|
+
const U = r.parser.json.textures[F];
|
|
989
|
+
if (!U) {
|
|
990
|
+
console.warn("Texture data not found for texture index " + F);
|
|
979
991
|
continue;
|
|
980
992
|
}
|
|
981
|
-
if ((h =
|
|
982
|
-
const
|
|
983
|
-
|
|
993
|
+
if ((h = U == null ? void 0 : U.extensions) != null && h[N]) {
|
|
994
|
+
const g = U.extensions[N];
|
|
995
|
+
g && s && b.registerTexture(s, M, g.lods.length, F, g);
|
|
984
996
|
}
|
|
985
997
|
}
|
|
986
998
|
}
|
|
@@ -995,9 +1007,9 @@ class at {
|
|
|
995
1007
|
}
|
|
996
1008
|
tryParseMeshLOD(t, e) {
|
|
997
1009
|
var i, o;
|
|
998
|
-
if (e[
|
|
1010
|
+
if (e[Ee] == !0)
|
|
999
1011
|
return;
|
|
1000
|
-
e[
|
|
1012
|
+
e[Ee] = !0;
|
|
1001
1013
|
const r = this.tryGetCurrentModelViewer(t), n = this.getUrl(r);
|
|
1002
1014
|
if (!n)
|
|
1003
1015
|
return;
|
|
@@ -1010,18 +1022,18 @@ class at {
|
|
|
1010
1022
|
}
|
|
1011
1023
|
function mt(a, t, e, r) {
|
|
1012
1024
|
Ie(t), ke(e), e.register((s) => new b(s, a));
|
|
1013
|
-
const n =
|
|
1025
|
+
const n = G.get(t);
|
|
1014
1026
|
return (r == null ? void 0 : r.enableLODsManager) !== !1 && n.enable(), n;
|
|
1015
1027
|
}
|
|
1016
1028
|
Re();
|
|
1017
1029
|
export {
|
|
1018
1030
|
N as EXTENSION_NAME,
|
|
1019
|
-
|
|
1031
|
+
G as LODsManager,
|
|
1020
1032
|
b as NEEDLE_progressive,
|
|
1021
1033
|
Be as VERSION,
|
|
1022
1034
|
ke as addDracoAndKTX2Loaders,
|
|
1023
1035
|
Ie as createLoaders,
|
|
1024
|
-
|
|
1036
|
+
me as getRaycastMesh,
|
|
1025
1037
|
Re as patchModelViewer,
|
|
1026
1038
|
et as registerRaycastMesh,
|
|
1027
1039
|
gt as setDracoDecoderLocation,
|