Constructor
new Vec3(x, y, z)
Creates new 3D Vector from parameters.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | |
y |
Number | |
z |
Number |
Members
data :Float32Array
a float array storing the components of the vector.
this can be passed to ShaderProgram as an uniform.
Type:
- Float32Array
Methods
copy(other)
Parameters:
Name | Type | Description |
---|---|---|
other |
Vec3 |
cross(other)
Set this vector to be the cross product with another.
Parameters:
Name | Type | Description |
---|---|---|
other |
Vec3 |
dot(other)
Dot product between this and other vector.
Parameters:
Name | Type | Description |
---|---|---|
other |
Vec3 |
isZero()
Returns true if all components are zero.
length() → {number}
Length of the vector.
Returns:
length
- Type
- number
lengthSqr() → {number}
Squared length of this vector. this is cheaper than Vec3#length.
Returns:
squared length.
- Type
- number
normalize()
Normalizes the vector by dividing it by its own length. This ensures that the length is always one.
transformMat4(mat)
Transforms this vector with the given 4x4 matrix.
Parameters:
Name | Type | Description |
---|---|---|
mat |
Mat4 |
(static) cross(a, b)
Cross product vector from two vectors.
Parameters:
Name | Type | Description |
---|---|---|
a |
Vec3 | |
b |
Vec3 |
(static) dot(a, b)
Dot product from two vectors.
Parameters:
Name | Type | Description |
---|---|---|
a |
Vec3 | |
b |
Vec3 |