@needle-tools/gltf-progressive 1.2.2-alpha.1 → 1.2.2-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/CHANGELOG.md +2 -1
- package/examples/modelviewer-multiple.html +72 -8
- package/examples/modelviewer.html +4 -0
- package/gltf-progressive.js +420 -403
- package/gltf-progressive.min.js +6 -6
- package/gltf-progressive.umd.cjs +6 -6
- package/lib/lods_manager.d.ts +8 -1
- package/lib/lods_manager.js +14 -2
- package/lib/plugins/modelviewer.js +20 -7
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/gltf-progressive.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BufferGeometry as
|
|
5
|
-
import { GLTFLoader as
|
|
6
|
-
import { MeshoptDecoder as
|
|
7
|
-
import { DRACOLoader as
|
|
8
|
-
import { KTX2Loader as
|
|
9
|
-
const
|
|
10
|
-
globalThis.GLTF_PROGRESSIVE_VERSION =
|
|
11
|
-
console.debug(`[gltf-progressive] version ${
|
|
12
|
-
let
|
|
13
|
-
fetch(
|
|
14
|
-
|
|
1
|
+
var Se = Object.defineProperty;
|
|
2
|
+
var be = (l, e, t) => e in l ? Se(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var f = (l, e, t) => (be(l, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import { BufferGeometry as se, Mesh as W, Material as Te, Texture as q, TextureLoader as Ae, Matrix4 as ye, Frustum as Pe, Sphere as Ce, Box3 as me, Vector3 as G } from "three";
|
|
5
|
+
import { GLTFLoader as Ee } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
6
|
+
import { MeshoptDecoder as Be } from "three/examples/jsm/libs/meshopt_decoder.module.js";
|
|
7
|
+
import { DRACOLoader as ke } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
8
|
+
import { KTX2Loader as Re } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
9
|
+
const De = "";
|
|
10
|
+
globalThis.GLTF_PROGRESSIVE_VERSION = De;
|
|
11
|
+
console.debug(`[gltf-progressive] version ${De}`);
|
|
12
|
+
let ie = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", ge = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
|
|
13
|
+
fetch(ie + "draco_decoder.js", { method: "head" }).catch((l) => {
|
|
14
|
+
ie = "./include/draco/", ge = "./include/ktx2/";
|
|
15
15
|
});
|
|
16
|
-
function Qe(l) {
|
|
17
|
-
se = l;
|
|
18
|
-
}
|
|
19
16
|
function Ze(l) {
|
|
20
|
-
|
|
17
|
+
ie = l;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Y || (Y = new Be(), Y.setDecoderPath(se), Y.setDecoderConfig({ type: "js" })), H || (H = new Ee(), H.setTranscoderPath(he)), ue || (ue = Re), l ? H.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
|
|
19
|
+
function je(l) {
|
|
20
|
+
ge = l;
|
|
25
21
|
}
|
|
22
|
+
let H, fe, J;
|
|
26
23
|
function we(l) {
|
|
27
|
-
|
|
24
|
+
H || (H = new ke(), H.setDecoderPath(ie), H.setDecoderConfig({ type: "js" })), J || (J = new Re(), J.setTranscoderPath(ge)), fe || (fe = Be), l ? J.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
|
|
25
|
+
}
|
|
26
|
+
function _e(l) {
|
|
27
|
+
l.dracoLoader || l.setDRACOLoader(H), l.ktx2Loader || l.setKTX2Loader(J), l.meshoptDecoder || l.setMeshoptDecoder(fe);
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
function
|
|
29
|
+
Z("debugprogressive");
|
|
30
|
+
function Z(l) {
|
|
31
31
|
const t = new URL(window.location.href).searchParams.get(l);
|
|
32
32
|
return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Ie(l, e) {
|
|
35
35
|
if (e === void 0 || e.startsWith("./") || e.startsWith("http") || l === void 0)
|
|
36
36
|
return e;
|
|
37
37
|
const t = l.lastIndexOf("/");
|
|
@@ -43,104 +43,104 @@ function ke(l, e) {
|
|
|
43
43
|
}
|
|
44
44
|
return e;
|
|
45
45
|
}
|
|
46
|
-
let
|
|
47
|
-
function
|
|
48
|
-
return
|
|
46
|
+
let X;
|
|
47
|
+
function Ge() {
|
|
48
|
+
return X !== void 0 || (X = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), Z("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", X)), X;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
function
|
|
52
|
-
return (l == null ? void 0 : l[
|
|
50
|
+
const de = Symbol("needle:raycast-mesh");
|
|
51
|
+
function pe(l) {
|
|
52
|
+
return (l == null ? void 0 : l[de]) instanceof se ? l[de] : null;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
if ((l.type === "Mesh" || l.type === "SkinnedMesh") && !
|
|
56
|
-
const r =
|
|
57
|
-
r.userData = { isRaycastMesh: !0 }, l[
|
|
54
|
+
function Fe(l, e) {
|
|
55
|
+
if ((l.type === "Mesh" || l.type === "SkinnedMesh") && !pe(l)) {
|
|
56
|
+
const r = $e(e);
|
|
57
|
+
r.userData = { isRaycastMesh: !0 }, l[de] = r;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function et(l = !0) {
|
|
61
61
|
if (l) {
|
|
62
|
-
if (
|
|
62
|
+
if (Y)
|
|
63
63
|
return;
|
|
64
|
-
const e =
|
|
65
|
-
|
|
66
|
-
const
|
|
64
|
+
const e = Y = W.prototype.raycast;
|
|
65
|
+
W.prototype.raycast = function(t, r) {
|
|
66
|
+
const i = this, n = pe(i);
|
|
67
67
|
let s;
|
|
68
|
-
|
|
68
|
+
n && i.isMesh && (s = i.geometry, i.geometry = n), e.call(this, t, r), s && (i.geometry = s);
|
|
69
69
|
};
|
|
70
70
|
} else {
|
|
71
|
-
if (!
|
|
71
|
+
if (!Y)
|
|
72
72
|
return;
|
|
73
|
-
|
|
73
|
+
W.prototype.raycast = Y, Y = null;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
let
|
|
77
|
-
function
|
|
78
|
-
const e = new
|
|
76
|
+
let Y = null;
|
|
77
|
+
function $e(l) {
|
|
78
|
+
const e = new se();
|
|
79
79
|
for (const t in l.attributes)
|
|
80
80
|
e.setAttribute(t, l.getAttribute(t));
|
|
81
81
|
return e.setIndex(l.getIndex()), e;
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const z = new Array(), F = "NEEDLE_progressive", m = Z("debugprogressive"), ae = Symbol("needle-progressive-texture"), Q = /* @__PURE__ */ new Map(), he = /* @__PURE__ */ new Set();
|
|
84
84
|
if (m) {
|
|
85
85
|
let l = function() {
|
|
86
|
-
e += 1, console.log("Toggle LOD level", e,
|
|
87
|
-
for (const s of
|
|
88
|
-
const o =
|
|
86
|
+
e += 1, console.log("Toggle LOD level", e, Q), Q.forEach((i, n) => {
|
|
87
|
+
for (const s of i.keys) {
|
|
88
|
+
const o = n[s];
|
|
89
89
|
if (o != null) {
|
|
90
90
|
if (o.isBufferGeometry === !0) {
|
|
91
91
|
const a = O.getMeshLODInformation(o), d = a ? Math.min(e, a.lods.length) : 0;
|
|
92
|
-
|
|
93
|
-
} else if (
|
|
94
|
-
|
|
92
|
+
n["DEBUG:LOD"] = e, O.assignMeshLOD(n, d), a && (t = Math.max(t, a.lods.length - 1));
|
|
93
|
+
} else if (n.isMaterial === !0) {
|
|
94
|
+
n["DEBUG:LOD"] = e, O.assignTextureLOD(n, e);
|
|
95
95
|
break;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}), e >= t && (e = -1);
|
|
100
100
|
}, e = -1, t = 2, r = !1;
|
|
101
|
-
window.addEventListener("keyup", (
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
window.addEventListener("keyup", (i) => {
|
|
102
|
+
i.key === "p" && l(), i.key === "w" && (r = !r, he && he.forEach((n) => {
|
|
103
|
+
n.name != "BackgroundCubeMaterial" && n.glyphMap == null && "wireframe" in n && (n.wireframe = r);
|
|
104
104
|
}));
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
var
|
|
107
|
+
function xe(l, e, t) {
|
|
108
|
+
var i;
|
|
109
109
|
if (!m)
|
|
110
110
|
return;
|
|
111
|
-
|
|
112
|
-
const r =
|
|
113
|
-
((
|
|
111
|
+
Q.has(l) || Q.set(l, { keys: [], sourceId: t });
|
|
112
|
+
const r = Q.get(l);
|
|
113
|
+
((i = r == null ? void 0 : r.keys) == null ? void 0 : i.includes(e)) == !1 && r.keys.push(e);
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const v = class {
|
|
116
116
|
constructor(e, t) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
var r,
|
|
117
|
+
f(this, "parser");
|
|
118
|
+
f(this, "url");
|
|
119
|
+
f(this, "_isLoadingMesh");
|
|
120
|
+
f(this, "loadMesh", (e) => {
|
|
121
|
+
var r, i;
|
|
122
122
|
if (this._isLoadingMesh)
|
|
123
123
|
return null;
|
|
124
|
-
const t = (
|
|
125
|
-
return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((
|
|
124
|
+
const t = (i = (r = this.parser.json.meshes[e]) == null ? void 0 : r.extensions) == null ? void 0 : i[F];
|
|
125
|
+
return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((n) => {
|
|
126
126
|
var s;
|
|
127
|
-
return this._isLoadingMesh = !1,
|
|
127
|
+
return this._isLoadingMesh = !1, n && v.registerMesh(this.url, t.guid, n, (s = t.lods) == null ? void 0 : s.length, void 0, t), n;
|
|
128
128
|
})) : null;
|
|
129
129
|
});
|
|
130
130
|
m && console.log("Progressive extension registered for", t), this.parser = e, this.url = t;
|
|
131
131
|
}
|
|
132
132
|
/** The name of the extension */
|
|
133
133
|
get name() {
|
|
134
|
-
return
|
|
134
|
+
return F;
|
|
135
135
|
}
|
|
136
136
|
static getMeshLODInformation(e) {
|
|
137
137
|
const t = this.getAssignedLODInformation(e);
|
|
138
138
|
return t != null && t.key ? this.lodInfos.get(t.key) : null;
|
|
139
139
|
}
|
|
140
140
|
static getMaterialMinMaxLODsCount(e, t) {
|
|
141
|
-
const r = this,
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
141
|
+
const r = this, i = "LODS:minmax", n = e[i];
|
|
142
|
+
if (n != null)
|
|
143
|
+
return n;
|
|
144
144
|
if (t || (t = {
|
|
145
145
|
min_count: 1 / 0,
|
|
146
146
|
max_count: 0,
|
|
@@ -148,7 +148,7 @@ const D = class {
|
|
|
148
148
|
}), Array.isArray(e)) {
|
|
149
149
|
for (const o of e)
|
|
150
150
|
this.getMaterialMinMaxLODsCount(o, t);
|
|
151
|
-
return e[
|
|
151
|
+
return e[i] = t, t;
|
|
152
152
|
}
|
|
153
153
|
if (m === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
|
|
154
154
|
const o = e;
|
|
@@ -161,7 +161,7 @@ const D = class {
|
|
|
161
161
|
const a = e[o];
|
|
162
162
|
(a == null ? void 0 : a.isTexture) === !0 && s(a, t);
|
|
163
163
|
}
|
|
164
|
-
return e[
|
|
164
|
+
return e[i] = t, t;
|
|
165
165
|
function s(o, a) {
|
|
166
166
|
const d = r.getAssignedLODInformation(o);
|
|
167
167
|
if (d) {
|
|
@@ -169,8 +169,8 @@ const D = class {
|
|
|
169
169
|
if (c && c.lods) {
|
|
170
170
|
a.min_count = Math.min(a.min_count, c.lods.length), a.max_count = Math.max(a.max_count, c.lods.length);
|
|
171
171
|
for (let x = 0; x < c.lods.length; x++) {
|
|
172
|
-
const
|
|
173
|
-
|
|
172
|
+
const u = c.lods[x];
|
|
173
|
+
u.width && (a.lods[x] = a.lods[x] || { min_height: 1 / 0, max_height: 0 }, a.lods[x].min_height = Math.min(a.lods[x].min_height, u.height), a.lods[x].max_height = Math.max(a.lods[x].max_height, u.height));
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -182,7 +182,7 @@ const D = class {
|
|
|
182
182
|
* @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
|
|
183
183
|
*/
|
|
184
184
|
static hasLODLevelAvailable(e, t) {
|
|
185
|
-
var
|
|
185
|
+
var n;
|
|
186
186
|
if (Array.isArray(e)) {
|
|
187
187
|
for (const s of e)
|
|
188
188
|
if (this.hasLODLevelAvailable(s, t))
|
|
@@ -201,13 +201,13 @@ const D = class {
|
|
|
201
201
|
if (s.isMesh === !0 && this.hasLODLevelAvailable(s, t))
|
|
202
202
|
return !0;
|
|
203
203
|
}
|
|
204
|
-
let r,
|
|
205
|
-
if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (
|
|
204
|
+
let r, i;
|
|
205
|
+
if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (n = r == null ? void 0 : r.userData) != null && n.LODS) {
|
|
206
206
|
const s = r.userData.LODS;
|
|
207
|
-
if (
|
|
208
|
-
return
|
|
209
|
-
if (
|
|
210
|
-
return Array.isArray(
|
|
207
|
+
if (i = this.lodInfos.get(s.key), t === void 0)
|
|
208
|
+
return i != null;
|
|
209
|
+
if (i)
|
|
210
|
+
return Array.isArray(i.lods) ? t < i.lods.length : t === 0;
|
|
211
211
|
}
|
|
212
212
|
return !1;
|
|
213
213
|
}
|
|
@@ -229,19 +229,19 @@ const D = class {
|
|
|
229
229
|
var r;
|
|
230
230
|
if (!e)
|
|
231
231
|
return Promise.resolve(null);
|
|
232
|
-
if (e instanceof
|
|
233
|
-
const
|
|
234
|
-
if (!
|
|
232
|
+
if (e instanceof W || e.isMesh === !0) {
|
|
233
|
+
const i = e.geometry, n = this.getAssignedLODInformation(i);
|
|
234
|
+
if (!n)
|
|
235
235
|
return Promise.resolve(null);
|
|
236
|
-
for (const s of
|
|
236
|
+
for (const s of z)
|
|
237
237
|
(r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
|
|
238
|
-
return e["LOD:requested level"] = t,
|
|
238
|
+
return e["LOD:requested level"] = t, v.getOrLoadLOD(i, t).then((s) => {
|
|
239
239
|
if (e["LOD:requested level"] === t) {
|
|
240
240
|
if (delete e["LOD:requested level"], Array.isArray(s)) {
|
|
241
|
-
const o =
|
|
241
|
+
const o = n.index || 0;
|
|
242
242
|
s = s[o];
|
|
243
243
|
}
|
|
244
|
-
s &&
|
|
244
|
+
s && i != s && ((s == null ? void 0 : s.isBufferGeometry) ? (e.geometry = s, m && xe(e, "geometry", n.url)) : m && console.error("Invalid LOD geometry", s));
|
|
245
245
|
}
|
|
246
246
|
return s;
|
|
247
247
|
}).catch((s) => (console.error("Error loading mesh LOD", e, s), null));
|
|
@@ -259,15 +259,15 @@ const D = class {
|
|
|
259
259
|
static assignTextureLOD(e, t = 0) {
|
|
260
260
|
if (!e)
|
|
261
261
|
return Promise.resolve(null);
|
|
262
|
-
if (e instanceof
|
|
263
|
-
const r = e,
|
|
264
|
-
if (m &&
|
|
262
|
+
if (e instanceof Te || e.isMaterial === !0) {
|
|
263
|
+
const r = e, i = [], n = new Array();
|
|
264
|
+
if (m && he.add(r), r.uniforms && r.isRawShaderMaterial || r.isShaderMaterial === !0) {
|
|
265
265
|
const s = r;
|
|
266
266
|
for (const o of Object.keys(s.uniforms)) {
|
|
267
267
|
const a = s.uniforms[o].value;
|
|
268
268
|
if ((a == null ? void 0 : a.isTexture) === !0) {
|
|
269
269
|
const d = this.assignTextureLODForSlot(a, t, r, o);
|
|
270
|
-
|
|
270
|
+
i.push(d), n.push(o);
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
} else
|
|
@@ -275,56 +275,56 @@ const D = class {
|
|
|
275
275
|
const o = r[s];
|
|
276
276
|
if ((o == null ? void 0 : o.isTexture) === !0) {
|
|
277
277
|
const a = this.assignTextureLODForSlot(o, t, r, s);
|
|
278
|
-
|
|
278
|
+
i.push(a), n.push(s);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
return Promise.all(
|
|
281
|
+
return Promise.all(i).then((s) => {
|
|
282
282
|
const o = new Array();
|
|
283
283
|
for (let a = 0; a < s.length; a++) {
|
|
284
|
-
const d = s[a], c =
|
|
284
|
+
const d = s[a], c = n[a];
|
|
285
285
|
d && d.isTexture === !0 ? o.push({ material: r, slot: c, texture: d, level: t }) : o.push({ material: r, slot: c, texture: null, level: t });
|
|
286
286
|
}
|
|
287
287
|
return o;
|
|
288
288
|
});
|
|
289
289
|
}
|
|
290
|
-
if (e instanceof
|
|
290
|
+
if (e instanceof q || e.isTexture === !0) {
|
|
291
291
|
const r = e;
|
|
292
292
|
return this.assignTextureLODForSlot(r, t, null, null);
|
|
293
293
|
}
|
|
294
294
|
return Promise.resolve(null);
|
|
295
295
|
}
|
|
296
|
-
static assignTextureLODForSlot(e, t, r,
|
|
297
|
-
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) :
|
|
298
|
-
if (Array.isArray(
|
|
296
|
+
static assignTextureLODForSlot(e, t, r, i) {
|
|
297
|
+
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : i === "glyphMap" ? Promise.resolve(e) : v.getOrLoadLOD(e, t).then((n) => {
|
|
298
|
+
if (Array.isArray(n))
|
|
299
299
|
return null;
|
|
300
|
-
if ((
|
|
301
|
-
if (
|
|
302
|
-
if (r &&
|
|
303
|
-
const s = r[
|
|
300
|
+
if ((n == null ? void 0 : n.isTexture) === !0) {
|
|
301
|
+
if (n != e) {
|
|
302
|
+
if (r && i) {
|
|
303
|
+
const s = r[i];
|
|
304
304
|
if (s) {
|
|
305
305
|
const o = this.getAssignedLODInformation(s);
|
|
306
306
|
if (o && (o == null ? void 0 : o.level) < t)
|
|
307
|
-
return m === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, t, r, s,
|
|
307
|
+
return m === "verbose" && console.warn("Assigned texture level is already higher: ", o.level, t, r, s, n), null;
|
|
308
308
|
}
|
|
309
|
-
r[
|
|
309
|
+
r[i] = n;
|
|
310
310
|
}
|
|
311
|
-
if (m &&
|
|
311
|
+
if (m && i && r) {
|
|
312
312
|
const s = this.getAssignedLODInformation(e);
|
|
313
|
-
s &&
|
|
313
|
+
s && xe(r, i, s.url);
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
return
|
|
316
|
+
return n;
|
|
317
317
|
} else
|
|
318
318
|
m == "verbose" && console.warn("No LOD found for", e, t);
|
|
319
319
|
return null;
|
|
320
|
-
}).catch((
|
|
320
|
+
}).catch((n) => (console.error("Error loading LOD", e, n), null));
|
|
321
321
|
}
|
|
322
322
|
afterRoot(e) {
|
|
323
323
|
var t, r;
|
|
324
|
-
return m && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((
|
|
324
|
+
return m && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
|
|
325
325
|
var s;
|
|
326
|
-
if (
|
|
327
|
-
const o =
|
|
326
|
+
if (i != null && i.extensions) {
|
|
327
|
+
const o = i == null ? void 0 : i.extensions[F];
|
|
328
328
|
if (o) {
|
|
329
329
|
if (!o.lods) {
|
|
330
330
|
m && console.warn("Texture has no LODs", o);
|
|
@@ -332,21 +332,21 @@ const D = class {
|
|
|
332
332
|
}
|
|
333
333
|
let a = !1;
|
|
334
334
|
for (const d of this.parser.associations.keys())
|
|
335
|
-
d.isTexture === !0 && this.parser.associations.get(d).textures ===
|
|
336
|
-
a || this.parser.getDependency("texture",
|
|
335
|
+
d.isTexture === !0 && this.parser.associations.get(d).textures === n && (a = !0, v.registerTexture(this.url, d, (s = o.lods) == null ? void 0 : s.length, n, o));
|
|
336
|
+
a || this.parser.getDependency("texture", n).then((d) => {
|
|
337
337
|
var c;
|
|
338
|
-
d &&
|
|
338
|
+
d && v.registerTexture(this.url, d, (c = o.lods) == null ? void 0 : c.length, n, o);
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
-
}), (r = this.parser.json.meshes) == null || r.forEach((
|
|
343
|
-
if (
|
|
344
|
-
const s =
|
|
342
|
+
}), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
|
|
343
|
+
if (i != null && i.extensions) {
|
|
344
|
+
const s = i == null ? void 0 : i.extensions[F];
|
|
345
345
|
if (s && s.lods) {
|
|
346
346
|
for (const o of this.parser.associations.keys())
|
|
347
347
|
if (o.isMesh) {
|
|
348
348
|
const a = this.parser.associations.get(o);
|
|
349
|
-
a.meshes ===
|
|
349
|
+
a.meshes === n && v.registerMesh(this.url, s.guid, o, s.lods.length, a.primitives, s);
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
}
|
|
@@ -354,118 +354,118 @@ const D = class {
|
|
|
354
354
|
}
|
|
355
355
|
static async getOrLoadLOD(e, t) {
|
|
356
356
|
var o, a, d, c;
|
|
357
|
-
const r = m == "verbose",
|
|
358
|
-
if (!
|
|
357
|
+
const r = m == "verbose", i = e.userData.LODS;
|
|
358
|
+
if (!i)
|
|
359
359
|
return null;
|
|
360
|
-
const
|
|
360
|
+
const n = i == null ? void 0 : i.key;
|
|
361
361
|
let s;
|
|
362
362
|
if (e.isTexture === !0) {
|
|
363
363
|
const x = e;
|
|
364
|
-
x.source && x.source[
|
|
364
|
+
x.source && x.source[ae] && (s = x.source[ae]);
|
|
365
365
|
}
|
|
366
|
-
if (s || (s =
|
|
366
|
+
if (s || (s = v.lodInfos.get(n)), s) {
|
|
367
367
|
if (t > 0) {
|
|
368
368
|
let y = !1;
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
return this.lowresCache.get(
|
|
369
|
+
const w = Array.isArray(s.lods);
|
|
370
|
+
if (w && t >= s.lods.length ? y = !0 : w || (y = !0), y)
|
|
371
|
+
return this.lowresCache.get(n);
|
|
372
372
|
}
|
|
373
373
|
const x = Array.isArray(s.lods) ? (o = s.lods[t]) == null ? void 0 : o.path : s.lods;
|
|
374
374
|
if (!x)
|
|
375
375
|
return m && !s["missing:uri"] && (s["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, s)), null;
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
376
|
+
const u = Ie(i.url, x);
|
|
377
|
+
if (u.endsWith(".glb") || u.endsWith(".gltf")) {
|
|
378
378
|
if (!s.guid)
|
|
379
379
|
return console.warn("missing pointer for glb/gltf texture", s), null;
|
|
380
|
-
const y =
|
|
381
|
-
if (
|
|
380
|
+
const y = u + "_" + s.guid, w = this.previouslyLoaded.get(y);
|
|
381
|
+
if (w !== void 0) {
|
|
382
382
|
r && console.log(`LOD ${t} was already loading/loaded: ${y}`);
|
|
383
|
-
let
|
|
384
|
-
`,
|
|
385
|
-
if (
|
|
386
|
-
return
|
|
383
|
+
let p = await w.catch((U) => (console.error(`Error loading LOD ${t} from ${u}
|
|
384
|
+
`, U), null)), M = !1;
|
|
385
|
+
if (p == null || (p instanceof q && e instanceof q ? (a = p.image) != null && a.data || (d = p.source) != null && d.data ? p = this.copySettings(e, p) : (M = !0, this.previouslyLoaded.delete(y)) : p instanceof se && e instanceof se && ((c = p.attributes.position) != null && c.array || (M = !0, this.previouslyLoaded.delete(y)))), !M)
|
|
386
|
+
return p;
|
|
387
387
|
}
|
|
388
|
-
const L = s,
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
let
|
|
388
|
+
const L = s, B = new Promise(async (p, M) => {
|
|
389
|
+
const U = new Ee();
|
|
390
|
+
_e(U), m && (await new Promise((S) => setTimeout(S, 1e3)), r && console.warn("Start loading (delayed) " + u, L.guid));
|
|
391
|
+
let k = u;
|
|
392
392
|
if (L && Array.isArray(L.lods)) {
|
|
393
|
-
const
|
|
394
|
-
|
|
393
|
+
const S = L.lods[t];
|
|
394
|
+
S.hash && (k += "?v=" + S.hash);
|
|
395
395
|
}
|
|
396
|
-
const
|
|
397
|
-
`,
|
|
398
|
-
if (!
|
|
396
|
+
const _ = await U.loadAsync(k).catch((S) => (console.error(`Error loading LOD ${t} from ${u}
|
|
397
|
+
`, S), null));
|
|
398
|
+
if (!_)
|
|
399
399
|
return null;
|
|
400
|
-
const
|
|
401
|
-
r && console.log("Loading finished " +
|
|
400
|
+
const $ = _.parser;
|
|
401
|
+
r && console.log("Loading finished " + u, L.guid);
|
|
402
402
|
let R = 0;
|
|
403
|
-
if (
|
|
404
|
-
let
|
|
405
|
-
for (const
|
|
406
|
-
if (
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
|
|
403
|
+
if (_.parser.json.textures) {
|
|
404
|
+
let S = !1;
|
|
405
|
+
for (const g of _.parser.json.textures) {
|
|
406
|
+
if (g != null && g.extensions) {
|
|
407
|
+
const h = g == null ? void 0 : g.extensions[F];
|
|
408
|
+
if (h != null && h.guid && h.guid === L.guid) {
|
|
409
|
+
S = !0;
|
|
410
410
|
break;
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
R++;
|
|
414
414
|
}
|
|
415
|
-
if (
|
|
416
|
-
let
|
|
417
|
-
return
|
|
415
|
+
if (S) {
|
|
416
|
+
let g = await $.getDependency("texture", R);
|
|
417
|
+
return g && v.assignLODInformation(i.url, g, n, t, void 0, void 0), r && console.log('change "' + e.name + '" → "' + g.name + '"', u, R, g, y), e instanceof q && (g = this.copySettings(e, g)), g && (g.guid = L.guid), p(g);
|
|
418
418
|
} else
|
|
419
|
-
m && console.warn("Could not find texture with guid", L.guid,
|
|
419
|
+
m && console.warn("Could not find texture with guid", L.guid, _.parser.json);
|
|
420
420
|
}
|
|
421
|
-
if (R = 0,
|
|
422
|
-
let
|
|
423
|
-
for (const
|
|
424
|
-
if (
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
|
|
421
|
+
if (R = 0, _.parser.json.meshes) {
|
|
422
|
+
let S = !1;
|
|
423
|
+
for (const g of _.parser.json.meshes) {
|
|
424
|
+
if (g != null && g.extensions) {
|
|
425
|
+
const h = g == null ? void 0 : g.extensions[F];
|
|
426
|
+
if (h != null && h.guid && h.guid === L.guid) {
|
|
427
|
+
S = !0;
|
|
428
428
|
break;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
R++;
|
|
432
432
|
}
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
435
|
-
if (r && console.log(`Loaded Mesh "${
|
|
436
|
-
const
|
|
437
|
-
return
|
|
433
|
+
if (S) {
|
|
434
|
+
const g = await $.getDependency("mesh", R), h = L;
|
|
435
|
+
if (r && console.log(`Loaded Mesh "${g.name}"`, u, R, g, y), g.isMesh === !0) {
|
|
436
|
+
const D = g.geometry;
|
|
437
|
+
return v.assignLODInformation(i.url, D, n, t, void 0, h.density), p(D);
|
|
438
438
|
} else {
|
|
439
|
-
const
|
|
440
|
-
for (let
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
const
|
|
444
|
-
|
|
439
|
+
const D = new Array();
|
|
440
|
+
for (let b = 0; b < g.children.length; b++) {
|
|
441
|
+
const T = g.children[b];
|
|
442
|
+
if (T.isMesh === !0) {
|
|
443
|
+
const A = T.geometry;
|
|
444
|
+
v.assignLODInformation(i.url, A, n, t, b, h.density), D.push(A);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
return
|
|
447
|
+
return p(D);
|
|
448
448
|
}
|
|
449
449
|
} else
|
|
450
|
-
m && console.warn("Could not find mesh with guid", L.guid,
|
|
450
|
+
m && console.warn("Could not find mesh with guid", L.guid, _.parser.json);
|
|
451
451
|
}
|
|
452
|
-
return
|
|
452
|
+
return p(null);
|
|
453
453
|
});
|
|
454
|
-
return this.previouslyLoaded.set(y,
|
|
455
|
-
} else if (e instanceof
|
|
456
|
-
r && console.log("Load texture from uri: " +
|
|
457
|
-
const
|
|
458
|
-
return
|
|
454
|
+
return this.previouslyLoaded.set(y, B), await B;
|
|
455
|
+
} else if (e instanceof q) {
|
|
456
|
+
r && console.log("Load texture from uri: " + u);
|
|
457
|
+
const w = await new Ae().loadAsync(u);
|
|
458
|
+
return w ? (w.guid = s.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, r && console.log(s, w)) : m && console.warn("failed loading", u), w;
|
|
459
459
|
}
|
|
460
460
|
} else
|
|
461
|
-
m && console.warn(`Can not load LOD ${t}: no LOD info found for "${
|
|
461
|
+
m && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
|
|
462
462
|
return null;
|
|
463
463
|
}
|
|
464
|
-
static assignLODInformation(e, t, r,
|
|
464
|
+
static assignLODInformation(e, t, r, i, n, s) {
|
|
465
465
|
if (!t)
|
|
466
466
|
return;
|
|
467
467
|
t.userData || (t.userData = {});
|
|
468
|
-
const o = new
|
|
468
|
+
const o = new ze(e, r, i, n, s);
|
|
469
469
|
t.userData.LODS = o;
|
|
470
470
|
}
|
|
471
471
|
static getAssignedLODInformation(e) {
|
|
@@ -479,93 +479,94 @@ const D = class {
|
|
|
479
479
|
`, t.uuid), t.offset = e.offset, t.repeat = e.repeat, t.colorSpace = e.colorSpace, t.magFilter = e.magFilter, t.minFilter = e.minFilter, t.wrapS = e.wrapS, t.wrapT = e.wrapT, t.flipY = e.flipY, t.anisotropy = e.anisotropy, t.mipmaps || (t.generateMipmaps = e.generateMipmaps), t;
|
|
480
480
|
}
|
|
481
481
|
};
|
|
482
|
-
let O =
|
|
482
|
+
let O = v;
|
|
483
483
|
/**
|
|
484
484
|
* Register a texture with LOD information
|
|
485
485
|
*/
|
|
486
|
-
|
|
487
|
-
if (m && console.log("> Progressive: register texture",
|
|
486
|
+
f(O, "registerTexture", (e, t, r, i, n) => {
|
|
487
|
+
if (m && console.log("> Progressive: register texture", i, t.name, t.uuid, t, n), !t) {
|
|
488
488
|
m && console.error("gltf-progressive: Register texture without texture");
|
|
489
489
|
return;
|
|
490
490
|
}
|
|
491
|
-
t.source && (t.source[
|
|
492
|
-
const s =
|
|
493
|
-
|
|
491
|
+
t.source && (t.source[ae] = n);
|
|
492
|
+
const s = n.guid;
|
|
493
|
+
v.assignLODInformation(e, t, s, r, i, void 0), v.lodInfos.set(s, n), v.lowresCache.set(s, t);
|
|
494
494
|
}), /**
|
|
495
495
|
* Register a mesh with LOD information
|
|
496
496
|
*/
|
|
497
|
-
|
|
497
|
+
f(O, "registerMesh", (e, t, r, i, n, s) => {
|
|
498
498
|
var d;
|
|
499
|
-
m && console.log("> Progressive: register mesh",
|
|
499
|
+
m && console.log("> Progressive: register mesh", n, r.name, s, r.uuid, r);
|
|
500
500
|
const o = r.geometry;
|
|
501
501
|
if (!o) {
|
|
502
502
|
m && console.warn("gltf-progressive: Register mesh without geometry");
|
|
503
503
|
return;
|
|
504
504
|
}
|
|
505
|
-
o.userData || (o.userData = {}),
|
|
506
|
-
let a =
|
|
507
|
-
a ? a.push(r.geometry) : a = [r.geometry],
|
|
508
|
-
for (const c of
|
|
505
|
+
o.userData || (o.userData = {}), v.assignLODInformation(e, o, t, i, n, s.density), v.lodInfos.set(t, s);
|
|
506
|
+
let a = v.lowresCache.get(t);
|
|
507
|
+
a ? a.push(r.geometry) : a = [r.geometry], v.lowresCache.set(t, a), i > 0 && !pe(r) && Fe(r, o);
|
|
508
|
+
for (const c of z)
|
|
509
509
|
(d = c.onRegisteredNewMesh) == null || d.call(c, r, s);
|
|
510
510
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
class
|
|
515
|
-
constructor(e, t, r,
|
|
516
|
-
|
|
511
|
+
f(O, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
|
|
512
|
+
f(O, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
|
|
513
|
+
f(O, "lowresCache", /* @__PURE__ */ new Map());
|
|
514
|
+
class ze {
|
|
515
|
+
constructor(e, t, r, i, n) {
|
|
516
|
+
f(this, "url");
|
|
517
517
|
/** the key to lookup the LOD information */
|
|
518
|
-
|
|
519
|
-
|
|
518
|
+
f(this, "key");
|
|
519
|
+
f(this, "level");
|
|
520
520
|
/** For multi objects (e.g. a group of meshes) this is the index of the object */
|
|
521
|
-
|
|
521
|
+
f(this, "index");
|
|
522
522
|
/** the mesh density */
|
|
523
|
-
|
|
524
|
-
this.url = e, this.key = t, this.level = r,
|
|
523
|
+
f(this, "density");
|
|
524
|
+
this.url = e, this.key = t, this.level = r, i != null && (this.index = i), n != null && (this.density = n);
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
-
const
|
|
527
|
+
const N = Z("debugprogressive"), Ue = Z("noprogressive"), le = Symbol("Needle:LODSManager"), ce = Symbol("Needle:LODState"), V = Symbol("Needle:CurrentLOD"), C = { mesh_lod: -1, texture_lod: -1 }, P = class {
|
|
528
528
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
529
529
|
constructor(e, t) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
530
|
+
f(this, "context");
|
|
531
|
+
f(this, "renderer");
|
|
532
|
+
f(this, "projectionScreenMatrix", new ye());
|
|
533
|
+
f(this, "cameraFrustrum", new Pe());
|
|
534
534
|
/**
|
|
535
535
|
* The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
|
|
536
536
|
* @default 200_000
|
|
537
537
|
*/
|
|
538
|
-
|
|
538
|
+
f(this, "targetTriangleDensity", 2e5);
|
|
539
539
|
/**
|
|
540
540
|
* The update interval in frames. If set to 0, the LODs will be updated every frame. If set to 1, the LODs will be updated every second frame, etc.
|
|
541
541
|
*/
|
|
542
|
-
|
|
542
|
+
f(this, "updateInterval", 0);
|
|
543
543
|
/**
|
|
544
544
|
* If set to true, the LODsManager will not update the LODs.
|
|
545
545
|
*/
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
546
|
+
f(this, "pause", !1);
|
|
547
|
+
f(this, "_lodchangedlisteners", []);
|
|
548
|
+
f(this, "_frame", 0);
|
|
549
|
+
f(this, "_originalRender");
|
|
549
550
|
// private testIfLODLevelsAreAvailable() {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
551
|
+
f(this, "_sphere", new Ce());
|
|
552
|
+
f(this, "_tempBox", new me());
|
|
553
|
+
f(this, "_tempBox2", new me());
|
|
554
|
+
f(this, "tempMatrix", new ye());
|
|
555
|
+
f(this, "_tempWorldPosition", new G());
|
|
556
|
+
f(this, "_tempBoxSize", new G());
|
|
557
|
+
f(this, "_tempBox2Size", new G());
|
|
557
558
|
this.renderer = e, this.context = { ...t };
|
|
558
559
|
}
|
|
559
560
|
/** @internal */
|
|
560
561
|
static getObjectLODState(e) {
|
|
561
|
-
return e[
|
|
562
|
+
return e[ce];
|
|
562
563
|
}
|
|
563
564
|
static addPlugin(e) {
|
|
564
|
-
|
|
565
|
+
z.push(e);
|
|
565
566
|
}
|
|
566
567
|
static removePlugin(e) {
|
|
567
|
-
const t =
|
|
568
|
-
t >= 0 &&
|
|
568
|
+
const t = z.indexOf(e);
|
|
569
|
+
t >= 0 && z.splice(t, 1);
|
|
569
570
|
}
|
|
570
571
|
/**
|
|
571
572
|
* Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
|
|
@@ -573,17 +574,20 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
|
|
|
573
574
|
* @returns The LODsManager instance.
|
|
574
575
|
*/
|
|
575
576
|
static get(e, t) {
|
|
576
|
-
if (e[
|
|
577
|
-
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), e[
|
|
577
|
+
if (e[le])
|
|
578
|
+
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), e[le];
|
|
578
579
|
const r = new P(e, {
|
|
579
580
|
engine: "unknown",
|
|
580
581
|
...t
|
|
581
582
|
});
|
|
582
|
-
return e[
|
|
583
|
+
return e[le] = r, r;
|
|
583
584
|
}
|
|
584
585
|
/** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
|
|
585
586
|
get plugins() {
|
|
586
|
-
return
|
|
587
|
+
return z;
|
|
588
|
+
}
|
|
589
|
+
addEventListener(e, t) {
|
|
590
|
+
e === "changed" && this._lodchangedlisteners.push(t);
|
|
587
591
|
}
|
|
588
592
|
/**
|
|
589
593
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
@@ -595,38 +599,38 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
|
|
|
595
599
|
let e = 0;
|
|
596
600
|
this._originalRender = this.renderer.render;
|
|
597
601
|
const t = this;
|
|
598
|
-
|
|
602
|
+
we(this.renderer), this.renderer.render = function(r, i) {
|
|
599
603
|
t.renderer.getRenderTarget() == null && (e = 0, t._frame += 1);
|
|
600
604
|
const s = t._frame, o = e++;
|
|
601
|
-
t.onBeforeRender(r,
|
|
605
|
+
t.onBeforeRender(r, i, o, s), t._originalRender.call(this, r, i), t.onAfterRender(r, i, o, s);
|
|
602
606
|
};
|
|
603
607
|
}
|
|
604
608
|
disable() {
|
|
605
609
|
this._originalRender && (this.renderer.render = this._originalRender, this._originalRender = void 0);
|
|
606
610
|
}
|
|
607
|
-
onBeforeRender(e, t, r,
|
|
611
|
+
onBeforeRender(e, t, r, i) {
|
|
608
612
|
}
|
|
609
|
-
onAfterRender(e, t, r,
|
|
613
|
+
onAfterRender(e, t, r, i) {
|
|
610
614
|
var a, d;
|
|
611
615
|
if (this.pause)
|
|
612
616
|
return;
|
|
613
|
-
const
|
|
617
|
+
const n = this.renderer.renderLists.get(e, 0), s = n.opaque;
|
|
614
618
|
let o = !0;
|
|
615
619
|
if (s.length === 1) {
|
|
616
620
|
const c = s[0].material;
|
|
617
621
|
(c.name === "EffectMaterial" || c.name === "CopyShader") && (o = !1);
|
|
618
622
|
}
|
|
619
623
|
if ((t.parent && t.parent.type === "CubeCamera" || r >= 1 && t.type === "OrthographicCamera") && (o = !1), o) {
|
|
620
|
-
if (
|
|
624
|
+
if (Ue || this.updateInterval > 0 && i % this.updateInterval != 0)
|
|
621
625
|
return;
|
|
622
626
|
this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this.cameraFrustrum.setFromProjectionMatrix(this.projectionScreenMatrix, this.renderer.coordinateSystem);
|
|
623
627
|
const c = this.targetTriangleDensity;
|
|
624
|
-
for (const
|
|
625
|
-
if (
|
|
626
|
-
|
|
628
|
+
for (const u of s) {
|
|
629
|
+
if (u.material && (((a = u.geometry) == null ? void 0 : a.type) === "BoxGeometry" || ((d = u.geometry) == null ? void 0 : d.type) === "BufferGeometry") && (u.material.name === "SphericalGaussianBlur" || u.material.name == "BackgroundCubeMaterial" || u.material.name === "CubemapFromEquirect" || u.material.name === "EquirectangularToCubeUV")) {
|
|
630
|
+
N && (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)));
|
|
627
631
|
continue;
|
|
628
632
|
}
|
|
629
|
-
switch (
|
|
633
|
+
switch (u.material.type) {
|
|
630
634
|
case "LineBasicMaterial":
|
|
631
635
|
case "LineDashedMaterial":
|
|
632
636
|
case "PointsMaterial":
|
|
@@ -635,34 +639,34 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
|
|
|
635
639
|
case "MeshDepthMaterial":
|
|
636
640
|
continue;
|
|
637
641
|
}
|
|
638
|
-
const y =
|
|
639
|
-
(y instanceof
|
|
642
|
+
const y = u.object;
|
|
643
|
+
(y instanceof W || y.isMesh) && this.updateLODs(e, t, y, c, i);
|
|
640
644
|
}
|
|
641
|
-
const x =
|
|
642
|
-
for (const
|
|
643
|
-
const y =
|
|
644
|
-
(y instanceof
|
|
645
|
+
const x = n.transparent;
|
|
646
|
+
for (const u of x) {
|
|
647
|
+
const y = u.object;
|
|
648
|
+
(y instanceof W || y.isMesh) && this.updateLODs(e, t, y, c, i);
|
|
645
649
|
}
|
|
646
650
|
}
|
|
647
651
|
}
|
|
648
652
|
/** Update the LOD levels for the renderer. */
|
|
649
|
-
updateLODs(e, t, r,
|
|
653
|
+
updateLODs(e, t, r, i, n) {
|
|
650
654
|
var a, d;
|
|
651
655
|
r.userData || (r.userData = {});
|
|
652
|
-
let s = r[
|
|
653
|
-
if (s || (s = new
|
|
656
|
+
let s = r[ce];
|
|
657
|
+
if (s || (s = new Ne(), r[ce] = s), s.frames++ < 2)
|
|
654
658
|
return;
|
|
655
|
-
for (const c of
|
|
659
|
+
for (const c of z)
|
|
656
660
|
(a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, e, t, r);
|
|
657
|
-
this.calculateLodLevel(t, r, s,
|
|
658
|
-
let o =
|
|
661
|
+
this.calculateLodLevel(t, r, s, i, C), C.mesh_lod = Math.round(C.mesh_lod), C.texture_lod = Math.round(C.texture_lod), C.mesh_lod >= 0 && this.loadProgressiveMeshes(r, C.mesh_lod);
|
|
662
|
+
let o = C.texture_lod;
|
|
659
663
|
if (r.material && o >= 0) {
|
|
660
664
|
const c = r["DEBUG:LOD"];
|
|
661
665
|
c != null && (o = c), this.loadProgressiveTextures(r.material, o);
|
|
662
666
|
}
|
|
663
|
-
for (const c of
|
|
664
|
-
(d = c.onAfterUpdatedLOD) == null || d.call(c, this.renderer, e, t, r,
|
|
665
|
-
s.lastLodLevel_Mesh =
|
|
667
|
+
for (const c of z)
|
|
668
|
+
(d = c.onAfterUpdatedLOD) == null || d.call(c, this.renderer, e, t, r, C);
|
|
669
|
+
s.lastLodLevel_Mesh = C.mesh_lod, s.lastLodLevel_Texture = C.texture_lod;
|
|
666
670
|
}
|
|
667
671
|
/** Load progressive textures for the given material
|
|
668
672
|
* @param material the material to load the textures for
|
|
@@ -673,12 +677,14 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
|
|
|
673
677
|
if (!e)
|
|
674
678
|
return;
|
|
675
679
|
if (Array.isArray(e)) {
|
|
676
|
-
for (const
|
|
677
|
-
this.loadProgressiveTextures(
|
|
680
|
+
for (const i of e)
|
|
681
|
+
this.loadProgressiveTextures(i, t);
|
|
678
682
|
return;
|
|
679
683
|
}
|
|
680
684
|
let r = !1;
|
|
681
|
-
(e[
|
|
685
|
+
(e[V] === void 0 || t < e[V]) && (r = !0), r && (e[V] = t, O.assignTextureLOD(e, t).then((i) => {
|
|
686
|
+
this._lodchangedlisteners.forEach((n) => n({ type: "texture", level: t, object: e }));
|
|
687
|
+
}));
|
|
682
688
|
}
|
|
683
689
|
/** Load progressive meshes for the given mesh
|
|
684
690
|
* @param mesh the mesh to load the LOD for
|
|
@@ -689,110 +695,113 @@ const U = Q("debugprogressive"), ze = Q("noprogressive"), ae = Symbol("Needle:LO
|
|
|
689
695
|
loadProgressiveMeshes(e, t) {
|
|
690
696
|
if (!e)
|
|
691
697
|
return Promise.resolve(null);
|
|
692
|
-
if (e[
|
|
693
|
-
e[
|
|
698
|
+
if (e[V] !== t) {
|
|
699
|
+
e[V] = t;
|
|
694
700
|
const r = e.geometry;
|
|
695
|
-
return O.assignMeshLOD(e, t).then((
|
|
701
|
+
return O.assignMeshLOD(e, t).then((i) => (i && e[V] == t && r != e.geometry && this._lodchangedlisteners.forEach((n) => n({ type: "mesh", level: t, object: e })), i));
|
|
696
702
|
}
|
|
697
703
|
return Promise.resolve(null);
|
|
698
704
|
}
|
|
699
705
|
static isInside(e, t) {
|
|
700
|
-
const r = e.min,
|
|
701
|
-
return this._tempPtInside.set(
|
|
706
|
+
const r = e.min, i = e.max, n = (r.x + i.x) * 0.5, s = (r.y + i.y) * 0.5;
|
|
707
|
+
return this._tempPtInside.set(n, s, r.z).applyMatrix4(t).z < 0;
|
|
702
708
|
}
|
|
703
|
-
calculateLodLevel(e, t, r,
|
|
704
|
-
var
|
|
709
|
+
calculateLodLevel(e, t, r, i, n) {
|
|
710
|
+
var B, I;
|
|
705
711
|
if (!t) {
|
|
706
|
-
|
|
712
|
+
n.mesh_lod = -1, n.texture_lod = -1;
|
|
707
713
|
return;
|
|
708
714
|
}
|
|
709
715
|
if (!e) {
|
|
710
|
-
|
|
716
|
+
n.mesh_lod = -1, n.texture_lod = -1;
|
|
711
717
|
return;
|
|
712
718
|
}
|
|
713
719
|
let o = 10 + 1, a = !1;
|
|
714
|
-
if (
|
|
720
|
+
if (N && t["DEBUG:LOD"] != null)
|
|
715
721
|
return t["DEBUG:LOD"];
|
|
716
|
-
const d = O.getMeshLODInformation(t.geometry), c = d == null ? void 0 : d.lods, x = c && c.length > 0,
|
|
722
|
+
const d = O.getMeshLODInformation(t.geometry), c = d == null ? void 0 : d.lods, x = c && c.length > 0, u = O.getMaterialMinMaxLODsCount(t.material), y = (u == null ? void 0 : u.min_count) != 1 / 0 && u.min_count > 0 && u.max_count > 0;
|
|
717
723
|
if (!x && !y) {
|
|
718
|
-
|
|
724
|
+
n.mesh_lod = 0, n.texture_lod = 0;
|
|
719
725
|
return;
|
|
720
726
|
}
|
|
721
|
-
if (x || (a = !0, o = 0), !((
|
|
722
|
-
|
|
727
|
+
if (x || (a = !0, o = 0), !((B = this.cameraFrustrum) != null && B.intersectsObject(t))) {
|
|
728
|
+
n.mesh_lod = 99, n.texture_lod = 99;
|
|
723
729
|
return;
|
|
724
730
|
}
|
|
725
|
-
const
|
|
731
|
+
const w = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
726
732
|
let L = t.geometry.boundingBox;
|
|
727
733
|
if (t.type === "SkinnedMesh") {
|
|
728
|
-
const
|
|
729
|
-
|
|
734
|
+
const p = t;
|
|
735
|
+
p.boundingBox || p.computeBoundingBox(), L = p.boundingBox;
|
|
730
736
|
}
|
|
731
737
|
if (L && e.isPerspectiveCamera) {
|
|
732
|
-
const
|
|
738
|
+
const p = e;
|
|
733
739
|
if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
|
|
734
740
|
this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
|
|
735
|
-
const
|
|
736
|
-
if (this._sphere.containsPoint(
|
|
737
|
-
|
|
741
|
+
const h = e.getWorldPosition(this._tempWorldPosition);
|
|
742
|
+
if (this._sphere.containsPoint(h)) {
|
|
743
|
+
n.mesh_lod = 0, n.texture_lod = 0;
|
|
738
744
|
return;
|
|
739
745
|
}
|
|
740
746
|
}
|
|
741
747
|
if (this._tempBox.copy(L), this._tempBox.applyMatrix4(t.matrixWorld), P.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
742
|
-
|
|
748
|
+
n.mesh_lod = 0, n.texture_lod = 0;
|
|
743
749
|
return;
|
|
744
750
|
}
|
|
745
|
-
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled &&
|
|
746
|
-
const
|
|
747
|
-
let
|
|
748
|
-
const
|
|
749
|
-
|
|
750
|
-
const ve =
|
|
751
|
-
r.lastCentrality = (
|
|
751
|
+
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && p.fov > 70) {
|
|
752
|
+
const h = this._tempBox.min, D = this._tempBox.max;
|
|
753
|
+
let b = h.x, T = h.y, A = D.x, K = D.y;
|
|
754
|
+
const j = 2, ne = 1.5, ee = (h.x + D.x) * 0.5, te = (h.y + D.y) * 0.5;
|
|
755
|
+
b = (b - ee) * j + ee, T = (T - te) * j + te, A = (A - ee) * j + ee, K = (K - te) * j + te;
|
|
756
|
+
const ve = b < 0 && A > 0 ? 0 : Math.min(Math.abs(h.x), Math.abs(D.x)), Oe = T < 0 && K > 0 ? 0 : Math.min(Math.abs(h.y), Math.abs(D.y)), oe = Math.max(ve, Oe);
|
|
757
|
+
r.lastCentrality = (ne - oe) * (ne - oe) * (ne - oe);
|
|
752
758
|
} else
|
|
753
759
|
r.lastCentrality = 1;
|
|
754
|
-
const
|
|
755
|
-
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
const
|
|
759
|
-
if (Math.max(
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
const
|
|
765
|
-
|
|
760
|
+
const M = this._tempBox.getSize(this._tempBoxSize);
|
|
761
|
+
M.multiplyScalar(0.5), screen.availHeight > 0 && w > 0 && M.multiplyScalar(w / screen.availHeight), M.x *= p.aspect;
|
|
762
|
+
const U = e.matrixWorldInverse, k = this._tempBox2;
|
|
763
|
+
k.copy(L), k.applyMatrix4(t.matrixWorld), k.applyMatrix4(U);
|
|
764
|
+
const _ = k.getSize(this._tempBox2Size), $ = Math.max(_.x, _.y);
|
|
765
|
+
if (Math.max(M.x, M.y) != 0 && $ != 0 && (M.z = _.z / Math.max(_.x, _.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, N && P.debugDrawLine) {
|
|
766
|
+
const h = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
767
|
+
h.invert();
|
|
768
|
+
const D = P.corner0, b = P.corner1, T = P.corner2, A = P.corner3;
|
|
769
|
+
D.copy(this._tempBox.min), b.copy(this._tempBox.max), b.x = D.x, T.copy(this._tempBox.max), T.y = D.y, A.copy(this._tempBox.max);
|
|
770
|
+
const K = (D.z + A.z) * 0.5;
|
|
771
|
+
D.z = b.z = T.z = A.z = K, D.applyMatrix4(h), b.applyMatrix4(h), T.applyMatrix4(h), A.applyMatrix4(h), P.debugDrawLine(D, b, 255), P.debugDrawLine(D, T, 255), P.debugDrawLine(b, A, 255), P.debugDrawLine(T, A, 255);
|
|
766
772
|
}
|
|
767
|
-
let
|
|
773
|
+
let S = 999;
|
|
768
774
|
if (c && r.lastScreenCoverage > 0) {
|
|
769
|
-
for (let
|
|
770
|
-
if (c[
|
|
771
|
-
|
|
775
|
+
for (let h = 0; h < c.length; h++)
|
|
776
|
+
if (c[h].density / r.lastScreenCoverage < i) {
|
|
777
|
+
S = h;
|
|
772
778
|
break;
|
|
773
779
|
}
|
|
774
780
|
}
|
|
775
|
-
|
|
781
|
+
S < o && (o = S, a = !0);
|
|
776
782
|
}
|
|
777
|
-
if (a ?
|
|
778
|
-
const
|
|
779
|
-
|
|
783
|
+
if (a ? n.mesh_lod = o : n.mesh_lod = r.lastLodLevel_Mesh, N && n.mesh_lod != r.lastLodLevel_Mesh) {
|
|
784
|
+
const M = c == null ? void 0 : c[n.mesh_lod];
|
|
785
|
+
M && console.log(`Mesh LOD changed: ${r.lastLodLevel_Mesh} → ${n.mesh_lod} (${M.density.toFixed(0)}) - ${t.name}`);
|
|
780
786
|
}
|
|
781
787
|
if (y)
|
|
782
788
|
if (r.lastLodLevel_Texture < 0) {
|
|
783
|
-
if (
|
|
784
|
-
const
|
|
785
|
-
|
|
789
|
+
if (n.texture_lod = u.max_count - 1, N) {
|
|
790
|
+
const p = u.lods[u.max_count - 1];
|
|
791
|
+
N && console.log(`First Texture LOD ${n.texture_lod} (${p.max_height}px) - ${t.name}`);
|
|
786
792
|
}
|
|
787
793
|
} else {
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
794
|
+
const p = r.lastScreenspaceVolume.x + r.lastScreenspaceVolume.y + r.lastScreenspaceVolume.z;
|
|
795
|
+
let M = r.lastScreenCoverage * 2;
|
|
796
|
+
((I = this.context) == null ? void 0 : I.engine) === "model-viewer" && (M *= 2);
|
|
797
|
+
const k = w / window.devicePixelRatio * M;
|
|
798
|
+
for (let _ = u.lods.length - 1; _ >= 0; _--) {
|
|
799
|
+
let $ = u.lods[_];
|
|
800
|
+
if (!(Ge() && $.max_height > 4096) && $.max_height > k) {
|
|
801
|
+
if (n.texture_lod = _, n.texture_lod < r.lastLodLevel_Texture) {
|
|
802
|
+
const R = $.max_height;
|
|
803
|
+
N && console.log(`Texture LOD changed: ${r.lastLodLevel_Texture} → ${n.texture_lod} = ${R}px
|
|
804
|
+
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * r.lastScreenCoverage).toFixed(2)}%, Volume ${p.toFixed(1)}
|
|
796
805
|
${t.name}`);
|
|
797
806
|
}
|
|
798
807
|
break;
|
|
@@ -800,66 +809,74 @@ ${t.name}`);
|
|
|
800
809
|
}
|
|
801
810
|
}
|
|
802
811
|
else
|
|
803
|
-
|
|
812
|
+
n.texture_lod = 0;
|
|
804
813
|
}
|
|
805
814
|
};
|
|
806
815
|
let E = P;
|
|
807
816
|
/** 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.
|
|
808
817
|
*/
|
|
809
|
-
|
|
810
|
-
class
|
|
818
|
+
f(E, "debugDrawLine"), f(E, "corner0", new G()), f(E, "corner1", new G()), f(E, "corner2", new G()), f(E, "corner3", new G()), f(E, "_tempPtInside", new G());
|
|
819
|
+
class Ne {
|
|
811
820
|
constructor() {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
821
|
+
f(this, "frames", 0);
|
|
822
|
+
f(this, "lastLodLevel_Mesh", -1);
|
|
823
|
+
f(this, "lastLodLevel_Texture", -1);
|
|
824
|
+
f(this, "lastScreenCoverage", 0);
|
|
825
|
+
f(this, "lastScreenspaceVolume", new G());
|
|
826
|
+
f(this, "lastCentrality", 0);
|
|
818
827
|
}
|
|
819
828
|
}
|
|
820
|
-
const
|
|
821
|
-
function
|
|
822
|
-
document.removeEventListener("DOMContentLoaded",
|
|
829
|
+
const Le = Symbol("NEEDLE_mesh_lod"), re = Symbol("NEEDLE_texture_lod");
|
|
830
|
+
function Ve() {
|
|
831
|
+
document.removeEventListener("DOMContentLoaded", ue), document.addEventListener("DOMContentLoaded", ue), ue();
|
|
823
832
|
}
|
|
824
|
-
function
|
|
833
|
+
function ue() {
|
|
825
834
|
document.querySelectorAll("model-viewer").forEach((e, t) => {
|
|
826
|
-
|
|
835
|
+
We(e, t);
|
|
827
836
|
});
|
|
828
837
|
}
|
|
829
|
-
const
|
|
830
|
-
function
|
|
831
|
-
if (!l ||
|
|
838
|
+
const Me = /* @__PURE__ */ new WeakSet();
|
|
839
|
+
function We(l, e) {
|
|
840
|
+
if (!l || Me.has(l))
|
|
832
841
|
return null;
|
|
833
|
-
|
|
834
|
-
let t = null, r = null,
|
|
835
|
-
for (let
|
|
836
|
-
const s = Object.getOwnPropertySymbols(
|
|
837
|
-
!t && o != null && (t = l[o].threeRenderer), !r && a != null && (r = l[a]), !
|
|
842
|
+
Me.add(l), console.debug("[gltf-progressive] found model-viewer..." + e);
|
|
843
|
+
let t = null, r = null, i = null;
|
|
844
|
+
for (let n = l; n != null; n = Object.getPrototypeOf(n)) {
|
|
845
|
+
const s = Object.getOwnPropertySymbols(n), o = s.find((c) => c.toString() == "Symbol(renderer)"), a = s.find((c) => c.toString() == "Symbol(scene)"), d = s.find((c) => c.toString() == "Symbol(needsRender)");
|
|
846
|
+
!t && o != null && (t = l[o].threeRenderer), !r && a != null && (r = l[a]), !i && d != null && (i = l[d]);
|
|
838
847
|
}
|
|
839
848
|
if (t && r) {
|
|
849
|
+
let n = function() {
|
|
850
|
+
if (i) {
|
|
851
|
+
let o = 0, a = setInterval(() => {
|
|
852
|
+
if (o++ > 5) {
|
|
853
|
+
clearInterval(a);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
i == null || i.call(l);
|
|
857
|
+
}, 300);
|
|
858
|
+
}
|
|
859
|
+
};
|
|
840
860
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
}
|
|
851
|
-
return () => {
|
|
852
|
-
i.disable();
|
|
861
|
+
const s = E.get(t, { engine: "model-viewer" });
|
|
862
|
+
return E.addPlugin(new Ke()), s.enable(), s.addEventListener("changed", () => {
|
|
863
|
+
i == null || i.call(l);
|
|
864
|
+
}), l.addEventListener("model-visibility", (o) => {
|
|
865
|
+
o.detail.visible && (i == null || i.call(l));
|
|
866
|
+
}), l.addEventListener("load", () => {
|
|
867
|
+
n();
|
|
868
|
+
}), () => {
|
|
869
|
+
s.disable();
|
|
853
870
|
};
|
|
854
871
|
}
|
|
855
872
|
return null;
|
|
856
873
|
}
|
|
857
|
-
class
|
|
874
|
+
class Ke {
|
|
858
875
|
constructor() {
|
|
859
|
-
|
|
876
|
+
f(this, "_didWarnAboutMissingUrl", !1);
|
|
860
877
|
}
|
|
861
|
-
onBeforeUpdateLOD(e, t, r,
|
|
862
|
-
this.tryParseMeshLOD(t,
|
|
878
|
+
onBeforeUpdateLOD(e, t, r, i) {
|
|
879
|
+
this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
|
|
863
880
|
}
|
|
864
881
|
getUrl(e) {
|
|
865
882
|
if (!e)
|
|
@@ -874,31 +891,31 @@ class We {
|
|
|
874
891
|
return e.element;
|
|
875
892
|
}
|
|
876
893
|
tryParseTextureLOD(e, t) {
|
|
877
|
-
if (t[
|
|
894
|
+
if (t[re] == !0)
|
|
878
895
|
return;
|
|
879
|
-
t[
|
|
880
|
-
const r = this.tryGetCurrentGLTF(e),
|
|
881
|
-
if (
|
|
896
|
+
t[re] = !0;
|
|
897
|
+
const r = this.tryGetCurrentGLTF(e), i = this.tryGetCurrentModelViewer(e), n = this.getUrl(i);
|
|
898
|
+
if (n && r && t.material) {
|
|
882
899
|
let s = function(a) {
|
|
883
|
-
var c, x,
|
|
884
|
-
if (a[
|
|
900
|
+
var c, x, u;
|
|
901
|
+
if (a[re] == !0)
|
|
885
902
|
return;
|
|
886
|
-
a[
|
|
903
|
+
a[re] = !0, a.userData && (a.userData.LOD = -1);
|
|
887
904
|
const d = Object.keys(a);
|
|
888
905
|
for (let y = 0; y < d.length; y++) {
|
|
889
|
-
const
|
|
906
|
+
const w = d[y], L = a[w];
|
|
890
907
|
if ((L == null ? void 0 : L.isTexture) === !0) {
|
|
891
|
-
const
|
|
892
|
-
if (
|
|
908
|
+
const B = (x = (c = L.userData) == null ? void 0 : c.associations) == null ? void 0 : x.textures;
|
|
909
|
+
if (B == null)
|
|
893
910
|
continue;
|
|
894
|
-
const
|
|
895
|
-
if (!
|
|
896
|
-
console.warn("Texture data not found for texture index " +
|
|
911
|
+
const I = r.parser.json.textures[B];
|
|
912
|
+
if (!I) {
|
|
913
|
+
console.warn("Texture data not found for texture index " + B);
|
|
897
914
|
continue;
|
|
898
915
|
}
|
|
899
|
-
if ((
|
|
900
|
-
const
|
|
901
|
-
|
|
916
|
+
if ((u = I == null ? void 0 : I.extensions) != null && u[F]) {
|
|
917
|
+
const p = I.extensions[F];
|
|
918
|
+
p && n && O.registerTexture(n, L, p.lods.length, B, p);
|
|
902
919
|
}
|
|
903
920
|
}
|
|
904
921
|
}
|
|
@@ -913,37 +930,37 @@ class We {
|
|
|
913
930
|
}
|
|
914
931
|
tryParseMeshLOD(e, t) {
|
|
915
932
|
var s, o;
|
|
916
|
-
if (t[
|
|
933
|
+
if (t[Le] == !0)
|
|
917
934
|
return;
|
|
918
|
-
t[
|
|
919
|
-
const r = this.tryGetCurrentModelViewer(e),
|
|
920
|
-
if (!
|
|
935
|
+
t[Le] = !0;
|
|
936
|
+
const r = this.tryGetCurrentModelViewer(e), i = this.getUrl(r);
|
|
937
|
+
if (!i)
|
|
921
938
|
return;
|
|
922
|
-
const
|
|
923
|
-
if (
|
|
939
|
+
const n = (o = (s = t.userData) == null ? void 0 : s.gltfExtensions) == null ? void 0 : o[F];
|
|
940
|
+
if (n && i) {
|
|
924
941
|
const a = t.uuid;
|
|
925
|
-
O.registerMesh(
|
|
942
|
+
O.registerMesh(i, a, t, 0, n.lods.length, n);
|
|
926
943
|
}
|
|
927
944
|
}
|
|
928
945
|
}
|
|
929
|
-
|
|
930
|
-
function
|
|
931
|
-
|
|
932
|
-
const
|
|
933
|
-
return (r == null ? void 0 : r.enableLODsManager) !== !1 &&
|
|
946
|
+
Ve();
|
|
947
|
+
function tt(l, e, t, r) {
|
|
948
|
+
we(e), _e(t), t.register((n) => new O(n, l));
|
|
949
|
+
const i = E.get(e);
|
|
950
|
+
return (r == null ? void 0 : r.enableLODsManager) !== !1 && i.enable(), i;
|
|
934
951
|
}
|
|
935
952
|
export {
|
|
936
|
-
|
|
953
|
+
F as EXTENSION_NAME,
|
|
937
954
|
E as LODsManager,
|
|
938
955
|
O as NEEDLE_progressive,
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
956
|
+
De as VERSION,
|
|
957
|
+
_e as addDracoAndKTX2Loaders,
|
|
958
|
+
we as createLoaders,
|
|
959
|
+
pe as getRaycastMesh,
|
|
960
|
+
Ve as patchModelViewer,
|
|
961
|
+
Ze as setDracoDecoderLocation,
|
|
962
|
+
je as setKTX2TranscoderLocation,
|
|
963
|
+
Fe as setRaycastMesh,
|
|
964
|
+
tt as useNeedleProgressive,
|
|
965
|
+
et as useRaycastMeshes
|
|
949
966
|
};
|