MovieFigure

go-to Low-level Three.js scene and movie builder; same object as Figure3D.

threejs_viz.MovieFigure(
    data=None,
    layout=None,
    frames=None,
    groups=None,
    styles=None,
    meta=None,
)

Plotly-like API for building Three.js movie scenes.

Methods

Name Description
add_cell Add unit-cell wireframe (static).
add_connections Add pore-graph connection lines + nodes (internal + optional periodic).
add_framework Add framework atoms + bonds as a mesh trace (static).
add_guests Add guest / adsorbate atoms as instanced spheres (single frame, static).
add_maxima Add pore-centre maxima points (internal always visible, periodic optionally hidden).
add_surface Add segmentation isosurface mesh (static).
add_windows Add window points between connected pores (internal + optional periodic).
export_png Export the current static scene to PNG.
save_html Write standalone HTML (alias of :meth:to_html).
set_lights Set Three.js scene lighting (embedded in exported HTML).
show Display the figure.
to_html Write the scene to a standalone HTML file.

add_cell

threejs_viz.MovieFigure.add_cell(atoms, **style)

Add unit-cell wireframe (static).

add_connections

threejs_viz.MovieFigure.add_connections(seg, atoms, hide_periodic=True, **style)

Add pore-graph connection lines + nodes (internal + optional periodic).

add_framework

threejs_viz.MovieFigure.add_framework(
    atoms,
    bonds='auto',
    representation='ball_and_stick',
    **style,
)

Add framework atoms + bonds as a mesh trace (static). representation: “ball_and_stick” (default), “stick”, or “space_filling”. When called with default representation, both ball-and-stick and stick meshes are added; the stick mesh starts hidden and can be toggled in the viewer.

add_guests

threejs_viz.MovieFigure.add_guests(atoms, color=None, **style)

Add guest / adsorbate atoms as instanced spheres (single frame, static).

add_maxima

threejs_viz.MovieFigure.add_maxima(seg, atoms, hide_periodic=True, **style)

Add pore-centre maxima points (internal always visible, periodic optionally hidden).

add_surface

threejs_viz.MovieFigure.add_surface(
    dgrid,
    regions,
    atoms,
    isovalue=1.0,
    step_size=1,
    **style,
)

Add segmentation isosurface mesh (static).

add_windows

threejs_viz.MovieFigure.add_windows(
    seg,
    hide_periodic=True,
    atoms=None,
    spacing=None,
    reclassify_far_outside=True,
    **style,
)

Add window points between connected pores (internal + optional periodic).

When atoms and spacing are supplied and reclassify_far_outside is True, windows tagged internal whose Cartesian position is far outside the unit cell are reclassified as periodic (prevents phantom internal-window markers for non-orthogonal cells).

export_png

threejs_viz.MovieFigure.export_png(
    path,
    *,
    resolution_mult=2,
    width=None,
    height=None,
    wait_ms=1500,
)

Export the current static scene to PNG.

Uses Playwright headless Chromium when installed::

pip install playwright
playwright install chromium

Otherwise raises with instructions to use the in-viewer Export PNG button after .show(renderer="browser").

Parameters

path Output .png path. resolution_mult Supersampling factor (matches the viewer Export PNG control). width, height Browser viewport in pixels (default 1280×720). wait_ms Milliseconds to wait for WebGL scene load before capture.

save_html

threejs_viz.MovieFigure.save_html(path, **kwargs)

Write standalone HTML (alias of :meth:to_html).

set_lights

threejs_viz.MovieFigure.set_lights(
    ambient=None,
    hemisphere_intensity=None,
    hemisphere_sky=None,
    hemisphere_ground=None,
    dir_key_intensity=None,
    dir_key_position=None,
    dir_fill_intensity=None,
    dir_fill_position=None,
    ssao=None,
    explicit=True,
)

Set Three.js scene lighting (embedded in exported HTML).

When explicit is True (default), the viewer uses these intensities as-is and does not apply the automatic orthographic compensation.

Parameters

ambient Ambient light intensity (0–1 typical). hemisphere_intensity, hemisphere_sky, hemisphere_ground Hemisphere light settings (sky/ground are hex colours). dir_key_intensity, dir_key_position Key directional light. dir_fill_intensity, dir_fill_position Fill directional light. ssao Enable SSAO. Default: off in orthographic, on in perspective. explicit If True, skip orthographic auto-boost of directional lights.

show

threejs_viz.MovieFigure.show(
    renderer=None,
    *,
    height=600,
    width='100%',
    port=None,
)

Display the figure.

renderer="notebook" shows inline (iframe srcdoc); "browser" serves on 127.0.0.1 and opens the system browser. Default: inline inside a Jupyter kernel, browser otherwise.

to_html

threejs_viz.MovieFigure.to_html(
    path,
    template='threejs_default',
    sidecar=False,
    fps=20.0,
    point_size=0.16,
    pack_binary=False,
    background=None,
)

Write the scene to a standalone HTML file.

background (opt-in; default None keeps the current look) sets the initial viewer background: a solid colour "#0b1d3a", ("linear", c1, c2[, ...]) (left-to-right), ("radial", centre, edge) or {"type": ..., "colors": [...]}. The Bg picker / gradient buttons still work (they override it) and Export PNG captures it (it is drawn in the WebGL scene).

pack_binary=True (opt-in) stores large numeric arrays (positions, indices, colors, radii, sizes) as base64 float32/uint16/uint32 blobs instead of JSON number lists; the viewer decodes them on load. Typically ~3-4x smaller files.