Skip to content

Commit

Permalink
Graphics3d._save_image_png: Try threejs with playwright first
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Aug 15, 2024
1 parent 95a3971 commit 7d40876
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/sage/plot/plot3d/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,19 @@ end_scene""".format(
opts = self._process_viewing_options(kwds)
viewer = opts['viewer']
if viewer == 'threejs':
viewer = 'jmol' # since threejs has no png dump
try:
scene = self._rich_repr_threejs(**opts)
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser_type = getattr(p, kwds.pop('browser_type', 'chromium'))
browser = browser_type.launch()
page = browser.new_page()
page.goto('file://' + scene.html.filename('html'))
page.screenshot(path=filename)
browser.close()
return
except Exception:
viewer = 'jmol'
if viewer == 'tachyon':
from sage.repl.rich_output.output_catalog import OutputImagePng
render = self._rich_repr_tachyon(OutputImagePng, **opts)
Expand Down

0 comments on commit 7d40876

Please sign in to comment.