Potential problems in Bone class

While investigating Return to Rest not Behaving as Expected?, I came to two things that may be bugs, so I would need experts to have a look:

  1. computeAbsoluteTransforms does not compute the invert absolute transform matrix. I think it needs to be added just before the loop on the children:
public computeAbsoluteTransforms(): void {

    if (this._parent) {
        this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
    } else {

        var poseMatrix = this._skeleton.getPoseMatrix();

        if (poseMatrix) {
            this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);

    this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform); // <== added
    var children = this.children;
    var len = children.length;

    for (var i = 0; i < len; i++) {
  1. translate (same problem in setPosition). When in the space = World case, if the bone has no parent, the tmat matrix used to compute the translation values is undefined (it has values from some previous computations). I think the code should be updated as:
var tmat = Bone._tmpMats[0];
var tvec = Bone._tmpVecs[0];

if (this._parent) {
    if (mesh && wm) {
        tmat.multiplyToRef(wm, tmat);
    } else {
} else { // <== added
    Matrix.IdentityToRef(tmat); // <== added

tmat.setTranslationFromFloats(0, 0, 0);
Vector3.TransformCoordinatesToRef(vec, tmat, tvec);

Would you be ok to do a Pr of the suggested changes? This will help evaluating the issue

Thanks a million


The fixes in this thread are unrelated to this problem (or at least they don’t fix it), I think it’s better to keep Return to Rest not Behaving as Expected? going.

Ill move it

Im seeing a lot of skeleton stuff pop up about how the last build broke things.

Is this related?