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

Vec3.constructor(x, y, z)
Arguments:
  • x (number) – None

  • y (number) – None

  • z (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

Vec3.equals(other)
Arguments:

Returns true if the vectors are equal

Return type:

boolean

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

Vec3.getPointDistance(otherPoint)
Arguments:
  • otherPoint (Vec3) – None

Returns the distance between this point and otherPoint

Return type:

number

getPointDistanceSquared

Vec3.getPointDistanceSquared(otherPoint)
Arguments:

Returns the squared distance between this point and otherPoint

Return type:

number

static add

Vec3.add(a, b)
Arguments:

Returns the result of adding the two vectors

Return type:

Vec3

static cross

Vec3.cross(a, b)
Arguments:

Returns the cross product of the 2 vectors

Return type:

Vec3

static dot

Vec3.dot(a, b)
Arguments:

Returns the dot product of the 2 vectors

Return type:

number

static from

Vec3.from(vec)
Arguments:

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

Return type:

Vec3

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

Vec3.negate(vec)
Arguments:

Returns the negation of the given vector

Return type:

Vec3

static scale

Vec3.scale(vec, factor)
Arguments:
  • vec (Vec3Like) – None

  • factor (number) – None

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

Return type:

Vec3

static sub

Vec3.sub(a, b)
Arguments:

Returns the result of subtracting vector b from vector a

Return type:

Vec3

static transformPoint

Vec3.transformPoint(p, matrix)
Arguments:

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)
Arguments:

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