ss-component-new 1.3.699 → 1.3.701
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/JSEncrypt-B36c1iN5.js +1983 -0
- package/dist/MTLLoader-DC5Di-ql.js +657 -0
- package/dist/URDFLoader-BqfNCQLH.js +2299 -0
- package/dist/animationData-BNQm3jIu.js +83 -0
- package/dist/array-BXz16Xf3.js +1045 -0
- package/dist/clone-Dp_gc9ll.js +8 -0
- package/dist/config.js +1 -1
- package/dist/eleIcon-qStmsM1q.js +29 -0
- package/dist/fileUtil-UOt_otFo.js +20 -0
- package/dist/iconfont-B2Moc_Mi.js +1026 -0
- package/dist/icons/svg/functionList.svg +1 -0
- package/dist/icons/svg/method.svg +1 -0
- package/dist/index-11kpzK0A.js +209 -0
- package/dist/index-B0H3C7WG.js +103 -0
- package/dist/index-B3OyTnhN.js +119 -0
- package/dist/{index-BKK_dL6t.js → index-BHtNKL1L.js} +1 -1
- package/dist/index-Bbwy0rRx.js +411 -0
- package/dist/index-BbyrFzEO.js +93 -0
- package/dist/index-Bk_HGMFV.js +20578 -0
- package/dist/index-BooO2Bml.js +78 -0
- package/dist/index-BpgixwCC.js +83 -0
- package/dist/index-Bw3sTXPI.js +8993 -0
- package/dist/index-Bz8vSCfN.js +84 -0
- package/dist/index-CAm10a_p.js +107 -0
- package/dist/index-CGVmScXF.js +470 -0
- package/dist/index-CGi0g-VN.js +627 -0
- package/dist/index-CTD1ZbEQ.js +873 -0
- package/dist/index-CV_jQDcg.js +9 -0
- package/dist/index-CWOXvFfD.js +44 -0
- package/dist/{index-BKoAuSBh.js → index-ChNfRlIP.js} +18 -223
- package/dist/index-Ch_Lf81f.js +63004 -0
- package/dist/index-CjsQSzV6.js +572 -0
- package/dist/index-Ck_oTi7E.js +25297 -0
- package/dist/index-CydXQbtX.js +622 -0
- package/dist/index-DAJxL40d.js +55 -0
- package/dist/index-DBsEVMiM.js +201 -0
- package/dist/index-DG4hoOWt.js +665 -0
- package/dist/index-DUbk5m5P.js +99 -0
- package/dist/index-Ds6m_4JJ.js +28500 -0
- package/dist/index-DupTchhl.js +1000 -0
- package/dist/index-DyCq_odP.js +331 -0
- package/dist/index-DynGQqC3.js +93 -0
- package/dist/index-UB_oCdlo.js +62 -0
- package/dist/index-YjBTGOkO.js +61 -0
- package/dist/index-ib1DMe8v.js +98 -0
- package/dist/index-jbOjjV0j.js +447 -0
- package/dist/index-ke-XsSa7.js +30 -0
- package/dist/index-lPVVum78.js +48 -0
- package/dist/index-rlStojTL.js +52 -0
- package/dist/index-uF-ibwG0.js +9 -0
- package/dist/{index-DzkvwqGK.js → index.vue_vue_type_style_index_0_scoped_05e3a1d8_lang-D9DRZPyb.js} +113595 -105662
- package/dist/isString-0ZglyOfu.js +8 -0
- package/dist/localIcon-D5UoFBU5.js +76 -0
- package/dist/main-1uytY6Nj.js +502 -0
- package/dist/menuIndex-BB0uVPRX.js +159 -0
- package/dist/request-1RPa2bBn.js +9048 -0
- package/dist/ss-component.css +8 -2
- package/dist/ss-component.js +64 -28
- package/dist/ss-component2.js +75 -15
- package/dist/ss-component3.js +1 -1
- package/dist/threeModel-BEmaHjYZ.js +1109 -0
- package/dist/threePreview-D7ncVQLV.js +2810 -0
- package/dist/threeSceneView-ClvW-1FZ.js +1290 -0
- package/dist/threeSceneViewForCPMPIP-D7zwZFBW.js +539 -0
- package/dist/threeTrackPathView-VySiazeH.js +620 -0
- package/dist/threeViewerHost-sD-GHVTI.js +233 -0
- package/dist/urdfTree-B-7DfE39.js +254 -0
- package/dist/workpieceTreePanel-DB06G34P.js +559 -0
- package/package.json +6 -8
- package/public/config.js +1 -1
- package/public/icons/svg/functionList.svg +1 -0
- package/public/icons/svg/method.svg +1 -0
- package/dist/index-BqyJXXmI.js +0 -213
- package/dist/index-CTEz1Xq6.js +0 -182
- package/dist/index-CrIVk8ml.js +0 -1044
- package/dist/index-D1ebCzlM.js +0 -50
- package/dist/menu-ZnhLgjWw.js +0 -5218
- package/dist/origin-Bs605dr-.js +0 -11468
- /package/dist/icons/svg/{update.svg → Update.svg} +0 -0
- /package/dist/icons/svg/{table-close.svg → tableClose.svg} +0 -0
- /package/dist/icons/svg/{table-expand.svg → tableExpand.svg} +0 -0
- /package/public/icons/svg/{update.svg → Update.svg} +0 -0
- /package/public/icons/svg/{table-close.svg → tableClose.svg} +0 -0
- /package/public/icons/svg/{table-expand.svg → tableExpand.svg} +0 -0
|
@@ -0,0 +1,2299 @@
|
|
|
1
|
+
import { S as Ln } from "./MTLLoader-DC5Di-ql.js";
|
|
2
|
+
import { bg as vn, aI as Rn, R as lt, aw as At, U as In, V as pe, n as he, aS as dt, S as Mn, aF as Tt, C as ut, o as Le, aZ as ft, bh as Sn, k as ve, b6 as Se, c as me, ay as On, l as Gn, a4 as qn, P as ht, aX as Pn, i as jn, aA as Un, j as Fn, D as Hn, s as pt, aC as Et, b3 as mt, b5 as Bn, u as Dn, Y as ye, a_ as zn, a2 as bt, aU as Vn, h as Ce, w as Jn, aV as Kn, aY as Wn, aO as Oe, aQ as gt, bi as Yn, bj as Xn, bk as yt, bl as $n, bm as Zn, bn as Qn, bo as ei, a0 as ti, bp as ni, bq as ii, E as si } from "./index.vue_vue_type_style_index_0_scoped_05e3a1d8_lang-D9DRZPyb.js";
|
|
3
|
+
class wt extends vn {
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a new TGA loader.
|
|
6
|
+
*
|
|
7
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
8
|
+
*/
|
|
9
|
+
constructor(O) {
|
|
10
|
+
super(O);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parses the given TGA texture data.
|
|
14
|
+
*
|
|
15
|
+
* @param {ArrayBuffer} buffer - The raw texture data.
|
|
16
|
+
* @return {DataTextureLoader~TexData} An object representing the parsed texture data.
|
|
17
|
+
*/
|
|
18
|
+
parse(O) {
|
|
19
|
+
function Q(u) {
|
|
20
|
+
switch (u.image_type) {
|
|
21
|
+
// check indexed type
|
|
22
|
+
case Ne:
|
|
23
|
+
case ee:
|
|
24
|
+
if (u.colormap_length > 256 || u.colormap_size !== 24 || u.colormap_type !== 1)
|
|
25
|
+
throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");
|
|
26
|
+
break;
|
|
27
|
+
// check colormap type
|
|
28
|
+
case $:
|
|
29
|
+
case ie:
|
|
30
|
+
case be:
|
|
31
|
+
case ge:
|
|
32
|
+
if (u.colormap_type)
|
|
33
|
+
throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");
|
|
34
|
+
break;
|
|
35
|
+
// What the need of a file without data ?
|
|
36
|
+
case ke:
|
|
37
|
+
throw new Error("THREE.TGALoader: No data.");
|
|
38
|
+
// Invalid type ?
|
|
39
|
+
default:
|
|
40
|
+
throw new Error("THREE.TGALoader: Invalid type " + u.image_type);
|
|
41
|
+
}
|
|
42
|
+
if (u.width <= 0 || u.height <= 0)
|
|
43
|
+
throw new Error("THREE.TGALoader: Invalid image size.");
|
|
44
|
+
if (u.pixel_size !== 8 && u.pixel_size !== 16 && u.pixel_size !== 24 && u.pixel_size !== 32)
|
|
45
|
+
throw new Error("THREE.TGALoader: Invalid pixel size " + u.pixel_size);
|
|
46
|
+
}
|
|
47
|
+
function R(u, W, z, B, X) {
|
|
48
|
+
let U, D;
|
|
49
|
+
const _ = z.pixel_size >> 3, x = z.width * z.height * _;
|
|
50
|
+
if (W && (D = X.subarray(B, B += z.colormap_length * (z.colormap_size >> 3))), u) {
|
|
51
|
+
U = new Uint8Array(x);
|
|
52
|
+
let N, f, A, V = 0;
|
|
53
|
+
const le = new Uint8Array(_);
|
|
54
|
+
for (; V < x; )
|
|
55
|
+
if (N = X[B++], f = (N & 127) + 1, N & 128) {
|
|
56
|
+
for (A = 0; A < _; ++A)
|
|
57
|
+
le[A] = X[B++];
|
|
58
|
+
for (A = 0; A < f; ++A)
|
|
59
|
+
U.set(le, V + A * _);
|
|
60
|
+
V += _ * f;
|
|
61
|
+
} else {
|
|
62
|
+
for (f *= _, A = 0; A < f; ++A)
|
|
63
|
+
U[V + A] = X[B++];
|
|
64
|
+
V += f;
|
|
65
|
+
}
|
|
66
|
+
} else
|
|
67
|
+
U = X.subarray(
|
|
68
|
+
B,
|
|
69
|
+
B += W ? z.width * z.height : x
|
|
70
|
+
);
|
|
71
|
+
return {
|
|
72
|
+
pixel_data: U,
|
|
73
|
+
palettes: D
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function se(u, W, z, B, X, U, D, _, x) {
|
|
77
|
+
const N = x;
|
|
78
|
+
let f, A = 0, V, le;
|
|
79
|
+
const Ae = C.width;
|
|
80
|
+
for (le = W; le !== B; le += z)
|
|
81
|
+
for (V = X; V !== D; V += U, A++)
|
|
82
|
+
f = _[A], u[(V + Ae * le) * 4 + 3] = 255, u[(V + Ae * le) * 4 + 2] = N[f * 3 + 0], u[(V + Ae * le) * 4 + 1] = N[f * 3 + 1], u[(V + Ae * le) * 4 + 0] = N[f * 3 + 2];
|
|
83
|
+
return u;
|
|
84
|
+
}
|
|
85
|
+
function v(u, W, z, B, X, U, D, _) {
|
|
86
|
+
let x, N = 0, f, A;
|
|
87
|
+
const V = C.width;
|
|
88
|
+
for (A = W; A !== B; A += z)
|
|
89
|
+
for (f = X; f !== D; f += U, N += 2)
|
|
90
|
+
x = _[N + 0] + (_[N + 1] << 8), u[(f + V * A) * 4 + 0] = (x & 31744) >> 7, u[(f + V * A) * 4 + 1] = (x & 992) >> 2, u[(f + V * A) * 4 + 2] = (x & 31) << 3, u[(f + V * A) * 4 + 3] = x & 32768 ? 0 : 255;
|
|
91
|
+
return u;
|
|
92
|
+
}
|
|
93
|
+
function oe(u, W, z, B, X, U, D, _) {
|
|
94
|
+
let x = 0, N, f;
|
|
95
|
+
const A = C.width;
|
|
96
|
+
for (f = W; f !== B; f += z)
|
|
97
|
+
for (N = X; N !== D; N += U, x += 3)
|
|
98
|
+
u[(N + A * f) * 4 + 3] = 255, u[(N + A * f) * 4 + 2] = _[x + 0], u[(N + A * f) * 4 + 1] = _[x + 1], u[(N + A * f) * 4 + 0] = _[x + 2];
|
|
99
|
+
return u;
|
|
100
|
+
}
|
|
101
|
+
function I(u, W, z, B, X, U, D, _) {
|
|
102
|
+
let x = 0, N, f;
|
|
103
|
+
const A = C.width;
|
|
104
|
+
for (f = W; f !== B; f += z)
|
|
105
|
+
for (N = X; N !== D; N += U, x += 4)
|
|
106
|
+
u[(N + A * f) * 4 + 2] = _[x + 0], u[(N + A * f) * 4 + 1] = _[x + 1], u[(N + A * f) * 4 + 0] = _[x + 2], u[(N + A * f) * 4 + 3] = _[x + 3];
|
|
107
|
+
return u;
|
|
108
|
+
}
|
|
109
|
+
function Y(u, W, z, B, X, U, D, _) {
|
|
110
|
+
let x, N = 0, f, A;
|
|
111
|
+
const V = C.width;
|
|
112
|
+
for (A = W; A !== B; A += z)
|
|
113
|
+
for (f = X; f !== D; f += U, N++)
|
|
114
|
+
x = _[N], u[(f + V * A) * 4 + 0] = x, u[(f + V * A) * 4 + 1] = x, u[(f + V * A) * 4 + 2] = x, u[(f + V * A) * 4 + 3] = 255;
|
|
115
|
+
return u;
|
|
116
|
+
}
|
|
117
|
+
function ne(u, W, z, B, X, U, D, _) {
|
|
118
|
+
let x = 0, N, f;
|
|
119
|
+
const A = C.width;
|
|
120
|
+
for (f = W; f !== B; f += z)
|
|
121
|
+
for (N = X; N !== D; N += U, x += 2)
|
|
122
|
+
u[(N + A * f) * 4 + 0] = _[x + 0], u[(N + A * f) * 4 + 1] = _[x + 0], u[(N + A * f) * 4 + 2] = _[x + 0], u[(N + A * f) * 4 + 3] = _[x + 1];
|
|
123
|
+
return u;
|
|
124
|
+
}
|
|
125
|
+
function we(u, W, z, B, X) {
|
|
126
|
+
let U, D, _, x, N, f;
|
|
127
|
+
switch ((C.flags & M) >> P) {
|
|
128
|
+
default:
|
|
129
|
+
case J:
|
|
130
|
+
U = 0, _ = 1, N = W, D = 0, x = 1, f = z;
|
|
131
|
+
break;
|
|
132
|
+
case F:
|
|
133
|
+
U = 0, _ = 1, N = W, D = z - 1, x = -1, f = -1;
|
|
134
|
+
break;
|
|
135
|
+
case S:
|
|
136
|
+
U = W - 1, _ = -1, N = -1, D = 0, x = 1, f = z;
|
|
137
|
+
break;
|
|
138
|
+
case E:
|
|
139
|
+
U = W - 1, _ = -1, N = -1, D = z - 1, x = -1, f = -1;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
if (j)
|
|
143
|
+
switch (C.pixel_size) {
|
|
144
|
+
case 8:
|
|
145
|
+
Y(u, D, x, f, U, _, N, B);
|
|
146
|
+
break;
|
|
147
|
+
case 16:
|
|
148
|
+
ne(u, D, x, f, U, _, N, B);
|
|
149
|
+
break;
|
|
150
|
+
default:
|
|
151
|
+
throw new Error("THREE.TGALoader: Format not supported.");
|
|
152
|
+
}
|
|
153
|
+
else
|
|
154
|
+
switch (C.pixel_size) {
|
|
155
|
+
case 8:
|
|
156
|
+
se(u, D, x, f, U, _, N, B, X);
|
|
157
|
+
break;
|
|
158
|
+
case 16:
|
|
159
|
+
v(u, D, x, f, U, _, N, B);
|
|
160
|
+
break;
|
|
161
|
+
case 24:
|
|
162
|
+
oe(u, D, x, f, U, _, N, B);
|
|
163
|
+
break;
|
|
164
|
+
case 32:
|
|
165
|
+
I(u, D, x, f, U, _, N, B);
|
|
166
|
+
break;
|
|
167
|
+
default:
|
|
168
|
+
throw new Error("THREE.TGALoader: Format not supported.");
|
|
169
|
+
}
|
|
170
|
+
return u;
|
|
171
|
+
}
|
|
172
|
+
const ke = 0, Ne = 1, $ = 2, ie = 3, ee = 9, be = 10, ge = 11, M = 48, P = 4, F = 0, E = 1, J = 2, S = 3;
|
|
173
|
+
if (O.length < 19) throw new Error("THREE.TGALoader: Not enough data to contain header.");
|
|
174
|
+
let m = 0;
|
|
175
|
+
const h = new Uint8Array(O), C = {
|
|
176
|
+
id_length: h[m++],
|
|
177
|
+
colormap_type: h[m++],
|
|
178
|
+
image_type: h[m++],
|
|
179
|
+
colormap_index: h[m++] | h[m++] << 8,
|
|
180
|
+
colormap_length: h[m++] | h[m++] << 8,
|
|
181
|
+
colormap_size: h[m++],
|
|
182
|
+
origin: [
|
|
183
|
+
h[m++] | h[m++] << 8,
|
|
184
|
+
h[m++] | h[m++] << 8
|
|
185
|
+
],
|
|
186
|
+
width: h[m++] | h[m++] << 8,
|
|
187
|
+
height: h[m++] | h[m++] << 8,
|
|
188
|
+
pixel_size: h[m++],
|
|
189
|
+
flags: h[m++]
|
|
190
|
+
};
|
|
191
|
+
if (Q(C), C.id_length + m > O.length)
|
|
192
|
+
throw new Error("THREE.TGALoader: No data.");
|
|
193
|
+
m += C.id_length;
|
|
194
|
+
let L = !1, k = !1, j = !1;
|
|
195
|
+
switch (C.image_type) {
|
|
196
|
+
case ee:
|
|
197
|
+
L = !0, k = !0;
|
|
198
|
+
break;
|
|
199
|
+
case Ne:
|
|
200
|
+
k = !0;
|
|
201
|
+
break;
|
|
202
|
+
case be:
|
|
203
|
+
L = !0;
|
|
204
|
+
break;
|
|
205
|
+
case $:
|
|
206
|
+
break;
|
|
207
|
+
case ge:
|
|
208
|
+
L = !0, j = !0;
|
|
209
|
+
break;
|
|
210
|
+
case ie:
|
|
211
|
+
j = !0;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
const ae = new Uint8Array(C.width * C.height * 4), te = R(L, k, C, m, h);
|
|
215
|
+
return we(ae, C.width, C.height, te.pixel_data, te.palettes), {
|
|
216
|
+
data: ae,
|
|
217
|
+
width: C.width,
|
|
218
|
+
height: C.height,
|
|
219
|
+
flipY: !0,
|
|
220
|
+
generateMipmaps: !0,
|
|
221
|
+
minFilter: Rn
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
class oi extends lt {
|
|
226
|
+
/**
|
|
227
|
+
* Starts loading from the given URL and passes the loaded Collada asset
|
|
228
|
+
* to the `onLoad()` callback.
|
|
229
|
+
*
|
|
230
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
231
|
+
* @param {function({scene:Group,animations:Array<AnimationClip>,kinematics:Object})} onLoad - Executed when the loading process has been finished.
|
|
232
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
233
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
234
|
+
*/
|
|
235
|
+
load(O, Q, R, se) {
|
|
236
|
+
const v = this, oe = v.path === "" ? At.extractUrlBase(O) : v.path, I = new In(v.manager);
|
|
237
|
+
I.setPath(v.path), I.setRequestHeader(v.requestHeader), I.setWithCredentials(v.withCredentials), I.load(O, function(Y) {
|
|
238
|
+
try {
|
|
239
|
+
Q(v.parse(Y, oe));
|
|
240
|
+
} catch (ne) {
|
|
241
|
+
se ? se(ne) : console.error(ne), v.manager.itemError(O);
|
|
242
|
+
}
|
|
243
|
+
}, R, se);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Parses the given Collada data and returns a result oject holding the parsed scene,
|
|
247
|
+
* an array of animation clips and kinematics.
|
|
248
|
+
*
|
|
249
|
+
* @param {string} text - The raw Collada data as a string.
|
|
250
|
+
* @param {string} path - The asset path.
|
|
251
|
+
* @return {{scene:Group,animations:Array<AnimationClip>,kinematics:Object}} An object representing the parsed asset.
|
|
252
|
+
*/
|
|
253
|
+
parse(O, Q) {
|
|
254
|
+
function R(t, e) {
|
|
255
|
+
const i = [], n = t.childNodes;
|
|
256
|
+
for (let s = 0, o = n.length; s < o; s++) {
|
|
257
|
+
const r = n[s];
|
|
258
|
+
r.nodeName === e && i.push(r);
|
|
259
|
+
}
|
|
260
|
+
return i;
|
|
261
|
+
}
|
|
262
|
+
function se(t) {
|
|
263
|
+
if (t.length === 0) return [];
|
|
264
|
+
const e = t.trim().split(/\s+/), i = new Array(e.length);
|
|
265
|
+
for (let n = 0, s = e.length; n < s; n++)
|
|
266
|
+
i[n] = e[n];
|
|
267
|
+
return i;
|
|
268
|
+
}
|
|
269
|
+
function v(t) {
|
|
270
|
+
if (t.length === 0) return [];
|
|
271
|
+
const e = t.trim().split(/\s+/), i = new Array(e.length);
|
|
272
|
+
for (let n = 0, s = e.length; n < s; n++)
|
|
273
|
+
i[n] = parseFloat(e[n]);
|
|
274
|
+
return i;
|
|
275
|
+
}
|
|
276
|
+
function oe(t) {
|
|
277
|
+
if (t.length === 0) return [];
|
|
278
|
+
const e = t.trim().split(/\s+/), i = new Array(e.length);
|
|
279
|
+
for (let n = 0, s = e.length; n < s; n++)
|
|
280
|
+
i[n] = parseInt(e[n]);
|
|
281
|
+
return i;
|
|
282
|
+
}
|
|
283
|
+
function I(t) {
|
|
284
|
+
return t.substring(1);
|
|
285
|
+
}
|
|
286
|
+
function Y() {
|
|
287
|
+
return "three_default_" + _n++;
|
|
288
|
+
}
|
|
289
|
+
function ne(t) {
|
|
290
|
+
return Object.keys(t).length === 0;
|
|
291
|
+
}
|
|
292
|
+
function we(t) {
|
|
293
|
+
return {
|
|
294
|
+
unit: ke(R(t, "unit")[0]),
|
|
295
|
+
upAxis: Ne(R(t, "up_axis")[0])
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function ke(t) {
|
|
299
|
+
return t !== void 0 && t.hasAttribute("meter") === !0 ? parseFloat(t.getAttribute("meter")) : 1;
|
|
300
|
+
}
|
|
301
|
+
function Ne(t) {
|
|
302
|
+
return t !== void 0 ? t.textContent : "Y_UP";
|
|
303
|
+
}
|
|
304
|
+
function $(t, e, i, n) {
|
|
305
|
+
const s = R(t, e)[0];
|
|
306
|
+
if (s !== void 0) {
|
|
307
|
+
const o = R(s, i);
|
|
308
|
+
for (let r = 0; r < o.length; r++)
|
|
309
|
+
n(o[r]);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function ie(t, e) {
|
|
313
|
+
for (const i in t) {
|
|
314
|
+
const n = t[i];
|
|
315
|
+
n.build = e(t[i]);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function ee(t, e) {
|
|
319
|
+
return t.build !== void 0 || (t.build = e(t)), t.build;
|
|
320
|
+
}
|
|
321
|
+
function be(t) {
|
|
322
|
+
const e = {
|
|
323
|
+
sources: {},
|
|
324
|
+
samplers: {},
|
|
325
|
+
channels: {}
|
|
326
|
+
};
|
|
327
|
+
let i = !1;
|
|
328
|
+
for (let n = 0, s = t.childNodes.length; n < s; n++) {
|
|
329
|
+
const o = t.childNodes[n];
|
|
330
|
+
if (o.nodeType !== 1) continue;
|
|
331
|
+
let r;
|
|
332
|
+
switch (o.nodeName) {
|
|
333
|
+
case "source":
|
|
334
|
+
r = o.getAttribute("id"), e.sources[r] = Ge(o);
|
|
335
|
+
break;
|
|
336
|
+
case "sampler":
|
|
337
|
+
r = o.getAttribute("id"), e.samplers[r] = ge(o);
|
|
338
|
+
break;
|
|
339
|
+
case "channel":
|
|
340
|
+
r = o.getAttribute("target"), e.channels[r] = M(o);
|
|
341
|
+
break;
|
|
342
|
+
case "animation":
|
|
343
|
+
be(o), i = !0;
|
|
344
|
+
break;
|
|
345
|
+
default:
|
|
346
|
+
console.log(o);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
i === !1 && (T.animations[t.getAttribute("id") || Le.generateUUID()] = e);
|
|
350
|
+
}
|
|
351
|
+
function ge(t) {
|
|
352
|
+
const e = {
|
|
353
|
+
inputs: {}
|
|
354
|
+
};
|
|
355
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
356
|
+
const s = t.childNodes[i];
|
|
357
|
+
if (s.nodeType === 1)
|
|
358
|
+
switch (s.nodeName) {
|
|
359
|
+
case "input":
|
|
360
|
+
const o = I(s.getAttribute("source")), r = s.getAttribute("semantic");
|
|
361
|
+
e.inputs[r] = o;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return e;
|
|
366
|
+
}
|
|
367
|
+
function M(t) {
|
|
368
|
+
const e = {};
|
|
369
|
+
let n = t.getAttribute("target").split("/");
|
|
370
|
+
const s = n.shift();
|
|
371
|
+
let o = n.shift();
|
|
372
|
+
const r = o.indexOf("(") !== -1, d = o.indexOf(".") !== -1;
|
|
373
|
+
if (d)
|
|
374
|
+
n = o.split("."), o = n.shift(), e.member = n.shift();
|
|
375
|
+
else if (r) {
|
|
376
|
+
const c = o.split("(");
|
|
377
|
+
o = c.shift();
|
|
378
|
+
for (let l = 0; l < c.length; l++)
|
|
379
|
+
c[l] = parseInt(c[l].replace(/\)/, ""));
|
|
380
|
+
e.indices = c;
|
|
381
|
+
}
|
|
382
|
+
return e.id = s, e.sid = o, e.arraySyntax = r, e.memberSyntax = d, e.sampler = I(t.getAttribute("source")), e;
|
|
383
|
+
}
|
|
384
|
+
function P(t) {
|
|
385
|
+
const e = [], i = t.channels, n = t.samplers, s = t.sources;
|
|
386
|
+
for (const o in i)
|
|
387
|
+
if (i.hasOwnProperty(o)) {
|
|
388
|
+
const r = i[o], d = n[r.sampler], c = d.inputs.INPUT, l = d.inputs.OUTPUT, g = s[c], a = s[l], b = E(r, g, a);
|
|
389
|
+
C(b, e);
|
|
390
|
+
}
|
|
391
|
+
return e;
|
|
392
|
+
}
|
|
393
|
+
function F(t) {
|
|
394
|
+
return ee(T.animations[t], P);
|
|
395
|
+
}
|
|
396
|
+
function E(t, e, i) {
|
|
397
|
+
const n = T.nodes[t.id], s = Ee(n.id), o = n.transforms[t.sid], r = n.matrix.clone().transpose();
|
|
398
|
+
let d, c, l, g, a, b;
|
|
399
|
+
const p = {};
|
|
400
|
+
switch (o) {
|
|
401
|
+
case "matrix":
|
|
402
|
+
for (l = 0, g = e.array.length; l < g; l++)
|
|
403
|
+
if (d = e.array[l], c = l * i.stride, p[d] === void 0 && (p[d] = {}), t.arraySyntax === !0) {
|
|
404
|
+
const K = i.array[c], H = t.indices[0] + 4 * t.indices[1];
|
|
405
|
+
p[d][H] = K;
|
|
406
|
+
} else
|
|
407
|
+
for (a = 0, b = i.stride; a < b; a++)
|
|
408
|
+
p[d][a] = i.array[c + a];
|
|
409
|
+
break;
|
|
410
|
+
case "translate":
|
|
411
|
+
console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', o);
|
|
412
|
+
break;
|
|
413
|
+
case "rotate":
|
|
414
|
+
console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', o);
|
|
415
|
+
break;
|
|
416
|
+
case "scale":
|
|
417
|
+
console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.', o);
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
const w = J(p, r);
|
|
421
|
+
return {
|
|
422
|
+
name: s.uuid,
|
|
423
|
+
keyframes: w
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function J(t, e) {
|
|
427
|
+
const i = [];
|
|
428
|
+
for (const s in t)
|
|
429
|
+
i.push({ time: parseFloat(s), value: t[s] });
|
|
430
|
+
i.sort(n);
|
|
431
|
+
for (let s = 0; s < 16; s++)
|
|
432
|
+
L(i, s, e.elements[s]);
|
|
433
|
+
return i;
|
|
434
|
+
function n(s, o) {
|
|
435
|
+
return s.time - o.time;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
const S = new pe(), m = new pe(), h = new Et();
|
|
439
|
+
function C(t, e) {
|
|
440
|
+
const i = t.keyframes, n = t.name, s = [], o = [], r = [], d = [];
|
|
441
|
+
for (let c = 0, l = i.length; c < l; c++) {
|
|
442
|
+
const g = i[c], a = g.time, b = g.value;
|
|
443
|
+
ce.fromArray(b).transpose(), ce.decompose(S, h, m), s.push(a), o.push(S.x, S.y, S.z), r.push(h.x, h.y, h.z, h.w), d.push(m.x, m.y, m.z);
|
|
444
|
+
}
|
|
445
|
+
return o.length > 0 && e.push(new mt(n + ".position", s, o)), r.length > 0 && e.push(new Bn(n + ".quaternion", s, r)), d.length > 0 && e.push(new mt(n + ".scale", s, d)), e;
|
|
446
|
+
}
|
|
447
|
+
function L(t, e, i) {
|
|
448
|
+
let n, s = !0, o, r;
|
|
449
|
+
for (o = 0, r = t.length; o < r; o++)
|
|
450
|
+
n = t[o], n.value[e] === void 0 ? n.value[e] = null : s = !1;
|
|
451
|
+
if (s === !0)
|
|
452
|
+
for (o = 0, r = t.length; o < r; o++)
|
|
453
|
+
n = t[o], n.value[e] = i;
|
|
454
|
+
else
|
|
455
|
+
k(t, e);
|
|
456
|
+
}
|
|
457
|
+
function k(t, e) {
|
|
458
|
+
let i, n;
|
|
459
|
+
for (let s = 0, o = t.length; s < o; s++) {
|
|
460
|
+
const r = t[s];
|
|
461
|
+
if (r.value[e] === null) {
|
|
462
|
+
if (i = j(t, s, e), n = ae(t, s, e), i === null) {
|
|
463
|
+
r.value[e] = n.value[e];
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (n === null) {
|
|
467
|
+
r.value[e] = i.value[e];
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
te(r, i, n, e);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function j(t, e, i) {
|
|
475
|
+
for (; e >= 0; ) {
|
|
476
|
+
const n = t[e];
|
|
477
|
+
if (n.value[i] !== null) return n;
|
|
478
|
+
e--;
|
|
479
|
+
}
|
|
480
|
+
return null;
|
|
481
|
+
}
|
|
482
|
+
function ae(t, e, i) {
|
|
483
|
+
for (; e < t.length; ) {
|
|
484
|
+
const n = t[e];
|
|
485
|
+
if (n.value[i] !== null) return n;
|
|
486
|
+
e++;
|
|
487
|
+
}
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
function te(t, e, i, n) {
|
|
491
|
+
if (i.time - e.time === 0) {
|
|
492
|
+
t.value[n] = e.value[n];
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
t.value[n] = (t.time - e.time) * (i.value[n] - e.value[n]) / (i.time - e.time) + e.value[n];
|
|
496
|
+
}
|
|
497
|
+
function u(t) {
|
|
498
|
+
const e = {
|
|
499
|
+
name: t.getAttribute("id") || "default",
|
|
500
|
+
start: parseFloat(t.getAttribute("start") || 0),
|
|
501
|
+
end: parseFloat(t.getAttribute("end") || 0),
|
|
502
|
+
animations: []
|
|
503
|
+
};
|
|
504
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
505
|
+
const s = t.childNodes[i];
|
|
506
|
+
if (s.nodeType === 1)
|
|
507
|
+
switch (s.nodeName) {
|
|
508
|
+
case "instance_animation":
|
|
509
|
+
e.animations.push(I(s.getAttribute("url")));
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
T.clips[t.getAttribute("id")] = e;
|
|
514
|
+
}
|
|
515
|
+
function W(t) {
|
|
516
|
+
const e = [], i = t.name, n = t.end - t.start || -1, s = t.animations;
|
|
517
|
+
for (let o = 0, r = s.length; o < r; o++) {
|
|
518
|
+
const d = F(s[o]);
|
|
519
|
+
for (let c = 0, l = d.length; c < l; c++)
|
|
520
|
+
e.push(d[c]);
|
|
521
|
+
}
|
|
522
|
+
return new ft(i, n, e);
|
|
523
|
+
}
|
|
524
|
+
function z(t) {
|
|
525
|
+
return ee(T.clips[t], W);
|
|
526
|
+
}
|
|
527
|
+
function B(t) {
|
|
528
|
+
const e = {};
|
|
529
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
530
|
+
const s = t.childNodes[i];
|
|
531
|
+
if (s.nodeType === 1)
|
|
532
|
+
switch (s.nodeName) {
|
|
533
|
+
case "skin":
|
|
534
|
+
e.id = I(s.getAttribute("source")), e.skin = X(s);
|
|
535
|
+
break;
|
|
536
|
+
case "morph":
|
|
537
|
+
e.id = I(s.getAttribute("source")), console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
T.controllers[t.getAttribute("id")] = e;
|
|
542
|
+
}
|
|
543
|
+
function X(t) {
|
|
544
|
+
const e = {
|
|
545
|
+
sources: {}
|
|
546
|
+
};
|
|
547
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
548
|
+
const s = t.childNodes[i];
|
|
549
|
+
if (s.nodeType === 1)
|
|
550
|
+
switch (s.nodeName) {
|
|
551
|
+
case "bind_shape_matrix":
|
|
552
|
+
e.bindShapeMatrix = v(s.textContent);
|
|
553
|
+
break;
|
|
554
|
+
case "source":
|
|
555
|
+
const o = s.getAttribute("id");
|
|
556
|
+
e.sources[o] = Ge(s);
|
|
557
|
+
break;
|
|
558
|
+
case "joints":
|
|
559
|
+
e.joints = U(s);
|
|
560
|
+
break;
|
|
561
|
+
case "vertex_weights":
|
|
562
|
+
e.vertexWeights = D(s);
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return e;
|
|
567
|
+
}
|
|
568
|
+
function U(t) {
|
|
569
|
+
const e = {
|
|
570
|
+
inputs: {}
|
|
571
|
+
};
|
|
572
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
573
|
+
const s = t.childNodes[i];
|
|
574
|
+
if (s.nodeType === 1)
|
|
575
|
+
switch (s.nodeName) {
|
|
576
|
+
case "input":
|
|
577
|
+
const o = s.getAttribute("semantic"), r = I(s.getAttribute("source"));
|
|
578
|
+
e.inputs[o] = r;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return e;
|
|
583
|
+
}
|
|
584
|
+
function D(t) {
|
|
585
|
+
const e = {
|
|
586
|
+
inputs: {}
|
|
587
|
+
};
|
|
588
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
589
|
+
const s = t.childNodes[i];
|
|
590
|
+
if (s.nodeType === 1)
|
|
591
|
+
switch (s.nodeName) {
|
|
592
|
+
case "input":
|
|
593
|
+
const o = s.getAttribute("semantic"), r = I(s.getAttribute("source")), d = parseInt(s.getAttribute("offset"));
|
|
594
|
+
e.inputs[o] = { id: r, offset: d };
|
|
595
|
+
break;
|
|
596
|
+
case "vcount":
|
|
597
|
+
e.vcount = oe(s.textContent);
|
|
598
|
+
break;
|
|
599
|
+
case "v":
|
|
600
|
+
e.v = oe(s.textContent);
|
|
601
|
+
break;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return e;
|
|
605
|
+
}
|
|
606
|
+
function _(t) {
|
|
607
|
+
const e = {
|
|
608
|
+
id: t.id
|
|
609
|
+
}, i = T.geometries[e.id];
|
|
610
|
+
return t.skin !== void 0 && (e.skin = x(t.skin), i.sources.skinIndices = e.skin.indices, i.sources.skinWeights = e.skin.weights), e;
|
|
611
|
+
}
|
|
612
|
+
function x(t) {
|
|
613
|
+
const i = {
|
|
614
|
+
joints: [],
|
|
615
|
+
// this must be an array to preserve the joint order
|
|
616
|
+
indices: {
|
|
617
|
+
array: [],
|
|
618
|
+
stride: 4
|
|
619
|
+
},
|
|
620
|
+
weights: {
|
|
621
|
+
array: [],
|
|
622
|
+
stride: 4
|
|
623
|
+
}
|
|
624
|
+
}, n = t.sources, s = t.vertexWeights, o = s.vcount, r = s.v, d = s.inputs.JOINT.offset, c = s.inputs.WEIGHT.offset, l = t.sources[t.joints.inputs.JOINT], g = t.sources[t.joints.inputs.INV_BIND_MATRIX], a = n[s.inputs.WEIGHT.id].array;
|
|
625
|
+
let b = 0, p, w, y;
|
|
626
|
+
for (p = 0, y = o.length; p < y; p++) {
|
|
627
|
+
const H = o[p], G = [];
|
|
628
|
+
for (w = 0; w < H; w++) {
|
|
629
|
+
const q = r[b + d], fe = r[b + c], re = a[fe];
|
|
630
|
+
G.push({ index: q, weight: re }), b += 2;
|
|
631
|
+
}
|
|
632
|
+
for (G.sort(K), w = 0; w < 4; w++) {
|
|
633
|
+
const q = G[w];
|
|
634
|
+
q !== void 0 ? (i.indices.array.push(q.index), i.weights.array.push(q.weight)) : (i.indices.array.push(0), i.weights.array.push(0));
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
for (t.bindShapeMatrix ? i.bindMatrix = new he().fromArray(t.bindShapeMatrix).transpose() : i.bindMatrix = new he().identity(), p = 0, y = l.array.length; p < y; p++) {
|
|
638
|
+
const H = l.array[p], G = new he().fromArray(g.array, p * g.stride).transpose();
|
|
639
|
+
i.joints.push({ name: H, boneInverse: G });
|
|
640
|
+
}
|
|
641
|
+
return i;
|
|
642
|
+
function K(H, G) {
|
|
643
|
+
return G.weight - H.weight;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
function N(t) {
|
|
647
|
+
return ee(T.controllers[t], _);
|
|
648
|
+
}
|
|
649
|
+
function f(t) {
|
|
650
|
+
const e = {
|
|
651
|
+
init_from: R(t, "init_from")[0].textContent
|
|
652
|
+
};
|
|
653
|
+
T.images[t.getAttribute("id")] = e;
|
|
654
|
+
}
|
|
655
|
+
function A(t) {
|
|
656
|
+
return t.build !== void 0 ? t.build : t.init_from;
|
|
657
|
+
}
|
|
658
|
+
function V(t) {
|
|
659
|
+
const e = T.images[t];
|
|
660
|
+
return e !== void 0 ? ee(e, A) : (console.warn("THREE.ColladaLoader: Couldn't find image with ID:", t), null);
|
|
661
|
+
}
|
|
662
|
+
function le(t) {
|
|
663
|
+
const e = {};
|
|
664
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
665
|
+
const s = t.childNodes[i];
|
|
666
|
+
if (s.nodeType === 1)
|
|
667
|
+
switch (s.nodeName) {
|
|
668
|
+
case "profile_COMMON":
|
|
669
|
+
e.profile = Ae(s);
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
T.effects[t.getAttribute("id")] = e;
|
|
674
|
+
}
|
|
675
|
+
function Ae(t) {
|
|
676
|
+
const e = {
|
|
677
|
+
surfaces: {},
|
|
678
|
+
samplers: {}
|
|
679
|
+
};
|
|
680
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
681
|
+
const s = t.childNodes[i];
|
|
682
|
+
if (s.nodeType === 1)
|
|
683
|
+
switch (s.nodeName) {
|
|
684
|
+
case "newparam":
|
|
685
|
+
xt(s, e);
|
|
686
|
+
break;
|
|
687
|
+
case "technique":
|
|
688
|
+
e.technique = Lt(s);
|
|
689
|
+
break;
|
|
690
|
+
case "extra":
|
|
691
|
+
e.extra = Be(s);
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return e;
|
|
696
|
+
}
|
|
697
|
+
function xt(t, e) {
|
|
698
|
+
const i = t.getAttribute("sid");
|
|
699
|
+
for (let n = 0, s = t.childNodes.length; n < s; n++) {
|
|
700
|
+
const o = t.childNodes[n];
|
|
701
|
+
if (o.nodeType === 1)
|
|
702
|
+
switch (o.nodeName) {
|
|
703
|
+
case "surface":
|
|
704
|
+
e.surfaces[i] = _t(o);
|
|
705
|
+
break;
|
|
706
|
+
case "sampler2D":
|
|
707
|
+
e.samplers[i] = Ct(o);
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function _t(t) {
|
|
713
|
+
const e = {};
|
|
714
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
715
|
+
const s = t.childNodes[i];
|
|
716
|
+
if (s.nodeType === 1)
|
|
717
|
+
switch (s.nodeName) {
|
|
718
|
+
case "init_from":
|
|
719
|
+
e.init_from = s.textContent;
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return e;
|
|
724
|
+
}
|
|
725
|
+
function Ct(t) {
|
|
726
|
+
const e = {};
|
|
727
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
728
|
+
const s = t.childNodes[i];
|
|
729
|
+
if (s.nodeType === 1)
|
|
730
|
+
switch (s.nodeName) {
|
|
731
|
+
case "source":
|
|
732
|
+
e.source = s.textContent;
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return e;
|
|
737
|
+
}
|
|
738
|
+
function Lt(t) {
|
|
739
|
+
const e = {};
|
|
740
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
741
|
+
const s = t.childNodes[i];
|
|
742
|
+
if (s.nodeType === 1)
|
|
743
|
+
switch (s.nodeName) {
|
|
744
|
+
case "constant":
|
|
745
|
+
case "lambert":
|
|
746
|
+
case "blinn":
|
|
747
|
+
case "phong":
|
|
748
|
+
e.type = s.nodeName, e.parameters = vt(s);
|
|
749
|
+
break;
|
|
750
|
+
case "extra":
|
|
751
|
+
e.extra = Be(s);
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return e;
|
|
756
|
+
}
|
|
757
|
+
function vt(t) {
|
|
758
|
+
const e = {};
|
|
759
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
760
|
+
const s = t.childNodes[i];
|
|
761
|
+
if (s.nodeType === 1)
|
|
762
|
+
switch (s.nodeName) {
|
|
763
|
+
case "emission":
|
|
764
|
+
case "diffuse":
|
|
765
|
+
case "specular":
|
|
766
|
+
case "bump":
|
|
767
|
+
case "ambient":
|
|
768
|
+
case "shininess":
|
|
769
|
+
case "transparency":
|
|
770
|
+
e[s.nodeName] = Fe(s);
|
|
771
|
+
break;
|
|
772
|
+
case "transparent":
|
|
773
|
+
e[s.nodeName] = {
|
|
774
|
+
opaque: s.hasAttribute("opaque") ? s.getAttribute("opaque") : "A_ONE",
|
|
775
|
+
data: Fe(s)
|
|
776
|
+
};
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
return e;
|
|
781
|
+
}
|
|
782
|
+
function Fe(t) {
|
|
783
|
+
const e = {};
|
|
784
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
785
|
+
const s = t.childNodes[i];
|
|
786
|
+
if (s.nodeType === 1)
|
|
787
|
+
switch (s.nodeName) {
|
|
788
|
+
case "color":
|
|
789
|
+
e[s.nodeName] = v(s.textContent);
|
|
790
|
+
break;
|
|
791
|
+
case "float":
|
|
792
|
+
e[s.nodeName] = parseFloat(s.textContent);
|
|
793
|
+
break;
|
|
794
|
+
case "texture":
|
|
795
|
+
e[s.nodeName] = { id: s.getAttribute("texture"), extra: He(s) };
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return e;
|
|
800
|
+
}
|
|
801
|
+
function He(t) {
|
|
802
|
+
const e = {
|
|
803
|
+
technique: {}
|
|
804
|
+
};
|
|
805
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
806
|
+
const s = t.childNodes[i];
|
|
807
|
+
if (s.nodeType === 1)
|
|
808
|
+
switch (s.nodeName) {
|
|
809
|
+
case "extra":
|
|
810
|
+
Rt(s, e);
|
|
811
|
+
break;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
return e;
|
|
815
|
+
}
|
|
816
|
+
function Rt(t, e) {
|
|
817
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
818
|
+
const s = t.childNodes[i];
|
|
819
|
+
if (s.nodeType === 1)
|
|
820
|
+
switch (s.nodeName) {
|
|
821
|
+
case "technique":
|
|
822
|
+
It(s, e);
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
function It(t, e) {
|
|
828
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
829
|
+
const s = t.childNodes[i];
|
|
830
|
+
if (s.nodeType === 1)
|
|
831
|
+
switch (s.nodeName) {
|
|
832
|
+
case "repeatU":
|
|
833
|
+
case "repeatV":
|
|
834
|
+
case "offsetU":
|
|
835
|
+
case "offsetV":
|
|
836
|
+
e.technique[s.nodeName] = parseFloat(s.textContent);
|
|
837
|
+
break;
|
|
838
|
+
case "wrapU":
|
|
839
|
+
case "wrapV":
|
|
840
|
+
s.textContent.toUpperCase() === "TRUE" ? e.technique[s.nodeName] = 1 : s.textContent.toUpperCase() === "FALSE" ? e.technique[s.nodeName] = 0 : e.technique[s.nodeName] = parseInt(s.textContent);
|
|
841
|
+
break;
|
|
842
|
+
case "bump":
|
|
843
|
+
e[s.nodeName] = De(s);
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
function Be(t) {
|
|
849
|
+
const e = {};
|
|
850
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
851
|
+
const s = t.childNodes[i];
|
|
852
|
+
if (s.nodeType === 1)
|
|
853
|
+
switch (s.nodeName) {
|
|
854
|
+
case "technique":
|
|
855
|
+
e.technique = Mt(s);
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return e;
|
|
860
|
+
}
|
|
861
|
+
function Mt(t) {
|
|
862
|
+
const e = {};
|
|
863
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
864
|
+
const s = t.childNodes[i];
|
|
865
|
+
if (s.nodeType === 1)
|
|
866
|
+
switch (s.nodeName) {
|
|
867
|
+
case "double_sided":
|
|
868
|
+
e[s.nodeName] = parseInt(s.textContent);
|
|
869
|
+
break;
|
|
870
|
+
case "bump":
|
|
871
|
+
e[s.nodeName] = De(s);
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return e;
|
|
876
|
+
}
|
|
877
|
+
function De(t) {
|
|
878
|
+
const e = {};
|
|
879
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
880
|
+
const s = t.childNodes[i];
|
|
881
|
+
if (s.nodeType === 1)
|
|
882
|
+
switch (s.nodeName) {
|
|
883
|
+
case "texture":
|
|
884
|
+
e[s.nodeName] = { id: s.getAttribute("texture"), texcoord: s.getAttribute("texcoord"), extra: He(s) };
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return e;
|
|
889
|
+
}
|
|
890
|
+
function ze(t) {
|
|
891
|
+
return t;
|
|
892
|
+
}
|
|
893
|
+
function St(t) {
|
|
894
|
+
return ee(T.effects[t], ze);
|
|
895
|
+
}
|
|
896
|
+
function Ot(t) {
|
|
897
|
+
const e = {
|
|
898
|
+
name: t.getAttribute("name")
|
|
899
|
+
};
|
|
900
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
901
|
+
const s = t.childNodes[i];
|
|
902
|
+
if (s.nodeType === 1)
|
|
903
|
+
switch (s.nodeName) {
|
|
904
|
+
case "instance_effect":
|
|
905
|
+
e.url = I(s.getAttribute("url"));
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
T.materials[t.getAttribute("id")] = e;
|
|
910
|
+
}
|
|
911
|
+
function Gt(t) {
|
|
912
|
+
let e, i = t.slice((t.lastIndexOf(".") - 1 >>> 0) + 2);
|
|
913
|
+
switch (i = i.toLowerCase(), i) {
|
|
914
|
+
case "tga":
|
|
915
|
+
e = je;
|
|
916
|
+
break;
|
|
917
|
+
default:
|
|
918
|
+
e = rt;
|
|
919
|
+
}
|
|
920
|
+
return e;
|
|
921
|
+
}
|
|
922
|
+
function Ve(t) {
|
|
923
|
+
const e = St(t.url), i = e.profile.technique;
|
|
924
|
+
let n;
|
|
925
|
+
switch (i.type) {
|
|
926
|
+
case "phong":
|
|
927
|
+
case "blinn":
|
|
928
|
+
n = new ve();
|
|
929
|
+
break;
|
|
930
|
+
case "lambert":
|
|
931
|
+
n = new Sn();
|
|
932
|
+
break;
|
|
933
|
+
default:
|
|
934
|
+
n = new dt();
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
937
|
+
n.name = t.name || "";
|
|
938
|
+
function s(c, l = null) {
|
|
939
|
+
const g = e.profile.samplers[c.id];
|
|
940
|
+
let a = null;
|
|
941
|
+
if (g !== void 0) {
|
|
942
|
+
const b = e.profile.surfaces[g.source];
|
|
943
|
+
a = V(b.init_from);
|
|
944
|
+
} else
|
|
945
|
+
console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."), a = V(c.id);
|
|
946
|
+
if (a !== null) {
|
|
947
|
+
const b = Gt(a);
|
|
948
|
+
if (b !== void 0) {
|
|
949
|
+
const p = b.load(a), w = c.extra;
|
|
950
|
+
if (w !== void 0 && w.technique !== void 0 && ne(w.technique) === !1) {
|
|
951
|
+
const y = w.technique;
|
|
952
|
+
p.wrapS = y.wrapU ? Oe : gt, p.wrapT = y.wrapV ? Oe : gt, p.offset.set(y.offsetU || 0, y.offsetV || 0), p.repeat.set(y.repeatU || 1, y.repeatV || 1);
|
|
953
|
+
} else
|
|
954
|
+
p.wrapS = Oe, p.wrapT = Oe;
|
|
955
|
+
return l !== null && (p.colorSpace = l), p;
|
|
956
|
+
} else
|
|
957
|
+
return console.warn("THREE.ColladaLoader: Loader for texture %s not found.", a), null;
|
|
958
|
+
} else
|
|
959
|
+
return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:", c.id), null;
|
|
960
|
+
}
|
|
961
|
+
const o = i.parameters;
|
|
962
|
+
for (const c in o) {
|
|
963
|
+
const l = o[c];
|
|
964
|
+
switch (c) {
|
|
965
|
+
case "diffuse":
|
|
966
|
+
l.color && n.color.fromArray(l.color), l.texture && (n.map = s(l.texture, me));
|
|
967
|
+
break;
|
|
968
|
+
case "specular":
|
|
969
|
+
l.color && n.specular && n.specular.fromArray(l.color), l.texture && (n.specularMap = s(l.texture));
|
|
970
|
+
break;
|
|
971
|
+
case "bump":
|
|
972
|
+
l.texture && (n.normalMap = s(l.texture));
|
|
973
|
+
break;
|
|
974
|
+
case "ambient":
|
|
975
|
+
l.texture && (n.lightMap = s(l.texture, me));
|
|
976
|
+
break;
|
|
977
|
+
case "shininess":
|
|
978
|
+
l.float && n.shininess && (n.shininess = l.float);
|
|
979
|
+
break;
|
|
980
|
+
case "emission":
|
|
981
|
+
l.color && n.emissive && n.emissive.fromArray(l.color), l.texture && (n.emissiveMap = s(l.texture, me));
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
Se.colorSpaceToWorking(n.color, me), n.specular && Se.colorSpaceToWorking(n.specular, me), n.emissive && Se.colorSpaceToWorking(n.emissive, me);
|
|
986
|
+
let r = o.transparent, d = o.transparency;
|
|
987
|
+
if (d === void 0 && r && (d = {
|
|
988
|
+
float: 1
|
|
989
|
+
}), r === void 0 && d && (r = {
|
|
990
|
+
opaque: "A_ONE",
|
|
991
|
+
data: {
|
|
992
|
+
color: [1, 1, 1, 1]
|
|
993
|
+
}
|
|
994
|
+
}), r && d)
|
|
995
|
+
if (r.data.texture)
|
|
996
|
+
n.transparent = !0;
|
|
997
|
+
else {
|
|
998
|
+
const c = r.data.color;
|
|
999
|
+
switch (r.opaque) {
|
|
1000
|
+
case "A_ONE":
|
|
1001
|
+
n.opacity = c[3] * d.float;
|
|
1002
|
+
break;
|
|
1003
|
+
case "RGB_ZERO":
|
|
1004
|
+
n.opacity = 1 - c[0] * d.float;
|
|
1005
|
+
break;
|
|
1006
|
+
case "A_ZERO":
|
|
1007
|
+
n.opacity = 1 - c[3] * d.float;
|
|
1008
|
+
break;
|
|
1009
|
+
case "RGB_ONE":
|
|
1010
|
+
n.opacity = c[0] * d.float;
|
|
1011
|
+
break;
|
|
1012
|
+
default:
|
|
1013
|
+
console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.', r.opaque);
|
|
1014
|
+
}
|
|
1015
|
+
n.opacity < 1 && (n.transparent = !0);
|
|
1016
|
+
}
|
|
1017
|
+
if (i.extra !== void 0 && i.extra.technique !== void 0) {
|
|
1018
|
+
const c = i.extra.technique;
|
|
1019
|
+
for (const l in c) {
|
|
1020
|
+
const g = c[l];
|
|
1021
|
+
switch (l) {
|
|
1022
|
+
case "double_sided":
|
|
1023
|
+
n.side = g === 1 ? Gn : qn;
|
|
1024
|
+
break;
|
|
1025
|
+
case "bump":
|
|
1026
|
+
n.normalMap = s(g.texture), n.normalScale = new On(1, 1);
|
|
1027
|
+
break;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return n;
|
|
1032
|
+
}
|
|
1033
|
+
function qt(t) {
|
|
1034
|
+
return ee(T.materials[t], Ve);
|
|
1035
|
+
}
|
|
1036
|
+
function Pt(t) {
|
|
1037
|
+
const e = {
|
|
1038
|
+
name: t.getAttribute("name")
|
|
1039
|
+
};
|
|
1040
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
1041
|
+
const s = t.childNodes[i];
|
|
1042
|
+
if (s.nodeType === 1)
|
|
1043
|
+
switch (s.nodeName) {
|
|
1044
|
+
case "optics":
|
|
1045
|
+
e.optics = jt(s);
|
|
1046
|
+
break;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
T.cameras[t.getAttribute("id")] = e;
|
|
1050
|
+
}
|
|
1051
|
+
function jt(t) {
|
|
1052
|
+
for (let e = 0; e < t.childNodes.length; e++) {
|
|
1053
|
+
const i = t.childNodes[e];
|
|
1054
|
+
switch (i.nodeName) {
|
|
1055
|
+
case "technique_common":
|
|
1056
|
+
return Ut(i);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return {};
|
|
1060
|
+
}
|
|
1061
|
+
function Ut(t) {
|
|
1062
|
+
const e = {};
|
|
1063
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1064
|
+
const n = t.childNodes[i];
|
|
1065
|
+
switch (n.nodeName) {
|
|
1066
|
+
case "perspective":
|
|
1067
|
+
case "orthographic":
|
|
1068
|
+
e.technique = n.nodeName, e.parameters = Ft(n);
|
|
1069
|
+
break;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return e;
|
|
1073
|
+
}
|
|
1074
|
+
function Ft(t) {
|
|
1075
|
+
const e = {};
|
|
1076
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1077
|
+
const n = t.childNodes[i];
|
|
1078
|
+
switch (n.nodeName) {
|
|
1079
|
+
case "xfov":
|
|
1080
|
+
case "yfov":
|
|
1081
|
+
case "xmag":
|
|
1082
|
+
case "ymag":
|
|
1083
|
+
case "znear":
|
|
1084
|
+
case "zfar":
|
|
1085
|
+
case "aspect_ratio":
|
|
1086
|
+
e[n.nodeName] = parseFloat(n.textContent);
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return e;
|
|
1091
|
+
}
|
|
1092
|
+
function Je(t) {
|
|
1093
|
+
let e;
|
|
1094
|
+
switch (t.optics.technique) {
|
|
1095
|
+
case "perspective":
|
|
1096
|
+
e = new ht(
|
|
1097
|
+
t.optics.parameters.yfov,
|
|
1098
|
+
t.optics.parameters.aspect_ratio,
|
|
1099
|
+
t.optics.parameters.znear,
|
|
1100
|
+
t.optics.parameters.zfar
|
|
1101
|
+
);
|
|
1102
|
+
break;
|
|
1103
|
+
case "orthographic":
|
|
1104
|
+
let i = t.optics.parameters.ymag, n = t.optics.parameters.xmag;
|
|
1105
|
+
const s = t.optics.parameters.aspect_ratio;
|
|
1106
|
+
n = n === void 0 ? i * s : n, i = i === void 0 ? n / s : i, n *= 0.5, i *= 0.5, e = new Pn(
|
|
1107
|
+
-n,
|
|
1108
|
+
n,
|
|
1109
|
+
i,
|
|
1110
|
+
-i,
|
|
1111
|
+
// left, right, top, bottom
|
|
1112
|
+
t.optics.parameters.znear,
|
|
1113
|
+
t.optics.parameters.zfar
|
|
1114
|
+
);
|
|
1115
|
+
break;
|
|
1116
|
+
default:
|
|
1117
|
+
e = new ht();
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
return e.name = t.name || "", e;
|
|
1121
|
+
}
|
|
1122
|
+
function Ht(t) {
|
|
1123
|
+
const e = T.cameras[t];
|
|
1124
|
+
return e !== void 0 ? ee(e, Je) : (console.warn("THREE.ColladaLoader: Couldn't find camera with ID:", t), null);
|
|
1125
|
+
}
|
|
1126
|
+
function Bt(t) {
|
|
1127
|
+
let e = {};
|
|
1128
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
1129
|
+
const s = t.childNodes[i];
|
|
1130
|
+
if (s.nodeType === 1)
|
|
1131
|
+
switch (s.nodeName) {
|
|
1132
|
+
case "technique_common":
|
|
1133
|
+
e = Dt(s);
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
T.lights[t.getAttribute("id")] = e;
|
|
1138
|
+
}
|
|
1139
|
+
function Dt(t) {
|
|
1140
|
+
const e = {};
|
|
1141
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
1142
|
+
const s = t.childNodes[i];
|
|
1143
|
+
if (s.nodeType === 1)
|
|
1144
|
+
switch (s.nodeName) {
|
|
1145
|
+
case "directional":
|
|
1146
|
+
case "point":
|
|
1147
|
+
case "spot":
|
|
1148
|
+
case "ambient":
|
|
1149
|
+
e.technique = s.nodeName, e.parameters = zt(s);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return e;
|
|
1153
|
+
}
|
|
1154
|
+
function zt(t) {
|
|
1155
|
+
const e = {};
|
|
1156
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
1157
|
+
const s = t.childNodes[i];
|
|
1158
|
+
if (s.nodeType === 1)
|
|
1159
|
+
switch (s.nodeName) {
|
|
1160
|
+
case "color":
|
|
1161
|
+
const o = v(s.textContent);
|
|
1162
|
+
e.color = new ut().fromArray(o), Se.colorSpaceToWorking(e.color, me);
|
|
1163
|
+
break;
|
|
1164
|
+
case "falloff_angle":
|
|
1165
|
+
e.falloffAngle = parseFloat(s.textContent);
|
|
1166
|
+
break;
|
|
1167
|
+
case "quadratic_attenuation":
|
|
1168
|
+
const r = parseFloat(s.textContent);
|
|
1169
|
+
e.distance = r ? Math.sqrt(1 / r) : 0;
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return e;
|
|
1174
|
+
}
|
|
1175
|
+
function Ke(t) {
|
|
1176
|
+
let e;
|
|
1177
|
+
switch (t.technique) {
|
|
1178
|
+
case "directional":
|
|
1179
|
+
e = new Hn();
|
|
1180
|
+
break;
|
|
1181
|
+
case "point":
|
|
1182
|
+
e = new Fn();
|
|
1183
|
+
break;
|
|
1184
|
+
case "spot":
|
|
1185
|
+
e = new Un();
|
|
1186
|
+
break;
|
|
1187
|
+
case "ambient":
|
|
1188
|
+
e = new jn();
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
return t.parameters.color && e.color.copy(t.parameters.color), t.parameters.distance && (e.distance = t.parameters.distance), e;
|
|
1192
|
+
}
|
|
1193
|
+
function Vt(t) {
|
|
1194
|
+
const e = T.lights[t];
|
|
1195
|
+
return e !== void 0 ? ee(e, Ke) : (console.warn("THREE.ColladaLoader: Couldn't find light with ID:", t), null);
|
|
1196
|
+
}
|
|
1197
|
+
function Jt(t) {
|
|
1198
|
+
const e = {
|
|
1199
|
+
name: t.getAttribute("name"),
|
|
1200
|
+
sources: {},
|
|
1201
|
+
vertices: {},
|
|
1202
|
+
primitives: []
|
|
1203
|
+
}, i = R(t, "mesh")[0];
|
|
1204
|
+
if (i !== void 0) {
|
|
1205
|
+
for (let n = 0; n < i.childNodes.length; n++) {
|
|
1206
|
+
const s = i.childNodes[n];
|
|
1207
|
+
if (s.nodeType !== 1) continue;
|
|
1208
|
+
const o = s.getAttribute("id");
|
|
1209
|
+
switch (s.nodeName) {
|
|
1210
|
+
case "source":
|
|
1211
|
+
e.sources[o] = Ge(s);
|
|
1212
|
+
break;
|
|
1213
|
+
case "vertices":
|
|
1214
|
+
e.vertices = Kt(s);
|
|
1215
|
+
break;
|
|
1216
|
+
case "polygons":
|
|
1217
|
+
console.warn("THREE.ColladaLoader: Unsupported primitive type: ", s.nodeName);
|
|
1218
|
+
break;
|
|
1219
|
+
case "lines":
|
|
1220
|
+
case "linestrips":
|
|
1221
|
+
case "polylist":
|
|
1222
|
+
case "triangles":
|
|
1223
|
+
e.primitives.push(Wt(s));
|
|
1224
|
+
break;
|
|
1225
|
+
default:
|
|
1226
|
+
console.log(s);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
T.geometries[t.getAttribute("id")] = e;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
function Ge(t) {
|
|
1233
|
+
const e = {
|
|
1234
|
+
array: [],
|
|
1235
|
+
stride: 3
|
|
1236
|
+
};
|
|
1237
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1238
|
+
const n = t.childNodes[i];
|
|
1239
|
+
if (n.nodeType === 1)
|
|
1240
|
+
switch (n.nodeName) {
|
|
1241
|
+
case "float_array":
|
|
1242
|
+
e.array = v(n.textContent);
|
|
1243
|
+
break;
|
|
1244
|
+
case "Name_array":
|
|
1245
|
+
e.array = se(n.textContent);
|
|
1246
|
+
break;
|
|
1247
|
+
case "technique_common":
|
|
1248
|
+
const s = R(n, "accessor")[0];
|
|
1249
|
+
s !== void 0 && (e.stride = parseInt(s.getAttribute("stride")));
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
return e;
|
|
1254
|
+
}
|
|
1255
|
+
function Kt(t) {
|
|
1256
|
+
const e = {};
|
|
1257
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1258
|
+
const n = t.childNodes[i];
|
|
1259
|
+
n.nodeType === 1 && (e[n.getAttribute("semantic")] = I(n.getAttribute("source")));
|
|
1260
|
+
}
|
|
1261
|
+
return e;
|
|
1262
|
+
}
|
|
1263
|
+
function Wt(t) {
|
|
1264
|
+
const e = {
|
|
1265
|
+
type: t.nodeName,
|
|
1266
|
+
material: t.getAttribute("material"),
|
|
1267
|
+
count: parseInt(t.getAttribute("count")),
|
|
1268
|
+
inputs: {},
|
|
1269
|
+
stride: 0,
|
|
1270
|
+
hasUV: !1
|
|
1271
|
+
};
|
|
1272
|
+
for (let i = 0, n = t.childNodes.length; i < n; i++) {
|
|
1273
|
+
const s = t.childNodes[i];
|
|
1274
|
+
if (s.nodeType === 1)
|
|
1275
|
+
switch (s.nodeName) {
|
|
1276
|
+
case "input":
|
|
1277
|
+
const o = I(s.getAttribute("source")), r = s.getAttribute("semantic"), d = parseInt(s.getAttribute("offset")), c = parseInt(s.getAttribute("set")), l = c > 0 ? r + c : r;
|
|
1278
|
+
e.inputs[l] = { id: o, offset: d }, e.stride = Math.max(e.stride, d + 1), r === "TEXCOORD" && (e.hasUV = !0);
|
|
1279
|
+
break;
|
|
1280
|
+
case "vcount":
|
|
1281
|
+
e.vcount = oe(s.textContent);
|
|
1282
|
+
break;
|
|
1283
|
+
case "p":
|
|
1284
|
+
e.p = oe(s.textContent);
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
return e;
|
|
1289
|
+
}
|
|
1290
|
+
function Yt(t) {
|
|
1291
|
+
const e = {};
|
|
1292
|
+
for (let i = 0; i < t.length; i++) {
|
|
1293
|
+
const n = t[i];
|
|
1294
|
+
e[n.type] === void 0 && (e[n.type] = []), e[n.type].push(n);
|
|
1295
|
+
}
|
|
1296
|
+
return e;
|
|
1297
|
+
}
|
|
1298
|
+
function Xt(t) {
|
|
1299
|
+
let e = 0;
|
|
1300
|
+
for (let i = 0, n = t.length; i < n; i++)
|
|
1301
|
+
t[i].hasUV === !0 && e++;
|
|
1302
|
+
e > 0 && e < t.length && (t.uvsNeedsFix = !0);
|
|
1303
|
+
}
|
|
1304
|
+
function We(t) {
|
|
1305
|
+
const e = {}, i = t.sources, n = t.vertices, s = t.primitives;
|
|
1306
|
+
if (s.length === 0) return {};
|
|
1307
|
+
const o = Yt(s);
|
|
1308
|
+
for (const r in o) {
|
|
1309
|
+
const d = o[r];
|
|
1310
|
+
Xt(d), e[r] = $t(d, i, n);
|
|
1311
|
+
}
|
|
1312
|
+
return e;
|
|
1313
|
+
}
|
|
1314
|
+
function $t(t, e, i) {
|
|
1315
|
+
const n = {}, s = { array: [], stride: 0 }, o = { array: [], stride: 0 }, r = { array: [], stride: 0 }, d = { array: [], stride: 0 }, c = { array: [], stride: 0 }, l = { array: [], stride: 4 }, g = { array: [], stride: 4 }, a = new Dn(), b = [];
|
|
1316
|
+
let p = 0;
|
|
1317
|
+
for (let w = 0; w < t.length; w++) {
|
|
1318
|
+
const y = t[w], K = y.inputs;
|
|
1319
|
+
let H = 0;
|
|
1320
|
+
switch (y.type) {
|
|
1321
|
+
case "lines":
|
|
1322
|
+
case "linestrips":
|
|
1323
|
+
H = y.count * 2;
|
|
1324
|
+
break;
|
|
1325
|
+
case "triangles":
|
|
1326
|
+
H = y.count * 3;
|
|
1327
|
+
break;
|
|
1328
|
+
case "polylist":
|
|
1329
|
+
for (let G = 0; G < y.count; G++) {
|
|
1330
|
+
const q = y.vcount[G];
|
|
1331
|
+
switch (q) {
|
|
1332
|
+
case 3:
|
|
1333
|
+
H += 3;
|
|
1334
|
+
break;
|
|
1335
|
+
case 4:
|
|
1336
|
+
H += 6;
|
|
1337
|
+
break;
|
|
1338
|
+
default:
|
|
1339
|
+
H += (q - 2) * 3;
|
|
1340
|
+
break;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
break;
|
|
1344
|
+
default:
|
|
1345
|
+
console.warn("THREE.ColladaLoader: Unknown primitive type:", y.type);
|
|
1346
|
+
}
|
|
1347
|
+
a.addGroup(p, H, w), p += H, y.material && b.push(y.material);
|
|
1348
|
+
for (const G in K) {
|
|
1349
|
+
const q = K[G];
|
|
1350
|
+
switch (G) {
|
|
1351
|
+
case "VERTEX":
|
|
1352
|
+
for (const fe in i) {
|
|
1353
|
+
const re = i[fe];
|
|
1354
|
+
switch (fe) {
|
|
1355
|
+
case "POSITION":
|
|
1356
|
+
const xe = s.array.length;
|
|
1357
|
+
if (de(y, e[re], q.offset, s.array), s.stride = e[re].stride, e.skinWeights && e.skinIndices && (de(y, e.skinIndices, q.offset, l.array), de(y, e.skinWeights, q.offset, g.array)), y.hasUV === !1 && t.uvsNeedsFix === !0) {
|
|
1358
|
+
const Cn = (s.array.length - xe) / s.stride;
|
|
1359
|
+
for (let ct = 0; ct < Cn; ct++)
|
|
1360
|
+
r.array.push(0, 0);
|
|
1361
|
+
}
|
|
1362
|
+
break;
|
|
1363
|
+
case "NORMAL":
|
|
1364
|
+
de(y, e[re], q.offset, o.array), o.stride = e[re].stride;
|
|
1365
|
+
break;
|
|
1366
|
+
case "COLOR":
|
|
1367
|
+
de(y, e[re], q.offset, c.array), c.stride = e[re].stride;
|
|
1368
|
+
break;
|
|
1369
|
+
case "TEXCOORD":
|
|
1370
|
+
de(y, e[re], q.offset, r.array), r.stride = e[re].stride;
|
|
1371
|
+
break;
|
|
1372
|
+
case "TEXCOORD1":
|
|
1373
|
+
de(y, e[re], q.offset, d.array), r.stride = e[re].stride;
|
|
1374
|
+
break;
|
|
1375
|
+
default:
|
|
1376
|
+
console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.', fe);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
break;
|
|
1380
|
+
case "NORMAL":
|
|
1381
|
+
de(y, e[q.id], q.offset, o.array), o.stride = e[q.id].stride;
|
|
1382
|
+
break;
|
|
1383
|
+
case "COLOR":
|
|
1384
|
+
de(y, e[q.id], q.offset, c.array, !0), c.stride = e[q.id].stride;
|
|
1385
|
+
break;
|
|
1386
|
+
case "TEXCOORD":
|
|
1387
|
+
de(y, e[q.id], q.offset, r.array), r.stride = e[q.id].stride;
|
|
1388
|
+
break;
|
|
1389
|
+
case "TEXCOORD1":
|
|
1390
|
+
de(y, e[q.id], q.offset, d.array), d.stride = e[q.id].stride;
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
return s.array.length > 0 && a.setAttribute("position", new ye(s.array, s.stride)), o.array.length > 0 && a.setAttribute("normal", new ye(o.array, o.stride)), c.array.length > 0 && a.setAttribute("color", new ye(c.array, c.stride)), r.array.length > 0 && a.setAttribute("uv", new ye(r.array, r.stride)), d.array.length > 0 && a.setAttribute("uv1", new ye(d.array, d.stride)), l.array.length > 0 && a.setAttribute("skinIndex", new ye(l.array, l.stride)), g.array.length > 0 && a.setAttribute("skinWeight", new ye(g.array, g.stride)), n.data = a, n.type = t[0].type, n.materialKeys = b, n;
|
|
1396
|
+
}
|
|
1397
|
+
function de(t, e, i, n, s = !1) {
|
|
1398
|
+
const o = t.p, r = t.stride, d = t.vcount;
|
|
1399
|
+
function c(a) {
|
|
1400
|
+
let b = o[a + i] * g;
|
|
1401
|
+
const p = b + g;
|
|
1402
|
+
for (; b < p; b++)
|
|
1403
|
+
n.push(l[b]);
|
|
1404
|
+
if (s) {
|
|
1405
|
+
const w = n.length - g - 1;
|
|
1406
|
+
Re.setRGB(
|
|
1407
|
+
n[w + 0],
|
|
1408
|
+
n[w + 1],
|
|
1409
|
+
n[w + 2],
|
|
1410
|
+
me
|
|
1411
|
+
), n[w + 0] = Re.r, n[w + 1] = Re.g, n[w + 2] = Re.b;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
const l = e.array, g = e.stride;
|
|
1415
|
+
if (t.vcount !== void 0) {
|
|
1416
|
+
let a = 0;
|
|
1417
|
+
for (let b = 0, p = d.length; b < p; b++) {
|
|
1418
|
+
const w = d[b];
|
|
1419
|
+
if (w === 4) {
|
|
1420
|
+
const y = a + r * 0, K = a + r * 1, H = a + r * 2, G = a + r * 3;
|
|
1421
|
+
c(y), c(K), c(G), c(K), c(H), c(G);
|
|
1422
|
+
} else if (w === 3) {
|
|
1423
|
+
const y = a + r * 0, K = a + r * 1, H = a + r * 2;
|
|
1424
|
+
c(y), c(K), c(H);
|
|
1425
|
+
} else if (w > 4)
|
|
1426
|
+
for (let y = 1, K = w - 2; y <= K; y++) {
|
|
1427
|
+
const H = a + r * 0, G = a + r * y, q = a + r * (y + 1);
|
|
1428
|
+
c(H), c(G), c(q);
|
|
1429
|
+
}
|
|
1430
|
+
a += r * w;
|
|
1431
|
+
}
|
|
1432
|
+
} else
|
|
1433
|
+
for (let a = 0, b = o.length; a < b; a += r)
|
|
1434
|
+
c(a);
|
|
1435
|
+
}
|
|
1436
|
+
function Ye(t) {
|
|
1437
|
+
return ee(T.geometries[t], We);
|
|
1438
|
+
}
|
|
1439
|
+
function Zt(t) {
|
|
1440
|
+
const e = {
|
|
1441
|
+
name: t.getAttribute("name") || "",
|
|
1442
|
+
joints: {},
|
|
1443
|
+
links: []
|
|
1444
|
+
};
|
|
1445
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1446
|
+
const n = t.childNodes[i];
|
|
1447
|
+
if (n.nodeType === 1)
|
|
1448
|
+
switch (n.nodeName) {
|
|
1449
|
+
case "technique_common":
|
|
1450
|
+
tn(n, e);
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
T.kinematicsModels[t.getAttribute("id")] = e;
|
|
1455
|
+
}
|
|
1456
|
+
function Qt(t) {
|
|
1457
|
+
return t.build !== void 0 ? t.build : t;
|
|
1458
|
+
}
|
|
1459
|
+
function en(t) {
|
|
1460
|
+
return ee(T.kinematicsModels[t], Qt);
|
|
1461
|
+
}
|
|
1462
|
+
function tn(t, e) {
|
|
1463
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1464
|
+
const n = t.childNodes[i];
|
|
1465
|
+
if (n.nodeType === 1)
|
|
1466
|
+
switch (n.nodeName) {
|
|
1467
|
+
case "joint":
|
|
1468
|
+
e.joints[n.getAttribute("sid")] = nn(n);
|
|
1469
|
+
break;
|
|
1470
|
+
case "link":
|
|
1471
|
+
e.links.push(Xe(n));
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
function nn(t) {
|
|
1477
|
+
let e;
|
|
1478
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1479
|
+
const n = t.childNodes[i];
|
|
1480
|
+
if (n.nodeType === 1)
|
|
1481
|
+
switch (n.nodeName) {
|
|
1482
|
+
case "prismatic":
|
|
1483
|
+
case "revolute":
|
|
1484
|
+
e = sn(n);
|
|
1485
|
+
break;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
return e;
|
|
1489
|
+
}
|
|
1490
|
+
function sn(t) {
|
|
1491
|
+
const e = {
|
|
1492
|
+
sid: t.getAttribute("sid"),
|
|
1493
|
+
name: t.getAttribute("name") || "",
|
|
1494
|
+
axis: new pe(),
|
|
1495
|
+
limits: {
|
|
1496
|
+
min: 0,
|
|
1497
|
+
max: 0
|
|
1498
|
+
},
|
|
1499
|
+
type: t.nodeName,
|
|
1500
|
+
static: !1,
|
|
1501
|
+
zeroPosition: 0,
|
|
1502
|
+
middlePosition: 0
|
|
1503
|
+
};
|
|
1504
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1505
|
+
const n = t.childNodes[i];
|
|
1506
|
+
if (n.nodeType === 1)
|
|
1507
|
+
switch (n.nodeName) {
|
|
1508
|
+
case "axis":
|
|
1509
|
+
const s = v(n.textContent);
|
|
1510
|
+
e.axis.fromArray(s);
|
|
1511
|
+
break;
|
|
1512
|
+
case "limits":
|
|
1513
|
+
const o = n.getElementsByTagName("max")[0], r = n.getElementsByTagName("min")[0];
|
|
1514
|
+
e.limits.max = parseFloat(o.textContent), e.limits.min = parseFloat(r.textContent);
|
|
1515
|
+
break;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
return e.limits.min >= e.limits.max && (e.static = !0), e.middlePosition = (e.limits.min + e.limits.max) / 2, e;
|
|
1519
|
+
}
|
|
1520
|
+
function Xe(t) {
|
|
1521
|
+
const e = {
|
|
1522
|
+
sid: t.getAttribute("sid"),
|
|
1523
|
+
name: t.getAttribute("name") || "",
|
|
1524
|
+
attachments: [],
|
|
1525
|
+
transforms: []
|
|
1526
|
+
};
|
|
1527
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1528
|
+
const n = t.childNodes[i];
|
|
1529
|
+
if (n.nodeType === 1)
|
|
1530
|
+
switch (n.nodeName) {
|
|
1531
|
+
case "attachment_full":
|
|
1532
|
+
e.attachments.push(on(n));
|
|
1533
|
+
break;
|
|
1534
|
+
case "matrix":
|
|
1535
|
+
case "translate":
|
|
1536
|
+
case "rotate":
|
|
1537
|
+
e.transforms.push($e(n));
|
|
1538
|
+
break;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
return e;
|
|
1542
|
+
}
|
|
1543
|
+
function on(t) {
|
|
1544
|
+
const e = {
|
|
1545
|
+
joint: t.getAttribute("joint").split("/").pop(),
|
|
1546
|
+
transforms: [],
|
|
1547
|
+
links: []
|
|
1548
|
+
};
|
|
1549
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1550
|
+
const n = t.childNodes[i];
|
|
1551
|
+
if (n.nodeType === 1)
|
|
1552
|
+
switch (n.nodeName) {
|
|
1553
|
+
case "link":
|
|
1554
|
+
e.links.push(Xe(n));
|
|
1555
|
+
break;
|
|
1556
|
+
case "matrix":
|
|
1557
|
+
case "translate":
|
|
1558
|
+
case "rotate":
|
|
1559
|
+
e.transforms.push($e(n));
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return e;
|
|
1564
|
+
}
|
|
1565
|
+
function $e(t) {
|
|
1566
|
+
const e = {
|
|
1567
|
+
type: t.nodeName
|
|
1568
|
+
}, i = v(t.textContent);
|
|
1569
|
+
switch (e.type) {
|
|
1570
|
+
case "matrix":
|
|
1571
|
+
e.obj = new he(), e.obj.fromArray(i).transpose();
|
|
1572
|
+
break;
|
|
1573
|
+
case "translate":
|
|
1574
|
+
e.obj = new pe(), e.obj.fromArray(i);
|
|
1575
|
+
break;
|
|
1576
|
+
case "rotate":
|
|
1577
|
+
e.obj = new pe(), e.obj.fromArray(i), e.angle = Le.degToRad(i[3]);
|
|
1578
|
+
break;
|
|
1579
|
+
}
|
|
1580
|
+
return e;
|
|
1581
|
+
}
|
|
1582
|
+
function rn(t) {
|
|
1583
|
+
const e = {
|
|
1584
|
+
name: t.getAttribute("name") || "",
|
|
1585
|
+
rigidBodies: {}
|
|
1586
|
+
};
|
|
1587
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1588
|
+
const n = t.childNodes[i];
|
|
1589
|
+
if (n.nodeType === 1)
|
|
1590
|
+
switch (n.nodeName) {
|
|
1591
|
+
case "rigid_body":
|
|
1592
|
+
e.rigidBodies[n.getAttribute("name")] = {}, an(n, e.rigidBodies[n.getAttribute("name")]);
|
|
1593
|
+
break;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
T.physicsModels[t.getAttribute("id")] = e;
|
|
1597
|
+
}
|
|
1598
|
+
function an(t, e) {
|
|
1599
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1600
|
+
const n = t.childNodes[i];
|
|
1601
|
+
if (n.nodeType === 1)
|
|
1602
|
+
switch (n.nodeName) {
|
|
1603
|
+
case "technique_common":
|
|
1604
|
+
cn(n, e);
|
|
1605
|
+
break;
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
function cn(t, e) {
|
|
1610
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1611
|
+
const n = t.childNodes[i];
|
|
1612
|
+
if (n.nodeType === 1)
|
|
1613
|
+
switch (n.nodeName) {
|
|
1614
|
+
case "inertia":
|
|
1615
|
+
e.inertia = v(n.textContent);
|
|
1616
|
+
break;
|
|
1617
|
+
case "mass":
|
|
1618
|
+
e.mass = v(n.textContent)[0];
|
|
1619
|
+
break;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
function ln(t) {
|
|
1624
|
+
const e = {
|
|
1625
|
+
bindJointAxis: []
|
|
1626
|
+
};
|
|
1627
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1628
|
+
const n = t.childNodes[i];
|
|
1629
|
+
if (n.nodeType === 1)
|
|
1630
|
+
switch (n.nodeName) {
|
|
1631
|
+
case "bind_joint_axis":
|
|
1632
|
+
e.bindJointAxis.push(dn(n));
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
T.kinematicsScenes[I(t.getAttribute("url"))] = e;
|
|
1637
|
+
}
|
|
1638
|
+
function dn(t) {
|
|
1639
|
+
const e = {
|
|
1640
|
+
target: t.getAttribute("target").split("/").pop()
|
|
1641
|
+
};
|
|
1642
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1643
|
+
const n = t.childNodes[i];
|
|
1644
|
+
if (n.nodeType === 1)
|
|
1645
|
+
switch (n.nodeName) {
|
|
1646
|
+
case "axis":
|
|
1647
|
+
const s = n.getElementsByTagName("param")[0];
|
|
1648
|
+
e.axis = s.textContent;
|
|
1649
|
+
const o = e.axis.split("inst_").pop().split("axis")[0];
|
|
1650
|
+
e.jointIndex = o.substring(0, o.length - 1);
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
return e;
|
|
1655
|
+
}
|
|
1656
|
+
function un(t) {
|
|
1657
|
+
return t.build !== void 0 ? t.build : t;
|
|
1658
|
+
}
|
|
1659
|
+
function fn(t) {
|
|
1660
|
+
return ee(T.kinematicsScenes[t], un);
|
|
1661
|
+
}
|
|
1662
|
+
function hn() {
|
|
1663
|
+
const t = Object.keys(T.kinematicsModels)[0], e = Object.keys(T.kinematicsScenes)[0], i = Object.keys(T.visualScenes)[0];
|
|
1664
|
+
if (t === void 0 || e === void 0) return;
|
|
1665
|
+
const n = en(t), s = fn(e), o = it(i), r = s.bindJointAxis, d = {};
|
|
1666
|
+
for (let g = 0, a = r.length; g < a; g++) {
|
|
1667
|
+
const b = r[g], p = Z.querySelector('[sid="' + b.target + '"]');
|
|
1668
|
+
if (p) {
|
|
1669
|
+
const w = p.parentElement;
|
|
1670
|
+
c(b.jointIndex, w);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
function c(g, a) {
|
|
1674
|
+
const b = a.getAttribute("name"), p = n.joints[g];
|
|
1675
|
+
o.traverse(function(w) {
|
|
1676
|
+
w.name === b && (d[g] = {
|
|
1677
|
+
object: w,
|
|
1678
|
+
transforms: pn(a),
|
|
1679
|
+
joint: p,
|
|
1680
|
+
position: p.zeroPosition
|
|
1681
|
+
});
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
const l = new he();
|
|
1685
|
+
at = {
|
|
1686
|
+
joints: n && n.joints,
|
|
1687
|
+
getJointValue: function(g) {
|
|
1688
|
+
const a = d[g];
|
|
1689
|
+
if (a)
|
|
1690
|
+
return a.position;
|
|
1691
|
+
console.warn("THREE.ColladaLoader: Joint " + g + " doesn't exist.");
|
|
1692
|
+
},
|
|
1693
|
+
setJointValue: function(g, a) {
|
|
1694
|
+
const b = d[g];
|
|
1695
|
+
if (b) {
|
|
1696
|
+
const p = b.joint;
|
|
1697
|
+
if (a > p.limits.max || a < p.limits.min)
|
|
1698
|
+
console.warn("THREE.ColladaLoader: Joint " + g + " value " + a + " outside of limits (min: " + p.limits.min + ", max: " + p.limits.max + ").");
|
|
1699
|
+
else if (p.static)
|
|
1700
|
+
console.warn("THREE.ColladaLoader: Joint " + g + " is static.");
|
|
1701
|
+
else {
|
|
1702
|
+
const w = b.object, y = p.axis, K = b.transforms;
|
|
1703
|
+
ce.identity();
|
|
1704
|
+
for (let H = 0; H < K.length; H++) {
|
|
1705
|
+
const G = K[H];
|
|
1706
|
+
if (G.sid && G.sid.indexOf(g) !== -1)
|
|
1707
|
+
switch (p.type) {
|
|
1708
|
+
case "revolute":
|
|
1709
|
+
ce.multiply(l.makeRotationAxis(y, Le.degToRad(a)));
|
|
1710
|
+
break;
|
|
1711
|
+
case "prismatic":
|
|
1712
|
+
ce.multiply(l.makeTranslation(y.x * a, y.y * a, y.z * a));
|
|
1713
|
+
break;
|
|
1714
|
+
default:
|
|
1715
|
+
console.warn("THREE.ColladaLoader: Unknown joint type: " + p.type);
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
else
|
|
1719
|
+
switch (G.type) {
|
|
1720
|
+
case "matrix":
|
|
1721
|
+
ce.multiply(G.obj);
|
|
1722
|
+
break;
|
|
1723
|
+
case "translate":
|
|
1724
|
+
ce.multiply(l.makeTranslation(G.obj.x, G.obj.y, G.obj.z));
|
|
1725
|
+
break;
|
|
1726
|
+
case "scale":
|
|
1727
|
+
ce.scale(G.obj);
|
|
1728
|
+
break;
|
|
1729
|
+
case "rotate":
|
|
1730
|
+
ce.multiply(l.makeRotationAxis(G.obj, G.angle));
|
|
1731
|
+
break;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
w.matrix.copy(ce), w.matrix.decompose(w.position, w.quaternion, w.scale), d[g].position = a;
|
|
1735
|
+
}
|
|
1736
|
+
} else
|
|
1737
|
+
console.log("THREE.ColladaLoader: " + g + " does not exist.");
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
function pn(t) {
|
|
1742
|
+
const e = [], i = Z.querySelector('[id="' + t.id + '"]');
|
|
1743
|
+
for (let n = 0; n < i.childNodes.length; n++) {
|
|
1744
|
+
const s = i.childNodes[n];
|
|
1745
|
+
if (s.nodeType !== 1) continue;
|
|
1746
|
+
let o, r;
|
|
1747
|
+
switch (s.nodeName) {
|
|
1748
|
+
case "matrix":
|
|
1749
|
+
o = v(s.textContent);
|
|
1750
|
+
const d = new he().fromArray(o).transpose();
|
|
1751
|
+
e.push({
|
|
1752
|
+
sid: s.getAttribute("sid"),
|
|
1753
|
+
type: s.nodeName,
|
|
1754
|
+
obj: d
|
|
1755
|
+
});
|
|
1756
|
+
break;
|
|
1757
|
+
case "translate":
|
|
1758
|
+
case "scale":
|
|
1759
|
+
o = v(s.textContent), r = new pe().fromArray(o), e.push({
|
|
1760
|
+
sid: s.getAttribute("sid"),
|
|
1761
|
+
type: s.nodeName,
|
|
1762
|
+
obj: r
|
|
1763
|
+
});
|
|
1764
|
+
break;
|
|
1765
|
+
case "rotate":
|
|
1766
|
+
o = v(s.textContent), r = new pe().fromArray(o);
|
|
1767
|
+
const c = Le.degToRad(o[3]);
|
|
1768
|
+
e.push({
|
|
1769
|
+
sid: s.getAttribute("sid"),
|
|
1770
|
+
type: s.nodeName,
|
|
1771
|
+
obj: r,
|
|
1772
|
+
angle: c
|
|
1773
|
+
});
|
|
1774
|
+
break;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return e;
|
|
1778
|
+
}
|
|
1779
|
+
function mn(t) {
|
|
1780
|
+
const e = t.getElementsByTagName("node");
|
|
1781
|
+
for (let i = 0; i < e.length; i++) {
|
|
1782
|
+
const n = e[i];
|
|
1783
|
+
n.hasAttribute("id") === !1 && n.setAttribute("id", Y());
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
const ce = new he(), Te = new pe();
|
|
1787
|
+
function qe(t) {
|
|
1788
|
+
const e = {
|
|
1789
|
+
name: t.getAttribute("name") || "",
|
|
1790
|
+
type: t.getAttribute("type"),
|
|
1791
|
+
id: t.getAttribute("id"),
|
|
1792
|
+
sid: t.getAttribute("sid"),
|
|
1793
|
+
matrix: new he(),
|
|
1794
|
+
nodes: [],
|
|
1795
|
+
instanceCameras: [],
|
|
1796
|
+
instanceControllers: [],
|
|
1797
|
+
instanceLights: [],
|
|
1798
|
+
instanceGeometries: [],
|
|
1799
|
+
instanceNodes: [],
|
|
1800
|
+
transforms: {}
|
|
1801
|
+
};
|
|
1802
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1803
|
+
const n = t.childNodes[i];
|
|
1804
|
+
if (n.nodeType !== 1) continue;
|
|
1805
|
+
let s;
|
|
1806
|
+
switch (n.nodeName) {
|
|
1807
|
+
case "node":
|
|
1808
|
+
e.nodes.push(n.getAttribute("id")), qe(n);
|
|
1809
|
+
break;
|
|
1810
|
+
case "instance_camera":
|
|
1811
|
+
e.instanceCameras.push(I(n.getAttribute("url")));
|
|
1812
|
+
break;
|
|
1813
|
+
case "instance_controller":
|
|
1814
|
+
e.instanceControllers.push(Ze(n));
|
|
1815
|
+
break;
|
|
1816
|
+
case "instance_light":
|
|
1817
|
+
e.instanceLights.push(I(n.getAttribute("url")));
|
|
1818
|
+
break;
|
|
1819
|
+
case "instance_geometry":
|
|
1820
|
+
e.instanceGeometries.push(Ze(n));
|
|
1821
|
+
break;
|
|
1822
|
+
case "instance_node":
|
|
1823
|
+
e.instanceNodes.push(I(n.getAttribute("url")));
|
|
1824
|
+
break;
|
|
1825
|
+
case "matrix":
|
|
1826
|
+
s = v(n.textContent), e.matrix.multiply(ce.fromArray(s).transpose()), e.transforms[n.getAttribute("sid")] = n.nodeName;
|
|
1827
|
+
break;
|
|
1828
|
+
case "translate":
|
|
1829
|
+
s = v(n.textContent), Te.fromArray(s), e.matrix.multiply(ce.makeTranslation(Te.x, Te.y, Te.z)), e.transforms[n.getAttribute("sid")] = n.nodeName;
|
|
1830
|
+
break;
|
|
1831
|
+
case "rotate":
|
|
1832
|
+
s = v(n.textContent);
|
|
1833
|
+
const o = Le.degToRad(s[3]);
|
|
1834
|
+
e.matrix.multiply(ce.makeRotationAxis(Te.fromArray(s), o)), e.transforms[n.getAttribute("sid")] = n.nodeName;
|
|
1835
|
+
break;
|
|
1836
|
+
case "scale":
|
|
1837
|
+
s = v(n.textContent), e.matrix.scale(Te.fromArray(s)), e.transforms[n.getAttribute("sid")] = n.nodeName;
|
|
1838
|
+
break;
|
|
1839
|
+
case "extra":
|
|
1840
|
+
break;
|
|
1841
|
+
default:
|
|
1842
|
+
console.log(n);
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
return tt(e.id) ? console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.", e.id) : T.nodes[e.id] = e, e;
|
|
1846
|
+
}
|
|
1847
|
+
function Ze(t) {
|
|
1848
|
+
const e = {
|
|
1849
|
+
id: I(t.getAttribute("url")),
|
|
1850
|
+
materials: {},
|
|
1851
|
+
skeletons: []
|
|
1852
|
+
};
|
|
1853
|
+
for (let i = 0; i < t.childNodes.length; i++) {
|
|
1854
|
+
const n = t.childNodes[i];
|
|
1855
|
+
switch (n.nodeName) {
|
|
1856
|
+
case "bind_material":
|
|
1857
|
+
const s = n.getElementsByTagName("instance_material");
|
|
1858
|
+
for (let o = 0; o < s.length; o++) {
|
|
1859
|
+
const r = s[o], d = r.getAttribute("symbol"), c = r.getAttribute("target");
|
|
1860
|
+
e.materials[d] = I(c);
|
|
1861
|
+
}
|
|
1862
|
+
break;
|
|
1863
|
+
case "skeleton":
|
|
1864
|
+
e.skeletons.push(I(n.textContent));
|
|
1865
|
+
break;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
return e;
|
|
1869
|
+
}
|
|
1870
|
+
function bn(t, e) {
|
|
1871
|
+
const i = [], n = [];
|
|
1872
|
+
let s, o, r;
|
|
1873
|
+
for (s = 0; s < t.length; s++) {
|
|
1874
|
+
const l = t[s];
|
|
1875
|
+
let g;
|
|
1876
|
+
if (tt(l))
|
|
1877
|
+
g = Ee(l), Qe(g, e, i);
|
|
1878
|
+
else if (Nn(l)) {
|
|
1879
|
+
const b = T.visualScenes[l].children;
|
|
1880
|
+
for (let p = 0; p < b.length; p++) {
|
|
1881
|
+
const w = b[p];
|
|
1882
|
+
if (w.type === "JOINT") {
|
|
1883
|
+
const y = Ee(w.id);
|
|
1884
|
+
Qe(y, e, i);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
} else
|
|
1888
|
+
console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:", l);
|
|
1889
|
+
}
|
|
1890
|
+
for (s = 0; s < e.length; s++)
|
|
1891
|
+
for (o = 0; o < i.length; o++)
|
|
1892
|
+
if (r = i[o], r.bone.name === e[s].name) {
|
|
1893
|
+
n[s] = r, r.processed = !0;
|
|
1894
|
+
break;
|
|
1895
|
+
}
|
|
1896
|
+
for (s = 0; s < i.length; s++)
|
|
1897
|
+
r = i[s], r.processed === !1 && (n.push(r), r.processed = !0);
|
|
1898
|
+
const d = [], c = [];
|
|
1899
|
+
for (s = 0; s < n.length; s++)
|
|
1900
|
+
r = n[s], d.push(r.bone), c.push(r.boneInverse);
|
|
1901
|
+
return new Wn(d, c);
|
|
1902
|
+
}
|
|
1903
|
+
function Qe(t, e, i) {
|
|
1904
|
+
t.traverse(function(n) {
|
|
1905
|
+
if (n.isBone === !0) {
|
|
1906
|
+
let s;
|
|
1907
|
+
for (let o = 0; o < e.length; o++) {
|
|
1908
|
+
const r = e[o];
|
|
1909
|
+
if (r.name === n.name) {
|
|
1910
|
+
s = r.boneInverse;
|
|
1911
|
+
break;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
s === void 0 && (s = new he()), i.push({ bone: n, boneInverse: s, processed: !1 });
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
function gn(t) {
|
|
1919
|
+
const e = [], i = t.matrix, n = t.nodes, s = t.type, o = t.instanceCameras, r = t.instanceControllers, d = t.instanceLights, c = t.instanceGeometries, l = t.instanceNodes;
|
|
1920
|
+
for (let a = 0, b = n.length; a < b; a++)
|
|
1921
|
+
e.push(Ee(n[a]));
|
|
1922
|
+
for (let a = 0, b = o.length; a < b; a++) {
|
|
1923
|
+
const p = Ht(o[a]);
|
|
1924
|
+
p !== null && e.push(p.clone());
|
|
1925
|
+
}
|
|
1926
|
+
for (let a = 0, b = r.length; a < b; a++) {
|
|
1927
|
+
const p = r[a], w = N(p.id), y = Ye(w.id), K = et(y, p.materials), H = p.skeletons, G = w.skin.joints, q = bn(H, G);
|
|
1928
|
+
for (let fe = 0, re = K.length; fe < re; fe++) {
|
|
1929
|
+
const xe = K[fe];
|
|
1930
|
+
xe.isSkinnedMesh && (xe.bind(q, w.skin.bindMatrix), xe.normalizeSkinWeights()), e.push(xe);
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
for (let a = 0, b = d.length; a < b; a++) {
|
|
1934
|
+
const p = Vt(d[a]);
|
|
1935
|
+
p !== null && e.push(p.clone());
|
|
1936
|
+
}
|
|
1937
|
+
for (let a = 0, b = c.length; a < b; a++) {
|
|
1938
|
+
const p = c[a], w = Ye(p.id), y = et(w, p.materials);
|
|
1939
|
+
for (let K = 0, H = y.length; K < H; K++)
|
|
1940
|
+
e.push(y[K]);
|
|
1941
|
+
}
|
|
1942
|
+
for (let a = 0, b = l.length; a < b; a++)
|
|
1943
|
+
e.push(Ee(l[a]).clone());
|
|
1944
|
+
let g;
|
|
1945
|
+
if (n.length === 0 && e.length === 1)
|
|
1946
|
+
g = e[0];
|
|
1947
|
+
else {
|
|
1948
|
+
g = s === "JOINT" ? new zn() : new pt();
|
|
1949
|
+
for (let a = 0; a < e.length; a++)
|
|
1950
|
+
g.add(e[a]);
|
|
1951
|
+
}
|
|
1952
|
+
return g.name = s === "JOINT" ? t.sid : t.name, g.matrix.copy(i), g.matrix.decompose(g.position, g.quaternion, g.scale), g;
|
|
1953
|
+
}
|
|
1954
|
+
const yn = new dt({
|
|
1955
|
+
name: lt.DEFAULT_MATERIAL_NAME,
|
|
1956
|
+
color: 16711935
|
|
1957
|
+
});
|
|
1958
|
+
function wn(t, e) {
|
|
1959
|
+
const i = [];
|
|
1960
|
+
for (let n = 0, s = t.length; n < s; n++) {
|
|
1961
|
+
const o = e[t[n]];
|
|
1962
|
+
o === void 0 ? (console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.", t[n]), i.push(yn)) : i.push(qt(o));
|
|
1963
|
+
}
|
|
1964
|
+
return i;
|
|
1965
|
+
}
|
|
1966
|
+
function et(t, e) {
|
|
1967
|
+
const i = [];
|
|
1968
|
+
for (const n in t) {
|
|
1969
|
+
const s = t[n], o = wn(s.materialKeys, e);
|
|
1970
|
+
if (o.length === 0 && (n === "lines" || n === "linestrips" ? o.push(new bt()) : o.push(new ve())), n === "lines" || n === "linestrips")
|
|
1971
|
+
for (let l = 0, g = o.length; l < g; l++) {
|
|
1972
|
+
const a = o[l];
|
|
1973
|
+
if (a.isMeshPhongMaterial === !0 || a.isMeshLambertMaterial === !0) {
|
|
1974
|
+
const b = new bt();
|
|
1975
|
+
b.color.copy(a.color), b.opacity = a.opacity, b.transparent = a.transparent, o[l] = b;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
const r = s.data.attributes.skinIndex !== void 0, d = o.length === 1 ? o[0] : o;
|
|
1979
|
+
let c;
|
|
1980
|
+
switch (n) {
|
|
1981
|
+
case "lines":
|
|
1982
|
+
c = new Kn(s.data, d);
|
|
1983
|
+
break;
|
|
1984
|
+
case "linestrips":
|
|
1985
|
+
c = new Jn(s.data, d);
|
|
1986
|
+
break;
|
|
1987
|
+
case "triangles":
|
|
1988
|
+
case "polylist":
|
|
1989
|
+
r ? c = new Vn(s.data, d) : c = new Ce(s.data, d);
|
|
1990
|
+
break;
|
|
1991
|
+
}
|
|
1992
|
+
i.push(c);
|
|
1993
|
+
}
|
|
1994
|
+
return i;
|
|
1995
|
+
}
|
|
1996
|
+
function tt(t) {
|
|
1997
|
+
return T.nodes[t] !== void 0;
|
|
1998
|
+
}
|
|
1999
|
+
function Ee(t) {
|
|
2000
|
+
return ee(T.nodes[t], gn);
|
|
2001
|
+
}
|
|
2002
|
+
function kn(t) {
|
|
2003
|
+
const e = {
|
|
2004
|
+
name: t.getAttribute("name"),
|
|
2005
|
+
children: []
|
|
2006
|
+
};
|
|
2007
|
+
mn(t);
|
|
2008
|
+
const i = R(t, "node");
|
|
2009
|
+
for (let n = 0; n < i.length; n++)
|
|
2010
|
+
e.children.push(qe(i[n]));
|
|
2011
|
+
T.visualScenes[t.getAttribute("id")] = e;
|
|
2012
|
+
}
|
|
2013
|
+
function nt(t) {
|
|
2014
|
+
const e = new pt();
|
|
2015
|
+
e.name = t.name;
|
|
2016
|
+
const i = t.children;
|
|
2017
|
+
for (let n = 0; n < i.length; n++) {
|
|
2018
|
+
const s = i[n];
|
|
2019
|
+
e.add(Ee(s.id));
|
|
2020
|
+
}
|
|
2021
|
+
return e;
|
|
2022
|
+
}
|
|
2023
|
+
function Nn(t) {
|
|
2024
|
+
return T.visualScenes[t] !== void 0;
|
|
2025
|
+
}
|
|
2026
|
+
function it(t) {
|
|
2027
|
+
return ee(T.visualScenes[t], nt);
|
|
2028
|
+
}
|
|
2029
|
+
function An(t) {
|
|
2030
|
+
const e = R(t, "instance_visual_scene")[0];
|
|
2031
|
+
return it(I(e.getAttribute("url")));
|
|
2032
|
+
}
|
|
2033
|
+
function Tn() {
|
|
2034
|
+
const t = T.clips;
|
|
2035
|
+
if (ne(t) === !0) {
|
|
2036
|
+
if (ne(T.animations) === !1) {
|
|
2037
|
+
const e = [];
|
|
2038
|
+
for (const i in T.animations) {
|
|
2039
|
+
const n = F(i);
|
|
2040
|
+
for (let s = 0, o = n.length; s < o; s++)
|
|
2041
|
+
e.push(n[s]);
|
|
2042
|
+
}
|
|
2043
|
+
Ie.push(new ft("default", -1, e));
|
|
2044
|
+
}
|
|
2045
|
+
} else
|
|
2046
|
+
for (const e in t)
|
|
2047
|
+
Ie.push(z(e));
|
|
2048
|
+
}
|
|
2049
|
+
function En(t) {
|
|
2050
|
+
let e = "";
|
|
2051
|
+
const i = [t];
|
|
2052
|
+
for (; i.length; ) {
|
|
2053
|
+
const n = i.shift();
|
|
2054
|
+
n.nodeType === Node.TEXT_NODE ? e += n.textContent : (e += `
|
|
2055
|
+
`, i.push(...n.childNodes));
|
|
2056
|
+
}
|
|
2057
|
+
return e.trim();
|
|
2058
|
+
}
|
|
2059
|
+
if (O.length === 0)
|
|
2060
|
+
return { scene: new Mn() };
|
|
2061
|
+
const st = new DOMParser().parseFromString(O, "application/xml"), Z = R(st, "COLLADA")[0], Pe = st.getElementsByTagName("parsererror")[0];
|
|
2062
|
+
if (Pe !== void 0) {
|
|
2063
|
+
const t = R(Pe, "div")[0];
|
|
2064
|
+
let e;
|
|
2065
|
+
return t ? e = t.textContent : e = En(Pe), console.error(`THREE.ColladaLoader: Failed to parse collada file.
|
|
2066
|
+
`, e), null;
|
|
2067
|
+
}
|
|
2068
|
+
const xn = Z.getAttribute("version");
|
|
2069
|
+
console.debug("THREE.ColladaLoader: File version", xn);
|
|
2070
|
+
const ot = we(R(Z, "asset")[0]), rt = new Tt(this.manager);
|
|
2071
|
+
rt.setPath(this.resourcePath || Q).setCrossOrigin(this.crossOrigin);
|
|
2072
|
+
let je;
|
|
2073
|
+
wt && (je = new wt(this.manager), je.setPath(this.resourcePath || Q));
|
|
2074
|
+
const Re = new ut(), Ie = [];
|
|
2075
|
+
let at = {}, _n = 0;
|
|
2076
|
+
const T = {
|
|
2077
|
+
animations: {},
|
|
2078
|
+
clips: {},
|
|
2079
|
+
controllers: {},
|
|
2080
|
+
images: {},
|
|
2081
|
+
effects: {},
|
|
2082
|
+
materials: {},
|
|
2083
|
+
cameras: {},
|
|
2084
|
+
lights: {},
|
|
2085
|
+
geometries: {},
|
|
2086
|
+
nodes: {},
|
|
2087
|
+
visualScenes: {},
|
|
2088
|
+
kinematicsModels: {},
|
|
2089
|
+
physicsModels: {},
|
|
2090
|
+
kinematicsScenes: {}
|
|
2091
|
+
};
|
|
2092
|
+
$(Z, "library_animations", "animation", be), $(Z, "library_animation_clips", "animation_clip", u), $(Z, "library_controllers", "controller", B), $(Z, "library_images", "image", f), $(Z, "library_effects", "effect", le), $(Z, "library_materials", "material", Ot), $(Z, "library_cameras", "camera", Pt), $(Z, "library_lights", "light", Bt), $(Z, "library_geometries", "geometry", Jt), $(Z, "library_nodes", "node", qe), $(Z, "library_visual_scenes", "visual_scene", kn), $(Z, "library_kinematics_models", "kinematics_model", Zt), $(Z, "library_physics_models", "physics_model", rn), $(Z, "scene", "instance_kinematics_scene", ln), ie(T.animations, P), ie(T.clips, W), ie(T.controllers, _), ie(T.images, A), ie(T.effects, ze), ie(T.materials, Ve), ie(T.cameras, Je), ie(T.lights, Ke), ie(T.geometries, We), ie(T.visualScenes, nt), Tn(), hn();
|
|
2093
|
+
const Me = An(R(Z, "scene")[0]);
|
|
2094
|
+
return Me.animations = Ie, ot.upAxis === "Z_UP" && (console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."), Me.rotation.set(-Math.PI / 2, 0, 0)), Me.scale.multiplyScalar(ot.unit), {
|
|
2095
|
+
get animations() {
|
|
2096
|
+
return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."), Ie;
|
|
2097
|
+
},
|
|
2098
|
+
kinematics: at,
|
|
2099
|
+
library: T,
|
|
2100
|
+
scene: Me
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
const Ue = new Et(), kt = new si();
|
|
2105
|
+
function _e(ue) {
|
|
2106
|
+
return ue ? ue.trim().split(/\s+/g).map((O) => parseFloat(O)) : [0, 0, 0];
|
|
2107
|
+
}
|
|
2108
|
+
function Nt(ue, O, Q = !1) {
|
|
2109
|
+
Q || ue.rotation.set(0, 0, 0), kt.set(O[0], O[1], O[2], "ZYX"), Ue.setFromEuler(kt), Ue.multiply(ue.quaternion), ue.quaternion.copy(Ue);
|
|
2110
|
+
}
|
|
2111
|
+
class ci {
|
|
2112
|
+
constructor(O) {
|
|
2113
|
+
this.manager = O || Yn, this.loadMeshCb = this.defaultMeshLoader.bind(this), this.parseVisual = !0, this.parseCollision = !1, this.packages = "", this.workingPath = "", this.fetchOptions = {};
|
|
2114
|
+
}
|
|
2115
|
+
/* Public API */
|
|
2116
|
+
loadAsync(O) {
|
|
2117
|
+
return new Promise((Q, R) => {
|
|
2118
|
+
this.load(O, Q, null, R);
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
// urdf: The path to the URDF within the package OR absolute
|
|
2122
|
+
// onComplete: Callback that is passed the model once loaded
|
|
2123
|
+
load(O, Q, R, se) {
|
|
2124
|
+
const v = this.manager, oe = At.extractUrlBase(O), I = this.manager.resolveURL(O);
|
|
2125
|
+
v.itemStart(I), fetch(I, this.fetchOptions).then((Y) => {
|
|
2126
|
+
if (Y.ok)
|
|
2127
|
+
return R && R(null), Y.text();
|
|
2128
|
+
throw new Error(`URDFLoader: Failed to load url '${I}' with error code ${Y.status} : ${Y.statusText}.`);
|
|
2129
|
+
}).then((Y) => {
|
|
2130
|
+
const ne = this.parse(Y, this.workingPath || oe);
|
|
2131
|
+
Q(ne), v.itemEnd(I);
|
|
2132
|
+
}).catch((Y) => {
|
|
2133
|
+
se ? se(Y) : console.error("URDFLoader: Error loading file.", Y), v.itemError(I), v.itemEnd(I);
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
parse(O, Q = this.workingPath) {
|
|
2137
|
+
const R = this.packages, se = this.loadMeshCb, v = this.parseVisual, oe = this.parseCollision, I = this.manager, Y = {}, ne = {}, we = {};
|
|
2138
|
+
function ke(M) {
|
|
2139
|
+
if (!/^package:\/\//.test(M))
|
|
2140
|
+
return Q ? Q + M : M;
|
|
2141
|
+
const [P, F] = M.replace(/^package:\/\//, "").split(/\/(.+)/);
|
|
2142
|
+
if (typeof R == "string")
|
|
2143
|
+
return R.endsWith(P) ? R + "/" + F : R + "/" + P + "/" + F;
|
|
2144
|
+
if (R instanceof Function)
|
|
2145
|
+
return R(P) + "/" + F;
|
|
2146
|
+
if (typeof R == "object")
|
|
2147
|
+
return P in R ? R[P] + "/" + F : (console.error(`URDFLoader : ${P} not found in provided package list.`), null);
|
|
2148
|
+
}
|
|
2149
|
+
function Ne(M) {
|
|
2150
|
+
let P;
|
|
2151
|
+
M instanceof Document ? P = [...M.children] : M instanceof Element ? P = [M] : P = [...new DOMParser().parseFromString(M, "text/xml").children];
|
|
2152
|
+
const F = P.filter((E) => E.nodeName === "robot").pop();
|
|
2153
|
+
return $(F);
|
|
2154
|
+
}
|
|
2155
|
+
function $(M) {
|
|
2156
|
+
const P = [...M.children], F = P.filter((L) => L.nodeName.toLowerCase() === "link"), E = P.filter((L) => L.nodeName.toLowerCase() === "joint"), J = P.filter((L) => L.nodeName.toLowerCase() === "material"), S = new Xn();
|
|
2157
|
+
S.robotName = M.getAttribute("name"), S.urdfRobotNode = M, J.forEach((L) => {
|
|
2158
|
+
const k = L.getAttribute("name");
|
|
2159
|
+
we[k] = be(L);
|
|
2160
|
+
});
|
|
2161
|
+
const m = {}, h = {};
|
|
2162
|
+
F.forEach((L) => {
|
|
2163
|
+
const k = L.getAttribute("name"), j = M.querySelector(`child[link="${k}"]`) === null;
|
|
2164
|
+
Y[k] = ee(L, m, h, j ? S : null);
|
|
2165
|
+
}), E.forEach((L) => {
|
|
2166
|
+
const k = L.getAttribute("name");
|
|
2167
|
+
ne[k] = ie(L);
|
|
2168
|
+
}), S.joints = ne, S.links = Y, S.colliders = h, S.visual = m;
|
|
2169
|
+
const C = Object.values(ne);
|
|
2170
|
+
return C.forEach((L) => {
|
|
2171
|
+
L instanceof yt && ne[L.mimicJoint].mimicJoints.push(L);
|
|
2172
|
+
}), C.forEach((L) => {
|
|
2173
|
+
const k = /* @__PURE__ */ new Set(), j = (ae) => {
|
|
2174
|
+
if (k.has(ae))
|
|
2175
|
+
throw new Error("URDFLoader: Detected an infinite loop of mimic joints.");
|
|
2176
|
+
k.add(ae), ae.mimicJoints.forEach((te) => {
|
|
2177
|
+
j(te);
|
|
2178
|
+
});
|
|
2179
|
+
};
|
|
2180
|
+
j(L);
|
|
2181
|
+
}), S.frames = {
|
|
2182
|
+
...h,
|
|
2183
|
+
...m,
|
|
2184
|
+
...Y,
|
|
2185
|
+
...ne
|
|
2186
|
+
}, S;
|
|
2187
|
+
}
|
|
2188
|
+
function ie(M) {
|
|
2189
|
+
const P = [...M.children], F = M.getAttribute("type");
|
|
2190
|
+
let E;
|
|
2191
|
+
const J = P.find((k) => k.nodeName.toLowerCase() === "mimic");
|
|
2192
|
+
J ? (E = new yt(), E.mimicJoint = J.getAttribute("joint"), E.multiplier = parseFloat(J.getAttribute("multiplier") || 1), E.offset = parseFloat(J.getAttribute("offset") || 0)) : E = new $n(), E.urdfNode = M, E.name = M.getAttribute("name"), E.urdfName = E.name, E.jointType = F;
|
|
2193
|
+
let S = null, m = null, h = [0, 0, 0], C = [0, 0, 0];
|
|
2194
|
+
P.forEach((k) => {
|
|
2195
|
+
const j = k.nodeName.toLowerCase();
|
|
2196
|
+
j === "origin" ? (h = _e(k.getAttribute("xyz")), C = _e(k.getAttribute("rpy"))) : j === "child" ? m = Y[k.getAttribute("link")] : j === "parent" ? S = Y[k.getAttribute("link")] : j === "limit" && (E.limit.lower = parseFloat(k.getAttribute("lower") || E.limit.lower), E.limit.upper = parseFloat(k.getAttribute("upper") || E.limit.upper));
|
|
2197
|
+
}), S.add(E), E.add(m), Nt(E, C), E.position.set(h[0], h[1], h[2]);
|
|
2198
|
+
const L = P.filter((k) => k.nodeName.toLowerCase() === "axis")[0];
|
|
2199
|
+
if (L) {
|
|
2200
|
+
const k = L.getAttribute("xyz").split(/\s+/g).map((j) => parseFloat(j));
|
|
2201
|
+
E.axis = new pe(k[0], k[1], k[2]), E.axis.normalize();
|
|
2202
|
+
}
|
|
2203
|
+
return E;
|
|
2204
|
+
}
|
|
2205
|
+
function ee(M, P, F, E = null) {
|
|
2206
|
+
E === null && (E = new Zn());
|
|
2207
|
+
const J = [...M.children];
|
|
2208
|
+
return E.name = M.getAttribute("name"), E.urdfName = E.name, E.urdfNode = M, v && J.filter((m) => m.nodeName.toLowerCase() === "visual").forEach((m) => {
|
|
2209
|
+
const h = ge(m, we);
|
|
2210
|
+
if (E.add(h), m.hasAttribute("name")) {
|
|
2211
|
+
const C = m.getAttribute("name");
|
|
2212
|
+
h.name = C, h.urdfName = C, P[C] = h;
|
|
2213
|
+
}
|
|
2214
|
+
}), oe && J.filter((m) => m.nodeName.toLowerCase() === "collision").forEach((m) => {
|
|
2215
|
+
const h = ge(m);
|
|
2216
|
+
if (E.add(h), m.hasAttribute("name")) {
|
|
2217
|
+
const C = m.getAttribute("name");
|
|
2218
|
+
h.name = C, h.urdfName = C, F[C] = h;
|
|
2219
|
+
}
|
|
2220
|
+
}), E;
|
|
2221
|
+
}
|
|
2222
|
+
function be(M) {
|
|
2223
|
+
const P = [...M.children], F = new ve();
|
|
2224
|
+
return F.name = M.getAttribute("name") || "", P.forEach((E) => {
|
|
2225
|
+
const J = E.nodeName.toLowerCase();
|
|
2226
|
+
if (J === "color") {
|
|
2227
|
+
const S = E.getAttribute("rgba").split(/\s/g).map((m) => parseFloat(m));
|
|
2228
|
+
F.color.setRGB(S[0], S[1], S[2]), F.opacity = S[3], F.transparent = S[3] < 1, F.depthWrite = !F.transparent;
|
|
2229
|
+
} else if (J === "texture") {
|
|
2230
|
+
const S = E.getAttribute("filename");
|
|
2231
|
+
if (S) {
|
|
2232
|
+
const m = new Tt(I), h = ke(S);
|
|
2233
|
+
F.map = m.load(h), F.map.colorSpace = me;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
}), F;
|
|
2237
|
+
}
|
|
2238
|
+
function ge(M, P = {}) {
|
|
2239
|
+
const F = M.nodeName.toLowerCase() === "collision", E = [...M.children];
|
|
2240
|
+
let J = null;
|
|
2241
|
+
const S = E.filter((h) => h.nodeName.toLowerCase() === "material")[0];
|
|
2242
|
+
if (S) {
|
|
2243
|
+
const h = S.getAttribute("name");
|
|
2244
|
+
h && h in P ? J = P[h] : J = be(S);
|
|
2245
|
+
} else
|
|
2246
|
+
J = new ve();
|
|
2247
|
+
const m = F ? new Qn() : new ei();
|
|
2248
|
+
return m.urdfNode = M, E.forEach((h) => {
|
|
2249
|
+
const C = h.nodeName.toLowerCase();
|
|
2250
|
+
if (C === "geometry") {
|
|
2251
|
+
const L = h.children[0].nodeName.toLowerCase();
|
|
2252
|
+
if (L === "mesh") {
|
|
2253
|
+
const k = h.children[0].getAttribute("filename"), j = ke(k);
|
|
2254
|
+
if (j !== null) {
|
|
2255
|
+
const ae = h.children[0].getAttribute("scale");
|
|
2256
|
+
if (ae) {
|
|
2257
|
+
const te = _e(ae);
|
|
2258
|
+
m.scale.set(te[0], te[1], te[2]);
|
|
2259
|
+
}
|
|
2260
|
+
se(j, I, (te, u) => {
|
|
2261
|
+
u ? console.error("URDFLoader: Error loading mesh.", u) : te && (te instanceof Ce && (te.material = J), te.position.set(0, 0, 0), te.quaternion.identity(), m.add(te));
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
} else if (L === "box") {
|
|
2265
|
+
const k = new Ce();
|
|
2266
|
+
k.geometry = new ti(1, 1, 1), k.material = J;
|
|
2267
|
+
const j = _e(h.children[0].getAttribute("size"));
|
|
2268
|
+
k.scale.set(j[0], j[1], j[2]), m.add(k);
|
|
2269
|
+
} else if (L === "sphere") {
|
|
2270
|
+
const k = new Ce();
|
|
2271
|
+
k.geometry = new ni(1, 30, 30), k.material = J;
|
|
2272
|
+
const j = parseFloat(h.children[0].getAttribute("radius")) || 0;
|
|
2273
|
+
k.scale.set(j, j, j), m.add(k);
|
|
2274
|
+
} else if (L === "cylinder") {
|
|
2275
|
+
const k = new Ce();
|
|
2276
|
+
k.geometry = new ii(1, 1, 1, 30), k.material = J;
|
|
2277
|
+
const j = parseFloat(h.children[0].getAttribute("radius")) || 0, ae = parseFloat(h.children[0].getAttribute("length")) || 0;
|
|
2278
|
+
k.scale.set(j, ae, j), k.rotation.set(Math.PI / 2, 0, 0), m.add(k);
|
|
2279
|
+
}
|
|
2280
|
+
} else if (C === "origin") {
|
|
2281
|
+
const L = _e(h.getAttribute("xyz")), k = _e(h.getAttribute("rpy"));
|
|
2282
|
+
m.position.set(L[0], L[1], L[2]), m.rotation.set(0, 0, 0), Nt(m, k);
|
|
2283
|
+
}
|
|
2284
|
+
}), m;
|
|
2285
|
+
}
|
|
2286
|
+
return Ne(O);
|
|
2287
|
+
}
|
|
2288
|
+
// Default mesh loading function
|
|
2289
|
+
defaultMeshLoader(O, Q, R) {
|
|
2290
|
+
/\.stl$/i.test(O) ? new Ln(Q).load(O, (v) => {
|
|
2291
|
+
const oe = new Ce(v, new ve());
|
|
2292
|
+
R(oe);
|
|
2293
|
+
}) : /\.dae$/i.test(O) ? new oi(Q).load(O, (v) => R(v.scene)) : console.warn(`URDFLoader: Could not load model at ${O}.
|
|
2294
|
+
No loader available`);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
export {
|
|
2298
|
+
ci as U
|
|
2299
|
+
};
|