Class: Vec3

og/math/Vec3~Vec3

new Vec3(x, y, z)

Class represents a 3d vector.
Name Type Description
x number optional First value.
y number optional Second value.
z number optional Third value.

Members

xnumber

ynumber

znumber

static,constantmodule:og/math/Vec3~Vec3.BACKWARD

static,constantmodule:og/math/Vec3~Vec3.DOWN

static,constantmodule:og/math/Vec3~Vec3.FORWARD

static,constantmodule:og/math/Vec3~Vec3.LEFT

static,constantmodule:og/math/Vec3~Vec3.RIGHT

static,constantmodule:og/math/Vec3~Vec3.UP

static,constantmodule:og/math/Vec3~Vec3.ZERO

Methods

add(point3){og.Vec3}

Gets two vectors summarization.
Name Type Description
point3 og.Vec3 Vector to add.
Returns:
Type Description
og.Vec3 Returns a sum vector.

addA(point3){og.Vec3}

Adds vector to the current.
Name Type Description
point3 og.Vec3 Point to add.
Returns:
Type Description
og.Vec3 -

angle(a){number}

Gets angle between two vectors.
Name Type Description
a og.Vec3 Another vector.
Returns:
Type Description
number -

clear(){og.Vec3}

Sets vector to zero.
Returns:
Type Description
og.Vec3 -

clone(){og.Vec3}

Returns clone vector.
Returns:
Type Description
og.Vec3 -

copy(point3){og.Vec3}

Copy input vector's values.
Name Type Description
point3 og.Vec3 Vector to copy.
Returns:
Type Description
og.Vec3 -

cross(point3){og.Vec3}

Gets vectors cross production.
Name Type Description
point3 og.Vec3 Another vector.
Returns:
Type Description
og.Vec3 -

distance(point3){number}

Gets distance to point.
Name Type Description
point3 og.Vec3 Distant point.
Returns:
Type Description
number -

div(vec){og.Vec3}

Divide current vector's components to another and returns new vector instance.
Name Type Description
vec og.Vec3 Div vector.
Returns:
Type Description
og.Vec3 -

divA(vec){og.Vec3}

Divide current vector's components to another. Results stores in the current vector object.
Name Type Description
vec og.Vec3 Div vector.
Returns:
Type Description
og.Vec3 -

dot(point3){number}

Gets vectors dot production.
Name Type Description
point3 og.Vec3 Another vector.
Returns:
Type Description
number -

dotArr(arr){number}

Gets vectors dot production.
Name Type Description
arr Array.<number, number, number> Array vector.
Returns:
Type Description
number -

equal(p){boolean}

Compares with vector. Returns true if it equals another.
Name Type Description
p og.Vec3 Vector to compare.
Returns:
Type Description
boolean -

getQuat(){og.Quat}

Converts vector's values to a quaternion object.
Returns:
Type Description
og.Quat -

isZero(){boolean}

Returns true if vector's values are zero.
Returns:
Type Description
boolean -

length(){number}

Gets vector's length.
Returns:
Type Description
number -

length2(){number}

Returns squared vector's length.
Returns:
Type Description
number -

lerp(v2, l){og.Vec3}

Returns two vectors linear interpolation.
Name Type Description
v2 og.Vec3 End vector.
l number Interpolate value.
Returns:
Type Description
og.Vec3 -

mul(vec){og.Vec3}

Multiply current vector object to another and returns new vector instance.
Name Type Description
vec og.Vec3 Multiply vector.
Returns:
Type Description
og.Vec3 -

mulA(vec){og.Vec3}

Multiply current vector object to another and store result in the current instance.
Name Type Description
vec og.Vec3 Multiply vector.
Returns:
Type Description
og.Vec3 -

negate(){og.Vec3}

Negate current vector.
Returns:
Type Description
og.Vec3 -

negateTo(){og.Vec3}

Negate current vector to another instance.
Returns:
Type Description
og.Vec3 -

normal(){og.Vec3}

Returns normalized vector.
Returns:
Type Description
og.Vec3 -

normalize(){og.Vec3}

Normalize current vector.
Returns:
Type Description
og.Vec3 -

projToRay(pos, direction){og.Vec3}

Gets projected point coordinates of the current vector on the ray.
Name Type Description
pos og.Vec3 Ray position.
direction og.Vec3 Ray direction.
Returns:
Type Description
og.Vec3 -

scale(scale){og.Vec3}

Scale current vector.
Name Type Description
scale number Scale value.
Returns:
Type Description
og.Vec3 -

