[name]

3D vector.

Example

var a = new THREE.Vector3( 1, 0, 0 ); var b = new THREE.Vector3( 0, 1, 0 ); var c = new THREE.Vector3(); c.crossVectors( a, b );

Constructor

[name]( [page:Float x], [page:Float y], [page:Float z] )

x -- [page:Float] the vector's x value
y -- [page:Float] the vector's y value
z -- [page:Float] the vector's z value
A 3 dimensional vector

Properties

.[page:Float x]

.[page:Float y]

.[page:Float z]

Methods

.set( [page:Float x], [page:Float y], [page:Float z] ) [page:this]

Sets value of this vector.

.setX( [page:Float x] ) [page:this]

Sets x value of this vector.

.setY( [page:Float y] ) [page:this]

Sets y value of this vector.

.setZ( [page:Float z] ) [page:this]

Sets z value of this vector.

.copy( [page:Vector3 v] ) [page:this]

Copies value of *v* to this vector.

.add( [page:Vector3 v] ) [page:this]

Adds *v* to this vector.

.addVectors( [page:Vector3 a], [page:Vector3 b] ) [page:this]

Sets this vector to *a + b*.

.sub( [page:Vector3 v] ) [page:this]

Subtracts *v* from this vector.

.subVectors( [page:Vector3 a], [page:Vector3 b] ) [page:this]

Sets this vector to *a - b*.

.multiplyScalar( [page:Float s] ) [page:this]

Multiplies this vector by scalar *s*.

.divideScalar( [page:Float s] ) [page:this]

Divides this vector by scalar *s*.
Set vector to *( 0, 0, 0 )* if *s == 0*.

.negate() [page:this]

Inverts this vector.

.dot( [page:Vector3 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.

.lengthManhattan() [page:Float]

Computes Manhattan length of this vector.
[link:http://en.wikipedia.org/wiki/Taxicab_geometry]

.normalize() [page:this]

Normalizes this vector. Transforms this Vector into a Unit vector by dividing the vector by it's length.

.distanceTo( [page:Vector3 v] ) [page:Float]

Computes distance of this vector to *v*.

.distanceToSquared( [page:Vector3 v] ) [page:Float]

Computes squared distance of this vector to *v*.

.setLength( [page:Float l] ) [page:this]

Normalizes this vector and multiplies it by *l*.

.cross( [page:Vector3 v] ) [page:this]

Sets this vector to cross product of itself and *v*.

.crossVectors( [page:Vector3 a], [page:Vector3 b] ) [page:this]

Sets this vector to cross product of *a* and *b*.

.getPositionFromMatrix( [page:Matrix4 m] ) [page:this]

Sets this vector extracting position from matrix transform.

.getScaleFromMatrix( [page:Matrix4 m] ) [page:this]

Sets this vector extracting scale from matrix transform.

.equals( [page:Vector3 v] ) [page:Boolean]

Checks for strict equality of this vector and *v*.

.clone() [page:Vector3]

Clones this vector.

.clamp([page:todo min], [page:todo max]) [page:this]

min -- [page:Vector3]
max -- [page:Vector3]
If this vector's x, y or z value is greater than the max vector's x, y or z value, it is replaced by the corresponding value.
If this vector's x, y or z value is less than the min vector's x, y or z value, it is replace by the corresponding value.

.applyMatrix3([page:todo m]) [page:this]

m -- [page:Matrix3]
Multiplies this vector times a 3 x 3 matrix.

.applyMatrix4([page:todo m]) [page:todo this]

m -- [page:todo Matrix4]
Multiplies this vector by 4 x 3 subset of a Matrix4.

.projectOnPlane([page:todo planeNormal]) [page:todo this]

planeNormal -- [page:todo Plane.normal]
Projects this vector onto a plane by subtracting this vector projected onto the plane's normal from this vector.

.projectOnVector([page:todo vector]) [page:todo this]

vector -- [page:todo Vector3]
Projects this vector onto another vector.

.addScalar([page:todo s]) [page:todo this]

s -- [page:todo Float]
Adds a s to this vector.

.divide([page:todo v]) [page:todo this]

v -- [page:todo Vector3]
Divides this vector by vector v.

.min([page:todo v]) [page:todo]

v -- [page:todo Vector3]
If this vector's x, y, or z value is less than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.

.setComponent([page:todo index], [page:todo value]) [page:todo this]

index -- 0, 1, or 2
value -- [page:todo Float]
If index equals 0 the method sets this vector's x value to value
If index equals 1 the method sets this vector's y value to value
If index equals 2 the method sets this vector's z value to value

.transformDirection([page:todo m]) [page:todo this]

m -- [page:todo Matrix4]
Multiplies this vector by a 3 x 3 subset of a Matrix4 and then normalizes the results.

.multiplyVectors([page:todo a], [page:todo b]) [page:todo this]

a -- [page:todo Vector3]
b -- [page:todo Vector3]
Sets this vector equal the result of multiplying vector a by vector b.

.getComponent([page:todo index]) [page:todo Float]

index -- 0, 1, or 2
If index equals 0 the method returns this vector's x value
If index equals 1 the method returns this vector's y value
If index equals 2 the method returns this vector's z value

.applyAxisAngle([page:todo axis], [page:todo angle]) [page:todo this]

axis -- a normalized [page:todo Vector3]
angle -- an angle in radians
Applies a rotation specified by an axis and an angle to this vector.

.lerp([page:todo v], [page:todo alpha]) [page:todo this]

v -- [page:todo Vector3]
alpha -- [page:todo Float] between 0 and 1.
Linear Interpolation between this vector and vector v, where alpha is the percent along the line.

.max([page:todo v]) [page:todo this]

v -- [page:todo Vector3]
If this vector's x, y, or z value is greater than vector v's x, y, or z value, that value is replaced by the corresponding vector v value.

.angleTo([page:todo v]) [page:todo Float]

v -- [page:todo Vector3]
Returns the angle between this vector and vector v in radians.

.getColumnFromMatrix([page:todo index], [page:todo matrix]) [page:todo this]

index -- 0, 1, 2, or 3
matrix -- [page:todo Matrix4]
Sets this vector's x, y, and z equal to the column of the matrix specified by the index.

.reflect([page:todo vector]) [page:todo this]

vector -- [page:todo Vector3] the vector to reflect about
Reflects this vector about a vector.

.fromArray([page:todo array]) [page:todo this]

array -- [page:todo Array]
Assigns this vectors x value to array[0].
Assigns this vectors y value to array[1].
Assigns this vectors z value to array[2].

.multiply([page:todo v]) [page:todo this]

v -- [page:todo Vector3]
Multipies this vector by vector v.

.applyProjection([page:todo m]) [page:todo ths]

m -- [page:todo Matrix4] projection matrix.
Multiplies this vector and m, and divides by perspective.

.toArray() [page:todo Array]

Assigns this vector's x value to array[0].
Assigns this vector's y value to array[1].
Assigns this vector's z value to array[2].
Returns the created array.

.applyEuler( [page:todo euler] ) [page:todo this]

euler -- [page:todo Euler]
Applies euler transform to this vector by converting the [page:Euler] obect to a [page:Quaternion] and applying.

.applyQuaternion([page:todo q]) [page:todo this]

q -- [page:Quaternion]
Applies a [page:Quaternion] transform to this vector.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]