( interface Vector )

Abstract interface of https://github.com/mrdoob/three.js/blob/master/src/math/Vector2.js|Vector2, https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js|Vector3 and https://github.com/mrdoob/three.js/blob/master/src/math/Vector4.js|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.

const v:THREE.Vector = new THREE.Vector3();
v.addVectors(new THREE.Vector2(0, 1), new THREE.Vector2(2, 3)); // invalid but compiled successfully
interface Vector {
    add(v: external.three.Vector): this;
    addScalar(scalar: number): this;
    addScaledVector(vector: external.three.Vector, scale: number): this;
    addVectors(a: external.three.Vector, b: external.three.Vector): this;
    clone(): external.three.Vector;
    copy(v: external.three.Vector): this;
    distanceTo?(v: external.three.Vector): number;
    distanceToSquared?(v: external.three.Vector): number;
    divideScalar(s: number): this;
    dot(v: external.three.Vector): number;
    equals(v: external.three.Vector): boolean;
    getComponent(index: number): number;
    length(): number;
    lengthSq(): number;
    lerp(v: external.three.Vector, alpha: number): this;
    multiplyScalar(s: number): this;
    negate(): this;
    normalize(): this;
    set(...args: number[]): this;
    setComponent(index: number, value: number): this;
    setLength(l: number): this;
    setScalar(scalar: number): this;
    sub(v: external.three.Vector): this;
    subVectors(a: external.three.Vector, b: external.three.Vector): this;
}

Implemented by

Methods

  • NOTE: The second argument is deprecated.

    add(v:T):T;

    Parameters

    Returns this

  • Adds the scalar value s to this vector's values.

    Parameters

    • scalar: number

    Returns this

  • Parameters

    Returns this

  • copy(v:T):T;

    Parameters

    Returns this

  • NOTE: Vector4 doesn't have the property.

    distanceTo(v:T):number;

    Parameters

    Returns number

  • NOTE: Vector4 doesn't have the property.

    distanceToSquared(v:T):number;

    Parameters

    Returns number

  • divideScalar(s:number):T;

    Parameters

    • s: number

    Returns this

  • dot(v:T):T;

    Parameters

    Returns number

  • equals(v:T):boolean;

    Parameters

    Returns boolean

  • Parameters

    • index: number

    Returns number

  • length():number;

    Returns number

  • lengthSq():number;

    Returns number

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

    Parameters

    Returns this

  • multiplyScalar(s:number):T;

    Parameters

    • s: number

    Returns this

  • negate():T;

    Returns this

  • normalize():T;

    Returns this

  • Parameters

    • Rest...args: number[]

    Returns this

  • Parameters

    • index: number
    • value: number

    Returns this

  • setLength(l:number):T;

    Parameters

    • l: number

    Returns this

  • Parameters

    • scalar: number

    Returns this

  • sub(v:T):T;

    Parameters

    Returns this