gl-matrix is a high-performance JavaScript library for vector and matrix math, purpose-built for real-time 3D graphics and physics simulations. It stores all vectors and matrices as typed arrays (Float32Array or Float64Array) in column-major order, matching the memory layout expected by OpenGL and WebGL shaders without requiring transposition. The library is implemented from scratch with zero external dependencies, keeping its bundle size minimal for web and Node.js environments.
The library distinguishes itself through its immutable operation pattern, where each math function returns a new typed array rather than mutating the input, enabling predictable state management in animation loops. It also offers a precision-switched build system that generates separate 32-bit and 64-bit float versions from a single codebase, allowing developers to trade performance for accuracy as needed. All matrix and vector operations output data in a format ready for direct upload to GPU uniform buffers, eliminating reformatting overhead.
The library covers the full range of vector and matrix operations needed for 3D graphics pipelines, including manipulation of 4x4 matrices and computation of vector math optimized for real-time rendering. Its typed array core ensures fast numeric operations and direct GPU-compatible memory layout across all computations.