Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot in a web page #192

Open
ssmns opened this issue Aug 11, 2020 · 14 comments
Open

plot in a web page #192

ssmns opened this issue Aug 11, 2020 · 14 comments

Comments

@ssmns
Copy link

ssmns commented Aug 11, 2020

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!)

@marcomusy
Copy link
Owner

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')

@ssmns
Copy link
Author

ssmns commented Aug 11, 2020

Thanks a lot.
This method works.

@ssmns
Copy link
Author

ssmns commented Aug 12, 2020

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.

@marcomusy
Copy link
Owner

how big is your data file on disk, before exporting?

@ssmns
Copy link
Author

ssmns commented Aug 13, 2020

The in put file : cavity.vtk (43.8 kb)
Output : .x3d (150 MB)

i used streamlines3.py code to generate x3d file

@marcomusy
Copy link
Owner

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..

@ssmns
Copy link
Author

ssmns commented Aug 14, 2020

I have some question ,
I need to export without showing anything . Just calculate then export.

@marcomusy
Copy link
Owner

Use offscreen keyword:

from vedo import *

pan = load(datadir+'panther.stl')

show(pan, offscreen=True)

exportWindow('panther.html')

@ssmns
Copy link
Author

ssmns commented Aug 16, 2020

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'

@ssmns
Copy link
Author

ssmns commented Aug 16, 2020

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 .

@marcomusy
Copy link
Owner

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 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.

@ssmns
Copy link
Author

ssmns commented Aug 16, 2020

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.

@ssmns
Copy link
Author

ssmns commented Aug 18, 2020

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...

@Owen-Miles
Copy link

Owen-Miles commented Apr 15, 2021

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants