I have a character loaded into the scene using ImportMesh. I am also loading animations into the scene using ImportAnimations.
The issue is that once animation is applied it completely deforms the original mesh. Here is the playground with my exact situation and files.
I am not sure how to proceed with the issue. There is slight difference between skeleton of the original mesh and skeletons of the animations (root bones).
I attached the both files used in here if it helps inspect the problem.
But with the original mesh skeleton “web_avatar.glb”, if I manually rotate the bones the mesh is following perfectly. Doesn’t that indicate that skin is fine? Shouldn’t imported animation just drive the existing skeleton, which is working fine with the mesh?
Does imported animation skeleton replaces the original skeleton on the mesh?
Maybe need some way of retargeting properly?
Ok, so the problem is with the skeletons that don’t have the same hierarchy, so there’s no correspondance between bone B1 at index i in the skeleton S1 and bone B2 at index i in skeleton S2.
Actually, there’s only a shift of one bone between both skeletons: skeleton S1 from walk.glb has an additional bone (“Armature”) at the root compared to the skeleton S2 of the avatar. Note that there’s an additional bone named “Joint1” in S1, but this one does not count because it has an index of -1, so it is not really used in the bone hierarchy.
It means we can make the meshes that have S2 as their skeleton use the skeleton from S1 by adding 1 to the bone indices in the “matricesIndices” vertex data:
Note that there is a problem with the eyes (left and right) because S1 don’t have those bones. As they are located at the end of the skeleton (indices 52 and 53 in S2), they are not a problem for the animation (which animates only bones from 0 to 52 in S1), but because they don’t have animation data, they don’t animate properly.
Amazing @Evgeni_Popov. Thank you so much. This is very helpful for the project I am working on. Me and my team will make changes on the skeleton to fix the eye issue.