vedo
vedo copied to clipboard
plot in a web page
I can't find any example for show plot into a web application so is it possible to show an object in a web page ? If yes, how can do it (a simple example can help me!)
what you can do is to generate html code to be embedded into web apps.
Examples are:
https://vedo.embl.es/examples/geo_scene.html
https://fedeclaudi.github.io/br-mouse.html
The above are using k3d
for the actual renderings.
Exporting to X3D
is also possible:
https://vedo.embl.es/examples/fenics_elasticity.html
To generate these pages check out python examples:
examples/other/export_x3d.py
examples/advanced/geological_model.py
basically you just need to do:
exportWindow('page.x3d')
or
exportWindow('page.html')
Thanks a lot. This method works.
I use export x3d. And my file is very large. So I can say that "this method is not a good way to explore data into web" I used cavity.vtk example and export to x3d, the file size was about 400 MB. I change some parameter and reach a 140 MB file.
how big is your data file on disk, before exporting?
The in put file : cavity.vtk (43.8 kb) Output : .x3d (150 MB)
i used streamlines3.py code to generate x3d file
that's because there are too many vertices:
nr. of actors: 4 (829711 vertices)
you can try removing the arrows and decimate the lines with:
stream.clean(0.005) # impose a min point distance of .5% of the bounding box size
but... the k3d
is buggy for displaying lines so it might not work.. and x3d i'm not sure if it supports it ( in my browser it just doesnt work)
So it could be that streamlines3.py
is a case where we cannot do much..
I have some question , I need to export without showing anything . Just calculate then export.
Use offscreen keyword:
from vedo import *
pan = load(datadir+'panther.stl')
show(pan, offscreen=True)
exportWindow('panther.html')
Error after use show(pan, offscreen=True)
:
Traceback (most recent call last):
File "/workkpost.py", line 28, in <module>
show(stream,offscreen=True,axes=0)
File "/Python/miniconda/envs/pyWeb/lib/python3.8/site-packages/vedo/plotter.py", line 297, in show
_plt_to_return = plt.show(
File "/Python/miniconda/envs/pyWeb/lib/python3.8/site-packages/vedo/plotter.py", line 1774, in show
self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
AttributeError: 'NoneType' object has no attribute 'SetInteractorStyle'
by beloow i export data .
vp = vedo.Plotter(axes=5)
vp.load('motorBike.obj')
vp += stream
vp += stream1
vp.show(interactive=0,offscreen=1)
vedo.exportWindow(target)
but I see a bug in exportWindows():
If I have a one stream, every thing is fine but when I used two streams in show, exportWindows to x3d, miss a </X3D>
at end of file .
AttributeError: 'NoneType' object has no attribute 'SetInteractorStyle'
Uhm are you running it from terminal or in a jupyter/ipython session?
If I have a one stream, every thing is fine but when I used two streams in show, exportWindows to x3d, miss a </X3D> at end of file .
indeed i never tested it for multiple objects, but the html output is only meant as an illustrative example, what matters is the x3d file. You have to create your own html to embed it the way you like.
i used in terminal not into jupyter .
indeed i never tested it for multiple objects, but the html output is only meant as an illustrative example, what matters is the x3d file. You have to create your own html to embed it the way you like.
The exported file.x3d
missed </X3D>
in last line, I add a </X3D>
with a simple code, but I can't find watts happen in your code to solve it.
for sever used (without x server) the
vp.show(interactive=0,offscreen=1)
dosent work .
error:
[141CC74D] vtkOpenGLRenderWindows:1183 Error | vtkOpenGLRenderWindows (0x56 ..) bad x server conection . Display...
Hi all, not sure if anyone else is having this issue, but the exportWindow(.x3d)
uses self closing html tags that don't always work in x3dom. Not a biggie, I edit them manually, but something to note if anyone else has the problem trying to embed to a website.
Specifically the components: <Background /> <Viewpoint /> <NavigationInfo /><DirectionalLight />
that always start the <scene>
. It may be safer to make these not-self closing?
Possibly related other bug: There appears to be some jank with the axes when exported to .x3d. I have not been able to debug specifically yet, but will figure it out eventually and update. (ATM I think its a bad line transform, tick marks show out of place and grid lines look wacky).