Incorrect Object Transforms when exporting Armature with Objects directly parented to Bones (GLTF)

Hey everyone.

I have a Rig setup in blender that includes an armature with a mesh as well as a gun thats a seperate object which is parented to a bone of the armature, so that I can animate both the hands and the gun at once.

The animations look alright in Blender, everything seems to work correctly. However, when I try to export to GLTF (.glb), all objects that have been directly parented to bones of the armature have incorrect transforms and are offset in a weird way.

I found an issue on GitHub that suggested turning off ‘+Y Up’ or enabling ‘Always sample animations’ in the export settings might fix the issue, but even after trying to change all of the export settings for GLTF, nothing seems to work.

Has anyone ever had this problem or does someone know a fix for this?

Apply your object transforms before exporting. Ctrl A - all transforms

Applying all Transforms doesn’t work unfortunately, the rig still looks the same when exported:

1 Like

Sounds like this may be a bug — is this a new or old version of Blender? If you’re able to share the model (or another that reproduces the issue) I would report it at https://github.com/KhronosGroup/glTF-Blender-IO. Some skinning issues have been fixed in recent Blender updates.

I tested it in both 3.0 and the latest 3.3 Experimental build (with the same file), I’m currently trying to reproduce the issue in another file to then share it, though I can’t seem to reproduce it consistently.

Even stranger (sorry for replying to you again but I feel like this might help with a bug report), I copied the rig from the original file into a new Blender 3.3 Alpha project, and now it sometimes exports with the objects still at wrong locations and other times I get an error when trying to export. (I should add that I got the same error for the same file in previous blender versions (3.0) before)

Then another time when I exported it without pushing to NLA tracks first, it exported correctly, but with only one animation. At this point I’m clueless as to what is happening so I attached the test file to this reply in case you (or someone else) can find out more.

Reproduction Project:
(I can’t add attachments so I uploaded it to filebin instead)
https://filebin.net/fi0satzcnhb224wp/BugReproduction.blend

Error message:

Python: Traceback (most recent call last):
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\__init__.py", line 637, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 46, in save
    json, buffer = __export(export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 63, in __export
    __gather_gltf(exporter, export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 77, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 39, in gather_gltf2
    animations += __gather_animations(blender_scene, export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 83, in __gather_animations
    animations_, merged_tracks = gltf2_blender_gather_animations.gather_animations(_blender_object, merged_tracks, len(animations), export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animations.py", line 76, in gather_animations
    animation = __gather_animation(blender_action, blender_object, export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animations.py", line 114, in __gather_animation
    channels=__gather_channels(blender_action, blender_object, export_settings),
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animations.py", line 149, in __gather_channels
    return gltf2_blender_gather_animation_channels.gather_animation_channels(
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 65, in wrapper_cached
    result = func(*args)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_channels.py", line 43, in gather_animation_channels
    groups = __get_channel_groups(blender_action, blender_object, export_settings)
  File "D:\Programme\Blender\Blender 3.0\3.0\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_animation_channels.py", line 367, in __get_channel_groups
    if rotation and target.rotation_mode not in rotation_modes:
AttributeError: 'Pose' object has no attribute 'rotation_mode'

location: <unknown location>:-1

I’ve stumbled across this same issue when exporting to glTF/GLB and viewing them in 3D Viewer for Windows 10 (Windows 11 removed it). I was never able to reproduce it in a fresh blend, oddly. But what I did find that helped in the buggy blend was to unparent a parented weapon (your gun in this case) from the mesh (arms) that is parented to the armature or from the armature if the weapon is parented to the armature.

2 Likes

Glad someone else was having the same issue. What exactly do you mean by unparenting? Like unparenting the gun from the armature wouldn’t really make sense since I would no longer be able to animate it.

Here is how my setup currently looks (the magazine and the melee weapon (BrassKnuckle) each are seperated from the gun and parented to yet another bone of the armature)

image

I meant unparent all of your items, with the exception of your arms. By doing so, you unfortunately won’t be able to animate them, as you mentioned. You’d need to export them separately and than reassign their parenting in your other software, if possible.

If you’d like, I can take a look at your blend. Fyi, try previewing in other 3rd-party previewers that support glTF & animation such as sandbox.babylon.com or https://playcanvas.com/viewer.


By the way, is your armature in Pose or Rest mode might I ask?

1 Like

Thanks, unparenting and then reparenting in the software (Godot Game engine in my case) works as a workaround to what seems to be a bug.

My armature is set to ‘Pose Position’.

Also, since there doesn’t seem to be another way around this issue, should I mark your answer as the solution?

Sorry, I didn’t see this late part of your message. I already marked my post as the solution, if you don’t mind. I also bookmarked your this thread as a future reference. I’ve told and help others who’ve had this same armature-parenting bug. I believe it’s caused by the Blender glTF 2.0 exporter. I’ve been tracking and researching their open/closed reports at their Github repository, but so far no open issues that seem related. There was this closed issue, but I’m not entirely convinced that this could be the issue. And even if it was, it’s supposedly fixed, which means it would be on the Blender developer’s end for not updating their add-on source.

1 Like

Just coming back to this post to say that this bug in the glTF exporter seems to be fixed in Blender 3.5, so for anyone still having the issue, updating to the newest version of Blender should fix it.

1 Like