// ThreeExtras.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,g,f,h,b,j;if(d==0)e=g=f=0;else{h=Math.floor(a*6);b=a*6-h;a=d*(1-c);j=d*(1-c*b);c=d*(1-c*(1-b));switch(h){case 1:e=j;g=d;f=a;break;case 2:e=a;g=d;f=c;break;case 3:e=a;g=j;f=d;break;case 4:e=c;g=a;f=d;break;case 5:e=d;g=a;f=j;break;case 6:case 0:e=d;g=c;f=a}}this.r=e;this.g=g;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0}; THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x= -this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}}; THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1}; THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,g=[];a=0;for(c=e.length;a0&&H>0&&k+H<1}var d,e,g,f,h,b,j,l,t,A, w,o=a.geometry,p=o.vertices,C=[];d=0;for(e=o.faces.length;dj?e:j;g=g>l? g:l}a()};this.add3Points=function(j,l,t,A,w,o){if(b){b=false;c=jt?j>w?j:w:t>w?t:w;g=l>A?l>o?l:o:A>o?A:o}else{c=jt?j>w?j>e?j:e:w>e?w:e:t>w?t>e?t:e:w>e?w:e;g=l>A?l>o?l>g?l:g:o>g?o:g:A>o?A>g?A:g:o>g?o:g}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();e=j.getRight();g=j.getBottom()}else{c=cj.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){c-=j;d-=j;e+=j;g+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString= function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; THREE.Matrix4=function(a,c,d,e,g,f,h,b,j,l,t,A,w,o,p,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=b||0;this.n31=j||0;this.n32=l||0;this.n33=t||1;this.n34=A||0;this.n41=w||0;this.n42=o||0;this.n43=p||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,g,f,h,b,j,l,t,A,w,o,p,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=b;this.n31=j;this.n32=l;this.n33=t;this.n34=A;this.n41=w;this.n42=o;this.n43=p;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,c).normalize();e.cross(d,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a); this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23* e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,b=a.n22,j=a.n23,l=a.n24,t=a.n31, A=a.n32,w=a.n33,o=a.n34,p=a.n41,C=a.n42,H=a.n43,y=a.n44,I=c.n11,v=c.n12,L=c.n13,k=c.n14,B=c.n21,n=c.n22,m=c.n23,z=c.n24,q=c.n31,D=c.n32,x=c.n33,u=c.n34,F=c.n41,J=c.n42,G=c.n43,T=c.n44;this.n11=d*I+e*B+g*q+f*F;this.n12=d*v+e*n+g*D+f*J;this.n13=d*L+e*m+g*x+f*G;this.n14=d*k+e*z+g*u+f*T;this.n21=h*I+b*B+j*q+l*F;this.n22=h*v+b*n+j*D+l*J;this.n23=h*L+b*m+j*x+l*G;this.n24=h*k+b*z+j*u+l*T;this.n31=t*I+A*B+w*q+o*F;this.n32=t*v+A*n+w*D+o*J;this.n33=t*L+A*m+w*x+o*G;this.n34=t*k+A*z+w*u+o*T;this.n41=p*I+C*B+ H*q+y*F;this.n42=p*v+C*n+H*D+y*J;this.n43=p*L+C*m+H*x+y*G;this.n44=p*k+C*z+H*u+y*T;return this},multiplyToArray:function(a,c,d){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,b=a.n21,j=a.n22,l=a.n23,t=a.n24,A=a.n31,w=a.n32,o=a.n33,p=a.n34,C=a.n41,H=a.n42,y=a.n43;a=a.n44;var I=c.n11,v=c.n12,L=c.n13,k=c.n14,B=c.n21,n=c.n22,m=c.n23,z=c.n24,q=c.n31,D=c.n32,x=c.n33,u=c.n34,F=c.n41,J=c.n42,G=c.n43;c=c.n44;this.n11=e*I+g*B+f*q+h*F;this.n12=e*v+g*n+f*D+h*J;this.n13=e*L+g*m+f*x+h*G;this.n14=e*k+g*z+f*u+h*c;this.n21= b*I+j*B+l*q+t*F;this.n22=b*v+j*n+l*D+t*J;this.n23=b*L+j*m+l*x+t*G;this.n24=b*k+j*z+l*u+t*c;this.n31=A*I+w*B+o*q+p*F;this.n32=A*v+w*n+o*D+p*J;this.n33=A*L+w*m+o*x+p*G;this.n34=A*k+w*z+o*u+p*c;this.n41=C*I+H*B+y*q+a*F;this.n42=C*v+H*n+y*D+a*J;this.n43=C*L+H*m+y*x+a*G;this.n44=C*k+H*z+y*u+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34; d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,b=this.n23,j=this.n24,l=this.n31,t=this.n32,A=this.n33,w=this.n34,o=this.n41,p=this.n42,C=this.n43,H=this.n44,y=a.n11,I=a.n21,v=a.n31,L=a.n41,k=a.n12,B=a.n22,n=a.n32,m=a.n42,z=a.n13,q=a.n23,D=a.n33,x=a.n43,u=a.n14,F=a.n24,J=a.n34;a=a.n44;this.n11=c*y+d*I+e*v+g*L;this.n12=c*k+d*B+e*n+g*m;this.n13=c*z+d*q+e*D+g*x;this.n14=c*u+d*F+e*J+g*a;this.n21=f*y+h*I+b*v+j*L;this.n22=f*k+h* B+b*n+j*m;this.n23=f*z+h*q+b*D+j*x;this.n24=f*u+h*F+b*J+j*a;this.n31=l*y+t*I+A*v+w*L;this.n32=l*k+t*B+A*n+w*m;this.n33=l*z+t*q+A*D+w*x;this.n34=l*u+t*F+A*J+w*a;this.n41=o*y+p*I+C*v+H*L;this.n42=o*k+p*B+C*n+H*m;this.n43=o*z+p*q+C*D+H*x;this.n44=o*u+p*F+C*J+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this}, determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,b=this.n24,j=this.n31,l=this.n32,t=this.n33,A=this.n34,w=this.n41,o=this.n42,p=this.n43,C=this.n44;return e*h*l*w-d*b*l*w-e*f*t*w+c*b*t*w+d*f*A*w-c*h*A*w-e*h*j*o+d*b*j*o+e*g*t*o-a*b*t*o-d*g*A*o+a*h*A*o+e*f*j*p-c*b*j*p-e*g*l*p+a*b*l*p+c*g*A*p-a*f*A*p-d*f*j*C+c*h*j*C+d*g*l*C-a*h*l*C-c*g*t*C+a*f*t*C},transpose:function(){function a(c,d,e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31", "n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]= this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0, 1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,f=a.x,h=a.y,b=a.z, j=g*f,l=g*h;this.set(j*f+d,j*h-e*b,j*b+e*h,0,j*h+e*b,l*h+d,l*b-e*f,0,j*b-e*h,l*b+e*f,g*b*b+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e}; THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d}; THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,b=a.n23,j=a.n24,l=a.n31,t=a.n32,A=a.n33,w=a.n34,o=a.n41,p=a.n42,C=a.n43,H=a.n44,y=new THREE.Matrix4;y.n11=b*w*p-j*A*p+j*t*C-h*w*C-b*t*H+h*A*H;y.n12=g*A*p-e*w*p-g*t*C+d*w*C+e*t*H-d*A*H;y.n13=e*j*p-g*b*p+g*h*C-d*j*C-e*h*H+d*b*H;y.n14=g*b*t-e*j*t-g*h*A+d*j*A+e*h*w-d*b*w;y.n21=j*A*o-b*w*o-j*l*C+f*w*C+b*l*H-f*A*H;y.n22=e*w*o-g*A*o+g*l*C-c*w*C-e*l*H+c*A*H;y.n23=g*b*o-e*j*o-g*f*C+c*j*C+e*f*H-c*b*H;y.n24=e*j*l-g*b*l+ g*f*A-c*j*A-e*f*w+c*b*w;y.n31=h*w*o-j*t*o+j*l*p-f*w*p-h*l*H+f*t*H;y.n32=g*t*o-d*w*o-g*l*p+c*w*p+d*l*H-c*t*H;y.n33=e*j*o-g*h*o+g*f*p-c*j*p-d*f*H+c*h*H;y.n34=g*h*l-d*j*l-g*f*t+c*j*t+d*f*w-c*h*w;y.n41=b*t*o-h*A*o-b*l*p+f*A*p+h*l*C-f*t*C;y.n42=d*A*o-e*t*o+e*l*p-c*A*p-d*l*C+c*t*C;y.n43=e*h*o-d*b*o-e*f*p+c*b*p+d*f*C-c*h*C;y.n44=d*b*l-e*h*l+e*f*t-c*b*t-d*f*A+c*h*A;y.multiplyScalar(1/a.determinant());return y}; THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,b=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*f;d[3]=a*h;d[4]=a*b;d[5]=a*j;d[6]=a*l;d[7]=a*t;d[8]=a*A;return c}; THREE.Matrix4.makeFrustum=function(a,c,d,e,g,f){var h,b,j;h=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=b;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)}; THREE.Matrix4.makeOrtho=function(a,c,d,e,g,f){var h,b,j,l;h=new THREE.Matrix4;b=c-a;j=d-e;l=f-g;a=(c+a)/b;d=(d+e)/j;g=(f+g)/l;h.n11=2/b;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,c,d,e,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,c,d,e,g,f){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c65535){l[b].counter+=1;j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light; THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3; THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth= a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.LineBasicMaterialCounter={value:0}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){a.color!== undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!== undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
light_map: "+this.light_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+ "
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.MeshBasicMaterialCounter={value:0}; THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){a.color!== undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!== undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
light_map: "+this.light_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
shading: "+this.shading+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+ "
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.MeshLambertMaterialCounter={value:0}; THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth= 1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map= a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth= a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (
id: "+this.id+"
color: "+this.color+"
ambient: "+this.ambient+"
specular: "+this.specular+"
shininess: "+this.shininess+"
opacity: "+this.opacity+"
map: "+this.map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
shading: "+this.shading+"
blending: "+this.blending+"
depth_test: "+ this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.MeshPhongMaterialCounter={value:0}; THREE.MeshDepthMaterial=function(a){this.id=THREE.MeshDepthMaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!== undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial (
id: "+this.id+"
opacity: "+this.opacity+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshDepthMaterialCounter={value:0}; THREE.MeshNormalMaterial=function(a){this.id=THREE.MeshNormalMaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!== undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial (
id: "+this.id+"
opacity: "+this.opacity+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
)"}};THREE.MeshNormalMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}}; THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader= a.vertex_shader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!== undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (
id: "+this.id+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending; if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
size: "+this.size+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.ParticleBasicMaterialCounter={value:0}; THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,e,g,f){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2; THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType}; var Uniforms={clone:function(a){var c,d,e,g={};for(c in a){g[c]={};for(d in a[c]){e=a[c][d];g[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var c,d,e,g={};for(c=0;c=0&&x>=0&&u>=0&&F>=0)return true;else if(D<0&&x<0||u<0&&F<0)return false;else{if(D<0)z=Math.max(z,D/(D-x));else if(x<0)q=Math.min(q,D/(D-x));if(u<0)z=Math.max(z,u/(u-F));else if(F<0)q=Math.min(q,u/(u-F));if(qD&&G.z0&&H.z<1){w=p[o]=p[o]||new THREE.RenderableParticle;w.x=H.x/H.w;w.y=H.y/H.w;w.z=H.z;w.rotation=O.rotation.z;w.scale.x=O.scale.x*Math.abs(w.x-(H.x+m.projectionMatrix.n11)/ (H.w+m.projectionMatrix.n14));w.scale.y=O.scale.y*Math.abs(w.y-(H.y+m.projectionMatrix.n22)/(H.w+m.projectionMatrix.n24));w.materials=O.materials;q.push(w);o++}}}}z&&q.sort(a);return q};this.unprojectVector=function(n,m){var z=THREE.Matrix4.makeInvert(m.matrix);z.multiplySelf(THREE.Matrix4.makeInvert(m.projectionMatrix));z.multiplyVector3(n);return n}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,b){d=h;e=b;g=d/2;f=e/2};this.render=function(h,b){var j,l,t,A,w,o,p,C;a=c.projectScene(h,b);j=0;for(l=a.length;j0){Q.r+=ma.r*fa;Q.g+=ma.g*fa;Q.b+=ma.b*fa}}else if(fa instanceof THREE.PointLight){N.sub(fa.position,ea);N.normalize();fa= $.dot(N)*na;if(fa>0){Q.r+=ma.r*fa;Q.g+=ma.g*fa;Q.b+=ma.b*fa}}}}function Ja(P,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var Q,Z,fa,ma,na,pa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){ma=$.map.image;na=ma.width>>1;pa=ma.height>>1;Z=ea.scale.x*b;fa=ea.scale.y*j;$=Z*na;Q=fa*pa;M.set(P.x-$,P.y-Q,P.x+$,P.y+Q);if(X.instersects(M)){l.save();l.translate(P.x,P.y);l.rotate(-ea.rotation);l.scale(Z,-fa);l.translate(-na,-pa);l.drawImage(ma,0,0);l.restore()}}}else if($ instanceof THREE.ParticleCircleMaterial){if(S){aa.r=ja.r+ha.r+E.r;aa.g=ja.g+ha.g+E.g;aa.b=ja.b+ha.b+E.b;q.r=$.color.r*aa.r;q.g=$.color.g*aa.g;q.b=$.color.b*aa.b;q.updateStyleString()}else q.__styleString=$.color.__styleString;$=ea.scale.x*b;Q=ea.scale.y*j;M.set(P.x-$,P.y-Q,P.x+$,P.y+Q);if(X.instersects(M)){Z=q.__styleString;if(C!=Z)l.fillStyle=C=Z;l.save();l.translate(P.x,P.y);l.rotate(-ea.rotation);l.scale($,Q);l.beginPath();l.arc(0,0,1,0,K,true);l.closePath();l.fill();l.restore()}}}}function Ka(P,ea,$,Q){if(Q.opacity!= 0){a(Q.opacity);c(Q.blending);l.beginPath();l.moveTo(P.positionScreen.x,P.positionScreen.y);l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){q.__styleString=Q.color.__styleString;P=Q.linewidth;if(H!=P)l.lineWidth=H=P;P=q.__styleString;if(p!=P)l.strokeStyle=p=P;l.stroke();M.inflate(Q.linewidth*2)}}}function Ga(P,ea,$,Q,Z,fa){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);L=P.positionScreen.x;k=P.positionScreen.y;B=ea.positionScreen.x;n=ea.positionScreen.y; m=$.positionScreen.x;z=$.positionScreen.y;l.beginPath();l.moveTo(L,k);l.lineTo(B,n);l.lineTo(m,z);l.lineTo(L,k);l.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Da(L,k,B,n,m,z,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=sa.matrix;N.copy(Q.vertexNormalsWorld[0]);U=(N.x*P.n11+N.y* P.n12+N.z*P.n13)*0.5+0.5;O=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;N.copy(Q.vertexNormalsWorld[1]);ba=(N.x*P.n11+N.y*P.n12+N.z*P.n13)*0.5+0.5;ca=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;N.copy(Q.vertexNormalsWorld[2]);W=(N.x*P.n11+N.y*P.n12+N.z*P.n13)*0.5+0.5;R=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;Da(L,k,B,n,m,z,Z.env_map.image,U,O,ba,ca,W,R)}}else Z.wireframe?qa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof THREE.UVMapping&&Da(L,k,B,n,m,z,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);c(THREE.SubtractiveBlending)}if(S)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=x.r=u.r=ja.r;D.g=x.g=u.g=ja.g;D.b=x.b=u.b=ja.b;Ba(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Ba(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],x);Ba(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],u);F.r=(x.r+u.r)*0.5;F.g=(x.g+u.g)*0.5;F.b=(x.b+u.b)*0.5;T=Pa(D,x,u,F); Da(L,k,B,n,m,z,T,0,0,1,0,0,1)}else{aa.r=ja.r;aa.g=ja.g;aa.b=ja.b;Ba(fa,Q.centroidWorld,Q.normalWorld,aa);q.r=Z.color.r*aa.r;q.g=Z.color.g*aa.g;q.b=Z.color.b*aa.b;q.updateStyleString();Z.wireframe?qa(q.__styleString,Z.wireframe_linewidth):Ha(q.__styleString)}else Z.wireframe?qa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){J=sa.near;G=sa.far;D.r=D.g=D.b=1-La(P.positionScreen.z,J,G);x.r=x.g=x.b=1-La(ea.positionScreen.z,J,G);u.r= u.g=u.b=1-La($.positionScreen.z,J,G);F.r=(x.r+u.r)*0.5;F.g=(x.g+u.g)*0.5;F.b=(x.b+u.b)*0.5;T=Pa(D,x,u,F);Da(L,k,B,n,m,z,T,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){q.r=Ma(Q.normalWorld.x);q.g=Ma(Q.normalWorld.y);q.b=Ma(Q.normalWorld.z);q.updateStyleString();Z.wireframe?qa(q.__styleString,Z.wireframe_linewidth):Ha(q.__styleString)}}}function qa(P,ea){if(p!=P)l.strokeStyle=p=P;if(H!=ea)l.lineWidth=H=ea;l.stroke();M.inflate(ea*2)}function Ha(P){if(C!=P)l.fillStyle=C=P;l.fill()}function Da(P, ea,$,Q,Z,fa,ma,na,pa,ya,ua,za,Ea){var wa,Aa;wa=ma.width-1;Aa=ma.height-1;na*=wa;pa*=Aa;ya*=wa;ua*=Aa;za*=wa;Ea*=Aa;$-=P;Q-=ea;Z-=P;fa-=ea;ya-=na;ua-=pa;za-=na;Ea-=pa;wa=ya*Ea-za*ua;if(wa!=0){Aa=1/wa;wa=(Ea*$-ua*Z)*Aa;ua=(Ea*Q-ua*fa)*Aa;$=(ya*Z-za*$)*Aa;Q=(ya*fa-za*Q)*Aa;P=P-wa*na-$*pa;ea=ea-ua*na-Q*pa;l.save();l.transform(wa,ua,$,Q,P,ea);l.clip();l.drawImage(ma,0,0);l.restore()}}function Pa(P,ea,$,Q){var Z=~~(P.r*255),fa=~~(P.g*255);P=~~(P.b*255);var ma=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255); var pa=~~($.r*255),ya=~~($.g*255);$=~~($.b*255);var ua=~~(Q.r*255),za=~~(Q.g*255);Q=~~(Q.b*255);ia[0]=Z<0?0:Z>255?255:Z;ia[1]=fa<0?0:fa>255?255:fa;ia[2]=P<0?0:P>255?255:P;ia[4]=ma<0?0:ma>255?255:ma;ia[5]=na<0?0:na>255?255:na;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=ya<0?0:ya>255?255:ya;ia[10]=$<0?0:$>255?255:$;ia[12]=ua<0?0:ua>255?255:ua;ia[13]=za<0?0:za>255?255:za;ia[14]=Q<0?0:Q>255?255:Q;da.putImageData(ga,0,0);ra.drawImage(V,0,0);return ta}function La(P,ea,$){P=(P-ea)/($-ea); return P*P*(3-2*P)}function Ma(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function Na(P,ea){var $=ea.x-P.x,Q=ea.y-P.y,Z=1/Math.sqrt($*$+Q*Q);$*=Z;Q*=Z;ea.x+=$;ea.y+=Q;P.x-=$;P.y-=Q}var Ia,Qa,la,xa,Ca,Oa,Ra,Fa;this.autoClear?this.clear():l.setTransform(1,0,0,-1,b,j);d=e.projectScene(ka,sa,this.sortElements);(S=ka.lights.length>0)&&oa(ka);Ia=0;for(Qa=d.length;Ia0){ba.r+=R.color.r*X;ba.g+=R.color.g*X;ba.b+=R.color.b*X}}else if(R instanceof THREE.PointLight){z.sub(R.position,O.centroidWorld);z.normalize();X=O.normalWorld.dot(z)*R.intensity;if(X>0){ba.r+=R.color.r*X;ba.g+=R.color.g*X;ba.b+=R.color.b*X}}}}function c(U,O,ba,ca,W,R){u=e(F++);u.setAttribute("d", "M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(W instanceof THREE.MeshBasicMaterial)v.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshLambertMaterial)if(I){L.r=k.r;L.g=k.g;L.b=k.b;a(R,ca,L);v.r=W.color.r*L.r;v.g=W.color.g*L.g;v.b=W.color.b*L.b;v.updateStyleString()}else v.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshDepthMaterial){m=1-W.__2near/(W.__farPlusNear- ca.z*W.__farMinusNear);v.setRGB(m,m,m)}else W instanceof THREE.MeshNormalMaterial&&v.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));W.wireframe?u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+W.wireframe_linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.wireframe_linecap+"; stroke-linejoin: "+W.wireframe_linejoin):u.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+W.opacity);b.appendChild(u)}function d(U,O,ba,ca,W, R,X){u=e(F++);u.setAttribute("d","M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)v.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(I){L.r=k.r;L.g=k.g;L.b=k.b;a(X,W,L);v.r=R.color.r*L.r;v.g=R.color.g*L.g;v.b=R.color.b*L.b;v.updateStyleString()}else v.__styleString=R.color.__styleString; else if(R instanceof THREE.MeshDepthMaterial){m=1-R.__2near/(R.__farPlusNear-W.z*R.__farMinusNear);v.setRGB(m,m,m)}else R instanceof THREE.MeshNormalMaterial&&v.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));R.wireframe?u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):u.setAttribute("style","fill: "+v.__styleString+ "; fill-opacity: "+R.opacity);b.appendChild(u)}function e(U){if(q[U]==null){q[U]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&q[U].setAttribute("shape-rendering","crispEdges");return q[U]}return q[U]}function g(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var f=null,h=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,t,A,w,o,p,C,H=new THREE.Rectangle,y=new THREE.Rectangle,I=false,v=new THREE.Color(16777215),L=new THREE.Color(16777215), k=new THREE.Color(0),B=new THREE.Color(0),n=new THREE.Color(0),m,z=new THREE.Vector3,q=[],D=[],x=[],u,F,J,G,T=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":T=1;break;case "low":T=0}};this.setSize=function(U,O){j=U;l=O;t=j/2;A=l/2;b.setAttribute("viewBox",-t+" "+-A+" "+j+" "+l);b.setAttribute("width",j);b.setAttribute("height",l);H.set(-t,-A,t,A)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])}; this.render=function(U,O){var ba,ca,W,R,X,Y,M,S;this.autoClear&&this.clear();f=h.projectScene(U,O,this.sortElements);G=J=F=0;if(I=U.lights.length>0){M=U.lights;k.setRGB(0,0,0);B.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(ca=M.length;ba0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,aa,n)}if(ra&&ca>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER, ja,n)}if(ta){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,V,n)}};this.setLineBuffers=function(k,B){var n,m,z,q=k.vertices,D=k.colors,x=q.length,u=D.length,F=k.__vertexArray,J=k.__colorArray,G=k.__dirtyColors;if(k.__dirtyVertices){for(n=0;n0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+ q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,g("fragment",z+u));b.attachShader(n, g("vertex",q+B));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};k.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(m in k.uniforms)n.push(m);m=k.program;u=0;for(B=n.length;u=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLColorBuffer);b.vertexAttribPointer(k.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.color)}if(k.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT, false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(z.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLUVBuffer);b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(z.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2, 2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2);if(q instanceof THREE.Mesh)if(m.wireframe){b.lineWidth(m.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,z.__webGLLineBuffer);b.drawElements(b.LINES,z.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,z.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(m.linewidth); b.drawArrays(q,0,z.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,z.__webGLParticleCount)};this.renderPass=function(k,B,n,m,z,q,D){var x,u,F,J,G;F=0;for(J=m.materials.length;F=0;n--){m=k.__webGLObjects[n].object; B==m&&k.__webGLObjects.splice(n,1)}};this.setupMatrices=function(k,B){k._modelViewMatrix.multiplyToArray(B.matrix,k.matrix,k._modelViewMatrixArray);k._normalMatrix=THREE.Matrix4.makeInvert3x3(k._modelViewMatrix).transposeIntoArray(k._normalMatrixArray)};this.setDepthTest=function(k){k?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(k,B){if(k){!B||B=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK); b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif", lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"}; THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i", value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}}; THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f", value:1}},fragment_shader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment, THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex, "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment, THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex, THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common, THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment, THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex, THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.Snippets.lights_vertex, "gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",THREE.Snippets.color_pars_vertex, "void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null}; THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null}; THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var c=document.body,d="oldie";if(a){if(a.parent!==undefined)c=a.parent;if(a.id!==undefined)d=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support WebGL
\n
\nPlease try in\nChrome 9+ /\nFirefox 4+ /\nSafari OSX 10.6+';e.id= d;d=e.style;d.fontFamily="monospace";d.fontSize="13px";d.textAlign="center";d.background="#eee";d.color="#000";d.padding="1em";d.width="475px";d.margin="5em auto 0";a.appendChild(e);c.appendChild(a);return e}}; var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,g=d?c.geometry:c,f=a.vertices,h=g.vertices,b=a.faces,j=g.faces,l=a.uvs;g=g.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var t=0,A=h.length;t= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t", value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25)f=25;g=(f-1)*0.5;d=Array(f);for(c=e=0;c0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,b,w)))-1);l.push(t)}c.push(l)}var o,p,C;g=c.length;for(d=0;d0)for(e=0;e1){o=this.vertices[h].position.clone(); p=this.vertices[j].position.clone();C=this.vertices[l].position.clone();o.normalize();p.normalize();C.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,A,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d= 1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;g=(this.segmentsT+1)*c+d-1;var f=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; var Icosahedron=function(a){function c(A,w,o){var p=Math.sqrt(A*A+w*w+o*o);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(A/p,w/p,o/p)))-1}function d(A,w,o,p){p.faces.push(new THREE.Face3(A,w,o))}function e(A,w){var o=g.vertices[A].position,p=g.vertices[w].position;return c((o.x+p.x)/2,(o.y+p.y)/2,(o.z+p.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a=this.maxCount-3&&b(this)};this.begin= function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;ethis.size-1)j=this.size-1;var w=Math.floor(l-b);if(w<1)w=1;l=Math.floor(l+b);if(l>this.size-1)l=this.size-1;var o=Math.floor(t-b);if(o<1)o=1;b=Math.floor(t+b); if(b>this.size-1)b=this.size-1;var p,C,H,y,I,v;for(A=A;A0)this.field[H+p]+=y}}}};this.addPlaneX=function(d,e){var g,f,h,b,j,l=this.size,t=this.yd,A=this.zd,w=this.field,o=l*Math.sqrt(d/e);if(o>l)o=l;for(g=0;g0)for(f=0;ft)p=t;for(f=0;f0){j=f*A;for(g=0;gsize)dist=size;for(h=0;h0){j=zd*h;for(f=0;f>7)-127;N=(da&127)<<16|V<<8|N;if(N==0&&ia==-127)return 0;return(1-2*(ga>>7))*(1+N*Math.pow(2,-23))*Math.pow(2,ia)}function b(E,K){var N=t(E,K),V=t(E,K+1),da=t(E,K+2);return(t(E,K+3)<<24)+(da<<16)+(V<<8)+N}function j(E,K){var N=t(E,K);return(t(E,K+1)<<8)+N}function l(E,K){var N=t(E,K);return N>127?N-256:N}function t(E,K){return E.charCodeAt(K)&255}function A(E){var K, N,V;K=b(a,E);N=b(a,E+B);V=b(a,E+n);E=j(a,E+m);THREE.Loader.prototype.f3(y,K,N,V,E)}function w(E){var K,N,V,da,ga,ia;K=b(a,E);N=b(a,E+B);V=b(a,E+n);da=j(a,E+m);ga=b(a,E+z);ia=b(a,E+q);E=b(a,E+D);THREE.Loader.prototype.f3n(y,L,K,N,V,da,ga,ia,E)}function o(E){var K,N,V,da;K=b(a,E);N=b(a,E+x);V=b(a,E+u);da=b(a,E+F);E=j(a,E+J);THREE.Loader.prototype.f4(y,K,N,V,da,E)}function p(E){var K,N,V,da,ga,ia,ta,ra;K=b(a,E);N=b(a,E+x);V=b(a,E+u);da=b(a,E+F);ga=j(a,E+J);ia=b(a,E+G);ta=b(a,E+T);ra=b(a,E+U);E=b(a,E+ O);THREE.Loader.prototype.f4n(y,L,K,N,V,da,ga,ia,ta,ra,E)}function C(E){var K,N;K=b(a,E);N=b(a,E+ba);E=b(a,E+ca);THREE.Loader.prototype.uv3(y.uvs,k[K*2],k[K*2+1],k[N*2],k[N*2+1],k[E*2],k[E*2+1])}function H(E){var K,N,V;K=b(a,E);N=b(a,E+W);V=b(a,E+R);E=b(a,E+X);THREE.Loader.prototype.uv4(y.uvs,k[K*2],k[K*2+1],k[N*2],k[N*2+1],k[V*2],k[V*2+1],k[E*2],k[E*2+1])}var y=this,I=0,v,L=[],k=[],B,n,m,z,q,D,x,u,F,J,G,T,U,O,ba,ca,W,R,X,Y,M,S,aa,ja,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y, e,f);v={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:b(a,I+16),nnormals:b(a,I+16+4),nuvs:b(a,I+16+8),ntri_flat:b(a,I+16+12),ntri_smooth:b(a,I+16+16),ntri_flat_uv:b(a,I+16+20),ntri_smooth_uv:b(a,I+16+24),nquad_flat:b(a,I+16+28),nquad_smooth:b(a,I+16+32),nquad_flat_uv:b(a,I+16+36), nquad_smooth_uv:b(a,I+16+40)};I+=v.header_bytes;B=v.vertex_index_bytes;n=v.vertex_index_bytes*2;m=v.vertex_index_bytes*3;z=v.vertex_index_bytes*3+v.material_index_bytes;q=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes;D=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*2;x=v.vertex_index_bytes;u=v.vertex_index_bytes*2;F=v.vertex_index_bytes*3;J=v.vertex_index_bytes*4;G=v.vertex_index_bytes*4+v.material_index_bytes;T=v.vertex_index_bytes*4+v.material_index_bytes+ v.normal_index_bytes;U=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*2;O=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*3;ba=v.uv_index_bytes;ca=v.uv_index_bytes*2;W=v.uv_index_bytes;R=v.uv_index_bytes*2;X=v.uv_index_bytes*3;f=v.vertex_index_bytes*3+v.material_index_bytes;ha=v.vertex_index_bytes*4+v.material_index_bytes;Y=v.ntri_flat*f;M=v.ntri_smooth*(f+v.normal_index_bytes*3);S=v.ntri_flat_uv*(f+v.uv_index_bytes*3);aa=v.ntri_smooth_uv*(f+v.normal_index_bytes* 3+v.uv_index_bytes*3);ja=v.nquad_flat*ha;f=v.nquad_smooth*(ha+v.normal_index_bytes*4);ha=v.nquad_flat_uv*(ha+v.uv_index_bytes*4);I+=function(E){var K,N,V,da=v.vertex_coordinate_bytes*3,ga=E+v.nvertices*da;for(E=E;E