How to bind separate glb file such as cloth etc to armature?

Hi, Team, Actually I have a question about how to bind a separate glb file to a main armature?
My ‘cloth’ glb file that have same skeleton name and hierarchy structure.

I can bind it together on blender, and then I import to babylon sandbox to get the transform node info and mesh info. all working.

and then I export the separate file, but after I bind it together with babylonjs, seem like having some issue. I checked the babylon inspector and compared the bind glb version and no-bind glb version, seem like no issue.

Code:
const nodeArmature = scene.getTransformNodeByName(“Avatar_Root”);
const nodeShirt = scene.getTransformNodeByName(“Cloth_Geo_01”);
const meshShirt = scene.getMeshByName(“Cloth_Geo_01”);
const meshBody = scene.getMeshByName(“Body_Geo”);
nodeShirt.setParent(nodeArmature);
meshShirt.setParent(nodeArmature);
const skeleton = scene.skeletons[1];
meshShirt.skeleton = skeleton;
meshShirt.updatePoseMatrix(Matrix.Invert(Matrix.RotationY(-Math.PI / 3)));

No matter how, Thank you

cc @PatrickRyan @bghgary and @thomlucc as it seems a common request

1 Like

@Jun_Wah_Soh, the problem you are running into has to do with the skeleton in the cloth mesh. I know that you mentioned that the skeletons of both meshes were identical, but when I open your Cloth_Geo_02.glb file in Blender, the skeleton that the mesh is bound to is missing legs, head, and portions of the arms:

Where the skeleton on the character is a complete skeleton:

If you want to just assign the skeleton from the cloth mesh to the character’s skeleton, you need to skin the cloth mesh to an exact copy of the character skeleton so that the skin has all the information it needs. It may seem unnecessary to have all of the bones of a character in a mesh of just a shirt, but The vertices need to have weight information for each bone in the hierarchy, and when you retarget a mesh to a skeleton with a different hierarchy, it can cause unexpected results like this.

I hope this helps, but please let me know if you have more questions.

2 Likes

No matter how, Thanks you!! :smile:
but after I retarget the cloth to the character’s skeleton, before play the animation, actually no issue, but after I play the animation, then having some animation issue.