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

Embedding less data for pythreejs #20

Open
bdice opened this issue Mar 10, 2019 · 2 comments
Open

Embedding less data for pythreejs #20

bdice opened this issue Mar 10, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@bdice
Copy link
Member

bdice commented Mar 10, 2019

It's possible to embed pythreejs 3D visualizations into documentation with Sphinx: https://pythreejs.readthedocs.io/en/stable/examples/Geometries.html

I have played with saving widget states into Jupyter notebooks for this purpose, and it works! I think this would be awesome for sharing interactive examples with 3D data from HOOMD and freud.

However, the data used by plato's pythreejs backend may be much larger than necessary, resulting in enormous file sizes of the resulting notebooks and slower loading / rendering. I built a notebook that visualizes a couple scenes like the one shown below (significantly smaller than most simulations in our group) and it ballooned to hundreds of megabytes, which isn't conducive to web viewers or file sharing. In my understanding, a vastly smaller data format could be used for most scenes without any loss of quality.

image

For example, the current sphere geometry class builds a buffer geometry of vertices and per-vertex colors, storing (N * 64 * (3 + 4)) float values for the vertex positions and colors alone, not counting however many integer face indices are required to construct the convex hull. I think this could be replaced by a SphereBufferGeometry that stores only positions, radii, and per-shape colors, resulting in the storage of something more like (N * (3 + 1 + 4)) values. That's a savings of about 56x for spheres, not counting the unnecessary storage of face indices.

I am not completely certain if this will work, but I believe it's worth trying with the Sphere class to see how it performs.

@klarh klarh added the enhancement New feature or request label Mar 10, 2019
@klarh
Copy link
Collaborator

klarh commented Mar 10, 2019

This seems like a good idea, but if we run into any limitations in three.js, it may be worth revisiting (once more) the idea of making our own plato.js library and ipywidgets-based adapter that is able to use the exact same schema as plato itself.

@klarh
Copy link
Collaborator

klarh commented May 14, 2019

In case anyone ends up tackling this later, @bdice pointed to a page in the pythreejs documentation that may be helpful. Making a proper ipywidgets extension as the documentation seems to imply would be necessary involves a lot of work as far as I recall, but it may be worth it at some point.

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

No branches or pull requests

2 participants