glMatrix provides vec, mat, and quat types tuned for WebGL and browser 3D math. Functions follow OpenGL-style matrix layout conventions used by WebGL renderers.
Overview
JavaScript lacks built-in high-performance linear algebra for realtime graphics and physics in the browser. glMatrix supplies hand-optimized operations on typed arrays with separate modules for vectors, matrices, and quaternions.
The API encourages efficient usage patterns and matches WebGL expectations, including 4x4 matrices stored as contiguous floats with translation in designated elements. Documentation contrasts this layout with column-major notation in OpenGL spec text to avoid confusion.
Version 2 onward reorganized types, added helpers such as forEach traversals, and expanded unit tests. Callers may switch to plain arrays instead of Float32Array when profiling shows better performance on a given engine.
WebGL applications, WebXR demos, and physics prototypes import glMatrix when they want a small dependency focused on speed rather than a full scene graph engine.
Key features
- vec2, vec3, vec4 utilities
- mat2, mat3, mat4 operations
- WebGL-oriented layout
- Float32Array optimized paths
- Modular type files
- Deterministic API conventions
- Optional plain array mode
Use cases
- WebGL transform math
- Browser 3D graphics
- Physics simulation prototypes
- WebXR scene calculations