After contemplating the use of three.js for incorporating 3D visualization into my Sphinx extension for model visualization, I realized that the current tool I am using is outdated and not being maintained.
The three.js library offers a variety of examples, and one that particularly caught my eye is the WebGL multiple elements text demonstration.
This example aligns perfectly with the requirements of my Sphinx extension because:
- It supports multiple scenes on a single page
- All scenes share the same WebGLRenderer, allowing for multiple instances on a page
- It enables the mixing of text and scenes seamlessly
However, there is one drawback to using this example - excessive CPU/GPU consumption even when the 3D visualizations are not being interacted with. To address this issue, I decided to eliminate animations and only render scenes upon user interaction:
Simple code change to stop animations and reduce CPU/GPU consumption when not in use...
With this adjustment:
- Animations are disabled, which is acceptable for my needs
- Unnecessary CPU/GPU usage is eliminated, achieving my goal
- Scenes remain interactive for user engagement
However, a new issue arises - the scenes do not scroll with the text when the user navigates down the page. How can I resolve this?
Considerations:
- The objective is to have minimal CPU/GPU consumption when the user is not interacting with the 3D scenes, ideally while scrolling through documentation pages
- Is it possible to reduce the impact of scrolling on CPU/GPU usage, similar to when the user is not interacting with the scenes?