"pip install vpython" installs an unusual module that makes it quite easy instead of extremely difficult to write Python programs that display real-time navigable 3D animations in a Jupyter notebook. Details are provided on the first page of
vpython.org.
Consider for example the following remarkably short program which displays a 3D cube, positions the camera so that the scene fills the canvas, sets up appropriate lighting, and activates mouse or touch controls to rotate and zoom the camera:
from vpython import *
box()
Most 3D libraries require a great deal of code to accomplish this.
You can run vpython demo programs at Binder, even on mobile devices:
Classic VPython was created in 2000 by David Scherer, a student at Carnegie Mellon University. Its core is written in C++. In 2014 John Coady created a pure Python implementation of the Classic VPython API which sends data to a Jupyter notebook that invokes the GlowScript 3D libraries, which are based on WebGL. Ruth Chabay and I have been working with Coady to implement the GlowScript VPython API, which is somewhat different from the classic API but better adapted to the browser/GPU world. Because the API is the same, identical code can run in a Jupyter notebook or in the pure browser GlowScript environment (
glowscript.org), where the RapydScript Python-to-JavaScript transpiler runs in the browser. (Currently widget invocation is different in the two versions; it is planned to provide wrappers around the Jupyter and jquery widgets so that widget code will also be transportable between the two environments.)
The GlowScript environment is particularly appropriate for novice programmers, whereas Jupyter VPython is better suited for professionals, because it provides access to all standard Python modules, which is not possible in the JavaScript-based GlowScript environment.
Although Jupyter VPython is already quite fast, as can be seen in some of the demo programs, John, Ruth, and I intend to use Cython to make it significantly faster.
Bruce Sherwood