@babylonjs/loaders 7.18.0 → 7.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/glTF/2.0/glTFLoader.js +23 -12
 - package/glTF/2.0/glTFLoader.js.map +1 -1
 - package/glTF/2.0/glTFLoaderInterfaces.d.ts +2 -0
 - package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
 - package/glTF/glTFFileLoader.d.ts +13 -0
 - package/glTF/glTFFileLoader.js +13 -0
 - package/glTF/glTFFileLoader.js.map +1 -1
 - package/package.json +3 -3
 
    
        package/glTF/2.0/glTFLoader.js
    CHANGED
    
    | 
         @@ -614,7 +614,9 @@ export class GLTFLoader { 
     | 
|
| 
       614 
614 
     | 
    
         
             
                        }
         
     | 
| 
       615 
615 
     | 
    
         
             
                        assign(babylonTransformNode);
         
     | 
| 
       616 
616 
     | 
    
         
             
                    };
         
     | 
| 
       617 
     | 
    
         
            -
                     
     | 
| 
      
 617 
     | 
    
         
            +
                    const hasMesh = node.mesh != undefined;
         
     | 
| 
      
 618 
     | 
    
         
            +
                    const hasSkin = this._parent.loadSkins && node.skin != undefined;
         
     | 
| 
      
 619 
     | 
    
         
            +
                    if (!hasMesh || hasSkin) {
         
     | 
| 
       618 
620 
     | 
    
         
             
                        const nodeName = node.name || `node${node.index}`;
         
     | 
| 
       619 
621 
     | 
    
         
             
                        this._babylonScene._blockEntityCollection = !!this._assetContainer;
         
     | 
| 
       620 
622 
     | 
    
         
             
                        const transformNode = new TransformNode(nodeName, this._babylonScene);
         
     | 
| 
         @@ -628,12 +630,8 @@ export class GLTFLoader { 
     | 
|
| 
       628 
630 
     | 
    
         
             
                        }
         
     | 
| 
       629 
631 
     | 
    
         
             
                        loadNode(transformNode);
         
     | 
| 
       630 
632 
     | 
    
         
             
                    }
         
     | 
| 
       631 
     | 
    
         
            -
                    if ( 
     | 
| 
       632 
     | 
    
         
            -
                        if ( 
     | 
| 
       633 
     | 
    
         
            -
                            const mesh = ArrayItem.Get(`${context}/mesh`, this._gltf.meshes, node.mesh);
         
     | 
| 
       634 
     | 
    
         
            -
                            promises.push(this._loadMeshAsync(`/meshes/${mesh.index}`, node, mesh, loadNode));
         
     | 
| 
       635 
     | 
    
         
            -
                        }
         
     | 
| 
       636 
     | 
    
         
            -
                        else {
         
     | 
| 
      
 633 
     | 
    
         
            +
                    if (hasMesh) {
         
     | 
| 
      
 634 
     | 
    
         
            +
                        if (hasSkin) {
         
     | 
| 
       637 
635 
     | 
    
         
             
                            // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
         
     | 
| 
       638 
636 
     | 
    
         
             
                            // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the
         
     | 
| 
       639 
637 
     | 
    
         
             
                            // transform, which effectively ignores the transform of the skinned mesh, as per spec.
         
     | 
| 
         @@ -668,6 +666,10 @@ export class GLTFLoader { 
     | 
|
| 
       668 
666 
     | 
    
         
             
                                }));
         
     | 
| 
       669 
667 
     | 
    
         
             
                            }));
         
     | 
| 
       670 
668 
     | 
    
         
             
                        }
         
     | 
| 
      
 669 
     | 
    
         
            +
                        else {
         
     | 
| 
      
 670 
     | 
    
         
            +
                            const mesh = ArrayItem.Get(`${context}/mesh`, this._gltf.meshes, node.mesh);
         
     | 
| 
      
 671 
     | 
    
         
            +
                            promises.push(this._loadMeshAsync(`/meshes/${mesh.index}`, node, mesh, loadNode));
         
     | 
| 
      
 672 
     | 
    
         
            +
                        }
         
     | 
| 
       671 
673 
     | 
    
         
             
                    }
         
     | 
| 
       672 
674 
     | 
    
         
             
                    this.logClose();
         
     | 
| 
       673 
675 
     | 
    
         
             
                    return Promise.all(promises).then(() => {
         
     | 
| 
         @@ -888,7 +890,7 @@ export class GLTFLoader { 
     | 
|
| 
       888 
890 
     | 
    
         
             
                    });
         
     | 
| 
       889 
891 
     | 
    
         
             
                }
         
     | 
| 
       890 
