Scene API#

class viser.SceneApi[source]#

Interface for adding 3D primitives to the scene.

Used by both our global server object, for sharing the same GUI elements with all clients, and by invidividual client handles.

world_axes: FrameHandle#

Handle for the world axes, which are created by default.

set_up_direction(direction: Literal[‘+x’, ‘+y’, ‘+z’, ‘-x’, ‘-y’, ‘-z’] | tuple[float, float, float] | ndarray) None[source]#

Set the global up direction of the scene. By default we follow +Z-up (similar to Blender, 3DS Max, ROS, etc), the most common alternative is +Y (OpenGL, Maya, etc).

Parameters:

direction (Literal[‘+x’, ‘+y’, ‘+z’, ‘-x’, ‘-y’, ‘-z’] | tuple[float, float, float] | ~numpy.ndarray) – New up direction. Can either be a string (one of +x, +y, +z, -x, -y, -z) or a length-3 direction vector.

Return type:

None

set_global_visibility(visible: bool) None[source]#

Set visibility for all scene nodes. If set to False, all scene nodes will be hidden.

This can be useful when we’ve called SceneApi.set_background_image(), and want to hide everything except for the background.

Parameters:

visible (bool) – Whether or not all scene nodes should be visible.

Return type:

None

add_glb(name: str, glb_data: bytes, scale=1.0, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) GlbHandle[source]#

Add a general 3D asset via binary glTF (GLB).

For glTF files, it’s often simpler to use trimesh.load() with .add_mesh_trimesh(). This will call .add_glb() under the hood.

For glTF features not supported by trimesh, glTF to GLB conversion can also be done programatically with libraries like pygltflib.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • glb_data (bytes) – A binary payload.

  • scale – A scale for resizing the GLB asset.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

GlbHandle

add_spline_catmull_rom(name: str, positions: tuple[tuple[float, float, float], ] | ndarray, curve_type: Literal[‘centripetal’, ‘chordal’, ‘catmullrom’] = 'centripetal', tension: float = 0.5, closed: bool = False, line_width: float = 1, color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray = (20, 20, 20), segments: int | None = None, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) SceneNodeHandle[source]#

Add a spline to the scene using Catmull-Rom interpolation.

This method creates a spline based on a set of positions and interpolates them using the Catmull-Rom algorithm. This can be used to create smooth curves.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • positions (tuple[tuple[float, float, float], ] | ndarray) – A tuple of 3D positions (x, y, z) defining the spline’s path.

  • curve_type (Literal[‘centripetal’, ‘chordal’, ‘catmullrom’]) – Type of the curve (‘centripetal’, ‘chordal’, ‘catmullrom’).

  • tension (float) – Tension of the curve. Affects the tightness of the curve.

  • closed (bool) – Boolean indicating if the spline is closed (forms a loop).

  • line_width (float) – Width of the spline line.

  • color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the spline as an RGB tuple.

  • segments (int | None) – Number of segments to divide the spline into.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

SceneNodeHandle

add_spline_cubic_bezier(name: str, positions: tuple[tuple[float, float, float], ] | ndarray, control_points: tuple[tuple[float, float, float], ] | ndarray, line_width: float = 1, color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray = (20, 20, 20), segments: int | None = None, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) SceneNodeHandle[source]#

Add a spline to the scene using Cubic Bezier interpolation.

This method allows for the creation of a cubic Bezier spline based on given positions and control points. It is useful for creating complex, smooth, curving shapes.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • positions (tuple[tuple[float, float, float], ] | ndarray) – A tuple of 3D positions (x, y, z) defining the spline’s key points.

  • control_points (tuple[tuple[float, float, float], ] | ndarray) – A tuple of control points for Bezier curve shaping.

  • line_width (float) – Width of the spline line.

  • color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the spline as an RGB tuple.

  • segments (int | None) – Number of segments to divide the spline into.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

SceneNodeHandle

add_camera_frustum(name: str, fov: float, aspect: float, scale: float = 0.3, color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray = (20, 20, 20), image: ndarray | None = None, format: Literal[‘png’, ‘jpeg’] = 'jpeg', jpeg_quality: int | None = None, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) CameraFrustumHandle[source]#

Add a camera frustum to the scene for visualization.

This method adds a frustum representation, typically used to visualize the field of view of a camera. It’s helpful for understanding the perspective and coverage of a camera in the 3D space.

