Update the plotter(pyvista) in streamlit dynamicly

Deploy : Running my app locallig.
Goal : developing a VISUALIZE TOOL for Autonomous Driving Dataset.
Questaion :
I want to render 3D point cloud within streamlit using pyvista and stpyvista.
Now, I can render single point cloud file.
But I want to plot a sequence of point cloud files, so I want to update the points in a single Plotter.
It should become a “GIF LIKE” image controled by a sidebar, and each frame is interactive.

Problem is that when I update the mesh.points, it does not update in the streamlit html.

def add_points(self, pdata)
    if self._plotter.mesh is not None:
        self._plotter.mesh = pdata[:, :3]
        self._plotter.scalars  = pdata[:, 3]
        self._plotter.render()
        return
    
    self._plotter.add_mesh(
        mesh=pdata[:, :3],
        color=color,
        style="points",
        scalars=pdata[:, 3],
        show_scalar_bar=show_scalar_bar,
        cmap=cmap)

PS: I really don’t want to use something like this :rofl: :rofl: :rofl:

plotter.export_html(tmp_html, copy=True)

# 读取 HTML 内容
with open(tmp_html, 'r') as f:
plot_html = f.read()

# 使用 Streamlit 组件嵌入 HTML
st.components.v1.html(plot_html, height=600, width=800)

That’s basically what stpyvista does under the hood. Check this example of a slider that controls the actor in the plotter:

The transition is not the smoothest because each interaction that modifies the plotter will trigger rebuilding the whole 3D view.

Instead of using Streamlit, I’d recommend you developing your app with Trame, which is specifically tailored for working with pyvista and vtk interactions.