@babylonjs/loaders 5.0.0-rc.2 → 5.0.0-rc.5
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/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +7 -6
- package/OBJ/mtlFileLoader.js +15 -14
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +11 -18
- package/OBJ/objFileLoader.js +19 -23
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +6 -5
- package/OBJ/solidParser.js +15 -21
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +7 -14
- package/STL/stlFileLoader.js +15 -21
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +4 -4
- package/glTF/1.0/glTFBinaryExtension.js +4 -5
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +80 -50
- package/glTF/1.0/glTFLoader.js +265 -146
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +10 -10
- package/glTF/1.0/glTFLoaderInterfaces.js +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +25 -25
- package/glTF/1.0/glTFLoaderUtils.js +70 -52
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +2 -2
- package/glTF/1.0/glTFMaterialsCommonExtension.js +13 -11
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +11 -4
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +9 -2
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +13 -5
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +12 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +12 -4
- package/glTF/2.0/Extensions/EXT_texture_webp.js +11 -3
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +26 -8
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -4
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +14 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +17 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +11 -3
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_specular.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +11 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +24 -13
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +17 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js +19 -8
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_volume.js +12 -5
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +5 -3
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +11 -3
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_transform.js +10 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +23 -7
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +38 -14
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +45 -11
- package/glTF/2.0/Extensions/MSFT_lod.js +44 -8
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +70 -22
- package/glTF/2.0/glTFLoader.js +180 -93
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +11 -11
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +7 -7
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +87 -27
- package/glTF/glTFFileLoader.js +102 -45
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +1 -1
- package/glTF/glTFValidation.js +12 -12
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.js.map +1 -1
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +1 -1
- package/legacy/legacy-glTF1.js +2 -2
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.js +1 -0
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +1 -1
- package/legacy/legacy-glTF2.js +11 -11
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.js +1 -0
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.js +1 -0
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +3 -3
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +3 -3
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +2 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +23 -198
- package/readme.md +2 -2
package/glTF/1.0/glTFLoader.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
|
+
import { EParameterType, ETextureFilterType, ECullingType, EBlendingFunction, EShaderType, } from "./glTFLoaderInterfaces.js";
|
2
3
|
import { Quaternion, Vector3, Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
3
|
-
import { Color3 } from
|
4
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
5
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
5
6
|
import { Camera } from "@babylonjs/core/Cameras/camera.js";
|
6
7
|
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera.js";
|
@@ -25,11 +26,11 @@ import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
|
|
25
26
|
import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
|
26
27
|
import { GLTFUtils } from "./glTFLoaderUtils.js";
|
27
28
|
import { GLTFFileLoader } from "../glTFFileLoader.js";
|
28
|
-
import { Constants } from
|
29
|
+
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
29
30
|
/**
|
30
|
-
* Tokenizer. Used for shaders compatibility
|
31
|
-
* Automatically map world, view, projection, worldViewProjection, attributes and so on
|
32
|
-
*/
|
31
|
+
* Tokenizer. Used for shaders compatibility
|
32
|
+
* Automatically map world, view, projection, worldViewProjection, attributes and so on
|
33
|
+
*/
|
33
34
|
var ETokenType;
|
34
35
|
(function (ETokenType) {
|
35
36
|
ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER";
|
@@ -55,7 +56,7 @@ var Tokenizer = /** @class */ (function () {
|
|
55
56
|
if (this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString)) {
|
56
57
|
this.currentToken = ETokenType.IDENTIFIER;
|
57
58
|
this.currentIdentifier = this.currentString;
|
58
|
-
while (!this.isEnd() && (this.isLetterOrDigitPattern.test(this.currentString = this.peek()) || this.currentString === "_")) {
|
59
|
+
while (!this.isEnd() && (this.isLetterOrDigitPattern.test((this.currentString = this.peek())) || this.currentString === "_")) {
|
59
60
|
this.currentIdentifier += this.currentString;
|
60
61
|
this.forward();
|
61
62
|
}
|
@@ -77,15 +78,17 @@ var Tokenizer = /** @class */ (function () {
|
|
77
78
|
return Tokenizer;
|
78
79
|
}());
|
79
80
|
/**
|
80
|
-
* Values
|
81
|
-
*/
|
81
|
+
* Values
|
82
|
+
*/
|
82
83
|
var glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"];
|
83
84
|
var babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"];
|
84
85
|
var glTFAnimationPaths = ["translation", "rotation", "scale"];
|
85
86
|
var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"];
|
86
87
|
/**
|
87
|
-
* Parse
|
88
|
-
|
88
|
+
* Parse
|
89
|
+
* @param parsedBuffers
|
90
|
+
* @param gltfRuntime
|
91
|
+
*/
|
89
92
|
var parseBuffers = function (parsedBuffers, gltfRuntime) {
|
90
93
|
for (var buf in parsedBuffers) {
|
91
94
|
var parsedBuffer = parsedBuffers[buf];
|
@@ -107,8 +110,9 @@ var parseObject = function (parsedObjects, runtimeProperty, gltfRuntime) {
|
|
107
110
|
}
|
108
111
|
};
|
109
112
|
/**
|
110
|
-
* Utils
|
111
|
-
|
113
|
+
* Utils
|
114
|
+
* @param buffer
|
115
|
+
*/
|
112
116
|
var normalizeUVs = function (buffer) {
|
113
117
|
if (!buffer) {
|
114
118
|
return;
|
@@ -140,8 +144,9 @@ var getAttribute = function (attributeParameter) {
|
|
140
144
|
return null;
|
141
145
|
};
|
142
146
|
/**
|
143
|
-
* Loads and creates animations
|
144
|
-
|
147
|
+
* Loads and creates animations
|
148
|
+
* @param gltfRuntime
|
149
|
+
*/
|
145
150
|
var loadAnimations = function (gltfRuntime) {
|
146
151
|
for (var anim in gltfRuntime.animations) {
|
147
152
|
var animation = gltfRuntime.animations[anim];
|
@@ -212,11 +217,13 @@ var loadAnimations = function (gltfRuntime) {
|
|
212
217
|
// For each frame
|
213
218
|
for (var j = 0; j < bufferInput.length; j++) {
|
214
219
|
var value = null;
|
215
|
-
if (targetPath === "rotationQuaternion") {
|
220
|
+
if (targetPath === "rotationQuaternion") {
|
221
|
+
// VEC4
|
216
222
|
value = Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);
|
217
223
|
arrayOffset += 4;
|
218
224
|
}
|
219
|
-
else {
|
225
|
+
else {
|
226
|
+
// Position and scaling are VEC3
|
220
227
|
value = Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);
|
221
228
|
arrayOffset += 3;
|
222
229
|
}
|
@@ -245,7 +252,7 @@ var loadAnimations = function (gltfRuntime) {
|
|
245
252
|
if (!modifyKey) {
|
246
253
|
keys.push({
|
247
254
|
frame: bufferInput[j],
|
248
|
-
value: value
|
255
|
+
value: value,
|
249
256
|
});
|
250
257
|
}
|
251
258
|
else if (lastAnimation) {
|
@@ -264,8 +271,9 @@ var loadAnimations = function (gltfRuntime) {
|
|
264
271
|
}
|
265
272
|
};
|
266
273
|
/**
|
267
|
-
* Returns the bones transformation matrix
|
268
|
-
|
274
|
+
* Returns the bones transformation matrix
|
275
|
+
* @param node
|
276
|
+
*/
|
269
277
|
var configureBoneTransformation = function (node) {
|
270
278
|
var mat = null;
|
271
279
|
if (node.translation || node.rotation || node.scale) {
|
@@ -280,8 +288,12 @@ var configureBoneTransformation = function (node) {
|
|
280
288
|
return mat;
|
281
289
|
};
|
282
290
|
/**
|
283
|
-
* Returns the parent bone
|
284
|
-
|
291
|
+
* Returns the parent bone
|
292
|
+
* @param gltfRuntime
|
293
|
+
* @param skins
|
294
|
+
* @param jointName
|
295
|
+
* @param newSkeleton
|
296
|
+
*/
|
285
297
|
var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) {
|
286
298
|
// Try to find
|
287
299
|
for (var i = 0; i < newSkeleton.bones.length; i++) {
|
@@ -313,8 +325,10 @@ var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) {
|
|
313
325
|
return null;
|
314
326
|
};
|
315
327
|
/**
|
316
|
-
* Returns the appropriate root node
|
317
|
-
|
328
|
+
* Returns the appropriate root node
|
329
|
+
* @param nodesToRoot
|
330
|
+
* @param id
|
331
|
+
*/
|
318
332
|
var getNodeToRoot = function (nodesToRoot, id) {
|
319
333
|
for (var i = 0; i < nodesToRoot.length; i++) {
|
320
334
|
var nodeToRoot = nodesToRoot[i];
|
@@ -328,15 +342,17 @@ var getNodeToRoot = function (nodesToRoot, id) {
|
|
328
342
|
return null;
|
329
343
|
};
|
330
344
|
/**
|
331
|
-
* Returns the node with the joint name
|
332
|
-
|
345
|
+
* Returns the node with the joint name
|
346
|
+
* @param gltfRuntime
|
347
|
+
* @param jointName
|
348
|
+
*/
|
333
349
|
var getJointNode = function (gltfRuntime, jointName) {
|
334
350
|
var nodes = gltfRuntime.nodes;
|
335
351
|
var node = nodes[jointName];
|
336
352
|
if (node) {
|
337
353
|
return {
|
338
354
|
node: node,
|
339
|
-
id: jointName
|
355
|
+
id: jointName,
|
340
356
|
};
|
341
357
|
}
|
342
358
|
for (var nde in nodes) {
|
@@ -344,15 +360,17 @@ var getJointNode = function (gltfRuntime, jointName) {
|
|
344
360
|
if (node.jointName === jointName) {
|
345
361
|
return {
|
346
362
|
node: node,
|
347
|
-
id: nde
|
363
|
+
id: nde,
|
348
364
|
};
|
349
365
|
}
|
350
366
|
}
|
351
367
|
return null;
|
352
368
|
};
|
353
369
|
/**
|
354
|
-
* Checks if a nodes is in joints
|
355
|
-
|
370
|
+
* Checks if a nodes is in joints
|
371
|
+
* @param skins
|
372
|
+
* @param id
|
373
|
+
*/
|
356
374
|
var nodeIsInJoints = function (skins, id) {
|
357
375
|
for (var i = 0; i < skins.jointNames.length; i++) {
|
358
376
|
if (skins.jointNames[i] === id) {
|
@@ -362,8 +380,12 @@ var nodeIsInJoints = function (skins, id) {
|
|
362
380
|
return false;
|
363
381
|
};
|
364
382
|
/**
|
365
|
-
* Fills the nodes to root for bones and builds hierarchy
|
366
|
-
|
383
|
+
* Fills the nodes to root for bones and builds hierarchy
|
384
|
+
* @param gltfRuntime
|
385
|
+
* @param newSkeleton
|
386
|
+
* @param skins
|
387
|
+
* @param nodesToRoot
|
388
|
+
*/
|
367
389
|
var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) {
|
368
390
|
// Creates nodes for root
|
369
391
|
for (var nde in gltfRuntime.nodes) {
|
@@ -398,9 +420,13 @@ var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) {
|
|
398
420
|
}
|
399
421
|
};
|
400
422
|
/**
|
401
|
-
* Imports a skeleton
|
402
|
-
|
403
|
-
|
423
|
+
* Imports a skeleton
|
424
|
+
* @param gltfRuntime
|
425
|
+
* @param skins
|
426
|
+
* @param mesh
|
427
|
+
* @param newSkeleton
|
428
|
+
*/
|
429
|
+
var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton) {
|
404
430
|
if (!newSkeleton) {
|
405
431
|
newSkeleton = new Skeleton(skins.name || "", "", gltfRuntime.scene);
|
406
432
|
}
|
@@ -495,8 +521,13 @@ var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton, id) {
|
|
495
521
|
return newSkeleton;
|
496
522
|
};
|
497
523
|
/**
|
498
|
-
* Imports a mesh and its geometries
|
499
|
-
|
524
|
+
* Imports a mesh and its geometries
|
525
|
+
* @param gltfRuntime
|
526
|
+
* @param node
|
527
|
+
* @param meshes
|
528
|
+
* @param id
|
529
|
+
* @param newMesh
|
530
|
+
*/
|
500
531
|
var importMesh = function (gltfRuntime, node, meshes, id, newMesh) {
|
501
532
|
if (!newMesh) {
|
502
533
|
gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
|
@@ -557,7 +588,7 @@ var importMesh = function (gltfRuntime, node, meshes, id, newMesh) {
|
|
557
588
|
}
|
558
589
|
else if (semantic.indexOf("TEXCOORD_") !== -1) {
|
559
590
|
var channel = Number(semantic.split("_")[1]);
|
560
|
-
var uvKind = VertexBuffer.UVKind + (channel === 0 ? "" :
|
591
|
+
var uvKind = VertexBuffer.UVKind + (channel === 0 ? "" : channel + 1);
|
561
592
|
var uvs = new Float32Array(buffer.length);
|
562
593
|
uvs.set(buffer);
|
563
594
|
normalizeUVs(uvs);
|
@@ -648,8 +679,12 @@ var importMesh = function (gltfRuntime, node, meshes, id, newMesh) {
|
|
648
679
|
return newMesh;
|
649
680
|
};
|
650
681
|
/**
|
651
|
-
* Configure node transformation from position, rotation and scaling
|
652
|
-
|
682
|
+
* Configure node transformation from position, rotation and scaling
|
683
|
+
* @param newNode
|
684
|
+
* @param position
|
685
|
+
* @param rotation
|
686
|
+
* @param scaling
|
687
|
+
*/
|
653
688
|
var configureNode = function (newNode, position, rotation, scaling) {
|
654
689
|
if (newNode.position) {
|
655
690
|
newNode.position = position;
|
@@ -662,9 +697,11 @@ var configureNode = function (newNode, position, rotation, scaling) {
|
|
662
697
|
}
|
663
698
|
};
|
664
699
|
/**
|
665
|
-
* Configures node from transformation matrix
|
666
|
-
|
667
|
-
|
700
|
+
* Configures node from transformation matrix
|
701
|
+
* @param newNode
|
702
|
+
* @param node
|
703
|
+
*/
|
704
|
+
var configureNodeFromMatrix = function (newNode, node) {
|
668
705
|
if (node.matrix) {
|
669
706
|
var position = new Vector3(0, 0, 0);
|
670
707
|
var rotation = new Quaternion();
|
@@ -679,9 +716,12 @@ var configureNodeFromMatrix = function (newNode, node, parent) {
|
|
679
716
|
newNode.computeWorldMatrix(true);
|
680
717
|
};
|
681
718
|
/**
|
682
|
-
* Imports a node
|
683
|
-
|
684
|
-
|
719
|
+
* Imports a node
|
720
|
+
* @param gltfRuntime
|
721
|
+
* @param node
|
722
|
+
* @param id
|
723
|
+
*/
|
724
|
+
var importNode = function (gltfRuntime, node, id) {
|
685
725
|
var lastNode = null;
|
686
726
|
if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {
|
687
727
|
if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) {
|
@@ -695,7 +735,7 @@ var importNode = function (gltfRuntime, node, id, parent) {
|
|
695
735
|
var newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);
|
696
736
|
newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin);
|
697
737
|
if (newMesh.skeleton === null) {
|
698
|
-
newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton
|
738
|
+
newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton);
|
699
739
|
if (!skin.babylonSkeleton) {
|
700
740
|
skin.babylonSkeleton = newMesh.skeleton;
|
701
741
|
}
|
@@ -705,8 +745,8 @@ var importNode = function (gltfRuntime, node, id, parent) {
|
|
705
745
|
}
|
706
746
|
else if (node.meshes) {
|
707
747
|
/**
|
708
|
-
|
709
|
-
|
748
|
+
* Improve meshes property
|
749
|
+
*/
|
710
750
|
var newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);
|
711
751
|
lastNode = newMesh;
|
712
752
|
}
|
@@ -805,7 +845,7 @@ var importNode = function (gltfRuntime, node, id, parent) {
|
|
805
845
|
}
|
806
846
|
if (lastNode !== null) {
|
807
847
|
if (node.matrix && lastNode instanceof Mesh) {
|
808
|
-
configureNodeFromMatrix(lastNode, node
|
848
|
+
configureNodeFromMatrix(lastNode, node);
|
809
849
|
}
|
810
850
|
else {
|
811
851
|
var translation = node.translation || [0, 0, 0];
|
@@ -819,8 +859,12 @@ var importNode = function (gltfRuntime, node, id, parent) {
|
|
819
859
|
return lastNode;
|
820
860
|
};
|
821
861
|
/**
|
822
|
-
* Traverses nodes and creates them
|
823
|
-
|
862
|
+
* Traverses nodes and creates them
|
863
|
+
* @param gltfRuntime
|
864
|
+
* @param id
|
865
|
+
* @param parent
|
866
|
+
* @param meshIncluded
|
867
|
+
*/
|
824
868
|
var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) {
|
825
869
|
if (meshIncluded === void 0) { meshIncluded = false; }
|
826
870
|
var node = gltfRuntime.nodes[id];
|
@@ -837,7 +881,7 @@ var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) {
|
|
837
881
|
meshIncluded = true;
|
838
882
|
}
|
839
883
|
if (!node.jointName && meshIncluded) {
|
840
|
-
newNode = importNode(gltfRuntime, node, id
|
884
|
+
newNode = importNode(gltfRuntime, node, id);
|
841
885
|
if (newNode !== null) {
|
842
886
|
newNode.id = id;
|
843
887
|
newNode.parent = parent;
|
@@ -850,8 +894,9 @@ var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) {
|
|
850
894
|
}
|
851
895
|
};
|
852
896
|
/**
|
853
|
-
* do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)
|
854
|
-
|
897
|
+
* do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)
|
898
|
+
* @param gltfRuntime
|
899
|
+
*/
|
855
900
|
var postLoad = function (gltfRuntime) {
|
856
901
|
// Nodes
|
857
902
|
var currentScene = gltfRuntime.currentScene;
|
@@ -876,8 +921,15 @@ var postLoad = function (gltfRuntime) {
|
|
876
921
|
}
|
877
922
|
};
|
878
923
|
/**
|
879
|
-
* onBind shaderrs callback to set uniforms and matrices
|
880
|
-
|
924
|
+
* onBind shaderrs callback to set uniforms and matrices
|
925
|
+
* @param mesh
|
926
|
+
* @param gltfRuntime
|
927
|
+
* @param unTreatedUniforms
|
928
|
+
* @param shaderMaterial
|
929
|
+
* @param technique
|
930
|
+
* @param material
|
931
|
+
* @param onSuccess
|
932
|
+
*/
|
881
933
|
var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) {
|
882
934
|
var materialValues = material.values || technique.parameters;
|
883
935
|
for (var unif in unTreatedUniforms) {
|
@@ -911,23 +963,24 @@ var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shade
|
|
911
963
|
shaderMaterial.getEffect().setTexture(unif, texture);
|
912
964
|
}
|
913
965
|
else {
|
914
|
-
GLTFUtils.SetUniform(
|
966
|
+
GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type);
|
915
967
|
}
|
916
968
|
}
|
917
969
|
}
|
918
970
|
onSuccess(shaderMaterial);
|
919
971
|
};
|
920
972
|
/**
|
921
|
-
* Prepare uniforms to send the only one time
|
922
|
-
* Loads the appropriate textures
|
923
|
-
|
973
|
+
* Prepare uniforms to send the only one time
|
974
|
+
* Loads the appropriate textures
|
975
|
+
* @param gltfRuntime
|
976
|
+
* @param shaderMaterial
|
977
|
+
* @param technique
|
978
|
+
* @param material
|
979
|
+
*/
|
924
980
|
var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) {
|
925
981
|
var materialValues = material.values || technique.parameters;
|
926
982
|
var techniqueUniforms = technique.uniforms;
|
927
|
-
|
928
|
-
* Prepare values here (not matrices)
|
929
|
-
*/
|
930
|
-
for (var unif in unTreatedUniforms) {
|
983
|
+
var _loop_1 = function (unif) {
|
931
984
|
var uniform = unTreatedUniforms[unif];
|
932
985
|
var type = uniform.type;
|
933
986
|
var value = materialValues[techniqueUniforms[unif]];
|
@@ -936,7 +989,7 @@ var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, techn
|
|
936
989
|
value = uniform.value;
|
937
990
|
}
|
938
991
|
if (!value) {
|
939
|
-
continue;
|
992
|
+
return "continue";
|
940
993
|
}
|
941
994
|
var onLoadTexture = function (uniformName) {
|
942
995
|
return function (texture) {
|
@@ -958,11 +1011,20 @@ var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, techn
|
|
958
1011
|
delete unTreatedUniforms[unif];
|
959
1012
|
}
|
960
1013
|
}
|
1014
|
+
};
|
1015
|
+
/**
|
1016
|
+
* Prepare values here (not matrices)
|
1017
|
+
*/
|
1018
|
+
for (var unif in unTreatedUniforms) {
|
1019
|
+
_loop_1(unif);
|
961
1020
|
}
|
962
1021
|
};
|
963
1022
|
/**
|
964
|
-
* Shader compilation failed
|
965
|
-
|
1023
|
+
* Shader compilation failed
|
1024
|
+
* @param program
|
1025
|
+
* @param shaderMaterial
|
1026
|
+
* @param onError
|
1027
|
+
*/
|
966
1028
|
var onShaderCompileError = function (program, shaderMaterial, onError) {
|
967
1029
|
return function (effect, error) {
|
968
1030
|
shaderMaterial.dispose(true);
|
@@ -970,8 +1032,14 @@ var onShaderCompileError = function (program, shaderMaterial, onError) {
|
|
970
1032
|
};
|
971
1033
|
};
|
972
1034
|
/**
|
973
|
-
* Shader compilation success
|
974
|
-
|
1035
|
+
* Shader compilation success
|
1036
|
+
* @param gltfRuntime
|
1037
|
+
* @param shaderMaterial
|
1038
|
+
* @param technique
|
1039
|
+
* @param material
|
1040
|
+
* @param unTreatedUniforms
|
1041
|
+
* @param onSuccess
|
1042
|
+
*/
|
975
1043
|
var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) {
|
976
1044
|
return function (_) {
|
977
1045
|
prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);
|
@@ -981,8 +1049,10 @@ var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, m
|
|
981
1049
|
};
|
982
1050
|
};
|
983
1051
|
/**
|
984
|
-
* Returns the appropriate uniform if already handled by babylon
|
985
|
-
|
1052
|
+
* Returns the appropriate uniform if already handled by babylon
|
1053
|
+
* @param tokenizer
|
1054
|
+
* @param technique
|
1055
|
+
*/
|
986
1056
|
var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) {
|
987
1057
|
for (var unif in technique.uniforms) {
|
988
1058
|
var uniform = technique.uniforms[unif];
|
@@ -1000,18 +1070,19 @@ var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) {
|
|
1000
1070
|
return tokenizer.currentIdentifier;
|
1001
1071
|
};
|
1002
1072
|
/**
|
1003
|
-
* All shaders loaded. Create materials one by one
|
1004
|
-
|
1073
|
+
* All shaders loaded. Create materials one by one
|
1074
|
+
* @param gltfRuntime
|
1075
|
+
*/
|
1005
1076
|
var importMaterials = function (gltfRuntime) {
|
1006
1077
|
// Create materials
|
1007
1078
|
for (var mat in gltfRuntime.materials) {
|
1008
|
-
GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function (
|
1079
|
+
GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function () { }, function () { });
|
1009
1080
|
}
|
1010
1081
|
};
|
1011
1082
|
/**
|
1012
|
-
* Implementation of the base glTF spec
|
1013
|
-
* @hidden
|
1014
|
-
*/
|
1083
|
+
* Implementation of the base glTF spec
|
1084
|
+
* @hidden
|
1085
|
+
*/
|
1015
1086
|
var GLTFLoaderBase = /** @class */ (function () {
|
1016
1087
|
function GLTFLoaderBase() {
|
1017
1088
|
}
|
@@ -1045,7 +1116,7 @@ var GLTFLoaderBase = /** @class */ (function () {
|
|
1045
1116
|
loadedShaderCount: 0,
|
1046
1117
|
importOnlyMeshes: false,
|
1047
1118
|
dummyNodes: [],
|
1048
|
-
assetContainer: null
|
1119
|
+
assetContainer: null,
|
1049
1120
|
};
|
1050
1121
|
// Parse
|
1051
1122
|
if (parsedData.extensions) {
|
@@ -1145,17 +1216,17 @@ var GLTFLoaderBase = /** @class */ (function () {
|
|
1145
1216
|
});
|
1146
1217
|
}
|
1147
1218
|
};
|
1148
|
-
GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess
|
1219
|
+
GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess) {
|
1149
1220
|
var texture = gltfRuntime.textures[id];
|
1150
1221
|
if (texture.babylonTexture) {
|
1151
1222
|
onSuccess(texture.babylonTexture);
|
1152
1223
|
return;
|
1153
1224
|
}
|
1154
1225
|
var sampler = gltfRuntime.samplers[texture.sampler];
|
1155
|
-
var createMipMaps =
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1226
|
+
var createMipMaps = sampler.minFilter === ETextureFilterType.NEAREST_MIPMAP_NEAREST ||
|
1227
|
+
sampler.minFilter === ETextureFilterType.NEAREST_MIPMAP_LINEAR ||
|
1228
|
+
sampler.minFilter === ETextureFilterType.LINEAR_MIPMAP_NEAREST ||
|
1229
|
+
sampler.minFilter === ETextureFilterType.LINEAR_MIPMAP_LINEAR;
|
1159
1230
|
var samplingMode = Texture.BILINEAR_SAMPLINGMODE;
|
1160
1231
|
var blob = buffer == null ? new Blob() : new Blob([buffer]);
|
1161
1232
|
var blobURL = URL.createObjectURL(blob);
|
@@ -1284,13 +1355,13 @@ var GLTFLoaderBase = /** @class */ (function () {
|
|
1284
1355
|
// Create shader material
|
1285
1356
|
var shaderPath = {
|
1286
1357
|
vertex: program.vertexShader + id,
|
1287
|
-
fragment: program.fragmentShader + id
|
1358
|
+
fragment: program.fragmentShader + id,
|
1288
1359
|
};
|
1289
1360
|
var options = {
|
1290
1361
|
attributes: attributes,
|
1291
1362
|
uniforms: uniforms,
|
1292
1363
|
samplers: samplers,
|
1293
|
-
needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1
|
1364
|
+
needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1,
|
1294
1365
|
};
|
1295
1366
|
Effect.ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader;
|
1296
1367
|
Effect.ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader;
|
@@ -1305,22 +1376,40 @@ var GLTFLoaderBase = /** @class */ (function () {
|
|
1305
1376
|
}
|
1306
1377
|
var blendFunc = functions.blendFuncSeparate;
|
1307
1378
|
if (blendFunc) {
|
1308
|
-
if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&
|
1379
|
+
if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&
|
1380
|
+
blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_ALPHA &&
|
1381
|
+
blendFunc[2] === EBlendingFunction.ONE &&
|
1382
|
+
blendFunc[3] === EBlendingFunction.ONE) {
|
1309
1383
|
shaderMaterial.alphaMode = Constants.ALPHA_COMBINE;
|
1310
1384
|
}
|
1311
|
-
else if (blendFunc[0] === EBlendingFunction.ONE &&
|
1385
|
+
else if (blendFunc[0] === EBlendingFunction.ONE &&
|
1386
|
+
blendFunc[1] === EBlendingFunction.ONE &&
|
1387
|
+
blendFunc[2] === EBlendingFunction.ZERO &&
|
1388
|
+
blendFunc[3] === EBlendingFunction.ONE) {
|
1312
1389
|
shaderMaterial.alphaMode = Constants.ALPHA_ONEONE;
|
1313
1390
|
}
|
1314
|
-
else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&
|
1391
|
+
else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&
|
1392
|
+
blendFunc[1] === EBlendingFunction.ONE &&
|
1393
|
+
blendFunc[2] === EBlendingFunction.ZERO &&
|
1394
|
+
blendFunc[3] === EBlendingFunction.ONE) {
|
1315
1395
|
shaderMaterial.alphaMode = Constants.ALPHA_ADD;
|
1316
1396
|
}
|
1317
|
-
else if (blendFunc[0] === EBlendingFunction.ZERO &&
|
1397
|
+
else if (blendFunc[0] === EBlendingFunction.ZERO &&
|
1398
|
+
blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR &&
|
1399
|
+
blendFunc[2] === EBlendingFunction.ONE &&
|
1400
|
+
blendFunc[3] === EBlendingFunction.ONE) {
|
1318
1401
|
shaderMaterial.alphaMode = Constants.ALPHA_SUBTRACT;
|
1319
1402
|
}
|
1320
|
-
else if (blendFunc[0] === EBlendingFunction.DST_COLOR &&
|
1403
|
+
else if (blendFunc[0] === EBlendingFunction.DST_COLOR &&
|
1404
|
+
blendFunc[1] === EBlendingFunction.ZERO &&
|
1405
|
+
blendFunc[2] === EBlendingFunction.ONE &&
|
1406
|
+
blendFunc[3] === EBlendingFunction.ONE) {
|
1321
1407
|
shaderMaterial.alphaMode = Constants.ALPHA_MULTIPLY;
|
1322
1408
|
}
|
1323
|
-
else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&
|
1409
|
+
else if (blendFunc[0] === EBlendingFunction.SRC_ALPHA &&
|
1410
|
+
blendFunc[1] === EBlendingFunction.ONE_MINUS_SRC_COLOR &&
|
1411
|
+
blendFunc[2] === EBlendingFunction.ONE &&
|
1412
|
+
blendFunc[3] === EBlendingFunction.ONE) {
|
1324
1413
|
shaderMaterial.alphaMode = Constants.ALPHA_MAXIMIZED;
|
1325
1414
|
}
|
1326
1415
|
}
|
@@ -1330,15 +1419,15 @@ var GLTFLoaderBase = /** @class */ (function () {
|
|
1330
1419
|
}());
|
1331
1420
|
export { GLTFLoaderBase };
|
1332
1421
|
/**
|
1333
|
-
* glTF V1 Loader
|
1334
|
-
* @hidden
|
1335
|
-
*/
|
1422
|
+
* glTF V1 Loader
|
1423
|
+
* @hidden
|
1424
|
+
*/
|
1336
1425
|
var GLTFLoader = /** @class */ (function () {
|
1337
1426
|
function GLTFLoader() {
|
1338
1427
|
}
|
1339
1428
|
GLTFLoader.RegisterExtension = function (extension) {
|
1340
1429
|
if (GLTFLoader.Extensions[extension.name]) {
|
1341
|
-
Tools.Error(
|
1430
|
+
Tools.Error('Tool with the same name "' + extension.name + '" already exists');
|
1342
1431
|
return;
|
1343
1432
|
}
|
1344
1433
|
GLTFLoader.Extensions[extension.name] = extension;
|
@@ -1391,7 +1480,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1391
1480
|
onSuccess(meshes, skeletons);
|
1392
1481
|
}
|
1393
1482
|
});
|
1394
|
-
}
|
1483
|
+
});
|
1395
1484
|
if (GLTFFileLoader.IncrementalLoading && onSuccess) {
|
1396
1485
|
onSuccess(meshes, skeletons);
|
1397
1486
|
}
|
@@ -1399,15 +1488,15 @@ var GLTFLoader = /** @class */ (function () {
|
|
1399
1488
|
return true;
|
1400
1489
|
};
|
1401
1490
|
/**
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1491
|
+
* Imports one or more meshes from a loaded gltf file and adds them to the scene
|
1492
|
+
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
1493
|
+
* @param scene the scene the meshes should be added to
|
1494
|
+
* @param assetContainer defines the asset container to use (can be null)
|
1495
|
+
* @param data gltf data containing information of the meshes in a loaded file
|
1496
|
+
* @param rootUrl root url to load from
|
1497
|
+
* @param onProgress event that fires when loading progress has occured
|
1498
|
+
* @returns a promise containg the loaded meshes, particles, skeletons and animations
|
1499
|
+
*/
|
1411
1500
|
GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, assetContainer, data, rootUrl, onProgress) {
|
1412
1501
|
var _this = this;
|
1413
1502
|
return new Promise(function (resolve, reject) {
|
@@ -1419,7 +1508,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1419
1508
|
animationGroups: [],
|
1420
1509
|
lights: [],
|
1421
1510
|
transformNodes: [],
|
1422
|
-
geometries: []
|
1511
|
+
geometries: [],
|
1423
1512
|
});
|
1424
1513
|
}, onProgress, function (message) {
|
1425
1514
|
reject(new Error(message));
|
@@ -1451,13 +1540,13 @@ var GLTFLoader = /** @class */ (function () {
|
|
1451
1540
|
}, onError);
|
1452
1541
|
};
|
1453
1542
|
/**
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1543
|
+
* Imports all objects from a loaded gltf file and adds them to the scene
|
1544
|
+
* @param scene the scene the objects should be added to
|
1545
|
+
* @param data gltf data containing information of the meshes in a loaded file
|
1546
|
+
* @param rootUrl root url to load from
|
1547
|
+
* @param onProgress event that fires when loading progress has occured
|
1548
|
+
* @returns a promise which completes when objects have been loaded to the scene
|
1549
|
+
*/
|
1461
1550
|
GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
|
1462
1551
|
var _this = this;
|
1463
1552
|
return new Promise(function (resolve, reject) {
|
@@ -1500,7 +1589,7 @@ var GLTFLoader = /** @class */ (function () {
|
|
1500
1589
|
onload();
|
1501
1590
|
}
|
1502
1591
|
};
|
1503
|
-
GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad
|
1592
|
+
GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad) {
|
1504
1593
|
var hasBuffers = false;
|
1505
1594
|
var processBuffer = function (buf, buffer) {
|
1506
1595
|
GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, function (bufferView) {
|
@@ -1567,51 +1656,81 @@ var GLTFLoaderExtension = /** @class */ (function () {
|
|
1567
1656
|
configurable: true
|
1568
1657
|
});
|
1569
1658
|
/**
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1659
|
+
* Defines an override for loading the runtime
|
1660
|
+
* Return true to stop further extensions from loading the runtime
|
1661
|
+
* @param scene
|
1662
|
+
* @param data
|
1663
|
+
* @param rootUrl
|
1664
|
+
* @param onSuccess
|
1665
|
+
* @param onError
|
1666
|
+
*/
|
1573
1667
|
GLTFLoaderExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
|
1574
1668
|
return false;
|
1575
1669
|
};
|
1576
1670
|
/**
|
1577
1671
|
* Defines an onverride for creating gltf runtime
|
1578
1672
|
* Return true to stop further extensions from creating the runtime
|
1673
|
+
* @param gltfRuntime
|
1674
|
+
* @param onSuccess
|
1675
|
+
* @param onError
|
1579
1676
|
*/
|
1580
1677
|
GLTFLoaderExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
|
1581
1678
|
return false;
|
1582
1679
|
};
|
1583
1680
|
/**
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1681
|
+
* Defines an override for loading buffers
|
1682
|
+
* Return true to stop further extensions from loading this buffer
|
1683
|
+
* @param gltfRuntime
|
1684
|
+
* @param id
|
1685
|
+
* @param onSuccess
|
1686
|
+
* @param onError
|
1687
|
+
* @param onProgress
|
1688
|
+
*/
|
1587
1689
|
GLTFLoaderExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
|
1588
1690
|
return false;
|
1589
1691
|
};
|
1590
1692
|
/**
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1693
|
+
* Defines an override for loading texture buffers
|
1694
|
+
* Return true to stop further extensions from loading this texture data
|
1695
|
+
* @param gltfRuntime
|
1696
|
+
* @param id
|
1697
|
+
* @param onSuccess
|
1698
|
+
* @param onError
|
1699
|
+
*/
|
1594
1700
|
GLTFLoaderExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1595
1701
|
return false;
|
1596
1702
|
};
|
1597
1703
|
/**
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1704
|
+
* Defines an override for creating textures
|
1705
|
+
* Return true to stop further extensions from loading this texture
|
1706
|
+
* @param gltfRuntime
|
1707
|
+
* @param id
|
1708
|
+
* @param buffer
|
1709
|
+
* @param onSuccess
|
1710
|
+
* @param onError
|
1711
|
+
*/
|
1601
1712
|
GLTFLoaderExtension.prototype.createTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
|
1602
1713
|
return false;
|
1603
1714
|
};
|
1604
1715
|
/**
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1716
|
+
* Defines an override for loading shader strings
|
1717
|
+
* Return true to stop further extensions from loading this shader data
|
1718
|
+
* @param gltfRuntime
|
1719
|
+
* @param id
|
1720
|
+
* @param onSuccess
|
1721
|
+
* @param onError
|
1722
|
+
*/
|
1608
1723
|
GLTFLoaderExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1609
1724
|
return false;
|
1610
1725
|
};
|
1611
1726
|
/**
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1727
|
+
* Defines an override for loading materials
|
1728
|
+
* Return true to stop further extensions from loading this material
|
1729
|
+
* @param gltfRuntime
|
1730
|
+
* @param id
|
1731
|
+
* @param onSuccess
|
1732
|
+
* @param onError
|
1733
|
+
*/
|
1615
1734
|
GLTFLoaderExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1616
1735
|
return false;
|
1617
1736
|
};
|
@@ -1619,7 +1738,7 @@ var GLTFLoaderExtension = /** @class */ (function () {
|
|
1619
1738
|
// Utilities
|
1620
1739
|
// ---------
|
1621
1740
|
GLTFLoaderExtension.LoadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
|
1622
|
-
GLTFLoaderExtension.
|
1741
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1623
1742
|
return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);
|
1624
1743
|
}, function () {
|
1625
1744
|
setTimeout(function () {
|
@@ -1631,7 +1750,7 @@ var GLTFLoaderExtension = /** @class */ (function () {
|
|
1631
1750
|
});
|
1632
1751
|
};
|
1633
1752
|
GLTFLoaderExtension.LoadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
|
1634
|
-
GLTFLoaderExtension.
|
1753
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1635
1754
|
return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);
|
1636
1755
|
}, function () {
|
1637
1756
|
setTimeout(function () {
|
@@ -1640,48 +1759,48 @@ var GLTFLoaderExtension = /** @class */ (function () {
|
|
1640
1759
|
});
|
1641
1760
|
};
|
1642
1761
|
GLTFLoaderExtension.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
|
1643
|
-
GLTFLoaderExtension.
|
1762
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1644
1763
|
return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
|
1645
1764
|
}, function () {
|
1646
1765
|
GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
|
1647
1766
|
});
|
1648
1767
|
};
|
1649
1768
|
GLTFLoaderExtension.LoadTextureAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1650
|
-
GLTFLoaderExtension.
|
1769
|
+
GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
|
1651
1770
|
if (buffer) {
|
1652
|
-
GLTFLoaderExtension.
|
1771
|
+
GLTFLoaderExtension._CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
|
1653
1772
|
}
|
1654
1773
|
}, onError);
|
1655
1774
|
};
|
1656
1775
|
GLTFLoaderExtension.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1657
|
-
GLTFLoaderExtension.
|
1776
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1658
1777
|
return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
|
1659
1778
|
}, function () {
|
1660
1779
|
GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
|
1661
1780
|
});
|
1662
1781
|
};
|
1663
1782
|
GLTFLoaderExtension.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1664
|
-
GLTFLoaderExtension.
|
1783
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1665
1784
|
return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);
|
1666
1785
|
}, function () {
|
1667
1786
|
GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);
|
1668
1787
|
});
|
1669
1788
|
};
|
1670
|
-
GLTFLoaderExtension.
|
1671
|
-
GLTFLoaderExtension.
|
1789
|
+
GLTFLoaderExtension._LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
|
1790
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1672
1791
|
return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
|
1673
1792
|
}, function () {
|
1674
1793
|
GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
|
1675
1794
|
});
|
1676
1795
|
};
|
1677
|
-
GLTFLoaderExtension.
|
1678
|
-
GLTFLoaderExtension.
|
1796
|
+
GLTFLoaderExtension._CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
|
1797
|
+
GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) {
|
1679
1798
|
return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
|
1680
1799
|
}, function () {
|
1681
|
-
GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess
|
1800
|
+
GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess);
|
1682
1801
|
});
|
1683
1802
|
};
|
1684
|
-
GLTFLoaderExtension.
|
1803
|
+
GLTFLoaderExtension._ApplyExtensions = function (func, defaultFunc) {
|
1685
1804
|
for (var extensionName in GLTFLoader.Extensions) {
|
1686
1805
|
var loaderExtension = GLTFLoader.Extensions[extensionName];
|
1687
1806
|
if (func(loaderExtension)) {
|