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