Class: vec3

vec3()

new vec3()

Vector helper refrence algorithm: https://evanw.github.io/lightgl.js/docs/main.html

Source:

Members

dot

get vector lenght

Source:

(static) mix

Vector.lerp() performs linear interpolation between two vectors.

Source:

Methods

add(v) → {vec3}

this += v, element wise.

TODO: https://stackoverflow.com/questions/19620667/javascript-operator-overloading

Parameters:
Name Type Description
v vec | array
Source:
Returns:

this

Type
vec3

addByScale(v, s) → {vec3}

this += v, element wise.

Parameters:
Name Type Description
v vec | array
s number

scale

Source:
Returns:

this

Type
vec3

angleTo(a) → {number}

acos ( dot (this, a) / (len * a_len) )

Parameters:
Name Type Description
a vec | array
Source:
Returns:

angle

Type
number

arr(nopt) → {array}

get a plain js array of [x, y, z], length n

Parameters:
Name Type Attributes Default Description
n number <optional>
3
Source:
Returns:

[x, y, z]

Type
array

clone()

Source:

cross() → {number}

this = cross product with v

Source:
Returns:

cross product

Type
number

div(v) → {vec3}

this divid v element wise.

Parameters:
Name Type Description
v vec | array
Source:
Returns:

this divided

Type
vec3

dot(v) → {number}

this = dot product with v

Parameters:
Name Type Description
v vec | array
Source:
Returns:

dot product

Type
number

eq(v, deltaopt) → {bool}

Is this equals to v? (delta is tolerated).

Parameters:
Name Type Attributes Default Description
v vec | array
delta number <optional>
0.001
Source:
Returns:
Type
bool

init()

Source:

mat3(m4) → {vec3}

get 3x3(m4) * this

Parameters:
Name Type Description
m4 mat4

only a 3x3 matrix is used

Source:
Returns:

this left mulitpled with m4

Type
vec3

mat4(m4) → {vec3}

get m4 * this

Parameters:
Name Type Description
m4 mat4
Source:
Returns:

this left mulitpled with m4

Type
vec3

max()

Source:

min()

Source:

mul(v) → {vec3}

this *= v, element wise.

Parameters:
Name Type Description
v vec | array
Source:
Returns:

this

Type
vec3

neg() → {vec3}

vec *= -1

Source:
Returns:

this

Type
vec3

scaleTo(len, buf) → {vec3|array}

set length s to buf, the vec3.

Parameters:
Name Type Description
len number

length

buf vec3 | array
Source:
Returns:

buf

Type
vec3 | array

set(xyz, yopt, zopt) → {vec3}

set value

Parameters:
Name Type Attributes Description
xyz array | number
y number <optional>

ignored when xyz is an array

z number <optional>

ignored when xyz is an array

Source:
Returns:

this

Type
vec3

sub(v) → {vec3}

this -= v, element wise.

Parameters:
Name Type Description
v vec | array
Source:
Returns:

this

Type
vec3

toAngles()

Source:

unit(a, b) → {vec3|array}

normalize.

Parameters:
Name Type Description
a vec3 | array

vectore

b vec3 | array

buffer

Source:
Returns:

b

Type
vec3 | array

unit() → {vec3}

Return unit vector

Source:
Returns:
Type
vec3

(static) js() → {THREE.Vector3}

Get THREE.Vector3 object

Source:
Returns:
Type
THREE.Vector3

(static) js()

create a THREE.Vector3

Source:

(static) lerp()

performs linear interpolation between two vectors.

Source:

(static) mul(a, b, copt) → {vec3}

c = a * b

Parameters:
Name Type Attributes Description
a array | vec3
b vec3 | number
c vec3 <optional>

result buffer

Source:
Returns:

c

Type
vec3

(static) mulArr(a, b, c) → {array}

c = a * b

Parameters:
Name Type Description
a array | vec3
b vec3 | number | array
c array

result buffer

Source:
Returns:

c

Type
array

(static) mulArr(a, b, copt) → {vec3}

cross product, right hand rule

Parameters:
Name Type Attributes Description
a array | vec3
b vec3 | number | array
c vec3 <optional>

result buffer

Source:
Returns:

c

Type
vec3

(static) mulArr(a, b, c) → {array}

cross product, right hand rule

Parameters:
Name Type Description
a array | vec3
b vec3 | number | array
c array

result buffer, must providen

Source:
Returns:

c

Type
array

(static) randomDirection()

returns a vector with a length of 1 and a statistically uniform direction.

Source: