sageplot[variant="3d"] vs interactive/slate[surface="sage"]

17 views
Skip to first unread message

Mitch Keller

unread,
Sep 30, 2026, 4:22:22 PM (11 days ago) Sep 30
to 'Rob Beezer' via PreTeXt development
I’m starting a new thread over here inspired by some of the things that JC raised in this thread on -support because we have some specific questions/requests for our 3D plots in Active Calculus - Multivariable.

We will have a blend of Sage interacts (with sliders, drop-downs, text boxes, checkboxes, etc.) and 3D plots. Because consistency is important to us, this rules out any attempt to do a mass conversion of the 3D plots to Asymptote, since afaik, Asymptote doesn’t provide the features we need for our true interactive features.

One thought I had about dealing with the understanding we arrived at in JC’s thread (the static version for 3D plots is produced using Sage’s .save method, which has limitations) is to have sageplot[variant=“3d”] not rely on a call to .save that produces a PNG (or whatever). Would it be possible to leverage the existing automated screenshot capabilities used for interactive to open the threeJS HTML files that are produced for inclusion into the HTML and take a screenshot of the nice version and save that as a PNG to include in formats like PDF?

The second thing we’re running into is probably more of a “Can Sage do this?” issue that maybe @KDC can help us with: Nick has refined things to specify viewpoint and camera_position so that the initial load of our our plots is where we want readers to start. When we use interactive/slate[surface=“sage”], we’re happy with how this fills the space. However, when we switch over to sageplot[variant=“3d”], it feels like Sage is not making optimal use of the space available. There is a zoom parameter that can be passed, but we’re not seeing that have an impact. I’m including two screenshots below. The first showing what comes up as we have configured and the second showing what a small adjustment in terms of pan and zooming in (within the browser) gives. Checking what threejs reports, these have the same viewpoint but different camera positions. It may be that part of our issue is that we’re not able to actually pass the camera position through from Sage to threejs. Even when I try to save to HTML using the threejs menu, what I get in that HTML file does not incorporate the change in camera position. So maybe I’ve talked myself through to the point of “Yeah, you’re just going to have to live with what you get or ask Sage to do better”, but I thought I’d see if anyone here has ideas before we try asking over there.

kcri...@gmail.com

unread,
Oct 1, 2026, 6:21:53 AM (11 days ago) Oct 1
to PreTeXt development
Briefly, I'm not too familiar with the internals of threejs in Sage.  If you look at https://doc.sagemath.org/html/en/reference/plot3d/threejs.html it seems that there are a lot of keywords, but at least two aren't documented (threejs_flat_shading and mesh), so one might hope there is a zoom one as well.

But no luck.  https://github.com/sagemath/sage/blob/develop/src/sage/plot/plot3d/base.pyx doesn't have any indication that the zoom is set (which for other viewers you can do).  It looks like one would have to either hack https://github.com/sagemath/sage/blob/develop/src/sage/ext_data/threejs/threejs_template.html or figure out how to pass the zoom parameter (which IS supported, as you can see from trying Tachyon) to this scene as developed by the js in that file.  Could then be as simple as "camera.zoom(2)" or something.

I think the Sage support list could be helpful here if you are serious about it, because my gut says that a change in the code would be needed to expose this.  OR you could find a way to send the info directly to the js in the html output, programmatically.  Sorry I can't be of more help.

Rob Beezer

unread,
Oct 1, 2026, 10:31:12 PM (10 days ago) Oct 1
to prete...@googlegroups.com
Dear Mitch,

A static image of a 3D graphic object in Sage has been substandard for a long
time. So any commitment to the #sageplot command should have been made with
that plainly visible.

Sage gets you a wide variety of algorithms for computing and has substandard
static output.

Asymptote has great (3D) graphics and maybe fewer computational powers.

I think Sage's graphics output is Sage's problem, not ours. Perhaps what we
pass to .save() can be improved. What little time I have spent on this
indicates large resolution (~3000) helps. I do not know about labels.

I do not plan to introduce more complexity in the Python (screenshotting the
three.JS versions).

Rob

On 9/30/26 13:21, Mitch Keller wrote:
> I’m starting a new thread over here inspired by some of the things that JC
> raised in this thread on -support <https://groups.google.com/g/pretext-support/
> c/hJnSOGxJWuM/m/v66B5AY1AwAJ> because we have some specific questions/requests
> PastedGraphic-2.tiffPastedGraphic-3.tiff
> --
> Mitch Keller
> mi...@rellek.net
>
> http://www.rellek.net/
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com <mailto:pretext-
> dev+uns...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> dev/3C3FC63F-6E4B-4FF1-A907-0269E3F95B32%40rellek.net <https://
> groups.google.com/d/msgid/pretext-dev/3C3FC63F-6E4B-4FF1-
> A907-0269E3F95B32%40rellek.net?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages