0.0.9 • Published 4 years ago

ftb-matrix v0.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

ftb-matrix

  • 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

  1. With npm :

    $ npm install --save ftb-matrix
  2. With yarn :

    $ yarn add ftb-matrix

Use

  1. Without CDN only :

    import ftbMatrix from 'ftb-matrix';
  2. Getting the matrix constructor :

    const { Mat } = await ftbMatrix();
    ```0.

Examples

IMPORTANT: these matrices use the column-major convention. 1. 101 : Getting an identity matrix

const mat = new Mat();
// getting the elements as a Float32Array
const arr = mat.elements;
// freeing the memory allocated in the WebAssembly memory object.
mat.free();
  1. Enabling garbage collection awareness
const { Mat, g } = await ftbMatrix({ autoFree });
const mat = new Mat();g(_=>mat);
// no need to do: mat.free();

Note: tedious but could be automated with framework like Svelte (inserting g(_=>varialbe) at compile time?).

  1. Enabling vector processing (SIMD) for even more speed (Chrome/Chromium only)
const { Mat } = await ftbMatrix({ simd: true });

Note: you can use { autodetect: true } instead of { simd: true }, for automatic fallback to standard code.

  1. More functions - see the ThreeJs documentation

Contributing

Feedbacks are welcome (email or PM, see my Twitter account):

  • Improving garbage collection awareness (is it possible to do it automatically? not sure because of closures...), by using WeakRef instead of WeakMap?
0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago