math is a collection of math helpers for graphics and simulations.
- High performance: allocation-free, monomorphic, benchmarked
- Tiny: mean and lean, tree-shakable, only pay for what you use
- Portable: interops with WebGL, WebGPU, Wasm, your favourite renderer, more.
- Data-oriented: data-in, data-out functions over caller-owned data, without owning the data lifecycle.
> npm install math@canaryimport { type Vec3, vec3 } from 'math';
// math types are plain arrays — the constructors just return literals:
const a: Vec3 = [1, 2, 3]; // a plain-array literal
const b = vec3.fromValues(1, 2, 3); // the same as `a`
const out = vec3.create(); // returns [0, 0, 0]
// functions write into their first argument, so nothing is allocated:
vec3.add(out, a, b); // out = [2, 4, 6]
vec3.normalize(out, out); // aliasing an argument is fineThe library is grouped by domain behind subpath entrypoints. All APIs are highly tree-shakeable, only pay for what you use:
import { mat4, quat, vec3 } from 'math'; // core: vectors, quats, matrices
import { simplex3d } from 'math/noise'; // perlin / simplex noise
import { mulberry32 } from 'math/random'; // seeded rng
import { easing, spring } from 'math/time'; // easings & springs
import { fabrik2, fabrik3 } from 'math/ik'; // inverse kinematics
// also: math/color, math/geometry, math/shapes — import only what you use- API.md — every export with its signature and a one-line description, grouped by module. Flat and greppable, so it's easy to search or hand to an AI coding assistant.
- Online API docs — the full typedoc reference, with search and cross-links.
- What's inside — jump straight to a module or namespace.
- The vec*, quat*, mat* code started life as a port of mathcat, which started as a TypeScript port of glMatrix (https://glmatrix.net/)
- The simplex noise is adapted from https://github.com/josephg/noisejs
- Thank you @kaleb for the npm package name!


















