@needle-tools/gltf-progressive 2.1.0-experimental.3 → 2.1.0
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 +16 -0
- package/gltf-progressive.js +305 -306
- package/gltf-progressive.min.js +7 -7
- package/gltf-progressive.umd.cjs +6 -6
- package/lib/extension.js +12 -10
- package/lib/lods_manager.js +25 -9
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/gltf-progressive.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
var We = Object.defineProperty;
|
|
2
|
-
var qe = (
|
|
3
|
-
var d = (
|
|
4
|
-
if (!e.has(
|
|
2
|
+
var qe = (n, e, t) => e in n ? We(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var d = (n, e, t) => (qe(n, typeof e != "symbol" ? e + "" : e, t), t), Te = (n, e, t) => {
|
|
4
|
+
if (!e.has(n))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var m = (
|
|
8
|
-
if (e.has(
|
|
7
|
+
var m = (n, e, t) => (Te(n, e, "read from private field"), t ? t.call(n) : e.get(n)), K = (n, e, t) => {
|
|
8
|
+
if (e.has(n))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
e instanceof WeakSet ? e.add(
|
|
11
|
-
}, U = (
|
|
12
|
-
import { BufferGeometry as ge, Mesh as
|
|
10
|
+
e instanceof WeakSet ? e.add(n) : e.set(n, t);
|
|
11
|
+
}, U = (n, e, t, s) => (Te(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
|
|
12
|
+
import { BufferGeometry as ge, Mesh as Z, Texture as se, TextureLoader as Xe, Matrix4 as Ae, Clock as Ke, MeshStandardMaterial as Ye, Sphere as He, Box3 as Ee, Vector3 as z } from "three";
|
|
13
13
|
import { GLTFLoader as be } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
14
|
-
import { MeshoptDecoder as
|
|
15
|
-
import { DRACOLoader as
|
|
16
|
-
import { KTX2Loader as
|
|
14
|
+
import { MeshoptDecoder as Je } from "three/examples/jsm/libs/meshopt_decoder.module.js";
|
|
15
|
+
import { DRACOLoader as Qe } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
16
|
+
import { KTX2Loader as Ze } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
17
17
|
const ke = "";
|
|
18
18
|
globalThis.GLTF_PROGRESSIVE_VERSION = ke;
|
|
19
19
|
console.debug(`[gltf-progressive] version ${ke}`);
|
|
20
20
|
let te = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", ae = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
|
|
21
|
-
const
|
|
22
|
-
fetch(
|
|
21
|
+
const je = te, et = ae, tt = new URL(te + "draco_decoder.js");
|
|
22
|
+
fetch(tt, {
|
|
23
23
|
method: "GET",
|
|
24
24
|
headers: {
|
|
25
25
|
Range: "bytes=0-1"
|
|
26
26
|
}
|
|
27
|
-
}).catch((
|
|
28
|
-
te ===
|
|
27
|
+
}).catch((n) => {
|
|
28
|
+
te === je && (te = "./include/draco/"), ae === et && (ae = "./include/ktx2/");
|
|
29
29
|
}).finally(() => {
|
|
30
30
|
Ie();
|
|
31
31
|
});
|
|
32
|
-
function
|
|
33
|
-
te =
|
|
32
|
+
function wt(n) {
|
|
33
|
+
te = n;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
ae =
|
|
35
|
+
function vt(n) {
|
|
36
|
+
ae = n;
|
|
37
37
|
}
|
|
38
|
-
let
|
|
38
|
+
let J, pe, Q;
|
|
39
39
|
function Ie() {
|
|
40
|
-
|
|
40
|
+
J || (J = new Qe(), J.setDecoderPath(te), J.setDecoderConfig({ type: "js" }), J.preload()), Q || (Q = new Ze(), Q.setTranscoderPath(ae), Q.init()), pe || (pe = Je);
|
|
41
41
|
}
|
|
42
|
-
function Ge(
|
|
43
|
-
return Ie(),
|
|
42
|
+
function Ge(n) {
|
|
43
|
+
return Ie(), n ? Q.detectSupport(n) : n !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: J, ktx2Loader: Q, meshoptDecoder: pe };
|
|
44
44
|
}
|
|
45
|
-
function $e(
|
|
46
|
-
|
|
45
|
+
function $e(n) {
|
|
46
|
+
n.dracoLoader || n.setDRACOLoader(J), n.ktx2Loader || n.setKTX2Loader(Q), n.meshoptDecoder || n.setMeshoptDecoder(pe);
|
|
47
47
|
}
|
|
48
48
|
const Oe = /* @__PURE__ */ new WeakMap();
|
|
49
|
-
function Fe(
|
|
50
|
-
let t = Oe.get(
|
|
51
|
-
t ? t = Object.assign(t, e) : t = e, Oe.set(
|
|
49
|
+
function Fe(n, e) {
|
|
50
|
+
let t = Oe.get(n);
|
|
51
|
+
t ? t = Object.assign(t, e) : t = e, Oe.set(n, t);
|
|
52
52
|
}
|
|
53
53
|
const Me = be.prototype.load;
|
|
54
|
-
function
|
|
54
|
+
function st(...n) {
|
|
55
55
|
const e = Oe.get(this);
|
|
56
|
-
let t =
|
|
56
|
+
let t = n[0];
|
|
57
57
|
const s = new URL(t, window.location.href);
|
|
58
58
|
if (s.hostname.endsWith("needle.tools")) {
|
|
59
59
|
const r = (e == null ? void 0 : e.progressive) !== void 0 ? e.progressive : !0, i = e != null && e.usecase ? e.usecase : "default";
|
|
60
60
|
r ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${i}` : this.requestHeader.Accept = `*/*;usecase=${i}`, t = s.toString();
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return n[0] = t, Me == null ? void 0 : Me.call(this, ...n);
|
|
63
63
|
}
|
|
64
|
-
be.prototype.load =
|
|
64
|
+
be.prototype.load = st;
|
|
65
65
|
le("debugprogressive");
|
|
66
|
-
function le(
|
|
66
|
+
function le(n) {
|
|
67
67
|
if (typeof window > "u")
|
|
68
68
|
return !1;
|
|
69
|
-
const t = new URL(window.location.href).searchParams.get(
|
|
69
|
+
const t = new URL(window.location.href).searchParams.get(n);
|
|
70
70
|
return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
if (e === void 0 || e.startsWith("./") || e.startsWith("http") ||
|
|
72
|
+
function rt(n, e) {
|
|
73
|
+
if (e === void 0 || e.startsWith("./") || e.startsWith("http") || n === void 0)
|
|
74
74
|
return e;
|
|
75
|
-
const t =
|
|
75
|
+
const t = n.lastIndexOf("/");
|
|
76
76
|
if (t >= 0) {
|
|
77
|
-
const s =
|
|
77
|
+
const s = n.substring(0, t + 1);
|
|
78
78
|
for (; s.endsWith("/") && e.startsWith("/"); )
|
|
79
79
|
e = e.substring(1);
|
|
80
80
|
return s + e;
|
|
@@ -82,73 +82,70 @@ function it(o, e) {
|
|
|
82
82
|
return e;
|
|
83
83
|
}
|
|
84
84
|
let re;
|
|
85
|
-
function
|
|
85
|
+
function it() {
|
|
86
86
|
return re !== void 0 || (re = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), le("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", re)), re;
|
|
87
87
|
}
|
|
88
88
|
const ot = typeof window > "u" && typeof document > "u", _e = Symbol("needle:raycast-mesh");
|
|
89
|
-
function ce(
|
|
90
|
-
return (
|
|
89
|
+
function ce(n) {
|
|
90
|
+
return (n == null ? void 0 : n[_e]) instanceof ge ? n[_e] : null;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
if ((
|
|
94
|
-
const s =
|
|
95
|
-
s.userData = { isRaycastMesh: !0 },
|
|
92
|
+
function nt(n, e) {
|
|
93
|
+
if ((n.type === "Mesh" || n.type === "SkinnedMesh") && !ce(n)) {
|
|
94
|
+
const s = lt(e);
|
|
95
|
+
s.userData = { isRaycastMesh: !0 }, n[_e] = s;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
if (
|
|
98
|
+
function at(n = !0) {
|
|
99
|
+
if (n) {
|
|
100
100
|
if (ie)
|
|
101
101
|
return;
|
|
102
|
-
const e = ie =
|
|
103
|
-
|
|
104
|
-
const
|
|
102
|
+
const e = ie = Z.prototype.raycast;
|
|
103
|
+
Z.prototype.raycast = function(t, s) {
|
|
104
|
+
const o = this, r = ce(o);
|
|
105
105
|
let i;
|
|
106
|
-
r &&
|
|
106
|
+
r && o.isMesh && (i = o.geometry, o.geometry = r), e.call(this, t, s), i && (o.geometry = i);
|
|
107
107
|
};
|
|
108
108
|
} else {
|
|
109
109
|
if (!ie)
|
|
110
110
|
return;
|
|
111
|
-
|
|
111
|
+
Z.prototype.raycast = ie, ie = null;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
let ie = null;
|
|
115
|
-
function
|
|
115
|
+
function lt(n) {
|
|
116
116
|
const e = new ge();
|
|
117
|
-
for (const t in
|
|
118
|
-
e.setAttribute(t,
|
|
119
|
-
return e.setIndex(
|
|
117
|
+
for (const t in n.attributes)
|
|
118
|
+
e.setAttribute(t, n.getAttribute(t));
|
|
119
|
+
return e.setIndex(n.getIndex()), e;
|
|
120
120
|
}
|
|
121
|
-
const
|
|
121
|
+
const H = new Array(), V = "NEEDLE_progressive", L = le("debugprogressive"), De = Symbol("needle-progressive-texture"), ne = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Set();
|
|
122
122
|
if (L) {
|
|
123
|
-
let
|
|
124
|
-
e += 1, console.log("Toggle LOD level", e,
|
|
125
|
-
for (const i of
|
|
123
|
+
let n = function() {
|
|
124
|
+
e += 1, console.log("Toggle LOD level", e, ne), ne.forEach((o, r) => {
|
|
125
|
+
for (const i of o.keys) {
|
|
126
126
|
const a = r[i];
|
|
127
|
-
if (a != null)
|
|
127
|
+
if (a != null)
|
|
128
128
|
if (a.isBufferGeometry === !0) {
|
|
129
|
-
const l =
|
|
130
|
-
r["DEBUG:LOD"] =
|
|
131
|
-
} else
|
|
132
|
-
r["DEBUG:LOD"] = e
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
129
|
+
const l = T.getMeshLODInformation(a), u = l ? Math.min(e, l.lods.length) : 0;
|
|
130
|
+
r["DEBUG:LOD"] = u, l && (t = Math.max(t, l.lods.length - 1));
|
|
131
|
+
} else
|
|
132
|
+
r.isMaterial === !0 && (r["DEBUG:LOD"] = e);
|
|
136
133
|
}
|
|
137
134
|
}), e >= t && (e = -1);
|
|
138
135
|
}, e = -1, t = 2, s = !1;
|
|
139
|
-
window.addEventListener("keyup", (
|
|
140
|
-
|
|
136
|
+
window.addEventListener("keyup", (o) => {
|
|
137
|
+
o.key === "p" && n(), o.key === "w" && (s = !s, Se && Se.forEach((r) => {
|
|
141
138
|
r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = s);
|
|
142
139
|
}));
|
|
143
140
|
});
|
|
144
141
|
}
|
|
145
|
-
function Pe(
|
|
146
|
-
var
|
|
142
|
+
function Pe(n, e, t) {
|
|
143
|
+
var o;
|
|
147
144
|
if (!L)
|
|
148
145
|
return;
|
|
149
|
-
|
|
150
|
-
const s =
|
|
151
|
-
((
|
|
146
|
+
ne.has(n) || ne.set(n, { keys: [], sourceId: t });
|
|
147
|
+
const s = ne.get(n);
|
|
148
|
+
((o = s == null ? void 0 : s.keys) == null ? void 0 : o.includes(e)) == !1 && s.keys.push(e);
|
|
152
149
|
}
|
|
153
150
|
const v = class {
|
|
154
151
|
constructor(e, t) {
|
|
@@ -156,10 +153,10 @@ const v = class {
|
|
|
156
153
|
d(this, "url");
|
|
157
154
|
d(this, "_isLoadingMesh");
|
|
158
155
|
d(this, "loadMesh", (e) => {
|
|
159
|
-
var s,
|
|
156
|
+
var s, o;
|
|
160
157
|
if (this._isLoadingMesh)
|
|
161
158
|
return null;
|
|
162
|
-
const t = (
|
|
159
|
+
const t = (o = (s = this.parser.json.meshes[e]) == null ? void 0 : s.extensions) == null ? void 0 : o[V];
|
|
163
160
|
return t ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", e).then((r) => {
|
|
164
161
|
var i;
|
|
165
162
|
return this._isLoadingMesh = !1, r && v.registerMesh(this.url, t.guid, r, (i = t.lods) == null ? void 0 : i.length, void 0, t), r;
|
|
@@ -169,14 +166,14 @@ const v = class {
|
|
|
169
166
|
}
|
|
170
167
|
/** The name of the extension */
|
|
171
168
|
get name() {
|
|
172
|
-
return
|
|
169
|
+
return V;
|
|
173
170
|
}
|
|
174
171
|
static getMeshLODInformation(e) {
|
|
175
172
|
const t = this.getAssignedLODInformation(e);
|
|
176
173
|
return t != null && t.key ? this.lodInfos.get(t.key) : null;
|
|
177
174
|
}
|
|
178
175
|
static getMaterialMinMaxLODsCount(e, t) {
|
|
179
|
-
const s = this,
|
|
176
|
+
const s = this, o = "LODS:minmax", r = e[o];
|
|
180
177
|
if (r != null)
|
|
181
178
|
return r;
|
|
182
179
|
if (t || (t = {
|
|
@@ -186,7 +183,7 @@ const v = class {
|
|
|
186
183
|
}), Array.isArray(e)) {
|
|
187
184
|
for (const a of e)
|
|
188
185
|
this.getMaterialMinMaxLODsCount(a, t);
|
|
189
|
-
return e[
|
|
186
|
+
return e[o] = t, t;
|
|
190
187
|
}
|
|
191
188
|
if (L === "verbose" && console.log("getMaterialMinMaxLODsCount", e), e.type === "ShaderMaterial" || e.type === "RawShaderMaterial") {
|
|
192
189
|
const a = e;
|
|
@@ -199,7 +196,7 @@ const v = class {
|
|
|
199
196
|
const l = e[a];
|
|
200
197
|
(l == null ? void 0 : l.isTexture) === !0 && i(l, t);
|
|
201
198
|
}
|
|
202
|
-
return e[
|
|
199
|
+
return e[o] = t, t;
|
|
203
200
|
function i(a, l) {
|
|
204
201
|
const u = s.getAssignedLODInformation(a);
|
|
205
202
|
if (u) {
|
|
@@ -239,13 +236,13 @@ const v = class {
|
|
|
239
236
|
if (i.isMesh === !0 && this.hasLODLevelAvailable(i, t))
|
|
240
237
|
return !0;
|
|
241
238
|
}
|
|
242
|
-
let s,
|
|
239
|
+
let s, o;
|
|
243
240
|
if (e.isMesh ? s = e.geometry : (e.isBufferGeometry || e.isTexture) && (s = e), s && (r = s == null ? void 0 : s.userData) != null && r.LODS) {
|
|
244
241
|
const i = s.userData.LODS;
|
|
245
|
-
if (
|
|
246
|
-
return
|
|
247
|
-
if (
|
|
248
|
-
return Array.isArray(
|
|
242
|
+
if (o = this.lodInfos.get(i.key), t === void 0)
|
|
243
|
+
return o != null;
|
|
244
|
+
if (o)
|
|
245
|
+
return Array.isArray(o.lods) ? t < o.lods.length : t === 0;
|
|
249
246
|
}
|
|
250
247
|
return !1;
|
|
251
248
|
}
|
|
@@ -267,18 +264,18 @@ const v = class {
|
|
|
267
264
|
var s;
|
|
268
265
|
if (!e)
|
|
269
266
|
return Promise.resolve(null);
|
|
270
|
-
if (e instanceof
|
|
271
|
-
const
|
|
267
|
+
if (e instanceof Z || e.isMesh === !0) {
|
|
268
|
+
const o = e.geometry, r = this.getAssignedLODInformation(o);
|
|
272
269
|
if (!r)
|
|
273
270
|
return Promise.resolve(null);
|
|
274
|
-
for (const i of
|
|
271
|
+
for (const i of H)
|
|
275
272
|
(s = i.onBeforeGetLODMesh) == null || s.call(i, e, t);
|
|
276
|
-
return e["LOD:requested level"] = t, v.getOrLoadLOD(
|
|
273
|
+
return e["LOD:requested level"] = t, v.getOrLoadLOD(o, t).then((i) => {
|
|
277
274
|
if (Array.isArray(i)) {
|
|
278
275
|
const a = r.index || 0;
|
|
279
276
|
i = i[a];
|
|
280
277
|
}
|
|
281
|
-
return e["LOD:requested level"] === t && (delete e["LOD:requested level"], i &&
|
|
278
|
+
return e["LOD:requested level"] === t && (delete e["LOD:requested level"], i && o != i && ((i == null ? void 0 : i.isBufferGeometry) ? (e.geometry = i, L && Pe(e, "geometry", r.url)) : L && console.error("Invalid LOD geometry", i))), i;
|
|
282
279
|
}).catch((i) => (console.error("Error loading mesh LOD", e, i), null));
|
|
283
280
|
} else
|
|
284
281
|
L && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", e);
|
|
@@ -290,12 +287,12 @@ const v = class {
|
|
|
290
287
|
if (e.isMesh === !0) {
|
|
291
288
|
const s = e;
|
|
292
289
|
if (Array.isArray(s.material)) {
|
|
293
|
-
const
|
|
290
|
+
const o = new Array();
|
|
294
291
|
for (const r of s.material) {
|
|
295
292
|
const i = this.assignTextureLOD(r, t);
|
|
296
|
-
|
|
293
|
+
o.push(i);
|
|
297
294
|
}
|
|
298
|
-
return Promise.all(
|
|
295
|
+
return Promise.all(o).then((r) => {
|
|
299
296
|
const i = new Array();
|
|
300
297
|
for (const a of r)
|
|
301
298
|
Array.isArray(a) && i.push(...a);
|
|
@@ -304,15 +301,15 @@ const v = class {
|
|
|
304
301
|
} else
|
|
305
302
|
return this.assignTextureLOD(s.material, t);
|
|
306
303
|
}
|
|
307
|
-
if (e
|
|
308
|
-
const s = e,
|
|
304
|
+
if (e.isMaterial === !0) {
|
|
305
|
+
const s = e, o = [], r = new Array();
|
|
309
306
|
if (L && Se.add(s), s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
310
307
|
const i = s;
|
|
311
308
|
for (const a of Object.keys(i.uniforms)) {
|
|
312
309
|
const l = i.uniforms[a].value;
|
|
313
310
|
if ((l == null ? void 0 : l.isTexture) === !0) {
|
|
314
311
|
const u = this.assignTextureLODForSlot(l, t, s, a).then((c) => (c && i.uniforms[a].value != c && (i.uniforms[a].value = c, i.uniformsNeedUpdate = !0), c));
|
|
315
|
-
|
|
312
|
+
o.push(u), r.push(a);
|
|
316
313
|
}
|
|
317
314
|
}
|
|
318
315
|
} else
|
|
@@ -320,10 +317,10 @@ const v = class {
|
|
|
320
317
|
const a = s[i];
|
|
321
318
|
if ((a == null ? void 0 : a.isTexture) === !0) {
|
|
322
319
|
const l = this.assignTextureLODForSlot(a, t, s, i);
|
|
323
|
-
|
|
320
|
+
o.push(l), r.push(i);
|
|
324
321
|
}
|
|
325
322
|
}
|
|
326
|
-
return Promise.all(
|
|
323
|
+
return Promise.all(o).then((i) => {
|
|
327
324
|
const a = new Array();
|
|
328
325
|
for (let l = 0; l < i.length; l++) {
|
|
329
326
|
const u = i[l], c = r[l];
|
|
@@ -338,24 +335,24 @@ const v = class {
|
|
|
338
335
|
}
|
|
339
336
|
return Promise.resolve(null);
|
|
340
337
|
}
|
|
341
|
-
static assignTextureLODForSlot(e, t, s,
|
|
342
|
-
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) :
|
|
338
|
+
static assignTextureLODForSlot(e, t, s, o) {
|
|
339
|
+
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : o === "glyphMap" ? Promise.resolve(e) : v.getOrLoadLOD(e, t).then((r) => {
|
|
343
340
|
if (Array.isArray(r))
|
|
344
341
|
return null;
|
|
345
342
|
if ((r == null ? void 0 : r.isTexture) === !0) {
|
|
346
343
|
if (r != e) {
|
|
347
|
-
if (s &&
|
|
348
|
-
const i = s[
|
|
349
|
-
if (i) {
|
|
344
|
+
if (s && o) {
|
|
345
|
+
const i = s[o];
|
|
346
|
+
if (i && !L) {
|
|
350
347
|
const a = this.getAssignedLODInformation(i);
|
|
351
348
|
if (a && (a == null ? void 0 : a.level) < t)
|
|
352
349
|
return L === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, t, s, i, r), null;
|
|
353
350
|
}
|
|
354
|
-
s[
|
|
351
|
+
s[o] = r;
|
|
355
352
|
}
|
|
356
|
-
if (L &&
|
|
353
|
+
if (L && o && s) {
|
|
357
354
|
const i = this.getAssignedLODInformation(e);
|
|
358
|
-
i
|
|
355
|
+
i ? Pe(s, o, i.url) : console.warn("No LOD info for texture", e);
|
|
359
356
|
}
|
|
360
357
|
}
|
|
361
358
|
return r;
|
|
@@ -366,10 +363,10 @@ const v = class {
|
|
|
366
363
|
}
|
|
367
364
|
afterRoot(e) {
|
|
368
365
|
var t, s;
|
|
369
|
-
return L && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((
|
|
366
|
+
return L && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((o, r) => {
|
|
370
367
|
var i;
|
|
371
|
-
if (
|
|
372
|
-
const a =
|
|
368
|
+
if (o != null && o.extensions) {
|
|
369
|
+
const a = o == null ? void 0 : o.extensions[V];
|
|
373
370
|
if (a) {
|
|
374
371
|
if (!a.lods) {
|
|
375
372
|
L && console.warn("Texture has no LODs", a);
|
|
@@ -387,9 +384,9 @@ const v = class {
|
|
|
387
384
|
});
|
|
388
385
|
}
|
|
389
386
|
}
|
|
390
|
-
}), (s = this.parser.json.meshes) == null || s.forEach((
|
|
391
|
-
if (
|
|
392
|
-
const i =
|
|
387
|
+
}), (s = this.parser.json.meshes) == null || s.forEach((o, r) => {
|
|
388
|
+
if (o != null && o.extensions) {
|
|
389
|
+
const i = o == null ? void 0 : o.extensions[V];
|
|
393
390
|
if (i && i.lods) {
|
|
394
391
|
for (const a of this.parser.associations.keys())
|
|
395
392
|
if (a.isMesh) {
|
|
@@ -402,10 +399,10 @@ const v = class {
|
|
|
402
399
|
}
|
|
403
400
|
static async getOrLoadLOD(e, t) {
|
|
404
401
|
var a, l, u, c;
|
|
405
|
-
const s = L == "verbose",
|
|
406
|
-
if (!
|
|
402
|
+
const s = L == "verbose", o = e.userData.LODS;
|
|
403
|
+
if (!o)
|
|
407
404
|
return null;
|
|
408
|
-
const r =
|
|
405
|
+
const r = o == null ? void 0 : o.key;
|
|
409
406
|
let i;
|
|
410
407
|
if (e.isTexture === !0) {
|
|
411
408
|
const g = e;
|
|
@@ -413,107 +410,107 @@ const v = class {
|
|
|
413
410
|
}
|
|
414
411
|
if (i || (i = v.lodInfos.get(r)), i) {
|
|
415
412
|
if (t > 0) {
|
|
416
|
-
let
|
|
413
|
+
let D = !1;
|
|
417
414
|
const w = Array.isArray(i.lods);
|
|
418
|
-
if (w && t >= i.lods.length ?
|
|
415
|
+
if (w && t >= i.lods.length ? D = !0 : w || (D = !0), D)
|
|
419
416
|
return this.lowresCache.get(r);
|
|
420
417
|
}
|
|
421
418
|
const g = Array.isArray(i.lods) ? (a = i.lods[t]) == null ? void 0 : a.path : i.lods;
|
|
422
419
|
if (!g)
|
|
423
420
|
return L && !i["missing:uri"] && (i["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, i)), null;
|
|
424
|
-
const p =
|
|
421
|
+
const p = rt(o.url, g);
|
|
425
422
|
if (p.endsWith(".glb") || p.endsWith(".gltf")) {
|
|
426
423
|
if (!i.guid)
|
|
427
424
|
return console.warn("missing pointer for glb/gltf texture", i), null;
|
|
428
|
-
const
|
|
425
|
+
const D = p + "_" + i.guid, w = this.previouslyLoaded.get(D);
|
|
429
426
|
if (w !== void 0) {
|
|
430
|
-
s && console.log(`LOD ${t} was already loading/loaded: ${
|
|
427
|
+
s && console.log(`LOD ${t} was already loading/loaded: ${D}`);
|
|
431
428
|
let h = await w.catch((F) => (console.error(`Error loading LOD ${t} from ${p}
|
|
432
429
|
`, F), null)), R = !1;
|
|
433
|
-
if (h == null || (h instanceof se && e instanceof se ? (l = h.image) != null && l.data || (u = h.source) != null && u.data ? h = this.copySettings(e, h) : (R = !0, this.previouslyLoaded.delete(
|
|
430
|
+
if (h == null || (h instanceof se && e instanceof se ? (l = h.image) != null && l.data || (u = h.source) != null && u.data ? h = this.copySettings(e, h) : (R = !0, this.previouslyLoaded.delete(D)) : h instanceof ge && e instanceof ge && ((c = h.attributes.position) != null && c.array || (R = !0, this.previouslyLoaded.delete(D)))), !R)
|
|
434
431
|
return h;
|
|
435
432
|
}
|
|
436
433
|
const x = i, $ = new Promise(async (h, R) => {
|
|
437
434
|
const F = new be();
|
|
438
|
-
$e(F), L && (await new Promise((
|
|
435
|
+
$e(F), L && (await new Promise((S) => setTimeout(S, 1e3)), s && console.warn("Start loading (delayed) " + p, x.guid));
|
|
439
436
|
let k = p;
|
|
440
437
|
if (x && Array.isArray(x.lods)) {
|
|
441
|
-
const
|
|
442
|
-
|
|
438
|
+
const S = x.lods[t];
|
|
439
|
+
S.hash && (k += "?v=" + S.hash);
|
|
443
440
|
}
|
|
444
|
-
const
|
|
445
|
-
`,
|
|
446
|
-
if (!
|
|
441
|
+
const A = await F.loadAsync(k).catch((S) => (console.error(`Error loading LOD ${t} from ${p}
|
|
442
|
+
`, S), null));
|
|
443
|
+
if (!A)
|
|
447
444
|
return null;
|
|
448
|
-
const
|
|
445
|
+
const N = A.parser;
|
|
449
446
|
s && console.log("Loading finished " + p, x.guid);
|
|
450
|
-
let
|
|
451
|
-
if (
|
|
452
|
-
let
|
|
453
|
-
for (const f of
|
|
447
|
+
let _ = 0;
|
|
448
|
+
if (A.parser.json.textures) {
|
|
449
|
+
let S = !1;
|
|
450
|
+
for (const f of A.parser.json.textures) {
|
|
454
451
|
if (f != null && f.extensions) {
|
|
455
|
-
const y = f == null ? void 0 : f.extensions[
|
|
452
|
+
const y = f == null ? void 0 : f.extensions[V];
|
|
456
453
|
if (y != null && y.guid && y.guid === x.guid) {
|
|
457
|
-
|
|
454
|
+
S = !0;
|
|
458
455
|
break;
|
|
459
456
|
}
|
|
460
457
|
}
|
|
461
|
-
|
|
458
|
+
_++;
|
|
462
459
|
}
|
|
463
|
-
if (
|
|
464
|
-
let f = await
|
|
465
|
-
return f && v.assignLODInformation(
|
|
460
|
+
if (S) {
|
|
461
|
+
let f = await N.getDependency("texture", _);
|
|
462
|
+
return f && v.assignLODInformation(o.url, f, r, t, void 0, void 0), s && console.log('change "' + e.name + '" → "' + f.name + '"', p, _, f, D), e instanceof se && (f = this.copySettings(e, f)), f && (f.guid = x.guid), h(f);
|
|
466
463
|
} else
|
|
467
|
-
L && console.warn("Could not find texture with guid", x.guid,
|
|
464
|
+
L && console.warn("Could not find texture with guid", x.guid, A.parser.json);
|
|
468
465
|
}
|
|
469
|
-
if (
|
|
470
|
-
let
|
|
471
|
-
for (const f of
|
|
466
|
+
if (_ = 0, A.parser.json.meshes) {
|
|
467
|
+
let S = !1;
|
|
468
|
+
for (const f of A.parser.json.meshes) {
|
|
472
469
|
if (f != null && f.extensions) {
|
|
473
|
-
const y = f == null ? void 0 : f.extensions[
|
|
470
|
+
const y = f == null ? void 0 : f.extensions[V];
|
|
474
471
|
if (y != null && y.guid && y.guid === x.guid) {
|
|
475
|
-
|
|
472
|
+
S = !0;
|
|
476
473
|
break;
|
|
477
474
|
}
|
|
478
475
|
}
|
|
479
|
-
|
|
476
|
+
_++;
|
|
480
477
|
}
|
|
481
|
-
if (
|
|
482
|
-
const f = await
|
|
483
|
-
if (s && console.log(`Loaded Mesh "${f.name}"`, p,
|
|
478
|
+
if (S) {
|
|
479
|
+
const f = await N.getDependency("mesh", _), y = x;
|
|
480
|
+
if (s && console.log(`Loaded Mesh "${f.name}"`, p, _, f, D), f.isMesh === !0) {
|
|
484
481
|
const O = f.geometry;
|
|
485
|
-
return v.assignLODInformation(
|
|
482
|
+
return v.assignLODInformation(o.url, O, r, t, void 0, y.density), h(O);
|
|
486
483
|
} else {
|
|
487
484
|
const O = new Array();
|
|
488
485
|
for (let b = 0; b < f.children.length; b++) {
|
|
489
486
|
const E = f.children[b];
|
|
490
487
|
if (E.isMesh === !0) {
|
|
491
488
|
const X = E.geometry;
|
|
492
|
-
v.assignLODInformation(
|
|
489
|
+
v.assignLODInformation(o.url, X, r, t, b, y.density), O.push(X);
|
|
493
490
|
}
|
|
494
491
|
}
|
|
495
492
|
return h(O);
|
|
496
493
|
}
|
|
497
494
|
} else
|
|
498
|
-
L && console.warn("Could not find mesh with guid", x.guid,
|
|
495
|
+
L && console.warn("Could not find mesh with guid", x.guid, A.parser.json);
|
|
499
496
|
}
|
|
500
497
|
return h(null);
|
|
501
498
|
});
|
|
502
|
-
return this.previouslyLoaded.set(
|
|
499
|
+
return this.previouslyLoaded.set(D, $), await $;
|
|
503
500
|
} else if (e instanceof se) {
|
|
504
501
|
s && console.log("Load texture from uri: " + p);
|
|
505
|
-
const w = await new
|
|
502
|
+
const w = await new Xe().loadAsync(p);
|
|
506
503
|
return w ? (w.guid = i.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, s && console.log(i, w)) : L && console.warn("failed loading", p), w;
|
|
507
504
|
}
|
|
508
505
|
} else
|
|
509
506
|
L && console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`, e.type);
|
|
510
507
|
return null;
|
|
511
508
|
}
|
|
512
|
-
static assignLODInformation(e, t, s,
|
|
509
|
+
static assignLODInformation(e, t, s, o, r, i) {
|
|
513
510
|
if (!t)
|
|
514
511
|
return;
|
|
515
512
|
t.userData || (t.userData = {});
|
|
516
|
-
const a = new
|
|
513
|
+
const a = new ct(e, s, o, r, i);
|
|
517
514
|
t.userData.LODS = a;
|
|
518
515
|
}
|
|
519
516
|
static getAssignedLODInformation(e) {
|
|
@@ -522,27 +519,27 @@ const v = class {
|
|
|
522
519
|
}
|
|
523
520
|
// private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
|
|
524
521
|
static copySettings(e, t) {
|
|
525
|
-
return
|
|
522
|
+
return L && console.warn(`Copy texture settings
|
|
526
523
|
`, e.uuid, `
|
|
527
|
-
`, 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;
|
|
524
|
+
`, t.uuid), t = t.clone(), 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;
|
|
528
525
|
}
|
|
529
526
|
};
|
|
530
|
-
let
|
|
527
|
+
let T = v;
|
|
531
528
|
/**
|
|
532
529
|
* Register a texture with LOD information
|
|
533
530
|
*/
|
|
534
|
-
d(
|
|
535
|
-
if (L && console.log("> Progressive: register texture",
|
|
531
|
+
d(T, "registerTexture", (e, t, s, o, r) => {
|
|
532
|
+
if (L && console.log("> Progressive: register texture", o, t.name, t.uuid, t, r), !t) {
|
|
536
533
|
L && console.error("gltf-progressive: Register texture without texture");
|
|
537
534
|
return;
|
|
538
535
|
}
|
|
539
536
|
t.source && (t.source[De] = r);
|
|
540
537
|
const i = r.guid;
|
|
541
|
-
v.assignLODInformation(e, t, i, s,
|
|
538
|
+
v.assignLODInformation(e, t, i, s, o, void 0), v.lodInfos.set(i, r), v.lowresCache.set(i, t);
|
|
542
539
|
}), /**
|
|
543
540
|
* Register a mesh with LOD information
|
|
544
541
|
*/
|
|
545
|
-
d(
|
|
542
|
+
d(T, "registerMesh", (e, t, s, o, r, i) => {
|
|
546
543
|
var u;
|
|
547
544
|
L && console.log("> Progressive: register mesh", r, s.name, i, s.uuid, s);
|
|
548
545
|
const a = s.geometry;
|
|
@@ -550,17 +547,17 @@ d(_, "registerMesh", (e, t, s, n, r, i) => {
|
|
|
550
547
|
L && console.warn("gltf-progressive: Register mesh without geometry");
|
|
551
548
|
return;
|
|
552
549
|
}
|
|
553
|
-
a.userData || (a.userData = {}), v.assignLODInformation(e, a, t,
|
|
550
|
+
a.userData || (a.userData = {}), v.assignLODInformation(e, a, t, o, r, i.density), v.lodInfos.set(t, i);
|
|
554
551
|
let l = v.lowresCache.get(t);
|
|
555
|
-
l ? l.push(s.geometry) : l = [s.geometry], v.lowresCache.set(t, l),
|
|
556
|
-
for (const c of
|
|
552
|
+
l ? l.push(s.geometry) : l = [s.geometry], v.lowresCache.set(t, l), o > 0 && !ce(s) && nt(s, a);
|
|
553
|
+
for (const c of H)
|
|
557
554
|
(u = c.onRegisteredNewMesh) == null || u.call(c, s, i);
|
|
558
555
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
559
|
-
d(
|
|
560
|
-
d(
|
|
561
|
-
d(
|
|
562
|
-
class
|
|
563
|
-
constructor(e, t, s,
|
|
556
|
+
d(T, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
|
|
557
|
+
d(T, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
|
|
558
|
+
d(T, "lowresCache", /* @__PURE__ */ new Map());
|
|
559
|
+
class ct {
|
|
560
|
+
constructor(e, t, s, o, r) {
|
|
564
561
|
d(this, "url");
|
|
565
562
|
/** the key to lookup the LOD information */
|
|
566
563
|
d(this, "key");
|
|
@@ -569,11 +566,11 @@ class ut {
|
|
|
569
566
|
d(this, "index");
|
|
570
567
|
/** the mesh density */
|
|
571
568
|
d(this, "density");
|
|
572
|
-
this.url = e, this.key = t, this.level = s,
|
|
569
|
+
this.url = e, this.key = t, this.level = s, o != null && (this.index = o), r != null && (this.density = r);
|
|
573
570
|
}
|
|
574
571
|
}
|
|
575
|
-
const I = le("debugprogressive"),
|
|
576
|
-
var C,
|
|
572
|
+
const I = le("debugprogressive"), ut = le("noprogressive"), we = Symbol("Needle:LODSManager"), ve = Symbol("Needle:LODState"), Y = Symbol("Needle:CurrentLOD"), G = { mesh_lod: -1, texture_lod: -1 };
|
|
573
|
+
var C, W, ye, j, ee, me, q;
|
|
577
574
|
const P = class {
|
|
578
575
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
579
576
|
constructor(e, t) {
|
|
@@ -603,21 +600,21 @@ const P = class {
|
|
|
603
600
|
*/
|
|
604
601
|
d(this, "manual", !1);
|
|
605
602
|
d(this, "_lodchangedlisteners", []);
|
|
606
|
-
K(this,
|
|
607
|
-
K(this, ye, new
|
|
603
|
+
K(this, W, void 0);
|
|
604
|
+
K(this, ye, new Ke());
|
|
608
605
|
K(this, j, 0);
|
|
609
606
|
K(this, ee, 0);
|
|
610
607
|
K(this, me, 0);
|
|
611
|
-
K(this,
|
|
608
|
+
K(this, q, 0);
|
|
612
609
|
d(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
|
|
613
610
|
// private testIfLODLevelsAreAvailable() {
|
|
614
|
-
d(this, "_sphere", new
|
|
611
|
+
d(this, "_sphere", new He());
|
|
615
612
|
d(this, "_tempBox", new Ee());
|
|
616
613
|
d(this, "_tempBox2", new Ee());
|
|
617
614
|
d(this, "tempMatrix", new Ae());
|
|
618
|
-
d(this, "_tempWorldPosition", new
|
|
619
|
-
d(this, "_tempBoxSize", new
|
|
620
|
-
d(this, "_tempBox2Size", new
|
|
615
|
+
d(this, "_tempWorldPosition", new z());
|
|
616
|
+
d(this, "_tempBoxSize", new z());
|
|
617
|
+
d(this, "_tempBox2Size", new z());
|
|
621
618
|
this.renderer = e, this.context = { ...t };
|
|
622
619
|
}
|
|
623
620
|
/** @internal */
|
|
@@ -625,11 +622,11 @@ const P = class {
|
|
|
625
622
|
return e[ve];
|
|
626
623
|
}
|
|
627
624
|
static addPlugin(e) {
|
|
628
|
-
|
|
625
|
+
H.push(e);
|
|
629
626
|
}
|
|
630
627
|
static removePlugin(e) {
|
|
631
|
-
const t =
|
|
632
|
-
t >= 0 &&
|
|
628
|
+
const t = H.indexOf(e);
|
|
629
|
+
t >= 0 && H.splice(t, 1);
|
|
633
630
|
}
|
|
634
631
|
/**
|
|
635
632
|
* Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
|
|
@@ -647,7 +644,7 @@ const P = class {
|
|
|
647
644
|
}
|
|
648
645
|
/** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
|
|
649
646
|
get plugins() {
|
|
650
|
-
return
|
|
647
|
+
return H;
|
|
651
648
|
}
|
|
652
649
|
addEventListener(e, t) {
|
|
653
650
|
e === "changed" && this._lodchangedlisteners.push(t);
|
|
@@ -662,21 +659,21 @@ const P = class {
|
|
|
662
659
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
663
660
|
*/
|
|
664
661
|
enable() {
|
|
665
|
-
if (m(this,
|
|
662
|
+
if (m(this, W))
|
|
666
663
|
return;
|
|
667
664
|
console.debug("[gltf-progressive] Enabling LODsManager for renderer");
|
|
668
665
|
let e = 0;
|
|
669
|
-
U(this,
|
|
666
|
+
U(this, W, this.renderer.render);
|
|
670
667
|
const t = this;
|
|
671
|
-
Ge(this.renderer), this.renderer.render = function(s,
|
|
668
|
+
Ge(this.renderer), this.renderer.render = function(s, o) {
|
|
672
669
|
const r = t.renderer.getRenderTarget();
|
|
673
|
-
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, U(t, j, m(t, j) + 1), U(t, ee, m(t, ye).getDelta()), U(t, me, m(t, me) + m(t, ee)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / m(t, ee)), U(t,
|
|
670
|
+
(r == null || "isXRRenderTarget" in r && r.isXRRenderTarget) && (e = 0, U(t, j, m(t, j) + 1), U(t, ee, m(t, ye).getDelta()), U(t, me, m(t, me) + m(t, ee)), t._fpsBuffer.shift(), t._fpsBuffer.push(1 / m(t, ee)), U(t, q, t._fpsBuffer.reduce((a, l) => a + l) / t._fpsBuffer.length), I && m(t, j) % 200 === 0 && console.log("FPS", Math.round(m(t, q)), "Interval:", m(t, C)));
|
|
674
671
|
const i = e++;
|
|
675
|
-
m(t,
|
|
672
|
+
m(t, W).call(this, s, o), t.onAfterRender(s, o, i);
|
|
676
673
|
};
|
|
677
674
|
}
|
|
678
675
|
disable() {
|
|
679
|
-
m(this,
|
|
676
|
+
m(this, W) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = m(this, W), U(this, W, void 0));
|
|
680
677
|
}
|
|
681
678
|
update(e, t) {
|
|
682
679
|
this.internalUpdate(e, t);
|
|
@@ -691,7 +688,7 @@ const P = class {
|
|
|
691
688
|
(a.name === "EffectMaterial" || a.name === "CopyShader") && (i = !1);
|
|
692
689
|
}
|
|
693
690
|
if ((t.parent && t.parent.type === "CubeCamera" || s >= 1 && t.type === "OrthographicCamera") && (i = !1), i) {
|
|
694
|
-
if (
|
|
691
|
+
if (ut || (this.updateInterval === "auto" ? m(this, q) < 40 && m(this, C) < 10 ? (U(this, C, m(this, C) + 1), I && console.warn("↓ Reducing LOD updates", m(this, C), m(this, q).toFixed(0))) : m(this, q) >= 60 && m(this, C) > 1 && (U(this, C, m(this, C) - 1), I && console.warn("↑ Increasing LOD updates", m(this, C), m(this, q).toFixed(0))) : U(this, C, this.updateInterval), m(this, C) > 0 && m(this, j) % m(this, C) != 0))
|
|
695
692
|
return;
|
|
696
693
|
this.internalUpdate(e, t);
|
|
697
694
|
}
|
|
@@ -701,10 +698,10 @@ const P = class {
|
|
|
701
698
|
*/
|
|
702
699
|
internalUpdate(e, t) {
|
|
703
700
|
var l, u;
|
|
704
|
-
const s = this.renderer.renderLists.get(e, 0),
|
|
701
|
+
const s = this.renderer.renderLists.get(e, 0), o = s.opaque;
|
|
705
702
|
this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse);
|
|
706
703
|
const r = this.targetTriangleDensity;
|
|
707
|
-
for (const c of
|
|
704
|
+
for (const c of o) {
|
|
708
705
|
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")) {
|
|
709
706
|
I && (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)));
|
|
710
707
|
continue;
|
|
@@ -720,39 +717,36 @@ const P = class {
|
|
|
720
717
|
}
|
|
721
718
|
if (I === "color" && c.material && !c.object.progressive_debug_color) {
|
|
722
719
|
c.object.progressive_debug_color = !0;
|
|
723
|
-
const p = Math.random() * 16777215,
|
|
724
|
-
c.object.material =
|
|
720
|
+
const p = Math.random() * 16777215, D = new Ye({ color: p });
|
|
721
|
+
c.object.material = D;
|
|
725
722
|
}
|
|
726
723
|
const g = c.object;
|
|
727
|
-
(g instanceof
|
|
724
|
+
(g instanceof Z || g.isMesh) && this.updateLODs(e, t, g, r);
|
|
728
725
|
}
|
|
729
726
|
const i = s.transparent;
|
|
730
727
|
for (const c of i) {
|
|
731
728
|
const g = c.object;
|
|
732
|
-
(g instanceof
|
|
729
|
+
(g instanceof Z || g.isMesh) && this.updateLODs(e, t, g, r);
|
|
733
730
|
}
|
|
734
731
|
const a = s.transmissive;
|
|
735
732
|
for (const c of a) {
|
|
736
733
|
const g = c.object;
|
|
737
|
-
(g instanceof
|
|
734
|
+
(g instanceof Z || g.isMesh) && this.updateLODs(e, t, g, r);
|
|
738
735
|
}
|
|
739
736
|
}
|
|
740
737
|
/** Update the LOD levels for the renderer. */
|
|
741
|
-
updateLODs(e, t, s,
|
|
738
|
+
updateLODs(e, t, s, o) {
|
|
742
739
|
var a, l;
|
|
743
740
|
s.userData || (s.userData = {});
|
|
744
741
|
let r = s[ve];
|
|
745
|
-
if (r || (r = new
|
|
742
|
+
if (r || (r = new ft(), s[ve] = r), r.frames++ < 2)
|
|
746
743
|
return;
|
|
747
|
-
for (const u of
|
|
744
|
+
for (const u of H)
|
|
748
745
|
(a = u.onBeforeUpdateLOD) == null || a.call(u, this.renderer, e, t, s);
|
|
749
|
-
this.calculateLodLevel(t, s, r,
|
|
746
|
+
this.calculateLodLevel(t, s, r, o, G), G.mesh_lod = Math.round(G.mesh_lod), G.texture_lod = Math.round(G.texture_lod), G.mesh_lod >= 0 && this.loadProgressiveMeshes(s, G.mesh_lod);
|
|
750
747
|
let i = G.texture_lod;
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
u != null && (i = u), this.loadProgressiveTextures(s.material, i);
|
|
754
|
-
}
|
|
755
|
-
for (const u of Y)
|
|
748
|
+
s.material && i >= 0 && this.loadProgressiveTextures(s.material, i);
|
|
749
|
+
for (const u of H)
|
|
756
750
|
(l = u.onAfterUpdatedLOD) == null || l.call(u, this.renderer, e, t, s, G);
|
|
757
751
|
r.lastLodLevel_Mesh = G.mesh_lod, r.lastLodLevel_Texture = G.texture_lod;
|
|
758
752
|
}
|
|
@@ -765,13 +759,15 @@ const P = class {
|
|
|
765
759
|
if (!e)
|
|
766
760
|
return;
|
|
767
761
|
if (Array.isArray(e)) {
|
|
768
|
-
for (const
|
|
769
|
-
this.loadProgressiveTextures(
|
|
762
|
+
for (const r of e)
|
|
763
|
+
this.loadProgressiveTextures(r, t);
|
|
770
764
|
return;
|
|
771
765
|
}
|
|
772
766
|
let s = !1;
|
|
773
|
-
(e[
|
|
774
|
-
|
|
767
|
+
(e[Y] === void 0 || t < e[Y]) && (s = !0);
|
|
768
|
+
const o = e["DEBUG:LOD"];
|
|
769
|
+
o != null && (s = e[Y] != o, t = o), s && (e[Y] = t, T.assignTextureLOD(e, t).then((r) => {
|
|
770
|
+
this._lodchangedlisteners.forEach((i) => i({ type: "texture", level: t, object: e }));
|
|
775
771
|
}));
|
|
776
772
|
}
|
|
777
773
|
/** Load progressive meshes for the given mesh
|
|
@@ -783,18 +779,20 @@ const P = class {
|
|
|
783
779
|
loadProgressiveMeshes(e, t) {
|
|
784
780
|
if (!e)
|
|
785
781
|
return Promise.resolve(null);
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
782
|
+
let s = e[Y] !== t;
|
|
783
|
+
const o = e["DEBUG:LOD"];
|
|
784
|
+
if (o != null && (s = e[Y] != o, t = o), s) {
|
|
785
|
+
e[Y] = t;
|
|
786
|
+
const r = e.geometry;
|
|
787
|
+
return T.assignMeshLOD(e, t).then((i) => (i && e[Y] == t && r != e.geometry && this._lodchangedlisteners.forEach((a) => a({ type: "mesh", level: t, object: e })), i));
|
|
790
788
|
}
|
|
791
789
|
return Promise.resolve(null);
|
|
792
790
|
}
|
|
793
791
|
static isInside(e, t) {
|
|
794
|
-
const s = e.min,
|
|
792
|
+
const s = e.min, o = e.max, r = (s.x + o.x) * 0.5, i = (s.y + o.y) * 0.5;
|
|
795
793
|
return this._tempPtInside.set(r, i, s.z).applyMatrix4(t).z < 0;
|
|
796
794
|
}
|
|
797
|
-
calculateLodLevel(e, t, s,
|
|
795
|
+
calculateLodLevel(e, t, s, o, r) {
|
|
798
796
|
var $;
|
|
799
797
|
if (!t) {
|
|
800
798
|
r.mesh_lod = -1, r.texture_lod = -1;
|
|
@@ -807,8 +805,8 @@ const P = class {
|
|
|
807
805
|
let a = 10 + 1, l = !1;
|
|
808
806
|
if (I && t["DEBUG:LOD"] != null)
|
|
809
807
|
return t["DEBUG:LOD"];
|
|
810
|
-
const u =
|
|
811
|
-
if (!g && !
|
|
808
|
+
const u = T.getMeshLODInformation(t.geometry), c = u == null ? void 0 : u.lods, g = c && c.length > 0, p = T.getMaterialMinMaxLODsCount(t.material), D = (p == null ? void 0 : p.min_count) != 1 / 0 && p.min_count > 0 && p.max_count > 0;
|
|
809
|
+
if (!g && !D) {
|
|
812
810
|
r.mesh_lod = 0, r.texture_lod = 0;
|
|
813
811
|
return;
|
|
814
812
|
}
|
|
@@ -816,17 +814,17 @@ const P = class {
|
|
|
816
814
|
const w = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
817
815
|
let x = t.geometry.boundingBox;
|
|
818
816
|
if (t.type === "SkinnedMesh") {
|
|
819
|
-
const
|
|
820
|
-
if (!
|
|
821
|
-
|
|
817
|
+
const M = t;
|
|
818
|
+
if (!M.boundingBox)
|
|
819
|
+
M.computeBoundingBox();
|
|
822
820
|
else if (s.frames % 30 === 0) {
|
|
823
|
-
const h = ce(
|
|
824
|
-
h && (
|
|
821
|
+
const h = ce(M), R = M.geometry;
|
|
822
|
+
h && (M.geometry = h), M.computeBoundingBox(), M.geometry = R;
|
|
825
823
|
}
|
|
826
|
-
x =
|
|
824
|
+
x = M.boundingBox;
|
|
827
825
|
}
|
|
828
|
-
if (x
|
|
829
|
-
const
|
|
826
|
+
if (x) {
|
|
827
|
+
const M = e;
|
|
830
828
|
if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
|
|
831
829
|
this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
|
|
832
830
|
const f = e.getWorldPosition(this._tempWorldPosition);
|
|
@@ -835,11 +833,11 @@ const P = class {
|
|
|
835
833
|
return;
|
|
836
834
|
}
|
|
837
835
|
}
|
|
838
|
-
if (this._tempBox.copy(x), this._tempBox.applyMatrix4(t.matrixWorld), P.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
836
|
+
if (this._tempBox.copy(x), this._tempBox.applyMatrix4(t.matrixWorld), M.isPerspectiveCamera && P.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
839
837
|
r.mesh_lod = 0, r.texture_lod = 0;
|
|
840
838
|
return;
|
|
841
839
|
}
|
|
842
|
-
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled &&
|
|
840
|
+
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && M.isPerspectiveCamera && M.fov > 70) {
|
|
843
841
|
const f = this._tempBox.min, y = this._tempBox.max;
|
|
844
842
|
let O = f.x, b = f.y, E = y.x, X = y.y;
|
|
845
843
|
const ue = 2, Le = 1.5, fe = (f.x + y.x) * 0.5, de = (f.y + y.y) * 0.5;
|
|
@@ -849,11 +847,11 @@ const P = class {
|
|
|
849
847
|
} else
|
|
850
848
|
s.lastCentrality = 1;
|
|
851
849
|
const h = this._tempBox.getSize(this._tempBoxSize);
|
|
852
|
-
h.multiplyScalar(0.5), screen.availHeight > 0 && w > 0 && h.multiplyScalar(w / screen.availHeight), h.x *=
|
|
850
|
+
h.multiplyScalar(0.5), screen.availHeight > 0 && w > 0 && h.multiplyScalar(w / screen.availHeight), e.isPerspectiveCamera ? h.x *= e.aspect : e.isOrthographicCamera;
|
|
853
851
|
const R = e.matrixWorldInverse, F = this._tempBox2;
|
|
854
852
|
F.copy(x), F.applyMatrix4(t.matrixWorld), F.applyMatrix4(R);
|
|
855
|
-
const k = F.getSize(this._tempBox2Size),
|
|
856
|
-
if (Math.max(h.x, h.y) != 0 &&
|
|
853
|
+
const k = F.getSize(this._tempBox2Size), A = Math.max(k.x, k.y);
|
|
854
|
+
if (Math.max(h.x, h.y) != 0 && A != 0 && (h.z = k.z / Math.max(k.x, k.y) * Math.max(h.x, h.y)), s.lastScreenCoverage = Math.max(h.x, h.y, h.z), s.lastScreenspaceVolume.copy(h), s.lastScreenCoverage *= s.lastCentrality, I && P.debugDrawLine) {
|
|
857
855
|
const f = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
858
856
|
f.invert();
|
|
859
857
|
const y = P.corner0, O = P.corner1, b = P.corner2, E = P.corner3;
|
|
@@ -861,22 +859,22 @@ const P = class {
|
|
|
861
859
|
const X = (y.z + E.z) * 0.5;
|
|
862
860
|
y.z = O.z = b.z = E.z = X, y.applyMatrix4(f), O.applyMatrix4(f), b.applyMatrix4(f), E.applyMatrix4(f), P.debugDrawLine(y, O, 255), P.debugDrawLine(y, b, 255), P.debugDrawLine(O, E, 255), P.debugDrawLine(b, E, 255);
|
|
863
861
|
}
|
|
864
|
-
let
|
|
862
|
+
let _ = 999;
|
|
865
863
|
if (c && s.lastScreenCoverage > 0) {
|
|
866
864
|
for (let f = 0; f < c.length; f++)
|
|
867
|
-
if (c[f].density / s.lastScreenCoverage <
|
|
868
|
-
|
|
865
|
+
if (c[f].density / s.lastScreenCoverage < o) {
|
|
866
|
+
_ = f;
|
|
869
867
|
break;
|
|
870
868
|
}
|
|
871
869
|
}
|
|
872
|
-
|
|
870
|
+
_ < a && (a = _, l = !0);
|
|
873
871
|
}
|
|
874
872
|
if (l ? r.mesh_lod = a : r.mesh_lod = s.lastLodLevel_Mesh, I && r.mesh_lod != s.lastLodLevel_Mesh) {
|
|
875
873
|
const h = c == null ? void 0 : c[r.mesh_lod];
|
|
876
874
|
h && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${r.mesh_lod} (${h.density.toFixed(0)}) - ${t.name}`);
|
|
877
875
|
}
|
|
878
|
-
if (
|
|
879
|
-
const
|
|
876
|
+
if (D) {
|
|
877
|
+
const M = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
880
878
|
if (s.lastLodLevel_Texture < 0) {
|
|
881
879
|
if (r.texture_lod = p.max_count - 1, I) {
|
|
882
880
|
const h = p.lods[p.max_count - 1];
|
|
@@ -887,12 +885,13 @@ const P = class {
|
|
|
887
885
|
let R = s.lastScreenCoverage * 4;
|
|
888
886
|
(($ = this.context) == null ? void 0 : $.engine) === "model-viewer" && (R *= 1.5);
|
|
889
887
|
const k = w / window.devicePixelRatio * R;
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
888
|
+
let A = !1;
|
|
889
|
+
for (let N = p.lods.length - 1; N >= 0; N--) {
|
|
890
|
+
let _ = p.lods[N];
|
|
891
|
+
if (!(M && _.max_height >= 2048) && !(it() && _.max_height > 4096) && (_.max_height > k || !A && N === 0)) {
|
|
892
|
+
if (A = !0, r.texture_lod = N, r.texture_lod < s.lastLodLevel_Texture) {
|
|
893
|
+
const S = _.max_height;
|
|
894
|
+
I && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${r.texture_lod} = ${S}px
|
|
896
895
|
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${h.toFixed(1)}
|
|
897
896
|
${t.name}`);
|
|
898
897
|
}
|
|
@@ -905,38 +904,38 @@ ${t.name}`);
|
|
|
905
904
|
}
|
|
906
905
|
};
|
|
907
906
|
let B = P;
|
|
908
|
-
C = new WeakMap(),
|
|
907
|
+
C = new WeakMap(), W = new WeakMap(), ye = new WeakMap(), j = new WeakMap(), ee = new WeakMap(), me = 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.
|
|
909
908
|
*/
|
|
910
|
-
d(B, "debugDrawLine"), d(B, "corner0", new
|
|
911
|
-
class
|
|
909
|
+
d(B, "debugDrawLine"), d(B, "corner0", new z()), d(B, "corner1", new z()), d(B, "corner2", new z()), d(B, "corner3", new z()), d(B, "_tempPtInside", new z());
|
|
910
|
+
class ft {
|
|
912
911
|
constructor() {
|
|
913
912
|
d(this, "frames", 0);
|
|
914
913
|
d(this, "lastLodLevel_Mesh", -1);
|
|
915
914
|
d(this, "lastLodLevel_Texture", -1);
|
|
916
915
|
d(this, "lastScreenCoverage", 0);
|
|
917
|
-
d(this, "lastScreenspaceVolume", new
|
|
916
|
+
d(this, "lastScreenspaceVolume", new z());
|
|
918
917
|
d(this, "lastCentrality", 0);
|
|
919
918
|
}
|
|
920
919
|
}
|
|
921
920
|
const Ce = Symbol("NEEDLE_mesh_lod"), he = Symbol("NEEDLE_texture_lod");
|
|
922
|
-
let
|
|
921
|
+
let oe = null;
|
|
923
922
|
function Ue() {
|
|
924
|
-
const
|
|
925
|
-
|
|
923
|
+
const n = dt();
|
|
924
|
+
n && (n.mapURLs(function(e) {
|
|
926
925
|
return Be(), e;
|
|
927
|
-
}), Be(),
|
|
926
|
+
}), Be(), oe == null || oe.disconnect(), oe = new MutationObserver((e) => {
|
|
928
927
|
e.forEach((t) => {
|
|
929
928
|
t.addedNodes.forEach((s) => {
|
|
930
929
|
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Ne(s);
|
|
931
930
|
});
|
|
932
931
|
});
|
|
933
|
-
}),
|
|
932
|
+
}), oe.observe(document, { childList: !0, subtree: !0 }));
|
|
934
933
|
}
|
|
935
|
-
function
|
|
934
|
+
function dt() {
|
|
936
935
|
if (typeof customElements > "u")
|
|
937
936
|
return null;
|
|
938
|
-
const
|
|
939
|
-
return
|
|
937
|
+
const n = customElements.get("model-viewer");
|
|
938
|
+
return n || (customElements.whenDefined("model-viewer").then(() => {
|
|
940
939
|
console.debug("[gltf-progressive] model-viewer defined"), Ue();
|
|
941
940
|
}), null);
|
|
942
941
|
}
|
|
@@ -948,49 +947,49 @@ function Be() {
|
|
|
948
947
|
});
|
|
949
948
|
}
|
|
950
949
|
const Re = /* @__PURE__ */ new WeakSet();
|
|
951
|
-
let
|
|
952
|
-
function Ne(
|
|
953
|
-
if (!
|
|
950
|
+
let ht = 0;
|
|
951
|
+
function Ne(n) {
|
|
952
|
+
if (!n || Re.has(n))
|
|
954
953
|
return null;
|
|
955
|
-
Re.add(
|
|
956
|
-
`,
|
|
954
|
+
Re.add(n), console.debug("[gltf-progressive] found new model-viewer..." + ++ht + `
|
|
955
|
+
`, n.getAttribute("src"));
|
|
957
956
|
let e = null, t = null, s = null;
|
|
958
|
-
for (let
|
|
959
|
-
const r = Object.getOwnPropertySymbols(
|
|
960
|
-
!e && i != null && (e =
|
|
957
|
+
for (let o = n; o != null; o = Object.getPrototypeOf(o)) {
|
|
958
|
+
const r = Object.getOwnPropertySymbols(o), i = r.find((u) => u.toString() == "Symbol(renderer)"), a = r.find((u) => u.toString() == "Symbol(scene)"), l = r.find((u) => u.toString() == "Symbol(needsRender)");
|
|
959
|
+
!e && i != null && (e = n[i].threeRenderer), !t && a != null && (t = n[a]), !s && l != null && (s = n[l]);
|
|
961
960
|
}
|
|
962
961
|
if (e && t) {
|
|
963
|
-
let
|
|
962
|
+
let o = function() {
|
|
964
963
|
if (s) {
|
|
965
964
|
let i = 0, a = setInterval(() => {
|
|
966
965
|
if (i++ > 5) {
|
|
967
966
|
clearInterval(a);
|
|
968
967
|
return;
|
|
969
968
|
}
|
|
970
|
-
s == null || s.call(
|
|
969
|
+
s == null || s.call(n);
|
|
971
970
|
}, 300);
|
|
972
971
|
}
|
|
973
972
|
};
|
|
974
973
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
975
974
|
const r = B.get(e, { engine: "model-viewer" });
|
|
976
|
-
return B.addPlugin(new
|
|
977
|
-
s == null || s.call(
|
|
978
|
-
}),
|
|
979
|
-
i.detail.visible && (s == null || s.call(
|
|
980
|
-
}),
|
|
981
|
-
|
|
975
|
+
return B.addPlugin(new gt()), r.enable(), r.addEventListener("changed", () => {
|
|
976
|
+
s == null || s.call(n);
|
|
977
|
+
}), n.addEventListener("model-visibility", (i) => {
|
|
978
|
+
i.detail.visible && (s == null || s.call(n));
|
|
979
|
+
}), n.addEventListener("load", () => {
|
|
980
|
+
o();
|
|
982
981
|
}), () => {
|
|
983
982
|
r.disable();
|
|
984
983
|
};
|
|
985
984
|
}
|
|
986
985
|
return null;
|
|
987
986
|
}
|
|
988
|
-
class
|
|
987
|
+
class gt {
|
|
989
988
|
constructor() {
|
|
990
989
|
d(this, "_didWarnAboutMissingUrl", !1);
|
|
991
990
|
}
|
|
992
|
-
onBeforeUpdateLOD(e, t, s,
|
|
993
|
-
this.tryParseMeshLOD(t,
|
|
991
|
+
onBeforeUpdateLOD(e, t, s, o) {
|
|
992
|
+
this.tryParseMeshLOD(t, o), this.tryParseTextureLOD(t, o);
|
|
994
993
|
}
|
|
995
994
|
getUrl(e) {
|
|
996
995
|
if (!e)
|
|
@@ -1008,7 +1007,7 @@ class pt {
|
|
|
1008
1007
|
if (t[he] == !0)
|
|
1009
1008
|
return;
|
|
1010
1009
|
t[he] = !0;
|
|
1011
|
-
const s = this.tryGetCurrentGLTF(e),
|
|
1010
|
+
const s = this.tryGetCurrentGLTF(e), o = this.tryGetCurrentModelViewer(e), r = this.getUrl(o);
|
|
1012
1011
|
if (r && s && t.material) {
|
|
1013
1012
|
let i = function(l) {
|
|
1014
1013
|
var c, g, p;
|
|
@@ -1016,20 +1015,20 @@ class pt {
|
|
|
1016
1015
|
return;
|
|
1017
1016
|
l[he] = !0, l.userData && (l.userData.LOD = -1);
|
|
1018
1017
|
const u = Object.keys(l);
|
|
1019
|
-
for (let
|
|
1020
|
-
const w = u[
|
|
1018
|
+
for (let D = 0; D < u.length; D++) {
|
|
1019
|
+
const w = u[D], x = l[w];
|
|
1021
1020
|
if ((x == null ? void 0 : x.isTexture) === !0) {
|
|
1022
1021
|
const $ = (g = (c = x.userData) == null ? void 0 : c.associations) == null ? void 0 : g.textures;
|
|
1023
1022
|
if ($ == null)
|
|
1024
1023
|
continue;
|
|
1025
|
-
const
|
|
1026
|
-
if (!
|
|
1024
|
+
const M = s.parser.json.textures[$];
|
|
1025
|
+
if (!M) {
|
|
1027
1026
|
console.warn("Texture data not found for texture index " + $);
|
|
1028
1027
|
continue;
|
|
1029
1028
|
}
|
|
1030
|
-
if ((p =
|
|
1031
|
-
const h =
|
|
1032
|
-
h && r &&
|
|
1029
|
+
if ((p = M == null ? void 0 : M.extensions) != null && p[V]) {
|
|
1030
|
+
const h = M.extensions[V];
|
|
1031
|
+
h && r && T.registerTexture(r, x, h.lods.length, $, h);
|
|
1033
1032
|
}
|
|
1034
1033
|
}
|
|
1035
1034
|
}
|
|
@@ -1047,54 +1046,54 @@ class pt {
|
|
|
1047
1046
|
if (t[Ce] == !0)
|
|
1048
1047
|
return;
|
|
1049
1048
|
t[Ce] = !0;
|
|
1050
|
-
const s = this.tryGetCurrentModelViewer(e),
|
|
1051
|
-
if (!
|
|
1049
|
+
const s = this.tryGetCurrentModelViewer(e), o = this.getUrl(s);
|
|
1050
|
+
if (!o)
|
|
1052
1051
|
return;
|
|
1053
|
-
const r = (a = (i = t.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[
|
|
1054
|
-
if (r &&
|
|
1052
|
+
const r = (a = (i = t.userData) == null ? void 0 : i.gltfExtensions) == null ? void 0 : a[V];
|
|
1053
|
+
if (r && o) {
|
|
1055
1054
|
const l = t.uuid;
|
|
1056
|
-
|
|
1055
|
+
T.registerMesh(o, l, t, 0, r.lods.length, r);
|
|
1057
1056
|
}
|
|
1058
1057
|
}
|
|
1059
1058
|
}
|
|
1060
|
-
function
|
|
1059
|
+
function pt(n, e, t, s) {
|
|
1061
1060
|
Ge(e), $e(t), Fe(t, {
|
|
1062
1061
|
progressive: !0,
|
|
1063
1062
|
...s == null ? void 0 : s.hints
|
|
1064
|
-
}), t.register((r) => new
|
|
1065
|
-
const
|
|
1066
|
-
return (s == null ? void 0 : s.enableLODsManager) !== !1 &&
|
|
1063
|
+
}), t.register((r) => new T(r, n));
|
|
1064
|
+
const o = B.get(e);
|
|
1065
|
+
return (s == null ? void 0 : s.enableLODsManager) !== !1 && o.enable(), o;
|
|
1067
1066
|
}
|
|
1068
1067
|
Ue();
|
|
1069
1068
|
if (!ot) {
|
|
1070
|
-
const
|
|
1069
|
+
const n = {
|
|
1071
1070
|
gltfProgressive: {
|
|
1072
|
-
useNeedleProgressive:
|
|
1071
|
+
useNeedleProgressive: pt,
|
|
1073
1072
|
LODsManager: B,
|
|
1074
1073
|
configureLoader: Fe,
|
|
1075
1074
|
getRaycastMesh: ce,
|
|
1076
|
-
useRaycastMeshes:
|
|
1075
|
+
useRaycastMeshes: at
|
|
1077
1076
|
}
|
|
1078
1077
|
};
|
|
1079
1078
|
if (!globalThis.Needle)
|
|
1080
|
-
globalThis.Needle =
|
|
1079
|
+
globalThis.Needle = n;
|
|
1081
1080
|
else
|
|
1082
|
-
for (const e in
|
|
1083
|
-
globalThis.Needle[e] =
|
|
1081
|
+
for (const e in n)
|
|
1082
|
+
globalThis.Needle[e] = n[e];
|
|
1084
1083
|
}
|
|
1085
1084
|
export {
|
|
1086
|
-
|
|
1085
|
+
V as EXTENSION_NAME,
|
|
1087
1086
|
B as LODsManager,
|
|
1088
|
-
|
|
1087
|
+
T as NEEDLE_progressive,
|
|
1089
1088
|
ke as VERSION,
|
|
1090
1089
|
$e as addDracoAndKTX2Loaders,
|
|
1091
1090
|
Fe as configureLoader,
|
|
1092
1091
|
Ge as createLoaders,
|
|
1093
1092
|
ce as getRaycastMesh,
|
|
1094
1093
|
Ue as patchModelViewer,
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1094
|
+
nt as registerRaycastMesh,
|
|
1095
|
+
wt as setDracoDecoderLocation,
|
|
1096
|
+
vt as setKTX2TranscoderLocation,
|
|
1097
|
+
pt as useNeedleProgressive,
|
|
1098
|
+
at as useRaycastMeshes
|
|
1100
1099
|
};
|