Like all cameras in the viser Python API, frustums follow the OpenCV [+Z forward, +X right, +Y down] convention. fov is vertical in radians; aspect is width over height

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • fov (float) – Field of view of the camera (in radians).

  • aspect (float) – Aspect ratio of the camera (width over height).

  • scale (float) – Scale factor for the size of the frustum.

  • color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the frustum as an RGB tuple.

  • image (ndarray | None) – Optional image to be displayed on the frustum.

  • format (Literal[‘png’, ‘jpeg’]) – Format of the provided image (‘png’ or ‘jpeg’).

  • jpeg_quality (int | None) – Quality of the jpeg image (if jpeg format is used).

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

CameraFrustumHandle

add_frame(name: str, show_axes: bool = True, axes_length: float = 0.5, axes_radius: float = 0.025, origin_radius: float | None = None, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) FrameHandle[source]#

Add a coordinate frame to the scene.

This method is used for adding a visual representation of a coordinate frame, which can help in understanding the orientation and position of objects in 3D space.

For cases where we want to visualize many coordinate frames, like trajectories containing thousands or tens of thousands of frames, batching and calling add_batched_axes() may be a better choice than calling add_frame() in a loop.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • show_axes (bool) – Boolean to indicate whether to show the frame as a set of axes + origin sphere.

  • axes_length (float) – Length of each axis.

  • axes_radius (float) – Radius of each axis.

  • origin_radius (float | None) – Radius of the origin sphere. If not set, defaults to 2 * axes_radius.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

FrameHandle

add_batched_axes(name: str, batched_wxyzs: tuple[tuple[float, float, float, float], ] | ndarray, batched_positions: tuple[tuple[float, float, float], ] | ndarray, axes_length: float = 0.5, axes_radius: float = 0.025, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) BatchedAxesHandle[source]#

Visualize batched sets of coordinate frame axes.

The functionality of add_batched_axes() overlaps significantly with add_frame() when show_axes=True. The primary difference is that add_batched_axes() supports multiple axes via the wxyzs_batched (shape Nx4) and positions_batched (shape Nx3) arguments.

Axes that are batched and rendered via a single call to add_batched_axes() are instanced on the client; this will be much faster to render than add_frame() called in a loop.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • batched_wxyzs (tuple[tuple[float, float, float, float], ] | ndarray) – Float array of shape (N,4).

  • batched_positions (tuple[tuple[float, float, float], ] | ndarray) – Float array of shape (N,3).

  • axes_length (float) – Length of each axis.

  • axes_radius (float) – Radius of each axis.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl). This will be applied to all axes.

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl). This will be applied to all axes.

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

BatchedAxesHandle

add_grid(name: str, width: float = 10.0, height: float = 10.0, width_segments: int = 10, height_segments: int = 10, plane: Literal[‘xz’, ‘xy’, ‘yx’, ‘yz’, ‘zx’, ‘zy’] = 'xy', cell_color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray = (200, 200, 200), cell_thickness: float = 1.0, cell_size: float = 0.5, section_color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray = (140, 140, 140), section_thickness: float = 1.0, section_size: float = 1.0, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) SceneNodeHandle[source]#

Add a 2D grid to the scene.

This can be useful as a size, orientation, or ground plane reference.

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

  • width (float) – Width of the grid.

  • height (float) – Height of the grid.

  • width_segments (int) – Number of segments along the width.

  • height_segments (int) – Number of segments along the height.

  • plane (Literal[‘xz’, ‘xy’, ‘yx’, ‘yz’, ‘zx’, ‘zy’]) – The plane in which the grid is oriented (e.g., ‘xy’, ‘yz’).

  • cell_color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the grid cells as an RGB tuple.

  • cell_thickness (float) – Thickness of the grid lines.

  • cell_size (float) – Size of each cell in the grid.

  • section_color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the grid sections as an RGB tuple.

  • section_thickness (float) – Thickness of the section lines.

  • section_size (float) – Size of each section in the grid.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

SceneNodeHandle

add_label(name: str, text: str, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) LabelHandle[source]#

Add a 2D label to the scene.

This method creates a text label in the 3D scene, which can be used to annotate or provide information about specific points or objects.

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

  • text (str) – Text content of the label.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

LabelHandle

add_point_cloud(name: str, points: ndarray, colors: ndarray | tuple[float, float, float], point_size: float = 0.1, point_shape: Literal[‘square’, ‘diamond’, ‘circle’, ‘rounded’, ‘sparkle’] = 'square', wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) PointCloudHandle[source]#

Add a point cloud to the scene.

