vec3

vec3

3 Dimensional Vector

Constructor

# new vec3()

Source:

Methods

# (static) add(out, a, b) → {vec3}

Source:

Adds two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) angle(a, b) → {Number}

Source:

Get the angle between two 3D vectors

Parameters:
Name Type Description
a vec3

The first operand

b vec3

The second operand

Returns:

The angle in radians

Type
Number

# (static) clone(a) → {vec3}

Source:

Creates a new vec3 initialized with values from an existing vector

Parameters:
Name Type Description
a vec3

vector to clone

Returns:

a new 3D vector

Type
vec3

# (static) copy(out, a) → {vec3}

Source:

Copy the values from one vec3 to another

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the source vector

Returns:

out

Type
vec3

# (static) create() → {vec3}

Source:

Creates a new, empty vec3

Returns:

a new 3D vector

Type
vec3

# (static) cross(out, a, b) → {vec3}

Source:

Computes the cross product of two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) dist()

Source:

Alias for vec3.distance

# (static) distance(a, b) → {Number}

Source:

Calculates the euclidian distance between two vec3's

Parameters:
Name Type Description
a vec3

the first operand

b vec3

the second operand

Returns:

distance between a and b

Type
Number

# (static) div()

Source:

Alias for vec3.divide

# (static) divide(out, a, b) → {vec3}

Source:

Divides two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) dot(a, b) → {Number}

Source:

Calculates the dot product of two vec3's

Parameters:
Name Type Description
a vec3

the first operand

b vec3

the second operand

Returns:

dot product of a and b

Type
Number

# (static) forEach(a, stride, offset, count, fn, argopt) → {Array}

Source:

Perform some operation over an array of vec3s.

Parameters:
Name Type Attributes Description
a Array

the array of vectors to iterate over

stride Number

Number of elements between the start of each vec3. If 0 assumes tightly packed

offset Number

Number of elements to skip at the beginning of the array

count Number

Number of vec3s to iterate over. If 0 iterates over entire array

fn function

Function to call for each vector in the array

arg Object <optional>

additional argument to pass to fn

Returns:

a

Type
Array

# (static) fromValues(x, y, z) → {vec3}

Source:

Creates a new vec3 initialized with the given values

Parameters:
Name Type Description
x Number

X component

y Number

Y component

z Number

Z component

Returns:

a new 3D vector

Type
vec3

# (static) inverse(out, a) → {vec3}

Source:

Returns the inverse of the components of a vec3

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

vector to invert

Returns:

out

Type
vec3

# (static) len()

Source:

Alias for vec3.length

# (static) length(a) → {Number}

Source:

Calculates the length of a vec3

Parameters:
Name Type Description
a vec3

vector to calculate length of

Returns:

length of a

Type
Number

# (static) lerp(out, a, b, t) → {vec3}

Source:

Performs a linear interpolation between two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

t Number

interpolation amount between the two inputs

Returns:

out

Type
vec3

# (static) max(out, a, b) → {vec3}

Source:

Returns the maximum of two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) min(out, a, b) → {vec3}

Source:

Returns the minimum of two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) mul()

Source:

Alias for vec3.multiply

# (static) multiply(out, a, b) → {vec3}

Source:

Multiplies two vec3's

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) negate(out, a) → {vec3}

Source:

Negates the components of a vec3

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

vector to negate

Returns:

out

Type
vec3

# (static) normalize(out, a) → {vec3}

Source:

Normalize a vec3

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

vector to normalize

Returns:

out

Type
vec3

# (static) random(out, scaleopt) → {vec3}

Source:

Generates a random vector with the given scale

Parameters:
Name Type Attributes Description
out vec3

the receiving vector

scale Number <optional>

Length of the resulting vector. If ommitted, a unit vector will be returned

Returns:

out

Type
vec3

# (static) rotateX(out, a, b, c) → {vec3}

Source:

Rotate a 3D vector around the x-axis

Parameters:
Name Type Description
out vec3

The receiving vec3

a vec3

The vec3 point to rotate

b vec3

The origin of the rotation

c Number

The angle of rotation

Returns:

out

Type
vec3

# (static) rotateY(out, a, b, c) → {vec3}

Source:

Rotate a 3D vector around the y-axis

Parameters:
Name Type Description
out vec3

The receiving vec3

a vec3

The vec3 point to rotate

b vec3

The origin of the rotation

c Number

The angle of rotation

Returns:

out

Type
vec3

# (static) rotateZ(out, a, b, c) → {vec3}

Source:

Rotate a 3D vector around the z-axis

Parameters:
Name Type Description
out vec3

The receiving vec3

a vec3

The vec3 point to rotate

b vec3

The origin of the rotation

c Number

The angle of rotation

Returns:

out

Type
vec3

# (static) scale(out, a, b) → {vec3}

Source:

Scales a vec3 by a scalar number

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the vector to scale

b Number

amount to scale the vector by

Returns:

out

Type
vec3

# (static) scaleAndAdd(out, a, b, scale) → {vec3}

Source:

Adds two vec3's after scaling the second operand by a scalar value

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

scale Number

the amount to scale b by before adding

Returns:

out

Type
vec3

# (static) set(out, x, y, z) → {vec3}

Source:

Set the components of a vec3 to the given values

Parameters:
Name Type Description
out vec3

the receiving vector

x Number

X component

y Number

Y component

z Number

Z component

Returns:

out

Type
vec3

# (static) sqrDist()

Source:

# (static) sqrLen()

Source:

Alias for vec3.squaredLength

# (static) squaredDistance(a, b) → {Number}

Source:

Calculates the squared euclidian distance between two vec3's

Parameters:
Name Type Description
a vec3

the first operand

b vec3

the second operand

Returns:

squared distance between a and b

Type
Number

# (static) squaredLength(a) → {Number}

Source:

Calculates the squared length of a vec3

Parameters:
Name Type Description
a vec3

vector to calculate squared length of

Returns:

squared length of a

Type
Number

# (static) sub()

Source:

Alias for vec3.subtract

# (static) subtract(out, a, b) → {vec3}

Source:

Subtracts vector b from vector a

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the first operand

b vec3

the second operand

Returns:

out

Type
vec3

# (static) transformMat3(out, a, m) → {vec3}

Source:

Transforms the vec3 with a mat3.

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the vector to transform

m mat4

the 3x3 matrix to transform with

Returns:

out

Type
vec3

# (static) transformMat4(out, a, m) → {vec3}

Source:

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the vector to transform

m mat4

matrix to transform with

Returns:

out

Type
vec3

# (static) transformQuat(out, a, q) → {vec3}

Source:

Transforms the vec3 with a quat

Parameters:
Name Type Description
out vec3

the receiving vector

a vec3

the vector to transform

q quat

quaternion to transform with

Returns:

out

Type
vec3