Major GLTF Importer Bug: FAILED SKELETONS

BJS GLTF importer has a major bug when it comes to importing this GLB (here is the .gltf and .bin file for reference).

The skins/skeletons fail to be imported into the scene. I believe this is because the skins/skeletons import section assumes that the order of the nodes are from parent to child. But in this GLTF file, some of the childs are ordered before their parents in ‘nodes’ e.g. mixamorig:HeadTop_End is in nodes index = 0 while RootNode/Hips are in index 15 and 16.

This GLB imports perfectly fine in Blender.

I can confirm this problem occurs for multiple GLBs if the nodes are not ordered from parent to child.

None of these issues are in blender

This .glb file does not work with Threejs glTF viewer nor with the official Khronos glTF viewer, so I would say it’s a problem with the file.

Note that this file has some errors when opened by those viewers (and by the sandbox):

Thanks for clearing it up

Why can’t we all be like Blender? :neutral_face:

Well, it would seem like Blender is bugged as it should not display the file correctly, so we should definitely not be like Blender :wink:

1 Like

well, the thing is blender DOES display the file correctly, including the mesh, skeleton + skinned animations…

whereas here BJS doesn’t even show any mesh or skeletons unfortunately

If according to the spec the file should not be displayed correctly, then Blender is bugged if it displays it correctly.

Note that I don’t know if it’s the case, but because there are some errors in this file and because 3 viewers can’t display it properly I would lean toward a mis-behaving on Blender side.

Note also that if you open the file in Blender, save it to glb then open this glb file in the sandbox (and in the other viewers), it does work.

1 Like

“Note also that if you open the file in Blender, save it to glb then open this glb file in the sandbox (and in the other viewers), it does work.” - Yep, Blender is awesome that way

I think when we last looked we where able to find blenders parsing stuff @mrlooi, maybe it would be possible to convert it and polyfill over the generic BJS parsing stuff with whatever blender is doing then the two would behave similarly. I just think we looked into this already and it was quite the project.

Yea probably, tho Blender’s codebase is quite the monster to say the least haha. And porting all those from blender python to JS to BJS internals is quiteee the port

As The Blender importer / exporter pair is the only one directly supported by the Khronos Group,
GitHub - KhronosGroup/glTF-Blender-IO: Blender glTF 2.0 importer and exporter, perhaps they put in stuff that fixes this problem, helped by the Blender API which does not even specify a parent bone when instancing a new bone

https://docs.blender.org/api/2.93/bpy.types.ArmatureEditBones.html#bpy.types.ArmatureEditBones.new

Basically, the data must being double passed, with all the bones instanced first, then a second pass to add any possible parent.

Actually that is kinda what they are already doing with the animation parsing if I’m not mistaken (still using that method @mrlooi from when I was with yall?). Could possibly recycling that code and modify it a hair to do a second pass like blender does to fix whichever problems.

Boldly go where nobody wants to. :grinning:

Yea possibly, it’s a bit different (that’s more for merging duplicate skeletons) but yea in principle some of the logic is the same : P

The main issue is that importing a GLB with empty nodes invalidates the entire BJS importer skeletons/skinned meshes, which is obv not what Blender does

As The Blender importer / exporter pair is the only one directly supported by the Khronos Group

Interesting, no wonder their GLTF support is so good

Adding @bghgary

This GLB contains meshes that are not referenced by the scene. All that needs to happen is to add the skinned mesh nodes to the scene and then it will load properly.

  "scenes": [
    {
      "nodes": [
        15,
        68, // add this
        69  // and this
      ]
    }
  ],

If Blender is loading all of the nodes regardless of what the scene says, that is technically also correct, but it’s not the typical behavior of viewers.

Here is updated glTF files with the scene fix: capoeira1.zip (1.1 MB)

2021-06-17_15-29-35

4 Likes

The validation errors are not great, but they don’t hurt the model in this specific case.

1 Like

Thank you for clearing this up @bghgary :grinning:

1 Like