@babylonjs/loaders 8.5.0 → 8.6.0
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/BVH/bvhFileLoader.d.ts +66 -0
- package/BVH/bvhFileLoader.js +105 -0
- package/BVH/bvhFileLoader.js.map +1 -0
- package/BVH/bvhFileLoader.metadata.d.ts +8 -0
- package/BVH/bvhFileLoader.metadata.js +8 -0
- package/BVH/bvhFileLoader.metadata.js.map +1 -0
- package/BVH/bvhLoader.d.ts +11 -0
- package/BVH/bvhLoader.js +329 -0
- package/BVH/bvhLoader.js.map +1 -0
- package/BVH/bvhLoadingOptions.d.ts +9 -0
- package/BVH/bvhLoadingOptions.js +2 -0
- package/BVH/bvhLoadingOptions.js.map +1 -0
- package/BVH/index.d.ts +1 -0
- package/BVH/index.js +3 -0
- package/BVH/index.js.map +1 -0
- package/OBJ/mtlFileLoader.js +6 -6
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +1 -1
- package/OBJ/objFileLoader.js +2 -2
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/solidParser.js +4 -2
- package/OBJ/solidParser.js.map +1 -1
- package/SPLAT/splatFileLoader.d.ts +2 -2
- package/SPLAT/splatFileLoader.js +7 -7
- package/SPLAT/splatFileLoader.js.map +1 -1
- package/bvh/license.md +21 -0
- package/dynamic.js +9 -0
- package/dynamic.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.js +4 -0
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.js +114 -86
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.js +2 -0
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_ies.js +2 -0
- package/glTF/2.0/Extensions/EXT_lights_ies.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +1 -0
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +1 -0
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +1 -0
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_avif.js +1 -0
- package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +2 -0
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.js +1 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +1 -0
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity.js +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_hoverability.js +7 -6
- package/glTF/2.0/Extensions/KHR_node_hoverability.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_selectability.js +1 -0
- package/glTF/2.0/Extensions/KHR_node_selectability.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_visibility.js +1 -0
- package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +1 -0
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +1 -0
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +6 -6
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +3 -0
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.js +5 -0
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +1 -0
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +2 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/objectModelMapping.js +120 -118
- package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
- package/glTF/2.0/glTFLoader.js +18 -1
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderAnimation.js +3 -0
- package/glTF/2.0/glTFLoaderAnimation.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtensionRegistry.js +7 -4
- package/glTF/2.0/glTFLoaderExtensionRegistry.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +2 -2
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.js +5 -5
- package/glTF/glTFValidation.js.map +1 -1
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.js +5 -5
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF2.js +5 -4
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-objFileLoader.js +4 -4
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.js +4 -4
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/package.json +3 -3
package/glTF/1.0/glTFLoader.js
CHANGED
@@ -30,6 +30,7 @@ import { Constants } from "@babylonjs/core/Engines/constants.js";
|
|
30
30
|
* Tokenizer. Used for shaders compatibility
|
31
31
|
* Automatically map world, view, projection, worldViewProjection, attributes and so on
|
32
32
|
*/
|
33
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
33
34
|
var ETokenType;
|
34
35
|
(function (ETokenType) {
|
35
36
|
ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER";
|
@@ -78,30 +79,32 @@ class Tokenizer {
|
|
78
79
|
/**
|
79
80
|
* Values
|
80
81
|
*/
|
82
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
81
83
|
const glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"];
|
82
|
-
const
|
84
|
+
const BabylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"];
|
85
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
83
86
|
const glTFAnimationPaths = ["translation", "rotation", "scale"];
|
84
|
-
const
|
87
|
+
const BabylonAnimationPaths = ["position", "rotationQuaternion", "scaling"];
|
85
88
|
/**
|
86
89
|
* Parse
|
87
90
|
* @param parsedBuffers
|
88
91
|
* @param gltfRuntime
|
89
92
|
*/
|
90
|
-
const
|
93
|
+
const ParseBuffers = (parsedBuffers, gltfRuntime) => {
|
91
94
|
for (const buf in parsedBuffers) {
|
92
95
|
const parsedBuffer = parsedBuffers[buf];
|
93
96
|
gltfRuntime.buffers[buf] = parsedBuffer;
|
94
97
|
gltfRuntime.buffersCount++;
|
95
98
|
}
|
96
99
|
};
|
97
|
-
const
|
100
|
+
const ParseShaders = (parsedShaders, gltfRuntime) => {
|
98
101
|
for (const sha in parsedShaders) {
|
99
102
|
const parsedShader = parsedShaders[sha];
|
100
103
|
gltfRuntime.shaders[sha] = parsedShader;
|
101
104
|
gltfRuntime.shaderscount++;
|
102
105
|
}
|
103
106
|
};
|
104
|
-
const
|
107
|
+
const ParseObject = (parsedObjects, runtimeProperty, gltfRuntime) => {
|
105
108
|
for (const object in parsedObjects) {
|
106
109
|
const parsedObject = parsedObjects[object];
|
107
110
|
gltfRuntime[runtimeProperty][object] = parsedObject;
|
@@ -111,7 +114,7 @@ const parseObject = (parsedObjects, runtimeProperty, gltfRuntime) => {
|
|
111
114
|
* Utils
|
112
115
|
* @param buffer
|
113
116
|
*/
|
114
|
-
const
|
117
|
+
const NormalizeUVs = (buffer) => {
|
115
118
|
if (!buffer) {
|
116
119
|
return;
|
117
120
|
}
|
@@ -119,7 +122,7 @@ const normalizeUVs = (buffer) => {
|
|
119
122
|
buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1];
|
120
123
|
}
|
121
124
|
};
|
122
|
-
const
|
125
|
+
const GetAttribute = (attributeParameter) => {
|
123
126
|
if (attributeParameter.semantic === "NORMAL") {
|
124
127
|
return "normal";
|
125
128
|
}
|
@@ -145,7 +148,7 @@ const getAttribute = (attributeParameter) => {
|
|
145
148
|
* Loads and creates animations
|
146
149
|
* @param gltfRuntime
|
147
150
|
*/
|
148
|
-
const
|
151
|
+
const LoadAnimations = (gltfRuntime) => {
|
149
152
|
for (const anim in gltfRuntime.animations) {
|
150
153
|
const animation = gltfRuntime.animations[anim];
|
151
154
|
if (!animation.channels || !animation.samplers) {
|
@@ -185,7 +188,7 @@ const loadAnimations = (gltfRuntime) => {
|
|
185
188
|
let targetPath = channel.target.path;
|
186
189
|
const targetPathIndex = glTFAnimationPaths.indexOf(targetPath);
|
187
190
|
if (targetPathIndex !== -1) {
|
188
|
-
targetPath =
|
191
|
+
targetPath = BabylonAnimationPaths[targetPathIndex];
|
189
192
|
}
|
190
193
|
// Determine animation type
|
191
194
|
let animationType = Animation.ANIMATIONTYPE_MATRIX;
|
@@ -272,7 +275,7 @@ const loadAnimations = (gltfRuntime) => {
|
|
272
275
|
* @returns the bones transformation matrix
|
273
276
|
* @param node
|
274
277
|
*/
|
275
|
-
const
|
278
|
+
const ConfigureBoneTransformation = (node) => {
|
276
279
|
let mat = null;
|
277
280
|
if (node.translation || node.rotation || node.scale) {
|
278
281
|
const scale = Vector3.FromArray(node.scale || [1, 1, 1]);
|
@@ -293,7 +296,7 @@ const configureBoneTransformation = (node) => {
|
|
293
296
|
* @param newSkeleton
|
294
297
|
* @returns the parent bone
|
295
298
|
*/
|
296
|
-
const
|
299
|
+
const GetParentBone = (gltfRuntime, skins, jointName, newSkeleton) => {
|
297
300
|
// Try to find
|
298
301
|
for (let i = 0; i < newSkeleton.bones.length; i++) {
|
299
302
|
if (newSkeleton.bones[i].name === jointName) {
|
@@ -314,8 +317,8 @@ const getParentBone = (gltfRuntime, skins, jointName, newSkeleton) => {
|
|
314
317
|
continue;
|
315
318
|
}
|
316
319
|
if (child.jointName === jointName) {
|
317
|
-
const mat =
|
318
|
-
const bone = new Bone(node.name || "", newSkeleton,
|
320
|
+
const mat = ConfigureBoneTransformation(node);
|
321
|
+
const bone = new Bone(node.name || "", newSkeleton, GetParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat);
|
319
322
|
bone.id = nde;
|
320
323
|
return bone;
|
321
324
|
}
|
@@ -329,7 +332,7 @@ const getParentBone = (gltfRuntime, skins, jointName, newSkeleton) => {
|
|
329
332
|
* @param id
|
330
333
|
* @returns the root node
|
331
334
|
*/
|
332
|
-
const
|
335
|
+
const GetNodeToRoot = (nodesToRoot, id) => {
|
333
336
|
for (let i = 0; i < nodesToRoot.length; i++) {
|
334
337
|
const nodeToRoot = nodesToRoot[i];
|
335
338
|
for (let j = 0; j < nodeToRoot.node.children.length; j++) {
|
@@ -347,7 +350,7 @@ const getNodeToRoot = (nodesToRoot, id) => {
|
|
347
350
|
* @param jointName
|
348
351
|
* @returns the node with the joint name
|
349
352
|
*/
|
350
|
-
const
|
353
|
+
const GetJointNode = (gltfRuntime, jointName) => {
|
351
354
|
const nodes = gltfRuntime.nodes;
|
352
355
|
let node = nodes[jointName];
|
353
356
|
if (node) {
|
@@ -373,7 +376,7 @@ const getJointNode = (gltfRuntime, jointName) => {
|
|
373
376
|
* @param id
|
374
377
|
* @returns true if the node is in joints, else false
|
375
378
|
*/
|
376
|
-
const
|
379
|
+
const NodeIsInJoints = (skins, id) => {
|
377
380
|
for (let i = 0; i < skins.jointNames.length; i++) {
|
378
381
|
if (skins.jointNames[i] === id) {
|
379
382
|
return true;
|
@@ -388,16 +391,16 @@ const nodeIsInJoints = (skins, id) => {
|
|
388
391
|
* @param skins
|
389
392
|
* @param nodesToRoot
|
390
393
|
*/
|
391
|
-
const
|
394
|
+
const GetNodesToRoot = (gltfRuntime, newSkeleton, skins, nodesToRoot) => {
|
392
395
|
// Creates nodes for root
|
393
396
|
for (const nde in gltfRuntime.nodes) {
|
394
397
|
const node = gltfRuntime.nodes[nde];
|
395
398
|
const id = nde;
|
396
|
-
if (!node.jointName ||
|
399
|
+
if (!node.jointName || NodeIsInJoints(skins, node.jointName)) {
|
397
400
|
continue;
|
398
401
|
}
|
399
402
|
// Create node to root bone
|
400
|
-
const mat =
|
403
|
+
const mat = ConfigureBoneTransformation(node);
|
401
404
|
const bone = new Bone(node.name || "", newSkeleton, null, mat);
|
402
405
|
bone.id = id;
|
403
406
|
nodesToRoot.push({ bone: bone, node: node, id: id });
|
@@ -429,7 +432,7 @@ const getNodesToRoot = (gltfRuntime, newSkeleton, skins, nodesToRoot) => {
|
|
429
432
|
* @param newSkeleton
|
430
433
|
* @returns the bone name
|
431
434
|
*/
|
432
|
-
const
|
435
|
+
const ImportSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
433
436
|
if (!newSkeleton) {
|
434
437
|
newSkeleton = new Skeleton(skins.name || "", "", gltfRuntime.scene);
|
435
438
|
}
|
@@ -439,11 +442,11 @@ const importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
|
439
442
|
// Find the root bones
|
440
443
|
const nodesToRoot = [];
|
441
444
|
const nodesToRootToAdd = [];
|
442
|
-
|
445
|
+
GetNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot);
|
443
446
|
newSkeleton.bones = [];
|
444
447
|
// Joints
|
445
448
|
for (let i = 0; i < skins.jointNames.length; i++) {
|
446
|
-
const jointNode =
|
449
|
+
const jointNode = GetJointNode(gltfRuntime, skins.jointNames[i]);
|
447
450
|
if (!jointNode) {
|
448
451
|
continue;
|
449
452
|
}
|
@@ -463,7 +466,7 @@ const importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
|
463
466
|
let foundBone = false;
|
464
467
|
let parentBone = null;
|
465
468
|
for (let j = 0; j < i; j++) {
|
466
|
-
const jointNode =
|
469
|
+
const jointNode = GetJointNode(gltfRuntime, skins.jointNames[j]);
|
467
470
|
if (!jointNode) {
|
468
471
|
continue;
|
469
472
|
}
|
@@ -479,7 +482,7 @@ const importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
|
479
482
|
foundBone = false;
|
480
483
|
for (let k = 0; k < children.length; k++) {
|
481
484
|
if (children[k] === id) {
|
482
|
-
parentBone =
|
485
|
+
parentBone = GetParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton);
|
483
486
|
foundBone = true;
|
484
487
|
break;
|
485
488
|
}
|
@@ -489,9 +492,9 @@ const importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
|
489
492
|
}
|
490
493
|
}
|
491
494
|
// Create bone
|
492
|
-
const mat =
|
495
|
+
const mat = ConfigureBoneTransformation(node);
|
493
496
|
if (!parentBone && nodesToRoot.length > 0) {
|
494
|
-
parentBone =
|
497
|
+
parentBone = GetNodeToRoot(nodesToRoot, id);
|
495
498
|
if (parentBone) {
|
496
499
|
if (nodesToRootToAdd.indexOf(parentBone) === -1) {
|
497
500
|
nodesToRootToAdd.push(parentBone);
|
@@ -505,7 +508,7 @@ const importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
|
505
508
|
const bones = newSkeleton.bones;
|
506
509
|
newSkeleton.bones = [];
|
507
510
|
for (let i = 0; i < skins.jointNames.length; i++) {
|
508
|
-
const jointNode =
|
511
|
+
const jointNode = GetJointNode(gltfRuntime, skins.jointNames[i]);
|
509
512
|
if (!jointNode) {
|
510
513
|
continue;
|
511
514
|
}
|
@@ -532,7 +535,7 @@ const importSkeleton = (gltfRuntime, skins, mesh, newSkeleton) => {
|
|
532
535
|
* @param newMesh
|
533
536
|
* @returns the new mesh
|
534
537
|
*/
|
535
|
-
const
|
538
|
+
const ImportMesh = (gltfRuntime, node, meshes, id, newMesh) => {
|
536
539
|
if (!newMesh) {
|
537
540
|
gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
|
538
541
|
newMesh = new Mesh(node.name || "", gltfRuntime.scene);
|
@@ -595,7 +598,7 @@ const importMesh = (gltfRuntime, node, meshes, id, newMesh) => {
|
|
595
598
|
const uvKind = VertexBuffer.UVKind + (channel === 0 ? "" : channel + 1);
|
596
599
|
const uvs = new Float32Array(buffer.length);
|
597
600
|
uvs.set(buffer);
|
598
|
-
|
601
|
+
NormalizeUVs(uvs);
|
599
602
|
tempVertexData.set(uvs, uvKind);
|
600
603
|
}
|
601
604
|
else if (semantic === "JOINT") {
|
@@ -689,7 +692,7 @@ const importMesh = (gltfRuntime, node, meshes, id, newMesh) => {
|
|
689
692
|
* @param rotation
|
690
693
|
* @param scaling
|
691
694
|
*/
|
692
|
-
const
|
695
|
+
const ConfigureNode = (newNode, position, rotation, scaling) => {
|
693
696
|
if (newNode.position) {
|
694
697
|
newNode.position = position;
|
695
698
|
}
|
@@ -705,17 +708,17 @@ const configureNode = (newNode, position, rotation, scaling) => {
|
|
705
708
|
* @param newNode
|
706
709
|
* @param node
|
707
710
|
*/
|
708
|
-
const
|
711
|
+
const ConfigureNodeFromMatrix = (newNode, node) => {
|
709
712
|
if (node.matrix) {
|
710
713
|
const position = new Vector3(0, 0, 0);
|
711
714
|
const rotation = new Quaternion();
|
712
715
|
const scaling = new Vector3(0, 0, 0);
|
713
716
|
const mat = Matrix.FromArray(node.matrix);
|
714
717
|
mat.decompose(scaling, rotation, position);
|
715
|
-
|
718
|
+
ConfigureNode(newNode, position, rotation, scaling);
|
716
719
|
}
|
717
720
|
else if (node.translation && node.rotation && node.scale) {
|
718
|
-
|
721
|
+
ConfigureNode(newNode, Vector3.FromArray(node.translation), Quaternion.FromArray(node.rotation), Vector3.FromArray(node.scale));
|
719
722
|
}
|
720
723
|
newNode.computeWorldMatrix(true);
|
721
724
|
};
|
@@ -726,7 +729,7 @@ const configureNodeFromMatrix = (newNode, node) => {
|
|
726
729
|
* @param id
|
727
730
|
* @returns the newly imported node
|
728
731
|
*/
|
729
|
-
const
|
732
|
+
const ImportNode = (gltfRuntime, node, id) => {
|
730
733
|
let lastNode = null;
|
731
734
|
if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {
|
732
735
|
if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) {
|
@@ -737,10 +740,10 @@ const importNode = (gltfRuntime, node, id) => {
|
|
737
740
|
if (node.skin) {
|
738
741
|
if (node.meshes) {
|
739
742
|
const skin = gltfRuntime.skins[node.skin];
|
740
|
-
const newMesh =
|
743
|
+
const newMesh = ImportMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);
|
741
744
|
newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin);
|
742
745
|
if (newMesh.skeleton === null) {
|
743
|
-
newMesh.skeleton =
|
746
|
+
newMesh.skeleton = ImportSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton);
|
744
747
|
if (!skin.babylonSkeleton) {
|
745
748
|
skin.babylonSkeleton = newMesh.skeleton;
|
746
749
|
}
|
@@ -752,7 +755,7 @@ const importNode = (gltfRuntime, node, id) => {
|
|
752
755
|
/**
|
753
756
|
* Improve meshes property
|
754
757
|
*/
|
755
|
-
const newMesh =
|
758
|
+
const newMesh = ImportMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);
|
756
759
|
lastNode = newMesh;
|
757
760
|
}
|
758
761
|
// Lights
|
@@ -850,13 +853,13 @@ const importNode = (gltfRuntime, node, id) => {
|
|
850
853
|
}
|
851
854
|
if (lastNode !== null) {
|
852
855
|
if (node.matrix && lastNode instanceof Mesh) {
|
853
|
-
|
856
|
+
ConfigureNodeFromMatrix(lastNode, node);
|
854
857
|
}
|
855
858
|
else {
|
856
859
|
const translation = node.translation || [0, 0, 0];
|
857
860
|
const rotation = node.rotation || [0, 0, 0, 1];
|
858
861
|
const scale = node.scale || [1, 1, 1];
|
859
|
-
|
862
|
+
ConfigureNode(lastNode, Vector3.FromArray(translation), Quaternion.FromArray(rotation), Vector3.FromArray(scale));
|
860
863
|
}
|
861
864
|
lastNode.updateCache(true);
|
862
865
|
node.babylonNode = lastNode;
|
@@ -870,7 +873,7 @@ const importNode = (gltfRuntime, node, id) => {
|
|
870
873
|
* @param parent
|
871
874
|
* @param meshIncluded
|
872
875
|
*/
|
873
|
-
const
|
876
|
+
const TraverseNodes = (gltfRuntime, id, parent, meshIncluded = false) => {
|
874
877
|
const node = gltfRuntime.nodes[id];
|
875
878
|
let newNode = null;
|
876
879
|
if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) {
|
@@ -885,7 +888,7 @@ const traverseNodes = (gltfRuntime, id, parent, meshIncluded = false) => {
|
|
885
888
|
meshIncluded = true;
|
886
889
|
}
|
887
890
|
if (!node.jointName && meshIncluded) {
|
888
|
-
newNode =
|
891
|
+
newNode = ImportNode(gltfRuntime, node, id);
|
889
892
|
if (newNode !== null) {
|
890
893
|
newNode.id = id;
|
891
894
|
newNode.parent = parent;
|
@@ -893,7 +896,7 @@ const traverseNodes = (gltfRuntime, id, parent, meshIncluded = false) => {
|
|
893
896
|
}
|
894
897
|
if (node.children) {
|
895
898
|
for (let i = 0; i < node.children.length; i++) {
|
896
|
-
|
899
|
+
TraverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded);
|
897
900
|
}
|
898
901
|
}
|
899
902
|
};
|
@@ -901,24 +904,24 @@ const traverseNodes = (gltfRuntime, id, parent, meshIncluded = false) => {
|
|
901
904
|
* do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)
|
902
905
|
* @param gltfRuntime
|
903
906
|
*/
|
904
|
-
const
|
907
|
+
const PostLoad = (gltfRuntime) => {
|
905
908
|
// Nodes
|
906
909
|
let currentScene = gltfRuntime.currentScene;
|
907
910
|
if (currentScene) {
|
908
911
|
for (let i = 0; i < currentScene.nodes.length; i++) {
|
909
|
-
|
912
|
+
TraverseNodes(gltfRuntime, currentScene.nodes[i], null);
|
910
913
|
}
|
911
914
|
}
|
912
915
|
else {
|
913
916
|
for (const thing in gltfRuntime.scenes) {
|
914
917
|
currentScene = gltfRuntime.scenes[thing];
|
915
918
|
for (let i = 0; i < currentScene.nodes.length; i++) {
|
916
|
-
|
919
|
+
TraverseNodes(gltfRuntime, currentScene.nodes[i], null);
|
917
920
|
}
|
918
921
|
}
|
919
922
|
}
|
920
923
|
// Set animations
|
921
|
-
|
924
|
+
LoadAnimations(gltfRuntime);
|
922
925
|
for (let i = 0; i < gltfRuntime.scene.skeletons.length; i++) {
|
923
926
|
const skeleton = gltfRuntime.scene.skeletons[i];
|
924
927
|
gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0);
|
@@ -934,7 +937,7 @@ const postLoad = (gltfRuntime) => {
|
|
934
937
|
* @param material
|
935
938
|
* @param onSuccess
|
936
939
|
*/
|
937
|
-
const
|
940
|
+
const OnBindShaderMaterial = (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) => {
|
938
941
|
const materialValues = material.values || technique.parameters;
|
939
942
|
for (const unif in unTreatedUniforms) {
|
940
943
|
const uniform = unTreatedUniforms[unif];
|
@@ -981,7 +984,7 @@ const onBindShaderMaterial = (mesh, gltfRuntime, unTreatedUniforms, shaderMateri
|
|
981
984
|
* @param technique
|
982
985
|
* @param material
|
983
986
|
*/
|
984
|
-
const
|
987
|
+
const PrepareShaderMaterialUniforms = (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) => {
|
985
988
|
const materialValues = material.values || technique.parameters;
|
986
989
|
const techniqueUniforms = technique.uniforms;
|
987
990
|
/**
|
@@ -1027,7 +1030,7 @@ const prepareShaderMaterialUniforms = (gltfRuntime, shaderMaterial, technique, m
|
|
1027
1030
|
* @param onError
|
1028
1031
|
* @returns callback when shader is compiled
|
1029
1032
|
*/
|
1030
|
-
const
|
1033
|
+
const OnShaderCompileError = (program, shaderMaterial, onError) => {
|
1031
1034
|
return (effect, error) => {
|
1032
1035
|
shaderMaterial.dispose(true);
|
1033
1036
|
onError("Cannot compile program named " + program.name + ". Error: " + error + ". Default material will be applied");
|
@@ -1043,11 +1046,11 @@ const onShaderCompileError = (program, shaderMaterial, onError) => {
|
|
1043
1046
|
* @param onSuccess
|
1044
1047
|
* @returns callback when shader is compiled
|
1045
1048
|
*/
|
1046
|
-
const
|
1049
|
+
const OnShaderCompileSuccess = (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) => {
|
1047
1050
|
return (_) => {
|
1048
|
-
|
1051
|
+
PrepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);
|
1049
1052
|
shaderMaterial.onBind = (mesh) => {
|
1050
|
-
|
1053
|
+
OnBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess);
|
1051
1054
|
};
|
1052
1055
|
};
|
1053
1056
|
};
|
@@ -1058,7 +1061,7 @@ const onShaderCompileSuccess = (gltfRuntime, shaderMaterial, technique, material
|
|
1058
1061
|
* @param unTreatedUniforms
|
1059
1062
|
* @returns the name of the uniform handled by babylon
|
1060
1063
|
*/
|
1061
|
-
const
|
1064
|
+
const ParseShaderUniforms = (tokenizer, technique, unTreatedUniforms) => {
|
1062
1065
|
for (const unif in technique.uniforms) {
|
1063
1066
|
const uniform = technique.uniforms[unif];
|
1064
1067
|
const uniformParameter = technique.parameters[uniform];
|
@@ -1067,7 +1070,7 @@ const parseShaderUniforms = (tokenizer, technique, unTreatedUniforms) => {
|
|
1067
1070
|
const transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
|
1068
1071
|
if (transformIndex !== -1) {
|
1069
1072
|
delete unTreatedUniforms[unif];
|
1070
|
-
return
|
1073
|
+
return BabylonTransforms[transformIndex];
|
1071
1074
|
}
|
1072
1075
|
}
|
1073
1076
|
}
|
@@ -1078,7 +1081,7 @@ const parseShaderUniforms = (tokenizer, technique, unTreatedUniforms) => {
|
|
1078
1081
|
* All shaders loaded. Create materials one by one
|
1079
1082
|
* @param gltfRuntime
|
1080
1083
|
*/
|
1081
|
-
const
|
1084
|
+
const ImportMaterials = (gltfRuntime) => {
|
1082
1085
|
// Create materials
|
1083
1086
|
for (const mat in gltfRuntime.materials) {
|
1084
1087
|
GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, () => { }, () => { });
|
@@ -1123,58 +1126,58 @@ export class GLTFLoaderBase {
|
|
1123
1126
|
};
|
1124
1127
|
// Parse
|
1125
1128
|
if (parsedData.extensions) {
|
1126
|
-
|
1129
|
+
ParseObject(parsedData.extensions, "extensions", gltfRuntime);
|
1127
1130
|
}
|
1128
1131
|
if (parsedData.extensionsUsed) {
|
1129
|
-
|
1132
|
+
ParseObject(parsedData.extensionsUsed, "extensionsUsed", gltfRuntime);
|
1130
1133
|
}
|
1131
1134
|
if (parsedData.buffers) {
|
1132
|
-
|
1135
|
+
ParseBuffers(parsedData.buffers, gltfRuntime);
|
1133
1136
|
}
|
1134
1137
|
if (parsedData.bufferViews) {
|
1135
|
-
|
1138
|
+
ParseObject(parsedData.bufferViews, "bufferViews", gltfRuntime);
|
1136
1139
|
}
|
1137
1140
|
if (parsedData.accessors) {
|
1138
|
-
|
1141
|
+
ParseObject(parsedData.accessors, "accessors", gltfRuntime);
|
1139
1142
|
}
|
1140
1143
|
if (parsedData.meshes) {
|
1141
|
-
|
1144
|
+
ParseObject(parsedData.meshes, "meshes", gltfRuntime);
|
1142
1145
|
}
|
1143
1146
|
if (parsedData.lights) {
|
1144
|
-
|
1147
|
+
ParseObject(parsedData.lights, "lights", gltfRuntime);
|
1145
1148
|
}
|
1146
1149
|
if (parsedData.cameras) {
|
1147
|
-
|
1150
|
+
ParseObject(parsedData.cameras, "cameras", gltfRuntime);
|
1148
1151
|
}
|
1149
1152
|
if (parsedData.nodes) {
|
1150
|
-
|
1153
|
+
ParseObject(parsedData.nodes, "nodes", gltfRuntime);
|
1151
1154
|
}
|
1152
1155
|
if (parsedData.images) {
|
1153
|
-
|
1156
|
+
ParseObject(parsedData.images, "images", gltfRuntime);
|
1154
1157
|
}
|
1155
1158
|
if (parsedData.textures) {
|
1156
|
-
|
1159
|
+
ParseObject(parsedData.textures, "textures", gltfRuntime);
|
1157
1160
|
}
|
1158
1161
|
if (parsedData.shaders) {
|
1159
|
-
|
1162
|
+
ParseShaders(parsedData.shaders, gltfRuntime);
|
1160
1163
|
}
|
1161
1164
|
if (parsedData.programs) {
|
1162
|
-
|
1165
|
+
ParseObject(parsedData.programs, "programs", gltfRuntime);
|
1163
1166
|
}
|
1164
1167
|
if (parsedData.samplers) {
|
1165
|
-
|
1168
|
+
ParseObject(parsedData.samplers, "samplers", gltfRuntime);
|
1166
1169
|
}
|
1167
1170
|
if (parsedData.techniques) {
|
1168
|
-
|
1171
|
+
ParseObject(parsedData.techniques, "techniques", gltfRuntime);
|
1169
1172
|
}
|
1170
1173
|
if (parsedData.materials) {
|
1171
|
-
|
1174
|
+
ParseObject(parsedData.materials, "materials", gltfRuntime);
|
1172
1175
|
}
|
1173
1176
|
if (parsedData.animations) {
|
1174
|
-
|
1177
|
+
ParseObject(parsedData.animations, "animations", gltfRuntime);
|
1175
1178
|
}
|
1176
1179
|
if (parsedData.skins) {
|
1177
|
-
|
1180
|
+
ParseObject(parsedData.skins, "skins", gltfRuntime);
|
1178
1181
|
}
|
1179
1182
|
if (parsedData.scenes) {
|
1180
1183
|
gltfRuntime.scenes = parsedData.scenes;
|
@@ -1184,6 +1187,7 @@ export class GLTFLoaderBase {
|
|
1184
1187
|
}
|
1185
1188
|
return gltfRuntime;
|
1186
1189
|
}
|
1190
|
+
// eslint-disable-next-line no-restricted-syntax
|
1187
1191
|
static LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {
|
1188
1192
|
const buffer = gltfRuntime.buffers[id];
|
1189
1193
|
if (Tools.IsBase64(buffer.uri)) {
|
@@ -1197,6 +1201,7 @@ export class GLTFLoaderBase {
|
|
1197
1201
|
});
|
1198
1202
|
}
|
1199
1203
|
}
|
1204
|
+
// eslint-disable-next-line no-restricted-syntax
|
1200
1205
|
static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {
|
1201
1206
|
const texture = gltfRuntime.textures[id];
|
1202
1207
|
if (!texture || !texture.source) {
|
@@ -1219,6 +1224,7 @@ export class GLTFLoaderBase {
|
|
1219
1224
|
});
|
1220
1225
|
}
|
1221
1226
|
}
|
1227
|
+
// eslint-disable-next-line no-restricted-syntax
|
1222
1228
|
static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess) {
|
1223
1229
|
const texture = gltfRuntime.textures[id];
|
1224
1230
|
if (texture.babylonTexture) {
|
@@ -1245,6 +1251,7 @@ export class GLTFLoaderBase {
|
|
1245
1251
|
texture.babylonTexture = newTexture;
|
1246
1252
|
onSuccess(newTexture);
|
1247
1253
|
}
|
1254
|
+
// eslint-disable-next-line no-restricted-syntax
|
1248
1255
|
static LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {
|
1249
1256
|
const shader = gltfRuntime.shaders[id];
|
1250
1257
|
if (Tools.IsBase64(shader.uri)) {
|
@@ -1261,6 +1268,7 @@ export class GLTFLoaderBase {
|
|
1261
1268
|
});
|
1262
1269
|
}
|
1263
1270
|
}
|
1271
|
+
// eslint-disable-next-line no-restricted-syntax
|
1264
1272
|
static LoadMaterialAsync(gltfRuntime, id, onSuccess, onError) {
|
1265
1273
|
const material = gltfRuntime.materials[id];
|
1266
1274
|
if (!material.technique) {
|
@@ -1300,7 +1308,7 @@ export class GLTFLoaderBase {
|
|
1300
1308
|
if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) {
|
1301
1309
|
const transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
|
1302
1310
|
if (transformIndex !== -1) {
|
1303
|
-
uniforms.push(
|
1311
|
+
uniforms.push(BabylonTransforms[transformIndex]);
|
1304
1312
|
delete unTreatedUniforms[unif];
|
1305
1313
|
}
|
1306
1314
|
else {
|
@@ -1318,7 +1326,7 @@ export class GLTFLoaderBase {
|
|
1318
1326
|
const attribute = technique.attributes[attr];
|
1319
1327
|
const attributeParameter = technique.parameters[attribute];
|
1320
1328
|
if (attributeParameter.semantic) {
|
1321
|
-
const name =
|
1329
|
+
const name = GetAttribute(attributeParameter);
|
1322
1330
|
if (name) {
|
1323
1331
|
attributes.push(name);
|
1324
1332
|
}
|
@@ -1336,7 +1344,7 @@ export class GLTFLoaderBase {
|
|
1336
1344
|
const attribute = technique.attributes[attr];
|
1337
1345
|
const attributeParameter = technique.parameters[attribute];
|
1338
1346
|
if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) {
|
1339
|
-
newVertexShader +=
|
1347
|
+
newVertexShader += GetAttribute(attributeParameter);
|
1340
1348
|
foundAttribute = true;
|
1341
1349
|
break;
|
1342
1350
|
}
|
@@ -1344,7 +1352,7 @@ export class GLTFLoaderBase {
|
|
1344
1352
|
if (foundAttribute) {
|
1345
1353
|
continue;
|
1346
1354
|
}
|
1347
|
-
newVertexShader +=
|
1355
|
+
newVertexShader += ParseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms);
|
1348
1356
|
}
|
1349
1357
|
// Configure pixel shader
|
1350
1358
|
while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) {
|
@@ -1353,7 +1361,7 @@ export class GLTFLoaderBase {
|
|
1353
1361
|
newPixelShader += pixelTokenizer.currentString;
|
1354
1362
|
continue;
|
1355
1363
|
}
|
1356
|
-
newPixelShader +=
|
1364
|
+
newPixelShader += ParseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms);
|
1357
1365
|
}
|
1358
1366
|
// Create shader material
|
1359
1367
|
const shaderPath = {
|
@@ -1369,8 +1377,8 @@ export class GLTFLoaderBase {
|
|
1369
1377
|
Effect.ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader;
|
1370
1378
|
Effect.ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader;
|
1371
1379
|
const shaderMaterial = new ShaderMaterial(id, gltfRuntime.scene, shaderPath, options);
|
1372
|
-
shaderMaterial.onError =
|
1373
|
-
shaderMaterial.onCompiled =
|
1380
|
+
shaderMaterial.onError = OnShaderCompileError(program, shaderMaterial, onError);
|
1381
|
+
shaderMaterial.onCompiled = OnShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess);
|
1374
1382
|
shaderMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;
|
1375
1383
|
if (states && states.functions) {
|
1376
1384
|
const functions = states.functions;
|
@@ -1435,6 +1443,7 @@ export class GLTFLoader {
|
|
1435
1443
|
dispose() {
|
1436
1444
|
// do nothing
|
1437
1445
|
}
|
1446
|
+
// eslint-disable-next-line no-restricted-syntax
|
1438
1447
|
_importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) {
|
1439
1448
|
scene.useRightHandedSystem = true;
|
1440
1449
|
GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, (gltfRuntime) => {
|
@@ -1473,8 +1482,8 @@ export class GLTFLoader {
|
|
1473
1482
|
// Load buffers, shaders, materials, etc.
|
1474
1483
|
this._loadBuffersAsync(gltfRuntime, () => {
|
1475
1484
|
this._loadShadersAsync(gltfRuntime, () => {
|
1476
|
-
|
1477
|
-
|
1485
|
+
ImportMaterials(gltfRuntime);
|
1486
|
+
PostLoad(gltfRuntime);
|
1478
1487
|
if (!GLTFFileLoader.IncrementalLoading && onSuccess) {
|
1479
1488
|
onSuccess(meshes, skeletons);
|
1480
1489
|
}
|
@@ -1514,6 +1523,7 @@ export class GLTFLoader {
|
|
1514
1523
|
});
|
1515
1524
|
});
|
1516
1525
|
}
|
1526
|
+
// eslint-disable-next-line no-restricted-syntax
|
1517
1527
|
_loadAsync(scene, data, rootUrl, onSuccess, onProgress, onError) {
|
1518
1528
|
scene.useRightHandedSystem = true;
|
1519
1529
|
GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, (gltfRuntime) => {
|
@@ -1524,8 +1534,8 @@ export class GLTFLoader {
|
|
1524
1534
|
// Load buffers, shaders, materials, etc.
|
1525
1535
|
this._loadBuffersAsync(gltfRuntime, () => {
|
1526
1536
|
this._loadShadersAsync(gltfRuntime, () => {
|
1527
|
-
|
1528
|
-
|
1537
|
+
ImportMaterials(gltfRuntime);
|
1538
|
+
PostLoad(gltfRuntime);
|
1529
1539
|
if (!GLTFFileLoader.IncrementalLoading) {
|
1530
1540
|
onSuccess();
|
1531
1541
|
}
|
@@ -1554,6 +1564,7 @@ export class GLTFLoader {
|
|
1554
1564
|
});
|
1555
1565
|
});
|
1556
1566
|
}
|
1567
|
+
// eslint-disable-next-line no-restricted-syntax
|
1557
1568
|
_loadShadersAsync(gltfRuntime, onload) {
|
1558
1569
|
let hasShaders = false;
|
1559
1570
|
const processShader = (sha, shader) => {
|
@@ -1586,6 +1597,7 @@ export class GLTFLoader {
|
|
1586
1597
|
onload();
|
1587
1598
|
}
|
1588
1599
|
}
|
1600
|
+
// eslint-disable-next-line no-restricted-syntax
|
1589
1601
|
_loadBuffersAsync(gltfRuntime, onLoad) {
|
1590
1602
|
let hasBuffers = false;
|
1591
1603
|
const processBuffer = (buf, buffer) => {
|
@@ -1623,7 +1635,7 @@ export class GLTFLoader {
|
|
1623
1635
|
if (currentScene) {
|
1624
1636
|
// Only one scene even if multiple scenes are defined
|
1625
1637
|
for (let i = 0; i < currentScene.nodes.length; i++) {
|
1626
|
-
|
1638
|
+
TraverseNodes(gltfRuntime, currentScene.nodes[i], null);
|
1627
1639
|
}
|
1628
1640
|
}
|
1629
1641
|
else {
|
@@ -1631,7 +1643,7 @@ export class GLTFLoader {
|
|
1631
1643
|
for (const thing in gltfRuntime.scenes) {
|
1632
1644
|
currentScene = gltfRuntime.scenes[thing];
|
1633
1645
|
for (let i = 0; i < currentScene.nodes.length; i++) {
|
1634
|
-
|
1646
|
+
TraverseNodes(gltfRuntime, currentScene.nodes[i], null);
|
1635
1647
|
}
|
1636
1648
|
}
|
1637
1649
|
}
|
@@ -1656,6 +1668,7 @@ export class GLTFLoaderExtension {
|
|
1656
1668
|
* @param onError
|
1657
1669
|
* @returns true to stop further extensions from loading the runtime
|
1658
1670
|
*/
|
1671
|
+
// eslint-disable-next-line no-restricted-syntax
|
1659
1672
|
loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError) {
|
1660
1673
|
return false;
|
1661
1674
|
}
|
@@ -1667,6 +1680,7 @@ export class GLTFLoaderExtension {
|
|
1667
1680
|
* @param onError
|
1668
1681
|
* @returns true to stop further extensions from creating the runtime
|
1669
1682
|
*/
|
1683
|
+
// eslint-disable-next-line no-restricted-syntax
|
1670
1684
|
loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError) {
|
1671
1685
|
return false;
|
1672
1686
|
}
|
@@ -1680,6 +1694,8 @@ export class GLTFLoaderExtension {
|
|
1680
1694
|
* @param onProgress
|
1681
1695
|
* @returns true to stop further extensions from loading this buffer
|
1682
1696
|
*/
|
1697
|
+
// eslint-disable-next-line no-restricted-syntax
|
1698
|
+
// eslint-disable-next-line no-restricted-syntax
|
1683
1699
|
loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {
|
1684
1700
|
return false;
|
1685
1701
|
}
|
@@ -1692,6 +1708,7 @@ export class GLTFLoaderExtension {
|
|
1692
1708
|
* @param onError
|
1693
1709
|
* @returns true to stop further extensions from loading this texture data
|
1694
1710
|
*/
|
1711
|
+
// eslint-disable-next-line no-restricted-syntax
|
1695
1712
|
loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {
|
1696
1713
|
return false;
|
1697
1714
|
}
|
@@ -1705,6 +1722,7 @@ export class GLTFLoaderExtension {
|
|
1705
1722
|
* @param onError
|
1706
1723
|
* @returns true to stop further extensions from loading this texture
|
1707
1724
|
*/
|
1725
|
+
// eslint-disable-next-line no-restricted-syntax
|
1708
1726
|
createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError) {
|
1709
1727
|
return false;
|
1710
1728
|
}
|
@@ -1717,6 +1735,7 @@ export class GLTFLoaderExtension {
|
|
1717
1735
|
* @param onError
|
1718
1736
|
* @returns true to stop further extensions from loading this shader data
|
1719
1737
|
*/
|
1738
|
+
// eslint-disable-next-line no-restricted-syntax
|
1720
1739
|
loadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {
|
1721
1740
|
return false;
|
1722
1741
|
}
|
@@ -1729,12 +1748,14 @@ export class GLTFLoaderExtension {
|
|
1729
1748
|
* @param onError
|
1730
1749
|
* @returns true to stop further extensions from loading this material
|
1731
1750
|
*/
|
1751
|
+
// eslint-disable-next-line no-restricted-syntax
|
1732
1752
|
loadMaterialAsync(gltfRuntime, id, onSuccess, onError) {
|
1733
1753
|
return false;
|
1734
1754
|
}
|
1735
1755
|
// ---------
|
1736
1756
|
// Utilities
|
1737
1757
|
// ---------
|
1758
|
+
// eslint-disable-next-line no-restricted-syntax
|
1738
1759
|
static LoadRuntimeAsync(scene, data, rootUrl, onSuccess, onError) {
|
1739
1760
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1740
1761
|
return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);
|
@@ -1747,6 +1768,7 @@ export class GLTFLoaderExtension {
|
|
1747
1768
|
});
|
1748
1769
|
});
|
1749
1770
|
}
|
1771
|
+
// eslint-disable-next-line no-restricted-syntax
|
1750
1772
|
static LoadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError) {
|
1751
1773
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1752
1774
|
return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);
|
@@ -1756,6 +1778,7 @@ export class GLTFLoaderExtension {
|
|
1756
1778
|
});
|
1757
1779
|
});
|
1758
1780
|
}
|
1781
|
+
// eslint-disable-next-line no-restricted-syntax
|
1759
1782
|
static LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress) {
|
1760
1783
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1761
1784
|
return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
|
@@ -1763,6 +1786,7 @@ export class GLTFLoaderExtension {
|
|
1763
1786
|
GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
|
1764
1787
|
});
|
1765
1788
|
}
|
1789
|
+
// eslint-disable-next-line no-restricted-syntax
|
1766
1790
|
static LoadTextureAsync(gltfRuntime, id, onSuccess, onError) {
|
1767
1791
|
GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, (buffer) => {
|
1768
1792
|
if (buffer) {
|
@@ -1770,6 +1794,7 @@ export class GLTFLoaderExtension {
|
|
1770
1794
|
}
|
1771
1795
|
}, onError);
|
1772
1796
|
}
|
1797
|
+
// eslint-disable-next-line no-restricted-syntax
|
1773
1798
|
static LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError) {
|
1774
1799
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1775
1800
|
return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
|
@@ -1777,6 +1802,7 @@ export class GLTFLoaderExtension {
|
|
1777
1802
|
GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
|
1778
1803
|
});
|
1779
1804
|
}
|
1805
|
+
// eslint-disable-next-line no-restricted-syntax
|
1780
1806
|
static LoadMaterialAsync(gltfRuntime, id, onSuccess, onError) {
|
1781
1807
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1782
1808
|
return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);
|
@@ -1784,6 +1810,7 @@ export class GLTFLoaderExtension {
|
|
1784
1810
|
GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);
|
1785
1811
|
});
|
1786
1812
|
}
|
1813
|
+
// eslint-disable-next-line no-restricted-syntax
|
1787
1814
|
static _LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError) {
|
1788
1815
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1789
1816
|
return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
|
@@ -1791,6 +1818,7 @@ export class GLTFLoaderExtension {
|
|
1791
1818
|
GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
|
1792
1819
|
});
|
1793
1820
|
}
|
1821
|
+
// eslint-disable-next-line no-restricted-syntax
|
1794
1822
|
static _CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError) {
|
1795
1823
|
GLTFLoaderExtension._ApplyExtensions((loaderExtension) => {
|
1796
1824
|
return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
|