Module: vec3

Summary

Methods

Detailed Description

Methods

add(a, b, out) → {Vec3}

Adds two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

angle(a, b) → {Number}

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
Source:

bezier(a, b, c, d, t, out) → {Vec3}

Performs a bezier interpolation with two control points
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
c Vec3 the third operand
d Vec3 the fourth operand
t Number interpolation amount between the two inputs
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

clone(a) → {Vec3}

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
Source:

copy(a, out) → {Vec3}

Copy the values from one vec3 to another
Parameters:
Name Type Description
a Vec3 the source vector
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

create() → {Vec3}

Creates a new, empty vec3
Returns:
a new 3D vector
Type
Vec3
Source:

cross(a, b, out) → {Vec3}

Computes the cross product of two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

dist()

Alias for vec3.distance
Source:

distance(a, b) → {Number}

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
Source:

div()

Alias for vec3.divide
Source:

divide(a, b, out) → {Vec3}

Divides two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

dot(a, b) → {Number}

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
Source:

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

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
Source:

fromValues(x, y, z) → {Vec3}

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
Source:

hermite(a, b, c, d, t, out) → {Vec3}

Performs a hermite interpolation with two control points
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
c Vec3 the third operand
d Vec3 the fourth operand
t Number interpolation amount between the two inputs
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

inverse(a, out) → {Vec3}

Returns the inverse of the components of a vec3
Parameters:
Name Type Description
a Vec3 vector to invert
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

len()

Alias for vec3.length
Source:

length(a) → {Number}

Calculates the length of a vec3
Parameters:
Name Type Description
a Vec3 vector to calculate length of
Returns:
length of a
Type
Number
Source:

lerp(a, b, t, out) → {Vec3}

Performs a linear interpolation between two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
t Number interpolation amount between the two inputs
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

max(a, b, out) → {Vec3}

Returns the maximum of two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

min(a, b, out) → {Vec3}

Returns the minimum of two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

mul()

Alias for vec3.multiply
Source:

multiply(a, b, out) → {Vec3}

Multiplies two vec3's
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

negate(a, out) → {Vec3}

Negates the components of a vec3
Parameters:
Name Type Description
a Vec3 vector to negate
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

normalize(a, out) → {Vec3}

Normalize a vec3
Parameters:
Name Type Description
a Vec3 vector to normalize
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

random(scaleopt, out) → {Vec3}

Generates a random vector with the given scale
Parameters:
Name Type Attributes Description
scale Number <optional>
Length of the resulting vector. If ommitted, a unit vector will be returned
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

rotateX(a, b, c, out) → {Vec3}

Rotate a 3D vector around the x-axis
Parameters:
Name Type Description
a Vec3 The vec3 point to rotate
b Vec3 The origin of the rotation
c Number The angle of rotation
out Vec3 The receiving vec3
Returns:
out
Type
Vec3
Source:

rotateY(a, b, c, out) → {Vec3}

Rotate a 3D vector around the y-axis
Parameters:
Name Type Description
a Vec3 The vec3 point to rotate
b Vec3 The origin of the rotation
c Number The angle of rotation
out Vec3 The receiving vec3
Returns:
out
Type
Vec3
Source:

rotateZ(a, b, c, out) → {Vec3}

Rotate a 3D vector around the z-axis
Parameters:
Name Type Description
a Vec3 The vec3 point to rotate
b Vec3 The origin of the rotation
c Number The angle of rotation
out Vec3 The receiving vec3
Returns:
out
Type
Vec3
Source:

scale(a, b, out) → {Vec3}

Scales a vec3 by a scalar number
Parameters:
Name Type Description
a Vec3 the vector to scale
b Number amount to scale the vector by
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

scaleAndAdd(a, b, scale, out) → {Vec3}

Adds two vec3's after scaling the second operand by a scalar value
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
scale Number the amount to scale b by before adding
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

set(x, y, z, out) → {Vec3}

Set the components of a vec3 to the given values
Parameters:
Name Type Description
x Number X component
y Number Y component
z Number Z component
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

sqrDist()

Alias for vec3.squaredDistance
Source:

sqrLen()

Alias for vec3.squaredLength
Source:

squaredDistance(a, b) → {Number}

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
Source:

squaredLength(a) → {Number}

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
Source:

str(vec) → {String}

Returns a string representation of a vector
Parameters:
Name Type Description
vec Vec3 vector to represent as a string
Returns:
string representation of the vector
Type
String
Source:

sub()

Alias for vec3.subtract
Source:

subtract(a, b, out) → {Vec3}

Subtracts vector b from vector a
Parameters:
Name Type Description
a Vec3 the first operand
b Vec3 the second operand
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

transformMat3(a, m, out) → {Vec3}

Transforms the vec3 with a mat3.
Parameters:
Name Type Description
a Vec3 the vector to transform
m Mat4 the 3x3 matrix to transform with
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

transformMat4(a, m, out) → {Vec3}

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
Parameters:
Name Type Description
a Vec3 the vector to transform
m Mat4 matrix to transform with
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source:

transformQuat(a, q, out) → {Vec3}

Transforms the vec3 with a quat
Parameters:
Name Type Description
a Vec3 the vector to transform
q Quat quaternion to transform with
out Vec3 the receiving vector
Returns:
out
Type
Vec3
Source: