M JS
3D math operations in JavaScript.
Install
In the browser just load the file m.js
in a script
tag at the bottom of its body
.
...
In node just install the package m.js
and require (or import) it in your module.
$ npm i m.js
var M = ; // or import it (e.g. in React, Vue... whatever);
Use
Demo code:
// define a matrix where to locate the vertices of a cubevar cube = ; // define the length of the sidesvar side = 100; // define the vertices from one sidecube0;cube0;cube0;cube0; // define the vertices from the opposite sidecube1;cube1;cube1;cube1; for var i in cube // translate the cube to locate its reference point (0, 0, 0) to its center M; // rotate the cube a bit in z and x axis M; M; // next render the geometry ...
SEE animated demo cube-3d.js
by running index.html
in the browser.