Hi everyone,
I am currently making a panel dashboard and want to use the VTK pane to display some objects. In my main script I have a series of objects where I am updating the colour based on a button being pressed. To update the plotter with the new colours i have been using ‘synchronize()’, but here is where i run into issues.
In calling the synchronize method multiple times, the vtk pane start to lag quite considerably, to the point where it becomes basically unusable.
I have recreated a simple example, with a button that only synchronizes the window:
import pyvista as pv
import panel as pn
pn.extension('vtk')
class test_page:
def __init__(self):
self.update_button = pn.widgets.Button(name="DEMO", button_type="danger", align='center')
self.update_button.on_click(self.update_clicked)
self.plotter = pv.Plotter()
self.plotter.background_color = (0.1, 0.2, 0.4)
self.terrain_pane = pn.pane.VTK(
self.plotter.ren_win,
height=600,
width=600,
enable_keybindings=True,
orientation_widget=True
)
pvcylinder = pv.Cylinder(resolution=8, direction=(0,1,0))
self.plotter.add_mesh(pvcylinder, color='red', smooth_shading=True)
self.layout = pn.Column(self.terrain_pane, self.update_button)
self.layout.show()
def update_clicked(self, event):
print('Update Clicked')
self.terrain_pane.synchronize()# This is causing lag
test_page()
Although the first few syncs are okay after a while the lag becomes more noticeable. Is there anyway I can update the colors avoiding syncing, fix the syncing so it doesnt cause this immense lag or another better way of achieving this?