glotzerlab / plato

Efficient visualization of particle data supporting several rendering engines.
https://plato-draw.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
12 stars 4 forks source link

Material transparency in pythreejs #15

Closed bdice closed 5 years ago

bdice commented 5 years ago

This PR resolves #14 by adding material transparency to the pythreejs backend.

This only works when all colors in the primitive have the same alpha value, and it doesn't trigger material transparency unless those colors have alpha < 1.

Three.js doesn't support RGBA values for each vertex, which may be necessary to make this work for individual shapes in a primitive (https://github.com/mrdoob/three.js/issues/2118). It might be possible to enhance this feature by using custom shaders, but that's currently out of scope for me.

To show this transparency more clearly, I modified the ConvexPolyhedra test to make those shapes slightly more transparent.

Example (rotated from default view for the test scene)

image