on master help sign in
added some more of MJS, and needed my own custom makeCoords util matrix
commited58c3f2aa45857a4909e2e7e5cb850386ae6af8 authorJohn P Mayer Jr <john.p.mayer.jr@gmail.com> dateWed 18 Dec 2013, 00:39 (13 years ago) parent469be37
2 files changed+42
libraries/MJS.elm+16 libraries/Native/MJS.js+26
libraries/MJS.elm+16
@@ -15,6 +15,9 @@ v3 = Native.MJS.v3
1515v3add : V3 -> V3 -> V3
1616v3add = Native.MJS.v3add
1717
18+v3sub : V3 -> V3 -> V3
19+v3sub = Native.MJS.v3sub
20+
1821v3length : V3 -> Float
1922v3length = Native.MJS.v3length
2023
@@ -24,6 +27,12 @@ v3normalize = Native.MJS.v3normalize
2427v3scale : V3 -> Float -> V3
2528v3scale = Native.MJS.v3scale
2629
30+v3dot : V3 -> V3 -> Float
31+v3dot = Native.MJS.v3dot
32+
33+v3cross : V3 -> V3 -> V3
34+v3cross = Native.MJS.v3cross
35+
2736v3mul4x4 : M4x4 -> V3 -> V3
2837v3mul4x4 = Native.MJS.v3mul4x4
2938
@@ -36,8 +45,15 @@ m4x4mul = Native.MJS.m4x4mul
3645m4x4makeRotate : Float -> V3 -> M4x4
3746m4x4makeRotate = Native.MJS.m4x4makeRotate
3847
48+m4x4makeTranslate : V3 -> M4x4
49+m4x4makeTranslate = Native.MJS.m4x4makeTranslate
50+
3951m4x4makeLookAt : V3 -> V3 -> V3 -> M4x4
4052m4x4makeLookAt = Native.MJS.m4x4makeLookAt
4153
4254m4x4makePerspective : Float -> Float -> Float -> Float -> M4x4
4355m4x4makePerspective = Native.MJS.m4x4makePerspective
56+
57+{- Custom constructor for supplying arbitrary x,y,z axis -}
58+m4x4makeCoords : V3 -> V3 -> V3 -> M4x4
59+m4x4makeCoords = Native.MJS.m4x4makeCoords
libraries/Native/MJS.js+26
@@ -1844,6 +1844,31 @@ Elm.Native.MJS.make = function(elm) {
18441844 return r;
18451845 };
18461846
1847+ M4x4.makeCoords = function M4x4_makeCoords(vx,vy,vz) {
1848+
1849+ var r = new MJS_FLOAT_ARRAY_TYPE(16);
1850+
1851+ r[0] = vx[0];
1852+ r[1] = vx[1];
1853+ r[2] = vx[2];
1854+ r[3] = 0;
1855+ r[4] = vy[0];
1856+ r[5] = vy[1];
1857+ r[6] = vy[2];
1858+ r[7] = 0;
1859+ r[8] = vz[0];
1860+ r[9] = vz[1];
1861+ r[10] = vz[2];
1862+ r[11] = 0;
1863+ r[12] = 0;
1864+ r[13] = 0;
1865+ r[14] = 0;
1866+ r[15] = 1;
1867+
1868+ return r;
1869+
1870+ };
1871+
18471872 return {
18481873 V3: V3,
18491874 v3: F3(V3.$),
@@ -1896,6 +1921,7 @@ Elm.Native.MJS.make = function(elm) {
18961921 m4x4_transformPointFffine (m, v, r) {
18971922 m4x4_transformLineFffine(m, v, r) {
18981923 */
1924+ m4x4makeCoords: F3(M4x4.makeCoords),
18991925 };
19001926
19011927}