pygfx.utils.transform.AffineTransform

class pygfx.utils.transform.AffineTransform(matrix=None, /, *, position=None, rotation=None, scale=None, reference_up=(0, 1, 0), is_camera_space=False)

Bases: AffineBase

A single affine transform.

Parameters:
  • matrix (ndarray, [4, 4]) – The affine matrix used to back this transform. If None, a new diagonal matrix will be initialized.

  • position (ndarray, [3]) – The position of this transform expressed in the target frame. This will overwrite the position component of matrix if present.

  • rotation (ndarray, [4]) – The rotation quaternion of this transform expressed in the target frame. This will overwrite the rotation component of matrix if present.

  • scale (ndarray, [3]) – The per-axis scale of this transform expressed in the target frame. This will overwrite the scale component of matrix if present.

  • reference_up (ndarray, [3]) – The direction of the reference_up vector expressed in the target frame. It indicates neutral tilt and is used by the axis properties (right, up, forward) to maintain a common level of rotation around an axis when it is updated by it’s setter. By default, it points along the Y-axis.

  • is_camera_space (bool) – If True, the transform represents a camera space which means that it’s forward and right directions are inverted.

Notes

The transform class “wraps” the provided matrix and shares its buffer. This is useful when optimizing performance, as it is possible to wrap a view into an (aligned) buffer of multiple transformation matrices or, alternatively, to directly wrap a uniform buffer. Updates to the transform will then directly modify this matrix which speeds up computation by avoiding copies or exploiting data alignment.

When updating the underlying matrix in-place these updates will not propagate via the transform’s callback system nor will they invalidate existing caches. To inform the transform of these updates call transform.flag_update(), which will trigger both callbacks and cache invalidation.

See also

AffineBase

Base class defining various useful properties for this transform.

flag_update()

Signal that this transform has updated.

property matrix

Affine matrix describing this transform.

vec_target = matrix @ vec_source.

Examples

Culling

Culling