Class Vector3

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 );

see

src/math/Vector3.js

( class Vector3 implements Vector )

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(x?: number, y?: number, z?: number): Vector3

Parameters

  • x?: number optional
  • y?: number optional
  • z?: number optional

Returns

Vector3

Properties

public x: number

public y: number

public z: number

Methods

public add(a: Object): Vector3

Adds v to this vector.

Parameters

  • a: Object

Returns

Vector3

public addScalar(s: number): Vector3

Parameters

  • s: number

Returns

Vector3

public addVectors(a: Vector3, b: Vector3): Vector3

Sets this vector to a + b.

Parameters

Returns

Vector3

public angleTo(v: Vector3): number

Parameters

Returns

number

public applyAxisAngle(axis: Vector3, angle: number): Vector3

Parameters

Returns

Vector3

public applyEuler(euler: Euler): Vector3

Parameters

Returns

Vector3

public applyMatrix3(m: Matrix3): Vector3

Parameters

Returns

Vector3

public applyMatrix4(m: Matrix4): Vector3

Parameters

Returns

Vector3

public applyProjection(m: Matrix4): Vector3

Parameters

Returns

Vector3

public applyQuaternion(q: Quaternion): Vector3

Parameters

Returns

Vector3

public ceil(): Vector3

Returns

Vector3

public clamp(min: Vector3, max: Vector3): Vector3

Parameters

Returns

Vector3

public clampScalar(min: number, max: number): Vector3

Parameters

  • min: number
  • max: number

Returns

Vector3

public clone(): Vector3

Clones this vector.

Returns

Vector3

public copy(v: Vector3): Vector3

Copies value of v to this vector.

Parameters

Returns

Vector3

public cross(a: Vector3): Vector3

Sets this vector to cross product of itself and v.

Parameters

Returns

Vector3

public crossVectors(a: Vector3, b: Vector3): Vector3

Sets this vector to cross product of a and b.

Parameters

Returns

Vector3

public distanceTo(v: Vector3): number

Computes distance of this vector to v.

Parameters

Returns

number

public distanceToSquared(v: Vector3): number

Computes squared distance of this vector to v.

Parameters

Returns

number

public divide(v: Vector3): Vector3

Parameters

Returns

Vector3

public divideScalar(s: number): Vector3

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

Parameters

  • s: number

Returns

Vector3

public dot(v: Vector3): number

Computes dot product of this vector and v.

Parameters

Returns

number

public equals(v: Vector3): boolean

Checks for strict equality of this vector and v.

Parameters

Returns

boolean

public floor(): Vector3

Returns

Vector3

public fromArray(xyz: Array<number>): Vector3

Parameters

  • xyz: Array<number>

Returns

Vector3

public getComponent(index: number): number

Parameters

  • index: number

Returns

number

public length(): number

Computes length of this vector.

Returns

number

public lengthManhattan(): number

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

Returns

number

public lengthSq(): number

Computes squared length of this vector.

Returns

number

public lerp(v: Vector3, alpha: number): Vector3

Parameters

Returns

Vector3

public max(v: Vector3): Vector3

Parameters

Returns

Vector3

public min(v: Vector3): Vector3

Parameters

Returns

Vector3

public multiply(v: Vector3): Vector3

Parameters

Returns

Vector3

public multiplyScalar(s: number): Vector3

Multiplies this vector by scalar s.

Parameters

  • s: number

Returns

Vector3

public multiplyVectors(a: Vector3, b: Vector3): Vector3

Parameters

Returns

Vector3

public negate(): Vector3

Inverts this vector.

Returns

Vector3

public normalize(): Vector3

Normalizes this vector.

Returns

Vector3

public projectOnPlane(planeNormal: Vector3): Vector3

Parameters

Returns

Vector3

public projectOnVector(v: Vector3): Vector3

Parameters

Returns

Vector3

public reflect(vector: Vector3): Vector3

Parameters

Returns

Vector3

public round(): Vector3

Returns

Vector3

public roundToZero(): Vector3

Returns

Vector3

public set(x: number, y: number, z: number): Vector3

Sets value of this vector.

Parameters

  • x: number
  • y: number
  • z: number

Returns

Vector3

public setComponent(index: number, value: number)

Parameters

  • index: number
  • value: number

public setFromMatrixColumn(index: number, matrix: Matrix4): Vector3

Parameters

Returns

Vector3

public setFromMatrixPosition(m: Matrix4): Vector3

Parameters

Returns

Vector3

public setFromMatrixScale(m: Matrix4): Vector3

Parameters

Returns

Vector3

public setLength(l: number): Vector3

Normalizes this vector and multiplies it by l.

Parameters

  • l: number

Returns

Vector3

public setX(x: number): Vector3

Sets x value of this vector.

Parameters

  • x: number

Returns

Vector3

public setY(y: number): Vector3

Sets y value of this vector.

Parameters

  • y: number

Returns

Vector3

public setZ(z: number): Vector3

Sets z value of this vector.

Parameters

  • z: number

Returns

Vector3

public sub(a: Vector3): Vector3

Subtracts v from this vector.

Parameters

Returns

Vector3

public subVectors(a: Vector3, b: Vector3): Vector3

Sets this vector to a - b.

Parameters

Returns

Vector3

public toArray(): Array<number>

Returns

Array<number>

public transformDirection(m: Matrix4): Vector3

Parameters

Returns

Vector3