Back to Rerun

Partial updates

examples/notebook/notebook/partial_updates.ipynb

0.37.11.2 KB
Original Source

Partial updates

This example demonstrates how to perform partial updates on individual components. To learn more about this concept check this doc page.

Setup a point cloud

from __future__ import annotations

import numpy as np

import rerun as rr

rng = np.random.default_rng(42)
n = 1000
positions = rng.uniform(0, 10, size=[n, 3])

rr.init("partial_updates")
rr.set_time("t", sequence=0)
rr.log("points", rr.Points3D(positions, radii=0.1))

rr.notebook_show()

Update colors for different timestamps in a loop

The previously logged positions are still used

for i in range(10):
    rr.set_time("t", sequence=i)
    colors_slide_x = n * [(255, 0, 0)] * (positions < i)
    rr.log("points", rr.Points3D.from_fields(colors=colors_slide_x))

Update colors for different timestamps in a single call

Like before, but passes columnar data with a single SDK call

times = np.arange(0, 10)
all_colors_slide_z = np.vstack([n * [(0, 0, 255)] * (positions < t) for t in times])

rr.send_columns(
    "points",
    [rr.TimeColumn("t", sequence=times)],
    rr.Points3D.columns(colors=all_colors_slide_z).partition([n] * 10),
)