Creates a new Vector4.
Optional
x: numberthe x value of this vector. Default is 0.
Optional
y: numberthe y value of this vector. Default is 0.
Optional
z: numberthe z value of this vector. Default is 0.
Optional
w: numberthe w value of this vector. Default is 0.
Alias for w.
Read-only flag to check if a given object is of type Vector.
Read-only flag to check if a given object is of type Vector4.
Alias for z.
If this vector's x, y, z or w value is greater than the max vector's x, y, z or w value, it is replaced by the corresponding value.
If this vector's x, y, z or w value is less than the min vector's x, y, z or w value, it is replaced by the corresponding value.
This instance.
Restrict the min and max length of this vector. If this vector's length is greater than the max value, it is replaced by the max value. If this vector's length is less than the min value, it is replaced by the min value.
This instance.
the minimum value the length will be clamped to
the maximum value the length will be clamped to
Restrict the min and max component values. If this vector's x, y, z or w values are greater than the max value, they are replaced by the max value.
If this vector's x, y, z or w values are less than the min value, they are replaced by the min value.
This instance.
The minimum value the components will be clamped to
The maximum value the components will be clamped to
Sets this vector's x value to be array[ offset + 0 ]
, y value to be
array[ offset + 1 ]
z value to be array[ offset + 2 ]
and w value to be array[ offset + 3 ]
.
This instance.
The source array.
Optional
offset: number(Optional) offset into the array. Default is 0.
Computes the square of the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
The length squared.
Linearly interpolates between this vector and v, where alpha is the percent distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.
This instance.
Vector4 to interpolate towards.
interpolation factor, typically in the closed interval [0, 1].
Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the percent distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
This instance.
Sets the x, y and z components of this vector to the quaternion's axis and w to the angle.
This instance.
The source quaternion
Set the componet referenced by index. If index equals 0 set x to value. If index equals 1 set y to value. If index equals 2 set z to value. If index equals 3 set w to value.
This instance.
0, 1 or 2.
THe new component value
Create an array [x, y, z, w], or copies x, y, z and w into the provided array.
The array.
Optional
array: number[](optional) array to store this vector to. If this is not provided, a new array will be created.
Optional
offset: number(optional) optional offset into the array.
Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers (labeled x, y, z, and w), which can be used to represent a number of things, such as:
Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
Example