ss-component-new 1.3.545 → 1.3.547

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.
@@ -1,2225 +0,0 @@
1
- import { ref as K, shallowRef as ze, defineComponent as Xe, watch as ee, onMounted as We, nextTick as qe, onBeforeUnmount as Ye, resolveComponent as $e, createElementBlock as me, openBlock as te, createElementVNode as S, withDirectives as Je, createCommentVNode as ge, createVNode as H, unref as U, renderSlot as Te, toDisplayString as Re, withCtx as Qe, createBlock as Ze, vShow as et } from "vue";
2
- import { ak as tt, al as ce, am as Ie, R as Ce, an as W, U as Q, ao as N, ap as Ne, C as v, aq as C, c as D, ar as nt, j as st, D as rt, n as Z, V as B, as as ot, at as ke, au as it, av as Oe, aw as at, ax as ct, a1 as q, ay as lt, az as Pe, aA as ut, aB as dt, aC as ft, aD as le, aE as De, aF as ue, aG as ht, aH as pt, _ as mt, aI as ne, a2 as gt, t as ve, l as Tt, aJ as X, aK as Rt, u as Fe, aL as _t, h as He, aM as xt, w as At, aN as yt, $ as Lt, s as se, P as Et, o as wt, aO as bt, aP as Mt, aQ as St, aR as It, aS as Ct, aT as Ue, aU as Nt, aV as _e, aW as xe, aX as Ae, aY as ye, aZ as de, a4 as kt, a_ as Ot, B as Ge, a$ as Pt, k as Dt } from "./index.vue_vue_type_style_index_0_scoped_07c75c98_lang-DGUr6qBw.js";
3
- import "./index-DqXvOyIs.js";
4
- import { u as vt, a as Ft, b as Ht, C as Ut } from "./iconfont-CdO3WbzY.js";
5
- import { M as Gt, O as jt, S as Bt } from "./MTLLoader-Cej1eu5u.js";
6
- import { T as j } from "./svgIcon-4u4PW7Is.js";
7
- import { E as Le } from "./request-B1c8BUkR.js";
8
- import { _ as Kt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
9
- function Ee(f, e) {
10
- if (e === tt)
11
- return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), f;
12
- if (e === ce || e === Ie) {
13
- let t = f.getIndex();
14
- if (t === null) {
15
- const s = [], a = f.getAttribute("position");
16
- if (a !== void 0) {
17
- for (let i = 0; i < a.count; i++)
18
- s.push(i);
19
- f.setIndex(s), t = f.getIndex();
20
- } else
21
- return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), f;
22
- }
23
- const o = t.count - 2, n = [];
24
- if (e === ce)
25
- for (let s = 1; s <= o; s++)
26
- n.push(t.getX(0)), n.push(t.getX(s)), n.push(t.getX(s + 1));
27
- else
28
- for (let s = 0; s < o; s++)
29
- 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)));
30
- n.length / 3 !== o && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
31
- const r = f.clone();
32
- return r.setIndex(n), r.clearGroups(), r;
33
- } else
34
- return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), f;
35
- }
36
- class Vt extends Ce {
37
- /**
38
- * Constructs a new glTF loader.
39
- *
40
- * @param {LoadingManager} [manager] - The loading manager.
41
- */
42
- constructor(e) {
43
- super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
44
- return new Yt(t);
45
- }), this.register(function(t) {
46
- return new $t(t);
47
- }), this.register(function(t) {
48
- return new on(t);
49
- }), this.register(function(t) {
50
- return new an(t);
51
- }), this.register(function(t) {
52
- return new cn(t);
53
- }), this.register(function(t) {
54
- return new Qt(t);
55
- }), this.register(function(t) {
56
- return new Zt(t);
57
- }), this.register(function(t) {
58
- return new en(t);
59
- }), this.register(function(t) {
60
- return new tn(t);
61
- }), this.register(function(t) {
62
- return new qt(t);
63
- }), this.register(function(t) {
64
- return new nn(t);
65
- }), this.register(function(t) {
66
- return new Jt(t);
67
- }), this.register(function(t) {
68
- return new rn(t);
69
- }), this.register(function(t) {
70
- return new sn(t);
71
- }), this.register(function(t) {
72
- return new Xt(t);
73
- }), this.register(function(t) {
74
- return new ln(t);
75
- }), this.register(function(t) {
76
- return new un(t);
77
- });
78
- }
79
- /**
80
- * Starts loading from the given URL and passes the loaded glTF asset
81
- * to the `onLoad()` callback.
82
- *
83
- * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
84
- * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
85
- * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
86
- * @param {onErrorCallback} onError - Executed when errors occur.
87
- */
88
- load(e, t, o, n) {
89
- const r = this;
90
- let s;
91
- if (this.resourcePath !== "")
92
- s = this.resourcePath;
93
- else if (this.path !== "") {
94
- const c = W.extractUrlBase(e);
95
- s = W.resolveURL(c, this.path);
96
- } else
97
- s = W.extractUrlBase(e);
98
- this.manager.itemStart(e);
99
- const a = function(c) {
100
- n ? n(c) : console.error(c), r.manager.itemError(e), r.manager.itemEnd(e);
101
- }, i = new Q(this.manager);
102
- i.setPath(this.path), i.setResponseType("arraybuffer"), i.setRequestHeader(this.requestHeader), i.setWithCredentials(this.withCredentials), i.load(e, function(c) {
103
- try {
104
- r.parse(c, s, function(u) {
105
- t(u), r.manager.itemEnd(e);
106
- }, a);
107
- } catch (u) {
108
- a(u);
109
- }
110
- }, o, a);
111
- }
112
- /**
113
- * Sets the given Draco loader to this loader. Required for decoding assets
114
- * compressed with the `KHR_draco_mesh_compression` extension.
115
- *
116
- * @param {DRACOLoader} dracoLoader - The Draco loader to set.
117
- * @return {GLTFLoader} A reference to this loader.
118
- */
119
- setDRACOLoader(e) {
120
- return this.dracoLoader = e, this;
121
- }
122
- /**
123
- * Sets the given KTX2 loader to this loader. Required for loading KTX2
124
- * compressed textures.
125
- *
126
- * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
127
- * @return {GLTFLoader} A reference to this loader.
128
- */
129
- setKTX2Loader(e) {
130
- return this.ktx2Loader = e, this;
131
- }
132
- /**
133
- * Sets the given meshopt decoder. Required for decoding assets
134
- * compressed with the `EXT_meshopt_compression` extension.
135
- *
136
- * @param {Object} meshoptDecoder - The meshopt decoder to set.
137
- * @return {GLTFLoader} A reference to this loader.
138
- */
139
- setMeshoptDecoder(e) {
140
- return this.meshoptDecoder = e, this;
141
- }
142
- /**
143
- * Registers a plugin callback. This API is internally used to implement the various
144
- * glTF extensions but can also used by third-party code to add additional logic
145
- * to the loader.
146
- *
147
- * @param {function(parser:GLTFParser)} callback - The callback function to register.
148
- * @return {GLTFLoader} A reference to this loader.
149
- */
150
- register(e) {
151
- return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
152
- }
153
- /**
154
- * Unregisters a plugin callback.
155
- *
156
- * @param {Function} callback - The callback function to unregister.
157
- * @return {GLTFLoader} A reference to this loader.
158
- */
159
- unregister(e) {
160
- return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
161
- }
162
- /**
163
- * Parses the given FBX data and returns the resulting group.
164
- *
165
- * @param {string|ArrayBuffer} data - The raw glTF data.
166
- * @param {string} path - The URL base path.
167
- * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
168
- * @param {onErrorCallback} onError - Executed when errors occur.
169
- */
170
- parse(e, t, o, n) {
171
- let r;
172
- const s = {}, a = {}, i = new TextDecoder();
173
- if (typeof e == "string")
174
- r = JSON.parse(e);
175
- else if (e instanceof ArrayBuffer)
176
- if (i.decode(new Uint8Array(e, 0, 4)) === je) {
177
- try {
178
- s[x.KHR_BINARY_GLTF] = new dn(e);
179
- } catch (l) {
180
- n && n(l);
181
- return;
182
- }
183
- r = JSON.parse(s[x.KHR_BINARY_GLTF].content);
184
- } else
185
- r = JSON.parse(i.decode(e));
186
- else
187
- r = e;
188
- if (r.asset === void 0 || r.asset.version[0] < 2) {
189
- n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
190
- return;
191
- }
192
- const c = new En(r, {
193
- path: t || this.resourcePath || "",
194
- crossOrigin: this.crossOrigin,
195
- requestHeader: this.requestHeader,
196
- manager: this.manager,
197
- ktx2Loader: this.ktx2Loader,
198
- meshoptDecoder: this.meshoptDecoder
199
- });
200
- c.fileLoader.setRequestHeader(this.requestHeader);
201
- for (let u = 0; u < this.pluginCallbacks.length; u++) {
202
- const l = this.pluginCallbacks[u](c);
203
- l.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[l.name] = l, s[l.name] = !0;
204
- }
205
- if (r.extensionsUsed)
206
- for (let u = 0; u < r.extensionsUsed.length; ++u) {
207
- const l = r.extensionsUsed[u], d = r.extensionsRequired || [];
208
- switch (l) {
209
- case x.KHR_MATERIALS_UNLIT:
210
- s[l] = new Wt();
211
- break;
212
- case x.KHR_DRACO_MESH_COMPRESSION:
213
- s[l] = new fn(r, this.dracoLoader);
214
- break;
215
- case x.KHR_TEXTURE_TRANSFORM:
216
- s[l] = new hn();
217
- break;
218
- case x.KHR_MESH_QUANTIZATION:
219
- s[l] = new pn();
220
- break;
221
- default:
222
- d.indexOf(l) >= 0 && a[l] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + l + '".');
223
- }
224
- }
225
- c.setExtensions(s), c.setPlugins(a), c.parse(o, n);
226
- }
227
- /**
228
- * Async version of {@link GLTFLoader#parse}.
229
- *
230
- * @async
231
- * @param {string|ArrayBuffer} data - The raw glTF data.
232
- * @param {string} path - The URL base path.
233
- * @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
234
- */
235
- parseAsync(e, t) {
236
- const o = this;
237
- return new Promise(function(n, r) {
238
- o.parse(e, t, n, r);
239
- });
240
- }
241
- }
242
- function zt() {
243
- let f = {};
244
- return {
245
- get: function(e) {
246
- return f[e];
247
- },
248
- add: function(e, t) {
249
- f[e] = t;
250
- },
251
- remove: function(e) {
252
- delete f[e];
253
- },
254
- removeAll: function() {
255
- f = {};
256
- }
257
- };
258
- }
259
- const x = {
260
- KHR_BINARY_GLTF: "KHR_binary_glTF",
261
- KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
262
- KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
263
- KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
264
- KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
265
- KHR_MATERIALS_IOR: "KHR_materials_ior",
266
- KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
267
- KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
268
- KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
269
- KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
270
- KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
271
- KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
272
- KHR_MATERIALS_VOLUME: "KHR_materials_volume",
273
- KHR_TEXTURE_BASISU: "KHR_texture_basisu",
274
- KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
275
- KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
276
- KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
277
- EXT_MATERIALS_BUMP: "EXT_materials_bump",
278
- EXT_TEXTURE_WEBP: "EXT_texture_webp",
279
- EXT_TEXTURE_AVIF: "EXT_texture_avif",
280
- EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
281
- EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
282
- };
283
- class Xt {
284
- constructor(e) {
285
- this.parser = e, this.name = x.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
286
- }
287
- _markDefs() {
288
- const e = this.parser, t = this.parser.json.nodes || [];
289
- for (let o = 0, n = t.length; o < n; o++) {
290
- const r = t[o];
291
- r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
292
- }
293
- }
294
- _loadLight(e) {
295
- const t = this.parser, o = "light:" + e;
296
- let n = t.cache.get(o);
297
- if (n) return n;
298
- const r = t.json, i = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e];
299
- let c;
300
- const u = new v(16777215);
301
- i.color !== void 0 && u.setRGB(i.color[0], i.color[1], i.color[2], C);
302
- const l = i.range !== void 0 ? i.range : 0;
303
- switch (i.type) {
304
- case "directional":
305
- c = new rt(u), c.target.position.set(0, 0, -1), c.add(c.target);
306
- break;
307
- case "point":
308
- c = new st(u), c.distance = l;
309
- break;
310
- case "spot":
311
- c = new nt(u), c.distance = l, i.spot = i.spot || {}, i.spot.innerConeAngle = i.spot.innerConeAngle !== void 0 ? i.spot.innerConeAngle : 0, i.spot.outerConeAngle = i.spot.outerConeAngle !== void 0 ? i.spot.outerConeAngle : Math.PI / 4, c.angle = i.spot.outerConeAngle, c.penumbra = 1 - i.spot.innerConeAngle / i.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
312
- break;
313
- default:
314
- throw new Error("THREE.GLTFLoader: Unexpected light type: " + i.type);
315
- }
316
- return c.position.set(0, 0, 0), O(c, i), i.intensity !== void 0 && (c.intensity = i.intensity), c.name = t.createUniqueName(i.name || "light_" + e), n = Promise.resolve(c), t.cache.add(o, n), n;
317
- }
318
- getDependency(e, t) {
319
- if (e === "light")
320
- return this._loadLight(t);
321
- }
322
- createNodeAttachment(e) {
323
- const t = this, o = this.parser, r = o.json.nodes[e], a = (r.extensions && r.extensions[this.name] || {}).light;
324
- return a === void 0 ? null : this._loadLight(a).then(function(i) {
325
- return o._getNodeRef(t.cache, a, i);
326
- });
327
- }
328
- }
329
- class Wt {
330
- constructor() {
331
- this.name = x.KHR_MATERIALS_UNLIT;
332
- }
333
- getMaterialType() {
334
- return X;
335
- }
336
- extendParams(e, t, o) {
337
- const n = [];
338
- e.color = new v(1, 1, 1), e.opacity = 1;
339
- const r = t.pbrMetallicRoughness;
340
- if (r) {
341
- if (Array.isArray(r.baseColorFactor)) {
342
- const s = r.baseColorFactor;
343
- e.color.setRGB(s[0], s[1], s[2], C), e.opacity = s[3];
344
- }
345
- r.baseColorTexture !== void 0 && n.push(o.assignTexture(e, "map", r.baseColorTexture, D));
346
- }
347
- return Promise.all(n);
348
- }
349
- }
350
- class qt {
351
- constructor(e) {
352
- this.parser = e, this.name = x.KHR_MATERIALS_EMISSIVE_STRENGTH;
353
- }
354
- extendMaterialParams(e, t) {
355
- const n = this.parser.json.materials[e];
356
- if (!n.extensions || !n.extensions[this.name])
357
- return Promise.resolve();
358
- const r = n.extensions[this.name].emissiveStrength;
359
- return r !== void 0 && (t.emissiveIntensity = r), Promise.resolve();
360
- }
361
- }
362
- class Yt {
363
- constructor(e) {
364
- this.parser = e, this.name = x.KHR_MATERIALS_CLEARCOAT;
365
- }
366
- getMaterialType(e) {
367
- const o = this.parser.json.materials[e];
368
- return !o.extensions || !o.extensions[this.name] ? null : N;
369
- }
370
- extendMaterialParams(e, t) {
371
- const o = this.parser, n = o.json.materials[e];
372
- if (!n.extensions || !n.extensions[this.name])
373
- return Promise.resolve();
374
- const r = [], s = n.extensions[this.name];
375
- if (s.clearcoatFactor !== void 0 && (t.clearcoat = s.clearcoatFactor), s.clearcoatTexture !== void 0 && r.push(o.assignTexture(t, "clearcoatMap", s.clearcoatTexture)), s.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = s.clearcoatRoughnessFactor), s.clearcoatRoughnessTexture !== void 0 && r.push(o.assignTexture(t, "clearcoatRoughnessMap", s.clearcoatRoughnessTexture)), s.clearcoatNormalTexture !== void 0 && (r.push(o.assignTexture(t, "clearcoatNormalMap", s.clearcoatNormalTexture)), s.clearcoatNormalTexture.scale !== void 0)) {
376
- const a = s.clearcoatNormalTexture.scale;
377
- t.clearcoatNormalScale = new Ne(a, a);
378
- }
379
- return Promise.all(r);
380
- }
381
- }
382
- class $t {
383
- constructor(e) {
384
- this.parser = e, this.name = x.KHR_MATERIALS_DISPERSION;
385
- }
386
- getMaterialType(e) {
387
- const o = this.parser.json.materials[e];
388
- return !o.extensions || !o.extensions[this.name] ? null : N;
389
- }
390
- extendMaterialParams(e, t) {
391
- const n = this.parser.json.materials[e];
392
- if (!n.extensions || !n.extensions[this.name])
393
- return Promise.resolve();
394
- const r = n.extensions[this.name];
395
- return t.dispersion = r.dispersion !== void 0 ? r.dispersion : 0, Promise.resolve();
396
- }
397
- }
398
- class Jt {
399
- constructor(e) {
400
- this.parser = e, this.name = x.KHR_MATERIALS_IRIDESCENCE;
401
- }
402
- getMaterialType(e) {
403
- const o = this.parser.json.materials[e];
404
- return !o.extensions || !o.extensions[this.name] ? null : N;
405
- }
406
- extendMaterialParams(e, t) {
407
- const o = this.parser, n = o.json.materials[e];
408
- if (!n.extensions || !n.extensions[this.name])
409
- return Promise.resolve();
410
- const r = [], s = n.extensions[this.name];
411
- return s.iridescenceFactor !== void 0 && (t.iridescence = s.iridescenceFactor), s.iridescenceTexture !== void 0 && r.push(o.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 && r.push(o.assignTexture(t, "iridescenceThicknessMap", s.iridescenceThicknessTexture)), Promise.all(r);
412
- }
413
- }
414
- class Qt {
415
- constructor(e) {
416
- this.parser = e, this.name = x.KHR_MATERIALS_SHEEN;
417
- }
418
- getMaterialType(e) {
419
- const o = this.parser.json.materials[e];
420
- return !o.extensions || !o.extensions[this.name] ? null : N;
421
- }
422
- extendMaterialParams(e, t) {
423
- const o = this.parser, n = o.json.materials[e];
424
- if (!n.extensions || !n.extensions[this.name])
425
- return Promise.resolve();
426
- const r = [];
427
- t.sheenColor = new v(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
428
- const s = n.extensions[this.name];
429
- if (s.sheenColorFactor !== void 0) {
430
- const a = s.sheenColorFactor;
431
- t.sheenColor.setRGB(a[0], a[1], a[2], C);
432
- }
433
- return s.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = s.sheenRoughnessFactor), s.sheenColorTexture !== void 0 && r.push(o.assignTexture(t, "sheenColorMap", s.sheenColorTexture, D)), s.sheenRoughnessTexture !== void 0 && r.push(o.assignTexture(t, "sheenRoughnessMap", s.sheenRoughnessTexture)), Promise.all(r);
434
- }
435
- }
436
- class Zt {
437
- constructor(e) {
438
- this.parser = e, this.name = x.KHR_MATERIALS_TRANSMISSION;
439
- }
440
- getMaterialType(e) {
441
- const o = this.parser.json.materials[e];
442
- return !o.extensions || !o.extensions[this.name] ? null : N;
443
- }
444
- extendMaterialParams(e, t) {
445
- const o = this.parser, n = o.json.materials[e];
446
- if (!n.extensions || !n.extensions[this.name])
447
- return Promise.resolve();
448
- const r = [], s = n.extensions[this.name];
449
- return s.transmissionFactor !== void 0 && (t.transmission = s.transmissionFactor), s.transmissionTexture !== void 0 && r.push(o.assignTexture(t, "transmissionMap", s.transmissionTexture)), Promise.all(r);
450
- }
451
- }
452
- class en {
453
- constructor(e) {
454
- this.parser = e, this.name = x.KHR_MATERIALS_VOLUME;
455
- }
456
- getMaterialType(e) {
457
- const o = this.parser.json.materials[e];
458
- return !o.extensions || !o.extensions[this.name] ? null : N;
459
- }
460
- extendMaterialParams(e, t) {
461
- const o = this.parser, n = o.json.materials[e];
462
- if (!n.extensions || !n.extensions[this.name])
463
- return Promise.resolve();
464
- const r = [], s = n.extensions[this.name];
465
- t.thickness = s.thicknessFactor !== void 0 ? s.thicknessFactor : 0, s.thicknessTexture !== void 0 && r.push(o.assignTexture(t, "thicknessMap", s.thicknessTexture)), t.attenuationDistance = s.attenuationDistance || 1 / 0;
466
- const a = s.attenuationColor || [1, 1, 1];
467
- return t.attenuationColor = new v().setRGB(a[0], a[1], a[2], C), Promise.all(r);
468
- }
469
- }
470
- class tn {
471
- constructor(e) {
472
- this.parser = e, this.name = x.KHR_MATERIALS_IOR;
473
- }
474
- getMaterialType(e) {
475
- const o = this.parser.json.materials[e];
476
- return !o.extensions || !o.extensions[this.name] ? null : N;
477
- }
478
- extendMaterialParams(e, t) {
479
- const n = this.parser.json.materials[e];
480
- if (!n.extensions || !n.extensions[this.name])
481
- return Promise.resolve();
482
- const r = n.extensions[this.name];
483
- return t.ior = r.ior !== void 0 ? r.ior : 1.5, Promise.resolve();
484
- }
485
- }
486
- class nn {
487
- constructor(e) {
488
- this.parser = e, this.name = x.KHR_MATERIALS_SPECULAR;
489
- }
490
- getMaterialType(e) {
491
- const o = this.parser.json.materials[e];
492
- return !o.extensions || !o.extensions[this.name] ? null : N;
493
- }
494
- extendMaterialParams(e, t) {
495
- const o = this.parser, n = o.json.materials[e];
496
- if (!n.extensions || !n.extensions[this.name])
497
- return Promise.resolve();
498
- const r = [], s = n.extensions[this.name];
499
- t.specularIntensity = s.specularFactor !== void 0 ? s.specularFactor : 1, s.specularTexture !== void 0 && r.push(o.assignTexture(t, "specularIntensityMap", s.specularTexture));
500
- const a = s.specularColorFactor || [1, 1, 1];
501
- return t.specularColor = new v().setRGB(a[0], a[1], a[2], C), s.specularColorTexture !== void 0 && r.push(o.assignTexture(t, "specularColorMap", s.specularColorTexture, D)), Promise.all(r);
502
- }
503
- }
504
- class sn {
505
- constructor(e) {
506
- this.parser = e, this.name = x.EXT_MATERIALS_BUMP;
507
- }
508
- getMaterialType(e) {
509
- const o = this.parser.json.materials[e];
510
- return !o.extensions || !o.extensions[this.name] ? null : N;
511
- }
512
- extendMaterialParams(e, t) {
513
- const o = this.parser, n = o.json.materials[e];
514
- if (!n.extensions || !n.extensions[this.name])
515
- return Promise.resolve();
516
- const r = [], s = n.extensions[this.name];
517
- return t.bumpScale = s.bumpFactor !== void 0 ? s.bumpFactor : 1, s.bumpTexture !== void 0 && r.push(o.assignTexture(t, "bumpMap", s.bumpTexture)), Promise.all(r);
518
- }
519
- }
520
- class rn {
521
- constructor(e) {
522
- this.parser = e, this.name = x.KHR_MATERIALS_ANISOTROPY;
523
- }
524
- getMaterialType(e) {
525
- const o = this.parser.json.materials[e];
526
- return !o.extensions || !o.extensions[this.name] ? null : N;
527
- }
528
- extendMaterialParams(e, t) {
529
- const o = this.parser, n = o.json.materials[e];
530
- if (!n.extensions || !n.extensions[this.name])
531
- return Promise.resolve();
532
- const r = [], s = n.extensions[this.name];
533
- return s.anisotropyStrength !== void 0 && (t.anisotropy = s.anisotropyStrength), s.anisotropyRotation !== void 0 && (t.anisotropyRotation = s.anisotropyRotation), s.anisotropyTexture !== void 0 && r.push(o.assignTexture(t, "anisotropyMap", s.anisotropyTexture)), Promise.all(r);
534
- }
535
- }
536
- class on {
537
- constructor(e) {
538
- this.parser = e, this.name = x.KHR_TEXTURE_BASISU;
539
- }
540
- loadTexture(e) {
541
- const t = this.parser, o = t.json, n = o.textures[e];
542
- if (!n.extensions || !n.extensions[this.name])
543
- return null;
544
- const r = n.extensions[this.name], s = t.options.ktx2Loader;
545
- if (!s) {
546
- if (o.extensionsRequired && o.extensionsRequired.indexOf(this.name) >= 0)
547
- throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
548
- return null;
549
- }
550
- return t.loadTextureImage(e, r.source, s);
551
- }
552
- }
553
- class an {
554
- constructor(e) {
555
- this.parser = e, this.name = x.EXT_TEXTURE_WEBP;
556
- }
557
- loadTexture(e) {
558
- const t = this.name, o = this.parser, n = o.json, r = n.textures[e];
559
- if (!r.extensions || !r.extensions[t])
560
- return null;
561
- const s = r.extensions[t], a = n.images[s.source];
562
- let i = o.textureLoader;
563
- if (a.uri) {
564
- const c = o.options.manager.getHandler(a.uri);
565
- c !== null && (i = c);
566
- }
567
- return o.loadTextureImage(e, s.source, i);
568
- }
569
- }
570
- class cn {
571
- constructor(e) {
572
- this.parser = e, this.name = x.EXT_TEXTURE_AVIF;
573
- }
574
- loadTexture(e) {
575
- const t = this.name, o = this.parser, n = o.json, r = n.textures[e];
576
- if (!r.extensions || !r.extensions[t])
577
- return null;
578
- const s = r.extensions[t], a = n.images[s.source];
579
- let i = o.textureLoader;
580
- if (a.uri) {
581
- const c = o.options.manager.getHandler(a.uri);
582
- c !== null && (i = c);
583
- }
584
- return o.loadTextureImage(e, s.source, i);
585
- }
586
- }
587
- class ln {
588
- constructor(e) {
589
- this.name = x.EXT_MESHOPT_COMPRESSION, this.parser = e;
590
- }
591
- loadBufferView(e) {
592
- const t = this.parser.json, o = t.bufferViews[e];
593
- if (o.extensions && o.extensions[this.name]) {
594
- const n = o.extensions[this.name], r = this.parser.getDependency("buffer", n.buffer), s = this.parser.options.meshoptDecoder;
595
- if (!s || !s.supported) {
596
- if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
597
- throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
598
- return null;
599
- }
600
- return r.then(function(a) {
601
- const i = n.byteOffset || 0, c = n.byteLength || 0, u = n.count, l = n.byteStride, d = new Uint8Array(a, i, c);
602
- return s.decodeGltfBufferAsync ? s.decodeGltfBufferAsync(u, l, d, n.mode, n.filter).then(function(h) {
603
- return h.buffer;
604
- }) : s.ready.then(function() {
605
- const h = new ArrayBuffer(u * l);
606
- return s.decodeGltfBuffer(new Uint8Array(h), u, l, d, n.mode, n.filter), h;
607
- });
608
- });
609
- } else
610
- return null;
611
- }
612
- }
613
- class un {
614
- constructor(e) {
615
- this.name = x.EXT_MESH_GPU_INSTANCING, this.parser = e;
616
- }
617
- createNodeMesh(e) {
618
- const t = this.parser.json, o = t.nodes[e];
619
- if (!o.extensions || !o.extensions[this.name] || o.mesh === void 0)
620
- return null;
621
- const n = t.meshes[o.mesh];
622
- for (const c of n.primitives)
623
- if (c.mode !== b.TRIANGLES && c.mode !== b.TRIANGLE_STRIP && c.mode !== b.TRIANGLE_FAN && c.mode !== void 0)
624
- return null;
625
- const s = o.extensions[this.name].attributes, a = [], i = {};
626
- for (const c in s)
627
- a.push(this.parser.getDependency("accessor", s[c]).then((u) => (i[c] = u, i[c])));
628
- return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((c) => {
629
- const u = c.pop(), l = u.isGroup ? u.children : [u], d = c[0].count, h = [];
630
- for (const m of l) {
631
- const g = new Z(), p = new B(), T = new ke(), R = new B(1, 1, 1), A = new ot(m.geometry, m.material, d);
632
- for (let _ = 0; _ < d; _++)
633
- i.TRANSLATION && p.fromBufferAttribute(i.TRANSLATION, _), i.ROTATION && T.fromBufferAttribute(i.ROTATION, _), i.SCALE && R.fromBufferAttribute(i.SCALE, _), A.setMatrixAt(_, g.compose(p, T, R));
634
- for (const _ in i)
635
- if (_ === "_COLOR_0") {
636
- const L = i[_];
637
- A.instanceColor = new it(L.array, L.itemSize, L.normalized);
638
- } else _ !== "TRANSLATION" && _ !== "ROTATION" && _ !== "SCALE" && m.geometry.setAttribute(_, i[_]);
639
- Oe.prototype.copy.call(A, m), this.parser.assignFinalMaterial(A), h.push(A);
640
- }
641
- return u.isGroup ? (u.clear(), u.add(...h), u) : h[0];
642
- }));
643
- }
644
- }
645
- const je = "glTF", z = 12, we = { JSON: 1313821514, BIN: 5130562 };
646
- class dn {
647
- constructor(e) {
648
- this.name = x.KHR_BINARY_GLTF, this.content = null, this.body = null;
649
- const t = new DataView(e, 0, z), o = new TextDecoder();
650
- if (this.header = {
651
- magic: o.decode(new Uint8Array(e.slice(0, 4))),
652
- version: t.getUint32(4, !0),
653
- length: t.getUint32(8, !0)
654
- }, this.header.magic !== je)
655
- throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
656
- if (this.header.version < 2)
657
- throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
658
- const n = this.header.length - z, r = new DataView(e, z);
659
- let s = 0;
660
- for (; s < n; ) {
661
- const a = r.getUint32(s, !0);
662
- s += 4;
663
- const i = r.getUint32(s, !0);
664
- if (s += 4, i === we.JSON) {
665
- const c = new Uint8Array(e, z + s, a);
666
- this.content = o.decode(c);
667
- } else if (i === we.BIN) {
668
- const c = z + s;
669
- this.body = e.slice(c, c + a);
670
- }
671
- s += a;
672
- }
673
- if (this.content === null)
674
- throw new Error("THREE.GLTFLoader: JSON content not found.");
675
- }
676
- }
677
- class fn {
678
- constructor(e, t) {
679
- if (!t)
680
- throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
681
- this.name = x.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
682
- }
683
- decodePrimitive(e, t) {
684
- const o = this.json, n = this.dracoLoader, r = e.extensions[this.name].bufferView, s = e.extensions[this.name].attributes, a = {}, i = {}, c = {};
685
- for (const u in s) {
686
- const l = fe[u] || u.toLowerCase();
687
- a[l] = s[u];
688
- }
689
- for (const u in e.attributes) {
690
- const l = fe[u] || u.toLowerCase();
691
- if (s[u] !== void 0) {
692
- const d = o.accessors[e.attributes[u]], h = V[d.componentType];
693
- c[l] = h.name, i[l] = d.normalized === !0;
694
- }
695
- }
696
- return t.getDependency("bufferView", r).then(function(u) {
697
- return new Promise(function(l, d) {
698
- n.decodeDracoFile(u, function(h) {
699
- for (const m in h.attributes) {
700
- const g = h.attributes[m], p = i[m];
701
- p !== void 0 && (g.normalized = p);
702
- }
703
- l(h);
704
- }, a, c, C, d);
705
- });
706
- });
707
- }
708
- }
709
- class hn {
710
- constructor() {
711
- this.name = x.KHR_TEXTURE_TRANSFORM;
712
- }
713
- extendTexture(e, t) {
714
- 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;
715
- }
716
- }
717
- class pn {
718
- constructor() {
719
- this.name = x.KHR_MESH_QUANTIZATION;
720
- }
721
- }
722
- class Be extends Ot {
723
- constructor(e, t, o, n) {
724
- super(e, t, o, n);
725
- }
726
- copySampleValue_(e) {
727
- const t = this.resultBuffer, o = this.sampleValues, n = this.valueSize, r = e * n * 3 + n;
728
- for (let s = 0; s !== n; s++)
729
- t[s] = o[r + s];
730
- return t;
731
- }
732
- interpolate_(e, t, o, n) {
733
- const r = this.resultBuffer, s = this.sampleValues, a = this.valueSize, i = a * 2, c = a * 3, u = n - t, l = (o - t) / u, d = l * l, h = d * l, m = e * c, g = m - c, p = -2 * h + 3 * d, T = h - d, R = 1 - p, A = T - d + l;
734
- for (let _ = 0; _ !== a; _++) {
735
- const L = s[g + _ + a], w = s[g + _ + i] * u, E = s[m + _ + a], k = s[m + _] * u;
736
- r[_] = R * L + A * w + p * E + T * k;
737
- }
738
- return r;
739
- }
740
- }
741
- const mn = new ke();
742
- class gn extends Be {
743
- interpolate_(e, t, o, n) {
744
- const r = super.interpolate_(e, t, o, n);
745
- return mn.fromArray(r).normalize().toArray(r), r;
746
- }
747
- }
748
- const b = {
749
- POINTS: 0,
750
- LINES: 1,
751
- LINE_LOOP: 2,
752
- LINE_STRIP: 3,
753
- TRIANGLES: 4,
754
- TRIANGLE_STRIP: 5,
755
- TRIANGLE_FAN: 6
756
- }, V = {
757
- 5120: Int8Array,
758
- 5121: Uint8Array,
759
- 5122: Int16Array,
760
- 5123: Uint16Array,
761
- 5125: Uint32Array,
762
- 5126: Float32Array
763
- }, be = {
764
- 9728: De,
765
- 9729: le,
766
- 9984: ft,
767
- 9985: dt,
768
- 9986: ut,
769
- 9987: Pe
770
- }, Me = {
771
- 33071: pt,
772
- 33648: ht,
773
- 10497: ue
774
- }, re = {
775
- SCALAR: 1,
776
- VEC2: 2,
777
- VEC3: 3,
778
- VEC4: 4,
779
- MAT2: 4,
780
- MAT3: 9,
781
- MAT4: 16
782
- }, fe = {
783
- POSITION: "position",
784
- NORMAL: "normal",
785
- TANGENT: "tangent",
786
- TEXCOORD_0: "uv",
787
- TEXCOORD_1: "uv1",
788
- TEXCOORD_2: "uv2",
789
- TEXCOORD_3: "uv3",
790
- COLOR_0: "color",
791
- WEIGHTS_0: "skinWeight",
792
- JOINTS_0: "skinIndex"
793
- }, P = {
794
- scale: "scale",
795
- translation: "position",
796
- rotation: "quaternion",
797
- weights: "morphTargetInfluences"
798
- }, Tn = {
799
- CUBICSPLINE: void 0,
800
- // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
801
- // keyframe track will be initialized with a default interpolation type, then modified.
802
- LINEAR: Ue,
803
- STEP: Ct
804
- }, oe = {
805
- OPAQUE: "OPAQUE",
806
- MASK: "MASK",
807
- BLEND: "BLEND"
808
- };
809
- function Rn(f) {
810
- return f.DefaultMaterial === void 0 && (f.DefaultMaterial = new ve({
811
- color: 16777215,
812
- emissive: 0,
813
- metalness: 1,
814
- roughness: 1,
815
- transparent: !1,
816
- depthTest: !0,
817
- side: kt
818
- })), f.DefaultMaterial;
819
- }
820
- function G(f, e, t) {
821
- for (const o in t.extensions)
822
- f[o] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[o] = t.extensions[o]);
823
- }
824
- function O(f, e) {
825
- e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(f.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
826
- }
827
- function _n(f, e, t) {
828
- let o = !1, n = !1, r = !1;
829
- for (let c = 0, u = e.length; c < u; c++) {
830
- const l = e[c];
831
- if (l.POSITION !== void 0 && (o = !0), l.NORMAL !== void 0 && (n = !0), l.COLOR_0 !== void 0 && (r = !0), o && n && r) break;
832
- }
833
- if (!o && !n && !r) return Promise.resolve(f);
834
- const s = [], a = [], i = [];
835
- for (let c = 0, u = e.length; c < u; c++) {
836
- const l = e[c];
837
- if (o) {
838
- const d = l.POSITION !== void 0 ? t.getDependency("accessor", l.POSITION) : f.attributes.position;
839
- s.push(d);
840
- }
841
- if (n) {
842
- const d = l.NORMAL !== void 0 ? t.getDependency("accessor", l.NORMAL) : f.attributes.normal;
843
- a.push(d);
844
- }
845
- if (r) {
846
- const d = l.COLOR_0 !== void 0 ? t.getDependency("accessor", l.COLOR_0) : f.attributes.color;
847
- i.push(d);
848
- }
849
- }
850
- return Promise.all([
851
- Promise.all(s),
852
- Promise.all(a),
853
- Promise.all(i)
854
- ]).then(function(c) {
855
- const u = c[0], l = c[1], d = c[2];
856
- return o && (f.morphAttributes.position = u), n && (f.morphAttributes.normal = l), r && (f.morphAttributes.color = d), f.morphTargetsRelative = !0, f;
857
- });
858
- }
859
- function xn(f, e) {
860
- if (f.updateMorphTargets(), e.weights !== void 0)
861
- for (let t = 0, o = e.weights.length; t < o; t++)
862
- f.morphTargetInfluences[t] = e.weights[t];
863
- if (e.extras && Array.isArray(e.extras.targetNames)) {
864
- const t = e.extras.targetNames;
865
- if (f.morphTargetInfluences.length === t.length) {
866
- f.morphTargetDictionary = {};
867
- for (let o = 0, n = t.length; o < n; o++)
868
- f.morphTargetDictionary[t[o]] = o;
869
- } else
870
- console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
871
- }
872
- }
873
- function An(f) {
874
- let e;
875
- const t = f.extensions && f.extensions[x.KHR_DRACO_MESH_COMPRESSION];
876
- if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + ie(t.attributes) : e = f.indices + ":" + ie(f.attributes) + ":" + f.mode, f.targets !== void 0)
877
- for (let o = 0, n = f.targets.length; o < n; o++)
878
- e += ":" + ie(f.targets[o]);
879
- return e;
880
- }
881
- function ie(f) {
882
- let e = "";
883
- const t = Object.keys(f).sort();
884
- for (let o = 0, n = t.length; o < n; o++)
885
- e += t[o] + ":" + f[t[o]] + ";";
886
- return e;
887
- }
888
- function he(f) {
889
- switch (f) {
890
- case Int8Array:
891
- return 1 / 127;
892
- case Uint8Array:
893
- return 1 / 255;
894
- case Int16Array:
895
- return 1 / 32767;
896
- case Uint16Array:
897
- return 1 / 65535;
898
- default:
899
- throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
900
- }
901
- }
902
- function yn(f) {
903
- return f.search(/\.jpe?g($|\?)/i) > 0 || f.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : f.search(/\.webp($|\?)/i) > 0 || f.search(/^data\:image\/webp/) === 0 ? "image/webp" : f.search(/\.ktx2($|\?)/i) > 0 || f.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
904
- }
905
- const Ln = new Z();
906
- class En {
907
- constructor(e = {}, t = {}) {
908
- this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new zt(), 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 = {};
909
- let o = !1, n = -1, r = !1, s = -1;
910
- if (typeof navigator < "u") {
911
- const a = navigator.userAgent;
912
- o = /^((?!chrome|android).)*safari/i.test(a) === !0;
913
- const i = a.match(/Version\/(\d+)/);
914
- n = o && i ? parseInt(i[1], 10) : -1, r = a.indexOf("Firefox") > -1, s = r ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
915
- }
916
- typeof createImageBitmap > "u" || o && n < 17 || r && s < 98 ? this.textureLoader = new at(this.options.manager) : this.textureLoader = new ct(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Q(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
917
- }
918
- setExtensions(e) {
919
- this.extensions = e;
920
- }
921
- setPlugins(e) {
922
- this.plugins = e;
923
- }
924
- parse(e, t) {
925
- const o = this, n = this.json, r = this.extensions;
926
- this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(s) {
927
- return s._markDefs && s._markDefs();
928
- }), Promise.all(this._invokeAll(function(s) {
929
- return s.beforeRoot && s.beforeRoot();
930
- })).then(function() {
931
- return Promise.all([
932
- o.getDependencies("scene"),
933
- o.getDependencies("animation"),
934
- o.getDependencies("camera")
935
- ]);
936
- }).then(function(s) {
937
- const a = {
938
- scene: s[0][n.scene || 0],
939
- scenes: s[0],
940
- animations: s[1],
941
- cameras: s[2],
942
- asset: n.asset,
943
- parser: o,
944
- userData: {}
945
- };
946
- return G(r, a, n), O(a, n), Promise.all(o._invokeAll(function(i) {
947
- return i.afterRoot && i.afterRoot(a);
948
- })).then(function() {
949
- for (const i of a.scenes)
950
- i.updateMatrixWorld();
951
- e(a);
952
- });
953
- }).catch(t);
954
- }
955
- /**
956
- * Marks the special nodes/meshes in json for efficient parse.
957
- *
958
- * @private
959
- */
960
- _markDefs() {
961
- const e = this.json.nodes || [], t = this.json.skins || [], o = this.json.meshes || [];
962
- for (let n = 0, r = t.length; n < r; n++) {
963
- const s = t[n].joints;
964
- for (let a = 0, i = s.length; a < i; a++)
965
- e[s[a]].isBone = !0;
966
- }
967
- for (let n = 0, r = e.length; n < r; n++) {
968
- const s = e[n];
969
- s.mesh !== void 0 && (this._addNodeRef(this.meshCache, s.mesh), s.skin !== void 0 && (o[s.mesh].isSkinnedMesh = !0)), s.camera !== void 0 && this._addNodeRef(this.cameraCache, s.camera);
970
- }
971
- }
972
- /**
973
- * Counts references to shared node / Object3D resources. These resources
974
- * can be reused, or "instantiated", at multiple nodes in the scene
975
- * hierarchy. Mesh, Camera, and Light instances are instantiated and must
976
- * be marked. Non-scenegraph resources (like Materials, Geometries, and
977
- * Textures) can be reused directly and are not marked here.
978
- *
979
- * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
980
- *
981
- * @private
982
- * @param {Object} cache
983
- * @param {Object3D} index
984
- */
985
- _addNodeRef(e, t) {
986
- t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
987
- }
988
- /**
989
- * Returns a reference to a shared resource, cloning it if necessary.
990
- *
991
- * @private
992
- * @param {Object} cache
993
- * @param {number} index
994
- * @param {Object} object
995
- * @return {Object}
996
- */
997
- _getNodeRef(e, t, o) {
998
- if (e.refs[t] <= 1) return o;
999
- const n = o.clone(), r = (s, a) => {
1000
- const i = this.associations.get(s);
1001
- i != null && this.associations.set(a, i);
1002
- for (const [c, u] of s.children.entries())
1003
- r(u, a.children[c]);
1004
- };
1005
- return r(o, n), n.name += "_instance_" + e.uses[t]++, n;
1006
- }
1007
- _invokeOne(e) {
1008
- const t = Object.values(this.plugins);
1009
- t.push(this);
1010
- for (let o = 0; o < t.length; o++) {
1011
- const n = e(t[o]);
1012
- if (n) return n;
1013
- }
1014
- return null;
1015
- }
1016
- _invokeAll(e) {
1017
- const t = Object.values(this.plugins);
1018
- t.unshift(this);
1019
- const o = [];
1020
- for (let n = 0; n < t.length; n++) {
1021
- const r = e(t[n]);
1022
- r && o.push(r);
1023
- }
1024
- return o;
1025
- }
1026
- /**
1027
- * Requests the specified dependency asynchronously, with caching.
1028
- *
1029
- * @private
1030
- * @param {string} type
1031
- * @param {number} index
1032
- * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
1033
- */
1034
- getDependency(e, t) {
1035
- const o = e + ":" + t;
1036
- let n = this.cache.get(o);
1037
- if (!n) {
1038
- switch (e) {
1039
- case "scene":
1040
- n = this.loadScene(t);
1041
- break;
1042
- case "node":
1043
- n = this._invokeOne(function(r) {
1044
- return r.loadNode && r.loadNode(t);
1045
- });
1046
- break;
1047
- case "mesh":
1048
- n = this._invokeOne(function(r) {
1049
- return r.loadMesh && r.loadMesh(t);
1050
- });
1051
- break;
1052
- case "accessor":
1053
- n = this.loadAccessor(t);
1054
- break;
1055
- case "bufferView":
1056
- n = this._invokeOne(function(r) {
1057
- return r.loadBufferView && r.loadBufferView(t);
1058
- });
1059
- break;
1060
- case "buffer":
1061
- n = this.loadBuffer(t);
1062
- break;
1063
- case "material":
1064
- n = this._invokeOne(function(r) {
1065
- return r.loadMaterial && r.loadMaterial(t);
1066
- });
1067
- break;
1068
- case "texture":
1069
- n = this._invokeOne(function(r) {
1070
- return r.loadTexture && r.loadTexture(t);
1071
- });
1072
- break;
1073
- case "skin":
1074
- n = this.loadSkin(t);
1075
- break;
1076
- case "animation":
1077
- n = this._invokeOne(function(r) {
1078
- return r.loadAnimation && r.loadAnimation(t);
1079
- });
1080
- break;
1081
- case "camera":
1082
- n = this.loadCamera(t);
1083
- break;
1084
- default:
1085
- if (n = this._invokeOne(function(r) {
1086
- return r != this && r.getDependency && r.getDependency(e, t);
1087
- }), !n)
1088
- throw new Error("Unknown type: " + e);
1089
- break;
1090
- }
1091
- this.cache.add(o, n);
1092
- }
1093
- return n;
1094
- }
1095
- /**
1096
- * Requests all dependencies of the specified type asynchronously, with caching.
1097
- *
1098
- * @private
1099
- * @param {string} type
1100
- * @return {Promise<Array<Object>>}
1101
- */
1102
- getDependencies(e) {
1103
- let t = this.cache.get(e);
1104
- if (!t) {
1105
- const o = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
1106
- t = Promise.all(n.map(function(r, s) {
1107
- return o.getDependency(e, s);
1108
- })), this.cache.add(e, t);
1109
- }
1110
- return t;
1111
- }
1112
- /**
1113
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1114
- *
1115
- * @private
1116
- * @param {number} bufferIndex
1117
- * @return {Promise<ArrayBuffer>}
1118
- */
1119
- loadBuffer(e) {
1120
- const t = this.json.buffers[e], o = this.fileLoader;
1121
- if (t.type && t.type !== "arraybuffer")
1122
- throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
1123
- if (t.uri === void 0 && e === 0)
1124
- return Promise.resolve(this.extensions[x.KHR_BINARY_GLTF].body);
1125
- const n = this.options;
1126
- return new Promise(function(r, s) {
1127
- o.load(W.resolveURL(t.uri, n.path), r, void 0, function() {
1128
- s(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
1129
- });
1130
- });
1131
- }
1132
- /**
1133
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1134
- *
1135
- * @private
1136
- * @param {number} bufferViewIndex
1137
- * @return {Promise<ArrayBuffer>}
1138
- */
1139
- loadBufferView(e) {
1140
- const t = this.json.bufferViews[e];
1141
- return this.getDependency("buffer", t.buffer).then(function(o) {
1142
- const n = t.byteLength || 0, r = t.byteOffset || 0;
1143
- return o.slice(r, r + n);
1144
- });
1145
- }
1146
- /**
1147
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
1148
- *
1149
- * @private
1150
- * @param {number} accessorIndex
1151
- * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
1152
- */
1153
- loadAccessor(e) {
1154
- const t = this, o = this.json, n = this.json.accessors[e];
1155
- if (n.bufferView === void 0 && n.sparse === void 0) {
1156
- const s = re[n.type], a = V[n.componentType], i = n.normalized === !0, c = new a(n.count * s);
1157
- return Promise.resolve(new q(c, s, i));
1158
- }
1159
- const r = [];
1160
- return n.bufferView !== void 0 ? r.push(this.getDependency("bufferView", n.bufferView)) : r.push(null), n.sparse !== void 0 && (r.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(r).then(function(s) {
1161
- const a = s[0], i = re[n.type], c = V[n.componentType], u = c.BYTES_PER_ELEMENT, l = u * i, d = n.byteOffset || 0, h = n.bufferView !== void 0 ? o.bufferViews[n.bufferView].byteStride : void 0, m = n.normalized === !0;
1162
- let g, p;
1163
- if (h && h !== l) {
1164
- const T = Math.floor(d / h), R = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + T + ":" + n.count;
1165
- let A = t.cache.get(R);
1166
- A || (g = new c(a, T * h, n.count * h / u), A = new lt(g, h / u), t.cache.add(R, A)), p = new Nt(A, i, d % h / u, m);
1167
- } else
1168
- a === null ? g = new c(n.count * i) : g = new c(a, d, n.count * i), p = new q(g, i, m);
1169
- if (n.sparse !== void 0) {
1170
- const T = re.SCALAR, R = V[n.sparse.indices.componentType], A = n.sparse.indices.byteOffset || 0, _ = n.sparse.values.byteOffset || 0, L = new R(s[1], A, n.sparse.count * T), w = new c(s[2], _, n.sparse.count * i);
1171
- a !== null && (p = new q(p.array.slice(), p.itemSize, p.normalized)), p.normalized = !1;
1172
- for (let E = 0, k = L.length; E < k; E++) {
1173
- const M = L[E];
1174
- if (p.setX(M, w[E * i]), i >= 2 && p.setY(M, w[E * i + 1]), i >= 3 && p.setZ(M, w[E * i + 2]), i >= 4 && p.setW(M, w[E * i + 3]), i >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
1175
- }
1176
- p.normalized = m;
1177
- }
1178
- return p;
1179
- });
1180
- }
1181
- /**
1182
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
1183
- *
1184
- * @private
1185
- * @param {number} textureIndex
1186
- * @return {Promise<THREE.Texture|null>}
1187
- */
1188
- loadTexture(e) {
1189
- const t = this.json, o = this.options, r = t.textures[e].source, s = t.images[r];
1190
- let a = this.textureLoader;
1191
- if (s.uri) {
1192
- const i = o.manager.getHandler(s.uri);
1193
- i !== null && (a = i);
1194
- }
1195
- return this.loadTextureImage(e, r, a);
1196
- }
1197
- loadTextureImage(e, t, o) {
1198
- const n = this, r = this.json, s = r.textures[e], a = r.images[t], i = (a.uri || a.bufferView) + ":" + s.sampler;
1199
- if (this.textureCache[i])
1200
- return this.textureCache[i];
1201
- const c = this.loadImageSource(t, o).then(function(u) {
1202
- 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);
1203
- const d = (r.samplers || {})[s.sampler] || {};
1204
- return u.magFilter = be[d.magFilter] || le, u.minFilter = be[d.minFilter] || Pe, u.wrapS = Me[d.wrapS] || ue, u.wrapT = Me[d.wrapT] || ue, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== De && u.minFilter !== le, n.associations.set(u, { textures: e }), u;
1205
- }).catch(function() {
1206
- return null;
1207
- });
1208
- return this.textureCache[i] = c, c;
1209
- }
1210
- loadImageSource(e, t) {
1211
- const o = this, n = this.json, r = this.options;
1212
- if (this.sourceCache[e] !== void 0)
1213
- return this.sourceCache[e].then((l) => l.clone());
1214
- const s = n.images[e], a = self.URL || self.webkitURL;
1215
- let i = s.uri || "", c = !1;
1216
- if (s.bufferView !== void 0)
1217
- i = o.getDependency("bufferView", s.bufferView).then(function(l) {
1218
- c = !0;
1219
- const d = new Blob([l], { type: s.mimeType });
1220
- return i = a.createObjectURL(d), i;
1221
- });
1222
- else if (s.uri === void 0)
1223
- throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
1224
- const u = Promise.resolve(i).then(function(l) {
1225
- return new Promise(function(d, h) {
1226
- let m = d;
1227
- t.isImageBitmapLoader === !0 && (m = function(g) {
1228
- const p = new _e(g);
1229
- p.needsUpdate = !0, d(p);
1230
- }), t.load(W.resolveURL(l, r.path), m, void 0, h);
1231
- });
1232
- }).then(function(l) {
1233
- return c === !0 && a.revokeObjectURL(i), O(l, s), l.userData.mimeType = s.mimeType || yn(s.uri), l;
1234
- }).catch(function(l) {
1235
- throw console.error("THREE.GLTFLoader: Couldn't load texture", i), l;
1236
- });
1237
- return this.sourceCache[e] = u, u;
1238
- }
1239
- /**
1240
- * Asynchronously assigns a texture to the given material parameters.
1241
- *
1242
- * @private
1243
- * @param {Object} materialParams
1244
- * @param {string} mapName
1245
- * @param {Object} mapDef
1246
- * @param {string} [colorSpace]
1247
- * @return {Promise<Texture>}
1248
- */
1249
- assignTexture(e, t, o, n) {
1250
- const r = this;
1251
- return this.getDependency("texture", o.index).then(function(s) {
1252
- if (!s) return null;
1253
- if (o.texCoord !== void 0 && o.texCoord > 0 && (s = s.clone(), s.channel = o.texCoord), r.extensions[x.KHR_TEXTURE_TRANSFORM]) {
1254
- const a = o.extensions !== void 0 ? o.extensions[x.KHR_TEXTURE_TRANSFORM] : void 0;
1255
- if (a) {
1256
- const i = r.associations.get(s);
1257
- s = r.extensions[x.KHR_TEXTURE_TRANSFORM].extendTexture(s, a), r.associations.set(s, i);
1258
- }
1259
- }
1260
- return n !== void 0 && (s.colorSpace = n), e[t] = s, s;
1261
- });
1262
- }
1263
- /**
1264
- * Assigns final material to a Mesh, Line, or Points instance. The instance
1265
- * already has a material (generated from the glTF material options alone)
1266
- * but reuse of the same glTF material may require multiple threejs materials
1267
- * to accommodate different primitive types, defines, etc. New materials will
1268
- * be created if necessary, and reused from a cache.
1269
- *
1270
- * @private
1271
- * @param {Object3D} mesh Mesh, Line, or Points instance.
1272
- */
1273
- assignFinalMaterial(e) {
1274
- const t = e.geometry;
1275
- let o = e.material;
1276
- const n = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, s = t.attributes.normal === void 0;
1277
- if (e.isPoints) {
1278
- const a = "PointsMaterial:" + o.uuid;
1279
- let i = this.cache.get(a);
1280
- i || (i = new mt(), ne.prototype.copy.call(i, o), i.color.copy(o.color), i.map = o.map, i.sizeAttenuation = !1, this.cache.add(a, i)), o = i;
1281
- } else if (e.isLine) {
1282
- const a = "LineBasicMaterial:" + o.uuid;
1283
- let i = this.cache.get(a);
1284
- i || (i = new gt(), ne.prototype.copy.call(i, o), i.color.copy(o.color), i.map = o.map, this.cache.add(a, i)), o = i;
1285
- }
1286
- if (n || r || s) {
1287
- let a = "ClonedMaterial:" + o.uuid + ":";
1288
- n && (a += "derivative-tangents:"), r && (a += "vertex-colors:"), s && (a += "flat-shading:");
1289
- let i = this.cache.get(a);
1290
- i || (i = o.clone(), r && (i.vertexColors = !0), s && (i.flatShading = !0), n && (i.normalScale && (i.normalScale.y *= -1), i.clearcoatNormalScale && (i.clearcoatNormalScale.y *= -1)), this.cache.add(a, i), this.associations.set(i, this.associations.get(o))), o = i;
1291
- }
1292
- e.material = o;
1293
- }
1294
- getMaterialType() {
1295
- return ve;
1296
- }
1297
- /**
1298
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
1299
- *
1300
- * @private
1301
- * @param {number} materialIndex
1302
- * @return {Promise<Material>}
1303
- */
1304
- loadMaterial(e) {
1305
- const t = this, o = this.json, n = this.extensions, r = o.materials[e];
1306
- let s;
1307
- const a = {}, i = r.extensions || {}, c = [];
1308
- if (i[x.KHR_MATERIALS_UNLIT]) {
1309
- const l = n[x.KHR_MATERIALS_UNLIT];
1310
- s = l.getMaterialType(), c.push(l.extendParams(a, r, t));
1311
- } else {
1312
- const l = r.pbrMetallicRoughness || {};
1313
- if (a.color = new v(1, 1, 1), a.opacity = 1, Array.isArray(l.baseColorFactor)) {
1314
- const d = l.baseColorFactor;
1315
- a.color.setRGB(d[0], d[1], d[2], C), a.opacity = d[3];
1316
- }
1317
- l.baseColorTexture !== void 0 && c.push(t.assignTexture(a, "map", l.baseColorTexture, D)), a.metalness = l.metallicFactor !== void 0 ? l.metallicFactor : 1, a.roughness = l.roughnessFactor !== void 0 ? l.roughnessFactor : 1, l.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(a, "metalnessMap", l.metallicRoughnessTexture)), c.push(t.assignTexture(a, "roughnessMap", l.metallicRoughnessTexture))), s = this._invokeOne(function(d) {
1318
- return d.getMaterialType && d.getMaterialType(e);
1319
- }), c.push(Promise.all(this._invokeAll(function(d) {
1320
- return d.extendMaterialParams && d.extendMaterialParams(e, a);
1321
- })));
1322
- }
1323
- r.doubleSided === !0 && (a.side = Tt);
1324
- const u = r.alphaMode || oe.OPAQUE;
1325
- if (u === oe.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, u === oe.MASK && (a.alphaTest = r.alphaCutoff !== void 0 ? r.alphaCutoff : 0.5)), r.normalTexture !== void 0 && s !== X && (c.push(t.assignTexture(a, "normalMap", r.normalTexture)), a.normalScale = new Ne(1, 1), r.normalTexture.scale !== void 0)) {
1326
- const l = r.normalTexture.scale;
1327
- a.normalScale.set(l, l);
1328
- }
1329
- if (r.occlusionTexture !== void 0 && s !== X && (c.push(t.assignTexture(a, "aoMap", r.occlusionTexture)), r.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = r.occlusionTexture.strength)), r.emissiveFactor !== void 0 && s !== X) {
1330
- const l = r.emissiveFactor;
1331
- a.emissive = new v().setRGB(l[0], l[1], l[2], C);
1332
- }
1333
- return r.emissiveTexture !== void 0 && s !== X && c.push(t.assignTexture(a, "emissiveMap", r.emissiveTexture, D)), Promise.all(c).then(function() {
1334
- const l = new s(a);
1335
- return r.name && (l.name = r.name), O(l, r), t.associations.set(l, { materials: e }), r.extensions && G(n, l, r), l;
1336
- });
1337
- }
1338
- /**
1339
- * When Object3D instances are targeted by animation, they need unique names.
1340
- *
1341
- * @private
1342
- * @param {string} originalName
1343
- * @return {string}
1344
- */
1345
- createUniqueName(e) {
1346
- const t = Rt.sanitizeNodeName(e || "");
1347
- return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
1348
- }
1349
- /**
1350
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
1351
- *
1352
- * Creates BufferGeometries from primitives.
1353
- *
1354
- * @private
1355
- * @param {Array<GLTF.Primitive>} primitives
1356
- * @return {Promise<Array<BufferGeometry>>}
1357
- */
1358
- loadGeometries(e) {
1359
- const t = this, o = this.extensions, n = this.primitiveCache;
1360
- function r(a) {
1361
- return o[x.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, t).then(function(i) {
1362
- return Se(i, a, t);
1363
- });
1364
- }
1365
- const s = [];
1366
- for (let a = 0, i = e.length; a < i; a++) {
1367
- const c = e[a], u = An(c), l = n[u];
1368
- if (l)
1369
- s.push(l.promise);
1370
- else {
1371
- let d;
1372
- c.extensions && c.extensions[x.KHR_DRACO_MESH_COMPRESSION] ? d = r(c) : d = Se(new Fe(), c, t), n[u] = { primitive: c, promise: d }, s.push(d);
1373
- }
1374
- }
1375
- return Promise.all(s);
1376
- }
1377
- /**
1378
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
1379
- *
1380
- * @private
1381
- * @param {number} meshIndex
1382
- * @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
1383
- */
1384
- loadMesh(e) {
1385
- const t = this, o = this.json, n = this.extensions, r = o.meshes[e], s = r.primitives, a = [];
1386
- for (let i = 0, c = s.length; i < c; i++) {
1387
- const u = s[i].material === void 0 ? Rn(this.cache) : this.getDependency("material", s[i].material);
1388
- a.push(u);
1389
- }
1390
- return a.push(t.loadGeometries(s)), Promise.all(a).then(function(i) {
1391
- const c = i.slice(0, i.length - 1), u = i[i.length - 1], l = [];
1392
- for (let h = 0, m = u.length; h < m; h++) {
1393
- const g = u[h], p = s[h];
1394
- let T;
1395
- const R = c[h];
1396
- if (p.mode === b.TRIANGLES || p.mode === b.TRIANGLE_STRIP || p.mode === b.TRIANGLE_FAN || p.mode === void 0)
1397
- T = r.isSkinnedMesh === !0 ? new _t(g, R) : new He(g, R), T.isSkinnedMesh === !0 && T.normalizeSkinWeights(), p.mode === b.TRIANGLE_STRIP ? T.geometry = Ee(T.geometry, Ie) : p.mode === b.TRIANGLE_FAN && (T.geometry = Ee(T.geometry, ce));
1398
- else if (p.mode === b.LINES)
1399
- T = new xt(g, R);
1400
- else if (p.mode === b.LINE_STRIP)
1401
- T = new At(g, R);
1402
- else if (p.mode === b.LINE_LOOP)
1403
- T = new yt(g, R);
1404
- else if (p.mode === b.POINTS)
1405
- T = new Lt(g, R);
1406
- else
1407
- throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + p.mode);
1408
- Object.keys(T.geometry.morphAttributes).length > 0 && xn(T, r), T.name = t.createUniqueName(r.name || "mesh_" + e), O(T, r), p.extensions && G(n, T, p), t.assignFinalMaterial(T), l.push(T);
1409
- }
1410
- for (let h = 0, m = l.length; h < m; h++)
1411
- t.associations.set(l[h], {
1412
- meshes: e,
1413
- primitives: h
1414
- });
1415
- if (l.length === 1)
1416
- return r.extensions && G(n, l[0], r), l[0];
1417
- const d = new se();
1418
- r.extensions && G(n, d, r), t.associations.set(d, { meshes: e });
1419
- for (let h = 0, m = l.length; h < m; h++)
1420
- d.add(l[h]);
1421
- return d;
1422
- });
1423
- }
1424
- /**
1425
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
1426
- *
1427
- * @private
1428
- * @param {number} cameraIndex
1429
- * @return {Promise<THREE.Camera>}
1430
- */
1431
- loadCamera(e) {
1432
- let t;
1433
- const o = this.json.cameras[e], n = o[o.type];
1434
- if (!n) {
1435
- console.warn("THREE.GLTFLoader: Missing camera parameters.");
1436
- return;
1437
- }
1438
- return o.type === "perspective" ? t = new Et(wt.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : o.type === "orthographic" && (t = new bt(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), o.name && (t.name = this.createUniqueName(o.name)), O(t, o), Promise.resolve(t);
1439
- }
1440
- /**
1441
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
1442
- *
1443
- * @private
1444
- * @param {number} skinIndex
1445
- * @return {Promise<Skeleton>}
1446
- */
1447
- loadSkin(e) {
1448
- const t = this.json.skins[e], o = [];
1449
- for (let n = 0, r = t.joints.length; n < r; n++)
1450
- o.push(this._loadNodeShallow(t.joints[n]));
1451
- return t.inverseBindMatrices !== void 0 ? o.push(this.getDependency("accessor", t.inverseBindMatrices)) : o.push(null), Promise.all(o).then(function(n) {
1452
- const r = n.pop(), s = n, a = [], i = [];
1453
- for (let c = 0, u = s.length; c < u; c++) {
1454
- const l = s[c];
1455
- if (l) {
1456
- a.push(l);
1457
- const d = new Z();
1458
- r !== null && d.fromArray(r.array, c * 16), i.push(d);
1459
- } else
1460
- console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[c]);
1461
- }
1462
- return new Mt(a, i);
1463
- });
1464
- }
1465
- /**
1466
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
1467
- *
1468
- * @private
1469
- * @param {number} animationIndex
1470
- * @return {Promise<AnimationClip>}
1471
- */
1472
- loadAnimation(e) {
1473
- const t = this.json, o = this, n = t.animations[e], r = n.name ? n.name : "animation_" + e, s = [], a = [], i = [], c = [], u = [];
1474
- for (let l = 0, d = n.channels.length; l < d; l++) {
1475
- const h = n.channels[l], m = n.samplers[h.sampler], g = h.target, p = g.node, T = n.parameters !== void 0 ? n.parameters[m.input] : m.input, R = n.parameters !== void 0 ? n.parameters[m.output] : m.output;
1476
- g.node !== void 0 && (s.push(this.getDependency("node", p)), a.push(this.getDependency("accessor", T)), i.push(this.getDependency("accessor", R)), c.push(m), u.push(g));
1477
- }
1478
- return Promise.all([
1479
- Promise.all(s),
1480
- Promise.all(a),
1481
- Promise.all(i),
1482
- Promise.all(c),
1483
- Promise.all(u)
1484
- ]).then(function(l) {
1485
- const d = l[0], h = l[1], m = l[2], g = l[3], p = l[4], T = [];
1486
- for (let R = 0, A = d.length; R < A; R++) {
1487
- const _ = d[R], L = h[R], w = m[R], E = g[R], k = p[R];
1488
- if (_ === void 0) continue;
1489
- _.updateMatrix && _.updateMatrix();
1490
- const M = o._createAnimationTracks(_, L, w, E, k);
1491
- if (M)
1492
- for (let F = 0; F < M.length; F++)
1493
- T.push(M[F]);
1494
- }
1495
- return new St(r, void 0, T);
1496
- });
1497
- }
1498
- createNodeMesh(e) {
1499
- const t = this.json, o = this, n = t.nodes[e];
1500
- return n.mesh === void 0 ? null : o.getDependency("mesh", n.mesh).then(function(r) {
1501
- const s = o._getNodeRef(o.meshCache, n.mesh, r);
1502
- return n.weights !== void 0 && s.traverse(function(a) {
1503
- if (a.isMesh)
1504
- for (let i = 0, c = n.weights.length; i < c; i++)
1505
- a.morphTargetInfluences[i] = n.weights[i];
1506
- }), s;
1507
- });
1508
- }
1509
- /**
1510
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
1511
- *
1512
- * @private
1513
- * @param {number} nodeIndex
1514
- * @return {Promise<Object3D>}
1515
- */
1516
- loadNode(e) {
1517
- const t = this.json, o = this, n = t.nodes[e], r = o._loadNodeShallow(e), s = [], a = n.children || [];
1518
- for (let c = 0, u = a.length; c < u; c++)
1519
- s.push(o.getDependency("node", a[c]));
1520
- const i = n.skin === void 0 ? Promise.resolve(null) : o.getDependency("skin", n.skin);
1521
- return Promise.all([
1522
- r,
1523
- Promise.all(s),
1524
- i
1525
- ]).then(function(c) {
1526
- const u = c[0], l = c[1], d = c[2];
1527
- d !== null && u.traverse(function(h) {
1528
- h.isSkinnedMesh && h.bind(d, Ln);
1529
- });
1530
- for (let h = 0, m = l.length; h < m; h++)
1531
- u.add(l[h]);
1532
- return u;
1533
- });
1534
- }
1535
- // ._loadNodeShallow() parses a single node.
1536
- // skin and child nodes are created and added in .loadNode() (no '_' prefix).
1537
- _loadNodeShallow(e) {
1538
- const t = this.json, o = this.extensions, n = this;
1539
- if (this.nodeCache[e] !== void 0)
1540
- return this.nodeCache[e];
1541
- const r = t.nodes[e], s = r.name ? n.createUniqueName(r.name) : "", a = [], i = n._invokeOne(function(c) {
1542
- return c.createNodeMesh && c.createNodeMesh(e);
1543
- });
1544
- return i && a.push(i), r.camera !== void 0 && a.push(n.getDependency("camera", r.camera).then(function(c) {
1545
- return n._getNodeRef(n.cameraCache, r.camera, c);
1546
- })), n._invokeAll(function(c) {
1547
- return c.createNodeAttachment && c.createNodeAttachment(e);
1548
- }).forEach(function(c) {
1549
- a.push(c);
1550
- }), this.nodeCache[e] = Promise.all(a).then(function(c) {
1551
- let u;
1552
- if (r.isBone === !0 ? u = new It() : c.length > 1 ? u = new se() : c.length === 1 ? u = c[0] : u = new Oe(), u !== c[0])
1553
- for (let l = 0, d = c.length; l < d; l++)
1554
- u.add(c[l]);
1555
- if (r.name && (u.userData.name = r.name, u.name = s), O(u, r), r.extensions && G(o, u, r), r.matrix !== void 0) {
1556
- const l = new Z();
1557
- l.fromArray(r.matrix), u.applyMatrix4(l);
1558
- } else
1559
- r.translation !== void 0 && u.position.fromArray(r.translation), r.rotation !== void 0 && u.quaternion.fromArray(r.rotation), r.scale !== void 0 && u.scale.fromArray(r.scale);
1560
- if (!n.associations.has(u))
1561
- n.associations.set(u, {});
1562
- else if (r.mesh !== void 0 && n.meshCache.refs[r.mesh] > 1) {
1563
- const l = n.associations.get(u);
1564
- n.associations.set(u, { ...l });
1565
- }
1566
- return n.associations.get(u).nodes = e, u;
1567
- }), this.nodeCache[e];
1568
- }
1569
- /**
1570
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
1571
- *
1572
- * @private
1573
- * @param {number} sceneIndex
1574
- * @return {Promise<Group>}
1575
- */
1576
- loadScene(e) {
1577
- const t = this.extensions, o = this.json.scenes[e], n = this, r = new se();
1578
- o.name && (r.name = n.createUniqueName(o.name)), O(r, o), o.extensions && G(t, r, o);
1579
- const s = o.nodes || [], a = [];
1580
- for (let i = 0, c = s.length; i < c; i++)
1581
- a.push(n.getDependency("node", s[i]));
1582
- return Promise.all(a).then(function(i) {
1583
- for (let u = 0, l = i.length; u < l; u++)
1584
- r.add(i[u]);
1585
- const c = (u) => {
1586
- const l = /* @__PURE__ */ new Map();
1587
- for (const [d, h] of n.associations)
1588
- (d instanceof ne || d instanceof _e) && l.set(d, h);
1589
- return u.traverse((d) => {
1590
- const h = n.associations.get(d);
1591
- h != null && l.set(d, h);
1592
- }), l;
1593
- };
1594
- return n.associations = c(r), r;
1595
- });
1596
- }
1597
- _createAnimationTracks(e, t, o, n, r) {
1598
- const s = [], a = e.name ? e.name : e.uuid, i = [];
1599
- P[r.path] === P.weights ? e.traverse(function(d) {
1600
- d.morphTargetInfluences && i.push(d.name ? d.name : d.uuid);
1601
- }) : i.push(a);
1602
- let c;
1603
- switch (P[r.path]) {
1604
- case P.weights:
1605
- c = Ae;
1606
- break;
1607
- case P.rotation:
1608
- c = ye;
1609
- break;
1610
- case P.translation:
1611
- case P.scale:
1612
- c = xe;
1613
- break;
1614
- default:
1615
- switch (o.itemSize) {
1616
- case 1:
1617
- c = Ae;
1618
- break;
1619
- case 2:
1620
- case 3:
1621
- default:
1622
- c = xe;
1623
- break;
1624
- }
1625
- break;
1626
- }
1627
- const u = n.interpolation !== void 0 ? Tn[n.interpolation] : Ue, l = this._getArrayFromAccessor(o);
1628
- for (let d = 0, h = i.length; d < h; d++) {
1629
- const m = new c(
1630
- i[d] + "." + P[r.path],
1631
- t.array,
1632
- l,
1633
- u
1634
- );
1635
- n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(m), s.push(m);
1636
- }
1637
- return s;
1638
- }
1639
- _getArrayFromAccessor(e) {
1640
- let t = e.array;
1641
- if (e.normalized) {
1642
- const o = he(t.constructor), n = new Float32Array(t.length);
1643
- for (let r = 0, s = t.length; r < s; r++)
1644
- n[r] = t[r] * o;
1645
- t = n;
1646
- }
1647
- return t;
1648
- }
1649
- _createCubicSplineTrackInterpolant(e) {
1650
- e.createInterpolant = function(o) {
1651
- const n = this instanceof ye ? gn : Be;
1652
- return new n(this.times, this.values, this.getValueSize() / 3, o);
1653
- }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
1654
- }
1655
- }
1656
- function wn(f, e, t) {
1657
- const o = e.attributes, n = new Ge();
1658
- if (o.POSITION !== void 0) {
1659
- const a = t.json.accessors[o.POSITION], i = a.min, c = a.max;
1660
- if (i !== void 0 && c !== void 0) {
1661
- if (n.set(
1662
- new B(i[0], i[1], i[2]),
1663
- new B(c[0], c[1], c[2])
1664
- ), a.normalized) {
1665
- const u = he(V[a.componentType]);
1666
- n.min.multiplyScalar(u), n.max.multiplyScalar(u);
1667
- }
1668
- } else {
1669
- console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
1670
- return;
1671
- }
1672
- } else
1673
- return;
1674
- const r = e.targets;
1675
- if (r !== void 0) {
1676
- const a = new B(), i = new B();
1677
- for (let c = 0, u = r.length; c < u; c++) {
1678
- const l = r[c];
1679
- if (l.POSITION !== void 0) {
1680
- const d = t.json.accessors[l.POSITION], h = d.min, m = d.max;
1681
- if (h !== void 0 && m !== void 0) {
1682
- if (i.setX(Math.max(Math.abs(h[0]), Math.abs(m[0]))), i.setY(Math.max(Math.abs(h[1]), Math.abs(m[1]))), i.setZ(Math.max(Math.abs(h[2]), Math.abs(m[2]))), d.normalized) {
1683
- const g = he(V[d.componentType]);
1684
- i.multiplyScalar(g);
1685
- }
1686
- a.max(i);
1687
- } else
1688
- console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
1689
- }
1690
- }
1691
- n.expandByVector(a);
1692
- }
1693
- f.boundingBox = n;
1694
- const s = new Pt();
1695
- n.getCenter(s.center), s.radius = n.min.distanceTo(n.max) / 2, f.boundingSphere = s;
1696
- }
1697
- function Se(f, e, t) {
1698
- const o = e.attributes, n = [];
1699
- function r(s, a) {
1700
- return t.getDependency("accessor", s).then(function(i) {
1701
- f.setAttribute(a, i);
1702
- });
1703
- }
1704
- for (const s in o) {
1705
- const a = fe[s] || s.toLowerCase();
1706
- a in f.attributes || n.push(r(o[s], a));
1707
- }
1708
- if (e.indices !== void 0 && !f.index) {
1709
- const s = t.getDependency("accessor", e.indices).then(function(a) {
1710
- f.setIndex(a);
1711
- });
1712
- n.push(s);
1713
- }
1714
- return de.workingColorSpace !== C && "COLOR_0" in o && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${de.workingColorSpace}" not supported.`), O(f, e), wn(f, e, t), Promise.all(n).then(function() {
1715
- return e.targets !== void 0 ? _n(f, e.targets, t) : f;
1716
- });
1717
- }
1718
- const ae = /* @__PURE__ */ new WeakMap();
1719
- class bn extends Ce {
1720
- /**
1721
- * Constructs a new Draco loader.
1722
- *
1723
- * @param {LoadingManager} [manager] - The loading manager.
1724
- */
1725
- constructor(e) {
1726
- super(e), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
1727
- position: "POSITION",
1728
- normal: "NORMAL",
1729
- color: "COLOR",
1730
- uv: "TEX_COORD"
1731
- }, this.defaultAttributeTypes = {
1732
- position: "Float32Array",
1733
- normal: "Float32Array",
1734
- color: "Float32Array",
1735
- uv: "Float32Array"
1736
- };
1737
- }
1738
- /**
1739
- * Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
1740
- *
1741
- * @param {string} path - The decoder path.
1742
- * @return {DRACOLoader} A reference to this loader.
1743
- */
1744
- setDecoderPath(e) {
1745
- return this.decoderPath = e, this;
1746
- }
1747
- /**
1748
- * Provides configuration for the decoder libraries. Configuration cannot be changed after decoding begins.
1749
- *
1750
- * @param {{type:('js'|'wasm')}} config - The decoder config.
1751
- * @return {DRACOLoader} A reference to this loader.
1752
- */
1753
- setDecoderConfig(e) {
1754
- return this.decoderConfig = e, this;
1755
- }
1756
- /**
1757
- * Sets the maximum number of Web Workers to be used during decoding.
1758
- * A lower limit may be preferable if workers are also for other tasks in the application.
1759
- *
1760
- * @param {number} workerLimit - The worker limit.
1761
- * @return {DRACOLoader} A reference to this loader.
1762
- */
1763
- setWorkerLimit(e) {
1764
- return this.workerLimit = e, this;
1765
- }
1766
- /**
1767
- * Starts loading from the given URL and passes the loaded Draco asset
1768
- * to the `onLoad()` callback.
1769
- *
1770
- * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
1771
- * @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished.
1772
- * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
1773
- * @param {onErrorCallback} onError - Executed when errors occur.
1774
- */
1775
- load(e, t, o, n) {
1776
- const r = new Q(this.manager);
1777
- r.setPath(this.path), r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials), r.load(e, (s) => {
1778
- this.parse(s, t, n);
1779
- }, o, n);
1780
- }
1781
- /**
1782
- * Parses the given Draco data.
1783
- *
1784
- * @param {ArrayBuffer} buffer - The raw Draco data as an array buffer.
1785
- * @param {function(BufferGeometry)} onLoad - Executed when the loading/parsing process has been finished.
1786
- * @param {onErrorCallback} onError - Executed when errors occur.
1787
- */
1788
- parse(e, t, o = () => {
1789
- }) {
1790
- this.decodeDracoFile(e, t, null, null, D, o).catch(o);
1791
- }
1792
- //
1793
- decodeDracoFile(e, t, o, n, r = C, s = () => {
1794
- }) {
1795
- const a = {
1796
- attributeIDs: o || this.defaultAttributeIDs,
1797
- attributeTypes: n || this.defaultAttributeTypes,
1798
- useUniqueIDs: !!o,
1799
- vertexColorSpace: r
1800
- };
1801
- return this.decodeGeometry(e, a).then(t).catch(s);
1802
- }
1803
- decodeGeometry(e, t) {
1804
- const o = JSON.stringify(t);
1805
- if (ae.has(e)) {
1806
- const i = ae.get(e);
1807
- if (i.key === o)
1808
- return i.promise;
1809
- if (e.byteLength === 0)
1810
- throw new Error(
1811
- "THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred."
1812
- );
1813
- }
1814
- let n;
1815
- const r = this.workerNextTaskID++, s = e.byteLength, a = this._getWorker(r, s).then((i) => (n = i, new Promise((c, u) => {
1816
- n._callbacks[r] = { resolve: c, reject: u }, n.postMessage({ type: "decode", id: r, taskConfig: t, buffer: e }, [e]);
1817
- }))).then((i) => this._createGeometry(i.geometry));
1818
- return a.catch(() => !0).then(() => {
1819
- n && r && this._releaseTask(n, r);
1820
- }), ae.set(e, {
1821
- key: o,
1822
- promise: a
1823
- }), a;
1824
- }
1825
- _createGeometry(e) {
1826
- const t = new Fe();
1827
- e.index && t.setIndex(new q(e.index.array, 1));
1828
- for (let o = 0; o < e.attributes.length; o++) {
1829
- const n = e.attributes[o], r = n.name, s = n.array, a = n.itemSize, i = new q(s, a);
1830
- r === "color" && (this._assignVertexColorSpace(i, n.vertexColorSpace), i.normalized = !(s instanceof Float32Array)), t.setAttribute(r, i);
1831
- }
1832
- return t;
1833
- }
1834
- _assignVertexColorSpace(e, t) {
1835
- if (t !== D) return;
1836
- const o = new v();
1837
- for (let n = 0, r = e.count; n < r; n++)
1838
- o.fromBufferAttribute(e, n), de.colorSpaceToWorking(o, D), e.setXYZ(n, o.r, o.g, o.b);
1839
- }
1840
- _loadLibrary(e, t) {
1841
- const o = new Q(this.manager);
1842
- return o.setPath(this.decoderPath), o.setResponseType(t), o.setWithCredentials(this.withCredentials), new Promise((n, r) => {
1843
- o.load(e, n, void 0, r);
1844
- });
1845
- }
1846
- preload() {
1847
- return this._initDecoder(), this;
1848
- }
1849
- _initDecoder() {
1850
- if (this.decoderPending) return this.decoderPending;
1851
- const e = typeof WebAssembly != "object" || this.decoderConfig.type === "js", t = [];
1852
- 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((o) => {
1853
- const n = o[0];
1854
- e || (this.decoderConfig.wasmBinary = o[1]);
1855
- const r = Mn.toString(), s = [
1856
- "/* draco decoder */",
1857
- n,
1858
- "",
1859
- "/* worker */",
1860
- r.substring(r.indexOf("{") + 1, r.lastIndexOf("}"))
1861
- ].join(`
1862
- `);
1863
- this.workerSourceURL = URL.createObjectURL(new Blob([s]));
1864
- }), this.decoderPending;
1865
- }
1866
- _getWorker(e, t) {
1867
- return this._initDecoder().then(() => {
1868
- if (this.workerPool.length < this.workerLimit) {
1869
- const n = new Worker(this.workerSourceURL);
1870
- n._callbacks = {}, n._taskCosts = {}, n._taskLoad = 0, n.postMessage({ type: "init", decoderConfig: this.decoderConfig }), n.onmessage = function(r) {
1871
- const s = r.data;
1872
- switch (s.type) {
1873
- case "decode":
1874
- n._callbacks[s.id].resolve(s);
1875
- break;
1876
- case "error":
1877
- n._callbacks[s.id].reject(s);
1878
- break;
1879
- default:
1880
- console.error('THREE.DRACOLoader: Unexpected message, "' + s.type + '"');
1881
- }
1882
- }, this.workerPool.push(n);
1883
- } else
1884
- this.workerPool.sort(function(n, r) {
1885
- return n._taskLoad > r._taskLoad ? -1 : 1;
1886
- });
1887
- const o = this.workerPool[this.workerPool.length - 1];
1888
- return o._taskCosts[e] = t, o._taskLoad += t, o;
1889
- });
1890
- }
1891
- _releaseTask(e, t) {
1892
- e._taskLoad -= e._taskCosts[t], delete e._callbacks[t], delete e._taskCosts[t];
1893
- }
1894
- debug() {
1895
- console.log("Task load: ", this.workerPool.map((e) => e._taskLoad));
1896
- }
1897
- dispose() {
1898
- for (let e = 0; e < this.workerPool.length; ++e)
1899
- this.workerPool[e].terminate();
1900
- return this.workerPool.length = 0, this.workerSourceURL !== "" && URL.revokeObjectURL(this.workerSourceURL), this;
1901
- }
1902
- }
1903
- function Mn() {
1904
- let f, e;
1905
- onmessage = function(s) {
1906
- const a = s.data;
1907
- switch (a.type) {
1908
- case "init":
1909
- f = a.decoderConfig, e = new Promise(function(u) {
1910
- f.onModuleLoaded = function(l) {
1911
- u({ draco: l });
1912
- }, DracoDecoderModule(f);
1913
- });
1914
- break;
1915
- case "decode":
1916
- const i = a.buffer, c = a.taskConfig;
1917
- e.then((u) => {
1918
- const l = u.draco, d = new l.Decoder();
1919
- try {
1920
- const h = t(l, d, new Int8Array(i), c), m = h.attributes.map((g) => g.array.buffer);
1921
- h.index && m.push(h.index.array.buffer), self.postMessage({ type: "decode", id: a.id, geometry: h }, m);
1922
- } catch (h) {
1923
- console.error(h), self.postMessage({ type: "error", id: a.id, error: h.message });
1924
- } finally {
1925
- l.destroy(d);
1926
- }
1927
- });
1928
- break;
1929
- }
1930
- };
1931
- function t(s, a, i, c) {
1932
- const u = c.attributeIDs, l = c.attributeTypes;
1933
- let d, h;
1934
- const m = a.GetEncodedGeometryType(i);
1935
- if (m === s.TRIANGULAR_MESH)
1936
- d = new s.Mesh(), h = a.DecodeArrayToMesh(i, i.byteLength, d);
1937
- else if (m === s.POINT_CLOUD)
1938
- d = new s.PointCloud(), h = a.DecodeArrayToPointCloud(i, i.byteLength, d);
1939
- else
1940
- throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
1941
- if (!h.ok() || d.ptr === 0)
1942
- throw new Error("THREE.DRACOLoader: Decoding failed: " + h.error_msg());
1943
- const g = { index: null, attributes: [] };
1944
- for (const p in u) {
1945
- const T = self[l[p]];
1946
- let R, A;
1947
- if (c.useUniqueIDs)
1948
- A = u[p], R = a.GetAttributeByUniqueId(d, A);
1949
- else {
1950
- if (A = a.GetAttributeId(d, s[u[p]]), A === -1) continue;
1951
- R = a.GetAttribute(d, A);
1952
- }
1953
- const _ = n(s, a, d, p, T, R);
1954
- p === "color" && (_.vertexColorSpace = c.vertexColorSpace), g.attributes.push(_);
1955
- }
1956
- return m === s.TRIANGULAR_MESH && (g.index = o(s, a, d)), s.destroy(d), g;
1957
- }
1958
- function o(s, a, i) {
1959
- const u = i.num_faces() * 3, l = u * 4, d = s._malloc(l);
1960
- a.GetTrianglesUInt32Array(i, l, d);
1961
- const h = new Uint32Array(s.HEAPF32.buffer, d, u).slice();
1962
- return s._free(d), { array: h, itemSize: 1 };
1963
- }
1964
- function n(s, a, i, c, u, l) {
1965
- const d = l.num_components(), m = i.num_points() * d, g = m * u.BYTES_PER_ELEMENT, p = r(s, u), T = s._malloc(g);
1966
- a.GetAttributeDataArrayForAllPoints(i, l, p, g, T);
1967
- const R = new u(s.HEAPF32.buffer, T, m).slice();
1968
- return s._free(T), {
1969
- name: c,
1970
- array: R,
1971
- itemSize: d
1972
- };
1973
- }
1974
- function r(s, a) {
1975
- switch (a) {
1976
- case Float32Array:
1977
- return s.DT_FLOAT32;
1978
- case Int8Array:
1979
- return s.DT_INT8;
1980
- case Int16Array:
1981
- return s.DT_INT16;
1982
- case Int32Array:
1983
- return s.DT_INT32;
1984
- case Uint8Array:
1985
- return s.DT_UINT8;
1986
- case Uint16Array:
1987
- return s.DT_UINT16;
1988
- case Uint32Array:
1989
- return s.DT_UINT32;
1990
- }
1991
- }
1992
- }
1993
- function Sn() {
1994
- const f = K(!1), e = K(""), t = ze([]), o = K(null), n = new Gt(), r = new jt(), s = new Bt(), a = new Vt();
1995
- let i = null;
1996
- return {
1997
- isLoading: f,
1998
- loadingProgress: e,
1999
- loadedModels: t,
2000
- error: o,
2001
- loadModelsFromBlobs: async (u) => {
2002
- var m;
2003
- if (!u || u.length === 0) {
2004
- console.warn("loadModelsFromBlobs 加载的文件数组为空!");
2005
- return;
2006
- }
2007
- f.value = !0, e.value = "准备加载...", t.value = [], o.value = null;
2008
- const l = /* @__PURE__ */ new Map();
2009
- u.forEach((g) => {
2010
- g instanceof File && l.set(g.name.toLowerCase(), g);
2011
- });
2012
- const d = [], h = [];
2013
- try {
2014
- for (const g of u) {
2015
- const p = g.name || "unknown_file", T = (m = p.split(".").pop()) == null ? void 0 : m.toLowerCase();
2016
- if (T === "mtl") continue;
2017
- const R = URL.createObjectURL(g);
2018
- d.push(R);
2019
- let A = null;
2020
- const _ = (L) => {
2021
- const w = L.lengthComputable ? L.loaded / L.total * 100 : 0;
2022
- e.value = `正在加载 ${p}... ${Math.round(w)}%`;
2023
- };
2024
- switch (e.value = `正在加载 ${p}... 0%`, T) {
2025
- case "obj":
2026
- const L = p.replace(/\.obj$/i, ".mtl").toLowerCase();
2027
- if (l.has(L)) {
2028
- const F = l.get(L), Y = URL.createObjectURL(F);
2029
- d.push(Y);
2030
- const $ = await n.loadAsync(Y);
2031
- $.preload(), r.setMaterials($);
2032
- } else
2033
- r.setMaterials(null);
2034
- A = await r.loadAsync(R, _);
2035
- break;
2036
- case "stl":
2037
- const w = await s.loadAsync(R, _), E = new Dt({ color: 11184810, specular: 1118481, shininess: 200 });
2038
- A = new He(w, E);
2039
- break;
2040
- case "gltf":
2041
- A = (await a.loadAsync(R, _)).scene;
2042
- break;
2043
- case "glb":
2044
- i || (i = new bn(), i.setDecoderPath("/draco/"), i.preload()), a.setDRACOLoader(i), A = (await a.loadAsync(R, _)).scene;
2045
- break;
2046
- default:
2047
- console.warn(`不支持的文件类型: .${T}`), e.value = `不支持的文件类型: ${p}`;
2048
- continue;
2049
- }
2050
- A && (A.userData.boundingBox = new Ge().setFromObject(A), h.push(A));
2051
- }
2052
- t.value = h, e.value = "加载完成!";
2053
- } catch (g) {
2054
- throw console.error("加载模型时出错:", g), o.value = `加载失败: ${g.message || "未知错误"}`, e.value = "加载失败!", t.value = [], g;
2055
- } finally {
2056
- f.value = !1, d.forEach((g) => URL.revokeObjectURL(g));
2057
- }
2058
- }
2059
- };
2060
- }
2061
- function In(f, e = {}) {
2062
- const t = {
2063
- threeInfo: {},
2064
- modelLoader: {},
2065
- animation: {},
2066
- clipping: {}
2067
- }, o = vt(f);
2068
- t.threeInfo = o;
2069
- const { currentModels: n, getThreeJSObjects: r } = o, { useModelLoaderHook: s, useAnimationHook: a, useClippingHook: i } = e;
2070
- return s && (t.modelLoader = Sn()), a && (t.animation = Ft(r, n)), i && (t.clipping = Ht(r, n)), t;
2071
- }
2072
- const Cn = { class: "obj-viewer-container" }, Nn = { class: "buttonGroup-topLeft" }, kn = { class: "buttonGroup-left" }, On = { class: "buttonGroup-right" }, Pn = { class: "left-panel" }, Dn = { class: "panel-header" }, vn = {
2073
- key: 0,
2074
- class: "loading-overlay"
2075
- }, Fn = /* @__PURE__ */ Xe({
2076
- __name: "threePreview",
2077
- props: {
2078
- fileBlobs: { default: () => [] }
2079
- },
2080
- setup(f) {
2081
- const e = f, t = K(null), o = K(!1), n = K(""), {
2082
- threeInfo: {
2083
- currentModels: r,
2084
- resetView: s,
2085
- initThreeJS: a,
2086
- handleResize: i,
2087
- getThreeJSObjects: c,
2088
- cleanup: u,
2089
- setAndFitModels: l,
2090
- axesHelperVisible: d,
2091
- toggleAxesVisibility: h
2092
- },
2093
- modelLoader: {
2094
- isLoading: m,
2095
- loadingProgress: g,
2096
- loadedModels: p,
2097
- error: T,
2098
- loadModelsFromBlobs: R
2099
- },
2100
- animation: { isAnimating: A, toggleAnimation: _, startAnimation: L, stopAnimation: w },
2101
- clipping: {
2102
- isClipping: E,
2103
- activeClippingAxis: k,
2104
- toggleClipping: M,
2105
- updateClippingPlanes: F
2106
- }
2107
- } = In(t, {
2108
- useModelLoaderHook: !0,
2109
- useAnimationHook: !0,
2110
- useClippingHook: !0
2111
- }), Y = () => {
2112
- h();
2113
- }, $ = (y) => {
2114
- k.value = y, F();
2115
- };
2116
- ee(() => e.fileBlobs, (y) => {
2117
- y && y.length > 0 && R(y).catch((I) => {
2118
- console.error("加载错误:", I);
2119
- });
2120
- }, {
2121
- immediate: !0,
2122
- deep: !0
2123
- }), ee(p, (y) => {
2124
- y && y.length > 0 && l(y);
2125
- }), ee(T, (y) => {
2126
- y && Le.error(`模型加载失败: ${y}`);
2127
- });
2128
- const pe = (y) => {
2129
- o.value = !0, n.value = y, y === "剖面视图" && !E.value && M();
2130
- };
2131
- let J = null;
2132
- return We(async () => {
2133
- await qe();
2134
- try {
2135
- a(), t.value && (J = new ResizeObserver(i), J.observe(t.value));
2136
- } catch (y) {
2137
- console.error("Three.js 初始化失败:", y), Le.error("渲染引擎初始化失败!");
2138
- }
2139
- }), Ye(() => {
2140
- n.value = "", J && J.disconnect(), A.value && w(), u();
2141
- }), (y, I) => {
2142
- const Ke = $e("el-scrollbar");
2143
- return te(), me("div", Cn, [
2144
- S("div", {
2145
- ref_key: "threejsContainer",
2146
- ref: t,
2147
- class: "threejs-container"
2148
- }, null, 512),
2149
- S("div", Nn, [
2150
- H(j, {
2151
- name: "viewReset",
2152
- size: "24",
2153
- onClick: U(s),
2154
- title: "重置"
2155
- }, null, 8, ["onClick"]),
2156
- H(j, {
2157
- name: "fangda",
2158
- size: "24",
2159
- title: "放大"
2160
- }),
2161
- H(j, {
2162
- name: "suoxiao",
2163
- size: "24",
2164
- title: "缩小"
2165
- }),
2166
- H(j, {
2167
- name: "lookAround",
2168
- size: "24",
2169
- onClick: U(_),
2170
- title: U(A) ? "停止动画" : "动画视图"
2171
- }, null, 8, ["onClick", "title"]),
2172
- H(j, {
2173
- name: "zuobiaoxi",
2174
- size: "24",
2175
- active: U(d),
2176
- onClick: Y,
2177
- title: "显隐坐标轴"
2178
- }, null, 8, ["active"])
2179
- ]),
2180
- S("div", kn, [
2181
- Te(y.$slots, "button-left", { switchRightPanel: pe }, void 0, !0),
2182
- H(j, {
2183
- name: "clipping",
2184
- size: "24",
2185
- onClick: I[0] || (I[0] = (Ve) => pe("剖面视图")),
2186
- active: o.value && n.value === "剖面视图",
2187
- title: "剖面视图"
2188
- }, null, 8, ["active"])
2189
- ]),
2190
- S("div", On, [
2191
- Te(y.$slots, "button-right", {}, void 0, !0)
2192
- ]),
2193
- I[3] || (I[3] = S("div", { class: "buttonGroup-bottom" }, null, -1)),
2194
- Je(S("div", Pn, [
2195
- S("div", Dn, [
2196
- S("span", null, Re(n.value), 1),
2197
- S("span", {
2198
- class: "close",
2199
- onClick: I[1] || (I[1] = (Ve) => o.value = !1)
2200
- }, " X ")
2201
- ]),
2202
- H(Ke, { "max-height": "650px" }, {
2203
- default: Qe(() => [
2204
- n.value === "剖面视图" ? (te(), Ze(Ut, {
2205
- key: 0,
2206
- value: U(k),
2207
- onChange: $
2208
- }, null, 8, ["value"])) : ge("", !0)
2209
- ]),
2210
- _: 1
2211
- })
2212
- ], 512), [
2213
- [et, o.value]
2214
- ]),
2215
- U(m) ? (te(), me("div", vn, [
2216
- I[2] || (I[2] = S("div", { class: "loading-spinner" }, null, -1)),
2217
- S("p", null, Re(U(g)), 1)
2218
- ])) : ge("", !0)
2219
- ]);
2220
- };
2221
- }
2222
- }), Xn = /* @__PURE__ */ Kt(Fn, [["__scopeId", "data-v-2268e4d4"]]);
2223
- export {
2224
- Xn as default
2225
- };