@quick-threejs/reactive 0.1.23 → 0.1.25

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