trimesh.viewer.trackball

Trackball class for 3D manipulation of viewpoints.

class trimesh.viewer.trackball.Trackball(pose, size, scale, target=array([0., 0., 0.]))

Bases: object

A trackball class for creating camera transforms from mouse movements.

STATE_PAN = 1
STATE_ROLL = 2
STATE_ROTATE = 0
STATE_ZOOM = 3
__init__(pose, size, scale, target=array([0., 0., 0.]))

Initialize a trackball with an initial camera-to-world pose and the given parameters.

Parameters
  • pose ([4,4]) – An initial camera-to-world pose for the trackball.

  • size ((float, float)) – The width and height of the camera image in pixels.

  • scale (float) – The diagonal of the scene’s bounding box – used for ensuring translation motions are sufficiently fast for differently-sized scenes.

  • target ((3,) float) – The center of the scene in world coordinates. The trackball will revolve around this point.

down(point)

Record an initial mouse press at a given point.

Parameters

point ((2,) int) – The x and y pixel coordinates of the mouse press.

drag(point)

Update the tracball during a drag.

Parameters

point ((2,) int) – The current x and y pixel coordinates of the mouse during a drag. This will compute a movement for the trackball with the relative motion between this point and the one marked by down().

property pose

The current camera-to-world pose.

Type

autolab_core.RigidTransform

resize(size)

Resize the window.

Parameters

size ((float, float)) – The new width and height of the camera image in pixels.

rotate(azimuth, axis=None)

Rotate the trackball about the “Up” axis by azimuth radians.

Parameters

azimuth (float) – The number of radians to rotate.

scroll(clicks)

Zoom using a mouse scroll wheel motion.

Parameters

clicks (int) – The number of clicks. Positive numbers indicate forward wheel movement.

set_state(state)

Set the state of the trackball in order to change the effect of dragging motions.

Parameters

state (int) – One of Trackball.STATE_ROTATE, Trackball.STATE_PAN, Trackball.STATE_ROLL, and Trackball.STATE_ZOOM.