Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/threejs_4_deno/src/Three.js>Vector

A simple transformation of three.js for use within a Deno workflow
Go to Latest
interface Vector
Re-export
import { type Vector } from "https://deno.land/x/threejs_4_deno@v121/src/Three.js";

( interface Vector )

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.

Examples

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

Methods

setComponent(index: number, value: number): this
getComponent(index: number): number
set(...args: number[]): this
setScalar(scalar: number): this
copy(v: Vector): this

copy(v:T):T;

add(v: Vector): this

NOTE: The second argument is deprecated.

add(v:T):T;

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

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

addScaledVector(vector: Vector, scale: number): this
addScalar(scalar: number): this

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

sub(v: Vector): this

sub(v:T):T;

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

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

multiplyScalar(s: number): this

multiplyScalar(s:number):T;

divideScalar(s: number): this

divideScalar(s:number):T;

negate(): this

negate():T;

dot(v: Vector): number

dot(v:T):T;

lengthSq(): number

lengthSq():number;

length(): number

length():number;

normalize(): this

normalize():T;

optional
distanceTo(v: Vector): number

NOTE: Vector4 doesn't have the property.

distanceTo(v:T):number;

optional
distanceToSquared(v: Vector): number

NOTE: Vector4 doesn't have the property.

distanceToSquared(v:T):number;

setLength(l: number): this

setLength(l:number):T;

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

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

equals(v: Vector): boolean

equals(v:T):boolean;

clone(): this

clone():T;