testpyvista / app.py
pgleeson's picture
test mesh
7c5bb4c
Raw
History Blame Contribute Delete
859 Bytes
import streamlit as st
import pyvista as pv
from stpyvista import stpyvista
from stpyvista.utils import start_xvfb
if "IS_XVFB_RUNNING" not in st.session_state:
start_xvfb()
st.session_state.IS_XVFB_RUNNING = True
## Initialize a plotter object
plotter = pv.Plotter(window_size=[400,400])
## Create a mesh with a cube
mesh = pv.Cube()
## Add some scalar field associated to the mesh
mesh['my_scalar'] = mesh.points[:, 2] * mesh.points[:, 0]
## Add mesh to the plotter
plotter.add_mesh(mesh, scalars='my_scalar', cmap='bwr')
mesh = pv.read('a_mouse.obj')
plotter.add_axes()
plotter.enable_mesh_picking()
plotter.add_mesh(mesh, smooth_shading=True)
## Final touches
plotter.view_isometric()
plotter.add_scalar_bar()
plotter.background_color = 'white'
## Pass a key to avoid re-rendering at each page change
stpyvista(plotter, key="pv_cube")