Interactive Notebooks

Viser can display 3D visualizations inline in Jupyter notebooks and myst-nb documentation.

Static Scenes

Use viser.SceneApi.show() to display the current scene:

import viser

server = viser.ViserServer(verbose=False)
server.scene.add_box("/box", color=(255, 0, 0), dimensions=(1, 1, 1))
server.scene.show()

The visualization is interactive with orbit controls and works offline once loaded.

Optional parameters:

  • height: Height of the embedded viewer in pixels (default: 400)

  • dark_mode: Use dark color scheme (default: False)

Setting the Initial Camera

Use viser.ViserServer.initial_camera to set the camera pose when the visualization first loads:

import viser

server = viser.ViserServer()
server.scene.add_box("/box", color=(255, 0, 0), dimensions=(1, 1, 1))

# Set the initial camera pose.
server.initial_camera.position = (3.0, 3.0, 2.0)
server.initial_camera.look_at = (0.0, 0.0, 0.0)

server.scene.show()

Available properties: position, look_at, up, fov, near, far. See viser.InitialCameraConfig for details.

Animated Scenes

For animations, use viser.infra.StateSerializer.insert_sleep() to record timing between frames, then viser.infra.StateSerializer.show() to display:

import numpy as np

import viser

server = viser.ViserServer(verbose=False)
box = server.scene.add_box("/box", color=(255, 0, 0), dimensions=(1, 1, 1))

# Get the scene serializer for recording animations.
serializer = server.get_scene_serializer()

# Animate the box position over 3 seconds at 60 fps.
for i in range(180):
    t = i / 180 * 2 * np.pi
    box.position = (np.sin(t), np.cos(t), 0.5)
    serializer.insert_sleep(1.0 / 60.0)
serializer.show()

The visualization includes a playback timeline with play/pause controls and a scrubber for navigating through the animation.

Plain Python Scripts

The same API works outside of notebooks. When running as a plain Python script, viser.SceneApi.show() opens the visualization in your default web browser:

import viser

server = viser.ViserServer()
server.scene.add_box("/box", color=(255, 0, 0), dimensions=(1, 1, 1))

# Opens in default web browser.
server.scene.show()

Google Colab

In Google Colab, you can use viser.SceneApi.show() for static snapshots as shown above. For a live connection with interactivity (including GUI elements), use Colab’s serve_kernel_port_as_iframe:

import viser
from google.colab import output

server = viser.ViserServer(port=8081)
server.scene.add_box("/box", color=(255, 0, 0), dimensions=(1, 1, 1))

# Serve the Viser port as an iframe for live interaction.
output.serve_kernel_port_as_iframe(8081)

This creates a live WebSocket connection to the Viser server, enabling real-time updates and GUI controls.

Features & Limitations

viser.SceneApi.show() and viser.infra.StateSerializer.show() support most Viser scene features:

  • 3D primitives: boxes, spheres, meshes, point clouds, etc.

  • Gaussian splats with WebAssembly sorting

  • Animations with timeline, play/pause, and scrubbing

Limitations compared to the full Viser client:

  • GUI elements: scene-only mode (no interactive GUI panels)

  • WebSocket connection: visualizations are static snapshots, not live connections

For hosting visualizations on a web server or exporting .viser files, see Embedded Visualizations.