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