Positioning CameraPersp with weird results

I’m trying to record some manually-placed camera positions in my scene and return to them later, but the resulting view is not the same as the one I try to set.

After placing the camera, I print its eye point & view direction. I set up a few key inputs to return to those views using setEyePoint() & setViewDirection(), yet the camera looks like it’s in a different position. Should I be using some other parameter, or using lookAt() instead? Do I need to worry about the pivot distance? It seems like that’s only needed for interaction, so I would guess not.

Well, looks like all I was missing was setWorldUp(vec3(0, 1, 0)); :man_facepalming:

You can set everything in a single call using mCam.lookAt( eye, pivot, up ), where pivot equals eye + distance * direction. The pivot is only used when you manually manipulate the camera using a CameraUi (it’s the point around which your view is rotated), but isn’t practically used otherwise.

Use mCam.getPivotPoint() to calculate the pivot yourself.

To properly store the camera’s parameters, store the eye point, pivot and up vector (as well as the vertical field of view and the lens shift). Aspect ratio and clip planes aren’t as important, as they may vary with viewport size.