Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
lookingAt(target:up:useModelFront:)
Returns a copy of the transform rotated such that the forward axis (-Z) points towards the target
position.
func lookingAt(target: Vector3, up: Vector3 = Vector3 (x: 0, y: 1, z: 0), useModelFront: Bool = false) -> Transform3D
The up axis (+Y) points as close to the up
vector as possible while staying perpendicular to the forward axis. The resulting transform is orthonormalized. The existing rotation, scale, and skew information from the original transform is discarded. The target
and up
vectors cannot be zero, cannot be parallel to each other, and are defined in global/parent space.
If useModelFront
is true
, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the target
position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).
Other members in extension
Type members
init(
) Constructs a default-initialized
Transform3D
set toIDENTITY
.init(basis: Basis, origin: Vector3
) Constructs a Transform3D from a
Basis
andVector3
.init(from: Transform3D
) Constructs a
Transform3D
as a copy of the givenTransform3D
.init(from: Projection
) Constructs a Transform3D from a
Projection
by trimming the last row of the projection matrix (from.x.w
,from.y.w
,from.z.w
, andfrom.w.w
are not copied over).init(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3, origin: Vector3
) Constructs a Transform3D from four
Vector3
values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled).static let flipX: Transform3D
Transform3D
with mirroring applied perpendicular to the YZ plane.static let flipY: Transform3D
Transform3D
with mirroring applied perpendicular to the XZ plane.static let flipZ: Transform3D
Transform3D
with mirroring applied perpendicular to the XY plane.static var godotType: Variant.GType
static let identity: Transform3D
Transform3D
with no translation, rotation or scaling applied. When applied to other data structures,IDENTITY
performs no transformation.static func != (lhs: Transform3D, rhs: Transform3D
) -> Bool Returns
true
if the transforms are not equal.static func * (lhs: Transform3D, rhs: Transform3D
) -> Transform3D This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform3D, rhs: Double
) -> Transform3D This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform3D, rhs: Int64
) -> Transform3D This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform3D, rhs: PackedVector3Array
) -> PackedVector3Array This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform3D, rhs: AABB
) -> AABB This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform3D, rhs: Plane
) -> Plane This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func * (lhs: Transform3D, rhs: Vector3
) -> Vector3 This operator multiplies all components of the
Transform3D
, including theorigin
vector, which scales it uniformly.static func == (lhs: Transform3D, rhs: Transform3D
) -> Bool Returns
true
if the transforms are exactly equal.
Instance members
var basis: Basis
The basis is a matrix containing 3
Vector3
as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object.var origin: Vector3
The translation offset of the transform (column 3, the fourth column). Equivalent to array index
3
.func affineInverse(
) -> Transform3D Returns the inverse of the transform, under the assumption that the basis is invertible (must have non-zero determinant).
func interpolateWith(xform: Transform3D, weight: Double
) -> Transform3D Returns a transform interpolated between this transform and another by a given
weight
(on the range of 0.0 to 1.0).func inverse(
) -> Transform3D Returns the inverse of the transform, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). Use
affineInverse
for non-orthonormal transforms (e.g. with scaling).func isEqualApprox(xform: Transform3D
) -> Bool Returns
true
if this transform andxform
are approximately equal, by running@GlobalScope.is_equal_approx
on each component.func isFinite(
) -> Bool Returns
true
if this transform is finite, by calling@GlobalScope.is_finite
on each component.func orthonormalized(
) -> Transform3D Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
func rotated(axis: Vector3, angle: Double
) -> Transform3D Returns a copy of the transform rotated around the given
axis
by the givenangle
(in radians).func rotatedLocal(axis: Vector3, angle: Double
) -> Transform3D Returns a copy of the transform rotated around the given
axis
by the givenangle
(in radians).func scaled(scale: Vector3
) -> Transform3D Returns a copy of the transform scaled by the given
scale
factor.func scaledLocal(scale: Vector3
) -> Transform3D Returns a copy of the transform scaled by the given
scale
factor.func translated(offset: Vector3
) -> Transform3D Returns a copy of the transform translated by the given
offset
.func translatedLocal(offset: Vector3
) -> Transform3D Returns a copy of the transform translated by the given
offset
.