I am trying to use Makie.jl to create a nice 3D visualization of a galaxy survey. Essentially, I count the number of galaxies within a grid cell, and then use GLMakie.volume(vol). The interactive display is already pretty nice!
Now, I would like to make an animation where the camera flies through the survey volume. I’m trying to follow this tutorial. However, I’m not sure how to control the camera. Here is a minimal example:
The camera view seems to only sporadically update in a nondeterministic way. That makes it very difficult to develop some intuition on the correct parameters.
Changing the lookat vector seems to have much smaller effect than I would expect. For example, changing it to (0,0,1), I would expect the camera to look straight up and miss the cube entirely. Instead, the cube is still there.
After a few attempts the cube no longer looks the same, even with the original view. Though using the mouse to rotate the cube fixes it - after the cube jumps to a new place.
or update the three Observables via update_cam! arguments, as is used later in the tutorial you refer to. Replacing the camera = cameracontrols(scene) line by camera = Camera3D(scene.scene, projectiontype = Makie.Perspective) yields the same result, cf. this example in the Makie documentation.
We’re explicitly using update_cam! here to update the scene camera.
lookat refers to a point in space, not a viewing direction. (You might want to use Point3f to emphasise this.) For the scene scale, (0, 0, 1) is just quite close to (-0.5, -0.5, -0.5), so that the difference is not very noticeable. Try something like Vec3f(0, 0, 300) to look above the cube.
In the Makie.camera approach I can indeed replicate this, but not using cameracontrols or Camera3D. In the latter case our camera gets updated when manually interacting with the figure, while this is not the case in the former case: manual interaction causes the camera to snap back to its old settings. Perhaps the issue is related to the fact Makie then needs to store two separate cameras?
You can adjust the zoom level using zoom!(scene.scene, relative_zoom_factor). See https://docs.makie.org/dev/explanations/cameras#3D-Camera. E.g. zoom!(scene.scene, 0.5) makes everything bigger. Alternatively, you could change camera.fov[] (in degrees).
The link to the Cameras documentation is very useful. My feedback would be that core concepts like the meaning of lookat are a bit buried under the heading “other kwargs…”. I also find it surprising that “zoom” changes the eyeposition.
I need to play a little more with all the options, especially near and far, and the FlyThroughPaths.jl package, but thank you both for excellent answers.