[SOLVED] Quat tweening

Hello!

Trying to get object to tween by -90 degrees every time object is clicked on.

Doing this directly with Euler angles results in Gimbal Lock

Below I have converted to Quaternion however when calling this tween multiple times the object scales strangly and rotates.

Any thoughts as to what is causing an unwanted scaling behaviour when code is called multiple times?

    var relativeRotationQuaternion = new pc.Quat().setFromEulerAngles(0, -90, 0);

    var targetRotation = this.entity.getLocalRotation().clone();
    targetRotation.mul(relativeRotationQuaternion);

    this.tween = this.entity.tween(this.entity.getLocalRotation())
        .to(targetRotation, 1.5, pc.Linear)
        .delay(0)
        .loop(false)
        .yoyo(false)
        .start();

Your code is correct and should be working fine. Can you make a small repro with an example on a cube that shows the problem?

Thanks @LeXXik - I’ve made a small repro here:
https://playcanvas.com/editor/scene/1829126

First click seems to work and then the cube starts scaling while rotating

I think you should use .rotate(targetRotation, instead of .to(targetRotation.

1 Like

Thanks @LeXXik that seems to fix it

1 Like

To be honest, I think .to should handle rotations as well. I’d say it is a bug in the library.

Feel free to submit a new issue to: