Transform3D class

This class describes a generic 3D transform, which is a combination of translations, rotations and scaling. These transforms are combined into a single matrix, that can be either applied to a graphical device like the canvas, composed with another transform, or used directly to convert coordinates.

The transform can be visualized as 2 reference frames: a "global" and a "local". At first, these two reference frames coincide. Then, the following sequence of transforms is applied:

  • translation to point position;
  • rotate using the rotation;
  • scaling in X, Y and Z directions by scale factors.

The class is optimized for repeated use: the transform matrix is cached and then recalculated only when the underlying properties change. Moreover, recalculation of the transform is postponed until the matrix is actually requested by the user. Thus, modifying multiple properties at once does not incur the penalty of unnecessary recalculations.

This class implements the ChangeNotifier API, allowing you to subscribe for notifications whenever the transform matrix changes. In addition, you can subscribe to get notified when individual components of the transform change: position, scale, and rotation.

Inheritance

Constructors

Transform3D()
This class describes a generic 3D transform, which is a combination of translations, rotations and scaling. These transforms are combined into a single matrix, that can be either applied to a graphical device like the canvas, composed with another transform, or used directly to convert coordinates.
Transform3D.copy(Transform3D other)
This class describes a generic 3D transform, which is a combination of translations, rotations and scaling. These transforms are combined into a single matrix, that can be either applied to a graphical device like the canvas, composed with another transform, or used directly to convert coordinates.
factory
Transform3D.fromMatrix4(Matrix4 matrix)
This class describes a generic 3D transform, which is a combination of translations, rotations and scaling. These transforms are combined into a single matrix, that can be either applied to a graphical device like the canvas, composed with another transform, or used directly to convert coordinates.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
position NotifyingVector3
The translation part of the transform. This translation is applied relative to the global coordinate space.
getter/setter pair
rotation NotifyingQuaternion
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale NotifyingVector3
The scale part of the transform. The default scale factor is (1, 1, 1), a scale greater than 1 corresponds to expansion, and less than 1 is contraction. A negative scale is also allowed, and it corresponds to a mirror reflection around the corresponding axis. Scale factors can be different for X, Y and Z directions.
getter/setter pair
transformMatrix Matrix4
The total transformation matrix for the component. This matrix combines translation, rotation and scale transforms into a single entity. The matrix is cached and gets recalculated only when necessary.
no setter
x double
X coordinate of the translation transform.
getter/setter pair
y double
Y coordinate of the translation transform.
getter/setter pair
z double
Z coordinate of the translation transform.
getter/setter pair

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
clone() Transform3D
Clone of this.
closeTo(Transform3D other, {double tolerance = 1e-10}) bool
Check whether this transform is equal to other, up to the given tolerance. Setting tolerance to zero will check for exact equality. Transforms are considered equal if their rotation angles are the same or differ by a multiple of 2π, and if all other transform parameters: translation, scale, and offset are the same.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
setFrom(Transform3D other) → void
Set this to the values of the other Transform3D.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited