Skip to content

Vector3

Bluu edited this page Feb 18, 2018 · 2 revisions

The Vector3 is the must commonly used vector for 3D.

Import

import { Vector3 } from "noobgl-vector";

Constructor

new Vector3(x, y, z);
  • x (optional) the vector value of the x axis (default 0).

  • y (optional) the vector value of the y axis (default 0).

  • z (optional) the vector value of the z axis (default 0).

Properties

.x the current value of the x axis.

.y the current value of the y axis.

.z the current value of the z axis.

.length the current length of the vector.

Methods

set(x, y, z)

Set the current values of the x, y and z axis.

  • x the value of the x axis to set.

  • y the value of the y axis to set.

  • z the value of the z axis to set.


add(x, y, z)

Add these values to the current vector.

  • x the value to add to the x axis.

  • y the value to add to the y axis.

  • z the value to add to the z axis.


subtract(x, y, z)

Subtract these values to the current vector.

  • x the value to subtract to the x axis.

  • y the value to subtract to the y axis.

  • z the value to subtract to the z axis.


multiply(x, y, z)

Multiply these values with the current vector.

  • x the value by which to multiply the x axis.

  • y the value by which to multiply the y axis.

  • z the value by which to multiply the z axis.


divide(x, y, z)

Divide these values with the current vector.

  • x the value by which to divide the x axis.

  • y the value by which to divide the y axis.

  • z the value by which to divide the z axis.


cross(x, y, z)

Set the current values of the x, y and z axis to the cross product of the current vector and the given one.

  • x the value by which to cross the x axis.

  • y the value by which to cross the y axis.

  • z the value by which to crioss the z axis.


normalize()

Normalize the current vector's axis values.


clone()

Clone the current vector into a new instance.


static length(x, y, z)

Return the length of the given axis.

  • x the value of the x axis.

  • y the value of the y axis.

  • z the value of the z axis.

Clone this wiki locally