@aixa-transformation/pptx-viewer 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +369 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/README.md +249 -0
- package/dist/GLTFLoader-CV33YWNT.js +2613 -0
- package/dist/GLTFLoader-FQJ2I67K.mjs +2611 -0
- package/dist/Model3DScene-5ODZLKJM.mjs +49 -0
- package/dist/Model3DScene-VLHFNN5B.js +51 -0
- package/dist/OrbitControls-HI6CI76Z.mjs +3 -0
- package/dist/OrbitControls-XGY7XEC6.js +12 -0
- package/dist/SmartArt3DScene-3FL5JELA.mjs +333 -0
- package/dist/SmartArt3DScene-7IZ3IJYV.js +335 -0
- package/dist/SurfaceChart3DScene-C6GQQQB7.mjs +77 -0
- package/dist/SurfaceChart3DScene-KHMGQAGP.js +79 -0
- package/dist/chunk-2TOLRBFU.js +27629 -0
- package/dist/chunk-2X72MOPZ.mjs +2796 -0
- package/dist/chunk-6DZX6EAA.mjs +33 -0
- package/dist/chunk-AD2CLKY6.js +92338 -0
- package/dist/chunk-CUUYYYC5.js +2800 -0
- package/dist/chunk-DAKELFNP.js +915 -0
- package/dist/chunk-F2HFXS2Z.mjs +19063 -0
- package/dist/chunk-F3LO2NKI.mjs +913 -0
- package/dist/chunk-HNI6JYAI.js +34591 -0
- package/dist/chunk-IKBO6CZC.js +2 -0
- package/dist/chunk-KVM4DBEU.mjs +91768 -0
- package/dist/chunk-MOEXMRVK.js +19220 -0
- package/dist/chunk-QGM4M3NI.js +37 -0
- package/dist/chunk-SQY54X47.js +43506 -0
- package/dist/chunk-T5U6P2JH.mjs +1 -0
- package/dist/chunk-TB5ZWNMX.mjs +34577 -0
- package/dist/chunk-W5V6CEFL.mjs +43064 -0
- package/dist/chunk-XAVVR6OX.mjs +27204 -0
- package/dist/chunk-Y6FQDUJU.js +1160 -0
- package/dist/chunk-YI3G35EC.mjs +1076 -0
- package/dist/dist-LQJHTLHL.mjs +2 -0
- package/dist/dist-NVA3FEUV.js +2275 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +19 -0
- package/dist/i18n.mjs +2 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +135 -0
- package/dist/index.mjs +6 -0
- package/dist/internals.d.ts +1 -0
- package/dist/internals.js +311 -0
- package/dist/internals.mjs +6 -0
- package/dist/pptx-viewer.css +2 -0
- package/dist/presentation.d.ts +1 -0
- package/dist/presentation.js +11 -0
- package/dist/presentation.mjs +2 -0
- package/dist/three.module-HOXVV2KF.mjs +2 -0
- package/dist/three.module-QSJWIYNI.js +1771 -0
- package/dist/viewer/index.d.ts +1 -0
- package/dist/viewer/index.js +76 -0
- package/dist/viewer/index.mjs +7 -0
- package/dist/y-webrtc-DFUKFWCA.mjs +4279 -0
- package/dist/y-webrtc-RRACJ6WX.js +4284 -0
- package/dist/y-websocket-T5R5YGVE.mjs +378 -0
- package/dist/y-websocket-WMSHYIGX.js +384 -0
- package/package.json +141 -0
|
@@ -0,0 +1,2613 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSQY54X47_js = require('./chunk-SQY54X47.js');
|
|
4
|
+
require('./chunk-QGM4M3NI.js');
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/three/examples/jsm/utils/BufferGeometryUtils.js
|
|
7
|
+
function toTrianglesDrawMode(geometry, drawMode) {
|
|
8
|
+
if (drawMode === chunkSQY54X47_js.TrianglesDrawMode) {
|
|
9
|
+
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
|
|
10
|
+
return geometry;
|
|
11
|
+
}
|
|
12
|
+
if (drawMode === chunkSQY54X47_js.TriangleFanDrawMode || drawMode === chunkSQY54X47_js.TriangleStripDrawMode) {
|
|
13
|
+
let index = geometry.getIndex();
|
|
14
|
+
if (index === null) {
|
|
15
|
+
const indices = [];
|
|
16
|
+
const position = geometry.getAttribute("position");
|
|
17
|
+
if (position !== void 0) {
|
|
18
|
+
for (let i = 0; i < position.count; i++) {
|
|
19
|
+
indices.push(i);
|
|
20
|
+
}
|
|
21
|
+
geometry.setIndex(indices);
|
|
22
|
+
index = geometry.getIndex();
|
|
23
|
+
} else {
|
|
24
|
+
console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.");
|
|
25
|
+
return geometry;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const numberOfTriangles = index.count - 2;
|
|
29
|
+
const newIndices = [];
|
|
30
|
+
if (drawMode === chunkSQY54X47_js.TriangleFanDrawMode) {
|
|
31
|
+
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
32
|
+
newIndices.push(index.getX(0));
|
|
33
|
+
newIndices.push(index.getX(i));
|
|
34
|
+
newIndices.push(index.getX(i + 1));
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
for (let i = 0; i < numberOfTriangles; i++) {
|
|
38
|
+
if (i % 2 === 0) {
|
|
39
|
+
newIndices.push(index.getX(i));
|
|
40
|
+
newIndices.push(index.getX(i + 1));
|
|
41
|
+
newIndices.push(index.getX(i + 2));
|
|
42
|
+
} else {
|
|
43
|
+
newIndices.push(index.getX(i + 2));
|
|
44
|
+
newIndices.push(index.getX(i + 1));
|
|
45
|
+
newIndices.push(index.getX(i));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (newIndices.length / 3 !== numberOfTriangles) {
|
|
50
|
+
console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
|
|
51
|
+
}
|
|
52
|
+
const newGeometry = geometry.clone();
|
|
53
|
+
newGeometry.setIndex(newIndices);
|
|
54
|
+
newGeometry.clearGroups();
|
|
55
|
+
return newGeometry;
|
|
56
|
+
} else {
|
|
57
|
+
console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", drawMode);
|
|
58
|
+
return geometry;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/three/examples/jsm/utils/SkeletonUtils.js
|
|
63
|
+
function clone(source) {
|
|
64
|
+
const sourceLookup = /* @__PURE__ */ new Map();
|
|
65
|
+
const cloneLookup = /* @__PURE__ */ new Map();
|
|
66
|
+
const clone2 = source.clone();
|
|
67
|
+
parallelTraverse(source, clone2, function(sourceNode, clonedNode) {
|
|
68
|
+
sourceLookup.set(clonedNode, sourceNode);
|
|
69
|
+
cloneLookup.set(sourceNode, clonedNode);
|
|
70
|
+
});
|
|
71
|
+
clone2.traverse(function(node) {
|
|
72
|
+
if (!node.isSkinnedMesh) return;
|
|
73
|
+
const clonedMesh = node;
|
|
74
|
+
const sourceMesh = sourceLookup.get(node);
|
|
75
|
+
const sourceBones = sourceMesh.skeleton.bones;
|
|
76
|
+
clonedMesh.skeleton = sourceMesh.skeleton.clone();
|
|
77
|
+
clonedMesh.bindMatrix.copy(sourceMesh.bindMatrix);
|
|
78
|
+
clonedMesh.skeleton.bones = sourceBones.map(function(bone) {
|
|
79
|
+
return cloneLookup.get(bone);
|
|
80
|
+
});
|
|
81
|
+
clonedMesh.bind(clonedMesh.skeleton, clonedMesh.bindMatrix);
|
|
82
|
+
});
|
|
83
|
+
return clone2;
|
|
84
|
+
}
|
|
85
|
+
function parallelTraverse(a, b, callback) {
|
|
86
|
+
callback(a, b);
|
|
87
|
+
for (let i = 0; i < a.children.length; i++) {
|
|
88
|
+
parallelTraverse(a.children[i], b.children[i], callback);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ../../node_modules/three/examples/jsm/loaders/GLTFLoader.js
|
|
93
|
+
var GLTFLoader = class extends chunkSQY54X47_js.Loader {
|
|
94
|
+
/**
|
|
95
|
+
* Constructs a new glTF loader.
|
|
96
|
+
*
|
|
97
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
98
|
+
*/
|
|
99
|
+
constructor(manager) {
|
|
100
|
+
super(manager);
|
|
101
|
+
this.dracoLoader = null;
|
|
102
|
+
this.ktx2Loader = null;
|
|
103
|
+
this.meshoptDecoder = null;
|
|
104
|
+
this.pluginCallbacks = [];
|
|
105
|
+
this.register(function(parser) {
|
|
106
|
+
return new GLTFMaterialsClearcoatExtension(parser);
|
|
107
|
+
});
|
|
108
|
+
this.register(function(parser) {
|
|
109
|
+
return new GLTFMaterialsDispersionExtension(parser);
|
|
110
|
+
});
|
|
111
|
+
this.register(function(parser) {
|
|
112
|
+
return new GLTFTextureBasisUExtension(parser);
|
|
113
|
+
});
|
|
114
|
+
this.register(function(parser) {
|
|
115
|
+
return new GLTFTextureWebPExtension(parser);
|
|
116
|
+
});
|
|
117
|
+
this.register(function(parser) {
|
|
118
|
+
return new GLTFTextureAVIFExtension(parser);
|
|
119
|
+
});
|
|
120
|
+
this.register(function(parser) {
|
|
121
|
+
return new GLTFMaterialsSheenExtension(parser);
|
|
122
|
+
});
|
|
123
|
+
this.register(function(parser) {
|
|
124
|
+
return new GLTFMaterialsTransmissionExtension(parser);
|
|
125
|
+
});
|
|
126
|
+
this.register(function(parser) {
|
|
127
|
+
return new GLTFMaterialsVolumeExtension(parser);
|
|
128
|
+
});
|
|
129
|
+
this.register(function(parser) {
|
|
130
|
+
return new GLTFMaterialsIorExtension(parser);
|
|
131
|
+
});
|
|
132
|
+
this.register(function(parser) {
|
|
133
|
+
return new GLTFMaterialsEmissiveStrengthExtension(parser);
|
|
134
|
+
});
|
|
135
|
+
this.register(function(parser) {
|
|
136
|
+
return new GLTFMaterialsSpecularExtension(parser);
|
|
137
|
+
});
|
|
138
|
+
this.register(function(parser) {
|
|
139
|
+
return new GLTFMaterialsIridescenceExtension(parser);
|
|
140
|
+
});
|
|
141
|
+
this.register(function(parser) {
|
|
142
|
+
return new GLTFMaterialsAnisotropyExtension(parser);
|
|
143
|
+
});
|
|
144
|
+
this.register(function(parser) {
|
|
145
|
+
return new GLTFMaterialsBumpExtension(parser);
|
|
146
|
+
});
|
|
147
|
+
this.register(function(parser) {
|
|
148
|
+
return new GLTFLightsExtension(parser);
|
|
149
|
+
});
|
|
150
|
+
this.register(function(parser) {
|
|
151
|
+
return new GLTFMeshoptCompression(parser, EXTENSIONS.EXT_MESHOPT_COMPRESSION);
|
|
152
|
+
});
|
|
153
|
+
this.register(function(parser) {
|
|
154
|
+
return new GLTFMeshoptCompression(parser, EXTENSIONS.KHR_MESHOPT_COMPRESSION);
|
|
155
|
+
});
|
|
156
|
+
this.register(function(parser) {
|
|
157
|
+
return new GLTFMeshGpuInstancing(parser);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Starts loading from the given URL and passes the loaded glTF asset
|
|
162
|
+
* to the `onLoad()` callback.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
165
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
166
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
167
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
168
|
+
*/
|
|
169
|
+
load(url, onLoad, onProgress, onError) {
|
|
170
|
+
const scope = this;
|
|
171
|
+
let resourcePath;
|
|
172
|
+
if (this.resourcePath !== "") {
|
|
173
|
+
resourcePath = this.resourcePath;
|
|
174
|
+
} else if (this.path !== "") {
|
|
175
|
+
const relativeUrl = chunkSQY54X47_js.LoaderUtils.extractUrlBase(url);
|
|
176
|
+
resourcePath = chunkSQY54X47_js.LoaderUtils.resolveURL(relativeUrl, this.path);
|
|
177
|
+
} else {
|
|
178
|
+
resourcePath = chunkSQY54X47_js.LoaderUtils.extractUrlBase(url);
|
|
179
|
+
}
|
|
180
|
+
this.manager.itemStart(url);
|
|
181
|
+
const _onError = function(e) {
|
|
182
|
+
if (onError) {
|
|
183
|
+
onError(e);
|
|
184
|
+
} else {
|
|
185
|
+
console.error(e);
|
|
186
|
+
}
|
|
187
|
+
scope.manager.itemError(url);
|
|
188
|
+
scope.manager.itemEnd(url);
|
|
189
|
+
};
|
|
190
|
+
const loader = new chunkSQY54X47_js.FileLoader(this.manager);
|
|
191
|
+
loader.setPath(this.path);
|
|
192
|
+
loader.setResponseType("arraybuffer");
|
|
193
|
+
loader.setRequestHeader(this.requestHeader);
|
|
194
|
+
loader.setWithCredentials(this.withCredentials);
|
|
195
|
+
loader.load(url, function(data) {
|
|
196
|
+
try {
|
|
197
|
+
scope.parse(data, resourcePath, function(gltf) {
|
|
198
|
+
onLoad(gltf);
|
|
199
|
+
scope.manager.itemEnd(url);
|
|
200
|
+
}, _onError);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
_onError(e);
|
|
203
|
+
}
|
|
204
|
+
}, onProgress, _onError);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Sets the given Draco loader to this loader. Required for decoding assets
|
|
208
|
+
* compressed with the `KHR_draco_mesh_compression` extension.
|
|
209
|
+
*
|
|
210
|
+
* @param {DRACOLoader} dracoLoader - The Draco loader to set.
|
|
211
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
212
|
+
*/
|
|
213
|
+
setDRACOLoader(dracoLoader) {
|
|
214
|
+
this.dracoLoader = dracoLoader;
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Sets the given KTX2 loader to this loader. Required for loading KTX2
|
|
219
|
+
* compressed textures.
|
|
220
|
+
*
|
|
221
|
+
* @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
|
|
222
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
223
|
+
*/
|
|
224
|
+
setKTX2Loader(ktx2Loader) {
|
|
225
|
+
this.ktx2Loader = ktx2Loader;
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Sets the given meshopt decoder. Required for decoding assets
|
|
230
|
+
* compressed with the `EXT_meshopt_compression` extension.
|
|
231
|
+
*
|
|
232
|
+
* @param {Object} meshoptDecoder - The meshopt decoder to set.
|
|
233
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
234
|
+
*/
|
|
235
|
+
setMeshoptDecoder(meshoptDecoder) {
|
|
236
|
+
this.meshoptDecoder = meshoptDecoder;
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
241
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
242
|
+
* to the loader.
|
|
243
|
+
*
|
|
244
|
+
* @param {function(parser:GLTFParser)} callback - The callback function to register.
|
|
245
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
246
|
+
*/
|
|
247
|
+
register(callback) {
|
|
248
|
+
if (this.pluginCallbacks.indexOf(callback) === -1) {
|
|
249
|
+
this.pluginCallbacks.push(callback);
|
|
250
|
+
}
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Unregisters a plugin callback.
|
|
255
|
+
*
|
|
256
|
+
* @param {Function} callback - The callback function to unregister.
|
|
257
|
+
* @return {GLTFLoader} A reference to this loader.
|
|
258
|
+
*/
|
|
259
|
+
unregister(callback) {
|
|
260
|
+
if (this.pluginCallbacks.indexOf(callback) !== -1) {
|
|
261
|
+
this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback), 1);
|
|
262
|
+
}
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Parses the given glTF data and returns the resulting group.
|
|
267
|
+
*
|
|
268
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
269
|
+
* @param {string} path - The URL base path.
|
|
270
|
+
* @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
|
|
271
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
272
|
+
*/
|
|
273
|
+
parse(data, path, onLoad, onError) {
|
|
274
|
+
let json;
|
|
275
|
+
const extensions = {};
|
|
276
|
+
const plugins = {};
|
|
277
|
+
const textDecoder = new TextDecoder();
|
|
278
|
+
if (typeof data === "string") {
|
|
279
|
+
json = JSON.parse(data);
|
|
280
|
+
} else if (data instanceof ArrayBuffer) {
|
|
281
|
+
const magic = textDecoder.decode(new Uint8Array(data, 0, 4));
|
|
282
|
+
if (magic === BINARY_EXTENSION_HEADER_MAGIC) {
|
|
283
|
+
try {
|
|
284
|
+
extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);
|
|
285
|
+
} catch (error) {
|
|
286
|
+
if (onError) onError(error);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
json = JSON.parse(extensions[EXTENSIONS.KHR_BINARY_GLTF].content);
|
|
290
|
+
} else {
|
|
291
|
+
json = JSON.parse(textDecoder.decode(data));
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
json = data;
|
|
295
|
+
}
|
|
296
|
+
if (json.asset === void 0 || json.asset.version[0] < 2) {
|
|
297
|
+
if (onError) onError(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const parser = new GLTFParser(json, {
|
|
301
|
+
path: path || this.resourcePath || "",
|
|
302
|
+
crossOrigin: this.crossOrigin,
|
|
303
|
+
requestHeader: this.requestHeader,
|
|
304
|
+
manager: this.manager,
|
|
305
|
+
ktx2Loader: this.ktx2Loader,
|
|
306
|
+
meshoptDecoder: this.meshoptDecoder
|
|
307
|
+
});
|
|
308
|
+
parser.fileLoader.setRequestHeader(this.requestHeader);
|
|
309
|
+
for (let i = 0; i < this.pluginCallbacks.length; i++) {
|
|
310
|
+
const plugin = this.pluginCallbacks[i](parser);
|
|
311
|
+
if (!plugin.name) console.error("THREE.GLTFLoader: Invalid plugin found: missing name");
|
|
312
|
+
plugins[plugin.name] = plugin;
|
|
313
|
+
extensions[plugin.name] = true;
|
|
314
|
+
}
|
|
315
|
+
if (json.extensionsUsed) {
|
|
316
|
+
for (let i = 0; i < json.extensionsUsed.length; ++i) {
|
|
317
|
+
const extensionName = json.extensionsUsed[i];
|
|
318
|
+
const extensionsRequired = json.extensionsRequired || [];
|
|
319
|
+
switch (extensionName) {
|
|
320
|
+
case EXTENSIONS.KHR_MATERIALS_UNLIT:
|
|
321
|
+
extensions[extensionName] = new GLTFMaterialsUnlitExtension();
|
|
322
|
+
break;
|
|
323
|
+
case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
|
|
324
|
+
extensions[extensionName] = new GLTFDracoMeshCompressionExtension(json, this.dracoLoader);
|
|
325
|
+
break;
|
|
326
|
+
case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
|
|
327
|
+
extensions[extensionName] = new GLTFTextureTransformExtension();
|
|
328
|
+
break;
|
|
329
|
+
case EXTENSIONS.KHR_MESH_QUANTIZATION:
|
|
330
|
+
extensions[extensionName] = new GLTFMeshQuantizationExtension();
|
|
331
|
+
break;
|
|
332
|
+
default:
|
|
333
|
+
if (extensionsRequired.indexOf(extensionName) >= 0 && plugins[extensionName] === void 0) {
|
|
334
|
+
console.warn('THREE.GLTFLoader: Unknown extension "' + extensionName + '".');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
parser.setExtensions(extensions);
|
|
340
|
+
parser.setPlugins(plugins);
|
|
341
|
+
parser.parse(onLoad, onError);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Async version of {@link GLTFLoader#parse}.
|
|
345
|
+
*
|
|
346
|
+
* @async
|
|
347
|
+
* @param {string|ArrayBuffer} data - The raw glTF data.
|
|
348
|
+
* @param {string} path - The URL base path.
|
|
349
|
+
* @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
|
|
350
|
+
*/
|
|
351
|
+
parseAsync(data, path) {
|
|
352
|
+
const scope = this;
|
|
353
|
+
return new Promise(function(resolve, reject) {
|
|
354
|
+
scope.parse(data, path, resolve, reject);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
function GLTFRegistry() {
|
|
359
|
+
let objects = {};
|
|
360
|
+
return {
|
|
361
|
+
get: function(key) {
|
|
362
|
+
return objects[key];
|
|
363
|
+
},
|
|
364
|
+
add: function(key, object) {
|
|
365
|
+
objects[key] = object;
|
|
366
|
+
},
|
|
367
|
+
remove: function(key) {
|
|
368
|
+
delete objects[key];
|
|
369
|
+
},
|
|
370
|
+
removeAll: function() {
|
|
371
|
+
objects = {};
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function getMaterialExtension(parser, materialIndex, extensionName) {
|
|
376
|
+
const materialDef = parser.json.materials[materialIndex];
|
|
377
|
+
if (materialDef.extensions && materialDef.extensions[extensionName]) {
|
|
378
|
+
return materialDef.extensions[extensionName];
|
|
379
|
+
}
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
var EXTENSIONS = {
|
|
383
|
+
KHR_BINARY_GLTF: "KHR_binary_glTF",
|
|
384
|
+
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
|
|
385
|
+
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
|
|
386
|
+
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
|
|
387
|
+
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
|
|
388
|
+
KHR_MATERIALS_IOR: "KHR_materials_ior",
|
|
389
|
+
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
|
|
390
|
+
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
|
|
391
|
+
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
|
|
392
|
+
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
|
|
393
|
+
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
|
|
394
|
+
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
|
|
395
|
+
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
|
|
396
|
+
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
|
|
397
|
+
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
|
|
398
|
+
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
|
|
399
|
+
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
|
|
400
|
+
EXT_MATERIALS_BUMP: "EXT_materials_bump",
|
|
401
|
+
EXT_TEXTURE_WEBP: "EXT_texture_webp",
|
|
402
|
+
EXT_TEXTURE_AVIF: "EXT_texture_avif",
|
|
403
|
+
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
|
|
404
|
+
KHR_MESHOPT_COMPRESSION: "KHR_meshopt_compression",
|
|
405
|
+
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
|
|
406
|
+
};
|
|
407
|
+
var GLTFLightsExtension = class {
|
|
408
|
+
constructor(parser) {
|
|
409
|
+
this.parser = parser;
|
|
410
|
+
this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
|
|
411
|
+
this.cache = { refs: {}, uses: {} };
|
|
412
|
+
}
|
|
413
|
+
_markDefs() {
|
|
414
|
+
const parser = this.parser;
|
|
415
|
+
const nodeDefs = this.parser.json.nodes || [];
|
|
416
|
+
for (let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
|
|
417
|
+
const nodeDef = nodeDefs[nodeIndex];
|
|
418
|
+
if (nodeDef.extensions && nodeDef.extensions[this.name] && nodeDef.extensions[this.name].light !== void 0) {
|
|
419
|
+
parser._addNodeRef(this.cache, nodeDef.extensions[this.name].light);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
_loadLight(lightIndex) {
|
|
424
|
+
const parser = this.parser;
|
|
425
|
+
const cacheKey = "light:" + lightIndex;
|
|
426
|
+
let dependency = parser.cache.get(cacheKey);
|
|
427
|
+
if (dependency) return dependency;
|
|
428
|
+
const json = parser.json;
|
|
429
|
+
const extensions = json.extensions && json.extensions[this.name] || {};
|
|
430
|
+
const lightDefs = extensions.lights || [];
|
|
431
|
+
const lightDef = lightDefs[lightIndex];
|
|
432
|
+
let lightNode;
|
|
433
|
+
const color = new chunkSQY54X47_js.Color(16777215);
|
|
434
|
+
if (lightDef.color !== void 0) color.setRGB(lightDef.color[0], lightDef.color[1], lightDef.color[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
435
|
+
const range = lightDef.range !== void 0 ? lightDef.range : 0;
|
|
436
|
+
switch (lightDef.type) {
|
|
437
|
+
case "directional":
|
|
438
|
+
lightNode = new chunkSQY54X47_js.DirectionalLight(color);
|
|
439
|
+
lightNode.target.position.set(0, 0, -1);
|
|
440
|
+
lightNode.add(lightNode.target);
|
|
441
|
+
break;
|
|
442
|
+
case "point":
|
|
443
|
+
lightNode = new chunkSQY54X47_js.PointLight(color);
|
|
444
|
+
lightNode.distance = range;
|
|
445
|
+
break;
|
|
446
|
+
case "spot":
|
|
447
|
+
lightNode = new chunkSQY54X47_js.SpotLight(color);
|
|
448
|
+
lightNode.distance = range;
|
|
449
|
+
lightDef.spot = lightDef.spot || {};
|
|
450
|
+
lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== void 0 ? lightDef.spot.innerConeAngle : 0;
|
|
451
|
+
lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== void 0 ? lightDef.spot.outerConeAngle : Math.PI / 4;
|
|
452
|
+
lightNode.angle = lightDef.spot.outerConeAngle;
|
|
453
|
+
lightNode.penumbra = 1 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
|
|
454
|
+
lightNode.target.position.set(0, 0, -1);
|
|
455
|
+
lightNode.add(lightNode.target);
|
|
456
|
+
break;
|
|
457
|
+
default:
|
|
458
|
+
throw new Error("THREE.GLTFLoader: Unexpected light type: " + lightDef.type);
|
|
459
|
+
}
|
|
460
|
+
lightNode.position.set(0, 0, 0);
|
|
461
|
+
assignExtrasToUserData(lightNode, lightDef);
|
|
462
|
+
if (lightDef.intensity !== void 0) lightNode.intensity = lightDef.intensity;
|
|
463
|
+
lightNode.name = parser.createUniqueName(lightDef.name || "light_" + lightIndex);
|
|
464
|
+
dependency = Promise.resolve(lightNode);
|
|
465
|
+
parser.cache.add(cacheKey, dependency);
|
|
466
|
+
return dependency;
|
|
467
|
+
}
|
|
468
|
+
getDependency(type, index) {
|
|
469
|
+
if (type !== "light") return;
|
|
470
|
+
return this._loadLight(index);
|
|
471
|
+
}
|
|
472
|
+
createNodeAttachment(nodeIndex) {
|
|
473
|
+
const self2 = this;
|
|
474
|
+
const parser = this.parser;
|
|
475
|
+
const json = parser.json;
|
|
476
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
477
|
+
const lightDef = nodeDef.extensions && nodeDef.extensions[this.name] || {};
|
|
478
|
+
const lightIndex = lightDef.light;
|
|
479
|
+
if (lightIndex === void 0) return null;
|
|
480
|
+
return this._loadLight(lightIndex).then(function(light) {
|
|
481
|
+
return parser._getNodeRef(self2.cache, lightIndex, light);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
var GLTFMaterialsUnlitExtension = class {
|
|
486
|
+
constructor() {
|
|
487
|
+
this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
|
|
488
|
+
}
|
|
489
|
+
getMaterialType() {
|
|
490
|
+
return chunkSQY54X47_js.MeshBasicMaterial;
|
|
491
|
+
}
|
|
492
|
+
extendParams(materialParams, materialDef, parser) {
|
|
493
|
+
const pending = [];
|
|
494
|
+
materialParams.color = new chunkSQY54X47_js.Color(1, 1, 1);
|
|
495
|
+
materialParams.opacity = 1;
|
|
496
|
+
const metallicRoughness = materialDef.pbrMetallicRoughness;
|
|
497
|
+
if (metallicRoughness) {
|
|
498
|
+
if (Array.isArray(metallicRoughness.baseColorFactor)) {
|
|
499
|
+
const array = metallicRoughness.baseColorFactor;
|
|
500
|
+
materialParams.color.setRGB(array[0], array[1], array[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
501
|
+
materialParams.opacity = array[3];
|
|
502
|
+
}
|
|
503
|
+
if (metallicRoughness.baseColorTexture !== void 0) {
|
|
504
|
+
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, chunkSQY54X47_js.SRGBColorSpace));
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return Promise.all(pending);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var GLTFMaterialsEmissiveStrengthExtension = class {
|
|
511
|
+
constructor(parser) {
|
|
512
|
+
this.parser = parser;
|
|
513
|
+
this.name = EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH;
|
|
514
|
+
}
|
|
515
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
516
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
517
|
+
if (extension === null) return Promise.resolve();
|
|
518
|
+
if (extension.emissiveStrength !== void 0) {
|
|
519
|
+
materialParams.emissiveIntensity = extension.emissiveStrength;
|
|
520
|
+
}
|
|
521
|
+
return Promise.resolve();
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
var GLTFMaterialsClearcoatExtension = class {
|
|
525
|
+
constructor(parser) {
|
|
526
|
+
this.parser = parser;
|
|
527
|
+
this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
|
|
528
|
+
}
|
|
529
|
+
getMaterialType(materialIndex) {
|
|
530
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
531
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
532
|
+
}
|
|
533
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
534
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
535
|
+
if (extension === null) return Promise.resolve();
|
|
536
|
+
const pending = [];
|
|
537
|
+
if (extension.clearcoatFactor !== void 0) {
|
|
538
|
+
materialParams.clearcoat = extension.clearcoatFactor;
|
|
539
|
+
}
|
|
540
|
+
if (extension.clearcoatTexture !== void 0) {
|
|
541
|
+
pending.push(this.parser.assignTexture(materialParams, "clearcoatMap", extension.clearcoatTexture));
|
|
542
|
+
}
|
|
543
|
+
if (extension.clearcoatRoughnessFactor !== void 0) {
|
|
544
|
+
materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
|
|
545
|
+
}
|
|
546
|
+
if (extension.clearcoatRoughnessTexture !== void 0) {
|
|
547
|
+
pending.push(this.parser.assignTexture(materialParams, "clearcoatRoughnessMap", extension.clearcoatRoughnessTexture));
|
|
548
|
+
}
|
|
549
|
+
if (extension.clearcoatNormalTexture !== void 0) {
|
|
550
|
+
pending.push(this.parser.assignTexture(materialParams, "clearcoatNormalMap", extension.clearcoatNormalTexture));
|
|
551
|
+
if (extension.clearcoatNormalTexture.scale !== void 0) {
|
|
552
|
+
const scale = extension.clearcoatNormalTexture.scale;
|
|
553
|
+
materialParams.clearcoatNormalScale = new chunkSQY54X47_js.Vector2(scale, scale);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return Promise.all(pending);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
var GLTFMaterialsDispersionExtension = class {
|
|
560
|
+
constructor(parser) {
|
|
561
|
+
this.parser = parser;
|
|
562
|
+
this.name = EXTENSIONS.KHR_MATERIALS_DISPERSION;
|
|
563
|
+
}
|
|
564
|
+
getMaterialType(materialIndex) {
|
|
565
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
566
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
567
|
+
}
|
|
568
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
569
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
570
|
+
if (extension === null) return Promise.resolve();
|
|
571
|
+
materialParams.dispersion = extension.dispersion !== void 0 ? extension.dispersion : 0;
|
|
572
|
+
return Promise.resolve();
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
var GLTFMaterialsIridescenceExtension = class {
|
|
576
|
+
constructor(parser) {
|
|
577
|
+
this.parser = parser;
|
|
578
|
+
this.name = EXTENSIONS.KHR_MATERIALS_IRIDESCENCE;
|
|
579
|
+
}
|
|
580
|
+
getMaterialType(materialIndex) {
|
|
581
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
582
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
583
|
+
}
|
|
584
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
585
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
586
|
+
if (extension === null) return Promise.resolve();
|
|
587
|
+
const pending = [];
|
|
588
|
+
if (extension.iridescenceFactor !== void 0) {
|
|
589
|
+
materialParams.iridescence = extension.iridescenceFactor;
|
|
590
|
+
}
|
|
591
|
+
if (extension.iridescenceTexture !== void 0) {
|
|
592
|
+
pending.push(this.parser.assignTexture(materialParams, "iridescenceMap", extension.iridescenceTexture));
|
|
593
|
+
}
|
|
594
|
+
if (extension.iridescenceIor !== void 0) {
|
|
595
|
+
materialParams.iridescenceIOR = extension.iridescenceIor;
|
|
596
|
+
}
|
|
597
|
+
if (materialParams.iridescenceThicknessRange === void 0) {
|
|
598
|
+
materialParams.iridescenceThicknessRange = [100, 400];
|
|
599
|
+
}
|
|
600
|
+
if (extension.iridescenceThicknessMinimum !== void 0) {
|
|
601
|
+
materialParams.iridescenceThicknessRange[0] = extension.iridescenceThicknessMinimum;
|
|
602
|
+
}
|
|
603
|
+
if (extension.iridescenceThicknessMaximum !== void 0) {
|
|
604
|
+
materialParams.iridescenceThicknessRange[1] = extension.iridescenceThicknessMaximum;
|
|
605
|
+
}
|
|
606
|
+
if (extension.iridescenceThicknessTexture !== void 0) {
|
|
607
|
+
pending.push(this.parser.assignTexture(materialParams, "iridescenceThicknessMap", extension.iridescenceThicknessTexture));
|
|
608
|
+
}
|
|
609
|
+
return Promise.all(pending);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
var GLTFMaterialsSheenExtension = class {
|
|
613
|
+
constructor(parser) {
|
|
614
|
+
this.parser = parser;
|
|
615
|
+
this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
|
|
616
|
+
}
|
|
617
|
+
getMaterialType(materialIndex) {
|
|
618
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
619
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
620
|
+
}
|
|
621
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
622
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
623
|
+
if (extension === null) return Promise.resolve();
|
|
624
|
+
const pending = [];
|
|
625
|
+
materialParams.sheenColor = new chunkSQY54X47_js.Color(0, 0, 0);
|
|
626
|
+
materialParams.sheenRoughness = 0;
|
|
627
|
+
materialParams.sheen = 1;
|
|
628
|
+
if (extension.sheenColorFactor !== void 0) {
|
|
629
|
+
const colorFactor = extension.sheenColorFactor;
|
|
630
|
+
materialParams.sheenColor.setRGB(colorFactor[0], colorFactor[1], colorFactor[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
631
|
+
}
|
|
632
|
+
if (extension.sheenRoughnessFactor !== void 0) {
|
|
633
|
+
materialParams.sheenRoughness = extension.sheenRoughnessFactor;
|
|
634
|
+
}
|
|
635
|
+
if (extension.sheenColorTexture !== void 0) {
|
|
636
|
+
pending.push(this.parser.assignTexture(materialParams, "sheenColorMap", extension.sheenColorTexture, chunkSQY54X47_js.SRGBColorSpace));
|
|
637
|
+
}
|
|
638
|
+
if (extension.sheenRoughnessTexture !== void 0) {
|
|
639
|
+
pending.push(this.parser.assignTexture(materialParams, "sheenRoughnessMap", extension.sheenRoughnessTexture));
|
|
640
|
+
}
|
|
641
|
+
return Promise.all(pending);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
var GLTFMaterialsTransmissionExtension = class {
|
|
645
|
+
constructor(parser) {
|
|
646
|
+
this.parser = parser;
|
|
647
|
+
this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
|
|
648
|
+
}
|
|
649
|
+
getMaterialType(materialIndex) {
|
|
650
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
651
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
652
|
+
}
|
|
653
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
654
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
655
|
+
if (extension === null) return Promise.resolve();
|
|
656
|
+
const pending = [];
|
|
657
|
+
if (extension.transmissionFactor !== void 0) {
|
|
658
|
+
materialParams.transmission = extension.transmissionFactor;
|
|
659
|
+
}
|
|
660
|
+
if (extension.transmissionTexture !== void 0) {
|
|
661
|
+
pending.push(this.parser.assignTexture(materialParams, "transmissionMap", extension.transmissionTexture));
|
|
662
|
+
}
|
|
663
|
+
return Promise.all(pending);
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
var GLTFMaterialsVolumeExtension = class {
|
|
667
|
+
constructor(parser) {
|
|
668
|
+
this.parser = parser;
|
|
669
|
+
this.name = EXTENSIONS.KHR_MATERIALS_VOLUME;
|
|
670
|
+
}
|
|
671
|
+
getMaterialType(materialIndex) {
|
|
672
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
673
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
674
|
+
}
|
|
675
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
676
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
677
|
+
if (extension === null) return Promise.resolve();
|
|
678
|
+
const pending = [];
|
|
679
|
+
materialParams.thickness = extension.thicknessFactor !== void 0 ? extension.thicknessFactor : 0;
|
|
680
|
+
if (extension.thicknessTexture !== void 0) {
|
|
681
|
+
pending.push(this.parser.assignTexture(materialParams, "thicknessMap", extension.thicknessTexture));
|
|
682
|
+
}
|
|
683
|
+
materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
|
|
684
|
+
const colorArray = extension.attenuationColor || [1, 1, 1];
|
|
685
|
+
materialParams.attenuationColor = new chunkSQY54X47_js.Color().setRGB(colorArray[0], colorArray[1], colorArray[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
686
|
+
return Promise.all(pending);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
var GLTFMaterialsIorExtension = class {
|
|
690
|
+
constructor(parser) {
|
|
691
|
+
this.parser = parser;
|
|
692
|
+
this.name = EXTENSIONS.KHR_MATERIALS_IOR;
|
|
693
|
+
}
|
|
694
|
+
getMaterialType(materialIndex) {
|
|
695
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
696
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
697
|
+
}
|
|
698
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
699
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
700
|
+
if (extension === null) return Promise.resolve();
|
|
701
|
+
materialParams.ior = extension.ior !== void 0 ? extension.ior : 1.5;
|
|
702
|
+
if (materialParams.ior === 0) materialParams.ior = 1e3;
|
|
703
|
+
return Promise.resolve();
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
var GLTFMaterialsSpecularExtension = class {
|
|
707
|
+
constructor(parser) {
|
|
708
|
+
this.parser = parser;
|
|
709
|
+
this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR;
|
|
710
|
+
}
|
|
711
|
+
getMaterialType(materialIndex) {
|
|
712
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
713
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
714
|
+
}
|
|
715
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
716
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
717
|
+
if (extension === null) return Promise.resolve();
|
|
718
|
+
const pending = [];
|
|
719
|
+
materialParams.specularIntensity = extension.specularFactor !== void 0 ? extension.specularFactor : 1;
|
|
720
|
+
if (extension.specularTexture !== void 0) {
|
|
721
|
+
pending.push(this.parser.assignTexture(materialParams, "specularIntensityMap", extension.specularTexture));
|
|
722
|
+
}
|
|
723
|
+
const colorArray = extension.specularColorFactor || [1, 1, 1];
|
|
724
|
+
materialParams.specularColor = new chunkSQY54X47_js.Color().setRGB(colorArray[0], colorArray[1], colorArray[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
725
|
+
if (extension.specularColorTexture !== void 0) {
|
|
726
|
+
pending.push(this.parser.assignTexture(materialParams, "specularColorMap", extension.specularColorTexture, chunkSQY54X47_js.SRGBColorSpace));
|
|
727
|
+
}
|
|
728
|
+
return Promise.all(pending);
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
var GLTFMaterialsBumpExtension = class {
|
|
732
|
+
constructor(parser) {
|
|
733
|
+
this.parser = parser;
|
|
734
|
+
this.name = EXTENSIONS.EXT_MATERIALS_BUMP;
|
|
735
|
+
}
|
|
736
|
+
getMaterialType(materialIndex) {
|
|
737
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
738
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
739
|
+
}
|
|
740
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
741
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
742
|
+
if (extension === null) return Promise.resolve();
|
|
743
|
+
const pending = [];
|
|
744
|
+
materialParams.bumpScale = extension.bumpFactor !== void 0 ? extension.bumpFactor : 1;
|
|
745
|
+
if (extension.bumpTexture !== void 0) {
|
|
746
|
+
pending.push(this.parser.assignTexture(materialParams, "bumpMap", extension.bumpTexture));
|
|
747
|
+
}
|
|
748
|
+
return Promise.all(pending);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
var GLTFMaterialsAnisotropyExtension = class {
|
|
752
|
+
constructor(parser) {
|
|
753
|
+
this.parser = parser;
|
|
754
|
+
this.name = EXTENSIONS.KHR_MATERIALS_ANISOTROPY;
|
|
755
|
+
}
|
|
756
|
+
getMaterialType(materialIndex) {
|
|
757
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
758
|
+
return extension !== null ? chunkSQY54X47_js.MeshPhysicalMaterial : null;
|
|
759
|
+
}
|
|
760
|
+
extendMaterialParams(materialIndex, materialParams) {
|
|
761
|
+
const extension = getMaterialExtension(this.parser, materialIndex, this.name);
|
|
762
|
+
if (extension === null) return Promise.resolve();
|
|
763
|
+
const pending = [];
|
|
764
|
+
if (extension.anisotropyStrength !== void 0) {
|
|
765
|
+
materialParams.anisotropy = extension.anisotropyStrength;
|
|
766
|
+
}
|
|
767
|
+
if (extension.anisotropyRotation !== void 0) {
|
|
768
|
+
materialParams.anisotropyRotation = extension.anisotropyRotation;
|
|
769
|
+
}
|
|
770
|
+
if (extension.anisotropyTexture !== void 0) {
|
|
771
|
+
pending.push(this.parser.assignTexture(materialParams, "anisotropyMap", extension.anisotropyTexture));
|
|
772
|
+
}
|
|
773
|
+
return Promise.all(pending);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
var GLTFTextureBasisUExtension = class {
|
|
777
|
+
constructor(parser) {
|
|
778
|
+
this.parser = parser;
|
|
779
|
+
this.name = EXTENSIONS.KHR_TEXTURE_BASISU;
|
|
780
|
+
}
|
|
781
|
+
loadTexture(textureIndex) {
|
|
782
|
+
const parser = this.parser;
|
|
783
|
+
const json = parser.json;
|
|
784
|
+
const textureDef = json.textures[textureIndex];
|
|
785
|
+
if (!textureDef.extensions || !textureDef.extensions[this.name]) {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
const extension = textureDef.extensions[this.name];
|
|
789
|
+
const loader = parser.options.ktx2Loader;
|
|
790
|
+
if (!loader) {
|
|
791
|
+
if (json.extensionsRequired && json.extensionsRequired.indexOf(this.name) >= 0) {
|
|
792
|
+
throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
|
|
793
|
+
} else {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return parser.loadTextureImage(textureIndex, extension.source, loader);
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
var GLTFTextureWebPExtension = class {
|
|
801
|
+
constructor(parser) {
|
|
802
|
+
this.parser = parser;
|
|
803
|
+
this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
|
|
804
|
+
}
|
|
805
|
+
loadTexture(textureIndex) {
|
|
806
|
+
const name = this.name;
|
|
807
|
+
const parser = this.parser;
|
|
808
|
+
const json = parser.json;
|
|
809
|
+
const textureDef = json.textures[textureIndex];
|
|
810
|
+
if (!textureDef.extensions || !textureDef.extensions[name]) {
|
|
811
|
+
return null;
|
|
812
|
+
}
|
|
813
|
+
const extension = textureDef.extensions[name];
|
|
814
|
+
const source = json.images[extension.source];
|
|
815
|
+
let loader = parser.textureLoader;
|
|
816
|
+
if (source.uri) {
|
|
817
|
+
const handler = parser.options.manager.getHandler(source.uri);
|
|
818
|
+
if (handler !== null) loader = handler;
|
|
819
|
+
}
|
|
820
|
+
return parser.loadTextureImage(textureIndex, extension.source, loader);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
var GLTFTextureAVIFExtension = class {
|
|
824
|
+
constructor(parser) {
|
|
825
|
+
this.parser = parser;
|
|
826
|
+
this.name = EXTENSIONS.EXT_TEXTURE_AVIF;
|
|
827
|
+
}
|
|
828
|
+
loadTexture(textureIndex) {
|
|
829
|
+
const name = this.name;
|
|
830
|
+
const parser = this.parser;
|
|
831
|
+
const json = parser.json;
|
|
832
|
+
const textureDef = json.textures[textureIndex];
|
|
833
|
+
if (!textureDef.extensions || !textureDef.extensions[name]) {
|
|
834
|
+
return null;
|
|
835
|
+
}
|
|
836
|
+
const extension = textureDef.extensions[name];
|
|
837
|
+
const source = json.images[extension.source];
|
|
838
|
+
let loader = parser.textureLoader;
|
|
839
|
+
if (source.uri) {
|
|
840
|
+
const handler = parser.options.manager.getHandler(source.uri);
|
|
841
|
+
if (handler !== null) loader = handler;
|
|
842
|
+
}
|
|
843
|
+
return parser.loadTextureImage(textureIndex, extension.source, loader);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
var GLTFMeshoptCompression = class {
|
|
847
|
+
constructor(parser, name) {
|
|
848
|
+
this.name = name;
|
|
849
|
+
this.parser = parser;
|
|
850
|
+
}
|
|
851
|
+
loadBufferView(index) {
|
|
852
|
+
const json = this.parser.json;
|
|
853
|
+
const bufferView = json.bufferViews[index];
|
|
854
|
+
if (bufferView.extensions && bufferView.extensions[this.name]) {
|
|
855
|
+
const extensionDef = bufferView.extensions[this.name];
|
|
856
|
+
const buffer = this.parser.getDependency("buffer", extensionDef.buffer);
|
|
857
|
+
const decoder = this.parser.options.meshoptDecoder;
|
|
858
|
+
if (!decoder || !decoder.supported) {
|
|
859
|
+
if (json.extensionsRequired && json.extensionsRequired.indexOf(this.name) >= 0) {
|
|
860
|
+
throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
|
|
861
|
+
} else {
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return buffer.then(function(res) {
|
|
866
|
+
const byteOffset = extensionDef.byteOffset || 0;
|
|
867
|
+
const byteLength = extensionDef.byteLength || 0;
|
|
868
|
+
const count = extensionDef.count;
|
|
869
|
+
const stride = extensionDef.byteStride;
|
|
870
|
+
const source = new Uint8Array(res, byteOffset, byteLength);
|
|
871
|
+
if (decoder.decodeGltfBufferAsync) {
|
|
872
|
+
return decoder.decodeGltfBufferAsync(count, stride, source, extensionDef.mode, extensionDef.filter).then(function(res2) {
|
|
873
|
+
return res2.buffer;
|
|
874
|
+
});
|
|
875
|
+
} else {
|
|
876
|
+
return decoder.ready.then(function() {
|
|
877
|
+
const result = new ArrayBuffer(count * stride);
|
|
878
|
+
decoder.decodeGltfBuffer(new Uint8Array(result), count, stride, source, extensionDef.mode, extensionDef.filter);
|
|
879
|
+
return result;
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
} else {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
var GLTFMeshGpuInstancing = class {
|
|
889
|
+
constructor(parser) {
|
|
890
|
+
this.name = EXTENSIONS.EXT_MESH_GPU_INSTANCING;
|
|
891
|
+
this.parser = parser;
|
|
892
|
+
}
|
|
893
|
+
createNodeMesh(nodeIndex) {
|
|
894
|
+
const json = this.parser.json;
|
|
895
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
896
|
+
if (!nodeDef.extensions || !nodeDef.extensions[this.name] || nodeDef.mesh === void 0) {
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
899
|
+
const meshDef = json.meshes[nodeDef.mesh];
|
|
900
|
+
for (const primitive of meshDef.primitives) {
|
|
901
|
+
if (primitive.mode !== WEBGL_CONSTANTS.TRIANGLES && primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_STRIP && primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_FAN && primitive.mode !== void 0) {
|
|
902
|
+
return null;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
const extensionDef = nodeDef.extensions[this.name];
|
|
906
|
+
const attributesDef = extensionDef.attributes;
|
|
907
|
+
const pending = [];
|
|
908
|
+
const attributes = {};
|
|
909
|
+
for (const key in attributesDef) {
|
|
910
|
+
pending.push(this.parser.getDependency("accessor", attributesDef[key]).then((accessor) => {
|
|
911
|
+
attributes[key] = accessor;
|
|
912
|
+
return attributes[key];
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
915
|
+
if (pending.length < 1) {
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
pending.push(this.parser.createNodeMesh(nodeIndex));
|
|
919
|
+
return Promise.all(pending).then((results) => {
|
|
920
|
+
const nodeObject = results.pop();
|
|
921
|
+
const meshes = nodeObject.isGroup ? nodeObject.children : [nodeObject];
|
|
922
|
+
const count = results[0].count;
|
|
923
|
+
const instancedMeshes = [];
|
|
924
|
+
for (const mesh of meshes) {
|
|
925
|
+
const m = new chunkSQY54X47_js.Matrix4();
|
|
926
|
+
const p = new chunkSQY54X47_js.Vector3();
|
|
927
|
+
const q = new chunkSQY54X47_js.Quaternion();
|
|
928
|
+
const s = new chunkSQY54X47_js.Vector3(1, 1, 1);
|
|
929
|
+
const instancedMesh = new chunkSQY54X47_js.InstancedMesh(mesh.geometry, mesh.material, count);
|
|
930
|
+
for (let i = 0; i < count; i++) {
|
|
931
|
+
if (attributes.TRANSLATION) {
|
|
932
|
+
p.fromBufferAttribute(attributes.TRANSLATION, i);
|
|
933
|
+
}
|
|
934
|
+
if (attributes.ROTATION) {
|
|
935
|
+
q.fromBufferAttribute(attributes.ROTATION, i);
|
|
936
|
+
}
|
|
937
|
+
if (attributes.SCALE) {
|
|
938
|
+
s.fromBufferAttribute(attributes.SCALE, i);
|
|
939
|
+
}
|
|
940
|
+
instancedMesh.setMatrixAt(i, m.compose(p, q, s));
|
|
941
|
+
}
|
|
942
|
+
for (const attributeName in attributes) {
|
|
943
|
+
if (attributeName === "_COLOR_0") {
|
|
944
|
+
const attr = attributes[attributeName];
|
|
945
|
+
instancedMesh.instanceColor = new chunkSQY54X47_js.InstancedBufferAttribute(attr.array, attr.itemSize, attr.normalized);
|
|
946
|
+
} else if (attributeName !== "TRANSLATION" && attributeName !== "ROTATION" && attributeName !== "SCALE") {
|
|
947
|
+
mesh.geometry.setAttribute(attributeName, attributes[attributeName]);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
chunkSQY54X47_js.Object3D.prototype.copy.call(instancedMesh, mesh);
|
|
951
|
+
this.parser.assignFinalMaterial(instancedMesh);
|
|
952
|
+
instancedMeshes.push(instancedMesh);
|
|
953
|
+
}
|
|
954
|
+
if (nodeObject.isGroup) {
|
|
955
|
+
nodeObject.clear();
|
|
956
|
+
nodeObject.add(...instancedMeshes);
|
|
957
|
+
return nodeObject;
|
|
958
|
+
}
|
|
959
|
+
return instancedMeshes[0];
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
var BINARY_EXTENSION_HEADER_MAGIC = "glTF";
|
|
964
|
+
var BINARY_EXTENSION_HEADER_LENGTH = 12;
|
|
965
|
+
var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 1313821514, BIN: 5130562 };
|
|
966
|
+
var GLTFBinaryExtension = class {
|
|
967
|
+
constructor(data) {
|
|
968
|
+
this.name = EXTENSIONS.KHR_BINARY_GLTF;
|
|
969
|
+
this.content = null;
|
|
970
|
+
this.body = null;
|
|
971
|
+
const headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);
|
|
972
|
+
const textDecoder = new TextDecoder();
|
|
973
|
+
this.header = {
|
|
974
|
+
magic: textDecoder.decode(new Uint8Array(data.slice(0, 4))),
|
|
975
|
+
version: headerView.getUint32(4, true),
|
|
976
|
+
length: headerView.getUint32(8, true)
|
|
977
|
+
};
|
|
978
|
+
if (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {
|
|
979
|
+
throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
|
|
980
|
+
} else if (this.header.version < 2) {
|
|
981
|
+
throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
|
|
982
|
+
}
|
|
983
|
+
const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH;
|
|
984
|
+
const chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);
|
|
985
|
+
let chunkIndex = 0;
|
|
986
|
+
while (chunkIndex < chunkContentsLength) {
|
|
987
|
+
const chunkLength = chunkView.getUint32(chunkIndex, true);
|
|
988
|
+
chunkIndex += 4;
|
|
989
|
+
const chunkType = chunkView.getUint32(chunkIndex, true);
|
|
990
|
+
chunkIndex += 4;
|
|
991
|
+
if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {
|
|
992
|
+
const contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);
|
|
993
|
+
this.content = textDecoder.decode(contentArray);
|
|
994
|
+
} else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {
|
|
995
|
+
const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
|
|
996
|
+
this.body = data.slice(byteOffset, byteOffset + chunkLength);
|
|
997
|
+
}
|
|
998
|
+
chunkIndex += chunkLength;
|
|
999
|
+
}
|
|
1000
|
+
if (this.content === null) {
|
|
1001
|
+
throw new Error("THREE.GLTFLoader: JSON content not found.");
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
var GLTFDracoMeshCompressionExtension = class {
|
|
1006
|
+
constructor(json, dracoLoader) {
|
|
1007
|
+
if (!dracoLoader) {
|
|
1008
|
+
throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
|
|
1009
|
+
}
|
|
1010
|
+
this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
|
|
1011
|
+
this.json = json;
|
|
1012
|
+
this.dracoLoader = dracoLoader;
|
|
1013
|
+
this.dracoLoader.preload();
|
|
1014
|
+
}
|
|
1015
|
+
decodePrimitive(primitive, parser) {
|
|
1016
|
+
const json = this.json;
|
|
1017
|
+
const dracoLoader = this.dracoLoader;
|
|
1018
|
+
const bufferViewIndex = primitive.extensions[this.name].bufferView;
|
|
1019
|
+
const gltfAttributeMap = primitive.extensions[this.name].attributes;
|
|
1020
|
+
const threeAttributeMap = {};
|
|
1021
|
+
const attributeNormalizedMap = {};
|
|
1022
|
+
const attributeTypeMap = {};
|
|
1023
|
+
for (const attributeName in gltfAttributeMap) {
|
|
1024
|
+
const threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
|
|
1025
|
+
threeAttributeMap[threeAttributeName] = gltfAttributeMap[attributeName];
|
|
1026
|
+
}
|
|
1027
|
+
for (const attributeName in primitive.attributes) {
|
|
1028
|
+
const threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();
|
|
1029
|
+
if (gltfAttributeMap[attributeName] !== void 0) {
|
|
1030
|
+
const accessorDef = json.accessors[primitive.attributes[attributeName]];
|
|
1031
|
+
const componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
|
|
1032
|
+
attributeTypeMap[threeAttributeName] = componentType.name;
|
|
1033
|
+
attributeNormalizedMap[threeAttributeName] = accessorDef.normalized === true;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return parser.getDependency("bufferView", bufferViewIndex).then(function(bufferView) {
|
|
1037
|
+
return new Promise(function(resolve, reject) {
|
|
1038
|
+
dracoLoader.decodeDracoFile(bufferView, function(geometry) {
|
|
1039
|
+
for (const attributeName in geometry.attributes) {
|
|
1040
|
+
const attribute = geometry.attributes[attributeName];
|
|
1041
|
+
const normalized = attributeNormalizedMap[attributeName];
|
|
1042
|
+
if (normalized !== void 0) attribute.normalized = normalized;
|
|
1043
|
+
}
|
|
1044
|
+
resolve(geometry);
|
|
1045
|
+
}, threeAttributeMap, attributeTypeMap, chunkSQY54X47_js.LinearSRGBColorSpace, reject);
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
var GLTFTextureTransformExtension = class {
|
|
1051
|
+
constructor() {
|
|
1052
|
+
this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
|
|
1053
|
+
}
|
|
1054
|
+
extendTexture(texture, transform) {
|
|
1055
|
+
if ((transform.texCoord === void 0 || transform.texCoord === texture.channel) && transform.offset === void 0 && transform.rotation === void 0 && transform.scale === void 0) {
|
|
1056
|
+
return texture;
|
|
1057
|
+
}
|
|
1058
|
+
texture = texture.clone();
|
|
1059
|
+
if (transform.texCoord !== void 0) {
|
|
1060
|
+
texture.channel = transform.texCoord;
|
|
1061
|
+
}
|
|
1062
|
+
if (transform.offset !== void 0) {
|
|
1063
|
+
texture.offset.fromArray(transform.offset);
|
|
1064
|
+
}
|
|
1065
|
+
if (transform.rotation !== void 0) {
|
|
1066
|
+
texture.rotation = transform.rotation;
|
|
1067
|
+
}
|
|
1068
|
+
if (transform.scale !== void 0) {
|
|
1069
|
+
texture.repeat.fromArray(transform.scale);
|
|
1070
|
+
}
|
|
1071
|
+
texture.needsUpdate = true;
|
|
1072
|
+
return texture;
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
var GLTFMeshQuantizationExtension = class {
|
|
1076
|
+
constructor() {
|
|
1077
|
+
this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
var GLTFCubicSplineInterpolant = class extends chunkSQY54X47_js.Interpolant {
|
|
1081
|
+
constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {
|
|
1082
|
+
super(parameterPositions, sampleValues, sampleSize, resultBuffer);
|
|
1083
|
+
}
|
|
1084
|
+
copySampleValue_(index) {
|
|
1085
|
+
const result = this.resultBuffer, values = this.sampleValues, valueSize = this.valueSize, offset = index * valueSize * 3 + valueSize;
|
|
1086
|
+
for (let i = 0; i !== valueSize; i++) {
|
|
1087
|
+
result[i] = values[offset + i];
|
|
1088
|
+
}
|
|
1089
|
+
return result;
|
|
1090
|
+
}
|
|
1091
|
+
interpolate_(i1, t0, t, t1) {
|
|
1092
|
+
const result = this.resultBuffer;
|
|
1093
|
+
const values = this.sampleValues;
|
|
1094
|
+
const stride = this.valueSize;
|
|
1095
|
+
const stride2 = stride * 2;
|
|
1096
|
+
const stride3 = stride * 3;
|
|
1097
|
+
const td = t1 - t0;
|
|
1098
|
+
const p = (t - t0) / td;
|
|
1099
|
+
const pp = p * p;
|
|
1100
|
+
const ppp = pp * p;
|
|
1101
|
+
const offset1 = i1 * stride3;
|
|
1102
|
+
const offset0 = offset1 - stride3;
|
|
1103
|
+
const s2 = -2 * ppp + 3 * pp;
|
|
1104
|
+
const s3 = ppp - pp;
|
|
1105
|
+
const s0 = 1 - s2;
|
|
1106
|
+
const s1 = s3 - pp + p;
|
|
1107
|
+
for (let i = 0; i !== stride; i++) {
|
|
1108
|
+
const p0 = values[offset0 + i + stride];
|
|
1109
|
+
const m0 = values[offset0 + i + stride2] * td;
|
|
1110
|
+
const p1 = values[offset1 + i + stride];
|
|
1111
|
+
const m1 = values[offset1 + i] * td;
|
|
1112
|
+
result[i] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
|
|
1113
|
+
}
|
|
1114
|
+
return result;
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
var _quaternion = new chunkSQY54X47_js.Quaternion();
|
|
1118
|
+
var GLTFCubicSplineQuaternionInterpolant = class extends GLTFCubicSplineInterpolant {
|
|
1119
|
+
interpolate_(i1, t0, t, t1) {
|
|
1120
|
+
const result = super.interpolate_(i1, t0, t, t1);
|
|
1121
|
+
_quaternion.fromArray(result).normalize().toArray(result);
|
|
1122
|
+
return result;
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
var WEBGL_CONSTANTS = {
|
|
1126
|
+
POINTS: 0,
|
|
1127
|
+
LINES: 1,
|
|
1128
|
+
LINE_LOOP: 2,
|
|
1129
|
+
LINE_STRIP: 3,
|
|
1130
|
+
TRIANGLES: 4,
|
|
1131
|
+
TRIANGLE_STRIP: 5,
|
|
1132
|
+
TRIANGLE_FAN: 6};
|
|
1133
|
+
var WEBGL_COMPONENT_TYPES = {
|
|
1134
|
+
5120: Int8Array,
|
|
1135
|
+
5121: Uint8Array,
|
|
1136
|
+
5122: Int16Array,
|
|
1137
|
+
5123: Uint16Array,
|
|
1138
|
+
5125: Uint32Array,
|
|
1139
|
+
5126: Float32Array
|
|
1140
|
+
};
|
|
1141
|
+
var WEBGL_FILTERS = {
|
|
1142
|
+
9728: chunkSQY54X47_js.NearestFilter,
|
|
1143
|
+
9729: chunkSQY54X47_js.LinearFilter,
|
|
1144
|
+
9984: chunkSQY54X47_js.NearestMipmapNearestFilter,
|
|
1145
|
+
9985: chunkSQY54X47_js.LinearMipmapNearestFilter,
|
|
1146
|
+
9986: chunkSQY54X47_js.NearestMipmapLinearFilter,
|
|
1147
|
+
9987: chunkSQY54X47_js.LinearMipmapLinearFilter
|
|
1148
|
+
};
|
|
1149
|
+
var WEBGL_WRAPPINGS = {
|
|
1150
|
+
33071: chunkSQY54X47_js.ClampToEdgeWrapping,
|
|
1151
|
+
33648: chunkSQY54X47_js.MirroredRepeatWrapping,
|
|
1152
|
+
10497: chunkSQY54X47_js.RepeatWrapping
|
|
1153
|
+
};
|
|
1154
|
+
var WEBGL_TYPE_SIZES = {
|
|
1155
|
+
"SCALAR": 1,
|
|
1156
|
+
"VEC2": 2,
|
|
1157
|
+
"VEC3": 3,
|
|
1158
|
+
"VEC4": 4,
|
|
1159
|
+
"MAT2": 4,
|
|
1160
|
+
"MAT3": 9,
|
|
1161
|
+
"MAT4": 16
|
|
1162
|
+
};
|
|
1163
|
+
var ATTRIBUTES = {
|
|
1164
|
+
POSITION: "position",
|
|
1165
|
+
NORMAL: "normal",
|
|
1166
|
+
TANGENT: "tangent",
|
|
1167
|
+
TEXCOORD_0: "uv",
|
|
1168
|
+
TEXCOORD_1: "uv1",
|
|
1169
|
+
TEXCOORD_2: "uv2",
|
|
1170
|
+
TEXCOORD_3: "uv3",
|
|
1171
|
+
COLOR_0: "color",
|
|
1172
|
+
WEIGHTS_0: "skinWeight",
|
|
1173
|
+
JOINTS_0: "skinIndex"
|
|
1174
|
+
};
|
|
1175
|
+
var PATH_PROPERTIES = {
|
|
1176
|
+
scale: "scale",
|
|
1177
|
+
translation: "position",
|
|
1178
|
+
rotation: "quaternion",
|
|
1179
|
+
weights: "morphTargetInfluences"
|
|
1180
|
+
};
|
|
1181
|
+
var INTERPOLATION = {
|
|
1182
|
+
CUBICSPLINE: void 0,
|
|
1183
|
+
// We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
|
|
1184
|
+
// keyframe track will be initialized with a default interpolation type, then modified.
|
|
1185
|
+
LINEAR: chunkSQY54X47_js.InterpolateLinear,
|
|
1186
|
+
STEP: chunkSQY54X47_js.InterpolateDiscrete
|
|
1187
|
+
};
|
|
1188
|
+
var ALPHA_MODES = {
|
|
1189
|
+
OPAQUE: "OPAQUE",
|
|
1190
|
+
MASK: "MASK",
|
|
1191
|
+
BLEND: "BLEND"
|
|
1192
|
+
};
|
|
1193
|
+
function createDefaultMaterial(cache) {
|
|
1194
|
+
if (cache["DefaultMaterial"] === void 0) {
|
|
1195
|
+
cache["DefaultMaterial"] = new chunkSQY54X47_js.MeshStandardMaterial({
|
|
1196
|
+
color: 16777215,
|
|
1197
|
+
emissive: 0,
|
|
1198
|
+
metalness: 1,
|
|
1199
|
+
roughness: 1,
|
|
1200
|
+
transparent: false,
|
|
1201
|
+
depthTest: true,
|
|
1202
|
+
side: chunkSQY54X47_js.FrontSide
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
return cache["DefaultMaterial"];
|
|
1206
|
+
}
|
|
1207
|
+
function addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {
|
|
1208
|
+
for (const name in objectDef.extensions) {
|
|
1209
|
+
if (knownExtensions[name] === void 0) {
|
|
1210
|
+
object.userData.gltfExtensions = object.userData.gltfExtensions || {};
|
|
1211
|
+
object.userData.gltfExtensions[name] = objectDef.extensions[name];
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
function assignExtrasToUserData(object, gltfDef) {
|
|
1216
|
+
if (gltfDef.extras !== void 0) {
|
|
1217
|
+
if (typeof gltfDef.extras === "object") {
|
|
1218
|
+
Object.assign(object.userData, gltfDef.extras);
|
|
1219
|
+
} else {
|
|
1220
|
+
console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + gltfDef.extras);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
function addMorphTargets(geometry, targets, parser) {
|
|
1225
|
+
let hasMorphPosition = false;
|
|
1226
|
+
let hasMorphNormal = false;
|
|
1227
|
+
let hasMorphColor = false;
|
|
1228
|
+
for (let i = 0, il = targets.length; i < il; i++) {
|
|
1229
|
+
const target = targets[i];
|
|
1230
|
+
if (target.POSITION !== void 0) hasMorphPosition = true;
|
|
1231
|
+
if (target.NORMAL !== void 0) hasMorphNormal = true;
|
|
1232
|
+
if (target.COLOR_0 !== void 0) hasMorphColor = true;
|
|
1233
|
+
if (hasMorphPosition && hasMorphNormal && hasMorphColor) break;
|
|
1234
|
+
}
|
|
1235
|
+
if (!hasMorphPosition && !hasMorphNormal && !hasMorphColor) return Promise.resolve(geometry);
|
|
1236
|
+
const pendingPositionAccessors = [];
|
|
1237
|
+
const pendingNormalAccessors = [];
|
|
1238
|
+
const pendingColorAccessors = [];
|
|
1239
|
+
for (let i = 0, il = targets.length; i < il; i++) {
|
|
1240
|
+
const target = targets[i];
|
|
1241
|
+
if (hasMorphPosition) {
|
|
1242
|
+
const pendingAccessor = target.POSITION !== void 0 ? parser.getDependency("accessor", target.POSITION) : geometry.attributes.position;
|
|
1243
|
+
pendingPositionAccessors.push(pendingAccessor);
|
|
1244
|
+
}
|
|
1245
|
+
if (hasMorphNormal) {
|
|
1246
|
+
const pendingAccessor = target.NORMAL !== void 0 ? parser.getDependency("accessor", target.NORMAL) : geometry.attributes.normal;
|
|
1247
|
+
pendingNormalAccessors.push(pendingAccessor);
|
|
1248
|
+
}
|
|
1249
|
+
if (hasMorphColor) {
|
|
1250
|
+
const pendingAccessor = target.COLOR_0 !== void 0 ? parser.getDependency("accessor", target.COLOR_0) : geometry.attributes.color;
|
|
1251
|
+
pendingColorAccessors.push(pendingAccessor);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return Promise.all([
|
|
1255
|
+
Promise.all(pendingPositionAccessors),
|
|
1256
|
+
Promise.all(pendingNormalAccessors),
|
|
1257
|
+
Promise.all(pendingColorAccessors)
|
|
1258
|
+
]).then(function(accessors) {
|
|
1259
|
+
const morphPositions = accessors[0];
|
|
1260
|
+
const morphNormals = accessors[1];
|
|
1261
|
+
const morphColors = accessors[2];
|
|
1262
|
+
if (hasMorphPosition) geometry.morphAttributes.position = morphPositions;
|
|
1263
|
+
if (hasMorphNormal) geometry.morphAttributes.normal = morphNormals;
|
|
1264
|
+
if (hasMorphColor) geometry.morphAttributes.color = morphColors;
|
|
1265
|
+
geometry.morphTargetsRelative = true;
|
|
1266
|
+
return geometry;
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
function updateMorphTargets(mesh, meshDef) {
|
|
1270
|
+
mesh.updateMorphTargets();
|
|
1271
|
+
if (meshDef.weights !== void 0) {
|
|
1272
|
+
for (let i = 0, il = meshDef.weights.length; i < il; i++) {
|
|
1273
|
+
mesh.morphTargetInfluences[i] = meshDef.weights[i];
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
if (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {
|
|
1277
|
+
const targetNames = meshDef.extras.targetNames;
|
|
1278
|
+
if (mesh.morphTargetInfluences.length === targetNames.length) {
|
|
1279
|
+
mesh.morphTargetDictionary = {};
|
|
1280
|
+
for (let i = 0, il = targetNames.length; i < il; i++) {
|
|
1281
|
+
mesh.morphTargetDictionary[targetNames[i]] = i;
|
|
1282
|
+
}
|
|
1283
|
+
} else {
|
|
1284
|
+
console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
function createPrimitiveKey(primitiveDef) {
|
|
1289
|
+
let geometryKey;
|
|
1290
|
+
const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];
|
|
1291
|
+
if (dracoExtension) {
|
|
1292
|
+
geometryKey = "draco:" + dracoExtension.bufferView + ":" + dracoExtension.indices + ":" + createAttributesKey(dracoExtension.attributes);
|
|
1293
|
+
} else {
|
|
1294
|
+
geometryKey = primitiveDef.indices + ":" + createAttributesKey(primitiveDef.attributes) + ":" + primitiveDef.mode;
|
|
1295
|
+
}
|
|
1296
|
+
if (primitiveDef.targets !== void 0) {
|
|
1297
|
+
for (let i = 0, il = primitiveDef.targets.length; i < il; i++) {
|
|
1298
|
+
geometryKey += ":" + createAttributesKey(primitiveDef.targets[i]);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return geometryKey;
|
|
1302
|
+
}
|
|
1303
|
+
function createAttributesKey(attributes) {
|
|
1304
|
+
let attributesKey = "";
|
|
1305
|
+
const keys = Object.keys(attributes).sort();
|
|
1306
|
+
for (let i = 0, il = keys.length; i < il; i++) {
|
|
1307
|
+
attributesKey += keys[i] + ":" + attributes[keys[i]] + ";";
|
|
1308
|
+
}
|
|
1309
|
+
return attributesKey;
|
|
1310
|
+
}
|
|
1311
|
+
function getNormalizedComponentScale(constructor) {
|
|
1312
|
+
switch (constructor) {
|
|
1313
|
+
case Int8Array:
|
|
1314
|
+
return 1 / 127;
|
|
1315
|
+
case Uint8Array:
|
|
1316
|
+
return 1 / 255;
|
|
1317
|
+
case Int16Array:
|
|
1318
|
+
return 1 / 32767;
|
|
1319
|
+
case Uint16Array:
|
|
1320
|
+
return 1 / 65535;
|
|
1321
|
+
default:
|
|
1322
|
+
throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
function getImageURIMimeType(uri) {
|
|
1326
|
+
if (uri.search(/\.jpe?g($|\?)/i) > 0 || uri.search(/^data\:image\/jpeg/) === 0) return "image/jpeg";
|
|
1327
|
+
if (uri.search(/\.webp($|\?)/i) > 0 || uri.search(/^data\:image\/webp/) === 0) return "image/webp";
|
|
1328
|
+
if (uri.search(/\.ktx2($|\?)/i) > 0 || uri.search(/^data\:image\/ktx2/) === 0) return "image/ktx2";
|
|
1329
|
+
return "image/png";
|
|
1330
|
+
}
|
|
1331
|
+
var _identityMatrix = new chunkSQY54X47_js.Matrix4();
|
|
1332
|
+
var GLTFParser = class {
|
|
1333
|
+
constructor(json = {}, options = {}) {
|
|
1334
|
+
this.json = json;
|
|
1335
|
+
this.extensions = {};
|
|
1336
|
+
this.plugins = {};
|
|
1337
|
+
this.options = options;
|
|
1338
|
+
this.cache = new GLTFRegistry();
|
|
1339
|
+
this.associations = /* @__PURE__ */ new Map();
|
|
1340
|
+
this.primitiveCache = {};
|
|
1341
|
+
this.nodeCache = {};
|
|
1342
|
+
this.meshCache = { refs: {}, uses: {} };
|
|
1343
|
+
this.cameraCache = { refs: {}, uses: {} };
|
|
1344
|
+
this.lightCache = { refs: {}, uses: {} };
|
|
1345
|
+
this.sourceCache = {};
|
|
1346
|
+
this.textureCache = {};
|
|
1347
|
+
this.nodeNamesUsed = {};
|
|
1348
|
+
let isSafari = false;
|
|
1349
|
+
let safariVersion = -1;
|
|
1350
|
+
let isFirefox = false;
|
|
1351
|
+
let firefoxVersion = -1;
|
|
1352
|
+
if (typeof navigator !== "undefined" && typeof navigator.userAgent !== "undefined") {
|
|
1353
|
+
const userAgent = navigator.userAgent;
|
|
1354
|
+
isSafari = /^((?!chrome|android).)*safari/i.test(userAgent) === true;
|
|
1355
|
+
const safariMatch = userAgent.match(/Version\/(\d+)/);
|
|
1356
|
+
safariVersion = isSafari && safariMatch ? parseInt(safariMatch[1], 10) : -1;
|
|
1357
|
+
isFirefox = userAgent.indexOf("Firefox") > -1;
|
|
1358
|
+
firefoxVersion = isFirefox ? userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1;
|
|
1359
|
+
}
|
|
1360
|
+
if (typeof createImageBitmap === "undefined" || isSafari && safariVersion < 17 || isFirefox && firefoxVersion < 98) {
|
|
1361
|
+
this.textureLoader = new chunkSQY54X47_js.TextureLoader(this.options.manager);
|
|
1362
|
+
} else {
|
|
1363
|
+
this.textureLoader = new chunkSQY54X47_js.ImageBitmapLoader(this.options.manager);
|
|
1364
|
+
}
|
|
1365
|
+
this.textureLoader.setCrossOrigin(this.options.crossOrigin);
|
|
1366
|
+
this.textureLoader.setRequestHeader(this.options.requestHeader);
|
|
1367
|
+
this.fileLoader = new chunkSQY54X47_js.FileLoader(this.options.manager);
|
|
1368
|
+
this.fileLoader.setResponseType("arraybuffer");
|
|
1369
|
+
if (this.options.crossOrigin === "use-credentials") {
|
|
1370
|
+
this.fileLoader.setWithCredentials(true);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
setExtensions(extensions) {
|
|
1374
|
+
this.extensions = extensions;
|
|
1375
|
+
}
|
|
1376
|
+
setPlugins(plugins) {
|
|
1377
|
+
this.plugins = plugins;
|
|
1378
|
+
}
|
|
1379
|
+
parse(onLoad, onError) {
|
|
1380
|
+
const parser = this;
|
|
1381
|
+
const json = this.json;
|
|
1382
|
+
const extensions = this.extensions;
|
|
1383
|
+
this.cache.removeAll();
|
|
1384
|
+
this.nodeCache = {};
|
|
1385
|
+
this._invokeAll(function(ext) {
|
|
1386
|
+
return ext._markDefs && ext._markDefs();
|
|
1387
|
+
});
|
|
1388
|
+
Promise.all(this._invokeAll(function(ext) {
|
|
1389
|
+
return ext.beforeRoot && ext.beforeRoot();
|
|
1390
|
+
})).then(function() {
|
|
1391
|
+
return Promise.all([
|
|
1392
|
+
parser.getDependencies("scene"),
|
|
1393
|
+
parser.getDependencies("animation"),
|
|
1394
|
+
parser.getDependencies("camera")
|
|
1395
|
+
]);
|
|
1396
|
+
}).then(function(dependencies) {
|
|
1397
|
+
const result = {
|
|
1398
|
+
scene: dependencies[0][json.scene || 0],
|
|
1399
|
+
scenes: dependencies[0],
|
|
1400
|
+
animations: dependencies[1],
|
|
1401
|
+
cameras: dependencies[2],
|
|
1402
|
+
asset: json.asset,
|
|
1403
|
+
parser,
|
|
1404
|
+
userData: {}
|
|
1405
|
+
};
|
|
1406
|
+
addUnknownExtensionsToUserData(extensions, result, json);
|
|
1407
|
+
assignExtrasToUserData(result, json);
|
|
1408
|
+
return Promise.all(parser._invokeAll(function(ext) {
|
|
1409
|
+
return ext.afterRoot && ext.afterRoot(result);
|
|
1410
|
+
})).then(function() {
|
|
1411
|
+
for (const scene of result.scenes) {
|
|
1412
|
+
scene.updateMatrixWorld();
|
|
1413
|
+
}
|
|
1414
|
+
onLoad(result);
|
|
1415
|
+
});
|
|
1416
|
+
}).catch(onError);
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Marks the special nodes/meshes in json for efficient parse.
|
|
1420
|
+
*
|
|
1421
|
+
* @private
|
|
1422
|
+
*/
|
|
1423
|
+
_markDefs() {
|
|
1424
|
+
const nodeDefs = this.json.nodes || [];
|
|
1425
|
+
const skinDefs = this.json.skins || [];
|
|
1426
|
+
const meshDefs = this.json.meshes || [];
|
|
1427
|
+
for (let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex++) {
|
|
1428
|
+
const joints = skinDefs[skinIndex].joints;
|
|
1429
|
+
for (let i = 0, il = joints.length; i < il; i++) {
|
|
1430
|
+
nodeDefs[joints[i]].isBone = true;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
for (let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {
|
|
1434
|
+
const nodeDef = nodeDefs[nodeIndex];
|
|
1435
|
+
if (nodeDef.mesh !== void 0) {
|
|
1436
|
+
this._addNodeRef(this.meshCache, nodeDef.mesh);
|
|
1437
|
+
if (nodeDef.skin !== void 0) {
|
|
1438
|
+
meshDefs[nodeDef.mesh].isSkinnedMesh = true;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
if (nodeDef.camera !== void 0) {
|
|
1442
|
+
this._addNodeRef(this.cameraCache, nodeDef.camera);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Counts references to shared node / Object3D resources. These resources
|
|
1448
|
+
* can be reused, or "instantiated", at multiple nodes in the scene
|
|
1449
|
+
* hierarchy. Mesh, Camera, and Light instances are instantiated and must
|
|
1450
|
+
* be marked. Non-scenegraph resources (like Materials, Geometries, and
|
|
1451
|
+
* Textures) can be reused directly and are not marked here.
|
|
1452
|
+
*
|
|
1453
|
+
* Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
|
|
1454
|
+
*
|
|
1455
|
+
* @private
|
|
1456
|
+
* @param {Object} cache
|
|
1457
|
+
* @param {Object3D} index
|
|
1458
|
+
*/
|
|
1459
|
+
_addNodeRef(cache, index) {
|
|
1460
|
+
if (index === void 0) return;
|
|
1461
|
+
if (cache.refs[index] === void 0) {
|
|
1462
|
+
cache.refs[index] = cache.uses[index] = 0;
|
|
1463
|
+
}
|
|
1464
|
+
cache.refs[index]++;
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Returns a reference to a shared resource, cloning it if necessary.
|
|
1468
|
+
*
|
|
1469
|
+
* @private
|
|
1470
|
+
* @param {Object} cache
|
|
1471
|
+
* @param {number} index
|
|
1472
|
+
* @param {Object} object
|
|
1473
|
+
* @return {Object}
|
|
1474
|
+
*/
|
|
1475
|
+
_getNodeRef(cache, index, object) {
|
|
1476
|
+
if (cache.refs[index] <= 1) return object;
|
|
1477
|
+
const ref = object.clone();
|
|
1478
|
+
const updateMappings = (original, clone2) => {
|
|
1479
|
+
const mappings = this.associations.get(original);
|
|
1480
|
+
if (mappings != null) {
|
|
1481
|
+
this.associations.set(clone2, mappings);
|
|
1482
|
+
}
|
|
1483
|
+
for (const [i, child] of original.children.entries()) {
|
|
1484
|
+
updateMappings(child, clone2.children[i]);
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
updateMappings(object, ref);
|
|
1488
|
+
ref.name += "_instance_" + cache.uses[index]++;
|
|
1489
|
+
return ref;
|
|
1490
|
+
}
|
|
1491
|
+
_invokeOne(func) {
|
|
1492
|
+
const extensions = Object.values(this.plugins);
|
|
1493
|
+
extensions.push(this);
|
|
1494
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
1495
|
+
const result = func(extensions[i]);
|
|
1496
|
+
if (result) return result;
|
|
1497
|
+
}
|
|
1498
|
+
return null;
|
|
1499
|
+
}
|
|
1500
|
+
_invokeAll(func) {
|
|
1501
|
+
const extensions = Object.values(this.plugins);
|
|
1502
|
+
extensions.unshift(this);
|
|
1503
|
+
const pending = [];
|
|
1504
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
1505
|
+
const result = func(extensions[i]);
|
|
1506
|
+
if (result) pending.push(result);
|
|
1507
|
+
}
|
|
1508
|
+
return pending;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Requests the specified dependency asynchronously, with caching.
|
|
1512
|
+
*
|
|
1513
|
+
* @private
|
|
1514
|
+
* @param {string} type
|
|
1515
|
+
* @param {number} index
|
|
1516
|
+
* @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
|
|
1517
|
+
*/
|
|
1518
|
+
getDependency(type, index) {
|
|
1519
|
+
const cacheKey = type + ":" + index;
|
|
1520
|
+
let dependency = this.cache.get(cacheKey);
|
|
1521
|
+
if (!dependency) {
|
|
1522
|
+
switch (type) {
|
|
1523
|
+
case "scene":
|
|
1524
|
+
dependency = this.loadScene(index);
|
|
1525
|
+
break;
|
|
1526
|
+
case "node":
|
|
1527
|
+
dependency = this._invokeOne(function(ext) {
|
|
1528
|
+
return ext.loadNode && ext.loadNode(index);
|
|
1529
|
+
});
|
|
1530
|
+
break;
|
|
1531
|
+
case "mesh":
|
|
1532
|
+
dependency = this._invokeOne(function(ext) {
|
|
1533
|
+
return ext.loadMesh && ext.loadMesh(index);
|
|
1534
|
+
});
|
|
1535
|
+
break;
|
|
1536
|
+
case "accessor":
|
|
1537
|
+
dependency = this.loadAccessor(index);
|
|
1538
|
+
break;
|
|
1539
|
+
case "bufferView":
|
|
1540
|
+
dependency = this._invokeOne(function(ext) {
|
|
1541
|
+
return ext.loadBufferView && ext.loadBufferView(index);
|
|
1542
|
+
});
|
|
1543
|
+
break;
|
|
1544
|
+
case "buffer":
|
|
1545
|
+
dependency = this.loadBuffer(index);
|
|
1546
|
+
break;
|
|
1547
|
+
case "material":
|
|
1548
|
+
dependency = this._invokeOne(function(ext) {
|
|
1549
|
+
return ext.loadMaterial && ext.loadMaterial(index);
|
|
1550
|
+
});
|
|
1551
|
+
break;
|
|
1552
|
+
case "texture":
|
|
1553
|
+
dependency = this._invokeOne(function(ext) {
|
|
1554
|
+
return ext.loadTexture && ext.loadTexture(index);
|
|
1555
|
+
});
|
|
1556
|
+
break;
|
|
1557
|
+
case "skin":
|
|
1558
|
+
dependency = this.loadSkin(index);
|
|
1559
|
+
break;
|
|
1560
|
+
case "animation":
|
|
1561
|
+
dependency = this._invokeOne(function(ext) {
|
|
1562
|
+
return ext.loadAnimation && ext.loadAnimation(index);
|
|
1563
|
+
});
|
|
1564
|
+
break;
|
|
1565
|
+
case "camera":
|
|
1566
|
+
dependency = this.loadCamera(index);
|
|
1567
|
+
break;
|
|
1568
|
+
default:
|
|
1569
|
+
dependency = this._invokeOne(function(ext) {
|
|
1570
|
+
return ext != this && ext.getDependency && ext.getDependency(type, index);
|
|
1571
|
+
});
|
|
1572
|
+
if (!dependency) {
|
|
1573
|
+
throw new Error("Unknown type: " + type);
|
|
1574
|
+
}
|
|
1575
|
+
break;
|
|
1576
|
+
}
|
|
1577
|
+
this.cache.add(cacheKey, dependency);
|
|
1578
|
+
}
|
|
1579
|
+
return dependency;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Requests all dependencies of the specified type asynchronously, with caching.
|
|
1583
|
+
*
|
|
1584
|
+
* @private
|
|
1585
|
+
* @param {string} type
|
|
1586
|
+
* @return {Promise<Array<Object>>}
|
|
1587
|
+
*/
|
|
1588
|
+
getDependencies(type) {
|
|
1589
|
+
let dependencies = this.cache.get(type);
|
|
1590
|
+
if (!dependencies) {
|
|
1591
|
+
const parser = this;
|
|
1592
|
+
const defs = this.json[type + (type === "mesh" ? "es" : "s")] || [];
|
|
1593
|
+
dependencies = Promise.all(defs.map(function(def, index) {
|
|
1594
|
+
return parser.getDependency(type, index);
|
|
1595
|
+
}));
|
|
1596
|
+
this.cache.add(type, dependencies);
|
|
1597
|
+
}
|
|
1598
|
+
return dependencies;
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1602
|
+
*
|
|
1603
|
+
* @private
|
|
1604
|
+
* @param {number} bufferIndex
|
|
1605
|
+
* @return {Promise<ArrayBuffer>}
|
|
1606
|
+
*/
|
|
1607
|
+
loadBuffer(bufferIndex) {
|
|
1608
|
+
const bufferDef = this.json.buffers[bufferIndex];
|
|
1609
|
+
const loader = this.fileLoader;
|
|
1610
|
+
if (bufferDef.type && bufferDef.type !== "arraybuffer") {
|
|
1611
|
+
throw new Error("THREE.GLTFLoader: " + bufferDef.type + " buffer type is not supported.");
|
|
1612
|
+
}
|
|
1613
|
+
if (bufferDef.uri === void 0 && bufferIndex === 0) {
|
|
1614
|
+
return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);
|
|
1615
|
+
}
|
|
1616
|
+
const options = this.options;
|
|
1617
|
+
return new Promise(function(resolve, reject) {
|
|
1618
|
+
loader.load(chunkSQY54X47_js.LoaderUtils.resolveURL(bufferDef.uri, options.path), resolve, void 0, function() {
|
|
1619
|
+
reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
|
|
1620
|
+
});
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
|
|
1625
|
+
*
|
|
1626
|
+
* @private
|
|
1627
|
+
* @param {number} bufferViewIndex
|
|
1628
|
+
* @return {Promise<ArrayBuffer>}
|
|
1629
|
+
*/
|
|
1630
|
+
loadBufferView(bufferViewIndex) {
|
|
1631
|
+
const bufferViewDef = this.json.bufferViews[bufferViewIndex];
|
|
1632
|
+
return this.getDependency("buffer", bufferViewDef.buffer).then(function(buffer) {
|
|
1633
|
+
const byteLength = bufferViewDef.byteLength || 0;
|
|
1634
|
+
const byteOffset = bufferViewDef.byteOffset || 0;
|
|
1635
|
+
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
|
|
1640
|
+
*
|
|
1641
|
+
* @private
|
|
1642
|
+
* @param {number} accessorIndex
|
|
1643
|
+
* @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
|
|
1644
|
+
*/
|
|
1645
|
+
loadAccessor(accessorIndex) {
|
|
1646
|
+
const parser = this;
|
|
1647
|
+
const json = this.json;
|
|
1648
|
+
const accessorDef = this.json.accessors[accessorIndex];
|
|
1649
|
+
if (accessorDef.bufferView === void 0 && accessorDef.sparse === void 0) {
|
|
1650
|
+
const itemSize = WEBGL_TYPE_SIZES[accessorDef.type];
|
|
1651
|
+
const TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
|
|
1652
|
+
const normalized = accessorDef.normalized === true;
|
|
1653
|
+
const array = new TypedArray(accessorDef.count * itemSize);
|
|
1654
|
+
return Promise.resolve(new chunkSQY54X47_js.BufferAttribute(array, itemSize, normalized));
|
|
1655
|
+
}
|
|
1656
|
+
const pendingBufferViews = [];
|
|
1657
|
+
if (accessorDef.bufferView !== void 0) {
|
|
1658
|
+
pendingBufferViews.push(this.getDependency("bufferView", accessorDef.bufferView));
|
|
1659
|
+
} else {
|
|
1660
|
+
pendingBufferViews.push(null);
|
|
1661
|
+
}
|
|
1662
|
+
if (accessorDef.sparse !== void 0) {
|
|
1663
|
+
pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.indices.bufferView));
|
|
1664
|
+
pendingBufferViews.push(this.getDependency("bufferView", accessorDef.sparse.values.bufferView));
|
|
1665
|
+
}
|
|
1666
|
+
return Promise.all(pendingBufferViews).then(function(bufferViews) {
|
|
1667
|
+
const bufferView = bufferViews[0];
|
|
1668
|
+
const itemSize = WEBGL_TYPE_SIZES[accessorDef.type];
|
|
1669
|
+
const TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];
|
|
1670
|
+
const elementBytes = TypedArray.BYTES_PER_ELEMENT;
|
|
1671
|
+
const itemBytes = elementBytes * itemSize;
|
|
1672
|
+
const byteOffset = accessorDef.byteOffset || 0;
|
|
1673
|
+
const byteStride = accessorDef.bufferView !== void 0 ? json.bufferViews[accessorDef.bufferView].byteStride : void 0;
|
|
1674
|
+
const normalized = accessorDef.normalized === true;
|
|
1675
|
+
let array, bufferAttribute;
|
|
1676
|
+
if (byteStride && byteStride !== itemBytes) {
|
|
1677
|
+
const ibSlice = Math.floor(byteOffset / byteStride);
|
|
1678
|
+
const ibCacheKey = "InterleavedBuffer:" + accessorDef.bufferView + ":" + accessorDef.componentType + ":" + ibSlice + ":" + accessorDef.count;
|
|
1679
|
+
let ib = parser.cache.get(ibCacheKey);
|
|
1680
|
+
if (!ib) {
|
|
1681
|
+
array = new TypedArray(bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes);
|
|
1682
|
+
ib = new chunkSQY54X47_js.InterleavedBuffer(array, byteStride / elementBytes);
|
|
1683
|
+
parser.cache.add(ibCacheKey, ib);
|
|
1684
|
+
}
|
|
1685
|
+
bufferAttribute = new chunkSQY54X47_js.InterleavedBufferAttribute(ib, itemSize, byteOffset % byteStride / elementBytes, normalized);
|
|
1686
|
+
} else {
|
|
1687
|
+
if (bufferView === null) {
|
|
1688
|
+
array = new TypedArray(accessorDef.count * itemSize);
|
|
1689
|
+
} else {
|
|
1690
|
+
array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);
|
|
1691
|
+
}
|
|
1692
|
+
bufferAttribute = new chunkSQY54X47_js.BufferAttribute(array, itemSize, normalized);
|
|
1693
|
+
}
|
|
1694
|
+
if (accessorDef.sparse !== void 0) {
|
|
1695
|
+
const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
|
|
1696
|
+
const TypedArrayIndices = WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType];
|
|
1697
|
+
const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
|
|
1698
|
+
const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
|
|
1699
|
+
const sparseIndices = new TypedArrayIndices(bufferViews[1], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices);
|
|
1700
|
+
const sparseValues = new TypedArray(bufferViews[2], byteOffsetValues, accessorDef.sparse.count * itemSize);
|
|
1701
|
+
if (bufferView !== null) {
|
|
1702
|
+
bufferAttribute = new chunkSQY54X47_js.BufferAttribute(bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized);
|
|
1703
|
+
}
|
|
1704
|
+
bufferAttribute.normalized = false;
|
|
1705
|
+
for (let i = 0, il = sparseIndices.length; i < il; i++) {
|
|
1706
|
+
const index = sparseIndices[i];
|
|
1707
|
+
bufferAttribute.setX(index, sparseValues[i * itemSize]);
|
|
1708
|
+
if (itemSize >= 2) bufferAttribute.setY(index, sparseValues[i * itemSize + 1]);
|
|
1709
|
+
if (itemSize >= 3) bufferAttribute.setZ(index, sparseValues[i * itemSize + 2]);
|
|
1710
|
+
if (itemSize >= 4) bufferAttribute.setW(index, sparseValues[i * itemSize + 3]);
|
|
1711
|
+
if (itemSize >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
|
|
1712
|
+
}
|
|
1713
|
+
bufferAttribute.normalized = normalized;
|
|
1714
|
+
}
|
|
1715
|
+
return bufferAttribute;
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
1720
|
+
*
|
|
1721
|
+
* @private
|
|
1722
|
+
* @param {number} textureIndex
|
|
1723
|
+
* @return {Promise<?Texture>}
|
|
1724
|
+
*/
|
|
1725
|
+
loadTexture(textureIndex) {
|
|
1726
|
+
const json = this.json;
|
|
1727
|
+
const options = this.options;
|
|
1728
|
+
const textureDef = json.textures[textureIndex];
|
|
1729
|
+
const sourceIndex = textureDef.source;
|
|
1730
|
+
const sourceDef = json.images[sourceIndex];
|
|
1731
|
+
let loader = this.textureLoader;
|
|
1732
|
+
if (sourceDef.uri) {
|
|
1733
|
+
const handler = options.manager.getHandler(sourceDef.uri);
|
|
1734
|
+
if (handler !== null) loader = handler;
|
|
1735
|
+
}
|
|
1736
|
+
return this.loadTextureImage(textureIndex, sourceIndex, loader);
|
|
1737
|
+
}
|
|
1738
|
+
loadTextureImage(textureIndex, sourceIndex, loader) {
|
|
1739
|
+
const parser = this;
|
|
1740
|
+
const json = this.json;
|
|
1741
|
+
const textureDef = json.textures[textureIndex];
|
|
1742
|
+
const sourceDef = json.images[sourceIndex];
|
|
1743
|
+
const cacheKey = (sourceDef.uri || sourceDef.bufferView) + ":" + textureDef.sampler;
|
|
1744
|
+
if (this.textureCache[cacheKey]) {
|
|
1745
|
+
return this.textureCache[cacheKey];
|
|
1746
|
+
}
|
|
1747
|
+
const promise = this.loadImageSource(sourceIndex, loader).then(function(texture) {
|
|
1748
|
+
texture.flipY = false;
|
|
1749
|
+
texture.name = textureDef.name || sourceDef.name || "";
|
|
1750
|
+
if (texture.name === "" && typeof sourceDef.uri === "string" && sourceDef.uri.startsWith("data:image/") === false) {
|
|
1751
|
+
texture.name = sourceDef.uri;
|
|
1752
|
+
}
|
|
1753
|
+
const samplers = json.samplers || {};
|
|
1754
|
+
const sampler = samplers[textureDef.sampler] || {};
|
|
1755
|
+
texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || chunkSQY54X47_js.LinearFilter;
|
|
1756
|
+
texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || chunkSQY54X47_js.LinearMipmapLinearFilter;
|
|
1757
|
+
texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || chunkSQY54X47_js.RepeatWrapping;
|
|
1758
|
+
texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || chunkSQY54X47_js.RepeatWrapping;
|
|
1759
|
+
texture.generateMipmaps = !texture.isCompressedTexture && texture.minFilter !== chunkSQY54X47_js.NearestFilter && texture.minFilter !== chunkSQY54X47_js.LinearFilter;
|
|
1760
|
+
parser.associations.set(texture, { textures: textureIndex });
|
|
1761
|
+
return texture;
|
|
1762
|
+
}).catch(function() {
|
|
1763
|
+
return null;
|
|
1764
|
+
});
|
|
1765
|
+
this.textureCache[cacheKey] = promise;
|
|
1766
|
+
return promise;
|
|
1767
|
+
}
|
|
1768
|
+
loadImageSource(sourceIndex, loader) {
|
|
1769
|
+
const parser = this;
|
|
1770
|
+
const json = this.json;
|
|
1771
|
+
const options = this.options;
|
|
1772
|
+
if (this.sourceCache[sourceIndex] !== void 0) {
|
|
1773
|
+
return this.sourceCache[sourceIndex].then((texture) => texture.clone());
|
|
1774
|
+
}
|
|
1775
|
+
const sourceDef = json.images[sourceIndex];
|
|
1776
|
+
const URL = self.URL || self.webkitURL;
|
|
1777
|
+
let sourceURI = sourceDef.uri || "";
|
|
1778
|
+
let isObjectURL = false;
|
|
1779
|
+
if (sourceDef.bufferView !== void 0) {
|
|
1780
|
+
sourceURI = parser.getDependency("bufferView", sourceDef.bufferView).then(function(bufferView) {
|
|
1781
|
+
isObjectURL = true;
|
|
1782
|
+
const blob = new Blob([bufferView], { type: sourceDef.mimeType });
|
|
1783
|
+
sourceURI = URL.createObjectURL(blob);
|
|
1784
|
+
return sourceURI;
|
|
1785
|
+
});
|
|
1786
|
+
} else if (sourceDef.uri === void 0) {
|
|
1787
|
+
throw new Error("THREE.GLTFLoader: Image " + sourceIndex + " is missing URI and bufferView");
|
|
1788
|
+
}
|
|
1789
|
+
const promise = Promise.resolve(sourceURI).then(function(sourceURI2) {
|
|
1790
|
+
return new Promise(function(resolve, reject) {
|
|
1791
|
+
let onLoad = resolve;
|
|
1792
|
+
if (loader.isImageBitmapLoader === true) {
|
|
1793
|
+
onLoad = function(imageBitmap) {
|
|
1794
|
+
const texture = new chunkSQY54X47_js.Texture(imageBitmap);
|
|
1795
|
+
texture.needsUpdate = true;
|
|
1796
|
+
resolve(texture);
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
loader.load(chunkSQY54X47_js.LoaderUtils.resolveURL(sourceURI2, options.path), onLoad, void 0, reject);
|
|
1800
|
+
});
|
|
1801
|
+
}).then(function(texture) {
|
|
1802
|
+
if (isObjectURL === true) {
|
|
1803
|
+
URL.revokeObjectURL(sourceURI);
|
|
1804
|
+
}
|
|
1805
|
+
assignExtrasToUserData(texture, sourceDef);
|
|
1806
|
+
texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType(sourceDef.uri);
|
|
1807
|
+
return texture;
|
|
1808
|
+
}).catch(function(error) {
|
|
1809
|
+
console.error("THREE.GLTFLoader: Couldn't load texture", sourceURI);
|
|
1810
|
+
throw error;
|
|
1811
|
+
});
|
|
1812
|
+
this.sourceCache[sourceIndex] = promise;
|
|
1813
|
+
return promise;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Asynchronously assigns a texture to the given material parameters.
|
|
1817
|
+
*
|
|
1818
|
+
* @private
|
|
1819
|
+
* @param {Object} materialParams
|
|
1820
|
+
* @param {string} mapName
|
|
1821
|
+
* @param {Object} mapDef
|
|
1822
|
+
* @param {string} [colorSpace]
|
|
1823
|
+
* @return {Promise<Texture>}
|
|
1824
|
+
*/
|
|
1825
|
+
assignTexture(materialParams, mapName, mapDef, colorSpace) {
|
|
1826
|
+
const parser = this;
|
|
1827
|
+
return this.getDependency("texture", mapDef.index).then(function(texture) {
|
|
1828
|
+
if (!texture) return null;
|
|
1829
|
+
if (mapDef.texCoord !== void 0 && mapDef.texCoord > 0) {
|
|
1830
|
+
texture = texture.clone();
|
|
1831
|
+
texture.channel = mapDef.texCoord;
|
|
1832
|
+
}
|
|
1833
|
+
if (parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]) {
|
|
1834
|
+
const transform = mapDef.extensions !== void 0 ? mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM] : void 0;
|
|
1835
|
+
if (transform) {
|
|
1836
|
+
const gltfReference = parser.associations.get(texture);
|
|
1837
|
+
texture = parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(texture, transform);
|
|
1838
|
+
parser.associations.set(texture, gltfReference);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
if (colorSpace !== void 0) {
|
|
1842
|
+
texture.colorSpace = colorSpace;
|
|
1843
|
+
}
|
|
1844
|
+
materialParams[mapName] = texture;
|
|
1845
|
+
return texture;
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Assigns final material to a Mesh, Line, or Points instance. The instance
|
|
1850
|
+
* already has a material (generated from the glTF material options alone)
|
|
1851
|
+
* but reuse of the same glTF material may require multiple threejs materials
|
|
1852
|
+
* to accommodate different primitive types, defines, etc. New materials will
|
|
1853
|
+
* be created if necessary, and reused from a cache.
|
|
1854
|
+
*
|
|
1855
|
+
* @private
|
|
1856
|
+
* @param {Object3D} mesh Mesh, Line, or Points instance.
|
|
1857
|
+
*/
|
|
1858
|
+
assignFinalMaterial(mesh) {
|
|
1859
|
+
const geometry = mesh.geometry;
|
|
1860
|
+
let material = mesh.material;
|
|
1861
|
+
const useDerivativeTangents = geometry.attributes.tangent === void 0;
|
|
1862
|
+
const useVertexColors = geometry.attributes.color !== void 0;
|
|
1863
|
+
const useFlatShading = geometry.attributes.normal === void 0;
|
|
1864
|
+
if (mesh.isPoints) {
|
|
1865
|
+
const cacheKey = "PointsMaterial:" + material.uuid;
|
|
1866
|
+
let pointsMaterial = this.cache.get(cacheKey);
|
|
1867
|
+
if (!pointsMaterial) {
|
|
1868
|
+
pointsMaterial = new chunkSQY54X47_js.PointsMaterial();
|
|
1869
|
+
chunkSQY54X47_js.Material.prototype.copy.call(pointsMaterial, material);
|
|
1870
|
+
pointsMaterial.color.copy(material.color);
|
|
1871
|
+
pointsMaterial.map = material.map;
|
|
1872
|
+
pointsMaterial.sizeAttenuation = false;
|
|
1873
|
+
this.cache.add(cacheKey, pointsMaterial);
|
|
1874
|
+
}
|
|
1875
|
+
material = pointsMaterial;
|
|
1876
|
+
} else if (mesh.isLine) {
|
|
1877
|
+
const cacheKey = "LineBasicMaterial:" + material.uuid;
|
|
1878
|
+
let lineMaterial = this.cache.get(cacheKey);
|
|
1879
|
+
if (!lineMaterial) {
|
|
1880
|
+
lineMaterial = new chunkSQY54X47_js.LineBasicMaterial();
|
|
1881
|
+
chunkSQY54X47_js.Material.prototype.copy.call(lineMaterial, material);
|
|
1882
|
+
lineMaterial.color.copy(material.color);
|
|
1883
|
+
lineMaterial.map = material.map;
|
|
1884
|
+
this.cache.add(cacheKey, lineMaterial);
|
|
1885
|
+
}
|
|
1886
|
+
material = lineMaterial;
|
|
1887
|
+
}
|
|
1888
|
+
if (useDerivativeTangents || useVertexColors || useFlatShading) {
|
|
1889
|
+
let cacheKey = "ClonedMaterial:" + material.uuid + ":";
|
|
1890
|
+
if (useDerivativeTangents) cacheKey += "derivative-tangents:";
|
|
1891
|
+
if (useVertexColors) cacheKey += "vertex-colors:";
|
|
1892
|
+
if (useFlatShading) cacheKey += "flat-shading:";
|
|
1893
|
+
let cachedMaterial = this.cache.get(cacheKey);
|
|
1894
|
+
if (!cachedMaterial) {
|
|
1895
|
+
cachedMaterial = material.clone();
|
|
1896
|
+
if (useVertexColors) cachedMaterial.vertexColors = true;
|
|
1897
|
+
if (useFlatShading) cachedMaterial.flatShading = true;
|
|
1898
|
+
if (useDerivativeTangents) {
|
|
1899
|
+
if (cachedMaterial.normalScale) cachedMaterial.normalScale.y *= -1;
|
|
1900
|
+
if (cachedMaterial.clearcoatNormalScale) cachedMaterial.clearcoatNormalScale.y *= -1;
|
|
1901
|
+
}
|
|
1902
|
+
this.cache.add(cacheKey, cachedMaterial);
|
|
1903
|
+
this.associations.set(cachedMaterial, this.associations.get(material));
|
|
1904
|
+
}
|
|
1905
|
+
material = cachedMaterial;
|
|
1906
|
+
}
|
|
1907
|
+
mesh.material = material;
|
|
1908
|
+
}
|
|
1909
|
+
getMaterialType() {
|
|
1910
|
+
return chunkSQY54X47_js.MeshStandardMaterial;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
|
|
1914
|
+
*
|
|
1915
|
+
* @private
|
|
1916
|
+
* @param {number} materialIndex
|
|
1917
|
+
* @return {Promise<Material>}
|
|
1918
|
+
*/
|
|
1919
|
+
loadMaterial(materialIndex) {
|
|
1920
|
+
const parser = this;
|
|
1921
|
+
const json = this.json;
|
|
1922
|
+
const extensions = this.extensions;
|
|
1923
|
+
const materialDef = json.materials[materialIndex];
|
|
1924
|
+
let materialType;
|
|
1925
|
+
const materialParams = {};
|
|
1926
|
+
const materialExtensions = materialDef.extensions || {};
|
|
1927
|
+
const pending = [];
|
|
1928
|
+
if (materialExtensions[EXTENSIONS.KHR_MATERIALS_UNLIT]) {
|
|
1929
|
+
const kmuExtension = extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];
|
|
1930
|
+
materialType = kmuExtension.getMaterialType();
|
|
1931
|
+
pending.push(kmuExtension.extendParams(materialParams, materialDef, parser));
|
|
1932
|
+
} else {
|
|
1933
|
+
const metallicRoughness = materialDef.pbrMetallicRoughness || {};
|
|
1934
|
+
materialParams.color = new chunkSQY54X47_js.Color(1, 1, 1);
|
|
1935
|
+
materialParams.opacity = 1;
|
|
1936
|
+
if (Array.isArray(metallicRoughness.baseColorFactor)) {
|
|
1937
|
+
const array = metallicRoughness.baseColorFactor;
|
|
1938
|
+
materialParams.color.setRGB(array[0], array[1], array[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
1939
|
+
materialParams.opacity = array[3];
|
|
1940
|
+
}
|
|
1941
|
+
if (metallicRoughness.baseColorTexture !== void 0) {
|
|
1942
|
+
pending.push(parser.assignTexture(materialParams, "map", metallicRoughness.baseColorTexture, chunkSQY54X47_js.SRGBColorSpace));
|
|
1943
|
+
}
|
|
1944
|
+
materialParams.metalness = metallicRoughness.metallicFactor !== void 0 ? metallicRoughness.metallicFactor : 1;
|
|
1945
|
+
materialParams.roughness = metallicRoughness.roughnessFactor !== void 0 ? metallicRoughness.roughnessFactor : 1;
|
|
1946
|
+
if (metallicRoughness.metallicRoughnessTexture !== void 0) {
|
|
1947
|
+
pending.push(parser.assignTexture(materialParams, "metalnessMap", metallicRoughness.metallicRoughnessTexture));
|
|
1948
|
+
pending.push(parser.assignTexture(materialParams, "roughnessMap", metallicRoughness.metallicRoughnessTexture));
|
|
1949
|
+
}
|
|
1950
|
+
materialType = this._invokeOne(function(ext) {
|
|
1951
|
+
return ext.getMaterialType && ext.getMaterialType(materialIndex);
|
|
1952
|
+
});
|
|
1953
|
+
pending.push(Promise.all(this._invokeAll(function(ext) {
|
|
1954
|
+
return ext.extendMaterialParams && ext.extendMaterialParams(materialIndex, materialParams);
|
|
1955
|
+
})));
|
|
1956
|
+
}
|
|
1957
|
+
if (materialDef.doubleSided === true) {
|
|
1958
|
+
materialParams.side = chunkSQY54X47_js.DoubleSide;
|
|
1959
|
+
}
|
|
1960
|
+
const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
|
|
1961
|
+
if (alphaMode === ALPHA_MODES.BLEND) {
|
|
1962
|
+
materialParams.transparent = true;
|
|
1963
|
+
materialParams.depthWrite = false;
|
|
1964
|
+
} else {
|
|
1965
|
+
materialParams.transparent = false;
|
|
1966
|
+
if (alphaMode === ALPHA_MODES.MASK) {
|
|
1967
|
+
materialParams.alphaTest = materialDef.alphaCutoff !== void 0 ? materialDef.alphaCutoff : 0.5;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
if (materialDef.normalTexture !== void 0 && materialType !== chunkSQY54X47_js.MeshBasicMaterial) {
|
|
1971
|
+
pending.push(parser.assignTexture(materialParams, "normalMap", materialDef.normalTexture));
|
|
1972
|
+
materialParams.normalScale = new chunkSQY54X47_js.Vector2(1, 1);
|
|
1973
|
+
if (materialDef.normalTexture.scale !== void 0) {
|
|
1974
|
+
const scale = materialDef.normalTexture.scale;
|
|
1975
|
+
materialParams.normalScale.set(scale, scale);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
if (materialDef.occlusionTexture !== void 0 && materialType !== chunkSQY54X47_js.MeshBasicMaterial) {
|
|
1979
|
+
pending.push(parser.assignTexture(materialParams, "aoMap", materialDef.occlusionTexture));
|
|
1980
|
+
if (materialDef.occlusionTexture.strength !== void 0) {
|
|
1981
|
+
materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
if (materialDef.emissiveFactor !== void 0 && materialType !== chunkSQY54X47_js.MeshBasicMaterial) {
|
|
1985
|
+
const emissiveFactor = materialDef.emissiveFactor;
|
|
1986
|
+
materialParams.emissive = new chunkSQY54X47_js.Color().setRGB(emissiveFactor[0], emissiveFactor[1], emissiveFactor[2], chunkSQY54X47_js.LinearSRGBColorSpace);
|
|
1987
|
+
}
|
|
1988
|
+
if (materialDef.emissiveTexture !== void 0 && materialType !== chunkSQY54X47_js.MeshBasicMaterial) {
|
|
1989
|
+
pending.push(parser.assignTexture(materialParams, "emissiveMap", materialDef.emissiveTexture, chunkSQY54X47_js.SRGBColorSpace));
|
|
1990
|
+
}
|
|
1991
|
+
return Promise.all(pending).then(function() {
|
|
1992
|
+
const material = new materialType(materialParams);
|
|
1993
|
+
if (materialDef.name) material.name = materialDef.name;
|
|
1994
|
+
assignExtrasToUserData(material, materialDef);
|
|
1995
|
+
parser.associations.set(material, { materials: materialIndex });
|
|
1996
|
+
if (materialDef.extensions) addUnknownExtensionsToUserData(extensions, material, materialDef);
|
|
1997
|
+
return material;
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* When Object3D instances are targeted by animation, they need unique names.
|
|
2002
|
+
*
|
|
2003
|
+
* @private
|
|
2004
|
+
* @param {string} originalName
|
|
2005
|
+
* @return {string}
|
|
2006
|
+
*/
|
|
2007
|
+
createUniqueName(originalName) {
|
|
2008
|
+
const sanitizedName = chunkSQY54X47_js.PropertyBinding.sanitizeNodeName(originalName || "");
|
|
2009
|
+
if (sanitizedName in this.nodeNamesUsed) {
|
|
2010
|
+
return sanitizedName + "_" + ++this.nodeNamesUsed[sanitizedName];
|
|
2011
|
+
} else {
|
|
2012
|
+
this.nodeNamesUsed[sanitizedName] = 0;
|
|
2013
|
+
return sanitizedName;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
|
|
2018
|
+
*
|
|
2019
|
+
* Creates BufferGeometries from primitives.
|
|
2020
|
+
*
|
|
2021
|
+
* @private
|
|
2022
|
+
* @param {Array<GLTF.Primitive>} primitives
|
|
2023
|
+
* @return {Promise<Array<BufferGeometry>>}
|
|
2024
|
+
*/
|
|
2025
|
+
loadGeometries(primitives) {
|
|
2026
|
+
const parser = this;
|
|
2027
|
+
const extensions = this.extensions;
|
|
2028
|
+
const cache = this.primitiveCache;
|
|
2029
|
+
function createDracoPrimitive(primitive) {
|
|
2030
|
+
return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(primitive, parser).then(function(geometry) {
|
|
2031
|
+
return addPrimitiveAttributes(geometry, primitive, parser);
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
const pending = [];
|
|
2035
|
+
for (let i = 0, il = primitives.length; i < il; i++) {
|
|
2036
|
+
const primitive = primitives[i];
|
|
2037
|
+
const cacheKey = createPrimitiveKey(primitive);
|
|
2038
|
+
const cached = cache[cacheKey];
|
|
2039
|
+
if (cached) {
|
|
2040
|
+
pending.push(cached.promise);
|
|
2041
|
+
} else {
|
|
2042
|
+
let geometryPromise;
|
|
2043
|
+
if (primitive.extensions && primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]) {
|
|
2044
|
+
geometryPromise = createDracoPrimitive(primitive);
|
|
2045
|
+
} else {
|
|
2046
|
+
geometryPromise = addPrimitiveAttributes(new chunkSQY54X47_js.BufferGeometry(), primitive, parser);
|
|
2047
|
+
}
|
|
2048
|
+
cache[cacheKey] = { primitive, promise: geometryPromise };
|
|
2049
|
+
pending.push(geometryPromise);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
return Promise.all(pending);
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2055
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
|
|
2056
|
+
*
|
|
2057
|
+
* @private
|
|
2058
|
+
* @param {number} meshIndex
|
|
2059
|
+
* @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
|
|
2060
|
+
*/
|
|
2061
|
+
loadMesh(meshIndex) {
|
|
2062
|
+
const parser = this;
|
|
2063
|
+
const json = this.json;
|
|
2064
|
+
const extensions = this.extensions;
|
|
2065
|
+
const meshDef = json.meshes[meshIndex];
|
|
2066
|
+
const primitives = meshDef.primitives;
|
|
2067
|
+
const pending = [];
|
|
2068
|
+
for (let i = 0, il = primitives.length; i < il; i++) {
|
|
2069
|
+
const material = primitives[i].material === void 0 ? createDefaultMaterial(this.cache) : this.getDependency("material", primitives[i].material);
|
|
2070
|
+
pending.push(material);
|
|
2071
|
+
}
|
|
2072
|
+
pending.push(parser.loadGeometries(primitives));
|
|
2073
|
+
return Promise.all(pending).then(function(results) {
|
|
2074
|
+
const materials = results.slice(0, results.length - 1);
|
|
2075
|
+
const geometries = results[results.length - 1];
|
|
2076
|
+
const meshes = [];
|
|
2077
|
+
for (let i = 0, il = geometries.length; i < il; i++) {
|
|
2078
|
+
const geometry = geometries[i];
|
|
2079
|
+
const primitive = primitives[i];
|
|
2080
|
+
let mesh;
|
|
2081
|
+
const material = materials[i];
|
|
2082
|
+
if (primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === void 0) {
|
|
2083
|
+
mesh = meshDef.isSkinnedMesh === true ? new chunkSQY54X47_js.SkinnedMesh(geometry, material) : new chunkSQY54X47_js.Mesh(geometry, material);
|
|
2084
|
+
if (mesh.isSkinnedMesh === true) {
|
|
2085
|
+
mesh.normalizeSkinWeights();
|
|
2086
|
+
}
|
|
2087
|
+
if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {
|
|
2088
|
+
mesh.geometry = toTrianglesDrawMode(mesh.geometry, chunkSQY54X47_js.TriangleStripDrawMode);
|
|
2089
|
+
} else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {
|
|
2090
|
+
mesh.geometry = toTrianglesDrawMode(mesh.geometry, chunkSQY54X47_js.TriangleFanDrawMode);
|
|
2091
|
+
}
|
|
2092
|
+
} else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
|
|
2093
|
+
mesh = new chunkSQY54X47_js.LineSegments(geometry, material);
|
|
2094
|
+
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {
|
|
2095
|
+
mesh = new chunkSQY54X47_js.Line(geometry, material);
|
|
2096
|
+
} else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {
|
|
2097
|
+
mesh = new chunkSQY54X47_js.LineLoop(geometry, material);
|
|
2098
|
+
} else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {
|
|
2099
|
+
mesh = new chunkSQY54X47_js.Points(geometry, material);
|
|
2100
|
+
} else {
|
|
2101
|
+
throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + primitive.mode);
|
|
2102
|
+
}
|
|
2103
|
+
if (Object.keys(mesh.geometry.morphAttributes).length > 0) {
|
|
2104
|
+
updateMorphTargets(mesh, meshDef);
|
|
2105
|
+
}
|
|
2106
|
+
mesh.name = parser.createUniqueName(meshDef.name || "mesh_" + meshIndex);
|
|
2107
|
+
assignExtrasToUserData(mesh, meshDef);
|
|
2108
|
+
if (primitive.extensions) addUnknownExtensionsToUserData(extensions, mesh, primitive);
|
|
2109
|
+
parser.assignFinalMaterial(mesh);
|
|
2110
|
+
meshes.push(mesh);
|
|
2111
|
+
}
|
|
2112
|
+
for (let i = 0, il = meshes.length; i < il; i++) {
|
|
2113
|
+
parser.associations.set(meshes[i], {
|
|
2114
|
+
meshes: meshIndex,
|
|
2115
|
+
primitives: i
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
if (meshes.length === 1) {
|
|
2119
|
+
if (meshDef.extensions) addUnknownExtensionsToUserData(extensions, meshes[0], meshDef);
|
|
2120
|
+
return meshes[0];
|
|
2121
|
+
}
|
|
2122
|
+
const group = new chunkSQY54X47_js.Group();
|
|
2123
|
+
if (meshDef.extensions) addUnknownExtensionsToUserData(extensions, group, meshDef);
|
|
2124
|
+
parser.associations.set(group, { meshes: meshIndex });
|
|
2125
|
+
for (let i = 0, il = meshes.length; i < il; i++) {
|
|
2126
|
+
group.add(meshes[i]);
|
|
2127
|
+
}
|
|
2128
|
+
return group;
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
|
|
2133
|
+
*
|
|
2134
|
+
* @private
|
|
2135
|
+
* @param {number} cameraIndex
|
|
2136
|
+
* @return {Promise<Camera>|undefined}
|
|
2137
|
+
*/
|
|
2138
|
+
loadCamera(cameraIndex) {
|
|
2139
|
+
let camera;
|
|
2140
|
+
const cameraDef = this.json.cameras[cameraIndex];
|
|
2141
|
+
const params = cameraDef[cameraDef.type];
|
|
2142
|
+
if (!params) {
|
|
2143
|
+
console.warn("THREE.GLTFLoader: Missing camera parameters.");
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
if (cameraDef.type === "perspective") {
|
|
2147
|
+
camera = new chunkSQY54X47_js.PerspectiveCamera(chunkSQY54X47_js.MathUtils.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6);
|
|
2148
|
+
} else if (cameraDef.type === "orthographic") {
|
|
2149
|
+
camera = new chunkSQY54X47_js.OrthographicCamera(-params.xmag, params.xmag, params.ymag, -params.ymag, params.znear, params.zfar);
|
|
2150
|
+
}
|
|
2151
|
+
if (cameraDef.name) camera.name = this.createUniqueName(cameraDef.name);
|
|
2152
|
+
assignExtrasToUserData(camera, cameraDef);
|
|
2153
|
+
return Promise.resolve(camera);
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
2157
|
+
*
|
|
2158
|
+
* @private
|
|
2159
|
+
* @param {number} skinIndex
|
|
2160
|
+
* @return {Promise<Skeleton>}
|
|
2161
|
+
*/
|
|
2162
|
+
loadSkin(skinIndex) {
|
|
2163
|
+
const skinDef = this.json.skins[skinIndex];
|
|
2164
|
+
const pending = [];
|
|
2165
|
+
for (let i = 0, il = skinDef.joints.length; i < il; i++) {
|
|
2166
|
+
pending.push(this._loadNodeShallow(skinDef.joints[i]));
|
|
2167
|
+
}
|
|
2168
|
+
if (skinDef.inverseBindMatrices !== void 0) {
|
|
2169
|
+
pending.push(this.getDependency("accessor", skinDef.inverseBindMatrices));
|
|
2170
|
+
} else {
|
|
2171
|
+
pending.push(null);
|
|
2172
|
+
}
|
|
2173
|
+
return Promise.all(pending).then(function(results) {
|
|
2174
|
+
const inverseBindMatrices = results.pop();
|
|
2175
|
+
const jointNodes = results;
|
|
2176
|
+
const bones = [];
|
|
2177
|
+
const boneInverses = [];
|
|
2178
|
+
for (let i = 0, il = jointNodes.length; i < il; i++) {
|
|
2179
|
+
const jointNode = jointNodes[i];
|
|
2180
|
+
if (jointNode) {
|
|
2181
|
+
bones.push(jointNode);
|
|
2182
|
+
const mat = new chunkSQY54X47_js.Matrix4();
|
|
2183
|
+
if (inverseBindMatrices !== null) {
|
|
2184
|
+
mat.fromArray(inverseBindMatrices.array, i * 16);
|
|
2185
|
+
}
|
|
2186
|
+
boneInverses.push(mat);
|
|
2187
|
+
} else {
|
|
2188
|
+
console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[i]);
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
return new chunkSQY54X47_js.Skeleton(bones, boneInverses);
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
|
|
2196
|
+
*
|
|
2197
|
+
* @private
|
|
2198
|
+
* @param {number} animationIndex
|
|
2199
|
+
* @return {Promise<AnimationClip>}
|
|
2200
|
+
*/
|
|
2201
|
+
loadAnimation(animationIndex) {
|
|
2202
|
+
const json = this.json;
|
|
2203
|
+
const parser = this;
|
|
2204
|
+
const animationDef = json.animations[animationIndex];
|
|
2205
|
+
const animationName = animationDef.name ? animationDef.name : "animation_" + animationIndex;
|
|
2206
|
+
const pendingNodes = [];
|
|
2207
|
+
const pendingInputAccessors = [];
|
|
2208
|
+
const pendingOutputAccessors = [];
|
|
2209
|
+
const pendingSamplers = [];
|
|
2210
|
+
const pendingTargets = [];
|
|
2211
|
+
for (let i = 0, il = animationDef.channels.length; i < il; i++) {
|
|
2212
|
+
const channel = animationDef.channels[i];
|
|
2213
|
+
const sampler = animationDef.samplers[channel.sampler];
|
|
2214
|
+
const target = channel.target;
|
|
2215
|
+
const name = target.node;
|
|
2216
|
+
const input = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.input] : sampler.input;
|
|
2217
|
+
const output = animationDef.parameters !== void 0 ? animationDef.parameters[sampler.output] : sampler.output;
|
|
2218
|
+
if (target.node === void 0) continue;
|
|
2219
|
+
pendingNodes.push(this.getDependency("node", name));
|
|
2220
|
+
pendingInputAccessors.push(this.getDependency("accessor", input));
|
|
2221
|
+
pendingOutputAccessors.push(this.getDependency("accessor", output));
|
|
2222
|
+
pendingSamplers.push(sampler);
|
|
2223
|
+
pendingTargets.push(target);
|
|
2224
|
+
}
|
|
2225
|
+
return Promise.all([
|
|
2226
|
+
Promise.all(pendingNodes),
|
|
2227
|
+
Promise.all(pendingInputAccessors),
|
|
2228
|
+
Promise.all(pendingOutputAccessors),
|
|
2229
|
+
Promise.all(pendingSamplers),
|
|
2230
|
+
Promise.all(pendingTargets)
|
|
2231
|
+
]).then(function(dependencies) {
|
|
2232
|
+
const nodes = dependencies[0];
|
|
2233
|
+
const inputAccessors = dependencies[1];
|
|
2234
|
+
const outputAccessors = dependencies[2];
|
|
2235
|
+
const samplers = dependencies[3];
|
|
2236
|
+
const targets = dependencies[4];
|
|
2237
|
+
const tracks = [];
|
|
2238
|
+
for (let i = 0, il = nodes.length; i < il; i++) {
|
|
2239
|
+
const node = nodes[i];
|
|
2240
|
+
const inputAccessor = inputAccessors[i];
|
|
2241
|
+
const outputAccessor = outputAccessors[i];
|
|
2242
|
+
const sampler = samplers[i];
|
|
2243
|
+
const target = targets[i];
|
|
2244
|
+
if (node === void 0) continue;
|
|
2245
|
+
if (node.updateMatrix) {
|
|
2246
|
+
node.updateMatrix();
|
|
2247
|
+
}
|
|
2248
|
+
const createdTracks = parser._createAnimationTracks(node, inputAccessor, outputAccessor, sampler, target);
|
|
2249
|
+
if (createdTracks) {
|
|
2250
|
+
for (let k = 0; k < createdTracks.length; k++) {
|
|
2251
|
+
tracks.push(createdTracks[k]);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
const animation = new chunkSQY54X47_js.AnimationClip(animationName, void 0, tracks);
|
|
2256
|
+
assignExtrasToUserData(animation, animationDef);
|
|
2257
|
+
return animation;
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
createNodeMesh(nodeIndex) {
|
|
2261
|
+
const json = this.json;
|
|
2262
|
+
const parser = this;
|
|
2263
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
2264
|
+
if (nodeDef.mesh === void 0) return null;
|
|
2265
|
+
return parser.getDependency("mesh", nodeDef.mesh).then(function(mesh) {
|
|
2266
|
+
const node = parser._getNodeRef(parser.meshCache, nodeDef.mesh, mesh);
|
|
2267
|
+
if (nodeDef.weights !== void 0) {
|
|
2268
|
+
node.traverse(function(o) {
|
|
2269
|
+
if (!o.isMesh) return;
|
|
2270
|
+
for (let i = 0, il = nodeDef.weights.length; i < il; i++) {
|
|
2271
|
+
o.morphTargetInfluences[i] = nodeDef.weights[i];
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
return node;
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
|
|
2280
|
+
*
|
|
2281
|
+
* @private
|
|
2282
|
+
* @param {number} nodeIndex
|
|
2283
|
+
* @return {Promise<Object3D>}
|
|
2284
|
+
*/
|
|
2285
|
+
loadNode(nodeIndex) {
|
|
2286
|
+
const json = this.json;
|
|
2287
|
+
const parser = this;
|
|
2288
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
2289
|
+
const nodePending = parser._loadNodeShallow(nodeIndex);
|
|
2290
|
+
const childPending = [];
|
|
2291
|
+
const childrenDef = nodeDef.children || [];
|
|
2292
|
+
for (let i = 0, il = childrenDef.length; i < il; i++) {
|
|
2293
|
+
childPending.push(parser.getDependency("node", childrenDef[i]));
|
|
2294
|
+
}
|
|
2295
|
+
const skeletonPending = nodeDef.skin === void 0 ? Promise.resolve(null) : parser.getDependency("skin", nodeDef.skin);
|
|
2296
|
+
return Promise.all([
|
|
2297
|
+
nodePending,
|
|
2298
|
+
Promise.all(childPending),
|
|
2299
|
+
skeletonPending
|
|
2300
|
+
]).then(function(results) {
|
|
2301
|
+
const node = results[0];
|
|
2302
|
+
const children = results[1];
|
|
2303
|
+
const skeleton = results[2];
|
|
2304
|
+
if (skeleton !== null) {
|
|
2305
|
+
node.traverse(function(mesh) {
|
|
2306
|
+
if (!mesh.isSkinnedMesh) return;
|
|
2307
|
+
mesh.bind(skeleton, _identityMatrix);
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
for (let i = 0, il = children.length; i < il; i++) {
|
|
2311
|
+
node.add(children[i]);
|
|
2312
|
+
}
|
|
2313
|
+
if (node.userData.pivot !== void 0 && children.length > 0) {
|
|
2314
|
+
const pivot = node.userData.pivot;
|
|
2315
|
+
const pivotChild = children[0];
|
|
2316
|
+
node.pivot = new chunkSQY54X47_js.Vector3().fromArray(pivot);
|
|
2317
|
+
node.position.x -= pivot[0];
|
|
2318
|
+
node.position.y -= pivot[1];
|
|
2319
|
+
node.position.z -= pivot[2];
|
|
2320
|
+
pivotChild.position.set(0, 0, 0);
|
|
2321
|
+
delete node.userData.pivot;
|
|
2322
|
+
}
|
|
2323
|
+
return node;
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
// ._loadNodeShallow() parses a single node.
|
|
2327
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
2328
|
+
_loadNodeShallow(nodeIndex) {
|
|
2329
|
+
const json = this.json;
|
|
2330
|
+
const extensions = this.extensions;
|
|
2331
|
+
const parser = this;
|
|
2332
|
+
if (this.nodeCache[nodeIndex] !== void 0) {
|
|
2333
|
+
return this.nodeCache[nodeIndex];
|
|
2334
|
+
}
|
|
2335
|
+
const nodeDef = json.nodes[nodeIndex];
|
|
2336
|
+
const nodeName = nodeDef.name ? parser.createUniqueName(nodeDef.name) : "";
|
|
2337
|
+
const pending = [];
|
|
2338
|
+
const meshPromise = parser._invokeOne(function(ext) {
|
|
2339
|
+
return ext.createNodeMesh && ext.createNodeMesh(nodeIndex);
|
|
2340
|
+
});
|
|
2341
|
+
if (meshPromise) {
|
|
2342
|
+
pending.push(meshPromise);
|
|
2343
|
+
}
|
|
2344
|
+
if (nodeDef.camera !== void 0) {
|
|
2345
|
+
pending.push(parser.getDependency("camera", nodeDef.camera).then(function(camera) {
|
|
2346
|
+
return parser._getNodeRef(parser.cameraCache, nodeDef.camera, camera);
|
|
2347
|
+
}));
|
|
2348
|
+
}
|
|
2349
|
+
parser._invokeAll(function(ext) {
|
|
2350
|
+
return ext.createNodeAttachment && ext.createNodeAttachment(nodeIndex);
|
|
2351
|
+
}).forEach(function(promise) {
|
|
2352
|
+
pending.push(promise);
|
|
2353
|
+
});
|
|
2354
|
+
this.nodeCache[nodeIndex] = Promise.all(pending).then(function(objects) {
|
|
2355
|
+
let node;
|
|
2356
|
+
if (nodeDef.isBone === true) {
|
|
2357
|
+
node = new chunkSQY54X47_js.Bone();
|
|
2358
|
+
} else if (objects.length > 1) {
|
|
2359
|
+
node = new chunkSQY54X47_js.Group();
|
|
2360
|
+
} else if (objects.length === 1) {
|
|
2361
|
+
node = objects[0];
|
|
2362
|
+
} else {
|
|
2363
|
+
node = new chunkSQY54X47_js.Object3D();
|
|
2364
|
+
}
|
|
2365
|
+
if (node !== objects[0]) {
|
|
2366
|
+
for (let i = 0, il = objects.length; i < il; i++) {
|
|
2367
|
+
node.add(objects[i]);
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
if (nodeDef.name) {
|
|
2371
|
+
node.userData.name = nodeDef.name;
|
|
2372
|
+
node.name = nodeName;
|
|
2373
|
+
}
|
|
2374
|
+
assignExtrasToUserData(node, nodeDef);
|
|
2375
|
+
if (nodeDef.extensions) addUnknownExtensionsToUserData(extensions, node, nodeDef);
|
|
2376
|
+
if (nodeDef.matrix !== void 0) {
|
|
2377
|
+
const matrix = new chunkSQY54X47_js.Matrix4();
|
|
2378
|
+
matrix.fromArray(nodeDef.matrix);
|
|
2379
|
+
node.applyMatrix4(matrix);
|
|
2380
|
+
} else {
|
|
2381
|
+
if (nodeDef.translation !== void 0) {
|
|
2382
|
+
node.position.fromArray(nodeDef.translation);
|
|
2383
|
+
}
|
|
2384
|
+
if (nodeDef.rotation !== void 0) {
|
|
2385
|
+
node.quaternion.fromArray(nodeDef.rotation);
|
|
2386
|
+
}
|
|
2387
|
+
if (nodeDef.scale !== void 0) {
|
|
2388
|
+
node.scale.fromArray(nodeDef.scale);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
if (!parser.associations.has(node)) {
|
|
2392
|
+
parser.associations.set(node, {});
|
|
2393
|
+
} else if (nodeDef.mesh !== void 0 && parser.meshCache.refs[nodeDef.mesh] > 1) {
|
|
2394
|
+
const mapping = parser.associations.get(node);
|
|
2395
|
+
parser.associations.set(node, { ...mapping });
|
|
2396
|
+
}
|
|
2397
|
+
parser.associations.get(node).nodes = nodeIndex;
|
|
2398
|
+
return node;
|
|
2399
|
+
});
|
|
2400
|
+
return this.nodeCache[nodeIndex];
|
|
2401
|
+
}
|
|
2402
|
+
/**
|
|
2403
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
|
|
2404
|
+
*
|
|
2405
|
+
* @private
|
|
2406
|
+
* @param {number} sceneIndex
|
|
2407
|
+
* @return {Promise<Group>}
|
|
2408
|
+
*/
|
|
2409
|
+
loadScene(sceneIndex) {
|
|
2410
|
+
const extensions = this.extensions;
|
|
2411
|
+
const sceneDef = this.json.scenes[sceneIndex];
|
|
2412
|
+
const parser = this;
|
|
2413
|
+
const scene = new chunkSQY54X47_js.Group();
|
|
2414
|
+
if (sceneDef.name) scene.name = parser.createUniqueName(sceneDef.name);
|
|
2415
|
+
assignExtrasToUserData(scene, sceneDef);
|
|
2416
|
+
if (sceneDef.extensions) addUnknownExtensionsToUserData(extensions, scene, sceneDef);
|
|
2417
|
+
const nodeIds = sceneDef.nodes || [];
|
|
2418
|
+
const pending = [];
|
|
2419
|
+
for (let i = 0, il = nodeIds.length; i < il; i++) {
|
|
2420
|
+
pending.push(parser.getDependency("node", nodeIds[i]));
|
|
2421
|
+
}
|
|
2422
|
+
return Promise.all(pending).then(function(nodes) {
|
|
2423
|
+
for (let i = 0, il = nodes.length; i < il; i++) {
|
|
2424
|
+
const node = nodes[i];
|
|
2425
|
+
if (node.parent !== null) {
|
|
2426
|
+
scene.add(clone(node));
|
|
2427
|
+
} else {
|
|
2428
|
+
scene.add(node);
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
const reduceAssociations = (node) => {
|
|
2432
|
+
const reducedAssociations = /* @__PURE__ */ new Map();
|
|
2433
|
+
for (const [key, value] of parser.associations) {
|
|
2434
|
+
if (key instanceof chunkSQY54X47_js.Material || key instanceof chunkSQY54X47_js.Texture) {
|
|
2435
|
+
reducedAssociations.set(key, value);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
node.traverse((node2) => {
|
|
2439
|
+
const mappings = parser.associations.get(node2);
|
|
2440
|
+
if (mappings != null) {
|
|
2441
|
+
reducedAssociations.set(node2, mappings);
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
return reducedAssociations;
|
|
2445
|
+
};
|
|
2446
|
+
parser.associations = reduceAssociations(scene);
|
|
2447
|
+
return scene;
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
_createAnimationTracks(node, inputAccessor, outputAccessor, sampler, target) {
|
|
2451
|
+
const tracks = [];
|
|
2452
|
+
const targetName = node.name ? node.name : node.uuid;
|
|
2453
|
+
const targetNames = [];
|
|
2454
|
+
function collectMorphTargets(object) {
|
|
2455
|
+
if (object.morphTargetInfluences) {
|
|
2456
|
+
targetNames.push(object.name ? object.name : object.uuid);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {
|
|
2460
|
+
collectMorphTargets(node);
|
|
2461
|
+
if (node.isGroup) {
|
|
2462
|
+
node.children.forEach(collectMorphTargets);
|
|
2463
|
+
}
|
|
2464
|
+
} else {
|
|
2465
|
+
targetNames.push(targetName);
|
|
2466
|
+
}
|
|
2467
|
+
let TypedKeyframeTrack;
|
|
2468
|
+
switch (PATH_PROPERTIES[target.path]) {
|
|
2469
|
+
case PATH_PROPERTIES.weights:
|
|
2470
|
+
TypedKeyframeTrack = chunkSQY54X47_js.NumberKeyframeTrack;
|
|
2471
|
+
break;
|
|
2472
|
+
case PATH_PROPERTIES.rotation:
|
|
2473
|
+
TypedKeyframeTrack = chunkSQY54X47_js.QuaternionKeyframeTrack;
|
|
2474
|
+
break;
|
|
2475
|
+
case PATH_PROPERTIES.translation:
|
|
2476
|
+
case PATH_PROPERTIES.scale:
|
|
2477
|
+
TypedKeyframeTrack = chunkSQY54X47_js.VectorKeyframeTrack;
|
|
2478
|
+
break;
|
|
2479
|
+
default:
|
|
2480
|
+
switch (outputAccessor.itemSize) {
|
|
2481
|
+
case 1:
|
|
2482
|
+
TypedKeyframeTrack = chunkSQY54X47_js.NumberKeyframeTrack;
|
|
2483
|
+
break;
|
|
2484
|
+
case 2:
|
|
2485
|
+
case 3:
|
|
2486
|
+
default:
|
|
2487
|
+
TypedKeyframeTrack = chunkSQY54X47_js.VectorKeyframeTrack;
|
|
2488
|
+
break;
|
|
2489
|
+
}
|
|
2490
|
+
break;
|
|
2491
|
+
}
|
|
2492
|
+
const interpolation = sampler.interpolation !== void 0 ? INTERPOLATION[sampler.interpolation] : chunkSQY54X47_js.InterpolateLinear;
|
|
2493
|
+
const outputArray = this._getArrayFromAccessor(outputAccessor);
|
|
2494
|
+
for (let j = 0, jl = targetNames.length; j < jl; j++) {
|
|
2495
|
+
const track = new TypedKeyframeTrack(
|
|
2496
|
+
targetNames[j] + "." + PATH_PROPERTIES[target.path],
|
|
2497
|
+
inputAccessor.array,
|
|
2498
|
+
outputArray,
|
|
2499
|
+
interpolation
|
|
2500
|
+
);
|
|
2501
|
+
if (sampler.interpolation === "CUBICSPLINE") {
|
|
2502
|
+
this._createCubicSplineTrackInterpolant(track);
|
|
2503
|
+
}
|
|
2504
|
+
tracks.push(track);
|
|
2505
|
+
}
|
|
2506
|
+
return tracks;
|
|
2507
|
+
}
|
|
2508
|
+
_getArrayFromAccessor(accessor) {
|
|
2509
|
+
let outputArray = accessor.array;
|
|
2510
|
+
if (accessor.normalized) {
|
|
2511
|
+
const scale = getNormalizedComponentScale(outputArray.constructor);
|
|
2512
|
+
const scaled = new Float32Array(outputArray.length);
|
|
2513
|
+
for (let j = 0, jl = outputArray.length; j < jl; j++) {
|
|
2514
|
+
scaled[j] = outputArray[j] * scale;
|
|
2515
|
+
}
|
|
2516
|
+
outputArray = scaled;
|
|
2517
|
+
}
|
|
2518
|
+
return outputArray;
|
|
2519
|
+
}
|
|
2520
|
+
_createCubicSplineTrackInterpolant(track) {
|
|
2521
|
+
track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {
|
|
2522
|
+
const interpolantType = this instanceof chunkSQY54X47_js.QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
|
|
2523
|
+
return new interpolantType(this.times, this.values, this.getValueSize() / 3, result);
|
|
2524
|
+
};
|
|
2525
|
+
track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2528
|
+
function computeBounds(geometry, primitiveDef, parser) {
|
|
2529
|
+
const attributes = primitiveDef.attributes;
|
|
2530
|
+
const box = new chunkSQY54X47_js.Box3();
|
|
2531
|
+
if (attributes.POSITION !== void 0) {
|
|
2532
|
+
const accessor = parser.json.accessors[attributes.POSITION];
|
|
2533
|
+
const min = accessor.min;
|
|
2534
|
+
const max = accessor.max;
|
|
2535
|
+
if (min !== void 0 && max !== void 0) {
|
|
2536
|
+
box.set(
|
|
2537
|
+
new chunkSQY54X47_js.Vector3(min[0], min[1], min[2]),
|
|
2538
|
+
new chunkSQY54X47_js.Vector3(max[0], max[1], max[2])
|
|
2539
|
+
);
|
|
2540
|
+
if (accessor.normalized) {
|
|
2541
|
+
const boxScale = getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[accessor.componentType]);
|
|
2542
|
+
box.min.multiplyScalar(boxScale);
|
|
2543
|
+
box.max.multiplyScalar(boxScale);
|
|
2544
|
+
}
|
|
2545
|
+
} else {
|
|
2546
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
} else {
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
2552
|
+
const targets = primitiveDef.targets;
|
|
2553
|
+
if (targets !== void 0) {
|
|
2554
|
+
const maxDisplacement = new chunkSQY54X47_js.Vector3();
|
|
2555
|
+
const vector = new chunkSQY54X47_js.Vector3();
|
|
2556
|
+
for (let i = 0, il = targets.length; i < il; i++) {
|
|
2557
|
+
const target = targets[i];
|
|
2558
|
+
if (target.POSITION !== void 0) {
|
|
2559
|
+
const accessor = parser.json.accessors[target.POSITION];
|
|
2560
|
+
const min = accessor.min;
|
|
2561
|
+
const max = accessor.max;
|
|
2562
|
+
if (min !== void 0 && max !== void 0) {
|
|
2563
|
+
vector.setX(Math.max(Math.abs(min[0]), Math.abs(max[0])));
|
|
2564
|
+
vector.setY(Math.max(Math.abs(min[1]), Math.abs(max[1])));
|
|
2565
|
+
vector.setZ(Math.max(Math.abs(min[2]), Math.abs(max[2])));
|
|
2566
|
+
if (accessor.normalized) {
|
|
2567
|
+
const boxScale = getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[accessor.componentType]);
|
|
2568
|
+
vector.multiplyScalar(boxScale);
|
|
2569
|
+
}
|
|
2570
|
+
maxDisplacement.max(vector);
|
|
2571
|
+
} else {
|
|
2572
|
+
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
box.expandByVector(maxDisplacement);
|
|
2577
|
+
}
|
|
2578
|
+
geometry.boundingBox = box;
|
|
2579
|
+
const sphere = new chunkSQY54X47_js.Sphere();
|
|
2580
|
+
box.getCenter(sphere.center);
|
|
2581
|
+
sphere.radius = box.min.distanceTo(box.max) / 2;
|
|
2582
|
+
geometry.boundingSphere = sphere;
|
|
2583
|
+
}
|
|
2584
|
+
function addPrimitiveAttributes(geometry, primitiveDef, parser) {
|
|
2585
|
+
const attributes = primitiveDef.attributes;
|
|
2586
|
+
const pending = [];
|
|
2587
|
+
function assignAttributeAccessor(accessorIndex, attributeName) {
|
|
2588
|
+
return parser.getDependency("accessor", accessorIndex).then(function(accessor) {
|
|
2589
|
+
geometry.setAttribute(attributeName, accessor);
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
for (const gltfAttributeName in attributes) {
|
|
2593
|
+
const threeAttributeName = ATTRIBUTES[gltfAttributeName] || gltfAttributeName.toLowerCase();
|
|
2594
|
+
if (threeAttributeName in geometry.attributes) continue;
|
|
2595
|
+
pending.push(assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName));
|
|
2596
|
+
}
|
|
2597
|
+
if (primitiveDef.indices !== void 0 && !geometry.index) {
|
|
2598
|
+
const accessor = parser.getDependency("accessor", primitiveDef.indices).then(function(accessor2) {
|
|
2599
|
+
geometry.setIndex(accessor2);
|
|
2600
|
+
});
|
|
2601
|
+
pending.push(accessor);
|
|
2602
|
+
}
|
|
2603
|
+
if (chunkSQY54X47_js.ColorManagement.workingColorSpace !== chunkSQY54X47_js.LinearSRGBColorSpace && "COLOR_0" in attributes) {
|
|
2604
|
+
console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${chunkSQY54X47_js.ColorManagement.workingColorSpace}" not supported.`);
|
|
2605
|
+
}
|
|
2606
|
+
assignExtrasToUserData(geometry, primitiveDef);
|
|
2607
|
+
computeBounds(geometry, primitiveDef, parser);
|
|
2608
|
+
return Promise.all(pending).then(function() {
|
|
2609
|
+
return primitiveDef.targets !== void 0 ? addMorphTargets(geometry, primitiveDef.targets, parser) : geometry;
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
exports.GLTFLoader = GLTFLoader;
|