pygfx.utils.transform.AffineTransform
- class pygfx.utils.transform.AffineTransform(position=(0, 0, 0), rotation=(0, 0, 0, 1), scale=(1, 1, 1), *, reference_up=(0, 1, 0), is_camera_space=False, state_basis='components', matrix: ndarray = None)
Bases:
AffineBase
A single affine transform.
- Parameters:
position (ndarray, [3]) – The position of this transform expressed in the target frame. This argument is only consumed if
state_basis
is set to “components”.rotation (ndarray, [4]) – The rotation quaternion of this transform expressed in the target frame. This argument is only consumed if
state_basis
is set to “components”.scale (ndarray, [3]) – The per-axis scale of this transform expressed in the target frame. This argument is only consumed if
state_basis
is set to “components”.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
andright
directions are inverted.state_basis (str) – One of “components” or “matrix”. The default is “components”. If “components”, the transform will store its state in the form of position, rotation, and scale, while the matrix will be computed. If “matrix”, the transform will store its state in the form of a matrix, while the position, rotation and scale will be computed. This option is provided to allow for performance optimizations when the transform is used in a context where the state is updated in one form but queried in another. Depending on your usage patterns, you may avoid significant overhead by choosing the appropriate basis.
matrix (ndarray, [4, 4]) – The affine matrix describing this transform. This argument is only consumed if
state_basis
is set to “matrix”.
Notes
When updating the underlying numpy arrays 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.