Interface Vector

( interface Vector<T> )

Abstruct interface of Vector2, Vector3 and Vector4. Currently the members of Vector is NOT type safe because it accepts different typed vectors. Those definitions will be changed when TypeScript innovates Generics to be type safe.

example

var v:THREE.Vector = new THREE.Vector3(); v.addVectors(new THREE.Vector2(0, 1), new THREE.Vector2(2, 3)); // invalid but compiled successfully

Index

Methods

Methods

public add(v: Vector): Vector

add(v:T):T;

Parameters

Returns

Vector

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

addVectors(a:T, b:T):T;

Parameters

Returns

Vector

public clone(): Vector

clone():T;

Returns

Vector

public copy(v: Vector): Vector

copy(v:T):T;

Parameters

Returns

Vector

public distanceTo(v: Vector): number

NOTE: Vector4 doesn't have the property.

distanceTo(v:T):number;

Parameters

Returns

number

public distanceToSquared(v: Vector): number

NOTE: Vector4 doesn't have the property.

distanceToSquared(v:T):number;

Parameters

Returns

number

public divideScalar(s: number): Vector

divideScalar(s:number):T;

Parameters

  • s: number

Returns

Vector

public dot(v: Vector): number

dot(v:T):T;

Parameters

Returns

number

public equals(v: Vector): boolean

equals(v:T):boolean;

Parameters

Returns

boolean

public getComponent(index: number): number

Parameters

  • index: number

Returns

number

public length(): number

length():number;

Returns

number

public lengthSq(): number

lengthSq():number;

Returns

number

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

lerp(v:T, alpha:number):T;

Parameters

Returns

Vector

public multiplyScalar(s: number): Vector

multiplyScalar(s:number):T;

Parameters

  • s: number

Returns

Vector

public negate(): Vector

negate():T;

Returns

Vector

public normalize(): Vector

normalize():T;

Returns

Vector

public setComponent(index: number, value: number)

Parameters

  • index: number
  • value: number

public setLength(l: number): Vector

setLength(l:number):T;

Parameters

  • l: number

Returns

Vector

public sub(v: Vector): Vector

sub(v:T):T;

Parameters

Returns

Vector

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

subVectors(a:T, b:T):T;

Parameters

Returns

Vector