Vec3
- class cee.Vec3()
An immutable 3d vector with x, y and z values.
Used for positions, normals and other 3d entities.
Constructors
Methods
Constructors
constructor
- cee.Vec3.constructor(x, y, z)
Constructor
- Arguments
x (
number
) –y (
number
) –z (
number
) –
- Return type
cee.Vec3
Properties
- cee.Vec3.x
The x coordinate of the vector
- cee.Vec3.y
The y coordinate of the vector
- cee.Vec3.z
The z coordinate of the vector
Methods
equals
- cee.Vec3.equals(other)
Returns true if the vectors are equal
- Arguments
other (
cee.Vec3Like
) –
- Return type
boolean
getLength
- cee.Vec3.getLength()
Returns the length of the vector (sqrt(x^2 + y^2 + z^2)).
- Return type
number
getLengthSquared
- cee.Vec3.getLengthSquared()
Returns the squared length of the vector
- Return type
number
getNegated
- cee.Vec3.getNegated()
Returns a negated version of the vector.
- Return type
cee.Vec3
getNormalized
- cee.Vec3.getNormalized()
Returns a normalized version of the vector.
- Return type
cee.Vec3
getPointDistance
getPointDistanceSquared
- cee.Vec3.getPointDistanceSquared(otherPoint)
Returns the squared distance between this point and otherPoint
- Arguments
otherPoint (
cee.Vec3Like
) –
- Return type
number
add
- cee.Vec3.add(a, b)
Returns the result of adding the two vectors
- Arguments
a (
cee.Vec3Like
) –b (
cee.Vec3Like
) –
- Return type
cee.Vec3
cross
- cee.Vec3.cross(a, b)
Returns the cross product of the 2 vectors
- Arguments
a (
cee.Vec3Like
) –b (
cee.Vec3Like
) –
- Return type
cee.Vec3
dot
- cee.Vec3.dot(a, b)
Returns the dot product of the 2 vectors
- Arguments
a (
cee.Vec3Like
) –b (
cee.Vec3Like
) –
- Return type
number
from
- cee.Vec3.from(vec)
Creates a new Vec3 instance from any object with x, y and z properties.
- Arguments
vec (
cee.Vec3Like
) –
- Return type
cee.Vec3
fromArray
- cee.Vec3.fromArray(arr)
Creates a new Vec3 instance from the first 3 elements of the given array.
- Arguments
arr (
ArrayLike[number]
) –
- Return type
cee.Vec3
negate
- cee.Vec3.negate(vec)
Returns the negation of the given vector
- Arguments
vec (
cee.Vec3Like
) –
- Return type
cee.Vec3
scale
- cee.Vec3.scale(vec, factor)
Returns the result of scaling the given vector by the given factor
- Arguments
vec (
cee.Vec3Like
) –factor (
number
) –
- Return type
cee.Vec3
sub
- cee.Vec3.sub(a, b)
Returns the result of subtracting vector b from vector a
- Arguments
a (
cee.Vec3Like
) –b (
cee.Vec3Like
) –
- Return type
cee.Vec3
transformPoint
- cee.Vec3.transformPoint(p, matrix)
Returns a new vector with the given vector transforms as a point.
- Arguments
p (
cee.Vec3Like
) –matrix (
cee.Mat4
) –
- Return type
cee.Vec3
Transforms the vector as a point by multiplying it with the given matrix. This will both rotate and translate the vector p. Assumes the matrix m doesn’t contain any perspective projection.
transformVector
- cee.Vec3.transformVector(p, matrix)
Returns a new vector with the given vector transforms as a vector.
- Arguments
p (
cee.Vec3Like
) –matrix (
cee.Mat4
) –
- Return type
cee.Vec3
Transforms the vector as a vector by multiplying it with the given matrix. This will only rotate the vector. The translation part of the matrix will be ignored. Assumes the matrix m doesn’t contain any perspective projection.