Static inline display¶
display_snapshot() renders a self-contained, serverless Three.js document
inline — no WebSocket server, no daemon threads. Each call snapshots the
current scene; entities added later appear in subsequent calls, not earlier
ones. For live (interactive) display, see live.md.
Single scene¶
display_snapshot() returns an inline iframe of the current scene. In Jupyter
it renders inline; outside Jupyter it opens a browser tab.
In [1]:
Copied!
from pytanga.geometry import Point, Sphere
from pytanga.viz import Visualizer
viz = Visualizer()
viz.add(Point(1, 2, 3), color="#ff4444")
viz.add(Sphere(Point(0, 0, 0), radius=2), opacity=0.3)
viz.display_snapshot()
from pytanga.geometry import Point, Sphere
from pytanga.viz import Visualizer
viz = Visualizer()
viz.add(Point(1, 2, 3), color="#ff4444")
viz.add(Sphere(Point(0, 0, 0), radius=2), opacity=0.3)
viz.display_snapshot()
Out[1]:
Multi-scene side by side¶
display_row(mode="static") shows several scenes side by side as static
snapshots in a single cell.
In [2]:
Copied!
overview = viz.scene("overview")
detail = viz.scene("detail")
overview.add(Sphere(Point(0, 0, 0), radius=3), opacity=0.2)
detail.add(Sphere(Point(2, 1, 0), radius=1), opacity=0.8)
viz.display_row((overview, None), (detail, None), mode="static")
overview = viz.scene("overview")
detail = viz.scene("detail")
overview.add(Sphere(Point(0, 0, 0), radius=3), opacity=0.2)
detail.add(Sphere(Point(2, 1, 0), radius=1), opacity=0.8)
viz.display_row((overview, None), (detail, None), mode="static")
Scene: overview
Scene: detail
When to use¶
| Scenario | Use |
|---|---|
| Live interaction (rotate, zoom, animate) | start_server() + flush() + _repr_html_() |
| Quick static visualization | display_snapshot() |
| Export to HTML/PDF (nbconvert) | display_snapshot() |
| Progressive figure building | Call display_snapshot() after each add |