pygfx.helpers.TransformGizmo

class pygfx.helpers.TransformGizmo(object=None, screen_size=100)

Bases: WorldObject

Gizmo to manipulate a WorldObject.

This Gizmo allows to interactively control WorldObjects with the mouse inside a canvas. It can translate and rotate objects relative to the world frame, local frame, or camera frame (screen space).

To control the Gizmo:

  • Click the center sphere to toggle between object-space, world-space and screen-space.

  • Grab the center sphere for uniform scaling.

  • Grab the cubes for one-directional scaling (only in object-space).

  • Grab the arrows to translate in one direction.

  • Grab the planes to translate in two directions.

  • Grab the spheres to rotate.

Parameters:
  • object (WorldObject) – The controlled world object.

  • screen_size (float) – The approximate size of the widget in logical pixels. Default 100.

set_object(object: WorldObject)

Update the controlled object.

Parameters:

object (WorldObject) – The new controlled object.

toggle_mode(mode=None)

Switch the reference frame.

Parameters:

mode (str) – The reference frame to switch to. Must be one of "object" (local frame), "world" (world frame), or "screen" (camera frame). If None the next mode (following this order) is selected.

add_default_event_handlers(viewport, camera)

Register Gizmo callbacks.

process_event(event)

Callback to handle gizmo-related events.

Examples

Gizmo to transform world objects

Gizmo to transform world objects