newton.viewer.ViewerRerun#

class newton.viewer.ViewerRerun(*, app_id=None, address=None, serve_web_viewer=True, web_port=9090, grpc_port=9876, keep_historical_data=False, keep_scalar_history=True, record_to_rrd=None)[source]#

Bases: ViewerBase

ViewerRerun 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. By default, it spawns a viewer. Alternatively, it can connect to a specific rerun server address. Multiple parallel simulations are supported—use unique app_id values to differentiate them. The class manages mesh assets, instanced geometry, and frame/timeline synchronization with rerun.

__init__(*, app_id=None, address=None, serve_web_viewer=True, web_port=9090, grpc_port=9876, 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 supports both standalone and Jupyter notebook environments. When an address is provided, it connects to that remote rerun server regardless of environment. When address is None, it spawns a local viewer (web-based or standalone, depending on serve_web_viewer flag), only if not running in a Jupyter notebook (notebooks use show_notebook() instead).

Parameters:
  • app_id (str | None) – Application ID for rerun (defaults to ‘newton-viewer’). Use different IDs to differentiate between parallel viewer instances.

  • address (str | None) – Optional server address to connect to a remote rerun server via gRPC. You will need to start a stand-alone rerun server first, e.g. by typing rerun in your terminal. See rerun.io documentation for supported address formats. If provided, connects to the specified server regardless of environment.

  • serve_web_viewer (bool) – If True, serves a web viewer over HTTP on the given web_port and opens it in the browser. If False, spawns a native Rerun viewer (only outside Jupyter notebooks). Defaults to True.

  • web_port (int) – Port to serve the web viewer on. Only used if serve_web_viewer is True.

  • grpc_port (int) – Port to serve the gRPC server on.

  • 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 *.rrd recording 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:

bool

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.

Parameters:
  • name (str) – Name of the line batch.

  • starts – Line start points.

  • ends – Line end points.

  • colors – Line colors.

  • width (float) – Line width.

  • hidden (bool) – Whether the lines are hidden.

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.

Parameters:
  • name (str) – Name of the point batch.

  • points – Point positions (can be a wp.array or a numpy array).

  • radii – Point radii (can be a wp.array or a numpy array).

  • colors – Point colors (can be a wp.array or a numpy array).

  • hidden (bool) – Whether the points are hidden.

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.

Parameters:
  • width (int) – Width of the viewer in pixels.

  • height (int) – Height of the viewer in pixels.

  • legacy_notebook_show (bool) – Whether to use rr.legacy_notebook_show instead of rr.notebook_show for displaying the viewer as static HTML with embedded recording data.