Vec3

Vec3

3D vector class

Constructor

new Vec3(x, y, z)

Source:
Creates new 3D Vector from parameters.
Parameters:
Name Type Description
x Number
y Number
z Number

Members

data :Float32Array

Source:
a float array storing the components of the vector. this can be passed to ShaderProgram as an uniform.
Type:
  • Float32Array

Methods

copy(other)

Source:
Parameters:
Name Type Description
other Vec3

cross(other)

Source:
Set this vector to be the cross product with another.
Parameters:
Name Type Description
other Vec3

dot(other)

Source:
Dot product between this and other vector.
Parameters:
Name Type Description
other Vec3

isZero()

Source:
Returns true if all components are zero.

length() → {number}

Source:
Length of the vector.
Returns:
length
Type
number

lengthSqr() → {number}

Source:
Squared length of this vector. this is cheaper than Vec3#length.
Returns:
squared length.
Type
number

normalize()

Source:
Normalizes the vector by dividing it by its own length. This ensures that the length is always one.

transformMat4(mat)

Source:
Transforms this vector with the given 4x4 matrix.
Parameters:
Name Type Description
mat Mat4

(static) cross(a, b)

Source:
Cross product vector from two vectors.
Parameters:
Name Type Description
a Vec3
b Vec3

(static) dot(a, b)

Source:
Dot product from two vectors.
Parameters:
Name Type Description
a Vec3
b Vec3