@quick-threejs/reactive 0.1.23 → 0.1.24
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/dist/main.js +7 -2829
- package/dist/main.mjs +2834 -0
- package/dist/worker.js +3 -318
- package/dist/worker.mjs +318 -0
- package/package.json +12 -19
- package/dist/main.cjs +0 -12
- package/dist/worker.cjs +0 -3
- /package/dist/{app.module-Da11YIUG.cjs → app.module-Da11YIUG.js} +0 -0
- /package/dist/{app.module-Dg_0i25D.js → app.module-Dg_0i25D.mjs} +0 -0
package/dist/main.mjs
ADDED
|
@@ -0,0 +1,2834 @@
|
|
|
1
|
+
var et = Object.defineProperty;
|
|
2
|
+
var tt = (o, e, t) => e in o ? et(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var g = (o, e, t) => tt(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { i as nt, a as K, L as we, b as $, s as ye, P as st, c as Fe, K as it, A as xe, R as Ee, D as ve } from "./app.module-Dg_0i25D.mjs";
|
|
5
|
+
import { d as _s, f as Ts, g as xs, h as Es, e as vs } from "./app.module-Dg_0i25D.mjs";
|
|
6
|
+
import { Loader as He, FileLoader as z, SRGBColorSpace as D, LinearSRGBColorSpace as R, BufferGeometry as Be, BufferAttribute as j, Color as O, ColorManagement as ae, TrianglesDrawMode as rt, TriangleFanDrawMode as le, TriangleStripDrawMode as Ge, LoaderUtils as U, SpotLight as ot, PointLight as at, DirectionalLight as lt, MeshBasicMaterial as G, MeshPhysicalMaterial as S, Vector2 as je, Matrix4 as X, Vector3 as N, Quaternion as Ue, InstancedMesh as ct, InstancedBufferAttribute as ht, Object3D as Ve, TextureLoader as dt, ImageBitmapLoader as Ke, InterleavedBuffer as ut, InterleavedBufferAttribute as pt, LinearFilter as ze, LinearMipmapLinearFilter as Xe, RepeatWrapping as ce, PointsMaterial as ft, Material as q, LineBasicMaterial as mt, MeshStandardMaterial as We, DoubleSide as gt, PropertyBinding as At, SkinnedMesh as bt, Mesh as wt, LineSegments as yt, Line as _t, LineLoop as Tt, Points as xt, Group as J, PerspectiveCamera as Et, MathUtils as vt, OrthographicCamera as Lt, Skeleton as Rt, AnimationClip as St, Bone as Ct, InterpolateLinear as Ye, NearestFilter as Mt, NearestMipmapNearestFilter as It, LinearMipmapNearestFilter as kt, NearestMipmapLinearFilter as Dt, ClampToEdgeWrapping as Ot, MirroredRepeatWrapping as Pt, InterpolateDiscrete as Nt, FrontSide as $t, Texture as Le, VectorKeyframeTrack as Re, NumberKeyframeTrack as Se, QuaternionKeyframeTrack as Ce, Box3 as Ft, Sphere as Ht, Interpolant as Bt, LoadingManager as Gt, CubeTextureLoader as jt, AudioLoader as Ut, VideoTexture as Vt, CanvasTexture as Kt } from "three";
|
|
7
|
+
import { Subject as he, filter as qe, fromEvent as zt, map as Xt } from "rxjs";
|
|
8
|
+
import { createWorkerPool as Wt, copyProperties as Q, excludeProperties as Yt, isUndefined as Z, isBoolean as ee, isFunction as qt } from "@quick-threejs/utils";
|
|
9
|
+
import Me from "stats.js";
|
|
10
|
+
function _e(o, e) {
|
|
11
|
+
return function(t) {
|
|
12
|
+
nt()(t), K.register(t, t, {
|
|
13
|
+
lifecycle: o
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const te = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
class Jt extends He {
|
|
19
|
+
constructor(e) {
|
|
20
|
+
super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
|
|
21
|
+
position: "POSITION",
|
|
22
|
+
normal: "NORMAL",
|
|
23
|
+
color: "COLOR",
|
|
24
|
+
uv: "TEX_COORD"
|
|
25
|
+
}, this.defaultAttributeTypes = {
|
|
26
|
+
position: "Float32Array",
|
|
27
|
+
normal: "Float32Array",
|
|
28
|
+
color: "Float32Array",
|
|
29
|
+
uv: "Float32Array"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
setDecoderPath(e) {
|
|
33
|
+
return this.decoderPath = e, this;
|
|
34
|
+
}
|
|
35
|
+
setDecoderConfig(e) {
|
|
36
|
+
return this.decoderConfig = e, this;
|
|
37
|
+
}
|
|
38
|
+
setWorkerLimit(e) {
|
|
39
|
+
return this.workerLimit = e, this;
|
|
40
|
+
}
|
|
41
|
+
load(e, t, s, n) {
|
|
42
|
+
const r = new z(this.manager);
|
|
43
|
+
r.setPath(this.path), r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials), r.load(e, (i) => {
|
|
44
|
+
this.parse(i, t, n);
|
|
45
|
+
}, s, n);
|
|
46
|
+
}
|
|
47
|
+
parse(e, t, s = () => {
|
|
48
|
+
}) {
|
|
49
|
+
this.decodeDracoFile(e, t, null, null, D, s).catch(s);
|
|
50
|
+
}
|
|
51
|
+
decodeDracoFile(e, t, s, n, r = R, i = () => {
|
|
52
|
+
}) {
|
|
53
|
+
const l = {
|
|
54
|
+
attributeIDs: s || this.defaultAttributeIDs,
|
|
55
|
+
attributeTypes: n || this.defaultAttributeTypes,
|
|
56
|
+
useUniqueIDs: !!s,
|
|
57
|
+
vertexColorSpace: r
|
|
58
|
+
};
|
|
59
|
+
return this.decodeGeometry(e, l).then(t).catch(i);
|
|
60
|
+
}
|
|
61
|
+
decodeGeometry(e, t) {
|
|
62
|
+
const s = JSON.stringify(t);
|
|
63
|
+
if (te.has(e)) {
|
|
64
|
+
const a = te.get(e);
|
|
65
|
+
if (a.key === s)
|
|
66
|
+
return a.promise;
|
|
67
|
+
if (e.byteLength === 0)
|
|
68
|
+
throw new Error(
|
|
69
|
+
"THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
let n;
|
|
73
|
+
const r = this.workerNextTaskID++, i = e.byteLength, l = this._getWorker(r, i).then((a) => (n = a, new Promise((c, h) => {
|
|
74
|
+
n._callbacks[r] = { resolve: c, reject: h }, n.postMessage({ type: "decode", id: r, taskConfig: t, buffer: e }, [e]);
|
|
75
|
+
}))).then((a) => this._createGeometry(a.geometry));
|
|
76
|
+
return l.catch(() => !0).then(() => {
|
|
77
|
+
n && r && this._releaseTask(n, r);
|
|
78
|
+
}), te.set(e, {
|
|
79
|
+
key: s,
|
|
80
|
+
promise: l
|
|
81
|
+
}), l;
|
|
82
|
+
}
|
|
83
|
+
_createGeometry(e) {
|
|
84
|
+
const t = new Be();
|
|
85
|
+
e.index && t.setIndex(new j(e.index.array, 1));
|
|
86
|
+
for (let s = 0; s < e.attributes.length; s++) {
|
|
87
|
+
const n = e.attributes[s], r = n.name, i = n.array, l = n.itemSize, a = new j(i, l);
|
|
88
|
+
r === "color" && (this._assignVertexColorSpace(a, n.vertexColorSpace), a.normalized = !(i instanceof Float32Array)), t.setAttribute(r, a);
|
|
89
|
+
}
|
|
90
|
+
return t;
|
|
91
|
+
}
|
|
92
|
+
_assignVertexColorSpace(e, t) {
|
|
93
|
+
if (t !== D) return;
|
|
94
|
+
const s = new O();
|
|
95
|
+
for (let n = 0, r = e.count; n < r; n++)
|
|
96
|
+
s.fromBufferAttribute(e, n), ae.toWorkingColorSpace(s, D), e.setXYZ(n, s.r, s.g, s.b);
|
|
97
|
+
}
|
|
98
|
+
_loadLibrary(e, t) {
|
|
99
|
+
const s = new z(this.manager);
|
|
100
|
+
return s.setPath(this.decoderPath), s.setResponseType(t), s.setWithCredentials(this.withCredentials), new Promise((n, r) => {
|
|
101
|
+
s.load(e, n, void 0, r);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
preload() {
|
|
105
|
+
return this._initDecoder(), this;
|
|
106
|
+
}
|
|
107
|
+
_initDecoder() {
|
|
108
|
+
if (this.decoderPending) return this.decoderPending;
|
|
109
|
+
const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
|
|
110
|
+
return e ? t.push(this._loadLibrary("draco_decoder.js", "text")) : (t.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), t.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(t).then((s) => {
|
|
111
|
+
const n = s[0];
|
|
112
|
+
e || (this.decoderConfig.wasmBinary = s[1]);
|
|
113
|
+
const r = Qt.toString(), i = [
|
|
114
|
+
"/* draco decoder */",
|
|
115
|
+
n,
|
|
116
|
+
"",
|
|
117
|
+
"/* worker */",
|
|
118
|
+
r.substring(r.indexOf("{") + 1, r.lastIndexOf("}"))
|
|
119
|
+
].join(`
|
|
120
|
+
`);
|
|
121
|
+
this.workerSourceURL = URL.createObjectURL(new Blob([i]));
|
|
122
|
+
}), this.decoderPending;
|
|
123
|
+
}
|
|
124
|
+
_getWorker(e, t) {
|
|
125
|
+
return this._initDecoder().then(() => {
|
|
126
|
+
if (this.workerPool.length < this.workerLimit) {
|
|
127
|
+
const n = new Worker(this.workerSourceURL);
|
|
128
|
+
n._callbacks = {}, n._taskCosts = {}, n._taskLoad = 0, n.postMessage({ type: "init", decoderConfig: this.decoderConfig }), n.onmessage = function(r) {
|
|
129
|
+
const i = r.data;
|
|
130
|
+
switch (i.type) {
|
|
131
|
+
case "decode":
|
|
132
|
+
n._callbacks[i.id].resolve(i);
|
|
133
|
+
break;
|
|
134
|
+
case "error":
|
|
135
|
+
n._callbacks[i.id].reject(i);
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
console.error('THREE.DRACOLoader: Unexpected message, "' + i.type + '"');
|
|
139
|
+
}
|
|
140
|
+
}, this.workerPool.push(n);
|
|
141
|
+
} else
|
|
142
|
+
this.workerPool.sort(function(n, r) {
|
|
143
|
+
return n._taskLoad > r._taskLoad ? -1 : 1;
|
|
144
|
+
});
|
|
145
|
+
const s = this.workerPool[this.workerPool.length - 1];
|
|
146
|
+
return s._taskCosts[e] = t, s._taskLoad += t, s;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
_releaseTask(e, t) {
|
|
150
|
+
e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t];
|
|
151
|
+
}
|
|
152
|
+
debug() {
|
|
153
|
+
console.log("Task load: ", this.workerPool.map((e) => e._taskLoad));
|
|
154
|
+
}
|
|
155
|
+
dispose() {
|
|
156
|
+
for (let e = 0; e < this.workerPool.length; ++e)
|
|
157
|
+
this.workerPool[e].terminate();
|
|
158
|
+
return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function Qt() {
|
|
162
|
+
let o, e;
|
|
163
|
+
onmessage = function(i) {
|
|
164
|
+
const l = i.data;
|
|
165
|
+
switch (l.type) {
|
|
166
|
+
case "init":
|
|
167
|
+
o = l.decoderConfig, e = new Promise(function(h) {
|
|
168
|
+
o.onModuleLoaded = function(d) {
|
|
169
|
+
h({ draco: d });
|
|
170
|
+
}, DracoDecoderModule(o);
|
|
171
|
+
});
|
|
172
|
+
break;
|
|
173
|
+
case "decode":
|
|
174
|
+
const a = l.buffer, c = l.taskConfig;
|
|
175
|
+
e.then((h) => {
|
|
176
|
+
const d = h.draco, u = new d.Decoder();
|
|
177
|
+
try {
|
|
178
|
+
const p = t(d, u, new Int8Array(a), c), f = p.attributes.map((b) => b.array.buffer);
|
|
179
|
+
p.index && f.push(p.index.array.buffer), self.postMessage({ type: "decode", id: l.id, geometry: p }, f);
|
|
180
|
+
} catch (p) {
|
|
181
|
+
console.error(p), self.postMessage({ type: "error", id: l.id, error: p.message });
|
|
182
|
+
} finally {
|
|
183
|
+
d.destroy(u);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
function t(i, l, a, c) {
|
|
190
|
+
const h = c.attributeIDs, d = c.attributeTypes;
|
|
191
|
+
let u, p;
|
|
192
|
+
const f = l.GetEncodedGeometryType(a);
|
|
193
|
+
if (f === i.TRIANGULAR_MESH)
|
|
194
|
+
u = new i.Mesh(), p = l.DecodeArrayToMesh(a, a.byteLength, u);
|
|
195
|
+
else if (f === i.POINT_CLOUD)
|
|
196
|
+
u = new i.PointCloud(), p = l.DecodeArrayToPointCloud(a, a.byteLength, u);
|
|
197
|
+
else
|
|
198
|
+
throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
|
|
199
|
+
if (!p.ok() || u.ptr === 0)
|
|
200
|
+
throw new Error("THREE.DRACOLoader: Decoding failed: " + p.error_msg());
|
|
201
|
+
const b = { index: null, attributes: [] };
|
|
202
|
+
for (const m in h) {
|
|
203
|
+
const A = self[d[m]];
|
|
204
|
+
let y, T;
|
|
205
|
+
if (c.useUniqueIDs)
|
|
206
|
+
T = h[m], y = l.GetAttributeByUniqueId(u, T);
|
|
207
|
+
else {
|
|
208
|
+
if (T = l.GetAttributeId(u, i[h[m]]), T === -1) continue;
|
|
209
|
+
y = l.GetAttribute(u, T);
|
|
210
|
+
}
|
|
211
|
+
const _ = n(i, l, u, m, A, y);
|
|
212
|
+
m === "color" && (_.vertexColorSpace = c.vertexColorSpace), b.attributes.push(_);
|
|
213
|
+
}
|
|
214
|
+
return f === i.TRIANGULAR_MESH && (b.index = s(i, l, u)), i.destroy(u), b;
|
|
215
|
+
}
|
|
216
|
+
function s(i, l, a) {
|
|
217
|
+
const h = a.num_faces() * 3, d = h * 4, u = i._malloc(d);
|
|
218
|
+
l.GetTrianglesUInt32Array(a, d, u);
|
|
219
|
+
const p = new Uint32Array(i.HEAPF32.buffer, u, h).slice();
|
|
220
|
+
return i._free(u), { array: p, itemSize: 1 };
|
|
221
|
+
}
|
|
222
|
+
function n(i, l, a, c, h, d) {
|
|
223
|
+
const u = d.num_components(), f = a.num_points() * u, b = f * h.BYTES_PER_ELEMENT, m = r(i, h), A = i._malloc(b);
|
|
224
|
+
l.GetAttributeDataArrayForAllPoints(a, d, m, b, A);
|
|
225
|
+
const y = new h(i.HEAPF32.buffer, A, f).slice();
|
|
226
|
+
return i._free(A), {
|
|
227
|
+
name: c,
|
|
228
|
+
array: y,
|
|
229
|
+
itemSize: u
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function r(i, l) {
|
|
233
|
+
switch (l) {
|
|
234
|
+
case Float32Array:
|
|
235
|
+
return i.DT_FLOAT32;
|
|
236
|
+
case Int8Array:
|
|
237
|
+
return i.DT_INT8;
|
|
238
|
+
case Int16Array:
|
|
239
|
+
return i.DT_INT16;
|
|
240
|
+
case Int32Array:
|
|
241
|
+
return i.DT_INT32;
|
|
242
|
+
case Uint8Array:
|
|
243
|
+
return i.DT_UINT8;
|
|
244
|
+
case Uint16Array:
|
|
245
|
+
return i.DT_UINT16;
|
|
246
|
+
case Uint32Array:
|
|
247
|
+
return i.DT_UINT32;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
var Zt = Object.defineProperty, en = Object.getOwnPropertyDescriptor, tn = (o, e, t, s) => {
|
|
252
|
+
for (var n = s > 1 ? void 0 : s ? en(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
253
|
+
(i = o[r]) && (n = (s ? i(e, t, n) : i(n)) || n);
|
|
254
|
+
return s && n && Zt(e, t, n), n;
|
|
255
|
+
};
|
|
256
|
+
let de = class {
|
|
257
|
+
constructor() {
|
|
258
|
+
g(this, "lifecycle$$", new he());
|
|
259
|
+
g(this, "progress$$", new he());
|
|
260
|
+
g(this, "progress$", this.progress$$.pipe());
|
|
261
|
+
g(this, "lifecycle$", this.lifecycle$$.pipe());
|
|
262
|
+
g(this, "progressCompleted$", this.progress$.pipe(
|
|
263
|
+
qe((o) => o.toLoad === o.loaded)
|
|
264
|
+
));
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
de = tn([
|
|
268
|
+
_e(we.ResolutionScoped)
|
|
269
|
+
], de);
|
|
270
|
+
function Ie(o, e) {
|
|
271
|
+
if (e === rt)
|
|
272
|
+
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), o;
|
|
273
|
+
if (e === le || e === Ge) {
|
|
274
|
+
let t = o.getIndex();
|
|
275
|
+
if (t === null) {
|
|
276
|
+
const i = [], l = o.getAttribute("position");
|
|
277
|
+
if (l !== void 0) {
|
|
278
|
+
for (let a = 0; a < l.count; a++)
|
|
279
|
+
i.push(a);
|
|
280
|
+
o.setIndex(i), t = o.getIndex();
|
|
281
|
+
} else
|
|
282
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), o;
|
|
283
|
+
}
|
|
284
|
+
const s = t.count - 2, n = [];
|
|
285
|
+
if (e === le)
|
|
286
|
+
for (let i = 1; i <= s; i++)
|
|
287
|
+
n.push(t.getX(0)), n.push(t.getX(i)), n.push(t.getX(i + 1));
|
|
288
|
+
else
|
|
289
|
+
for (let i = 0; i < s; i++)
|
|
290
|
+
i % 2 === 0 ? (n.push(t.getX(i)), n.push(t.getX(i + 1)), n.push(t.getX(i + 2))) : (n.push(t.getX(i + 2)), n.push(t.getX(i + 1)), n.push(t.getX(i)));
|
|
291
|
+
n.length / 3 !== s && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
292
|
+
const r = o.clone();
|
|
293
|
+
return r.setIndex(n), r.clearGroups(), r;
|
|
294
|
+
} else
|
|
295
|
+
return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), o;
|
|
296
|
+
}
|
|
297
|
+
class nn extends He {
|
|
298
|
+
constructor(e) {
|
|
299
|
+
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
|
|
300
|
+
return new ln(t);
|
|
301
|
+
}), this.register(function(t) {
|
|
302
|
+
return new cn(t);
|
|
303
|
+
}), this.register(function(t) {
|
|
304
|
+
return new bn(t);
|
|
305
|
+
}), this.register(function(t) {
|
|
306
|
+
return new wn(t);
|
|
307
|
+
}), this.register(function(t) {
|
|
308
|
+
return new yn(t);
|
|
309
|
+
}), this.register(function(t) {
|
|
310
|
+
return new dn(t);
|
|
311
|
+
}), this.register(function(t) {
|
|
312
|
+
return new un(t);
|
|
313
|
+
}), this.register(function(t) {
|
|
314
|
+
return new pn(t);
|
|
315
|
+
}), this.register(function(t) {
|
|
316
|
+
return new fn(t);
|
|
317
|
+
}), this.register(function(t) {
|
|
318
|
+
return new an(t);
|
|
319
|
+
}), this.register(function(t) {
|
|
320
|
+
return new mn(t);
|
|
321
|
+
}), this.register(function(t) {
|
|
322
|
+
return new hn(t);
|
|
323
|
+
}), this.register(function(t) {
|
|
324
|
+
return new An(t);
|
|
325
|
+
}), this.register(function(t) {
|
|
326
|
+
return new gn(t);
|
|
327
|
+
}), this.register(function(t) {
|
|
328
|
+
return new rn(t);
|
|
329
|
+
}), this.register(function(t) {
|
|
330
|
+
return new _n(t);
|
|
331
|
+
}), this.register(function(t) {
|
|
332
|
+
return new Tn(t);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
load(e, t, s, n) {
|
|
336
|
+
const r = this;
|
|
337
|
+
let i;
|
|
338
|
+
if (this.resourcePath !== "")
|
|
339
|
+
i = this.resourcePath;
|
|
340
|
+
else if (this.path !== "") {
|
|
341
|
+
const c = U.extractUrlBase(e);
|
|
342
|
+
i = U.resolveURL(c, this.path);
|
|
343
|
+
} else
|
|
344
|
+
i = U.extractUrlBase(e);
|
|
345
|
+
this.manager.itemStart(e);
|
|
346
|
+
const l = function(c) {
|
|
347
|
+
n ? n(c) : console.error(c), r.manager.itemError(e), r.manager.itemEnd(e);
|
|
348
|
+
}, a = new z(this.manager);
|
|
349
|
+
a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(c) {
|
|
350
|
+
try {
|
|
351
|
+
r.parse(c, i, function(h) {
|
|
352
|
+
t(h), r.manager.itemEnd(e);
|
|
353
|
+
}, l);
|
|
354
|
+
} catch (h) {
|
|
355
|
+
l(h);
|
|
356
|
+
}
|
|
357
|
+
}, s, l);
|
|
358
|
+
}
|
|
359
|
+
setDRACOLoader(e) {
|
|
360
|
+
return this.dracoLoader = e, this;
|
|
361
|
+
}
|
|
362
|
+
setKTX2Loader(e) {
|
|
363
|
+
return this.ktx2Loader = e, this;
|
|
364
|
+
}
|
|
365
|
+
setMeshoptDecoder(e) {
|
|
366
|
+
return this.meshoptDecoder = e, this;
|
|
367
|
+
}
|
|
368
|
+
register(e) {
|
|
369
|
+
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
|
|
370
|
+
}
|
|
371
|
+
unregister(e) {
|
|
372
|
+
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
|
|
373
|
+
}
|
|
374
|
+
parse(e, t, s, n) {
|
|
375
|
+
let r;
|
|
376
|
+
const i = {}, l = {}, a = new TextDecoder();
|
|
377
|
+
if (typeof e == "string")
|
|
378
|
+
r = JSON.parse(e);
|
|
379
|
+
else if (e instanceof ArrayBuffer)
|
|
380
|
+
if (a.decode(new Uint8Array(e, 0, 4)) === Je) {
|
|
381
|
+
try {
|
|
382
|
+
i[w.KHR_BINARY_GLTF] = new xn(e);
|
|
383
|
+
} catch (d) {
|
|
384
|
+
n && n(d);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
r = JSON.parse(i[w.KHR_BINARY_GLTF].content);
|
|
388
|
+
} else
|
|
389
|
+
r = JSON.parse(a.decode(e));
|
|
390
|
+
else
|
|
391
|
+
r = e;
|
|
392
|
+
if (r.asset === void 0 || r.asset.version[0] < 2) {
|
|
393
|
+
n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const c = new Nn(r, {
|
|
397
|
+
path: t || this.resourcePath || "",
|
|
398
|
+
crossOrigin: this.crossOrigin,
|
|
399
|
+
requestHeader: this.requestHeader,
|
|
400
|
+
manager: this.manager,
|
|
401
|
+
ktx2Loader: this.ktx2Loader,
|
|
402
|
+
meshoptDecoder: this.meshoptDecoder
|
|
403
|
+
});
|
|
404
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
405
|
+
for (let h = 0; h < this.pluginCallbacks.length; h++) {
|
|
406
|
+
const d = this.pluginCallbacks[h](c);
|
|
407
|
+
d.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), l[d.name] = d, i[d.name] = !0;
|
|
408
|
+
}
|
|
409
|
+
if (r.extensionsUsed)
|
|
410
|
+
for (let h = 0; h < r.extensionsUsed.length; ++h) {
|
|
411
|
+
const d = r.extensionsUsed[h], u = r.extensionsRequired || [];
|
|
412
|
+
switch (d) {
|
|
413
|
+
case w.KHR_MATERIALS_UNLIT:
|
|
414
|
+
i[d] = new on();
|
|
415
|
+
break;
|
|
416
|
+
case w.KHR_DRACO_MESH_COMPRESSION:
|
|
417
|
+
i[d] = new En(r, this.dracoLoader);
|
|
418
|
+
break;
|
|
419
|
+
case w.KHR_TEXTURE_TRANSFORM:
|
|
420
|
+
i[d] = new vn();
|
|
421
|
+
break;
|
|
422
|
+
case w.KHR_MESH_QUANTIZATION:
|
|
423
|
+
i[d] = new Ln();
|
|
424
|
+
break;
|
|
425
|
+
default:
|
|
426
|
+
u.indexOf(d) >= 0 && l[d] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + d + '".');
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
c.setExtensions(i), c.setPlugins(l), c.parse(s, n);
|
|
430
|
+
}
|
|
431
|
+
parseAsync(e, t) {
|
|
432
|
+
const s = this;
|
|
433
|
+
return new Promise(function(n, r) {
|
|
434
|
+
s.parse(e, t, n, r);
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function sn() {
|
|
439
|
+
let o = {};
|
|
440
|
+
return {
|
|
441
|
+
get: function(e) {
|
|
442
|
+
return o[e];
|
|
443
|
+
},
|
|
444
|
+
add: function(e, t) {
|
|
445
|
+
o[e] = t;
|
|
446
|
+
},
|
|
447
|
+
remove: function(e) {
|
|
448
|
+
delete o[e];
|
|
449
|
+
},
|
|
450
|
+
removeAll: function() {
|
|
451
|
+
o = {};
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const w = {
|
|
456
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
457
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
458
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
459
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
460
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
461
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
462
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
463
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
464
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
465
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
466
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
467
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
468
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
469
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
470
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
471
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
472
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
473
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
474
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
475
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
476
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
477
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
478
|
+
};
|
|
479
|
+
class rn {
|
|
480
|
+
constructor(e) {
|
|
481
|
+
this.parser = e, this.name = w.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
482
|
+
}
|
|
483
|
+
_markDefs() {
|
|
484
|
+
const e = this.parser, t = this.parser.json.nodes || [];
|
|
485
|
+
for (let s = 0, n = t.length; s < n; s++) {
|
|
486
|
+
const r = t[s];
|
|
487
|
+
r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
_loadLight(e) {
|
|
491
|
+
const t = this.parser, s = "light:" + e;
|
|
492
|
+
let n = t.cache.get(s);
|
|
493
|
+
if (n) return n;
|
|
494
|
+
const r = t.json, a = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e];
|
|
495
|
+
let c;
|
|
496
|
+
const h = new O(16777215);
|
|
497
|
+
a.color !== void 0 && h.setRGB(a.color[0], a.color[1], a.color[2], R);
|
|
498
|
+
const d = a.range !== void 0 ? a.range : 0;
|
|
499
|
+
switch (a.type) {
|
|
500
|
+
case "directional":
|
|
501
|
+
c = new lt(h), c.target.position.set(0, 0, -1), c.add(c.target);
|
|
502
|
+
break;
|
|
503
|
+
case "point":
|
|
504
|
+
c = new at(h), c.distance = d;
|
|
505
|
+
break;
|
|
506
|
+
case "spot":
|
|
507
|
+
c = new ot(h), c.distance = d, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0, a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4, c.angle = a.spot.outerConeAngle, c.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
|
|
508
|
+
break;
|
|
509
|
+
default:
|
|
510
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + a.type);
|
|
511
|
+
}
|
|
512
|
+
return c.position.set(0, 0, 0), c.decay = 2, C(c, a), a.intensity !== void 0 && (c.intensity = a.intensity), c.name = t.createUniqueName(a.name || "light_" + e), n = Promise.resolve(c), t.cache.add(s, n), n;
|
|
513
|
+
}
|
|
514
|
+
getDependency(e, t) {
|
|
515
|
+
if (e === "light")
|
|
516
|
+
return this._loadLight(t);
|
|
517
|
+
}
|
|
518
|
+
createNodeAttachment(e) {
|
|
519
|
+
const t = this, s = this.parser, r = s.json.nodes[e], l = (r.extensions && r.extensions[this.name] || {}).light;
|
|
520
|
+
return l === void 0 ? null : this._loadLight(l).then(function(a) {
|
|
521
|
+
return s._getNodeRef(t.cache, l, a);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
class on {
|
|
526
|
+
constructor() {
|
|
527
|
+
this.name = w.KHR_MATERIALS_UNLIT;
|
|
528
|
+
}
|
|
529
|
+
getMaterialType() {
|
|
530
|
+
return G;
|
|
531
|
+
}
|
|
532
|
+
extendParams(e, t, s) {
|
|
533
|
+
const n = [];
|
|
534
|
+
e.color = new O(1, 1, 1), e.opacity = 1;
|
|
535
|
+
const r = t.pbrMetallicRoughness;
|
|
536
|
+
if (r) {
|
|
537
|
+
if (Array.isArray(r.baseColorFactor)) {
|
|
538
|
+
const i = r.baseColorFactor;
|
|
539
|
+
e.color.setRGB(i[0], i[1], i[2], R), e.opacity = i[3];
|
|
540
|
+
}
|
|
541
|
+
r.baseColorTexture !== void 0 && n.push(s.assignTexture(e, "map", r.baseColorTexture, D));
|
|
542
|
+
}
|
|
543
|
+
return Promise.all(n);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
class an {
|
|
547
|
+
constructor(e) {
|
|
548
|
+
this.parser = e, this.name = w.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
549
|
+
}
|
|
550
|
+
extendMaterialParams(e, t) {
|
|
551
|
+
const n = this.parser.json.materials[e];
|
|
552
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
553
|
+
return Promise.resolve();
|
|
554
|
+
const r = n.extensions[this.name].emissiveStrength;
|
|
555
|
+
return r !== void 0 && (t.emissiveIntensity = r), Promise.resolve();
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
class ln {
|
|
559
|
+
constructor(e) {
|
|
560
|
+
this.parser = e, this.name = w.KHR_MATERIALS_CLEARCOAT;
|
|
561
|
+
}
|
|
562
|
+
getMaterialType(e) {
|
|
563
|
+
const s = this.parser.json.materials[e];
|
|
564
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
565
|
+
}
|
|
566
|
+
extendMaterialParams(e, t) {
|
|
567
|
+
const s = this.parser, n = s.json.materials[e];
|
|
568
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
569
|
+
return Promise.resolve();
|
|
570
|
+
const r = [], i = n.extensions[this.name];
|
|
571
|
+
if (i.clearcoatFactor !== void 0 && (t.clearcoat = i.clearcoatFactor), i.clearcoatTexture !== void 0 && r.push(s.assignTexture(t, "clearcoatMap", i.clearcoatTexture)), i.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = i.clearcoatRoughnessFactor), i.clearcoatRoughnessTexture !== void 0 && r.push(s.assignTexture(t, "clearcoatRoughnessMap", i.clearcoatRoughnessTexture)), i.clearcoatNormalTexture !== void 0 && (r.push(s.assignTexture(t, "clearcoatNormalMap", i.clearcoatNormalTexture)), i.clearcoatNormalTexture.scale !== void 0)) {
|
|
572
|
+
const l = i.clearcoatNormalTexture.scale;
|
|
573
|
+
t.clearcoatNormalScale = new je(l, l);
|
|
574
|
+
}
|
|
575
|
+
return Promise.all(r);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
class cn {
|
|
579
|
+
constructor(e) {
|
|
580
|
+
this.parser = e, this.name = w.KHR_MATERIALS_DISPERSION;
|
|
581
|
+
}
|
|
582
|
+
getMaterialType(e) {
|
|
583
|
+
const s = this.parser.json.materials[e];
|
|
584
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
585
|
+
}
|
|
586
|
+
extendMaterialParams(e, t) {
|
|
587
|
+
const n = this.parser.json.materials[e];
|
|
588
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
589
|
+
return Promise.resolve();
|
|
590
|
+
const r = n.extensions[this.name];
|
|
591
|
+
return t.dispersion = r.dispersion !== void 0 ? r.dispersion : 0, Promise.resolve();
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
class hn {
|
|
595
|
+
constructor(e) {
|
|
596
|
+
this.parser = e, this.name = w.KHR_MATERIALS_IRIDESCENCE;
|
|
597
|
+
}
|
|
598
|
+
getMaterialType(e) {
|
|
599
|
+
const s = this.parser.json.materials[e];
|
|
600
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
601
|
+
}
|
|
602
|
+
extendMaterialParams(e, t) {
|
|
603
|
+
const s = this.parser, n = s.json.materials[e];
|
|
604
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
605
|
+
return Promise.resolve();
|
|
606
|
+
const r = [], i = n.extensions[this.name];
|
|
607
|
+
return i.iridescenceFactor !== void 0 && (t.iridescence = i.iridescenceFactor), i.iridescenceTexture !== void 0 && r.push(s.assignTexture(t, "iridescenceMap", i.iridescenceTexture)), i.iridescenceIor !== void 0 && (t.iridescenceIOR = i.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), i.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = i.iridescenceThicknessMinimum), i.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = i.iridescenceThicknessMaximum), i.iridescenceThicknessTexture !== void 0 && r.push(s.assignTexture(t, "iridescenceThicknessMap", i.iridescenceThicknessTexture)), Promise.all(r);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
class dn {
|
|
611
|
+
constructor(e) {
|
|
612
|
+
this.parser = e, this.name = w.KHR_MATERIALS_SHEEN;
|
|
613
|
+
}
|
|
614
|
+
getMaterialType(e) {
|
|
615
|
+
const s = this.parser.json.materials[e];
|
|
616
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
617
|
+
}
|
|
618
|
+
extendMaterialParams(e, t) {
|
|
619
|
+
const s = this.parser, n = s.json.materials[e];
|
|
620
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
621
|
+
return Promise.resolve();
|
|
622
|
+
const r = [];
|
|
623
|
+
t.sheenColor = new O(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
|
|
624
|
+
const i = n.extensions[this.name];
|
|
625
|
+
if (i.sheenColorFactor !== void 0) {
|
|
626
|
+
const l = i.sheenColorFactor;
|
|
627
|
+
t.sheenColor.setRGB(l[0], l[1], l[2], R);
|
|
628
|
+
}
|
|
629
|
+
return i.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = i.sheenRoughnessFactor), i.sheenColorTexture !== void 0 && r.push(s.assignTexture(t, "sheenColorMap", i.sheenColorTexture, D)), i.sheenRoughnessTexture !== void 0 && r.push(s.assignTexture(t, "sheenRoughnessMap", i.sheenRoughnessTexture)), Promise.all(r);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
class un {
|
|
633
|
+
constructor(e) {
|
|
634
|
+
this.parser = e, this.name = w.KHR_MATERIALS_TRANSMISSION;
|
|
635
|
+
}
|
|
636
|
+
getMaterialType(e) {
|
|
637
|
+
const s = this.parser.json.materials[e];
|
|
638
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
639
|
+
}
|
|
640
|
+
extendMaterialParams(e, t) {
|
|
641
|
+
const s = this.parser, n = s.json.materials[e];
|
|
642
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
643
|
+
return Promise.resolve();
|
|
644
|
+
const r = [], i = n.extensions[this.name];
|
|
645
|
+
return i.transmissionFactor !== void 0 && (t.transmission = i.transmissionFactor), i.transmissionTexture !== void 0 && r.push(s.assignTexture(t, "transmissionMap", i.transmissionTexture)), Promise.all(r);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
class pn {
|
|
649
|
+
constructor(e) {
|
|
650
|
+
this.parser = e, this.name = w.KHR_MATERIALS_VOLUME;
|
|
651
|
+
}
|
|
652
|
+
getMaterialType(e) {
|
|
653
|
+
const s = this.parser.json.materials[e];
|
|
654
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
655
|
+
}
|
|
656
|
+
extendMaterialParams(e, t) {
|
|
657
|
+
const s = this.parser, n = s.json.materials[e];
|
|
658
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
659
|
+
return Promise.resolve();
|
|
660
|
+
const r = [], i = n.extensions[this.name];
|
|
661
|
+
t.thickness = i.thicknessFactor !== void 0 ? i.thicknessFactor : 0, i.thicknessTexture !== void 0 && r.push(s.assignTexture(t, "thicknessMap", i.thicknessTexture)), t.attenuationDistance = i.attenuationDistance || 1 / 0;
|
|
662
|
+
const l = i.attenuationColor || [1, 1, 1];
|
|
663
|
+
return t.attenuationColor = new O().setRGB(l[0], l[1], l[2], R), Promise.all(r);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
class fn {
|
|
667
|
+
constructor(e) {
|
|
668
|
+
this.parser = e, this.name = w.KHR_MATERIALS_IOR;
|
|
669
|
+
}
|
|
670
|
+
getMaterialType(e) {
|
|
671
|
+
const s = this.parser.json.materials[e];
|
|
672
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
673
|
+
}
|
|
674
|
+
extendMaterialParams(e, t) {
|
|
675
|
+
const n = this.parser.json.materials[e];
|
|
676
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
677
|
+
return Promise.resolve();
|
|
678
|
+
const r = n.extensions[this.name];
|
|
679
|
+
return t.ior = r.ior !== void 0 ? r.ior : 1.5, Promise.resolve();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
class mn {
|
|
683
|
+
constructor(e) {
|
|
684
|
+
this.parser = e, this.name = w.KHR_MATERIALS_SPECULAR;
|
|
685
|
+
}
|
|
686
|
+
getMaterialType(e) {
|
|
687
|
+
const s = this.parser.json.materials[e];
|
|
688
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
689
|
+
}
|
|
690
|
+
extendMaterialParams(e, t) {
|
|
691
|
+
const s = this.parser, n = s.json.materials[e];
|
|
692
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
693
|
+
return Promise.resolve();
|
|
694
|
+
const r = [], i = n.extensions[this.name];
|
|
695
|
+
t.specularIntensity = i.specularFactor !== void 0 ? i.specularFactor : 1, i.specularTexture !== void 0 && r.push(s.assignTexture(t, "specularIntensityMap", i.specularTexture));
|
|
696
|
+
const l = i.specularColorFactor || [1, 1, 1];
|
|
697
|
+
return t.specularColor = new O().setRGB(l[0], l[1], l[2], R), i.specularColorTexture !== void 0 && r.push(s.assignTexture(t, "specularColorMap", i.specularColorTexture, D)), Promise.all(r);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
class gn {
|
|
701
|
+
constructor(e) {
|
|
702
|
+
this.parser = e, this.name = w.EXT_MATERIALS_BUMP;
|
|
703
|
+
}
|
|
704
|
+
getMaterialType(e) {
|
|
705
|
+
const s = this.parser.json.materials[e];
|
|
706
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
707
|
+
}
|
|
708
|
+
extendMaterialParams(e, t) {
|
|
709
|
+
const s = this.parser, n = s.json.materials[e];
|
|
710
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
711
|
+
return Promise.resolve();
|
|
712
|
+
const r = [], i = n.extensions[this.name];
|
|
713
|
+
return t.bumpScale = i.bumpFactor !== void 0 ? i.bumpFactor : 1, i.bumpTexture !== void 0 && r.push(s.assignTexture(t, "bumpMap", i.bumpTexture)), Promise.all(r);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
class An {
|
|
717
|
+
constructor(e) {
|
|
718
|
+
this.parser = e, this.name = w.KHR_MATERIALS_ANISOTROPY;
|
|
719
|
+
}
|
|
720
|
+
getMaterialType(e) {
|
|
721
|
+
const s = this.parser.json.materials[e];
|
|
722
|
+
return !s.extensions || !s.extensions[this.name] ? null : S;
|
|
723
|
+
}
|
|
724
|
+
extendMaterialParams(e, t) {
|
|
725
|
+
const s = this.parser, n = s.json.materials[e];
|
|
726
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
727
|
+
return Promise.resolve();
|
|
728
|
+
const r = [], i = n.extensions[this.name];
|
|
729
|
+
return i.anisotropyStrength !== void 0 && (t.anisotropy = i.anisotropyStrength), i.anisotropyRotation !== void 0 && (t.anisotropyRotation = i.anisotropyRotation), i.anisotropyTexture !== void 0 && r.push(s.assignTexture(t, "anisotropyMap", i.anisotropyTexture)), Promise.all(r);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
class bn {
|
|
733
|
+
constructor(e) {
|
|
734
|
+
this.parser = e, this.name = w.KHR_TEXTURE_BASISU;
|
|
735
|
+
}
|
|
736
|
+
loadTexture(e) {
|
|
737
|
+
const t = this.parser, s = t.json, n = s.textures[e];
|
|
738
|
+
if (!n.extensions || !n.extensions[this.name])
|
|
739
|
+
return null;
|
|
740
|
+
const r = n.extensions[this.name], i = t.options.ktx2Loader;
|
|
741
|
+
if (!i) {
|
|
742
|
+
if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0)
|
|
743
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
744
|
+
return null;
|
|
745
|
+
}
|
|
746
|
+
return t.loadTextureImage(e, r.source, i);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
class wn {
|
|
750
|
+
constructor(e) {
|
|
751
|
+
this.parser = e, this.name = w.EXT_TEXTURE_WEBP, this.isSupported = null;
|
|
752
|
+
}
|
|
753
|
+
loadTexture(e) {
|
|
754
|
+
const t = this.name, s = this.parser, n = s.json, r = n.textures[e];
|
|
755
|
+
if (!r.extensions || !r.extensions[t])
|
|
756
|
+
return null;
|
|
757
|
+
const i = r.extensions[t], l = n.images[i.source];
|
|
758
|
+
let a = s.textureLoader;
|
|
759
|
+
if (l.uri) {
|
|
760
|
+
const c = s.options.manager.getHandler(l.uri);
|
|
761
|
+
c !== null && (a = c);
|
|
762
|
+
}
|
|
763
|
+
return this.detectSupport().then(function(c) {
|
|
764
|
+
if (c) return s.loadTextureImage(e, i.source, a);
|
|
765
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
|
|
766
|
+
throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
|
|
767
|
+
return s.loadTexture(e);
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
detectSupport() {
|
|
771
|
+
return this.isSupported || (this.isSupported = new Promise(function(e) {
|
|
772
|
+
const t = new Image();
|
|
773
|
+
t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() {
|
|
774
|
+
e(t.height === 1);
|
|
775
|
+
};
|
|
776
|
+
})), this.isSupported;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
class yn {
|
|
780
|
+
constructor(e) {
|
|
781
|
+
this.parser = e, this.name = w.EXT_TEXTURE_AVIF, this.isSupported = null;
|
|
782
|
+
}
|
|
783
|
+
loadTexture(e) {
|
|
784
|
+
const t = this.name, s = this.parser, n = s.json, r = n.textures[e];
|
|
785
|
+
if (!r.extensions || !r.extensions[t])
|
|
786
|
+
return null;
|
|
787
|
+
const i = r.extensions[t], l = n.images[i.source];
|
|
788
|
+
let a = s.textureLoader;
|
|
789
|
+
if (l.uri) {
|
|
790
|
+
const c = s.options.manager.getHandler(l.uri);
|
|
791
|
+
c !== null && (a = c);
|
|
792
|
+
}
|
|
793
|
+
return this.detectSupport().then(function(c) {
|
|
794
|
+
if (c) return s.loadTextureImage(e, i.source, a);
|
|
795
|
+
if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
|
|
796
|
+
throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
|
|
797
|
+
return s.loadTexture(e);
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
detectSupport() {
|
|
801
|
+
return this.isSupported || (this.isSupported = new Promise(function(e) {
|
|
802
|
+
const t = new Image();
|
|
803
|
+
t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() {
|
|
804
|
+
e(t.height === 1);
|
|
805
|
+
};
|
|
806
|
+
})), this.isSupported;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
class _n {
|
|
810
|
+
constructor(e) {
|
|
811
|
+
this.name = w.EXT_MESHOPT_COMPRESSION, this.parser = e;
|
|
812
|
+
}
|
|
813
|
+
loadBufferView(e) {
|
|
814
|
+
const t = this.parser.json, s = t.bufferViews[e];
|
|
815
|
+
if (s.extensions && s.extensions[this.name]) {
|
|
816
|
+
const n = s.extensions[this.name], r = this.parser.getDependency("buffer", n.buffer), i = this.parser.options.meshoptDecoder;
|
|
817
|
+
if (!i || !i.supported) {
|
|
818
|
+
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
|
|
819
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
return r.then(function(l) {
|
|
823
|
+
const a = n.byteOffset || 0, c = n.byteLength || 0, h = n.count, d = n.byteStride, u = new Uint8Array(l, a, c);
|
|
824
|
+
return i.decodeGltfBufferAsync ? i.decodeGltfBufferAsync(h, d, u, n.mode, n.filter).then(function(p) {
|
|
825
|
+
return p.buffer;
|
|
826
|
+
}) : i.ready.then(function() {
|
|
827
|
+
const p = new ArrayBuffer(h * d);
|
|
828
|
+
return i.decodeGltfBuffer(new Uint8Array(p), h, d, u, n.mode, n.filter), p;
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
} else
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
class Tn {
|
|
836
|
+
constructor(e) {
|
|
837
|
+
this.name = w.EXT_MESH_GPU_INSTANCING, this.parser = e;
|
|
838
|
+
}
|
|
839
|
+
createNodeMesh(e) {
|
|
840
|
+
const t = this.parser.json, s = t.nodes[e];
|
|
841
|
+
if (!s.extensions || !s.extensions[this.name] || s.mesh === void 0)
|
|
842
|
+
return null;
|
|
843
|
+
const n = t.meshes[s.mesh];
|
|
844
|
+
for (const c of n.primitives)
|
|
845
|
+
if (c.mode !== x.TRIANGLES && c.mode !== x.TRIANGLE_STRIP && c.mode !== x.TRIANGLE_FAN && c.mode !== void 0)
|
|
846
|
+
return null;
|
|
847
|
+
const i = s.extensions[this.name].attributes, l = [], a = {};
|
|
848
|
+
for (const c in i)
|
|
849
|
+
l.push(this.parser.getDependency("accessor", i[c]).then((h) => (a[c] = h, a[c])));
|
|
850
|
+
return l.length < 1 ? null : (l.push(this.parser.createNodeMesh(e)), Promise.all(l).then((c) => {
|
|
851
|
+
const h = c.pop(), d = h.isGroup ? h.children : [h], u = c[0].count, p = [];
|
|
852
|
+
for (const f of d) {
|
|
853
|
+
const b = new X(), m = new N(), A = new Ue(), y = new N(1, 1, 1), T = new ct(f.geometry, f.material, u);
|
|
854
|
+
for (let _ = 0; _ < u; _++)
|
|
855
|
+
a.TRANSLATION && m.fromBufferAttribute(a.TRANSLATION, _), a.ROTATION && A.fromBufferAttribute(a.ROTATION, _), a.SCALE && y.fromBufferAttribute(a.SCALE, _), T.setMatrixAt(_, b.compose(m, A, y));
|
|
856
|
+
for (const _ in a)
|
|
857
|
+
if (_ === "_COLOR_0") {
|
|
858
|
+
const v = a[_];
|
|
859
|
+
T.instanceColor = new ht(v.array, v.itemSize, v.normalized);
|
|
860
|
+
} else _ !== "TRANSLATION" && _ !== "ROTATION" && _ !== "SCALE" && f.geometry.setAttribute(_, a[_]);
|
|
861
|
+
Ve.prototype.copy.call(T, f), this.parser.assignFinalMaterial(T), p.push(T);
|
|
862
|
+
}
|
|
863
|
+
return h.isGroup ? (h.clear(), h.add(...p), h) : p[0];
|
|
864
|
+
}));
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
const Je = "glTF", B = 12, ke = { JSON: 1313821514, BIN: 5130562 };
|
|
868
|
+
class xn {
|
|
869
|
+
constructor(e) {
|
|
870
|
+
this.name = w.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
871
|
+
const t = new DataView(e, 0, B), s = new TextDecoder();
|
|
872
|
+
if (this.header = {
|
|
873
|
+
magic: s.decode(new Uint8Array(e.slice(0, 4))),
|
|
874
|
+
version: t.getUint32(4, !0),
|
|
875
|
+
length: t.getUint32(8, !0)
|
|
876
|
+
}, this.header.magic !== Je)
|
|
877
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
878
|
+
if (this.header.version < 2)
|
|
879
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
880
|
+
const n = this.header.length - B, r = new DataView(e, B);
|
|
881
|
+
let i = 0;
|
|
882
|
+
for (; i < n; ) {
|
|
883
|
+
const l = r.getUint32(i, !0);
|
|
884
|
+
i += 4;
|
|
885
|
+
const a = r.getUint32(i, !0);
|
|
886
|
+
if (i += 4, a === ke.JSON) {
|
|
887
|
+
const c = new Uint8Array(e, B + i, l);
|
|
888
|
+
this.content = s.decode(c);
|
|
889
|
+
} else if (a === ke.BIN) {
|
|
890
|
+
const c = B + i;
|
|
891
|
+
this.body = e.slice(c, c + l);
|
|
892
|
+
}
|
|
893
|
+
i += l;
|
|
894
|
+
}
|
|
895
|
+
if (this.content === null)
|
|
896
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
class En {
|
|
900
|
+
constructor(e, t) {
|
|
901
|
+
if (!t)
|
|
902
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
903
|
+
this.name = w.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
|
|
904
|
+
}
|
|
905
|
+
decodePrimitive(e, t) {
|
|
906
|
+
const s = this.json, n = this.dracoLoader, r = e.extensions[this.name].bufferView, i = e.extensions[this.name].attributes, l = {}, a = {}, c = {};
|
|
907
|
+
for (const h in i) {
|
|
908
|
+
const d = ue[h] || h.toLowerCase();
|
|
909
|
+
l[d] = i[h];
|
|
910
|
+
}
|
|
911
|
+
for (const h in e.attributes) {
|
|
912
|
+
const d = ue[h] || h.toLowerCase();
|
|
913
|
+
if (i[h] !== void 0) {
|
|
914
|
+
const u = s.accessors[e.attributes[h]], p = F[u.componentType];
|
|
915
|
+
c[d] = p.name, a[d] = u.normalized === !0;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
return t.getDependency("bufferView", r).then(function(h) {
|
|
919
|
+
return new Promise(function(d, u) {
|
|
920
|
+
n.decodeDracoFile(h, function(p) {
|
|
921
|
+
for (const f in p.attributes) {
|
|
922
|
+
const b = p.attributes[f], m = a[f];
|
|
923
|
+
m !== void 0 && (b.normalized = m);
|
|
924
|
+
}
|
|
925
|
+
d(p);
|
|
926
|
+
}, l, c, R, u);
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
class vn {
|
|
932
|
+
constructor() {
|
|
933
|
+
this.name = w.KHR_TEXTURE_TRANSFORM;
|
|
934
|
+
}
|
|
935
|
+
extendTexture(e, t) {
|
|
936
|
+
return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
class Ln {
|
|
940
|
+
constructor() {
|
|
941
|
+
this.name = w.KHR_MESH_QUANTIZATION;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
class Qe extends Bt {
|
|
945
|
+
constructor(e, t, s, n) {
|
|
946
|
+
super(e, t, s, n);
|
|
947
|
+
}
|
|
948
|
+
copySampleValue_(e) {
|
|
949
|
+
const t = this.resultBuffer, s = this.sampleValues, n = this.valueSize, r = e * n * 3 + n;
|
|
950
|
+
for (let i = 0; i !== n; i++)
|
|
951
|
+
t[i] = s[r + i];
|
|
952
|
+
return t;
|
|
953
|
+
}
|
|
954
|
+
interpolate_(e, t, s, n) {
|
|
955
|
+
const r = this.resultBuffer, i = this.sampleValues, l = this.valueSize, a = l * 2, c = l * 3, h = n - t, d = (s - t) / h, u = d * d, p = u * d, f = e * c, b = f - c, m = -2 * p + 3 * u, A = p - u, y = 1 - m, T = A - u + d;
|
|
956
|
+
for (let _ = 0; _ !== l; _++) {
|
|
957
|
+
const v = i[b + _ + l], M = i[b + _ + a] * h, E = i[f + _ + l], H = i[f + _] * h;
|
|
958
|
+
r[_] = y * v + T * M + m * E + A * H;
|
|
959
|
+
}
|
|
960
|
+
return r;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
const Rn = new Ue();
|
|
964
|
+
class Sn extends Qe {
|
|
965
|
+
interpolate_(e, t, s, n) {
|
|
966
|
+
const r = super.interpolate_(e, t, s, n);
|
|
967
|
+
return Rn.fromArray(r).normalize().toArray(r), r;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
const x = {
|
|
971
|
+
FLOAT: 5126,
|
|
972
|
+
//FLOAT_MAT2: 35674,
|
|
973
|
+
FLOAT_MAT3: 35675,
|
|
974
|
+
FLOAT_MAT4: 35676,
|
|
975
|
+
FLOAT_VEC2: 35664,
|
|
976
|
+
FLOAT_VEC3: 35665,
|
|
977
|
+
FLOAT_VEC4: 35666,
|
|
978
|
+
LINEAR: 9729,
|
|
979
|
+
REPEAT: 10497,
|
|
980
|
+
SAMPLER_2D: 35678,
|
|
981
|
+
POINTS: 0,
|
|
982
|
+
LINES: 1,
|
|
983
|
+
LINE_LOOP: 2,
|
|
984
|
+
LINE_STRIP: 3,
|
|
985
|
+
TRIANGLES: 4,
|
|
986
|
+
TRIANGLE_STRIP: 5,
|
|
987
|
+
TRIANGLE_FAN: 6,
|
|
988
|
+
UNSIGNED_BYTE: 5121,
|
|
989
|
+
UNSIGNED_SHORT: 5123
|
|
990
|
+
}, F = {
|
|
991
|
+
5120: Int8Array,
|
|
992
|
+
5121: Uint8Array,
|
|
993
|
+
5122: Int16Array,
|
|
994
|
+
5123: Uint16Array,
|
|
995
|
+
5125: Uint32Array,
|
|
996
|
+
5126: Float32Array
|
|
997
|
+
}, De = {
|
|
998
|
+
9728: Mt,
|
|
999
|
+
9729: ze,
|
|
1000
|
+
9984: It,
|
|
1001
|
+
9985: kt,
|
|
1002
|
+
9986: Dt,
|
|
1003
|
+
9987: Xe
|
|
1004
|
+
}, Oe = {
|
|
1005
|
+
33071: Ot,
|
|
1006
|
+
33648: Pt,
|
|
1007
|
+
10497: ce
|
|
1008
|
+
}, ne = {
|
|
1009
|
+
SCALAR: 1,
|
|
1010
|
+
VEC2: 2,
|
|
1011
|
+
VEC3: 3,
|
|
1012
|
+
VEC4: 4,
|
|
1013
|
+
MAT2: 4,
|
|
1014
|
+
MAT3: 9,
|
|
1015
|
+
MAT4: 16
|
|
1016
|
+
}, ue = {
|
|
1017
|
+
POSITION: "position",
|
|
1018
|
+
NORMAL: "normal",
|
|
1019
|
+
TANGENT: "tangent",
|
|
1020
|
+
TEXCOORD_0: "uv",
|
|
1021
|
+
TEXCOORD_1: "uv1",
|
|
1022
|
+
TEXCOORD_2: "uv2",
|
|
1023
|
+
TEXCOORD_3: "uv3",
|
|
1024
|
+
COLOR_0: "color",
|
|
1025
|
+
WEIGHTS_0: "skinWeight",
|
|
1026
|
+
JOINTS_0: "skinIndex"
|
|
1027
|
+
}, k = {
|
|
1028
|
+
scale: "scale",
|
|
1029
|
+
translation: "position",
|
|
1030
|
+
rotation: "quaternion",
|
|
1031
|
+
weights: "morphTargetInfluences"
|
|
1032
|
+
}, Cn = {
|
|
1033
|
+
CUBICSPLINE: void 0,
|
|
1034
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
1035
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
1036
|
+
LINEAR: Ye,
|
|
1037
|
+
STEP: Nt
|
|
1038
|
+
}, se = {
|
|
1039
|
+
OPAQUE: "OPAQUE",
|
|
1040
|
+
MASK: "MASK",
|
|
1041
|
+
BLEND: "BLEND"
|
|
1042
|
+
};
|
|
1043
|
+
function Mn(o) {
|
|
1044
|
+
return o.DefaultMaterial === void 0 && (o.DefaultMaterial = new We({
|
|
1045
|
+
color: 16777215,
|
|
1046
|
+
emissive: 0,
|
|
1047
|
+
metalness: 1,
|
|
1048
|
+
roughness: 1,
|
|
1049
|
+
transparent: !1,
|
|
1050
|
+
depthTest: !0,
|
|
1051
|
+
side: $t
|
|
1052
|
+
})), o.DefaultMaterial;
|
|
1053
|
+
}
|
|
1054
|
+
function P(o, e, t) {
|
|
1055
|
+
for (const s in t.extensions)
|
|
1056
|
+
o[s] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[s] = t.extensions[s]);
|
|
1057
|
+
}
|
|
1058
|
+
function C(o, e) {
|
|
1059
|
+
e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(o.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
|
|
1060
|
+
}
|
|
1061
|
+
function In(o, e, t) {
|
|
1062
|
+
let s = !1, n = !1, r = !1;
|
|
1063
|
+
for (let c = 0, h = e.length; c < h; c++) {
|
|
1064
|
+
const d = e[c];
|
|
1065
|
+
if (d.POSITION !== void 0 && (s = !0), d.NORMAL !== void 0 && (n = !0), d.COLOR_0 !== void 0 && (r = !0), s && n && r) break;
|
|
1066
|
+
}
|
|
1067
|
+
if (!s && !n && !r) return Promise.resolve(o);
|
|
1068
|
+
const i = [], l = [], a = [];
|
|
1069
|
+
for (let c = 0, h = e.length; c < h; c++) {
|
|
1070
|
+
const d = e[c];
|
|
1071
|
+
if (s) {
|
|
1072
|
+
const u = d.POSITION !== void 0 ? t.getDependency("accessor", d.POSITION) : o.attributes.position;
|
|
1073
|
+
i.push(u);
|
|
1074
|
+
}
|
|
1075
|
+
if (n) {
|
|
1076
|
+
const u = d.NORMAL !== void 0 ? t.getDependency("accessor", d.NORMAL) : o.attributes.normal;
|
|
1077
|
+
l.push(u);
|
|
1078
|
+
}
|
|
1079
|
+
if (r) {
|
|
1080
|
+
const u = d.COLOR_0 !== void 0 ? t.getDependency("accessor", d.COLOR_0) : o.attributes.color;
|
|
1081
|
+
a.push(u);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return Promise.all([
|
|
1085
|
+
Promise.all(i),
|
|
1086
|
+
Promise.all(l),
|
|
1087
|
+
Promise.all(a)
|
|
1088
|
+
]).then(function(c) {
|
|
1089
|
+
const h = c[0], d = c[1], u = c[2];
|
|
1090
|
+
return s && (o.morphAttributes.position = h), n && (o.morphAttributes.normal = d), r && (o.morphAttributes.color = u), o.morphTargetsRelative = !0, o;
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
function kn(o, e) {
|
|
1094
|
+
if (o.updateMorphTargets(), e.weights !== void 0)
|
|
1095
|
+
for (let t = 0, s = e.weights.length; t < s; t++)
|
|
1096
|
+
o.morphTargetInfluences[t] = e.weights[t];
|
|
1097
|
+
if (e.extras && Array.isArray(e.extras.targetNames)) {
|
|
1098
|
+
const t = e.extras.targetNames;
|
|
1099
|
+
if (o.morphTargetInfluences.length === t.length) {
|
|
1100
|
+
o.morphTargetDictionary = {};
|
|
1101
|
+
for (let s = 0, n = t.length; s < n; s++)
|
|
1102
|
+
o.morphTargetDictionary[t[s]] = s;
|
|
1103
|
+
} else
|
|
1104
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function Dn(o) {
|
|
1108
|
+
let e;
|
|
1109
|
+
const t = o.extensions && o.extensions[w.KHR_DRACO_MESH_COMPRESSION];
|
|
1110
|
+
if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + ie(t.attributes) : e = o.indices + ":" + ie(o.attributes) + ":" + o.mode, o.targets !== void 0)
|
|
1111
|
+
for (let s = 0, n = o.targets.length; s < n; s++)
|
|
1112
|
+
e += ":" + ie(o.targets[s]);
|
|
1113
|
+
return e;
|
|
1114
|
+
}
|
|
1115
|
+
function ie(o) {
|
|
1116
|
+
let e = "";
|
|
1117
|
+
const t = Object.keys(o).sort();
|
|
1118
|
+
for (let s = 0, n = t.length; s < n; s++)
|
|
1119
|
+
e += t[s] + ":" + o[t[s]] + ";";
|
|
1120
|
+
return e;
|
|
1121
|
+
}
|
|
1122
|
+
function pe(o) {
|
|
1123
|
+
switch (o) {
|
|
1124
|
+
case Int8Array:
|
|
1125
|
+
return 1 / 127;
|
|
1126
|
+
case Uint8Array:
|
|
1127
|
+
return 1 / 255;
|
|
1128
|
+
case Int16Array:
|
|
1129
|
+
return 1 / 32767;
|
|
1130
|
+
case Uint16Array:
|
|
1131
|
+
return 1 / 65535;
|
|
1132
|
+
default:
|
|
1133
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
function On(o) {
|
|
1137
|
+
return o.search(/\.jpe?g($|\?)/i) > 0 || o.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : o.search(/\.webp($|\?)/i) > 0 || o.search(/^data\:image\/webp/) === 0 ? "image/webp" : "image/png";
|
|
1138
|
+
}
|
|
1139
|
+
const Pn = new X();
|
|
1140
|
+
class Nn {
|
|
1141
|
+
constructor(e = {}, t = {}) {
|
|
1142
|
+
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new sn(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
|
|
1143
|
+
let s = !1, n = -1, r = !1, i = -1;
|
|
1144
|
+
if (typeof navigator < "u") {
|
|
1145
|
+
const l = navigator.userAgent;
|
|
1146
|
+
s = /^((?!chrome|android).)*safari/i.test(l) === !0;
|
|
1147
|
+
const a = l.match(/Version\/(\d+)/);
|
|
1148
|
+
n = s && a ? parseInt(a[1], 10) : -1, r = l.indexOf("Firefox") > -1, i = r ? l.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
1149
|
+
}
|
|
1150
|
+
typeof createImageBitmap > "u" || s && n < 17 || r && i < 98 ? this.textureLoader = new dt(this.options.manager) : this.textureLoader = new Ke(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new z(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
1151
|
+
}
|
|
1152
|
+
setExtensions(e) {
|
|
1153
|
+
this.extensions = e;
|
|
1154
|
+
}
|
|
1155
|
+
setPlugins(e) {
|
|
1156
|
+
this.plugins = e;
|
|
1157
|
+
}
|
|
1158
|
+
parse(e, t) {
|
|
1159
|
+
const s = this, n = this.json, r = this.extensions;
|
|
1160
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(i) {
|
|
1161
|
+
return i._markDefs && i._markDefs();
|
|
1162
|
+
}), Promise.all(this._invokeAll(function(i) {
|
|
1163
|
+
return i.beforeRoot && i.beforeRoot();
|
|
1164
|
+
})).then(function() {
|
|
1165
|
+
return Promise.all([
|
|
1166
|
+
s.getDependencies("scene"),
|
|
1167
|
+
s.getDependencies("animation"),
|
|
1168
|
+
s.getDependencies("camera")
|
|
1169
|
+
]);
|
|
1170
|
+
}).then(function(i) {
|
|
1171
|
+
const l = {
|
|
1172
|
+
scene: i[0][n.scene || 0],
|
|
1173
|
+
scenes: i[0],
|
|
1174
|
+
animations: i[1],
|
|
1175
|
+
cameras: i[2],
|
|
1176
|
+
asset: n.asset,
|
|
1177
|
+
parser: s,
|
|
1178
|
+
userData: {}
|
|
1179
|
+
};
|
|
1180
|
+
return P(r, l, n), C(l, n), Promise.all(s._invokeAll(function(a) {
|
|
1181
|
+
return a.afterRoot && a.afterRoot(l);
|
|
1182
|
+
})).then(function() {
|
|
1183
|
+
for (const a of l.scenes)
|
|
1184
|
+
a.updateMatrixWorld();
|
|
1185
|
+
e(l);
|
|
1186
|
+
});
|
|
1187
|
+
}).catch(t);
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
1191
|
+
*/
|
|
1192
|
+
_markDefs() {
|
|
1193
|
+
const e = this.json.nodes || [], t = this.json.skins || [], s = this.json.meshes || [];
|
|
1194
|
+
for (let n = 0, r = t.length; n < r; n++) {
|
|
1195
|
+
const i = t[n].joints;
|
|
1196
|
+
for (let l = 0, a = i.length; l < a; l++)
|
|
1197
|
+
e[i[l]].isBone = !0;
|
|
1198
|
+
}
|
|
1199
|
+
for (let n = 0, r = e.length; n < r; n++) {
|
|
1200
|
+
const i = e[n];
|
|
1201
|
+
i.mesh !== void 0 && (this._addNodeRef(this.meshCache, i.mesh), i.skin !== void 0 && (s[i.mesh].isSkinnedMesh = !0)), i.camera !== void 0 && this._addNodeRef(this.cameraCache, i.camera);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
1206
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
1207
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
1208
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
1209
|
+
* Textures) can be reused directly and are not marked here.
|
|
1210
|
+
*
|
|
1211
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
1212
|
+
*/
|
|
1213
|
+
_addNodeRef(e, t) {
|
|
1214
|
+
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
|
|
1215
|
+
}
|
|
1216
|
+
/** Returns a reference to a shared resource, cloning it if necessary. */
|
|
1217
|
+
_getNodeRef(e, t, s) {
|
|
1218
|
+
if (e.refs[t] <= 1) return s;
|
|
1219
|
+
const n = s.clone(), r = (i, l) => {
|
|
1220
|
+
const a = this.associations.get(i);
|
|
1221
|
+
a != null && this.associations.set(l, a);
|
|
1222
|
+
for (const [c, h] of i.children.entries())
|
|
1223
|
+
r(h, l.children[c]);
|
|
1224
|
+
};
|
|
1225
|
+
return r(s, n), n.name += "_instance_" + e.uses[t]++, n;
|
|
1226
|
+
}
|
|
1227
|
+
_invokeOne(e) {
|
|
1228
|
+
const t = Object.values(this.plugins);
|
|
1229
|
+
t.push(this);
|
|
1230
|
+
for (let s = 0; s < t.length; s++) {
|
|
1231
|
+
const n = e(t[s]);
|
|
1232
|
+
if (n) return n;
|
|
1233
|
+
}
|
|
1234
|
+
return null;
|
|
1235
|
+
}
|
|
1236
|
+
_invokeAll(e) {
|
|
1237
|
+
const t = Object.values(this.plugins);
|
|
1238
|
+
t.unshift(this);
|
|
1239
|
+
const s = [];
|
|
1240
|
+
for (let n = 0; n < t.length; n++) {
|
|
1241
|
+
const r = e(t[n]);
|
|
1242
|
+
r && s.push(r);
|
|
1243
|
+
}
|
|
1244
|
+
return s;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
1248
|
+
* @param {string} type
|
|
1249
|
+
* @param {number} index
|
|
1250
|
+
* @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
|
|
1251
|
+
*/
|
|
1252
|
+
getDependency(e, t) {
|
|
1253
|
+
const s = e + ":" + t;
|
|
1254
|
+
let n = this.cache.get(s);
|
|
1255
|
+
if (!n) {
|
|
1256
|
+
switch (e) {
|
|
1257
|
+
case "scene":
|
|
1258
|
+
n = this.loadScene(t);
|
|
1259
|
+
break;
|
|
1260
|
+
case "node":
|
|
1261
|
+
n = this._invokeOne(function(r) {
|
|
1262
|
+
return r.loadNode && r.loadNode(t);
|
|
1263
|
+
});
|
|
1264
|
+
break;
|
|
1265
|
+
case "mesh":
|
|
1266
|
+
n = this._invokeOne(function(r) {
|
|
1267
|
+
return r.loadMesh && r.loadMesh(t);
|
|
1268
|
+
});
|
|
1269
|
+
break;
|
|
1270
|
+
case "accessor":
|
|
1271
|
+
n = this.loadAccessor(t);
|
|
1272
|
+
break;
|
|
1273
|
+
case "bufferView":
|
|
1274
|
+
n = this._invokeOne(function(r) {
|
|
1275
|
+
return r.loadBufferView && r.loadBufferView(t);
|
|
1276
|
+
});
|
|
1277
|
+
break;
|
|
1278
|
+
case "buffer":
|
|
1279
|
+
n = this.loadBuffer(t);
|
|
1280
|
+
break;
|
|
1281
|
+
case "material":
|
|
1282
|
+
n = this._invokeOne(function(r) {
|
|
1283
|
+
return r.loadMaterial && r.loadMaterial(t);
|
|
1284
|
+
});
|
|
1285
|
+
break;
|
|
1286
|
+
case "texture":
|
|
1287
|
+
n = this._invokeOne(function(r) {
|
|
1288
|
+
return r.loadTexture && r.loadTexture(t);
|
|
1289
|
+
});
|
|
1290
|
+
break;
|
|
1291
|
+
case "skin":
|
|
1292
|
+
n = this.loadSkin(t);
|
|
1293
|
+
break;
|
|
1294
|
+
case "animation":
|
|
1295
|
+
n = this._invokeOne(function(r) {
|
|
1296
|
+
return r.loadAnimation && r.loadAnimation(t);
|
|
1297
|
+
});
|
|
1298
|
+
break;
|
|
1299
|
+
case "camera":
|
|
1300
|
+
n = this.loadCamera(t);
|
|
1301
|
+
break;
|
|
1302
|
+
default:
|
|
1303
|
+
if (n = this._invokeOne(function(r) {
|
|
1304
|
+
return r != this && r.getDependency && r.getDependency(e, t);
|
|
1305
|
+
}), !n)
|
|
1306
|
+
throw new Error("Unknown type: " + e);
|
|
1307
|
+
break;
|
|
1308
|
+
}
|
|
1309
|
+
this.cache.add(s, n);
|
|
1310
|
+
}
|
|
1311
|
+
return n;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1315
|
+
* @param {string} type
|
|
1316
|
+
* @return {Promise<Array<Object>>}
|
|
1317
|
+
*/
|
|
1318
|
+
getDependencies(e) {
|
|
1319
|
+
let t = this.cache.get(e);
|
|
1320
|
+
if (!t) {
|
|
1321
|
+
const s = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
|
|
1322
|
+
t = Promise.all(n.map(function(r, i) {
|
|
1323
|
+
return s.getDependency(e, i);
|
|
1324
|
+
})), this.cache.add(e, t);
|
|
1325
|
+
}
|
|
1326
|
+
return t;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1330
|
+
* @param {number} bufferIndex
|
|
1331
|
+
* @return {Promise<ArrayBuffer>}
|
|
1332
|
+
*/
|
|
1333
|
+
loadBuffer(e) {
|
|
1334
|
+
const t = this.json.buffers[e], s = this.fileLoader;
|
|
1335
|
+
if (t.type && t.type !== "arraybuffer")
|
|
1336
|
+
throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
|
|
1337
|
+
if (t.uri === void 0 && e === 0)
|
|
1338
|
+
return Promise.resolve(this.extensions[w.KHR_BINARY_GLTF].body);
|
|
1339
|
+
const n = this.options;
|
|
1340
|
+
return new Promise(function(r, i) {
|
|
1341
|
+
s.load(U.resolveURL(t.uri, n.path), r, void 0, function() {
|
|
1342
|
+
i(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
|
|
1343
|
+
});
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1348
|
+
* @param {number} bufferViewIndex
|
|
1349
|
+
* @return {Promise<ArrayBuffer>}
|
|
1350
|
+
*/
|
|
1351
|
+
loadBufferView(e) {
|
|
1352
|
+
const t = this.json.bufferViews[e];
|
|
1353
|
+
return this.getDependency("buffer", t.buffer).then(function(s) {
|
|
1354
|
+
const n = t.byteLength || 0, r = t.byteOffset || 0;
|
|
1355
|
+
return s.slice(r, r + n);
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1360
|
+
* @param {number} accessorIndex
|
|
1361
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1362
|
+
*/
|
|
1363
|
+
loadAccessor(e) {
|
|
1364
|
+
const t = this, s = this.json, n = this.json.accessors[e];
|
|
1365
|
+
if (n.bufferView === void 0 && n.sparse === void 0) {
|
|
1366
|
+
const i = ne[n.type], l = F[n.componentType], a = n.normalized === !0, c = new l(n.count * i);
|
|
1367
|
+
return Promise.resolve(new j(c, i, a));
|
|
1368
|
+
}
|
|
1369
|
+
const r = [];
|
|
1370
|
+
return n.bufferView !== void 0 ? r.push(this.getDependency("bufferView", n.bufferView)) : r.push(null), n.sparse !== void 0 && (r.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(r).then(function(i) {
|
|
1371
|
+
const l = i[0], a = ne[n.type], c = F[n.componentType], h = c.BYTES_PER_ELEMENT, d = h * a, u = n.byteOffset || 0, p = n.bufferView !== void 0 ? s.bufferViews[n.bufferView].byteStride : void 0, f = n.normalized === !0;
|
|
1372
|
+
let b, m;
|
|
1373
|
+
if (p && p !== d) {
|
|
1374
|
+
const A = Math.floor(u / p), y = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + A + ":" + n.count;
|
|
1375
|
+
let T = t.cache.get(y);
|
|
1376
|
+
T || (b = new c(l, A * p, n.count * p / h), T = new ut(b, p / h), t.cache.add(y, T)), m = new pt(T, a, u % p / h, f);
|
|
1377
|
+
} else
|
|
1378
|
+
l === null ? b = new c(n.count * a) : b = new c(l, u, n.count * a), m = new j(b, a, f);
|
|
1379
|
+
if (n.sparse !== void 0) {
|
|
1380
|
+
const A = ne.SCALAR, y = F[n.sparse.indices.componentType], T = n.sparse.indices.byteOffset || 0, _ = n.sparse.values.byteOffset || 0, v = new y(i[1], T, n.sparse.count * A), M = new c(i[2], _, n.sparse.count * a);
|
|
1381
|
+
l !== null && (m = new j(m.array.slice(), m.itemSize, m.normalized)), m.normalized = !1;
|
|
1382
|
+
for (let E = 0, H = v.length; E < H; E++) {
|
|
1383
|
+
const I = v[E];
|
|
1384
|
+
if (m.setX(I, M[E * a]), a >= 2 && m.setY(I, M[E * a + 1]), a >= 3 && m.setZ(I, M[E * a + 2]), a >= 4 && m.setW(I, M[E * a + 3]), a >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1385
|
+
}
|
|
1386
|
+
m.normalized = f;
|
|
1387
|
+
}
|
|
1388
|
+
return m;
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1393
|
+
* @param {number} textureIndex
|
|
1394
|
+
* @return {Promise<THREE.Texture|null>}
|
|
1395
|
+
*/
|
|
1396
|
+
loadTexture(e) {
|
|
1397
|
+
const t = this.json, s = this.options, r = t.textures[e].source, i = t.images[r];
|
|
1398
|
+
let l = this.textureLoader;
|
|
1399
|
+
if (i.uri) {
|
|
1400
|
+
const a = s.manager.getHandler(i.uri);
|
|
1401
|
+
a !== null && (l = a);
|
|
1402
|
+
}
|
|
1403
|
+
return this.loadTextureImage(e, r, l);
|
|
1404
|
+
}
|
|
1405
|
+
loadTextureImage(e, t, s) {
|
|
1406
|
+
const n = this, r = this.json, i = r.textures[e], l = r.images[t], a = (l.uri || l.bufferView) + ":" + i.sampler;
|
|
1407
|
+
if (this.textureCache[a])
|
|
1408
|
+
return this.textureCache[a];
|
|
1409
|
+
const c = this.loadImageSource(t, s).then(function(h) {
|
|
1410
|
+
h.flipY = !1, h.name = i.name || l.name || "", h.name === "" && typeof l.uri == "string" && l.uri.startsWith("data:image/") === !1 && (h.name = l.uri);
|
|
1411
|
+
const u = (r.samplers || {})[i.sampler] || {};
|
|
1412
|
+
return h.magFilter = De[u.magFilter] || ze, h.minFilter = De[u.minFilter] || Xe, h.wrapS = Oe[u.wrapS] || ce, h.wrapT = Oe[u.wrapT] || ce, n.associations.set(h, { textures: e }), h;
|
|
1413
|
+
}).catch(function() {
|
|
1414
|
+
return null;
|
|
1415
|
+
});
|
|
1416
|
+
return this.textureCache[a] = c, c;
|
|
1417
|
+
}
|
|
1418
|
+
loadImageSource(e, t) {
|
|
1419
|
+
const s = this, n = this.json, r = this.options;
|
|
1420
|
+
if (this.sourceCache[e] !== void 0)
|
|
1421
|
+
return this.sourceCache[e].then((d) => d.clone());
|
|
1422
|
+
const i = n.images[e], l = self.URL || self.webkitURL;
|
|
1423
|
+
let a = i.uri || "", c = !1;
|
|
1424
|
+
if (i.bufferView !== void 0)
|
|
1425
|
+
a = s.getDependency("bufferView", i.bufferView).then(function(d) {
|
|
1426
|
+
c = !0;
|
|
1427
|
+
const u = new Blob([d], { type: i.mimeType });
|
|
1428
|
+
return a = l.createObjectURL(u), a;
|
|
1429
|
+
});
|
|
1430
|
+
else if (i.uri === void 0)
|
|
1431
|
+
throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
|
|
1432
|
+
const h = Promise.resolve(a).then(function(d) {
|
|
1433
|
+
return new Promise(function(u, p) {
|
|
1434
|
+
let f = u;
|
|
1435
|
+
t.isImageBitmapLoader === !0 && (f = function(b) {
|
|
1436
|
+
const m = new Le(b);
|
|
1437
|
+
m.needsUpdate = !0, u(m);
|
|
1438
|
+
}), t.load(U.resolveURL(d, r.path), f, void 0, p);
|
|
1439
|
+
});
|
|
1440
|
+
}).then(function(d) {
|
|
1441
|
+
return c === !0 && l.revokeObjectURL(a), C(d, i), d.userData.mimeType = i.mimeType || On(i.uri), d;
|
|
1442
|
+
}).catch(function(d) {
|
|
1443
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", a), d;
|
|
1444
|
+
});
|
|
1445
|
+
return this.sourceCache[e] = h, h;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1449
|
+
* @param {Object} materialParams
|
|
1450
|
+
* @param {string} mapName
|
|
1451
|
+
* @param {Object} mapDef
|
|
1452
|
+
* @return {Promise<Texture>}
|
|
1453
|
+
*/
|
|
1454
|
+
assignTexture(e, t, s, n) {
|
|
1455
|
+
const r = this;
|
|
1456
|
+
return this.getDependency("texture", s.index).then(function(i) {
|
|
1457
|
+
if (!i) return null;
|
|
1458
|
+
if (s.texCoord !== void 0 && s.texCoord > 0 && (i = i.clone(), i.channel = s.texCoord), r.extensions[w.KHR_TEXTURE_TRANSFORM]) {
|
|
1459
|
+
const l = s.extensions !== void 0 ? s.extensions[w.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1460
|
+
if (l) {
|
|
1461
|
+
const a = r.associations.get(i);
|
|
1462
|
+
i = r.extensions[w.KHR_TEXTURE_TRANSFORM].extendTexture(i, l), r.associations.set(i, a);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
return n !== void 0 && (i.colorSpace = n), e[t] = i, i;
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1470
|
+
* already has a material (generated from the glTF material options alone)
|
|
1471
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1472
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1473
|
+
* be created if necessary, and reused from a cache.
|
|
1474
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1475
|
+
*/
|
|
1476
|
+
assignFinalMaterial(e) {
|
|
1477
|
+
const t = e.geometry;
|
|
1478
|
+
let s = e.material;
|
|
1479
|
+
const n = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, i = t.attributes.normal === void 0;
|
|
1480
|
+
if (e.isPoints) {
|
|
1481
|
+
const l = "PointsMaterial:" + s.uuid;
|
|
1482
|
+
let a = this.cache.get(l);
|
|
1483
|
+
a || (a = new ft(), q.prototype.copy.call(a, s), a.color.copy(s.color), a.map = s.map, a.sizeAttenuation = !1, this.cache.add(l, a)), s = a;
|
|
1484
|
+
} else if (e.isLine) {
|
|
1485
|
+
const l = "LineBasicMaterial:" + s.uuid;
|
|
1486
|
+
let a = this.cache.get(l);
|
|
1487
|
+
a || (a = new mt(), q.prototype.copy.call(a, s), a.color.copy(s.color), a.map = s.map, this.cache.add(l, a)), s = a;
|
|
1488
|
+
}
|
|
1489
|
+
if (n || r || i) {
|
|
1490
|
+
let l = "ClonedMaterial:" + s.uuid + ":";
|
|
1491
|
+
n && (l += "derivative-tangents:"), r && (l += "vertex-colors:"), i && (l += "flat-shading:");
|
|
1492
|
+
let a = this.cache.get(l);
|
|
1493
|
+
a || (a = s.clone(), r && (a.vertexColors = !0), i && (a.flatShading = !0), n && (a.normalScale && (a.normalScale.y *= -1), a.clearcoatNormalScale && (a.clearcoatNormalScale.y *= -1)), this.cache.add(l, a), this.associations.set(a, this.associations.get(s))), s = a;
|
|
1494
|
+
}
|
|
1495
|
+
e.material = s;
|
|
1496
|
+
}
|
|
1497
|
+
getMaterialType() {
|
|
1498
|
+
return We;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1502
|
+
* @param {number} materialIndex
|
|
1503
|
+
* @return {Promise<Material>}
|
|
1504
|
+
*/
|
|
1505
|
+
loadMaterial(e) {
|
|
1506
|
+
const t = this, s = this.json, n = this.extensions, r = s.materials[e];
|
|
1507
|
+
let i;
|
|
1508
|
+
const l = {}, a = r.extensions || {}, c = [];
|
|
1509
|
+
if (a[w.KHR_MATERIALS_UNLIT]) {
|
|
1510
|
+
const d = n[w.KHR_MATERIALS_UNLIT];
|
|
1511
|
+
i = d.getMaterialType(), c.push(d.extendParams(l, r, t));
|
|
1512
|
+
} else {
|
|
1513
|
+
const d = r.pbrMetallicRoughness || {};
|
|
1514
|
+
if (l.color = new O(1, 1, 1), l.opacity = 1, Array.isArray(d.baseColorFactor)) {
|
|
1515
|
+
const u = d.baseColorFactor;
|
|
1516
|
+
l.color.setRGB(u[0], u[1], u[2], R), l.opacity = u[3];
|
|
1517
|
+
}
|
|
1518
|
+
d.baseColorTexture !== void 0 && c.push(t.assignTexture(l, "map", d.baseColorTexture, D)), l.metalness = d.metallicFactor !== void 0 ? d.metallicFactor : 1, l.roughness = d.roughnessFactor !== void 0 ? d.roughnessFactor : 1, d.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(l, "metalnessMap", d.metallicRoughnessTexture)), c.push(t.assignTexture(l, "roughnessMap", d.metallicRoughnessTexture))), i = this._invokeOne(function(u) {
|
|
1519
|
+
return u.getMaterialType && u.getMaterialType(e);
|
|
1520
|
+
}), c.push(Promise.all(this._invokeAll(function(u) {
|
|
1521
|
+
return u.extendMaterialParams && u.extendMaterialParams(e, l);
|
|
1522
|
+
})));
|
|
1523
|
+
}
|
|
1524
|
+
r.doubleSided === !0 && (l.side = gt);
|
|
1525
|
+
const h = r.alphaMode || se.OPAQUE;
|
|
1526
|
+
if (h === se.BLEND ? (l.transparent = !0, l.depthWrite = !1) : (l.transparent = !1, h === se.MASK && (l.alphaTest = r.alphaCutoff !== void 0 ? r.alphaCutoff : 0.5)), r.normalTexture !== void 0 && i !== G && (c.push(t.assignTexture(l, "normalMap", r.normalTexture)), l.normalScale = new je(1, 1), r.normalTexture.scale !== void 0)) {
|
|
1527
|
+
const d = r.normalTexture.scale;
|
|
1528
|
+
l.normalScale.set(d, d);
|
|
1529
|
+
}
|
|
1530
|
+
if (r.occlusionTexture !== void 0 && i !== G && (c.push(t.assignTexture(l, "aoMap", r.occlusionTexture)), r.occlusionTexture.strength !== void 0 && (l.aoMapIntensity = r.occlusionTexture.strength)), r.emissiveFactor !== void 0 && i !== G) {
|
|
1531
|
+
const d = r.emissiveFactor;
|
|
1532
|
+
l.emissive = new O().setRGB(d[0], d[1], d[2], R);
|
|
1533
|
+
}
|
|
1534
|
+
return r.emissiveTexture !== void 0 && i !== G && c.push(t.assignTexture(l, "emissiveMap", r.emissiveTexture, D)), Promise.all(c).then(function() {
|
|
1535
|
+
const d = new i(l);
|
|
1536
|
+
return r.name && (d.name = r.name), C(d, r), t.associations.set(d, { materials: e }), r.extensions && P(n, d, r), d;
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
/** When Object3D instances are targeted by animation, they need unique names. */
|
|
1540
|
+
createUniqueName(e) {
|
|
1541
|
+
const t = At.sanitizeNodeName(e || "");
|
|
1542
|
+
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
1546
|
+
*
|
|
1547
|
+
* Creates BufferGeometries from primitives.
|
|
1548
|
+
*
|
|
1549
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
1550
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
1551
|
+
*/
|
|
1552
|
+
loadGeometries(e) {
|
|
1553
|
+
const t = this, s = this.extensions, n = this.primitiveCache;
|
|
1554
|
+
function r(l) {
|
|
1555
|
+
return s[w.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l, t).then(function(a) {
|
|
1556
|
+
return Pe(a, l, t);
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
const i = [];
|
|
1560
|
+
for (let l = 0, a = e.length; l < a; l++) {
|
|
1561
|
+
const c = e[l], h = Dn(c), d = n[h];
|
|
1562
|
+
if (d)
|
|
1563
|
+
i.push(d.promise);
|
|
1564
|
+
else {
|
|
1565
|
+
let u;
|
|
1566
|
+
c.extensions && c.extensions[w.KHR_DRACO_MESH_COMPRESSION] ? u = r(c) : u = Pe(new Be(), c, t), n[h] = { primitive: c, promise: u }, i.push(u);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
return Promise.all(i);
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
1573
|
+
* @param {number} meshIndex
|
|
1574
|
+
* @return {Promise<Group|Mesh|SkinnedMesh>}
|
|
1575
|
+
*/
|
|
1576
|
+
loadMesh(e) {
|
|
1577
|
+
const t = this, s = this.json, n = this.extensions, r = s.meshes[e], i = r.primitives, l = [];
|
|
1578
|
+
for (let a = 0, c = i.length; a < c; a++) {
|
|
1579
|
+
const h = i[a].material === void 0 ? Mn(this.cache) : this.getDependency("material", i[a].material);
|
|
1580
|
+
l.push(h);
|
|
1581
|
+
}
|
|
1582
|
+
return l.push(t.loadGeometries(i)), Promise.all(l).then(function(a) {
|
|
1583
|
+
const c = a.slice(0, a.length - 1), h = a[a.length - 1], d = [];
|
|
1584
|
+
for (let p = 0, f = h.length; p < f; p++) {
|
|
1585
|
+
const b = h[p], m = i[p];
|
|
1586
|
+
let A;
|
|
1587
|
+
const y = c[p];
|
|
1588
|
+
if (m.mode === x.TRIANGLES || m.mode === x.TRIANGLE_STRIP || m.mode === x.TRIANGLE_FAN || m.mode === void 0)
|
|
1589
|
+
A = r.isSkinnedMesh === !0 ? new bt(b, y) : new wt(b, y), A.isSkinnedMesh === !0 && A.normalizeSkinWeights(), m.mode === x.TRIANGLE_STRIP ? A.geometry = Ie(A.geometry, Ge) : m.mode === x.TRIANGLE_FAN && (A.geometry = Ie(A.geometry, le));
|
|
1590
|
+
else if (m.mode === x.LINES)
|
|
1591
|
+
A = new yt(b, y);
|
|
1592
|
+
else if (m.mode === x.LINE_STRIP)
|
|
1593
|
+
A = new _t(b, y);
|
|
1594
|
+
else if (m.mode === x.LINE_LOOP)
|
|
1595
|
+
A = new Tt(b, y);
|
|
1596
|
+
else if (m.mode === x.POINTS)
|
|
1597
|
+
A = new xt(b, y);
|
|
1598
|
+
else
|
|
1599
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + m.mode);
|
|
1600
|
+
Object.keys(A.geometry.morphAttributes).length > 0 && kn(A, r), A.name = t.createUniqueName(r.name || "mesh_" + e), C(A, r), m.extensions && P(n, A, m), t.assignFinalMaterial(A), d.push(A);
|
|
1601
|
+
}
|
|
1602
|
+
for (let p = 0, f = d.length; p < f; p++)
|
|
1603
|
+
t.associations.set(d[p], {
|
|
1604
|
+
meshes: e,
|
|
1605
|
+
primitives: p
|
|
1606
|
+
});
|
|
1607
|
+
if (d.length === 1)
|
|
1608
|
+
return r.extensions && P(n, d[0], r), d[0];
|
|
1609
|
+
const u = new J();
|
|
1610
|
+
r.extensions && P(n, u, r), t.associations.set(u, { meshes: e });
|
|
1611
|
+
for (let p = 0, f = d.length; p < f; p++)
|
|
1612
|
+
u.add(d[p]);
|
|
1613
|
+
return u;
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
1618
|
+
* @param {number} cameraIndex
|
|
1619
|
+
* @return {Promise<THREE.Camera>}
|
|
1620
|
+
*/
|
|
1621
|
+
loadCamera(e) {
|
|
1622
|
+
let t;
|
|
1623
|
+
const s = this.json.cameras[e], n = s[s.type];
|
|
1624
|
+
if (!n) {
|
|
1625
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
return s.type === "perspective" ? t = new Et(vt.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : s.type === "orthographic" && (t = new Lt(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), s.name && (t.name = this.createUniqueName(s.name)), C(t, s), Promise.resolve(t);
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
1632
|
+
* @param {number} skinIndex
|
|
1633
|
+
* @return {Promise<Skeleton>}
|
|
1634
|
+
*/
|
|
1635
|
+
loadSkin(e) {
|
|
1636
|
+
const t = this.json.skins[e], s = [];
|
|
1637
|
+
for (let n = 0, r = t.joints.length; n < r; n++)
|
|
1638
|
+
s.push(this._loadNodeShallow(t.joints[n]));
|
|
1639
|
+
return t.inverseBindMatrices !== void 0 ? s.push(this.getDependency("accessor", t.inverseBindMatrices)) : s.push(null), Promise.all(s).then(function(n) {
|
|
1640
|
+
const r = n.pop(), i = n, l = [], a = [];
|
|
1641
|
+
for (let c = 0, h = i.length; c < h; c++) {
|
|
1642
|
+
const d = i[c];
|
|
1643
|
+
if (d) {
|
|
1644
|
+
l.push(d);
|
|
1645
|
+
const u = new X();
|
|
1646
|
+
r !== null && u.fromArray(r.array, c * 16), a.push(u);
|
|
1647
|
+
} else
|
|
1648
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]);
|
|
1649
|
+
}
|
|
1650
|
+
return new Rt(l, a);
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
1655
|
+
* @param {number} animationIndex
|
|
1656
|
+
* @return {Promise<AnimationClip>}
|
|
1657
|
+
*/
|
|
1658
|
+
loadAnimation(e) {
|
|
1659
|
+
const t = this.json, s = this, n = t.animations[e], r = n.name ? n.name : "animation_" + e, i = [], l = [], a = [], c = [], h = [];
|
|
1660
|
+
for (let d = 0, u = n.channels.length; d < u; d++) {
|
|
1661
|
+
const p = n.channels[d], f = n.samplers[p.sampler], b = p.target, m = b.node, A = n.parameters !== void 0 ? n.parameters[f.input] : f.input, y = n.parameters !== void 0 ? n.parameters[f.output] : f.output;
|
|
1662
|
+
b.node !== void 0 && (i.push(this.getDependency("node", m)), l.push(this.getDependency("accessor", A)), a.push(this.getDependency("accessor", y)), c.push(f), h.push(b));
|
|
1663
|
+
}
|
|
1664
|
+
return Promise.all([
|
|
1665
|
+
Promise.all(i),
|
|
1666
|
+
Promise.all(l),
|
|
1667
|
+
Promise.all(a),
|
|
1668
|
+
Promise.all(c),
|
|
1669
|
+
Promise.all(h)
|
|
1670
|
+
]).then(function(d) {
|
|
1671
|
+
const u = d[0], p = d[1], f = d[2], b = d[3], m = d[4], A = [];
|
|
1672
|
+
for (let y = 0, T = u.length; y < T; y++) {
|
|
1673
|
+
const _ = u[y], v = p[y], M = f[y], E = b[y], H = m[y];
|
|
1674
|
+
if (_ === void 0) continue;
|
|
1675
|
+
_.updateMatrix && _.updateMatrix();
|
|
1676
|
+
const I = s._createAnimationTracks(_, v, M, E, H);
|
|
1677
|
+
if (I)
|
|
1678
|
+
for (let Y = 0; Y < I.length; Y++)
|
|
1679
|
+
A.push(I[Y]);
|
|
1680
|
+
}
|
|
1681
|
+
return new St(r, void 0, A);
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
createNodeMesh(e) {
|
|
1685
|
+
const t = this.json, s = this, n = t.nodes[e];
|
|
1686
|
+
return n.mesh === void 0 ? null : s.getDependency("mesh", n.mesh).then(function(r) {
|
|
1687
|
+
const i = s._getNodeRef(s.meshCache, n.mesh, r);
|
|
1688
|
+
return n.weights !== void 0 && i.traverse(function(l) {
|
|
1689
|
+
if (l.isMesh)
|
|
1690
|
+
for (let a = 0, c = n.weights.length; a < c; a++)
|
|
1691
|
+
l.morphTargetInfluences[a] = n.weights[a];
|
|
1692
|
+
}), i;
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
1697
|
+
* @param {number} nodeIndex
|
|
1698
|
+
* @return {Promise<Object3D>}
|
|
1699
|
+
*/
|
|
1700
|
+
loadNode(e) {
|
|
1701
|
+
const t = this.json, s = this, n = t.nodes[e], r = s._loadNodeShallow(e), i = [], l = n.children || [];
|
|
1702
|
+
for (let c = 0, h = l.length; c < h; c++)
|
|
1703
|
+
i.push(s.getDependency("node", l[c]));
|
|
1704
|
+
const a = n.skin === void 0 ? Promise.resolve(null) : s.getDependency("skin", n.skin);
|
|
1705
|
+
return Promise.all([
|
|
1706
|
+
r,
|
|
1707
|
+
Promise.all(i),
|
|
1708
|
+
a
|
|
1709
|
+
]).then(function(c) {
|
|
1710
|
+
const h = c[0], d = c[1], u = c[2];
|
|
1711
|
+
u !== null && h.traverse(function(p) {
|
|
1712
|
+
p.isSkinnedMesh && p.bind(u, Pn);
|
|
1713
|
+
});
|
|
1714
|
+
for (let p = 0, f = d.length; p < f; p++)
|
|
1715
|
+
h.add(d[p]);
|
|
1716
|
+
return h;
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
// ._loadNodeShallow() parses a single node.
|
|
1720
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
1721
|
+
_loadNodeShallow(e) {
|
|
1722
|
+
const t = this.json, s = this.extensions, n = this;
|
|
1723
|
+
if (this.nodeCache[e] !== void 0)
|
|
1724
|
+
return this.nodeCache[e];
|
|
1725
|
+
const r = t.nodes[e], i = r.name ? n.createUniqueName(r.name) : "", l = [], a = n._invokeOne(function(c) {
|
|
1726
|
+
return c.createNodeMesh && c.createNodeMesh(e);
|
|
1727
|
+
});
|
|
1728
|
+
return a && l.push(a), r.camera !== void 0 && l.push(n.getDependency("camera", r.camera).then(function(c) {
|
|
1729
|
+
return n._getNodeRef(n.cameraCache, r.camera, c);
|
|
1730
|
+
})), n._invokeAll(function(c) {
|
|
1731
|
+
return c.createNodeAttachment && c.createNodeAttachment(e);
|
|
1732
|
+
}).forEach(function(c) {
|
|
1733
|
+
l.push(c);
|
|
1734
|
+
}), this.nodeCache[e] = Promise.all(l).then(function(c) {
|
|
1735
|
+
let h;
|
|
1736
|
+
if (r.isBone === !0 ? h = new Ct() : c.length > 1 ? h = new J() : c.length === 1 ? h = c[0] : h = new Ve(), h !== c[0])
|
|
1737
|
+
for (let d = 0, u = c.length; d < u; d++)
|
|
1738
|
+
h.add(c[d]);
|
|
1739
|
+
if (r.name && (h.userData.name = r.name, h.name = i), C(h, r), r.extensions && P(s, h, r), r.matrix !== void 0) {
|
|
1740
|
+
const d = new X();
|
|
1741
|
+
d.fromArray(r.matrix), h.applyMatrix4(d);
|
|
1742
|
+
} else
|
|
1743
|
+
r.translation !== void 0 && h.position.fromArray(r.translation), r.rotation !== void 0 && h.quaternion.fromArray(r.rotation), r.scale !== void 0 && h.scale.fromArray(r.scale);
|
|
1744
|
+
return n.associations.has(h) || n.associations.set(h, {}), n.associations.get(h).nodes = e, h;
|
|
1745
|
+
}), this.nodeCache[e];
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
1749
|
+
* @param {number} sceneIndex
|
|
1750
|
+
* @return {Promise<Group>}
|
|
1751
|
+
*/
|
|
1752
|
+
loadScene(e) {
|
|
1753
|
+
const t = this.extensions, s = this.json.scenes[e], n = this, r = new J();
|
|
1754
|
+
s.name && (r.name = n.createUniqueName(s.name)), C(r, s), s.extensions && P(t, r, s);
|
|
1755
|
+
const i = s.nodes || [], l = [];
|
|
1756
|
+
for (let a = 0, c = i.length; a < c; a++)
|
|
1757
|
+
l.push(n.getDependency("node", i[a]));
|
|
1758
|
+
return Promise.all(l).then(function(a) {
|
|
1759
|
+
for (let h = 0, d = a.length; h < d; h++)
|
|
1760
|
+
r.add(a[h]);
|
|
1761
|
+
const c = (h) => {
|
|
1762
|
+
const d = /* @__PURE__ */ new Map();
|
|
1763
|
+
for (const [u, p] of n.associations)
|
|
1764
|
+
(u instanceof q || u instanceof Le) && d.set(u, p);
|
|
1765
|
+
return h.traverse((u) => {
|
|
1766
|
+
const p = n.associations.get(u);
|
|
1767
|
+
p != null && d.set(u, p);
|
|
1768
|
+
}), d;
|
|
1769
|
+
};
|
|
1770
|
+
return n.associations = c(r), r;
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
_createAnimationTracks(e, t, s, n, r) {
|
|
1774
|
+
const i = [], l = e.name ? e.name : e.uuid, a = [];
|
|
1775
|
+
k[r.path] === k.weights ? e.traverse(function(u) {
|
|
1776
|
+
u.morphTargetInfluences && a.push(u.name ? u.name : u.uuid);
|
|
1777
|
+
}) : a.push(l);
|
|
1778
|
+
let c;
|
|
1779
|
+
switch (k[r.path]) {
|
|
1780
|
+
case k.weights:
|
|
1781
|
+
c = Se;
|
|
1782
|
+
break;
|
|
1783
|
+
case k.rotation:
|
|
1784
|
+
c = Ce;
|
|
1785
|
+
break;
|
|
1786
|
+
case k.position:
|
|
1787
|
+
case k.scale:
|
|
1788
|
+
c = Re;
|
|
1789
|
+
break;
|
|
1790
|
+
default:
|
|
1791
|
+
switch (s.itemSize) {
|
|
1792
|
+
case 1:
|
|
1793
|
+
c = Se;
|
|
1794
|
+
break;
|
|
1795
|
+
case 2:
|
|
1796
|
+
case 3:
|
|
1797
|
+
default:
|
|
1798
|
+
c = Re;
|
|
1799
|
+
break;
|
|
1800
|
+
}
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
const h = n.interpolation !== void 0 ? Cn[n.interpolation] : Ye, d = this._getArrayFromAccessor(s);
|
|
1804
|
+
for (let u = 0, p = a.length; u < p; u++) {
|
|
1805
|
+
const f = new c(
|
|
1806
|
+
a[u] + "." + k[r.path],
|
|
1807
|
+
t.array,
|
|
1808
|
+
d,
|
|
1809
|
+
h
|
|
1810
|
+
);
|
|
1811
|
+
n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(f), i.push(f);
|
|
1812
|
+
}
|
|
1813
|
+
return i;
|
|
1814
|
+
}
|
|
1815
|
+
_getArrayFromAccessor(e) {
|
|
1816
|
+
let t = e.array;
|
|
1817
|
+
if (e.normalized) {
|
|
1818
|
+
const s = pe(t.constructor), n = new Float32Array(t.length);
|
|
1819
|
+
for (let r = 0, i = t.length; r < i; r++)
|
|
1820
|
+
n[r] = t[r] * s;
|
|
1821
|
+
t = n;
|
|
1822
|
+
}
|
|
1823
|
+
return t;
|
|
1824
|
+
}
|
|
1825
|
+
_createCubicSplineTrackInterpolant(e) {
|
|
1826
|
+
e.createInterpolant = function(s) {
|
|
1827
|
+
const n = this instanceof Ce ? Sn : Qe;
|
|
1828
|
+
return new n(this.times, this.values, this.getValueSize() / 3, s);
|
|
1829
|
+
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
function $n(o, e, t) {
|
|
1833
|
+
const s = e.attributes, n = new Ft();
|
|
1834
|
+
if (s.POSITION !== void 0) {
|
|
1835
|
+
const l = t.json.accessors[s.POSITION], a = l.min, c = l.max;
|
|
1836
|
+
if (a !== void 0 && c !== void 0) {
|
|
1837
|
+
if (n.set(
|
|
1838
|
+
new N(a[0], a[1], a[2]),
|
|
1839
|
+
new N(c[0], c[1], c[2])
|
|
1840
|
+
), l.normalized) {
|
|
1841
|
+
const h = pe(F[l.componentType]);
|
|
1842
|
+
n.min.multiplyScalar(h), n.max.multiplyScalar(h);
|
|
1843
|
+
}
|
|
1844
|
+
} else {
|
|
1845
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
} else
|
|
1849
|
+
return;
|
|
1850
|
+
const r = e.targets;
|
|
1851
|
+
if (r !== void 0) {
|
|
1852
|
+
const l = new N(), a = new N();
|
|
1853
|
+
for (let c = 0, h = r.length; c < h; c++) {
|
|
1854
|
+
const d = r[c];
|
|
1855
|
+
if (d.POSITION !== void 0) {
|
|
1856
|
+
const u = t.json.accessors[d.POSITION], p = u.min, f = u.max;
|
|
1857
|
+
if (p !== void 0 && f !== void 0) {
|
|
1858
|
+
if (a.setX(Math.max(Math.abs(p[0]), Math.abs(f[0]))), a.setY(Math.max(Math.abs(p[1]), Math.abs(f[1]))), a.setZ(Math.max(Math.abs(p[2]), Math.abs(f[2]))), u.normalized) {
|
|
1859
|
+
const b = pe(F[u.componentType]);
|
|
1860
|
+
a.multiplyScalar(b);
|
|
1861
|
+
}
|
|
1862
|
+
l.max(a);
|
|
1863
|
+
} else
|
|
1864
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
n.expandByVector(l);
|
|
1868
|
+
}
|
|
1869
|
+
o.boundingBox = n;
|
|
1870
|
+
const i = new Ht();
|
|
1871
|
+
n.getCenter(i.center), i.radius = n.min.distanceTo(n.max) / 2, o.boundingSphere = i;
|
|
1872
|
+
}
|
|
1873
|
+
function Pe(o, e, t) {
|
|
1874
|
+
const s = e.attributes, n = [];
|
|
1875
|
+
function r(i, l) {
|
|
1876
|
+
return t.getDependency("accessor", i).then(function(a) {
|
|
1877
|
+
o.setAttribute(l, a);
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
for (const i in s) {
|
|
1881
|
+
const l = ue[i] || i.toLowerCase();
|
|
1882
|
+
l in o.attributes || n.push(r(s[i], l));
|
|
1883
|
+
}
|
|
1884
|
+
if (e.indices !== void 0 && !o.index) {
|
|
1885
|
+
const i = t.getDependency("accessor", e.indices).then(function(l) {
|
|
1886
|
+
o.setIndex(l);
|
|
1887
|
+
});
|
|
1888
|
+
n.push(i);
|
|
1889
|
+
}
|
|
1890
|
+
return ae.workingColorSpace !== R && "COLOR_0" in s && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ae.workingColorSpace}" not supported.`), C(o, e), $n(o, e, t), Promise.all(n).then(function() {
|
|
1891
|
+
return e.targets !== void 0 ? In(o, e.targets, t) : o;
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
var Fn = Object.defineProperty, Hn = Object.getOwnPropertyDescriptor, Bn = (o, e, t, s) => {
|
|
1895
|
+
for (var n = s > 1 ? void 0 : s ? Hn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
1896
|
+
(i = o[r]) && (n = (s ? i(e, t, n) : i(n)) || n);
|
|
1897
|
+
return s && n && Fn(e, t, n), n;
|
|
1898
|
+
};
|
|
1899
|
+
let fe = class {
|
|
1900
|
+
constructor() {
|
|
1901
|
+
g(this, "loadingManager", new Gt());
|
|
1902
|
+
g(this, "loaders", {});
|
|
1903
|
+
g(this, "resources", []);
|
|
1904
|
+
g(this, "items", {});
|
|
1905
|
+
g(this, "toLoad", 0);
|
|
1906
|
+
g(this, "loaded", 0);
|
|
1907
|
+
}
|
|
1908
|
+
get videoLoader() {
|
|
1909
|
+
return {
|
|
1910
|
+
load: (o, e) => {
|
|
1911
|
+
let t = document.createElement("video");
|
|
1912
|
+
t.muted = !0, t.loop = !0, t.controls = !1, t.playsInline = !0, t.src = o, t.autoplay = !0;
|
|
1913
|
+
const s = () => {
|
|
1914
|
+
if (!t) return;
|
|
1915
|
+
t.play();
|
|
1916
|
+
const n = new Vt(t), r = n.dispose.bind(n);
|
|
1917
|
+
n.dispose = () => {
|
|
1918
|
+
n.userData.element = void 0, t == null || t.remove(), t = void 0, r();
|
|
1919
|
+
}, e(n), n.userData.element = t, t.removeEventListener("canplaythrough", s);
|
|
1920
|
+
};
|
|
1921
|
+
t.addEventListener("canplaythrough", s);
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
_setLoaders() {
|
|
1926
|
+
this.loaders.gltfLoader = new nn(this.loadingManager), this.loaders.textureLoader = new Ke(this.loadingManager), this.loaders.cubeTextureLoader = new jt(this.loadingManager), this.loaders.audioLoader = new Ut(this.loadingManager), this.loaders.videoLoader = this.videoLoader;
|
|
1927
|
+
}
|
|
1928
|
+
setResources(o) {
|
|
1929
|
+
this.resources = o, this.toLoad = this.resources.length, this.loaded = 0;
|
|
1930
|
+
}
|
|
1931
|
+
init(o = []) {
|
|
1932
|
+
this.resources = o, this._setLoaders();
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
fe = Bn([
|
|
1936
|
+
_e(we.ResolutionScoped)
|
|
1937
|
+
], fe);
|
|
1938
|
+
var Gn = Object.defineProperty, jn = Object.getOwnPropertyDescriptor, Un = (o, e, t, s) => {
|
|
1939
|
+
for (var n = s > 1 ? void 0 : s ? jn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
1940
|
+
(i = o[r]) && (n = (s ? i(e, t, n) : i(n)) || n);
|
|
1941
|
+
return s && n && Gn(e, t, n), n;
|
|
1942
|
+
}, Ne = (o, e) => (t, s) => e(t, s, o);
|
|
1943
|
+
let me = class {
|
|
1944
|
+
constructor(o, e) {
|
|
1945
|
+
this.controller = o, this.component = e, typeof self < "u" && (self.onmessage = (t) => {
|
|
1946
|
+
var n;
|
|
1947
|
+
const s = (n = t == null ? void 0 : t.data) == null ? void 0 : n.resources;
|
|
1948
|
+
s && this.init(s);
|
|
1949
|
+
});
|
|
1950
|
+
}
|
|
1951
|
+
_handleLoadedResource(o, e) {
|
|
1952
|
+
this.component.items[o.name] = e, this.component.loaded++, this.controller.progress$$.next({
|
|
1953
|
+
file: e,
|
|
1954
|
+
resource: o,
|
|
1955
|
+
loaded: this.component.loaded,
|
|
1956
|
+
toLoad: this.component.toLoad
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
setDracoLoader(o, e = !0) {
|
|
1960
|
+
this.component.loaders.dracoLoader = new Jt(
|
|
1961
|
+
this.component.loadingManager
|
|
1962
|
+
), this.component.loaders.dracoLoader.setDecoderPath(o), e && this.component.loaders.gltfLoader && this.component.loaders.gltfLoader.setDRACOLoader(
|
|
1963
|
+
this.component.loaders.dracoLoader
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
load() {
|
|
1967
|
+
var e, t, s, n, r;
|
|
1968
|
+
const o = this.component.resources[0];
|
|
1969
|
+
if (o) {
|
|
1970
|
+
this.controller.progress$$.next({
|
|
1971
|
+
resource: o,
|
|
1972
|
+
loaded: this.component.loaded,
|
|
1973
|
+
toLoad: this.component.toLoad
|
|
1974
|
+
});
|
|
1975
|
+
for (const i of this.component.resources)
|
|
1976
|
+
this.component.items[i.name] || (i.type === "gltfModel" && typeof i.path == "string" && ((e = this.component.loaders.gltfLoader) == null || e.load(
|
|
1977
|
+
i.path,
|
|
1978
|
+
(l) => this._handleLoadedResource(i, l)
|
|
1979
|
+
)), i.type === "texture" && typeof i.path == "string" && ((t = this.component.loaders.textureLoader) == null || t.load(i.path, (l) => {
|
|
1980
|
+
this._handleLoadedResource(i, new Kt(l));
|
|
1981
|
+
})), i.type === "cubeTexture" && typeof i.path == "object" && ((s = this.component.loaders.cubeTextureLoader) == null || s.load(
|
|
1982
|
+
i.path,
|
|
1983
|
+
(l) => this._handleLoadedResource(i, l)
|
|
1984
|
+
)), i.type === "video" && typeof i.path == "string" && ((n = this.component.loaders.videoLoader) == null || n.load(
|
|
1985
|
+
i.path,
|
|
1986
|
+
(l) => this._handleLoadedResource(i, l)
|
|
1987
|
+
)), i.type === "audio" && typeof i.path == "string" && ((r = this.component.loaders.audioLoader) == null || r.load(
|
|
1988
|
+
i.path,
|
|
1989
|
+
(l) => {
|
|
1990
|
+
this._handleLoadedResource(i, l);
|
|
1991
|
+
}
|
|
1992
|
+
)));
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
items() {
|
|
1996
|
+
return this.component.items;
|
|
1997
|
+
}
|
|
1998
|
+
loaders() {
|
|
1999
|
+
return this.component.loaders;
|
|
2000
|
+
}
|
|
2001
|
+
resources() {
|
|
2002
|
+
return this.component.resources;
|
|
2003
|
+
}
|
|
2004
|
+
loaded() {
|
|
2005
|
+
return this.component.loaded;
|
|
2006
|
+
}
|
|
2007
|
+
toLoad() {
|
|
2008
|
+
return this.component.toLoad;
|
|
2009
|
+
}
|
|
2010
|
+
init(o = []) {
|
|
2011
|
+
this.component.init(o);
|
|
2012
|
+
}
|
|
2013
|
+
dispose() {
|
|
2014
|
+
this.controller.lifecycle$$.complete(), this.controller.progress$$.complete();
|
|
2015
|
+
}
|
|
2016
|
+
lifecycle$() {
|
|
2017
|
+
return this.controller.lifecycle$;
|
|
2018
|
+
}
|
|
2019
|
+
progress$() {
|
|
2020
|
+
return this.controller.progress$;
|
|
2021
|
+
}
|
|
2022
|
+
progressCompleted$() {
|
|
2023
|
+
return this.controller.progressCompleted$;
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
me = Un([
|
|
2027
|
+
_e(we.ResolutionScoped),
|
|
2028
|
+
Ne(0, $(de)),
|
|
2029
|
+
Ne(1, $(fe))
|
|
2030
|
+
], me);
|
|
2031
|
+
const gs = K.resolve(me);
|
|
2032
|
+
/**
|
|
2033
|
+
* lil-gui
|
|
2034
|
+
* https://lil-gui.georgealways.com
|
|
2035
|
+
* @version 0.17.0
|
|
2036
|
+
* @author George Michael Brower
|
|
2037
|
+
* @license MIT
|
|
2038
|
+
*/
|
|
2039
|
+
class L {
|
|
2040
|
+
constructor(e, t, s, n, r = "div") {
|
|
2041
|
+
this.parent = e, this.object = t, this.property = s, this._disabled = !1, this._hidden = !1, this.initialValue = this.getValue(), this.domElement = document.createElement("div"), this.domElement.classList.add("controller"), this.domElement.classList.add(n), this.$name = document.createElement("div"), this.$name.classList.add("name"), L.nextNameID = L.nextNameID || 0, this.$name.id = "lil-gui-name-" + ++L.nextNameID, this.$widget = document.createElement(r), this.$widget.classList.add("widget"), this.$disable = this.$widget, this.domElement.appendChild(this.$name), this.domElement.appendChild(this.$widget), this.parent.children.push(this), this.parent.controllers.push(this), this.parent.$children.appendChild(this.domElement), this._listenCallback = this._listenCallback.bind(this), this.name(s);
|
|
2042
|
+
}
|
|
2043
|
+
name(e) {
|
|
2044
|
+
return this._name = e, this.$name.innerHTML = e, this;
|
|
2045
|
+
}
|
|
2046
|
+
onChange(e) {
|
|
2047
|
+
return this._onChange = e, this;
|
|
2048
|
+
}
|
|
2049
|
+
_callOnChange() {
|
|
2050
|
+
this.parent._callOnChange(this), this._onChange !== void 0 && this._onChange.call(this, this.getValue()), this._changed = !0;
|
|
2051
|
+
}
|
|
2052
|
+
onFinishChange(e) {
|
|
2053
|
+
return this._onFinishChange = e, this;
|
|
2054
|
+
}
|
|
2055
|
+
_callOnFinishChange() {
|
|
2056
|
+
this._changed && (this.parent._callOnFinishChange(this), this._onFinishChange !== void 0 && this._onFinishChange.call(this, this.getValue())), this._changed = !1;
|
|
2057
|
+
}
|
|
2058
|
+
reset() {
|
|
2059
|
+
return this.setValue(this.initialValue), this._callOnFinishChange(), this;
|
|
2060
|
+
}
|
|
2061
|
+
enable(e = !0) {
|
|
2062
|
+
return this.disable(!e);
|
|
2063
|
+
}
|
|
2064
|
+
disable(e = !0) {
|
|
2065
|
+
return e === this._disabled || (this._disabled = e, this.domElement.classList.toggle("disabled", e), this.$disable.toggleAttribute("disabled", e)), this;
|
|
2066
|
+
}
|
|
2067
|
+
show(e = !0) {
|
|
2068
|
+
return this._hidden = !e, this.domElement.style.display = this._hidden ? "none" : "", this;
|
|
2069
|
+
}
|
|
2070
|
+
hide() {
|
|
2071
|
+
return this.show(!1);
|
|
2072
|
+
}
|
|
2073
|
+
options(e) {
|
|
2074
|
+
const t = this.parent.add(this.object, this.property, e);
|
|
2075
|
+
return t.name(this._name), this.destroy(), t;
|
|
2076
|
+
}
|
|
2077
|
+
min(e) {
|
|
2078
|
+
return this;
|
|
2079
|
+
}
|
|
2080
|
+
max(e) {
|
|
2081
|
+
return this;
|
|
2082
|
+
}
|
|
2083
|
+
step(e) {
|
|
2084
|
+
return this;
|
|
2085
|
+
}
|
|
2086
|
+
decimals(e) {
|
|
2087
|
+
return this;
|
|
2088
|
+
}
|
|
2089
|
+
listen(e = !0) {
|
|
2090
|
+
return this._listening = e, this._listenCallbackID !== void 0 && (cancelAnimationFrame(this._listenCallbackID), this._listenCallbackID = void 0), this._listening && this._listenCallback(), this;
|
|
2091
|
+
}
|
|
2092
|
+
_listenCallback() {
|
|
2093
|
+
this._listenCallbackID = requestAnimationFrame(this._listenCallback);
|
|
2094
|
+
const e = this.save();
|
|
2095
|
+
e !== this._listenPrevValue && this.updateDisplay(), this._listenPrevValue = e;
|
|
2096
|
+
}
|
|
2097
|
+
getValue() {
|
|
2098
|
+
return this.object[this.property];
|
|
2099
|
+
}
|
|
2100
|
+
setValue(e) {
|
|
2101
|
+
return this.object[this.property] = e, this._callOnChange(), this.updateDisplay(), this;
|
|
2102
|
+
}
|
|
2103
|
+
updateDisplay() {
|
|
2104
|
+
return this;
|
|
2105
|
+
}
|
|
2106
|
+
load(e) {
|
|
2107
|
+
return this.setValue(e), this._callOnFinishChange(), this;
|
|
2108
|
+
}
|
|
2109
|
+
save() {
|
|
2110
|
+
return this.getValue();
|
|
2111
|
+
}
|
|
2112
|
+
destroy() {
|
|
2113
|
+
this.listen(!1), this.parent.children.splice(this.parent.children.indexOf(this), 1), this.parent.controllers.splice(this.parent.controllers.indexOf(this), 1), this.parent.$children.removeChild(this.domElement);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
class Vn extends L {
|
|
2117
|
+
constructor(e, t, s) {
|
|
2118
|
+
super(e, t, s, "boolean", "label"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "checkbox"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$widget.appendChild(this.$input), this.$input.addEventListener("change", () => {
|
|
2119
|
+
this.setValue(this.$input.checked), this._callOnFinishChange();
|
|
2120
|
+
}), this.$disable = this.$input, this.updateDisplay();
|
|
2121
|
+
}
|
|
2122
|
+
updateDisplay() {
|
|
2123
|
+
return this.$input.checked = this.getValue(), this;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
function ge(o) {
|
|
2127
|
+
let e, t;
|
|
2128
|
+
return (e = o.match(/(#|0x)?([a-f0-9]{6})/i)) ? t = e[2] : (e = o.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/)) ? t = parseInt(e[1]).toString(16).padStart(2, 0) + parseInt(e[2]).toString(16).padStart(2, 0) + parseInt(e[3]).toString(16).padStart(2, 0) : (e = o.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i)) && (t = e[1] + e[1] + e[2] + e[2] + e[3] + e[3]), !!t && "#" + t;
|
|
2129
|
+
}
|
|
2130
|
+
const Kn = { isPrimitive: !0, match: (o) => typeof o == "string", fromHexString: ge, toHexString: ge }, V = { isPrimitive: !0, match: (o) => typeof o == "number", fromHexString: (o) => parseInt(o.substring(1), 16), toHexString: (o) => "#" + o.toString(16).padStart(6, 0) }, zn = { isPrimitive: !1, match: Array.isArray, fromHexString(o, e, t = 1) {
|
|
2131
|
+
const s = V.fromHexString(o);
|
|
2132
|
+
e[0] = (s >> 16 & 255) / 255 * t, e[1] = (s >> 8 & 255) / 255 * t, e[2] = (255 & s) / 255 * t;
|
|
2133
|
+
}, toHexString: ([o, e, t], s = 1) => V.toHexString(o * (s = 255 / s) << 16 ^ e * s << 8 ^ t * s << 0) }, Xn = { isPrimitive: !1, match: (o) => Object(o) === o, fromHexString(o, e, t = 1) {
|
|
2134
|
+
const s = V.fromHexString(o);
|
|
2135
|
+
e.r = (s >> 16 & 255) / 255 * t, e.g = (s >> 8 & 255) / 255 * t, e.b = (255 & s) / 255 * t;
|
|
2136
|
+
}, toHexString: ({ r: o, g: e, b: t }, s = 1) => V.toHexString(o * (s = 255 / s) << 16 ^ e * s << 8 ^ t * s << 0) }, Wn = [Kn, V, zn, Xn];
|
|
2137
|
+
class Yn extends L {
|
|
2138
|
+
constructor(e, t, s, n) {
|
|
2139
|
+
var r;
|
|
2140
|
+
super(e, t, s, "color"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "color"), this.$input.setAttribute("tabindex", -1), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$text = document.createElement("input"), this.$text.setAttribute("type", "text"), this.$text.setAttribute("spellcheck", "false"), this.$text.setAttribute("aria-labelledby", this.$name.id), this.$display = document.createElement("div"), this.$display.classList.add("display"), this.$display.appendChild(this.$input), this.$widget.appendChild(this.$display), this.$widget.appendChild(this.$text), this._format = (r = this.initialValue, Wn.find((i) => i.match(r))), this._rgbScale = n, this._initialValueHexString = this.save(), this._textFocused = !1, this.$input.addEventListener("input", () => {
|
|
2141
|
+
this._setValueFromHexString(this.$input.value);
|
|
2142
|
+
}), this.$input.addEventListener("blur", () => {
|
|
2143
|
+
this._callOnFinishChange();
|
|
2144
|
+
}), this.$text.addEventListener("input", () => {
|
|
2145
|
+
const i = ge(this.$text.value);
|
|
2146
|
+
i && this._setValueFromHexString(i);
|
|
2147
|
+
}), this.$text.addEventListener("focus", () => {
|
|
2148
|
+
this._textFocused = !0, this.$text.select();
|
|
2149
|
+
}), this.$text.addEventListener("blur", () => {
|
|
2150
|
+
this._textFocused = !1, this.updateDisplay(), this._callOnFinishChange();
|
|
2151
|
+
}), this.$disable = this.$text, this.updateDisplay();
|
|
2152
|
+
}
|
|
2153
|
+
reset() {
|
|
2154
|
+
return this._setValueFromHexString(this._initialValueHexString), this;
|
|
2155
|
+
}
|
|
2156
|
+
_setValueFromHexString(e) {
|
|
2157
|
+
if (this._format.isPrimitive) {
|
|
2158
|
+
const t = this._format.fromHexString(e);
|
|
2159
|
+
this.setValue(t);
|
|
2160
|
+
} else this._format.fromHexString(e, this.getValue(), this._rgbScale), this._callOnChange(), this.updateDisplay();
|
|
2161
|
+
}
|
|
2162
|
+
save() {
|
|
2163
|
+
return this._format.toHexString(this.getValue(), this._rgbScale);
|
|
2164
|
+
}
|
|
2165
|
+
load(e) {
|
|
2166
|
+
return this._setValueFromHexString(e), this._callOnFinishChange(), this;
|
|
2167
|
+
}
|
|
2168
|
+
updateDisplay() {
|
|
2169
|
+
return this.$input.value = this._format.toHexString(this.getValue(), this._rgbScale), this._textFocused || (this.$text.value = this.$input.value.substring(1)), this.$display.style.backgroundColor = this.$input.value, this;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
class re extends L {
|
|
2173
|
+
constructor(e, t, s) {
|
|
2174
|
+
super(e, t, s, "function"), this.$button = document.createElement("button"), this.$button.appendChild(this.$name), this.$widget.appendChild(this.$button), this.$button.addEventListener("click", (n) => {
|
|
2175
|
+
n.preventDefault(), this.getValue().call(this.object);
|
|
2176
|
+
}), this.$button.addEventListener("touchstart", () => {
|
|
2177
|
+
}, { passive: !0 }), this.$disable = this.$button;
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
class qn extends L {
|
|
2181
|
+
constructor(e, t, s, n, r, i) {
|
|
2182
|
+
super(e, t, s, "number"), this._initInput(), this.min(n), this.max(r);
|
|
2183
|
+
const l = i !== void 0;
|
|
2184
|
+
this.step(l ? i : this._getImplicitStep(), l), this.updateDisplay();
|
|
2185
|
+
}
|
|
2186
|
+
decimals(e) {
|
|
2187
|
+
return this._decimals = e, this.updateDisplay(), this;
|
|
2188
|
+
}
|
|
2189
|
+
min(e) {
|
|
2190
|
+
return this._min = e, this._onUpdateMinMax(), this;
|
|
2191
|
+
}
|
|
2192
|
+
max(e) {
|
|
2193
|
+
return this._max = e, this._onUpdateMinMax(), this;
|
|
2194
|
+
}
|
|
2195
|
+
step(e, t = !0) {
|
|
2196
|
+
return this._step = e, this._stepExplicit = t, this;
|
|
2197
|
+
}
|
|
2198
|
+
updateDisplay() {
|
|
2199
|
+
const e = this.getValue();
|
|
2200
|
+
if (this._hasSlider) {
|
|
2201
|
+
let t = (e - this._min) / (this._max - this._min);
|
|
2202
|
+
t = Math.max(0, Math.min(t, 1)), this.$fill.style.width = 100 * t + "%";
|
|
2203
|
+
}
|
|
2204
|
+
return this._inputFocused || (this.$input.value = this._decimals === void 0 ? e : e.toFixed(this._decimals)), this;
|
|
2205
|
+
}
|
|
2206
|
+
_initInput() {
|
|
2207
|
+
this.$input = document.createElement("input"), this.$input.setAttribute("type", "number"), this.$input.setAttribute("step", "any"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$widget.appendChild(this.$input), this.$disable = this.$input;
|
|
2208
|
+
const e = (h) => {
|
|
2209
|
+
const d = parseFloat(this.$input.value);
|
|
2210
|
+
isNaN(d) || (this._snapClampSetValue(d + h), this.$input.value = this.getValue());
|
|
2211
|
+
};
|
|
2212
|
+
let t, s, n, r, i, l = !1;
|
|
2213
|
+
const a = (h) => {
|
|
2214
|
+
if (l) {
|
|
2215
|
+
const d = h.clientX - t, u = h.clientY - s;
|
|
2216
|
+
Math.abs(u) > 5 ? (h.preventDefault(), this.$input.blur(), l = !1, this._setDraggingStyle(!0, "vertical")) : Math.abs(d) > 5 && c();
|
|
2217
|
+
}
|
|
2218
|
+
if (!l) {
|
|
2219
|
+
const d = h.clientY - n;
|
|
2220
|
+
i -= d * this._step * this._arrowKeyMultiplier(h), r + i > this._max ? i = this._max - r : r + i < this._min && (i = this._min - r), this._snapClampSetValue(r + i);
|
|
2221
|
+
}
|
|
2222
|
+
n = h.clientY;
|
|
2223
|
+
}, c = () => {
|
|
2224
|
+
this._setDraggingStyle(!1, "vertical"), this._callOnFinishChange(), window.removeEventListener("mousemove", a), window.removeEventListener("mouseup", c);
|
|
2225
|
+
};
|
|
2226
|
+
this.$input.addEventListener("input", () => {
|
|
2227
|
+
let h = parseFloat(this.$input.value);
|
|
2228
|
+
isNaN(h) || (this._stepExplicit && (h = this._snap(h)), this.setValue(this._clamp(h)));
|
|
2229
|
+
}), this.$input.addEventListener("keydown", (h) => {
|
|
2230
|
+
h.code === "Enter" && this.$input.blur(), h.code === "ArrowUp" && (h.preventDefault(), e(this._step * this._arrowKeyMultiplier(h))), h.code === "ArrowDown" && (h.preventDefault(), e(this._step * this._arrowKeyMultiplier(h) * -1));
|
|
2231
|
+
}), this.$input.addEventListener("wheel", (h) => {
|
|
2232
|
+
this._inputFocused && (h.preventDefault(), e(this._step * this._normalizeMouseWheel(h)));
|
|
2233
|
+
}, { passive: !1 }), this.$input.addEventListener("mousedown", (h) => {
|
|
2234
|
+
t = h.clientX, s = n = h.clientY, l = !0, r = this.getValue(), i = 0, window.addEventListener("mousemove", a), window.addEventListener("mouseup", c);
|
|
2235
|
+
}), this.$input.addEventListener("focus", () => {
|
|
2236
|
+
this._inputFocused = !0;
|
|
2237
|
+
}), this.$input.addEventListener("blur", () => {
|
|
2238
|
+
this._inputFocused = !1, this.updateDisplay(), this._callOnFinishChange();
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
_initSlider() {
|
|
2242
|
+
this._hasSlider = !0, this.$slider = document.createElement("div"), this.$slider.classList.add("slider"), this.$fill = document.createElement("div"), this.$fill.classList.add("fill"), this.$slider.appendChild(this.$fill), this.$widget.insertBefore(this.$slider, this.$input), this.domElement.classList.add("hasSlider");
|
|
2243
|
+
const e = (u) => {
|
|
2244
|
+
const p = this.$slider.getBoundingClientRect();
|
|
2245
|
+
let f = (b = u, m = p.left, A = p.right, y = this._min, T = this._max, (b - m) / (A - m) * (T - y) + y);
|
|
2246
|
+
var b, m, A, y, T;
|
|
2247
|
+
this._snapClampSetValue(f);
|
|
2248
|
+
}, t = (u) => {
|
|
2249
|
+
e(u.clientX);
|
|
2250
|
+
}, s = () => {
|
|
2251
|
+
this._callOnFinishChange(), this._setDraggingStyle(!1), window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", s);
|
|
2252
|
+
};
|
|
2253
|
+
let n, r, i = !1;
|
|
2254
|
+
const l = (u) => {
|
|
2255
|
+
u.preventDefault(), this._setDraggingStyle(!0), e(u.touches[0].clientX), i = !1;
|
|
2256
|
+
}, a = (u) => {
|
|
2257
|
+
if (i) {
|
|
2258
|
+
const p = u.touches[0].clientX - n, f = u.touches[0].clientY - r;
|
|
2259
|
+
Math.abs(p) > Math.abs(f) ? l(u) : (window.removeEventListener("touchmove", a), window.removeEventListener("touchend", c));
|
|
2260
|
+
} else u.preventDefault(), e(u.touches[0].clientX);
|
|
2261
|
+
}, c = () => {
|
|
2262
|
+
this._callOnFinishChange(), this._setDraggingStyle(!1), window.removeEventListener("touchmove", a), window.removeEventListener("touchend", c);
|
|
2263
|
+
}, h = this._callOnFinishChange.bind(this);
|
|
2264
|
+
let d;
|
|
2265
|
+
this.$slider.addEventListener("mousedown", (u) => {
|
|
2266
|
+
this._setDraggingStyle(!0), e(u.clientX), window.addEventListener("mousemove", t), window.addEventListener("mouseup", s);
|
|
2267
|
+
}), this.$slider.addEventListener("touchstart", (u) => {
|
|
2268
|
+
u.touches.length > 1 || (this._hasScrollBar ? (n = u.touches[0].clientX, r = u.touches[0].clientY, i = !0) : l(u), window.addEventListener("touchmove", a, { passive: !1 }), window.addEventListener("touchend", c));
|
|
2269
|
+
}, { passive: !1 }), this.$slider.addEventListener("wheel", (u) => {
|
|
2270
|
+
if (Math.abs(u.deltaX) < Math.abs(u.deltaY) && this._hasScrollBar) return;
|
|
2271
|
+
u.preventDefault();
|
|
2272
|
+
const p = this._normalizeMouseWheel(u) * this._step;
|
|
2273
|
+
this._snapClampSetValue(this.getValue() + p), this.$input.value = this.getValue(), clearTimeout(d), d = setTimeout(h, 400);
|
|
2274
|
+
}, { passive: !1 });
|
|
2275
|
+
}
|
|
2276
|
+
_setDraggingStyle(e, t = "horizontal") {
|
|
2277
|
+
this.$slider && this.$slider.classList.toggle("active", e), document.body.classList.toggle("lil-gui-dragging", e), document.body.classList.toggle("lil-gui-" + t, e);
|
|
2278
|
+
}
|
|
2279
|
+
_getImplicitStep() {
|
|
2280
|
+
return this._hasMin && this._hasMax ? (this._max - this._min) / 1e3 : 0.1;
|
|
2281
|
+
}
|
|
2282
|
+
_onUpdateMinMax() {
|
|
2283
|
+
!this._hasSlider && this._hasMin && this._hasMax && (this._stepExplicit || this.step(this._getImplicitStep(), !1), this._initSlider(), this.updateDisplay());
|
|
2284
|
+
}
|
|
2285
|
+
_normalizeMouseWheel(e) {
|
|
2286
|
+
let { deltaX: t, deltaY: s } = e;
|
|
2287
|
+
return Math.floor(e.deltaY) !== e.deltaY && e.wheelDelta && (t = 0, s = -e.wheelDelta / 120, s *= this._stepExplicit ? 1 : 10), t + -s;
|
|
2288
|
+
}
|
|
2289
|
+
_arrowKeyMultiplier(e) {
|
|
2290
|
+
let t = this._stepExplicit ? 1 : 10;
|
|
2291
|
+
return e.shiftKey ? t *= 10 : e.altKey && (t /= 10), t;
|
|
2292
|
+
}
|
|
2293
|
+
_snap(e) {
|
|
2294
|
+
const t = Math.round(e / this._step) * this._step;
|
|
2295
|
+
return parseFloat(t.toPrecision(15));
|
|
2296
|
+
}
|
|
2297
|
+
_clamp(e) {
|
|
2298
|
+
return e < this._min && (e = this._min), e > this._max && (e = this._max), e;
|
|
2299
|
+
}
|
|
2300
|
+
_snapClampSetValue(e) {
|
|
2301
|
+
this.setValue(this._clamp(this._snap(e)));
|
|
2302
|
+
}
|
|
2303
|
+
get _hasScrollBar() {
|
|
2304
|
+
const e = this.parent.root.$children;
|
|
2305
|
+
return e.scrollHeight > e.clientHeight;
|
|
2306
|
+
}
|
|
2307
|
+
get _hasMin() {
|
|
2308
|
+
return this._min !== void 0;
|
|
2309
|
+
}
|
|
2310
|
+
get _hasMax() {
|
|
2311
|
+
return this._max !== void 0;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
class Jn extends L {
|
|
2315
|
+
constructor(e, t, s, n) {
|
|
2316
|
+
super(e, t, s, "option"), this.$select = document.createElement("select"), this.$select.setAttribute("aria-labelledby", this.$name.id), this.$display = document.createElement("div"), this.$display.classList.add("display"), this._values = Array.isArray(n) ? n : Object.values(n), this._names = Array.isArray(n) ? n : Object.keys(n), this._names.forEach((r) => {
|
|
2317
|
+
const i = document.createElement("option");
|
|
2318
|
+
i.innerHTML = r, this.$select.appendChild(i);
|
|
2319
|
+
}), this.$select.addEventListener("change", () => {
|
|
2320
|
+
this.setValue(this._values[this.$select.selectedIndex]), this._callOnFinishChange();
|
|
2321
|
+
}), this.$select.addEventListener("focus", () => {
|
|
2322
|
+
this.$display.classList.add("focus");
|
|
2323
|
+
}), this.$select.addEventListener("blur", () => {
|
|
2324
|
+
this.$display.classList.remove("focus");
|
|
2325
|
+
}), this.$widget.appendChild(this.$select), this.$widget.appendChild(this.$display), this.$disable = this.$select, this.updateDisplay();
|
|
2326
|
+
}
|
|
2327
|
+
updateDisplay() {
|
|
2328
|
+
const e = this.getValue(), t = this._values.indexOf(e);
|
|
2329
|
+
return this.$select.selectedIndex = t, this.$display.innerHTML = t === -1 ? e : this._names[t], this;
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
class Qn extends L {
|
|
2333
|
+
constructor(e, t, s) {
|
|
2334
|
+
super(e, t, s, "string"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "text"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$input.addEventListener("input", () => {
|
|
2335
|
+
this.setValue(this.$input.value);
|
|
2336
|
+
}), this.$input.addEventListener("keydown", (n) => {
|
|
2337
|
+
n.code === "Enter" && this.$input.blur();
|
|
2338
|
+
}), this.$input.addEventListener("blur", () => {
|
|
2339
|
+
this._callOnFinishChange();
|
|
2340
|
+
}), this.$widget.appendChild(this.$input), this.$disable = this.$input, this.updateDisplay();
|
|
2341
|
+
}
|
|
2342
|
+
updateDisplay() {
|
|
2343
|
+
return this.$input.value = this.getValue(), this;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
let $e = !1;
|
|
2347
|
+
class Te {
|
|
2348
|
+
constructor({ parent: e, autoPlace: t = e === void 0, container: s, width: n, title: r = "Controls", injectStyles: i = !0, touchStyles: l = !0 } = {}) {
|
|
2349
|
+
if (this.parent = e, this.root = e ? e.root : this, this.children = [], this.controllers = [], this.folders = [], this._closed = !1, this._hidden = !1, this.domElement = document.createElement("div"), this.domElement.classList.add("lil-gui"), this.$title = document.createElement("div"), this.$title.classList.add("title"), this.$title.setAttribute("role", "button"), this.$title.setAttribute("aria-expanded", !0), this.$title.setAttribute("tabindex", 0), this.$title.addEventListener("click", () => this.openAnimated(this._closed)), this.$title.addEventListener("keydown", (a) => {
|
|
2350
|
+
a.code !== "Enter" && a.code !== "Space" || (a.preventDefault(), this.$title.click());
|
|
2351
|
+
}), this.$title.addEventListener("touchstart", () => {
|
|
2352
|
+
}, { passive: !0 }), this.$children = document.createElement("div"), this.$children.classList.add("children"), this.domElement.appendChild(this.$title), this.domElement.appendChild(this.$children), this.title(r), l && this.domElement.classList.add("allow-touch-styles"), this.parent) return this.parent.children.push(this), this.parent.folders.push(this), void this.parent.$children.appendChild(this.domElement);
|
|
2353
|
+
this.domElement.classList.add("root"), !$e && i && (function(a) {
|
|
2354
|
+
const c = document.createElement("style");
|
|
2355
|
+
c.innerHTML = a;
|
|
2356
|
+
const h = document.querySelector("head link[rel=stylesheet], head style");
|
|
2357
|
+
h ? document.head.insertBefore(c, h) : document.head.appendChild(c);
|
|
2358
|
+
}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'), $e = !0), s ? s.appendChild(this.domElement) : t && (this.domElement.classList.add("autoPlace"), document.body.appendChild(this.domElement)), n && this.domElement.style.setProperty("--width", n + "px"), this.domElement.addEventListener("keydown", (a) => a.stopPropagation()), this.domElement.addEventListener("keyup", (a) => a.stopPropagation());
|
|
2359
|
+
}
|
|
2360
|
+
add(e, t, s, n, r) {
|
|
2361
|
+
if (Object(s) === s) return new Jn(this, e, t, s);
|
|
2362
|
+
const i = e[t];
|
|
2363
|
+
switch (typeof i) {
|
|
2364
|
+
case "number":
|
|
2365
|
+
return new qn(this, e, t, s, n, r);
|
|
2366
|
+
case "boolean":
|
|
2367
|
+
return new Vn(this, e, t);
|
|
2368
|
+
case "string":
|
|
2369
|
+
return new Qn(this, e, t);
|
|
2370
|
+
case "function":
|
|
2371
|
+
return new re(this, e, t);
|
|
2372
|
+
}
|
|
2373
|
+
console.error(`gui.add failed
|
|
2374
|
+
property:`, t, `
|
|
2375
|
+
object:`, e, `
|
|
2376
|
+
value:`, i);
|
|
2377
|
+
}
|
|
2378
|
+
addColor(e, t, s = 1) {
|
|
2379
|
+
return new Yn(this, e, t, s);
|
|
2380
|
+
}
|
|
2381
|
+
addFolder(e) {
|
|
2382
|
+
return new Te({ parent: this, title: e });
|
|
2383
|
+
}
|
|
2384
|
+
load(e, t = !0) {
|
|
2385
|
+
return e.controllers && this.controllers.forEach((s) => {
|
|
2386
|
+
s instanceof re || s._name in e.controllers && s.load(e.controllers[s._name]);
|
|
2387
|
+
}), t && e.folders && this.folders.forEach((s) => {
|
|
2388
|
+
s._title in e.folders && s.load(e.folders[s._title]);
|
|
2389
|
+
}), this;
|
|
2390
|
+
}
|
|
2391
|
+
save(e = !0) {
|
|
2392
|
+
const t = { controllers: {}, folders: {} };
|
|
2393
|
+
return this.controllers.forEach((s) => {
|
|
2394
|
+
if (!(s instanceof re)) {
|
|
2395
|
+
if (s._name in t.controllers) throw new Error(`Cannot save GUI with duplicate property "${s._name}"`);
|
|
2396
|
+
t.controllers[s._name] = s.save();
|
|
2397
|
+
}
|
|
2398
|
+
}), e && this.folders.forEach((s) => {
|
|
2399
|
+
if (s._title in t.folders) throw new Error(`Cannot save GUI with duplicate folder "${s._title}"`);
|
|
2400
|
+
t.folders[s._title] = s.save();
|
|
2401
|
+
}), t;
|
|
2402
|
+
}
|
|
2403
|
+
open(e = !0) {
|
|
2404
|
+
return this._closed = !e, this.$title.setAttribute("aria-expanded", !this._closed), this.domElement.classList.toggle("closed", this._closed), this;
|
|
2405
|
+
}
|
|
2406
|
+
close() {
|
|
2407
|
+
return this.open(!1);
|
|
2408
|
+
}
|
|
2409
|
+
show(e = !0) {
|
|
2410
|
+
return this._hidden = !e, this.domElement.style.display = this._hidden ? "none" : "", this;
|
|
2411
|
+
}
|
|
2412
|
+
hide() {
|
|
2413
|
+
return this.show(!1);
|
|
2414
|
+
}
|
|
2415
|
+
openAnimated(e = !0) {
|
|
2416
|
+
return this._closed = !e, this.$title.setAttribute("aria-expanded", !this._closed), requestAnimationFrame(() => {
|
|
2417
|
+
const t = this.$children.clientHeight;
|
|
2418
|
+
this.$children.style.height = t + "px", this.domElement.classList.add("transition");
|
|
2419
|
+
const s = (r) => {
|
|
2420
|
+
r.target === this.$children && (this.$children.style.height = "", this.domElement.classList.remove("transition"), this.$children.removeEventListener("transitionend", s));
|
|
2421
|
+
};
|
|
2422
|
+
this.$children.addEventListener("transitionend", s);
|
|
2423
|
+
const n = e ? this.$children.scrollHeight : 0;
|
|
2424
|
+
this.domElement.classList.toggle("closed", !e), requestAnimationFrame(() => {
|
|
2425
|
+
this.$children.style.height = n + "px";
|
|
2426
|
+
});
|
|
2427
|
+
}), this;
|
|
2428
|
+
}
|
|
2429
|
+
title(e) {
|
|
2430
|
+
return this._title = e, this.$title.innerHTML = e, this;
|
|
2431
|
+
}
|
|
2432
|
+
reset(e = !0) {
|
|
2433
|
+
return (e ? this.controllersRecursive() : this.controllers).forEach((t) => t.reset()), this;
|
|
2434
|
+
}
|
|
2435
|
+
onChange(e) {
|
|
2436
|
+
return this._onChange = e, this;
|
|
2437
|
+
}
|
|
2438
|
+
_callOnChange(e) {
|
|
2439
|
+
this.parent && this.parent._callOnChange(e), this._onChange !== void 0 && this._onChange.call(this, { object: e.object, property: e.property, value: e.getValue(), controller: e });
|
|
2440
|
+
}
|
|
2441
|
+
onFinishChange(e) {
|
|
2442
|
+
return this._onFinishChange = e, this;
|
|
2443
|
+
}
|
|
2444
|
+
_callOnFinishChange(e) {
|
|
2445
|
+
this.parent && this.parent._callOnFinishChange(e), this._onFinishChange !== void 0 && this._onFinishChange.call(this, { object: e.object, property: e.property, value: e.getValue(), controller: e });
|
|
2446
|
+
}
|
|
2447
|
+
destroy() {
|
|
2448
|
+
this.parent && (this.parent.children.splice(this.parent.children.indexOf(this), 1), this.parent.folders.splice(this.parent.folders.indexOf(this), 1)), this.domElement.parentElement && this.domElement.parentElement.removeChild(this.domElement), Array.from(this.children).forEach((e) => e.destroy());
|
|
2449
|
+
}
|
|
2450
|
+
controllersRecursive() {
|
|
2451
|
+
let e = Array.from(this.controllers);
|
|
2452
|
+
return this.folders.forEach((t) => {
|
|
2453
|
+
e = e.concat(t.controllersRecursive());
|
|
2454
|
+
}), e;
|
|
2455
|
+
}
|
|
2456
|
+
foldersRecursive() {
|
|
2457
|
+
let e = Array.from(this.folders);
|
|
2458
|
+
return this.folders.forEach((t) => {
|
|
2459
|
+
e = e.concat(t.foldersRecursive());
|
|
2460
|
+
}), e;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
var Zn = Object.defineProperty, es = Object.getOwnPropertyDescriptor, ts = (o, e, t, s) => {
|
|
2464
|
+
for (var n = s > 1 ? void 0 : s ? es(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
2465
|
+
(i = o[r]) && (n = (s ? i(e, t, n) : i(n)) || n);
|
|
2466
|
+
return s && n && Zn(e, t, n), n;
|
|
2467
|
+
};
|
|
2468
|
+
let W = class {
|
|
2469
|
+
constructor() {
|
|
2470
|
+
g(this, "workerPool", Wt());
|
|
2471
|
+
g(this, "canvas");
|
|
2472
|
+
g(this, "worker");
|
|
2473
|
+
g(this, "thread");
|
|
2474
|
+
g(this, "gui");
|
|
2475
|
+
g(this, "stats");
|
|
2476
|
+
}
|
|
2477
|
+
init(o) {
|
|
2478
|
+
this.worker = o.worker, this.thread = o.thread, this.gui = new Te(), this.stats = Me && new Me(), this.stats.showPanel(0), window && (window.document.body.appendChild(this.stats.dom), window.innerWidth <= 450 && this.gui.close());
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
W = ts([
|
|
2482
|
+
ye()
|
|
2483
|
+
], W);
|
|
2484
|
+
var ns = Object.defineProperty, ss = Object.getOwnPropertyDescriptor, is = (o, e, t, s) => {
|
|
2485
|
+
for (var n = s > 1 ? void 0 : s ? ss(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
2486
|
+
(i = o[r]) && (n = (s ? i(e, t, n) : i(n)) || n);
|
|
2487
|
+
return s && n && ns(e, t, n), n;
|
|
2488
|
+
}, rs = (o, e) => (t, s) => e(t, s, o);
|
|
2489
|
+
let Ae = class extends st {
|
|
2490
|
+
constructor(e) {
|
|
2491
|
+
super();
|
|
2492
|
+
g(this, "canvas");
|
|
2493
|
+
g(this, "lifecycle$$", new he());
|
|
2494
|
+
g(this, "lifecycle$", this.lifecycle$$.pipe());
|
|
2495
|
+
this.component = e;
|
|
2496
|
+
}
|
|
2497
|
+
init(e) {
|
|
2498
|
+
this.canvas = e;
|
|
2499
|
+
for (const t of Fe) {
|
|
2500
|
+
const s = t.startsWith("mouse") || t.startsWith("pointer") || t.startsWith("touch") ? this.mouseEventHandler : t.startsWith("key") ? this.keyEventHandler : t === "resize" ? this.uiEventHandler : t === "wheel" ? this.wheelEventHandler : this.preventDefaultHandler;
|
|
2501
|
+
this[`${t}$`] = zt(
|
|
2502
|
+
t === "resize" ? window : e,
|
|
2503
|
+
t
|
|
2504
|
+
).pipe(
|
|
2505
|
+
// @ts-ignore
|
|
2506
|
+
Xt(s.bind(this)),
|
|
2507
|
+
qe((n) => !(t === "keydown" && !n))
|
|
2508
|
+
), this[`${t}$`].subscribe((n) => {
|
|
2509
|
+
var r, i;
|
|
2510
|
+
(i = (r = this.component.thread) == null ? void 0 : r[t]) == null || i.call(r, n);
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
preventDefaultHandler(e) {
|
|
2515
|
+
return e.preventDefault(), {
|
|
2516
|
+
type: e.type
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2519
|
+
getScreenSizes() {
|
|
2520
|
+
return {
|
|
2521
|
+
width: this.canvas.width,
|
|
2522
|
+
height: this.canvas.height,
|
|
2523
|
+
windowWidth: (window == null ? void 0 : window.innerWidth) ?? 0,
|
|
2524
|
+
windowHeight: (window == null ? void 0 : window.innerHeight) ?? 0
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
uiEventHandler(e) {
|
|
2528
|
+
const t = this.canvas.getBoundingClientRect();
|
|
2529
|
+
return {
|
|
2530
|
+
...this.getScreenSizes(),
|
|
2531
|
+
type: e.type,
|
|
2532
|
+
top: t.top,
|
|
2533
|
+
left: t.left
|
|
2534
|
+
};
|
|
2535
|
+
}
|
|
2536
|
+
mouseEventHandler(e) {
|
|
2537
|
+
return {
|
|
2538
|
+
...this.getScreenSizes(),
|
|
2539
|
+
...Q(e, [
|
|
2540
|
+
"ctrlKey",
|
|
2541
|
+
"metaKey",
|
|
2542
|
+
"shiftKey",
|
|
2543
|
+
"button",
|
|
2544
|
+
"pointerType",
|
|
2545
|
+
"clientX",
|
|
2546
|
+
"clientY",
|
|
2547
|
+
"pageX",
|
|
2548
|
+
"pageY"
|
|
2549
|
+
])
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
touchEventHandler(e) {
|
|
2553
|
+
const t = [], s = { type: e.type, touches: t };
|
|
2554
|
+
for (let n = 0; n < e.touches.length; ++n) {
|
|
2555
|
+
const r = e.touches[n];
|
|
2556
|
+
t.push({
|
|
2557
|
+
pageX: (r == null ? void 0 : r.pageX) ?? 0,
|
|
2558
|
+
pageY: (r == null ? void 0 : r.pageY) ?? 0
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
return { ...this.getScreenSizes(), ...s };
|
|
2562
|
+
}
|
|
2563
|
+
wheelEventHandler(e) {
|
|
2564
|
+
return e.preventDefault(), {
|
|
2565
|
+
...this.getScreenSizes(),
|
|
2566
|
+
...Q(e, ["deltaX", "deltaY"])
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
2569
|
+
keyEventHandler(e) {
|
|
2570
|
+
if (it.includes(e.code))
|
|
2571
|
+
return e.preventDefault(), {
|
|
2572
|
+
...this.getScreenSizes(),
|
|
2573
|
+
...Q(e, ["ctrlKey", "metaKey", "shiftKey", "keyCode"])
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
};
|
|
2577
|
+
Ae = is([
|
|
2578
|
+
ye(),
|
|
2579
|
+
rs(0, $(W))
|
|
2580
|
+
], Ae);
|
|
2581
|
+
class Ze {
|
|
2582
|
+
constructor() {
|
|
2583
|
+
/**
|
|
2584
|
+
* @description The app worker logic location.
|
|
2585
|
+
*
|
|
2586
|
+
* @required
|
|
2587
|
+
*/
|
|
2588
|
+
g(this, "location");
|
|
2589
|
+
/**
|
|
2590
|
+
* @description App `canvas` element reference.
|
|
2591
|
+
*
|
|
2592
|
+
* @default undefined
|
|
2593
|
+
*/
|
|
2594
|
+
g(this, "canvas");
|
|
2595
|
+
/**
|
|
2596
|
+
* @description Set the `canvas` view in fullscreen and auto-resize it.
|
|
2597
|
+
*
|
|
2598
|
+
* @default true
|
|
2599
|
+
*/
|
|
2600
|
+
g(this, "fullScreen");
|
|
2601
|
+
/**
|
|
2602
|
+
* Default used camera.
|
|
2603
|
+
*
|
|
2604
|
+
* @see {@link DefaultCameraType}
|
|
2605
|
+
*
|
|
2606
|
+
* @default DefaultCameraType.PERSPECTIVE
|
|
2607
|
+
*/
|
|
2608
|
+
g(this, "defaultCamera");
|
|
2609
|
+
/**
|
|
2610
|
+
* @description Start timer update on launch.
|
|
2611
|
+
*
|
|
2612
|
+
* @default true
|
|
2613
|
+
*/
|
|
2614
|
+
g(this, "startTimer");
|
|
2615
|
+
/**
|
|
2616
|
+
* Enable the debug mode
|
|
2617
|
+
*
|
|
2618
|
+
* @default undefined
|
|
2619
|
+
*/
|
|
2620
|
+
g(this, "enableDebug");
|
|
2621
|
+
/**
|
|
2622
|
+
* Define the {@link THREE.AxesHelper} sizes.
|
|
2623
|
+
*
|
|
2624
|
+
* @remark __Deactivated if the value is `0` or `undefined`__
|
|
2625
|
+
* @remark __This property depends on {@link RegisterPropsModel.enableDebug}__
|
|
2626
|
+
*
|
|
2627
|
+
* @default undefined
|
|
2628
|
+
*/
|
|
2629
|
+
g(this, "axesSizes");
|
|
2630
|
+
/**
|
|
2631
|
+
* Define the {@link THREE.GridHelper} sizes.
|
|
2632
|
+
*
|
|
2633
|
+
* @remark __Deactivated if the value is `0` or `undefined`__
|
|
2634
|
+
* @remark __This property depends on {@link RegisterPropsModel.enableDebug}__
|
|
2635
|
+
*
|
|
2636
|
+
* @default undefined
|
|
2637
|
+
*/
|
|
2638
|
+
g(this, "gridSizes");
|
|
2639
|
+
/**
|
|
2640
|
+
* Display a mini perfective camera at the top right corner of the screen.
|
|
2641
|
+
*
|
|
2642
|
+
* @remark __This property depends on {@link RegisterPropsModel.enableDebug}__
|
|
2643
|
+
*
|
|
2644
|
+
* @default false
|
|
2645
|
+
*/
|
|
2646
|
+
g(this, "withMiniCamera");
|
|
2647
|
+
/**
|
|
2648
|
+
* @description Handler called when the app is ready.
|
|
2649
|
+
*
|
|
2650
|
+
* @default undefined
|
|
2651
|
+
*/
|
|
2652
|
+
g(this, "onReady");
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
class os {
|
|
2656
|
+
constructor() {
|
|
2657
|
+
g(this, "contextmenu$");
|
|
2658
|
+
g(this, "resize$");
|
|
2659
|
+
g(this, "mousedown$");
|
|
2660
|
+
g(this, "mousemove$");
|
|
2661
|
+
g(this, "mouseup$");
|
|
2662
|
+
g(this, "pointerdown$");
|
|
2663
|
+
g(this, "pointermove$");
|
|
2664
|
+
g(this, "pointercancel$");
|
|
2665
|
+
g(this, "pointerup$");
|
|
2666
|
+
g(this, "touchstart$");
|
|
2667
|
+
g(this, "touchmove$");
|
|
2668
|
+
g(this, "touchend$");
|
|
2669
|
+
g(this, "wheel$");
|
|
2670
|
+
g(this, "keydown$");
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
var as = Object.defineProperty, ls = Object.getOwnPropertyDescriptor, cs = (o, e, t, s) => {
|
|
2674
|
+
for (var n = s > 1 ? void 0 : s ? ls(e, t) : e, r = o.length - 1, i; r >= 0; r--)
|
|
2675
|
+
(i = o[r]) && (n = (s ? i(e, t, n) : i(n)) || n);
|
|
2676
|
+
return s && n && as(e, t, n), n;
|
|
2677
|
+
}, oe = (o, e) => (t, s) => e(t, s, o);
|
|
2678
|
+
let be = class extends os {
|
|
2679
|
+
constructor(o, e, t) {
|
|
2680
|
+
super(), this.component = o, this.controller = e, this.registerProps = t, this.init();
|
|
2681
|
+
}
|
|
2682
|
+
async _initCanvas() {
|
|
2683
|
+
try {
|
|
2684
|
+
if (this.component.canvas = document.createElement("canvas"), this.registerProps.canvas instanceof HTMLCanvasElement && (this.component.canvas = this.registerProps.canvas), typeof this.registerProps.canvas == "string") {
|
|
2685
|
+
const o = document.querySelector(
|
|
2686
|
+
this.registerProps.canvas
|
|
2687
|
+
);
|
|
2688
|
+
o instanceof HTMLCanvasElement && (this.component.canvas = o);
|
|
2689
|
+
}
|
|
2690
|
+
this.component.canvas.parentElement || document.body.appendChild(this.component.canvas);
|
|
2691
|
+
} catch (o) {
|
|
2692
|
+
console.error(
|
|
2693
|
+
`🛑 Unable to initialize the canvas:
|
|
2694
|
+
${(o == null ? void 0 : o.message) ?? "Something went wrong"}`
|
|
2695
|
+
);
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
async _initComponent() {
|
|
2699
|
+
this.component.init({
|
|
2700
|
+
worker: this.component.worker,
|
|
2701
|
+
thread: this.component.thread
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
async _initController() {
|
|
2705
|
+
var o, e, t;
|
|
2706
|
+
this.controller.init(this.component.canvas), !(!this.component.thread || !this.component.worker) && ((e = (o = this.component.thread) == null ? void 0 : o.resize) == null || e.call(o, {
|
|
2707
|
+
...this.controller.uiEventHandler({ type: "resize" })
|
|
2708
|
+
}), (t = this.component.thread) == null || t.lifecycle$().subscribe((s) => {
|
|
2709
|
+
var n, r;
|
|
2710
|
+
s === xe.STEP_STARTED && ((n = this.component.stats) == null || n.begin()), s === xe.STEP_ENDED && ((r = this.component.stats) == null || r.end());
|
|
2711
|
+
}));
|
|
2712
|
+
}
|
|
2713
|
+
async _initWorkerThread() {
|
|
2714
|
+
const o = this.component.canvas.transferControlToOffscreen();
|
|
2715
|
+
o.width = this.component.canvas.clientWidth, o.height = this.component.canvas.clientHeight;
|
|
2716
|
+
const e = await this.component.workerPool.run({
|
|
2717
|
+
payload: {
|
|
2718
|
+
path: this.registerProps.location,
|
|
2719
|
+
subject: {
|
|
2720
|
+
...Yt(this.registerProps, [
|
|
2721
|
+
"canvas",
|
|
2722
|
+
"location",
|
|
2723
|
+
"onReady"
|
|
2724
|
+
]),
|
|
2725
|
+
canvas: o
|
|
2726
|
+
},
|
|
2727
|
+
transferSubject: [o]
|
|
2728
|
+
}
|
|
2729
|
+
});
|
|
2730
|
+
if (!e.thread || !e.worker)
|
|
2731
|
+
throw new Error("Unable to retrieve app worker info.");
|
|
2732
|
+
this.component.worker = e.worker, this.component.thread = e.thread;
|
|
2733
|
+
}
|
|
2734
|
+
async _initProxyEvents() {
|
|
2735
|
+
Fe.forEach(
|
|
2736
|
+
(o) => this[`${o}$`] = () => {
|
|
2737
|
+
var e;
|
|
2738
|
+
return (e = this.controller) == null ? void 0 : e[`${o}$`];
|
|
2739
|
+
}
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
async init() {
|
|
2743
|
+
var o, e;
|
|
2744
|
+
await this._initCanvas(), await this._initWorkerThread(), await this._initComponent(), await this._initController(), await this._initProxyEvents(), this.controller.lifecycle$$.next(Ee.INITIALIZED), (e = (o = this.registerProps).onReady) == null || e.call(o, this);
|
|
2745
|
+
}
|
|
2746
|
+
async loadResources(o) {
|
|
2747
|
+
var t, s, n, r, i, l, a, c, h;
|
|
2748
|
+
const e = await this.component.workerPool.run({
|
|
2749
|
+
payload: {
|
|
2750
|
+
path: "../loader/loader.module-worker.ts",
|
|
2751
|
+
subject: {
|
|
2752
|
+
resources: o.resources
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
});
|
|
2756
|
+
return (t = e.thread) == null || t.progress$().subscribe((d) => {
|
|
2757
|
+
var u;
|
|
2758
|
+
(u = o.onProgress) == null || u.call(o, d);
|
|
2759
|
+
}), (s = e.thread) == null || s.progressCompleted$().subscribe((d) => {
|
|
2760
|
+
var u, p;
|
|
2761
|
+
(u = o.onProgressComplete) == null || u.call(o, d), (o.disposeOnComplete || o.disposeOnComplete === void 0) && ((p = e.thread) == null || p.dispose());
|
|
2762
|
+
}), (o.immediateLoad || o.immediateLoad === void 0) && await ((n = e.thread) == null ? void 0 : n.load()), {
|
|
2763
|
+
...e,
|
|
2764
|
+
load: await ((r = e.thread) == null ? void 0 : r.load),
|
|
2765
|
+
items: await ((i = e.thread) == null ? void 0 : i.items()),
|
|
2766
|
+
loaders: await ((l = e.thread) == null ? void 0 : l.items()),
|
|
2767
|
+
toLoad: await ((a = e.thread) == null ? void 0 : a.toLoad()),
|
|
2768
|
+
loaded: await ((c = e.thread) == null ? void 0 : c.loaded()),
|
|
2769
|
+
resources: await ((h = e.thread) == null ? void 0 : h.resources())
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
workerPool() {
|
|
2773
|
+
return this.component.workerPool;
|
|
2774
|
+
}
|
|
2775
|
+
canvas() {
|
|
2776
|
+
return this.component.canvas;
|
|
2777
|
+
}
|
|
2778
|
+
worker() {
|
|
2779
|
+
return this.component.worker;
|
|
2780
|
+
}
|
|
2781
|
+
thread() {
|
|
2782
|
+
return this.component.thread;
|
|
2783
|
+
}
|
|
2784
|
+
gui() {
|
|
2785
|
+
return this.component.gui;
|
|
2786
|
+
}
|
|
2787
|
+
dispose() {
|
|
2788
|
+
this.component.workerPool.terminateAll(), this.controller.lifecycle$$.next(Ee.DISPOSED);
|
|
2789
|
+
}
|
|
2790
|
+
lifecycle$() {
|
|
2791
|
+
return this.controller.lifecycle$;
|
|
2792
|
+
}
|
|
2793
|
+
};
|
|
2794
|
+
be = cs([
|
|
2795
|
+
ye(),
|
|
2796
|
+
oe(0, $(W)),
|
|
2797
|
+
oe(1, $(Ae)),
|
|
2798
|
+
oe(2, $(Ze))
|
|
2799
|
+
], be);
|
|
2800
|
+
const As = (o) => {
|
|
2801
|
+
if (typeof (o == null ? void 0 : o.location) != "string" && !((o == null ? void 0 : o.location) instanceof URL))
|
|
2802
|
+
throw new Error(
|
|
2803
|
+
"Invalid register props detected. location path is required"
|
|
2804
|
+
);
|
|
2805
|
+
return o.defaultCamera = o != null && o.defaultCamera && o.defaultCamera in ve ? o.defaultCamera : ve.PERSPECTIVE, o.withMiniCamera = Z(o.withMiniCamera) || !ee(o.withMiniCamera) ? !1 : o.withMiniCamera, o.startTimer = Z(o.startTimer) || !ee(o.startTimer) ? !0 : o.startTimer, o.fullScreen = Z(o.fullScreen) || !ee(o.fullScreen) ? !0 : o.fullScreen, o.onReady = qt(o.onReady) ? o.onReady : void 0, K.register(Ze, { useValue: o }), K.resolve(be);
|
|
2806
|
+
};
|
|
2807
|
+
class bs {
|
|
2808
|
+
constructor() {
|
|
2809
|
+
/**
|
|
2810
|
+
* @description Handler triggered when the app is ready.
|
|
2811
|
+
*/
|
|
2812
|
+
g(this, "onReady");
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
export {
|
|
2816
|
+
xe as AppLifecycleState,
|
|
2817
|
+
_s as AppModule,
|
|
2818
|
+
Ts as AppProxyEventHandlersModel,
|
|
2819
|
+
ve as DefaultCameraType,
|
|
2820
|
+
it as KEYBOARD_EVENT_CODES,
|
|
2821
|
+
bs as LaunchAppProps,
|
|
2822
|
+
me as LoaderModule,
|
|
2823
|
+
Fe as PROXY_EVENT_LISTENERS,
|
|
2824
|
+
st as ProxyEventHandlersModel,
|
|
2825
|
+
xs as ProxyEventObservablesModel,
|
|
2826
|
+
Es as ProxyEventSubjectsModel,
|
|
2827
|
+
Ee as RegisterLifecycleState,
|
|
2828
|
+
be as RegisterModule,
|
|
2829
|
+
Ze as RegisterPropsModel,
|
|
2830
|
+
os as RegisterProxyEventHandlersModel,
|
|
2831
|
+
vs as appModule,
|
|
2832
|
+
gs as loaderModule,
|
|
2833
|
+
As as register
|
|
2834
|
+
};
|