GLMakie Camera Controls vs Scene Controls

Answering my own question for people watching this in the future…

cam3d!(s1)
camc = cameracontrols(s1)
update_cam!(s1, camc, Vec3f(0.0, 0.0, 5.0), Vec3f(0.0,0.0,0.0), Vec3f(0.0,1.0,0.0)) 
# Sets camera position, lookat and upvector
rotate_cam!(s1, camc, Vec3f(pi/3, 0, 0)) # pi/3 radians around the x axis

The documentation doesn’t explicitly state it but from my testing, you need to have a camera controls object passed in as well.

Also, the rotate_cam! function rotates the camera in body-fixed composition of Euler Angles… XY’Z’'.

You might want to look at

# Rotation Center
camc.settings.rotation_center[] = :eyeposition # default is :lookat 
# :lookat preserves the lookat point and rotates the camera around it, but :eyeposition rotates the camera around the eyeposition, preserving the eyeposition instead. Upto you what to preserve.
camc.settings.rotation_center[] = :lookat # default is :lookat

Camera Controls (camc) in this case has loads of attributes to play around with!
You can change the fields manually but need to call update_cam!(scene) function to reflect the changes, which from what I understood updates the camera fields like view, etc based on fields like camera position (aka eyeposition), lookat and upvector.

4 Likes