# GLB file not loaded correctly

**URL:** <https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428>\
**Category:** Bugs\
**Created:** [July 14, 2023, 8:29am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428 "2023-07-14T08:29:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@Freeman](https://forum.babylonjs.com/u/Freeman)\
**Post date:** [July 14, 2023, 8:29am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/1 "2023-07-14T08:29:13Z")

</div>

Hi,  
I have a glb file that not loaded correctly in bjs:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/d/bd76918e38a66c44e65784310571ee4b4a48f343.jpeg)

And this is in 3js, no problem:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/c/ac5476a9445b2f5abdc65a1197e1c79117b81be7.jpeg)

Attached the glb file link  
[https://drive.google.com/file/d/10-iPHffZuII0i5p1tDRd3mpZ\_iV8jEYu/view?usp=sharing](https://drive.google.com/file/d/10-iPHffZuII0i5p1tDRd3mpZ_iV8jEYu/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 14, 2023, 2:15pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/2 "2023-07-14T14:15:49Z")

</div>

The Sandbox shows that the file has incorrect specifications:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/3/f3433b370b8e1d250e0efd8a7bcc2d8216d4de6e.png)

If you click on “More details”:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/8/182dd58715276f161c21812c6a1710faed68551e.png)

I’m not sure if Three.js is simply ignoring the error or doing something to try to correct it. @Evgeni_Popov or @bghgary who have a lot of experience w skeletons can explain the behavior better?

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 14, 2023, 5:23pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/3 "2023-07-14T17:23:54Z")

</div>



---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 14, 2023, 5:24pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/4 "2023-07-14T17:24:15Z")

</div>

I can repro. I don’t think the validation error is causing this problem. I’ll investigate.

---

<div class="post-metadata">

**Author:** ![SkyOps117](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/skyops117/32/31300_2.png) [@SkyOps117](https://forum.babylonjs.com/u/SkyOps117)\
**Post date:** [July 14, 2023, 9:03pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/5 "2023-07-14T21:03:28Z")

</div>

If you converted FBX to GLB they work differently. I had similar issue and used blender to correct them some times ago . .

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 19, 2023, 12:29am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/6 "2023-07-19T00:29:34Z")

</div>

Sorry for the delay, I’m busy with another task right now. I will get to this soon. 🤞

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 19, 2023, 8:24am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/7 "2023-07-19T08:24:26Z")

</div>

I looked at the file, the problem comes from `skeleton1` (this is the skeleton used by **Ch17\_Boots** ).

`skeleton1` is created as follows:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/5/e/5eef7641e5c1b1ea9a3a9714292ac90f3f3fca79.png)

The problem is that **RightUpLeg** is created under **RootNode** / **mixamorig1:Hips**. It’s because of this code in `_loadBone` :

```typescript
let parentBabylonBone: Nullable<Bone> = null;
if (node.index !== skin.skeleton) {
    if (node.parent && node.parent.index !== -1) {
        parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
    } else if (skin.skeleton !== undefined) {
        Logger.Warn(`/skins/${skin.index}/skeleton: Skeleton node is not a common root`);
    }
}

```

When processing **RightUpLeg** , `node.parent && node.parent.index !== -1` is `true`, so we go up the hierarchy and create **mixamorig1:Hips** first, then **RootNode** , because the node hierarchy is :

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/6/46af12ed410c1a878ae623f8e171bffc56825b46.png)

This doesn’t happen for **LeftUpLeg** because the index of this bone is also the value of `skin.skeleton`, so `node.index !== skin.skeleton` is `false` and we don’t execute the code inside the condition block.

Maybe we shouldn’t go up the hierarchy if `node.parent.index` isn’t one of the joints? Something like:

```typescript
if (node.index !== skin.skeleton) {
    if (node.parent && node.parent.index !== -1) {
        if (skin.joints.indexOf(node.parent.index) !== -1) {
            parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
        }
    } else if (skin.skeleton !== undefined) {
        Logger.Warn(`/skins/${skin.index}/skeleton: Skeleton node is not a common root`);
    }
}

```

This modification creates a skeleton like the one shown below and solves the problem, but I don’t know if it’s the right fix:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/b/abaaa55405590c14ffd9b00d979b100c4e7041d9.png)

---

<div class="post-metadata">

