Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Transform3D¶
A 3×4 matrix representing a 3D transformation.
Description¶
The Transform3D built-in Variant type is a 3×4 matrix representing a transformation in 3D space. It contains a Basis, which on its own can represent rotation, scale, and shear. Additionally, combined with its own origin, the transform can also represent a translation.
For a general introduction, see the Matrices and transforms tutorial.
Note: Godot uses a right-handed coordinate system, which is a common standard. For directions, the convention for built-in types like Camera3D is for -Z to point forward (+X is right, +Y is up, and +Z is back). Other objects may use different direction conventions. For more information, see the Importing 3D Scenes tutorial.
Note
There are notable differences when using this API with C#. See C# API differences to GDScript for more information.
Tutorials¶
Properties¶
|
||
|
Constructors¶
Transform3D ( ) |
|
Transform3D ( Transform3D from ) |
|
Transform3D ( Basis basis, Vector3 origin ) |
|
Transform3D ( Projection from ) |
|
Transform3D ( Vector3 x_axis, Vector3 y_axis, Vector3 z_axis, Vector3 origin ) |
Methods¶
affine_inverse ( ) const |
|
interpolate_with ( Transform3D xform, float weight ) const |
|
inverse ( ) const |
|
is_equal_approx ( Transform3D xform ) const |
|
is_finite ( ) const |
|
looking_at ( Vector3 target, Vector3 up=Vector3(0, 1, 0), bool use_model_front=false ) const |
|
orthonormalized ( ) const |
|
rotated_local ( Vector3 axis, float angle ) const |
|
scaled_local ( Vector3 scale ) const |
|
translated ( Vector3 offset ) const |
|
translated_local ( Vector3 offset ) const |
Operators¶
operator != ( Transform3D right ) |
|
operator * ( AABB right ) |
|
operator * ( PackedVector3Array right ) |
|
operator * ( Plane right ) |
|
operator * ( Transform3D right ) |
|
operator * ( Vector3 right ) |
|
operator * ( float right ) |
|
operator * ( int right ) |
|
operator == ( Transform3D right ) |
Constants¶
IDENTITY = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
A transform with no translation, no rotation, and its scale being 1
. Its basis is equal to Basis.IDENTITY.
When multiplied by another Variant such as AABB or another Transform3D, no transformation occurs.
FLIP_X = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
Transform3D with mirroring applied perpendicular to the YZ plane. Its basis is equal to Basis.FLIP_X.
FLIP_Y = Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)
Transform3D with mirroring applied perpendicular to the XZ plane. Its basis is equal to Basis.FLIP_Y.
FLIP_Z = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)
Transform3D with mirroring applied perpendicular to the XY plane. Its basis is equal to Basis.FLIP_Z.
Property Descriptions¶
Basis basis = Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)
The Basis of this transform. It is composed by 3 axes (Basis.x, Basis.y, and Basis.z). Together, these represent the transform's rotation, scale, and shear.
Vector3 origin = Vector3(0, 0, 0)
The translation offset of this transform. In 3D space, this can be seen as the position.
Constructor Descriptions¶
Transform3D Transform3D ( )
Constructs a Transform3D identical to the IDENTITY.
Transform3D Transform3D ( Transform3D from )
Constructs a Transform3D as a copy of the given Transform3D.
Transform3D Transform3D ( Basis basis, Vector3 origin )
Constructs a Transform3D from a Basis and Vector3.
Transform3D Transform3D ( Projection from )
Constructs a Transform3D from a Projection. Because Transform3D is a 3×4 matrix and Projection is a 4×4 matrix, this operation trims the last row of the projection matrix (from.x.w
, from.y.w
, from.z.w
, and from.w.w
are not included in the new transform).
Transform3D Transform3D ( Vector3 x_axis, Vector3 y_axis, Vector3 z_axis, Vector3 origin )
Constructs a Transform3D from four Vector3 values (also called matrix columns).