marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
2.03k stars 265 forks source link

How to integrate interactive volume objects on Webpage? #1151

Closed ivishalanand closed 3 months ago

ivishalanand commented 3 months ago

I'm looking to render the RayCastPlotter for one of my use cases and have it available as an interactive display on a webpage. Currently, I'm trying to export a sample volume using the plt.export() method,it seems that Volume objects can't be rendered on a webpage via this method.

Tried code

from vedo import Volume, dataurl
from vedo.applications import RayCastPlotter

# Load Volume data
embryo = Volume(dataurl + "embryo.slc")
embryo.mode(1).cmap("jet")  # change visual properties

# Create a Plotter instance and show
plt = RayCastPlotter(embryo, bg='black', bg2='blackboard', axes=7)
plt.show(viewup="z")
plt.export('raycastplot.x3d', binary=False)

Could you provide guidance for rendering RayCastPlotter/ any volume object with interactive sliders on a webpage? Are there any workarounds that would enable this functionality?

marcomusy commented 3 months ago

Hi, no that unfortunately is not possible. The upstream VTK relies on a openGL rendering window which is not supported in the browser. The x3d format only supports polygonal mesh objects. Check out examples/notebooks/ for alternative backends.