Parameters:
  • name (str) – Name of scene node. Determines location in kinematic tree.

  • points (ndarray) – Location of points. Should have shape (N, 3).

  • colors (ndarray | tuple[float, float, float]) – Colors of points. Should have shape (N, 3) or (3,).

  • point_size (float) – Size of each point.

  • point_shape (Literal[‘square’, ‘diamond’, ‘circle’, ‘rounded’, ‘sparkle’]) – Shape to draw each point.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

PointCloudHandle

add_mesh_simple(name: str, vertices: ndarray, faces: ndarray, color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray = (90, 200, 255), wireframe: bool = False, opacity: float | None = None, material: Literal[‘standard’, ‘toon3’, ‘toon5’] = 'standard', flat_shading: bool = False, side: Literal[‘front’, ‘back’, ‘double’] = 'front', wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) MeshHandle[source]#

Add a mesh to the scene.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • vertices (ndarray) – A numpy array of vertex positions. Should have shape (V, 3).

  • faces (ndarray) – A numpy array of faces, where each face is represented by indices of vertices. Should have shape (F,)

  • color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the mesh as an RGB tuple.

  • wireframe (bool) – Boolean indicating if the mesh should be rendered as a wireframe.

  • opacity (float | None) – Opacity of the mesh. None means opaque.

  • material (Literal[‘standard’, ‘toon3’, ‘toon5’]) – Material type of the mesh (‘standard’, ‘toon3’, ‘toon5’). This argument is ignored when wireframe=True.

  • flat_shading (bool) – Whether to do flat shading. This argument is ignored when wireframe=True.

  • side (Literal[‘front’, ‘back’, ‘double’]) – Side of the surface to render (‘front’, ‘back’, ‘double’).

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation from parent frame to local frame (t_pl).

  • visible (bool) – Whether or not this mesh is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

MeshHandle

add_mesh_trimesh(name: str, mesh: trimesh.Trimesh, scale: float = 1.0, wxyz: tuple[float, float, float, float] | onp.ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | onp.ndarray = (0.0, 0.0, 0.0), visible: bool = True) GlbHandle[source]#

