This code runs as expected when let
block is uncommented:
using AbstractPlotting, GLMakie
using GLMakie.GLFW
using GLMakie: to_native
# let
npoints = 10
points = Node(Point3f0.(rand(npoints), rand(npoints), rand(npoints)))
scene = Scene(limits = FRect3D(Vec3f0(0), Vec3f0(1)), resolution = (1200, 1200), camera = cam3d!, show_axis = false)
scatter!(scene, points)
window = to_native(display(scene))
GLFW.SetWindowTitle(window, "Test $npoints")
on(events(scene).keyboardbuttons) do key
ispressed(key, Keyboard.escape) && GLFW.SetWindowShouldClose(window, true)
ispressed(key, Keyboard.page_down) && (npoints = max(2, npoints-1))
ispressed(key, Keyboard.page_up) && (npoints += 1)
GLFW.SetWindowTitle(window, "Test $npoints")
points[] = Point3f0.(rand(npoints), rand(npoints), rand(npoints))
end
# end
but when it is commented, I’m getting:
UndefVarError: npoints not defined
Why is that?