@vikasietum_tecknology/record-rtc
Version:
record-rtc is a library based on recordrtc library. In this forked version of the original library we have optimized the memory management. The video recording is stored in IndexDB in chunks.
28 lines (26 loc) • 377 kB
JavaScript
/*!
GLGE WebGL Graphics Engine
Copyright (c) 2010, Paul Brunt
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of GLGE nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PAUL BRUNT BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
typeof GLGE=="undefined"&&(GLGE={}),function(a){function c(){var b=a.Vec([1,2,3,4]),c=a.Vec4(a.getVec4(b,3),a.get1basedVec4(b,3),a.getVec4(b,1),a.getVec4(b,0)),d=a.identMatrix(),e=a.mulMat4Vec4(d,c);if(a.getVec4(e,0)!=4||a.getVec4(e,1)!=3||a.getVec4(e,2)!=2||a.getVec4(e,3)!=1)throw"Unit Test 1 failed MatVecMul "+e;var f=a.Mat4([3,4,5,0,.5,.75,0,0,.75,.5,0,0,.25,.25,1,1]),g=a.Mat4([2,1,8,2,1,4,3,2,1,.5,6.5,2,8,3,1,.25]),h=a.mulMat4(f,g),i=a.Mat4([15,21.5,68.5,24,1.75,3.5,6.25,2.5,2,2.75,7.5,2.5,9.75,4.75,10.25,3.25]);for(var j=0;j<4;++j)for(var k=0;k<4;++k){var l=a.getMat4(h,j,k)-a.getMat4(i,j,k);if(l>=1e-6||l<=-1e-6)throw"Unit Test 1 failed Multiplication "+a.getMat4(h,j,k)+" != "+a.getMat4(i,j,k)}var m=a.inverseMat4(f),n=a.mulMat4(f,m),o=a.mulMat4(m,f);for(var j=0;j<4;++j)for(var k=0;k<4;++k){var l=a.getMat4(n,j,k)-a.getMat4(d,j,k);if(l>=1e-4||l<=-1e-4)throw"Unit Test 1 failed Inverse "+a.getMat4(n,j,k)+" != "+a.getMat4(d,j,k)}}var b=[];a.reuseMatrix4=function(a){},a.matrix4=function(a,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){if(b.length==0)var r=[a,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q];else{var r=b.shift();r[0]=a,r[1]=c,r[2]=d,r[3]=e,r[4]=f,r[5]=g,r[6]=h,r[7]=i,r[8]=j,r[9]=k,r[10]=l,r[11]=m,r[12]=n,r[13]=o,r[14]=p,r[15]=q}return r},a.Vec=function(a){return a.slice(0)},a.Vec3=function(a,b,c){return[a,b,c]},a.Vec4=function(a,b,c,d){return[a,b,c,d]},a.get1basedVec4=function(a,b){return a[b-1]},a.get1basedVec3=function(a,b){return a[b-1]},a.getVec4=function(a,b){return a[b]},a.getVec3=function(a,b){return a[b]},a.addVec4=function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2],a[3]+b[3]]},a.addVec3=function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2]]},a.subVec4=function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2],a[3]-b[3]]},a.subVec3=function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2]]},a.negVec4=function(a){return[-a[0],-a[1],-a[2],-a[3]]},a.negVec3=function(a){return[-a[0],-a[1],-a[2]]},a.dotVec3=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},a.dotVec4=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},a.scaleVec4=function(a,b){return[a[0]*b,a[1]*b,a[2]*b,a[3]*b]},a.scaleVec3=function(a,b){return[a[0]*b,a[1]*b,a[2]*b]},a.crossVec3=function(a,b){return[a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]]},a.toUnitVec3=function(a){var b=a[0]*a[0]+a[1]*a[1]+a[2]*a[2],c=1;b>0&&(c=Math.pow(b,.5));return[a[0]/c,a[1]/c,a[2]/c]},a.toUnitVec4=function(a){var b=a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3],c=1;b>0&&(c=Math.pow(b,.5));return[a[0]/c,a[1]/c,a[2]/c,a[3]/c]},a.lengthVec3=function(a){return Math.pow(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],.5)},a.distanceVec3=function(b,c){return a.lengthVec3(a.subVec3(b,c))},a.lengthVec4=function(a,b){return Math.pow(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3],.5)},a.distanceVec4=function(b,c){return a.lengthVec4(a.subVec4(b,c))},a.angleVec3=function(b,c){b=a.toUnitVec3(b),c=a.toUnitVec3(c),d=a.dotVec3(b,c),d<-1&&(d=-1),d>1&&(d=1);return Math.acos(d)},a.angleVec4=function(b,c){b=a.toUnitVec4(b),c=a.toUnitVec4(c),d=a.dotVec4(b,c),d<-1&&(d=-1),d>1&&(d=1);return Math.acos(d)},GLGE_math_use_webgl_float=!1,a.Mat3=GLGE_math_use_webgl_float?function(a){if(a.length==9)return new Float32Array(a);if(a.length==16)return new Float32Array([a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]]);throw"invalid matrix length"}:function(a){var b;if(a.length==9)b=a.slice(0);else if(a.length==16)b=[a[0],a[1],a[2],a[4],a[5],a[6],a[8],a[9],a[10]];else throw"invalid matrix length";b.get=function(a){return this[a]};return b},a.Mat=GLGE_math_use_webgl_float?function(a){return new Float32Array(a)}:function(a){var b=a.slice(0);b.get=function(a){return this[a]};return b},a.Mat4=function(a){var b;if(a.length==9)b=[a[0],a[1],a[2],0,a[3],a[4],a[5],0,a[6],a[7],a[8],0,0,0,0,1];else if(a.length==16)a.slice?b=a.slice(0):b=a.subarray(0);else throw"invalid matrix length";b.get=function(a){return this[a]};return b},a.determinantMat4=function(a){return a[12]*a[9]*a[6]*a[3]-a[8]*a[13]*a[6]*a[3]-a[12]*a[5]*a[10]*a[3]+a[4]*a[13]*a[10]*a[3]+a[8]*a[5]*a[14]*a[3]-a[4]*a[9]*a[14]*a[3]-a[12]*a[9]*a[2]*a[7]+a[8]*a[13]*a[2]*a[7]+a[12]*a[1]*a[10]*a[7]-a[0]*a[13]*a[10]*a[7]-a[8]*a[1]*a[14]*a[7]+a[0]*a[9]*a[14]*a[7]+a[12]*a[5]*a[2]*a[11]-a[4]*a[13]*a[2]*a[11]-a[12]*a[1]*a[6]*a[11]+a[0]*a[13]*a[6]*a[11]+a[4]*a[1]*a[14]*a[11]-a[0]*a[5]*a[14]*a[11]-a[8]*a[5]*a[2]*a[15]+a[4]*a[9]*a[2]*a[15]+a[8]*a[1]*a[6]*a[15]-a[0]*a[9]*a[6]*a[15]-a[4]*a[1]*a[10]*a[15]+a[0]*a[5]*a[10]*a[15]},a.inverseMat4=function(b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=o*l*i*f-k*p*i*f-o*h*m*f+g*p*m*f+k*h*q*f-g*l*q*f-o*l*e*j+k*p*e*j+o*d*m*j-c*p*m*j-k*d*q*j+c*l*q*j+o*h*e*n-g*p*e*n-o*d*i*n+c*p*i*n+g*d*q*n-c*h*q*n-k*h*e*r+g*l*e*r+k*d*i*r-c*l*i*r-g*d*m*r+c*h*m*r;return a.matrix4((l*q*j-p*m*j+p*i*n-h*q*n-l*i*r+h*m*r)/s,(p*m*f-l*q*f-p*e*n+d*q*n+l*e*r-d*m*r)/s,(h*q*f-p*i*f+p*e*j-d*q*j-h*e*r+d*i*r)/s,(l*i*f-h*m*f-l*e*j+d*m*j+h*e*n-d*i*n)/s,(o*m*j-k*q*j-o*i*n+g*q*n+k*i*r-g*m*r)/s,(k*q*f-o*m*f+o*e*n-c*q*n-k*e*r+c*m*r)/s,(o*i*f-g*q*f-o*e*j+c*q*j+g*e*r-c*i*r)/s,(g*m*f-k*i*f+k*e*j-c*m*j-g*e*n+c*i*n)/s,(k*p*j-o*l*j+o*h*n-g*p*n-k*h*r+g*l*r)/s,(o*l*f-k*p*f-o*d*n+c*p*n+k*d*r-c*l*r)/s,(g*p*f-o*h*f+o*d*j-c*p*j-g*d*r+c*h*r)/s,(k*h*f-g*l*f-k*d*j+c*l*j+g*d*n-c*h*n)/s,(o*l*i-k*p*i-o*h*m+g*p*m+k*h*q-g*l*q)/s,(k*p*e-o*l*e+o*d*m-c*p*m-k*d*q+c*l*q)/s,(o*h*e-g*p*e-o*d*i+c*p*i+g*d*q-c*h*q)/s,(g*l*e-k*h*e+k*d*i-c*l*i-g*d*m+c*h*m)/s)},a.mulMat4Vec3=function(b,c){return a.Vec3(b[0]*c[0]+b[1]*c[1]+b[2]*c[2]+b[3],b[4]*c[0]+b[5]*c[1]+b[6]*c[2]+b[7],b[8]*c[0]+b[9]*c[1]+b[10]*c[2]+b[11])},a.mulMat4Vec4=function(b,c){return a.Vec4(b[0]*c[0]+b[1]*c[1]+b[2]*c[2]+b[3]*c[3],b[4]*c[0]+b[5]*c[1]+b[6]*c[2]+b[7]*c[3],b[8]*c[0]+b[9]*c[1]+b[10]*c[2]+b[11]*c[3],b[12]*c[0]+b[13]*c[1]+b[14]*c[2]+b[15]*c[3])},a.scaleMat4=function(b,c){return a.matrix4([b[0]*c,b[1]*c,b[2]*c,b[3]*c,b[4]*c,b[5]*c,b[6]*c,b[7]*c,b[8]*c,b[9]*c,b[10]*c,b[11]*c,b[12]*c,b[13]*c,b[14]*c,b[15]*c])},a.scaleInPlaceMat4=function(a,b){a.set(0,a[0]*b),a.set(1,a[1]*b),a.set(2,a[2]*b),a.set(3,a[3]*b),a.set(4,a[4]*b),a.set(5,a[5]*b),a.set(6,a[6]*b),a.set(7,a[7]*b),a.set(8,a[8]*b),a.set(9,a[9]*b),a.set(10,a[10]*b),a.set(11,a[11]*b),a.set(12,a[12]*b),a.set(13,a[13]*b),a.set(14,a[14]*b),a.set(15,a[15]*b);return a},a.addInPlaceMat4=function(a,b){a.set(0,a[0]+b[0]),a.set(1,a[1]+b[1]),a.set(2,a[2]+b[2]),a.set(3,a[3]+b[3]),a.set(4,a[4]+b[4]),a.set(5,a[5]+b[5]),a.set(6,a[6]+b[6]),a.set(7,a[7]+b[7]),a.set(8,a[8]+b[8]),a.set(9,a[9]+b[9]),a.set(10,a[10]+b[10]),a.set(11,a[11]+b[11]),a.set(12,a[12]+b[12]),a.set(13,a[13]+b[13]),a.set(14,a[14]+b[14]),a.set(15,a[15]+b[15]);return a},a.addMat4=function(b,c){return a.Mat([b[0]+c[0],b[1]+c[1],b[2]+c[2],b[3]+c[3],b[4]+c[4],b[5]+c[5],b[6]+c[6],b[7]+c[7],b[8]+c[8],b[9]+c[9],b[10]+c[10],b[11]+c[11],b[12]+c[12],b[13]+c[13],b[14]+c[14],b[15]+c[15]])},a.subInPlaceMat4=function(a,b){a.set(0,a[0]-b[0]),a.set(1,a[1]-b[1]),a.set(2,a[2]-b[2]),a.set(3,a[3]-b[3]),a.set(4,a[4]-b[4]),a.set(5,a[5]-b[5]),a.set(6,a[6]-b[6]),a.set(7,a[7]-b[7]),a.set(8,a[8]-b[8]),a.set(9,a[9]-b[9]),a.set(10,a[10]-b[10]),a.set(11,a[11]-b[11]),a.set(12,a[12]-b[12]),a.set(13,a[13]-b[13]),a.set(14,a[14]-b[14]),a.set(15,a[15]-b[15]);return a},a.subMat4=function(b,c){return a.Mat([b[0]-c[0],b[1]-c[1],b[2]-c[2],b[3]-c[3],b[4]-c[4],b[5]-c[5],b[6]-c[6],b[7]-c[7],b[8]-c[8],b[9]-c[9],b[10]-c[10],b[11]-c[11],b[12]-c[12],b[13]-c[13],b[14]-c[14],b[15]-c[15]])},a.mulMat4=function(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],j=c[6],k=c[7],l=c[8],m=c[9],n=c[10],o=c[11],p=c[12],q=c[13],r=c[14],s=c[15],t=b[0],u=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],E=b[11],F=b[12],G=b[13],H=b[14],I=b[15];return a.matrix4(t*d+u*h+v*l+w*p,t*e+u*i+v*m+w*q,t*f+u*j+v*n+w*r,t*g+u*k+v*o+w*s,x*d+y*h+z*l+A*p,x*e+y*i+z*m+A*q,x*f+y*j+z*n+A*r,x*g+y*k+z*o+A*s,B*d+C*h+D*l+E*p,B*e+C*i+D*m+E*q,B*f+C*j+D*n+E*r,B*g+C*k+D*o+E*s,F*d+G*h+H*l+I*p,F*e+G*i+H*m+I*q,F*f+G*j+H*n+I*r,F*g+G*k+H*o+I*s)},a.transposeInPlaceMat4=function(a){var b=a[1];a.set(1,a[4]),a.set(4,b),b=a[8],a.set(8,a[2]),a.set(2,b),b=a[3],a.set(3,a[12]),a.set(12,b),b=a[9],a.set(9,a[6]),a.set(6,b),b=a[13],a.set(13,a[7]),a.set(7,b),b=a[14],a.set(14,a[11]),a.set(11,b)},a.transposeMat4=function(b){return a.matrix4(b[0],b[4],b[8],b[12],b[1],b[5],b[9],b[13],b[2],b[6],b[10],b[14],b[3],b[7],b[11],b[15])},a.mat4gl=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]},a.set1basedMat4=function(a,b,c,d){a[(b-1)*4+(c-1)]=d,a.glData!==undefined&&delete a.glData},a.setMat4=function(a,b,c,d){a[b*4+c]=d,a.glData!==undefined&&delete a.glData},a.get1basedMat4=function(a,b,c){return a.get((b-1)*4+(c-1))},a.getMat4=function(a,b,c){return a[b*4+c]},a.glDataMat4=function(a){a.glArray=new Float32Array(a);return a.glArray},a.identMatrix=function(){return a.matrix4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},a.translateMatrix=function(b){var c,d,e;arguments.length==3?(c=arguments[0],d=arguments[1],e=arguments[2]):b.data?(c=b.data[0],d=b.data[1],e=b.data[2]):b instanceof Array&&(c=b[0],d=b[1],e=b[2]);return a.matrix4(1,0,0,c,0,1,0,d,0,0,1,e,0,0,0,1)},a.scaleMatrix=function(b){var c,d,e;arguments.length==3?(c=arguments[0],d=arguments[1],e=arguments[2]):b.data?(c=b.data[0],d=b.data[1],e=b.data[2]):b instanceof Array&&(c=b[0],d=b[1],e=b[2]);return a.matrix4(c,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1)},a.ROT_XYZ=1,a.ROT_XZY=2,a.ROT_YXZ=3,a.ROT_YZX=4,a.ROT_ZXY=5,a.ROT_ZYX=6,a.rotateMatrix=function(b,c){var d,e,f;arguments.length>2?(d=arguments[0],e=arguments[1],f=arguments[2],c=arguments[3]):b.data?(d=b.data[0],e=b.data[1],f=b.data[2]):b instanceof Array&&(d=b[0],e=b[1],f=b[2]),c||(c=a.ROT_XYZ);var g=Math.cos(d),h=Math.sin(d),i=Math.cos(e),j=Math.sin(e),k=Math.cos(f),l=Math.sin(f),m=a.matrix4(1,0,0,0,0,g,-h,0,0,h,g,0,0,0,0,1),n=a.matrix4(i,0,j,0,0,1,0,0,-j,0,i,0,0,0,0,1),o=a.matrix4(k,-l,0,0,l,k,0,0,0,0,1,0,0,0,0,1);switch(c){case a.ROT_XYZ:return a.mulMat4(m,a.mulMat4(n,o));case a.ROT_XZY:return a.mulMat4(m,a.mulMat4(o,n));case a.ROT_YXZ:return a.mulMat4(n,a.mulMat4(m,o));case a.ROT_YZX:return a.mulMat4(n,a.mulMat4(o,m));case a.ROT_ZXY:return a.mulMat4(o,a.mulMat4(m,n));case a.ROT_ZYX:return a.mulMat4(o,a.mulMat4(n,m))}},a.angleAxis=function(b,c){var d,e,f,g,h,i,j,k,l;c=[c[0],c[1],c[2],0];var m=c[0],n=c[1],o=c[2],p=Math.cos(b),q=1-p,r=Math.sin(b);j=m*r,k=n*r,l=o*r,d=m*m,e=n*n,f=o*o,g=m*n,h=n*o,i=o*m;var s=a.matrix4(q*d+p,q*g-l,q*i+k,0,q*g+l,q*e+p,q*h-j,0,q*i-k,q*h+j,q*f+p,0,0,0,0,1);return a.Mat(s)},a.quatFromAxisAngle=function(a,b){var c=[],d=b*.5,e=Math.sin(d),f=Math.cos(d);c[0]=a[0]*e,c[1]=a[1]*e,c[2]=a[2]*e,c[3]=f;return c},a.mulQuat=function(a,b){var c=[],d=a[0],e=a[1],f=a[2],g=a[3],h=b[0],i=b[1],j=b[2],k=b[3],l=e*j-f*i,m=f*h-d*j,n=d*i-e*h,o=d*h+e*i+f*j;c[0]=d*k+h*g+l,c[1]=e*k+i*g+m,c[2]=f*k+j*g+n,c[3]=g*k-o;return c},a.mat4FromQuat=function(a){var b=a[0]*a[0],c=a[1]*a[1],d=a[2]*a[2],e=a[0]*a[1],f=a[2]*a[3],g=a[2]*a[0],h=a[1]*a[3],i=a[1]*a[2],j=a[0]*a[3],k=[];k[0]=1-2*(c+d),k[1]=2*(e+f),k[2]=2*(g-h),k[3]=0,k[4]=2*(e-f),k[5]=1-2*(d+b),k[6]=2*(i+j),k[7]=0,k[8]=2*(g+h),k[9]=2*(i-j),k[10]=1-2*(c+b),k[11]=0,k[12]=0,k[13]=0,k[14]=0,k[15]=1;return k},a.quatRotation=function(b,c,d,e){return a.matrix4(1-2*c*c-2*d*d,2*b*c-2*d*e,2*b*d+2*c*e,0,2*b*c+2*d*e,1-2*b*b-2*d*d,2*c*d-2*b*e,0,2*b*d-2*c*e,2*c*d+2*b*e,1-2*b*b-2*c*c,0,0,0,0,1)},a.makeOrtho=function(b,c,d,e,f,g){var h=-(c+b)/(c-b),i=-(e+d)/(e-d),j=-(g+f)/(g-f);return a.matrix4(2/(c-b),0,0,h,0,2/(e-d),0,i,0,0,-2/(g-f),j,0,0,0,1)},a.makeFrustum=function(b,c,d,e,f,g){var h=2*f/(c-b),i=2*f/(e-d),j=(c+b)/(c-b),k=(e+d)/(e-d),l=-(g+f)/(g-f),m=-2*g*f/(g-f);return a.matrix4(h,0,j,0,0,i,k,0,0,0,l,m,0,0,-1,0)},a.makePerspective=function(b,c,d,e){var f=d*Math.tan(b*.00872664625972),g=-f,h=g*c,i=f*c;return a.makeFrustum(h,i,g,f,d,e)},a.makePerspectiveX=function(b,c,d,e){var f=d*Math.tan(b*.00872664625972),g=-f,h=g/c,i=f/c;return a.makeFrustum(g,f,h,i,d,e)},a.matrix2Scale=function(a){var b=a[0],c=a[1],d=a[2],e=a[4],f=a[5],g=a[6],h=a[8],i=a[9],j=a[10],k=Math.sqrt(b*b+c*c+d*d),l=Math.sqrt(e*e+f*f+g*g),m=Math.sqrt(h*h+i*i+j*j);return[k,l,m]},a.rotationMatrix2Quat=function(a){var b=a[0]+a[5]+a[10]+1,c,d,e,f,g;b>0?(c=.5/Math.sqrt(b),g=.25/c,d=(a[9]-a[6])*c,e=(a[2]-a[8])*c,f=(a[4]-a[1])*c):a[0]>a[5]&&a[0]>a[10]?(c=Math.sqrt(1+a[0]-a[5]-a[10])*2,g=(a[9]-a[6])/c,d=.25/c,e=(a[1]+a[4])/c,f=(a[2]+a[8])/c):a[5]>a[10]?(c=Math.sqrt(1+a[5]-a[0]-a[10])*2,g=(a[2]-a[8])/c,d=(a[1]+a[4])/c,e=.25/c,f=(a[6]+a[9])/c):(c=Math.sqrt(1+a[10]-a[0]-a[5])*2,g=(a[4]-a[1])/c,d=(a[2]+a[8])/c,e=(a[6]+a[9])/c,f=.25/c);var h=Math.sqrt(d*d+e*e+f*f+g*g);return[d/h,e/h,f/h,g/h]},a.rayToPlane=function(b,c){var d=a.toUnitVec3(c);return[d[0],d[1],d[2],a.dotVec3(b,d)]},a.rayIntersectPlane=function(b,c,d){var e=[d[0],d[1],d[2]],f=d[3],g=a.dotVec3(e,c);if(g<=0)return!1;var h=-(a.dotVec3(e,b)+f),i=h/g;if(i<=0)return!1;return a.addVec3(b,a.scaleVec3(c,i))},a.screenToDirection=function(b,c,d,e,f){xcoord=-(2*b/d-1)/f[0],ycoord=(2*c/e-1)/f[5],zcoord=1;return a.toUnitVec3([xcoord,ycoord,zcoord])},a.BoundingVolume=function(a,b,c,d,e,f){this.limits=[a,b,c,d,e,f],this.calcProps()},a.BoundingVolume.prototype.getCornerPoints=function(){return this.points},a.BoundingVolume.prototype.getSphereRadius=function(){return this.radius},a.BoundingVolume.prototype.getCenter=function(){return this.center},a.BoundingVolume.prototype.isNull=function(){return this.limits[0]==0&&this.limits[1]==0&&this.limits[2]==0&&this.limits[3]==0&&this.limits[4]==0&&this.limits[5]==0},a.BoundingVolume.prototype.addBoundingVolume=function(a){this.isNull()?(this.limits[0]=a.limits[0],this.limits[1]=a.limits[1],this.limits[2]=a.limits[2],this.limits[3]=a.limits[3],this.limits[4]=a.limits[4],this.limits[5]=a.limits[5]):a.isNull()||(this.limits[0]=Math.min(a.limits[0],this.limits[0]),this.limits[2]=Math.min(a.limits[2],this.limits[2]),this.limits[4]=Math.min(a.limits[4],this.limits[4]),this.limits[1]=Math.max(a.limits[1],this.limits[1]),this.limits[3]=Math.max(a.limits[3],this.limits[3]),this.limits[5]=Math.max(a.limits[5],this.limits[5])),this.calcProps()},a.BoundingVolume.prototype.applyMatrix=function(b){var c=a.mulMat4Vec4(b,[this.limits[0],this.limits[2],this.limits[4],1]),d=a.mulMat4Vec4(b,[this.limits[1],this.limits[2],this.limits[4],1]),e=a.mulMat4Vec4(b,[this.limits[0],this.limits[3],this.limits[4],1]),f=a.mulMat4Vec4(b,[this.limits[1],this.limits[3],this.limits[4],1]),g=a.mulMat4Vec4(b,[this.limits[0],this.limits[2],this.limits[5],1]),h=a.mulMat4Vec4(b,[this.limits[1],this.limits[2],this.limits[5],1]),i=a.mulMat4Vec4(b,[this.limits[0],this.limits[3],this.limits[5],1]),j=a.mulMat4Vec4(b,[this.limits[1],this.limits[3],this.limits[5],1]);this.limits[0]=Math.min(c[0],d[0],e[0],f[0],g[0],h[0],i[0],j[0]),this.limits[1]=Math.max(c[0],d[0],e[0],f[0],g[0],h[0],i[0],j[0]),this.limits[2]=Math.min(c[1],d[1],e[1],f[1],g[1],h[1],i[1],j[1]),this.limits[3]=Math.max(c[1],d[1],e[1],f[1],g[1],h[1],i[1],j[1]),this.limits[4]=Math.min(c[2],d[2],e[2],f[2],g[2],h[2],i[2],j[2]),this.limits[5]=Math.max(c[2],d[2],e[2],f[2],g[2],h[2],i[2],j[2]),this.calcProps()},a.BoundingVolume.prototype.calcProps=function(){var a=this.limits[0],b=this.limits[1],c=this.limits[2],d=this.limits[3],e=this.limits[4],f=this.limits[5];this.points=[[a,c,e],[b,c,e],[a,d,e],[b,d,e],[a,c,f],[b,c,f],[a,d,f],[b,d,f]],this.center=[(this.limits[1]-this.limits[0])/2+this.limits[0],(this.limits[3]-this.limits[2])/2+this.limits[2],(this.limits[5]-this.limits[4])/2+this.limits[4]];var g=this.limits[0]-this.center[0],h=this.limits[2]-this.center[1],i=this.limits[4]-this.center[2];this.radius=Math.sqrt(g*g+h*h+i*i)},a.BoundingVolume.prototype.clone=function(){return new a.BoundingVolume(this.limits[0],this.limits[1],this.limits[2],this.limits[3],this.limits[4],this.limits[5])},a.BoundingVolume.prototype.toString=function(){return this.limits.toString()},a.cameraViewProjectionToPlanes=function(b){var c=a.inverseMat4(b),d=a.mulMat4Vec4,e=a.subVec3,f=a.crossVec3,g=a.toUnitVec3,h=a.dotVec3,i=d(c,[-1,-1,-1,1]),j=d(c,[1,-1,-1,1]),k=d(c,[-1,-1,1,1]),l=d(c,[1,1,-1,1]),m=d(c,[1,1,1,1]),n=d(c,[-1,1,1,1]);i=[i[0]/i[3],i[1]/i[3],i[2]/i[3]],j=[j[0]/j[3],j[1]/j[3],j[2]/j[3]],k=[k[0]/k[3],k[1]/k[3],k[2]/k[3]],l=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],m=[m[0]/m[3],m[1]/m[3],m[2]/m[3]],n=[n[0]/n[3],n[1]/n[3],n[2]/n[3]];var o=g(f(e(l,j),e(i,j))),p=g(f(e(n,k),e(m,k))),q=g(f(e(i,k),e(n,k))),r=g(f(e(m,l),e(l,j))),s=g(f(e(n,l),e(l,m))),t=g(f(e(i,j),e(k,i)));o.push(h(o,i)),p.push(h(p,k)),q.push(h(q,i)),r.push(h(r,j)),s.push(h(s,m)),t.push(h(t,i));return[o,p,q,r,s,t]},a.sphereInFrustumPlanes=function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=b[0],h=b[1],i=b[2],j=b[3],k=b[4],l=b[5];return c*g[0]+d*g[1]+e*g[2]-g[3]-f>0||c*h[0]+d*h[1]+e*h[2]-h[3]-f>0||c*i[0]+d*i[1]+e*i[2]-i[3]-f>0||c*j[0]+d*j[1]+e*j[2]-j[3]-f>0||c*k[0]+d*k[1]+e*k[2]-k[3]-f>0||c*l[0]+d*l[1]+e*l[2]-l[3]-f>0?!1:!0},a.pointsInFrustumPlanes=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i,j,k;for(var l=0;l<a.length;l++){i=a[l][0],j=a[l][1],k=a[l][2];if(i*c[0]+j*c[1]+k*c[2]-c[3]>0&&i*d[0]+j*d[1]+k*d[2]-d[3]>0&&i*e[0]+j*e[1]+k*e[2]-f[3]>0&&i*f[0]+j*f[1]+k*f[2]-g[3]>0&&i*g[0]+j*g[1]+k*g[2]-g[3]>0&&i*h[0]+j*h[1]+k*h[2]-h[3]>0)return!1}return!0},a.getDirLightProjection=function(b,c,d,e){var f=a.mulMat4(c,a.inverseMat4(b)),g=[0,0,0],h=[0,0,0];for(var i=0;i<2;i++)for(var j=0;j<2;j++)for(var k=0;k<2;k++){var l=a.mulMat4Vec4(f,[i*2-1,j*2-1,k*2-1,1]);l[0]=l[0]/l[3],l[1]=l[1]/l[3],l[2]=l[2]/l[3],g[0]=g[0]>l[0]?l[0]:g[0],g[1]=g[1]>l[1]?l[1]:g[1],h[0]=h[0]<l[0]?l[0]:h[0],h[1]=h[1]<l[1]?l[1]:h[1],h[2]=h[2]<l[2]?l[2]:h[2]}var m=a.makeOrtho(g[0],h[0],g[1],h[1],.01,+e);return m},c()}(GLGE),typeof GLGE=="undefined"&&(GLGE={}),function(a){var b=function(a){return typeof a!="number"?parseFloat(a):a};a.augment=function(a,b){b.prototype.baseclass=a;for(var c in a.prototype)b.prototype[c]?b.prototype.baseclass[c]=a.prototype[c]:b.prototype[c]=a.prototype[c]},a.makeGlobal=function(){for(var b in a)window[b]=a[b]},a.New=function(b){return a[b].prototype.className!=""?new a[b]:!1},a.TRUE=1,a.FALSE=0,a.GLOBAL=0,a.LOCAL=1,a.DRAW_TRIS=1,a.DRAW_LINES=2,a.DRAW_LINELOOPS=3,a.DRAW_LINESTRIPS=4,a.DRAW_POINTS=5,a.DRAW_TRIANGLESTRIP=6,a.RENDER_DEFAULT=0,a.RENDER_SHADOW=1,a.RENDER_PICK=2,a.RENDER_NORMAL=3,a.RENDER_EMIT=4,a.RENDER_DEPTH=5,a.RENDER_NULL=6,a.TEXT_BOXPICK=1,a.TEXT_TEXTPICK=2,a.P_EULER=1,a.P_QUAT=2,a.P_MATRIX=3,a.NONE=0,a.XAXIS=1,a.YAXIS=2,a.ZAXIS=3,a.POS_XAXIS=1,a.NEG_XAXIS=2,a.POS_YAXIS=3,a.NEG_YAXIS=4,a.POS_ZAXIS=5,a.NEG_ZAXIS=6,a.ZERO="ZERO",a.ONE="ONE",a.SRC_COLOR="SRC_COLOR",a.ONE_MINUS_SRC_COLOR="ONE_MINUS_SRC_COLOR",a.SRC_ALPHA="SRC_ALPHA",a.ONE_MINUS_SRC_ALPHA="ONE_MINUS_SRC_ALPHA",a.DST_ALPHA="DST_ALPHA",a.ONE_MINUS_DST_ALPHA="ONE_MINUS_DST_ALPHA",a.LINEAR_BLEND=function(a){return a},a.QUAD_BLEND=function(a){return a*a},a.SPECIAL_BLEND=function(a){a=a*(2-a);return a*a},a.error=function(a){console&&console.log&&console.log("GLGE error: "+a)},a.warning=function(a){console&&console.log&&console.log("GLGE warning: "+a)},a.Assets={},a.Assets.assets={},a.REGISTER_ASSETS=!1,a.Assets.createUUID=function(){var a=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],b=["8","9","A","B"];uuid="";for(var c=0;c<38;c++)switch(c){case 8:uuid=uuid+"-";break;case 13:uuid=uuid+"-";break;case 18:uuid=uuid+"-";break;case 14:uuid=uuid+"4";break;case 19:uuid=uuid+b[Math.round(Math.random()*3)];break;default:uuid=uuid+a[Math.round(Math.random()*15)]}return uuid},a.Assets.registerAsset=function(b,c){typeof c=="object"&&(b._&&b._(c),c=c.uid),c||(c=a.Assets.createUUID()),b.uid=c,a.REGISTER_ASSETS&&(a.Assets.assets[c]=b)},a.Assets.unregisterAsset=function(b){delete a.Assets.assets[b]},a.Assets.get=function(b){var c=a.Assets.assets[b];return c?c:!1},a.DJBHash=function(a){var b=5381;for(var c=0;c<a.length;c++)b=(b<<5)+b+a.charCodeAt(c);return b},a.getGLShader=function(b,c,d){var e=a.DJBHash(d);b.shaderCache||(b.shaderCache={});if(!b.shaderCache[e]){var f=b.createShader(c);b.shaderSource(f,d),b.compileShader(f);if(!b.getShaderParameter(f,b.COMPILE_STATUS))try{a.error(b.getShaderInfoLog(f));return}catch(g){}b.shaderCache[e]=f}return b.shaderCache[e]};var c=0;a.getGLProgram=function(b,d,e){b.programCache||(b.programCache=[]);var f=b.programCache;for(var g=0;g<f.length;g++)if(f[g].fShader==e&&f[g].vShader==d)return f[g].program;var h=b.createProgram();h.progIdx=c++,b.attachShader(h,d),b.attachShader(h,e),b.linkProgram(h),b.getProgramParameter(h,b.LINK_STATUS)||a.error("Couldn't link shader: "+b.getProgramInfoLog(h)),f.push({vShader:d,fShader:e,program:h});if(!h.uniformDetails){h.uniformDetails={};var i=b.getProgramParameter(h,b.ACTIVE_UNIFORMS);for(var g=0;g<i;++g){var j=b.getActiveUniform(h,g);h.uniformDetails[j.name]={loc:a.getUniformLocation(b,h,j.name),info:j}}}return h},a.getUniformLocation=function(a,b,c){b.uniformCache||(b.uniformCache={}),b.uniformChecked||(b.uniformChecked={}),b.uniformChecked[c]||(b.uniformCache[c]=a.getUniformLocation(b,c),b.uniformChecked[c]=!0);return b.uniformCache[c]},a.setUniform=function(a,b,c,d){typeof d=="string"&&(d=+d),c!=null&&a["uniform"+b](c,d)},a.setUniform3=function(a,b,c,d,e,f){typeof d=="string"&&(d=+d),typeof e=="string"&&(e=+e),typeof f=="string"&&(f=+f),c!=null&&a["uniform"+b](c,d,e,f)},a.setUniform2=function(a,b,c,d,e){typeof d=="string"&&(d=+d),typeof e=="string"&&(e=+e),c!=null&&a["uniform"+b](c,d,e)},a.setUniform4=function(a,b,c,d,e,f,g){c!=null&&a["uniform"+b](c,d,e,f,g)},a.setUniformMatrix=function(a,b,c,d,e){c!=null&&a["uniform"+b](c,d,e)},a.getAttribLocation=function(a,b,c){b.attribCache||(b.attribCache={}),b.attribCache[c]==undefined&&(b.attribCache[c]=a.getAttribLocation(b,c));return b.attribCache[c]},a.colorParse=function(a){var b,c,d,e,f={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};f[a]&&(a="#"+f[a]);if(a.substr&&a.substr(0,1)=="#")a=a.substr(1),a.length==8?(b=parseInt("0x"+a.substr(0,2))/255,c=parseInt("0x"+a.substr(2,2))/255,d=parseInt("0x"+a.substr(4,2))/255,e=parseInt("0x"+a.substr(6,2))/255):a.length==4?(b=parseInt("0x"+a.substr(0,1))/15,c=parseInt("0x"+a.substr(1,1))/15,d=parseInt("0x"+a.substr(2,1))/15,e=parseInt("0x"+a.substr(3,1))/15):a.length==6?(b=parseInt("0x"+a.substr(0,2))/255,c=parseInt("0x"+a.substr(2,2))/255,d=parseInt("0x"+a.substr(4,2))/255,e=1):a.length==3&&(b=parseInt("0x"+a.substr(0,1))/15,c=parseInt("0x"+a.substr(1,1))/15,d=parseInt("0x"+a.substr(2,1))/15,e=1);else if(a.substr&&a.substr(0,4)=="rgb("){var g=a.substr(4).split(",");b=parseInt(g[0])/255,c=parseInt(g[1])/255,d=parseInt(g[2])/255,e=1}else if(a.substr&&a.substr(0,5)=="rgba("){var g=a.substr(4).split(",");b=parseInt(g[0])/255,c=parseInt(g[1])/255,d=parseInt(g[2])/255,e=parseInt(g[3])/255}else b=0,c=0,d=0,e=0;return{r:b,g:c,b:d,a:e}}}(GLGE),function(a){a.Events=function(){},a.Events.prototype.fireEvent=function(a,b){if(this.events&&this.events[a]){var c=this.events[a];for(var d=0;d<c.length;d++)c[d]&&c[d].call&&c[d].call(this,b)}},a.Events.prototype.addEventListener=function(a,b){this.events||(this.events={}),this.events[a]||(this.events[a]=[]),this.events[a].push(b)},a.Events.prototype.removeEventListener=function(a,b){if(this.events[a]){var c=this.events[a].indexOf(b);c!=-1&&this.events[a].splice(c,1)}}}(GLGE),function(a){a.QuickNotation=function(){},a.QuickNotation.prototype._=function(){var a;for(var b=0;b<arguments.length;b++){a=arguments[b];if(typeof a=="object")if(a.className&&this["add"+a.className])this["add"+a.className](a);else for(var c in a)this["set"+c]&&this["set"+c](a[c])}return this}}(GLGE),function(a){a.Animatable=function(){},a.augment(a.Events,a.Animatable),a.Animatable.prototype.animationStart=null,a.Animatable.prototype.animation=null,a.Animatable.prototype.blendStart=0,a.Animatable.prototype.blendTime=0,a.Animatable.prototype.lastFrame=null,a.Animatable.prototype.frameRate=30,a.Animatable.prototype.loop=a.TRUE,a.Animatable.prototype.paused=a.FALSE,a.Animatable.prototype.pausedTime=null,a.Animatable.prototype.blendFunction=a.LINEAR_BLEND,a.Animatable.prototype.blendTo=function(b,c,d){d||(d=a.LINEAR_BLEND);var e=new a.AnimationVector,f,g;for(var h in b)f=new a.AnimationCurve,f.setChannel(h),g=new a.LinearPoint,g.setX(1),g.setY(b[h]),f.addPoint(g),e.addAnimationCurve(f);this.setBlendFunction(d),this.setAnimation(e,c);return this},a.Animatable.prototype.setBlendFunction=function(a){this.blendFunction=a;return this},a.Animatable.prototype.getBlendFunction=function(){return this.blendFunction},a.Animatable.prototype.setName=function(a){this.name=a;return this},a.Animatable.prototype.getName=function(){return this.name},a.Animatable.prototype.getFrameNumber=function(a){this.startFrame||(this.startFrame=this.animation.startFrame),this.animFrames||(this.animFrames=this.animation.frames);var b;a||(a=parseInt((new Date).getTime())),this.animFrames>1?this.loop?b=(parseFloat(a)-parseFloat(this.animationStart))/1e3*this.frameRate%(this.animFrames-1)+1+this.startFrame:(b=(parseFloat(a)-parseFloat(this.animationStart))/1e3*this.frameRate+1+this.startFrame,b>=this.animFrames+this.startFrame&&(b=this.animFrames)):b=1;return Math.round(b)},a.Animatable.prototype.setStartFrame=function(a,b,c){this.loop=c;var d=parseInt((new Date).getTime());b||(b=0),b>0&&(this.animation&&(this.blendInitValues=this.getInitialValues(this.animation,d),this.blendTime=b)),this.animationStart=d,this.lastFrame=null,this.animFinished=!1,this.startFrame=a;if(this.children)for(var e=0;e<this.children.length;e++)this.children[e].setStartFrame&&this.children[e].setStartFrame(a,b,c);return this},a.Animatable.prototype.setFrames=function(a){this.animFrames=a;if(this.children)for(var b=0;b<this.children.length;b++)this.children[b].setFrames&&this.children[b].setFrames(a);return this},a.Animatable.prototype.getInitialValues=function(a,b){var c={};this.animation&&(this.lastFrame=null,this.animate(b,!0));for(var d in a.curves)this["get"+d]&&(c[d]=this["get"+d]());return c},a.Animatable.prototype.animate=function(a,b){if(!this.paused&&this.animation){a||(a=parseInt((new Date).getTime()));var c=this.getFrameNumber(a);this.animation.animationCache||(this.animation.animationCache={});if(c!=this.lastFrame||this.blendTime!=0){this.lastFrame=c;if(this.blendTime==0)if(!this.animation.animationCache[c]||b){this.animation.animationCache[c]=[];if(this.animation.curves.LocX&&this.animation.curves.LocY&&this.animation.curves.LocZ&&this.animation.curves.ScaleX&&this.animation.curves.ScaleY&&this.animation.curves.ScaleZ&&this.animation.curves.QuatX&&this.animation.curves.QuatY&&this.animation.curves.QuatZ&&this.animation.curves.QuatW){for(var d in this.animation.curves)if(this["set"+d]){var e=this.animation.curves[d].getValue(parseFloat(c));switch(d){case"QuatX":case"QuatY":case"QuatZ":case"QuatW":case"LocX":case"LocY":case"LocZ":case"ScaleX":case"ScaleY":case"ScaleZ":break;default:this.animation.animationCache[c].push({property:d,value:e})}this["set"+d](e)}this.animation.animationCache[c].push({property:"StaticMatrix",value:this.getLocalMatrix()})}else{for(d in this.animation.curves)if(this["set"+d]){var e=this.animation.curves[d].getValue(parseFloat(c));switch(d){case"QuatX":case"QuatY":case"QuatZ":case"QuatW":case"RotX":case"RotY":case"RotZ":var f=!0;break;default:this.animation.animationCache[c].push({property:d,value:e})}this["set"+d](e)}f&&(e=this.getRotMatrix(),this.animation.animationCache[c].push({property:"RotMatrix",value:e}))}}else{var g=this.animation.animationCache[c];for(var h=0;h<g.length;h++)this["set"+g[h].property]&&this["set"+g[h].property](g[h].value)}else{var i=a-this.animationStart;if(i<this.blendTime){var j=i/this.blendTime;j=this.blendFunction(j);for(d in this.animation.curves)if(this["set"+d]){var e=this.animation.curves[d].getValue(parseFloat(c));e=e*j+this.blendInitValues[d]*(1-j),this["set"+d](e)}}else this.blendTime=0}}}if(this.children)for(var h=0;h<this.children.length;h++)this.children[h].animate&&this.children[h].animate(a,b);this.animation&&!this.animFinished&&this.blendTime==0&&this.animation.frames==c&&!b&&(this.animFinished=!0,this.fireEvent("animFinished",{}))},a.Animatable.prototype.setAnimation=function(a,b,c){c==null&&(c=parseInt((new Date).getTime())),b||(b=0),b>0&&(this.blendInitValues=this.getInitialValues(a,c),this.blendTime=b),this.animFrames=null,this.startFrame=null,this.animationStart=c,this.lastFrame=null,this.animation=a,this.animFinished=!1;return this},a.Animatable.prototype.getAnimation=function(){return this.animation},a.Animatable.prototype.setFrameRate=function(a){this.frameRate=a;if(this.children)for(var b=0;b<this.children.length;b++)this.children[b].setFrameRate&&this.children[b].setFrameRate(a);return this},a.Animatable.prototype.getFrameRate=function(){return this.frameRate},a.Animatable.prototype.setLoop=function(a){this.loop=a;return this},a.Animatable.prototype.getLoop=function(){return this.loop},a.Animatable.prototype.isLooping=a.Animatable.prototype.getLoop,a.Animatable.prototype.setPaused=function(a){a?this.pauseTime=parseInt((new Date).getTime()):this.animationStart=this.animationStart+(parseInt((new Date).getTime())-this.pauseTime),this.paused=a;return this},a.Animatable.prototype.getPaused=function(){return this.paused},a.Animatable.prototype.togglePaused=function(){this.setPaused(!this.getPaused());return this.paused}}(GLGE),function(a){a.Document=function(){this.listeners=[],this.documents=[]},a.Document.prototype.listeners=null,a.Document.prototype.documents=null,a.Document.prototype.rootURL=null,a.Document.prototype.loadCount=0,a.Document.prototype.version=0,a.Document.prototype.preloader=null,a.Document.prototype.getElementById=function(a){var b=this.getElementsByTagName("*");for(var c=0;c<b.length;c++)if(b[c].getAttribute("id")==a)return b[c];return null},a.Document.prototype.getAbsolutePath=function(a,b){if(a.substr(0,7)=="http://"||a.substr(0,7)=="file://"||a.substr(0,8)=="https://")return a;b||(b=window.location.href);var c=b.split("/"),d=c[2],e=c[0],f=[];for(var g=3;g<c.length-1;g++)f.push(c[g]);a.substr(0,1)=="/"&&(f=[]);var h=a.split("/");for(var g=0;g<h.length;g++)h[g]==".."?f.pop():h[g]!=""&&f.push(h[g]);return e+"//"+d+"/"+f.join("/")},a.Document.prototype.load=function(a,b){b&&this.usePreloader(b),this.documents=[],this.rootURL=a,this.loadDocument(a,null)},a.Document.prototype.loadDocument=function(b,c){this.loadCount++,b=this.getAbsolutePath(b,c);if(this.preloader)this.preloader.loadXMLFile(b);else{var d=new XMLHttpRequest;d&&(d.docurl=b,d.docObj=this,d.overrideMimeType("text/xml"),d.onreadystatechange=function(){this.readyState==4&&(this.status==200||this.status==0?(this.responseXML.getElementById=this.docObj.getElementById,this.docObj.loaded(this.docurl,this.responseXML)):a.error("Error loading Document: "+this.docurl+" status "+this.status))},d.open("GET",b,!0),d.send(""))}},a.Document.prototype.loaded=function(a,b){this.loadCount--,this.documents[a]={xml:b,url:a};var c=b.getElementsByTagName("glge");c[0]&&c[0].hasAttribute("version")&&(this.version=parseFloat(c[0].getAttribute("version")));var d=b.getElementsByTagName("import");for(var e=0;e<d.length;e++)this.documents[this.getAbsolutePath(d[e].getAttribute("url"),a)]||(this.documents[this.getAbsolutePath(d[e].getAttribute("url"),a)]={},this.loadDocument(d[e].getAttribute("url"),a));this.loadCount==0&&this.finishedLoading()},a.Document.prototype.finishedLoading=function(){for(var a=0;a<this.listeners.length;a++)this.listeners[a](this.rootURL);this.onLoad()},a.Document.prototype.onLoad=function(){},a.Document.prototype.usePreloader=function(b){this.preloader=new a.DocumentPreloader(this,b);var c=this;this.addLoadListener(function(a){c.preloadImages.call(c)})},a.Document.prototype.preloadImages=function(){var a=[],b=[];for(var c in this.documents)this.documents[c].xml&&(a.push(this.documents[c].xml.getElementsByTagName("texture")),b.push(this.documents[c].url));for(var d in a)for(var e=0;e<a[d].length;e++){var f=a[d][e].getAttribute("src");f&&this.preloader.addImage(this.getAbsolutePath(f,b[d]))}this.preloader.loadImages()},a.Document.prototype.classString=function(a){if(!a)return!1;var b=a.split("_"),c="";for(var d=0;d<b.length;d++)c=c+b[d][0].toUpperCase()+b[d].substr(1);return c},a.Document.prototype.setProperties=function(b){var c,d,e;for(var f=0;f<b.attributes.length;f++)e=!1,c="set"+this.classString(b.attributes[f].nodeName),b.attributes[f].value[0]=="#"&&(e=this.getElement(b.attributes[f].value.substr(1),!0)),e||(typeof a[b.attributes[f].value]!="undefined"?e=a[b.attributes[f].value]:e=b.attributes[f].value),b.object[c]&&b.object[c](e==parseFloat(e)?parseFloat(e):e),b.attributes[f].nodeName=="uid"&&(a.Assets.unregisterAsset(b.object.uid),b.object.uid=b.attributes[f].value,a.Assets.registerAsset(b.object,b.attributes[f].value))},a.Document.prototype.addChildren=function(a){var b,c=a.firstChild;while(c)b="add"+this.classString(c.tagName),a.object[b]&&a.object[b](this.getElement(c)),c=c.nextSibling},a.Document.prototype.getElement=function(b,c){var d,e;if(typeof b=="string")for(var e in this.documents)if(this.documents[e].xml){d=this.documents[e].xml.getElementById(b);if(d){b=d;break}}if(typeof b=="string"){c||a.error("Element "+b+" not found in document");return!1}return this["get"+this.classString(b.tagName)]?this["get"+this.classString(b.tagName)](b):this.getDefault(b)},a.Document.prototype.getData=function(b){if(!b.object){b.object=this.parseArray(b);if(b.hasAttribute("type")){var c=b.getAttribute("type");switch(c){case"matrix":for(var d=0;d<b.object.length;d++)b.object[d]=a.Mat4(b.object[d].split(" "));break;case"links":for(var d=0;d<b.object.length;d++)b.object[d]=this.getElement(b.object[d].substr(1))}}}return b.object},a.Document.prototype.getDefault=function(b){b.object||(a[this.classString(b.tagName)]?(b.object=new(a[this.classString(b.tagName)]),this.setProperties(b),this.addChildren(b)):a.error("XML Parse Error: GLGE Object not found"));return b.object},a.Document.prototype.getTexture=function(b){if(!b.object){var c=this.getAbsolutePath(this.rootURL,null);b.object=new(a[this.classString(b.tagName)]),b.object.setSrc(this.getAbsolutePath(b.getAttribute("src"),c)),b.removeAttribute("src"),this.setProperties(b)}return b.object},a.Document.prototype.getTextureVideo=a.Document.prototype.getTexture,a.Document.prototype.parseArray=function(a){var b=a.firstChild,c="",d=[],e,f;while(b){e=(c+b.nodeValue).split(","),b=b.nextSibling,e[0]==""&&e.unshift(),b&&(c=e.pop());for(var f=0;f<e.length;f++)d.push(e[f])}return d},a.Document.prototype.getMesh=function(b){if(this.version>0)return this.getDefault(b);if(!b.object){b.object=new a.Mesh,this.setProperties(b);var c=b.firstChild;while(c){switch(c.tagName){case"positions":b.object.setPositions(this.parseArray(c));break;case"normals":b.object.setNormals(this.parseArray(c));break;case"uv1":b.object.setUV(this.parseArray(c));break;case"uv2":b.object.setUV2(this.parseArray(c));break;case"faces":b.object.setFaces(this.parseArray(c));break;case"color":b.object.setVertexColors(this.parseArray(c));break;case"joint_names":var d=this.parseArray(c),e=[];for(var f=0;f<d.length;f++)d[f].substr(0,1)=="#"?e.push(this.getElement(d[f].substr(1))):e.push(d[f]);b.object.setJoints(e);break;case"bind_matrix":var g=this.parseArray(c),h=[];for(var f=0;f<g.length;f++)h.push(a.Mat4(g[f].split(" ")));b.object.setInvBindMatrix(h);break;case"joints":b.object.setVertexJoints(this.parseArray(c),c.getAttribute("count"));break;case"weights":b.object.setVertexWeights(this.parseArray(c),c.getAttribute("count"))}c=c.nextSibling}}return b.object},a.Document.prototype.addLoadListener=function(a){this.listeners.push(a)},a.Document.prototype.removeLoadListener=function(a){for(var b=0;b<this.listeners.length;b++)this.listeners[b]===a&&this.listeners.splice(b,1)},a.Document.prototype.parseScript=function(a){this.rootURL=window.location.toString();var b=document.getElementById(a);if(!b)return null;var c="",d=b.firstChild;while(d)d.nodeType==3&&(c+=d.textContent),d=d.nextSibling;var e=new DOMParser,f=e.parseFromString(c,"text/xml");f.getElementById=this.getElementById,this.documents["#"+a]={xml:f};var g=f.getElementsByTagName("import");for(var h=0;h<g.length;h++)this.documents[this.getAbsolutePath(g[h].getAttribute("url"),url)]||(this.documents[this.getAbsolutePath(g[h].getAttribute("url"),url)]={},this.loadDocument(g[h].getAttribute("url")));this.loadCount==0&&this.finishedLoading()}}(GLGE),function(a){a.ZUP=[0,0,1],a.YUP=[0,1,0],a.XUP=[1,0,0],a.Placeable=function(){},a.Placeable.prototype.locX=0,a.Placeable.prototype.locY=0,a.Placeable.prototype.locZ=0,a.Placeable.prototype.dLocX=0,a.Placeable.prototype.dLocY=0,a.Placeable.prototype.dLocZ=0,a.Placeable.prototype.quatX=0,a.Placeable.prototype.quatY=0,a.Placeable.prototype.quatZ=0,a.Placeable.prototype.quatW=0,a.Placeable.prototype.rotX=0,a.Placeable.prototype.rotY=0,a.Placeable.prototype.rotZ=0,a.Placeable.prototype.dRotX=0,a.Placeable.prototype.dRotY=0,a.Placeable.prototype.dRotZ=0,a.Placeable.prototype.scaleX=1,a.Placeable.prototype.scaleY=1,a.Placeable.prototype.scaleZ=1,a.Placeable.prototype.dScaleX=0,a.Placeable.prototype.dScaleY=0,a.Placeable.prototype.dScaleZ=0,a.Placeable.prototype.matrix=null,a.Placeable.prototype.rotOrder=a.ROT_XYZ,a.Placeable.prototype.lookAt=null,a.Placeable.prototype.mode=a.P_EULER,a.Placeable.prototype.upAxis=a.ZUP,a.Placeable.prototype.getRoot=function(){if(this.type==a.G_ROOT)return this;if(this.parent){var b=this.parent.getRoot();return b?b:this}return this},a.Placeable.prototype.getRef=function(){return this.id?this.id:this.parent?this.parent.getRef():null},a.Placeable.prototype.setId=function(a){this.id=a;return this},a.Placeable.prototype.getId=function(){return this.id},a.Placeable.prototype.getLookat=function(){return this.lookAt},a.Placeable.prototype.setLookat=function(a){this.lookAt=a;return this},a.Placeable.prototype.getUpAxis=function(){return this.upAxis},a.Placeable.prototype.setUpAxis=function(a){this.upAxis=a;return this},a.Placeable.prototype.Lookat=function(b){var c,d=this.getPosition();b.getPosition?c=b.getPosition():c={x:b[0],y:b[1],z:b[2]};var e=[d.x-c.x,d.y-c.y,d.z-c.z],f=a.toUnitVec3(e),g=a.toUnitVec3(a.crossVec3(this.upAxis,f));g[0]==0&&g[1]==0&&g[2]==0&&(g[1]=1);var h=a.toUnitVec3(a.crossVec3(f,g));this.setRotMatrix(a.Mat4([g[0],h[0],f[0],0,g[1],h[1],f[1],0,g[2],h[2],f[2],0,0,0,0,1]))},a.Placeable.prototype.setTransformMode=function(a){this.mode=a,this.matrix=null;return this},a.Placeable.prototype.getRotOrder=function(){return this.rotOrder},a.Placeable.prototype.setRotOrder=function(a){this.rotOrder=a,this.matrix=null,this.rotmatrix=null;return this},a.Placeable.prototype.getRotMatrix=function(){if(!this.rotmatrix){var b=this.getRotation();this.mode==a.P_EULER&&(this.rotmatrix=a.rotateMatrix(b.x,b.y,b.z,this.rotOrder)),this.mode==a.P_QUAT&&(this.rotmatrix=a.quatRotation(b.x,b.y,b.z,b.w))}return this.rotmatrix},a.Placeable.prototype.setRotMatrix=function(b){this.mode=a.P_MATRIX,this.rotmatrix=b,this.updateMatrix();return this},a.Placeable.prototype.setLocX=function(a){this.locX=a,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setLocY=function(a){this.locY=a,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setLocZ=function(a){this.locZ=a,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setLoc=function(a,b,c){this.locX=a,this.locY=b,this.locZ=c,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDLocX=function(a){this.dLocX=a,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDLocY=function(a){this.dLocY=a,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDLocZ=function(a){this.dLocZ=a,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDLoc=function(a,b,c){this.dLocX=a,this.dLocY=b,this.dLocZ=c,this.translateMatrix=null,this.staticMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setQuatX=function(b){this.mode=a.P_QUAT,this.quatX=parseFloat(b),this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setQuatY=function(b){this.mode=a.P_QUAT,this.quatY=parseFloat(b),this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setQuatZ=function(b){this.mode=a.P_QUAT,this.quatZ=parseFloat(b),this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setQuatW=function(b){this.mode=a.P_QUAT,this.quatW=parseFloat(b),this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setQuat=function(b,c,d,e){this.mode=a.P_QUAT,this.quatX=b,this.quatY=c,this.quatZ=d,this.quatW=e,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setRotX=function(b){this.mode=a.P_EULER,this.rotX=b,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setRotY=function(b){this.mode=a.P_EULER,this.rotY=b,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setRotZ=function(b){this.mode=a.P_EULER,this.rotZ=b,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setRot=function(b,c,d){this.mode=a.P_EULER,this.rotX=b,this.rotY=c,this.rotZ=d,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDRotX=function(b){this.mode=a.P_EULER,this.dRotX=b,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDRotY=function(b){this.mode=a.P_EULER,this.dRotY=b,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDRotZ=function(b){this.mode=a.P_EULER,this.dRotZ=b,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDRot=function(b,c,d){this.mode=a.P_EULER,this.dRotX=b,this.dRotY=c,this.dRotZ=d,this.staticMatrix=null,this.rotmatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setScaleX=function(a){if(this.ScaleX==a)return this;this.scaleX=a,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setScaleY=function(a){if(this.ScaleY==a)return this;this.scaleY=a,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setScaleZ=function(a){if(this.ScaleZ==a)return this;this.scaleZ=a,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setScale=function(a,b,c){b||(b=a,c=a),this.scaleX=a,this.scaleY=b,this.scaleZ=c,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDScaleX=function(a){if(this.dScaleX==a)return this;this.dScaleX=a,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDScaleY=function(a){if(this.dScaleY==a)return this;this.dScaleY=a,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDScaleZ=function(a){if(this.dScaleZ==a)return this;this.dScaleZ=a,this.staticMatrix=null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.setDScale=function(a,b,c){this.dScaleX=a,this.dScaleY=b,this.dScaleZ=c,this.staticMatrix==null,this.scaleMatrix=null,this.updateMatrix();return this},a.Placeable.prototype.getLocX=function(){return parseFloat(this.locX)},a.Placeable.prototype.getLocY=function(){return parseFloat(this.locY)},a.Placeable.prototype.getLocZ=function(){return parseFloat(this.locZ)},a.Placeable.prototype.getLoc=function(){return new a.Vec3(parseFloat(this.locX),parseFloat(this.locY),parseFloat(this.locZ))},a.Placeable.prototype.getDLocX=function(){return this.dLocX},a.Placeable.prototype.getDLocY=function(){return this.dLocY},a.Placeable.prototype.getDLocZ=function(){return this.dLocZ},a.Placeable.prototype.getQuatX=function(){return this.quatX},a.Placeable.prototype.getQuatY=function(){return this.quatY},a.Placeable.prototype.getQuatZ=function(){return this.quatZ},a.Placeable.prototype.getQuatW=function(){return this.quatW},a.Placeable.prototype.getRotX=function(){return this.rotX},a.Placeable.prototype.getRotY=function(){return this.rotY},a.Placeable.prototype.getRotZ=function(){return this.rotZ},a.Placeable.prototype.getDRotX=function(){return this.dRotX},a.Placeable.prototype.getDRotY=function(){return this.dRotY},a.Placeable.prototype.getDRotZ=function(){return this.dRotZ},a.Placeable.prototype.getScaleX=function(){return this.scaleX},a.Placeable.prototype.getScaleY=function(){return this.scaleY},a.Placeable.prototype.getScaleZ=function(){return this.scaleZ},a.Placeable.prototype.getDScaleX=function(){return this.dScaleX},a.Placeable.prototype.getDScaleY=function(){return this.dScaleY},a.Placeable.prototype.getDScaleZ=function(){return this.dScaleZ},a.Placeable.prototype.getPosition=function(){var a={};a.x=parseFloat(this.locX)+parseFloat(this.dLocX),a.y=parseFloat(this.locY)+parseFloat(this.dLocY),a.z=parseFloat(this.locZ)+parseFloat(this.dLocZ);return a},a.Placeable.prototype.getRotation=function(){var b={};this.mode==a.P_EULER&&(b.x=parseFloat(this.rotX)+parseFloat(this.dRotX),b.y=parseFloat(this.rotY)+parseFloat(this.dRotY),b.z=parseFloat(this.rotZ)+parseFloat(this.dRotZ)),this.mode==a.P_QUAT&&(b.x=parseFloat(this.quatX),b.y=parseFloat(this.quatY),b.z=parseFloat(this.quatZ),b.w=parseFloat(this.quatW));return b},a.Placeable.prototype.getScale=function(){var a={};a.x=parseFloat(this.scaleX)+parseFloat(this.dScaleX),a.y=parseFloat(this.scaleY)+parseFloat(this.dScaleY),a