Attach mesh to bone => wrong position

Hello guys, I have recently got some models and created some animations for my game, but I have ran into one issue fairly quickly - when I am attaching mesh to the bone, it is misplaced (and I mean misplaced compared to the bone position in Blender).

In Blender my “swordBone” is in right hand, but it appears to be in left hand when imported into application. It is something I can live with, but it will be better when it could be fixed somehow :slight_smile:


Thanx greatly in advance for some advice :slight_smile:

Hey! can you repro in the Playground? Will be far easier to help

Well looking at your 2 images, I see the bone you want to add the "sword" to, and I see where the “sword” ends up. So I will add my immediate thoughts.

The "sword’ seems to be added to the left side but not to the hand. It ends up near the top of the glove.

I am intrigued by the position that the “sword” mesh has before it is attached. Is it binding to the wrong bone? Or is there an issue with the origin and rotation of the sword before it binds to the hand bone?

Here is an example that I did a longtime ago updated just to use Babylon Js 4.1xx :slight_smile:


Click on the “sword” to bind to the skeleton. Click the sword again to unbind it.
Now click the T-shirt to animate the hand with and without the “sword”

Note the position of the unbound “sword” - the origin is 0,0,0 (between the legs). There is a slight rotation which accounts for the slight angle of the hand

As @Deltakosh suggests, more info would help - eg: the blend file

cheers, gryff :slight_smile:

1 Like

Hello, that small misplacement - weapon appears higher than it should was caused by transforms in Blender, that was not applied. I have applied all transforms and then sword appears where the swordBone is - but on the other hand.

Interesting is, that it works ok when I export into Babylon file, but it switch hands when exported into gltf. I will create playground with it ASAP:

Hello mate, is it possible to link my model from my server to Playground ? My model is on this URL:

But I am unable to link it from the plyground because cross-origin browser policy :-/ is there some other way how to use my gltf file in playground to reproduce that problem ?

Here is a doc that can help creating the pg: Using External Assets - Babylon.js Documentation

The coordinate system is right-handed in gltf files and left-handed in Babylon: maybe you can try to set the scene as right handed and see what happens (scene.useRightHandedSystem(true))?

There was once a discussion about having a flag to convert the right-handed to left-handed coordinates when loading a gltf file, but I don’t know if it were ever implemented.

By default gltf file are converted back to left handed so it should not be a problem

Surprisingly - scene.useRightHandedSystem = true; HELPED !

Sword is now correctly in right hand … but whole scene is flipped and models walking backwards which is certainly funny :slight_smile:

EDIT: I could tweak my scene to work with this “flipped” system, but problem is, that other models that are in babylon format (and not in GLTF) are then flipped too (because they were ok in the first place) It would be better if both formats use the same system :slight_smile:

That’s strange because the sword bone is really on the right side when viewing your GLTF in the Babylon sandbox.

I think you may have some offsets on the sword mesh itself that makes it appear in the left hand whereas it is really linked to the right one…

If you can setup a PG with the code you use to attach the bone, I think we will be able to see what’s going on.

Hello, there is really no offset - that sword even moves with the left hand instead of right hand. I will create sandbox example as soon as possible.


Hello guys I have found that problem. Somehow my source mesh (in gltf file) had Z scaling value = -1 and I have later changed it to +2 (positive value) which rotated whole mesh. When I respect the original value, then sword appears correctly. It is really weird because I am always applying all transformations in blender before I exporting files. :frowning: