a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Shared / Vector3
Vector3 Class representing a 3D vector, implementing the Vec3 interface.
new Vector3(
x,y,z):Vector3
Constructs a new Vector3 instance.
• x: number
The x-coordinate of the vector.
• y: number
The y-coordinate of the vector.
• z: number
The z-coordinate of the vector.
x:
number
The x-coordinate of the vector.
y:
number
The y-coordinate of the vector.
z:
number
The z-coordinate of the vector.
getLength():number
Gets the length (magnitude) of the vector.
number
The length of the vector.
getnormalize():Vector3
Gets a normalized version of this vector.
A new Vector3 object with the same direction as this vector but with a length of 1.
add(
v):Vec3
Adds a number or another vector to this vector.
• v: NumerableVector3
The value to add (either a number or a vector).
A new Vector3 representing the result of the addition.
clone():
Vector3
Clones the current Vector3 object into a new Vector3 object.
A new Vector3 object with the same x, y, and z values.
crossProduct(
v):Vector3
Calculates the cross product of this vector and another vector.
• v: Vec3
The other vector to calculate the cross product with.
A new Vector3 representing the cross product of the two vectors.
distance(
v):number
Calculates the distance between this vector and another vector.
• v: Vec3
The other vector to calculate the distance to.
number
The distance between the two vectors.
distanceSquared(
v):number
The product of the Euclidean magnitudes of this and another Vector3.
• v: Vec3
Vector3 to find Euclidean magnitude between.
number
Euclidean magnitude with another vector.
divide(
v):Vec3
Divides this vector by a number or another vector.
• v: NumerableVector3
The value to divide by (either a number or a vector).
A new Vector3 representing the result of the division.
dotProduct(
v):number
Calculates the dot product of this vector and another vector.
• v: Vec3
The other vector to calculate the dot product with.
number
The dot product of the two vectors.
multiply(
v):Vector3
Multiplies this vector by a number or another vector.
• v: NumerableVector3
The value to multiply by (either a number or a vector).
A new Vector3 representing the result of the multiplication.
replace(
v):void
Replaces the current vector’s components with those of another vector.
• v: Vec3
The vector to replace with.
void
subtract(
v):Vector3
Subtracts another vector from this vector.
• v: NumerableVector3
The vector to subtract.
A new Vector3 representing the result of the subtraction.
staticadd(v1,v2):Vector3
Adds two vectors or a vector and a number.
• v1: Vec3
The first vector.
• v2: NumerableVector3
The second vector or number to add.
A new Vector3 representing the result of the addition.
staticclone(v1):Vector3
Clones a vector.
• v1: Vec3
The vector to clone.
A new Vector3 instance identical to the input vector.
staticcreate(v1):Vector3
Creates a new Vector3 instance from a number or a vector.
• v1: NumerableVector3
A number or a vector to create a Vector3 from.
A new Vector3 instance.
staticcrossProduct(v1,v2):Vector3
Calculates the cross product of two vectors.
• v1: Vec3
The first vector.
• v2: Vec3
The second vector.
A new Vector3 representing the cross product of the two vectors.
staticdivide(v1,v2):Vector3
Divides a vector by another vector or a number.
• v1: Vec3
The vector to divide.
• v2: NumerableVector3
The vector or number to divide by.
A new Vector3 representing the result of the division.
staticdotProduct(v1,v2):number
Calculates the dot product of two vectors.
• v1: Vec3
The first vector.
• v2: Vec3
The second vector.
number
The dot product of the two vectors.
staticmultiply(v1,v2):Vector3
Multiplies two vectors or a vector and a number.
• v1: Vec3
The first vector.
• v2: NumerableVector3
The second vector or number to multiply by.
A new Vector3 representing the result of the multiplication.
staticnormalize(v):Vector3
Normalizes a vector, scaling it to have a length of 1.
• v: Vector3
The vector to normalize.
A new Vector3 representing the normalized vector.
staticsubtract(v1,v2):Vector3
Subtracts a vector or a number from another vector.
• v1: Vec3
The vector to subtract from.
• v2: NumerableVector3
The vector or number to subtract.
A new Vector3 representing the result of the subtraction.