Zoom, translate, rotate and save

I also want to create many 3D plots. I will zoom and rotate each to same extent and then save them. How to do it?
How to translate and rotate by code?
What is range of value that we can supply in zoom!() line end?

using GLMakie
fig = Figure()
ax = LScene(fig[1,1], show_axis=false)
box = Rect3f(Vec3f(-1, -2, -0.5), Vec3f(2, 4, 1))
mesh!(ax, box, color = :steelblue)
zoom!(ax.scene, cameracontrols(ax.scene), 2)
update_cam!(ax.scene, cameracontrols(ax.scene))
display(fig, update=false)

You can use translate_cam! and rotate_cam! but in my opinion update_cam!(scene, camcontrols, eyeposition, lookat, upvector) and the angle version are easier to use. eyeposition is where the camera is, lookat is the point it looks at and upvector is the up direction of your screen.

Iirc 0 < zoom_mult < Inf

1 Like

Please can you explain it in detail as i could not find examples in the 3D-Camera documentation.

I’m not sure what else there is to explain. Those variables are enough to uniquely define the camera orientation and position and the function applies them. To get an intuition for what the variables do, you can set up a demo scene and just try some different values

fig = Figure()
ax = LScene(fig[1,1], show_axis=false)
mesh!(ax, Rect3f(-0.2, -0.2, -0.2, 0.4, 0.4, 0.4), color = :gray)
mesh!(ax, Rect3f(0.5, -0.2, -0.2, 0.4, 0.4, 0.4), color = :red)
mesh!(ax, Rect3f(-0.2, 0.5, -0.2, 0.4, 0.4, 0.4), color = :green)
mesh!(ax, Rect3f(-0.2, -0.2, 0.5, 0.4, 0.4, 0.4), color = :blue)
update_cam!(
    ax.scene, cameracontrols(ax), 
    Point3f(2, 0.5, 1), Point3f(0, 0, 0.5), Vec3f(0, 0, 1)
)
display(fig, update=false)

Probably also useful to note that the camera tracks these values. If you interactively move and rotate the camera to an orientation you want, you can read out cameracontrols(ax).eyeposition[] etc. and restore the orientation by calling update_cam! with the same values.

1 Like