Alias for y.
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 Vector2.
Alias for x.
If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value.
If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
This instance.
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
If this vector's x or y values are greater than the max value, they are replaced by the max value.
If this vector's x or y 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
Computes the squared distance from this vector to v. If you are just comparing the distance with another distance, you should compare the distance squared instead as it is slightly more efficient to calculate.
The distance squared.
The other vector.
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.
Vector2 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.
Returns an array [x, y], or copies x and y into the provided array.
An 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 2D vector. A 2D vector is an ordered pair of numbers (labeled x and y), which can be used to represent a number of things, such as:
There are other things a 2D vector can be used to represent, such as momentum vectors, complex numbers and so on. However these are the most common uses in three.js.
Iterating through a Vector2 instance will yield its components (x, y) in the corresponding order.
Example