3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.

Static variables

@:native("Back")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).

@:native("Down")staticread onlyDOWN:Vector3

Down unit vector.

Value: Equivalent to new Vector3(0, -1, 0).

@:native("Forward")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).

@:native("Inf")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).

@:native("Left")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).

@:native("NegOne")staticread onlyNEG_ONE:Vector3

Deprecated, please use a negative sign with godot.Vector3.one instead.

Value: Equivalent to new Vector3(-1, -1, -1).

@:native("One")staticread onlyONE:Vector3

One vector, a vector with all components set to 1.

Value: Equivalent to new Vector3(1, 1, 1).

@:native("Right")staticread onlyRIGHT:Vector3

Right unit vector. Represents the local direction of right, and the global direction of east.

Value: Equivalent to new Vector3(1, 0, 0).

@:native("Up")staticread onlyUP:Vector3

Up unit vector.

Value: Equivalent to new Vector3(0, 1, 0).

@:native("Zero")staticread onlyZERO:Vector3

Zero vector, a vector with all components set to 0.

Value: Equivalent to new Vector3(0, 0, 0).

Static methods

@:op(A + B)staticinlineop_Addition(left:Vector3, right:Vector3):Vector3

Operator overload for godot.Vector3 + godot.Vector3.

@:op(A / B)staticinlineop_Division(vec:Vector3, divisor:Float):Vector3

@:op(A / B)staticinlineop_Division(vec:Vector3, divisorv:Vector3):Vector3

Operator overload for godot.Vector3 / ((global::System.Single)(Float)).

@:op(A == B)staticinlineop_Equality(left:Vector3, right:Vector3):Bool

Operator overload for godot.Vector3 == godot.Vector3.

@:op(A > B)staticinlineop_GreaterThan(left:Vector3, right:Vector3):Bool

Operator overload for godot.Vector3 > godot.Vector3.

@:op(A >= B)staticinlineop_GreaterThanOrEqual(left:Vector3, right:Vector3):Bool

Operator overload for godot.Vector3 >= godot.Vector3.

@:op(A != B)staticinlineop_Inequality(left:Vector3, right:Vector3):Bool

Operator overload for godot.Vector3 != godot.Vector3.

@:op(A < B)staticinlineop_LessThan(left:Vector3, right:Vector3):Bool

Operator overload for godot.Vector3 < godot.Vector3.

@:op(A <= B)staticinlineop_LessThanOrEqual(left:Vector3, right:Vector3):Bool

Operator overload for godot.Vector3 <= godot.Vector3.

@:op(A % B)staticinlineop_Modulus(vec:Vector3, divisor:Float):Vector3

@:op(A % B)staticinlineop_Modulus(vec:Vector3, divisorv:Vector3):Vector3

Operator overload for godot.Vector3 % ((global::System.Single)(Float)).

@:op(A * B)staticinlineop_Multiply(vec:Vector3, scale:Float):Vector3

@:op(A * B)staticinlineop_Multiply(left:Vector3, right:Vector3):Vector3

@:op(A * B)staticinlineop_Multiply(scale:Float, vec:Vector3):Vector3

Operator overload for godot.Vector3 * ((global::System.Single)(Float)).

@:op(A - B)staticinlineop_Subtraction(left:Vector3, right:Vector3):Vector3

Operator overload for godot.Vector3 - godot.Vector3.

@:op(-A)staticinlineop_UnaryNegation(vec:Vector3):Vector3

Operator overload for -godot.Vector3.

Constructor

@:value({ z : 0, y : 0, x : 0 })@:native("new")new(x:Single = 0, y:Single = 0, z:Single = 0)

@:native("new")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

@:native("x")x:Single

The vector's X component. Also accessible by using the index position [0].

@:native("y")y:Single

The vector's Y component. Also accessible by using the index position [1].

@:native("z")z:Single

The vector's Z component. Also accessible by using the index position [2].

Methods

@:native("Abs")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.

@:native("AngleTo")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.

@:native("Bounce")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.

@:native("Ceil")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.

@:native("Cross")cross(b:Vector3):Vector3

Returns the cross product of this vector and b.

Parameters:

b

The other vector.

Returns:

The cross product vector.

@:native("CubicInterpolate")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 b.

weight

A value on the range of 0.0 to 1.0, representing the amount of interpolation.

Returns:

The interpolated vector.

@:native("DirectionTo")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.

@:native("DistanceSquaredTo")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.

@:native("DistanceTo")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:

@:native("Dot")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.

@:native("Floor")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.

@:native("Inverse")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.

@:native("IsEqualApprox")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.

@:native("IsNormalized")isNormalized():Bool

Returns true if the vector is normalized, and false otherwise.

Returns:

A bool indicating whether or not the vector is normalized.

@:native("Length")length():Single

Returns the length (magnitude) of this vector.

Returns:

The length of this vector.

See also:

@:native("LengthSquared")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.

@:native("LinearInterpolate")linearInterpolate(to:Vector3, weight:Single):Vector3

@:native("LinearInterpolate")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.

@:native("MaxAxis")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.

@:native("MinAxis")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.

@:native("MoveToward")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.

@:native("Normalized")normalized():Vector3

Returns the vector scaled to unit length. Equivalent to v / v.Length().

Returns:

A normalized version of the vector.

@:native("Outer")outer(b:Vector3):Basis

Returns the outer product with b.

Parameters:

b

The other vector.

Returns:

A godot.Basis representing the outer product matrix.

@:native("PosMod")posMod(mod:Single):Vector3

@:native("PosMod")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.

@:native("Project")project(onNormal:Vector3):Vector3

Returns this vector projected onto another vector onNormal.

Parameters:

onNormal

The vector to project onto.

Returns:

The projected vector.

@:native("Reflect")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.

@:native("Rotated")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.

@:native("Round")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.

@:native("Set")set(x:Single, y:Single, z:Single):Void

@:native("Set")Set(v:Vector3):Void

@:native("Sign")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.

@:native("SignedAngleTo")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.

@:native("Slerp")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.

@:native("Slide")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.

@:native("Snapped")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.

@:native("ToDiagonalMatrix")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.

@:native("ToString")toString():String

@:native("ToString")ToString(format:String):String

Converts this godot.Vector3 to a string.

Returns:

A string representation of this vector.