State Serializer

class viser.infra.StateSerializer[source]

Handle for serializing messages. In Viser, this is used to save the scene state so it can be shared/embedded in static webpages.

insert_sleep(duration: float) None[source]

Insert a sleep into the recorded file. This can be useful for dynamic 3D data.

Parameters:

duration (float)

Return type:

None

serialize() bytes[source]

Serialize saved messages. Should only be called once. Our convention is to write this binary format to a file with a .viser extension, for example via pathlib.Path("file.viser").write_bytes(...).

Returns:

The recording as bytes.

Return type:

bytes

show(height: int = 400, dark_mode: bool = False) None[source]

Display the serialized scene in a Jupyter notebook or web browser.

In Jupyter notebooks/labs, displays an inline IFrame. When running as a script, opens the visualization in the default web browser.

See also viser.ViserServer.show().

Parameters:
  • height (int) – Height of the embedded viewer in pixels.

  • dark_mode (bool) – Use dark color scheme.

Return type:

None