Alias for y
Alias for x
the x value of this vector. Default is 0
the y value of this vector. Default is 0.
Computes the angle in radians of this vector with respect to the positive x-axis.
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.
The minimum x and y values.
The maximum x and y values in the desired range 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 length is less than the min value, it is replaced by the min value.
The minimum value the length will be clamped to
The maximum value the length will be clamped to If this vector's length is greater than the max value, it is 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.
The minimum value the components will be clamped to
The maximum value the components 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.
Calculates the cross product of this vector and v. Note that a 'cross-product' in 2D is not well-defined. This function computes a geometric cross-product often used in 2D graphics
Returns true if the components of this vector and v are strictly equal; false otherwise.
Calculates the dot product of this vector and v.
Sets this vector's .x and .y values from the attribute.
The source attribute.
index in the attribute.
If index equals 0 returns the .x value. If index equals 1 returns the .y value.
0 or 1.
Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).
Computes the square of the Euclidean length (straight-line length) from (0, 0) to (x, y). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
Computes the Manhattan distance from this vector to v.
Computes the Manhattan length of this vector.
Converts this vector to a unit vector - that is, sets it equal to a vector with the same direction as this one, but .length 1.
Generated using TypeDoc
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: A point in 2D space (i.e. a position on a plane). A direction and length across a plane. In three.js the length will always be the Euclidean distancee (straight-line distance) from (0, 0) to (x, y) and the direction is also measured from (0, 0) towards (x, y). Any arbitrary ordered pair of numbers. 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. See the ngx3js docs page for details.
Examples
css2d / label | misc / controls / drag | misc / controls / fly | misc / uv / tests | physics / ammo / break
Code Example