enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Backface culling using X3D backend in Jupyter #485

Open nicoguaro opened 7 years ago

nicoguaro commented 7 years ago

In Jupyter I use

from __future__ import division, print_function
from mayavi import mlab
import numpy as np

mlab.init_notebook()

fig = mlab.figure(bgcolor=(1.0, 1.0, 1.0))
phi, theta = np.mgrid[0:np.pi:51j, 0:2*np.pi:51j]
x = np.sin(phi) * np.cos(theta)
y = np.sin(phi) * np.sin(theta)
z = np.cos(phi)
sphere = mlab.mesh(x, y, z, colormap="summer", opacity=0.6)
sphere.actor.property.backface_culling = True
fig

to obtain

screenshot1

In a regular Python script I use

from __future__ import division, print_function
from mayavi import mlab
import numpy as np

fig = mlab.figure(bgcolor=(1.0, 1.0, 1.0))
phi, theta = np.mgrid[0:np.pi:51j, 0:2*np.pi:51j]
x = np.sin(phi) * np.cos(theta)
y = np.sin(phi) * np.sin(theta)
z = np.cos(phi)
sphere = mlab.mesh(x, y, z, colormap="summer", opacity=0.6)
sphere.actor.property.backface_culling = True
mlab.show()

to obtain

screenshot2

Is there a way to make the backface-culling to work in the Jupyter Notebook (X3D)??

prabhuramachandran commented 6 years ago

I am not sure, I suspect you'd need to manually edit the X3D output generated. Transparency seems like an issue with VTK's X3D exporter.

nicoguaro commented 6 years ago

@prabhuramachandran, do you have a working example?

prabhuramachandran commented 6 years ago

No, unfortunately not, here is a useful link though: http://fpavogt.github.io/x3d-pathway/dices.html

fpavogt commented 6 years ago

There's actually a lot of issues with the VTK's X3D exporter, but I never got to actually do anything about them. All I did was list what I found in this "red dice" example, alongside my work-arounds (which require to tweak the resulting X3D file by hand). But Mayavi could definitely benefit a lot from an improved X3D exporter ...