unilab.visualization.viser_scene

MuJoCo-to-viser scene adapter for interactive web-based 3D visualization.

This module renders MuJoCo scenes via a viser web server, providing browser-based interactive 3D viewing without requiring a local display or GLFW. It is gated behind the viser optional-dependency group and is not imported by default.

Usage (from scripts/play_viser.py):

from unilab.visualization.viser_scene import MujocoViserScene, VISER_AVAILABLE

Functions

build_visible_env_indices(num_envs, visible_envs)

Select a stable subset of env indices spread across the full batch.

Classes

MujocoViserScene

Bridges a mujoco.MjModel to a viser.ViserServer scene graph.

unilab.visualization.viser_scene.build_visible_env_indices(num_envs, visible_envs)[source]

Select a stable subset of env indices spread across the full batch.

Parameters:
  • num_envs (int) – Total number of runtime environments.

  • visible_envs (int) – Number of env slots exposed in the viewer.

Return type:

ndarray

Returns:

A monotonically increasing array of runtime env indices.

class unilab.visualization.viser_scene.MujocoViserScene[source]

Bases: object

Bridges a mujoco.MjModel to a viser.ViserServer scene graph.

Call build() once to populate the scene with geometry handles, then call update() each frame to sync body transforms from MjData.

Parameters:
__init__(server, model, *, name_prefix='/mujoco', position_offset=(0.0, 0.0, 0.0), render_plane=True)[source]
Parameters:
reset(model, *, position_offset=None, render_plane=None)[source]

Rebuild the viser scene for a new MuJoCo model.

Parameters:
  • model (MjModel) – MuJoCo model whose geoms should populate the scene.

  • position_offset (tuple[float, float, float] | None) – Optional XYZ offset applied to all geoms.

  • render_plane (bool | None) – Optional override for whether plane geoms should be built.

Return type:

None

Returns:

None.

close()[source]

Remove all scene handles owned by this adapter.

Return type:

None

update(data)[source]

Sync all geom transforms from data into the viser scene.

Parameters:

data (MjData)

Return type:

None