# Issue with Live Plotting 3D Objects using Meshes.jl, Observables, and GLMakie: Bound Error on Item Removal

**URL:** <https://discourse.julialang.org/t/issue-with-live-plotting-3d-objects-using-meshes-jl-observables-and-glmakie-bound-error-on-item-removal/111253>\
**Category:** Visualization\
**Tags:** question, plotting, makie, meshes, observables\
**Created:** [March 6, 2024, 5:39pm UTC](https://discourse.julialang.org/t/issue-with-live-plotting-3d-objects-using-meshes-jl-observables-and-glmakie-bound-error-on-item-removal/111253 "2024-03-06T17:39:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehsani63](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ehsani63/32/38199_2.png) [@ehsani63](https://discourse.julialang.org/u/ehsani63)\
**Post date:** [March 6, 2024, 5:39pm UTC](https://discourse.julialang.org/t/issue-with-live-plotting-3d-objects-using-meshes-jl-observables-and-glmakie-bound-error-on-item-removal/111253/1 "2024-03-06T17:39:39Z")

</div>

I’ve been exploring the use of [Meshes.jl](https://github.com/JuliaGeometry/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:

```julia
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!

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 6, 2024, 6:58pm UTC](https://discourse.julialang.org/t/issue-with-live-plotting-3d-objects-using-meshes-jl-observables-and-glmakie-bound-error-on-item-removal/111253/2 "2024-03-06T18:58:56Z")

</div>

I believe this is an issue within Makie.jl given that Meshes.jl is just passing the vector of observables forward. cc: @sdanisch

---

<div class="post-metadata">

**Author:** ![ehsani63](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ehsani63/32/38199_2.png) [@ehsani63](https://discourse.julialang.org/u/ehsani63)\
**Post date:** [March 6, 2024, 7:06pm UTC](https://discourse.julialang.org/t/issue-with-live-plotting-3d-objects-using-meshes-jl-observables-and-glmakie-bound-error-on-item-removal/111253/3 "2024-03-06T19:06:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [March 6, 2024, 7:20pm UTC](https://discourse.julialang.org/t/issue-with-live-plotting-3d-objects-using-meshes-jl-observables-and-glmakie-bound-error-on-item-removal/111253/4 "2024-03-06T19:20:18Z")

</div>

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:

> <https://github.com/JuliaGeometry/Meshes.jl/blob/8ead2cba7d63278509e8c9f9ed8a0c3cb74b956c/ext/geometryset.jl#L5-L35>

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.
