Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/threejs_4_deno/src/math/Vector3.d.ts>Vector3

A simple transformation of three.js for use within a Deno workflow
Go to Latest
class Vector3
implements Vector
import { Vector3 } from "https://deno.land/x/threejs_4_deno@v121/src/math/Vector3.d.ts";

3D vector.

Examples

const a = new THREE.Vector3( 1, 0, 0 ); const b = new THREE.Vector3( 0, 1, 0 ); const c = new THREE.Vector3(); c.crossVectors( a, b );

Constructors

new
Vector3(
x?: number,
y?: number,
z?: number,
)

Properties

readonly
isVector3: true
x: number
y: number
z: number

Methods

add(v: Vector3): this

Adds v to this vector.

addScalar(s: number): this
addScaledVector(v: Vector3, s: number): this
addVectors(a: Vector3, b: Vector3): this

Sets this vector to a + b.

angleTo(v: Vector3): number
applyAxisAngle(axis: Vector3, angle: number): this
applyEuler(euler: Euler): this
ceil(): this
clamp(min: Vector3, max: Vector3): this
clampLength(min: number, max: number): this
clampScalar(min: number, max: number): this
clone(): this

Clones this vector.

copy(v: Vector3): this

Copies value of v to this vector.

cross(a: Vector3): this

Sets this vector to cross product of itself and v.

Sets this vector to cross product of a and b.

distanceTo(v: Vector3): number

Computes distance of this vector to v.

deprecated
distanceToManhattan(v: Vector3): number

Computes squared distance of this vector to v.

divide(v: Vector3): this
divideScalar(s: number): this

Divides this vector by scalar s. Set vector to ( 0, 0, 0 ) if s == 0.

dot(v: Vector3): number

Computes dot product of this vector and v.

equals(v: Vector3): boolean

Checks for strict equality of this vector and v.

floor(): this
fromArray(array: number[], offset?: number): this

Sets this vector's x, y and z value from the provided array.

fromArray(array: ArrayLike<number>, offset?: number): this

Sets this vector's x, y and z value from the provided array-like.

getComponent(index: number): number
length(): number

Computes length of this vector.

deprecated
lengthManhattan(): number

Computes Manhattan length of this vector. http://en.wikipedia.org/wiki/Taxicab_geometry

lengthSq(): number

Computes squared length of this vector.

lerp(v: Vector3, alpha: number): this
lerpVectors(
v1: Vector3,
v2: Vector3,
alpha: number,
): this

Computes the Manhattan length (distance) from this vector to the given vector v

manhattanLength(): number

Computes the Manhattan length of this vector.

max(v: Vector3): this
min(v: Vector3): this
multiply(v: Vector3): this
multiplyScalar(s: number): this

Multiplies this vector by scalar s.

negate(): this

Inverts this vector.

normalize(): this

Normalizes this vector.

project(camera: Camera): this
projectOnPlane(planeNormal: Vector3): this
random(): this

Sets this vector's x, y and z from Math.random

reflect(vector: Vector3): this
round(): this
roundToZero(): this
set(
x: number,
y: number,
z: number,
): this

Sets value of this vector.

setComponent(index: number, value: number): this
setFromCylindricalCoords(
radius: number,
theta: number,
y: number,
): this
setFromMatrix3Column(matrix: Matrix3, index: number): this
setFromMatrixColumn(matrix: Matrix4, index: number): this
setFromSphericalCoords(
r: number,
phi: number,
theta: number,
): this
setLength(l: number): this

Normalizes this vector and multiplies it by l.

setScalar(scalar: number): this

Sets all values of this vector.

setX(x: number): Vector3

Sets x value of this vector.

setY(y: number): Vector3

Sets y value of this vector.

setZ(z: number): Vector3

Sets z value of this vector.

sub(a: Vector3): this

Subtracts v from this vector.

subScalar(s: number): this
subVectors(a: Vector3, b: Vector3): this

Sets this vector to a - b.

toArray(array?: number[], offset?: number): number[]

Returns an array [x, y, z], or copies x, y and z into the provided array.

toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>

Copies x, y and z into the provided array-like.

unproject(camera: Camera): this