Events¶
We define a small set of event types, which are passed to callback functions when events like clicks or GUI updates are triggered.
- class viser.ScenePointerEvent[source]¶
Event passed to pointer callbacks for the scene (currently only clicks).
- client: ClientHandle¶
Client that triggered this event.
- client_id: int¶
ID of client that triggered this event.
- event_type: _messages.ScenePointerEventType¶
Type of event that was triggered. Currently we only support clicks and box selections.
- ray_origin: tuple[float, float, float] | None¶
Origin of 3D ray corresponding to this click, in world coordinates.
- ray_direction: tuple[float, float, float] | None¶
Direction of 3D ray corresponding to this click, in world coordinates.
- screen_pos: tuple[tuple[float, float], ...]¶
Screen position of the click on the screen (OpenCV image coordinates, 0 to 1). (0, 0) is the upper-left corner, (1, 1) is the bottom-right corner. For a box selection, this includes the min- and max- corners of the box.
- property event¶
Deprecated. Use
event_type
instead.
- class viser.SceneNodePointerEvent[source]¶
Event passed to pointer callbacks for scene nodes (currently only clicks).
- client: ClientHandle¶
Client that triggered this event.
- client_id: int¶
ID of client that triggered this event.
- event: Literal['click']¶
Type of event that was triggered. Currently we only support clicks.
- target: TSceneNodeHandle¶
Scene node that was clicked.
- ray_origin: tuple[float, float, float]¶
Origin of 3D ray corresponding to this click, in world coordinates.
- ray_direction: tuple[float, float, float]¶
Direction of 3D ray corresponding to this click, in world coordinates.
- screen_pos: tuple[float, float]¶
Screen position of the click on the screen (OpenCV image coordinates, 0 to 1). (0, 0) is the upper-left corner, (1, 1) is the bottom-right corner.
- instance_index: int | None¶
Instance ID of the clicked object, if applicable. Currently this is
None
for all objects except for the output ofSceneApi.add_batched_axes()
.
- class viser.GuiEvent[source]¶
Information associated with a GUI event, such as an update or click.
Passed as input to callback functions.
- client: ClientHandle | None¶
Client that triggered this event.
- client_id: int | None¶
ID of client that triggered this event.
- target: TGuiHandle¶
GUI element that was affected.