Skip to content

Triggers

These are the available callbacks that the 3d view will trigger and can be subscribed with subscribe method:

Input triggers

  • click: Will be called when click event is triggered on the view.
  • dblclick: Will be called when dblclick event is triggered on the view.
  • contextmenu: Will be called when contextmenu event is triggered on the view.
  • up: Will be called when mouseup or touchstart events are triggered on the view.
  • down: Will be called when mousedown or touchend events are triggered on the view.
  • move: Will be called when mousemove or touchmove events are triggered on the view.
  • hover: Will be called when hovering a node.
  • enter: Will be called when the cursor enters the node.
  • leave: Will be called when the cursor leaves the node.
  • wheel: Will be called when wheel event is triggered on the view.
  • keydown: Will be called when a keyboard key is pressed while the viewer is focused.
  • keyup: Will be called when when a keyboard key is released while the viewer is focused.

Camera triggers

  • panning: Will be called when the camera moves.

Load triggers

  • load_start: Will be called when a view starts the load process.
  • load_success: Will be called when a view finishes the load process successfully.
  • load_error: Will be called when a view load process finishes with an error.
  • reset: Will be called when the 3d viewer is reset, through reset(), or if a load fails.
  • end_load_animation: Will be called when the load animation finishes.

Interface triggers

  • fullscreen_enabled: Will be called when full screen is enabled.
  • fullscreen_disabled: Will be called when full screen is disabled.

Misc triggers

  • update: Will be called in every frame.

To standardize and allow the content extension, all these callbacks will receive the following basic Object as first parameter:

  • action (string): Action ID that triggered the call (from the list above).
  • instance (Viewer3d): Viewer3d Instance that triggered the call.
  • nodes (Viewer3dNode[]): Viewer3dNode array with the nodes that triggered the call. This array can be empty, for example if a click is triggered from an empty part of the view, or in case of panning trigger, for example. It can also contain multiple nodes, for example clicking on on an object with another one behind it. They will be ordered by distance.
  • original_event (Event) [optional]: Original event (click, mousemove, etc) object triggered (if any).