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