I am trying to understand three.js's camera.lookAt function, and to implement my own.
I'm using eye = camera position, target = target look at point, and up is always (0, 1, 0). A friend proposed that the obvious way to rotate a camera to look at a point in space would be to get the desired forward by calculating target - eye, and compute the angle between the camera's forward vector (0, 0, -1) and the target forward (using atan2 method described in these answers), and this is the angle of rotation. I would be able to find the axis of the rotation by computing the crossProduct of the forward vector and the desired forward. I would use a function like setFromAxisAngle to get the resulting quaternion.
Tried to draw it here:
Would this work in theory? When testing it against the canonical lookAt method, which uses eye, up, and target and does z = (eye - target), x = Cross(up, z), y = Cross(x, z) -- (also, why is it eye - target instead of target - eye?) -- I see small ( < 0.1 differences).