Namespace vector

xeokit Vector Math Utilities


Mathematical functions and types for working with vectors


A small, allocation-conscious set of vector primitives and operations used by the math modules (eg. matrix and quat) and by geometry/transforms across the SDK.

Vectors are represented as either typed arrays (eg. Float32Array, Float64Array, Int32Array, …) or fixed-length numeric tuples. All functions accept either form and generally support an optional dest parameter to write results in-place, which helps avoid temporary allocations in tight loops.

This module defines vector aliases grouped by:

  • Length: Vec2, Vec3, Vec4, Vec9
  • Domain: integer vs floating-point
  • Precision (floats): explicit Float32 / Float64 or “either precision”

Notable aliases:

Factory helpers like createVec3Float64 and createVec4Float32 produce typed arrays of the requested size/precision, optionally seeded from an existing vector.

Many functions default to mutating their first input (eg. addVec3(u, v) writes into u) unless a dest is provided. If you need to keep inputs unchanged, always pass an explicit destination vector.

Type Aliases

Vec2
Vec2Float
Vec2Float32
Vec2Float64
Vec2Int
Vec3
Vec3Float
Vec3Float32
Vec3Float64
Vec3Int
Vec4
Vec4Float
Vec4Float32
Vec4Float64
Vec4Int
Vec9
Vec9Float
Vec9Float32
Vec9Float64

Functions

addVec3
addVec3Scalar
addVec4
addVec4Scalar
angleVec3
compareVec3
createVec2Float32
createVec2Float64
createVec2Int16
createVec2Int32
createVec2Uint16
createVec3Float32
createVec3Float64
createVec3Int16
createVec3Int32
createVec4Float32
createVec4Float64
createVec4Int16
createVec4Int32
createVec9Float32
createVec9Float64
cross3Vec3
cross3Vec4
distVec2
distVec3
divScalarVec3
divScalarVec4
divVec3
divVec3Scalar
divVec4
divVec4Scalar
dotVec2
dotVec3
dotVec4
geometricMeanVec2
lenVec2
lenVec3
lenVec4
lerpVec3
mulVec2Scalar
mulVec3Scalar
mulVec4
mulVec4Scalar
negateVec3
negateVec4
normalizeVec2
normalizeVec3
normalizeVec4
rcpVec3
sqLenVec2
sqLenVec3
sqLenVec4
subScalarVec4
subVec2
subVec3
subVec4
subVec4Scalar
testOrthogonalAxis
triangleNormal
vecToArray