Camera panning issue when using parenting

Hello everyone!

I am experimenting with camera panning in conjunction with a parent TransformNode.

When the parent transform rotates, I would expect the camera panning to happen in the local space of the parent TransformNode, but this is not the case:

I tried defining the panning axis by hand using the up vector of the parent transform, but it looks wrong so I guess I am not understanding something.

Any ideas on what could be wrong here?

I’m guessing that’s where the problem comes from, as far as I know target is local space, but there’s a world-space vector added here

Changing the source code like this fixes the problem

                    if (this.parent) {
                        const m = TmpVectors.Matrix[0];
                        Vector3.TransformCoordinatesToRef(this._transformedDirection, this.parent.getWorldMatrix().getRotationMatrix().invertToRef(m), this._transformedDirection);
                    }
                    this._target.addInPlace(this._transformedDirection);
2 Likes

Nice catch thank you!

I can make it a bit faster by transposing the rotation matrix instead of inverting it. I will make a pull request at once.

Associated PR:

Once it is merged, this should work:

1 Like

:joy: Awkward, I actually sent a pull request right after I replied to you.

3 Likes

But you’re right, I didn’t think about optimizing performance with transposed matrices.

bruuuh :joy: Too fast for me, sorry I didn’t check before making my own!

1 Like