skoch9 / meshplot

Plot 3D triangle meshes
GNU General Public License v3.0
148 stars 37 forks source link

Is there any way to advance time in offline website viewer, and keep it in one plot #19

Open otmanon opened 4 years ago

otmanon commented 4 years ago

Hi, I'm currently interested in having a mesh, and deforming it with time. The examples I've seen (using libigl with meshplot) , seem to not show the mesh object changing with time, but instead show snapshots of the mesh taken at a specific time.

What I'd like to do is have a mesh at the start of the simulation, run the simulation, and be able to see it deform in real time in the viewer. I can't seem to find any functionality for it in the source code, does it exist? Can you think of a workaround I could do instead? Thanks

skoch9 commented 4 years ago

Hi, you can update your plotted objects with the function p.update_object(vertices=new_v). A possible example of a plot that you describe then looks like this

import meshplot as mp
import time

p = mp.plot(v, f)

for i in range(100):
    v_new = run_simulation_step(v, f, ...)
    p.update_object(vertices=v_new)
    v = v_new
    time.sleep(0.1) # depending on how long your simulation step takes you want to wait for a little while
bmahlbrand commented 4 years ago

in the same vein, i'm curious about updating the wireframe of the plot for this purpose