Skip to content
Browse files

Reverted change to create due to performance regression

Added createFrom to handle the removed case.
  • Loading branch information...
1 parent 45cea95 commit c6a5dc146bf4743c1ba6803ca6466de795487523 Brandon Jones committed May 14, 2012
Showing with 259 additions and 114 deletions.
  1. +41 −41 gl-matrix-min.js
  2. +218 −73 gl-matrix.js
View
82 gl-matrix-min.js
@@ -1,44 +1,44 @@
// gl-matrix 1.3.3 - https://github.com/toji/gl-matrix/blob/master/LICENSE.md
-(function(p,E){"object"===typeof exports?module.exports=E(global):"function"===typeof define&&define.amd?define([],function(){return E(p)}):E(p)})(this,function(p){function E(a){return s=a}function L(){return s="undefined"!==typeof Float32Array?Float32Array:Array}var F={};(function(){if("undefined"!=typeof Float32Array){var a=new Float32Array(1),b=new Int32Array(a.buffer);F.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 F.invsqrt=function(a){return 1/
-Math.sqrt(a)}})();var s=null;L();var r={create:function(a){var b=new s(3);3===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2]):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]-
+(function(r,E){"object"===typeof exports?module.exports=E(global):"function"===typeof define&&define.amd?define([],function(){return E(r)}):E(r)})(this,function(r){function E(a){return o=a}function K(){return o="undefined"!==typeof Float32Array?Float32Array:Array}var F={};(function(){if("undefined"!=typeof Float32Array){var a=new Float32Array(1),b=new Int32Array(a.buffer);F.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 F.invsqrt=function(a){return 1/
+Math.sqrt(a)}})();var o=null;K();var t={create:function(a){var b=new o(3);a?(b[0]=a[0],b[1]=a[1],b[2]=a[2]):b[0]=b[1]=b[2]=0;return b},createFrom:function(a,b,c){var d=new o(3);d[0]=a;d[1]=b;d[2]=c;return d},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)}},M=null,t=new s(4);r.unproject=function(a,b,c,d,e){e||(e=a);M||(M=q.create());var g=M;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;q.multiply(c,b,g);if(!q.inverse(g))return null;q.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 Q=r.create(1,
-0,0),R=r.create(0,1,0),S=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(T,c);else if(-0.999999>d)r.cross(Q,a,e),1.0E-6>e.length&&r.cross(R,a,e),1.0E-6>e.length&&r.cross(S,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 v={create:function(a){var b=
-new s(9);4===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2],b[3]=arguments[3],b[4]=arguments[4],b[5]=arguments[5],b[6]=arguments[6],b[7]=arguments[7],b[8]=arguments[8]):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[0]=b[1]=b[2]=b[3]=b[4]=b[5]=b[6]=b[7]=b[8]=0;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,D=-m*g+h*i,o=k*g-f*i,n=c*l+d*D+e*o;if(!n)return null;n=1/n;b||(b=v.create());b[0]=l*n;b[1]=(-m*d+e*k)*n;b[2]=(h*d-e*f)*n;b[3]=D*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],D=b[1],o=b[2],n=b[3],j=b[4],C=b[5],G=b[6],H=b[7],b=b[8];c[0]=l*d+D*f+o*k;c[1]=l*e+D*h+o*m;c[2]=l*g+D*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]=G*d+H*f+b*k;c[7]=G*e+H*h+b*m;c[8]=G*g+H*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=v.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=q.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]+"]"}},q={create:function(a){var b=new s(16);4===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2],b[3]=arguments[3],b[4]=arguments[4],b[5]=arguments[5],b[6]=arguments[6],b[7]=arguments[7],b[8]=arguments[8],b[9]=arguments[9],b[10]=arguments[10],b[11]=arguments[11],b[12]=arguments[12],b[13]=arguments[13],b[14]=arguments[14],b[15]=arguments[15]):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=q.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],D=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*D-g*n*d*D-o*c*h*D+b*n*h*D+g*c*j*D-b*f*j*D-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],I=a[13],C=a[14],G=a[15],H=c*h-d*f,p=c*i-e*f,q=c*k-g*f,w=d*i-e*h,x=d*k-g*h,y=e*k-g*i,z=m*I-l*n,A=m*C-j*n,B=m*G-o*n,r=l*
-C-j*I,s=l*G-o*I,t=j*G-o*C,u=H*t-p*s+q*r+w*B-x*A+y*z;if(!u)return null;u=1/u;b[0]=(h*t-i*s+k*r)*u;b[1]=(-d*t+e*s-g*r)*u;b[2]=(I*y-C*x+G*w)*u;b[3]=(-l*y+j*x-o*w)*u;b[4]=(-f*t+i*B-k*A)*u;b[5]=(c*t-e*B+g*A)*u;b[6]=(-n*y+C*q-G*p)*u;b[7]=(m*y-j*q+o*p)*u;b[8]=(f*s-h*B+k*z)*u;b[9]=(-c*s+d*B-g*z)*u;b[10]=(n*x-I*q+G*H)*u;b[11]=(-m*x+l*q-o*H)*u;b[12]=(-f*r+h*A-i*z)*u;b[13]=(c*r-d*A+e*z)*u;b[14]=(-n*w+I*p-C*H)*u;b[15]=(m*w-l*p+j*H)*u;return b},toRotationMat:function(a,b){b||(b=q.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=v.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=v.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],t=b[2],w=b[3],x=b[4],y=b[5],z=b[6],A=b[7],B=b[8],v=b[9],E=b[10],F=b[11],u=b[12],J=b[13],K=b[14],b=b[15];c[0]=r*d+s*h+t*l+w*p;c[1]=r*e+s*i+t*j+w*C;c[2]=r*g+s*k+t*o+w*q;c[3]=r*f+s*m+t*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+v*h+E*l+F*p;c[9]=B*e+v*i+E*j+F*C;c[10]=B*g+v*k+E*o+F*q;c[11]=B*f+v*m+E*n+F*a;c[12]=u*d+J*h+K*l+b*p;c[13]=u*e+J*i+K*j+b*C;c[14]=u*g+J*k+K*o+b*q;c[15]=u*f+J*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,t,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];t=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+t*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+t*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+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],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=q.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 q.frustum(-b,b,-a,a,c,d,e)},ortho:function(a,
-b,c,d,e,g,f){f||(f=q.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=q.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 q.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=q.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);4===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2],b[3]=arguments[3]):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}},T=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=v.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=q.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};v.toQuat4=j.fromRotationMatrix;(function(){var a=v.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=F.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);2===arguments.length?(b[0]=arguments[0],b[1]=arguments[1]):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);4===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2],b[3]=arguments[3]):a?(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]):b[0]=b[1]=b[2]=b[3]=0;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]+"]"}},P={create:function(a){var b=new s(4);4===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2],b[3]=
-arguments[3]):a?(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]):(b[0]=0,b[1]=0,b[2]=0,b[3]=0);return b},add:function(a,b,c){c||(c=b);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},subtract:function(a,b,c){c||(c=b);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},multiply:function(a,b,c){c||(c=b);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},divide:function(a,b,c){c||(c=b);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},
-scale:function(a,b,c){c||(c=a);c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;return c},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},negate:function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=-a[3];return b},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]);d[3]=a[3]+c*(b[3]-a[3]);return d},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"}};p&&(p.glMatrixArrayType=s,p.MatrixArray=s,p.setMatrixArrayType=
-E,p.determineMatrixArrayType=L,p.glMath=F,p.vec2=O,p.vec3=r,p.vec4=P,p.mat2=N,p.mat3=v,p.mat4=q,p.quat4=j);return{glMatrixArrayType:s,MatrixArray:s,setMatrixArrayType:E,determineMatrixArrayType:L,glMath:F,vec2:O,vec3:r,vec4:P,mat2:N,mat3:v,mat4:q,quat4:j}});
+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,u=new o(4);t.unproject=function(a,b,c,d,e){e||(e=a);L||(L=s.create());var g=L;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;s.multiply(c,b,g);if(!s.inverse(g))return null;s.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=t.createFrom(1,
+0,0),Q=t.createFrom(0,1,0),R=t.createFrom(0,0,1);t.rotationTo=function(a,b,c){c||(c=k.create());var d=t.dot(a,b),e=t.create();if(1<=d)k.set(S,c);else if(-0.999999>d)t.cross(P,a,e),1.0E-6>e.length&&t.cross(Q,a,e),1.0E-6>e.length&&t.cross(R,a,e),t.normalize(e),k.fromAxisAngle(e,Math.PI,c);else{var d=Math.sqrt(2*(1+d)),g=1/d;t.cross(a,b,e);c[0]=e[0]*g;c[1]=e[1]*g;c[2]=e[2]*g;c[3]=0.5*d;k.normalize(c)}1<c[3]?c[3]=1:-1>c[3]&&(c[3]=-1);return c};t.str=function(a){return"["+a[0]+", "+a[1]+", "+a[2]+"]"};
+var D={create:function(a){var b=new o(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]):b[0]=b[1]=b[2]=b[3]=b[4]=b[5]=b[6]=b[7]=b[8]=0;return b},createFrom:function(a,b,c,d,e,g,f,h,j){var i=new o(9);i[0]=a;i[1]=b;i[2]=c;i[3]=d;i[4]=e;i[5]=g;i[6]=f;i[7]=h;i[8]=j;return i},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],j=a[6],i=a[7],m=a[8],l=m*f-h*i,C=-m*g+h*j,q=i*g-f*j,n=c*l+d*C+e*q;if(!n)return null;n=1/n;b||(b=D.create());b[0]=l*n;b[1]=(-m*d+e*i)*n;b[2]=(h*d-e*f)*n;b[3]=C*n;b[4]=(m*c-e*j)*n;b[5]=(-h*c+e*g)*n;b[6]=q*n;b[7]=(-i*c+d*j)*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],j=a[5],i=a[6],m=a[7],a=a[8],l=b[0],C=b[1],q=b[2],n=b[3],k=b[4],p=b[5],o=b[6],H=b[7],b=b[8];c[0]=l*d+C*f+q*i;c[1]=l*e+C*h+q*m;c[2]=l*g+C*j+q*a;c[3]=n*d+k*f+p*i;c[4]=n*e+k*h+
+p*m;c[5]=n*g+k*j+p*a;c[6]=o*d+H*f+b*i;c[7]=o*e+H*h+b*m;c[8]=o*g+H*j+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=s.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]+"]"}},s={create:function(a){var b=new o(16);4===arguments.length?(b[0]=arguments[0],b[1]=arguments[1],b[2]=arguments[2],b[3]=arguments[3],b[4]=arguments[4],b[5]=arguments[5],b[6]=arguments[6],b[7]=arguments[7],b[8]=arguments[8],b[9]=arguments[9],b[10]=arguments[10],b[11]=arguments[11],b[12]=arguments[12],b[13]=arguments[13],b[14]=arguments[14],b[15]=arguments[15]):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},createFrom:function(a,b,c,d,e,g,f,h,j,i,m,l,C,q,n,k){var p=new o(16);p[0]=a;p[1]=b;p[2]=c;p[3]=d;p[4]=e;p[5]=g;p[6]=f;p[7]=h;p[8]=j;p[9]=i;p[10]=m;p[11]=l;p[12]=C;p[13]=q;p[14]=n;p[15]=k;return p},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=s.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],j=a[7],i=a[8],m=a[9],l=a[10],C=a[11],q=a[12],n=a[13],k=a[14],a=a[15];return q*m*h*e-i*n*h*e-q*f*l*e+g*n*l*e+i*f*k*e-g*m*k*e-q*m*d*j+i*n*d*j+q*c*l*j-b*n*l*j-i*c*k*j+b*m*k*j+q*f*d*C-g*n*d*C-q*c*h*C+b*n*h*C+g*c*k*C-b*f*k*C-i*f*d*a+g*m*d*a+i*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],j=a[6],i=a[7],m=a[8],l=a[9],k=a[10],q=a[11],n=a[12],o=a[13],p=a[14],r=a[15],H=c*h-d*f,s=c*j-e*f,I=c*i-g*f,w=d*j-e*h,x=d*i-g*h,y=e*i-g*j,z=m*o-l*n,A=m*p-k*n,B=m*r-q*n,t=l*p-k*o,u=l*r-q*o,G=k*r-q*p,v=H*G-s*u+I*t+w*B-x*A+y*z;if(!v)return null;v=1/v;b[0]=(h*G-j*u+i*t)*v;b[1]=(-d*G+e*u-g*t)*v;b[2]=(o*y-p*x+r*w)*v;b[3]=(-l*y+k*x-q*w)*v;b[4]=(-f*G+j*B-i*A)*v;b[5]=(c*G-e*B+g*A)*v;b[6]=(-n*y+p*I-r*s)*v;b[7]=(m*y-k*I+q*s)*v;b[8]=(f*u-h*B+i*z)*v;b[9]=(-c*u+d*B-g*z)*v;b[10]=(n*x-o*I+r*H)*v;b[11]=(-m*x+
+l*I-q*H)*v;b[12]=(-f*t+h*A-j*z)*v;b[13]=(c*t-d*A+e*z)*v;b[14]=(-n*w+o*s-p*H)*v;b[15]=(m*w-l*s+k*H)*v;return b},toRotationMat:function(a,b){b||(b=s.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],j=a[8],i=a[9],m=a[10],l=m*f-h*i,k=-m*g+h*j,q=i*g-f*j,n=c*l+d*k+e*q;if(!n)return null;n=1/n;b||(b=D.create());b[0]=l*n;b[1]=(-m*d+e*i)*n;b[2]=(h*d-e*f)*n;b[3]=k*n;b[4]=(m*c-e*j)*n;b[5]=(-h*c+e*g)*n;b[6]=q*n;b[7]=(-i*c+d*j)*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],j=a[5],i=a[6],m=a[7],l=a[8],k=a[9],q=a[10],n=a[11],o=a[12],p=a[13],r=a[14],a=a[15],s=b[0],t=b[1],u=b[2],w=b[3],x=b[4],y=b[5],z=b[6],A=b[7],B=b[8],
+D=b[9],E=b[10],G=b[11],v=b[12],F=b[13],J=b[14],b=b[15];c[0]=s*d+t*h+u*l+w*o;c[1]=s*e+t*j+u*k+w*p;c[2]=s*g+t*i+u*q+w*r;c[3]=s*f+t*m+u*n+w*a;c[4]=x*d+y*h+z*l+A*o;c[5]=x*e+y*j+z*k+A*p;c[6]=x*g+y*i+z*q+A*r;c[7]=x*f+y*m+z*n+A*a;c[8]=B*d+D*h+E*l+G*o;c[9]=B*e+D*j+E*k+G*p;c[10]=B*g+D*i+E*q+G*r;c[11]=B*f+D*m+E*n+G*a;c[12]=v*d+F*h+J*l+b*o;c[13]=v*e+F*j+J*k+b*p;c[14]=v*g+F*i+J*q+b*r;c[15]=v*f+F*m+J*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,j,i,m,l,k,q,n,o,p;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];j=a[3];i=a[4];m=a[5];l=a[6];k=a[7];q=a[8];n=a[9];o=a[10];p=a[11];c[0]=g;c[1]=f;c[2]=h;c[3]=j;c[4]=i;c[5]=m;c[6]=l;c[7]=k;c[8]=q;c[9]=n;c[10]=o;c[11]=p;c[12]=g*d+i*e+q*b+a[12];c[13]=f*d+m*e+n*b+a[13];c[14]=h*d+l*e+o*b+a[14];c[15]=j*d+k*e+p*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,j,i,m,l,k,q,n,o,p,r,s,t,u,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);j=Math.cos(b);i=1-j;b=a[0];f=a[1];m=a[2];l=a[3];k=a[4];q=a[5];n=a[6];o=a[7];p=a[8];r=a[9];s=a[10];t=a[11];u=e*e*i+j;w=g*e*i+c*h;x=c*e*i-g*h;y=e*g*i-c*h;
+z=g*g*i+j;A=c*g*i+e*h;B=e*c*i+g*h;e=g*c*i-e*h;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*u+k*w+p*x;d[1]=f*u+q*w+r*x;d[2]=m*u+n*w+s*x;d[3]=l*u+o*w+t*x;d[4]=b*y+k*z+p*A;d[5]=f*y+q*z+r*A;d[6]=m*y+n*z+s*A;d[7]=l*y+o*z+t*A;d[8]=b*B+k*e+p*g;d[9]=f*B+q*e+r*g;d[10]=m*B+n*e+s*g;d[11]=l*B+o*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],h=a[7],j=a[8],i=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+j*d;c[5]=g*b+i*d;c[6]=f*b+m*d;c[7]=h*b+l*d;c[8]=e*-d+j*b;c[9]=g*-d+i*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],j=a[8],i=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+j*-d;c[1]=g*b+i*-d;c[2]=f*b+m*-d;c[3]=h*b+l*-d;c[8]=e*d+j*b;c[9]=g*d+i*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],j=a[4],i=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+j*d;c[1]=g*b+i*d;c[2]=f*b+m*d;c[3]=h*b+l*d;c[4]=e*-d+j*b;c[5]=g*-d+i*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=s.create());var h=b-a,j=d-c,i=g-e;f[0]=2*e/h;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)/h;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 s.frustum(-b,b,-a,a,c,d,e)},ortho:function(a,b,c,d,e,g,f){f||(f=s.create());var h=b-a,j=d-c,i=g-e;f[0]=2/h;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)/h;f[13]=-(d+c)/j;f[14]=-(g+e)/i;f[15]=1;return f},lookAt:function(a,b,c,d){d||(d=s.create());var e,g,f,h,j,i,m,l,k=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(k===m&&o===c&&a===e)return s.identity(d);b=k-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;j=m*e-b*f;i=b*g-c*e;(l=Math.sqrt(h*h+j*j+i*i))?(l=1/l,h*=l,j*=l,i*=l):i=j=h=0;d[0]=e;d[1]=h;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]=m;d[11]=0;d[12]=-(e*k+g*o+f*a);d[13]=-(h*k+j*o+i*a);d[14]=-(b*k+c*o+m*a);d[15]=1;return d},fromRotationTranslation:function(a,
+b,c){c||(c=s.create());var d=a[0],e=a[1],g=a[2],f=a[3],h=d+d,j=e+e,i=g+g,a=d*h,m=d*j,d=d*i,k=e*j,e=e*i,g=g*i,h=f*h,j=f*j,f=f*i;c[0]=1-(k+g);c[1]=m+f;c[2]=d-j;c[3]=0;c[4]=m-f;c[5]=1-(a+g);c[6]=e+h;c[7]=0;c[8]=d+j;c[9]=e-h;c[10]=1-(a+k);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]+"]"}},k={create:function(a){var b=
+new o(4);a?(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]):b[0]=b[1]=b[2]=b[3]=0;return b},createFrom:function(a,b,c,d){var e=new o(4);e[0]=a;e[1]=b;e[2]=c;e[3]=d;return e},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=k.create());a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a}},S=k.identity();k.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};k.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};k.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};k.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};k.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)};k.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};k.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};k.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};k.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,k=a*g+b*e-f*d,d=-b*d-f*e-h*g;c[0]=j*a+d*-b+i*-h-k*-f;c[1]=i*a+d*-f+k*-b-j*-h;c[2]=k*a+d*-h+j*-f-i*-b;return c};k.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};k.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,j=e+e,i=c*f,k=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]=k+g;b[2]=c-h;b[3]=k-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};k.toMat4=function(a,b){b||(b=s.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,k=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]=k+g;b[2]=c-h;b[3]=0;b[4]=k-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};k.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};k.fromRotationMatrix=function(a,b){b||(b=k.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=k.fromRotationMatrix.s_iNext=k.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=k.fromRotationMatrix;(function(){var a=D.create();k.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 k.fromRotationMatrix(a,e)}})();k.identity=function(a){a||(a=k.create());a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a};k.fromAngleAxis=function(a,b,c){c||(c=k.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};k.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=F.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};k.str=function(a){return"["+a[0]+
+", "+a[1]+", "+a[2]+", "+a[3]+"]"};var N={create:function(a){var b=new o(2);a?(b[0]=a[0],b[1]=a[1]):(b[0]=0,b[1]=0);return b},createFrom:function(a,b){var c=new o(2);c[0]=a;c[1]=b;return c},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 o(4);a?(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]):b[0]=b[1]=b[2]=b[3]=0;return b},createFrom:function(a,b,c,d){var e=new o(4);e[0]=a;
+e[1]=b;e[2]=c;e[3]=d;return e},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]+"]"}},O={create:function(a){var b=new o(4);a?(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3]):(b[0]=0,b[1]=0,b[2]=0,b[3]=0);return b},createFrom:function(a,b,c,d){var e=new o(4);e[0]=a;e[1]=b;e[2]=c;e[3]=d;return e},add:function(a,b,c){c||(c=b);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},subtract:function(a,b,c){c||(c=b);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},multiply:function(a,
+b,c){c||(c=b);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},divide:function(a,b,c){c||(c=b);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},scale:function(a,b,c){c||(c=a);c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;return c},set:function(a,b){b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},negate:function(a,b){b||(b=a);b[0]=-a[0];b[1]=-a[1];b[2]=-a[2];b[3]=-a[3];return b},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]);d[3]=a[3]+c*(b[3]-a[3]);return d},str:function(a){return"["+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"]"}};r&&(r.glMatrixArrayType=o,r.MatrixArray=o,r.setMatrixArrayType=E,r.determineMatrixArrayType=K,r.glMath=F,r.vec2=N,r.vec3=t,r.vec4=O,r.mat2=M,r.mat3=D,r.mat4=s,r.quat4=k);return{glMatrixArrayType:o,MatrixArray:o,setMatrixArrayType:E,determineMatrixArrayType:K,glMath:F,vec2:N,vec3:t,vec4:O,mat2:M,mat3:D,mat4:s,quat4:k}});
View
291 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.3
+ * @version 1.3.4
*/
/*
@@ -118,11 +118,7 @@
vec3.create = function (vec) {
var dest = new MatrixArray(3);
- if(arguments.length === 3) {
- dest[0] = arguments[0];
- dest[1] = arguments[1];
- dest[2] = arguments[2];
- } else if (vec) {
+ if (vec) {
dest[0] = vec[0];
dest[1] = vec[1];
dest[2] = vec[2];
@@ -134,6 +130,25 @@
};
/**
+ * Creates a new instance of a vec3, initializing it with the given arguments
+ *
+ * @param {number} x X value
+ * @param {number} y Y value
+ * @param {number} z Z value
+
+ * @returns {vec3} New vec3
+ */
+ vec3.createFrom = function (x, y, z) {
+ var dest = new MatrixArray(3);
+
+ dest[0] = x;
+ dest[1] = y;
+ dest[2] = z;
+
+ return dest;
+ };
+
+ /**
* Copies the values of one vec3 to another
*
* @param {vec3} vec vec3 containing values to copy
@@ -448,9 +463,9 @@
return dest;
};
- var xUnitVec3 = vec3.create(1,0,0);
- var yUnitVec3 = vec3.create(0,1,0);
- var zUnitVec3 = vec3.create(0,0,1);
+ var xUnitVec3 = vec3.createFrom(1,0,0);
+ var yUnitVec3 = vec3.createFrom(0,1,0);
+ var zUnitVec3 = vec3.createFrom(0,0,1);
/**
* Generates a quaternion of rotation between two given normalized vectors
@@ -519,17 +534,7 @@
mat3.create = function (mat) {
var dest = new MatrixArray(9);
- if(arguments.length === 4) {
- dest[0] = arguments[0];
- dest[1] = arguments[1];
- dest[2] = arguments[2];
- dest[3] = arguments[3];
- dest[4] = arguments[4];
- dest[5] = arguments[5];
- dest[6] = arguments[6];
- dest[7] = arguments[7];
- dest[8] = arguments[8];
- } else if (mat) {
+ if (mat) {
dest[0] = mat[0];
dest[1] = mat[1];
dest[2] = mat[2];
@@ -551,6 +556,37 @@
};
/**
+ * Creates a new instance of a mat3, initializing it with the given arguments
+ *
+ * @param {number} m00
+ * @param {number} m01
+ * @param {number} m02
+ * @param {number} m10
+ * @param {number} m11
+ * @param {number} m12
+ * @param {number} m20
+ * @param {number} m21
+ * @param {number} m22
+
+ * @returns {mat3} New mat3
+ */
+ mat3.createFrom = function (m00, m01, m02, m10, m11, m12, m20, m21, m22) {
+ var dest = new MatrixArray(9);
+
+ dest[0] = m00;
+ dest[1] = m01;
+ dest[2] = m02;
+ dest[3] = m10;
+ dest[4] = m11;
+ dest[5] = m12;
+ dest[6] = m20;
+ dest[7] = m21;
+ dest[8] = m22;
+
+ return dest;
+ };
+
+ /**
* Calculates the determinant of a mat3
*
* @param {mat3} mat mat3 to calculate determinant of
@@ -857,6 +893,51 @@
};
/**
+ * Creates a new instance of a mat4, initializing it with the given arguments
+ *
+ * @param {number} m00
+ * @param {number} m01
+ * @param {number} m02
+ * @param {number} m03
+ * @param {number} m10
+ * @param {number} m11
+ * @param {number} m12
+ * @param {number} m13
+ * @param {number} m20
+ * @param {number} m21
+ * @param {number} m22
+ * @param {number} m23
+ * @param {number} m30
+ * @param {number} m31
+ * @param {number} m32
+ * @param {number} m33
+
+ * @returns {mat4} New mat4
+ */
+ mat4.createFrom = function (m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
+ var dest = new MatrixArray(16);
+
+ dest[0] = m00;
+ dest[1] = m01;
+ dest[2] = m02;
+ dest[3] = m03;
+ dest[4] = m10;
+ dest[5] = m11;
+ dest[6] = m12;
+ dest[7] = m13;
+ dest[8] = m20;
+ dest[9] = m21;
+ dest[10] = m22;
+ dest[11] = m23;
+ dest[12] = m30;
+ dest[13] = m31;
+ dest[14] = m32;
+ dest[15] = m33;
+
+ return dest;
+ };
+
+ /**
* Copies the values of one mat4 to another
*
* @param {mat4} mat mat4 containing values to copy
@@ -1792,22 +1873,40 @@
quat4.create = function (quat) {
var dest = new MatrixArray(4);
- if(arguments.length === 4) {
- dest[0] = arguments[0];
- dest[1] = arguments[1];
- dest[2] = arguments[2];
- dest[3] = arguments[3];
- } else if (quat) {
+ if (quat) {
dest[0] = quat[0];
dest[1] = quat[1];
dest[2] = quat[2];
dest[3] = quat[3];
+ } else {
+ dest[0] = dest[1] = dest[2] = dest[3] = 0;
}
return dest;
};
/**
+ * Creates a new instance of a quat4, initializing it with the given arguments
+ *
+ * @param {number} x X value
+ * @param {number} y Y value
+ * @param {number} z Z value
+ * @param {number} w W value
+
+ * @returns {quat4} New quat4
+ */
+ quat4.createFrom = function (x, y, z, w) {
+ var dest = new MatrixArray(4);
+
+ dest[0] = x;
+ dest[1] = y;
+ dest[2] = z;
+ dest[3] = w;
+
+ return dest;
+ };
+
+ /**
* Copies the values of one quat4 to another
*
* @param {quat4} quat quat4 containing values to copy
@@ -2413,17 +2512,31 @@
vec2.create = function(vec) {
var dest = new MatrixArray(2);
- if(arguments.length === 2) {
- dest[0] = arguments[0];
- dest[1] = arguments[1];
- } else if (vec) {
+ if (vec) {
dest[0] = vec[0];
dest[1] = vec[1];
} else {
dest[0] = 0;
dest[1] = 0;
}
- return dest;
+ return dest;
+ };
+
+ /**
+ * Creates a new instance of a vec2, initializing it with the given arguments
+ *
+ * @param {number} x X value
+ * @param {number} y Y value
+
+ * @returns {vec2} New vec2
+ */
+ vec2.createFrom = function (x, y) {
+ var dest = new MatrixArray(2);
+
+ dest[0] = x;
+ dest[1] = y;
+
+ return dest;
};
/**
@@ -2436,10 +2549,10 @@
* @returns {vec2} dest
*/
vec2.add = function(vecA, vecB, dest) {
- if (!dest) dest = vecB;
- dest[0] = vecA[0] + vecB[0];
- dest[1] = vecA[1] + vecB[1];
- return dest;
+ if (!dest) dest = vecB;
+ dest[0] = vecA[0] + vecB[0];
+ dest[1] = vecA[1] + vecB[1];
+ return dest;
};
/**
@@ -2452,10 +2565,10 @@
* @returns {vec2} dest
*/
vec2.subtract = function(vecA, vecB, dest) {
- if (!dest) dest = vecB;
- dest[0] = vecA[0] - vecB[0];
- dest[1] = vecA[1] - vecB[1];
- return dest;
+ if (!dest) dest = vecB;
+ dest[0] = vecA[0] - vecB[0];
+ dest[1] = vecA[1] - vecB[1];
+ return dest;
};
/**
@@ -2468,10 +2581,10 @@
* @returns {vec2} dest
*/
vec2.multiply = function(vecA, vecB, dest) {
- if (!dest) dest = vecB;
- dest[0] = vecA[0] * vecB[0];
- dest[1] = vecA[1] * vecB[1];
- return dest;
+ if (!dest) dest = vecB;
+ dest[0] = vecA[0] * vecB[0];
+ dest[1] = vecA[1] * vecB[1];
+ return dest;
};
/**
@@ -2484,10 +2597,10 @@
* @returns {vec2} dest
*/
vec2.divide = function(vecA, vecB, dest) {
- if (!dest) dest = vecB;
- dest[0] = vecA[0] / vecB[0];
- dest[1] = vecA[1] / vecB[1];
- return dest;
+ if (!dest) dest = vecB;
+ dest[0] = vecA[0] / vecB[0];
+ dest[1] = vecA[1] / vecB[1];
+ return dest;
};
/**
@@ -2503,10 +2616,10 @@
* @returns {vec2} dest
*/
vec2.scale = function(vecA, scalar, dest) {
- if (!dest) dest = vecA;
- dest[0] = vecA[0] * scalar;
- dest[1] = vecA[1] * scalar;
- return dest;
+ if (!dest) dest = vecA;
+ dest[0] = vecA[0] * scalar;
+ dest[1] = vecA[1] * scalar;
+ return dest;
};
/**
@@ -2565,11 +2678,11 @@
if (!dest) { dest = vec; }
var mag = vec[0] * vec[0] + vec[1] * vec[1];
if (mag > 0) {
- mag = Math.sqrt(mag);
- dest[0] = vec[0] / mag;
- dest[1] = vec[1] / mag;
+ mag = Math.sqrt(mag);
+ dest[0] = vec[0] / mag;
+ dest[1] = vec[1] / mag;
} else {
- dest[0] = dest[1] = 0;
+ dest[0] = dest[1] = 0;
}
return dest;
};
@@ -2584,7 +2697,7 @@
* var crossResult = vec3.create();
* vec2.cross([1, 2], [3, 4], crossResult);
* //=> [0, 0, -2]
- *
+ *
* vec2.cross([1, 2], [3, 4]);
* //=> -2
*
@@ -2597,11 +2710,11 @@
*
*/
vec2.cross = function (vecA, vecB, dest) {
- var z = vecA[0] * vecB[1] - vecA[1] * vecB[0];
- if (!dest) return z;
- dest[0] = dest[1] = 0;
- dest[2] = z;
- return dest;
+ var z = vecA[0] * vecB[1] - vecA[1] * vecB[0];
+ if (!dest) return z;
+ dest[0] = dest[1] = 0;
+ dest[2] = z;
+ return dest;
};
/**
@@ -2701,12 +2814,7 @@
mat2.create = function(src) {
var dest = new MatrixArray(4);
- if(arguments.length === 4) {
- dest[0] = arguments[0];
- dest[1] = arguments[1];
- dest[2] = arguments[2];
- dest[3] = arguments[3];
- } else if (src) {
+ if (src) {
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
@@ -2716,6 +2824,27 @@
}
return dest;
};
+
+ /**
+ * Creates a new instance of a mat2, initializing it with the given arguments
+ *
+ * @param {number} m00
+ * @param {number} m01
+ * @param {number} m10
+ * @param {number} m11
+
+ * @returns {mat2} New mat2
+ */
+ mat2.createFrom = function (m00, m01, m10, m11) {
+ var dest = new MatrixArray(4);
+
+ dest[0] = m00;
+ dest[1] = m01;
+ dest[2] = m10;
+ dest[3] = m11;
+
+ return dest;
+ };
/**
* Copies the values of one mat2 to another
@@ -2920,12 +3049,7 @@
vec4.create = function(vec) {
var dest = new MatrixArray(4);
- if(arguments.length === 4) {
- dest[0] = arguments[0];
- dest[1] = arguments[1];
- dest[2] = arguments[2];
- dest[3] = arguments[3];
- } else if (vec) {
+ if (vec) {
dest[0] = vec[0];
dest[1] = vec[1];
dest[2] = vec[2];
@@ -2938,6 +3062,27 @@
}
return dest;
};
+
+ /**
+ * Creates a new instance of a vec4, initializing it with the given arguments
+ *
+ * @param {number} x X value
+ * @param {number} y Y value
+ * @param {number} z Z value
+ * @param {number} w W value
+
+ * @returns {vec4} New vec4
+ */
+ vec4.createFrom = function (x, y, z, w) {
+ var dest = new MatrixArray(4);
+
+ dest[0] = x;
+ dest[1] = y;
+ dest[2] = z;
+ dest[3] = w;
+
+ return dest;
+ };
/**
* Adds the vec4's together. If dest is given, the result

0 comments on commit c6a5dc1

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