Vector3
Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z).
Implements
- Vector
Constructors
constructor
Parameters
- _x: number
- _y: number
- _z: number
Returns Vector3
Properties
x0
the x value of this vector.
y0
the y value of this vector.
z0
the z value of this vector.
is Vector3
Check the type whether it belongs to Vector3. This value should not be changed by user.
Methods
has Nan
If NaN exists in three elements, return true.
Returns boolean
set
set Scalar
set X
set Y
set Z
set Component
get Component
clone
clone Readonly
- cloneReadonly(): Readonly<
Pick<
ReadonlyMarked,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "x"
| "y"
| "z"
| "getNumberCount"
| "toArray"
| "dot"
| "lengthSq"
| "length"
| "manhattanLength"
| "distanceTo"
| "distanceToSquared"
| "manhattanDistanceTo"
| "angleTo",
>,
>Returns Readonly<
Pick<
ReadonlyMarked,
| "_readonly_mark"
| "cloneReadonly"
| "clone"
| "equals"
| "getSerializeData"
| "x"
| "y"
| "z"
| "getNumberCount"
| "toArray"
| "dot"
| "lengthSq"
| "length"
| "manhattanLength"
| "distanceTo"
| "distanceToSquared"
| "manhattanDistanceTo"
| "angleTo",
>,
>
copy
add
add Scalar
add Vectors
add Scaled Vector
sub
sub Scalar
sub Vectors
multiply
multiply Scalar
Multiplies this vector by scalar s.
Parameters
- scalar: number
Returns Vector3
Implementation of Vector.multiplyScalar
multiply Vectors
apply Matrix3
apply Matrix4
apply Quaternion
project
unproject
transform Direction
Transforms the direction of this vector by a matrix (the upper left 3 x 3 subset of a m) and then normalizes the result.
Parameters
- m: Matrix4
Returns Vector3
divide
divide Scalar
Divides this vector by scalar s. Sets vector to
( 0, 0, 0 )ifs = 0.Parameters
- scalar: number
Returns Vector3
Implementation of Vector.divideScalar
min
max
clamp
clamp Scalar
If this vector's x, y or z values are greater than the max value, they are replaced by the max value.
If this vector's x, y or z values are less than the min value, they are replaced by the min value.Parameters
- minVal: number
- maxVal: number
Returns Vector3
clamp Length
If this vector's length is greater than the max value, the vector will be scaled down so its length is the max value.
If this vector's length is less than the min value, the vector will be scaled up so its length is the min value.Parameters
- min: number
the minimum value the length will be clamped to.
- max: number
the maximum value the length will be clamped to.
Returns Vector3
- min: number
floor
The components of this vector are rounded down to the nearest integer value.
Returns Vector3
ceil
round
The components of this vector are rounded to the nearest integer value.
Returns Vector3
round To Zero
The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.
Returns Vector3
negate
Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
Returns Vector3
Implementation of Vector.negate
dot
Calculate the dot product of this vector and v.
Parameters
- v: Vector3
Returns number
Implementation of Vector.dot
length Sq
Computes the square of the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
Returns number
Implementation of Vector.lengthSq
length
Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
Returns number
Implementation of Vector.length
manhattan Length
Computes the Manhattan length of this vector.
Returns number
normalize
Convert this vector to a unit vector
- that is, sets it equal to a vector with the same direction as this one, but length| length 1.
Returns Vector3
Implementation of Vector.normalize
set Length
Sets this vector to a vector with given length the same direction as this one.
Parameters
- length: number
Returns Vector3
Implementation of Vector.setLength
lerp
lerp Vectors
cross
cross Vectors
project On Vector
project On Plane
reflect
angle To
distance To
distance To Squared
manhattan Distance To
set From Spherical
set From Spherical Coords
Sets this vector from the spherical coordinates Spherical| radius, Spherical| phi and Spherical| theta.
Parameters
- radius: number
- phi: number
- theta: number
Returns Vector3
set From Cylindrical
Sets this vector from the cylindrical coordinates Cylindrical| c.
Parameters
- c: Cylindrical
Returns Vector3
set From Cylindrical Coords
Sets this vector from the cylindrical coordinates Cylindrical| radius, Cylindrical| theta and Cylindrical| y.
Parameters
- radius: number
- theta: number
- y: number
Returns Vector3
set From Matrix Position
Sets this vector to the position elements of the transformation matrix m.
Parameters
- m: Matrix4
Returns Vector3
set From Matrix Column
set From Matrix Scale
Sets this vector to the scale elements of the transformation matrix m.
Parameters
- m: Matrix4
Returns Vector3
equals
from Array0
get Number Count
There are 3 elements in this vector.
Returns number
to Array
Returns an array [x, y, z], or copies x, y and z into the provided array.
Parameters
- array: number[]
(optional) array to store this vector to. If this is not provided a new array will be created.
- offset: number
(optional) optional offset into the array.
Returns number[]
Implementation of Vector.toArray
- array: number[]
Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z).