How to make smooth mesh lookAt?

I have two objects: mesh.position, mesh.rotation and lookPoint: Vector3. I need to make slow and smooth transition between two rotations so I can’t just use mesh.lookAt( point ).
How can I find target rotation for the mesh object?

Hello! I would get the rotation matrix of the two orientations by using the Matrix LookAt: Matrix | Babylon.js Documentation, convert to Quaternions: Quaternion | Babylon.js Documentation and interpolate by using Slerp: Quaternion | Babylon.js Documentation

1 Like

Thanks! That’s the good idea! Ended up with the following code using your links. I’ll put my solution here in case of someone will be looking for similar question.

const lookAt = BABYLON.Matrix.LookAtLH(
	followerObj.position,
	targetObj.position,
	BABYLON.Vector3.Up()
).invert();
followerObj.rotationQuaternion = BABYLON.Quaternion.FromRotationMatrix( lookAt );

So now we can just use BABYLON.Quaternion.Slerp( rotationFrom, rotationTo, dt ).

3 Likes