You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fast & small (WebAssembly) single-precision matrix4x4 library
ThreeJs-like interface
targets both modern browsers and NodeJs (UMD module)
Installation
CDN
Insert the following script before the closing body tag of your index.html file and before the other scripts :
<script src="https://cdn.jsdelivr.net/npm/ftb-matrix@0.0.9/dist/ftb-matrix.js"></script>
Via package managers
With npm :
$ npm install --save ftb-matrix
With yarn :
$ yarn add ftb-matrix
Use
Without CDN only :
importftbMatrixfrom'ftb-matrix';
Getting the matrix constructor :
const{ Mat }=awaitftbMatrix();
Examples
IMPORTANT: these matrices use the column-major convention.
101 : Getting an identity matrix
constmat=newMat();// getting the elements as a Float32Arrayconstarr=mat.elements;// freeing the memory allocated in the WebAssembly memory object.mat.free();
Enabling garbage collection awareness
const{ Mat, g }=awaitftbMatrix({ autoFree });constmat=newMat();g(_=>mat);// no need to do: mat.free();
Note: tedious but could be automated with framework like Svelte
(inserting g(_=>varialbe) at compile time?).