Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

dan_fulea's answer above is great advice for searching the source code of Sage as well as other places with the other functions he mentioned. I've worked on a few bug fixes / features for the three.js viewer, so I can perhaps point you to more specific locations:

The front-end consists of a single template HTML file containing the JavaScript that's used to render and manipulate the 3D scene. It's located at src/sage/ext_data/threejs/threejs_template.html.

The best place to start looking on the back-end is src/sage/plot/plot3d/base.pyx. Within, there's a Graphics3d class, and inside it is the _rich_repr_threejs method. Briefly, this method collects viewing options set by the user or defaults; builds up the points, lines, surfaces, and texts used in the scene; and inserts those options and the scene data into a copy of the HTML from the template.

How the resulting HTML gets saved to a file and launched in your browser, I'm less knowledgeable of, but output_browser.py, output_graphics3d.py, and buffer.py in src/sage/repl/rich_output/ may be good places to look.

Any features or bug fixes you contribute would be greatly appreciated! If you create a ticket over at trac dot sagemath dot org (can't seem to post a link) for such changes, consider CC'ing paulmasson as he's the creator of the three.js viewer and is who I've been most in contact with regarding it. And feel free to CC me as well: gh-jcamp0x2a.