Opened 10 years ago

Last modified 8 months ago

#12402 closed enhancement

Make a three.js backend for 3d plotting — at Version 23

Reported by: jason Owned by: jason, was
Priority: major Milestone: sage-7.5
Component: graphics Keywords:
Cc: kini, novoselt, mbejger, gagern, egourgoulhon, paulmasson, yzh, mkoeppe Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: u/paulmasson/12402 (Commits, GitHub, GitLab) Commit: 7cedf75db69671cfb0a201435e5148d1041f0f05
Dependencies: Stopgaps:

Status badges

Change History (24)

comment:1 Changed 10 years ago by kini

  • Cc kini added

comment:2 Changed 10 years ago by novoselt

  • Cc novoselt added

comment:3 Changed 10 years ago by was

  • Description modified (diff)

comment:4 Changed 9 years ago by kcrisman

Jason, William, can you put whatever code exists on here since public worksheets are disabled? We don't want this just in the cloud.sagemath :-)

Changed 9 years ago by jason

comment:6 follow-up: Changed 9 years ago by kcrisman

Just as an update, this is now apparently working in cloud.sagemath.

comment:7 in reply to: ↑ 6 Changed 9 years ago by was

Replying to kcrisman:

Just as an update, this is now apparently working in cloud.sagemath.

It sort of works, but it isn't included by default. It will be soon though, so that anybody can at least test out some minimal functionality. I'll post when that happens.

comment:8 Changed 9 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:9 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:10 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:11 Changed 8 years ago by mbejger

  • Cc mbejger added

comment:12 follow-up: Changed 8 years ago by jason

Just FYI, there are now three different threejs backends: SMC, the threejs command in the sage cell, and the pythreejs-based backend that works in the sage cell too.

comment:13 Changed 8 years ago by novoselt

Jason - what is the status of the last one? Will it be pushed to get "standard" or there is still work to be done there and with your switch nobody is available to steer it?

The first two were definitely lacking features, in particular "things that don't scale with zoom" plus some transparency issues.

comment:14 follow-up: Changed 8 years ago by jason

The transparency issues are not fixed---those are inherent in how three.js draws things, and stem from limitations of webgl (there are experiements overcoming them in webgl, which might be interesting to look at, though; the author of mathbox is looking at them, for example).

I think that anything "pushed to standard" should be supported by SMC and the sage cell. Right now, the pythreejs solution requires an communication framework that is/emulates the ipython comm/widget framework. Something like that would need to be implemented for SMC to get it to work there. I think that would be a great project in itself, though---there is starting to be some good development of interactive things for the IPython notebook, and it would be great to use those things from SMC too.

comment:15 in reply to: ↑ 14 Changed 8 years ago by kcrisman

I think that anything "pushed to standard" should be supported by SMC and the sage cell. Right now, the pythreejs solution requires an communication framework that is/emulates the ipython comm/widget framework. Something like that would need to be implemented for SMC to get it to work there. I think that would be a great project in itself, though---there is starting to be some good development of interactive things for the IPython notebook, and it would be great to use those things from SMC too.

But I thought SMC only uses the js plotting - does it also do Jmols too? (You'll notice I still haven't had time to properly try out SMC, and won't for some time).


See also #16004 as a related ticket I also haven't had enough time to review properly.

comment:16 in reply to: ↑ 12 ; follow-up: Changed 8 years ago by mbejger

Replying to jason:

Just FYI, there are now three different threejs backends: SMC, the threejs command in the sage cell, and the pythreejs-based backend that works in the sage cell too.

Thanks :-) I am interested in enhancing the capabilities of SageManifolds? (#14865), which is still under development, so I guess the most natural thing would be to somehow use threejs locally. Probably this question was asked already many times, but what is the current status of threejs in sage notebook (local ipython notebook)?

comment:17 in reply to: ↑ 16 Changed 8 years ago by kcrisman

Thanks :-) I am interested in enhancing the capabilities of SageManifolds? (#14865), which is still under development, so I guess the most natural thing would be to somehow use threejs locally. Probably this question was asked already many times, but what is the current status of threejs in sage notebook (local ipython notebook)?

The Sagenb is not really at all an Ipython notebook, though it may have inspired earlier versions thereof. Anyway, the current status is that you can get it to work - see the examples above - but no one has put time into this. Partly because the sagenb is in maintenance mode currently (though it would be nice to have it more actively developed) but also because of the slight backwards functionality loss involved as you see in previous comments.

comment:18 Changed 8 years ago by gagern

  • Cc gagern added

comment:19 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:20 Changed 8 years ago by egourgoulhon

  • Cc egourgoulhon added

comment:21 Changed 6 years ago by paulmasson

  • Cc paulmasson added

comment:22 Changed 6 years ago by paulmasson

  • Branch set to u/paulmasson/12402

comment:23 Changed 6 years ago by paulmasson

  • Commit set to 7cedf75db69671cfb0a201435e5148d1041f0f05
  • Description modified (diff)
  • Milestone changed from sage-6.4 to sage-7.4
  • Status changed from new to needs_review

Here's some basic Three.js support for Graphics3d objects. It is modeled on the corresponding function in SageMathCell: simply use threejs() to wrap any combination of points, lines and surfaces. This will save an HTML file with the JavaScript needed to render the scene and open it in a browser.

There are a great many features that can be added in the future, but I first would like to see how much interest there is in this. There have been problems surfacing with Jmol (#20978 for example) and I certainly think it would be preferable to have a native viewer that can be updated more quickly. The HTML format is also more portable than Jmol files, since it only requires a modern browser to run.

This version relies on an external CDN to retrieve the Three.js library, since it does not currently download to the hard drive during the build process. I'll need help on figuring out how to change that at some point, since I'm sure people will want to be able to view saved files offline.


Last 10 new commits:

3d1cd2aHandle nested lists
efb3d0aHandle nested lists
f70ac3dAdd line plots
55f12e6Add point plots
b4c8414Adjust centering and camera
374809aRebase to move point bounds off points
9a42352Add auto z-aspect
d560683Minor rebase
aa322adAdd axis labels
7cedf75Check for equal bounds
Note: See TracTickets for help on using tickets.