Add a trimesh mesh to the scene. Internally calls self.add_glb().

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • mesh (trimesh.Trimesh) – A trimesh mesh object.

  • scale (float) – A scale for resizing the mesh.

  • wxyz (tuple[float, float, float, float] | onp.ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | onp.ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

GlbHandle

add_box(name: str, color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray, dimensions: tuple[float, float, float] | ndarray = (1.0, 1.0, 1.0), wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) MeshHandle[source]#

Add a box to the scene.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the box as an RGB tuple.

  • dimensions (tuple[float, float, float] | ndarray) – Dimensions of the box (x, y, z).

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation from parent frame to local frame (t_pl).

  • visible (bool) – Whether or not this box is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

MeshHandle

add_icosphere(name: str, radius: float, color: Tuple[int, int, int] | Tuple[float, float, float] | ndarray, subdivisions: int = 3, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) MeshHandle[source]#

Add an icosphere to the scene.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • radius (float) – Radius of the icosphere.

  • color (Tuple[int, int, int] | Tuple[float, float, float] | ndarray) – Color of the icosphere as an RGB tuple.

  • subdivisions (int) – Number of subdivisions to use when creating the icosphere.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation from parent frame to local frame (t_pl).

  • visible (bool) – Whether or not this icosphere is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

MeshHandle

set_background_image(image: ndarray, format: Literal[‘png’, ‘jpeg’] = 'jpeg', jpeg_quality: int | None = None, depth: ndarray | None = None) None[source]#

Set a background image for the scene, optionally with depth compositing.

Parameters:
  • image (ndarray) – The image to set as the background. Should have shape (H, W, 3).

  • format (Literal[‘png’, ‘jpeg’]) – Format to transport and display the image using (‘png’ or ‘jpeg’).

  • jpeg_quality (int | None) – Quality of the jpeg image (if jpeg format is used).

  • depth (ndarray | None) – Optional depth image to use to composite background with scene elements.

Return type:

None

add_image(name: str, image: ndarray, render_width: float, render_height: float, format: Literal[‘png’, ‘jpeg’] = 'jpeg', jpeg_quality: int | None = None, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) ImageHandle[source]#

Add a 2D image to the scene.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • image (ndarray) – A numpy array representing the image.

  • render_width (float) – Width at which the image should be rendered in the scene.

  • render_height (float) – Height at which the image should be rendered in the scene.

  • format (Literal[‘png’, ‘jpeg’]) – Format to transport and display the image using (‘png’ or ‘jpeg’).

  • jpeg_quality (int | None) – Quality of the jpeg image (if jpeg format is used).

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation from parent frame to local frame (t_pl).

  • visible (bool) – Whether or not this image is initially visible.

Returns:

Handle for manipulating scene node.

Return type:

ImageHandle

add_transform_controls(name: str, scale: float = 1.0, line_width: float = 2.5, fixed: bool = False, auto_transform: bool = True, active_axes: tuple[bool, bool, bool] = (True, True, True), disable_axes: bool = False, disable_sliders: bool = False, disable_rotations: bool = False, translation_limits: tuple[tuple[float, float], tuple[float, float], tuple[float, float]] = ((-1000.0, 1000.0), (-1000.0, 1000.0), (-1000.0, 1000.0)), rotation_limits: tuple[tuple[float, float], tuple[float, float], tuple[float, float]] = ((-1000.0, 1000.0), (-1000.0, 1000.0), (-1000.0, 1000.0)), depth_test: bool = True, opacity: float = 1.0, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) TransformControlsHandle[source]#

Add a transform gizmo for interacting with the scene.

This method adds a transform control (gizmo) to the scene, allowing for interactive manipulation of objects in terms of their position, rotation, and scale.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • scale (float) – Scale of the transform controls.

  • line_width (float) – Width of the lines used in the gizmo.

  • fixed (bool) – Boolean indicating if the gizmo should be fixed in position.

  • auto_transform (bool) – Whether the transform should be applied automatically.

  • active_axes (tuple[bool, bool, bool]) – tuple of booleans indicating active axes.

  • disable_axes (bool) – Boolean to disable axes interaction.

  • disable_sliders (bool) – Boolean to disable slider interaction.

  • disable_rotations (bool) – Boolean to disable rotation interaction.

  • translation_limits (tuple[tuple[float, float], tuple[float, float], tuple[float, float]]) – Limits for translation.

  • rotation_limits (tuple[tuple[float, float], tuple[float, float], tuple[float, float]]) – Limits for rotation.

  • depth_test (bool) – Boolean indicating if depth testing should be used when rendering.

  • opacity (float) – Opacity of the gizmo.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation from parent frame to local frame (t_pl).

  • visible (bool) – Whether or not this gizmo is initially visible.

Returns:

Handle for manipulating (and reading state of) scene node.

Return type:

TransformControlsHandle

reset() None[source]#

Reset the scene.

Return type:

None

on_pointer_event(event_type: Literal[‘click’, ‘rect-select’]) Callable[[Callable[[ScenePointerEvent], None]], Callable[[ScenePointerEvent], None]][source]#

Add a callback for scene pointer events.

Parameters:

event_type (Literal[‘click’, ‘rect-select’]) – event to listen to.

Return type:

Callable[[Callable[[ScenePointerEvent], None]], Callable[[ScenePointerEvent], None]]

on_pointer_callback_removed(func: Callable[[], None]) Callable[[], None][source]#

Add a callback to run automatically when the callback for a scene pointer event is removed. This will be triggered exactly once, either manually (via remove_pointer_callback()) or automatically (if the scene pointer event is overridden with another call to on_pointer_event()).

Parameters:

func (Callable[[], None]) – Callback for when scene pointer events are removed.

Return type:

Callable[[], None]

remove_pointer_callback() None[source]#

Remove the currently attached scene pointer event. This will trigger any callback attached to .on_scene_pointer_removed().

Return type:

None

add_3d_gui_container(name: str, wxyz: tuple[float, float, float, float] | ndarray = (1.0, 0.0, 0.0, 0.0), position: tuple[float, float, float] | ndarray = (0.0, 0.0, 0.0), visible: bool = True) Gui3dContainerHandle[source]#

Add a 3D gui container to the scene. The returned container handle can be used as a context to place GUI elements into the 3D scene.

Parameters:
  • name (str) – A scene tree name. Names in the format of /parent/child can be used to define a kinematic tree.

  • wxyz (tuple[float, float, float, float] | ndarray) – Quaternion rotation to parent frame from local frame (R_pl).

  • position (tuple[float, float, float] | ndarray) – Translation to parent frame from local frame (t_pl).

  • visible (bool) – Whether or not this scene node is initially visible.

Returns:

Handle for manipulating scene node. Can be used as a context to place GUI elements inside of the container.

Return type:

Gui3dContainerHandle