Spaces:
Paused
Paused
File size: 859 Bytes
aed1755 bf6f707 7c5bb4c bf6f707 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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") |