Meshes attached to bone get scaled

Hello everyone, I was attaching an object, which consists of several meshes, to a bone. To make things simpler, I created a TransformNode and added all the meshes to the transform node and then attached the TransformNode to the bone.

Now, after I added the TransformNode to the bone, the TransformNode appears to be scaled by an amount which is equal to the scaling of the parent mesh of the skeleton. Is this the expected behavior? How to prevent the TransformNode from being scaled on being attached to a bone?

It is probably related to what your animation is doing and might need to reexport it.

A playground would definitely help digging deeper.

2 Likes

Here is a playground example:

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

Please press the key “p” on the keyboard to pick up the red sphere. Not sure what I am doing wrong here. Thanks in advance.

This is expected as the mesh you pass in is having a scale so it applies to the attached element.

What you could do is create inversely scale the mesh to attach:

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

1 Like

Thanks for the clarification. That’s exactly what I did but, somehow, was not not sure I was doing the right thing.

Also when a mesh is far from world origin and it is attached to a bone, the mesh will appear nowhere near the bone unless you set the position of the attached mesh to (0 0,0) or to somewhere close to the origin before calling attachToBone. This is not documented anywhere but is important as it may look like the mesh is not attached to the bone which may lead to thinking that attachment is not working. The mesh is attached to the bone in this case but with a large offset.

3 Likes

Adding @PirateJC to improve our doc :slight_smile: cause his english his infinitely better than mine

1 Like

@idutta2007

Any interest in taking a stab at writing a small note of clarification for our documentation?

If you submit a PR and copy me on I’d be happy to review it.

Thoughts?

1 Like

Yes, I will be happy to do so. Please send me the repository info. I will create a branch and submit a PR and add whoever wants to review it - thanks.

1 Like

GitHub - BabylonJS/Documentation: Babylon.js's documentation website is our doc repo, basically just need to update the md in content and it should be good to go :slight_smile:

1 Like

@sebavan, sounds good.

2 Likes

Yup perfect!

Thanks @idutta2007 !!!

2 Likes

It is done now! Here is the pull request:

4 Likes

Love it! Thoughts @PirateJC?

2 Likes

Merged!

Awesome Job @idutta2007!

Congrats on your first PR and a very sincere welcome to the Babylon family!

So glad to have you as a part of our awesome community!

3 Likes

Happy to help and an wonderful community!

3 Likes