// 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,e){this.r=a;this.g=b;this.b=e;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,e){this.x=a||0;this.y=b||0;this.z=e||0}; THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;this.z=e;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,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*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,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+e*e+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,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1}; THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;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,e,f=a.objects,g=[];a=0;for(b=f.length;a0&&N>0&&n+N<1}var e,f,g,i,k,d,j,l,q,F, o,A=a.geometry,D=A.vertices,E=[];e=0;for(f=A.faces.length;ej?f:j;g=g>l? g:l}a()};this.add3Points=function(j,l,q,F,o,A){if(d){d=false;b=jq?j>o?j:o:q>o?q:o;g=l>F?l>A?l:A:F>A?F:A}else{b=jq?j>o?j>f?j:f:o>f?o:f:q>o?q>f?q:f:o>f?o:f;g=l>F?l>A?l>g?l:g:A>g?A:g:F>A?F>g?F:g:A>g?A:g}a()};this.addRectangle=function(j){if(d){d=false;b=j.getLeft();e=j.getTop();f=j.getRight();g=j.getBottom()}else{b=bj.getRight()?f:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;e-=j;f+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();e=e>j.getTop()?e:j.getTop();f=f=0&&Math.min(g,j.getBottom())-Math.max(e,j.getTop())>=0};this.empty=function(){d=true;g=f=e=b=0;a()};this.isEmpty=function(){return d};this.toString= function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+i+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(a,b,e,f,g,i,k,d,j,l,q,F,o,A,D,E){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=k||0;this.n24=d||0;this.n31=j||0;this.n32=l||0;this.n33=q||1;this.n34=F||0;this.n41=o||0;this.n42=A||0;this.n43=D||0;this.n44=E||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,e,f,g,i,k,d,j,l,q,F,o,A,D,E){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=i;this.n23=k;this.n24=d;this.n31=j;this.n32=l;this.n33=q;this.n34=F;this.n41=o;this.n42=A;this.n43=D;this.n44=E;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,e){var f=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,b).normalize();f.cross(e,i).normalize();g.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a); this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23* f+this.n24*g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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 e=a.n11,f=a.n12,g=a.n13,i=a.n14,k=a.n21,d=a.n22,j=a.n23,l=a.n24,q=a.n31, F=a.n32,o=a.n33,A=a.n34,D=a.n41,E=a.n42,N=a.n43,r=a.n44,O=b.n11,m=b.n12,h=b.n13,n=b.n14,C=b.n21,p=b.n22,B=b.n23,P=b.n24,v=b.n31,G=b.n32,I=b.n33,H=b.n34,w=b.n41,R=b.n42,L=b.n43,X=b.n44;this.n11=e*O+f*C+g*v+i*w;this.n12=e*m+f*p+g*G+i*R;this.n13=e*h+f*B+g*I+i*L;this.n14=e*n+f*P+g*H+i*X;this.n21=k*O+d*C+j*v+l*w;this.n22=k*m+d*p+j*G+l*R;this.n23=k*h+d*B+j*I+l*L;this.n24=k*n+d*P+j*H+l*X;this.n31=q*O+F*C+o*v+A*w;this.n32=q*m+F*p+o*G+A*R;this.n33=q*h+F*B+o*I+A*L;this.n34=q*n+F*P+o*H+A*X;this.n41=D*O+E*C+ N*v+r*w;this.n42=D*m+E*p+N*G+r*R;this.n43=D*h+E*B+N*I+r*L;this.n44=D*n+E*P+N*H+r*X;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,i=this.n21,k=this.n22,d=this.n23,j=this.n24,l=this.n31,q=this.n32,F=this.n33,o=this.n34,A=this.n41,D=this.n42,E=this.n43,N=this.n44,r=a.n11,O=a.n21,m=a.n31,h=a.n41,n=a.n12,C=a.n22,p=a.n32,B=a.n42,P=a.n13,v=a.n23,G=a.n33,I=a.n43,H=a.n14,w=a.n24,R=a.n34;a=a.n44;this.n11=b*r+e*O+f*m+g*h;this.n12=b*n+e*C+f*p+g*B;this.n13=b*P+e*v+f*G+g* I;this.n14=b*H+e*w+f*R+g*a;this.n21=i*r+k*O+d*m+j*h;this.n22=i*n+k*C+d*p+j*B;this.n23=i*P+k*v+d*G+j*I;this.n24=i*H+k*w+d*R+j*a;this.n31=l*r+q*O+F*m+o*h;this.n32=l*n+q*C+F*p+o*B;this.n33=l*P+q*v+F*G+o*I;this.n34=l*H+q*w+F*R+o*a;this.n41=A*r+D*O+E*m+N*h;this.n42=A*n+D*C+E*p+N*B;this.n43=A*P+D*v+E*G+N*I;this.n44=A*H+D*w+E*R+N*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,e=this.n13,f=this.n14,g=this.n21,i=this.n22,k=this.n23,d=this.n24,j=this.n31,l=this.n32,q=this.n33,F=this.n34,o=this.n41,A=this.n42,D=this.n43,E=this.n44;return f*k*l*o-e*d*l*o-f*i*q*o+b*d*q*o+e*i*F*o-b*k*F*o-f*k*j*A+e*d*j*A+f*g*q*A-a*d*q*A-e*g*F*A+a*k*F*A+f*i*j*D-b*d*j*D-f*g*l*D+a*d*l*D+b*g*F*D-a*i*F*D-e*i*j*E+b*k*j*E+e*g*l*E-a*k*l*E-b*g*q*E+a*i*q*E},transpose:function(){function a(b,e, f){var g=b[e];b[e]=b[f];b[f]=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(){this.flat[0]=this.n11;this.flat[1]= this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},setTranslation:function(a,b,e){this.set(1,0,0,a,0,1,0,b,0,0,1,e,0,0,0,1);return this},setScale:function(a,b,e){this.set(a,0,0,0,0,b,0,0,0,0,e,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){c=Math.cos(b);s=Math.sin(b);t=1-c;x=a.x;y=a.y;z=a.z;tx=t*x;ty=t*y;this.set(tx*x+c,tx*y-s*z,tx*z+s*y,0,tx*y+s*z,ty*y+c,ty*z-s*x,0,tx*z-s*y,ty*z+s*x,t*z*z+ 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,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f};THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),i=1-f,k=a.x,d=a.y,j=a.z,l=i*k,q=i*d;e.n11=l*k+f;e.n12=l*d-g*j;e.n13=l*j+g*d;e.n21=l*d+g*j;e.n22=q*d+f;e.n23=q*j-g*k;e.n31=l*j-g*d;e.n32=q*j+g*k;e.n33=i*j*j+f;return e}; THREE.Matrix4.makeInvert=function(a){var b=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,k=a.n22,d=a.n23,j=a.n24,l=a.n31,q=a.n32,F=a.n33,o=a.n34,A=a.n41,D=a.n42,E=a.n43,N=a.n44,r=new THREE.Matrix4;r.n11=d*o*D-j*F*D+j*q*E-k*o*E-d*q*N+k*F*N;r.n12=g*F*D-f*o*D-g*q*E+e*o*E+f*q*N-e*F*N;r.n13=f*j*D-g*d*D+g*k*E-e*j*E-f*k*N+e*d*N;r.n14=g*d*q-f*j*q-g*k*F+e*j*F+f*k*o-e*d*o;r.n21=j*F*A-d*o*A-j*l*E+i*o*E+d*l*N-i*F*N;r.n22=f*o*A-g*F*A+g*l*E-b*o*E-f*l*N+b*F*N;r.n23=g*d*A-f*j*A-g*i*E+b*j*E+f*i*N-b*d*N;r.n24=f*j*l-g*d*l+ g*i*F-b*j*F-f*i*o+b*d*o;r.n31=k*o*A-j*q*A+j*l*D-i*o*D-k*l*N+i*q*N;r.n32=g*q*A-e*o*A-g*l*D+b*o*D+e*l*N-b*q*N;r.n33=f*j*A-g*k*A+g*i*D-b*j*D-e*i*N+b*k*N;r.n34=g*k*l-e*j*l-g*i*q+b*j*q+e*i*o-b*k*o;r.n41=d*q*A-k*F*A-d*l*D+i*F*D+k*l*E-i*q*E;r.n42=e*F*A-f*q*A+f*l*D-b*F*D-e*l*E+b*q*E;r.n43=f*k*A-e*d*A-f*i*D+b*d*D+e*i*E-b*k*E;r.n44=e*d*l-f*k*l+f*i*q-b*d*q-e*i*F+b*k*F;r.multiplyScalar(1/a.determinant());return r}; THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=a.m33;var e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],i=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],d=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],q=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*i+b[2]*j;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*i;a.m[4]=b*k;a.m[5]=b*d;a.m[6]=b*j;a.m[7]=b*l;a.m[8]=b*q;return a}; THREE.Matrix4.makeFrustum=function(a,b,e,f,g,i){var k,d,j;k=new THREE.Matrix4;d=2*g/(b-a);j=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(i+g)/(i-g);g=-2*i*g/(i-g);k.n11=d;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=j;k.n23=e;k.n24=0;k.n31=0;k.n32=0;k.n33=f;k.n34=g;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)}; THREE.Matrix4.makeOrtho=function(a,b,e,f,g,i){var k,d,j,l;k=new THREE.Matrix4;d=b-a;j=e-f;l=i-g;a=(b+a)/d;e=(e+f)/j;g=(i+g)/l;k.n11=2/d;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/j;k.n23=0;k.n24=-e;k.n31=0;k.n32=0;k.n33=-2/l;k.n34=-g;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};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,e,f,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,e,f,g,i){this.a=a;this.b=b;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=i instanceof Array?i:[i]};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.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;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,e=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,e=this.vertices.length;b65535){l[d].counter+=1;j=l[d].hash+"_"+l[d].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:k,vertices:0}}this.geometryChunks[j].faces.push(f);this.geometryChunks[j].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;this.far=f;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.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.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,b=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.identity();if(b.x!=0){f.setRotX(b.x);this.matrix.multiplySelf(f);this.rotationMatrix.multiplySelf(f)}if(b.y!=0){f.setRotY(b.y);this.matrix.multiplySelf(f);this.rotationMatrix.multiplySelf(f)}if(b.z!=0){f.setRotZ(b.z);this.matrix.multiplySelf(f);this.rotationMatrix.multiplySelf(f)}if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y, e.z);this.matrix.multiplySelf(f)}}};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.autoUpdateMatrix=false};THREE.ParticleSystem.prototype=new THREE.Object3D; THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!=undefined?e: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.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";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.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);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.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;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}}; THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
opacity: "+this.opacity+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+ "
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshBasicMaterialCounter={value:0}; THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);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.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;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}}; THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (
id: "+this.id+"
color: "+this.color+"
map: "+this.map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
opacity: "+this.opacity+"
shading: "+this.shading+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+ this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};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.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin= this.wireframe_linecap="round";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.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_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.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;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}}; THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (
id: "+this.id+"
color: "+this.color+"
ambient: "+this.ambient+"
specular: "+this.specular+"
shininess: "+this.shininess+"
map: "+this.map+"
specular_map: "+this.specular_map+"
env_map: "+this.env_map+"
combine: "+this.combine+"
reflectivity: "+this.reflectivity+"
refraction_ratio: "+this.refraction_ratio+"
opacity: "+this.opacity+"
shading: "+this.shading+"
wireframe: "+ this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshPhongMaterialCounter={value:0}; THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}}; THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;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}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};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.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";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.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;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}}; THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (
id: "+this.id+"
blending: "+this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};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,e,f,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i: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,e){this.width=a;this.height=b;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType}; var Uniforms={clone:function(a){var b,e,f,g={};for(b in a){g[b]={};for(e in a[b]){f=a[b][e];g[b][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(a){var b,e,f,g={};for(b=0;b=0&&I>=0&&H>=0&&w>=0)return true;else if(G<0&&I<0||H<0&&w<0)return false;else{if(G<0)P=Math.max(P,G/(G-I));else if(I<0)v=Math.min(v,G/(G-I));if(H<0)P=Math.max(P,H/(H-w));else if(w<0)v=Math.min(v,H/(H-w));if(vG&&L.z0&&N.z<1){o=D[A]=D[A]||new THREE.RenderableParticle;o.x=N.x/N.w;o.y=N.y/N.w;o.z=N.z;o.rotation=S.rotation.z;o.scale.x=S.scale.x*Math.abs(o.x-(N.x+B.projectionMatrix.n11)/(N.w+B.projectionMatrix.n14)); o.scale.y=S.scale.y*Math.abs(o.y-(N.y+B.projectionMatrix.n22)/(N.w+B.projectionMatrix.n24));o.materials=S.materials;v.push(o);A++}}}}P&&v.sort(a);return v};this.unprojectVector=function(p,B){var P=new THREE.Matrix4;P.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));P.multiplyVector3(p);return p}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,i;this.domElement=document.createElement("div");this.setSize=function(k,d){e=k;f=d;g=e/2;i=f/2};this.render=function(k,d){var j,l,q,F,o,A,D,E;a=b.projectScene(k,d);j=0;for(l=a.length;j0){T.r+=oa.r*ia;T.g+=oa.g*ia;T.b+=oa.b*ia}}else if(ia instanceof THREE.PointLight){K.sub(ia.position,ha);K.normalize();ia=da.dot(K)*qa;if(ia>0){T.r+=oa.r*ia;T.g+=oa.g*ia;T.b+=oa.b*ia}}}}function Ta(Q,ha,da){if(da.opacity!= 0){a(da.opacity);b(da.blending);var T,ca,ia,oa,qa,ra;if(da instanceof THREE.ParticleBasicMaterial){if(da.map){oa=da.map;qa=oa.width>>1;ra=oa.height>>1;ca=ha.scale.x*d;ia=ha.scale.y*j;da=ca*qa;T=ia*ra;J.set(Q.x-da,Q.y-T,Q.x+da,Q.y+T);if(ea.instersects(J)){l.save();l.translate(Q.x,Q.y);l.rotate(-ha.rotation);l.scale(ca,-ia);l.translate(-qa,-ra);l.drawImage(oa,0,0);l.restore()}}}else if(da instanceof THREE.ParticleCircleMaterial){if(V){Y.r=la.r+ka.r+u.r;Y.g=la.g+ka.g+u.g;Y.b=la.b+ka.b+u.b;v.r=da.color.r* Y.r;v.g=da.color.g*Y.g;v.b=da.color.b*Y.b;v.updateStyleString()}else v.__styleString=da.color.__styleString;da=ha.scale.x*d;T=ha.scale.y*j;J.set(Q.x-da,Q.y-T,Q.x+da,Q.y+T);if(ea.instersects(J)){ca=v.__styleString;if(E!=ca)l.fillStyle=E=ca;l.save();l.translate(Q.x,Q.y);l.rotate(-ha.rotation);l.scale(da,T);l.beginPath();l.arc(0,0,1,0,M,true);l.closePath();l.fill();l.restore()}}}}function Ua(Q,ha,da,T){if(T.opacity!=0){a(T.opacity);b(T.blending);l.beginPath();l.moveTo(Q.positionScreen.x,Q.positionScreen.y); l.lineTo(ha.positionScreen.x,ha.positionScreen.y);l.closePath();if(T instanceof THREE.LineBasicMaterial){v.__styleString=T.color.__styleString;Q=T.linewidth;if(N!=Q)l.lineWidth=N=Q;Q=v.__styleString;if(D!=Q)l.strokeStyle=D=Q;l.stroke();J.inflate(T.linewidth*2)}}}function Oa(Q,ha,da,T,ca,ia){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);h=Q.positionScreen.x;n=Q.positionScreen.y;C=ha.positionScreen.x;p=ha.positionScreen.y;B=da.positionScreen.x;P=da.positionScreen.y;l.beginPath();l.moveTo(h,n);l.lineTo(C, p);l.lineTo(B,P);l.lineTo(h,n);l.closePath();if(ca instanceof THREE.MeshBasicMaterial)if(ca.map)ca.map.image.loaded&&ca.map.mapping instanceof THREE.UVMapping&&Da(h,n,C,p,B,P,ca.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(ca.env_map){if(ca.env_map.image.loaded)if(ca.env_map.mapping instanceof THREE.SphericalReflectionMapping){Q=za.matrix;K.copy(T.vertexNormalsWorld[0]);Z=(K.x*Q.n11+K.y*Q.n12+K.z*Q.n13)*0.5+0.5;S=-(K.x*Q.n21+K.y*Q.n22+K.z*Q.n23)*0.5+0.5;K.copy(T.vertexNormalsWorld[1]); ga=(K.x*Q.n11+K.y*Q.n12+K.z*Q.n13)*0.5+0.5;$=-(K.x*Q.n21+K.y*Q.n22+K.z*Q.n23)*0.5+0.5;K.copy(T.vertexNormalsWorld[2]);U=(K.x*Q.n11+K.y*Q.n12+K.z*Q.n13)*0.5+0.5;W=-(K.x*Q.n21+K.y*Q.n22+K.z*Q.n23)*0.5+0.5;Da(h,n,C,p,B,P,ca.env_map.image,Z,S,ga,$,U,W)}}else ca.wireframe?Ha(ca.color.__styleString,ca.wireframe_linewidth):Ia(ca.color.__styleString);else if(ca instanceof THREE.MeshLambertMaterial){if(ca.map&&!ca.wireframe){ca.map.mapping instanceof THREE.UVMapping&&Da(h,n,C,p,B,P,ca.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(V)if(!ca.wireframe&&ca.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){G.r=I.r=H.r=la.r;G.g=I.g=H.g=la.g;G.b=I.b=H.b=la.b;Ga(ia,T.v1.positionWorld,T.vertexNormalsWorld[0],G);Ga(ia,T.v2.positionWorld,T.vertexNormalsWorld[1],I);Ga(ia,T.v3.positionWorld,T.vertexNormalsWorld[2],H);w.r=(I.r+H.r)*0.5;w.g=(I.g+H.g)*0.5;w.b=(I.b+H.b)*0.5;X=Pa(G,I,H,w);Da(h,n,C,p,B,P,X,0,0,1,0,0,1)}else{Y.r=la.r;Y.g=la.g; Y.b=la.b;Ga(ia,T.centroidWorld,T.normalWorld,Y);v.r=ca.color.r*Y.r;v.g=ca.color.g*Y.g;v.b=ca.color.b*Y.b;v.updateStyleString();ca.wireframe?Ha(v.__styleString,ca.wireframe_linewidth):Ia(v.__styleString)}else ca.wireframe?Ha(ca.color.__styleString,ca.wireframe_linewidth):Ia(ca.color.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){R=za.near;L=za.far;G.r=G.g=G.b=1-Ka(Q.positionScreen.z,R,L);I.r=I.g=I.b=1-Ka(ha.positionScreen.z,R,L);H.r=H.g=H.b=1-Ka(da.positionScreen.z,R,L);w.r=(I.r+H.r)* 0.5;w.g=(I.g+H.g)*0.5;w.b=(I.b+H.b)*0.5;X=Pa(G,I,H,w);Da(h,n,C,p,B,P,X,0,0,1,0,0,1)}else if(ca instanceof THREE.MeshNormalMaterial){v.r=La(T.normalWorld.x);v.g=La(T.normalWorld.y);v.b=La(T.normalWorld.z);v.updateStyleString();ca.wireframe?Ha(v.__styleString,ca.wireframe_linewidth):Ia(v.__styleString)}}}function Ha(Q,ha){if(D!=Q)l.strokeStyle=D=Q;if(N!=ha)l.lineWidth=N=ha;l.stroke();J.inflate(ha*2)}function Ia(Q){if(E!=Q)l.fillStyle=E=Q;l.fill()}function Da(Q,ha,da,T,ca,ia,oa,qa,ra,wa,sa,xa,Ea){var Aa, ya;Aa=oa.width-1;ya=oa.height-1;qa*=Aa;ra*=ya;wa*=Aa;sa*=ya;xa*=Aa;Ea*=ya;da-=Q;T-=ha;ca-=Q;ia-=ha;wa-=qa;sa-=ra;xa-=qa;Ea-=ra;ya=1/(wa*Ea-xa*sa);Aa=(Ea*da-sa*ca)*ya;sa=(Ea*T-sa*ia)*ya;da=(wa*ca-xa*da)*ya;T=(wa*ia-xa*T)*ya;Q=Q-Aa*qa-da*ra;ha=ha-sa*qa-T*ra;l.save();l.transform(Aa,sa,da,T,Q,ha);l.clip();l.drawImage(oa,0,0);l.restore()}function Pa(Q,ha,da,T){var ca=~~(Q.r*255),ia=~~(Q.g*255);Q=~~(Q.b*255);var oa=~~(ha.r*255),qa=~~(ha.g*255);ha=~~(ha.b*255);var ra=~~(da.r*255),wa=~~(da.g*255);da=~~(da.b* 255);var sa=~~(T.r*255),xa=~~(T.g*255);T=~~(T.b*255);ma[0]=ca<0?0:ca>255?255:ca;ma[1]=ia<0?0:ia>255?255:ia;ma[2]=Q<0?0:Q>255?255:Q;ma[4]=oa<0?0:oa>255?255:oa;ma[5]=qa<0?0:qa>255?255:qa;ma[6]=ha<0?0:ha>255?255:ha;ma[8]=ra<0?0:ra>255?255:ra;ma[9]=wa<0?0:wa>255?255:wa;ma[10]=da<0?0:da>255?255:da;ma[12]=sa<0?0:sa>255?255:sa;ma[13]=xa<0?0:xa>255?255:xa;ma[14]=T<0?0:T>255?255:T;fa.putImageData(ja,0,0);va.drawImage(ba,0,0);return ta}function Ka(Q,ha,da){Q=(Q-ha)/(da-ha);return Q*Q*(3-2*Q)}function La(Q){Q= (Q+1)*0.5;return Q<0?0:Q>1?1:Q}function Ma(Q,ha){var da=ha.x-Q.x,T=ha.y-Q.y,ca=1/Math.sqrt(da*da+T*T);da*=ca;T*=ca;ha.x+=da;ha.y+=T;Q.x-=da;Q.y-=T}var Ja,Qa,na,ua,Ca,Na,Ra,Fa;l.setTransform(1,0,0,-1,d,j);this.autoClear&&this.clear();e=f.projectScene(pa,za,this.sortElements);(V=pa.lights.length>0)&&Sa(pa);Ja=0;for(Qa=e.length;Ja0){ga.r+=W.color.r*ea;ga.g+=W.color.g*ea;ga.b+=W.color.b*ea}}else if(W instanceof THREE.PointLight){P.sub(W.position,S.centroidWorld);P.normalize();ea=S.normalWorld.dot(P)*W.intensity;if(ea>0){ga.r+=W.color.r*ea;ga.g+=W.color.g*ea;ga.b+=W.color.b*ea}}}}function b(Z,S,ga,$,U,W){H=f(w++);H.setAttribute("d", "M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+ga.positionScreen.x+","+ga.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(O){h.r=n.r;h.g=n.g;h.b=n.b;a(W,$,h);m.r=U.color.r*h.r;m.g=U.color.g*h.g;m.b=U.color.b*h.b;m.updateStyleString()}else m.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshDepthMaterial){B=1-U.__2near/(U.__farPlusNear- $.z*U.__farMinusNear);m.setRGB(B,B,B)}else U instanceof THREE.MeshNormalMaterial&&m.setRGB(g($.normalWorld.x),g($.normalWorld.y),g($.normalWorld.z));U.wireframe?H.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):H.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+U.opacity);d.appendChild(H)}function e(Z,S,ga,$,U,W,ea){H= f(w++);H.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+S.positionScreen.x+" "+S.positionScreen.y+" L "+ga.positionScreen.x+","+ga.positionScreen.y+" L "+$.positionScreen.x+","+$.positionScreen.y+"z");if(W instanceof THREE.MeshBasicMaterial)m.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshLambertMaterial)if(O){h.r=n.r;h.g=n.g;h.b=n.b;a(ea,U,h);m.r=W.color.r*h.r;m.g=W.color.g*h.g;m.b=W.color.b*h.b;m.updateStyleString()}else m.__styleString=W.color.__styleString; else if(W instanceof THREE.MeshDepthMaterial){B=1-W.__2near/(W.__farPlusNear-U.z*W.__farMinusNear);m.setRGB(B,B,B)}else W instanceof THREE.MeshNormalMaterial&&m.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));W.wireframe?H.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+W.wireframe_linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.wireframe_linecap+"; stroke-linejoin: "+W.wireframe_linejoin):H.setAttribute("style","fill: "+m.__styleString+ "; fill-opacity: "+W.opacity);d.appendChild(H)}function f(Z){if(v[Z]==null){v[Z]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&v[Z].setAttribute("shape-rendering","crispEdges");return v[Z]}return v[Z]}function g(Z){return Z<0?Math.min((1+Z)*0.5,0.5):0.5+Math.min(Z*0.5,0.5)}var i=null,k=new THREE.Projector,d=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,q,F,o,A,D,E,N=new THREE.Rectangle,r=new THREE.Rectangle,O=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215), n=new THREE.Color(0),C=new THREE.Color(0),p=new THREE.Color(0),B,P=new THREE.Vector3,v=[],G=[],I=[],H,w,R,L,X=1;this.domElement=d;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Z){switch(Z){case "high":X=1;break;case "low":X=0}};this.setSize=function(Z,S){j=Z;l=S;q=j/2;F=l/2;d.setAttribute("viewBox",-q+" "+-F+" "+j+" "+l);d.setAttribute("width",j);d.setAttribute("height",l);N.set(-q,-F,q,F)};this.clear=function(){for(;d.childNodes.length>0;)d.removeChild(d.childNodes[0])}; this.render=function(Z,S){var ga,$,U,W,ea,aa,J,V;this.autoClear&&this.clear();i=k.projectScene(Z,S,this.sortElements);L=R=w=0;if(O=Z.lights.length>0){J=Z.lights;n.setRGB(0,0,0);C.setRGB(0,0,0);p.setRGB(0,0,0);ga=0;for($=J.length;ga<$;ga++){U=J[ga];W=U.color;if(U instanceof THREE.AmbientLight){n.r+=W.r;n.g+=W.g;n.b+=W.b}else if(U instanceof THREE.DirectionalLight){C.r+=W.r;C.g+=W.g;C.b+=W.b}else if(U instanceof THREE.PointLight){p.r+=W.r;p.g+=W.g;p.b+=W.b}}}ga=0;for($=i.length;ga<$;ga++){J=i[ga];r.empty(); if(J instanceof THREE.RenderableParticle){o=J;o.x*=q;o.y*=-F;U=0;for(W=J.materials.length;U0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,la,C)}if(B){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, h.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,M,C);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,K,C)}};this.setLineBuffers=function(h,n,C,p){var B,P,v=h.vertices,G=v.length,I=h.__vertexArray,H=h.__lineArray;if(C)for(C=0;C0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+H.maxDirLights,"#define MAX_POINT_LIGHTS "+H.maxPointLights, H.map?"#define USE_MAP":"",H.env_map?"#define USE_ENVMAP":"","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 vec2 uv;\n"].join("\n");d.attachShader(R,g("fragment",L+G));d.attachShader(R,g("vertex",H+w));d.linkProgram(R);d.getProgramParameter(R,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+ d.getProgramParameter(R,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");R.uniforms={};R.attributes={};p.program=R;G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in p.uniforms)G.push(v);v=p.program;w=0;for(R=G.length;w=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLNormalBuffer);d.vertexAttribPointer(I.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.normal)}if(I.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLTangentBuffer); d.vertexAttribPointer(I.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.tangent)}if(I.uv>=0)if(B.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,B.__webGLUVBuffer);d.vertexAttribPointer(I.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(I.uv)}else d.disableVertexAttribArray(I.uv);if(p.wireframe||p instanceof THREE.LineBasicMaterial){I=p.wireframe_linewidth!==undefined?p.wireframe_linewidth:p.linewidth!==undefined?p.linewidth:1;p=p instanceof THREE.LineBasicMaterial&&P.type==THREE.LineStrip? d.LINE_STRIP:d.LINES;d.lineWidth(I);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);d.drawElements(p,B.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,B.__webGLFaceCount,d.UNSIGNED_SHORT,0)}};this.renderPass=function(h,n,C,p,B,P,v){var G,I,H,w,R;H=0;for(w=p.materials.length;H=0;C--){p=h.__webGLObjects[C].object;n==p&&h.__webGLObjects.splice(C,1)}};this.setupMatrices=function(h,n){h.autoUpdateMatrix&& h.updateMatrix();q.multiply(n.matrix,h.matrix);A.set(q.flatten());F=THREE.Matrix4.makeInvert3x3(q).transpose();E.set(F.m);N.set(h.matrix.flatten())};this.loadMatrices=function(h){d.uniformMatrix4fv(h.uniforms.viewMatrix,false,o);d.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,A);d.uniformMatrix4fv(h.uniforms.projectionMatrix,false,D);d.uniformMatrix3fv(h.uniforms.normalMatrix,false,E);d.uniformMatrix4fv(h.uniforms.objectMatrix,false,N)};this.loadCamera=function(h,n){d.uniform3f(h.uniforms.cameraPosition, n.position.x,n.position.y,n.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,n){if(h){!n||n=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(h=="back")d.cullFace(d.BACK);else h=="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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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 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"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,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:[]}}}; THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\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 color;\nuniform float opacity;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );", THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 color;\nuniform float opacity;\nvarying vec3 vLightWeighting;", THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,"gl_FragColor = mColor * mapColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex, THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_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 color;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.map_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,THREE.Snippets.lights_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );\nvec4 cubeColor = vec4( 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lights_fragment, "gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );",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.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_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")}};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}; var GeometryUtils={merge:function(a,b){var e=b instanceof THREE.Mesh,f=a.vertices.length,g=e?b.geometry:b,i=a.vertices,k=g.vertices,d=a.faces,j=g.faces,l=a.uvs;g=g.uvs;e&&b.autoUpdateMatrix&&b.updateMatrix();for(var q=0,F=k.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}"},basic:{uniforms:{}, vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"}}},Cube=function(a,b,e,f,g,i,k,d){function j(E,N,r,O,m,h,n,C){var p,B,P=f||1,v=g||1,G=P+1,I=v+1,H=m/2,w=h/2;m=m/P;var R=h/v,L=l.vertices.length;if(E=="x"&&N=="y"||E=="y"&&N=="x")p="z";else if(E=="x"&&N=="z"||E=="z"&&N=="x")p="y";else if(E=="z"&&N=="y"||E=="y"&&N=="z")p="x";for(B=0;B0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(F,d,o)))-1);l.push(q)}b.push(l)}var A,D,E;g=b.length;for(e=0;e0)for(f=0;f1){A=this.vertices[k].position.clone(); D=this.vertices[j].position.clone();E=this.vertices[l].position.clone();A.normalize();D.normalize();E.normalize();this.faces.push(new THREE.Face3(k,j,l,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(D.x,D.y,D.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([q,F,N])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; function LathedObject(a,b,e){THREE.Geometry.call(this);b=b||12;e=e||2*Math.PI;b=e/b;for(var f=[],g=[],i=[],k=[],d=0;d>7)-127;K=(fa&127)<<16|ba<<8|K;if(K==0&&ma==-127)return 0;return(1-2*(ja>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,ma)}function d(u,M){var K=q(u,M),ba=q(u,M+1),fa=q(u,M+2);return(q(u,M+3)<<24)+(fa<<16)+(ba<<8)+K}function j(u,M){var K=q(u,M);return(q(u,M+1)<<8)+K}function l(u,M){var K=q(u,M);return K>127?K-256:K}function q(u,M){return u.charCodeAt(M)&255}function F(u){var M, K,ba;M=d(a,u);K=d(a,u+C);ba=d(a,u+p);u=j(a,u+B);THREE.Loader.prototype.f3(r,M,K,ba,u)}function o(u){var M,K,ba,fa,ja,ma;M=d(a,u);K=d(a,u+C);ba=d(a,u+p);fa=j(a,u+B);ja=d(a,u+P);ma=d(a,u+v);u=d(a,u+G);THREE.Loader.prototype.f3n(r,h,M,K,ba,fa,ja,ma,u)}function A(u){var M,K,ba,fa;M=d(a,u);K=d(a,u+I);ba=d(a,u+H);fa=d(a,u+w);u=j(a,u+R);THREE.Loader.prototype.f4(r,M,K,ba,fa,u)}function D(u){var M,K,ba,fa,ja,ma,ta,va;M=d(a,u);K=d(a,u+I);ba=d(a,u+H);fa=d(a,u+w);ja=j(a,u+R);ma=d(a,u+L);ta=d(a,u+X);va=d(a,u+ Z);u=d(a,u+S);THREE.Loader.prototype.f4n(r,h,M,K,ba,fa,ja,ma,ta,va,u)}function E(u){var M,K;M=d(a,u);K=d(a,u+ga);u=d(a,u+$);THREE.Loader.prototype.uv3(r,n[M*2],n[M*2+1],n[K*2],n[K*2+1],n[u*2],n[u*2+1])}function N(u){var M,K,ba;M=d(a,u);K=d(a,u+U);ba=d(a,u+W);u=d(a,u+ea);THREE.Loader.prototype.uv4(r,n[M*2],n[M*2+1],n[K*2],n[K*2+1],n[ba*2],n[ba*2+1],n[u*2],n[u*2+1])}var r=this,O=0,m,h=[],n=[],C,p,B,P,v,G,I,H,w,R,L,X,Z,S,ga,$,U,W,ea,aa,J,V,Y,la,ka;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(r, f,i);m={signature:a.substr(O,8),header_bytes:q(a,O+8),vertex_coordinate_bytes:q(a,O+9),normal_coordinate_bytes:q(a,O+10),uv_coordinate_bytes:q(a,O+11),vertex_index_bytes:q(a,O+12),normal_index_bytes:q(a,O+13),uv_index_bytes:q(a,O+14),material_index_bytes:q(a,O+15),nvertices:d(a,O+16),nnormals:d(a,O+16+4),nuvs:d(a,O+16+8),ntri_flat:d(a,O+16+12),ntri_smooth:d(a,O+16+16),ntri_flat_uv:d(a,O+16+20),ntri_smooth_uv:d(a,O+16+24),nquad_flat:d(a,O+16+28),nquad_smooth:d(a,O+16+32),nquad_flat_uv:d(a,O+16+36), nquad_smooth_uv:d(a,O+16+40)};O+=m.header_bytes;C=m.vertex_index_bytes;p=m.vertex_index_bytes*2;B=m.vertex_index_bytes*3;P=m.vertex_index_bytes*3+m.material_index_bytes;v=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;G=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;I=m.vertex_index_bytes;H=m.vertex_index_bytes*2;w=m.vertex_index_bytes*3;R=m.vertex_index_bytes*4;L=m.vertex_index_bytes*4+m.material_index_bytes;X=m.vertex_index_bytes*4+m.material_index_bytes+ m.normal_index_bytes;Z=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;S=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;ga=m.uv_index_bytes;$=m.uv_index_bytes*2;U=m.uv_index_bytes;W=m.uv_index_bytes*2;ea=m.uv_index_bytes*3;i=m.vertex_index_bytes*3+m.material_index_bytes;ka=m.vertex_index_bytes*4+m.material_index_bytes;aa=m.ntri_flat*i;J=m.ntri_smooth*(i+m.normal_index_bytes*3);V=m.ntri_flat_uv*(i+m.uv_index_bytes*3);Y=m.ntri_smooth_uv*(i+m.normal_index_bytes* 3+m.uv_index_bytes*3);la=m.nquad_flat*ka;i=m.nquad_smooth*(ka+m.normal_index_bytes*4);ka=m.nquad_flat_uv*(ka+m.uv_index_bytes*4);O+=function(u){var M,K,ba,fa=m.vertex_coordinate_bytes*3,ja=u+m.nvertices*fa;for(u=u;u