trying to manually reposition some bones in skeleton, with something like this:
function reposition(position: BABYLON.Vector3, bone: BABYLON.Bone) {
// same issue is using bone.setPosition or just bone.position
bone.setAbsolutePosition(position);
// this should always be 0!
const errorOffset = Vector3.Distance(position, bone.getAbsolutePosition());
}
and that works fine while repositioning a single bone at the time
but when trying to manipulate multiple bones which have hierarchical relationship, it works for first bone (e.g. Hips as that is the root bone of a skeleton)
but if trying to reposition any of the child bones in the same pass results in some offsetError
(which can be quite large and causes visual artifacts and overall skeleton tearing)
and running reposition again immediately doesn’t change it at all
only solution is to let scene render and repeat the same operation several times
(each time errorOffset gets smaller until it hits zero)
how can i force recalculation so multiple bones can be repositioned in the single pass?
or alternatively, how can i even know that i shouldn’t touch a specific bone since some of its parents have not yet updated rendering?
i’ve tried checking isDirty for all bones and it doesn’t do much
i’ll try to create a playground reproduction, but i hope you get the idea from the description
It seems that just calling computeAbsoluteTransforms() on the bone after calling setAbsolutePosition() on it positions the bones correctly and reduces the calculated error to 0 (or basically 0, like 1e-21).