[name]
2D vector.
Example
var a = new THREE.Vector2( 0, 1 );
var b = new THREE.Vector2( 1, 0 );
var d = a.distanceTo( b );
Constructor
[name]( [page:Float x], [page:Float y] )
x -- [page:Float] representing the x value of the vector
y -- [page:Float] representing the y value of the vector
A vector in 2 dimensional space
Properties
[property:Float x]
[property:Float y]
Methods
.set( [page:Float x], [page:Float y] ) [page:Vector2 this]
Sets value of this vector.
.copy( [page:Vector2 v] ) [page:Vector2 this]
Copies value of *v* to this vector.
.add( [page:Vector2 v] ) [page:Vector2 this]
Adds *v* to this vector.
.addVectors( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]
Sets this vector to *a + b*.
.sub( [page:Vector2 v] ) [page:Vector2 this]
Subtracts *v* from this vector.
.subVectors( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2 this]
Sets this vector to *a - b*.
.multiplyScalar( [page:Float s] ) [page:Vector2 this]
Multiplies this vector by scalar *s*.
.divideScalar( [page:Float s] ) [page:Vector2 this]
Divides this vector by scalar *s*.
Set vector to *( 0, 0 )* if *s == 0*.
.negate() [page:Vector2 this]
Inverts this vector.
.dot( [page:Vector2 v] ) [page:Float]
Computes dot product of this vector and *v*.
.lengthSq() [page:Float]
Computes squared length of this vector.
.length() [page:Float]
Computes length of this vector.
.normalize() [page:Vector2 this]
Normalizes this vector.
.distanceTo( [page:Vector2 v] ) [page:Float]
Computes distance of this vector to *v*.
.distanceToSquared( [page:Vector2 v] ) [page:Float]
Computes squared distance of this vector to *v*.
.setLength( [page:Float l] ) [page:Vector2 this]
Normalizes this vector and multiplies it by *l*.
.equals( [page:Vector2 v] ) [page:Boolean]
Checks for strict equality of this vector and *v*.
.clone() [page:Vector2]
Clones this vector.
.clamp([page:Vector2 min], [page:Vector2 max]) [page:Vector2 this]
min -- [page:Vector2] containing the min x and y values in the desired range
max -- [page:Vector2] containing the max 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 x or y value is less than the min vector's x or y value, it is replace by the corresponding value.
.clampScalar([page:Float min], [page:Float max]) [page:Vector2 this]
min -- [page:Float] the minimum value the components will be clamped to
max -- [page:Float] 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.
If this vector's x or y values are less than the min value, they are replace by the min value.
.floor() [page:Vector2]
The components of the vector are rounded downwards (towards negative infinity) to an integer value.
.ceil() [page:Vector2]
The components of the vector are rounded upwards (towards positive infinity) to an integer value.
.round() [page:Vector2]
The components of the vector are rounded towards the nearest integer value.
.roundToZero() [page:Vector2]
The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
.lerp([page:Vector2 v], [page:Float alpha]) [page:Vector2 this]
v -- [page:Vector2]
alpha -- [page:Float] between 0 and 1;
Linear interpolation between this vector and v, where alpha is the percent along the line.
.setComponent([page:Integer index], [page:Float value]) [page:undefined]
index -- 0 or 1
value -- [page:Float]
if index equals 0 method replaces this.x with value.
if index equals 1 method replaces this.y with value.
.addScalar([page:Float s]) [page:Vector2 this]
s -- [page:Float]
Add the scalar value s to this vector's x and y values.
.getComponent([page:Integer index]) [page:Float]
index -- 0 or 1
if index equals 0 returns the x value.
if index equals 1 returns the y value.
.fromArray([page:Array array]) [page:Vector2 this]
array -- [page:Array] of length 2
Sets this vector's x value to be array[0] and y value to be array[1].
.toArray() [page:Array]
Returns an array [x, y].
.min([page:Vector2 v]) [page:Vector2 this]
v -- [page:Vector2]
If this vector's x or y value is less than v's x or y value, replace that value with the corresponding min value.
.max([page:Vector2 v]) [page:Vector2 this]
v -- [page:Vector2]
If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding max value.
.setX([page:Float x]) [page:Vector2 this]
x -- [page:Float]
replace this vector's x value with x.
.setY([page:Float y]) [page:Vector2 this]
y -- [page:Float]
replace this vector's y value with y.
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]