Vec3

class cee.Vec3()

An immutable 3d vector with x, y and z values.

Used for positions, normals and other 3d entities.

Constructors

Properties


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

cee.Vec3.getPointDistance(otherPoint)

Returns the distance between this point and otherPoint

Arguments
Return type

number

getPointDistanceSquared

cee.Vec3.getPointDistanceSquared(otherPoint)

Returns the squared distance between this point and otherPoint

Arguments
Return type

number

add

cee.Vec3.add(a, b)

Returns the result of adding the two vectors

Arguments
Return type

cee.Vec3

cross

cee.Vec3.cross(a, b)

Returns the cross product of the 2 vectors

Arguments
Return type

cee.Vec3

dot

cee.Vec3.dot(a, b)

Returns the dot product of the 2 vectors

Arguments
Return type

number

from

cee.Vec3.from(vec)

Creates a new Vec3 instance from any object with x, y and z properties.

Arguments
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
Return type

cee.Vec3

scale

cee.Vec3.scale(vec, factor)

Returns the result of scaling the given vector by the given factor

Arguments
Return type

cee.Vec3

sub

cee.Vec3.sub(a, b)

Returns the result of subtracting vector b from vector a

Arguments
Return type

cee.Vec3

transformPoint

cee.Vec3.transformPoint(p, matrix)

Returns a new vector with the given vector transforms as a point.

Arguments
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
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.