[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:Vector3 this]

Sets value of this vector.

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

Sets x value of this vector.

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

Sets y value of this vector.

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

Sets z value of this vector.

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

Copies value of *v* to this vector.

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

Adds *v* to this vector.

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

Sets this vector to *a + b*.

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

Subtracts *v* from this vector.

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

Sets this vector to *a - b*.

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

Multiplies this vector by scalar *s*.

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

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

.negate() [page:Vector3 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:Vector3 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:Vector3 this]

Normalizes this vector and multiplies it by *l*.

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

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

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

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

.setFromMatrixPosition( [page:Matrix4 m] ) [page:Vector3 this]

Sets this vector extracting position from matrix transform.

.setFromMatrixScale( [page:Matrix4 m] ) [page:Vector3 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:Vector3 min], [page:Vector3 max]) [page:Vector3 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.

.clampScalar([page:Float min], [page:Float max]) [page:Vector3 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, y or z values are greater than the max value, they are replaced by the max value.
If this vector's x, y or z values are less than the min value, they are replace by the min value.

.floor() [page:Vector3]

The components of the vector are rounded downwards (towards negative infinity) to an integer value.

.ceil() [page:Vector3]

The components of the vector are rounded upwards (towards positive infinity) to an integer value.

.round() [page:Vector3]

The components of the vector are rounded towards the nearest integer value.

.roundToZero() [page:Vector3]

The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.

.applyMatrix3([page:Matrix3 m]) [page:Vector3 this]

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

.applyMatrix4([page:Matrix3 m]) [page:Vector3 this]

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

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

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

.projectOnVector([page:Vector3]) [page:Vector3 this]

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

.addScalar([page:Float]) [page:Vector3 this]

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

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

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

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

v -- [page: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.

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

v -- [page: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.

.setComponent([page:Integer index], [page:Float value]) [page:Vector3 this]

index -- 0, 1, or 2
value -- [page: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:Matrix4 m]) [page:Vector3 this]

m -- [page:Matrix4]
Transforms the direction of this vector by a matrix (a 3 x 3 subset of a Matrix4) and then normalizes the result.

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

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

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

index -- [page:Integer] 0, 1, or 2
Returns the value of the vector component x, y, or z by an index.

Index 0: x
Index 1: y
Index 2: z

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

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

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

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

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

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

.setFromMatrixColumn([page:Integer index], [page:Matrix4 matrix]) [page:Vector3 this]

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

.reflect([page:Vector3 normal]) [page:Vector3 this]

normal -- [page:Vector3] the normal to the reflecting plane
Reflect incident vector off of plane orthogonal to normal. normal is assumed to have unit length.

.fromArray([page:Array array]) [page:Vector3 this]

array -- [page:Array] [x, y, z]
Sets the vector's components based on an array formatted like [x, y, z]

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

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

.applyProjection([page:Matrix4 m]) [page:Vector3 this]

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

.toArray() [page: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:Euler euler]) [page:Vector3 this]

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

.applyQuaternion([page:Quaternion quaternion]) [page:Vector3 this]

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

.projectCamera( [page:Camera camera] ) [page:Vector3]

[page:Camera camera] — camera to use in the projection.
Projects the vector with the camera.

.unprojectCamera( [page:Camera camera] ) [page:Vector3]

[page:Camera camera] — camera to use in the projection.
Unprojects the vector with the camera.

Source

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