Skip to main content

Vector3

Index

Constructors

constructor

  • new Vector3(x: number, y: number, z: number): Vector3
  • new Vector3(arr: [number, number, number]): Vector3
  • new Vector3(obj: IVector3): Vector3
  • new Vector3(value: number): Vector3

Properties

publicreadonlyx

x: number

publicreadonlyy

y: number

publicreadonlyz

z: number

publicstaticreadonlyback

back: Vector3

(0, -1, 0) vector

publicstaticreadonlydown

down: Vector3

(0, 0, -1) vector

publicstaticreadonlyforward

forward: Vector3

(0, 1, 0) vector

publicstaticreadonlyleft

left: Vector3

(-1, 0, 0) vector

publicstaticreadonlynegativeInfinity

negativeInfinity: Vector3

(-Infinity, -Infinity, -Infinity) vector

publicstaticreadonlyone

one: Vector3

(1, 1, 1) vector

publicstaticreadonlypositiveInfinity

positiveInfinity: Vector3

(Infinity, Infinity, Infinity) vector

publicstaticreadonlyright

right: Vector3

(1, 0, 0) vector

publicstaticreadonlyup

up: Vector3

(0, 0, 1) vector

publicstaticreadonlyzero

zero: Vector3

(0, 0, 0) vector

Accessors

publiclength

  • get length(): number

Methods

publicadd

  • add(x: number, y: number, z: number): Vector3
  • add(value: number): Vector3
  • add(array: [number, number, number]): Vector3
  • add(vector: IVector3): Vector3
  • Adds two vectors.

publicangleTo

  • angleTo(vector: IVector3): number
  • Calculates angle between to vectors (in radians).

publicangleToDegrees

  • angleToDegrees(vector: IVector3): number
  • Calculates angle between to vectors (in degrees).

publiccross

  • cross(x: number, y: number, z: number): Vector3
  • cross(value: number): Vector3
  • cross(array: [number, number, number]): Vector3
  • cross(vector: IVector3): Vector3
  • Calculates cross product between two vectors.

publicdistanceTo

  • distanceTo(vector: IVector3): number
  • Calculates distance between vectors.

publicdistanceToSquared

  • distanceToSquared(vector: IVector3): number
  • Calculates squared distance between vectors.

publicdiv

  • div(x: number, y: number, z: number): Vector3
  • div(value: number): Vector3
  • div(array: [number, number, number]): Vector3
  • div(vector: IVector3): Vector3
  • Divides two vectors.

publicdot

  • dot(x: number, y: number, z: number): number
  • dot(value: number): number
  • dot(array: [number, number, number]): number
  • dot(vector: IVector3): number
  • Calculates dot product between two vectors.

publicinverse

  • inverse(): Vector3

publicisInRange

  • isInRange(vector: IVector3, range: number): boolean
  • Checks if distance between vectors is smaller or equal to range.

publiclerp

  • lerp(vector: IVector3, ratio: number): Vector3
  • Interpolates vectors linearly.

publicmul

  • mul(x: number, y: number, z: number): Vector3
  • mul(value: number): Vector3
  • mul(array: [number, number, number]): Vector3
  • mul(vector: IVector3): Vector3
  • Multiplies two vectors.

publicnegative

  • negative(): Vector3
  • Negates vector.

publicnormalize

  • normalize(): Vector3
  • Normalizes vector.

publicsub

  • sub(x: number, y: number, z: number): Vector3
  • sub(value: number): Vector3
  • sub(array: [number, number, number]): Vector3
  • sub(vector: IVector3): Vector3
  • Subtracts two vectors.

publictoArray

  • toArray(): [number, number, number]
  • Returns [x, y, z] array.

publictoDegrees

  • toDegrees(): Vector3
  • Converts radians to degrees.

publictoFixed

  • toFixed(precision: number): Vector3

publictoRadians

  • toRadians(): Vector3
  • Converts degrees to radians.

publictoString

  • toString(): string