// 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,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,f,h,k,j;if(c==0)e=g=f=0;else{h=Math.floor(a*6);k=a*6-h;a=c*(1-b);j=c*(1-b*k);b=c*(1-b*(1-k));switch(h){case 1:e=j;g=c;f=a;break;case 2:e=a;g=c;f=b;break;case 3:e=a;g=j;f=c;break;case 4:e=b;g=a;f=c;break;case 5:e=c;g=a;f=j;break;case 6:case 0:e=c;g=b;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,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,c){this.x=a||0;this.y=b||0;this.z=c||0}; THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,e=this.z;this.x=c*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.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 b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+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,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1}; THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a0&&E>0&&d+E<1}var c,e,g,f,h,k,j,m,q,w, u,t=a.geometry,x=t.vertices,A=[];c=0;for(e=t.faces.length;cj?e:j;g=g>m? g:m}a()};this.add3Points=function(j,m,q,w,u,t){if(k){k=false;b=jq?j>u?j:u:q>u?q:u;g=m>w?m>t?m:t:w>t?w:t}else{b=jq?j>u?j>e?j:e:u>e?u:e:q>u?q>e?q:e:u>e?u:e;g=m>w?m>t?m>g?m:g:t>g?t:g:w>t?w>g?w:g:t>g?t:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=bj.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString= function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=q||1;this.n34=w||0;this.n41=u||0;this.n42=t||0;this.n43=x||0;this.n44=A||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,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=q;this.n34=w;this.n41=u;this.n42=t;this.n43=x;this.n44=A;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,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,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 b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23* e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,q=a.n31, w=a.n32,u=a.n33,t=a.n34,x=a.n41,A=a.n42,E=a.n43,v=a.n44,F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43,fa=b.n44;this.n11=c*F+e*aa+g*Q+f*Y;this.n12=c*p+e*O+g*U+f*ea;this.n13=c*M+e*K+g*V+f*Z;this.n14=c*d+e*X+g*H+f*fa;this.n21=h*F+k*aa+j*Q+m*Y;this.n22=h*p+k*O+j*U+m*ea;this.n23=h*M+k*K+j*V+m*Z;this.n24=h*d+k*X+j*H+m*fa;this.n31=q*F+w*aa+u*Q+t*Y;this.n32=q*p+w*O+u*U+t*ea;this.n33=q*M+w*K+u*V+t*Z;this.n34=q*d+w*X+u*H+t*fa;this.n41= x*F+A*aa+E*Q+v*Y;this.n42=x*p+A*O+E*U+v*ea;this.n43=x*M+A*K+E*V+v*Z;this.n44=x*d+A*X+E*H+v*fa;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,q=a.n24,w=a.n31,u=a.n32,t=a.n33,x=a.n34,A=a.n41,E=a.n42,v=a.n43;a=a.n44;var F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43;b=b.n44;this.n11=e*F+g*aa+f*Q+h*Y;this.n12=e*p+g*O+f*U+h*ea;this.n13=e*M+g*K+f*V+h*Z;this.n14=e*d+g*X+f* H+h*b;this.n21=k*F+j*aa+m*Q+q*Y;this.n22=k*p+j*O+m*U+q*ea;this.n23=k*M+j*K+m*V+q*Z;this.n24=k*d+j*X+m*H+q*b;this.n31=w*F+u*aa+t*Q+x*Y;this.n32=w*p+u*O+t*U+x*ea;this.n33=w*M+u*K+t*V+x*Z;this.n34=w*d+u*X+t*H+x*b;this.n41=A*F+E*aa+v*Q+a*Y;this.n42=A*p+E*O+v*U+a*ea;this.n43=A*M+E*K+v*V+a*Z;this.n44=A*d+E*X+v*H+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]= this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,q=this.n32,w=this.n33,u=this.n34,t=this.n41,x=this.n42,A=this.n43,E=this.n44,v=a.n11,F=a.n21,p=a.n31,M=a.n41,d=a.n12,aa=a.n22,O=a.n32,K=a.n42,X=a.n13,Q=a.n23,U=a.n33,V=a.n43,H=a.n14,Y=a.n24,ea=a.n34;a=a.n44;this.n11=b*v+c*F+e*p+g*M;this.n12=b*d+c*aa+e*O+g*K;this.n13=b*X+c*Q+e*U+g*V;this.n14=b*H+c*Y+e*ea+g*a;this.n21=f*v+ h*F+k*p+j*M;this.n22=f*d+h*aa+k*O+j*K;this.n23=f*X+h*Q+k*U+j*V;this.n24=f*H+h*Y+k*ea+j*a;this.n31=m*v+q*F+w*p+u*M;this.n32=m*d+q*aa+w*O+u*K;this.n33=m*X+q*Q+w*U+u*V;this.n34=m*H+q*Y+w*ea+u*a;this.n41=t*v+x*F+A*p+E*M;this.n42=t*d+x*aa+A*O+E*K;this.n43=t*X+x*Q+A*U+E*V;this.n44=t*H+x*Y+A*ea+E*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,b=this.n12,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,q=this.n33,w=this.n34,u=this.n41,t=this.n42,x=this.n43,A=this.n44;return e*h*m*u-c*k*m*u-e*f*q*u+b*k*q*u+c*f*w*u-b*h*w*u-e*h*j*t+c*k*j*t+e*g*q*t-a*k*q*t-c*g*w*t+a*h*w*t+e*f*j*x-b*k*j*x-e*g*m*x+a*k*m*x+b*g*w*x-a*f*w*x-c*f*j*A+b*h*j*A+c*g*m*A-a*h*m*A-b*g*q*A+a*f*q*A},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[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,b,c){this.set(1, 0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b), g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,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,b,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e}; THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,q=a.n32,w=a.n33,u=a.n34,t=a.n41,x=a.n42,A=a.n43,E=a.n44,v=new THREE.Matrix4;v.n11=k*u*x-j*w*x+j*q*A-h*u*A-k*q*E+h*w*E;v.n12=g*w*x-e*u*x-g*q*A+c*u*A+e*q*E-c*w*E;v.n13=e*j*x-g*k*x+g*h*A-c*j*A-e*h*E+c*k*E;v.n14=g*k*q-e*j*q-g*h*w+c*j*w+e*h*u-c*k*u;v.n21=j*w*t-k*u*t-j*m*A+f*u*A+k*m*E-f*w*E;v.n22=e*u*t-g*w*t+g*m*A-b*u*A-e*m*E+b*w*E;v.n23=g*k*t-e*j*t-g*f*A+b*j*A+e*f*E-b*k*E;v.n24=e*j*m-g*k*m+ g*f*w-b*j*w-e*f*u+b*k*u;v.n31=h*u*t-j*q*t+j*m*x-f*u*x-h*m*E+f*q*E;v.n32=g*q*t-c*u*t-g*m*x+b*u*x+c*m*E-b*q*E;v.n33=e*j*t-g*h*t+g*f*x-b*j*x-c*f*E+b*h*E;v.n34=g*h*m-c*j*m-g*f*q+b*j*q+c*f*u-b*h*u;v.n41=k*q*t-h*w*t-k*m*x+f*w*x+h*m*A-f*q*A;v.n42=c*w*t-e*q*t+e*m*x-b*w*x-c*m*A+b*q*A;v.n43=e*h*t-c*k*t-e*f*x+b*k*x+c*f*A-b*h*A;v.n44=c*k*m-e*h*m+e*f*q-b*k*q-c*f*w+b*h*w;v.multiplyScalar(1/a.determinant());return v}; THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.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,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*q;c[8]=a*w;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;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,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)}; THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;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,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||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,b,c,e,g){this.a=a;this.b=b;this.c=c;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,b,c,e,g,f){this.a=a;this.b=b;this.c=c;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,b){this.u=a||0;this.v=b||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.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=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 b=1,c=this.vertices.length;bthis.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,b=0,c=this.vertices.length;b65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].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.GeometryIdCounter=0; THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light; THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||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.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]}; THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,b=this.rotation,c=this.scale,e=this.matrix,g=this.rotationMatrix,f=this.tmpMatrix;e.setTranslation(a.x,a.y,a.z);g.setRotX(b.x);b.y!=0&&g.multiplySelf(f.setRotY(b.y));b.z!=0&&g.multiplySelf(f.setRotZ(b.z));e.multiplySelf(g);if(c.x!=0||c.y!=0||c.z!=0)e.multiplySelf(f.setScale(c.x, c.y,c.z))}};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,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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,b,c,e,g,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c: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,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType}; var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]){e=a[b][c];g[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,c,e,g={};for(b=0;b=0&&V>=0&&H>=0&&Y>=0)return true;else if(U<0&&V<0||H<0&&Y<0)return false;else{if(U<0)X=Math.max(X,U/(U-V));else if(V<0)Q=Math.min(Q,U/(U-V));if(H<0)X=Math.max(X,H/(H-Y));else if(Y<0)Q=Math.min(Q,H/(H-Y));if(QU&&Z.z0&&E.z<1){u=x[t]=x[t]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=l.rotation.z;u.scale.x=l.scale.x*Math.abs(u.x-(E.x+K.projectionMatrix.n11)/ (E.w+K.projectionMatrix.n14));u.scale.y=l.scale.y*Math.abs(u.y-(E.y+K.projectionMatrix.n22)/(E.w+K.projectionMatrix.n24));u.materials=l.materials;Q.push(u);t++}}}}X&&Q.sort(a);return Q};this.unprojectVector=function(O,K){var X=THREE.Matrix4.makeInvert(K.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));X.multiplyVector3(O);return O}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,q,w,u,t,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}else if(ja instanceof THREE.PointLight){J.sub(ja.position,ha);J.normalize(); ja=ca.dot(J)*za;if(ja>0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}}}function ya(P,ha,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,ba,ja,ua,za,Ba;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){ua=ca.map.image;za=ua.width>>1;Ba=ua.height>>1;ba=ha.scale.x*k;ja=ha.scale.y*j;ca=ba*za;T=ja*Ba;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ba,-ja);m.translate(-za,-Ba);m.drawImage(ua,0,0);m.restore()}}}else if(ca instanceof THREE.ParticleCircleMaterial){if(I){D.r=$.r+da.r+C.r;D.g=$.g+da.g+C.g;D.b=$.b+da.b+C.b;Q.r=ca.color.r*D.r;Q.g=ca.color.g*D.g;Q.b=ca.color.b*D.b;Q.updateStyleString()}else Q.__styleString=ca.color.__styleString;ca=ha.scale.x*k;T=ha.scale.y*j;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){ba=Q.__styleString;if(A!=ba)m.fillStyle=A=ba;m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function qa(P,ha,ca, T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(P.positionScreen.x,P.positionScreen.y);m.lineTo(ha.positionScreen.x,ha.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){Q.__styleString=T.color.__styleString;P=T.linewidth;if(E!=P)m.lineWidth=E=P;P=Q.__styleString;if(x!=P)m.strokeStyle=x=P;m.stroke();z.inflate(T.linewidth*2)}}}function ra(P,ha,ca,T,ba,ja){if(ba.opacity!=0){a(ba.opacity);b(ba.blending);M=P.positionScreen.x;d=P.positionScreen.y;aa=ha.positionScreen.x; O=ha.positionScreen.y;K=ca.positionScreen.x;X=ca.positionScreen.y;m.beginPath();m.moveTo(M,d);m.lineTo(aa,O);m.lineTo(K,X);m.lineTo(M,d);m.closePath();if(ba instanceof THREE.MeshBasicMaterial)if(ba.map)ba.map.image.loaded&&ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if(ba.env_map){if(ba.env_map.image.loaded)if(ba.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=ka.matrix;J.copy(T.vertexNormalsWorld[0]); ia=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;l=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[1]);y=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;B=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[2]);o=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;n=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;wa(M,d,aa,O,K,X,ba.env_map.image,ia,l,y,B,o,n)}}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString);else if(ba instanceof THREE.MeshLambertMaterial){if(ba.map&& !ba.wireframe){ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(I)if(!ba.wireframe&&ba.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){U.r=V.r=H.r=$.r;U.g=V.g=H.g=$.g;U.b=V.b=H.b=$.b;Ca(ja,T.v1.positionWorld,T.vertexNormalsWorld[0],U);Ca(ja,T.v2.positionWorld,T.vertexNormalsWorld[1],V);Ca(ja,T.v3.positionWorld,T.vertexNormalsWorld[2],H);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+ H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else{D.r=$.r;D.g=$.g;D.b=$.b;Ca(ja,T.centroidWorld,T.normalWorld,D);Q.r=ba.color.r*D.r;Q.g=ba.color.g*D.g;Q.b=ba.color.b*D.b;Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString)}else if(ba instanceof THREE.MeshDepthMaterial){ea=ka.near;Z=ka.far;U.r=U.g=U.b=1-pa(P.positionScreen.z,ea,Z); V.r=V.g=V.b=1-pa(ha.positionScreen.z,ea,Z);H.r=H.g=H.b=1-pa(ca.positionScreen.z,ea,Z);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else if(ba instanceof THREE.MeshNormalMaterial){Q.r=Da(T.normalWorld.x);Q.g=Da(T.normalWorld.y);Q.b=Da(T.normalWorld.z);Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}}}function Ha(P,ha){if(x!=P)m.strokeStyle=x=P;if(E!=ha)m.lineWidth=E=ha;m.stroke();z.inflate(ha* 2)}function Ia(P){if(A!=P)m.fillStyle=A=P;m.fill()}function wa(P,ha,ca,T,ba,ja,ua,za,Ba,Ka,Ga,La,Ra){var Ja,Ma;Ja=ua.width-1;Ma=ua.height-1;za*=Ja;Ba*=Ma;Ka*=Ja;Ga*=Ma;La*=Ja;Ra*=Ma;ca-=P;T-=ha;ba-=P;ja-=ha;Ka-=za;Ga-=Ba;La-=za;Ra-=Ba;Ja=Ka*Ra-La*Ga;if(Ja!=0){Ma=1/Ja;Ja=(Ra*ca-Ga*ba)*Ma;Ga=(Ra*T-Ga*ja)*Ma;ca=(Ka*ba-La*ca)*Ma;T=(Ka*ja-La*T)*Ma;P=P-Ja*za-ca*Ba;ha=ha-Ga*za-T*Ba;m.save();m.transform(Ja,Ga,ca,T,P,ha);m.clip();m.drawImage(ua,0,0);m.restore()}}function ma(P,ha,ca,T){var ba=~~(P.r*255),ja= ~~(P.g*255);P=~~(P.b*255);var ua=~~(ha.r*255),za=~~(ha.g*255);ha=~~(ha.b*255);var Ba=~~(ca.r*255),Ka=~~(ca.g*255);ca=~~(ca.b*255);var Ga=~~(T.r*255),La=~~(T.g*255);T=~~(T.b*255);S[0]=ba<0?0:ba>255?255:ba;S[1]=ja<0?0:ja>255?255:ja;S[2]=P<0?0:P>255?255:P;S[4]=ua<0?0:ua>255?255:ua;S[5]=za<0?0:za>255?255:za;S[6]=ha<0?0:ha>255?255:ha;S[8]=Ba<0?0:Ba>255?255:Ba;S[9]=Ka<0?0:Ka>255?255:Ka;S[10]=ca<0?0:ca>255?255:ca;S[12]=Ga<0?0:Ga>255?255:Ga;S[13]=La<0?0:La>255?255:La;S[14]=T<0?0:T>255?255:T;W.putImageData(la, 0,0);sa.drawImage(R,0,0);return ta}function pa(P,ha,ca){P=(P-ha)/(ca-ha);return P*P*(3-2*P)}function Da(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function xa(P,ha){var ca=ha.x-P.x,T=ha.y-P.y,ba=1/Math.sqrt(ca*ca+T*T);ca*=ba;T*=ba;ha.x+=ca;ha.y+=T;P.x-=ca;P.y-=T}var Oa,Aa,oa,Ea,Fa,Pa,Qa,Na;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(ga,ka,this.sortElements);(I=ga.lights.length>0)&&na(ga);Oa=0;for(Aa=c.length;Oa0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}else if(n instanceof THREE.PointLight){X.sub(n.position,l.centroidWorld);X.normalize();N=l.normalWorld.dot(X)*n.intensity;if(N>0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}}}function b(ia,l,y,B,o,n){H=e(Y++);H.setAttribute("d","M "+ia.positionScreen.x+ " "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(o instanceof THREE.MeshBasicMaterial)p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(n,B,M);p.r=o.color.r*M.r;p.g=o.color.g*M.g;p.b=o.color.b*M.b;p.updateStyleString()}else p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshDepthMaterial){K=1-o.__2near/(o.__farPlusNear-B.z*o.__farMinusNear); p.setRGB(K,K,K)}else o instanceof THREE.MeshNormalMaterial&&p.setRGB(g(B.normalWorld.x),g(B.normalWorld.y),g(B.normalWorld.z));o.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+o.wireframe_linewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframe_linecap+"; stroke-linejoin: "+o.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+o.opacity);k.appendChild(H)}function c(ia,l,y,B,o,n,N){H=e(Y++);H.setAttribute("d", "M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+B.positionScreen.x+","+B.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)p.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(N,o,M);p.r=n.color.r*M.r;p.g=n.color.g*M.g;p.b=n.color.b*M.b;p.updateStyleString()}else p.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshDepthMaterial){K=1-n.__2near/(n.__farPlusNear-o.z*n.__farMinusNear);p.setRGB(K,K,K)}else n instanceof THREE.MeshNormalMaterial&&p.setRGB(g(o.normalWorld.x),g(o.normalWorld.y),g(o.normalWorld.z));n.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+ n.opacity);k.appendChild(H)}function e(ia){if(Q[ia]==null){Q[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");fa==0&&Q[ia].setAttribute("shape-rendering","crispEdges");return Q[ia]}return Q[ia]}function g(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,q,w,u,t,x,A,E=new THREE.Rectangle,v=new THREE.Rectangle,F=false,p=new THREE.Color(16777215),M=new THREE.Color(16777215), d=new THREE.Color(0),aa=new THREE.Color(0),O=new THREE.Color(0),K,X=new THREE.Vector3,Q=[],U=[],V=[],H,Y,ea,Z,fa=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ia){switch(ia){case "high":fa=1;break;case "low":fa=0}};this.setSize=function(ia,l){j=ia;m=l;q=j/2;w=m/2;k.setAttribute("viewBox",-q+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);E.set(-q,-w,q,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; this.render=function(ia,l){var y,B,o,n,N,G,z,I;this.autoClear&&this.clear();f=h.projectScene(ia,l,this.sortElements);Z=ea=Y=0;if(F=ia.lights.length>0){z=ia.lights;d.setRGB(0,0,0);aa.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(B=z.length;y0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUVBuffer); d.bufferData(d.ARRAY_BUFFER,Ha,da)}if(Fa&&L>0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ia,da)}if(Ea){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,da);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,da)}}x(objlist,N,o,l,y,B)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(y instanceof THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();o=n.vertices.length;n.__vertexArray=new Float32Array(o*3);n.__colorArray=new Float32Array(o*3);n.__webGLLineCount=o;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){o=d.DYNAMIC_DRAW;z=n.vertices;G=n.colors;$=z.length;da=G.length;L=n.__vertexArray;C=n.__colorArray;J=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I<$;I++){D=z[I].position;l=I*3;L[l]=D.x; L[l+1]=D.y;L[l+2]=D.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,L,o)}if(J){for(I=0;I0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+N.maxDirLights,"#define MAX_POINT_LIGHTS "+N.maxPointLights,N.map?"#define USE_MAP":"",N.env_map?"#define USE_ENVMAP":"",N.light_map?"#define USE_LIGHTMAP":"",N.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"); d.attachShader(B,F("fragment",n+I));d.attachShader(B,F("vertex",N+y));d.linkProgram(B);d.getProgramParameter(B,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(B,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(o in l.uniforms)B.push(o);o=l.program;I=0;for(y=B.length;I=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>= 0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>= 0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(N instanceof THREE.Mesh)if(o.wireframe){d.lineWidth(o.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT, 0)}else if(N instanceof THREE.Line){N=N.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(o.linewidth);d.drawArrays(N,0,n.__webGLLineCount)}else N instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,y,B,o){var n,N,G,z,I,D,$,da=l.lights,C=l.fog;y.autoUpdateMatrix&&y.updateMatrix();y.matrix.flattenToArray(Y);y.projectionMatrix.flattenToArray(H);V.multiply(y.projectionMatrix,y.matrix);f(V);this.initWebGLObjects(l,y);v(B,o!==undefined?o:true); this.autoClear&&this.clear();z=l.__webGLObjects.length;for(o=0;o=0;B--){o=l.__webGLObjects[B].object;y==o&&l.__webGLObjects.splice(B,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.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 b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=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= c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}}; var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var q=0,w=h.length;q= 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;c=Array(f);for(b=e=0;b0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,u)))-1);m.push(q)}b.push(m)}var t,x,A;g=b.length;for(c=0;c0)for(e=0;e1){t=this.vertices[h].position.clone(); x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();t.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,w,E])}}}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,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/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([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= 1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;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 b(w,u,t){var x=Math.sqrt(w*w+u*u+t*t);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,u/x,t/x)))-1}function c(w,u,t,x){x.faces.push(new THREE.Face3(w,u,t))}function e(w,u){var t=g.vertices[w].position,x=g.vertices[u].position;return b((t.x+x.x)/2,(t.y+x.y)/2,(t.z+x.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0, 1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a=this.maxCount-3&&k(this)};this.begin= function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;ethis.size-1)j=this.size-1;var u=Math.floor(m-k);if(u<1)u=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var t=Math.floor(q-k);if(t<1)t=1;k=Math.floor(q+k); if(k>this.size-1)k=this.size-1;var x,A,E,v,F,p;for(w=w;w0)this.field[E+x]+=v}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,q=this.yd,w=this.zd,u=this.field,t=m*Math.sqrt(c/e);if(t>m)t=m;for(g=0;g0)for(f=0;fq)x=q;for(f=0;f0){j=f*w;for(g=0;gsize)dist=size;for(h=0;h0){j=zd*h;for(f=0;f>7)-127;J=(W&127)<<16|R<<8|J;if(J==0&&S==-127)return 0;return(1-2*(la>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,S)}function k(C,L){var J=q(C,L),R=q(C,L+1),W=q(C,L+2);return(q(C,L+3)<<24)+(W<<16)+(R<<8)+J}function j(C,L){var J=q(C,L);return(q(C,L+1)<<8)+J}function m(C,L){var J=q(C,L);return J>127?J-256:J}function q(C,L){return C.charCodeAt(L)&255}function w(C){var L,J,R;L=k(a, C);J=k(a,C+aa);R=k(a,C+O);C=j(a,C+K);THREE.Loader.prototype.f3(v,L,J,R,C)}function u(C){var L,J,R,W,la,S;L=k(a,C);J=k(a,C+aa);R=k(a,C+O);W=j(a,C+K);la=k(a,C+X);S=k(a,C+Q);C=k(a,C+U);THREE.Loader.prototype.f3n(v,M,L,J,R,W,la,S,C)}function t(C){var L,J,R,W;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);C=j(a,C+ea);THREE.Loader.prototype.f4(v,L,J,R,W,C)}function x(C){var L,J,R,W,la,S,ta,sa;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);la=j(a,C+ea);S=k(a,C+Z);ta=k(a,C+fa);sa=k(a,C+ia);C=k(a,C+l);THREE.Loader.prototype.f4n(v, M,L,J,R,W,la,S,ta,sa,C)}function A(C){var L,J;L=k(a,C);J=k(a,C+y);C=k(a,C+B);THREE.Loader.prototype.uv3(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[C*2],d[C*2+1])}function E(C){var L,J,R;L=k(a,C);J=k(a,C+o);R=k(a,C+n);C=k(a,C+N);THREE.Loader.prototype.uv4(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[R*2],d[R*2+1],d[C*2],d[C*2+1])}var v=this,F=0,p,M=[],d=[],aa,O,K,X,Q,U,V,H,Y,ea,Z,fa,ia,l,y,B,o,n,N,G,z,I,D,$,da;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);p={signature:a.substr(F,8), header_bytes:q(a,F+8),vertex_coordinate_bytes:q(a,F+9),normal_coordinate_bytes:q(a,F+10),uv_coordinate_bytes:q(a,F+11),vertex_index_bytes:q(a,F+12),normal_index_bytes:q(a,F+13),uv_index_bytes:q(a,F+14),material_index_bytes:q(a,F+15),nvertices:k(a,F+16),nnormals:k(a,F+16+4),nuvs:k(a,F+16+8),ntri_flat:k(a,F+16+12),ntri_smooth:k(a,F+16+16),ntri_flat_uv:k(a,F+16+20),ntri_smooth_uv:k(a,F+16+24),nquad_flat:k(a,F+16+28),nquad_smooth:k(a,F+16+32),nquad_flat_uv:k(a,F+16+36),nquad_smooth_uv:k(a,F+16+40)};F+= p.header_bytes;aa=p.vertex_index_bytes;O=p.vertex_index_bytes*2;K=p.vertex_index_bytes*3;X=p.vertex_index_bytes*3+p.material_index_bytes;Q=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;U=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;V=p.vertex_index_bytes;H=p.vertex_index_bytes*2;Y=p.vertex_index_bytes*3;ea=p.vertex_index_bytes*4;Z=p.vertex_index_bytes*4+p.material_index_bytes;fa=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;ia=p.vertex_index_bytes* 4+p.material_index_bytes+p.normal_index_bytes*2;l=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;y=p.uv_index_bytes;B=p.uv_index_bytes*2;o=p.uv_index_bytes;n=p.uv_index_bytes*2;N=p.uv_index_bytes*3;f=p.vertex_index_bytes*3+p.material_index_bytes;da=p.vertex_index_bytes*4+p.material_index_bytes;G=p.ntri_flat*f;z=p.ntri_smooth*(f+p.normal_index_bytes*3);I=p.ntri_flat_uv*(f+p.uv_index_bytes*3);D=p.ntri_smooth_uv*(f+p.normal_index_bytes*3+p.uv_index_bytes*3);$=p.nquad_flat*da;f= p.nquad_smooth*(da+p.normal_index_bytes*4);da=p.nquad_flat_uv*(da+p.uv_index_bytes*4);F+=function(C){var L,J,R,W=p.vertex_coordinate_bytes*3,la=C+p.nvertices*W;for(C=C;C