And more Spaghetti Monster
What and what and what?
Why would spinning up a SkeletonViewer make a spaghetti monster.

Man you are asking a lot of questions!

1 Like

The problem is they seem to be different things so I am trying to keep them separate as far as topics otherwise Id just keep the same topic rolling.

Makes sense!

It seems that this one is linked to the fact you added the viewer so it should be something to investigate as the viewer should not have ANY impact on the skeleton

Shows that its something odd, because you would think it would happen to every model then.

This one has been introduced lately and is fixed by:


The skeleton viewer has some impacts because it calls skeleton.computeAbsoluteTransforms() which update the absolute transform matrices (when you set autoUpdateBonesMatrices = true).

The calls to getPosition also trigger a call to computeAbsoluteTransforms.

this is maybe where we can improve it so it could compute stuff without being impactful on the skeleton

It does not impact the skeleton but the bones (maybe that what you meant).

Note that calling bone.getPosition() also calls bone.computeAbsoluteTransforms() in the end, and the skeleton viewer can’t avoid calling getPosition

Here’s the source of bone.getPositionToRef():

    public getPositionToRef(space = Space.LOCAL, mesh: Nullable<AbstractMesh>, result: Vector3): void {
        if (space == Space.LOCAL) {
            var lm = this.getLocalMatrix();

            result.x = lm.m[12];
            result.y = lm.m[13];
            result.z = lm.m[14];
        } else {
            var wm: Nullable<Matrix> = null;

            //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
            if (mesh) {
                wm = mesh.getWorldMatrix();


            var tmat = Bone._tmpMats[0];

            if (mesh && wm) {
                tmat.multiplyToRef(wm, tmat);
            } else {
                tmat = this.getAbsoluteTransform();

            result.x = tmat.m[12];
            result.y = tmat.m[13];
            result.z = tmat.m[14];

There’s a this._skeleton.computeAbsoluteTransforms(); (which in turn calls computeAbsoluteTransform for each bone) in the space=WORLD case (which is the one used by the skeleton viewer).

Yep :slight_smile:

I did not have time to dig into it for now but can you summarize for me why calling computeAbsoluteTransforms is a problem?

It is not a problem, I was replying to:

It will not be possible to not being impactful on the skeleton when using the skeleton viewer because it is calling bone.getPosition which in turn call computeAbsoluteTransforms(), which in turn update the _absoluteTransform property of the bone => so it is changing the internal state of the bone.

Yep I get that but I do not understand why this is impacting the rendering
this is where we have the issue for sure. It should not be a problem to do that

The impact on the rendering (meaning the visual problem) was because of the bug I introduced: with the latest fix there’s no more visual problem by adding a skeleton viewer to the scene.

1 Like

oh ok this is great then :slight_smile: