Get Euler Angles from LookAt function

Hey All,

I’ve been using the lookAt function for some prototyping but am wanting to now smooth out rotation between points. It would be extremely helpful to be able to pull the desired Euler Angles (or Quaternions honestly) from the lookAt function. Is this possible or is there a place I can see the underlying lookAt code so I can do it myself?

Thanks in advance.

You can get a quaternion from the transform matrix:

const m = new pc.Mat4();
const q = new pc.Quat();

m.setLookAt(currentPosition, targetPosition, upVector);
q.setFromMat4(m);
2 Likes

Hi @Jake_Johnson! There are a couple of topics about it here on the forum. For example the topic below where I share my own solution in the last post.

@LeXXik Thank you this is what I went with. Very helpful.

@Albertos Thank you for pointing me to this. Great solution at the end.

1 Like