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