@limrun/ui 0.16.0 → 0.17.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/GLTFLoader-Cami_vza.mjs +1679 -0
- package/dist/GLTFLoader-DeCLxW_q.js +1 -0
- package/dist/components/duo-button-hinge.d.ts +16 -0
- package/dist/components/duo-controls.d.ts +21 -0
- package/dist/components/duo-flat-frame.d.ts +7 -0
- package/dist/components/duo-flat-geometry.d.ts +52 -0
- package/dist/components/duo-fold-motion.d.ts +27 -0
- package/dist/components/duo-fold-renderer.d.ts +19 -0
- package/dist/components/duo-fold-timing.d.ts +1 -0
- package/dist/components/duo-frame.d.ts +16 -0
- package/dist/components/duo-hardware.d.ts +20 -0
- package/dist/components/duo-loading.d.ts +8 -0
- package/dist/components/duo-model.d.ts +19 -0
- package/dist/components/duo-screen-handoff.d.ts +4 -0
- package/dist/components/duo-view.d.ts +9 -0
- package/dist/components/remote-control.d.ts +5 -1
- package/dist/core/duo.d.ts +63 -0
- package/dist/duo-fold-renderer-BXejNHcY.mjs +257 -0
- package/dist/duo-fold-renderer-DdltAnF7.js +53 -0
- package/dist/duo-frame-Cmw4p2uN.mjs +26767 -0
- package/dist/duo-frame-iMtrvx_a.js +4059 -0
- package/dist/duo-view-BAh-w2Kz.js +1 -0
- package/dist/duo-view-D9Ae00rj.mjs +512 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +1 -1
- package/dist/remote-control-B2jZpf3c.js +1 -0
- package/dist/remote-control-DiddxS8l.mjs +2883 -0
- package/package.json +8 -2
- package/dist/demo.d.ts +0 -1
- package/dist/remote-control-BRgbD7yo.mjs +0 -2516
- package/dist/remote-control-VISrP1zI.js +0 -1
- package/index.html +0 -199
- package/src/assets/Apple_logo_white.svg +0 -4
- package/src/assets/android_boot.gif +0 -0
- package/src/assets/android_boot.webp +0 -0
- package/src/assets/iphone16pro_black.webp +0 -0
- package/src/assets/iphone16pro_black_bg.webp +0 -0
- package/src/assets/iphone16pro_black_landscape.webp +0 -0
- package/src/assets/iphone16pro_black_landscape_bg.webp +0 -0
- package/src/assets/pixel9_black.webp +0 -0
- package/src/assets/pixel9_black_landscape.webp +0 -0
- package/src/assets/pixel_tablet_landscape.webp +0 -0
- package/src/assets/pixel_tablet_portrait.webp +0 -0
- package/src/components/device-install/index.ts +0 -1
- package/src/components/inspect-overlay.css +0 -223
- package/src/components/inspect-overlay.tsx +0 -437
- package/src/components/remote-control-framed.tsx +0 -14
- package/src/components/remote-control.css +0 -131
- package/src/components/remote-control.test.ts +0 -34
- package/src/components/remote-control.tsx +0 -3853
- package/src/core/ax-fetcher.test.ts +0 -418
- package/src/core/ax-fetcher.ts +0 -387
- package/src/core/ax-tree.test.ts +0 -491
- package/src/core/ax-tree.ts +0 -416
- package/src/core/camera.test.ts +0 -155
- package/src/core/camera.ts +0 -133
- package/src/core/constants.ts +0 -344
- package/src/core/webrtc-messages.ts +0 -148
- package/src/demo.tsx +0 -269
- package/src/frame-assets.ts +0 -22
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -29
- package/src/lite.test.ts +0 -30
- package/src/lite.ts +0 -30
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -35
- package/vitest.config.ts +0 -24
|
@@ -0,0 +1,1679 @@
|
|
|
1
|
+
import { L as Ae, a as G, F as he, M as w, V as fe, C as F, b, S as U, c as Le, P as Me, D as Se, d as K, e as C, I as ye, Q as de, f as we, O as pe, T as be, g as Ne, B as V, h as Ie, i as me, N as Oe, j as Ce, k as Fe, l as Q, m as ge, R as J, n as Pe, o as ke, p as He, q as z, r as De, s as Te, t as ve, u as v, v as Ge, w as Ue, x as Ke, y as Be, z as ee, A as je, E as Ve, G as ze, H as Xe, J as X, K as qe, U as We, W as Ye, X as Qe, Y as Je, Z as Ze, _ as $e, $ as Re, a0 as en, a1 as ne, a2 as te, a3 as se, a4 as ie, a5 as re, a6 as nn, a7 as tn, a8 as sn, a9 as rn, aa as on, ab as an } from "./duo-frame-Cmw4p2uN.mjs";
|
|
2
|
+
function cn(f) {
|
|
3
|
+
const n = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), t = f.clone();
|
|
4
|
+
return Ee(f, t, function(s, i) {
|
|
5
|
+
n.set(i, s), e.set(s, i);
|
|
6
|
+
}), t.traverse(function(s) {
|
|
7
|
+
if (!s.isSkinnedMesh) return;
|
|
8
|
+
const i = s, o = n.get(s), a = o.skeleton.bones;
|
|
9
|
+
i.skeleton = o.skeleton.clone(), i.bindMatrix.copy(o.bindMatrix), i.skeleton.bones = a.map(function(r) {
|
|
10
|
+
return e.get(r);
|
|
11
|
+
}), i.bind(i.skeleton, i.bindMatrix);
|
|
12
|
+
}), t;
|
|
13
|
+
}
|
|
14
|
+
function Ee(f, n, e) {
|
|
15
|
+
e(f, n);
|
|
16
|
+
for (let t = 0; t < f.children.length; t++)
|
|
17
|
+
Ee(f.children[t], n.children[t], e);
|
|
18
|
+
}
|
|
19
|
+
class jn extends Ae {
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new glTF loader.
|
|
22
|
+
*
|
|
23
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
24
|
+
*/
|
|
25
|
+
constructor(n) {
|
|
26
|
+
super(n), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(e) {
|
|
27
|
+
return new dn(e);
|
|
28
|
+
}), this.register(function(e) {
|
|
29
|
+
return new pn(e);
|
|
30
|
+
}), this.register(function(e) {
|
|
31
|
+
return new Ln(e);
|
|
32
|
+
}), this.register(function(e) {
|
|
33
|
+
return new Mn(e);
|
|
34
|
+
}), this.register(function(e) {
|
|
35
|
+
return new Sn(e);
|
|
36
|
+
}), this.register(function(e) {
|
|
37
|
+
return new gn(e);
|
|
38
|
+
}), this.register(function(e) {
|
|
39
|
+
return new Tn(e);
|
|
40
|
+
}), this.register(function(e) {
|
|
41
|
+
return new Rn(e);
|
|
42
|
+
}), this.register(function(e) {
|
|
43
|
+
return new En(e);
|
|
44
|
+
}), this.register(function(e) {
|
|
45
|
+
return new fn(e);
|
|
46
|
+
}), this.register(function(e) {
|
|
47
|
+
return new xn(e);
|
|
48
|
+
}), this.register(function(e) {
|
|
49
|
+
return new mn(e);
|
|
50
|
+
}), this.register(function(e) {
|
|
51
|
+
return new An(e);
|
|
52
|
+
}), this.register(function(e) {
|
|
53
|
+
return new _n(e);
|
|
54
|
+
}), this.register(function(e) {
|
|
55
|
+
return new ln(e);
|
|
56
|
+
}), this.register(function(e) {
|
|
57
|
+
return new oe(e, g.EXT_MESHOPT_COMPRESSION);
|
|
58
|
+
}), this.register(function(e) {
|
|
59
|
+
return new oe(e, g.KHR_MESHOPT_COMPRESSION);
|
|
60
|
+
}), this.register(function(e) {
|
|
61
|
+
return new yn(e);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
66
|
+
* to the `onLoad()` callback.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
69
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
70
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
71
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
72
|
+
*/
|
|
73
|
+
load(n, e, t, s) {
|
|
74
|
+
const i = this;
|
|
75
|
+
let o;
|
|
76
|
+
if (this.resourcePath !== "")
|
|
77
|
+
o = this.resourcePath;
|
|
78
|
+
else if (this.path !== "") {
|
|
79
|
+
const c = G.extractUrlBase(n);
|
|
80
|
+
o = G.resolveURL(c, this.path);
|
|
81
|
+
} else
|
|
82
|
+
o = G.extractUrlBase(n);
|
|
83
|
+
this.manager.itemStart(n);
|
|
84
|
+
const a = function(c) {
|
|
85
|
+
s ? s(c) : console.error(c), i.manager.itemError(n), i.manager.itemEnd(n);
|
|
86
|
+
}, r = new he(this.manager);
|
|
87
|
+
r.setPath(this.path), r.setResponseType("arraybuffer"), r.setRequestHeader(this.requestHeader), r.setWithCredentials(this.withCredentials), r.load(n, function(c) {
|
|
88
|
+
try {
|
|
89
|
+
i.parse(c, o, function(l) {
|
|
90
|
+
e(l), i.manager.itemEnd(n);
|
|
91
|
+
}, a);
|
|
92
|
+
} catch (l) {
|
|
93
|
+
a(l);
|
|
94
|
+
}
|
|
95
|
+
}, t, a);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
99
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
100
|
+
*
|
|
101
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
102
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
103
|
+
*/
|
|
104
|
+
setDRACOLoader(n) {
|
|
105
|
+
return this.dracoLoader = n, this;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
109
|
+
* compressed textures.
|
|
110
|
+
*
|
|
111
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
112
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
113
|
+
*/
|
|
114
|
+
setKTX2Loader(n) {
|
|
115
|
+
return this.ktx2Loader = n, this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
119
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
120
|
+
*
|
|
121
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
122
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
123
|
+
*/
|
|
124
|
+
setMeshoptDecoder(n) {
|
|
125
|
+
return this.meshoptDecoder = n, this;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
129
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
130
|
+
* to the loader.
|
|
131
|
+
*
|
|
132
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
133
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
134
|
+
*/
|
|
135
|
+
register(n) {
|
|
136
|
+
return this.pluginCallbacks.indexOf(n) === -1 && this.pluginCallbacks.push(n), this;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Unregisters a plugin callback.
|
|
140
|
+
*
|
|
141
|
+
* @param {Function} callback - The callback function to unregister.
|
|
142
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
143
|
+
*/
|
|
144
|
+
unregister(n) {
|
|
145
|
+
return this.pluginCallbacks.indexOf(n) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(n), 1), this;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Parses the given glTF data and returns the resulting group.
|
|
149
|
+
*
|
|
150
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
151
|
+
* @param {string} path - The URL base path.
|
|
152
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
153
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
154
|
+
*/
|
|
155
|
+
parse(n, e, t, s) {
|
|
156
|
+
let i;
|
|
157
|
+
const o = {}, a = {}, r = new TextDecoder();
|
|
158
|
+
if (typeof n == "string")
|
|
159
|
+
i = JSON.parse(n);
|
|
160
|
+
else if (n instanceof ArrayBuffer)
|
|
161
|
+
if (r.decode(new Uint8Array(n, 0, 4)) === xe) {
|
|
162
|
+
try {
|
|
163
|
+
o[g.KHR_BINARY_GLTF] = new wn(n);
|
|
164
|
+
} catch (u) {
|
|
165
|
+
s && s(u);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
i = JSON.parse(o[g.KHR_BINARY_GLTF].content);
|
|
169
|
+
} else
|
|
170
|
+
i = JSON.parse(r.decode(n));
|
|
171
|
+
else
|
|
172
|
+
i = n;
|
|
173
|
+
if (i.asset === void 0 || i.asset.version[0] < 2) {
|
|
174
|
+
s && s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const c = new Un(i, {
|
|
178
|
+
path: e || this.resourcePath || "",
|
|
179
|
+
crossOrigin: this.crossOrigin,
|
|
180
|
+
requestHeader: this.requestHeader,
|
|
181
|
+
manager: this.manager,
|
|
182
|
+
ktx2Loader: this.ktx2Loader,
|
|
183
|
+
meshoptDecoder: this.meshoptDecoder
|
|
184
|
+
});
|
|
185
|
+
c.fileLoader.setRequestHeader(this.requestHeader);
|
|
186
|
+
for (let l = 0; l < this.pluginCallbacks.length; l++) {
|
|
187
|
+
const u = this.pluginCallbacks[l](c);
|
|
188
|
+
u.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), a[u.name] = u, o[u.name] = !0;
|
|
189
|
+
}
|
|
190
|
+
if (i.extensionsUsed)
|
|
191
|
+
for (let l = 0; l < i.extensionsUsed.length; ++l) {
|
|
192
|
+
const u = i.extensionsUsed[l], h = i.extensionsRequired || [];
|
|
193
|
+
switch (u) {
|
|
194
|
+
case g.KHR_MATERIALS_UNLIT:
|
|
195
|
+
o[u] = new hn();
|
|
196
|
+
break;
|
|
197
|
+
case g.KHR_DRACO_MESH_COMPRESSION:
|
|
198
|
+
o[u] = new bn(i, this.dracoLoader);
|
|
199
|
+
break;
|
|
200
|
+
case g.KHR_TEXTURE_TRANSFORM:
|
|
201
|
+
o[u] = new Nn();
|
|
202
|
+
break;
|
|
203
|
+
case g.KHR_MESH_QUANTIZATION:
|
|
204
|
+
o[u] = new In();
|
|
205
|
+
break;
|
|
206
|
+
default:
|
|
207
|
+
h.indexOf(u) >= 0 && a[u] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + u + '".');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
c.setExtensions(o), c.setPlugins(a), c.parse(t, s);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
214
|
+
*
|
|
215
|
+
* @async
|
|
216
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
217
|
+
* @param {string} path - The URL base path.
|
|
218
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
219
|
+
*/
|
|
220
|
+
parseAsync(n, e) {
|
|
221
|
+
const t = this;
|
|
222
|
+
return new Promise(function(s, i) {
|
|
223
|
+
t.parse(n, e, s, i);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function un() {
|
|
228
|
+
let f = {};
|
|
229
|
+
return {
|
|
230
|
+
get: function(n) {
|
|
231
|
+
return f[n];
|
|
232
|
+
},
|
|
233
|
+
add: function(n, e) {
|
|
234
|
+
f[n] = e;
|
|
235
|
+
},
|
|
236
|
+
remove: function(n) {
|
|
237
|
+
delete f[n];
|
|
238
|
+
},
|
|
239
|
+
removeAll: function() {
|
|
240
|
+
f = {};
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function A(f, n, e) {
|
|
245
|
+
const t = f.json.materials[n];
|
|
246
|
+
return t.extensions && t.extensions[e] ? t.extensions[e] : null;
|
|
247
|
+
}
|
|
248
|
+
const g = {
|
|
249
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
250
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
251
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
252
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
253
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
254
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
255
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
256
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
257
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
258
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
259
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
260
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
261
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
262
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
263
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
264
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
265
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
266
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
267
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
268
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
269
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
270
|
+
KHR_MESHOPT_COMPRESSION: "KHR_meshopt_compression",
|
|
271
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
272
|
+
};
|
|
273
|
+
class ln {
|
|
274
|
+
constructor(n) {
|
|
275
|
+
this.parser = n, this.name = g.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
|
|
276
|
+
}
|
|
277
|
+
_markDefs() {
|
|
278
|
+
const n = this.parser, e = this.parser.json.nodes || [];
|
|
279
|
+
for (let t = 0, s = e.length; t < s; t++) {
|
|
280
|
+
const i = e[t];
|
|
281
|
+
i.extensions && i.extensions[this.name] && i.extensions[this.name].light !== void 0 && n._addNodeRef(this.cache, i.extensions[this.name].light);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
_loadLight(n) {
|
|
285
|
+
const e = this.parser, t = "light:" + n;
|
|
286
|
+
let s = e.cache.get(t);
|
|
287
|
+
if (s) return s;
|
|
288
|
+
const i = e.json, r = ((i.extensions && i.extensions[this.name] || {}).lights || [])[n];
|
|
289
|
+
let c;
|
|
290
|
+
const l = new F(16777215);
|
|
291
|
+
r.color !== void 0 && l.setRGB(r.color[0], r.color[1], r.color[2], b);
|
|
292
|
+
const u = r.range !== void 0 ? r.range : 0;
|
|
293
|
+
switch (r.type) {
|
|
294
|
+
case "directional":
|
|
295
|
+
c = new Se(l), c.target.position.set(0, 0, -1), c.add(c.target);
|
|
296
|
+
break;
|
|
297
|
+
case "point":
|
|
298
|
+
c = new Me(l), c.distance = u;
|
|
299
|
+
break;
|
|
300
|
+
case "spot":
|
|
301
|
+
c = new Le(l), c.distance = u, r.spot = r.spot || {}, r.spot.innerConeAngle = r.spot.innerConeAngle !== void 0 ? r.spot.innerConeAngle : 0, r.spot.outerConeAngle = r.spot.outerConeAngle !== void 0 ? r.spot.outerConeAngle : Math.PI / 4, c.angle = r.spot.outerConeAngle, c.penumbra = 1 - r.spot.innerConeAngle / r.spot.outerConeAngle, c.target.position.set(0, 0, -1), c.add(c.target);
|
|
302
|
+
break;
|
|
303
|
+
default:
|
|
304
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + r.type);
|
|
305
|
+
}
|
|
306
|
+
return c.position.set(0, 0, 0), y(c, r), r.intensity !== void 0 && (c.intensity = r.intensity), c.name = e.createUniqueName(r.name || "light_" + n), s = Promise.resolve(c), e.cache.add(t, s), s;
|
|
307
|
+
}
|
|
308
|
+
getDependency(n, e) {
|
|
309
|
+
if (n === "light")
|
|
310
|
+
return this._loadLight(e);
|
|
311
|
+
}
|
|
312
|
+
createNodeAttachment(n) {
|
|
313
|
+
const e = this, t = this.parser, i = t.json.nodes[n], a = (i.extensions && i.extensions[this.name] || {}).light;
|
|
314
|
+
return a === void 0 ? null : this._loadLight(a).then(function(r) {
|
|
315
|
+
return t._getNodeRef(e.cache, a, r);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
class hn {
|
|
320
|
+
constructor() {
|
|
321
|
+
this.name = g.KHR_MATERIALS_UNLIT;
|
|
322
|
+
}
|
|
323
|
+
getMaterialType() {
|
|
324
|
+
return v;
|
|
325
|
+
}
|
|
326
|
+
extendParams(n, e, t) {
|
|
327
|
+
const s = [];
|
|
328
|
+
n.color = new F(1, 1, 1), n.opacity = 1;
|
|
329
|
+
const i = e.pbrMetallicRoughness;
|
|
330
|
+
if (i) {
|
|
331
|
+
if (Array.isArray(i.baseColorFactor)) {
|
|
332
|
+
const o = i.baseColorFactor;
|
|
333
|
+
n.color.setRGB(o[0], o[1], o[2], b), n.opacity = o[3];
|
|
334
|
+
}
|
|
335
|
+
i.baseColorTexture !== void 0 && s.push(t.assignTexture(n, "map", i.baseColorTexture, U));
|
|
336
|
+
}
|
|
337
|
+
return Promise.all(s);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
class fn {
|
|
341
|
+
constructor(n) {
|
|
342
|
+
this.parser = n, this.name = g.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
343
|
+
}
|
|
344
|
+
extendMaterialParams(n, e) {
|
|
345
|
+
const t = A(this.parser, n, this.name);
|
|
346
|
+
return t === null || t.emissiveStrength !== void 0 && (e.emissiveIntensity = t.emissiveStrength), Promise.resolve();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
class dn {
|
|
350
|
+
constructor(n) {
|
|
351
|
+
this.parser = n, this.name = g.KHR_MATERIALS_CLEARCOAT;
|
|
352
|
+
}
|
|
353
|
+
getMaterialType(n) {
|
|
354
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
355
|
+
}
|
|
356
|
+
extendMaterialParams(n, e) {
|
|
357
|
+
const t = A(this.parser, n, this.name);
|
|
358
|
+
if (t === null) return Promise.resolve();
|
|
359
|
+
const s = [];
|
|
360
|
+
if (t.clearcoatFactor !== void 0 && (e.clearcoat = t.clearcoatFactor), t.clearcoatTexture !== void 0 && s.push(this.parser.assignTexture(e, "clearcoatMap", t.clearcoatTexture)), t.clearcoatRoughnessFactor !== void 0 && (e.clearcoatRoughness = t.clearcoatRoughnessFactor), t.clearcoatRoughnessTexture !== void 0 && s.push(this.parser.assignTexture(e, "clearcoatRoughnessMap", t.clearcoatRoughnessTexture)), t.clearcoatNormalTexture !== void 0 && (s.push(this.parser.assignTexture(e, "clearcoatNormalMap", t.clearcoatNormalTexture)), t.clearcoatNormalTexture.scale !== void 0)) {
|
|
361
|
+
const i = t.clearcoatNormalTexture.scale;
|
|
362
|
+
e.clearcoatNormalScale = new fe(i, i);
|
|
363
|
+
}
|
|
364
|
+
return Promise.all(s);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
class pn {
|
|
368
|
+
constructor(n) {
|
|
369
|
+
this.parser = n, this.name = g.KHR_MATERIALS_DISPERSION;
|
|
370
|
+
}
|
|
371
|
+
getMaterialType(n) {
|
|
372
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
373
|
+
}
|
|
374
|
+
extendMaterialParams(n, e) {
|
|
375
|
+
const t = A(this.parser, n, this.name);
|
|
376
|
+
return t === null || (e.dispersion = t.dispersion !== void 0 ? t.dispersion : 0), Promise.resolve();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
class mn {
|
|
380
|
+
constructor(n) {
|
|
381
|
+
this.parser = n, this.name = g.KHR_MATERIALS_IRIDESCENCE;
|
|
382
|
+
}
|
|
383
|
+
getMaterialType(n) {
|
|
384
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
385
|
+
}
|
|
386
|
+
extendMaterialParams(n, e) {
|
|
387
|
+
const t = A(this.parser, n, this.name);
|
|
388
|
+
if (t === null) return Promise.resolve();
|
|
389
|
+
const s = [];
|
|
390
|
+
return t.iridescenceFactor !== void 0 && (e.iridescence = t.iridescenceFactor), t.iridescenceTexture !== void 0 && s.push(this.parser.assignTexture(e, "iridescenceMap", t.iridescenceTexture)), t.iridescenceIor !== void 0 && (e.iridescenceIOR = t.iridescenceIor), e.iridescenceThicknessRange === void 0 && (e.iridescenceThicknessRange = [100, 400]), t.iridescenceThicknessMinimum !== void 0 && (e.iridescenceThicknessRange[0] = t.iridescenceThicknessMinimum), t.iridescenceThicknessMaximum !== void 0 && (e.iridescenceThicknessRange[1] = t.iridescenceThicknessMaximum), t.iridescenceThicknessTexture !== void 0 && s.push(this.parser.assignTexture(e, "iridescenceThicknessMap", t.iridescenceThicknessTexture)), Promise.all(s);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
class gn {
|
|
394
|
+
constructor(n) {
|
|
395
|
+
this.parser = n, this.name = g.KHR_MATERIALS_SHEEN;
|
|
396
|
+
}
|
|
397
|
+
getMaterialType(n) {
|
|
398
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
399
|
+
}
|
|
400
|
+
extendMaterialParams(n, e) {
|
|
401
|
+
const t = A(this.parser, n, this.name);
|
|
402
|
+
if (t === null) return Promise.resolve();
|
|
403
|
+
const s = [];
|
|
404
|
+
if (e.sheenColor = new F(0, 0, 0), e.sheenRoughness = 0, e.sheen = 1, t.sheenColorFactor !== void 0) {
|
|
405
|
+
const i = t.sheenColorFactor;
|
|
406
|
+
e.sheenColor.setRGB(i[0], i[1], i[2], b);
|
|
407
|
+
}
|
|
408
|
+
return t.sheenRoughnessFactor !== void 0 && (e.sheenRoughness = t.sheenRoughnessFactor), t.sheenColorTexture !== void 0 && s.push(this.parser.assignTexture(e, "sheenColorMap", t.sheenColorTexture, U)), t.sheenRoughnessTexture !== void 0 && s.push(this.parser.assignTexture(e, "sheenRoughnessMap", t.sheenRoughnessTexture)), Promise.all(s);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
class Tn {
|
|
412
|
+
constructor(n) {
|
|
413
|
+
this.parser = n, this.name = g.KHR_MATERIALS_TRANSMISSION;
|
|
414
|
+
}
|
|
415
|
+
getMaterialType(n) {
|
|
416
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
417
|
+
}
|
|
418
|
+
extendMaterialParams(n, e) {
|
|
419
|
+
const t = A(this.parser, n, this.name);
|
|
420
|
+
if (t === null) return Promise.resolve();
|
|
421
|
+
const s = [];
|
|
422
|
+
return t.transmissionFactor !== void 0 && (e.transmission = t.transmissionFactor), t.transmissionTexture !== void 0 && s.push(this.parser.assignTexture(e, "transmissionMap", t.transmissionTexture)), Promise.all(s);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
class Rn {
|
|
426
|
+
constructor(n) {
|
|
427
|
+
this.parser = n, this.name = g.KHR_MATERIALS_VOLUME;
|
|
428
|
+
}
|
|
429
|
+
getMaterialType(n) {
|
|
430
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
431
|
+
}
|
|
432
|
+
extendMaterialParams(n, e) {
|
|
433
|
+
const t = A(this.parser, n, this.name);
|
|
434
|
+
if (t === null) return Promise.resolve();
|
|
435
|
+
const s = [];
|
|
436
|
+
e.thickness = t.thicknessFactor !== void 0 ? t.thicknessFactor : 0, t.thicknessTexture !== void 0 && s.push(this.parser.assignTexture(e, "thicknessMap", t.thicknessTexture)), e.attenuationDistance = t.attenuationDistance || 1 / 0;
|
|
437
|
+
const i = t.attenuationColor || [1, 1, 1];
|
|
438
|
+
return e.attenuationColor = new F().setRGB(i[0], i[1], i[2], b), Promise.all(s);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
class En {
|
|
442
|
+
constructor(n) {
|
|
443
|
+
this.parser = n, this.name = g.KHR_MATERIALS_IOR;
|
|
444
|
+
}
|
|
445
|
+
getMaterialType(n) {
|
|
446
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
447
|
+
}
|
|
448
|
+
extendMaterialParams(n, e) {
|
|
449
|
+
const t = A(this.parser, n, this.name);
|
|
450
|
+
return t === null || (e.ior = t.ior !== void 0 ? t.ior : 1.5), Promise.resolve();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
class xn {
|
|
454
|
+
constructor(n) {
|
|
455
|
+
this.parser = n, this.name = g.KHR_MATERIALS_SPECULAR;
|
|
456
|
+
}
|
|
457
|
+
getMaterialType(n) {
|
|
458
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
459
|
+
}
|
|
460
|
+
extendMaterialParams(n, e) {
|
|
461
|
+
const t = A(this.parser, n, this.name);
|
|
462
|
+
if (t === null) return Promise.resolve();
|
|
463
|
+
const s = [];
|
|
464
|
+
e.specularIntensity = t.specularFactor !== void 0 ? t.specularFactor : 1, t.specularTexture !== void 0 && s.push(this.parser.assignTexture(e, "specularIntensityMap", t.specularTexture));
|
|
465
|
+
const i = t.specularColorFactor || [1, 1, 1];
|
|
466
|
+
return e.specularColor = new F().setRGB(i[0], i[1], i[2], b), t.specularColorTexture !== void 0 && s.push(this.parser.assignTexture(e, "specularColorMap", t.specularColorTexture, U)), Promise.all(s);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
class _n {
|
|
470
|
+
constructor(n) {
|
|
471
|
+
this.parser = n, this.name = g.EXT_MATERIALS_BUMP;
|
|
472
|
+
}
|
|
473
|
+
getMaterialType(n) {
|
|
474
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
475
|
+
}
|
|
476
|
+
extendMaterialParams(n, e) {
|
|
477
|
+
const t = A(this.parser, n, this.name);
|
|
478
|
+
if (t === null) return Promise.resolve();
|
|
479
|
+
const s = [];
|
|
480
|
+
return e.bumpScale = t.bumpFactor !== void 0 ? t.bumpFactor : 1, t.bumpTexture !== void 0 && s.push(this.parser.assignTexture(e, "bumpMap", t.bumpTexture)), Promise.all(s);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
class An {
|
|
484
|
+
constructor(n) {
|
|
485
|
+
this.parser = n, this.name = g.KHR_MATERIALS_ANISOTROPY;
|
|
486
|
+
}
|
|
487
|
+
getMaterialType(n) {
|
|
488
|
+
return A(this.parser, n, this.name) !== null ? w : null;
|
|
489
|
+
}
|
|
490
|
+
extendMaterialParams(n, e) {
|
|
491
|
+
const t = A(this.parser, n, this.name);
|
|
492
|
+
if (t === null) return Promise.resolve();
|
|
493
|
+
const s = [];
|
|
494
|
+
return t.anisotropyStrength !== void 0 && (e.anisotropy = t.anisotropyStrength), t.anisotropyRotation !== void 0 && (e.anisotropyRotation = t.anisotropyRotation), t.anisotropyTexture !== void 0 && s.push(this.parser.assignTexture(e, "anisotropyMap", t.anisotropyTexture)), Promise.all(s);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
class Ln {
|
|
498
|
+
constructor(n) {
|
|
499
|
+
this.parser = n, this.name = g.KHR_TEXTURE_BASISU;
|
|
500
|
+
}
|
|
501
|
+
loadTexture(n) {
|
|
502
|
+
const e = this.parser, t = e.json, s = t.textures[n];
|
|
503
|
+
if (!s.extensions || !s.extensions[this.name])
|
|
504
|
+
return null;
|
|
505
|
+
const i = s.extensions[this.name], o = e.options.ktx2Loader;
|
|
506
|
+
if (!o) {
|
|
507
|
+
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
|
|
508
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
return e.loadTextureImage(n, i.source, o);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
class Mn {
|
|
515
|
+
constructor(n) {
|
|
516
|
+
this.parser = n, this.name = g.EXT_TEXTURE_WEBP;
|
|
517
|
+
}
|
|
518
|
+
loadTexture(n) {
|
|
519
|
+
const e = this.name, t = this.parser, s = t.json, i = s.textures[n];
|
|
520
|
+
if (!i.extensions || !i.extensions[e])
|
|
521
|
+
return null;
|
|
522
|
+
const o = i.extensions[e], a = s.images[o.source];
|
|
523
|
+
let r = t.textureLoader;
|
|
524
|
+
if (a.uri) {
|
|
525
|
+
const c = t.options.manager.getHandler(a.uri);
|
|
526
|
+
c !== null && (r = c);
|
|
527
|
+
}
|
|
528
|
+
return t.loadTextureImage(n, o.source, r);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
class Sn {
|
|
532
|
+
constructor(n) {
|
|
533
|
+
this.parser = n, this.name = g.EXT_TEXTURE_AVIF;
|
|
534
|
+
}
|
|
535
|
+
loadTexture(n) {
|
|
536
|
+
const e = this.name, t = this.parser, s = t.json, i = s.textures[n];
|
|
537
|
+
if (!i.extensions || !i.extensions[e])
|
|
538
|
+
return null;
|
|
539
|
+
const o = i.extensions[e], a = s.images[o.source];
|
|
540
|
+
let r = t.textureLoader;
|
|
541
|
+
if (a.uri) {
|
|
542
|
+
const c = t.options.manager.getHandler(a.uri);
|
|
543
|
+
c !== null && (r = c);
|
|
544
|
+
}
|
|
545
|
+
return t.loadTextureImage(n, o.source, r);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
class oe {
|
|
549
|
+
constructor(n, e) {
|
|
550
|
+
this.name = e, this.parser = n;
|
|
551
|
+
}
|
|
552
|
+
loadBufferView(n) {
|
|
553
|
+
const e = this.parser.json, t = e.bufferViews[n];
|
|
554
|
+
if (t.extensions && t.extensions[this.name]) {
|
|
555
|
+
const s = t.extensions[this.name], i = this.parser.getDependency("buffer", s.buffer), o = this.parser.options.meshoptDecoder;
|
|
556
|
+
if (!o || !o.supported) {
|
|
557
|
+
if (e.extensionsRequired && e.extensionsRequired.indexOf(this.name) >= 0)
|
|
558
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
return i.then(function(a) {
|
|
562
|
+
const r = s.byteOffset || 0, c = s.byteLength || 0, l = s.count, u = s.byteStride, h = new Uint8Array(a, r, c);
|
|
563
|
+
return o.decodeGltfBufferAsync ? o.decodeGltfBufferAsync(l, u, h, s.mode, s.filter).then(function(d) {
|
|
564
|
+
return d.buffer;
|
|
565
|
+
}) : o.ready.then(function() {
|
|
566
|
+
const d = new ArrayBuffer(l * u);
|
|
567
|
+
return o.decodeGltfBuffer(new Uint8Array(d), l, u, h, s.mode, s.filter), d;
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
} else
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
class yn {
|
|
575
|
+
constructor(n) {
|
|
576
|
+
this.name = g.EXT_MESH_GPU_INSTANCING, this.parser = n;
|
|
577
|
+
}
|
|
578
|
+
createNodeMesh(n) {
|
|
579
|
+
const e = this.parser.json, t = e.nodes[n];
|
|
580
|
+
if (!t.extensions || !t.extensions[this.name] || t.mesh === void 0)
|
|
581
|
+
return null;
|
|
582
|
+
const s = e.meshes[t.mesh];
|
|
583
|
+
for (const c of s.primitives)
|
|
584
|
+
if (c.mode !== M.TRIANGLES && c.mode !== M.TRIANGLE_STRIP && c.mode !== M.TRIANGLE_FAN && c.mode !== void 0)
|
|
585
|
+
return null;
|
|
586
|
+
const o = t.extensions[this.name].attributes, a = [], r = {};
|
|
587
|
+
for (const c in o)
|
|
588
|
+
a.push(this.parser.getDependency("accessor", o[c]).then((l) => (r[c] = l, r[c])));
|
|
589
|
+
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(n)), Promise.all(a).then((c) => {
|
|
590
|
+
const l = c.pop(), u = l.isGroup ? l.children : [l], h = c[0].count, d = [];
|
|
591
|
+
for (const p of u) {
|
|
592
|
+
const R = new K(), m = new C(), T = new de(), _ = new C(1, 1, 1), x = new ye(p.geometry, p.material, h);
|
|
593
|
+
for (let E = 0; E < h; E++)
|
|
594
|
+
r.TRANSLATION && m.fromBufferAttribute(r.TRANSLATION, E), r.ROTATION && T.fromBufferAttribute(r.ROTATION, E), r.SCALE && _.fromBufferAttribute(r.SCALE, E), x.setMatrixAt(E, R.compose(m, T, _));
|
|
595
|
+
for (const E in r)
|
|
596
|
+
if (E === "_COLOR_0") {
|
|
597
|
+
const L = r[E];
|
|
598
|
+
x.instanceColor = new we(L.array, L.itemSize, L.normalized);
|
|
599
|
+
} else E !== "TRANSLATION" && E !== "ROTATION" && E !== "SCALE" && p.geometry.setAttribute(E, r[E]);
|
|
600
|
+
pe.prototype.copy.call(x, p), this.parser.assignFinalMaterial(x), d.push(x);
|
|
601
|
+
}
|
|
602
|
+
return l.isGroup ? (l.clear(), l.add(...d), l) : d[0];
|
|
603
|
+
}));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
const xe = "glTF", D = 12, ae = { JSON: 1313821514, BIN: 5130562 };
|
|
607
|
+
class wn {
|
|
608
|
+
constructor(n) {
|
|
609
|
+
this.name = g.KHR_BINARY_GLTF, this.content = null, this.body = null;
|
|
610
|
+
const e = new DataView(n, 0, D), t = new TextDecoder();
|
|
611
|
+
if (this.header = {
|
|
612
|
+
magic: t.decode(new Uint8Array(n.slice(0, 4))),
|
|
613
|
+
version: e.getUint32(4, !0),
|
|
614
|
+
length: e.getUint32(8, !0)
|
|
615
|
+
}, this.header.magic !== xe)
|
|
616
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
617
|
+
if (this.header.version < 2)
|
|
618
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
619
|
+
const s = this.header.length - D, i = new DataView(n, D);
|
|
620
|
+
let o = 0;
|
|
621
|
+
for (; o < s; ) {
|
|
622
|
+
const a = i.getUint32(o, !0);
|
|
623
|
+
o += 4;
|
|
624
|
+
const r = i.getUint32(o, !0);
|
|
625
|
+
if (o += 4, r === ae.JSON) {
|
|
626
|
+
const c = new Uint8Array(n, D + o, a);
|
|
627
|
+
this.content = t.decode(c);
|
|
628
|
+
} else if (r === ae.BIN) {
|
|
629
|
+
const c = D + o;
|
|
630
|
+
this.body = n.slice(c, c + a);
|
|
631
|
+
}
|
|
632
|
+
o += a;
|
|
633
|
+
}
|
|
634
|
+
if (this.content === null)
|
|
635
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
class bn {
|
|
639
|
+
constructor(n, e) {
|
|
640
|
+
if (!e)
|
|
641
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
642
|
+
this.name = g.KHR_DRACO_MESH_COMPRESSION, this.json = n, this.dracoLoader = e, this.dracoLoader.preload();
|
|
643
|
+
}
|
|
644
|
+
decodePrimitive(n, e) {
|
|
645
|
+
const t = this.json, s = this.dracoLoader, i = n.extensions[this.name].bufferView, o = n.extensions[this.name].attributes, a = {}, r = {}, c = {};
|
|
646
|
+
for (const l in o) {
|
|
647
|
+
const u = Z[l] || l.toLowerCase();
|
|
648
|
+
a[u] = o[l];
|
|
649
|
+
}
|
|
650
|
+
for (const l in n.attributes) {
|
|
651
|
+
const u = Z[l] || l.toLowerCase();
|
|
652
|
+
if (o[l] !== void 0) {
|
|
653
|
+
const h = t.accessors[n.attributes[l]], d = k[h.componentType];
|
|
654
|
+
c[u] = d.name, r[u] = h.normalized === !0;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return e.getDependency("bufferView", i).then(function(l) {
|
|
658
|
+
return new Promise(function(u, h) {
|
|
659
|
+
s.decodeDracoFile(l, function(d) {
|
|
660
|
+
for (const p in d.attributes) {
|
|
661
|
+
const R = d.attributes[p], m = r[p];
|
|
662
|
+
m !== void 0 && (R.normalized = m);
|
|
663
|
+
}
|
|
664
|
+
u(d);
|
|
665
|
+
}, a, c, b, h);
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
class Nn {
|
|
671
|
+
constructor() {
|
|
672
|
+
this.name = g.KHR_TEXTURE_TRANSFORM;
|
|
673
|
+
}
|
|
674
|
+
extendTexture(n, e) {
|
|
675
|
+
return (e.texCoord === void 0 || e.texCoord === n.channel) && e.offset === void 0 && e.rotation === void 0 && e.scale === void 0 || (n = n.clone(), e.texCoord !== void 0 && (n.channel = e.texCoord), e.offset !== void 0 && n.offset.fromArray(e.offset), e.rotation !== void 0 && (n.rotation = e.rotation), e.scale !== void 0 && n.repeat.fromArray(e.scale), n.needsUpdate = !0), n;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
class In {
|
|
679
|
+
constructor() {
|
|
680
|
+
this.name = g.KHR_MESH_QUANTIZATION;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
class _e extends tn {
|
|
684
|
+
constructor(n, e, t, s) {
|
|
685
|
+
super(n, e, t, s);
|
|
686
|
+
}
|
|
687
|
+
copySampleValue_(n) {
|
|
688
|
+
const e = this.resultBuffer, t = this.sampleValues, s = this.valueSize, i = n * s * 3 + s;
|
|
689
|
+
for (let o = 0; o !== s; o++)
|
|
690
|
+
e[o] = t[i + o];
|
|
691
|
+
return e;
|
|
692
|
+
}
|
|
693
|
+
interpolate_(n, e, t, s) {
|
|
694
|
+
const i = this.resultBuffer, o = this.sampleValues, a = this.valueSize, r = a * 2, c = a * 3, l = s - e, u = (t - e) / l, h = u * u, d = h * u, p = n * c, R = p - c, m = -2 * d + 3 * h, T = d - h, _ = 1 - m, x = T - h + u;
|
|
695
|
+
for (let E = 0; E !== a; E++) {
|
|
696
|
+
const L = o[R + E + a], N = o[R + E + r] * l, S = o[p + E + a], H = o[p + E] * l;
|
|
697
|
+
i[E] = _ * L + x * N + m * S + T * H;
|
|
698
|
+
}
|
|
699
|
+
return i;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
const On = new de();
|
|
703
|
+
class Cn extends _e {
|
|
704
|
+
interpolate_(n, e, t, s) {
|
|
705
|
+
const i = super.interpolate_(n, e, t, s);
|
|
706
|
+
return On.fromArray(i).normalize().toArray(i), i;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
const M = {
|
|
710
|
+
POINTS: 0,
|
|
711
|
+
LINES: 1,
|
|
712
|
+
LINE_LOOP: 2,
|
|
713
|
+
LINE_STRIP: 3,
|
|
714
|
+
TRIANGLES: 4,
|
|
715
|
+
TRIANGLE_STRIP: 5,
|
|
716
|
+
TRIANGLE_FAN: 6
|
|
717
|
+
}, k = {
|
|
718
|
+
5120: Int8Array,
|
|
719
|
+
5121: Uint8Array,
|
|
720
|
+
5122: Int16Array,
|
|
721
|
+
5123: Uint16Array,
|
|
722
|
+
5125: Uint32Array,
|
|
723
|
+
5126: Float32Array
|
|
724
|
+
}, ce = {
|
|
725
|
+
9728: ge,
|
|
726
|
+
9729: Q,
|
|
727
|
+
9984: Fe,
|
|
728
|
+
9985: Ce,
|
|
729
|
+
9986: Oe,
|
|
730
|
+
9987: me
|
|
731
|
+
}, ue = {
|
|
732
|
+
33071: ke,
|
|
733
|
+
33648: Pe,
|
|
734
|
+
10497: J
|
|
735
|
+
}, q = {
|
|
736
|
+
SCALAR: 1,
|
|
737
|
+
VEC2: 2,
|
|
738
|
+
VEC3: 3,
|
|
739
|
+
VEC4: 4,
|
|
740
|
+
MAT2: 4,
|
|
741
|
+
MAT3: 9,
|
|
742
|
+
MAT4: 16
|
|
743
|
+
}, Z = {
|
|
744
|
+
POSITION: "position",
|
|
745
|
+
NORMAL: "normal",
|
|
746
|
+
TANGENT: "tangent",
|
|
747
|
+
TEXCOORD_0: "uv",
|
|
748
|
+
TEXCOORD_1: "uv1",
|
|
749
|
+
TEXCOORD_2: "uv2",
|
|
750
|
+
TEXCOORD_3: "uv3",
|
|
751
|
+
COLOR_0: "color",
|
|
752
|
+
WEIGHTS_0: "skinWeight",
|
|
753
|
+
JOINTS_0: "skinIndex"
|
|
754
|
+
}, I = {
|
|
755
|
+
scale: "scale",
|
|
756
|
+
translation: "position",
|
|
757
|
+
rotation: "quaternion",
|
|
758
|
+
weights: "morphTargetInfluences"
|
|
759
|
+
}, Fn = {
|
|
760
|
+
CUBICSPLINE: void 0,
|
|
761
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
762
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
763
|
+
LINEAR: Re,
|
|
764
|
+
STEP: $e
|
|
765
|
+
}, W = {
|
|
766
|
+
OPAQUE: "OPAQUE",
|
|
767
|
+
MASK: "MASK",
|
|
768
|
+
BLEND: "BLEND"
|
|
769
|
+
};
|
|
770
|
+
function Pn(f) {
|
|
771
|
+
return f.DefaultMaterial === void 0 && (f.DefaultMaterial = new Te({
|
|
772
|
+
color: 16777215,
|
|
773
|
+
emissive: 0,
|
|
774
|
+
metalness: 1,
|
|
775
|
+
roughness: 1,
|
|
776
|
+
transparent: !1,
|
|
777
|
+
depthTest: !0,
|
|
778
|
+
side: nn
|
|
779
|
+
})), f.DefaultMaterial;
|
|
780
|
+
}
|
|
781
|
+
function O(f, n, e) {
|
|
782
|
+
for (const t in e.extensions)
|
|
783
|
+
f[t] === void 0 && (n.userData.gltfExtensions = n.userData.gltfExtensions || {}, n.userData.gltfExtensions[t] = e.extensions[t]);
|
|
784
|
+
}
|
|
785
|
+
function y(f, n) {
|
|
786
|
+
n.extras !== void 0 && (typeof n.extras == "object" ? Object.assign(f.userData, n.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + n.extras));
|
|
787
|
+
}
|
|
788
|
+
function kn(f, n, e) {
|
|
789
|
+
let t = !1, s = !1, i = !1;
|
|
790
|
+
for (let c = 0, l = n.length; c < l; c++) {
|
|
791
|
+
const u = n[c];
|
|
792
|
+
if (u.POSITION !== void 0 && (t = !0), u.NORMAL !== void 0 && (s = !0), u.COLOR_0 !== void 0 && (i = !0), t && s && i) break;
|
|
793
|
+
}
|
|
794
|
+
if (!t && !s && !i) return Promise.resolve(f);
|
|
795
|
+
const o = [], a = [], r = [];
|
|
796
|
+
for (let c = 0, l = n.length; c < l; c++) {
|
|
797
|
+
const u = n[c];
|
|
798
|
+
if (t) {
|
|
799
|
+
const h = u.POSITION !== void 0 ? e.getDependency("accessor", u.POSITION) : f.attributes.position;
|
|
800
|
+
o.push(h);
|
|
801
|
+
}
|
|
802
|
+
if (s) {
|
|
803
|
+
const h = u.NORMAL !== void 0 ? e.getDependency("accessor", u.NORMAL) : f.attributes.normal;
|
|
804
|
+
a.push(h);
|
|
805
|
+
}
|
|
806
|
+
if (i) {
|
|
807
|
+
const h = u.COLOR_0 !== void 0 ? e.getDependency("accessor", u.COLOR_0) : f.attributes.color;
|
|
808
|
+
r.push(h);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return Promise.all([
|
|
812
|
+
Promise.all(o),
|
|
813
|
+
Promise.all(a),
|
|
814
|
+
Promise.all(r)
|
|
815
|
+
]).then(function(c) {
|
|
816
|
+
const l = c[0], u = c[1], h = c[2];
|
|
817
|
+
return t && (f.morphAttributes.position = l), s && (f.morphAttributes.normal = u), i && (f.morphAttributes.color = h), f.morphTargetsRelative = !0, f;
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function Hn(f, n) {
|
|
821
|
+
if (f.updateMorphTargets(), n.weights !== void 0)
|
|
822
|
+
for (let e = 0, t = n.weights.length; e < t; e++)
|
|
823
|
+
f.morphTargetInfluences[e] = n.weights[e];
|
|
824
|
+
if (n.extras && Array.isArray(n.extras.targetNames)) {
|
|
825
|
+
const e = n.extras.targetNames;
|
|
826
|
+
if (f.morphTargetInfluences.length === e.length) {
|
|
827
|
+
f.morphTargetDictionary = {};
|
|
828
|
+
for (let t = 0, s = e.length; t < s; t++)
|
|
829
|
+
f.morphTargetDictionary[e[t]] = t;
|
|
830
|
+
} else
|
|
831
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
function Dn(f) {
|
|
835
|
+
let n;
|
|
836
|
+
const e = f.extensions && f.extensions[g.KHR_DRACO_MESH_COMPRESSION];
|
|
837
|
+
if (e ? n = "draco:" + e.bufferView + ":" + e.indices + ":" + Y(e.attributes) : n = f.indices + ":" + Y(f.attributes) + ":" + f.mode, f.targets !== void 0)
|
|
838
|
+
for (let t = 0, s = f.targets.length; t < s; t++)
|
|
839
|
+
n += ":" + Y(f.targets[t]);
|
|
840
|
+
return n;
|
|
841
|
+
}
|
|
842
|
+
function Y(f) {
|
|
843
|
+
let n = "";
|
|
844
|
+
const e = Object.keys(f).sort();
|
|
845
|
+
for (let t = 0, s = e.length; t < s; t++)
|
|
846
|
+
n += e[t] + ":" + f[e[t]] + ";";
|
|
847
|
+
return n;
|
|
848
|
+
}
|
|
849
|
+
function $(f) {
|
|
850
|
+
switch (f) {
|
|
851
|
+
case Int8Array:
|
|
852
|
+
return 1 / 127;
|
|
853
|
+
case Uint8Array:
|
|
854
|
+
return 1 / 255;
|
|
855
|
+
case Int16Array:
|
|
856
|
+
return 1 / 32767;
|
|
857
|
+
case Uint16Array:
|
|
858
|
+
return 1 / 65535;
|
|
859
|
+
default:
|
|
860
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
function vn(f) {
|
|
864
|
+
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";
|
|
865
|
+
}
|
|
866
|
+
const Gn = new K();
|
|
867
|
+
class Un {
|
|
868
|
+
constructor(n = {}, e = {}) {
|
|
869
|
+
this.json = n, this.extensions = {}, this.plugins = {}, this.options = e, this.cache = new un(), 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 = {};
|
|
870
|
+
let t = !1, s = -1, i = !1, o = -1;
|
|
871
|
+
if (typeof navigator < "u" && typeof navigator.userAgent < "u") {
|
|
872
|
+
const a = navigator.userAgent;
|
|
873
|
+
t = /^((?!chrome|android).)*safari/i.test(a) === !0;
|
|
874
|
+
const r = a.match(/Version\/(\d+)/);
|
|
875
|
+
s = t && r ? parseInt(r[1], 10) : -1, i = a.indexOf("Firefox") > -1, o = i ? a.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
876
|
+
}
|
|
877
|
+
typeof createImageBitmap > "u" || t && s < 17 || i && o < 98 ? this.textureLoader = new be(this.options.manager) : this.textureLoader = new Ne(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new he(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
|
|
878
|
+
}
|
|
879
|
+
setExtensions(n) {
|
|
880
|
+
this.extensions = n;
|
|
881
|
+
}
|
|
882
|
+
setPlugins(n) {
|
|
883
|
+
this.plugins = n;
|
|
884
|
+
}
|
|
885
|
+
parse(n, e) {
|
|
886
|
+
const t = this, s = this.json, i = this.extensions;
|
|
887
|
+
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(o) {
|
|
888
|
+
return o._markDefs && o._markDefs();
|
|
889
|
+
}), Promise.all(this._invokeAll(function(o) {
|
|
890
|
+
return o.beforeRoot && o.beforeRoot();
|
|
891
|
+
})).then(function() {
|
|
892
|
+
return Promise.all([
|
|
893
|
+
t.getDependencies("scene"),
|
|
894
|
+
t.getDependencies("animation"),
|
|
895
|
+
t.getDependencies("camera")
|
|
896
|
+
]);
|
|
897
|
+
}).then(function(o) {
|
|
898
|
+
const a = {
|
|
899
|
+
scene: o[0][s.scene || 0],
|
|
900
|
+
scenes: o[0],
|
|
901
|
+
animations: o[1],
|
|
902
|
+
cameras: o[2],
|
|
903
|
+
asset: s.asset,
|
|
904
|
+
parser: t,
|
|
905
|
+
userData: {}
|
|
906
|
+
};
|
|
907
|
+
return O(i, a, s), y(a, s), Promise.all(t._invokeAll(function(r) {
|
|
908
|
+
return r.afterRoot && r.afterRoot(a);
|
|
909
|
+
})).then(function() {
|
|
910
|
+
for (const r of a.scenes)
|
|
911
|
+
r.updateMatrixWorld();
|
|
912
|
+
n(a);
|
|
913
|
+
});
|
|
914
|
+
}).catch(e);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
918
|
+
*
|
|
919
|
+
* @private
|
|
920
|
+
*/
|
|
921
|
+
_markDefs() {
|
|
922
|
+
const n = this.json.nodes || [], e = this.json.skins || [], t = this.json.meshes || [];
|
|
923
|
+
for (let s = 0, i = e.length; s < i; s++) {
|
|
924
|
+
const o = e[s].joints;
|
|
925
|
+
for (let a = 0, r = o.length; a < r; a++)
|
|
926
|
+
n[o[a]].isBone = !0;
|
|
927
|
+
}
|
|
928
|
+
for (let s = 0, i = n.length; s < i; s++) {
|
|
929
|
+
const o = n[s];
|
|
930
|
+
o.mesh !== void 0 && (this._addNodeRef(this.meshCache, o.mesh), o.skin !== void 0 && (t[o.mesh].isSkinnedMesh = !0)), o.camera !== void 0 && this._addNodeRef(this.cameraCache, o.camera);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
935
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
936
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
937
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
938
|
+
* Textures) can be reused directly and are not marked here.
|
|
939
|
+
*
|
|
940
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
941
|
+
*
|
|
942
|
+
* @private
|
|
943
|
+
* @param {Object} cache
|
|
944
|
+
* @param {Object3D} index
|
|
945
|
+
*/
|
|
946
|
+
_addNodeRef(n, e) {
|
|
947
|
+
e !== void 0 && (n.refs[e] === void 0 && (n.refs[e] = n.uses[e] = 0), n.refs[e]++);
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
951
|
+
*
|
|
952
|
+
* @private
|
|
953
|
+
* @param {Object} cache
|
|
954
|
+
* @param {number} index
|
|
955
|
+
* @param {Object} object
|
|
956
|
+
* @return {Object}
|
|
957
|
+
*/
|
|
958
|
+
_getNodeRef(n, e, t) {
|
|
959
|
+
if (n.refs[e] <= 1) return t;
|
|
960
|
+
const s = t.clone(), i = (o, a) => {
|
|
961
|
+
const r = this.associations.get(o);
|
|
962
|
+
r != null && this.associations.set(a, r);
|
|
963
|
+
for (const [c, l] of o.children.entries())
|
|
964
|
+
i(l, a.children[c]);
|
|
965
|
+
};
|
|
966
|
+
return i(t, s), s.name += "_instance_" + n.uses[e]++, s;
|
|
967
|
+
}
|
|
968
|
+
_invokeOne(n) {
|
|
969
|
+
const e = Object.values(this.plugins);
|
|
970
|
+
e.push(this);
|
|
971
|
+
for (let t = 0; t < e.length; t++) {
|
|
972
|
+
const s = n(e[t]);
|
|
973
|
+
if (s) return s;
|
|
974
|
+
}
|
|
975
|
+
return null;
|
|
976
|
+
}
|
|
977
|
+
_invokeAll(n) {
|
|
978
|
+
const e = Object.values(this.plugins);
|
|
979
|
+
e.unshift(this);
|
|
980
|
+
const t = [];
|
|
981
|
+
for (let s = 0; s < e.length; s++) {
|
|
982
|
+
const i = n(e[s]);
|
|
983
|
+
i && t.push(i);
|
|
984
|
+
}
|
|
985
|
+
return t;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
989
|
+
*
|
|
990
|
+
* @private
|
|
991
|
+
* @param {string} type
|
|
992
|
+
* @param {number} index
|
|
993
|
+
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
|
|
994
|
+
*/
|
|
995
|
+
getDependency(n, e) {
|
|
996
|
+
const t = n + ":" + e;
|
|
997
|
+
let s = this.cache.get(t);
|
|
998
|
+
if (!s) {
|
|
999
|
+
switch (n) {
|
|
1000
|
+
case "scene":
|
|
1001
|
+
s = this.loadScene(e);
|
|
1002
|
+
break;
|
|
1003
|
+
case "node":
|
|
1004
|
+
s = this._invokeOne(function(i) {
|
|
1005
|
+
return i.loadNode && i.loadNode(e);
|
|
1006
|
+
});
|
|
1007
|
+
break;
|
|
1008
|
+
case "mesh":
|
|
1009
|
+
s = this._invokeOne(function(i) {
|
|
1010
|
+
return i.loadMesh && i.loadMesh(e);
|
|
1011
|
+
});
|
|
1012
|
+
break;
|
|
1013
|
+
case "accessor":
|
|
1014
|
+
s = this.loadAccessor(e);
|
|
1015
|
+
break;
|
|
1016
|
+
case "bufferView":
|
|
1017
|
+
s = this._invokeOne(function(i) {
|
|
1018
|
+
return i.loadBufferView && i.loadBufferView(e);
|
|
1019
|
+
});
|
|
1020
|
+
break;
|
|
1021
|
+
case "buffer":
|
|
1022
|
+
s = this.loadBuffer(e);
|
|
1023
|
+
break;
|
|
1024
|
+
case "material":
|
|
1025
|
+
s = this._invokeOne(function(i) {
|
|
1026
|
+
return i.loadMaterial && i.loadMaterial(e);
|
|
1027
|
+
});
|
|
1028
|
+
break;
|
|
1029
|
+
case "texture":
|
|
1030
|
+
s = this._invokeOne(function(i) {
|
|
1031
|
+
return i.loadTexture && i.loadTexture(e);
|
|
1032
|
+
});
|
|
1033
|
+
break;
|
|
1034
|
+
case "skin":
|
|
1035
|
+
s = this.loadSkin(e);
|
|
1036
|
+
break;
|
|
1037
|
+
case "animation":
|
|
1038
|
+
s = this._invokeOne(function(i) {
|
|
1039
|
+
return i.loadAnimation && i.loadAnimation(e);
|
|
1040
|
+
});
|
|
1041
|
+
break;
|
|
1042
|
+
case "camera":
|
|
1043
|
+
s = this.loadCamera(e);
|
|
1044
|
+
break;
|
|
1045
|
+
default:
|
|
1046
|
+
if (s = this._invokeOne(function(i) {
|
|
1047
|
+
return i != this && i.getDependency && i.getDependency(n, e);
|
|
1048
|
+
}), !s)
|
|
1049
|
+
throw new Error("Unknown type: " + n);
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
this.cache.add(t, s);
|
|
1053
|
+
}
|
|
1054
|
+
return s;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1058
|
+
*
|
|
1059
|
+
* @private
|
|
1060
|
+
* @param {string} type
|
|
1061
|
+
* @return {Promise<Array<Object>>}
|
|
1062
|
+
*/
|
|
1063
|
+
getDependencies(n) {
|
|
1064
|
+
let e = this.cache.get(n);
|
|
1065
|
+
if (!e) {
|
|
1066
|
+
const t = this, s = this.json[n + (n === "mesh" ? "es" : "s")] || [];
|
|
1067
|
+
e = Promise.all(s.map(function(i, o) {
|
|
1068
|
+
return t.getDependency(n, o);
|
|
1069
|
+
})), this.cache.add(n, e);
|
|
1070
|
+
}
|
|
1071
|
+
return e;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1075
|
+
*
|
|
1076
|
+
* @private
|
|
1077
|
+
* @param {number} bufferIndex
|
|
1078
|
+
* @return {Promise<ArrayBuffer>}
|
|
1079
|
+
*/
|
|
1080
|
+
loadBuffer(n) {
|
|
1081
|
+
const e = this.json.buffers[n], t = this.fileLoader;
|
|
1082
|
+
if (e.type && e.type !== "arraybuffer")
|
|
1083
|
+
throw new Error("THREE.GLTFLoader: " + e.type + " buffer type is not supported.");
|
|
1084
|
+
if (e.uri === void 0 && n === 0)
|
|
1085
|
+
return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);
|
|
1086
|
+
const s = this.options;
|
|
1087
|
+
return new Promise(function(i, o) {
|
|
1088
|
+
t.load(G.resolveURL(e.uri, s.path), i, void 0, function() {
|
|
1089
|
+
o(new Error('THREE.GLTFLoader: Failed to load buffer "' + e.uri + '".'));
|
|
1090
|
+
});
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1095
|
+
*
|
|
1096
|
+
* @private
|
|
1097
|
+
* @param {number} bufferViewIndex
|
|
1098
|
+
* @return {Promise<ArrayBuffer>}
|
|
1099
|
+
*/
|
|
1100
|
+
loadBufferView(n) {
|
|
1101
|
+
const e = this.json.bufferViews[n];
|
|
1102
|
+
return this.getDependency("buffer", e.buffer).then(function(t) {
|
|
1103
|
+
const s = e.byteLength || 0, i = e.byteOffset || 0;
|
|
1104
|
+
return t.slice(i, i + s);
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1109
|
+
*
|
|
1110
|
+
* @private
|
|
1111
|
+
* @param {number} accessorIndex
|
|
1112
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1113
|
+
*/
|
|
1114
|
+
loadAccessor(n) {
|
|
1115
|
+
const e = this, t = this.json, s = this.json.accessors[n];
|
|
1116
|
+
if (s.bufferView === void 0 && s.sparse === void 0) {
|
|
1117
|
+
const o = q[s.type], a = k[s.componentType], r = s.normalized === !0, c = new a(s.count * o);
|
|
1118
|
+
return Promise.resolve(new V(c, o, r));
|
|
1119
|
+
}
|
|
1120
|
+
const i = [];
|
|
1121
|
+
return s.bufferView !== void 0 ? i.push(this.getDependency("bufferView", s.bufferView)) : i.push(null), s.sparse !== void 0 && (i.push(this.getDependency("bufferView", s.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", s.sparse.values.bufferView))), Promise.all(i).then(function(o) {
|
|
1122
|
+
const a = o[0], r = q[s.type], c = k[s.componentType], l = c.BYTES_PER_ELEMENT, u = l * r, h = s.byteOffset || 0, d = s.bufferView !== void 0 ? t.bufferViews[s.bufferView].byteStride : void 0, p = s.normalized === !0;
|
|
1123
|
+
let R, m;
|
|
1124
|
+
if (d && d !== u) {
|
|
1125
|
+
const T = Math.floor(h / d), _ = "InterleavedBuffer:" + s.bufferView + ":" + s.componentType + ":" + T + ":" + s.count;
|
|
1126
|
+
let x = e.cache.get(_);
|
|
1127
|
+
x || (R = new c(a, T * d, s.count * d / l), x = new Ie(R, d / l), e.cache.add(_, x)), m = new en(x, r, h % d / l, p);
|
|
1128
|
+
} else
|
|
1129
|
+
a === null ? R = new c(s.count * r) : R = new c(a, h, s.count * r), m = new V(R, r, p);
|
|
1130
|
+
if (s.sparse !== void 0) {
|
|
1131
|
+
const T = q.SCALAR, _ = k[s.sparse.indices.componentType], x = s.sparse.indices.byteOffset || 0, E = s.sparse.values.byteOffset || 0, L = new _(o[1], x, s.sparse.count * T), N = new c(o[2], E, s.sparse.count * r);
|
|
1132
|
+
a !== null && (m = new V(m.array.slice(), m.itemSize, m.normalized)), m.normalized = !1;
|
|
1133
|
+
for (let S = 0, H = L.length; S < H; S++) {
|
|
1134
|
+
const P = L[S];
|
|
1135
|
+
if (m.setX(P, N[S * r]), r >= 2 && m.setY(P, N[S * r + 1]), r >= 3 && m.setZ(P, N[S * r + 2]), r >= 4 && m.setW(P, N[S * r + 3]), r >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1136
|
+
}
|
|
1137
|
+
m.normalized = p;
|
|
1138
|
+
}
|
|
1139
|
+
return m;
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1144
|
+
*
|
|
1145
|
+
* @private
|
|
1146
|
+
* @param {number} textureIndex
|
|
1147
|
+
* @return {Promise<?Texture>}
|
|
1148
|
+
*/
|
|
1149
|
+
loadTexture(n) {
|
|
1150
|
+
const e = this.json, t = this.options, i = e.textures[n].source, o = e.images[i];
|
|
1151
|
+
let a = this.textureLoader;
|
|
1152
|
+
if (o.uri) {
|
|
1153
|
+
const r = t.manager.getHandler(o.uri);
|
|
1154
|
+
r !== null && (a = r);
|
|
1155
|
+
}
|
|
1156
|
+
return this.loadTextureImage(n, i, a);
|
|
1157
|
+
}
|
|
1158
|
+
loadTextureImage(n, e, t) {
|
|
1159
|
+
const s = this, i = this.json, o = i.textures[n], a = i.images[e], r = (a.uri || a.bufferView) + ":" + o.sampler;
|
|
1160
|
+
if (this.textureCache[r])
|
|
1161
|
+
return this.textureCache[r];
|
|
1162
|
+
const c = this.loadImageSource(e, t).then(function(l) {
|
|
1163
|
+
l.flipY = !1, l.name = o.name || a.name || "", l.name === "" && typeof a.uri == "string" && a.uri.startsWith("data:image/") === !1 && (l.name = a.uri);
|
|
1164
|
+
const h = (i.samplers || {})[o.sampler] || {};
|
|
1165
|
+
return l.magFilter = ce[h.magFilter] || Q, l.minFilter = ce[h.minFilter] || me, l.wrapS = ue[h.wrapS] || J, l.wrapT = ue[h.wrapT] || J, l.generateMipmaps = !l.isCompressedTexture && l.minFilter !== ge && l.minFilter !== Q, s.associations.set(l, { textures: n }), l;
|
|
1166
|
+
}).catch(function() {
|
|
1167
|
+
return null;
|
|
1168
|
+
});
|
|
1169
|
+
return this.textureCache[r] = c, c;
|
|
1170
|
+
}
|
|
1171
|
+
loadImageSource(n, e) {
|
|
1172
|
+
const t = this, s = this.json, i = this.options;
|
|
1173
|
+
if (this.sourceCache[n] !== void 0)
|
|
1174
|
+
return this.sourceCache[n].then((u) => u.clone());
|
|
1175
|
+
const o = s.images[n], a = self.URL || self.webkitURL;
|
|
1176
|
+
let r = o.uri || "", c = !1;
|
|
1177
|
+
if (o.bufferView !== void 0)
|
|
1178
|
+
r = t.getDependency("bufferView", o.bufferView).then(function(u) {
|
|
1179
|
+
c = !0;
|
|
1180
|
+
const h = new Blob([u], { type: o.mimeType });
|
|
1181
|
+
return r = a.createObjectURL(h), r;
|
|
1182
|
+
});
|
|
1183
|
+
else if (o.uri === void 0)
|
|
1184
|
+
throw new Error("THREE.GLTFLoader: Image " + n + " is missing URI and bufferView");
|
|
1185
|
+
const l = Promise.resolve(r).then(function(u) {
|
|
1186
|
+
return new Promise(function(h, d) {
|
|
1187
|
+
let p = h;
|
|
1188
|
+
e.isImageBitmapLoader === !0 && (p = function(R) {
|
|
1189
|
+
const m = new ne(R);
|
|
1190
|
+
m.needsUpdate = !0, h(m);
|
|
1191
|
+
}), e.load(G.resolveURL(u, i.path), p, void 0, d);
|
|
1192
|
+
});
|
|
1193
|
+
}).then(function(u) {
|
|
1194
|
+
return c === !0 && a.revokeObjectURL(r), y(u, o), u.userData.mimeType = o.mimeType || vn(o.uri), u;
|
|
1195
|
+
}).catch(function(u) {
|
|
1196
|
+
throw console.error("THREE.GLTFLoader: Couldn't load texture", r), u;
|
|
1197
|
+
});
|
|
1198
|
+
return this.sourceCache[n] = l, l;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1202
|
+
*
|
|
1203
|
+
* @private
|
|
1204
|
+
* @param {Object} materialParams
|
|
1205
|
+
* @param {string} mapName
|
|
1206
|
+
* @param {Object} mapDef
|
|
1207
|
+
* @param {string} [colorSpace]
|
|
1208
|
+
* @return {Promise<Texture>}
|
|
1209
|
+
*/
|
|
1210
|
+
assignTexture(n, e, t, s) {
|
|
1211
|
+
const i = this;
|
|
1212
|
+
return this.getDependency("texture", t.index).then(function(o) {
|
|
1213
|
+
if (!o) return null;
|
|
1214
|
+
if (t.texCoord !== void 0 && t.texCoord > 0 && (o = o.clone(), o.channel = t.texCoord), i.extensions[g.KHR_TEXTURE_TRANSFORM]) {
|
|
1215
|
+
const a = t.extensions !== void 0 ? t.extensions[g.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1216
|
+
if (a) {
|
|
1217
|
+
const r = i.associations.get(o);
|
|
1218
|
+
o = i.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(o, a), i.associations.set(o, r);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
return s !== void 0 && (o.colorSpace = s), n[e] = o, o;
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1226
|
+
* already has a material (generated from the glTF material options alone)
|
|
1227
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1228
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1229
|
+
* be created if necessary, and reused from a cache.
|
|
1230
|
+
*
|
|
1231
|
+
* @private
|
|
1232
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1233
|
+
*/
|
|
1234
|
+
assignFinalMaterial(n) {
|
|
1235
|
+
const e = n.geometry;
|
|
1236
|
+
let t = n.material;
|
|
1237
|
+
const s = e.attributes.tangent === void 0, i = e.attributes.color !== void 0, o = e.attributes.normal === void 0;
|
|
1238
|
+
if (n.isPoints) {
|
|
1239
|
+
const a = "PointsMaterial:" + t.uuid;
|
|
1240
|
+
let r = this.cache.get(a);
|
|
1241
|
+
r || (r = new He(), z.prototype.copy.call(r, t), r.color.copy(t.color), r.map = t.map, r.sizeAttenuation = !1, this.cache.add(a, r)), t = r;
|
|
1242
|
+
} else if (n.isLine) {
|
|
1243
|
+
const a = "LineBasicMaterial:" + t.uuid;
|
|
1244
|
+
let r = this.cache.get(a);
|
|
1245
|
+
r || (r = new De(), z.prototype.copy.call(r, t), r.color.copy(t.color), r.map = t.map, this.cache.add(a, r)), t = r;
|
|
1246
|
+
}
|
|
1247
|
+
if (s || i || o) {
|
|
1248
|
+
let a = "ClonedMaterial:" + t.uuid + ":";
|
|
1249
|
+
s && (a += "derivative-tangents:"), i && (a += "vertex-colors:"), o && (a += "flat-shading:");
|
|
1250
|
+
let r = this.cache.get(a);
|
|
1251
|
+
r || (r = t.clone(), i && (r.vertexColors = !0), o && (r.flatShading = !0), s && (r.normalScale && (r.normalScale.y *= -1), r.clearcoatNormalScale && (r.clearcoatNormalScale.y *= -1)), this.cache.add(a, r), this.associations.set(r, this.associations.get(t))), t = r;
|
|
1252
|
+
}
|
|
1253
|
+
n.material = t;
|
|
1254
|
+
}
|
|
1255
|
+
getMaterialType() {
|
|
1256
|
+
return Te;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1260
|
+
*
|
|
1261
|
+
* @private
|
|
1262
|
+
* @param {number} materialIndex
|
|
1263
|
+
* @return {Promise<Material>}
|
|
1264
|
+
*/
|
|
1265
|
+
loadMaterial(n) {
|
|
1266
|
+
const e = this, t = this.json, s = this.extensions, i = t.materials[n];
|
|
1267
|
+
let o;
|
|
1268
|
+
const a = {}, r = i.extensions || {}, c = [];
|
|
1269
|
+
if (r[g.KHR_MATERIALS_UNLIT]) {
|
|
1270
|
+
const u = s[g.KHR_MATERIALS_UNLIT];
|
|
1271
|
+
o = u.getMaterialType(), c.push(u.extendParams(a, i, e));
|
|
1272
|
+
} else {
|
|
1273
|
+
const u = i.pbrMetallicRoughness || {};
|
|
1274
|
+
if (a.color = new F(1, 1, 1), a.opacity = 1, Array.isArray(u.baseColorFactor)) {
|
|
1275
|
+
const h = u.baseColorFactor;
|
|
1276
|
+
a.color.setRGB(h[0], h[1], h[2], b), a.opacity = h[3];
|
|
1277
|
+
}
|
|
1278
|
+
u.baseColorTexture !== void 0 && c.push(e.assignTexture(a, "map", u.baseColorTexture, U)), a.metalness = u.metallicFactor !== void 0 ? u.metallicFactor : 1, a.roughness = u.roughnessFactor !== void 0 ? u.roughnessFactor : 1, u.metallicRoughnessTexture !== void 0 && (c.push(e.assignTexture(a, "metalnessMap", u.metallicRoughnessTexture)), c.push(e.assignTexture(a, "roughnessMap", u.metallicRoughnessTexture))), o = this._invokeOne(function(h) {
|
|
1279
|
+
return h.getMaterialType && h.getMaterialType(n);
|
|
1280
|
+
}), c.push(Promise.all(this._invokeAll(function(h) {
|
|
1281
|
+
return h.extendMaterialParams && h.extendMaterialParams(n, a);
|
|
1282
|
+
})));
|
|
1283
|
+
}
|
|
1284
|
+
i.doubleSided === !0 && (a.side = ve);
|
|
1285
|
+
const l = i.alphaMode || W.OPAQUE;
|
|
1286
|
+
if (l === W.BLEND ? (a.transparent = !0, a.depthWrite = !1) : (a.transparent = !1, l === W.MASK && (a.alphaTest = i.alphaCutoff !== void 0 ? i.alphaCutoff : 0.5)), i.normalTexture !== void 0 && o !== v && (c.push(e.assignTexture(a, "normalMap", i.normalTexture)), a.normalScale = new fe(1, 1), i.normalTexture.scale !== void 0)) {
|
|
1287
|
+
const u = i.normalTexture.scale;
|
|
1288
|
+
a.normalScale.set(u, u);
|
|
1289
|
+
}
|
|
1290
|
+
if (i.occlusionTexture !== void 0 && o !== v && (c.push(e.assignTexture(a, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (a.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && o !== v) {
|
|
1291
|
+
const u = i.emissiveFactor;
|
|
1292
|
+
a.emissive = new F().setRGB(u[0], u[1], u[2], b);
|
|
1293
|
+
}
|
|
1294
|
+
return i.emissiveTexture !== void 0 && o !== v && c.push(e.assignTexture(a, "emissiveMap", i.emissiveTexture, U)), Promise.all(c).then(function() {
|
|
1295
|
+
const u = new o(a);
|
|
1296
|
+
return i.name && (u.name = i.name), y(u, i), e.associations.set(u, { materials: n }), i.extensions && O(s, u, i), u;
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
1301
|
+
*
|
|
1302
|
+
* @private
|
|
1303
|
+
* @param {string} originalName
|
|
1304
|
+
* @return {string}
|
|
1305
|
+
*/
|
|
1306
|
+
createUniqueName(n) {
|
|
1307
|
+
const e = Ge.sanitizeNodeName(n || "");
|
|
1308
|
+
return e in this.nodeNamesUsed ? e + "_" + ++this.nodeNamesUsed[e] : (this.nodeNamesUsed[e] = 0, e);
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
1312
|
+
*
|
|
1313
|
+
* Creates BufferGeometries from primitives.
|
|
1314
|
+
*
|
|
1315
|
+
* @private
|
|
1316
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
1317
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
1318
|
+
*/
|
|
1319
|
+
loadGeometries(n) {
|
|
1320
|
+
const e = this, t = this.extensions, s = this.primitiveCache;
|
|
1321
|
+
function i(a) {
|
|
1322
|
+
return t[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a, e).then(function(r) {
|
|
1323
|
+
return le(r, a, e);
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
const o = [];
|
|
1327
|
+
for (let a = 0, r = n.length; a < r; a++) {
|
|
1328
|
+
const c = n[a], l = Dn(c), u = s[l];
|
|
1329
|
+
if (u)
|
|
1330
|
+
o.push(u.promise);
|
|
1331
|
+
else {
|
|
1332
|
+
let h;
|
|
1333
|
+
c.extensions && c.extensions[g.KHR_DRACO_MESH_COMPRESSION] ? h = i(c) : h = le(new Ue(), c, e), s[l] = { primitive: c, promise: h }, o.push(h);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
return Promise.all(o);
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
1340
|
+
*
|
|
1341
|
+
* @private
|
|
1342
|
+
* @param {number} meshIndex
|
|
1343
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
1344
|
+
*/
|
|
1345
|
+
loadMesh(n) {
|
|
1346
|
+
const e = this, t = this.json, s = this.extensions, i = t.meshes[n], o = i.primitives, a = [];
|
|
1347
|
+
for (let r = 0, c = o.length; r < c; r++) {
|
|
1348
|
+
const l = o[r].material === void 0 ? Pn(this.cache) : this.getDependency("material", o[r].material);
|
|
1349
|
+
a.push(l);
|
|
1350
|
+
}
|
|
1351
|
+
return a.push(e.loadGeometries(o)), Promise.all(a).then(function(r) {
|
|
1352
|
+
const c = r.slice(0, r.length - 1), l = r[r.length - 1], u = [];
|
|
1353
|
+
for (let d = 0, p = l.length; d < p; d++) {
|
|
1354
|
+
const R = l[d], m = o[d];
|
|
1355
|
+
let T;
|
|
1356
|
+
const _ = c[d];
|
|
1357
|
+
if (m.mode === M.TRIANGLES || m.mode === M.TRIANGLE_STRIP || m.mode === M.TRIANGLE_FAN || m.mode === void 0)
|
|
1358
|
+
T = i.isSkinnedMesh === !0 ? new Ke(R, _) : new Be(R, _), T.isSkinnedMesh === !0 && T.normalizeSkinWeights(), m.mode === M.TRIANGLE_STRIP ? T.geometry = ee(T.geometry, on) : m.mode === M.TRIANGLE_FAN && (T.geometry = ee(T.geometry, an));
|
|
1359
|
+
else if (m.mode === M.LINES)
|
|
1360
|
+
T = new je(R, _);
|
|
1361
|
+
else if (m.mode === M.LINE_STRIP)
|
|
1362
|
+
T = new Ve(R, _);
|
|
1363
|
+
else if (m.mode === M.LINE_LOOP)
|
|
1364
|
+
T = new ze(R, _);
|
|
1365
|
+
else if (m.mode === M.POINTS)
|
|
1366
|
+
T = new Xe(R, _);
|
|
1367
|
+
else
|
|
1368
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + m.mode);
|
|
1369
|
+
Object.keys(T.geometry.morphAttributes).length > 0 && Hn(T, i), T.name = e.createUniqueName(i.name || "mesh_" + n), y(T, i), m.extensions && O(s, T, m), e.assignFinalMaterial(T), u.push(T);
|
|
1370
|
+
}
|
|
1371
|
+
for (let d = 0, p = u.length; d < p; d++)
|
|
1372
|
+
e.associations.set(u[d], {
|
|
1373
|
+
meshes: n,
|
|
1374
|
+
primitives: d
|
|
1375
|
+
});
|
|
1376
|
+
if (u.length === 1)
|
|
1377
|
+
return i.extensions && O(s, u[0], i), u[0];
|
|
1378
|
+
const h = new X();
|
|
1379
|
+
i.extensions && O(s, h, i), e.associations.set(h, { meshes: n });
|
|
1380
|
+
for (let d = 0, p = u.length; d < p; d++)
|
|
1381
|
+
h.add(u[d]);
|
|
1382
|
+
return h;
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
1387
|
+
*
|
|
1388
|
+
* @private
|
|
1389
|
+
* @param {number} cameraIndex
|
|
1390
|
+
* @return {Promise<Camera>|undefined}
|
|
1391
|
+
*/
|
|
1392
|
+
loadCamera(n) {
|
|
1393
|
+
let e;
|
|
1394
|
+
const t = this.json.cameras[n], s = t[t.type];
|
|
1395
|
+
if (!s) {
|
|
1396
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
return t.type === "perspective" ? e = new qe(We.radToDeg(s.yfov), s.aspectRatio || 1, s.znear || 1, s.zfar || 2e6) : t.type === "orthographic" && (e = new Ye(-s.xmag, s.xmag, s.ymag, -s.ymag, s.znear, s.zfar)), t.name && (e.name = this.createUniqueName(t.name)), y(e, t), Promise.resolve(e);
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
1403
|
+
*
|
|
1404
|
+
* @private
|
|
1405
|
+
* @param {number} skinIndex
|
|
1406
|
+
* @return {Promise<Skeleton>}
|
|
1407
|
+
*/
|
|
1408
|
+
loadSkin(n) {
|
|
1409
|
+
const e = this.json.skins[n], t = [];
|
|
1410
|
+
for (let s = 0, i = e.joints.length; s < i; s++)
|
|
1411
|
+
t.push(this._loadNodeShallow(e.joints[s]));
|
|
1412
|
+
return e.inverseBindMatrices !== void 0 ? t.push(this.getDependency("accessor", e.inverseBindMatrices)) : t.push(null), Promise.all(t).then(function(s) {
|
|
1413
|
+
const i = s.pop(), o = s, a = [], r = [];
|
|
1414
|
+
for (let c = 0, l = o.length; c < l; c++) {
|
|
1415
|
+
const u = o[c];
|
|
1416
|
+
if (u) {
|
|
1417
|
+
a.push(u);
|
|
1418
|
+
const h = new K();
|
|
1419
|
+
i !== null && h.fromArray(i.array, c * 16), r.push(h);
|
|
1420
|
+
} else
|
|
1421
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', e.joints[c]);
|
|
1422
|
+
}
|
|
1423
|
+
return new Qe(a, r);
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
1428
|
+
*
|
|
1429
|
+
* @private
|
|
1430
|
+
* @param {number} animationIndex
|
|
1431
|
+
* @return {Promise<AnimationClip>}
|
|
1432
|
+
*/
|
|
1433
|
+
loadAnimation(n) {
|
|
1434
|
+
const e = this.json, t = this, s = e.animations[n], i = s.name ? s.name : "animation_" + n, o = [], a = [], r = [], c = [], l = [];
|
|
1435
|
+
for (let u = 0, h = s.channels.length; u < h; u++) {
|
|
1436
|
+
const d = s.channels[u], p = s.samplers[d.sampler], R = d.target, m = R.node, T = s.parameters !== void 0 ? s.parameters[p.input] : p.input, _ = s.parameters !== void 0 ? s.parameters[p.output] : p.output;
|
|
1437
|
+
R.node !== void 0 && (o.push(this.getDependency("node", m)), a.push(this.getDependency("accessor", T)), r.push(this.getDependency("accessor", _)), c.push(p), l.push(R));
|
|
1438
|
+
}
|
|
1439
|
+
return Promise.all([
|
|
1440
|
+
Promise.all(o),
|
|
1441
|
+
Promise.all(a),
|
|
1442
|
+
Promise.all(r),
|
|
1443
|
+
Promise.all(c),
|
|
1444
|
+
Promise.all(l)
|
|
1445
|
+
]).then(function(u) {
|
|
1446
|
+
const h = u[0], d = u[1], p = u[2], R = u[3], m = u[4], T = [];
|
|
1447
|
+
for (let x = 0, E = h.length; x < E; x++) {
|
|
1448
|
+
const L = h[x], N = d[x], S = p[x], H = R[x], P = m[x];
|
|
1449
|
+
if (L === void 0) continue;
|
|
1450
|
+
L.updateMatrix && L.updateMatrix();
|
|
1451
|
+
const B = t._createAnimationTracks(L, N, S, H, P);
|
|
1452
|
+
if (B)
|
|
1453
|
+
for (let j = 0; j < B.length; j++)
|
|
1454
|
+
T.push(B[j]);
|
|
1455
|
+
}
|
|
1456
|
+
const _ = new Je(i, void 0, T);
|
|
1457
|
+
return y(_, s), _;
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
createNodeMesh(n) {
|
|
1461
|
+
const e = this.json, t = this, s = e.nodes[n];
|
|
1462
|
+
return s.mesh === void 0 ? null : t.getDependency("mesh", s.mesh).then(function(i) {
|
|
1463
|
+
const o = t._getNodeRef(t.meshCache, s.mesh, i);
|
|
1464
|
+
return s.weights !== void 0 && o.traverse(function(a) {
|
|
1465
|
+
if (a.isMesh)
|
|
1466
|
+
for (let r = 0, c = s.weights.length; r < c; r++)
|
|
1467
|
+
a.morphTargetInfluences[r] = s.weights[r];
|
|
1468
|
+
}), o;
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
1473
|
+
*
|
|
1474
|
+
* @private
|
|
1475
|
+
* @param {number} nodeIndex
|
|
1476
|
+
* @return {Promise<Object3D>}
|
|
1477
|
+
*/
|
|
1478
|
+
loadNode(n) {
|
|
1479
|
+
const e = this.json, t = this, s = e.nodes[n], i = t._loadNodeShallow(n), o = [], a = s.children || [];
|
|
1480
|
+
for (let c = 0, l = a.length; c < l; c++)
|
|
1481
|
+
o.push(t.getDependency("node", a[c]));
|
|
1482
|
+
const r = s.skin === void 0 ? Promise.resolve(null) : t.getDependency("skin", s.skin);
|
|
1483
|
+
return Promise.all([
|
|
1484
|
+
i,
|
|
1485
|
+
Promise.all(o),
|
|
1486
|
+
r
|
|
1487
|
+
]).then(function(c) {
|
|
1488
|
+
const l = c[0], u = c[1], h = c[2];
|
|
1489
|
+
h !== null && l.traverse(function(d) {
|
|
1490
|
+
d.isSkinnedMesh && d.bind(h, Gn);
|
|
1491
|
+
});
|
|
1492
|
+
for (let d = 0, p = u.length; d < p; d++)
|
|
1493
|
+
l.add(u[d]);
|
|
1494
|
+
if (l.userData.pivot !== void 0 && u.length > 0) {
|
|
1495
|
+
const d = l.userData.pivot, p = u[0];
|
|
1496
|
+
l.pivot = new C().fromArray(d), l.position.x -= d[0], l.position.y -= d[1], l.position.z -= d[2], p.position.set(0, 0, 0), delete l.userData.pivot;
|
|
1497
|
+
}
|
|
1498
|
+
return l;
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
// ._loadNodeShallow() parses a single node.
|
|
1502
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
1503
|
+
_loadNodeShallow(n) {
|
|
1504
|
+
const e = this.json, t = this.extensions, s = this;
|
|
1505
|
+
if (this.nodeCache[n] !== void 0)
|
|
1506
|
+
return this.nodeCache[n];
|
|
1507
|
+
const i = e.nodes[n], o = i.name ? s.createUniqueName(i.name) : "", a = [], r = s._invokeOne(function(c) {
|
|
1508
|
+
return c.createNodeMesh && c.createNodeMesh(n);
|
|
1509
|
+
});
|
|
1510
|
+
return r && a.push(r), i.camera !== void 0 && a.push(s.getDependency("camera", i.camera).then(function(c) {
|
|
1511
|
+
return s._getNodeRef(s.cameraCache, i.camera, c);
|
|
1512
|
+
})), s._invokeAll(function(c) {
|
|
1513
|
+
return c.createNodeAttachment && c.createNodeAttachment(n);
|
|
1514
|
+
}).forEach(function(c) {
|
|
1515
|
+
a.push(c);
|
|
1516
|
+
}), this.nodeCache[n] = Promise.all(a).then(function(c) {
|
|
1517
|
+
let l;
|
|
1518
|
+
if (i.isBone === !0 ? l = new Ze() : c.length > 1 ? l = new X() : c.length === 1 ? l = c[0] : l = new pe(), l !== c[0])
|
|
1519
|
+
for (let u = 0, h = c.length; u < h; u++)
|
|
1520
|
+
l.add(c[u]);
|
|
1521
|
+
if (i.name && (l.userData.name = i.name, l.name = o), y(l, i), i.extensions && O(t, l, i), i.matrix !== void 0) {
|
|
1522
|
+
const u = new K();
|
|
1523
|
+
u.fromArray(i.matrix), l.applyMatrix4(u);
|
|
1524
|
+
} else
|
|
1525
|
+
i.translation !== void 0 && l.position.fromArray(i.translation), i.rotation !== void 0 && l.quaternion.fromArray(i.rotation), i.scale !== void 0 && l.scale.fromArray(i.scale);
|
|
1526
|
+
if (!s.associations.has(l))
|
|
1527
|
+
s.associations.set(l, {});
|
|
1528
|
+
else if (i.mesh !== void 0 && s.meshCache.refs[i.mesh] > 1) {
|
|
1529
|
+
const u = s.associations.get(l);
|
|
1530
|
+
s.associations.set(l, { ...u });
|
|
1531
|
+
}
|
|
1532
|
+
return s.associations.get(l).nodes = n, l;
|
|
1533
|
+
}), this.nodeCache[n];
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
1537
|
+
*
|
|
1538
|
+
* @private
|
|
1539
|
+
* @param {number} sceneIndex
|
|
1540
|
+
* @return {Promise<Group>}
|
|
1541
|
+
*/
|
|
1542
|
+
loadScene(n) {
|
|
1543
|
+
const e = this.extensions, t = this.json.scenes[n], s = this, i = new X();
|
|
1544
|
+
t.name && (i.name = s.createUniqueName(t.name)), y(i, t), t.extensions && O(e, i, t);
|
|
1545
|
+
const o = t.nodes || [], a = [];
|
|
1546
|
+
for (let r = 0, c = o.length; r < c; r++)
|
|
1547
|
+
a.push(s.getDependency("node", o[r]));
|
|
1548
|
+
return Promise.all(a).then(function(r) {
|
|
1549
|
+
for (let l = 0, u = r.length; l < u; l++) {
|
|
1550
|
+
const h = r[l];
|
|
1551
|
+
h.parent !== null ? i.add(cn(h)) : i.add(h);
|
|
1552
|
+
}
|
|
1553
|
+
const c = (l) => {
|
|
1554
|
+
const u = /* @__PURE__ */ new Map();
|
|
1555
|
+
for (const [h, d] of s.associations)
|
|
1556
|
+
(h instanceof z || h instanceof ne) && u.set(h, d);
|
|
1557
|
+
return l.traverse((h) => {
|
|
1558
|
+
const d = s.associations.get(h);
|
|
1559
|
+
d != null && u.set(h, d);
|
|
1560
|
+
}), u;
|
|
1561
|
+
};
|
|
1562
|
+
return s.associations = c(i), i;
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
_createAnimationTracks(n, e, t, s, i) {
|
|
1566
|
+
const o = [], a = n.name ? n.name : n.uuid, r = [];
|
|
1567
|
+
I[i.path] === I.weights ? n.traverse(function(h) {
|
|
1568
|
+
h.morphTargetInfluences && r.push(h.name ? h.name : h.uuid);
|
|
1569
|
+
}) : r.push(a);
|
|
1570
|
+
let c;
|
|
1571
|
+
switch (I[i.path]) {
|
|
1572
|
+
case I.weights:
|
|
1573
|
+
c = se;
|
|
1574
|
+
break;
|
|
1575
|
+
case I.rotation:
|
|
1576
|
+
c = ie;
|
|
1577
|
+
break;
|
|
1578
|
+
case I.translation:
|
|
1579
|
+
case I.scale:
|
|
1580
|
+
c = te;
|
|
1581
|
+
break;
|
|
1582
|
+
default:
|
|
1583
|
+
t.itemSize === 1 ? c = se : c = te;
|
|
1584
|
+
break;
|
|
1585
|
+
}
|
|
1586
|
+
const l = s.interpolation !== void 0 ? Fn[s.interpolation] : Re, u = this._getArrayFromAccessor(t);
|
|
1587
|
+
for (let h = 0, d = r.length; h < d; h++) {
|
|
1588
|
+
const p = new c(
|
|
1589
|
+
r[h] + "." + I[i.path],
|
|
1590
|
+
e.array,
|
|
1591
|
+
u,
|
|
1592
|
+
l
|
|
1593
|
+
);
|
|
1594
|
+
s.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(p), o.push(p);
|
|
1595
|
+
}
|
|
1596
|
+
return o;
|
|
1597
|
+
}
|
|
1598
|
+
_getArrayFromAccessor(n) {
|
|
1599
|
+
let e = n.array;
|
|
1600
|
+
if (n.normalized) {
|
|
1601
|
+
const t = $(e.constructor), s = new Float32Array(e.length);
|
|
1602
|
+
for (let i = 0, o = e.length; i < o; i++)
|
|
1603
|
+
s[i] = e[i] * t;
|
|
1604
|
+
e = s;
|
|
1605
|
+
}
|
|
1606
|
+
return e;
|
|
1607
|
+
}
|
|
1608
|
+
_createCubicSplineTrackInterpolant(n) {
|
|
1609
|
+
n.createInterpolant = function(t) {
|
|
1610
|
+
const s = this instanceof ie ? Cn : _e;
|
|
1611
|
+
return new s(this.times, this.values, this.getValueSize() / 3, t);
|
|
1612
|
+
}, n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
function Kn(f, n, e) {
|
|
1616
|
+
const t = n.attributes, s = new sn();
|
|
1617
|
+
if (t.POSITION !== void 0) {
|
|
1618
|
+
const a = e.json.accessors[t.POSITION], r = a.min, c = a.max;
|
|
1619
|
+
if (r !== void 0 && c !== void 0) {
|
|
1620
|
+
if (s.set(
|
|
1621
|
+
new C(r[0], r[1], r[2]),
|
|
1622
|
+
new C(c[0], c[1], c[2])
|
|
1623
|
+
), a.normalized) {
|
|
1624
|
+
const l = $(k[a.componentType]);
|
|
1625
|
+
s.min.multiplyScalar(l), s.max.multiplyScalar(l);
|
|
1626
|
+
}
|
|
1627
|
+
} else {
|
|
1628
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
} else
|
|
1632
|
+
return;
|
|
1633
|
+
const i = n.targets;
|
|
1634
|
+
if (i !== void 0) {
|
|
1635
|
+
const a = new C(), r = new C();
|
|
1636
|
+
for (let c = 0, l = i.length; c < l; c++) {
|
|
1637
|
+
const u = i[c];
|
|
1638
|
+
if (u.POSITION !== void 0) {
|
|
1639
|
+
const h = e.json.accessors[u.POSITION], d = h.min, p = h.max;
|
|
1640
|
+
if (d !== void 0 && p !== void 0) {
|
|
1641
|
+
if (r.setX(Math.max(Math.abs(d[0]), Math.abs(p[0]))), r.setY(Math.max(Math.abs(d[1]), Math.abs(p[1]))), r.setZ(Math.max(Math.abs(d[2]), Math.abs(p[2]))), h.normalized) {
|
|
1642
|
+
const R = $(k[h.componentType]);
|
|
1643
|
+
r.multiplyScalar(R);
|
|
1644
|
+
}
|
|
1645
|
+
a.max(r);
|
|
1646
|
+
} else
|
|
1647
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
s.expandByVector(a);
|
|
1651
|
+
}
|
|
1652
|
+
f.boundingBox = s;
|
|
1653
|
+
const o = new rn();
|
|
1654
|
+
s.getCenter(o.center), o.radius = s.min.distanceTo(s.max) / 2, f.boundingSphere = o;
|
|
1655
|
+
}
|
|
1656
|
+
function le(f, n, e) {
|
|
1657
|
+
const t = n.attributes, s = [];
|
|
1658
|
+
function i(o, a) {
|
|
1659
|
+
return e.getDependency("accessor", o).then(function(r) {
|
|
1660
|
+
f.setAttribute(a, r);
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
for (const o in t) {
|
|
1664
|
+
const a = Z[o] || o.toLowerCase();
|
|
1665
|
+
a in f.attributes || s.push(i(t[o], a));
|
|
1666
|
+
}
|
|
1667
|
+
if (n.indices !== void 0 && !f.index) {
|
|
1668
|
+
const o = e.getDependency("accessor", n.indices).then(function(a) {
|
|
1669
|
+
f.setIndex(a);
|
|
1670
|
+
});
|
|
1671
|
+
s.push(o);
|
|
1672
|
+
}
|
|
1673
|
+
return re.workingColorSpace !== b && "COLOR_0" in t && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${re.workingColorSpace}" not supported.`), y(f, n), Kn(f, n, e), Promise.all(s).then(function() {
|
|
1674
|
+
return n.targets !== void 0 ? kn(f, n.targets, e) : f;
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
export {
|
|
1678
|
+
jn as GLTFLoader
|
|
1679
|
+
};
|