@needle-tools/gltf-progressive 2.1.6 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/gltf-progressive.js +753 -668
- package/gltf-progressive.min.js +7 -7
- package/gltf-progressive.umd.cjs +8 -8
- package/lib/extension.d.ts +10 -6
- package/lib/extension.js +20 -94
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/lods.debug.d.ts +4 -0
- package/lib/lods.debug.js +41 -0
- package/lib/lods.loading.d.ts +50 -0
- package/lib/lods.loading.js +82 -0
- package/lib/{lods_manager.d.ts → lods.manager.d.ts} +21 -4
- package/lib/{lods_manager.js → lods.manager.js} +66 -21
- package/lib/plugins/modelviewer.js +1 -1
- package/lib/plugins/plugin.d.ts +2 -2
- package/lib/utils.internal.d.ts +1 -0
- package/lib/utils.internal.js +8 -0
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/gltf-progressive.js
CHANGED
|
@@ -1,213 +1,215 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (
|
|
4
|
-
if (!
|
|
5
|
-
throw TypeError("Cannot " +
|
|
1
|
+
var Ye = Object.defineProperty;
|
|
2
|
+
var He = (n, t, e) => t in n ? Ye(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var d = (n, t, e) => (He(n, typeof t != "symbol" ? t + "" : t, e), e), Ee = (n, t, e) => {
|
|
4
|
+
if (!t.has(n))
|
|
5
|
+
throw TypeError("Cannot " + e);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
7
|
+
var p = (n, t, e) => (Ee(n, t, "read from private field"), e ? e.call(n) : t.get(n)), J = (n, t, e) => {
|
|
8
|
+
if (t.has(n))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
import { BufferGeometry as
|
|
13
|
-
import { GLTFLoader as
|
|
14
|
-
import { MeshoptDecoder as
|
|
15
|
-
import { DRACOLoader as
|
|
16
|
-
import { KTX2Loader as
|
|
17
|
-
const
|
|
18
|
-
globalThis.GLTF_PROGRESSIVE_VERSION =
|
|
10
|
+
t instanceof WeakSet ? t.add(n) : t.set(n, e);
|
|
11
|
+
}, V = (n, t, e, s) => (Ee(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e);
|
|
12
|
+
import { BufferGeometry as Le, Mesh as se, Texture as ne, TextureLoader as je, Matrix4 as Ge, Clock as Je, MeshStandardMaterial as Qe, Sphere as Ze, Box3 as Ie, Vector3 as K } from "three";
|
|
13
|
+
import { GLTFLoader as Ce } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
14
|
+
import { MeshoptDecoder as et } from "three/examples/jsm/libs/meshopt_decoder.module.js";
|
|
15
|
+
import { DRACOLoader as tt } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
16
|
+
import { KTX2Loader as st } from "three/examples/jsm/loaders/KTX2Loader.js";
|
|
17
|
+
const rt = "";
|
|
18
|
+
globalThis.GLTF_PROGRESSIVE_VERSION = rt;
|
|
19
19
|
console.debug("[gltf-progressive] version -");
|
|
20
|
-
let
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
fetch(
|
|
20
|
+
let W = "https://www.gstatic.com/draco/versioned/decoders/1.5.7/", re = "https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";
|
|
21
|
+
const it = W, ot = re, $e = new URL(W + "draco_decoder.js");
|
|
22
|
+
$e.searchParams.append("range", "true");
|
|
23
|
+
fetch($e, {
|
|
24
24
|
method: "GET",
|
|
25
25
|
headers: {
|
|
26
26
|
Range: "bytes=0-1"
|
|
27
27
|
}
|
|
28
|
-
}).catch((
|
|
29
|
-
console.debug(`Failed to fetch remote Draco decoder from ${
|
|
28
|
+
}).catch((n) => {
|
|
29
|
+
console.debug(`Failed to fetch remote Draco decoder from ${W} (offline: ${typeof navigator < "u" ? navigator.onLine : "unknown"})`), W === it && nt("./include/draco/"), re === ot && at("./include/ktx2/");
|
|
30
30
|
}).finally(() => {
|
|
31
|
-
|
|
31
|
+
Fe();
|
|
32
32
|
});
|
|
33
|
-
function
|
|
34
|
-
|
|
33
|
+
function nt(n) {
|
|
34
|
+
W = n, B && B[Te] != W ? (console.debug("Updating Draco decoder path to " + n), B[Te] = W, B.setDecoderPath(W), B.preload()) : console.debug("Setting Draco decoder path to " + n);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
36
|
+
function at(n) {
|
|
37
|
+
re = n, U && U.transcoderPath != re ? (console.debug("Updating KTX2 transcoder path to " + n), U.setTranscoderPath(re), U.init()) : console.debug("Setting KTX2 transcoder path to " + n);
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
let B,
|
|
41
|
-
function
|
|
42
|
-
B || (B = new
|
|
39
|
+
const Te = Symbol("dracoDecoderPath");
|
|
40
|
+
let B, xe, U;
|
|
41
|
+
function Fe() {
|
|
42
|
+
B || (B = new tt(), B[Te] = W, B.setDecoderPath(W), B.setDecoderConfig({ type: "js" }), B.preload()), U || (U = new st(), U.setTranscoderPath(re), U.init()), xe || (xe = et);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
44
|
+
function Ue(n) {
|
|
45
|
+
return Fe(), n ? U.detectSupport(n) : n !== null && console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures might fail"), { dracoLoader: B, ktx2Loader: U, meshoptDecoder: xe };
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
47
|
+
function Ne(n) {
|
|
48
|
+
n.dracoLoader || n.setDRACOLoader(B), n.ktx2Loader || n.setKTX2Loader(U), n.meshoptDecoder || n.setMeshoptDecoder(xe);
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
function
|
|
52
|
-
let
|
|
53
|
-
|
|
50
|
+
const Pe = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function ze(n, t) {
|
|
52
|
+
let e = Pe.get(n);
|
|
53
|
+
e ? e = Object.assign(e, t) : e = t, Pe.set(n, e);
|
|
54
54
|
}
|
|
55
|
-
const
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
let
|
|
59
|
-
const s = new URL(
|
|
55
|
+
const Me = Ce.prototype.load;
|
|
56
|
+
function lt(...n) {
|
|
57
|
+
const t = Pe.get(this);
|
|
58
|
+
let e = n[0];
|
|
59
|
+
const s = new URL(e, window.location.href);
|
|
60
60
|
if (s.hostname.endsWith("needle.tools")) {
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const i = (t == null ? void 0 : t.progressive) !== void 0 ? t.progressive : !0, r = t != null && t.usecase ? t.usecase : "default";
|
|
62
|
+
i ? this.requestHeader.Accept = `*/*;progressive=allowed;usecase=${r}` : this.requestHeader.Accept = `*/*;usecase=${r}`, e = s.toString();
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return n[0] = e, Me == null ? void 0 : Me.call(this, ...n);
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function
|
|
66
|
+
Ce.prototype.load = lt;
|
|
67
|
+
ue("debugprogressive");
|
|
68
|
+
function ue(n) {
|
|
69
69
|
if (typeof window > "u")
|
|
70
70
|
return !1;
|
|
71
|
-
const
|
|
72
|
-
return
|
|
71
|
+
const e = new URL(window.location.href).searchParams.get(n);
|
|
72
|
+
return e == null || e === "0" || e === "false" ? !1 : e === "" ? !0 : e;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const s =
|
|
80
|
-
for (; s.endsWith("/") &&
|
|
81
|
-
|
|
82
|
-
return s +
|
|
74
|
+
function dt(n, t) {
|
|
75
|
+
if (t === void 0 || t.startsWith("./") || t.startsWith("http") || n === void 0)
|
|
76
|
+
return t;
|
|
77
|
+
const e = n.lastIndexOf("/");
|
|
78
|
+
if (e >= 0) {
|
|
79
|
+
const s = n.substring(0, e + 1);
|
|
80
|
+
for (; s.endsWith("/") && t.startsWith("/"); )
|
|
81
|
+
t = t.substring(1);
|
|
82
|
+
return s + t;
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return t;
|
|
85
85
|
}
|
|
86
|
-
let
|
|
87
|
-
function
|
|
88
|
-
return
|
|
86
|
+
let ae;
|
|
87
|
+
function ut() {
|
|
88
|
+
return ae !== void 0 || (ae = /iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent), ue("debugprogressive") && console.log("[glTF Progressive]: isMobileDevice", ae)), ae;
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
function ct() {
|
|
91
|
+
if (typeof window > "u")
|
|
92
|
+
return !1;
|
|
93
|
+
const n = new URL(window.location.href), t = n.hostname === "localhost" || /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n.hostname);
|
|
94
|
+
return n.hostname === "127.0.0.1" || t;
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const ft = typeof window > "u" && typeof document > "u", Ae = Symbol("needle:raycast-mesh");
|
|
97
|
+
function ce(n) {
|
|
98
|
+
return (n == null ? void 0 : n[Ae]) instanceof Le ? n[Ae] : null;
|
|
99
|
+
}
|
|
100
|
+
function ht(n, t) {
|
|
101
|
+
if ((n.type === "Mesh" || n.type === "SkinnedMesh") && !ce(n)) {
|
|
102
|
+
const s = pt(t);
|
|
103
|
+
s.userData = { isRaycastMesh: !0 }, n[Ae] = s;
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
|
-
function
|
|
101
|
-
if (
|
|
102
|
-
if (
|
|
106
|
+
function gt(n = !0) {
|
|
107
|
+
if (n) {
|
|
108
|
+
if (le)
|
|
103
109
|
return;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
let
|
|
108
|
-
|
|
110
|
+
const t = le = se.prototype.raycast;
|
|
111
|
+
se.prototype.raycast = function(e, s) {
|
|
112
|
+
const o = this, i = ce(o);
|
|
113
|
+
let r;
|
|
114
|
+
i && o.isMesh && (r = o.geometry, o.geometry = i), t.call(this, e, s), r && (o.geometry = r);
|
|
109
115
|
};
|
|
110
116
|
} else {
|
|
111
|
-
if (!
|
|
117
|
+
if (!le)
|
|
112
118
|
return;
|
|
113
|
-
|
|
119
|
+
se.prototype.raycast = le, le = null;
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
|
-
let
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
for (const
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
+
let le = null;
|
|
123
|
+
function pt(n) {
|
|
124
|
+
const t = new Le();
|
|
125
|
+
for (const e in n.attributes)
|
|
126
|
+
t.setAttribute(e, n.getAttribute(e));
|
|
127
|
+
return t.setIndex(n.getIndex()), t;
|
|
122
128
|
}
|
|
123
|
-
const Z = new Array(),
|
|
129
|
+
const Z = new Array(), L = ue("debugprogressive");
|
|
130
|
+
let me, te = -1;
|
|
124
131
|
if (L) {
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
r["DEBUG:LOD"] = u, l && (t = Math.max(t, l.lods.length - 1));
|
|
133
|
-
} else
|
|
134
|
-
r.isMaterial === !0 && (r["DEBUG:LOD"] = e);
|
|
135
|
-
}
|
|
136
|
-
}), e >= t && (e = -1);
|
|
137
|
-
}, e = -1, t = 2, s = !1;
|
|
138
|
-
window.addEventListener("keyup", (n) => {
|
|
139
|
-
n.key === "p" && i(), n.key === "w" && (s = !s, Se && Se.forEach((r) => {
|
|
140
|
-
r.name != "BackgroundCubeMaterial" && r.glyphMap == null && "wireframe" in r && (r.wireframe = s);
|
|
141
|
-
}));
|
|
132
|
+
let n = function() {
|
|
133
|
+
te += 1, te >= t && (te = -1), console.log(`Toggle LOD level [${te}]`);
|
|
134
|
+
}, t = 6;
|
|
135
|
+
window.addEventListener("keyup", (e) => {
|
|
136
|
+
e.key === "p" && n(), e.key === "w" && (me = !me, console.log(`Toggle wireframe [${me}]`));
|
|
137
|
+
const s = parseInt(e.key);
|
|
138
|
+
!isNaN(s) && s >= 0 && (te = s, console.log(`Set LOD level to [${te}]`));
|
|
142
139
|
});
|
|
143
140
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
141
|
+
function Ve(n) {
|
|
142
|
+
if (L)
|
|
143
|
+
if (Array.isArray(n))
|
|
144
|
+
for (const t of n)
|
|
145
|
+
Ve(t);
|
|
146
|
+
else
|
|
147
|
+
n && "wireframe" in n && (n.wireframe = me === !0);
|
|
151
148
|
}
|
|
152
|
-
const
|
|
153
|
-
constructor(
|
|
149
|
+
const Y = "NEEDLE_progressive", Oe = Symbol("needle-progressive-texture"), b = class {
|
|
150
|
+
constructor(t, e) {
|
|
154
151
|
d(this, "parser");
|
|
155
152
|
d(this, "url");
|
|
156
153
|
d(this, "_isLoadingMesh");
|
|
157
|
-
d(this, "loadMesh", (
|
|
158
|
-
var s,
|
|
154
|
+
d(this, "loadMesh", (t) => {
|
|
155
|
+
var s, o;
|
|
159
156
|
if (this._isLoadingMesh)
|
|
160
157
|
return null;
|
|
161
|
-
const
|
|
162
|
-
return
|
|
163
|
-
var
|
|
164
|
-
return this._isLoadingMesh = !1,
|
|
158
|
+
const e = (o = (s = this.parser.json.meshes[t]) == null ? void 0 : s.extensions) == null ? void 0 : o[Y];
|
|
159
|
+
return e ? (this._isLoadingMesh = !0, this.parser.getDependency("mesh", t).then((i) => {
|
|
160
|
+
var r;
|
|
161
|
+
return this._isLoadingMesh = !1, i && b.registerMesh(this.url, e.guid, i, (r = e.lods) == null ? void 0 : r.length, 0, e), i;
|
|
165
162
|
})) : null;
|
|
166
163
|
});
|
|
167
|
-
L && console.log("Progressive extension registered for",
|
|
164
|
+
L && console.log("Progressive extension registered for", e), this.parser = t, this.url = e;
|
|
168
165
|
}
|
|
169
166
|
/** The name of the extension */
|
|
170
167
|
get name() {
|
|
171
|
-
return
|
|
168
|
+
return Y;
|
|
172
169
|
}
|
|
173
|
-
static
|
|
174
|
-
const
|
|
175
|
-
return
|
|
170
|
+
static getMeshLODExtension(t) {
|
|
171
|
+
const e = this.getAssignedLODInformation(t);
|
|
172
|
+
return e != null && e.key ? this.lodInfos.get(e.key) : null;
|
|
173
|
+
}
|
|
174
|
+
static getPrimitiveIndex(t) {
|
|
175
|
+
var s;
|
|
176
|
+
const e = (s = this.getAssignedLODInformation(t)) == null ? void 0 : s.index;
|
|
177
|
+
return e ?? -1;
|
|
176
178
|
}
|
|
177
|
-
static getMaterialMinMaxLODsCount(
|
|
178
|
-
const s = this,
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
181
|
-
if (
|
|
179
|
+
static getMaterialMinMaxLODsCount(t, e) {
|
|
180
|
+
const s = this, o = "LODS:minmax", i = t[o];
|
|
181
|
+
if (i != null)
|
|
182
|
+
return i;
|
|
183
|
+
if (e || (e = {
|
|
182
184
|
min_count: 1 / 0,
|
|
183
185
|
max_count: 0,
|
|
184
186
|
lods: []
|
|
185
|
-
}), Array.isArray(
|
|
186
|
-
for (const a of
|
|
187
|
-
this.getMaterialMinMaxLODsCount(a,
|
|
188
|
-
return
|
|
187
|
+
}), Array.isArray(t)) {
|
|
188
|
+
for (const a of t)
|
|
189
|
+
this.getMaterialMinMaxLODsCount(a, e);
|
|
190
|
+
return t[o] = e, e;
|
|
189
191
|
}
|
|
190
|
-
if (L === "verbose" && console.log("getMaterialMinMaxLODsCount",
|
|
191
|
-
const a =
|
|
192
|
+
if (L === "verbose" && console.log("getMaterialMinMaxLODsCount", t), t.type === "ShaderMaterial" || t.type === "RawShaderMaterial") {
|
|
193
|
+
const a = t;
|
|
192
194
|
for (const l of Object.keys(a.uniforms)) {
|
|
193
|
-
const
|
|
194
|
-
(
|
|
195
|
+
const c = a.uniforms[l].value;
|
|
196
|
+
(c == null ? void 0 : c.isTexture) === !0 && r(c, e);
|
|
195
197
|
}
|
|
196
|
-
} else if (
|
|
197
|
-
for (const a of Object.keys(
|
|
198
|
-
const l =
|
|
199
|
-
(l == null ? void 0 : l.isTexture) === !0 &&
|
|
198
|
+
} else if (t.isMaterial)
|
|
199
|
+
for (const a of Object.keys(t)) {
|
|
200
|
+
const l = t[a];
|
|
201
|
+
(l == null ? void 0 : l.isTexture) === !0 && r(l, e);
|
|
200
202
|
}
|
|
201
|
-
return
|
|
202
|
-
function
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
l.min_count = Math.min(l.min_count,
|
|
208
|
-
for (let
|
|
209
|
-
const
|
|
210
|
-
|
|
203
|
+
return t[o] = e, e;
|
|
204
|
+
function r(a, l) {
|
|
205
|
+
const c = s.getAssignedLODInformation(a);
|
|
206
|
+
if (c) {
|
|
207
|
+
const u = s.lodInfos.get(c.key);
|
|
208
|
+
if (u && u.lods) {
|
|
209
|
+
l.min_count = Math.min(l.min_count, u.lods.length), l.max_count = Math.max(l.max_count, u.lods.length);
|
|
210
|
+
for (let h = 0; h < u.lods.length; h++) {
|
|
211
|
+
const g = u.lods[h];
|
|
212
|
+
g.width && (l.lods[h] = l.lods[h] || { min_height: 1 / 0, max_height: 0 }, l.lods[h].min_height = Math.min(l.lods[h].min_height, g.height), l.lods[h].max_height = Math.max(l.lods[h].max_height, g.height));
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
215
|
}
|
|
@@ -218,33 +220,33 @@ const v = class {
|
|
|
218
220
|
* @param level the level of detail to check for (0 is the highest resolution). If undefined, the function checks if any LOD level is available
|
|
219
221
|
* @returns true if the LOD level is available (or if any LOD level is available if level is undefined)
|
|
220
222
|
*/
|
|
221
|
-
static hasLODLevelAvailable(
|
|
222
|
-
var
|
|
223
|
-
if (Array.isArray(
|
|
224
|
-
for (const
|
|
225
|
-
if (this.hasLODLevelAvailable(
|
|
223
|
+
static hasLODLevelAvailable(t, e) {
|
|
224
|
+
var i;
|
|
225
|
+
if (Array.isArray(t)) {
|
|
226
|
+
for (const r of t)
|
|
227
|
+
if (this.hasLODLevelAvailable(r, e))
|
|
226
228
|
return !0;
|
|
227
229
|
return !1;
|
|
228
230
|
}
|
|
229
|
-
if (
|
|
230
|
-
for (const
|
|
231
|
-
const a =
|
|
232
|
-
if (a && a.isTexture && this.hasLODLevelAvailable(a,
|
|
231
|
+
if (t.isMaterial === !0) {
|
|
232
|
+
for (const r of Object.keys(t)) {
|
|
233
|
+
const a = t[r];
|
|
234
|
+
if (a && a.isTexture && this.hasLODLevelAvailable(a, e))
|
|
233
235
|
return !0;
|
|
234
236
|
}
|
|
235
237
|
return !1;
|
|
236
|
-
} else if (
|
|
237
|
-
for (const
|
|
238
|
-
if (
|
|
238
|
+
} else if (t.isGroup === !0) {
|
|
239
|
+
for (const r of t.children)
|
|
240
|
+
if (r.isMesh === !0 && this.hasLODLevelAvailable(r, e))
|
|
239
241
|
return !0;
|
|
240
242
|
}
|
|
241
|
-
let s,
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
if (
|
|
245
|
-
return
|
|
246
|
-
if (
|
|
247
|
-
return Array.isArray(
|
|
243
|
+
let s, o;
|
|
244
|
+
if (t.isMesh ? s = t.geometry : (t.isBufferGeometry || t.isTexture) && (s = t), s && (i = s == null ? void 0 : s.userData) != null && i.LODS) {
|
|
245
|
+
const r = s.userData.LODS;
|
|
246
|
+
if (o = this.lodInfos.get(r.key), e === void 0)
|
|
247
|
+
return o != null;
|
|
248
|
+
if (o)
|
|
249
|
+
return Array.isArray(o.lods) ? e < o.lods.length : e === 0;
|
|
248
250
|
}
|
|
249
251
|
return !1;
|
|
250
252
|
}
|
|
@@ -262,323 +264,376 @@ const v = class {
|
|
|
262
264
|
* });
|
|
263
265
|
* ```
|
|
264
266
|
*/
|
|
265
|
-
static assignMeshLOD(
|
|
267
|
+
static assignMeshLOD(t, e) {
|
|
266
268
|
var s;
|
|
267
|
-
if (!
|
|
269
|
+
if (!t)
|
|
268
270
|
return Promise.resolve(null);
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
if (!
|
|
271
|
+
if (t instanceof se || t.isMesh === !0) {
|
|
272
|
+
const o = t.geometry, i = this.getAssignedLODInformation(o);
|
|
273
|
+
if (!i)
|
|
272
274
|
return Promise.resolve(null);
|
|
273
|
-
for (const
|
|
274
|
-
(s =
|
|
275
|
-
return
|
|
276
|
-
if (Array.isArray(
|
|
277
|
-
const a =
|
|
278
|
-
|
|
275
|
+
for (const r of Z)
|
|
276
|
+
(s = r.onBeforeGetLODMesh) == null || s.call(r, t, e);
|
|
277
|
+
return t["LOD:requested level"] = e, b.getOrLoadLOD(o, e).then((r) => {
|
|
278
|
+
if (Array.isArray(r)) {
|
|
279
|
+
const a = i.index || 0;
|
|
280
|
+
r = r[a];
|
|
279
281
|
}
|
|
280
|
-
return
|
|
281
|
-
}).catch((
|
|
282
|
+
return t["LOD:requested level"] === e && (delete t["LOD:requested level"], r && o != r && ((r == null ? void 0 : r.isBufferGeometry) ? t.geometry = r : L && console.error("Invalid LOD geometry", r))), r;
|
|
283
|
+
}).catch((r) => (console.error("Error loading mesh LOD", t, r), null));
|
|
282
284
|
} else
|
|
283
|
-
L && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",
|
|
285
|
+
L && console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh", t);
|
|
284
286
|
return Promise.resolve(null);
|
|
285
287
|
}
|
|
286
|
-
static assignTextureLOD(
|
|
287
|
-
if (!
|
|
288
|
+
static assignTextureLOD(t, e = 0) {
|
|
289
|
+
if (!t)
|
|
288
290
|
return Promise.resolve(null);
|
|
289
|
-
if (
|
|
290
|
-
const s =
|
|
291
|
+
if (t.isMesh === !0) {
|
|
292
|
+
const s = t;
|
|
291
293
|
if (Array.isArray(s.material)) {
|
|
292
|
-
const
|
|
293
|
-
for (const
|
|
294
|
-
const
|
|
295
|
-
|
|
294
|
+
const o = new Array();
|
|
295
|
+
for (const i of s.material) {
|
|
296
|
+
const r = this.assignTextureLOD(i, e);
|
|
297
|
+
o.push(r);
|
|
296
298
|
}
|
|
297
|
-
return Promise.all(
|
|
298
|
-
const
|
|
299
|
-
for (const a of
|
|
300
|
-
Array.isArray(a) &&
|
|
301
|
-
return
|
|
299
|
+
return Promise.all(o).then((i) => {
|
|
300
|
+
const r = new Array();
|
|
301
|
+
for (const a of i)
|
|
302
|
+
Array.isArray(a) && r.push(...a);
|
|
303
|
+
return r;
|
|
302
304
|
});
|
|
303
305
|
} else
|
|
304
|
-
return this.assignTextureLOD(s.material,
|
|
306
|
+
return this.assignTextureLOD(s.material, e);
|
|
305
307
|
}
|
|
306
|
-
if (
|
|
307
|
-
const s =
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
for (const a of Object.keys(
|
|
311
|
-
const l =
|
|
308
|
+
if (t.isMaterial === !0) {
|
|
309
|
+
const s = t, o = [], i = new Array();
|
|
310
|
+
if (s.uniforms && (s.isRawShaderMaterial || s.isShaderMaterial === !0)) {
|
|
311
|
+
const r = s;
|
|
312
|
+
for (const a of Object.keys(r.uniforms)) {
|
|
313
|
+
const l = r.uniforms[a].value;
|
|
312
314
|
if ((l == null ? void 0 : l.isTexture) === !0) {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
+
const c = this.assignTextureLODForSlot(l, e, s, a).then((u) => (u && r.uniforms[a].value != u && (r.uniforms[a].value = u, r.uniformsNeedUpdate = !0), u));
|
|
316
|
+
o.push(c), i.push(a);
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
} else
|
|
318
|
-
for (const
|
|
319
|
-
const a = s[
|
|
320
|
+
for (const r of Object.keys(s)) {
|
|
321
|
+
const a = s[r];
|
|
320
322
|
if ((a == null ? void 0 : a.isTexture) === !0) {
|
|
321
|
-
const l = this.assignTextureLODForSlot(a,
|
|
322
|
-
|
|
323
|
+
const l = this.assignTextureLODForSlot(a, e, s, r);
|
|
324
|
+
o.push(l), i.push(r);
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
|
-
return Promise.all(
|
|
327
|
+
return Promise.all(o).then((r) => {
|
|
326
328
|
const a = new Array();
|
|
327
|
-
for (let l = 0; l <
|
|
328
|
-
const
|
|
329
|
-
|
|
329
|
+
for (let l = 0; l < r.length; l++) {
|
|
330
|
+
const c = r[l], u = i[l];
|
|
331
|
+
c && c.isTexture === !0 ? a.push({ material: s, slot: u, texture: c, level: e }) : a.push({ material: s, slot: u, texture: null, level: e });
|
|
330
332
|
}
|
|
331
333
|
return a;
|
|
332
334
|
});
|
|
333
335
|
}
|
|
334
|
-
if (
|
|
335
|
-
const s =
|
|
336
|
-
return this.assignTextureLODForSlot(s,
|
|
336
|
+
if (t instanceof ne || t.isTexture === !0) {
|
|
337
|
+
const s = t;
|
|
338
|
+
return this.assignTextureLODForSlot(s, e, null, null);
|
|
337
339
|
}
|
|
338
340
|
return Promise.resolve(null);
|
|
339
341
|
}
|
|
340
|
-
static assignTextureLODForSlot(
|
|
341
|
-
return (
|
|
342
|
-
if (Array.isArray(
|
|
342
|
+
static assignTextureLODForSlot(t, e, s, o) {
|
|
343
|
+
return (t == null ? void 0 : t.isTexture) !== !0 ? Promise.resolve(null) : o === "glyphMap" ? Promise.resolve(t) : b.getOrLoadLOD(t, e).then((i) => {
|
|
344
|
+
if (Array.isArray(i))
|
|
343
345
|
return null;
|
|
344
|
-
if ((
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return L === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, t, s, o, r), null;
|
|
352
|
-
}
|
|
353
|
-
s[n] = r;
|
|
354
|
-
}
|
|
355
|
-
if (L && n && s) {
|
|
356
|
-
const o = this.getAssignedLODInformation(e);
|
|
357
|
-
o ? Ce(s, n, o.url) : console.warn("No LOD info for texture", e);
|
|
346
|
+
if ((i == null ? void 0 : i.isTexture) === !0) {
|
|
347
|
+
if (i != t && s && o) {
|
|
348
|
+
const r = s[o];
|
|
349
|
+
if (r && !L) {
|
|
350
|
+
const a = this.getAssignedLODInformation(r);
|
|
351
|
+
if (a && (a == null ? void 0 : a.level) < e)
|
|
352
|
+
return L === "verbose" && console.warn("Assigned texture level is already higher: ", a.level, e, s, r, i), null;
|
|
358
353
|
}
|
|
354
|
+
s[o] = i;
|
|
359
355
|
}
|
|
360
|
-
return
|
|
356
|
+
return i;
|
|
361
357
|
} else
|
|
362
|
-
L == "verbose" && console.warn("No LOD found for",
|
|
358
|
+
L == "verbose" && console.warn("No LOD found for", t, e);
|
|
363
359
|
return null;
|
|
364
|
-
}).catch((
|
|
360
|
+
}).catch((i) => (console.error("Error loading LOD", t, i), null));
|
|
365
361
|
}
|
|
366
|
-
afterRoot(
|
|
367
|
-
var
|
|
368
|
-
return L && console.log("AFTER", this.url,
|
|
369
|
-
var
|
|
370
|
-
if (
|
|
371
|
-
const a =
|
|
362
|
+
afterRoot(t) {
|
|
363
|
+
var e, s;
|
|
364
|
+
return L && console.log("AFTER", this.url, t), (e = this.parser.json.textures) == null || e.forEach((o, i) => {
|
|
365
|
+
var r;
|
|
366
|
+
if (o != null && o.extensions) {
|
|
367
|
+
const a = o == null ? void 0 : o.extensions[Y];
|
|
372
368
|
if (a) {
|
|
373
369
|
if (!a.lods) {
|
|
374
370
|
L && console.warn("Texture has no LODs", a);
|
|
375
371
|
return;
|
|
376
372
|
}
|
|
377
373
|
let l = !1;
|
|
378
|
-
for (const
|
|
379
|
-
if (
|
|
380
|
-
const
|
|
381
|
-
(
|
|
374
|
+
for (const c of this.parser.associations.keys())
|
|
375
|
+
if (c.isTexture === !0) {
|
|
376
|
+
const u = this.parser.associations.get(c);
|
|
377
|
+
(u == null ? void 0 : u.textures) === i && (l = !0, b.registerTexture(this.url, c, (r = a.lods) == null ? void 0 : r.length, i, a));
|
|
382
378
|
}
|
|
383
|
-
l || this.parser.getDependency("texture",
|
|
384
|
-
var
|
|
385
|
-
|
|
379
|
+
l || this.parser.getDependency("texture", i).then((c) => {
|
|
380
|
+
var u;
|
|
381
|
+
c && b.registerTexture(this.url, c, (u = a.lods) == null ? void 0 : u.length, i, a);
|
|
386
382
|
});
|
|
387
383
|
}
|
|
388
384
|
}
|
|
389
|
-
}), (s = this.parser.json.meshes) == null || s.forEach((
|
|
390
|
-
if (
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
385
|
+
}), (s = this.parser.json.meshes) == null || s.forEach((o, i) => {
|
|
386
|
+
if (o != null && o.extensions) {
|
|
387
|
+
const r = o == null ? void 0 : o.extensions[Y];
|
|
388
|
+
if (r && r.lods) {
|
|
393
389
|
for (const a of this.parser.associations.keys())
|
|
394
390
|
if (a.isMesh) {
|
|
395
391
|
const l = this.parser.associations.get(a);
|
|
396
|
-
(l == null ? void 0 : l.meshes) ===
|
|
392
|
+
(l == null ? void 0 : l.meshes) === i && b.registerMesh(this.url, r.guid, a, r.lods.length, l.primitives, r);
|
|
397
393
|
}
|
|
398
394
|
}
|
|
399
395
|
}
|
|
400
396
|
}), null;
|
|
401
397
|
}
|
|
402
|
-
static async getOrLoadLOD(
|
|
403
|
-
var a, l,
|
|
404
|
-
const s = L == "verbose",
|
|
405
|
-
if (!
|
|
398
|
+
static async getOrLoadLOD(t, e) {
|
|
399
|
+
var a, l, c, u;
|
|
400
|
+
const s = L == "verbose", o = t.userData.LODS;
|
|
401
|
+
if (!o)
|
|
406
402
|
return null;
|
|
407
|
-
const
|
|
408
|
-
let
|
|
409
|
-
if (
|
|
410
|
-
const
|
|
411
|
-
|
|
403
|
+
const i = o == null ? void 0 : o.key;
|
|
404
|
+
let r;
|
|
405
|
+
if (t.isTexture === !0) {
|
|
406
|
+
const h = t;
|
|
407
|
+
h.source && h.source[Oe] && (r = h.source[Oe]);
|
|
412
408
|
}
|
|
413
|
-
if (
|
|
414
|
-
if (
|
|
415
|
-
let
|
|
416
|
-
const
|
|
417
|
-
if (
|
|
418
|
-
return this.lowresCache.get(
|
|
409
|
+
if (r || (r = b.lodInfos.get(i)), r) {
|
|
410
|
+
if (e > 0) {
|
|
411
|
+
let w = !1;
|
|
412
|
+
const M = Array.isArray(r.lods);
|
|
413
|
+
if (M && e >= r.lods.length ? w = !0 : M || (w = !0), w)
|
|
414
|
+
return this.lowresCache.get(i);
|
|
419
415
|
}
|
|
420
|
-
const
|
|
421
|
-
if (!
|
|
422
|
-
return L && !
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
if (!
|
|
426
|
-
return console.warn("missing pointer for glb/gltf texture",
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
429
|
-
s && console.log(`LOD ${
|
|
430
|
-
let
|
|
431
|
-
`,
|
|
432
|
-
if (
|
|
433
|
-
return
|
|
416
|
+
const h = Array.isArray(r.lods) ? (a = r.lods[e]) == null ? void 0 : a.path : r.lods;
|
|
417
|
+
if (!h)
|
|
418
|
+
return L && !r["missing:uri"] && (r["missing:uri"] = !0, console.warn("Missing uri for progressive asset for LOD " + e, r)), null;
|
|
419
|
+
const g = dt(o.url, h);
|
|
420
|
+
if (g.endsWith(".glb") || g.endsWith(".gltf")) {
|
|
421
|
+
if (!r.guid)
|
|
422
|
+
return console.warn("missing pointer for glb/gltf texture", r), null;
|
|
423
|
+
const w = g + "_" + r.guid, M = this.previouslyLoaded.get(w);
|
|
424
|
+
if (M !== void 0) {
|
|
425
|
+
s && console.log(`LOD ${e} was already loading/loaded: ${w}`);
|
|
426
|
+
let _ = await M.catch((m) => (console.error(`Error loading LOD ${e} from ${g}
|
|
427
|
+
`, m), null)), D = !1;
|
|
428
|
+
if (_ == null || (_ instanceof ne && t instanceof ne ? (l = _.image) != null && l.data || (c = _.source) != null && c.data ? _ = this.copySettings(t, _) : (D = !0, this.previouslyLoaded.delete(w)) : _ instanceof Le && t instanceof Le && ((u = _.attributes.position) != null && u.array || (D = !0, this.previouslyLoaded.delete(w)))), !D)
|
|
429
|
+
return _;
|
|
434
430
|
}
|
|
435
|
-
const x =
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
let
|
|
431
|
+
const x = r, N = new Promise(async (_, D) => {
|
|
432
|
+
const m = new Ce();
|
|
433
|
+
Ne(m), L && (await new Promise((O) => setTimeout(O, 1e3)), s && console.warn("Start loading (delayed) " + g, x.guid));
|
|
434
|
+
let q = g;
|
|
439
435
|
if (x && Array.isArray(x.lods)) {
|
|
440
|
-
const
|
|
441
|
-
|
|
436
|
+
const O = x.lods[e];
|
|
437
|
+
O.hash && (q += "?v=" + O.hash);
|
|
442
438
|
}
|
|
443
|
-
const A = await
|
|
444
|
-
`,
|
|
439
|
+
const A = await m.loadAsync(q).catch((O) => (console.error(`Error loading LOD ${e} from ${g}
|
|
440
|
+
`, O), null));
|
|
445
441
|
if (!A)
|
|
446
442
|
return null;
|
|
447
|
-
const
|
|
448
|
-
s && console.log("Loading finished " +
|
|
449
|
-
let
|
|
443
|
+
const k = A.parser;
|
|
444
|
+
s && console.log("Loading finished " + g, x.guid);
|
|
445
|
+
let R = 0;
|
|
450
446
|
if (A.parser.json.textures) {
|
|
451
|
-
let
|
|
447
|
+
let O = !1;
|
|
452
448
|
for (const f of A.parser.json.textures) {
|
|
453
449
|
if (f != null && f.extensions) {
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
|
|
450
|
+
const S = f == null ? void 0 : f.extensions[Y];
|
|
451
|
+
if (S != null && S.guid && S.guid === x.guid) {
|
|
452
|
+
O = !0;
|
|
457
453
|
break;
|
|
458
454
|
}
|
|
459
455
|
}
|
|
460
|
-
|
|
456
|
+
R++;
|
|
461
457
|
}
|
|
462
|
-
if (
|
|
463
|
-
let f = await
|
|
464
|
-
return f &&
|
|
458
|
+
if (O) {
|
|
459
|
+
let f = await k.getDependency("texture", R);
|
|
460
|
+
return f && b.assignLODInformation(o.url, f, i, e, void 0), s && console.log('change "' + t.name + '" → "' + f.name + '"', g, R, f, w), t instanceof ne && (f = this.copySettings(t, f)), f && (f.guid = x.guid), _(f);
|
|
465
461
|
} else
|
|
466
462
|
L && console.warn("Could not find texture with guid", x.guid, A.parser.json);
|
|
467
463
|
}
|
|
468
|
-
if (
|
|
469
|
-
let
|
|
464
|
+
if (R = 0, A.parser.json.meshes) {
|
|
465
|
+
let O = !1;
|
|
470
466
|
for (const f of A.parser.json.meshes) {
|
|
471
467
|
if (f != null && f.extensions) {
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
474
|
-
|
|
468
|
+
const S = f == null ? void 0 : f.extensions[Y];
|
|
469
|
+
if (S != null && S.guid && S.guid === x.guid) {
|
|
470
|
+
O = !0;
|
|
475
471
|
break;
|
|
476
472
|
}
|
|
477
473
|
}
|
|
478
|
-
|
|
474
|
+
R++;
|
|
479
475
|
}
|
|
480
|
-
if (
|
|
481
|
-
const f = await
|
|
482
|
-
if (s && console.log(`Loaded Mesh "${f.name}"`,
|
|
483
|
-
const
|
|
484
|
-
return
|
|
476
|
+
if (O) {
|
|
477
|
+
const f = await k.getDependency("mesh", R);
|
|
478
|
+
if (s && console.log(`Loaded Mesh "${f.name}"`, g, R, f, w), f.isMesh === !0) {
|
|
479
|
+
const S = f.geometry;
|
|
480
|
+
return b.assignLODInformation(o.url, S, i, e, 0), _(S);
|
|
485
481
|
} else {
|
|
486
|
-
const
|
|
487
|
-
for (let
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
491
|
-
|
|
482
|
+
const S = new Array();
|
|
483
|
+
for (let y = 0; y < f.children.length; y++) {
|
|
484
|
+
const v = f.children[y];
|
|
485
|
+
if (v.isMesh === !0) {
|
|
486
|
+
const C = v.geometry;
|
|
487
|
+
b.assignLODInformation(o.url, C, i, e, y), S.push(C);
|
|
492
488
|
}
|
|
493
489
|
}
|
|
494
|
-
return
|
|
490
|
+
return _(S);
|
|
495
491
|
}
|
|
496
492
|
} else
|
|
497
493
|
L && console.warn("Could not find mesh with guid", x.guid, A.parser.json);
|
|
498
494
|
}
|
|
499
|
-
return
|
|
495
|
+
return _(null);
|
|
500
496
|
});
|
|
501
|
-
return this.previouslyLoaded.set(
|
|
502
|
-
} else if (
|
|
503
|
-
s && console.log("Load texture from uri: " +
|
|
504
|
-
const
|
|
505
|
-
return
|
|
497
|
+
return this.previouslyLoaded.set(w, N), await N;
|
|
498
|
+
} else if (t instanceof ne) {
|
|
499
|
+
s && console.log("Load texture from uri: " + g);
|
|
500
|
+
const M = await new je().loadAsync(g);
|
|
501
|
+
return M ? (M.guid = r.guid, M.flipY = !1, M.needsUpdate = !0, M.colorSpace = t.colorSpace, s && console.log(r, M)) : L && console.warn("failed loading", g), M;
|
|
506
502
|
}
|
|
507
503
|
} else
|
|
508
|
-
L && console.warn(`Can not load LOD ${
|
|
504
|
+
L && console.warn(`Can not load LOD ${e}: no LOD info found for "${i}" ${t.name}`, t.type);
|
|
509
505
|
return null;
|
|
510
506
|
}
|
|
511
|
-
static assignLODInformation(
|
|
512
|
-
if (!
|
|
507
|
+
static assignLODInformation(t, e, s, o, i) {
|
|
508
|
+
if (!e)
|
|
513
509
|
return;
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
|
|
510
|
+
e.userData || (e.userData = {});
|
|
511
|
+
const r = new mt(t, s, o, i);
|
|
512
|
+
e.userData.LODS = r;
|
|
517
513
|
}
|
|
518
|
-
static getAssignedLODInformation(
|
|
519
|
-
var
|
|
520
|
-
return ((
|
|
514
|
+
static getAssignedLODInformation(t) {
|
|
515
|
+
var e;
|
|
516
|
+
return ((e = t == null ? void 0 : t.userData) == null ? void 0 : e.LODS) || null;
|
|
521
517
|
}
|
|
522
518
|
// private static readonly _copiedTextures: WeakMap<Texture, Texture> = new Map();
|
|
523
|
-
static copySettings(
|
|
524
|
-
return
|
|
525
|
-
`,
|
|
526
|
-
`,
|
|
519
|
+
static copySettings(t, e) {
|
|
520
|
+
return e ? (L && console.warn(`Copy texture settings
|
|
521
|
+
`, t.uuid, `
|
|
522
|
+
`, e.uuid), e = e.clone(), e.offset = t.offset, e.repeat = t.repeat, e.colorSpace = t.colorSpace, e.magFilter = t.magFilter, e.minFilter = t.minFilter, e.wrapS = t.wrapS, e.wrapT = t.wrapT, e.flipY = t.flipY, e.anisotropy = t.anisotropy, e.mipmaps || (e.generateMipmaps = t.generateMipmaps), e) : t;
|
|
527
523
|
}
|
|
528
524
|
};
|
|
529
|
-
let
|
|
525
|
+
let P = b;
|
|
530
526
|
/**
|
|
531
527
|
* Register a texture with LOD information
|
|
532
528
|
*/
|
|
533
|
-
d(
|
|
534
|
-
if (L && console.log("> Progressive: register texture",
|
|
529
|
+
d(P, "registerTexture", (t, e, s, o, i) => {
|
|
530
|
+
if (L && console.log("> Progressive: register texture", o, e.name, e.uuid, e, i), !e) {
|
|
535
531
|
L && console.error("gltf-progressive: Register texture without texture");
|
|
536
532
|
return;
|
|
537
533
|
}
|
|
538
|
-
|
|
539
|
-
const
|
|
540
|
-
|
|
534
|
+
e.source && (e.source[Oe] = i);
|
|
535
|
+
const r = i.guid;
|
|
536
|
+
b.assignLODInformation(t, e, r, s, o), b.lodInfos.set(r, i), b.lowresCache.set(r, e);
|
|
541
537
|
}), /**
|
|
542
538
|
* Register a mesh with LOD information
|
|
543
539
|
*/
|
|
544
|
-
d(
|
|
545
|
-
var
|
|
546
|
-
L && console.log("> Progressive: register mesh", r, s.name, o, s.uuid, s);
|
|
540
|
+
d(P, "registerMesh", (t, e, s, o, i, r) => {
|
|
541
|
+
var c;
|
|
547
542
|
const a = s.geometry;
|
|
548
543
|
if (!a) {
|
|
549
544
|
L && console.warn("gltf-progressive: Register mesh without geometry");
|
|
550
545
|
return;
|
|
551
546
|
}
|
|
552
|
-
a.userData || (a.userData = {}),
|
|
553
|
-
let l =
|
|
554
|
-
l ? l.push(s.geometry) : l = [s.geometry],
|
|
555
|
-
for (const
|
|
556
|
-
(
|
|
547
|
+
a.userData || (a.userData = {}), L && console.log("> Progressive: register mesh " + s.name, { index: i, uuid: s.uuid }, r, s), b.assignLODInformation(t, a, e, o, i), b.lodInfos.set(e, r);
|
|
548
|
+
let l = b.lowresCache.get(e);
|
|
549
|
+
l ? l.push(s.geometry) : l = [s.geometry], b.lowresCache.set(e, l), o > 0 && !ce(s) && ht(s, a);
|
|
550
|
+
for (const u of Z)
|
|
551
|
+
(c = u.onRegisteredNewMesh) == null || c.call(u, s, r);
|
|
557
552
|
}), /** A map of key = asset uuid and value = LOD information */
|
|
558
|
-
d(
|
|
559
|
-
d(
|
|
560
|
-
d(
|
|
561
|
-
class
|
|
562
|
-
constructor(
|
|
553
|
+
d(P, "lodInfos", /* @__PURE__ */ new Map()), /** cache of already loaded mesh lods */
|
|
554
|
+
d(P, "previouslyLoaded", /* @__PURE__ */ new Map()), /** this contains the geometry/textures that were originally loaded */
|
|
555
|
+
d(P, "lowresCache", /* @__PURE__ */ new Map());
|
|
556
|
+
class mt {
|
|
557
|
+
constructor(t, e, s, o) {
|
|
563
558
|
d(this, "url");
|
|
564
559
|
/** the key to lookup the LOD information */
|
|
565
560
|
d(this, "key");
|
|
566
561
|
d(this, "level");
|
|
567
562
|
/** For multi objects (e.g. a group of meshes) this is the index of the object */
|
|
568
563
|
d(this, "index");
|
|
569
|
-
|
|
570
|
-
d(this, "density");
|
|
571
|
-
this.url = e, this.key = t, this.level = s, n != null && (this.index = n), r != null && (this.density = r);
|
|
564
|
+
this.url = t, this.key = e, this.level = s, o != null && (this.index = o);
|
|
572
565
|
}
|
|
573
566
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
567
|
+
class ye {
|
|
568
|
+
constructor(t, e) {
|
|
569
|
+
d(this, "frame_start");
|
|
570
|
+
d(this, "frame_capture_end");
|
|
571
|
+
d(this, "ready");
|
|
572
|
+
d(this, "_resolve");
|
|
573
|
+
d(this, "_signal");
|
|
574
|
+
d(this, "_resolved", !1);
|
|
575
|
+
d(this, "_addedCount", 0);
|
|
576
|
+
d(this, "_resolvedCount", 0);
|
|
577
|
+
/** These promises are currently being awaited */
|
|
578
|
+
d(this, "_awaiting", []);
|
|
579
|
+
d(this, "_currentFrame", 0);
|
|
580
|
+
var i;
|
|
581
|
+
const s = t === 0 ? 2 : 1, o = Math.max(e.frames ?? s, s);
|
|
582
|
+
this.frame_start = t, this.frame_capture_end = t + o, this.ready = new Promise((r) => {
|
|
583
|
+
this._resolve = r;
|
|
584
|
+
}), this.ready.finally(() => {
|
|
585
|
+
this._resolved = !0, this._awaiting.length = 0;
|
|
586
|
+
}), this._signal = e.signal, (i = this._signal) == null || i.addEventListener("abort", () => {
|
|
587
|
+
this.resolveNow();
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* The number of promises that have been added to this group so far.
|
|
592
|
+
*/
|
|
593
|
+
get awaitedCount() {
|
|
594
|
+
return this._addedCount;
|
|
595
|
+
}
|
|
596
|
+
get resolvedCount() {
|
|
597
|
+
return this._resolvedCount;
|
|
598
|
+
}
|
|
599
|
+
get currentlyAwaiting() {
|
|
600
|
+
return this._awaiting.length;
|
|
601
|
+
}
|
|
602
|
+
update(t) {
|
|
603
|
+
var e;
|
|
604
|
+
this._currentFrame = t, ((e = this._signal) != null && e.aborted || this._currentFrame > this.frame_capture_end && this._awaiting.length === 0) && this.resolveNow();
|
|
605
|
+
}
|
|
606
|
+
add(t, e) {
|
|
607
|
+
if (this._resolved) {
|
|
608
|
+
console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
this._currentFrame > this.frame_capture_end || (this._awaiting.push(e), this._addedCount++, e.finally(() => {
|
|
612
|
+
this._resolvedCount++, this._awaiting.splice(this._awaiting.indexOf(e), 1);
|
|
613
|
+
}));
|
|
614
|
+
}
|
|
615
|
+
resolveNow() {
|
|
616
|
+
var t, e;
|
|
617
|
+
this._resolved || (e = this._resolve) == null || e.call(this, {
|
|
618
|
+
awaited_count: this._addedCount,
|
|
619
|
+
resolved_count: this._resolvedCount,
|
|
620
|
+
cancelled: ((t = this._signal) == null ? void 0 : t.aborted) ?? !1
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
d(ye, "addPromise", (t, e, s) => {
|
|
625
|
+
s.forEach((o) => {
|
|
626
|
+
o.add(t, e);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
const F = ue("debugprogressive"), yt = ue("noprogressive"), be = Symbol("Needle:LODSManager"), Se = Symbol("Needle:LODState"), Q = Symbol("Needle:CurrentLOD"), E = { mesh_lod: -1, texture_lod: -1 };
|
|
630
|
+
var G, H, we, ee, ie, _e, j;
|
|
631
|
+
const T = class {
|
|
577
632
|
// readonly plugins: NEEDLE_progressive_plugin[] = [];
|
|
578
|
-
constructor(
|
|
579
|
-
d(this, "context");
|
|
633
|
+
constructor(t, e) {
|
|
580
634
|
d(this, "renderer");
|
|
581
|
-
d(this, "
|
|
635
|
+
d(this, "context");
|
|
636
|
+
d(this, "projectionScreenMatrix", new Ge());
|
|
582
637
|
/**
|
|
583
638
|
* The target triangle density is the desired max amount of triangles on screen when the mesh is filling the screen.
|
|
584
639
|
* @default 200_000
|
|
@@ -595,7 +650,7 @@ const E = class {
|
|
|
595
650
|
* @default "auto"
|
|
596
651
|
*/
|
|
597
652
|
d(this, "updateInterval", "auto");
|
|
598
|
-
J(this,
|
|
653
|
+
J(this, G, 1);
|
|
599
654
|
/**
|
|
600
655
|
* If set to true, the LODsManager will not update the LODs.
|
|
601
656
|
* @default false
|
|
@@ -607,59 +662,81 @@ const E = class {
|
|
|
607
662
|
* @default false
|
|
608
663
|
*/
|
|
609
664
|
d(this, "manual", !1);
|
|
665
|
+
d(this, "_newPromiseGroups", []);
|
|
666
|
+
d(this, "_promiseGroupIds", 0);
|
|
610
667
|
d(this, "_lodchangedlisteners", []);
|
|
611
|
-
J(this,
|
|
612
|
-
J(this,
|
|
613
|
-
J(this,
|
|
614
|
-
J(this,
|
|
615
|
-
J(this,
|
|
616
|
-
J(this,
|
|
668
|
+
J(this, H, void 0);
|
|
669
|
+
J(this, we, new Je());
|
|
670
|
+
J(this, ee, 0);
|
|
671
|
+
J(this, ie, 0);
|
|
672
|
+
J(this, _e, 0);
|
|
673
|
+
J(this, j, 0);
|
|
617
674
|
d(this, "_fpsBuffer", [60, 60, 60, 60, 60]);
|
|
618
675
|
// private testIfLODLevelsAreAvailable() {
|
|
619
|
-
d(this, "_sphere", new
|
|
620
|
-
d(this, "_tempBox", new
|
|
621
|
-
d(this, "_tempBox2", new
|
|
622
|
-
d(this, "tempMatrix", new
|
|
623
|
-
d(this, "_tempWorldPosition", new
|
|
624
|
-
d(this, "_tempBoxSize", new
|
|
625
|
-
d(this, "_tempBox2Size", new
|
|
626
|
-
this.renderer =
|
|
676
|
+
d(this, "_sphere", new Ze());
|
|
677
|
+
d(this, "_tempBox", new Ie());
|
|
678
|
+
d(this, "_tempBox2", new Ie());
|
|
679
|
+
d(this, "tempMatrix", new Ge());
|
|
680
|
+
d(this, "_tempWorldPosition", new K());
|
|
681
|
+
d(this, "_tempBoxSize", new K());
|
|
682
|
+
d(this, "_tempBox2Size", new K());
|
|
683
|
+
this.renderer = t, this.context = { ...e };
|
|
627
684
|
}
|
|
628
685
|
/** @internal */
|
|
629
|
-
static getObjectLODState(
|
|
630
|
-
return
|
|
686
|
+
static getObjectLODState(t) {
|
|
687
|
+
return t[Se];
|
|
631
688
|
}
|
|
632
|
-
static addPlugin(
|
|
633
|
-
Z.push(
|
|
689
|
+
static addPlugin(t) {
|
|
690
|
+
Z.push(t);
|
|
634
691
|
}
|
|
635
|
-
static removePlugin(
|
|
636
|
-
const
|
|
637
|
-
|
|
692
|
+
static removePlugin(t) {
|
|
693
|
+
const e = Z.indexOf(t);
|
|
694
|
+
e >= 0 && Z.splice(e, 1);
|
|
638
695
|
}
|
|
639
696
|
/**
|
|
640
697
|
* Gets the LODsManager for the given renderer. If the LODsManager does not exist yet, it will be created.
|
|
641
698
|
* @param renderer The renderer to get the LODsManager for.
|
|
642
699
|
* @returns The LODsManager instance.
|
|
643
700
|
*/
|
|
644
|
-
static get(
|
|
645
|
-
if (
|
|
646
|
-
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),
|
|
647
|
-
const s = new
|
|
701
|
+
static get(t, e) {
|
|
702
|
+
if (t[be])
|
|
703
|
+
return console.debug("[gltf-progressive] LODsManager already exists for this renderer"), t[be];
|
|
704
|
+
const s = new T(t, {
|
|
648
705
|
engine: "unknown",
|
|
649
|
-
...
|
|
706
|
+
...e
|
|
650
707
|
});
|
|
651
|
-
return
|
|
708
|
+
return t[be] = s, s;
|
|
652
709
|
}
|
|
653
710
|
/** @deprecated use static `LODsManager.addPlugin()` method. This getter will be removed in later versions */
|
|
654
711
|
get plugins() {
|
|
655
712
|
return Z;
|
|
656
713
|
}
|
|
657
|
-
|
|
658
|
-
|
|
714
|
+
/**
|
|
715
|
+
* Call to await LODs loading during the next render cycle.
|
|
716
|
+
*/
|
|
717
|
+
awaitLoading(t) {
|
|
718
|
+
const e = this._promiseGroupIds++, s = new ye(p(this, ee), { ...t });
|
|
719
|
+
this._newPromiseGroups.push(s);
|
|
720
|
+
const o = performance.now();
|
|
721
|
+
return s.ready.finally(() => {
|
|
722
|
+
const i = this._newPromiseGroups.indexOf(s);
|
|
723
|
+
i >= 0 && (this._newPromiseGroups.splice(i, 1), ct() && performance.measure("LODsManager:awaitLoading", {
|
|
724
|
+
start: o,
|
|
725
|
+
detail: { id: e, name: t == null ? void 0 : t.name, awaited: s.awaitedCount, resolved: s.resolvedCount }
|
|
726
|
+
}));
|
|
727
|
+
}), s.ready;
|
|
728
|
+
}
|
|
729
|
+
_postprocessPromiseGroups() {
|
|
730
|
+
if (this._newPromiseGroups.length !== 0)
|
|
731
|
+
for (let t = this._newPromiseGroups.length - 1; t >= 0; t--)
|
|
732
|
+
this._newPromiseGroups[t].update(p(this, ee));
|
|
659
733
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
734
|
+
addEventListener(t, e) {
|
|
735
|
+
t === "changed" && this._lodchangedlisteners.push(e);
|
|
736
|
+
}
|
|
737
|
+
removeEventListener(t, e) {
|
|
738
|
+
if (t === "changed") {
|
|
739
|
+
const s = this._lodchangedlisteners.indexOf(e);
|
|
663
740
|
s >= 0 && this._lodchangedlisteners.splice(s, 1);
|
|
664
741
|
}
|
|
665
742
|
}
|
|
@@ -667,54 +744,54 @@ const E = class {
|
|
|
667
744
|
* Enable the LODsManager. This will replace the render method of the renderer with a method that updates the LODs.
|
|
668
745
|
*/
|
|
669
746
|
enable() {
|
|
670
|
-
if (
|
|
747
|
+
if (p(this, H))
|
|
671
748
|
return;
|
|
672
749
|
console.debug("[gltf-progressive] Enabling LODsManager for renderer");
|
|
673
|
-
let
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
const
|
|
678
|
-
(
|
|
679
|
-
const
|
|
680
|
-
|
|
750
|
+
let t = 0;
|
|
751
|
+
V(this, H, this.renderer.render);
|
|
752
|
+
const e = this;
|
|
753
|
+
Ue(this.renderer), this.renderer.render = function(s, o) {
|
|
754
|
+
const i = e.renderer.getRenderTarget();
|
|
755
|
+
(i == null || "isXRRenderTarget" in i && i.isXRRenderTarget) && (t = 0, V(e, ee, p(e, ee) + 1), V(e, ie, p(e, we).getDelta()), V(e, _e, p(e, _e) + p(e, ie)), e._fpsBuffer.shift(), e._fpsBuffer.push(1 / p(e, ie)), V(e, j, e._fpsBuffer.reduce((a, l) => a + l) / e._fpsBuffer.length), F && p(e, ee) % 200 === 0 && console.log("FPS", Math.round(p(e, j)), "Interval:", p(e, G)));
|
|
756
|
+
const r = t++;
|
|
757
|
+
p(e, H).call(this, s, o), e.onAfterRender(s, o, r);
|
|
681
758
|
};
|
|
682
759
|
}
|
|
683
760
|
disable() {
|
|
684
|
-
|
|
761
|
+
p(this, H) && (console.debug("[gltf-progressive] Disabling LODsManager for renderer"), this.renderer.render = p(this, H), V(this, H, void 0));
|
|
685
762
|
}
|
|
686
|
-
update(
|
|
687
|
-
this.internalUpdate(
|
|
763
|
+
update(t, e) {
|
|
764
|
+
this.internalUpdate(t, e);
|
|
688
765
|
}
|
|
689
|
-
onAfterRender(
|
|
766
|
+
onAfterRender(t, e, s) {
|
|
690
767
|
if (this.pause)
|
|
691
768
|
return;
|
|
692
|
-
const
|
|
693
|
-
let
|
|
694
|
-
if (
|
|
695
|
-
const a =
|
|
696
|
-
(a.name === "EffectMaterial" || a.name === "CopyShader") && (
|
|
769
|
+
const i = this.renderer.renderLists.get(t, 0).opaque;
|
|
770
|
+
let r = !0;
|
|
771
|
+
if (i.length === 1) {
|
|
772
|
+
const a = i[0].material;
|
|
773
|
+
(a.name === "EffectMaterial" || a.name === "CopyShader") && (r = !1);
|
|
697
774
|
}
|
|
698
|
-
if ((
|
|
699
|
-
if (
|
|
775
|
+
if ((e.parent && e.parent.type === "CubeCamera" || s >= 1 && e.type === "OrthographicCamera") && (r = !1), r) {
|
|
776
|
+
if (yt || (this.updateInterval === "auto" ? p(this, j) < 40 && p(this, G) < 10 ? (V(this, G, p(this, G) + 1), F && console.warn("↓ Reducing LOD updates", p(this, G), p(this, j).toFixed(0))) : p(this, j) >= 60 && p(this, G) > 1 && (V(this, G, p(this, G) - 1), F && console.warn("↑ Increasing LOD updates", p(this, G), p(this, j).toFixed(0))) : V(this, G, this.updateInterval), p(this, G) > 0 && p(this, ee) % p(this, G) != 0))
|
|
700
777
|
return;
|
|
701
|
-
this.internalUpdate(e,
|
|
778
|
+
this.internalUpdate(t, e), this._postprocessPromiseGroups();
|
|
702
779
|
}
|
|
703
780
|
}
|
|
704
781
|
/**
|
|
705
782
|
* Update LODs in a scene
|
|
706
783
|
*/
|
|
707
|
-
internalUpdate(
|
|
708
|
-
var l,
|
|
709
|
-
const s = this.renderer.renderLists.get(
|
|
710
|
-
this.projectionScreenMatrix.multiplyMatrices(
|
|
711
|
-
const
|
|
712
|
-
for (const
|
|
713
|
-
if (
|
|
714
|
-
|
|
784
|
+
internalUpdate(t, e) {
|
|
785
|
+
var l, c;
|
|
786
|
+
const s = this.renderer.renderLists.get(t, 0), o = s.opaque;
|
|
787
|
+
this.projectionScreenMatrix.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse);
|
|
788
|
+
const i = this.targetTriangleDensity;
|
|
789
|
+
for (const u of o) {
|
|
790
|
+
if (u.material && (((l = u.geometry) == null ? void 0 : l.type) === "BoxGeometry" || ((c = u.geometry) == null ? void 0 : c.type) === "BufferGeometry") && (u.material.name === "SphericalGaussianBlur" || u.material.name == "BackgroundCubeMaterial" || u.material.name === "CubemapFromEquirect" || u.material.name === "EquirectangularToCubeUV")) {
|
|
791
|
+
F && (u.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] || (u.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"] = !0, console.warn("Ignoring skybox or BLIT object", u, u.material.name, u.material.type)));
|
|
715
792
|
continue;
|
|
716
793
|
}
|
|
717
|
-
switch (
|
|
794
|
+
switch (u.material.type) {
|
|
718
795
|
case "LineBasicMaterial":
|
|
719
796
|
case "LineDashedMaterial":
|
|
720
797
|
case "PointsMaterial":
|
|
@@ -723,60 +800,63 @@ const E = class {
|
|
|
723
800
|
case "MeshDepthMaterial":
|
|
724
801
|
continue;
|
|
725
802
|
}
|
|
726
|
-
if (
|
|
727
|
-
|
|
728
|
-
const
|
|
729
|
-
|
|
803
|
+
if (F === "color" && u.material && !u.object.progressive_debug_color) {
|
|
804
|
+
u.object.progressive_debug_color = !0;
|
|
805
|
+
const g = Math.random() * 16777215, w = new Qe({ color: g });
|
|
806
|
+
u.object.material = w;
|
|
730
807
|
}
|
|
731
|
-
const
|
|
732
|
-
(
|
|
808
|
+
const h = u.object;
|
|
809
|
+
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h, i);
|
|
733
810
|
}
|
|
734
|
-
const
|
|
735
|
-
for (const
|
|
736
|
-
const
|
|
737
|
-
(
|
|
811
|
+
const r = s.transparent;
|
|
812
|
+
for (const u of r) {
|
|
813
|
+
const h = u.object;
|
|
814
|
+
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h, i);
|
|
738
815
|
}
|
|
739
816
|
const a = s.transmissive;
|
|
740
|
-
for (const
|
|
741
|
-
const
|
|
742
|
-
(
|
|
817
|
+
for (const u of a) {
|
|
818
|
+
const h = u.object;
|
|
819
|
+
(h instanceof se || h.isMesh) && this.updateLODs(t, e, h, i);
|
|
743
820
|
}
|
|
744
821
|
}
|
|
745
822
|
/** Update the LOD levels for the renderer. */
|
|
746
|
-
updateLODs(
|
|
823
|
+
updateLODs(t, e, s, o) {
|
|
747
824
|
var a, l;
|
|
748
825
|
s.userData || (s.userData = {});
|
|
749
|
-
let
|
|
750
|
-
if (
|
|
826
|
+
let i = s[Se];
|
|
827
|
+
if (i || (i = new Lt(), s[Se] = i), i.frames++ < 2)
|
|
751
828
|
return;
|
|
752
|
-
for (const
|
|
753
|
-
(a =
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
r.lastLodLevel_Mesh = $.mesh_lod, r.lastLodLevel_Texture = $.texture_lod;
|
|
829
|
+
for (const c of Z)
|
|
830
|
+
(a = c.onBeforeUpdateLOD) == null || a.call(c, this.renderer, t, e, s);
|
|
831
|
+
const r = T.overrideGlobalLodLevel !== void 0 ? T.overrideGlobalLodLevel : te;
|
|
832
|
+
r >= 0 ? (E.mesh_lod = r, E.texture_lod = r) : (this.calculateLodLevel(e, s, i, o, E), E.mesh_lod = Math.round(E.mesh_lod), E.texture_lod = Math.round(E.texture_lod)), E.mesh_lod >= 0 && this.loadProgressiveMeshes(s, E.mesh_lod), s.material && E.texture_lod >= 0 && this.loadProgressiveTextures(s.material, E.texture_lod), L && s.material && !s.isGizmo && Ve(s.material);
|
|
833
|
+
for (const c of Z)
|
|
834
|
+
(l = c.onAfterUpdatedLOD) == null || l.call(c, this.renderer, t, e, s, E);
|
|
835
|
+
i.lastLodLevel_Mesh = E.mesh_lod, i.lastLodLevel_Texture = E.texture_lod;
|
|
760
836
|
}
|
|
761
837
|
/** Load progressive textures for the given material
|
|
762
838
|
* @param material the material to load the textures for
|
|
763
839
|
* @param level the LOD level to load. Level 0 is the best quality, higher levels are lower quality
|
|
764
840
|
* @returns Promise with true if the LOD was loaded, false if not
|
|
765
841
|
*/
|
|
766
|
-
loadProgressiveTextures(
|
|
767
|
-
if (!
|
|
842
|
+
loadProgressiveTextures(t, e) {
|
|
843
|
+
if (!t)
|
|
768
844
|
return;
|
|
769
|
-
if (Array.isArray(
|
|
770
|
-
for (const
|
|
771
|
-
this.loadProgressiveTextures(
|
|
845
|
+
if (Array.isArray(t)) {
|
|
846
|
+
for (const i of t)
|
|
847
|
+
this.loadProgressiveTextures(i, e);
|
|
772
848
|
return;
|
|
773
849
|
}
|
|
774
850
|
let s = !1;
|
|
775
|
-
(
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
851
|
+
(t[Q] === void 0 || e < t[Q]) && (s = !0);
|
|
852
|
+
const o = t["DEBUG:LOD"];
|
|
853
|
+
if (o != null && (s = t[Q] != o, e = o), s) {
|
|
854
|
+
t[Q] = e;
|
|
855
|
+
const i = P.assignTextureLOD(t, e).then((r) => {
|
|
856
|
+
this._lodchangedlisteners.forEach((a) => a({ type: "texture", level: e, object: t }));
|
|
857
|
+
});
|
|
858
|
+
ye.addPromise("texture", i, this._newPromiseGroups);
|
|
859
|
+
}
|
|
780
860
|
}
|
|
781
861
|
/** Load progressive meshes for the given mesh
|
|
782
862
|
* @param mesh the mesh to load the LOD for
|
|
@@ -784,324 +864,329 @@ const E = class {
|
|
|
784
864
|
* @param level the LOD level to load. Level 0 is the best quality, higher levels are lower quality
|
|
785
865
|
* @returns Promise with true if the LOD was loaded, false if not
|
|
786
866
|
*/
|
|
787
|
-
loadProgressiveMeshes(
|
|
788
|
-
if (!
|
|
867
|
+
loadProgressiveMeshes(t, e) {
|
|
868
|
+
if (!t)
|
|
789
869
|
return Promise.resolve(null);
|
|
790
|
-
let s =
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
|
|
794
|
-
const r = e.geometry;
|
|
795
|
-
return
|
|
870
|
+
let s = t[Q] !== e;
|
|
871
|
+
const o = t["DEBUG:LOD"];
|
|
872
|
+
if (o != null && (s = t[Q] != o, e = o), s) {
|
|
873
|
+
t[Q] = e;
|
|
874
|
+
const i = t.geometry, r = P.assignMeshLOD(t, e).then((a) => (a && t[Q] == e && i != t.geometry && this._lodchangedlisteners.forEach((l) => l({ type: "mesh", level: e, object: t })), a));
|
|
875
|
+
return ye.addPromise("mesh", r, this._newPromiseGroups), r;
|
|
796
876
|
}
|
|
797
877
|
return Promise.resolve(null);
|
|
798
878
|
}
|
|
799
|
-
static isInside(
|
|
800
|
-
const s =
|
|
801
|
-
return this._tempPtInside.set(
|
|
879
|
+
static isInside(t, e) {
|
|
880
|
+
const s = t.min, o = t.max, i = (s.x + o.x) * 0.5, r = (s.y + o.y) * 0.5;
|
|
881
|
+
return this._tempPtInside.set(i, r, s.z).applyMatrix4(e).z < 0;
|
|
802
882
|
}
|
|
803
|
-
calculateLodLevel(
|
|
804
|
-
var
|
|
805
|
-
if (!
|
|
806
|
-
|
|
883
|
+
calculateLodLevel(t, e, s, o, i) {
|
|
884
|
+
var N, X, _;
|
|
885
|
+
if (!e) {
|
|
886
|
+
i.mesh_lod = -1, i.texture_lod = -1;
|
|
807
887
|
return;
|
|
808
888
|
}
|
|
809
|
-
if (!
|
|
810
|
-
|
|
889
|
+
if (!t) {
|
|
890
|
+
i.mesh_lod = -1, i.texture_lod = -1;
|
|
811
891
|
return;
|
|
812
892
|
}
|
|
813
893
|
let a = 10 + 1, l = !1;
|
|
814
|
-
if (
|
|
815
|
-
return
|
|
816
|
-
const
|
|
817
|
-
if (!
|
|
818
|
-
|
|
894
|
+
if (F && e["DEBUG:LOD"] != null)
|
|
895
|
+
return e["DEBUG:LOD"];
|
|
896
|
+
const c = (N = P.getMeshLODExtension(e.geometry)) == null ? void 0 : N.lods, u = P.getPrimitiveIndex(e.geometry), h = c && c.length > 0, g = P.getMaterialMinMaxLODsCount(e.material), w = (g == null ? void 0 : g.min_count) != 1 / 0 && g.min_count > 0 && g.max_count > 0;
|
|
897
|
+
if (!h && !w) {
|
|
898
|
+
i.mesh_lod = 0, i.texture_lod = 0;
|
|
819
899
|
return;
|
|
820
900
|
}
|
|
821
|
-
|
|
822
|
-
const
|
|
823
|
-
let x =
|
|
824
|
-
if (
|
|
825
|
-
const D =
|
|
901
|
+
h || (l = !0, a = 0);
|
|
902
|
+
const M = this.renderer.domElement.clientHeight || this.renderer.domElement.height;
|
|
903
|
+
let x = e.geometry.boundingBox;
|
|
904
|
+
if (e.type === "SkinnedMesh") {
|
|
905
|
+
const D = e;
|
|
826
906
|
if (!D.boundingBox)
|
|
827
907
|
D.computeBoundingBox();
|
|
828
908
|
else if (this.skinnedMeshAutoUpdateBoundsInterval > 0 && s.frames % this.skinnedMeshAutoUpdateBoundsInterval === 0) {
|
|
829
|
-
const
|
|
830
|
-
|
|
909
|
+
const m = ce(D), q = D.geometry;
|
|
910
|
+
m && (D.geometry = m), D.computeBoundingBox(), D.geometry = q;
|
|
831
911
|
}
|
|
832
912
|
x = D.boundingBox;
|
|
833
913
|
}
|
|
834
914
|
if (x) {
|
|
835
|
-
const D =
|
|
836
|
-
if (
|
|
837
|
-
this._sphere.copy(
|
|
838
|
-
const
|
|
839
|
-
if (this._sphere.containsPoint(
|
|
840
|
-
|
|
915
|
+
const D = t;
|
|
916
|
+
if (e.geometry.attributes.color && e.geometry.attributes.color.count < 100 && e.geometry.boundingSphere) {
|
|
917
|
+
this._sphere.copy(e.geometry.boundingSphere), this._sphere.applyMatrix4(e.matrixWorld);
|
|
918
|
+
const y = t.getWorldPosition(this._tempWorldPosition);
|
|
919
|
+
if (this._sphere.containsPoint(y)) {
|
|
920
|
+
i.mesh_lod = 0, i.texture_lod = 0;
|
|
841
921
|
return;
|
|
842
922
|
}
|
|
843
923
|
}
|
|
844
|
-
if (this._tempBox.copy(x), this._tempBox.applyMatrix4(
|
|
845
|
-
|
|
924
|
+
if (this._tempBox.copy(x), this._tempBox.applyMatrix4(e.matrixWorld), D.isPerspectiveCamera && T.isInside(this._tempBox, this.projectionScreenMatrix)) {
|
|
925
|
+
i.mesh_lod = 0, i.texture_lod = 0;
|
|
846
926
|
return;
|
|
847
927
|
}
|
|
848
928
|
if (this._tempBox.applyMatrix4(this.projectionScreenMatrix), this.renderer.xr.enabled && D.isPerspectiveCamera && D.fov > 70) {
|
|
849
|
-
const
|
|
850
|
-
let
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
const
|
|
854
|
-
s.lastCentrality = (
|
|
929
|
+
const y = this._tempBox.min, v = this._tempBox.max;
|
|
930
|
+
let C = y.x, $ = y.y, z = v.x, oe = v.y;
|
|
931
|
+
const fe = 2, ve = 1.5, he = (y.x + v.x) * 0.5, ge = (y.y + v.y) * 0.5;
|
|
932
|
+
C = (C - he) * fe + he, $ = ($ - ge) * fe + ge, z = (z - he) * fe + he, oe = (oe - ge) * fe + ge;
|
|
933
|
+
const qe = C < 0 && z > 0 ? 0 : Math.min(Math.abs(y.x), Math.abs(v.x)), Ke = $ < 0 && oe > 0 ? 0 : Math.min(Math.abs(y.y), Math.abs(v.y)), De = Math.max(qe, Ke);
|
|
934
|
+
s.lastCentrality = (ve - De) * (ve - De) * (ve - De);
|
|
855
935
|
} else
|
|
856
936
|
s.lastCentrality = 1;
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
const
|
|
862
|
-
if (Math.max(
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
const
|
|
868
|
-
|
|
937
|
+
const m = this._tempBox.getSize(this._tempBoxSize);
|
|
938
|
+
m.multiplyScalar(0.5), screen.availHeight > 0 && M > 0 && m.multiplyScalar(M / screen.availHeight), t.isPerspectiveCamera ? m.x *= t.aspect : t.isOrthographicCamera;
|
|
939
|
+
const q = t.matrixWorldInverse, A = this._tempBox2;
|
|
940
|
+
A.copy(x), A.applyMatrix4(e.matrixWorld), A.applyMatrix4(q);
|
|
941
|
+
const k = A.getSize(this._tempBox2Size), R = Math.max(k.x, k.y);
|
|
942
|
+
if (Math.max(m.x, m.y) != 0 && R != 0 && (m.z = k.z / Math.max(k.x, k.y) * Math.max(m.x, m.y)), s.lastScreenCoverage = Math.max(m.x, m.y, m.z), s.lastScreenspaceVolume.copy(m), s.lastScreenCoverage *= s.lastCentrality, F && T.debugDrawLine) {
|
|
943
|
+
const y = this.tempMatrix.copy(this.projectionScreenMatrix);
|
|
944
|
+
y.invert();
|
|
945
|
+
const v = T.corner0, C = T.corner1, $ = T.corner2, z = T.corner3;
|
|
946
|
+
v.copy(this._tempBox.min), C.copy(this._tempBox.max), C.x = v.x, $.copy(this._tempBox.max), $.y = v.y, z.copy(this._tempBox.max);
|
|
947
|
+
const oe = (v.z + z.z) * 0.5;
|
|
948
|
+
v.z = C.z = $.z = z.z = oe, v.applyMatrix4(y), C.applyMatrix4(y), $.applyMatrix4(y), z.applyMatrix4(y), T.debugDrawLine(v, C, 255), T.debugDrawLine(v, $, 255), T.debugDrawLine(C, z, 255), T.debugDrawLine($, z, 255);
|
|
869
949
|
}
|
|
870
|
-
let
|
|
871
|
-
if (c && s.lastScreenCoverage > 0)
|
|
872
|
-
for (let
|
|
873
|
-
|
|
874
|
-
|
|
950
|
+
let f = 999;
|
|
951
|
+
if (c && s.lastScreenCoverage > 0)
|
|
952
|
+
for (let y = 0; y < c.length; y++) {
|
|
953
|
+
const v = c[y];
|
|
954
|
+
if ((((X = v.densities) == null ? void 0 : X[u]) || v.density || 1e-5) / s.lastScreenCoverage < o) {
|
|
955
|
+
f = y;
|
|
875
956
|
break;
|
|
876
957
|
}
|
|
877
|
-
|
|
878
|
-
|
|
958
|
+
}
|
|
959
|
+
f < a && (a = f, l = !0);
|
|
879
960
|
}
|
|
880
|
-
if (l ?
|
|
881
|
-
const
|
|
882
|
-
|
|
961
|
+
if (l ? i.mesh_lod = a : i.mesh_lod = s.lastLodLevel_Mesh, F && i.mesh_lod != s.lastLodLevel_Mesh) {
|
|
962
|
+
const m = c == null ? void 0 : c[i.mesh_lod];
|
|
963
|
+
m && console.log(`Mesh LOD changed: ${s.lastLodLevel_Mesh} → ${i.mesh_lod} (${m.density.toFixed(0)}) - ${e.name}`);
|
|
883
964
|
}
|
|
884
|
-
if (
|
|
965
|
+
if (w) {
|
|
885
966
|
const D = "saveData" in globalThis.navigator && globalThis.navigator.saveData === !0;
|
|
886
967
|
if (s.lastLodLevel_Texture < 0) {
|
|
887
|
-
if (
|
|
888
|
-
const
|
|
889
|
-
|
|
968
|
+
if (i.texture_lod = g.max_count - 1, F) {
|
|
969
|
+
const m = g.lods[g.max_count - 1];
|
|
970
|
+
F && console.log(`First Texture LOD ${i.texture_lod} (${m.max_height}px) - ${e.name}`);
|
|
890
971
|
}
|
|
891
972
|
} else {
|
|
892
|
-
const
|
|
893
|
-
let
|
|
894
|
-
((
|
|
895
|
-
const
|
|
896
|
-
let
|
|
897
|
-
for (let
|
|
898
|
-
const
|
|
899
|
-
if (!(D &&
|
|
900
|
-
if (
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
Screensize: ${
|
|
904
|
-
${
|
|
973
|
+
const m = s.lastScreenspaceVolume.x + s.lastScreenspaceVolume.y + s.lastScreenspaceVolume.z;
|
|
974
|
+
let q = s.lastScreenCoverage * 4;
|
|
975
|
+
((_ = this.context) == null ? void 0 : _.engine) === "model-viewer" && (q *= 1.5);
|
|
976
|
+
const k = M / window.devicePixelRatio * q;
|
|
977
|
+
let R = !1;
|
|
978
|
+
for (let O = g.lods.length - 1; O >= 0; O--) {
|
|
979
|
+
const f = g.lods[O];
|
|
980
|
+
if (!(D && f.max_height >= 2048) && !(ut() && f.max_height > 4096) && (f.max_height > k || !R && O === 0)) {
|
|
981
|
+
if (R = !0, i.texture_lod = O, i.texture_lod < s.lastLodLevel_Texture) {
|
|
982
|
+
const S = f.max_height;
|
|
983
|
+
F && console.log(`Texture LOD changed: ${s.lastLodLevel_Texture} → ${i.texture_lod} = ${S}px
|
|
984
|
+
Screensize: ${k.toFixed(0)}px, Coverage: ${(100 * s.lastScreenCoverage).toFixed(2)}%, Volume ${m.toFixed(1)}
|
|
985
|
+
${e.name}`);
|
|
905
986
|
}
|
|
906
987
|
break;
|
|
907
988
|
}
|
|
908
989
|
}
|
|
909
990
|
}
|
|
910
991
|
} else
|
|
911
|
-
|
|
992
|
+
i.texture_lod = 0;
|
|
912
993
|
}
|
|
913
994
|
};
|
|
914
|
-
let
|
|
915
|
-
|
|
995
|
+
let I = T;
|
|
996
|
+
G = new WeakMap(), H = new WeakMap(), we = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), _e = new WeakMap(), j = new WeakMap(), /**
|
|
997
|
+
* 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.
|
|
998
|
+
*/
|
|
999
|
+
d(I, "debugDrawLine"), /**
|
|
1000
|
+
* Force override the LOD level for all objects in the scene
|
|
916
1001
|
*/
|
|
917
|
-
d(
|
|
918
|
-
class
|
|
1002
|
+
d(I, "overrideGlobalLodLevel"), d(I, "corner0", new K()), d(I, "corner1", new K()), d(I, "corner2", new K()), d(I, "corner3", new K()), d(I, "_tempPtInside", new K());
|
|
1003
|
+
class Lt {
|
|
919
1004
|
constructor() {
|
|
920
1005
|
d(this, "frames", 0);
|
|
921
1006
|
d(this, "lastLodLevel_Mesh", -1);
|
|
922
1007
|
d(this, "lastLodLevel_Texture", -1);
|
|
923
1008
|
d(this, "lastScreenCoverage", 0);
|
|
924
|
-
d(this, "lastScreenspaceVolume", new
|
|
1009
|
+
d(this, "lastScreenspaceVolume", new K());
|
|
925
1010
|
d(this, "lastCentrality", 0);
|
|
926
1011
|
}
|
|
927
1012
|
}
|
|
928
|
-
const Be = Symbol("NEEDLE_mesh_lod"),
|
|
929
|
-
let
|
|
930
|
-
function
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
return
|
|
934
|
-
}),
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" &&
|
|
1013
|
+
const Be = Symbol("NEEDLE_mesh_lod"), pe = Symbol("NEEDLE_texture_lod");
|
|
1014
|
+
let de = null;
|
|
1015
|
+
function We() {
|
|
1016
|
+
const n = xt();
|
|
1017
|
+
n && (n.mapURLs(function(t) {
|
|
1018
|
+
return Re(), t;
|
|
1019
|
+
}), Re(), de == null || de.disconnect(), de = new MutationObserver((t) => {
|
|
1020
|
+
t.forEach((e) => {
|
|
1021
|
+
e.addedNodes.forEach((s) => {
|
|
1022
|
+
s instanceof HTMLElement && s.tagName.toLowerCase() === "model-viewer" && Xe(s);
|
|
938
1023
|
});
|
|
939
1024
|
});
|
|
940
|
-
}),
|
|
1025
|
+
}), de.observe(document, { childList: !0, subtree: !0 }));
|
|
941
1026
|
}
|
|
942
|
-
function
|
|
1027
|
+
function xt() {
|
|
943
1028
|
if (typeof customElements > "u")
|
|
944
1029
|
return null;
|
|
945
|
-
const
|
|
946
|
-
return
|
|
947
|
-
console.debug("[gltf-progressive] model-viewer defined"),
|
|
1030
|
+
const n = customElements.get("model-viewer");
|
|
1031
|
+
return n || (customElements.whenDefined("model-viewer").then(() => {
|
|
1032
|
+
console.debug("[gltf-progressive] model-viewer defined"), We();
|
|
948
1033
|
}), null);
|
|
949
1034
|
}
|
|
950
|
-
function
|
|
1035
|
+
function Re() {
|
|
951
1036
|
if (typeof document > "u")
|
|
952
1037
|
return;
|
|
953
|
-
document.querySelectorAll("model-viewer").forEach((
|
|
954
|
-
|
|
1038
|
+
document.querySelectorAll("model-viewer").forEach((t) => {
|
|
1039
|
+
Xe(t);
|
|
955
1040
|
});
|
|
956
1041
|
}
|
|
957
|
-
const
|
|
958
|
-
let
|
|
959
|
-
function
|
|
960
|
-
if (!
|
|
1042
|
+
const ke = /* @__PURE__ */ new WeakSet();
|
|
1043
|
+
let wt = 0;
|
|
1044
|
+
function Xe(n) {
|
|
1045
|
+
if (!n || ke.has(n))
|
|
961
1046
|
return null;
|
|
962
|
-
|
|
963
|
-
`,
|
|
964
|
-
let
|
|
965
|
-
for (let
|
|
966
|
-
const
|
|
967
|
-
!
|
|
1047
|
+
ke.add(n), console.debug("[gltf-progressive] found new model-viewer..." + ++wt + `
|
|
1048
|
+
`, n.getAttribute("src"));
|
|
1049
|
+
let t = null, e = null, s = null;
|
|
1050
|
+
for (let o = n; o != null; o = Object.getPrototypeOf(o)) {
|
|
1051
|
+
const i = Object.getOwnPropertySymbols(o), r = i.find((c) => c.toString() == "Symbol(renderer)"), a = i.find((c) => c.toString() == "Symbol(scene)"), l = i.find((c) => c.toString() == "Symbol(needsRender)");
|
|
1052
|
+
!t && r != null && (t = n[r].threeRenderer), !e && a != null && (e = n[a]), !s && l != null && (s = n[l]);
|
|
968
1053
|
}
|
|
969
|
-
if (
|
|
970
|
-
let
|
|
1054
|
+
if (t && e) {
|
|
1055
|
+
let o = function() {
|
|
971
1056
|
if (s) {
|
|
972
|
-
let
|
|
973
|
-
if (
|
|
1057
|
+
let r = 0, a = setInterval(() => {
|
|
1058
|
+
if (r++ > 5) {
|
|
974
1059
|
clearInterval(a);
|
|
975
1060
|
return;
|
|
976
1061
|
}
|
|
977
|
-
s == null || s.call(
|
|
1062
|
+
s == null || s.call(n);
|
|
978
1063
|
}, 300);
|
|
979
1064
|
}
|
|
980
1065
|
};
|
|
981
1066
|
console.debug("[gltf-progressive] setup model-viewer");
|
|
982
|
-
const
|
|
983
|
-
return
|
|
984
|
-
s == null || s.call(
|
|
985
|
-
}),
|
|
986
|
-
|
|
987
|
-
}),
|
|
988
|
-
|
|
1067
|
+
const i = I.get(t, { engine: "model-viewer" });
|
|
1068
|
+
return I.addPlugin(new _t()), i.enable(), i.addEventListener("changed", () => {
|
|
1069
|
+
s == null || s.call(n);
|
|
1070
|
+
}), n.addEventListener("model-visibility", (r) => {
|
|
1071
|
+
r.detail.visible && (s == null || s.call(n));
|
|
1072
|
+
}), n.addEventListener("load", () => {
|
|
1073
|
+
o();
|
|
989
1074
|
}), () => {
|
|
990
|
-
|
|
1075
|
+
i.disable();
|
|
991
1076
|
};
|
|
992
1077
|
}
|
|
993
1078
|
return null;
|
|
994
1079
|
}
|
|
995
|
-
class
|
|
1080
|
+
class _t {
|
|
996
1081
|
constructor() {
|
|
997
1082
|
d(this, "_didWarnAboutMissingUrl", !1);
|
|
998
1083
|
}
|
|
999
|
-
onBeforeUpdateLOD(
|
|
1000
|
-
this.tryParseMeshLOD(
|
|
1084
|
+
onBeforeUpdateLOD(t, e, s, o) {
|
|
1085
|
+
this.tryParseMeshLOD(e, o), this.tryParseTextureLOD(e, o);
|
|
1001
1086
|
}
|
|
1002
|
-
getUrl(
|
|
1003
|
-
if (!
|
|
1087
|
+
getUrl(t) {
|
|
1088
|
+
if (!t)
|
|
1004
1089
|
return null;
|
|
1005
|
-
let
|
|
1006
|
-
return
|
|
1090
|
+
let e = t.getAttribute("src");
|
|
1091
|
+
return e || (e = t.src), e || (this._didWarnAboutMissingUrl || console.warn("No url found in modelviewer", t), this._didWarnAboutMissingUrl = !0), e;
|
|
1007
1092
|
}
|
|
1008
|
-
tryGetCurrentGLTF(
|
|
1009
|
-
return
|
|
1093
|
+
tryGetCurrentGLTF(t) {
|
|
1094
|
+
return t._currentGLTF;
|
|
1010
1095
|
}
|
|
1011
|
-
tryGetCurrentModelViewer(
|
|
1012
|
-
return
|
|
1096
|
+
tryGetCurrentModelViewer(t) {
|
|
1097
|
+
return t.element;
|
|
1013
1098
|
}
|
|
1014
|
-
tryParseTextureLOD(
|
|
1015
|
-
if (
|
|
1099
|
+
tryParseTextureLOD(t, e) {
|
|
1100
|
+
if (e[pe] == !0)
|
|
1016
1101
|
return;
|
|
1017
|
-
|
|
1018
|
-
const s = this.tryGetCurrentGLTF(
|
|
1019
|
-
if (
|
|
1020
|
-
let
|
|
1021
|
-
var
|
|
1022
|
-
if (l[
|
|
1102
|
+
e[pe] = !0;
|
|
1103
|
+
const s = this.tryGetCurrentGLTF(t), o = this.tryGetCurrentModelViewer(t), i = this.getUrl(o);
|
|
1104
|
+
if (i && s && e.material) {
|
|
1105
|
+
let r = function(l) {
|
|
1106
|
+
var u, h, g;
|
|
1107
|
+
if (l[pe] == !0)
|
|
1023
1108
|
return;
|
|
1024
|
-
l[
|
|
1025
|
-
const
|
|
1026
|
-
for (let
|
|
1027
|
-
const
|
|
1109
|
+
l[pe] = !0, l.userData && (l.userData.LOD = -1);
|
|
1110
|
+
const c = Object.keys(l);
|
|
1111
|
+
for (let w = 0; w < c.length; w++) {
|
|
1112
|
+
const M = c[w], x = l[M];
|
|
1028
1113
|
if ((x == null ? void 0 : x.isTexture) === !0) {
|
|
1029
|
-
const
|
|
1030
|
-
if (
|
|
1114
|
+
const N = (h = (u = x.userData) == null ? void 0 : u.associations) == null ? void 0 : h.textures;
|
|
1115
|
+
if (N == null)
|
|
1031
1116
|
continue;
|
|
1032
|
-
const
|
|
1033
|
-
if (!
|
|
1034
|
-
console.warn("Texture data not found for texture index " +
|
|
1117
|
+
const X = s.parser.json.textures[N];
|
|
1118
|
+
if (!X) {
|
|
1119
|
+
console.warn("Texture data not found for texture index " + N);
|
|
1035
1120
|
continue;
|
|
1036
1121
|
}
|
|
1037
|
-
if ((
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1122
|
+
if ((g = X == null ? void 0 : X.extensions) != null && g[Y]) {
|
|
1123
|
+
const _ = X.extensions[Y];
|
|
1124
|
+
_ && i && P.registerTexture(i, x, _.lods.length, N, _);
|
|
1040
1125
|
}
|
|
1041
1126
|
}
|
|
1042
1127
|
}
|
|
1043
1128
|
};
|
|
1044
|
-
const a =
|
|
1129
|
+
const a = e.material;
|
|
1045
1130
|
if (Array.isArray(a))
|
|
1046
1131
|
for (const l of a)
|
|
1047
|
-
|
|
1132
|
+
r(l);
|
|
1048
1133
|
else
|
|
1049
|
-
|
|
1134
|
+
r(a);
|
|
1050
1135
|
}
|
|
1051
1136
|
}
|
|
1052
|
-
tryParseMeshLOD(
|
|
1053
|
-
var
|
|
1054
|
-
if (
|
|
1137
|
+
tryParseMeshLOD(t, e) {
|
|
1138
|
+
var r, a;
|
|
1139
|
+
if (e[Be] == !0)
|
|
1055
1140
|
return;
|
|
1056
|
-
|
|
1057
|
-
const s = this.tryGetCurrentModelViewer(
|
|
1058
|
-
if (!
|
|
1141
|
+
e[Be] = !0;
|
|
1142
|
+
const s = this.tryGetCurrentModelViewer(t), o = this.getUrl(s);
|
|
1143
|
+
if (!o)
|
|
1059
1144
|
return;
|
|
1060
|
-
const
|
|
1061
|
-
if (
|
|
1062
|
-
const l =
|
|
1063
|
-
|
|
1145
|
+
const i = (a = (r = e.userData) == null ? void 0 : r.gltfExtensions) == null ? void 0 : a[Y];
|
|
1146
|
+
if (i && o) {
|
|
1147
|
+
const l = e.uuid;
|
|
1148
|
+
P.registerMesh(o, l, e, 0, i.lods.length, i);
|
|
1064
1149
|
}
|
|
1065
1150
|
}
|
|
1066
1151
|
}
|
|
1067
|
-
function
|
|
1068
|
-
|
|
1152
|
+
function vt(n, t, e, s) {
|
|
1153
|
+
Ue(t), Ne(e), ze(e, {
|
|
1069
1154
|
progressive: !0,
|
|
1070
1155
|
...s == null ? void 0 : s.hints
|
|
1071
|
-
}),
|
|
1072
|
-
const
|
|
1073
|
-
return (s == null ? void 0 : s.enableLODsManager) !== !1 &&
|
|
1156
|
+
}), e.register((i) => new P(i, n));
|
|
1157
|
+
const o = I.get(t);
|
|
1158
|
+
return (s == null ? void 0 : s.enableLODsManager) !== !1 && o.enable(), o;
|
|
1074
1159
|
}
|
|
1075
|
-
|
|
1076
|
-
if (!
|
|
1077
|
-
const
|
|
1160
|
+
We();
|
|
1161
|
+
if (!ft) {
|
|
1162
|
+
const n = {
|
|
1078
1163
|
gltfProgressive: {
|
|
1079
|
-
useNeedleProgressive:
|
|
1080
|
-
LODsManager:
|
|
1081
|
-
configureLoader:
|
|
1164
|
+
useNeedleProgressive: vt,
|
|
1165
|
+
LODsManager: I,
|
|
1166
|
+
configureLoader: ze,
|
|
1082
1167
|
getRaycastMesh: ce,
|
|
1083
|
-
useRaycastMeshes:
|
|
1168
|
+
useRaycastMeshes: gt
|
|
1084
1169
|
}
|
|
1085
1170
|
};
|
|
1086
1171
|
if (!globalThis.Needle)
|
|
1087
|
-
globalThis.Needle =
|
|
1172
|
+
globalThis.Needle = n;
|
|
1088
1173
|
else
|
|
1089
|
-
for (const
|
|
1090
|
-
globalThis.Needle[
|
|
1174
|
+
for (const t in n)
|
|
1175
|
+
globalThis.Needle[t] = n[t];
|
|
1091
1176
|
}
|
|
1092
1177
|
export {
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1178
|
+
Y as EXTENSION_NAME,
|
|
1179
|
+
I as LODsManager,
|
|
1180
|
+
P as NEEDLE_progressive,
|
|
1181
|
+
rt as VERSION,
|
|
1182
|
+
Ne as addDracoAndKTX2Loaders,
|
|
1183
|
+
ze as configureLoader,
|
|
1184
|
+
Ue as createLoaders,
|
|
1100
1185
|
ce as getRaycastMesh,
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1186
|
+
We as patchModelViewer,
|
|
1187
|
+
ht as registerRaycastMesh,
|
|
1188
|
+
nt as setDracoDecoderLocation,
|
|
1189
|
+
at as setKTX2TranscoderLocation,
|
|
1190
|
+
vt as useNeedleProgressive,
|
|
1191
|
+
gt as useRaycastMeshes
|
|
1107
1192
|
};
|