I have a figure with two LScenes and a slider which is used to change data in the scenes. I have linked the cameras in the two LScenes, using the method shown in this post. The problem is that when I change the slider one of the camera gets reset. Here is the MWE,
using GLMakie
npts = 100
n = 10
pts_1_series = [rand(Point3f, npts) for _ in 1:n]
pts_2_series = [rand(Point3f, npts) for _ in 1:n]
fig = Figure()
l1 = LScene(fig[1,1], scenekw=(;center=false))
l2 = LScene(fig[1,2], scenekw=(;center=false))
sg = SliderGrid(fig[2,:][1,1], (label="n", range=1:n, startvalue=1), width=350, tellwidth=false)
pts_1 = @lift pts_1_series[$(sg.sliders[1].value)]
pts_2 = @lift pts_2_series[$(sg.sliders[1].value)]
scatter!(l1, pts_1)
scatter!(l2, pts_2)
link_cameras_lscene(f; step=0.01) = begin
scenes = filter(x -> x isa LScene, f.content)
cameras = map(x -> cameracontrols(x.scene), scenes)
for i ∈ 1:length(cameras)
on(cameras[i].eyeposition) do eye
for j ∈ 1:length(cameras)
i == j && continue
if sum(abs, eye - cameras[j].eyeposition[]) > step
update_cam!(scenes[j].scene, cameras[i])
end
end
end
end
f
end
fig = link_cameras_lscene(fig; step=0.1)
Any idea how I can stop the cameras from updating on slider change?