Poll: three.js as the default 3d viewer in Sage

166 views
Skip to first unread message

Eric Gourgoulhon

unread,
Sep 23, 2019, 7:51:23 AM9/23/19
to sage-devel
Dear Sage-dev,

This is a poll to make three.js (https://threejs.org/) the default 3d viewer
in Sage, in replacement of Jmol (https://sourceforge.net/projects/jmol/).

Indeed, thanks to the work of Paul Masson, the three.js 3d viewer is doing a
very good job in displaying Sage 3d plots, as you can see in these examples
taken from Sage reference's manual:
https://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/sage_reference_threejs.ipynb

You can rotate/zoom the 3d view with the mouse and, by clicking on the small black
arrow at the bottom right of the view, you can download a png screenshot.

Other examples of three.js rendering can be found in this notebook devoted to
anti de Sitter space:
https://nbviewer.jupyter.org/github/sagemanifolds/SageManifolds/blob/master/Notebooks/SM_anti_de_Sitter.ipynb

For more information about the three.js renderer in Sage, see
https://doc.sagemath.org/html/en/reference/plot3d/threejs.html

The discussion about having three.js as the default viewer is taking place in
the ticket
https://trac.sagemath.org/ticket/22408
This ticket also contains the git branch to perform the change if decided.

Here is a discussion summary: in favor of three.js, we have

- three.js, which is based on the WebGL API, displays 3d plots faster than
  Jmol, and with a better quality

- 3d plots rendered with three.js can be publicly shared via
  nbviewer.jupyter.org, contrary to those rendered with Jmol, which appear as
  blank spaces, cf. this test notebook:
  https://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/test_3d_view.ipynb

- three.js enables to label the plot axes (via the option 'axes_labels', the default
  of which is ['x', 'y', 'z']); on the opposite, there are no labels on Jmol
  plots and the option 'axes_labels' is ineffective, which looks like a serious
  drawback for a mathematical software...

- Jmol causes many troubles to Sage packagers (see #22408 for details);
  for instance in Sage 8.8 console, Jmol display is broken on recent
  Debian-based distros (e.g. Debian Buster and Ubuntu 18.04), due to a JRE
  issue; fortunately this is fixed by https://trac.sagemath.org/ticket/25026

On the con side, there are

- the current lack of non-interactive conversion of three.js views to static
  png figures (in interactive mode, the black arrow mentioned above does the
  job). As a result, the png figures in the reference manual will still be
  generated with Jmol, as proposed in #22408

- some minor opacity issues (see #22408 for details)


Given the above elements, please vote!

Eric.

Emmanuel Charpentier

unread,
Sep 23, 2019, 8:53:32 AM9/23/19
to sage-devel
Eric quite eloquently made the case for threejs. I tend to agree with him on most of the points. However, a couple points should be complemented:
  • The "minor transparency issues" he mentions may deprive the resulting plot of part of its mathematical meaning (for example, the plot of a sphere and a cone can curently clobber the display of the part of the cone inside the sphere...).
  • Recent progress on the jmol front (Trac#25026, positively reviewed) may render this switch a bit less urgent.
  • The extra abilities of jmol/jsmol may ake it a bit more useful for some tasks (e. g. determining the "right" view parameters for a planned static view, e. g. for publication).
That said, I support the idea of the switch of defaults (if only because of spite against Java ;-).

==> +1

kcrisman

unread,
Sep 23, 2019, 10:32:48 AM9/23/19
to sage-devel

That said, I support the idea of the switch of defaults (if only because of spite against Java ;-).


Though I believe we mostly use Jmol in its jsmol form in the notebooks, for what it's worth :-)  Nonetheless having a fully functional threejs is great news too.

thierry

unread,
Sep 23, 2019, 3:41:55 PM9/23/19
to sage-...@googlegroups.com
To complement Karl-Dieter's answer, we should notice that in console
mode threejs opens a webpage with the javascript. So, if we want to
avoid the use of java, we could do exactly the same with opening a
webpage as well with jsmol, instead of running (java) jmol.

Also, the java issue is now fixed, which also means that jmol is still
maintained.

Ciao,
Thierry

John H Palmieri

unread,
Sep 23, 2019, 5:26:00 PM9/23/19
to sage-devel
+1 for threejs

I tried to compare the two: in a single Jupyter notebook, I plotted the same function with both viewers. threejs produced the plot faster, and it was snappier when rotating, zooming, etc. (This is with both Firefox and Safari on OS X.) Same from the command-line: the threejs window in my browser was faster to use than the jmol java app. The jmol app may have more features, but since we aren't talking about eliminating jmol, it will still be available as a possible viewer for people who need those features.

  John

Eric Gourgoulhon

unread,
Sep 23, 2019, 5:34:42 PM9/23/19
to sage-devel
Le lundi 23 septembre 2019 14:53:32 UTC+2, Emmanuel Charpentier a écrit :

  • The "minor transparency issues" he mentions may deprive the resulting plot of part of its mathematical meaning (for example, the plot of a sphere and a cone can curently clobber the display of the part of the cone inside the sphere...).
I call this a "minor" issue because the user can fix it, buy adjusting the opacity parameter, cf.
IMHO, Jmol issues of (1) lacking axes labels and (2) not displaying in nbviewer.jupyter.org or mybinder.org are more serious.

Eric.

Eric Gourgoulhon

unread,
Sep 23, 2019, 5:37:28 PM9/23/19
to sage-devel
Le lundi 23 septembre 2019 21:41:55 UTC+2, Thierry (sage-googlesucks@xxx) a écrit :

Also, the java issue is now fixed, which also means that jmol is still
maintained.


Yes. To be 100% clear: this poll is not about deprecating Jmol, but about making three.js the default.

Eric.

Eric Gourgoulhon

unread,
Sep 23, 2019, 6:11:29 PM9/23/19
to sage-devel
Le lundi 23 septembre 2019 13:51:23 UTC+2, Eric Gourgoulhon a écrit :
Indeed, thanks to the work of Paul Masson, the three.js 3d viewer is doing a
very good job in displaying Sage 3d plots, as you can see in these examples
taken from Sage reference's manual:
https://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/sage_reference_threejs.ipynb
 

Addendum: you can check that three.js works well in mybinder.org by clicking on the button "Execute on Binder" (the three interleaved circles) in the top right menu of the above Jupyter notebook.

Eric.
 

Travis Scrimshaw

unread,
Sep 23, 2019, 7:24:54 PM9/23/19
to sage-devel
+1 for making the default threejs.

Best,
Travis

David Roe

unread,
Sep 24, 2019, 12:52:15 AM9/24/19
to sage-devel
+1 for threejs as default.
David

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/0579cfb4-85c0-42e4-b5ee-0d10d92ffc26%40googlegroups.com.

Eric Gourgoulhon

unread,
Sep 24, 2019, 2:03:30 AM9/24/19
to sage-devel
Le lundi 23 septembre 2019 13:51:23 UTC+2, Eric Gourgoulhon a écrit :
- 3d plots rendered with three.js can be publicly shared via
  nbviewer.jupyter.org, contrary to those rendered with Jmol, which appear as
  blank spaces, cf. this test notebook:
  https://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/test_3d_view.ipynb

Addendum: contrary to nbviewer.jupyter.org and mybinder.org, publicly sharing a Jupyter notebook with Jmol plots works in CoCalc:

jplab

unread,
Sep 24, 2019, 3:56:05 AM9/24/19
to sage-devel
+1 to make threejs the default viewer.

Eric Gourgoulhon

unread,
Oct 12, 2019, 10:10:06 AM10/12/19
to sage-devel
This is to close this poll properly.

The clearly expressed opinions are
- in favor of making three.js the default: 6 (8 if one adds mine as well as that of Dima, who positively reviewed the ticket)
- in favor of keeping Jmol as the default: 0

Consequently, the branch of the ticket implementing the change (#22408) has been merged in Sage 9.0.beta0.
It's nice that the change takes place at the beginning of a beta cycle, since this leaves time for fixing possible bugs.

Additional note: the transparency issues of three.js discussed in this thread and in the ticket have been recently addressed in #28584.

Eric.
Reply all
Reply to author
Forward
0 new messages