@needle-tools/gltf-progressive 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +7 -0
- package/gltf-progressive.js +279 -273
- package/gltf-progressive.min.js +3 -3
- package/gltf-progressive.umd.cjs +3 -3
- package/lib/extension.js +0 -1
- package/lib/index.js +0 -1
- package/lib/loaders.js +0 -1
- package/lib/lods_manager.js +19 -1
- package/lib/plugins/index.js +0 -1
- package/lib/plugins/modelviewer.js +12 -4
- package/lib/plugins/plugin.js +0 -1
- package/lib/utils.js +0 -1
- package/package.json +1 -1
- package/lib/extension.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/loaders.js.map +0 -1
- package/lib/lods_manager.js.map +0 -1
- package/lib/plugins/index.js.map +0 -1
- package/lib/plugins/modelviewer.js.map +0 -1
- package/lib/plugins/plugin.js.map +0 -1
- package/lib/utils.js.map +0 -1
package/gltf-progressive.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
var ae = (l, e, t) => e in l ?
|
|
1
|
+
var oe = Object.defineProperty;
|
|
2
|
+
var ae = (l, e, t) => e in l ? oe(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
3
|
var u = (l, e, t) => (ae(l, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { Mesh as
|
|
4
|
+
import { Mesh as q, BufferGeometry as X, Material as le, RawShaderMaterial as ue, Texture as U, TextureLoader as ce, Matrix4 as j, Frustum as fe, Sphere as de, Box3 as ee, Vector3 as k } from "three";
|
|
5
5
|
import { GLTFLoader as ge } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
6
6
|
import { MeshoptDecoder as he } from "three/examples/jsm/libs/meshopt_decoder.module.js";
|
|
7
7
|
import { DRACOLoader as pe } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
8
8
|
import { KTX2Loader as ye } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
9
|
-
const
|
|
10
|
-
let
|
|
9
|
+
const me = "https://www.gstatic.com/draco/versioned/decoders/1.4.1/", Le = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
|
|
10
|
+
let F, H, W;
|
|
11
11
|
function se(l) {
|
|
12
|
-
|
|
12
|
+
F || (F = new pe(), F.setDecoderPath(me), F.setDecoderConfig({ type: "js" })), W || (W = new ye(), W.setTranscoderPath(Le)), H || (H = he), l ? W.detectSupport(l) : console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail");
|
|
13
13
|
}
|
|
14
14
|
function ie(l) {
|
|
15
|
-
l.dracoLoader || l.setDRACOLoader(
|
|
15
|
+
l.dracoLoader || l.setDRACOLoader(F), l.ktx2Loader || l.setKTX2Loader(W), l.meshoptDecoder || l.setMeshoptDecoder(H);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function Z(l) {
|
|
18
18
|
const t = new URL(window.location.href).searchParams.get(l);
|
|
19
19
|
return t == null || t === "0" || t === "false" ? !1 : t === "" ? !0 : t;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function De(l, e) {
|
|
22
22
|
if (e === void 0 || e.startsWith("./") || e.startsWith("http") || l === void 0)
|
|
23
23
|
return e;
|
|
24
24
|
const t = l.lastIndexOf("/");
|
|
@@ -30,41 +30,41 @@ function me(l, e) {
|
|
|
30
30
|
}
|
|
31
31
|
return e;
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
function
|
|
35
|
-
|
|
33
|
+
const J = new Array();
|
|
34
|
+
function Be(l) {
|
|
35
|
+
J.push(l);
|
|
36
36
|
}
|
|
37
|
-
const R = "NEEDLE_progressive", S =
|
|
37
|
+
const R = "NEEDLE_progressive", S = Z("debugprogressive"), V = Symbol("needle-progressive-texture"), z = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Set();
|
|
38
38
|
if (S) {
|
|
39
39
|
let l = function() {
|
|
40
|
-
e += 1, console.log("Toggle LOD level", e,
|
|
40
|
+
e += 1, console.log("Toggle LOD level", e, z), z.forEach((i, n) => {
|
|
41
41
|
for (const s of i.keys) {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
const a =
|
|
45
|
-
|
|
46
|
-
} else if (
|
|
47
|
-
|
|
42
|
+
const o = n[s];
|
|
43
|
+
if (o.isBufferGeometry === !0) {
|
|
44
|
+
const a = v.getMeshLODInformation(o), h = a ? Math.min(e, a.lods.length) : 0;
|
|
45
|
+
n["DEBUG:LOD"] = e, v.assignMeshLOD(n, h), a && (t = Math.max(t, a.lods.length - 1));
|
|
46
|
+
} else if (n.isMaterial === !0) {
|
|
47
|
+
n["DEBUG:LOD"] = e, v.assignTextureLOD(n, e);
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}), e >= t && (e = -1);
|
|
52
52
|
}, e = -1, t = 2, r = !1;
|
|
53
53
|
window.addEventListener("keyup", (i) => {
|
|
54
|
-
i.key === "p" && l(), i.key === "w" && (r = !r,
|
|
55
|
-
|
|
54
|
+
i.key === "p" && l(), i.key === "w" && (r = !r, Q && Q.forEach((n) => {
|
|
55
|
+
n.name != "BackgroundCubeMaterial" && "wireframe" in n && (n.wireframe = r);
|
|
56
56
|
}));
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function te(l, e, t) {
|
|
60
60
|
var i;
|
|
61
61
|
if (!S)
|
|
62
62
|
return;
|
|
63
|
-
|
|
64
|
-
const r =
|
|
63
|
+
z.has(l) || z.set(l, { keys: [], sourceId: t });
|
|
64
|
+
const r = z.get(l);
|
|
65
65
|
((i = r == null ? void 0 : r.keys) == null ? void 0 : i.includes(e)) == !1 && r.keys.push(e);
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const M = class {
|
|
68
68
|
constructor(e, t) {
|
|
69
69
|
u(this, "parser");
|
|
70
70
|
u(this, "url");
|
|
@@ -84,11 +84,11 @@ const v = class {
|
|
|
84
84
|
* @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
|
|
85
85
|
*/
|
|
86
86
|
static hasLODLevelAvailable(e, t) {
|
|
87
|
-
var
|
|
87
|
+
var n;
|
|
88
88
|
if (e.isMaterial === !0) {
|
|
89
89
|
for (const s of Object.keys(e)) {
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
90
|
+
const o = e[s];
|
|
91
|
+
if (o.isTexture && this.hasLODLevelAvailable(o, t))
|
|
92
92
|
return !0;
|
|
93
93
|
}
|
|
94
94
|
return !1;
|
|
@@ -98,7 +98,7 @@ const v = class {
|
|
|
98
98
|
return !0;
|
|
99
99
|
}
|
|
100
100
|
let r, i;
|
|
101
|
-
if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (
|
|
101
|
+
if (e.isMesh ? r = e.geometry : (e.isBufferGeometry || e.isTexture) && (r = e), r && (n = r == null ? void 0 : r.userData) != null && n.LODS) {
|
|
102
102
|
const s = r.userData.LODS;
|
|
103
103
|
if (i = this.lodInfos.get(s.key), t === void 0)
|
|
104
104
|
return i != null;
|
|
@@ -125,19 +125,19 @@ const v = class {
|
|
|
125
125
|
var r;
|
|
126
126
|
if (!e)
|
|
127
127
|
return Promise.resolve(null);
|
|
128
|
-
if (e instanceof
|
|
129
|
-
const i = e.geometry,
|
|
130
|
-
if (!
|
|
128
|
+
if (e instanceof q || e.isMesh === !0) {
|
|
129
|
+
const i = e.geometry, n = this.getAssignedLODInformation(i);
|
|
130
|
+
if (!n)
|
|
131
131
|
return Promise.resolve(null);
|
|
132
|
-
for (const s of
|
|
132
|
+
for (const s of J)
|
|
133
133
|
(r = s.onBeforeGetLODMesh) == null || r.call(s, e, t);
|
|
134
|
-
return e["LOD:requested level"] = t,
|
|
134
|
+
return e["LOD:requested level"] = t, M.getOrLoadLOD(i, t).then((s) => {
|
|
135
135
|
if (e["LOD:requested level"] === t) {
|
|
136
136
|
if (delete e["LOD:requested level"], Array.isArray(s)) {
|
|
137
|
-
const
|
|
138
|
-
s = s[
|
|
137
|
+
const o = n.index || 0;
|
|
138
|
+
s = s[o];
|
|
139
139
|
}
|
|
140
|
-
s && i != s && s instanceof X && (e.geometry = s, S &&
|
|
140
|
+
s && i != s && s instanceof X && (e.geometry = s, S && te(e, "geometry", n.url));
|
|
141
141
|
}
|
|
142
142
|
return s;
|
|
143
143
|
}).catch((s) => (console.error("Error loading mesh LOD", e, s), null));
|
|
@@ -156,193 +156,193 @@ const v = class {
|
|
|
156
156
|
if (!e)
|
|
157
157
|
return Promise.resolve(null);
|
|
158
158
|
if (e instanceof le || e.isMaterial === !0) {
|
|
159
|
-
const r = e, i = [],
|
|
160
|
-
if (S &&
|
|
159
|
+
const r = e, i = [], n = new Array();
|
|
160
|
+
if (S && Q.add(r), r instanceof ue)
|
|
161
161
|
for (const s of Object.keys(r.uniforms)) {
|
|
162
|
-
const
|
|
163
|
-
if ((
|
|
164
|
-
const a = this.assignTextureLODForSlot(
|
|
165
|
-
i.push(a),
|
|
162
|
+
const o = r.uniforms[s].value;
|
|
163
|
+
if ((o == null ? void 0 : o.isTexture) === !0) {
|
|
164
|
+
const a = this.assignTextureLODForSlot(o, t, r, s);
|
|
165
|
+
i.push(a), n.push(s);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
else
|
|
169
169
|
for (const s of Object.keys(r)) {
|
|
170
|
-
const
|
|
171
|
-
if ((
|
|
172
|
-
const a = this.assignTextureLODForSlot(
|
|
173
|
-
i.push(a),
|
|
170
|
+
const o = r[s];
|
|
171
|
+
if ((o == null ? void 0 : o.isTexture) === !0) {
|
|
172
|
+
const a = this.assignTextureLODForSlot(o, t, r, s);
|
|
173
|
+
i.push(a), n.push(s);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
return Promise.all(i).then((s) => {
|
|
177
|
-
const
|
|
177
|
+
const o = new Array();
|
|
178
178
|
for (let a = 0; a < s.length; a++) {
|
|
179
|
-
const
|
|
180
|
-
|
|
179
|
+
const h = s[a], d = n[a];
|
|
180
|
+
h && h.isTexture === !0 ? o.push({ material: r, slot: d, texture: h, level: t }) : o.push({ material: r, slot: d, texture: null, level: t });
|
|
181
181
|
}
|
|
182
|
-
return
|
|
182
|
+
return o;
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
|
-
if (e instanceof
|
|
185
|
+
if (e instanceof U || e.isTexture === !0) {
|
|
186
186
|
const r = e;
|
|
187
187
|
return this.assignTextureLODForSlot(r, t, null, null);
|
|
188
188
|
}
|
|
189
189
|
return Promise.resolve(null);
|
|
190
190
|
}
|
|
191
191
|
static assignTextureLODForSlot(e, t, r, i) {
|
|
192
|
-
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) :
|
|
193
|
-
if (Array.isArray(
|
|
192
|
+
return (e == null ? void 0 : e.isTexture) !== !0 ? Promise.resolve(null) : M.getOrLoadLOD(e, t).then((n) => {
|
|
193
|
+
if (Array.isArray(n))
|
|
194
194
|
return null;
|
|
195
|
-
if ((
|
|
196
|
-
if (
|
|
195
|
+
if ((n == null ? void 0 : n.isTexture) === !0) {
|
|
196
|
+
if (n != e && (r && i && (r[i] = n), S && i && r)) {
|
|
197
197
|
const s = this.getAssignedLODInformation(e);
|
|
198
|
-
s &&
|
|
198
|
+
s && te(r, i, s.url);
|
|
199
199
|
}
|
|
200
|
-
return
|
|
200
|
+
return n;
|
|
201
201
|
} else
|
|
202
202
|
S == "verbose" && console.warn("No LOD found for", e, t);
|
|
203
203
|
return null;
|
|
204
|
-
}).catch((
|
|
204
|
+
}).catch((n) => (console.error("Error loading LOD", e, n), null));
|
|
205
205
|
}
|
|
206
206
|
afterRoot(e) {
|
|
207
207
|
var t, r;
|
|
208
|
-
return S && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i,
|
|
208
|
+
return S && console.log("AFTER", this.url, e), (t = this.parser.json.textures) == null || t.forEach((i, n) => {
|
|
209
209
|
if (i != null && i.extensions) {
|
|
210
210
|
const s = i == null ? void 0 : i.extensions[R];
|
|
211
211
|
if (s) {
|
|
212
|
-
let
|
|
212
|
+
let o = !1;
|
|
213
213
|
for (const a of this.parser.associations.keys())
|
|
214
|
-
a.isTexture === !0 && this.parser.associations.get(a).textures ===
|
|
215
|
-
|
|
216
|
-
a &&
|
|
214
|
+
a.isTexture === !0 && this.parser.associations.get(a).textures === n && (o = !0, M.registerTexture(this.url, a, n, s));
|
|
215
|
+
o || this.parser.getDependency("texture", n).then((a) => {
|
|
216
|
+
a && M.registerTexture(this.url, a, n, s);
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
}), (r = this.parser.json.meshes) == null || r.forEach((i,
|
|
220
|
+
}), (r = this.parser.json.meshes) == null || r.forEach((i, n) => {
|
|
221
221
|
if (i != null && i.extensions) {
|
|
222
222
|
const s = i == null ? void 0 : i.extensions[R];
|
|
223
223
|
if (s && s.lods) {
|
|
224
|
-
for (const
|
|
225
|
-
if (
|
|
226
|
-
const a = this.parser.associations.get(
|
|
227
|
-
a.meshes ===
|
|
224
|
+
for (const o of this.parser.associations.keys())
|
|
225
|
+
if (o.isMesh) {
|
|
226
|
+
const a = this.parser.associations.get(o);
|
|
227
|
+
a.meshes === n && M.registerMesh(this.url, s.guid, o, s.lods.length, a.primitives, s);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
}), null;
|
|
232
232
|
}
|
|
233
233
|
static async getOrLoadLOD(e, t) {
|
|
234
|
-
var
|
|
234
|
+
var o, a, h;
|
|
235
235
|
const r = S == "verbose", i = e.userData.LODS;
|
|
236
236
|
if (!i)
|
|
237
237
|
return null;
|
|
238
|
-
const
|
|
238
|
+
const n = i == null ? void 0 : i.key;
|
|
239
239
|
let s;
|
|
240
240
|
if (e.isTexture === !0) {
|
|
241
|
-
const
|
|
242
|
-
|
|
241
|
+
const d = e;
|
|
242
|
+
d.source && d.source[V] && (s = d.source[V]);
|
|
243
243
|
}
|
|
244
|
-
if (s || (s =
|
|
244
|
+
if (s || (s = M.lodInfos.get(n)), s) {
|
|
245
245
|
if (t > 0) {
|
|
246
|
-
let
|
|
246
|
+
let f = !1;
|
|
247
247
|
const w = Array.isArray(s.lods);
|
|
248
|
-
if (w && t >= s.lods.length ?
|
|
249
|
-
return this.lowresCache.get(
|
|
248
|
+
if (w && t >= s.lods.length ? f = !0 : w || (f = !0), f)
|
|
249
|
+
return this.lowresCache.get(n);
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
251
|
+
const d = Array.isArray(s.lods) ? s.lods[t].path : s.lods;
|
|
252
|
+
if (!d)
|
|
253
253
|
return S && !s["missing:uri"] && (s["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + t, s)), null;
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
254
|
+
const c = De(i.url, d);
|
|
255
|
+
if (c.endsWith(".glb") || c.endsWith(".gltf")) {
|
|
256
256
|
if (!s.guid)
|
|
257
257
|
return console.warn("missing pointer for glb/gltf texture", s), null;
|
|
258
|
-
const
|
|
258
|
+
const f = c + "_" + s.guid, w = this.previouslyLoaded.get(f);
|
|
259
259
|
if (w !== void 0) {
|
|
260
|
-
r && console.log(`LOD ${t} was already loading/loaded: ${
|
|
261
|
-
let
|
|
262
|
-
`,
|
|
263
|
-
if (
|
|
264
|
-
return
|
|
260
|
+
r && console.log(`LOD ${t} was already loading/loaded: ${f}`);
|
|
261
|
+
let D = await w.catch((I) => (console.error(`Error loading LOD ${t} from ${c}
|
|
262
|
+
`, I), null)), C = !1;
|
|
263
|
+
if (D == null || (D instanceof U && e instanceof U ? (o = D.image) != null && o.data || (a = D.source) != null && a.data ? D = this.copySettings(e, D) : (C = !0, this.previouslyLoaded.delete(f)) : D instanceof X && e instanceof X && ((h = D.attributes.position) != null && h.array || (C = !0, this.previouslyLoaded.delete(f)))), !C)
|
|
264
|
+
return D;
|
|
265
265
|
}
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
ie(
|
|
269
|
-
let
|
|
270
|
-
if (
|
|
271
|
-
const
|
|
272
|
-
|
|
266
|
+
const L = s, A = new Promise(async (D, C) => {
|
|
267
|
+
const I = new ge();
|
|
268
|
+
ie(I), S && (await new Promise((y) => setTimeout(y, 1e3)), r && console.warn("Start loading (delayed) " + c, L.guid));
|
|
269
|
+
let m = c;
|
|
270
|
+
if (L && Array.isArray(L.lods)) {
|
|
271
|
+
const y = L.lods[t];
|
|
272
|
+
y.hash && (m += "?v=" + y.hash);
|
|
273
273
|
}
|
|
274
|
-
const
|
|
275
|
-
`,
|
|
276
|
-
if (!
|
|
274
|
+
const p = await I.loadAsync(m).catch((y) => (console.error(`Error loading LOD ${t} from ${c}
|
|
275
|
+
`, y), null));
|
|
276
|
+
if (!p)
|
|
277
277
|
return null;
|
|
278
|
-
const
|
|
279
|
-
r && console.log("Loading finished " +
|
|
278
|
+
const b = p.parser;
|
|
279
|
+
r && console.log("Loading finished " + c, L.guid);
|
|
280
280
|
let x = 0;
|
|
281
|
-
if (
|
|
282
|
-
let
|
|
283
|
-
for (const
|
|
284
|
-
if (
|
|
285
|
-
const O =
|
|
286
|
-
if (O != null && O.guid && O.guid ===
|
|
287
|
-
|
|
281
|
+
if (p.parser.json.textures) {
|
|
282
|
+
let y = !1;
|
|
283
|
+
for (const g of p.parser.json.textures) {
|
|
284
|
+
if (g != null && g.extensions) {
|
|
285
|
+
const O = g == null ? void 0 : g.extensions[R];
|
|
286
|
+
if (O != null && O.guid && O.guid === L.guid) {
|
|
287
|
+
y = !0;
|
|
288
288
|
break;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
x++;
|
|
292
292
|
}
|
|
293
|
-
if (
|
|
294
|
-
let
|
|
295
|
-
return r && console.log('change "' + e.name + '" → "' +
|
|
293
|
+
if (y) {
|
|
294
|
+
let g = await b.getDependency("texture", x);
|
|
295
|
+
return r && console.log('change "' + e.name + '" → "' + g.name + '"', c, x, g, f), e instanceof U && (g = this.copySettings(e, g)), g && (g.guid = L.guid), D(g);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
if (x = 0,
|
|
299
|
-
let
|
|
300
|
-
for (const
|
|
301
|
-
if (
|
|
302
|
-
const O =
|
|
303
|
-
if (O != null && O.guid && O.guid ===
|
|
304
|
-
|
|
298
|
+
if (x = 0, p.parser.json.meshes) {
|
|
299
|
+
let y = !1;
|
|
300
|
+
for (const g of p.parser.json.meshes) {
|
|
301
|
+
if (g != null && g.extensions) {
|
|
302
|
+
const O = g == null ? void 0 : g.extensions[R];
|
|
303
|
+
if (O != null && O.guid && O.guid === L.guid) {
|
|
304
|
+
y = !0;
|
|
305
305
|
break;
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
x++;
|
|
309
309
|
}
|
|
310
|
-
if (
|
|
311
|
-
const
|
|
312
|
-
if (r && console.log(`Loaded Mesh "${
|
|
313
|
-
const
|
|
314
|
-
return
|
|
310
|
+
if (y) {
|
|
311
|
+
const g = await b.getDependency("mesh", x), O = L;
|
|
312
|
+
if (r && console.log(`Loaded Mesh "${g.name}"`, c, x, g, f), g.isMesh === !0) {
|
|
313
|
+
const P = g.geometry;
|
|
314
|
+
return M.assignLODInformation(i.url, P, n, t, void 0, O.density), D(P);
|
|
315
315
|
} else {
|
|
316
|
-
const
|
|
317
|
-
for (let _ = 0; _ <
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
const
|
|
321
|
-
|
|
316
|
+
const P = new Array();
|
|
317
|
+
for (let _ = 0; _ < g.children.length; _++) {
|
|
318
|
+
const E = g.children[_];
|
|
319
|
+
if (E instanceof q) {
|
|
320
|
+
const N = E.geometry;
|
|
321
|
+
M.assignLODInformation(i.url, N, n, t, _, O.density), P.push(N);
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
return
|
|
324
|
+
return D(P);
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
return
|
|
328
|
+
return D(null);
|
|
329
329
|
});
|
|
330
|
-
return this.previouslyLoaded.set(
|
|
331
|
-
} else if (e instanceof
|
|
332
|
-
r && console.log("Load texture from uri: " +
|
|
333
|
-
const w = await new ce().loadAsync(
|
|
334
|
-
return w ? (w.guid = s.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, r && console.log(s, w)) : S && console.warn("failed loading",
|
|
330
|
+
return this.previouslyLoaded.set(f, A), await A;
|
|
331
|
+
} else if (e instanceof U) {
|
|
332
|
+
r && console.log("Load texture from uri: " + c);
|
|
333
|
+
const w = await new ce().loadAsync(c);
|
|
334
|
+
return w ? (w.guid = s.guid, w.flipY = !1, w.needsUpdate = !0, w.colorSpace = e.colorSpace, r && console.log(s, w)) : S && console.warn("failed loading", c), w;
|
|
335
335
|
}
|
|
336
336
|
} else
|
|
337
|
-
S && console.warn(`Can not load LOD ${t}: no LOD info found for "${
|
|
337
|
+
S && console.warn(`Can not load LOD ${t}: no LOD info found for "${n}" ${e.name}`, e.type);
|
|
338
338
|
return null;
|
|
339
339
|
}
|
|
340
|
-
static assignLODInformation(e, t, r, i,
|
|
340
|
+
static assignLODInformation(e, t, r, i, n, s) {
|
|
341
341
|
if (!t)
|
|
342
342
|
return;
|
|
343
343
|
t.userData || (t.userData = {});
|
|
344
|
-
const
|
|
345
|
-
t.userData.LODS =
|
|
344
|
+
const o = new xe(e, r, i, n, s);
|
|
345
|
+
t.userData.LODS = o, t.userData.LOD = i;
|
|
346
346
|
}
|
|
347
347
|
static getAssignedLODInformation(e) {
|
|
348
348
|
var t;
|
|
@@ -353,32 +353,32 @@ const v = class {
|
|
|
353
353
|
return r || (t = t.clone(), this._copiedTextures.set(e, t), t.offset = e.offset, t.repeat = e.repeat, t.colorSpace = e.colorSpace, t);
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
|
-
let
|
|
356
|
+
let v = M;
|
|
357
357
|
/**
|
|
358
358
|
* Register a texture with LOD information
|
|
359
359
|
*/
|
|
360
|
-
u(
|
|
361
|
-
S && console.log("> Progressive: register texture", r, t.name, t.uuid, t, i), t.source && (t.source[
|
|
362
|
-
const
|
|
363
|
-
|
|
360
|
+
u(v, "registerTexture", (e, t, r, i) => {
|
|
361
|
+
S && console.log("> Progressive: register texture", r, t.name, t.uuid, t, i), t.source && (t.source[V] = i);
|
|
362
|
+
const n = i.guid;
|
|
363
|
+
M.assignLODInformation(e, t, n, 0, 0, void 0), M.lodInfos.set(n, i), M.lowresCache.set(n, t);
|
|
364
364
|
}), /**
|
|
365
365
|
* Register a mesh with LOD information
|
|
366
366
|
*/
|
|
367
|
-
u(
|
|
368
|
-
var
|
|
369
|
-
S && console.log("> Progressive: register mesh",
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
let a =
|
|
373
|
-
a ? a.push(r.geometry) : a = [r.geometry],
|
|
374
|
-
for (const
|
|
375
|
-
(
|
|
367
|
+
u(v, "registerMesh", (e, t, r, i, n, s) => {
|
|
368
|
+
var h;
|
|
369
|
+
S && console.log("> Progressive: register mesh", n, r.name, s, r.uuid, r);
|
|
370
|
+
const o = r.geometry;
|
|
371
|
+
o.userData || (o.userData = {}), M.assignLODInformation(e, o, t, i, n, s.density), M.lodInfos.set(t, s);
|
|
372
|
+
let a = M.lowresCache.get(t);
|
|
373
|
+
a ? a.push(r.geometry) : a = [r.geometry], M.lowresCache.set(t, a);
|
|
374
|
+
for (const d of J)
|
|
375
|
+
(h = d.onRegisteredNewMesh) == null || h.call(d, r, s);
|
|
376
376
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
377
|
-
u(
|
|
378
|
-
u(
|
|
379
|
-
u(
|
|
377
|
+
u(v, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
|
|
378
|
+
u(v, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
|
|
379
|
+
u(v, "lowresCache", /* @__PURE__ */ new Map()), u(v, "_copiedTextures", /* @__PURE__ */ new Map());
|
|
380
380
|
class xe {
|
|
381
|
-
constructor(e, t, r, i,
|
|
381
|
+
constructor(e, t, r, i, n) {
|
|
382
382
|
u(this, "url");
|
|
383
383
|
/** the key to lookup the LOD information */
|
|
384
384
|
u(this, "key");
|
|
@@ -387,13 +387,13 @@ class xe {
|
|
|
387
387
|
u(this, "index");
|
|
388
388
|
/** the mesh density */
|
|
389
389
|
u(this, "density");
|
|
390
|
-
this.url = e, this.key = t, this.level = r, i != null && (this.index = i),
|
|
390
|
+
this.url = e, this.key = t, this.level = r, i != null && (this.index = i), n != null && (this.density = n);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
const
|
|
393
|
+
const Y = Z("debugprogressive"), we = Z("noprogressive"), T = class {
|
|
394
394
|
constructor(e) {
|
|
395
395
|
u(this, "renderer");
|
|
396
|
-
u(this, "projectionScreenMatrix", new
|
|
396
|
+
u(this, "projectionScreenMatrix", new j());
|
|
397
397
|
u(this, "cameraFrustrum", new fe());
|
|
398
398
|
/**
|
|
399
399
|
* 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.
|
|
@@ -407,11 +407,11 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
|
|
|
407
407
|
u(this, "_originalRender");
|
|
408
408
|
// private testIfLODLevelsAreAvailable() {
|
|
409
409
|
u(this, "_sphere", new de());
|
|
410
|
-
u(this, "_tempBox", new
|
|
411
|
-
u(this, "tempMatrix", new
|
|
412
|
-
u(this, "_tempWorldPosition", new
|
|
413
|
-
u(this, "_tempBoxSize", new
|
|
414
|
-
u(this, "_tempBox2Size", new
|
|
410
|
+
u(this, "_tempBox", new ee());
|
|
411
|
+
u(this, "tempMatrix", new j());
|
|
412
|
+
u(this, "_tempWorldPosition", new k());
|
|
413
|
+
u(this, "_tempBoxSize", new k());
|
|
414
|
+
u(this, "_tempBox2Size", new k());
|
|
415
415
|
this.renderer = e;
|
|
416
416
|
}
|
|
417
417
|
/** @internal */
|
|
@@ -429,9 +429,9 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
|
|
|
429
429
|
this._originalRender = this.renderer.render;
|
|
430
430
|
const t = this;
|
|
431
431
|
let r = 0;
|
|
432
|
-
se(this.renderer), this.renderer.render = function(i,
|
|
433
|
-
const s = r++,
|
|
434
|
-
t.onBeforeRender(i,
|
|
432
|
+
se(this.renderer), this.renderer.render = function(i, n) {
|
|
433
|
+
const s = r++, o = e++;
|
|
434
|
+
t.onBeforeRender(i, n, o, s), t._originalRender.call(this, i, n), t.onAfterRender(i, n, o, s), e--;
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
437
|
disable() {
|
|
@@ -440,36 +440,46 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
|
|
|
440
440
|
onBeforeRender(e, t, r, i) {
|
|
441
441
|
}
|
|
442
442
|
onAfterRender(e, t, r, i) {
|
|
443
|
+
var h, d;
|
|
443
444
|
if (we || this.pause || this.updateInterval > 0 && i % this.updateInterval != 0)
|
|
444
445
|
return;
|
|
445
446
|
this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this.cameraFrustrum.setFromProjectionMatrix(this.projectionScreenMatrix, this.renderer.coordinateSystem);
|
|
446
|
-
const
|
|
447
|
-
for (const
|
|
448
|
-
|
|
449
|
-
|
|
447
|
+
const n = 1e5, s = this.renderer.renderLists.get(e, r), o = s.opaque;
|
|
448
|
+
for (const c of o) {
|
|
449
|
+
if (c.material && (((h = c.geometry) == null ? void 0 : h.type) === "BoxGeometry" || ((d = c.geometry) == null ? void 0 : d.type) === "BufferGeometry") && (c.material.name === "SphericalGaussianBlur" || c.material.name == "BackgroundCubeMaterial" || c.material.name === "CubemapFromEquirect" || c.material.name === "EquirectangularToCubeUV")) {
|
|
450
|
+
Y && (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)));
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
const f = c.object;
|
|
454
|
+
(f instanceof q || f.isMesh) && this.updateLODs(e, t, f, n);
|
|
455
|
+
}
|
|
456
|
+
const a = s.transparent;
|
|
457
|
+
for (const c of a) {
|
|
458
|
+
const f = c.object;
|
|
459
|
+
(f instanceof q || f.isMesh) && this.updateLODs(e, t, f, n);
|
|
450
460
|
}
|
|
451
461
|
}
|
|
452
462
|
/** Update the LOD levels for the renderer. */
|
|
453
463
|
updateLODs(e, t, r, i) {
|
|
454
|
-
var a,
|
|
455
|
-
for (const
|
|
456
|
-
(a =
|
|
457
|
-
let
|
|
458
|
-
|
|
459
|
-
let s = this.calculateLodLevel(t, r,
|
|
464
|
+
var a, h;
|
|
465
|
+
for (const d of this.plugins)
|
|
466
|
+
(a = d.onBeforeUpdateLOD) == null || a.call(d, this.renderer, e, t, r);
|
|
467
|
+
let n = r.userData.LOD_state;
|
|
468
|
+
n || (n = new Oe(), r.userData.LOD_state = n);
|
|
469
|
+
let s = this.calculateLodLevel(t, r, n, i);
|
|
460
470
|
s = Math.round(s), s >= 0 && this.loadProgressiveMeshes(r, s);
|
|
461
|
-
let
|
|
471
|
+
let o = 0;
|
|
462
472
|
if (r.material) {
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
465
|
-
for (const
|
|
466
|
-
this.loadProgressiveTextures(
|
|
473
|
+
const d = r["DEBUG:LOD"];
|
|
474
|
+
if (d != null && (o = d), Array.isArray(r.material))
|
|
475
|
+
for (const c of r.material)
|
|
476
|
+
this.loadProgressiveTextures(c, o);
|
|
467
477
|
else
|
|
468
|
-
this.loadProgressiveTextures(r.material,
|
|
478
|
+
this.loadProgressiveTextures(r.material, o);
|
|
469
479
|
}
|
|
470
|
-
for (const
|
|
471
|
-
(
|
|
472
|
-
|
|
480
|
+
for (const d of this.plugins)
|
|
481
|
+
(h = d.onAfterUpdatedLOD) == null || h.call(d, this.renderer, e, t, r, s);
|
|
482
|
+
n.lastLodLevel = s;
|
|
473
483
|
}
|
|
474
484
|
/** Load progressive textures for the given material
|
|
475
485
|
* @param material the material to load the textures for
|
|
@@ -477,7 +487,7 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
|
|
|
477
487
|
* @returns Promise with true if the LOD was loaded, false if not
|
|
478
488
|
*/
|
|
479
489
|
loadProgressiveTextures(e, t) {
|
|
480
|
-
return e && e.userData && e.userData.LOD !== t ? (e.userData.LOD = t,
|
|
490
|
+
return e && e.userData && e.userData.LOD !== t ? (e.userData.LOD = t, v.assignTextureLOD(e, t)) : Promise.resolve(null);
|
|
481
491
|
}
|
|
482
492
|
/** Load progressive meshes for the given mesh
|
|
483
493
|
* @param mesh the mesh to load the LOD for
|
|
@@ -491,92 +501,92 @@ const te = Q("debugprogressive"), we = Q("noprogressive"), P = class {
|
|
|
491
501
|
if (e.userData || (e.userData = {}), e.userData.LOD !== t) {
|
|
492
502
|
e.userData.LOD = t;
|
|
493
503
|
const r = e.geometry;
|
|
494
|
-
return
|
|
504
|
+
return v.assignMeshLOD(e, t).then((i) => (i && e.userData.LOD == t && r != e.geometry, i));
|
|
495
505
|
}
|
|
496
506
|
return Promise.resolve(null);
|
|
497
507
|
}
|
|
498
508
|
calculateLodLevel(e, t, r, i) {
|
|
499
|
-
var
|
|
509
|
+
var o;
|
|
500
510
|
if (!t)
|
|
501
511
|
return -1;
|
|
502
512
|
let s = 10 + 1;
|
|
503
513
|
if (e) {
|
|
504
|
-
if (
|
|
514
|
+
if (Y && t["DEBUG:LOD"] != null)
|
|
505
515
|
return t["DEBUG:LOD"];
|
|
506
|
-
const a =
|
|
507
|
-
if (!
|
|
516
|
+
const a = v.getMeshLODInformation(t.geometry), h = a == null ? void 0 : a.lods;
|
|
517
|
+
if (!h || h.length <= 0 || !((o = this.cameraFrustrum) != null && o.intersectsObject(t)))
|
|
508
518
|
return 99;
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
511
|
-
const
|
|
519
|
+
const d = t.geometry.boundingBox;
|
|
520
|
+
if (d && e.isPerspectiveCamera) {
|
|
521
|
+
const c = e;
|
|
512
522
|
if (t.geometry.attributes.color && t.geometry.attributes.color.count < 100 && t.geometry.boundingSphere) {
|
|
513
523
|
this._sphere.copy(t.geometry.boundingSphere), this._sphere.applyMatrix4(t.matrixWorld);
|
|
514
|
-
const
|
|
515
|
-
if (this._sphere.containsPoint(
|
|
524
|
+
const m = e.getWorldPosition(this._tempWorldPosition);
|
|
525
|
+
if (this._sphere.containsPoint(m))
|
|
516
526
|
return 0;
|
|
517
527
|
}
|
|
518
|
-
if (this._tempBox.copy(
|
|
519
|
-
const
|
|
520
|
-
let
|
|
521
|
-
const O = 2,
|
|
522
|
-
|
|
523
|
-
const
|
|
524
|
-
r.lastCentrality = (
|
|
528
|
+
if (this._tempBox.copy(d), this._tempBox.applyMatrix4(t.matrixWorld), this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && c.fov > 70) {
|
|
529
|
+
const m = this._tempBox.min, p = this._tempBox.max;
|
|
530
|
+
let b = m.x, x = m.y, y = p.x, g = p.y;
|
|
531
|
+
const O = 2, P = 1.5, _ = (m.x + p.x) * 0.5, E = (m.y + p.y) * 0.5;
|
|
532
|
+
b = (b - _) * O + _, x = (x - E) * O + E, y = (y - _) * O + _, g = (g - E) * O + E;
|
|
533
|
+
const N = b < 0 && y > 0 ? 0 : Math.min(Math.abs(m.x), Math.abs(p.x)), ne = x < 0 && g > 0 ? 0 : Math.min(Math.abs(m.y), Math.abs(p.y)), K = Math.max(N, ne);
|
|
534
|
+
r.lastCentrality = (P - K) * (P - K) * (P - K);
|
|
525
535
|
} else
|
|
526
536
|
r.lastCentrality = 1;
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
const w = e.matrixWorldInverse,
|
|
530
|
-
|
|
531
|
-
const A =
|
|
532
|
-
if (Math.max(
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
537
|
+
const f = this._tempBox.getSize(this._tempBoxSize);
|
|
538
|
+
f.multiplyScalar(0.5), screen.availHeight > 0 && f.multiplyScalar(this.renderer.domElement.clientHeight / screen.availHeight), f.x *= c.aspect;
|
|
539
|
+
const w = e.matrixWorldInverse, L = new ee();
|
|
540
|
+
L.copy(d), L.applyMatrix4(t.matrixWorld), L.applyMatrix4(w);
|
|
541
|
+
const A = L.getSize(this._tempBox2Size), G = Math.max(A.x, A.y);
|
|
542
|
+
if (Math.max(f.x, f.y) != 0 && G != 0 && (f.z = A.z / Math.max(A.x, A.y) * Math.max(f.x, f.y)), r.lastScreenCoverage = Math.max(f.x, f.y, f.z), r.lastScreenspaceVolume.copy(f), r.lastScreenCoverage *= r.lastCentrality, Y && T.debugDrawLine) {
|
|
543
|
+
const m = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
544
|
+
m.invert();
|
|
545
|
+
const p = T.corner0, b = T.corner1, x = T.corner2, y = T.corner3;
|
|
546
|
+
p.copy(this._tempBox.min), b.copy(this._tempBox.max), b.x = p.x, x.copy(this._tempBox.max), x.y = p.y, y.copy(this._tempBox.max);
|
|
547
|
+
const g = (p.z + y.z) * 0.5;
|
|
548
|
+
p.z = b.z = x.z = y.z = g, p.applyMatrix4(m), b.applyMatrix4(m), x.applyMatrix4(m), y.applyMatrix4(m), T.debugDrawLine(p, b, 255), T.debugDrawLine(p, x, 255), T.debugDrawLine(b, y, 255), T.debugDrawLine(x, y, 255);
|
|
539
549
|
}
|
|
540
|
-
let
|
|
541
|
-
if (
|
|
542
|
-
for (let
|
|
543
|
-
if (
|
|
544
|
-
|
|
550
|
+
let C = 999;
|
|
551
|
+
if (h && r.lastScreenCoverage > 0) {
|
|
552
|
+
for (let m = 0; m < h.length; m++)
|
|
553
|
+
if (h[m].density / r.lastScreenCoverage < i) {
|
|
554
|
+
C = m;
|
|
545
555
|
break;
|
|
546
556
|
}
|
|
547
557
|
}
|
|
548
|
-
|
|
558
|
+
C < s && (s = C);
|
|
549
559
|
}
|
|
550
560
|
}
|
|
551
561
|
return s;
|
|
552
562
|
}
|
|
553
563
|
};
|
|
554
|
-
let
|
|
564
|
+
let B = T;
|
|
555
565
|
/** 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.
|
|
556
566
|
*/
|
|
557
|
-
u(
|
|
567
|
+
u(B, "debugDrawLine"), u(B, "corner0", new k()), u(B, "corner1", new k()), u(B, "corner2", new k()), u(B, "corner3", new k());
|
|
558
568
|
class Oe {
|
|
559
569
|
constructor() {
|
|
560
570
|
u(this, "lastLodLevel", 0);
|
|
561
571
|
u(this, "lastScreenCoverage", 0);
|
|
562
|
-
u(this, "lastScreenspaceVolume", new
|
|
572
|
+
u(this, "lastScreenspaceVolume", new k());
|
|
563
573
|
u(this, "lastCentrality", 0);
|
|
564
574
|
}
|
|
565
575
|
}
|
|
566
|
-
const re = Symbol("NEEDLE_mesh_lod"),
|
|
567
|
-
function
|
|
576
|
+
const re = Symbol("NEEDLE_mesh_lod"), $ = Symbol("NEEDLE_texture_lod");
|
|
577
|
+
function Me(l) {
|
|
568
578
|
if (!l)
|
|
569
579
|
return null;
|
|
570
580
|
let e = null, t = null;
|
|
571
581
|
for (let r = l; r != null; r = Object.getPrototypeOf(r)) {
|
|
572
|
-
const i = Object.getOwnPropertySymbols(r),
|
|
573
|
-
!e &&
|
|
582
|
+
const i = Object.getOwnPropertySymbols(r), n = i.find((o) => o.toString() == "Symbol(renderer)"), s = i.find((o) => o.toString() == "Symbol(scene)");
|
|
583
|
+
!e && n != null && (e = l[n].threeRenderer), !t && s != null && (t = l[s]);
|
|
574
584
|
}
|
|
575
585
|
if (e) {
|
|
576
586
|
console.log("Adding Needle LODs to modelviewer");
|
|
577
|
-
const r = new
|
|
578
|
-
if (r.plugins.push(new
|
|
579
|
-
const i = t.camera || t.traverse((
|
|
587
|
+
const r = new B(e);
|
|
588
|
+
if (r.plugins.push(new ve(l)), r.enable(), t) {
|
|
589
|
+
const i = t.camera || t.traverse((n) => n.type == "PerspectiveCamera")[0];
|
|
580
590
|
i && e.render(t, i);
|
|
581
591
|
}
|
|
582
592
|
return () => {
|
|
@@ -585,85 +595,81 @@ function ve(l) {
|
|
|
585
595
|
}
|
|
586
596
|
return null;
|
|
587
597
|
}
|
|
588
|
-
class
|
|
598
|
+
class ve {
|
|
589
599
|
constructor(e) {
|
|
590
600
|
u(this, "modelviewer");
|
|
601
|
+
u(this, "_didWarnAboutMissingUrl", !1);
|
|
591
602
|
this.modelviewer = e;
|
|
592
603
|
}
|
|
593
604
|
onBeforeUpdateLOD(e, t, r, i) {
|
|
594
605
|
this.tryParseMeshLOD(t, i), this.tryParseTextureLOD(t, i);
|
|
595
606
|
}
|
|
596
607
|
getUrl() {
|
|
597
|
-
|
|
608
|
+
let e = this.modelviewer.getAttribute("src");
|
|
609
|
+
return e || (e = this.modelviewer.src), e || (this._didWarnAboutMissingUrl || console.warn("No url found in modelviewer", this.modelviewer), this._didWarnAboutMissingUrl = !0), e;
|
|
598
610
|
}
|
|
599
611
|
tryGetCurrentGLTF(e) {
|
|
600
612
|
return e._currentGLTF;
|
|
601
613
|
}
|
|
602
614
|
tryParseTextureLOD(e, t) {
|
|
603
|
-
if (t[
|
|
615
|
+
if (t[$] == !0)
|
|
604
616
|
return;
|
|
605
|
-
t[
|
|
617
|
+
t[$] = !0;
|
|
606
618
|
const r = this.tryGetCurrentGLTF(e), i = this.getUrl();
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
if (r && t.material) {
|
|
612
|
-
let o = function(n) {
|
|
613
|
-
var g, f, L;
|
|
614
|
-
if (n[K] == !0)
|
|
619
|
+
if (i && r && t.material) {
|
|
620
|
+
let n = function(o) {
|
|
621
|
+
var h, d, c;
|
|
622
|
+
if (o[$] == !0)
|
|
615
623
|
return;
|
|
616
|
-
|
|
617
|
-
const a = Object.keys(
|
|
618
|
-
for (let
|
|
619
|
-
const w = a[
|
|
620
|
-
if ((
|
|
621
|
-
const A = (
|
|
622
|
-
if ((
|
|
623
|
-
const
|
|
624
|
-
|
|
624
|
+
o[$] = !0, o.userData && (o.userData.LOD = -1);
|
|
625
|
+
const a = Object.keys(o);
|
|
626
|
+
for (let f = 0; f < a.length; f++) {
|
|
627
|
+
const w = a[f], L = o[w];
|
|
628
|
+
if ((L == null ? void 0 : L.isTexture) === !0) {
|
|
629
|
+
const A = (d = (h = L.userData) == null ? void 0 : h.associations) == null ? void 0 : d.textures, G = r.parser.json.textures[A];
|
|
630
|
+
if ((c = G.extensions) != null && c[R]) {
|
|
631
|
+
const D = G.extensions[R];
|
|
632
|
+
D && i && v.registerTexture(i, L, D.lods.length, D);
|
|
625
633
|
}
|
|
626
634
|
}
|
|
627
635
|
}
|
|
628
636
|
};
|
|
629
637
|
const s = t.material;
|
|
630
638
|
if (Array.isArray(s))
|
|
631
|
-
for (const
|
|
632
|
-
o
|
|
639
|
+
for (const o of s)
|
|
640
|
+
n(o);
|
|
633
641
|
else
|
|
634
|
-
|
|
642
|
+
n(s);
|
|
635
643
|
}
|
|
636
644
|
}
|
|
637
645
|
tryParseMeshLOD(e, t) {
|
|
638
|
-
var
|
|
646
|
+
var n, s;
|
|
639
647
|
if (t[re] == !0)
|
|
640
648
|
return;
|
|
641
649
|
t[re] = !0;
|
|
642
650
|
const r = this.getUrl();
|
|
643
|
-
if (!r)
|
|
644
|
-
console.error("No url found in modelviewer");
|
|
651
|
+
if (!r)
|
|
645
652
|
return;
|
|
646
|
-
|
|
647
|
-
const i = (s = (o = t.userData) == null ? void 0 : o.gltfExtensions) == null ? void 0 : s[R];
|
|
653
|
+
const i = (s = (n = t.userData) == null ? void 0 : n.gltfExtensions) == null ? void 0 : s[R];
|
|
648
654
|
if (i && r) {
|
|
649
|
-
const
|
|
650
|
-
|
|
655
|
+
const o = t.uuid;
|
|
656
|
+
v.registerMesh(r, o, t, 0, i.lods.length, i);
|
|
651
657
|
}
|
|
652
658
|
}
|
|
653
659
|
}
|
|
654
|
-
function
|
|
655
|
-
se(e), ie(t), t.register((
|
|
656
|
-
const i = new
|
|
660
|
+
function Ce(l, e, t, r) {
|
|
661
|
+
se(e), ie(t), t.register((n) => new v(n, l));
|
|
662
|
+
const i = new B(e);
|
|
657
663
|
return (r == null ? void 0 : r.enableLODsManager) !== !1 && i.enable(), i;
|
|
658
664
|
}
|
|
659
665
|
document.addEventListener("DOMContentLoaded", () => {
|
|
660
|
-
|
|
666
|
+
Me(document.querySelector("model-viewer"));
|
|
661
667
|
});
|
|
662
668
|
export {
|
|
663
669
|
R as EXTENSION_NAME,
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
670
|
+
B as LODsManager,
|
|
671
|
+
v as NEEDLE_progressive,
|
|
672
|
+
Me as patchModelViewer,
|
|
673
|
+
Be as registerPlugin,
|
|
674
|
+
Ce as useNeedleProgressive
|
|
669
675
|
};
|