Skip to content
Browse files

Added mat3.determinant, mat3.inverse, and mat3.multiply

Thanks to Marius Gundersen for the suggestion!
  • Loading branch information...
1 parent 7c9e83b commit 39f181f64bed59c9a9138bab5b25a9b79f60ec00 Brandon Jones committed May 10, 2012
Showing with 132 additions and 42 deletions.
  1. +38 −37 gl-matrix-min.js
  2. +94 −5 gl-matrix.js
View
75 gl-matrix-min.js
@@ -1,39 +1,40 @@
-// gl-matrix 1.3.1 - https://github.com/toji/gl-matrix/blob/master/LICENSE.md
-(function(n,D){"object"===typeof exports?module.exports=D(global):"function"===typeof define&&define.amd?define([],function(){return D(n)}):D(n)})(this,function(n){function D(a){return s=a}function K(){return s="undefined"!==typeof Float32Array?Float32Array:Array}var E={};(function(){if("undefined"!=typeof Float32Array){var a=new Float32Array(1),b=new Int32Array(a.buffer);E.invsqrt=function(c){a[0]=c;b[0]=1597463007-(b[0]>>1);var d=a[0];return d*(1.5-0.5*c*d*d)}}else E.invsqrt=function(a){return 1/
-Math.sqrt(a)}})();var s=null;K();var r={create:function(a){var b=new s(3);a?(b[0]=a[0],b[1]=a[1],b[2]=a[2]):b[0]=b[1]=b[2]=0;return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];return b},add:function(a,b,c){if(!c||a===c)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a;c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];return c},subtract:function(a,b,c){if(!c||a===c)return a[0]-=b[0],a[1]-=b[1],a[2]-=b[2],a;c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];return c},multiply:function(a,b,c){if(!c||a===c)return a[0]*=
+// gl-matrix 1.3.2 - https://github.com/toji/gl-matrix/blob/master/LICENSE.md
+(function(q,F){"object"===typeof exports?module.exports=F(global):"function"===typeof define&&define.amd?define([],function(){return F(q)}):F(q)})(this,function(q){function F(a){return s=a}function L(){return s="undefined"!==typeof Float32Array?Float32Array:Array}var G={};(function(){if("undefined"!=typeof Float32Array){var a=new Float32Array(1),b=new Int32Array(a.buffer);G.invsqrt=function(c){a[0]=c;b[0]=1597463007-(b[0]>>1);var d=a[0];return d*(1.5-0.5*c*d*d)}}else G.invsqrt=function(a){return 1/
+Math.sqrt(a)}})();var s=null;L();var r={create:function(a){var b=new s(3);a?(b[0]=a[0],b[1]=a[1],b[2]=a[2]):b[0]=b[1]=b[2]=0;return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];return b},add:function(a,b,c){if(!c||a===c)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a;c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];return c},subtract:function(a,b,c){if(!c||a===c)return a[0]-=b[0],a[1]-=b[1],a[2]-=b[2],a;c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];return c},multiply:function(a,b,c){if(!c||a===c)return a[0]*=
b[0],a[1]*=b[1],a[2]*=b[2],a;c[0]=a[0]*b[0];c[1]=a[1]*b[1];c[2]=a[2]*b[2];return c},negate:function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];return b},scale:function(a,b,c){if(!c||a===c)return a[0]*=b,a[1]*=b,a[2]*=b,a;c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;return c},normalize:function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=Math.sqrt(c*c+d*d+e*e);if(!g)return b[0]=0,b[1]=0,b[2]=0,b;if(1===g)return b[0]=c,b[1]=d,b[2]=e,b;g=1/g;b[0]=c*g;b[1]=d*g;b[2]=e*g;return b},cross:function(a,b,c){c||(c=a);
var d=a[0],e=a[1],a=a[2],g=b[0],f=b[1],b=b[2];c[0]=e*b-a*f;c[1]=a*g-d*b;c[2]=d*f-e*g;return c},length:function(a){var b=a[0],c=a[1],a=a[2];return Math.sqrt(b*b+c*c+a*a)},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},direction:function(a,b,c){c||(c=a);var d=a[0]-b[0],e=a[1]-b[1],a=a[2]-b[2],b=Math.sqrt(d*d+e*e+a*a);if(!b)return c[0]=0,c[1]=0,c[2]=0,c;b=1/b;c[0]=d*b;c[1]=e*b;c[2]=a*b;return c},lerp:function(a,b,c,d){d||(d=a);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);d[2]=a[2]+c*(b[2]-
-a[2]);return d},dist:function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return Math.sqrt(c*c+d*d+e*e)}},L=null,t=new s(4);r.unproject=function(a,b,c,d,e){e||(e=a);L||(L=p.create());var g=L;t[0]=2*(a[0]-d[0])/d[2]-1;t[1]=2*(a[1]-d[1])/d[3]-1;t[2]=2*a[2]-1;t[3]=1;p.multiply(c,b,g);if(!p.inverse(g))return null;p.multiplyVec4(g,t);if(0===t[3])return null;e[0]=t[0]/t[3];e[1]=t[1]/t[3];e[2]=t[2]/t[3];return e};var O=r.create([1,0,0]),P=r.create([0,1,0]),Q=r.create([0,0,1]);r.rotationTo=function(a,b,
-c){c||(c=h.create());var d=r.dot(a,b),e=r.create();if(1<=d)h.set(R,c);else if(-0.999999>d)r.cross(O,a,e),1.0E-6>e.length&&r.cross(P,a,e),1.0E-6>e.length&&r.cross(Q,a,e),r.normalize(e),h.fromAxisAngle(e,Math.PI,c);else{var d=Math.sqrt(2*(1+d)),g=1/d;r.cross(a,b,e);c[0]=e[0]*g;c[1]=e[1]*g;c[2]=e[2]*g;c[3]=0.5*d;h.normalize(c)}1<c[3]?c[3]=1:-1>c[3]&&(c[3]=-1);return c};r.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+"]"};var C={create:function(a){var b=new s(9);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],
-b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8]);return b},multiplyVec2:function(a,b,c){c||(c=b);var d=b[0],b=b[1];c[0]=d*a[0]+b*a[3]+a[6];c[1]=d*a[1]+b*a[4]+a[7];return c},multiplyVec3:function(a,b,c){c||(c=b);var d=b[0],e=b[1],b=b[2];c[0]=d*a[0]+e*a[3]+b*a[6];c[1]=d*a[1]+e*a[4]+b*a[7];c[2]=d*a[2]+e*a[5]+b*a[8];return c},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return b},identity:function(a){a||(a=C.create());a[0]=1;a[1]=
-0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a},transpose:function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];a[1]=a[3];a[2]=a[6];a[3]=c;a[5]=a[7];a[6]=d;a[7]=e;return a}b[0]=a[0];b[1]=a[3];b[2]=a[6];b[3]=a[1];b[4]=a[4];b[5]=a[7];b[6]=a[2];b[7]=a[5];b[8]=a[8];return b},toMat4:function(a,b){b||(b=p.create());b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=a[8];b[9]=a[7];b[8]=a[6];b[7]=0;b[6]=a[5];b[5]=a[4];b[4]=a[3];b[3]=0;b[2]=a[2];b[1]=a[1];b[0]=a[0];return b},str:function(a){return"["+
-a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+"]"}},p={create:function(a){var b=new s(16);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15]);return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];
-return b},identity:function(a){a||(a=p.create());a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a},transpose:function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],g=a[6],f=a[7],k=a[11];a[1]=a[4];a[2]=a[8];a[3]=a[12];a[4]=c;a[6]=a[9];a[7]=a[13];a[8]=d;a[9]=g;a[11]=a[14];a[12]=e;a[13]=f;a[14]=k;return a}b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];
-b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b},determinant:function(a){var b=a[0],c=a[1],d=a[2],e=a[3],g=a[4],f=a[5],k=a[6],j=a[7],i=a[8],m=a[9],l=a[10],G=a[11],q=a[12],o=a[13],h=a[14],a=a[15];return q*m*k*e-i*o*k*e-q*f*l*e+g*o*l*e+i*f*h*e-g*m*h*e-q*m*d*j+i*o*d*j+q*c*l*j-b*o*l*j-i*c*h*j+b*m*h*j+q*f*d*G-g*o*d*G-q*c*k*G+b*o*k*G+g*c*h*G-b*f*h*G-i*f*d*a+g*m*d*a+i*c*k*a-b*m*k*a-g*c*l*a+b*f*l*a},inverse:function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=a[4],k=a[5],j=a[6],i=a[7],m=a[8],l=
-a[9],h=a[10],q=a[11],o=a[12],H=a[13],I=a[14],p=a[15],n=c*k-d*f,r=c*j-e*f,v=c*i-g*f,w=d*j-e*k,x=d*i-g*k,y=e*i-g*j,z=m*H-l*o,A=m*I-h*o,B=m*p-q*o,s=l*I-h*H,t=l*p-q*H,F=h*p-q*I,u=n*F-r*t+v*s+w*B-x*A+y*z;if(!u)return null;u=1/u;b[0]=(k*F-j*t+i*s)*u;b[1]=(-d*F+e*t-g*s)*u;b[2]=(H*y-I*x+p*w)*u;b[3]=(-l*y+h*x-q*w)*u;b[4]=(-f*F+j*B-i*A)*u;b[5]=(c*F-e*B+g*A)*u;b[6]=(-o*y+I*v-p*r)*u;b[7]=(m*y-h*v+q*r)*u;b[8]=(f*t-k*B+i*z)*u;b[9]=(-c*t+d*B-g*z)*u;b[10]=(o*x-H*v+p*n)*u;b[11]=(-m*x+l*v-q*n)*u;b[12]=(-f*s+k*A-j*
-z)*u;b[13]=(c*s-d*A+e*z)*u;b[14]=(-o*w+H*r-I*n)*u;b[15]=(m*w-l*r+h*n)*u;return b},toRotationMat:function(a,b){b||(b=p.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},toMat3:function(a,b){b||(b=C.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[4];b[4]=a[5];b[5]=a[6];b[6]=a[8];b[7]=a[9];b[8]=a[10];return b},toInverseMat3:function(a,b){var c=a[0],d=a[1],e=a[2],g=a[4],f=a[5],
-k=a[6],j=a[8],i=a[9],m=a[10],l=m*f-k*i,h=-m*g+k*j,q=i*g-f*j,o=c*l+d*h+e*q;if(!o)return null;o=1/o;b||(b=C.create());b[0]=l*o;b[1]=(-m*d+e*i)*o;b[2]=(k*d-e*f)*o;b[3]=h*o;b[4]=(m*c-e*j)*o;b[5]=(-k*c+e*g)*o;b[6]=q*o;b[7]=(-i*c+d*j)*o;b[8]=(f*c-d*g)*o;return b},multiply:function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],f=a[3],k=a[4],j=a[5],i=a[6],m=a[7],l=a[8],h=a[9],q=a[10],o=a[11],p=a[12],n=a[13],r=a[14],a=a[15],s=b[0],t=b[1],v=b[2],w=b[3],x=b[4],y=b[5],z=b[6],A=b[7],B=b[8],C=b[9],D=b[10],F=b[11],u=
-b[12],E=b[13],J=b[14],b=b[15];c[0]=s*d+t*k+v*l+w*p;c[1]=s*e+t*j+v*h+w*n;c[2]=s*g+t*i+v*q+w*r;c[3]=s*f+t*m+v*o+w*a;c[4]=x*d+y*k+z*l+A*p;c[5]=x*e+y*j+z*h+A*n;c[6]=x*g+y*i+z*q+A*r;c[7]=x*f+y*m+z*o+A*a;c[8]=B*d+C*k+D*l+F*p;c[9]=B*e+C*j+D*h+F*n;c[10]=B*g+C*i+D*q+F*r;c[11]=B*f+C*m+D*o+F*a;c[12]=u*d+E*k+J*l+b*p;c[13]=u*e+E*j+J*h+b*n;c[14]=u*g+E*i+J*q+b*r;c[15]=u*f+E*m+J*o+b*a;return c},multiplyVec3:function(a,b,c){c||(c=b);var d=b[0],e=b[1],b=b[2];c[0]=a[0]*d+a[4]*e+a[8]*b+a[12];c[1]=a[1]*d+a[5]*e+a[9]*
-b+a[13];c[2]=a[2]*d+a[6]*e+a[10]*b+a[14];return c},multiplyVec4:function(a,b,c){c||(c=b);var d=b[0],e=b[1],g=b[2],b=b[3];c[0]=a[0]*d+a[4]*e+a[8]*g+a[12]*b;c[1]=a[1]*d+a[5]*e+a[9]*g+a[13]*b;c[2]=a[2]*d+a[6]*e+a[10]*g+a[14]*b;c[3]=a[3]*d+a[7]*e+a[11]*g+a[15]*b;return c},translate:function(a,b,c){var d=b[0],e=b[1],b=b[2],g,f,k,j,i,m,l,h,q,o,p,n;if(!c||a===c)return a[12]=a[0]*d+a[4]*e+a[8]*b+a[12],a[13]=a[1]*d+a[5]*e+a[9]*b+a[13],a[14]=a[2]*d+a[6]*e+a[10]*b+a[14],a[15]=a[3]*d+a[7]*e+a[11]*b+a[15],a;g=
-a[0];f=a[1];k=a[2];j=a[3];i=a[4];m=a[5];l=a[6];h=a[7];q=a[8];o=a[9];p=a[10];n=a[11];c[0]=g;c[1]=f;c[2]=k;c[3]=j;c[4]=i;c[5]=m;c[6]=l;c[7]=h;c[8]=q;c[9]=o;c[10]=p;c[11]=n;c[12]=g*d+i*e+q*b+a[12];c[13]=f*d+m*e+o*b+a[13];c[14]=k*d+l*e+p*b+a[14];c[15]=j*d+h*e+n*b+a[15];return c},scale:function(a,b,c){var d=b[0],e=b[1],b=b[2];if(!c||a===c)return a[0]*=d,a[1]*=d,a[2]*=d,a[3]*=d,a[4]*=e,a[5]*=e,a[6]*=e,a[7]*=e,a[8]*=b,a[9]*=b,a[10]*=b,a[11]*=b,a;c[0]=a[0]*d;c[1]=a[1]*d;c[2]=a[2]*d;c[3]=a[3]*d;c[4]=a[4]*
-e;c[5]=a[5]*e;c[6]=a[6]*e;c[7]=a[7]*e;c[8]=a[8]*b;c[9]=a[9]*b;c[10]=a[10]*b;c[11]=a[11]*b;c[12]=a[12];c[13]=a[13];c[14]=a[14];c[15]=a[15];return c},rotate:function(a,b,c,d){var e=c[0],g=c[1],c=c[2],f=Math.sqrt(e*e+g*g+c*c),k,j,i,m,l,h,q,o,p,n,r,s,t,v,w,x,y,z,A,B;if(!f)return null;1!==f&&(f=1/f,e*=f,g*=f,c*=f);k=Math.sin(b);j=Math.cos(b);i=1-j;b=a[0];f=a[1];m=a[2];l=a[3];h=a[4];q=a[5];o=a[6];p=a[7];n=a[8];r=a[9];s=a[10];t=a[11];v=e*e*i+j;w=g*e*i+c*k;x=c*e*i-g*k;y=e*g*i-c*k;z=g*g*i+j;A=c*g*i+e*k;B=
-e*c*i+g*k;e=g*c*i-e*k;g=c*c*i+j;d?a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]):d=a;d[0]=b*v+h*w+n*x;d[1]=f*v+q*w+r*x;d[2]=m*v+o*w+s*x;d[3]=l*v+p*w+t*x;d[4]=b*y+h*z+n*A;d[5]=f*y+q*z+r*A;d[6]=m*y+o*z+s*A;d[7]=l*y+p*z+t*A;d[8]=b*B+h*e+n*g;d[9]=f*B+q*e+r*g;d[10]=m*B+o*e+s*g;d[11]=l*B+p*e+t*g;return d},rotateX:function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[4],g=a[5],f=a[6],k=a[7],j=a[8],i=a[9],m=a[10],h=a[11];c?a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=
-a[14],c[15]=a[15]):c=a;c[4]=e*b+j*d;c[5]=g*b+i*d;c[6]=f*b+m*d;c[7]=k*b+h*d;c[8]=e*-d+j*b;c[9]=g*-d+i*b;c[10]=f*-d+m*b;c[11]=k*-d+h*b;return c},rotateY:function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[0],g=a[1],f=a[2],k=a[3],j=a[8],i=a[9],m=a[10],h=a[11];c?a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+j*-d;c[1]=g*b+i*-d;c[2]=f*b+m*-d;c[3]=k*b+h*-d;c[8]=e*d+j*b;c[9]=g*d+i*b;c[10]=f*d+m*b;c[11]=k*d+h*b;return c},rotateZ:function(a,b,
-c){var d=Math.sin(b),b=Math.cos(b),e=a[0],g=a[1],f=a[2],k=a[3],j=a[4],i=a[5],h=a[6],l=a[7];c?a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+j*d;c[1]=g*b+i*d;c[2]=f*b+h*d;c[3]=k*b+l*d;c[4]=e*-d+j*b;c[5]=g*-d+i*b;c[6]=f*-d+h*b;c[7]=k*-d+l*b;return c},frustum:function(a,b,c,d,e,g,f){f||(f=p.create());var k=b-a,j=d-c,i=g-e;f[0]=2*e/k;f[1]=0;f[2]=0;f[3]=0;f[4]=0;f[5]=2*e/j;f[6]=0;f[7]=0;f[8]=(b+a)/k;f[9]=(d+c)/j;f[10]=-(g+e)/i;f[11]=-1;
-f[12]=0;f[13]=0;f[14]=-(2*g*e)/i;f[15]=0;return f},perspective:function(a,b,c,d,e){a=c*Math.tan(a*Math.PI/360);b*=a;return p.frustum(-b,b,-a,a,c,d,e)},ortho:function(a,b,c,d,e,g,f){f||(f=p.create());var k=b-a,j=d-c,i=g-e;f[0]=2/k;f[1]=0;f[2]=0;f[3]=0;f[4]=0;f[5]=2/j;f[6]=0;f[7]=0;f[8]=0;f[9]=0;f[10]=-2/i;f[11]=0;f[12]=-(a+b)/k;f[13]=-(d+c)/j;f[14]=-(g+e)/i;f[15]=1;return f},lookAt:function(a,b,c,d){d||(d=p.create());var e,g,f,k,j,i,h,l,n=a[0],q=a[1],a=a[2];f=c[0];k=c[1];g=c[2];h=b[0];c=b[1];e=b[2];
-if(n===h&&q===c&&a===e)return p.identity(d);b=n-h;c=q-c;h=a-e;l=1/Math.sqrt(b*b+c*c+h*h);b*=l;c*=l;h*=l;e=k*h-g*c;g=g*b-f*h;f=f*c-k*b;(l=Math.sqrt(e*e+g*g+f*f))?(l=1/l,e*=l,g*=l,f*=l):f=g=e=0;k=c*f-h*g;j=h*e-b*f;i=b*g-c*e;(l=Math.sqrt(k*k+j*j+i*i))?(l=1/l,k*=l,j*=l,i*=l):i=j=k=0;d[0]=e;d[1]=k;d[2]=b;d[3]=0;d[4]=g;d[5]=j;d[6]=c;d[7]=0;d[8]=f;d[9]=i;d[10]=h;d[11]=0;d[12]=-(e*n+g*q+f*a);d[13]=-(k*n+j*q+i*a);d[14]=-(b*n+c*q+h*a);d[15]=1;return d},fromRotationTranslation:function(a,b,c){c||(c=p.create());
-var d=a[0],e=a[1],g=a[2],f=a[3],k=d+d,h=e+e,i=g+g,a=d*k,m=d*h,d=d*i,l=e*h,e=e*i,g=g*i,k=f*k,h=f*h,f=f*i;c[0]=1-(l+g);c[1]=m+f;c[2]=d-h;c[3]=0;c[4]=m-f;c[5]=1-(a+g);c[6]=e+k;c[7]=0;c[8]=d+h;c[9]=e-k;c[10]=1-(a+l);c[11]=0;c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+"]"}},h={create:function(a){var b=new s(4);
-a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]);return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},identity:function(a){a||(a=h.create());a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a}},R=h.identity();h.calculateW=function(a,b){var c=a[0],d=a[1],e=a[2];if(!b||a===b)return a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a;b[0]=c;b[1]=d;b[2]=e;b[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e));return b};h.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};h.inverse=function(a,b){var c=
-a[0],d=a[1],e=a[2],g=a[3],c=(c=c*c+d*d+e*e+g*g)?1/c:0;if(!b||a===b)return a[0]*=-c,a[1]*=-c,a[2]*=-c,a[3]*=c,a;b[0]=-a[0]*c;b[1]=-a[1]*c;b[2]=-a[2]*c;b[3]=a[3]*c;return b};h.conjugate=function(a,b){if(!b||a===b)return a[0]*=-1,a[1]*=-1,a[2]*=-1,a;b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b};h.length=function(a){var b=a[0],c=a[1],d=a[2],a=a[3];return Math.sqrt(b*b+c*c+d*d+a*a)};h.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=Math.sqrt(c*c+d*d+e*e+g*g);if(0===f)return b[0]=
-0,b[1]=0,b[2]=0,b[3]=0,b;f=1/f;b[0]=c*f;b[1]=d*f;b[2]=e*f;b[3]=g*f;return b};h.add=function(a,b,c){if(!c||a===c)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a[3]+=b[3],a;c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];return c};h.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3],f=b[0],h=b[1],j=b[2],b=b[3];c[0]=d*b+a*f+e*j-g*h;c[1]=e*b+a*h+g*f-d*j;c[2]=g*b+a*j+d*h-e*f;c[3]=a*b-d*f-e*h-g*j;return c};h.multiplyVec3=function(a,b,c){c||(c=b);var d=b[0],e=b[1],g=b[2],b=a[0],f=a[1],
-h=a[2],a=a[3],j=a*d+f*g-h*e,i=a*e+h*d-b*g,m=a*g+b*e-f*d,d=-b*d-f*e-h*g;c[0]=j*a+d*-b+i*-h-m*-f;c[1]=i*a+d*-f+m*-b-j*-h;c[2]=m*a+d*-h+j*-f-i*-b;return c};h.scale=function(a,b,c){if(!c||a===c)return a[0]*=b,a[1]*=b,a[2]*=b,a[3]*=b,a;c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;return c};h.toMat3=function(a,b){b||(b=C.create());var c=a[0],d=a[1],e=a[2],g=a[3],f=c+c,h=d+d,j=e+e,i=c*f,m=c*h,c=c*j,l=d*h,d=d*j,e=e*j,f=g*f,h=g*h,g=g*j;b[0]=1-(l+e);b[1]=m+g;b[2]=c-h;b[3]=m-g;b[4]=1-(i+e);b[5]=d+f;b[6]=
-c+h;b[7]=d-f;b[8]=1-(i+l);return b};h.toMat4=function(a,b){b||(b=p.create());var c=a[0],d=a[1],e=a[2],g=a[3],f=c+c,h=d+d,j=e+e,i=c*f,m=c*h,c=c*j,l=d*h,d=d*j,e=e*j,f=g*f,h=g*h,g=g*j;b[0]=1-(l+e);b[1]=m+g;b[2]=c-h;b[3]=0;b[4]=m-g;b[5]=1-(i+e);b[6]=d+f;b[7]=0;b[8]=c+h;b[9]=d-f;b[10]=1-(i+l);b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};h.slerp=function(a,b,c,d){d||(d=a);var e=a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3],g,f;if(1<=Math.abs(e))return d!==a&&(d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=a[3]),d;g=
-Math.acos(e);f=Math.sqrt(1-e*e);if(0.001>Math.abs(f))return d[0]=0.5*a[0]+0.5*b[0],d[1]=0.5*a[1]+0.5*b[1],d[2]=0.5*a[2]+0.5*b[2],d[3]=0.5*a[3]+0.5*b[3],d;e=Math.sin((1-c)*g)/f;c=Math.sin(c*g)/f;d[0]=a[0]*e+b[0]*c;d[1]=a[1]*e+b[1]*c;d[2]=a[2]*e+b[2]*c;d[3]=a[3]*e+b[3]*c;return d};h.fromRotationMatrix=function(a,b){b||(b=h.create());var c=a[0]+a[4]+a[8],d;if(0<c)d=Math.sqrt(c+1),b[3]=0.5*d,d=0.5/d,b[0]=(a[7]-a[5])*d,b[1]=(a[2]-a[6])*d,b[2]=(a[3]-a[1])*d;else{d=h.fromRotationMatrix.s_iNext=h.fromRotationMatrix.s_iNext||
-[1,2,0];c=0;a[4]>a[0]&&(c=1);a[8]>a[3*c+c]&&(c=2);var e=d[c],g=d[e];d=Math.sqrt(a[3*c+c]-a[3*e+e]-a[3*g+g]+1);b[c]=0.5*d;d=0.5/d;b[3]=(a[3*g+e]-a[3*e+g])*d;b[e]=(a[3*e+c]+a[3*c+e])*d;b[g]=(a[3*g+c]+a[3*c+g])*d}return b};C.toQuat4=h.fromRotationMatrix;(function(){var a=C.create();h.fromAxes=function(b,c,d,e){a[0]=c[0];a[3]=c[1];a[6]=c[2];a[1]=d[0];a[4]=d[1];a[7]=d[2];a[2]=b[0];a[5]=b[1];a[8]=b[2];return h.fromRotationMatrix(a,e)}})();h.identity=function(a){a||(a=h.create());a[0]=0;a[1]=0;a[2]=0;a[3]=
-1;return a};h.fromAngleAxis=function(a,b,c){c||(c=h.create());var a=0.5*a,d=Math.sin(a);c[3]=Math.cos(a);c[0]=d*b[0];c[1]=d*b[1];c[2]=d*b[2];return c};h.toAngleAxis=function(a,b){b||(b=a);var c=a[0]*a[0]+a[1]*a[1]+a[2]*a[2];0<c?(b[3]=2*Math.acos(a[3]),c=E.invsqrt(c),b[0]=a[0]*c,b[1]=a[1]*c,b[2]=a[2]*c):(b[3]=0,b[0]=1,b[1]=0,b[2]=0);return b};h.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"};var N={create:function(a){var b=new s(2);a?(b[0]=a[0],b[1]=a[1]):(b[0]=0,b[1]=0);return b},
-add:function(a,b,c){c||(c=b);c[0]=a[0]+b[0];c[1]=a[1]+b[1];return c},subtract:function(a,b,c){c||(c=b);c[0]=a[0]-b[0];c[1]=a[1]-b[1];return c},multiply:function(a,b,c){c||(c=b);c[0]=a[0]*b[0];c[1]=a[1]*b[1];return c},divide:function(a,b,c){c||(c=b);c[0]=a[0]/b[0];c[1]=a[1]/b[1];return c},scale:function(a,b,c){c||(c=a);c[0]=a[0]*b;c[1]=a[1]*b;return c},dist:function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},set:function(a,b){b[0]=a[0];b[1]=a[1];return b},negate:function(a,b){b||(b=
-a);b[0]=-a[0];b[1]=-a[1];return b},normalize:function(a,b){b||(b=a);var c=a[0]*a[0]+a[1]*a[1];0<c?(c=Math.sqrt(c),b[0]=a[0]/c,b[1]=a[1]/c):b[0]=b[1]=0;return b},cross:function(a,b,c){a=a[0]*b[1]-a[1]*b[0];if(!c)return a;c[0]=c[1]=0;c[2]=a;return c},length:function(a){var b=a[0],a=a[1];return Math.sqrt(b*b+a*a)},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]},direction:function(a,b,c){c||(c=a);var d=a[0]-b[0],a=a[1]-b[1],b=d*d+a*a;if(!b)return c[0]=0,c[1]=0,c[2]=0,c;b=1/Math.sqrt(b);c[0]=d*b;c[1]=a*
-b;return c},lerp:function(a,b,c,d){d||(d=a);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);return d},str:function(a){return"["+a[0]+", "+a[1]+"]"}},M={create:function(a){var b=new s(4);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]);return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},identity:function(a){a||(a=M.create());a[0]=1;a[1]=0;a[2]=0;a[3]=1;return a},transpose:function(a,b){if(!b||a===b){var c=a[1];a[1]=a[2];a[2]=c;return a}b[0]=a[0];b[1]=a[2];b[2]=a[1];b[3]=a[3];
-return b},determinant:function(a){return a[0]*a[3]-a[2]*a[1]},inverse:function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=c*g-e*d;if(!f)return null;f=1/f;b[0]=g*f;b[1]=-d*f;b[2]=-e*f;b[3]=c*f;return b},multiply:function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3];c[0]=d*b[0]+e*b[2];c[1]=d*b[1]+e*b[3];c[2]=g*b[0]+a*b[2];c[3]=g*b[1]+a*b[3];return c},rotate:function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3],f=Math.sin(b),b=Math.cos(b);c[0]=d*b+e*f;c[1]=d*-f+e*b;c[2]=g*b+a*f;c[3]=g*-f+
-a*b;return c},multiplyVec2:function(a,b,c){c||(c=b);var d=b[0],b=b[1];c[0]=d*a[0]+b*a[1];c[1]=d*a[2]+b*a[3];return c},scale:function(a,b,c){c||(c=a);var d=a[1],e=a[2],g=a[3],f=b[0],b=b[1];c[0]=a[0]*f;c[1]=d*b;c[2]=e*f;c[3]=g*b;return c},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"}};n&&(n.glMatrixArrayType=s,n.MatrixArray=s,n.setMatrixArrayType=D,n.determineMatrixArrayType=K,n.glMath=E,n.vec2=N,n.vec3=r,n.mat2=M,n.mat3=C,n.mat4=p,n.quat4=h);return{glMatrixArrayType:s,MatrixArray:s,
-setMatrixArrayType:D,determineMatrixArrayType:K,glMath:E,vec2:N,vec3:r,mat2:M,mat3:C,mat4:p,quat4:h}});
+a[2]);return d},dist:function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return Math.sqrt(c*c+d*d+e*e)}},M=null,u=new s(4);r.unproject=function(a,b,c,d,e){e||(e=a);M||(M=p.create());var g=M;u[0]=2*(a[0]-d[0])/d[2]-1;u[1]=2*(a[1]-d[1])/d[3]-1;u[2]=2*a[2]-1;u[3]=1;p.multiply(c,b,g);if(!p.inverse(g))return null;p.multiplyVec4(g,u);if(0===u[3])return null;e[0]=u[0]/u[3];e[1]=u[1]/u[3];e[2]=u[2]/u[3];return e};var P=r.create([1,0,0]),Q=r.create([0,1,0]),R=r.create([0,0,1]);r.rotationTo=function(a,b,
+c){c||(c=j.create());var d=r.dot(a,b),e=r.create();if(1<=d)j.set(S,c);else if(-0.999999>d)r.cross(P,a,e),1.0E-6>e.length&&r.cross(Q,a,e),1.0E-6>e.length&&r.cross(R,a,e),r.normalize(e),j.fromAxisAngle(e,Math.PI,c);else{var d=Math.sqrt(2*(1+d)),g=1/d;r.cross(a,b,e);c[0]=e[0]*g;c[1]=e[1]*g;c[2]=e[2]*g;c[3]=0.5*d;j.normalize(c)}1<c[3]?c[3]=1:-1>c[3]&&(c[3]=-1);return c};r.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+"]"};var D={create:function(a){var b=new s(9);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],
+b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8]);return b},determinant:function(a){var b=a[3],c=a[4],d=a[5],e=a[6],g=a[7],f=a[8];return a[0]*(f*c-d*g)+a[1]*(-f*b+d*e)+a[2]*(g*b-c*e)},inverse:function(a,b){var c=a[0],d=a[1],e=a[2],g=a[3],f=a[4],h=a[5],i=a[6],k=a[7],m=a[8],l=m*f-h*k,E=-m*g+h*i,o=k*g-f*i,n=c*l+d*E+e*o;if(!n)return null;n=1/n;b||(b=D.create());b[0]=l*n;b[1]=(-m*d+e*k)*n;b[2]=(h*d-e*f)*n;b[3]=E*n;b[4]=(m*c-e*i)*n;b[5]=(-h*c+e*g)*n;b[6]=o*n;b[7]=(-k*c+d*i)*n;b[8]=(f*c-d*g)*
+n;return b},multiply:function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],f=a[3],h=a[4],i=a[5],k=a[6],m=a[7],a=a[8],l=b[0],E=b[1],o=b[2],n=b[3],j=b[4],C=b[5],H=b[6],I=b[7],b=b[8];c[0]=l*d+E*f+o*k;c[1]=l*e+E*h+o*m;c[2]=l*g+E*i+o*a;c[3]=n*d+j*f+C*k;c[4]=n*e+j*h+C*m;c[5]=n*g+j*i+C*a;c[6]=H*d+I*f+b*k;c[7]=H*e+I*h+b*m;c[8]=H*g+I*i+b*a;return c},multiplyVec2:function(a,b,c){c||(c=b);var d=b[0],b=b[1];c[0]=d*a[0]+b*a[3]+a[6];c[1]=d*a[1]+b*a[4]+a[7];return c},multiplyVec3:function(a,b,c){c||(c=b);var d=b[0],
+e=b[1],b=b[2];c[0]=d*a[0]+e*a[3]+b*a[6];c[1]=d*a[1]+e*a[4]+b*a[7];c[2]=d*a[2]+e*a[5]+b*a[8];return c},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return b},identity:function(a){a||(a=D.create());a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a},transpose:function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];a[1]=a[3];a[2]=a[6];a[3]=c;a[5]=a[7];a[6]=d;a[7]=e;return a}b[0]=a[0];b[1]=a[3];b[2]=a[6];b[3]=a[1];b[4]=a[4];
+b[5]=a[7];b[6]=a[2];b[7]=a[5];b[8]=a[8];return b},toMat4:function(a,b){b||(b=p.create());b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=a[8];b[9]=a[7];b[8]=a[6];b[7]=0;b[6]=a[5];b[5]=a[4];b[4]=a[3];b[3]=0;b[2]=a[2];b[1]=a[1];b[0]=a[0];return b},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+"]"}},p={create:function(a){var b=new s(16);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],
+b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15]);return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b},identity:function(a){a||(a=p.create());a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a},transpose:function(a,b){if(!b||a===b){var c=a[1],d=
+a[2],e=a[3],g=a[6],f=a[7],h=a[11];a[1]=a[4];a[2]=a[8];a[3]=a[12];a[4]=c;a[6]=a[9];a[7]=a[13];a[8]=d;a[9]=g;a[11]=a[14];a[12]=e;a[13]=f;a[14]=h;return a}b[0]=a[0];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=a[1];b[5]=a[5];b[6]=a[9];b[7]=a[13];b[8]=a[2];b[9]=a[6];b[10]=a[10];b[11]=a[14];b[12]=a[3];b[13]=a[7];b[14]=a[11];b[15]=a[15];return b},determinant:function(a){var b=a[0],c=a[1],d=a[2],e=a[3],g=a[4],f=a[5],h=a[6],i=a[7],k=a[8],m=a[9],l=a[10],E=a[11],o=a[12],n=a[13],j=a[14],a=a[15];return o*m*h*e-k*n*h*
+e-o*f*l*e+g*n*l*e+k*f*j*e-g*m*j*e-o*m*d*i+k*n*d*i+o*c*l*i-b*n*l*i-k*c*j*i+b*m*j*i+o*f*d*E-g*n*d*E-o*c*h*E+b*n*h*E+g*c*j*E-b*f*j*E-k*f*d*a+g*m*d*a+k*c*h*a-b*m*h*a-g*c*l*a+b*f*l*a},inverse:function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=a[4],h=a[5],i=a[6],k=a[7],m=a[8],l=a[9],j=a[10],o=a[11],n=a[12],J=a[13],C=a[14],H=a[15],I=c*h-d*f,p=c*i-e*f,v=c*k-g*f,w=d*i-e*h,x=d*k-g*h,y=e*k-g*i,z=m*J-l*n,A=m*C-j*n,B=m*H-o*n,q=l*C-j*J,r=l*H-o*J,s=j*H-o*C,t=I*s-p*r+v*q+w*B-x*A+y*z;if(!t)return null;t=1/t;
+b[0]=(h*s-i*r+k*q)*t;b[1]=(-d*s+e*r-g*q)*t;b[2]=(J*y-C*x+H*w)*t;b[3]=(-l*y+j*x-o*w)*t;b[4]=(-f*s+i*B-k*A)*t;b[5]=(c*s-e*B+g*A)*t;b[6]=(-n*y+C*v-H*p)*t;b[7]=(m*y-j*v+o*p)*t;b[8]=(f*r-h*B+k*z)*t;b[9]=(-c*r+d*B-g*z)*t;b[10]=(n*x-J*v+H*I)*t;b[11]=(-m*x+l*v-o*I)*t;b[12]=(-f*q+h*A-i*z)*t;b[13]=(c*q-d*A+e*z)*t;b[14]=(-n*w+J*p-C*I)*t;b[15]=(m*w-l*p+j*I)*t;return b},toRotationMat:function(a,b){b||(b=p.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=
+a[9];b[10]=a[10];b[11]=a[11];b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b},toMat3:function(a,b){b||(b=D.create());b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[4];b[4]=a[5];b[5]=a[6];b[6]=a[8];b[7]=a[9];b[8]=a[10];return b},toInverseMat3:function(a,b){var c=a[0],d=a[1],e=a[2],g=a[4],f=a[5],h=a[6],i=a[8],k=a[9],m=a[10],l=m*f-h*k,j=-m*g+h*i,o=k*g-f*i,n=c*l+d*j+e*o;if(!n)return null;n=1/n;b||(b=D.create());b[0]=l*n;b[1]=(-m*d+e*k)*n;b[2]=(h*d-e*f)*n;b[3]=j*n;b[4]=(m*c-e*i)*n;b[5]=(-h*c+e*g)*n;b[6]=o*n;b[7]=(-k*c+
+d*i)*n;b[8]=(f*c-d*g)*n;return b},multiply:function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],f=a[3],h=a[4],i=a[5],k=a[6],m=a[7],l=a[8],j=a[9],o=a[10],n=a[11],p=a[12],C=a[13],q=a[14],a=a[15],r=b[0],s=b[1],v=b[2],w=b[3],x=b[4],y=b[5],z=b[6],A=b[7],B=b[8],u=b[9],D=b[10],F=b[11],t=b[12],G=b[13],K=b[14],b=b[15];c[0]=r*d+s*h+v*l+w*p;c[1]=r*e+s*i+v*j+w*C;c[2]=r*g+s*k+v*o+w*q;c[3]=r*f+s*m+v*n+w*a;c[4]=x*d+y*h+z*l+A*p;c[5]=x*e+y*i+z*j+A*C;c[6]=x*g+y*k+z*o+A*q;c[7]=x*f+y*m+z*n+A*a;c[8]=B*d+u*h+D*l+F*p;c[9]=
+B*e+u*i+D*j+F*C;c[10]=B*g+u*k+D*o+F*q;c[11]=B*f+u*m+D*n+F*a;c[12]=t*d+G*h+K*l+b*p;c[13]=t*e+G*i+K*j+b*C;c[14]=t*g+G*k+K*o+b*q;c[15]=t*f+G*m+K*n+b*a;return c},multiplyVec3:function(a,b,c){c||(c=b);var d=b[0],e=b[1],b=b[2];c[0]=a[0]*d+a[4]*e+a[8]*b+a[12];c[1]=a[1]*d+a[5]*e+a[9]*b+a[13];c[2]=a[2]*d+a[6]*e+a[10]*b+a[14];return c},multiplyVec4:function(a,b,c){c||(c=b);var d=b[0],e=b[1],g=b[2],b=b[3];c[0]=a[0]*d+a[4]*e+a[8]*g+a[12]*b;c[1]=a[1]*d+a[5]*e+a[9]*g+a[13]*b;c[2]=a[2]*d+a[6]*e+a[10]*g+a[14]*b;
+c[3]=a[3]*d+a[7]*e+a[11]*g+a[15]*b;return c},translate:function(a,b,c){var d=b[0],e=b[1],b=b[2],g,f,h,i,k,m,l,j,o,n,p,q;if(!c||a===c)return a[12]=a[0]*d+a[4]*e+a[8]*b+a[12],a[13]=a[1]*d+a[5]*e+a[9]*b+a[13],a[14]=a[2]*d+a[6]*e+a[10]*b+a[14],a[15]=a[3]*d+a[7]*e+a[11]*b+a[15],a;g=a[0];f=a[1];h=a[2];i=a[3];k=a[4];m=a[5];l=a[6];j=a[7];o=a[8];n=a[9];p=a[10];q=a[11];c[0]=g;c[1]=f;c[2]=h;c[3]=i;c[4]=k;c[5]=m;c[6]=l;c[7]=j;c[8]=o;c[9]=n;c[10]=p;c[11]=q;c[12]=g*d+k*e+o*b+a[12];c[13]=f*d+m*e+n*b+a[13];c[14]=
+h*d+l*e+p*b+a[14];c[15]=i*d+j*e+q*b+a[15];return c},scale:function(a,b,c){var d=b[0],e=b[1],b=b[2];if(!c||a===c)return a[0]*=d,a[1]*=d,a[2]*=d,a[3]*=d,a[4]*=e,a[5]*=e,a[6]*=e,a[7]*=e,a[8]*=b,a[9]*=b,a[10]*=b,a[11]*=b,a;c[0]=a[0]*d;c[1]=a[1]*d;c[2]=a[2]*d;c[3]=a[3]*d;c[4]=a[4]*e;c[5]=a[5]*e;c[6]=a[6]*e;c[7]=a[7]*e;c[8]=a[8]*b;c[9]=a[9]*b;c[10]=a[10]*b;c[11]=a[11]*b;c[12]=a[12];c[13]=a[13];c[14]=a[14];c[15]=a[15];return c},rotate:function(a,b,c,d){var e=c[0],g=c[1],c=c[2],f=Math.sqrt(e*e+g*g+c*c),h,
+i,k,m,l,j,o,n,p,q,r,s,u,v,w,x,y,z,A,B;if(!f)return null;1!==f&&(f=1/f,e*=f,g*=f,c*=f);h=Math.sin(b);i=Math.cos(b);k=1-i;b=a[0];f=a[1];m=a[2];l=a[3];j=a[4];o=a[5];n=a[6];p=a[7];q=a[8];r=a[9];s=a[10];u=a[11];v=e*e*k+i;w=g*e*k+c*h;x=c*e*k-g*h;y=e*g*k-c*h;z=g*g*k+i;A=c*g*k+e*h;B=e*c*k+g*h;e=g*c*k-e*h;g=c*c*k+i;d?a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]):d=a;d[0]=b*v+j*w+q*x;d[1]=f*v+o*w+r*x;d[2]=m*v+n*w+s*x;d[3]=l*v+p*w+u*x;d[4]=b*y+j*z+q*A;d[5]=f*y+o*z+r*A;d[6]=m*y+n*z+s*A;d[7]=l*y+p*
+z+u*A;d[8]=b*B+j*e+q*g;d[9]=f*B+o*e+r*g;d[10]=m*B+n*e+s*g;d[11]=l*B+p*e+u*g;return d},rotateX:function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[4],g=a[5],f=a[6],h=a[7],i=a[8],k=a[9],m=a[10],l=a[11];c?a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[4]=e*b+i*d;c[5]=g*b+k*d;c[6]=f*b+m*d;c[7]=h*b+l*d;c[8]=e*-d+i*b;c[9]=g*-d+k*b;c[10]=f*-d+m*b;c[11]=h*-d+l*b;return c},rotateY:function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[0],g=a[1],f=a[2],h=
+a[3],i=a[8],k=a[9],m=a[10],l=a[11];c?a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+i*-d;c[1]=g*b+k*-d;c[2]=f*b+m*-d;c[3]=h*b+l*-d;c[8]=e*d+i*b;c[9]=g*d+k*b;c[10]=f*d+m*b;c[11]=h*d+l*b;return c},rotateZ:function(a,b,c){var d=Math.sin(b),b=Math.cos(b),e=a[0],g=a[1],f=a[2],h=a[3],i=a[4],k=a[5],m=a[6],l=a[7];c?a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]):c=a;c[0]=e*b+i*d;c[1]=g*b+k*
+d;c[2]=f*b+m*d;c[3]=h*b+l*d;c[4]=e*-d+i*b;c[5]=g*-d+k*b;c[6]=f*-d+m*b;c[7]=h*-d+l*b;return c},frustum:function(a,b,c,d,e,g,f){f||(f=p.create());var h=b-a,i=d-c,k=g-e;f[0]=2*e/h;f[1]=0;f[2]=0;f[3]=0;f[4]=0;f[5]=2*e/i;f[6]=0;f[7]=0;f[8]=(b+a)/h;f[9]=(d+c)/i;f[10]=-(g+e)/k;f[11]=-1;f[12]=0;f[13]=0;f[14]=-(2*g*e)/k;f[15]=0;return f},perspective:function(a,b,c,d,e){a=c*Math.tan(a*Math.PI/360);b*=a;return p.frustum(-b,b,-a,a,c,d,e)},ortho:function(a,b,c,d,e,g,f){f||(f=p.create());var h=b-a,i=d-c,k=g-e;
+f[0]=2/h;f[1]=0;f[2]=0;f[3]=0;f[4]=0;f[5]=2/i;f[6]=0;f[7]=0;f[8]=0;f[9]=0;f[10]=-2/k;f[11]=0;f[12]=-(a+b)/h;f[13]=-(d+c)/i;f[14]=-(g+e)/k;f[15]=1;return f},lookAt:function(a,b,c,d){d||(d=p.create());var e,g,f,h,i,k,m,l,j=a[0],o=a[1],a=a[2];f=c[0];h=c[1];g=c[2];m=b[0];c=b[1];e=b[2];if(j===m&&o===c&&a===e)return p.identity(d);b=j-m;c=o-c;m=a-e;l=1/Math.sqrt(b*b+c*c+m*m);b*=l;c*=l;m*=l;e=h*m-g*c;g=g*b-f*m;f=f*c-h*b;(l=Math.sqrt(e*e+g*g+f*f))?(l=1/l,e*=l,g*=l,f*=l):f=g=e=0;h=c*f-m*g;i=m*e-b*f;k=b*g-c*
+e;(l=Math.sqrt(h*h+i*i+k*k))?(l=1/l,h*=l,i*=l,k*=l):k=i=h=0;d[0]=e;d[1]=h;d[2]=b;d[3]=0;d[4]=g;d[5]=i;d[6]=c;d[7]=0;d[8]=f;d[9]=k;d[10]=m;d[11]=0;d[12]=-(e*j+g*o+f*a);d[13]=-(h*j+i*o+k*a);d[14]=-(b*j+c*o+m*a);d[15]=1;return d},fromRotationTranslation:function(a,b,c){c||(c=p.create());var d=a[0],e=a[1],g=a[2],f=a[3],h=d+d,i=e+e,k=g+g,a=d*h,m=d*i,d=d*k,j=e*i,e=e*k,g=g*k,h=f*h,i=f*i,f=f*k;c[0]=1-(j+g);c[1]=m+f;c[2]=d-i;c[3]=0;c[4]=m-f;c[5]=1-(a+g);c[6]=e+h;c[7]=0;c[8]=d+i;c[9]=e-h;c[10]=1-(a+j);c[11]=
+0;c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+"]"}},j={create:function(a){var b=new s(4);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]);return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},identity:function(a){a||(a=j.create());a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a}},S=j.identity();j.calculateW=
+function(a,b){var c=a[0],d=a[1],e=a[2];if(!b||a===b)return a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a;b[0]=c;b[1]=d;b[2]=e;b[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e));return b};j.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};j.inverse=function(a,b){var c=a[0],d=a[1],e=a[2],g=a[3],c=(c=c*c+d*d+e*e+g*g)?1/c:0;if(!b||a===b)return a[0]*=-c,a[1]*=-c,a[2]*=-c,a[3]*=c,a;b[0]=-a[0]*c;b[1]=-a[1]*c;b[2]=-a[2]*c;b[3]=a[3]*c;return b};j.conjugate=function(a,b){if(!b||a===b)return a[0]*=-1,a[1]*=
+-1,a[2]*=-1,a;b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=a[3];return b};j.length=function(a){var b=a[0],c=a[1],d=a[2],a=a[3];return Math.sqrt(b*b+c*c+d*d+a*a)};j.normalize=function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=Math.sqrt(c*c+d*d+e*e+g*g);if(0===f)return b[0]=0,b[1]=0,b[2]=0,b[3]=0,b;f=1/f;b[0]=c*f;b[1]=d*f;b[2]=e*f;b[3]=g*f;return b};j.add=function(a,b,c){if(!c||a===c)return a[0]+=b[0],a[1]+=b[1],a[2]+=b[2],a[3]+=b[3],a;c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];return c};
+j.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3],f=b[0],h=b[1],i=b[2],b=b[3];c[0]=d*b+a*f+e*i-g*h;c[1]=e*b+a*h+g*f-d*i;c[2]=g*b+a*i+d*h-e*f;c[3]=a*b-d*f-e*h-g*i;return c};j.multiplyVec3=function(a,b,c){c||(c=b);var d=b[0],e=b[1],g=b[2],b=a[0],f=a[1],h=a[2],a=a[3],i=a*d+f*g-h*e,k=a*e+h*d-b*g,j=a*g+b*e-f*d,d=-b*d-f*e-h*g;c[0]=i*a+d*-b+k*-h-j*-f;c[1]=k*a+d*-f+j*-b-i*-h;c[2]=j*a+d*-h+i*-f-k*-b;return c};j.scale=function(a,b,c){if(!c||a===c)return a[0]*=b,a[1]*=b,a[2]*=b,a[3]*=b,a;c[0]=
+a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;return c};j.toMat3=function(a,b){b||(b=D.create());var c=a[0],d=a[1],e=a[2],g=a[3],f=c+c,h=d+d,i=e+e,k=c*f,j=c*h,c=c*i,l=d*h,d=d*i,e=e*i,f=g*f,h=g*h,g=g*i;b[0]=1-(l+e);b[1]=j+g;b[2]=c-h;b[3]=j-g;b[4]=1-(k+e);b[5]=d+f;b[6]=c+h;b[7]=d-f;b[8]=1-(k+l);return b};j.toMat4=function(a,b){b||(b=p.create());var c=a[0],d=a[1],e=a[2],g=a[3],f=c+c,h=d+d,i=e+e,k=c*f,j=c*h,c=c*i,l=d*h,d=d*i,e=e*i,f=g*f,h=g*h,g=g*i;b[0]=1-(l+e);b[1]=j+g;b[2]=c-h;b[3]=0;b[4]=j-g;b[5]=1-(k+
+e);b[6]=d+f;b[7]=0;b[8]=c+h;b[9]=d-f;b[10]=1-(k+l);b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};j.slerp=function(a,b,c,d){d||(d=a);var e=a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3],g,f;if(1<=Math.abs(e))return d!==a&&(d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=a[3]),d;g=Math.acos(e);f=Math.sqrt(1-e*e);if(0.001>Math.abs(f))return d[0]=0.5*a[0]+0.5*b[0],d[1]=0.5*a[1]+0.5*b[1],d[2]=0.5*a[2]+0.5*b[2],d[3]=0.5*a[3]+0.5*b[3],d;e=Math.sin((1-c)*g)/f;c=Math.sin(c*g)/f;d[0]=a[0]*e+b[0]*c;d[1]=a[1]*e+b[1]*c;d[2]=
+a[2]*e+b[2]*c;d[3]=a[3]*e+b[3]*c;return d};j.fromRotationMatrix=function(a,b){b||(b=j.create());var c=a[0]+a[4]+a[8],d;if(0<c)d=Math.sqrt(c+1),b[3]=0.5*d,d=0.5/d,b[0]=(a[7]-a[5])*d,b[1]=(a[2]-a[6])*d,b[2]=(a[3]-a[1])*d;else{d=j.fromRotationMatrix.s_iNext=j.fromRotationMatrix.s_iNext||[1,2,0];c=0;a[4]>a[0]&&(c=1);a[8]>a[3*c+c]&&(c=2);var e=d[c],g=d[e];d=Math.sqrt(a[3*c+c]-a[3*e+e]-a[3*g+g]+1);b[c]=0.5*d;d=0.5/d;b[3]=(a[3*g+e]-a[3*e+g])*d;b[e]=(a[3*e+c]+a[3*c+e])*d;b[g]=(a[3*g+c]+a[3*c+g])*d}return b};
+D.toQuat4=j.fromRotationMatrix;(function(){var a=D.create();j.fromAxes=function(b,c,d,e){a[0]=c[0];a[3]=c[1];a[6]=c[2];a[1]=d[0];a[4]=d[1];a[7]=d[2];a[2]=b[0];a[5]=b[1];a[8]=b[2];return j.fromRotationMatrix(a,e)}})();j.identity=function(a){a||(a=j.create());a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a};j.fromAngleAxis=function(a,b,c){c||(c=j.create());var a=0.5*a,d=Math.sin(a);c[3]=Math.cos(a);c[0]=d*b[0];c[1]=d*b[1];c[2]=d*b[2];return c};j.toAngleAxis=function(a,b){b||(b=a);var c=a[0]*a[0]+a[1]*a[1]+a[2]*
+a[2];0<c?(b[3]=2*Math.acos(a[3]),c=G.invsqrt(c),b[0]=a[0]*c,b[1]=a[1]*c,b[2]=a[2]*c):(b[3]=0,b[0]=1,b[1]=0,b[2]=0);return b};j.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"};var O={create:function(a){var b=new s(2);a?(b[0]=a[0],b[1]=a[1]):(b[0]=0,b[1]=0);return b},add:function(a,b,c){c||(c=b);c[0]=a[0]+b[0];c[1]=a[1]+b[1];return c},subtract:function(a,b,c){c||(c=b);c[0]=a[0]-b[0];c[1]=a[1]-b[1];return c},multiply:function(a,b,c){c||(c=b);c[0]=a[0]*b[0];c[1]=a[1]*b[1];return c},
+divide:function(a,b,c){c||(c=b);c[0]=a[0]/b[0];c[1]=a[1]/b[1];return c},scale:function(a,b,c){c||(c=a);c[0]=a[0]*b;c[1]=a[1]*b;return c},dist:function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},set:function(a,b){b[0]=a[0];b[1]=a[1];return b},negate:function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];return b},normalize:function(a,b){b||(b=a);var c=a[0]*a[0]+a[1]*a[1];0<c?(c=Math.sqrt(c),b[0]=a[0]/c,b[1]=a[1]/c):b[0]=b[1]=0;return b},cross:function(a,b,c){a=a[0]*b[1]-a[1]*b[0];if(!c)return a;
+c[0]=c[1]=0;c[2]=a;return c},length:function(a){var b=a[0],a=a[1];return Math.sqrt(b*b+a*a)},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]},direction:function(a,b,c){c||(c=a);var d=a[0]-b[0],a=a[1]-b[1],b=d*d+a*a;if(!b)return c[0]=0,c[1]=0,c[2]=0,c;b=1/Math.sqrt(b);c[0]=d*b;c[1]=a*b;return c},lerp:function(a,b,c,d){d||(d=a);d[0]=a[0]+c*(b[0]-a[0]);d[1]=a[1]+c*(b[1]-a[1]);return d},str:function(a){return"["+a[0]+", "+a[1]+"]"}},N={create:function(a){var b=new s(4);a&&(b[0]=a[0],b[1]=a[1],b[2]=a[2],
+b[3]=a[3]);return b},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},identity:function(a){a||(a=N.create());a[0]=1;a[1]=0;a[2]=0;a[3]=1;return a},transpose:function(a,b){if(!b||a===b){var c=a[1];a[1]=a[2];a[2]=c;return a}b[0]=a[0];b[1]=a[2];b[2]=a[1];b[3]=a[3];return b},determinant:function(a){return a[0]*a[3]-a[2]*a[1]},inverse:function(a,b){b||(b=a);var c=a[0],d=a[1],e=a[2],g=a[3],f=c*g-e*d;if(!f)return null;f=1/f;b[0]=g*f;b[1]=-d*f;b[2]=-e*f;b[3]=c*f;return b},multiply:function(a,
+b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3];c[0]=d*b[0]+e*b[2];c[1]=d*b[1]+e*b[3];c[2]=g*b[0]+a*b[2];c[3]=g*b[1]+a*b[3];return c},rotate:function(a,b,c){c||(c=a);var d=a[0],e=a[1],g=a[2],a=a[3],f=Math.sin(b),b=Math.cos(b);c[0]=d*b+e*f;c[1]=d*-f+e*b;c[2]=g*b+a*f;c[3]=g*-f+a*b;return c},multiplyVec2:function(a,b,c){c||(c=b);var d=b[0],b=b[1];c[0]=d*a[0]+b*a[1];c[1]=d*a[2]+b*a[3];return c},scale:function(a,b,c){c||(c=a);var d=a[1],e=a[2],g=a[3],f=b[0],b=b[1];c[0]=a[0]*f;c[1]=d*b;c[2]=e*f;c[3]=g*b;
+return c},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"}};q&&(q.glMatrixArrayType=s,q.MatrixArray=s,q.setMatrixArrayType=F,q.determineMatrixArrayType=L,q.glMath=G,q.vec2=O,q.vec3=r,q.mat2=N,q.mat3=D,q.mat4=p,q.quat4=j);return{glMatrixArrayType:s,MatrixArray:s,setMatrixArrayType:F,determineMatrixArrayType:L,glMath:G,vec2:O,vec3:r,mat2:N,mat3:D,mat4:p,quat4:j}});
View
99 gl-matrix.js
@@ -2,7 +2,7 @@
* @fileoverview gl-matrix - High performance matrix and vector operations for WebGL
* @author Brandon Jones
* @author Colin MacKenzie IV
- * @version 1.3.1
+ * @version 1.3.2
*/
/*
@@ -537,9 +537,98 @@
};
/**
- * Transforms the vec2 according to the given 3x3 matrix.
+ * Calculates the determinant of a mat3
*
- * @param {mat3} matrix the 3x3 matrix to multiply against
+ * @param {mat3} mat mat3 to calculate determinant of
+ *
+ * @returns {Number} determinant of mat
+ */
+ mat3.determinant = function (mat) {
+ var a00 = mat[0], a01 = mat[1], a02 = mat[2],
+ a10 = mat[3], a11 = mat[4], a12 = mat[5],
+ a20 = mat[6], a21 = mat[7], a22 = mat[8];
+
+ return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
+ };
+
+ /**
+ * Calculates the inverse matrix of a mat3
+ *
+ * @param {mat3} mat mat3 to calculate inverse of
+ * @param {mat3} [dest] mat3 receiving inverse matrix. If not specified result is written to mat
+ *
+ * @param {mat3} dest is specified, mat otherwise, null if matrix cannot be inverted
+ */
+ mat3.inverse = function (mat, dest) {
+ var a00 = mat[0], a01 = mat[1], a02 = mat[2],
+ a10 = mat[3], a11 = mat[4], a12 = mat[5],
+ a20 = mat[6], a21 = mat[7], a22 = mat[8],
+
+ b01 = a22 * a11 - a12 * a21,
+ b11 = -a22 * a10 + a12 * a20,
+ b21 = a21 * a10 - a11 * a20,
+
+ d = a00 * b01 + a01 * b11 + a02 * b21,
+ id;
+
+ if (!d) { return null; }
+ id = 1 / d;
+
+ if (!dest) { dest = mat3.create(); }
+
+ dest[0] = b01 * id;
+ dest[1] = (-a22 * a01 + a02 * a21) * id;
+ dest[2] = (a12 * a01 - a02 * a11) * id;
+ dest[3] = b11 * id;
+ dest[4] = (a22 * a00 - a02 * a20) * id;
+ dest[5] = (-a12 * a00 + a02 * a10) * id;
+ dest[6] = b21 * id;
+ dest[7] = (-a21 * a00 + a01 * a20) * id;
+ dest[8] = (a11 * a00 - a01 * a10) * id;
+ return dest;
+ };
+
+ /**
+ * Performs a matrix multiplication
+ *
+ * @param {mat3} mat First operand
+ * @param {mat3} mat2 Second operand
+ * @param {mat3} [dest] mat3 receiving operation result. If not specified result is written to mat
+ *
+ * @returns {mat3} dest if specified, mat otherwise
+ */
+ mat3.multiply = function (mat, mat2, dest) {
+ if (!dest) { dest = mat; }
+
+
+ // Cache the matrix values (makes for huge speed increases!)
+ var a00 = mat[0], a01 = mat[1], a02 = mat[2],
+ a10 = mat[3], a11 = mat[4], a12 = mat[5],
+ a20 = mat[6], a21 = mat[7], a22 = mat[8],
+
+ b00 = mat2[0], b01 = mat2[1], b02 = mat2[2],
+ b10 = mat2[3], b11 = mat2[4], b12 = mat2[5],
+ b20 = mat2[6], b21 = mat2[7], b22 = mat2[8];
+
+ dest[0] = b00 * a00 + b01 * a10 + b02 * a20;
+ dest[1] = b00 * a01 + b01 * a11 + b02 * a21;
+ dest[2] = b00 * a02 + b01 * a12 + b02 * a22;
+
+ dest[3] = b10 * a00 + b11 * a10 + b12 * a20;
+ dest[4] = b10 * a01 + b11 * a11 + b12 * a21;
+ dest[5] = b10 * a02 + b11 * a12 + b12 * a22;
+
+ dest[6] = b20 * a00 + b21 * a10 + b22 * a20;
+ dest[7] = b20 * a01 + b21 * a11 + b22 * a21;
+ dest[8] = b20 * a02 + b21 * a12 + b22 * a22;
+
+ return dest;
+ };
+
+ /**
+ * Transforms the vec2 according to the given mat3.
+ *
+ * @param {mat3} matrix mat3 to multiply against
* @param {vec2} vec the vector to multiply
* @param {vec2} [dest] an optional receiving vector. If not given, vec is used.
*
@@ -554,9 +643,9 @@
};
/**
- * Transforms the vec3 according to this rotation matrix.
+ * Transforms the vec3 according to the given mat3
*
- * @param {mat3} matrix the 3x3 matrix to multiply against
+ * @param {mat3} matrix mat3 to multiply against
* @param {vec3} vec the vector to multiply
* @param {vec3} [dest] an optional receiving vector. If not given, vec is used.
*

0 comments on commit 39f181f

Please sign in to comment.
Something went wrong with that request. Please try again.