glMatrix is a high-performance JavaScript library for vector and matrix mathematics, specifically optimized for real-time 3D graphics applications like those built with WebGL. It leverages `Float32Array` by default for numerical operations, ensuring maximum performance by minimizing garbage collection and memory overhead. The current stable version is 3.4.4, with releases occurring periodically to address bug fixes, introduce performance improvements, and maintain compatibility with modern JavaScript and TypeScript environments. Key differentiators include its focus on raw speed, a comprehensive set of operations for `vec2`, `vec3`, `vec4`, `mat3`, `mat4`, and `quat` types, and its design to prevent global namespace pollution by using named imports or a single `glMatrix` global object. It also supports cherry-picking individual modules for better tree-shaking.
npm install gl-matrixVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup of projection and view matrices for a 3D scene, along with common model matrix transformations like translation and rotation using `mat4` and `vec3`.
Update your build setup or runtime environment to use ES Module imports (`import ... from 'gl-matrix'`). For Node.js, ensure your `package.json` also has `"type": "module"` or use `.mjs` extensions for files importing gl-matrix. If you must use CommonJS, consider transpiling your code or sticking to an older, non-ESM version, though this is not recommended for long-term maintenance.
Update existing browser scripts that rely on global access to prepend `glMatrix.` to all calls (e.g., `mat4.create()` becomes `glMatrix.mat4.create()`). Alternatively, for modern browser development, use ES Module imports with a bundler.
Ensure you are using `3.4.1` or newer if you intended to update gl-matrix around that time. Version `3.4.0` should be explicitly avoided.
For most high-performance scenarios, stick with the default `Float32Array`. Only switch to `Array` after thorough profiling if a specific performance bottleneck is identified related to `Float32Array` usage in your target environment.
For modern TypeScript projects, use `gl-matrix@^3.2.0` or newer to get official, integrated type support. If constrained to older versions, ensure `@types/gl-matrix` is installed and its version is compatible with your `gl-matrix` version.
Update your project to use ES Module `import` syntax (`import { mat4 } from 'gl-matrix';`) and ensure your Node.js environment or bundler correctly handles ESM. For Node.js, this often means adding `"type": "module"` to your `package.json` or using the `.mjs` file extension for the importing file.Access functions via the `glMatrix` global object: `glMatrix.mat4.create()` instead of `mat4.create()`. Alternatively, use ES Module imports with a bundler for modern browser development.
Ensure `gl-matrix` is at least `v3.2.0` for integrated type definitions. If using older versions, verify that `@types/gl-matrix` is installed and compatible. When declaring array types, remember gl-matrix defaults to `Float32Array` (`import type { vec3 } from 'gl-matrix';` will correctly infer this).Ensure the file importing `gl-matrix` is also treated as an ES Module by Node.js. This typically means adding `"type": "module"` to your project's `package.json` or using the `.mjs` file extension for the importing file.
No dependency data recorded yet.