Перейти к основному содержанию

Vector3

Class which represents three-dimensional vector and basic operations with it.

Implements

  • Vector

Index

Constructors

constructor

  • new Vector3(vx: number, vy: number, vz: number): Vector3
  • new Vector3(vector: Vector): Vector3
  • Parameters

    • vx: number
    • vy: number
    • vz: number

    Returns Vector3

Properties

x

x: number

X coord of the vector

y

y: number

Y coord of the vector

z

z: number

Z coord of the vector

staticreadonlyDOWN

DOWN: Vector3

staticreadonlyEAST

EAST: Vector3

staticreadonlyNORTH

NORTH: Vector3

staticreadonlySOUTH

SOUTH: Vector3

staticreadonlyUP

staticreadonlyWEST

WEST: Vector3

Methods

add

  • add(vx: number, vy: number, vz: number): Vector3
  • add(vector: Vector): Vector3
  • Adds vector.


    Parameters

    • vx: number
    • vy: number
    • vz: number

    Returns Vector3

    result vector.

addScaled

  • addScaled(vector: Vector, scale: number): Vector3
  • Adds vector scaled by factor.


    Parameters

    • vector: Vector

      vector to add.

    • scale: number

      scale factor

    Returns Vector3

    result vector.

copy

  • Copies coords to a new vector.


    Returns Vector3

    vector copy.

cross

  • cross(vx: number, vy: number, vz: number): Vector3
  • cross(vector: Vector): Vector3
  • Calculates cross product of vectors.


    Parameters

    • vx: number
    • vy: number
    • vz: number

    Returns Vector3

    result vector.

distance

  • distance(vx: number, vy: number, vz: number): number
  • distance(coords: Vector): number
  • Calculates distance to another point.


    Parameters

    • vx: number

      x coord

    • vy: number

      y coord

    • vz: number

      z coord

    Returns number

    distance

distanceSquared

  • distanceSquared(vx: number, vy: number, vz: number): number
  • distanceSquared(coords: Vector): number
  • Calculates squared distance to another point.


    Parameters

    • vx: number

      x coord

    • vy: number

      y coord

    • vz: number

      z coord

    Returns number

    squared distance

dot

  • dot(vx: number, vy: number, vz: number): number
  • dot(vector: any): number

  • Parameters

    • vx: number
    • vy: number
    • vz: number

    Returns number

    dot product of vectors.

length

  • length(): number

  • Returns number

    vector length.

lengthSquared

  • lengthSquared(): number

  • Returns number

    vector length squared

negate

  • Multiplies vector coords by -1.


    Returns Vector3

    opposite vector.

normalize

  • Normalizes vector.


    Returns Vector3

    normalized vector.

scale

  • Scales vector coords by factor.


    Parameters

    • factor: number

      scaling factor

    Returns Vector3

    scaled vector

scaleTo

  • Scales vector length to specified value.


    Parameters

    • len: number

      target length

    Returns Vector3

    scaled vector

set

  • set(vx: number, vy: number, vz: number): Vector3
  • set(vector: Vector): Vector3
  • Sets vector coords.


    Parameters

    • vx: number
    • vy: number
    • vz: number

    Returns Vector3

sub

  • sub(vx: number, vy: number, vz: number): Vector3
  • sub(vector: Vector): Vector3
  • Substracts vector.


    Parameters

    • vx: number
    • vy: number
    • vz: number

    Returns Vector3

    result vector.

toString

  • toString(): string
  • Returns string

staticgetDirection

  • getDirection(side: number): Vector3

  • Parameters

    • side: number

      block side

    Returns Vector3

    direction vector for specified side