mp-react-components
mp-react-components copied to clipboard
Feature: Simple3DScene -> .png
It would be helpful to render 3D scenes directly to .png (such as crystal structures, or any other 3D scene we might draw, e.g. Brillouin zones, Wulff shapes, etc.)
Two options occur to me:
- Adapt the current component to render a .png on-the-fly, would be more limited to modern browsers but would presumably be quick to implement. This would involve, essentially, the same as the current capability to draw a png of the scene to a div:
https://github.com/materialsproject/mp-react-components/blob/d516af4a5820b9134d11548da6738ed762c23e92/src/crystal-toolkit-components/components-v2/Simple3DScene/Simple3DScene.ts#L513
Except we would skip adding the WebGl context itself to the DOM in this case.
- Alternatively (or in addition) figure out a way to do offline rendering using a headless browser (e.g. Chomedriver via Selenium) and render all images we want ahead-of-time, we can then store these in a database and write a dedicated API route to serve them. This might be useful for speed and compatibility.
Thoughts welcome!
Applications of this are (a) speed-up page load and provide images (both for end-user and for SEO), (b) allow new functionality, such as search results which include images of crystal structures or related crystal structures on the same page, where several dozen active WebGL contexts might not be practical, (c) improve accessibility for users from older web browsers or under-powered devices.