3D views and images
Every scene has a 3D view: drag to turn it, scroll to zoom. Free-space parts stand on posts at the beam height; chip parts stand on their die. Save it as an interactive page, or as an image.
See it
Section titled “See it”The coupled rings of Borghi et al. (2019), Fig. 1; the cell opens on its 3D tab:
# The coupled rings of Borghi et al., Sci. Rep. 9, 408 (2019), Fig. 1from optodraw import MicroringResonator, Scene
scene = Scene(title="Photonic molecule", platform="on_chip")ring1 = scene.add(MicroringResonator(center=(-26, 0), add_drop=True, with_heater=True, label="1"))ring2 = scene.add(MicroringResonator(center=(26, 0), add_drop=True, with_heater=True, label="2"))scene.route((ring1, "o2"), (ring2, "o1"), kind="waveguide")scene.route((ring1, "o4"), (ring2, "o3"), kind="waveguide")# as the paper's figure: heaters with no contacts, and the bus ends where the light enters and leaves left openfor ring in (ring1, ring2): scene.leave_open(ring, "e1", "e2")scene.leave_open(ring1, "o1", "o3")scene.leave_open(ring2, "o2", "o4")sceneSave it
Section titled “Save it”scene.render_threejs("scene.html") # the interactive view as one pagescene.render_3d_image("scene.png") # a studio image: soft light, shadows, reflectionsscene.render_3d_image("draft.png", quality="draft") # a quick lookscene.render_3d_image("live.png", engine="viewer") # the viewer's real-time imagescene.render_3d_svg("scene.svg", projection="parallel") # vector paths, no browserrender_3d_image needs Chrome, Chromium or Edge (OPTODRAW_CHROME names one). It runs on the CPU: no GPU
and no other program. render_3d_svg needs no browser. It draws the same solids as vector paths, in studio
light. On a figure page, use a View3D inset.
Options
Section titled “Options”| Option | Values | Default |
|---|---|---|
engine |
"studio", "viewer" |
"studio" |
background |
"none", "light", "dark" |
"none" |
camera |
a viewer preset, such as "isometric" or "top" |
"isometric" |
width, height, scale |
the image is width by height times scale pixels |
1600, 1000, 2 |
quality |
"final", "draft" |
"final" |
The viewer itself takes quality="high" (with ambient occlusion) or "fast" for a weak GPU. A saved page has
one bar at the bottom: Camera, World, Labels, Light, Save, Fullscreen and More (GLB, JSON, Photoreal). Labels
and light start off; render_threejs(animate=True) starts the light.
Animation
Section titled “Animation”The Light menu has two looks. Light shows glowing pulses inside the drawn guides: brightness is power, and speed follows the group index. Field shows the steady-state field, with crests, mode shape and interference. The light starts off. Captions state every scaled quantity.
# The same rings in the Field look, light on: crests, mode shape and interferencescene.render_threejs(look="field", animate=True, show_labels=False)Play tour moves the camera from device to device and slows at each stop. Save the tour as a video:
scene.render_tour_video("tour.mp4", look="light", tour="auto", width=1920, height=1080, fps=30)MP4 needs ffmpeg. Without it the video is WebM, in real time.
How it works
Section titled “How it works”The studio renderer is a ray tracer that runs in the page, on every CPU core: soft studio light, soft shadows, reflections, glass that refracts and beams that glow. The same scene and options always give the same PNG.
Borghi, M., Trenti, A. and Pavesi, L. Four wave mixing control in a photonic molecule made by silicon microring resonators. Sci. Rep. 9, 408 (2019). doi:10.1038/s41598-018-36694-5