Creates a new Vec4 object.
Optional
x: number | number[] = 0The x value. Defaults to 0. If x is an array of length 4, the array will be used to populate all components.
Optional
y: number = 0The y value. Defaults to 0.
Optional
z: number = 0The z value. Defaults to 0.
Optional
w: number = 0The w value. Defaults to 0.
The fourth component of the vector.
The first component of the vector.
The second component of the vector.
The third component of the vector.
Static
Readonly
HALFA constant vector set to [0.5, 0.5, 0.5, 0.5].
Static
Readonly
ONEA constant vector set to [1, 1, 1, 1].
Static
Readonly
ZEROA constant vector set to [0, 0, 0, 0].
Reports whether two vectors are equal using an absolute error tolerance.
The vector to be compared against.
Optional
epsilon: number = 1e-6The maximum difference between each component of the two vectors. Defaults to 1e-6.
True if the vectors are equal and false otherwise.
Set the values of the vector from an array.
The array to set the vector values from.
Optional
offset: number = 0The zero-based index at which to start copying elements from the array. Default is 0.
Self for chaining.
Returns the result of a linear interpolation between two specified 4-dimensional vectors.
The 4-dimensional to interpolate from.
The 4-dimensional to interpolate to.
The value controlling the point of interpolation. Between 0 and 1, the linear interpolant will occur on a straight line between lhs and rhs. Outside of this range, the linear interpolant will occur on a ray extrapolated from this line.
Self for chaining.
Returns this 4-dimensional vector converted to a unit vector in place. If the vector has a length of zero, the vector's elements will be set to zero.
Optional
src: Vec4 = ...The vector to normalize. If not set, the operation is done in place.
Self for chaining.
Sets the specified 4-dimensional vector to the supplied numerical values.
The value to set on the first component of the vector.
The value to set on the second component of the vector.
The value to set on the third component of the vector.
The value to set on the fourth component of the vector.
Self for chaining.
Converts the vector to an array.
Optional
arr: ArrayBufferView | number[] = []The array to populate with the color components. If not specified, a new array is created.
Optional
offset: number = 0The zero-based index at which to start copying elements to the array. Default is 0.
The vector as an array.
A 4-dimensional vector.