Vec3

class cee.Vec3()

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

Used for positions, normals and other 3d entities.

Constructors

cee.Vec3.constructor()
Vec3(x: number, y: number, z: number): Vec3

Constructor

Parameters

x: number

y: number

z: number

Returns: Vec3

Properties

cee.Vec3.x

readonly

x: number

The x coordinate of the vector

cee.Vec3.y

readonly

y: number

The y coordinate of the vector

cee.Vec3.z

readonly

z: number

The z coordinate of the vector

Methods

cee.Vec3.equals()
equals(other: Vec3Like): boolean

Returns true if the vectors are equal

Parameters

other: Vec3Like

Returns: boolean

cee.Vec3.getLength()
getLength(): number

Returns the length of the vector (sqrt(x^2 + y^2 + z^2)).

Returns: number

cee.Vec3.getLengthSquared()
getLengthSquared(): number

Returns the squared length of the vector

Returns: number

cee.Vec3.getNegated()
getNegated(): Vec3

Returns a negated version of the vector.

Returns: Vec3

cee.Vec3.getNormalized()
getNormalized(): Vec3

Returns a normalized version of the vector.

Returns: Vec3

cee.Vec3.getPointDistance()
getPointDistance(otherPoint: Vec3): number

Returns the distance between this point and otherPoint

Parameters

otherPoint: Vec3

Returns: number

cee.Vec3.getPointDistanceSquared()
getPointDistanceSquared(otherPoint: Vec3Like): number

Returns the squared distance between this point and otherPoint

Parameters

otherPoint: Vec3Like

Returns: number

static cee.Vec3.add()

static

add(a: Vec3Like, b: Vec3Like): Vec3

Returns the result of adding the two vectors

Parameters

Returns: Vec3

static cee.Vec3.cross()

static

cross(a: Vec3Like, b: Vec3Like): Vec3

Returns the cross product of the 2 vectors

Parameters

Returns: Vec3

static cee.Vec3.dot()

static

dot(a: Vec3Like, b: Vec3Like): number

Returns the dot product of the 2 vectors

Parameters

Returns: number

static cee.Vec3.from()

static

from(vec: Vec3Like): Vec3

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

Parameters

Returns: Vec3

static cee.Vec3.fromArray()

static

fromArray(arr: ArrayLike): Vec3

Creates a new Vec3 instance from the first 3 elements of the given array.

Parameters

arr: ArrayLike

Returns: Vec3

static cee.Vec3.negate()

static

negate(vec: Vec3Like): Vec3

Returns the negation of the given vector

Parameters

Returns: Vec3

static cee.Vec3.scale()

static

scale(vec: Vec3Like, factor: number): Vec3

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

Parameters

vec: Vec3Like

factor: number

Returns: Vec3

static cee.Vec3.sub()

static

sub(a: Vec3Like, b: Vec3Like): Vec3

Returns the result of subtracting vector b from vector a

Parameters

Returns: Vec3

static cee.Vec3.transformPoint()

static

transformPoint(p: Vec3Like, matrix: Mat4): Vec3

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.

Parameters

p: Vec3Like

matrix: Mat4

Returns: Vec3

static cee.Vec3.transformVector()

static

transformVector(p: Vec3Like, matrix: Mat4): Vec3

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.

Parameters

p: Vec3Like

matrix: Mat4

Returns: Vec3