# toji/gl-matrix

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/toji-gl-matrix).**

5,654 stars · 728 forks · JavaScript · mit

## Links

- GitHub: https://github.com/toji/gl-matrix
- Homepage: glmatrix.net
- awesome-repositories: https://awesome-repositories.com/repository/toji-gl-matrix.md

## Description

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.

## Tags

### Graphics & Multimedia

- [3D Math and Geometry Toolkits](https://awesome-repositories.com/f/graphics-multimedia/graphics-engines-rendering/3d-math-and-geometry-toolkits.md) — Performs vector and matrix math for real-time 3D graphics and physics simulations using typed arrays.
- [WebGL-Formatted Outputs](https://awesome-repositories.com/f/graphics-multimedia/graphics-engines-rendering/webgl-gpu-rendering/webgl-formatted-outputs.md) — Exposes matrices and vectors as flat arrays ready for direct upload to GPU uniform buffers without reformatting.
- [WebGL Matrix Formattings](https://awesome-repositories.com/f/graphics-multimedia/graphics-engines-rendering/webgl-gpu-rendering/webgl-matrix-formattings.md) — Stores and formats 4x4 matrices as column-major float arrays for direct use in WebGL rendering pipelines.
- [Column-Major Matrix Libraries](https://awesome-repositories.com/f/graphics-multimedia/webgl-rasterization-engines/column-major-matrix-libraries.md) — Provides column-major 4x4 matrix operations formatted for direct use with WebGL shaders.

### Artificial Intelligence & ML

- [Component-wise Math Operators](https://awesome-repositories.com/f/artificial-intelligence-ml/unary-mathematical-operations/component-wise-math-operators.md) — Returns new typed arrays from each operation instead of mutating inputs for predictable state management.
- [32/64-bit Build Variants](https://awesome-repositories.com/f/artificial-intelligence-ml/dual-model-memory-architectures/dual-model-architectures/32-64-bit-build-variants.md) — Generates separate 32-bit and 64-bit float builds from a single codebase for performance or accuracy trade-offs.

### Data & Databases

- [GPU-Compatible Typed Array Math](https://awesome-repositories.com/f/data-databases/shared-memory-data-exchange/direct-memory-data-transfer/typed-array-buffers/binary-buffer-management/typed-arrays/gpu-compatible-typed-array-math.md) — Stores vectors and matrices as Float32Array or Float64Array for direct GPU-compatible memory layout and fast numeric operations.
- [Typed Array Math Computations](https://awesome-repositories.com/f/data-databases/shared-memory-data-exchange/direct-memory-data-transfer/typed-array-buffers/binary-buffer-management/typed-arrays/typed-array-math-computations.md) — Computes vector and matrix operations with typed arrays for high-performance 3D graphics and physics calculations.

### Development Tools & Productivity

- [Typed Array Math Cores](https://awesome-repositories.com/f/development-tools-productivity/type-definition-generators/type-customization-extensions/gpu-math-type-constructors/typed-array-math-cores.md) — Stores vectors and matrices as Float32Array or Float64Array for direct GPU-compatible memory layout.
- [Dependency Minimizers](https://awesome-repositories.com/f/development-tools-productivity/package-dependency-managers/dependency-bloat-reducers/dependency-minimizers.md) — Implements all math from scratch with zero external dependencies, keeping bundle size minimal.

### Scientific & Mathematical Computing

- [Spatial Vector and Matrix Operations](https://awesome-repositories.com/f/scientific-mathematical-computing/high-performance-execution-environments/scientific-computing-platforms/scientific-computing/matrix-operations/matrix-vector-products/spatial-vector-and-matrix-operations.md) — Computes vector and matrix math with typed arrays for fast 3D graphics and physics calculations. ([source](https://glmatrix.net/docs/v4))
- [JavaScript Math Libraries](https://awesome-repositories.com/f/scientific-mathematical-computing/javascript-math-libraries.md) — Provides high-performance vector and matrix math using typed arrays for WebGL and graphics applications.
- [Column-Major Matrix Conventions](https://awesome-repositories.com/f/scientific-mathematical-computing/matrix-transposition-kernels/column-major-matrix-conventions.md) — Provides column-major matrix storage that matches OpenGL and WebGL shader memory layout without transposition.
- [Zero-Dependency Implementations](https://awesome-repositories.com/f/scientific-mathematical-computing/javascript-math-libraries/zero-dependency-implementations.md) — Implements vector and matrix math from scratch with zero external dependencies for minimal bundle size.
- [Floating-Point Precision Utilities](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/floating-point-handlers/floating-point-precision-utilities.md) — Switches between 32-bit and 64-bit float versions of math operations to trade performance for precision. ([source](https://glmatrix.net/docs/v4))
- [Precision-Switched Float Builds](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-mathematical-foundations/arithmetic-number-types/floating-point-handlers/floating-point-precision-utilities/precision-switched-float-builds.md) — Generates separate 32-bit and 64-bit float builds from a single codebase for performance or accuracy.
- [Precision Math Polyfills](https://awesome-repositories.com/f/scientific-mathematical-computing/scalar-mathematical-operations/precision-math-polyfills.md) — Supports both 32-bit and 64-bit float precision for vector and matrix computations.

### Software Engineering & Architecture

- [Immutable Data Patterns](https://awesome-repositories.com/f/software-engineering-architecture/immutable-data-patterns.md) — Returns new typed arrays from each operation instead of mutating inputs for predictable state management.
- [Zero-Dependency Libraries](https://awesome-repositories.com/f/software-engineering-architecture/zero-dependency-libraries.md) — Implements all math from scratch with zero external dependencies, keeping bundle size minimal.

### User Interface & Experience

- [Column-Major Matrix Libraries](https://awesome-repositories.com/f/user-interface-experience/column-layout-configurations/vertical-column-layouts/column-major-matrix-libraries.md) — Stores 4x4 matrices in column-major order matching OpenGL and WebGL shader memory layout.
- [WebGL Matrix Formatters](https://awesome-repositories.com/f/user-interface-experience/transformation-matrices/webgl-matrix-formatters.md) — Formats 4x4 matrices as contiguous float arrays with translation components at specific indices for OpenGL conventions. ([source](http://glmatrix.net/))
- [WebGL Matrix Manipulators](https://awesome-repositories.com/f/user-interface-experience/transformation-matrices/webgl-matrix-manipulators.md) — Stores transformation data in column-major float arrays matching OpenGL memory layout conventions. ([source](https://glmatrix.net))
