3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
Static variables
staticread onlyBACK:Vector3
Back unit vector. Represents the local direction of back, and the global direction of south.
Value: Equivalent to new Vector3(0, 0, 1)
.
staticread onlyFORWARD:Vector3
Forward unit vector. Represents the local direction of forward, and the global direction of north.
Value: Equivalent to new Vector3(0, 0, -1)
.
staticread onlyINF:Vector3
Infinity vector, a vector with all components set to godot.Mathf.INF
.
Value: Equivalent to new Vector3(Mathf.Inf, Mathf.Inf, Mathf.Inf)
.
staticread onlyLEFT:Vector3
Left unit vector. Represents the local direction of left, and the global direction of west.
Value: Equivalent to new Vector3(-1, 0, 0)
.
staticread onlyNEG_ONE:Vector3
Deprecated, please use a negative sign with godot.Vector3.one
instead.
Value: Equivalent to new Vector3(-1, -1, -1)
.
staticread onlyONE:Vector3
One vector, a vector with all components set to 1
.
Value: Equivalent to new Vector3(1, 1, 1)
.
Static methods
staticinlineop_Addition(left:Vector3, right:Vector3):Vector3
Operator overload for godot.Vector3
+ godot.Vector3
.
staticinlineop_Division(vec:Vector3, divisor:Float):Vector3
staticinlineop_Division(vec:Vector3, divisorv:Vector3):Vector3
Operator overload for godot.Vector3
/ ((global::System.Single)(Float
)).
staticinlineop_Equality(left:Vector3, right:Vector3):Bool
Operator overload for godot.Vector3
== godot.Vector3
.
staticinlineop_GreaterThan(left:Vector3, right:Vector3):Bool
Operator overload for godot.Vector3
> godot.Vector3
.
staticinlineop_GreaterThanOrEqual(left:Vector3, right:Vector3):Bool
Operator overload for godot.Vector3
>= godot.Vector3
.
staticinlineop_Inequality(left:Vector3, right:Vector3):Bool
Operator overload for godot.Vector3
!= godot.Vector3
.
staticinlineop_LessThan(left:Vector3, right:Vector3):Bool
Operator overload for godot.Vector3
< godot.Vector3
.
staticinlineop_LessThanOrEqual(left:Vector3, right:Vector3):Bool
Operator overload for godot.Vector3
<= godot.Vector3
.
staticinlineop_Modulus(vec:Vector3, divisor:Float):Vector3
staticinlineop_Modulus(vec:Vector3, divisorv:Vector3):Vector3
Operator overload for godot.Vector3
% ((global::System.Single)(Float
)).
staticinlineop_Multiply(vec:Vector3, scale:Float):Vector3
staticinlineop_Multiply(left:Vector3, right:Vector3):Vector3
staticinlineop_Multiply(scale:Float, vec:Vector3):Vector3
Operator overload for godot.Vector3
* ((global::System.Single)(Float
)).
staticinlineop_Subtraction(left:Vector3, right:Vector3):Vector3
Operator overload for godot.Vector3
- godot.Vector3
.
Constructor
new(x:Single = 0, y:Single = 0, z:Single = 0)
new(v:Vector3)
Constructs a new godot.Vector3
with the given components.
Parameters:
x | The vector's X component. |
---|---|
y | The vector's Y component. |
z | The vector's Z component. |
Variables
Methods
abs():Vector3
Returns a new vector with all components in absolute values (i.e. positive).
Returns:
A vector with godot.Mathf.abs
called on each component.
angleTo(to:Vector3):Single
Returns the unsigned minimum angle to the given vector, in radians.
Parameters:
to | The other vector to compare this vector to. |
---|
Returns:
The unsigned angle between the two vectors, in radians.
bounce(normal:Vector3):Vector3
Returns this vector "bounced off" from a plane defined by the given normal.
Parameters:
normal | The normal vector defining the plane to bounce off. Must be normalized. |
---|
Returns:
The bounced vector.
ceil():Vector3
Returns a new vector with all components rounded up (towards positive infinity).
Returns:
A vector with godot.Mathf.ceil
called on each component.
cross(b:Vector3):Vector3
Returns the cross product of this vector and b
.
Parameters:
b | The other vector. |
---|
Returns:
The cross product vector.
cubicInterpolate(b:Vector3, preA:Vector3, postB:Vector3, weight:Single):Vector3
Performs a cubic interpolation between vectors preA
, this vector,
b
, and postB
, by the given amount weight
.
Parameters:
b | The destination vector. |
---|---|
preA | A vector before this vector. |
postB | A vector after |
weight | A value on the range of 0.0 to 1.0, representing the amount of interpolation. |
Returns:
The interpolated vector.
directionTo(b:Vector3):Vector3
Returns the normalized vector pointing from this vector to b
.
Parameters:
b | The other vector to point towards. |
---|
Returns:
The direction from this vector to b
.
distanceSquaredTo(b:Vector3):Single
Returns the squared distance between this vector and b
.
This method runs faster than godot.Vector3.distanceTo
, so prefer it if
you need to compare vectors or need the squared distance for some formula.
Parameters:
b | The other vector to use. |
---|
Returns:
The squared distance between the two vectors.
distanceTo(b:Vector3):Single
Returns the distance between this vector and b
.
Parameters:
b | The other vector to use. |
---|
Returns:
The distance between the two vectors.
See also:
dot(b:Vector3):Single
Returns the dot product of this vector and b
.
Parameters:
b | The other vector to use. |
---|
Returns:
The dot product of the two vectors.
floor():Vector3
Returns a new vector with all components rounded down (towards negative infinity).
Returns:
A vector with godot.Mathf.floor
called on each component.
inverse():Vector3
Returns the inverse of this vector. This is the same as new Vector3(1 / v.x, 1 / v.y, 1 / v.z)
.
Returns:
The inverse of this vector.
isEqualApprox(other:Vector3):Bool
Returns true
if this vector and other
are approximately equal,
by running godot.Mathf.isEqualApprox
on each component.
Parameters:
other | The other vector to compare. |
---|
Returns:
Whether or not the vectors are approximately equal.
isNormalized():Bool
Returns true
if the vector is normalized, and false
otherwise.
Returns:
A bool
indicating whether or not the vector is normalized.
length():Single
Returns the length (magnitude) of this vector.
Returns:
The length of this vector.
See also:
lengthSquared():Single
Returns the squared length (squared magnitude) of this vector.
This method runs faster than godot.Vector3.length
, so prefer it if
you need to compare vectors or need the squared length for some formula.
Returns:
The squared length of this vector.
linearInterpolate(to:Vector3, weight:Single):Vector3
LinearInterpolate(to:Vector3, weight:Vector3):Vector3
Returns the result of the linear interpolation between
this vector and to
by amount weight
.
Parameters:
to | The destination vector for interpolation. |
---|---|
weight | A value on the range of 0.0 to 1.0, representing the amount of interpolation. |
Returns:
The resulting vector of the interpolation.
maxAxis():Vector3_Axis
Returns the axis of the vector's largest value. See godot.Vector3_Axis
.
If all components are equal, this method returns godot.Vector3_Axis.x
.
Returns:
The index of the largest axis.
minAxis():Vector3_Axis
Returns the axis of the vector's smallest value. See godot.Vector3_Axis
.
If all components are equal, this method returns godot.Vector3_Axis.z
.
Returns:
The index of the smallest axis.
moveToward(to:Vector3, delta:Single):Vector3
Moves this vector toward to
by the fixed delta
amount.
Parameters:
to | The vector to move towards. |
---|---|
delta | The amount to move towards by. |
Returns:
The resulting vector.
normalized():Vector3
Returns the vector scaled to unit length. Equivalent to v / v.Length()
.
Returns:
A normalized version of the vector.
outer(b:Vector3):Basis
Returns the outer product with b
.
Parameters:
b | The other vector. |
---|
Returns:
A godot.Basis
representing the outer product matrix.
posMod(mod:Single):Vector3
PosMod(modv:Vector3):Vector3
Returns a vector composed of the godot.Mathf.posMod
of this vector's components
and mod
.
Parameters:
mod | A value representing the divisor of the operation. |
---|
Returns:
A vector with each component godot.Mathf.posMod
by mod
.
project(onNormal:Vector3):Vector3
Returns this vector projected onto another vector onNormal
.
Parameters:
onNormal | The vector to project onto. |
---|
Returns:
The projected vector.
reflect(normal:Vector3):Vector3
Returns this vector reflected from a plane defined by the given normal
.
Parameters:
normal | The normal vector defining the plane to reflect from. Must be normalized. |
---|
Returns:
The reflected vector.
rotated(axis:Vector3, phi:Single):Vector3
Rotates this vector around a given axis
vector by phi
radians.
The axis
vector must be a normalized vector.
Parameters:
axis | The vector to rotate around. Must be normalized. |
---|---|
phi | The angle to rotate by, in radians. |
Returns:
The rotated vector.
round():Vector3
Returns this vector with all components rounded to the nearest integer, with halfway cases rounded towards the nearest multiple of two.
Returns:
The rounded vector.
sign():Vector3
Returns a vector with each component set to one or negative one, depending
on the signs of this vector's components, or zero if the component is zero,
by calling godot.Mathf.sign
on each component.
Returns:
A vector with all components as either 1
, -1
, or 0
.
signedAngleTo(to:Vector3, axis:Vector3):Single
Returns the signed angle to the given vector, in radians.
The sign of the angle is positive in a counter-clockwise
direction and negative in a clockwise direction when viewed
from the side specified by the axis
.
Parameters:
to | The other vector to compare this vector to. |
---|---|
axis | The reference axis to use for the angle sign. |
Returns:
The signed angle between the two vectors, in radians.
slerp(to:Vector3, weight:Single):Vector3
Returns the result of the spherical linear interpolation between
this vector and to
by amount weight
.
Note: Both vectors must be normalized.
Parameters:
to | The destination vector for interpolation. Must be normalized. |
---|---|
weight | A value on the range of 0.0 to 1.0, representing the amount of interpolation. |
Returns:
The resulting vector of the interpolation.
slide(normal:Vector3):Vector3
Returns this vector slid along a plane defined by the given normal
.
Parameters:
normal | The normal vector defining the plane to slide on. |
---|
Returns:
The slid vector.
snapped(step:Vector3):Vector3
Returns this vector with each component snapped to the nearest multiple of step
.
This can also be used to round to an arbitrary number of decimals.
Parameters:
step | A vector value representing the step size to snap to. |
---|
Returns:
The snapped vector.
toDiagonalMatrix():Basis
Returns a diagonal matrix with the vector as main diagonal.
This is equivalent to a godot.Basis
with no rotation or shearing and
this vector's components set as the scale.
Returns:
A godot.Basis
with the vector as its main diagonal.