Attaching a mesh to a bone makes the mesh vanish

Hi everyone,

I ran into an issue while attaching a mesh to a bone in the player character with the player character loaded from a gltf file. Attaching meshes to bone worked fine when a similar character was loaded from a .babylon file. The gltf file was exported from blender.

Anyway, here is a playground example to show this:
https://playground.babylonjs.com/#39CVTR

Note that the red sphere is supposed to be attached to the character’s right arm when you press the key “p” on your keyboard. But the sphere simply vanishes - nowhere to be seen.

Give it a few seconds to load the playground as the mesh is loaded from github and may be bit slow first time.

Thanks
Indra

Hey Indra,

The problem seems to be the scaling of the sphere I tried increasing the scaling of the itemMesh after attaching the bone, and it seems to be there. I assume it was just too tiny to see before. Check out this playground link: Attaching a sphere to a mixamo character | Babylon.js Playground (babylonjs.com)

Hope this helps resolve your issue!

3 Likes

Thanks for looking into this. This definitely explains why the sphere was not seen. The mesh loaded from gltf file was scaled by a factor 1.5 - so I expected the red sphere to be scaled by a factor of 1.5 upon attaching to the bone. But that is apparently not the case.

Can someone please explain why the sphere was scaled to such a small size? When we attach a mesh to a bone, the result should be something predictable. It seems to me that in some cases the mesh gets scaled up and in some cases the mesh gets scaled down. See below a case where the mesh actually gets scaled up on attaching to a bone:

https://playground.babylonjs.com/#ZBL4E5

In both cases, the mesh loaded from a file, was scaled by a factor of 1.5.

Thanks
Indra

After reading some of the babylonjs code and doing some experimentation, this is what I have found out:

  • When a mesh is attached to a bone, it may be scaled multiple times based on hierarchy of bones to which it is attached.
  • The scaling of the bone, the scaling of the parent bone, the scaling of the grandparent bone and so on, all will be applied to the mesh.

In my case most bones in the hierarchy had scale factor of 1.0 but the root bone had scale factor of 0.001. Don’t know why it was so. But let’s say I hate 3D modelling due to lack of standard. :slight_smile:

Thanks
Indra

1 Like