**Author:** ![gryff](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gryff/32/1855_2.png) [@gryff](https://forum.babylonjs.com/u/gryff)\
**Post date:** [July 19, 2023, 2:45pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/8 "2023-07-19T14:45:37Z")

</div>

I don’t use the .glb file format as I usually export .babylon files from Blender using @JCPalmer 's Blender exporter, but I saw this thread and the results shown above seemed a little odd, so I took a look.

I downloaded the file in @Freeman 's first post and imported the file into Blender, simplified the materials in Blender ( it uses very large UDIM textures \> than 20Mbs in one case) and exported as a .babylon file. I then viewed both the original file and my .babylon file in the sandbox. Results are Images 1 and 2

Like @Freeman 's original image above, Image 1 it shows the “boot” at the hips!! It also shows what appears to be 8(!!) skeletons with lows of ~2 bones to a high of ~52 bones

Image 2 is a screenshot of my .babylon file in the sandbox. There is one skeleton (65 bones), the boot is in the correct position **and** the character has a beard (B in Image 2) not seen in either of the two images above. So _three.js_ is also not dealing correctly with the file either.

@Evgeni_Popov is likely correct about the bones in the imported from the skeleton in the .glb file, but what is happening to the beard? To test the skeleton that was being exported from Blender, I added 2 mixamo animations to the character - here is a playground with the animated character :

[Animated Worker](https://playground.babylonjs.com/#0JFDI1#1)

I did not adjust or rearrange any bones in the Blender skeleton - just added the animations

I have no idea why I am getting good results after I import the file into Blender then export as a .babylon file. 🤔

**EDIT** : The bones in the rig are named like “mixamorig:hips”. Does that “:” interfere with the parsing of the .glb file ?

cheers, gryff 🙂

Image 1 : Screen shot of original .glb file in sandbox :

 ![orig_model_sandbox](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/9/99b5121a50c463642efbd3668949170e50840a37.jpeg)

Image 2 : Screen shot of .babylon file exported from Blender :

 ![my_model_sandbox](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/c/1c57f9597bb68759ee15c549fac83e521d7bd19b.jpeg)

---

<div class="post-metadata">

**Author:** ![gryff](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gryff/32/1855_2.png) [@gryff](https://forum.babylonjs.com/u/gryff)\
**Post date:** [July 19, 2023, 6:16pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/9 "2023-07-19T18:16:30Z")

</div>

And just for @Evgeni_Popov , here is an image of the rig outline from Blender. The foot bone is selected and it shows up in the proper place in the bone hierarchy (A) . Why does the glb file have this abnormal hierarchy?

As I have said above, the “ **:** ” does not parse well in game engines like GODOT.

cheers, gryff 🙂

 ![rightfoot01](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/6/8649b558524945e2ba71f0b7085e0ab390a5271b.jpeg)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 19, 2023, 7:58pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/10 "2023-07-19T19:58:20Z")

</div>

Thanks @gryff!

The “no beard” display is either expected (for some reasons) or a bug in the Blender export, as all the 4 or 5 glTF viewers I tested don’t show the beard.

“:” is not a problem, they are all over the place in Mixamo avatars and we do have other files coming from Mixamo that work well.

> [@gryff](#):
>
> Image 2 is a screenshot of my .babylon file in the sandbox. There is one skeleton (65 bones), the boot is in the correct position

Yes, the problem only concerns the glTF parsing code. Let’s see what @bghgary has to say about it.

---

<div class="post-metadata">

**Author:** ![gryff](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gryff/32/1855_2.png) [@gryff](https://forum.babylonjs.com/u/gryff)\
**Post date:** [July 19, 2023, 8:49pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/11 "2023-07-19T20:49:36Z")

</div>

@Evgeni_Popov : I don’t think it is a bug in the Blender **export** as the meshes are visible in the Blender display windows before any export… A problem with the Blender **"import**" maybe? I am using Blender 3.3.1 and the beard has ~7600 vertices. So not an insignificant mesh.

See image below. I have hidden the armature for the picture.

Like you, I await @bghgary thoughts and ideas - and solutions!!

Did you try my playground above?

cheers, gryff 🙂

 ![beard01](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/f/ff04aa6faca3e4899c379c4354810d4342918bfe.jpeg)

---

<div class="post-metadata">

**Author:** ![Freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@Freeman](https://forum.babylonjs.com/u/Freeman)\
**Post date:** [July 20, 2023, 12:36am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/12 "2023-07-20T00:36:59Z")

</div>

@Evgeni_Popov ,  
The glb file is converted from a fbx file. The fbx file do have hair and beard. As “no beard” display in both bjs and 3js, I thought it was a convert issue.

But it can display in Blender by @gryff , I think the loader doesn’t parse the “beard” correctly as well.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 20, 2023, 8:06am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/13 "2023-07-20T08:06:40Z")

</div>

I think it’s a Blender export issue, as none of the 5 or 6 different glTF viewers I’ve used (including the official Khronos viewer) display the hair/beard.

[…] On closer inspection, Blender exports the material for this mesh with alpha=0. If I set alpha=1 for this material (`Ch17_hair`), it works:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/b/0b6ca1ab5aecafd2b355305441724a2fdbc4c229.jpeg)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 21, 2023, 8:50pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/14 "2023-07-21T20:50:52Z")

</div>

Finally getting a chance to look at this. I’ll address the easier question first 🙂

Regarding the missing beard, @Evgeni_Popov is right. The glTF material for the `C17_hair` is this:

```json
    {
      "name": "Ch17_hair",
      "alphaMode": "BLEND",
      "extras": {
        "fromFBX": {
          "shadingModel": "Phong",
          "isTruePBR": false
        }
      },
      "pbrMetallicRoughness": {
        "baseColorTexture": {
          "index": 3,
          "texCoord": 0
        },
        "baseColorFactor": [
          0.800000011920929,
          0.800000011920929,
          0.800000011920929,
          0.0 // ***This is the problem!***
        ],
        "metallicFactor": 0.400000005960464,
        "roughnessFactor": 0.301511347293854
      }
    }

```

I don’t know why Blender exporter would do this, so it’s probably better to ask them. Changing this value to `1.0` makes it show up.

I will look at the skeleton issue next.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 22, 2023, 1:05am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/15 "2023-07-22T01:05:46Z")

</div>

Regarding the boot issue, this is still an issue with the asset. The reason why it only happens in Babylon is probably because we are the only loader that uses the `skeleton` property of the glTF which has been incorrectly set in the asset.

It turns out that I was wrong about the glTF Validation errors not causing the problems. The warnings are ignorable, but the first error is the exact source of the issue.

```json
      {
        "code": "SKIN_SKELETON_INVALID",
        "message": "Skeleton node is not a common root.",
        "severity": 0,
        "pointer": "/skins/1/skeleton"
      },

```

The offending glTF JSON:

```json
    {
      "joints": [
        56,
        57,
        58,
        59,
        60,
        61,
        62,
        63,
        64,
        65
      ],
      "inverseBindMatrices": 49,
      "skeleton": 56 // ***this node is not a common root of the nodes in the list above***
    },

```

If this node is not a common root, the loader will load incorrectly for some cases. Changing this value to `1` or removing this property (such that the loader will auto-calculate the common root) fixes the issue.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [July 22, 2023, 1:05am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/16 "2023-07-22T01:05:51Z")

</div>



---

<div class="post-metadata">

**Author:** ![newbeea](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/newbeea/32/29263_2.png) [@newbeea](https://forum.babylonjs.com/u/newbeea)\
**Post date:** [August 16, 2023, 2:30am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/17 "2023-08-16T02:30:34Z")

</div>

I have the same issue, thanks for your solution, it works by changing skeleton to 1.  
But I am wondering why we need this part if the skeleton can be set to 1. Why can’t we discard this value, what is it used for? thank you so so much.

```auto
let parentBabylonBone: Nullable<Bone> = null;
if (node.index !== skin.skeleton) {
    if (node.parent && node.parent.index !== -1) {
        parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
    } else if (skin.skeleton !== undefined) {
        Logger.Warn(`/skins/${skin.index}/skeleton: Skeleton node is not a common root`);
    }
}

```

And will we fix this issue in the future?

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [August 16, 2023, 6:29pm UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/18 "2023-08-16T18:29:31Z")

</div>

> [@newbeea](#):
>
> Why can’t we discard this value, what is it used for?

This property represents the root of the skeleton. Babylon handles skeletons differently than glTF so we have to move of the mesh nodes to accommodate (see [here](https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh)). The root of the skeleton can be specified to be higher than the common ancestor if needed. The loader respects this property for this reason and to save CPU cycles from computing the common ancestor.

> [@newbeea](#):
>
> And will we fix this issue in the future?

I’m not sure there is anything to fix. The glTF is malformed as indicated by the glTF validator. The loader also has a flag called [alwaysComputeSkeletonRootNode](https://doc.babylonjs.com/typedoc/classes/BABYLON.GLTFFileLoader#alwaysComputeSkeletonRootNode) if you want to always compute the common ancestor and ignore the provided one.

---

<div class="post-metadata">

**Author:** ![newbeea](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/newbeea/32/29263_2.png) [@newbeea](https://forum.babylonjs.com/u/newbeea)\
**Post date:** [August 17, 2023, 6:49am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/19 "2023-08-17T06:49:57Z")

</div>

I understand now, thank you so much for your explanation.  
I will use this ` alwaysComputeSkeletonRootNode` parameter because most of the files I convert from FBX to GLTF using Godot’s fbx2gltf have this issue.

---

<div class="post-metadata">

**Author:** ![newbeea](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/newbeea/32/29263_2.png) [@newbeea](https://forum.babylonjs.com/u/newbeea)\
**Post date:** [August 17, 2023, 7:06am UTC](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428/20 "2023-08-17T07:06:26Z")

</div>

I use alwaysComputeSkeletonRootNode like this:

```auto
const gltfLoader = SceneLoader.GetPluginForExtension('.gltf')
gltfLoader.alwaysComputeSkeletonRootNode = true

```

It doesn’t seem to be working, am I using it correctly?

[Next page](https://forum.babylonjs.com/t/glb-file-not-loaded-correctly/42428.md?page=2)
