Skip to main content

A viser extension with out-of-the-box support for the time dimension

Project description

viser4d

viser4d is a small wrapper around viser that adds a time dimension. It records scene operations across timesteps and can seek or play them back.

Quickstart

pip install -e .
import numpy as np
import viser4d

server = viser4d.Viser4dServer(num_steps=10)

point_cloud = None
for i in range(10):
    with server.at(i):
        points = np.random.uniform(-1.0, 1.0, size=(200, 3))
        if point_cloud is None:
            point_cloud = server.scene.add_point_cloud(
                "/points",
                points=points,
                colors=(255, 200, 0),
            )
        else:
            point_cloud.points = points

server.play(fps=10, loop=True)
server.sleep_forever()

Timestep callbacks

If you have your own visualization logic and just want to use viser4d's timeline infrastructure (playback controls, seeking, scrubbing), you can register a callback that fires whenever the timestep changes:

import viser4d

server = viser4d.Viser4dServer(num_steps=100)

def on_timestep(t: int) -> None:
    # Update your custom visualizations here
    update_video_frames(t)
    update_body_meshes(t)
    update_3d_keypoints(t)

server.on_timestep_change(on_timestep)
server.play(fps=30, loop=True)
server.sleep_forever()

Callbacks are invoked after viser4d applies its own recorded state, so you can mix both approaches - record some operations with at(t) and handle others via callbacks.

How it works

Context determines behavior. server.scene always returns the same ProxyScene object, but it behaves differently based on whether you're inside an at(t) context:

Inside at(t):                          Outside at(t):
─────────────                          ──────────────
scene.add_frame(...)                   scene.add_frame(...)
       │                                      │
       ▼                                      ▼
    records to Timeline                    forwards to live viser scene
  • Inside at(t): Operations are recorded to a timeline, not executed.
  • Outside at(t): Operations forward directly to viser's live scene.
  • Playback: seek(t) or play() applies recorded state to the live scene.

See examples/ for more.

Quality checks

uvx ruff format .
uvx ruff check .
uvx ty check

Tests

uv run --group dev pytest -q

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viser4d-0.1.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viser4d-0.1.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file viser4d-0.1.1.tar.gz.

File metadata

  • Download URL: viser4d-0.1.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for viser4d-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f7c00c0c45f59afb2768e111880212275518269601586fad5e45e910a37e1bfa
MD5 e477d0513e38aec6ce0c09446af7e31b
BLAKE2b-256 429ef9caf2e42c8a59b55adacc2d4d031715474cd71efd92a0608bc7f2b3cc97

See more details on using hashes here.

File details

Details for the file viser4d-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: viser4d-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for viser4d-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3df71f742753963016dd5b5aaf64892f491103951a72f958adf1daf328755c76
MD5 08fbdac5c82eaca8531a5ce18362e735
BLAKE2b-256 ecb2dc698ed431c068215b87ebb310e766a397b6f1fedbb5e772e0889733a07a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page