Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Array-based ES6 math classes built on the amazing gl-matrix and THREE.js math libraries.
math.gl is a JavaScript math library primarily intended to support WebGL applications. It is a generic library but was developed as a companion for luma.gl and deck.gl.
math.gl contains a set of classes (Matrix4 etc) to complement the procedural interface of gl-matrix. It also imports a limited subset of the standard gl-matrix
functions (to keep bundle size down), these can be used in parallel with the classes.
JavaScript WebGL programmers who:
Array-based
toArray
or similar.Error checking to assist in debugging.
WebGL-friendly
toString()
etc are row-major. Matrices are organized internally in the layout expected by WebGL (an array of contiguous floats in column-major order),toArray
and fromArray
functions take optional offsets allowing copying directly to and from vertex attribute arrays.Math objects are Arrays
- All math objects are subclasses of the built-in JavaScript Array
class, which means that class instances can be used wherever an array is expected. I.e. these classes are not wrappers of Array
s, they are Array
s, just with additional methods.
Focuses on needs of WebGL based applications and basic computational geometry, which includes 4x4 matrices, 2, 3 and 4 dimensional vectors and quaternions. May grow to include other classes, but is not intended to become a general math library.
gl-matrix
wrappers if additional classes are deemed valuable for the target user group.The gl-matrix docs are a good start.
The class API is intentionally designed to remain intuitively similar to the wrapped gl-matrix
procedures, usually just removing the first one or two parameters from each function (the out argument and the first input arguments, both are implictly set to this), and exposes the remaining arguments in the same order as the gl-matrix api.
Only in a few cases where gl-matrix
methods take a long list arguments (e.g. mat4.perspective
, mat4.ortho
etc) or return multiple values (e.g. quat.getAxisRotation
) do methods provide a modified API that is more natural for modern ES6 applications to use, e.g. using named parameters, or collecting all results in one returned object.
Also, for transforming vectors with matrices, the transformVector*
methods are offered in the matrix classes, instead of on the vector classes. They also (optionally) auto allocate the result vectors.
A technical caveat is that JavaScript Array
subclassing, which is fundamental to the design of this library, is only supported on "evergreen" browsers, such as Chrome, Safari, Firefox, Edge etc, i.e. no Internet Explorer < 10 (details).
If this is not acceptable, math.gl is not the right choice for you. As a fallback, you can always use gl-matrix
directly.
FAQs
Array-based 3D Math Classes optimized for WebGL applications
The npm package math.gl receives a total of 79,404 weekly downloads. As such, math.gl popularity was classified as popular.
We found that math.gl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.