892 
     | 
    
         
             
                _createMorphTargets(context, node, mesh, primitive, babylonMesh) {
         
     | 
| 
       891 
     | 
    
         
            -
                    if (!primitive.targets) {
         
     | 
| 
      
 893 
     | 
    
         
            +
                    if (!primitive.targets || !this._parent.loadMorphTargets) {
         
     | 
| 
       892 
894 
     | 
    
         
             
                        return;
         
     | 
| 
       893 
895 
     | 
    
         
             
                    }
         
     | 
| 
       894 
896 
     | 
    
         
             
                    if (node._numMorphTargets == undefined) {
         
     | 
| 
         @@ -911,7 +913,7 @@ export class GLTFLoader { 
     | 
|
| 
       911 
913 
     | 
    
         
             
                    }
         
     | 
| 
       912 
914 
     | 
    
         
             
                }
         
     | 
| 
       913 
915 
     | 
    
         
             
                _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonGeometry) {
         
     | 
| 
       914 
     | 
    
         
            -
                    if (!primitive.targets) {
         
     | 
| 
      
 916 
     | 
    
         
            +
                    if (!primitive.targets || !this._parent.loadMorphTargets) {
         
     | 
| 
       915 
917 
     | 
    
         
             
                        return Promise.resolve();
         
     | 
| 
       916 
918 
     | 
    
         
             
                    }
         
     | 
| 
       917 
919 
     | 
    
         
             
                    const promises = new Array();
         
     | 
| 
         @@ -998,6 +1000,9 @@ export class GLTFLoader { 
     | 
|
| 
       998 
1000 
     | 
    
         
             
                    babylonNode.scaling = scaling;
         
     | 
| 
       999 
1001 
     | 
    
         
             
                }
         
     | 
| 
       1000 
1002 
     | 
    
         
             
                _loadSkinAsync(context, node, skin, assign) {
         
     | 
| 
      
 1003 
     | 
    
         
            +
                    if (!this._parent.loadSkins) {
         
     | 
| 
      
 1004 
     | 
    
         
            +
                        return Promise.resolve();
         
     | 
| 
      
 1005 
     | 
    
         
            +
                    }
         
     | 
| 
       1001 
1006 
     | 
    
         
             
                    const extensionPromise = this._extensionsLoadSkinAsync(context, node, skin);
         
     | 
| 
       1002 
1007 
     | 
    
         
             
                    if (extensionPromise) {
         
     | 
| 
       1003 
1008 
     | 
    
         
             
                        return extensionPromise;
         
     | 
| 
         @@ -1086,6 +1091,7 @@ export class GLTFLoader { 
     | 
|
| 
       1086 
1091 
     | 
    
         
             
                    }
         
     | 
| 
       1087 
1092 
     | 
    
         
             
                }
         
     | 
| 
       1088 
1093 
     | 
    
         
             
                _loadBone(node, skin, babylonSkeleton, babylonBones) {
         
     | 
| 
      
 1094 
     | 
    
         
            +
                    node._isJoint = true;
         
     | 
| 
       1089 
1095 
     | 
    
         
             
                    let babylonBone = babylonBones[node.index];
         
     | 
| 
       1090 
1096 
     | 
    
         
             
                    if (babylonBone) {
         
     | 
| 
       1091 
1097 
     | 
    
         
             
                        return babylonBone;
         
     | 
| 
         @@ -1263,13 +1269,18 @@ export class GLTFLoader { 
     | 
|
| 
       1263 
1269 
     | 
    
         
             
                        return Promise.resolve();
         
     | 
| 
       1264 
1270 
     | 
    
         
             
                    }
         
     | 
| 
       1265 
1271 
     | 
    
         
             
                    const targetNode = ArrayItem.Get(`${context}/target/node`, this._gltf.nodes, channel.target.node);
         
     | 
| 
      
 1272 
     | 
    
         
            +
                    const channelTargetPath = channel.target.path;
         
     | 
| 
      
 1273 
     | 
    
         
            +
                    const pathIsWeights = channelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */;
         
     | 
| 
       1266 
1274 
     | 
    
         
             
                    // Ignore animations that have no animation targets.
         
     | 
| 
       1267 
     | 
    
         
            -
                    if (( 
     | 
| 
       1268 
     | 
    
         
            -
                         
     | 
| 
      
 1275 
     | 
    
         
            +
                    if ((pathIsWeights && !targetNode._numMorphTargets) || (!pathIsWeights && !targetNode._babylonTransformNode)) {
         
     | 
| 
      
 1276 
     | 
    
         
            +
                        return Promise.resolve();
         
     | 
| 
      
 1277 
     | 
    
         
            +
                    }
         
     | 
| 
      
 1278 
     | 
    
         
            +
                    // Don't load node animations if disabled.
         
     | 
| 
      
 1279 
     | 
    
         
            +
                    if (!this._parent.loadNodeAnimations && !pathIsWeights && !targetNode._isJoint) {
         
     | 
| 
       1269 
1280 
     | 
    
         
             
                        return Promise.resolve();
         
     | 
| 
       1270 
1281 
     | 
    
         
             
                    }
         
     | 
| 
       1271 
1282 
     | 
    
         
             
                    let properties;
         
     | 
| 
       1272 
     | 
    
         
            -
                    switch ( 
     | 
| 
      
 1283 
     | 
    
         
            +
                    switch (channelTargetPath) {
         
     | 
| 
       1273 
1284 
     | 
    
         
             
                        case "translation" /* AnimationChannelTargetPath.TRANSLATION */: {
         
     | 
| 
       1274 
1285 
     | 
    
         
             
                            properties = nodeAnimationData.translation;
         
     | 
| 
       1275 
1286 
     | 
    
         
             
                            break;
         
     |