scaleTo(scale){og.Vec3}

Scale current vector to another instance.
Name Type Description
scale number Scale value.
Returns:
Type Description
og.Vec3 -

set(x, y, z){og.Vec3}

Sets vector's values.
Name Type Description
x number Value X.
y number Value Y.
z number Value Z.
Returns:
Type Description
og.Vec3 -

slerp(v2, t){og.Vec3}

Spherically interpolates between two vectors. Interpolates between current and v2 vector by amount t. The difference between this and linear interpolation (aka, "lerp") is that the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated by the angle and its magnitude is interpolated between the magnitudes of from and to.
Name Type Description
v2 og.Vec3 -
t number The parameter t is clamped to the range [0, 1].
Returns:
Type Description
og.Vec3 -

smerp(v2, t){og.Vec3}

Returns vector interpolation by v(t) = v1 * t + v2 * (1 - t)
Name Type Description
v2 og.Vec3 End vector.
t number Interpolate value.
Returns:
Type Description
og.Vec3 -

sub(point3){og.Vec3}

Gets vector subtraction.
Name Type Description
point3 og.Vec3 Subtract vector.
Returns:
Type Description
og.Vec3 Returns new instance of a subtraction

subA(point3){og.Vec3}

Subtract vector from the current.
Name Type Description
point3 og.Vec3 Subtract vector.
Returns:
Type Description
og.Vec3 -

toArray(){Array.<number, number, number>}

Converts vector to a number array.
Returns:
Type Description
Array.<number, number, number> -

toString(){string}

Converts vector to text string.
Returns:
Type Description
string -

toVec(){Array.<number, number, number>}

Converts vector to a number array.
Deprecated
  • Yes
Returns:
Type Description
Array.<number, number, number> -

toVec4(){og.Vec4}

Converts to 4d vector, Fourth value is 1.0.
Returns:
Type Description
og.Vec4 -

staticmodule:og/math/Vec3~Vec3.add(a, b){og.Vec3}

Returns summary vector.
Name Type Description
a og.Vec3 First vector.
b og.Vec3 Second vector.
Returns:
Type Description
og.Vec3 - Summary vector.

staticmodule:og/math/Vec3~Vec3.angle(a, b){number}

Gets angle between two vectors.
Name Type Description
a og.Vec3 First vector.
b og.Vec3 Second vector.
Returns:
Type Description
number -

staticmodule:og/math/Vec3~Vec3.div(a, b){og.Vec3}

Returns vector components division product one to another.
Name Type Description
a og.Vec3 First vector.
b og.Vec3 Second vector.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.fromVec(arr){og.Vec3}

Creates 3d vector from array.
Name Type Description
arr Array.<number, number, number>
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.lerp(v1, v2, l){og.Vec3}

Returns two vectors linear interpolation.
Name Type Description
v1 og.Vec3 Start vector.
v2 og.Vec3 End vector.
l number Interpolate value.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.mul(a, b){og.Vec3}

Returns two vectors production.
Name Type Description
a og.Vec3 First vector.
b og.Vec3 Second vector.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.noncollinear(a, b){og.Vec3}

Returns true if two vectors are non collinear.
Name Type Description
a og.Vec3 First vector.
b og.Vec3 Second vector.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.orthoNormalize(normal, tangent){og.Vec3}

Makes vectors normalized and orthogonal to each other. Normalizes normal. Normalizes tangent and makes sure it is orthogonal to normal (that is, angle between them is 90 degrees).
Name Type Description
normal og.Vec3 Normal vector.
tangent og.Vec3 Tangent vector.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.proj_b_to_a(b, a){og.Vec3}

Get projection of the first vector to the second.
Name Type Description
b og.Vec3 First vector.
a og.Vec3 Second vector.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.proj_b_to_plane(b, n, def){og.Vec3}

Get projection of the vector to plane where n - normal to the plane.
Name Type Description
b og.Vec3 Vector to project.
n og.Vec3 Plane normal.
def og.Vec3 optional Default value for non existed result.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.scale(a, scale){og.Vec3}

Returns scaled vector.
Name Type Description
a og.Vec3 Input vector.
scale number Scale value.
Returns:
Type Description
og.Vec3 -

staticmodule:og/math/Vec3~Vec3.sub(a, b){og.Vec3}

Returns two vectors subtraction.
Name Type Description
a og.Vec3 First vector.
b og.Vec3 Second vector.
Returns:
Type Description
og.Vec3 - Vectors subtraction.