Skip to content

Commit

Permalink
Ensure all camera attributes are updated in Makie
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed May 20, 2024
1 parent 1a39a20 commit 7e53145
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ext/FlyThroughPathsMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ FlyThroughPaths.capture_view(scene::Scene) = capture_view(cameracontrols(scene))
FlyThroughPaths.capture_view(axis::Makie.AbstractAxis) = capture_view(axis.scene) # by convention, all axes have a `ax.scene` that holds the scene with content

function FlyThroughPaths.set_view!(scene::Scene, view::ViewState)
Makie.update_cam!(scene, view.eyeposition, view.lookat, view.upvector)
cameracontrols(scene).fov[] = view.fov[]
# Extract the camera controls from the Scene
cam = Makie.cameracontrols(scene)
@assert cam isa Makie.Camera3D "`cameracontrols(scene)` must be a `Camera3D`, we don't support any other camera. Got $(typeof(cam))."
# Set the appropriate fields
cam.eyeposition[] = view.eyeposition
cam.lookat[] = view.lookat
cam.upvector[] = view.upvector
cam.fov[] = view.fov
# Update the camera using the new controls
Makie.update_cam!(scene, cam)
return scene
end

FlyThroughPaths.set_view!(axis::Makie.AbstractAxis, view::ViewState) = set_view!(axis.scene, view)

end

0 comments on commit 7e53145

Please sign in to comment.