newton.viewer.ViewerRerun#
- class newton.viewer.ViewerRerun(server=True, address='127.0.0.1:9876', launch_viewer=True, app_id=None, keep_historical_data=False, keep_scalar_history=True, record_to_rrd=None)[source]#
Bases:
ViewerBaseViewerRerun provides a backend for visualizing Newton simulations using the rerun visualization library.
This viewer logs mesh and instance data to rerun, enabling real-time or offline visualization of simulation geometry and transforms. It supports both server and client modes, and can optionally launch a web viewer. The class manages mesh assets, instanced geometry, and frame/timeline synchronization with rerun.
- __init__(server=True, address='127.0.0.1:9876', launch_viewer=True, app_id=None, keep_historical_data=False, keep_scalar_history=True, record_to_rrd=None)#
Initialize the ViewerRerun backend for Newton using the Rerun.io visualization library.
This viewer detects whether it is created inside a Jupyter notebook environment and automatically generates an output widget for the viewer. If it is not created inside a Jupyter notebook environment, it will start a local rerun server serving over gRPC that can be connected to from a web browser.
- Parameters:
server (bool) – If True, start rerun in server mode (gRPC).
address (str) – Address and port for rerun server mode (only used if server is True).
launch_viewer (bool) – If True, launch a local rerun viewer client.
app_id (Optional[str]) – Application ID for rerun (defaults to ‘newton-viewer’).
keep_historical_data (bool) – If True, keep historical data in the timeline of the web viewer. If False, the web viewer will only show the current frame to keep the memory usage constant when sending transform updates via
ViewerRerun.log_state(). This is useful for visualizing long and complex simulations that would quickly fill up the web viewer’s memory if the historical data was kept. If True, the historical simulation data is kept in the viewer to be able to scrub through the simulation timeline. Defaults to False.keep_scalar_history (bool) – If True, historical scala data logged via
ViewerRerun.log_scalar()is kept in the viewer.record_to_rrd (str) – Path to record the viewer to a
*.rrdrecording file (e.g. “my_recording.rrd”). If None, the viewer will not record to a file.
- begin_frame(time)#
Begin a new frame and set the timeline for rerun.
- Parameters:
time (float) – The current simulation time.
- close()#
Close the viewer and clean up resources.
This will terminate any spawned viewer process and disconnect from rerun.
- end_frame()#
End the current frame.
Note
Rerun handles frame finishing automatically.
- is_running()#
Check if the viewer is still running.
- Returns:
True if the viewer is running, False otherwise.
- Return type:
- log_array(name, array)#
Log a generic array for visualization.
- Parameters:
name (str) – Name of the array.
array – The array data (can be a wp.array or a numpy array).
- log_geo(name, geo_type, geo_scale, geo_thickness, geo_is_solid, geo_src=None, hidden=False)#
- log_instances(name, mesh, xforms, scales, colors, materials, hidden=False)#
Log instanced mesh data to rerun using InstancePoses3D.
- Parameters:
name (str) – Entity path for the instances.
mesh (str) – Name of the mesh asset to instance.
xforms (wp.array) – Instance transforms (wp.transform).
scales (wp.array) – Instance scales (wp.vec3).
colors (wp.array) – Instance colors (wp.vec3).
materials (wp.array) – Instance materials (wp.vec4).
hidden (bool) – Whether the instances are hidden. (unused)
- log_lines(name, starts, ends, colors, width=0.01, hidden=False)#
Log lines for visualization.
- log_mesh(name, points, indices, normals=None, uvs=None, hidden=False, backface_culling=True)#
Log a mesh to rerun for visualization.
- Parameters:
name (str) – Entity path for the mesh.
points (wp.array) – Vertex positions (wp.vec3).
indices (wp.array) – Triangle indices (wp.uint32).
normals (wp.array, optional) – Vertex normals (wp.vec3).
uvs (wp.array, optional) – UV coordinates (wp.vec2).
hidden (bool) – Whether the mesh is hidden (unused).
backface_culling (bool) – Whether to enable backface culling (unused).
- log_points(name, points, radii=None, colors=None, hidden=False)#
Log points for visualization.
- log_scalar(name, value)#
Log a scalar value for visualization.
- Parameters:
name (str) – Name of the scalar.
value – The scalar value.
- show_notebook(width=1000, height=400, legacy_notebook_show=False)#
Show the viewer in a Jupyter notebook.