( 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.

Example

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): this;
    addScalar(scalar): this;
    addScaledVector(vector, scale): this;
    addVectors(a, b): this;
    clone(): external.three.Vector;
    copy(v): this;
    distanceTo?(v): number;
    distanceToSquared?(v): number;
    divideScalar(s): this;
    dot(v): number;
    equals(v): boolean;
    getComponent(index): number;
    length(): number;
    lengthSq(): number;
    lerp(v, alpha): this;
    multiplyScalar(s): this;
    negate(): this;
    normalize(): this;
    set(...args): this;
    setComponent(index, value): this;
    setLength(l): this;
    setScalar(scalar): this;
    sub(v): this;
    subVectors(a, b): 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