I’ve been exploring the use of Meshes.jl in combination with Observables and GLMakie for live plotting of 3D objects. My goal is to dynamically update a plot by adding or removing 3D objects (like Box or Ball) and visualize these changes in real-time. Adding new objects to the plot works seamlessly, but I encounter a BoundError whenever I try to remove an object from the observable vector. This issue seems specific to 3D systems, as I don’t face the same problem with 2D objects.
Here is a minimal code snippet that reproduces the situation:
using Meshes
using Observables
using GLMakie
rand_boxes = rand(Meshes.Box{3, Float64}, 10)
obs_boxes = Observable(rand_boxes)
# create the plot
viz(obs_boxes)
# Adding a new box works without any problem
b = Meshes.Box((0,0,0), (1, 1, 1))
push!(rand_boxes, b)
notify(obs_boxes)
# Removing an item results in an error
pop!(rand_boxes)
notify(obs_boxes)
Could anyone help me to understand what might be going wrong or point me towards a workaround or solution? Thank you in advance for your insights and assistance!
I was thinking the same, but then I realized that if, instead of using Meshes.viz, I use Makie’s meshscatter, then there is no problem in removing items from the vector.
You can take a look into the viz recipe, it should take your vector of Box in 3D, place them into a GeometrySet and call this method:
You can run in debug mode to see which Makie function is being called at the end. I still believe it is an issue outside the scope of Meshes.jl since the case where you push! works as expected.
If the issue is really on our side, please open it on GitHub and we will take a look.