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
- Vec3.constructor(x, y, z)
- Arguments:
x (
number
) – Noney (
number
) – Nonez (
number
) – None
Constructor
- Return type:
Vec3
Properties
- Vec3.x
- Type:
number
The x coordinate of the vector
- Vec3.y
- Type:
number
The y coordinate of the vector
- Vec3.z
- Type:
number
The z coordinate of the vector
Methods
equals
getLength
- Vec3.getLength()
Returns the length of the vector (sqrt(x^2 + y^2 + z^2)).
- Return type:
number
getLengthSquared
- Vec3.getLengthSquared()
Returns the squared length of the vector
- Return type:
number
getNegated
- Vec3.getNegated()
Returns a negated version of the vector.
- Return type:
Vec3
getNormalized
- Vec3.getNormalized()
Returns a normalized version of the vector.
- Return type:
Vec3
getPointDistance
getPointDistanceSquared
static add
static cross
static dot
static from
static fromArray
- Vec3.fromArray(arr)
- Arguments:
arr (
ArrayLike
) – None
Creates a new Vec3 instance from the first 3 elements of the given array.
- Return type:
Vec3
static negate
static scale
static sub
static transformPoint
- Vec3.transformPoint(p, matrix)
-
Returns a new vector with the given vector transforms as a point.
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.
- Return type:
Vec3
static transformVector
- Vec3.transformVector(p, matrix)
-
Returns a new vector with the given vector transforms as a vector.
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.
- Return type:
Vec3