Abstract 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

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

Hierarchy

  • Vector

Implemented by

Properties

isVector: boolean

Read-only flag to check if a given object is of type Vector.

Methods

  • NOTE: The second argument is deprecated.

    add(v:T):T;

    Parameters

    Returns Vector

  • addScalar(scalar: number): Vector
  • Adds the scalar value s to this vector's values.

    Parameters

    • scalar: number

    Returns Vector

  • distanceTo(v: Vector): number
  • NOTE: Vector4 doesn't have the property.

    distanceTo(v:T):number;

    Parameters

    Returns number

  • distanceToSquared(v: Vector): number
  • NOTE: Vector4 doesn't have the property.

    distanceToSquared(v:T):number;

    Parameters

    Returns number

  • divideScalar(s: number): Vector
  • divideScalar(s:number):T;

    Parameters

    • s: number

    Returns Vector

  • dot(v:T):T;

    Parameters

    Returns number

  • equals(v:T):boolean;

    Parameters

    Returns boolean

  • getComponent(index: number): number
  • Parameters

    • index: number

    Returns number

  • length(): number
  • length():number;

    Returns number

  • lengthSq(): number
  • lengthSq():number;

    Returns number

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

    Parameters

    Returns Vector

  • multiplyScalar(s: number): Vector
  • multiplyScalar(s:number):T;

    Parameters

    • s: number

    Returns Vector

  • normalize():T;

    Returns Vector

  • set(...args: number[]): Vector
  • Parameters

    • Rest ...args: number[]

    Returns Vector

  • setComponent(index: number, value: number): Vector
  • Parameters

    • index: number
    • value: number

    Returns Vector

  • setLength(l:number):T;

    Parameters

    • l: number

    Returns Vector

  • setScalar(scalar: number): Vector
  • Parameters

    • scalar: number

    Returns Vector