Rotate around local axis using slerp

Hey,

I’d like some help with Quaternions. I want an object to rotate around its own local axes, using offsets. So, say offsetRotation = (0, 360, 0), I want the object to rotate 360 degrees around its local Y axis.

What I’m having trouble with is calculating the target rotation. I can get the startRotation using:

this.entity.getLocalRotation()

I can also convert the offsets to Quaternions using:

this.targetRotation.setFromEulerAngles(this.offsetRotation.x, this.offsetRotation.y, this.offsetRotation.z);

But to get the actual targetRotation, I have to offset the startRotation by the offset quaternion, in its local space. I just can’t figure out how to do this…

When it’s all done, I should be able to use:

rot.slerp( this.startRotation, this.targetRotation, this.percent );

Here’s the project, where you can see some of my attempts: https://playcanvas.com/editor/scene/725066

If you just rotating around the axis, you should be able to modify the w component as that represents the angle around the axis. https://developer.playcanvas.com/en/api/pc.Quat.html#w

I can’t remember if the engine uses degrees or radians.

You can always use the world space rotation instead?
https://developer.playcanvas.com/en/api/pc.Entity.html#getRotation

this.entity.getRotation();