ThreeExtras.js 162 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. // ThreeExtras.js r32 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
  3. THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,g,f,h,b,j;if(d==0)e=g=f=0;else{h=Math.floor(a*6);b=a*6-h;a=d*(1-c);j=d*(1-c*b);c=d*(1-c*(1-b));switch(h){case 1:e=j;g=d;f=a;break;case 2:e=a;g=d;f=c;break;case 3:e=a;g=j;f=d;break;case 4:e=c;g=a;f=d;break;case 5:e=d;g=a;f=j;break;case 6:case 0:e=d;g=c;f=a}}this.r=e;this.g=g;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
  4. 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: "+
  5. this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
  6. THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
  7. this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
  8. THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
  9. cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
  10. a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
  11. -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+" )"}};
  12. THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
  13. THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
  14. return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
  15. THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  16. THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,g=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function c(H,y,I,v){v=v.clone().subSelf(y);I=I.clone().subSelf(y);var L=H.clone().subSelf(y);H=v.dot(v);y=v.dot(I);v=v.dot(L);var k=I.dot(I);I=I.dot(L);L=1/(H*k-y*y);k=(k*v-y*I)*L;H=(H*I-y*v)*L;return k>0&&H>0&&k+H<1}var d,e,g,f,h,b,j,l,t,A,
  17. w,o=a.geometry,p=o.vertices,C=[];d=0;for(e=o.faces.length;d<e;d++){g=o.faces[d];A=this.origin.clone();w=this.direction.clone();f=a.matrix.multiplyVector3(p[g.a].position.clone());h=a.matrix.multiplyVector3(p[g.b].position.clone());b=a.matrix.multiplyVector3(p[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(p[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());t=w.dot(l);if(t<0){l=l.dot((new THREE.Vector3).sub(f,A))/t;A=A.addSelf(w.multiplyScalar(l));
  18. if(g instanceof THREE.Face3){if(c(A,f,h,b)){g={distance:this.origin.distanceTo(A),point:A,face:g,object:a};C.push(g)}}else if(g instanceof THREE.Face4)if(c(A,f,h,j)||c(A,h,b,j)){g={distance:this.origin.distanceTo(A),point:A,face:g,object:a};C.push(g)}}}return C}};
  19. THREE.Rectangle=function(){function a(){f=e-c;h=g-d}var c,d,e,g,f,h,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,l,t,A){b=false;c=j;d=l;e=t;g=A;a()};this.addPoint=function(j,l){if(b){b=false;c=j;d=l;e=j;g=l}else{c=c<j?c:j;d=d<l?d:l;e=e>j?e:j;g=g>l?
  20. g:l}a()};this.add3Points=function(j,l,t,A,w,o){if(b){b=false;c=j<t?j<w?j:w:t<w?t:w;d=l<A?l<o?l:o:A<o?A:o;e=j>t?j>w?j:w:t>w?t:w;g=l>A?l>o?l:o:A>o?A:o}else{c=j<t?j<w?j<c?j:c:w<c?w:c:t<w?t<c?t:c:w<c?w:c;d=l<A?l<o?l<d?l:d:o<d?o:d:A<o?A<d?A:d:o<d?o:d;e=j>t?j>w?j>e?j:e:w>e?w:e:t>w?t>e?t:e:w>e?w:e;g=l>A?l>o?l>g?l:g:o>g?o:g:A>o?A>g?A:g:o>g?o:g}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();e=j.getRight();g=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();d=d<j.getTop()?d:j.getTop();
  21. e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){c-=j;d-=j;e+=j;g+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
  22. function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
  23. THREE.Matrix4=function(a,c,d,e,g,f,h,b,j,l,t,A,w,o,p,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=b||0;this.n31=j||0;this.n32=l||0;this.n33=t||1;this.n34=A||0;this.n41=w||0;this.n42=o||0;this.n43=p||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
  24. THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,g,f,h,b,j,l,t,A,w,o,p,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=b;this.n31=j;this.n32=l;this.n33=t;this.n34=A;this.n41=w;this.n42=o;this.n43=p;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
  25. a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,c).normalize();e.cross(d,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
  26. this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
  27. e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,b=a.n22,j=a.n23,l=a.n24,t=a.n31,
  28. A=a.n32,w=a.n33,o=a.n34,p=a.n41,C=a.n42,H=a.n43,y=a.n44,I=c.n11,v=c.n12,L=c.n13,k=c.n14,B=c.n21,n=c.n22,m=c.n23,z=c.n24,q=c.n31,D=c.n32,x=c.n33,u=c.n34,F=c.n41,J=c.n42,G=c.n43,T=c.n44;this.n11=d*I+e*B+g*q+f*F;this.n12=d*v+e*n+g*D+f*J;this.n13=d*L+e*m+g*x+f*G;this.n14=d*k+e*z+g*u+f*T;this.n21=h*I+b*B+j*q+l*F;this.n22=h*v+b*n+j*D+l*J;this.n23=h*L+b*m+j*x+l*G;this.n24=h*k+b*z+j*u+l*T;this.n31=t*I+A*B+w*q+o*F;this.n32=t*v+A*n+w*D+o*J;this.n33=t*L+A*m+w*x+o*G;this.n34=t*k+A*z+w*u+o*T;this.n41=p*I+C*B+
  29. H*q+y*F;this.n42=p*v+C*n+H*D+y*J;this.n43=p*L+C*m+H*x+y*G;this.n44=p*k+C*z+H*u+y*T;return this},multiplyToArray:function(a,c,d){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,b=a.n21,j=a.n22,l=a.n23,t=a.n24,A=a.n31,w=a.n32,o=a.n33,p=a.n34,C=a.n41,H=a.n42,y=a.n43;a=a.n44;var I=c.n11,v=c.n12,L=c.n13,k=c.n14,B=c.n21,n=c.n22,m=c.n23,z=c.n24,q=c.n31,D=c.n32,x=c.n33,u=c.n34,F=c.n41,J=c.n42,G=c.n43;c=c.n44;this.n11=e*I+g*B+f*q+h*F;this.n12=e*v+g*n+f*D+h*J;this.n13=e*L+g*m+f*x+h*G;this.n14=e*k+g*z+f*u+h*c;this.n21=
  30. b*I+j*B+l*q+t*F;this.n22=b*v+j*n+l*D+t*J;this.n23=b*L+j*m+l*x+t*G;this.n24=b*k+j*z+l*u+t*c;this.n31=A*I+w*B+o*q+p*F;this.n32=A*v+w*n+o*D+p*J;this.n33=A*L+w*m+o*x+p*G;this.n34=A*k+w*z+o*u+p*c;this.n41=C*I+H*B+y*q+a*F;this.n42=C*v+H*n+y*D+a*J;this.n43=C*L+H*m+y*x+a*G;this.n44=C*k+H*z+y*u+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;
  31. d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,b=this.n23,j=this.n24,l=this.n31,t=this.n32,A=this.n33,w=this.n34,o=this.n41,p=this.n42,C=this.n43,H=this.n44,y=a.n11,I=a.n21,v=a.n31,L=a.n41,k=a.n12,B=a.n22,n=a.n32,m=a.n42,z=a.n13,q=a.n23,D=a.n33,x=a.n43,u=a.n14,F=a.n24,J=a.n34;a=a.n44;this.n11=c*y+d*I+e*v+g*L;this.n12=c*k+d*B+e*n+g*m;this.n13=c*z+d*q+e*D+g*x;this.n14=c*u+d*F+e*J+g*a;this.n21=f*y+h*I+b*v+j*L;this.n22=f*k+h*
  32. B+b*n+j*m;this.n23=f*z+h*q+b*D+j*x;this.n24=f*u+h*F+b*J+j*a;this.n31=l*y+t*I+A*v+w*L;this.n32=l*k+t*B+A*n+w*m;this.n33=l*z+t*q+A*D+w*x;this.n34=l*u+t*F+A*J+w*a;this.n41=o*y+p*I+C*v+H*L;this.n42=o*k+p*B+C*n+H*m;this.n43=o*z+p*q+C*D+H*x;this.n44=o*u+p*F+C*J+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},
  33. determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,b=this.n24,j=this.n31,l=this.n32,t=this.n33,A=this.n34,w=this.n41,o=this.n42,p=this.n43,C=this.n44;return e*h*l*w-d*b*l*w-e*f*t*w+c*b*t*w+d*f*A*w-c*h*A*w-e*h*j*o+d*b*j*o+e*g*t*o-a*b*t*o-d*g*A*o+a*h*A*o+e*f*j*p-c*b*j*p-e*g*l*p+a*b*l*p+c*g*A*p-a*f*A*p-d*f*j*C+c*h*j*C+d*g*l*C-a*h*l*C-c*g*t*C+a*f*t*C},transpose:function(){function a(c,d,e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31",
  34. "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]=
  35. this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,
  36. 1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,f=a.x,h=a.y,b=a.z,
  37. j=g*f,l=g*h;this.set(j*f+d,j*h-e*b,j*b+e*h,0,j*h+e*b,l*h+d,l*b-e*f,0,j*b-e*h,l*b+e*f,g*b*b+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};
  38. THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
  39. THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,b=a.n23,j=a.n24,l=a.n31,t=a.n32,A=a.n33,w=a.n34,o=a.n41,p=a.n42,C=a.n43,H=a.n44,y=new THREE.Matrix4;y.n11=b*w*p-j*A*p+j*t*C-h*w*C-b*t*H+h*A*H;y.n12=g*A*p-e*w*p-g*t*C+d*w*C+e*t*H-d*A*H;y.n13=e*j*p-g*b*p+g*h*C-d*j*C-e*h*H+d*b*H;y.n14=g*b*t-e*j*t-g*h*A+d*j*A+e*h*w-d*b*w;y.n21=j*A*o-b*w*o-j*l*C+f*w*C+b*l*H-f*A*H;y.n22=e*w*o-g*A*o+g*l*C-c*w*C-e*l*H+c*A*H;y.n23=g*b*o-e*j*o-g*f*C+c*j*C+e*f*H-c*b*H;y.n24=e*j*l-g*b*l+
  40. g*f*A-c*j*A-e*f*w+c*b*w;y.n31=h*w*o-j*t*o+j*l*p-f*w*p-h*l*H+f*t*H;y.n32=g*t*o-d*w*o-g*l*p+c*w*p+d*l*H-c*t*H;y.n33=e*j*o-g*h*o+g*f*p-c*j*p-d*f*H+c*h*H;y.n34=g*h*l-d*j*l-g*f*t+c*j*t+d*f*w-c*h*w;y.n41=b*t*o-h*A*o-b*l*p+f*A*p+h*l*C-f*t*C;y.n42=d*A*o-e*t*o+e*l*p-c*A*p-d*l*C+c*t*C;y.n43=e*h*o-d*b*o-e*f*p+c*b*p+d*f*C-c*h*C;y.n44=d*b*l-e*h*l+e*f*t-c*b*t-d*f*A+c*h*A;y.multiplyScalar(1/a.determinant());return y};
  41. THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,b=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*f;d[3]=a*h;d[4]=a*b;d[5]=a*j;d[6]=a*l;d[7]=a*t;d[8]=a*A;return c};
  42. THREE.Matrix4.makeFrustum=function(a,c,d,e,g,f){var h,b,j;h=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=b;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)};
  43. THREE.Matrix4.makeOrtho=function(a,c,d,e,g,f){var h,b,j,l;h=new THREE.Matrix4;b=c-a;j=d-e;l=f-g;a=(c+a)/b;d=(d+e)/j;g=(f+g)/l;h.n11=2/b;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  44. THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
  45. THREE.Face3=function(a,c,d,e,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  46. THREE.Face4=function(a,c,d,e,g,f){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
  47. THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
  48. THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
  49. d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,g,f,h,b=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){b.set(0,0,0);c=0;for(d=f.normal.length;c<d;c++)b.addSelf(f.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[f.a];d=this.vertices[f.b];h=this.vertices[f.c];b.sub(h.position,
  50. d.position);j.sub(c.position,d.position);b.crossSelf(j)}b.isZero()||b.normalize();f.normal.copy(b)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
  51. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
  52. c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(u,F,J,G,T,U,O){f=u.vertices[F].position;h=u.vertices[J].position;b=u.vertices[G].position;j=g[T];l=g[U];t=g[O];A=h.x-f.x;w=b.x-f.x;o=h.y-f.y;p=b.y-f.y;
  53. C=h.z-f.z;H=b.z-f.z;y=l.u-j.u;I=t.u-j.u;v=l.v-j.v;L=t.v-j.v;k=1/(y*L-I*v);m.set((L*A-v*w)*k,(L*o-v*p)*k,(L*C-v*H)*k);z.set((y*w-I*A)*k,(y*p-I*o)*k,(y*H-I*C)*k);B[F].addSelf(m);B[J].addSelf(m);B[G].addSelf(m);n[F].addSelf(z);n[J].addSelf(z);n[G].addSelf(z)}var c,d,e,g,f,h,b,j,l,t,A,w,o,p,C,H,y,I,v,L,k,B=[],n=[],m=new THREE.Vector3,z=new THREE.Vector3,q=new THREE.Vector3,D=new THREE.Vector3,x=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){B[c]=new THREE.Vector3;n[c]=new THREE.Vector3}c=0;
  54. for(d=this.faces.length;c<d;c++){e=this.faces[c];g=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
  55. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){x.copy(this.vertices[c].normal);e=B[c];q.copy(e);q.subSelf(x.multiplyScalar(x.dot(e))).normalize();D.cross(this.vertices[c].normal,e);e=D.dot(n[c]);e=e<0?-1:1;this.vertices[c].tangent.set(q.x,q.y,q.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
  56. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
  57. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(t){var A=[];c=0;for(d=t.length;c<d;c++)t[c]==undefined?A.push("undefined"):A.push(t[c].toString());return A.join("_")}var c,d,e,g,f,h,b,j,l={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
  58. h=f.materials;b=a(h);if(l[b]==undefined)l[b]={hash:b,counter:0};j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){l[b].counter+=1;j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
  59. this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
  60. THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
  61. 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()};
  62. THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
  63. THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
  64. 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};
  65. THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
  66. THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
  67. THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
  68. 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;
  69. 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=
  70. 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}};
  71. THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.LineBasicMaterialCounter={value:0};
  72. 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!==
  73. 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!==
  74. 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}};
  75. THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+
  76. "<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
  77. 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!==
  78. 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!==
  79. 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}};
  80. THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+
  81. "<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
  82. 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=
  83. 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=
  84. 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=
  85. 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}};
  86. THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+
  87. this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
  88. 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!==
  89. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshDepthMaterialCounter={value:0};
  90. 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!==
  91. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshNormalMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
  92. 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=
  93. 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!==
  94. undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  95. THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
  96. 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;
  97. 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 (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
  98. 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 (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
  99. THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,e,g,f){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter};
  100. 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 (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
  101. 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;
  102. THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
  103. var Uniforms={clone:function(a){var c,d,e,g={};for(c in a){g[c]={};for(d in a[c]){e=a[c][d];g[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var c,d,e,g={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)g[d]=e[d]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  104. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  105. THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
  106. THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
  107. THREE.Projector=function(){function a(n,m){return m.z-n.z}function c(n,m){var z=0,q=1,D=n.z+n.w,x=m.z+m.w,u=-n.z+n.w,F=-m.z+m.w;if(D>=0&&x>=0&&u>=0&&F>=0)return true;else if(D<0&&x<0||u<0&&F<0)return false;else{if(D<0)z=Math.max(z,D/(D-x));else if(x<0)q=Math.min(q,D/(D-x));if(u<0)z=Math.max(z,u/(u-F));else if(F<0)q=Math.min(q,u/(u-F));if(q<z)return false;else{n.lerpSelf(m,z);m.lerpSelf(n,1-q);return true}}}var d,e,g=[],f,h,b,j=[],l,t,A=[],w,o,p=[],C=new THREE.Vector4,H=new THREE.Vector4,y=new THREE.Matrix4,
  108. I=new THREE.Matrix4,v=[],L=new THREE.Vector4,k=new THREE.Vector4,B;this.projectObjects=function(n,m,z){var q=[],D,x;e=0;y.multiply(m.projectionMatrix,m.matrix);v[0]=new THREE.Vector4(y.n41-y.n11,y.n42-y.n12,y.n43-y.n13,y.n44-y.n14);v[1]=new THREE.Vector4(y.n41+y.n11,y.n42+y.n12,y.n43+y.n13,y.n44+y.n14);v[2]=new THREE.Vector4(y.n41+y.n21,y.n42+y.n22,y.n43+y.n23,y.n44+y.n24);v[3]=new THREE.Vector4(y.n41-y.n21,y.n42-y.n22,y.n43-y.n23,y.n44-y.n24);v[4]=new THREE.Vector4(y.n41-y.n31,y.n42-y.n32,y.n43-
  109. y.n33,y.n44-y.n34);v[5]=new THREE.Vector4(y.n41+y.n31,y.n42+y.n32,y.n43+y.n33,y.n44+y.n34);m=0;for(D=v.length;m<D;m++){x=v[m];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}D=n.objects;n=0;for(m=D.length;n<m;n++){x=D[n];var u;if(!(u=!x.visible)){if(u=x instanceof THREE.Mesh){a:{u=void 0;for(var F=x.position,J=-x.geometry.boundingSphere.radius*Math.max(x.scale.x,Math.max(x.scale.y,x.scale.z)),G=0;G<6;G++){u=v[G].x*F.x+v[G].y*F.y+v[G].z*F.z+v[G].w;if(u<=J){u=false;break a}}u=true}u=!u}u=u}if(!u){d=
  110. g[e]=g[e]||new THREE.RenderableObject;C.copy(x.position);y.multiplyVector3(C);d.object=x;d.z=C.z;q.push(d);e++}}z&&q.sort(a);return q};this.projectScene=function(n,m,z){var q=[],D=m.near,x=m.far,u,F,J,G,T,U,O,ba,ca,W,R,X,Y,M,S,aa;b=t=o=0;m.autoUpdateMatrix&&m.updateMatrix();y.multiply(m.projectionMatrix,m.matrix);U=this.projectObjects(n,m,true);n=0;for(u=U.length;n<u;n++){O=U[n].object;if(O.visible){O.autoUpdateMatrix&&O.updateMatrix();ba=O.matrix;ca=O.rotationMatrix;W=O.materials;R=O.overdraw;if(O instanceof
  111. THREE.Mesh){X=O.geometry;Y=X.vertices;F=0;for(J=Y.length;F<J;F++){M=Y[F];M.positionWorld.copy(M.position);ba.multiplyVector3(M.positionWorld);G=M.positionScreen;G.copy(M.positionWorld);y.multiplyVector4(G);G.x/=G.w;G.y/=G.w;M.__visible=G.z>D&&G.z<x}X=X.faces;F=0;for(J=X.length;F<J;F++){M=X[F];if(M instanceof THREE.Face3){G=Y[M.a];T=Y[M.b];S=Y[M.c];if(G.__visible&&T.__visible&&S.__visible)if(O.doubleSided||O.flipSided!=(S.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-
  112. (S.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0){f=j[b]=j[b]||new THREE.RenderableFace3;f.v1.positionWorld.copy(G.positionWorld);f.v2.positionWorld.copy(T.positionWorld);f.v3.positionWorld.copy(S.positionWorld);f.v1.positionScreen.copy(G.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(S.positionScreen);f.normalWorld.copy(M.normal);ca.multiplyVector3(f.normalWorld);f.centroidWorld.copy(M.centroid);ba.multiplyVector3(f.centroidWorld);
  113. f.centroidScreen.copy(f.centroidWorld);y.multiplyVector3(f.centroidScreen);S=M.vertexNormals;B=f.vertexNormalsWorld;G=0;for(T=S.length;G<T;G++){aa=B[G]=B[G]||new THREE.Vector3;aa.copy(S[G]);ca.multiplyVector3(aa)}f.z=f.centroidScreen.z;f.meshMaterials=W;f.faceMaterials=M.materials;f.overdraw=R;if(O.geometry.uvs[F]){f.uvs[0]=O.geometry.uvs[F][0];f.uvs[1]=O.geometry.uvs[F][1];f.uvs[2]=O.geometry.uvs[F][2]}q.push(f);b++}}else if(M instanceof THREE.Face4){G=Y[M.a];T=Y[M.b];S=Y[M.c];aa=Y[M.d];if(G.__visible&&
  114. T.__visible&&S.__visible&&aa.__visible)if(O.doubleSided||O.flipSided!=((aa.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-(aa.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0||(T.positionScreen.x-S.positionScreen.x)*(aa.positionScreen.y-S.positionScreen.y)-(T.positionScreen.y-S.positionScreen.y)*(aa.positionScreen.x-S.positionScreen.x)<0)){f=j[b]=j[b]||new THREE.RenderableFace3;f.v1.positionWorld.copy(G.positionWorld);f.v2.positionWorld.copy(T.positionWorld);
  115. f.v3.positionWorld.copy(aa.positionWorld);f.v1.positionScreen.copy(G.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(aa.positionScreen);f.normalWorld.copy(M.normal);ca.multiplyVector3(f.normalWorld);f.centroidWorld.copy(M.centroid);ba.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);y.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=W;f.faceMaterials=M.materials;f.overdraw=R;if(O.geometry.uvs[F]){f.uvs[0]=O.geometry.uvs[F][0];
  116. f.uvs[1]=O.geometry.uvs[F][1];f.uvs[2]=O.geometry.uvs[F][3]}q.push(f);b++;h=j[b]=j[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(T.positionWorld);h.v2.positionWorld.copy(S.positionWorld);h.v3.positionWorld.copy(aa.positionWorld);h.v1.positionScreen.copy(T.positionScreen);h.v2.positionScreen.copy(S.positionScreen);h.v3.positionScreen.copy(aa.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
  117. h.meshMaterials=W;h.faceMaterials=M.materials;h.overdraw=R;if(O.geometry.uvs[F]){h.uvs[0]=O.geometry.uvs[F][1];h.uvs[1]=O.geometry.uvs[F][2];h.uvs[2]=O.geometry.uvs[F][3]}q.push(h);b++}}}}else if(O instanceof THREE.Line){I.multiply(y,ba);Y=O.geometry.vertices;M=Y[0];M.positionScreen.copy(M.position);I.multiplyVector4(M.positionScreen);F=1;for(J=Y.length;F<J;F++){G=Y[F];G.positionScreen.copy(G.position);I.multiplyVector4(G.positionScreen);T=Y[F-1];L.copy(G.positionScreen);k.copy(T.positionScreen);
  118. if(c(L,k)){L.multiplyScalar(1/L.w);k.multiplyScalar(1/k.w);l=A[t]=A[t]||new THREE.RenderableLine;l.v1.positionScreen.copy(L);l.v2.positionScreen.copy(k);l.z=Math.max(L.z,k.z);l.materials=O.materials;q.push(l);t++}}}else if(O instanceof THREE.Particle){H.set(O.position.x,O.position.y,O.position.z,1);y.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){w=p[o]=p[o]||new THREE.RenderableParticle;w.x=H.x/H.w;w.y=H.y/H.w;w.z=H.z;w.rotation=O.rotation.z;w.scale.x=O.scale.x*Math.abs(w.x-(H.x+m.projectionMatrix.n11)/
  119. (H.w+m.projectionMatrix.n14));w.scale.y=O.scale.y*Math.abs(w.y-(H.y+m.projectionMatrix.n22)/(H.w+m.projectionMatrix.n24));w.materials=O.materials;q.push(w);o++}}}}z&&q.sort(a);return q};this.unprojectVector=function(n,m){var z=THREE.Matrix4.makeInvert(m.matrix);z.multiplySelf(THREE.Matrix4.makeInvert(m.projectionMatrix));z.multiplyVector3(n);return n}};
  120. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,b){d=h;e=b;g=d/2;f=e/2};this.render=function(h,b){var j,l,t,A,w,o,p,C;a=c.projectScene(h,b);j=0;for(l=a.length;j<l;j++){w=a[j];if(w instanceof THREE.RenderableParticle){p=w.x*g+g;C=w.y*f+f;t=0;for(A=w.material.length;t<A;t++){o=w.material[t];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=p+"px";o.style.top=C+"px"}}}}}};
  121. THREE.CanvasRenderer=function(){function a(ka){if(w!=ka)l.globalAlpha=w=ka}function c(ka){if(o!=ka){switch(ka){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}o=ka}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,b,j,l=g.getContext("2d"),t=new THREE.Color(0),A=0,w=1,o=0,p=null,C=null,H=1,y,I,v,L,k,B,n,m,z,q=new THREE.Color,
  122. D=new THREE.Color,x=new THREE.Color,u=new THREE.Color,F=new THREE.Color,J,G,T,U,O,ba,ca,W,R,X=new THREE.Rectangle,Y=new THREE.Rectangle,M=new THREE.Rectangle,S=false,aa=new THREE.Color,ja=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,K=Math.PI*2,N=new THREE.Vector3,V,da,ga,ia,ta,ra,va=16;V=document.createElement("canvas");V.width=V.height=2;da=V.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);ga=da.getImageData(0,0,2,2);ia=ga.data;ta=document.createElement("canvas");ta.width=
  123. ta.height=va;ra=ta.getContext("2d");ra.translate(-va/2,-va/2);ra.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,sa){f=ka;h=sa;b=f/2;j=h/2;g.width=f;g.height=h;X.set(-b,-j,b,j);w=1;o=0;C=p=null;H=1};this.setClearColor=function(ka,sa){t=ka;A=sa;Y.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.setClearColorHex=function(ka,sa){t.setHex(ka);A=sa;Y.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.clear=function(){l.setTransform(1,
  124. 0,0,-1,b,j);if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(X);if(t.hex==0&&A==0)l.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());else{c(THREE.NormalBlending);a(1);l.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+A+")";l.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}Y.empty()}};this.render=function(ka,sa){function oa(P){var ea,$,Q,Z=P.lights;ja.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);P=0;for(ea=Z.length;P<ea;P++){$=Z[P];Q=$.color;if($ instanceof
  125. THREE.AmbientLight){ja.r+=Q.r;ja.g+=Q.g;ja.b+=Q.b}else if($ instanceof THREE.DirectionalLight){ha.r+=Q.r;ha.g+=Q.g;ha.b+=Q.b}else if($ instanceof THREE.PointLight){E.r+=Q.r;E.g+=Q.g;E.b+=Q.b}}}function Ba(P,ea,$,Q){var Z,fa,ma,na,pa=P.lights;P=0;for(Z=pa.length;P<Z;P++){fa=pa[P];ma=fa.color;na=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=$.dot(fa.position)*na;if(fa>0){Q.r+=ma.r*fa;Q.g+=ma.g*fa;Q.b+=ma.b*fa}}else if(fa instanceof THREE.PointLight){N.sub(fa.position,ea);N.normalize();fa=
  126. $.dot(N)*na;if(fa>0){Q.r+=ma.r*fa;Q.g+=ma.g*fa;Q.b+=ma.b*fa}}}}function Ja(P,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var Q,Z,fa,ma,na,pa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){ma=$.map.image;na=ma.width>>1;pa=ma.height>>1;Z=ea.scale.x*b;fa=ea.scale.y*j;$=Z*na;Q=fa*pa;M.set(P.x-$,P.y-Q,P.x+$,P.y+Q);if(X.instersects(M)){l.save();l.translate(P.x,P.y);l.rotate(-ea.rotation);l.scale(Z,-fa);l.translate(-na,-pa);l.drawImage(ma,0,0);l.restore()}}}else if($ instanceof
  127. THREE.ParticleCircleMaterial){if(S){aa.r=ja.r+ha.r+E.r;aa.g=ja.g+ha.g+E.g;aa.b=ja.b+ha.b+E.b;q.r=$.color.r*aa.r;q.g=$.color.g*aa.g;q.b=$.color.b*aa.b;q.updateStyleString()}else q.__styleString=$.color.__styleString;$=ea.scale.x*b;Q=ea.scale.y*j;M.set(P.x-$,P.y-Q,P.x+$,P.y+Q);if(X.instersects(M)){Z=q.__styleString;if(C!=Z)l.fillStyle=C=Z;l.save();l.translate(P.x,P.y);l.rotate(-ea.rotation);l.scale($,Q);l.beginPath();l.arc(0,0,1,0,K,true);l.closePath();l.fill();l.restore()}}}}function Ka(P,ea,$,Q){if(Q.opacity!=
  128. 0){a(Q.opacity);c(Q.blending);l.beginPath();l.moveTo(P.positionScreen.x,P.positionScreen.y);l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){q.__styleString=Q.color.__styleString;P=Q.linewidth;if(H!=P)l.lineWidth=H=P;P=q.__styleString;if(p!=P)l.strokeStyle=p=P;l.stroke();M.inflate(Q.linewidth*2)}}}function Ga(P,ea,$,Q,Z,fa){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);L=P.positionScreen.x;k=P.positionScreen.y;B=ea.positionScreen.x;n=ea.positionScreen.y;
  129. m=$.positionScreen.x;z=$.positionScreen.y;l.beginPath();l.moveTo(L,k);l.lineTo(B,n);l.lineTo(m,z);l.lineTo(L,k);l.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Da(L,k,B,n,m,z,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=sa.matrix;N.copy(Q.vertexNormalsWorld[0]);U=(N.x*P.n11+N.y*
  130. P.n12+N.z*P.n13)*0.5+0.5;O=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;N.copy(Q.vertexNormalsWorld[1]);ba=(N.x*P.n11+N.y*P.n12+N.z*P.n13)*0.5+0.5;ca=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;N.copy(Q.vertexNormalsWorld[2]);W=(N.x*P.n11+N.y*P.n12+N.z*P.n13)*0.5+0.5;R=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;Da(L,k,B,n,m,z,Z.env_map.image,U,O,ba,ca,W,R)}}else Z.wireframe?qa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof
  131. THREE.UVMapping&&Da(L,k,B,n,m,z,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);c(THREE.SubtractiveBlending)}if(S)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=x.r=u.r=ja.r;D.g=x.g=u.g=ja.g;D.b=x.b=u.b=ja.b;Ba(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Ba(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],x);Ba(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],u);F.r=(x.r+u.r)*0.5;F.g=(x.g+u.g)*0.5;F.b=(x.b+u.b)*0.5;T=Pa(D,x,u,F);
  132. Da(L,k,B,n,m,z,T,0,0,1,0,0,1)}else{aa.r=ja.r;aa.g=ja.g;aa.b=ja.b;Ba(fa,Q.centroidWorld,Q.normalWorld,aa);q.r=Z.color.r*aa.r;q.g=Z.color.g*aa.g;q.b=Z.color.b*aa.b;q.updateStyleString();Z.wireframe?qa(q.__styleString,Z.wireframe_linewidth):Ha(q.__styleString)}else Z.wireframe?qa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){J=sa.near;G=sa.far;D.r=D.g=D.b=1-La(P.positionScreen.z,J,G);x.r=x.g=x.b=1-La(ea.positionScreen.z,J,G);u.r=
  133. u.g=u.b=1-La($.positionScreen.z,J,G);F.r=(x.r+u.r)*0.5;F.g=(x.g+u.g)*0.5;F.b=(x.b+u.b)*0.5;T=Pa(D,x,u,F);Da(L,k,B,n,m,z,T,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){q.r=Ma(Q.normalWorld.x);q.g=Ma(Q.normalWorld.y);q.b=Ma(Q.normalWorld.z);q.updateStyleString();Z.wireframe?qa(q.__styleString,Z.wireframe_linewidth):Ha(q.__styleString)}}}function qa(P,ea){if(p!=P)l.strokeStyle=p=P;if(H!=ea)l.lineWidth=H=ea;l.stroke();M.inflate(ea*2)}function Ha(P){if(C!=P)l.fillStyle=C=P;l.fill()}function Da(P,
  134. ea,$,Q,Z,fa,ma,na,pa,ya,ua,za,Ea){var wa,Aa;wa=ma.width-1;Aa=ma.height-1;na*=wa;pa*=Aa;ya*=wa;ua*=Aa;za*=wa;Ea*=Aa;$-=P;Q-=ea;Z-=P;fa-=ea;ya-=na;ua-=pa;za-=na;Ea-=pa;wa=ya*Ea-za*ua;if(wa!=0){Aa=1/wa;wa=(Ea*$-ua*Z)*Aa;ua=(Ea*Q-ua*fa)*Aa;$=(ya*Z-za*$)*Aa;Q=(ya*fa-za*Q)*Aa;P=P-wa*na-$*pa;ea=ea-ua*na-Q*pa;l.save();l.transform(wa,ua,$,Q,P,ea);l.clip();l.drawImage(ma,0,0);l.restore()}}function Pa(P,ea,$,Q){var Z=~~(P.r*255),fa=~~(P.g*255);P=~~(P.b*255);var ma=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);
  135. var pa=~~($.r*255),ya=~~($.g*255);$=~~($.b*255);var ua=~~(Q.r*255),za=~~(Q.g*255);Q=~~(Q.b*255);ia[0]=Z<0?0:Z>255?255:Z;ia[1]=fa<0?0:fa>255?255:fa;ia[2]=P<0?0:P>255?255:P;ia[4]=ma<0?0:ma>255?255:ma;ia[5]=na<0?0:na>255?255:na;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=ya<0?0:ya>255?255:ya;ia[10]=$<0?0:$>255?255:$;ia[12]=ua<0?0:ua>255?255:ua;ia[13]=za<0?0:za>255?255:za;ia[14]=Q<0?0:Q>255?255:Q;da.putImageData(ga,0,0);ra.drawImage(V,0,0);return ta}function La(P,ea,$){P=(P-ea)/($-ea);
  136. return P*P*(3-2*P)}function Ma(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function Na(P,ea){var $=ea.x-P.x,Q=ea.y-P.y,Z=1/Math.sqrt($*$+Q*Q);$*=Z;Q*=Z;ea.x+=$;ea.y+=Q;P.x-=$;P.y-=Q}var Ia,Qa,la,xa,Ca,Oa,Ra,Fa;this.autoClear?this.clear():l.setTransform(1,0,0,-1,b,j);d=e.projectScene(ka,sa,this.sortElements);(S=ka.lights.length>0)&&oa(ka);Ia=0;for(Qa=d.length;Ia<Qa;Ia++){la=d[Ia];M.empty();if(la instanceof THREE.RenderableParticle){y=la;y.x*=b;y.y*=j;xa=0;for(Ca=la.materials.length;xa<Ca;xa++)Ja(y,la,la.materials[xa],
  137. ka)}else if(la instanceof THREE.RenderableLine){y=la.v1;I=la.v2;y.positionScreen.x*=b;y.positionScreen.y*=j;I.positionScreen.x*=b;I.positionScreen.y*=j;M.addPoint(y.positionScreen.x,y.positionScreen.y);M.addPoint(I.positionScreen.x,I.positionScreen.y);if(X.instersects(M)){xa=0;for(Ca=la.materials.length;xa<Ca;)Ka(y,I,la,la.materials[xa++],ka)}}else if(la instanceof THREE.RenderableFace3){y=la.v1;I=la.v2;v=la.v3;y.positionScreen.x*=b;y.positionScreen.y*=j;I.positionScreen.x*=b;I.positionScreen.y*=
  138. j;v.positionScreen.x*=b;v.positionScreen.y*=j;if(la.overdraw){Na(y.positionScreen,I.positionScreen);Na(I.positionScreen,v.positionScreen);Na(v.positionScreen,y.positionScreen)}M.add3Points(y.positionScreen.x,y.positionScreen.y,I.positionScreen.x,I.positionScreen.y,v.positionScreen.x,v.positionScreen.y);if(X.instersects(M)){xa=0;for(Ca=la.meshMaterials.length;xa<Ca;){Fa=la.meshMaterials[xa++];if(Fa instanceof THREE.MeshFaceMaterial){Oa=0;for(Ra=la.faceMaterials.length;Oa<Ra;)(Fa=la.faceMaterials[Oa++])&&
  139. Ga(y,I,v,la,Fa,ka)}else Ga(y,I,v,la,Fa,ka)}}}Y.addRectangle(M)}l.setTransform(1,0,0,1,0,0)}};
  140. THREE.SVGRenderer=function(){function a(U,O,ba){var ca,W,R,X;ca=0;for(W=U.lights.length;ca<W;ca++){R=U.lights[ca];if(R instanceof THREE.DirectionalLight){X=O.normalWorld.dot(R.position)*R.intensity;if(X>0){ba.r+=R.color.r*X;ba.g+=R.color.g*X;ba.b+=R.color.b*X}}else if(R instanceof THREE.PointLight){z.sub(R.position,O.centroidWorld);z.normalize();X=O.normalWorld.dot(z)*R.intensity;if(X>0){ba.r+=R.color.r*X;ba.g+=R.color.g*X;ba.b+=R.color.b*X}}}}function c(U,O,ba,ca,W,R){u=e(F++);u.setAttribute("d",
  141. "M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(W instanceof THREE.MeshBasicMaterial)v.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshLambertMaterial)if(I){L.r=k.r;L.g=k.g;L.b=k.b;a(R,ca,L);v.r=W.color.r*L.r;v.g=W.color.g*L.g;v.b=W.color.b*L.b;v.updateStyleString()}else v.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshDepthMaterial){m=1-W.__2near/(W.__farPlusNear-
  142. ca.z*W.__farMinusNear);v.setRGB(m,m,m)}else W instanceof THREE.MeshNormalMaterial&&v.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));W.wireframe?u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+W.wireframe_linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.wireframe_linecap+"; stroke-linejoin: "+W.wireframe_linejoin):u.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+W.opacity);b.appendChild(u)}function d(U,O,ba,ca,W,
  143. R,X){u=e(F++);u.setAttribute("d","M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)v.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(I){L.r=k.r;L.g=k.g;L.b=k.b;a(X,W,L);v.r=R.color.r*L.r;v.g=R.color.g*L.g;v.b=R.color.b*L.b;v.updateStyleString()}else v.__styleString=R.color.__styleString;
  144. else if(R instanceof THREE.MeshDepthMaterial){m=1-R.__2near/(R.__farPlusNear-W.z*R.__farMinusNear);v.setRGB(m,m,m)}else R instanceof THREE.MeshNormalMaterial&&v.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));R.wireframe?u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):u.setAttribute("style","fill: "+v.__styleString+
  145. "; fill-opacity: "+R.opacity);b.appendChild(u)}function e(U){if(q[U]==null){q[U]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&q[U].setAttribute("shape-rendering","crispEdges");return q[U]}return q[U]}function g(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var f=null,h=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,t,A,w,o,p,C,H=new THREE.Rectangle,y=new THREE.Rectangle,I=false,v=new THREE.Color(16777215),L=new THREE.Color(16777215),
  146. k=new THREE.Color(0),B=new THREE.Color(0),n=new THREE.Color(0),m,z=new THREE.Vector3,q=[],D=[],x=[],u,F,J,G,T=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":T=1;break;case "low":T=0}};this.setSize=function(U,O){j=U;l=O;t=j/2;A=l/2;b.setAttribute("viewBox",-t+" "+-A+" "+j+" "+l);b.setAttribute("width",j);b.setAttribute("height",l);H.set(-t,-A,t,A)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};
  147. this.render=function(U,O){var ba,ca,W,R,X,Y,M,S;this.autoClear&&this.clear();f=h.projectScene(U,O,this.sortElements);G=J=F=0;if(I=U.lights.length>0){M=U.lights;k.setRGB(0,0,0);B.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(ca=M.length;ba<ca;ba++){W=M[ba];R=W.color;if(W instanceof THREE.AmbientLight){k.r+=R.r;k.g+=R.g;k.b+=R.b}else if(W instanceof THREE.DirectionalLight){B.r+=R.r;B.g+=R.g;B.b+=R.b}else if(W instanceof THREE.PointLight){n.r+=R.r;n.g+=R.g;n.b+=R.b}}}ba=0;for(ca=f.length;ba<ca;ba++){M=f[ba];
  148. y.empty();if(M instanceof THREE.RenderableParticle){w=M;w.x*=t;w.y*=-A;W=0;for(R=M.materials.length;W<R;W++)if(S=M.materials[W]){X=w;Y=M;S=S;var aa=J++;if(D[aa]==null){D[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&D[aa].setAttribute("shape-rendering","crispEdges")}u=D[aa];u.setAttribute("cx",X.x);u.setAttribute("cy",X.y);u.setAttribute("r",Y.scale.x*t);if(S instanceof THREE.ParticleCircleMaterial){if(I){L.r=k.r+B.r+n.r;L.g=k.g+B.g+n.g;L.b=k.b+B.b+n.b;v.r=S.color.r*L.r;
  149. v.g=S.color.g*L.g;v.b=S.color.b*L.b;v.updateStyleString()}else v=S.color;u.setAttribute("style","fill: "+v.__styleString)}b.appendChild(u)}}else if(M instanceof THREE.RenderableLine){w=M.v1;o=M.v2;w.positionScreen.x*=t;w.positionScreen.y*=-A;o.positionScreen.x*=t;o.positionScreen.y*=-A;y.addPoint(w.positionScreen.x,w.positionScreen.y);y.addPoint(o.positionScreen.x,o.positionScreen.y);if(H.instersects(y)){W=0;for(R=M.materials.length;W<R;)if(S=M.materials[W++]){X=w;Y=o;S=S;aa=G++;if(x[aa]==null){x[aa]=
  150. document.createElementNS("http://www.w3.org/2000/svg","line");T==0&&x[aa].setAttribute("shape-rendering","crispEdges")}u=x[aa];u.setAttribute("x1",X.positionScreen.x);u.setAttribute("y1",X.positionScreen.y);u.setAttribute("x2",Y.positionScreen.x);u.setAttribute("y2",Y.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){v.__styleString=S.color.__styleString;u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+
  151. S.linecap+"; stroke-linejoin: "+S.linejoin);b.appendChild(u)}}}}else if(M instanceof THREE.RenderableFace3){w=M.v1;o=M.v2;p=M.v3;w.positionScreen.x*=t;w.positionScreen.y*=-A;o.positionScreen.x*=t;o.positionScreen.y*=-A;p.positionScreen.x*=t;p.positionScreen.y*=-A;y.addPoint(w.positionScreen.x,w.positionScreen.y);y.addPoint(o.positionScreen.x,o.positionScreen.y);y.addPoint(p.positionScreen.x,p.positionScreen.y);if(H.instersects(y)){W=0;for(R=M.meshMaterials.length;W<R;){S=M.meshMaterials[W++];if(S instanceof
  152. THREE.MeshFaceMaterial){X=0;for(Y=M.faceMaterials.length;X<Y;)(S=M.faceMaterials[X++])&&c(w,o,p,M,S,U)}else S&&c(w,o,p,M,S,U)}}}else if(M instanceof THREE.RenderableFace4){w=M.v1;o=M.v2;p=M.v3;C=M.v4;w.positionScreen.x*=t;w.positionScreen.y*=-A;o.positionScreen.x*=t;o.positionScreen.y*=-A;p.positionScreen.x*=t;p.positionScreen.y*=-A;C.positionScreen.x*=t;C.positionScreen.y*=-A;y.addPoint(w.positionScreen.x,w.positionScreen.y);y.addPoint(o.positionScreen.x,o.positionScreen.y);y.addPoint(p.positionScreen.x,
  153. p.positionScreen.y);y.addPoint(C.positionScreen.x,C.positionScreen.y);if(H.instersects(y)){W=0;for(R=M.meshMaterials.length;W<R;){S=M.meshMaterials[W++];if(S instanceof THREE.MeshFaceMaterial){X=0;for(Y=M.faceMaterials.length;X<Y;)(S=M.faceMaterials[X++])&&d(w,o,p,C,M,S,U)}else S&&d(w,o,p,C,M,S,U)}}}}}};
  154. THREE.WebGLRenderer=function(a){function c(k,B){k.fragment_shader=B.fragment_shader;k.vertex_shader=B.vertex_shader;k.uniforms=Uniforms.clone(B.uniforms)}function d(k){if(t!=k.doubleSided){k.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);t=k.doubleSided}if(A!=k.flipSided){k.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);A=k.flipSided}}function e(k){if(k!=w){switch(k){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,
  155. b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}w=k}}function g(k,B){var n;if(k=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(k=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,B);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function f(k){switch(k){case THREE.RepeatWrapping:return b.REPEAT;
  156. case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;
  157. case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),
  158. b,j=null,l=null,t=null,A=null,w=null,o=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],p=new THREE.Matrix4,C=new Float32Array(16),H=new Float32Array(16),y=new THREE.Vector4,I=true,v=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)I=a.antialias;a.clearColor!==undefined&&v.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(k,B,n){try{b=h.getContext("experimental-webgl",
  159. {antialias:k})}catch(m){console.log(m)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(B.r,B.g,B.b,n);_cullEnabled=true})(I,v,L);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=
  160. function(k,B){h.width=k;h.height=B;b.viewport(0,0,h.width,h.height)};this.setClearColorHex=function(k,B){var n=new THREE.Color(k);b.clearColor(n.r,n.g,n.b,B)};this.setClearColor=function(k,B){b.clearColor(k.r,k.g,k.b,B)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,B){var n,m,z,q=0,D=0,x=0,u,F,J,G=this.lights,T=G.directional.colors,U=G.directional.positions,O=G.point.colors,ba=G.point.positions,ca=0,W=0;n=z=z=0;for(m=B.length;n<m;n++){z=B[n];u=
  161. z.color;F=z.position;J=z.intensity;if(z instanceof THREE.AmbientLight){q+=u.r;D+=u.g;x+=u.b}else if(z instanceof THREE.DirectionalLight){z=ca*3;T[z]=u.r*J;T[z+1]=u.g*J;T[z+2]=u.b*J;U[z]=F.x;U[z+1]=F.y;U[z+2]=F.z;ca+=1}else if(z instanceof THREE.PointLight){z=W*3;O[z]=u.r*J;O[z+1]=u.g*J;O[z+2]=u.b*J;ba[z]=F.x;ba[z+1]=F.y;ba[z+2]=F.z;W+=1}}for(n=ca*3;n<T.length;n++)T[n]=0;for(n=W*3;n<O.length;n++)O[n]=0;G.point.length=W;G.directional.length=ca;G.ambient[0]=q;G.ambient[1]=D;G.ambient[2]=x};this.createParticleBuffers=
  162. function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLNormalBuffer=b.createBuffer();k.__webGLTangentBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer();k.__webGLUVBuffer=b.createBuffer();k.__webGLUV2Buffer=b.createBuffer();k.__webGLFaceBuffer=b.createBuffer();
  163. k.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(k){var B=k.vertices.length;k.__vertexArray=new Float32Array(B*3);k.__colorArray=new Float32Array(B*3);k.__webGLLineCount=B};this.initParticleBuffers=function(k){var B=k.vertices.length;k.__vertexArray=new Float32Array(B*3);k.__colorArray=new Float32Array(B*3);k.__sortArray=[];k.__webGLParticleCount=B};this.initMeshBuffers=function(k,B){var n,m,z=0,q=0,D=0,x=B.geometry.faces,u=k.faces;n=0;for(m=u.length;n<m;n++){fi=u[n];face=x[fi];
  164. if(face instanceof THREE.Face3){z+=3;q+=1;D+=3}else if(face instanceof THREE.Face4){z+=4;q+=2;D+=4}}k.__vertexArray=new Float32Array(z*3);k.__normalArray=new Float32Array(z*3);k.__tangentArray=new Float32Array(z*4);k.__colorArray=new Float32Array(z*3);k.__uvArray=new Float32Array(z*2);k.__uv2Array=new Float32Array(z*2);k.__faceArray=new Uint16Array(q*3);k.__lineArray=new Uint16Array(D*2);z=false;n=0;for(m=B.materials.length;n<m;n++){x=B.materials[n];if(x instanceof THREE.MeshFaceMaterial){x=0;for(u=
  165. k.materials.length;x<u;x++)if(k.materials[x]&&k.materials[x].shading!=undefined&&k.materials[x].shading==THREE.SmoothShading){z=true;break}}else if(x&&x.shading!=undefined&&x.shading==THREE.SmoothShading){z=true;break}if(z)break}k.__needsSmoothNormals=z;k.__webGLFaceCount=q*3;k.__webGLLineCount=D*2};this.setMeshBuffers=function(k,B,n){var m,z,q,D,x,u,F,J,G,T,U=0,O=0,ba=0,ca=0,W=0,R=0,X=0,Y=0,M=0,S=k.__vertexArray,aa=k.__uvArray,ja=k.__uv2Array,ha=k.__normalArray,E=k.__tangentArray,K=k.__colorArray,
  166. N=k.__faceArray,V=k.__lineArray,da=k.__needsSmoothNormals,ga=B.geometry,ia=ga.__dirtyVertices,ta=ga.__dirtyElements,ra=ga.__dirtyUvs,va=ga.__dirtyNormals,ka=ga.__dirtyTangents,sa=ga.__dirtyColors,oa=ga.vertices,Ba=k.faces,Ja=ga.faces,Ka=ga.uvs,Ga=ga.uvs2,qa=ga.colors;B=0;for(m=Ba.length;B<m;B++){z=Ba[B];q=Ja[z];u=Ka[z];z=Ga[z];D=q.vertexNormals;x=q.normal;if(q instanceof THREE.Face3){if(ia){F=oa[q.a].position;J=oa[q.b].position;G=oa[q.c].position;S[O]=F.x;S[O+1]=F.y;S[O+2]=F.z;S[O+3]=J.x;S[O+4]=J.y;
  167. S[O+5]=J.z;S[O+6]=G.x;S[O+7]=G.y;S[O+8]=G.z;O+=9}if(sa&&qa.length){F=qa[q.a];J=qa[q.b];G=qa[q.c];K[M]=F.r;K[M+1]=F.g;K[M+2]=F.b;K[M+3]=J.r;K[M+4]=J.g;K[M+5]=J.b;K[M+6]=G.r;K[M+7]=G.g;K[M+8]=G.b;M+=9}if(ka&&ga.hasTangents){F=oa[q.a].tangent;J=oa[q.b].tangent;G=oa[q.c].tangent;E[X]=F.x;E[X+1]=F.y;E[X+2]=F.z;E[X+3]=F.w;E[X+4]=J.x;E[X+5]=J.y;E[X+6]=J.z;E[X+7]=J.w;E[X+8]=G.x;E[X+9]=G.y;E[X+10]=G.z;E[X+11]=G.w;X+=12}if(va)if(D.length==3&&da)for(q=0;q<3;q++){x=D[q];ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}else for(q=
  168. 0;q<3;q++){ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}if(ra&&u)for(q=0;q<3;q++){D=u[q];aa[ba]=D.u;aa[ba+1]=D.v;ba+=2}if(ra&&z)for(q=0;q<3;q++){u=z[q];ja[ca]=u.u;ja[ca+1]=u.v;ca+=2}if(ta){N[W]=U;N[W+1]=U+1;N[W+2]=U+2;W+=3;V[Y]=U;V[Y+1]=U+1;V[Y+2]=U;V[Y+3]=U+2;V[Y+4]=U+1;V[Y+5]=U+2;Y+=6;U+=3}}else if(q instanceof THREE.Face4){if(ia){F=oa[q.a].position;J=oa[q.b].position;G=oa[q.c].position;T=oa[q.d].position;S[O]=F.x;S[O+1]=F.y;S[O+2]=F.z;S[O+3]=J.x;S[O+4]=J.y;S[O+5]=J.z;S[O+6]=G.x;S[O+7]=G.y;S[O+8]=G.z;
  169. S[O+9]=T.x;S[O+10]=T.y;S[O+11]=T.z;O+=12}if(sa&&qa.length){F=qa[q.a];J=qa[q.b];G=qa[q.c];T=qa[q.d];K[M]=F.r;K[M+1]=F.g;K[M+2]=F.b;K[M+3]=J.r;K[M+4]=J.g;K[M+5]=J.b;K[M+6]=G.r;K[M+7]=G.g;K[M+8]=G.b;K[M+9]=T.r;K[M+10]=T.g;K[M+11]=T.b;M+=12}if(ka&&ga.hasTangents){F=oa[q.a].tangent;J=oa[q.b].tangent;G=oa[q.c].tangent;q=oa[q.d].tangent;E[X]=F.x;E[X+1]=F.y;E[X+2]=F.z;E[X+3]=F.w;E[X+4]=J.x;E[X+5]=J.y;E[X+6]=J.z;E[X+7]=J.w;E[X+8]=G.x;E[X+9]=G.y;E[X+10]=G.z;E[X+11]=G.w;E[X+12]=q.x;E[X+13]=q.y;E[X+14]=q.z;E[X+
  170. 15]=q.w;X+=16}if(va)if(D.length==4&&da)for(q=0;q<4;q++){x=D[q];ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}else for(q=0;q<4;q++){ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}if(ra&&u)for(q=0;q<4;q++){D=u[q];aa[ba]=D.u;aa[ba+1]=D.v;ba+=2}if(ra&&z)for(q=0;q<4;q++){u=z[q];ja[ca]=u.u;ja[ca+1]=u.v;ca+=2}if(ta){N[W]=U;N[W+1]=U+1;N[W+2]=U+2;N[W+3]=U;N[W+4]=U+2;N[W+5]=U+3;W+=6;V[Y]=U;V[Y+1]=U+1;V[Y+2]=U;V[Y+3]=U+3;V[Y+4]=U+1;V[Y+5]=U+2;V[Y+6]=U+2;V[Y+7]=U+3;Y+=8;U+=4}}}if(ia){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);
  171. b.bufferData(b.ARRAY_BUFFER,S,n)}if(sa&&qa.length){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,K,n)}if(va){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,n)}if(ka&&ga.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,E,n)}if(ra&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,aa,n)}if(ra&&ca>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,
  172. ja,n)}if(ta){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,V,n)}};this.setLineBuffers=function(k,B){var n,m,z,q=k.vertices,D=k.colors,x=q.length,u=D.length,F=k.__vertexArray,J=k.__colorArray,G=k.__dirtyColors;if(k.__dirtyVertices){for(n=0;n<x;n++){m=q[n].position;z=n*3;F[z]=m.x;F[z+1]=m.y;F[z+2]=m.z}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
  173. F,B)}if(G){for(n=0;n<u;n++){color=D[n];z=n*3;J[z]=color.r;J[z+1]=color.g;J[z+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,J,B)}};this.setParticleBuffers=function(k,B,n){var m,z,q,D=k.vertices,x=D.length,u=k.colors,F=u.length,J=k.__vertexArray,G=k.__colorArray,T=k.__sortArray,U=k.__dirtyVertices,O=k.__dirtyColors;if(n.sortParticles){p.multiplySelf(n.matrix);for(m=0;m<x;m++){z=D[m].position;y.copy(z);p.multiplyVector3(y);T[m]=[y.z,m]}T.sort(function(ba,ca){return ca[0]-
  174. ba[0]});for(m=0;m<x;m++){z=D[T[m][1]].position;q=m*3;J[q]=z.x;J[q+1]=z.y;J[q+2]=z.z}for(m=0;m<F;m++){q=m*3;color=u[T[m][1]];G[q]=color.r;G[q+1]=color.g;G[q+2]=color.b}}else{if(U)for(m=0;m<x;m++){z=D[m].position;q=m*3;J[q]=z.x;J[q+1]=z.y;J[q+2]=z.z}if(O)for(m=0;m<F;m++){color=u[m];q=m*3;G[q]=color.r;G[q+1]=color.g;G[q+2]=color.b}}if(U||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,J,B)}if(O||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);
  175. b.bufferData(b.ARRAY_BUFFER,G,B)}};this.initMaterial=function(k,B,n){var m,z;if(k instanceof THREE.MeshDepthMaterial)c(k,THREE.ShaderLib.depth);else if(k instanceof THREE.MeshNormalMaterial)c(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)c(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)c(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)c(k,THREE.ShaderLib.phong);else if(k instanceof THREE.LineBasicMaterial)c(k,THREE.ShaderLib.basic);
  176. else k instanceof THREE.ParticleBasicMaterial&&c(k,THREE.ShaderLib.particle_basic);var q,D,x,u;z=x=u=0;for(q=B.length;z<q;z++){D=B[z];D instanceof THREE.DirectionalLight&&x++;D instanceof THREE.PointLight&&u++}if(u+x<=4){B=x;u=u}else{B=Math.ceil(4*x/(u+x));u=4-B}z={directional:B,point:u};u=k.fragment_shader;B=k.vertex_shader;q={fog:n,map:k.map,env_map:k.env_map,light_map:k.light_map,vertex_colors:k.vertex_colors,maxDirLights:z.directional,maxPointLights:z.point};n=b.createProgram();z=["#ifdef GL_ES\nprecision highp float;\n#endif",
  177. "#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+
  178. q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,g("fragment",z+u));b.attachShader(n,
  179. g("vertex",q+B));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};k.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(m in k.uniforms)n.push(m);m=k.program;u=0;for(B=n.length;u<B;u++){z=n[u];m.uniforms[z]=b.getUniformLocation(m,z)}k=k.program;m=["position","normal",
  180. "uv","uv2","tangent","color"];n=0;for(u=m.length;n<u;n++){B=m[n];k.attributes[B]=b.getAttribLocation(k,B)}};this.setProgram=function(k,B,n,m,z){m.program||this.initMaterial(m,B,n);var q=m.program,D=q.uniforms,x=m.uniforms;if(q!=j){b.useProgram(q);j=q;b.uniformMatrix4fv(D.projectionMatrix,false,C)}if(n&&(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial||m instanceof THREE.LineBasicMaterial||m instanceof THREE.ParticleBasicMaterial)){x.fogColor.value.setHex(n.color.hex);
  181. if(n instanceof THREE.Fog){x.fogNear.value=n.near;x.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)x.fogDensity.value=n.density}if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){this.setupLights(q,B);B=this.lights;x.enableLighting.value=B.directional.length+B.point.length;x.ambientLightColor.value=B.ambient;x.directionalLightColor.value=B.directional.colors;x.directionalLightDirection.value=B.directional.positions;x.pointLightColor.value=B.point.colors;x.pointLightPosition.value=
  182. B.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial){x.diffuse.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);x.opacity.value=m.opacity;x.map.texture=m.map;x.light_map.texture=m.light_map;x.env_map.texture=m.env_map;x.reflectivity.value=m.reflectivity;x.refraction_ratio.value=m.refraction_ratio;x.combine.value=m.combine;x.useRefract.value=m.env_map&&m.env_map.mapping instanceof THREE.CubeRefractionMapping}if(m instanceof
  183. THREE.LineBasicMaterial){x.diffuse.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);x.opacity.value=m.opacity}else if(m instanceof THREE.ParticleBasicMaterial){x.psColor.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);x.opacity.value=m.opacity;x.size.value=m.size;x.map.texture=m.map}else if(m instanceof THREE.MeshPhongMaterial){x.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);x.specular.value.setRGB(m.specular.r,m.specular.g,m.specular.b);
  184. x.shininess.value=m.shininess}else if(m instanceof THREE.MeshDepthMaterial){x.mNear.value=k.near;x.mFar.value=k.far;x.opacity.value=m.opacity}else if(m instanceof THREE.MeshNormalMaterial)x.opacity.value=m.opacity;var u,F,J;for(u in x)if(J=q.uniforms[u]){n=x[u];F=n.type;B=n.value;if(F=="i")b.uniform1i(J,B);else if(F=="f")b.uniform1f(J,B);else if(F=="fv1")b.uniform1fv(J,B);else if(F=="fv")b.uniform3fv(J,B);else if(F=="v2")b.uniform2f(J,B.x,B.y);else if(F=="v3")b.uniform3f(J,B.x,B.y,B.z);else if(F==
  185. "c")b.uniform3f(J,B.r,B.g,B.b);else if(F=="t"){b.uniform1i(J,B);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;B=B;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
  186. b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(F=0;F<6;++F)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image[F]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+B);b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;B=B;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=b.createTexture();
  187. b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(n.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+B);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture)}}}b.uniformMatrix4fv(D.modelViewMatrix,
  188. false,z._modelViewMatrixArray);b.uniformMatrix3fv(D.normalMatrix,false,z._normalMatrixArray);if(m instanceof THREE.MeshShaderMaterial||m instanceof THREE.MeshPhongMaterial||m.env_map)b.uniform3f(D.cameraPosition,k.position.x,k.position.y,k.position.z);if(m instanceof THREE.MeshShaderMaterial||m.env_map)b.uniformMatrix4fv(D.objectMatrix,false,z._objectMatrixArray);if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(D.viewMatrix,
  189. false,H);return q};this.renderBuffer=function(k,B,n,m,z,q){k=this.setProgram(k,B,n,m,q).attributes;b.bindBuffer(b.ARRAY_BUFFER,z.__webGLVertexBuffer);b.vertexAttribPointer(k.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.position);if(k.color>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLColorBuffer);b.vertexAttribPointer(k.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.color)}if(k.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT,
  190. false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(z.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLUVBuffer);b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(z.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2,
  191. 2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2);if(q instanceof THREE.Mesh)if(m.wireframe){b.lineWidth(m.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,z.__webGLLineBuffer);b.drawElements(b.LINES,z.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,z.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(m.linewidth);
  192. b.drawArrays(q,0,z.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,z.__webGLParticleCount)};this.renderPass=function(k,B,n,m,z,q,D){var x,u,F,J,G;F=0;for(J=m.materials.length;F<J;F++){x=m.materials[F];if(x instanceof THREE.MeshFaceMaterial){x=0;for(u=z.materials.length;x<u;x++)if((G=z.materials[x])&&G.blending==q&&G.opacity<1==D){e(G.blending);this.setDepthTest(G.depth_test);this.renderBuffer(k,B,n,G,z,m)}}else if((G=x)&&G.blending==q&&G.opacity<1==D){e(G.blending);
  193. this.setDepthTest(G.depth_test);this.renderBuffer(k,B,n,G,z,m)}}};this.renderPassImmediate=function(k,B,n,m,z,q){var D,x,u,F;D=0;for(x=m.materials.length;D<x;D++)if((u=m.materials[D])&&u.blending==z&&u.opacity<1==q){e(u.blending);this.setDepthTest(u.depth_test);F=this.setProgram(k,B,n,u,m);m.render(function(J){var G=F;if(!J.__webGLVertexBuffer)J.__webGLVertexBuffer=b.createBuffer();if(!J.__webGLNormalBuffer)J.__webGLNormalBuffer=b.createBuffer();if(J.hasPos){b.bindBuffer(b.ARRAY_BUFFER,J.__webGLVertexBuffer);
  194. b.bufferData(b.ARRAY_BUFFER,J.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(G.attributes.position);b.vertexAttribPointer(G.attributes.position,3,b.FLOAT,false,0,0)}if(J.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,J.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,J.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(G.attributes.normal);b.vertexAttribPointer(G.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,J.count);J.count=0})}};this.render=function(k,B,n,m){var z,q,D,x,
  195. u=k.lights,F=k.fog;B.autoUpdateMatrix&&B.updateMatrix();B.matrix.flattenToArray(H);B.projectionMatrix.flattenToArray(C);p.multiply(B.projectionMatrix,B.matrix);o[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);o[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);o[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);o[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);o[4].set(p.n41-p.n31,p.n42-p.n32,p.n43-p.n33,p.n44-p.n34);o[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+
  196. p.n34);for(z=0;z<5;z++){x=o[z];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}this.initWebGLObjects(k,B);m=m!==undefined?m:true;if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=b.createFramebuffer();n.__webGLRenderbuffer=b.createRenderbuffer();n.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,n.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,n.width,n.height);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,
  197. f(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(n.format),n.width,n.height,0,f(n.format),f(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,
  198. n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){z=n.__webGLFramebuffer;x=n.width;D=n.height}else{z=null;x=h.width;D=h.height}if(z!=l){b.bindFramebuffer(b.FRAMEBUFFER,z);b.viewport(0,0,x,D);m&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);l=z}this.autoClear&&this.clear();z=k.__webGLObjects.length;for(m=0;m<z;m++){D=k.__webGLObjects[m];x=D.object;if(q=x.visible){if(!(q=!(x instanceof THREE.Mesh)))a:{q=void 0;
  199. for(var J=x.matrix,G=-x.geometry.boundingSphere.radius*Math.max(x.scale.x,Math.max(x.scale.y,x.scale.z)),T=0;T<6;T++){q=o[T].x*J.n14+o[T].y*J.n24+o[T].z*J.n34+o[T].w;if(q<=G){q=false;break a}}q=true}q=q}if(q){if(x.autoUpdateMatrix){x.updateMatrix();x.matrix.flattenToArray(x._objectMatrixArray)}this.setupMatrices(x,B);D.render=true}else D.render=false}q=k.__webGLObjectsImmediate.length;for(m=0;m<q;m++){x=k.__webGLObjectsImmediate[m].object;if(x.visible){if(x.autoUpdateMatrix){x.updateMatrix();x.matrix.flattenToArray(x._objectMatrixArray)}this.setupMatrices(x,
  200. B)}}for(m=0;m<z;m++){D=k.__webGLObjects[m];if(D.render){x=D.object;D=D.buffer;d(x);this.renderPass(B,u,F,x,D,THREE.NormalBlending,false)}}for(m=0;m<q;m++){x=k.__webGLObjectsImmediate[m].object;if(x.visible){d(x);this.renderPassImmediate(B,u,F,x,THREE.NormalBlending,false)}}for(m=0;m<z;m++){D=k.__webGLObjects[m];if(D.render){x=D.object;D=D.buffer;d(x);this.renderPass(B,u,F,x,D,THREE.AdditiveBlending,false);this.renderPass(B,u,F,x,D,THREE.SubtractiveBlending,false);this.renderPass(B,u,F,x,D,THREE.AdditiveBlending,
  201. true);this.renderPass(B,u,F,x,D,THREE.SubtractiveBlending,true);this.renderPass(B,u,F,x,D,THREE.NormalBlending,true);this.renderPass(B,u,F,x,D,THREE.BillboardBlending,false)}}for(m=0;m<q;m++){x=k.__webGLObjectsImmediate[m].object;if(x.visible){d(x);this.renderPassImmediate(B,u,F,x,THREE.NormalBlending,true)}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
  202. function(k,B){function n(G,T,U,O){if(G[T]==undefined){k.__webGLObjects.push({buffer:U,object:O});G[T]=1}}function m(G,T,U){if(G[T]==undefined){k.__webGLObjectsImmediate.push({object:U});G[T]=1}}var z,q,D,x,u,F,J;if(!k.__webGLObjects){k.__webGLObjects=[];k.__webGLObjectsMap={};k.__webGLObjectsImmediate=[]}z=0;for(q=k.objects.length;z<q;z++){D=k.objects[z];u=D.geometry;if(k.__webGLObjectsMap[D.id]==undefined){k.__webGLObjectsMap[D.id]={};D._modelViewMatrix=new THREE.Matrix4;D._normalMatrixArray=new Float32Array(9);
  203. D._modelViewMatrixArray=new Float32Array(16);D._objectMatrixArray=new Float32Array(16);D.matrix.flattenToArray(D._objectMatrixArray)}J=k.__webGLObjectsMap[D.id];if(D instanceof THREE.Mesh){for(x in u.geometryChunks){F=u.geometryChunks[x];if(!F.__webGLVertexBuffer){this.createMeshBuffers(F);this.initMeshBuffers(F,D);u.__dirtyVertices=true;u.__dirtyElements=true;u.__dirtyUvs=true;u.__dirtyNormals=true;u.__dirtyTangents=true;u.__dirtyColors=true}if(u.__dirtyVertices||u.__dirtyElements||u.__dirtyUvs||
  204. u.__dirtyNormals||u.__dirtyColors||u.__dirtyTangents)this.setMeshBuffers(F,D,b.DYNAMIC_DRAW);n(J,x,F,D)}u.__dirtyVertices=false;u.__dirtyElements=false;u.__dirtyUvs=false;u.__dirtyNormals=false;u.__dirtyTangents=false;u.__dirtyColors=false}else if(D instanceof THREE.Line){if(!u.__webGLVertexBuffer){this.createLineBuffers(u);this.initLineBuffers(u);u.__dirtyVertices=true;u.__dirtyColors=true}if(u.__dirtyVertices||u.__dirtyColors)this.setLineBuffers(u,b.DYNAMIC_DRAW);n(J,0,u,D);u.__dirtyVertices=false;
  205. u.__dirtyColors=false}else if(D instanceof THREE.ParticleSystem){if(!u.__webGLVertexBuffer){this.createParticleBuffers(u);this.initParticleBuffers(u);u.__dirtyVertices=true;u.__dirtyColors=true}if(u.__dirtyVertices||u.__dirtyColors||D.sortParticles)this.setParticleBuffers(u,b.DYNAMIC_DRAW,D,B);n(J,0,u,D);u.__dirtyVertices=false;u.__dirtyColors=false}else D instanceof THREE.MarchingCubes&&m(J,0,D)}};this.removeObject=function(k,B){var n,m;for(n=k.__webGLObjects.length-1;n>=0;n--){m=k.__webGLObjects[n].object;
  206. B==m&&k.__webGLObjects.splice(n,1)}};this.setupMatrices=function(k,B){k._modelViewMatrix.multiplyToArray(B.matrix,k.matrix,k._modelViewMatrixArray);k._normalMatrix=THREE.Matrix4.makeInvert3x3(k._modelViewMatrix).transposeIntoArray(k._normalMatrixArray)};this.setDepthTest=function(k){k?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(k,B){if(k){!B||B=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
  207. b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  208. 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",
  209. 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",
  210. 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",
  211. 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",
  212. 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}",
  213. 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;",
  214. 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"};
  215. 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",
  216. 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)}}};
  217. 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",
  218. 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,
  219. 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,
  220. "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,
  221. 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,
  222. 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,
  223. 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,
  224. 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,
  225. 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,
  226. "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,
  227. "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};
  228. 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};
  229. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
  230. THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var c=document.body,d="oldie";if(a){if(a.parent!==undefined)c=a.parent;if(a.id!==undefined)d=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
  231. d;d=e.style;d.fontFamily="monospace";d.fontSize="13px";d.textAlign="center";d.background="#eee";d.color="#000";d.padding="1em";d.width="475px";d.margin="5em auto 0";a.appendChild(e);c.appendChild(a);return e}};
  232. var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,g=d?c.geometry:c,f=a.vertices,h=g.vertices,b=a.faces,j=g.faces,l=a.uvs;g=g.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var t=0,A=h.length;t<A;t++){var w=new THREE.Vertex(h[t].position.clone());d&&c.matrix.multiplyVector3(w.position);f.push(w)}t=0;for(A=j.length;t<A;t++){h=j[t];var o,p=h.vertexNormals;if(h instanceof THREE.Face3)o=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)o=new THREE.Face4(h.a+
  233. e,h.b+e,h.c+e,h.d+e);o.centroid.copy(h.centroid);o.normal.copy(h.normal);d=0;for(f=p.length;d<f;d++){w=p[d];o.vertexNormals.push(w.clone())}o.materials=h.materials.slice();b.push(o)}t=0;for(A=g.length;t<A;t++){e=g[t];b=[];d=0;for(f=e.length;d<f;d++)b.push(new THREE.UV(e[d].u,e[d].v));l.push(b)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,g=[];d=g.loadCount=0;for(e=
  234. a.length;d<e;++d){g[d]=new Image;g[d].loaded=0;g[d].onload=function(){g.loadCount+=1;this.loaded=true;c&&c(this)};g[d].src=a[d]}return g}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(t in n.objects)if(!u.objects[t]){C=n.objects[t];if(v=u.geometries[C.geometry]){B=[];for(i=0;i<C.materials.length;i++)B[i]=u.materials[C.materials[i]];H=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(v,B);object.position.set(H[0],H[1],H[2]);
  235. object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;u.scene.addObject(object);u.objects[t]=object}}}function h(F){return function(J){u.geometries[F]=J;f();z-=1;b()}}function b(){e({total_models:D,total_textures:x,loaded_models:D-z,loaded_textures:x-q},u);z==0&&q==0&&d(u)}var j,l,t,A,w,o,p,C,H,y,I,v,L,k,B,n,m,z,q,D,x,u;n=g.data;m=new THREE.Loader;q=z=0;u={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
  236. g=function(){q-=1;b()};for(w in n.cameras){y=n.cameras[w];if(y.type=="perspective")L=new THREE.Camera(y.fov,y.aspect,y.near,y.far);else if(y.type=="ortho"){L=new THREE.Camera;L.projectionMatrix=THREE.Matrix4.makeOrtho(y.left,y.right,y.top,y.bottom,y.near,y.far)}H=y.position;y=y.target;L.position.set(H[0],H[1],H[2]);L.target.position.set(y[0],y[1],y[2]);u.cameras[w]=L}for(A in n.lights){w=n.lights[A];if(w.type=="directional"){H=w.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
  237. H[2]);light.position.normalize()}else if(w.type=="point"){H=w.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}y=w.color;i=w.intensity||1;light.color.setRGB(y[0]*i,y[1]*i,y[2]*i);u.scene.addLight(light);u.lights[A]=light}for(o in n.fogs){A=n.fogs[o];if(A.type=="linear")k=new THREE.Fog(0,A.near,A.far);else if(A.type=="exp2")k=new THREE.FogExp2(0,A.density);y=A.color;k.color.setRGB(y[0],y[1],y[2]);u.fogs[o]=k}if(u.cameras&&n.defaults.camera)u.currentCamera=u.cameras[n.defaults.camera];
  238. if(u.fogs&&n.defaults.fog)u.scene.fog=u.fogs[n.defaults.fog];y=n.defaults.bgcolor;u.bgColor=new THREE.Color;u.bgColor.setRGB(y[0],y[1],y[2]);u.bgColorAlpha=n.defaults.bgalpha;for(j in n.geometries){o=n.geometries[j];if(o.type=="bin_mesh"||o.type=="ascii_mesh")z+=1}D=z;for(j in n.geometries){o=n.geometries[j];if(o.type=="cube"){v=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);u.geometries[j]=v}else if(o.type=="plane"){v=new Plane(o.width,o.height,o.segments_width,
  239. o.segments_height);u.geometries[j]=v}else if(o.type=="sphere"){v=new Sphere(o.radius,o.segments_width,o.segments_height);u.geometries[j]=v}else if(o.type=="cylinder"){v=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);u.geometries[j]=v}else if(o.type=="torus"){v=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);u.geometries[j]=v}else if(o.type=="icosahedron"){v=new Icosahedron(o.subdivisions);u.geometries[j]=v}else if(o.type=="bin_mesh")m.loadBinary({model:o.url,callback:h(j)});
  240. else o.type=="ascii_mesh"&&m.loadAscii({model:o.url,callback:h(j)})}for(p in n.textures){j=n.textures[p];q+=j.url instanceof Array?j.url.length:1}x=q;for(p in n.textures){j=n.textures[p];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){o=ImageUtils.loadArray(j.url,g);o=new THREE.Texture(o,j.mapping)}else{o=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)o.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
  241. undefined)o.mag_filter=THREE[j.mag_filter]}u.textures[p]=o}for(l in n.materials){p=n.materials[l];for(I in p.parameters)if(I=="env_map"||I=="map"||I=="light_map")p.parameters[I]=u.textures[p.parameters[I]];else if(I=="shading")p.parameters[I]=p.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")p.parameters[I]=THREE[p.parameters[I]]?THREE[p.parameters[I]]:THREE.NormalBlending;else if(I=="combine")p.parameters[I]=p.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
  242. p=new THREE[p.type](p.parameters);u.materials[l]=p}f();c(u)}},addMesh:function(a,c,d,e,g,f,h,b,j,l){c=new THREE.Mesh(c,l);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=g;c.position.z=f;c.rotation.x=h;c.rotation.y=b;c.rotation.z=j;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
  243. c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
  244. c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var g=Math.PI/2,f=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
  245. SceneUtils.addMesh(a,c,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
  246. vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
  247. normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
  248. uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + 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, 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}",
  249. 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}"},
  250. 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",
  251. 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; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
  252. film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
  253. screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
  254. fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;d=Array(f);for(c=e=0;c<f;++c){d[c]=Math.exp(-((c-g)*(c-g))/(2*a*a));e+=d[c]}for(c=0;c<f;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,g,f,h,b){function j(C,H,y,I,v,L,k,B){var n,m,z=e||1,q=g||1,D=z+1,x=q+1,u=v/2,F=L/2;v=v/z;var J=L/q,G=l.vertices.length;if(C=="x"&&H=="y"||C=="y"&&H=="x")n="z";else if(C=="x"&&H=="z"||C=="z"&&H=="x")n="y";else if(C==
  255. "z"&&H=="y"||C=="y"&&H=="z")n="x";for(m=0;m<x;m++)for(L=0;L<D;L++){var T=new THREE.Vector3;T[C]=(L*v-u)*y;T[H]=(m*J-F)*I;T[n]=k;l.vertices.push(new THREE.Vertex(T))}for(m=0;m<q;m++)for(L=0;L<z;L++){l.faces.push(new THREE.Face4(L+D*m+G,L+D*(m+1)+G,L+1+D*(m+1)+G,L+1+D*m+G,null,B));l.uvs.push([new THREE.UV(L/z,m/q),new THREE.UV(L/z,(m+1)/q),new THREE.UV((L+1)/z,(m+1)/q),new THREE.UV((L+1)/z,m/q)])}}THREE.Geometry.call(this);var l=this,t=a/2,A=c/2,w=d/2;h=h?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=
  256. f;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(b!=undefined)for(var p in b)if(this.sides[p]!=undefined)this.sides[p]=b[p];this.sides.px&&j("z","y",1*h,-1,d,c,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,d,c,t,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,d,A,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,d,-A,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,a,c,w,this.materials[4]);
  257. this.sides.nz&&j("x","y",-1*h,-1,a,c,-w,this.materials[5]);(function(){for(var C=[],H=[],y=0,I=l.vertices.length;y<I;y++){for(var v=l.vertices[y],L=false,k=0,B=C.length;k<B;k++){var n=C[k];if(v.position.x==n.position.x&&v.position.y==n.position.y&&v.position.z==n.position.z){H[y]=k;L=true;break}}if(!L){H[y]=C.length;C.push(new THREE.Vertex(v.position.clone()))}}y=0;for(I=l.faces.length;y<I;y++){v=l.faces[y];v.a=H[v.a];v.b=H[v.b];v.c=H[v.c];v.d=H[v.d]}l.vertices=C})();this.computeCentroids();this.computeFaceNormals();
  258. this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  259. var Cylinder=function(a,c,d,e,g){function f(l,t,A){h.vertices.push(new THREE.Vertex(new THREE.Vector3(l,t,A)))}THREE.Geometry.call(this);var h=this,b=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*b*j/a)*c,Math.cos(2*b*j/a)*c,0);for(j=0;j<a;j++)f(Math.sin(2*b*j/a)*d,Math.cos(2*b*j/a)*d,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(d!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(c!=0){f(0,0,e+g);for(j=a+a/2;j<
  260. 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  261. var Plane=function(a,c,d,e){THREE.Geometry.call(this);var g,f=a/2,h=c/2;d=d||1;e=e||1;var b=d+1,j=e+1;a=a/d;var l=c/e;for(g=0;g<j;g++)for(c=0;c<b;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(g*l-h),0)));for(g=0;g<e;g++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+b*g,c+b*(g+1),c+1+b*(g+1),c+1+b*g));this.uvs.push([new THREE.UV(c/d,g/e),new THREE.UV(c/d,(g+1)/e),new THREE.UV((c+1)/d,(g+1)/e),new THREE.UV((c+1)/d,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
  262. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  263. var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,c||8),h=Math.max(2,d||6);c=[];for(d=0;d<h+1;d++){e=d/h;var b=a*Math.cos(e*g),j=a*Math.sin(e*g),l=[],t=0;for(e=0;e<f;e++){var A=2*e/f,w=j*Math.sin(A*g);A=j*Math.cos(A*g);(d==0||d==h)&&e>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,b,w)))-1);l.push(t)}c.push(l)}var o,p,C;g=c.length;for(d=0;d<g;d++){f=c[d].length;if(d>0)for(e=0;e<f;e++){l=e==f-1;h=c[d][l?0:e+1];b=c[d][l?f-1:e];j=c[d-1][l?f-1:e];l=c[d-1][l?
  264. 0:e+1];w=d/(g-1);o=(d-1)/(g-1);p=(e+1)/f;A=e/f;t=new THREE.UV(1-p,w);w=new THREE.UV(1-A,w);A=new THREE.UV(1-A,o);var H=new THREE.UV(1-p,o);if(d<c.length-1){o=this.vertices[h].position.clone();p=this.vertices[b].position.clone();C=this.vertices[j].position.clone();o.normalize();p.normalize();C.normalize();this.faces.push(new THREE.Face3(h,b,j,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,w,A])}if(d>1){o=this.vertices[h].position.clone();
  265. p=this.vertices[j].position.clone();C=this.vertices[l].position.clone();o.normalize();p.normalize();C.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,A,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  266. var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
  267. 1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;g=(this.segmentsT+1)*c+d-1;var f=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
  268. var Icosahedron=function(a){function c(A,w,o){var p=Math.sqrt(A*A+w*w+o*o);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(A/p,w/p,o/p)))-1}function d(A,w,o,p){p.faces.push(new THREE.Face3(A,w,o))}function e(A,w){var o=g.vertices[A].position,p=g.vertices[w].position;return c((o.x+p.x)/2,(o.y+p.y)/2,(o.z+p.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
  269. 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var b in f.faces){var j=e(f.faces[b].a,f.faces[b].b),l=e(f.faces[b].b,f.faces[b].c),t=e(f.faces[b].c,f.faces[b].a);d(f.faces[b].a,j,t,h);d(f.faces[b].b,l,j,h);d(f.faces[b].c,
  270. t,l,h);d(j,l,t,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
  271. function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],g=[],f=[],h=[],b=0;b<a.length;b++){this.vertices.push(new THREE.Vertex(a[b]));g[b]=this.vertices.length-1;e[b]=new THREE.Vector3(a[b].x,a[b].y,a[b].z)}for(var j=THREE.Matrix4.rotationZMatrix(c),l=0;l<=d+0.0010;l+=c){for(b=0;b<e.length;b++)if(l<d){e[b]=j.multiplyVector3(e[b].clone());this.vertices.push(new THREE.Vertex(e[b]));f[b]=this.vertices.length-1}else f=h;if(l==0)h=g;for(b=0;b<g.length-1;b++){this.faces.push(new THREE.Face4(f[b],
  272. f[b+1],g[b+1],g[b]));this.uvs.push([new THREE.UV(l/d,b/a.length),new THREE.UV(l/d,(b+1)/a.length),new THREE.UV((l-c)/d,(b+1)/a.length),new THREE.UV((l-c)/d,b/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  273. THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(d){this.isolation=80;this.size=d;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
  274. 0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,g){return d+(e-d)*g};this.VIntX=function(d,e,g,f,h,b,j,l,t,A){h=(h-t)/(A-t);t=this.normal_cache;e[f]=b+h*this.delta;e[f+1]=j;e[f+2]=l;g[f]=this.lerp(t[d],t[d+3],h);g[f+1]=this.lerp(t[d+1],t[d+4],h);g[f+2]=this.lerp(t[d+2],t[d+5],h)};this.VIntY=function(d,e,g,f,h,b,j,l,t,A){h=(h-t)/(A-t);t=this.normal_cache;e[f]=b;e[f+1]=j+h*this.delta;e[f+
  275. 2]=l;e=d+this.yd*3;g[f]=this.lerp(t[d],t[e],h);g[f+1]=this.lerp(t[d+1],t[e+1],h);g[f+2]=this.lerp(t[d+2],t[e+2],h)};this.VIntZ=function(d,e,g,f,h,b,j,l,t,A){h=(h-t)/(A-t);t=this.normal_cache;e[f]=b;e[f+1]=j;e[f+2]=l+h*this.delta;e=d+this.zd*3;g[f]=this.lerp(t[d],t[e],h);g[f+1]=this.lerp(t[d+1],t[e+1],h);g[f+2]=this.lerp(t[d+2],t[e+2],h)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
  276. this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,g,f,h,b){var j=f+1,l=f+this.yd,t=f+this.zd,A=j+this.yd,w=j+this.zd,o=f+this.yd+this.zd,p=j+this.yd+this.zd,C=0,H=this.field[f],y=this.field[j],I=this.field[l],v=this.field[A],L=this.field[t],k=this.field[w],B=this.field[o],n=this.field[p];if(H<h)C|=1;if(y<h)C|=2;if(I<h)C|=8;if(v<h)C|=4;if(L<h)C|=16;if(k<h)C|=32;if(B<h)C|=128;if(n<h)C|=64;var m=THREE.edgeTable[C];if(m==0)return 0;
  277. var z=this.delta,q=d+z,D=e+z;z=g+z;if(m&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,d,e,g,H,y)}if(m&2){this.compNorm(j);this.compNorm(A);this.VIntY(j*3,this.vlist,this.nlist,3,h,q,e,g,y,v)}if(m&4){this.compNorm(l);this.compNorm(A);this.VIntX(l*3,this.vlist,this.nlist,6,h,d,D,g,I,v)}if(m&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,h,d,e,g,H,I)}if(m&16){this.compNorm(t);this.compNorm(w);this.VIntX(t*3,this.vlist,this.nlist,12,h,d,e,z,
  278. L,k)}if(m&32){this.compNorm(w);this.compNorm(p);this.VIntY(w*3,this.vlist,this.nlist,15,h,q,e,z,k,n)}if(m&64){this.compNorm(o);this.compNorm(p);this.VIntX(o*3,this.vlist,this.nlist,18,h,d,D,z,B,n)}if(m&128){this.compNorm(t);this.compNorm(o);this.VIntY(t*3,this.vlist,this.nlist,21,h,d,e,z,L,B)}if(m&256){this.compNorm(f);this.compNorm(t);this.VIntZ(f*3,this.vlist,this.nlist,24,h,d,e,g,H,L)}if(m&512){this.compNorm(j);this.compNorm(w);this.VIntZ(j*3,this.vlist,this.nlist,27,h,q,e,g,y,k)}if(m&1024){this.compNorm(A);
  279. this.compNorm(p);this.VIntZ(A*3,this.vlist,this.nlist,30,h,q,D,g,v,n)}if(m&2048){this.compNorm(l);this.compNorm(o);this.VIntZ(l*3,this.vlist,this.nlist,33,h,d,D,g,I,B)}C<<=4;for(h=f=0;THREE.triTable[C+h]!=-1;){d=C+h;e=d+1;g=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[g],b);h+=3;f++}return f};this.posnormtriv=function(d,e,g,f,h,b){var j=this.count*3;this.positionArray[j]=d[g];this.positionArray[j+1]=d[g+1];this.positionArray[j+2]=d[g+2];this.positionArray[j+
  280. 3]=d[f];this.positionArray[j+4]=d[f+1];this.positionArray[j+5]=d[f+2];this.positionArray[j+6]=d[h];this.positionArray[j+7]=d[h+1];this.positionArray[j+8]=d[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&b(this)};this.begin=
  281. function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,g,f,h){var b=this.size*Math.sqrt(f/h),j=g*this.size,l=e*this.size,t=d*this.size,A=Math.floor(j-b);if(A<1)A=1;j=Math.floor(j+b);if(j>this.size-1)j=this.size-1;var w=Math.floor(l-b);if(w<1)w=1;l=Math.floor(l+b);if(l>this.size-1)l=this.size-1;var o=Math.floor(t-b);if(o<1)o=1;b=Math.floor(t+b);
  282. if(b>this.size-1)b=this.size-1;var p,C,H,y,I,v;for(A=A;A<j;A++){t=this.size2*A;C=A/this.size-g;I=C*C;for(C=w;C<l;C++){H=t+this.size*C;p=C/this.size-e;v=p*p;for(p=o;p<b;p++){y=p/this.size-d;y=f/(1.0E-6+y*y+v+I)-h;if(y>0)this.field[H+p]+=y}}}};this.addPlaneX=function(d,e){var g,f,h,b,j,l=this.size,t=this.yd,A=this.zd,w=this.field,o=l*Math.sqrt(d/e);if(o>l)o=l;for(g=0;g<o;g++){f=g/l;f=f*f;b=d/(1.0E-4+f)-e;if(b>0)for(f=0;f<l;f++){j=g+f*t;for(h=0;h<l;h++)w[A*h+j]+=b}}};this.addPlaneY=function(d,e){var g,
  283. f,h,b,j,l,t=this.size,A=this.yd,w=this.zd,o=this.field,p=t*Math.sqrt(d/e);if(p>t)p=t;for(f=0;f<p;f++){g=f/t;g=g*g;b=d/(1.0E-4+g)-e;if(b>0){j=f*A;for(g=0;g<t;g++){l=j+g;for(h=0;h<t;h++)o[w*h+l]+=b}}}};this.addPlaneZ=function(d,e){var g,f,h,b,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(h=0;h<dist;h++){g=h/size;g=g*g;b=d/(1.0E-4+g)-e;if(b>0){j=zd*h;for(f=0;f<size;f++){l=j+f*yd;for(g=0;g<size;g++)field[l+g]+=b}}}};this.reset=function(){var d;
  284. for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,g,f,h,b,j,l,t,A,w=this.size-2;for(h=1;h<w;h++){A=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(f=1;f<w;f++){t=A+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<w;g++){b=(g-this.halfsize)/this.halfsize;e=t+g;this.polygonize(b,j,l,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(g){var f,h,b,j,l,t,A,w;for(f=
  285. 0;f<g.count;f++){l=f*3;A=l+1;w=l+2;h=g.positionArray[l];b=g.positionArray[A];j=g.positionArray[w];t=new THREE.Vector3(h,b,j);h=g.normalArray[l];b=g.normalArray[A];j=g.normalArray[w];l=new THREE.Vector3(h,b,j);l.normalize();l=new THREE.Vertex(t,l);e.vertices.push(l)}nfaces=g.count/3;for(f=0;f<nfaces;f++){l=(d+f)*3;A=l+1;w=l+2;t=e.vertices[l].normal;h=e.vertices[A].normal;b=e.vertices[w].normal;l=new THREE.Face3(l,A,w,[t,h,b]);e.faces.push(l)}d+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
  286. this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  287. THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
  288. 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
  289. 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
  290. THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
  291. -1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
  292. -1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
  293. -1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
  294. 8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
  295. -1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
  296. 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
  297. -1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
  298. 10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
  299. 6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
  300. 8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
  301. 2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
  302. -1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
  303. -1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
  304. -1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
  305. 1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
  306. -1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
  307. 2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
  308. 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
  309. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
  310. 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
  311. THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
  312. c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
  313. THREE.Loader.prototype.extractUrlbase(c),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,g,e,f)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,g,f){var h=new XMLHttpRequest,b=e+"/"+a,j=0;
  314. h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,g,c):alert("Couldn't load ["+b+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",b,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
  315. createBinModel:function(a,c,d,e){var g=function(f){function h(E,K){var N=t(E,K),V=t(E,K+1),da=t(E,K+2),ga=t(E,K+3),ia=(ga<<1&255|da>>7)-127;N=(da&127)<<16|V<<8|N;if(N==0&&ia==-127)return 0;return(1-2*(ga>>7))*(1+N*Math.pow(2,-23))*Math.pow(2,ia)}function b(E,K){var N=t(E,K),V=t(E,K+1),da=t(E,K+2);return(t(E,K+3)<<24)+(da<<16)+(V<<8)+N}function j(E,K){var N=t(E,K);return(t(E,K+1)<<8)+N}function l(E,K){var N=t(E,K);return N>127?N-256:N}function t(E,K){return E.charCodeAt(K)&255}function A(E){var K,
  316. N,V;K=b(a,E);N=b(a,E+B);V=b(a,E+n);E=j(a,E+m);THREE.Loader.prototype.f3(y,K,N,V,E)}function w(E){var K,N,V,da,ga,ia;K=b(a,E);N=b(a,E+B);V=b(a,E+n);da=j(a,E+m);ga=b(a,E+z);ia=b(a,E+q);E=b(a,E+D);THREE.Loader.prototype.f3n(y,L,K,N,V,da,ga,ia,E)}function o(E){var K,N,V,da;K=b(a,E);N=b(a,E+x);V=b(a,E+u);da=b(a,E+F);E=j(a,E+J);THREE.Loader.prototype.f4(y,K,N,V,da,E)}function p(E){var K,N,V,da,ga,ia,ta,ra;K=b(a,E);N=b(a,E+x);V=b(a,E+u);da=b(a,E+F);ga=j(a,E+J);ia=b(a,E+G);ta=b(a,E+T);ra=b(a,E+U);E=b(a,E+
  317. O);THREE.Loader.prototype.f4n(y,L,K,N,V,da,ga,ia,ta,ra,E)}function C(E){var K,N;K=b(a,E);N=b(a,E+ba);E=b(a,E+ca);THREE.Loader.prototype.uv3(y.uvs,k[K*2],k[K*2+1],k[N*2],k[N*2+1],k[E*2],k[E*2+1])}function H(E){var K,N,V;K=b(a,E);N=b(a,E+W);V=b(a,E+R);E=b(a,E+X);THREE.Loader.prototype.uv4(y.uvs,k[K*2],k[K*2+1],k[N*2],k[N*2+1],k[V*2],k[V*2+1],k[E*2],k[E*2+1])}var y=this,I=0,v,L=[],k=[],B,n,m,z,q,D,x,u,F,J,G,T,U,O,ba,ca,W,R,X,Y,M,S,aa,ja,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,
  318. e,f);v={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:b(a,I+16),nnormals:b(a,I+16+4),nuvs:b(a,I+16+8),ntri_flat:b(a,I+16+12),ntri_smooth:b(a,I+16+16),ntri_flat_uv:b(a,I+16+20),ntri_smooth_uv:b(a,I+16+24),nquad_flat:b(a,I+16+28),nquad_smooth:b(a,I+16+32),nquad_flat_uv:b(a,I+16+36),
  319. nquad_smooth_uv:b(a,I+16+40)};I+=v.header_bytes;B=v.vertex_index_bytes;n=v.vertex_index_bytes*2;m=v.vertex_index_bytes*3;z=v.vertex_index_bytes*3+v.material_index_bytes;q=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes;D=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*2;x=v.vertex_index_bytes;u=v.vertex_index_bytes*2;F=v.vertex_index_bytes*3;J=v.vertex_index_bytes*4;G=v.vertex_index_bytes*4+v.material_index_bytes;T=v.vertex_index_bytes*4+v.material_index_bytes+
  320. v.normal_index_bytes;U=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*2;O=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*3;ba=v.uv_index_bytes;ca=v.uv_index_bytes*2;W=v.uv_index_bytes;R=v.uv_index_bytes*2;X=v.uv_index_bytes*3;f=v.vertex_index_bytes*3+v.material_index_bytes;ha=v.vertex_index_bytes*4+v.material_index_bytes;Y=v.ntri_flat*f;M=v.ntri_smooth*(f+v.normal_index_bytes*3);S=v.ntri_flat_uv*(f+v.uv_index_bytes*3);aa=v.ntri_smooth_uv*(f+v.normal_index_bytes*
  321. 3+v.uv_index_bytes*3);ja=v.nquad_flat*ha;f=v.nquad_smooth*(ha+v.normal_index_bytes*4);ha=v.nquad_flat_uv*(ha+v.uv_index_bytes*4);I+=function(E){var K,N,V,da=v.vertex_coordinate_bytes*3,ga=E+v.nvertices*da;for(E=E;E<ga;E+=da){K=h(a,E);N=h(a,E+v.vertex_coordinate_bytes);V=h(a,E+v.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(y,K,N,V)}return v.nvertices*da}(I);I+=function(E){var K,N,V,da=v.normal_coordinate_bytes*3,ga=E+v.nnormals*da;for(E=E;E<ga;E+=da){K=l(a,E);N=l(a,E+v.normal_coordinate_bytes);
  322. V=l(a,E+v.normal_coordinate_bytes*2);L.push(K/127,N/127,V/127)}return v.nnormals*da}(I);I+=function(E){var K,N,V=v.uv_coordinate_bytes*2,da=E+v.nuvs*V;for(E=E;E<da;E+=V){K=h(a,E);N=h(a,E+v.uv_coordinate_bytes);k.push(K,N)}return v.nuvs*V}(I);I=I;Y=I+Y;M=Y+M;S=M+S;aa=S+aa;ja=aa+ja;f=ja+f;ha=f+ha;(function(E){var K,N=v.vertex_index_bytes*3+v.material_index_bytes,V=N+v.uv_index_bytes*3,da=E+v.ntri_flat_uv*V;for(K=E;K<da;K+=V){A(K);C(K+N)}return da-E})(M);(function(E){var K,N=v.vertex_index_bytes*3+v.material_index_bytes+
  323. v.normal_index_bytes*3,V=N+v.uv_index_bytes*3,da=E+v.ntri_smooth_uv*V;for(K=E;K<da;K+=V){w(K);C(K+N)}return da-E})(S);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes,V=N+v.uv_index_bytes*4,da=E+v.nquad_flat_uv*V;for(K=E;K<da;K+=V){o(K);H(K+N)}return da-E})(f);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*4,V=N+v.uv_index_bytes*4,da=E+v.nquad_smooth_uv*V;for(K=E;K<da;K+=V){p(K);H(K+N)}return da-E})(ha);(function(E){var K,N=v.vertex_index_bytes*
  324. 3+v.material_index_bytes,V=E+v.ntri_flat*N;for(K=E;K<V;K+=N)A(K);return V-E})(I);(function(E){var K,N=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*3,V=E+v.ntri_smooth*N;for(K=E;K<V;K+=N)w(K);return V-E})(Y);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes,V=E+v.nquad_flat*N;for(K=E;K<V;K+=N)o(K);return V-E})(aa);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*4,V=E+v.nquad_smooth*N;for(K=E;K<V;K+=N)p(K);return V-E})(ja);
  325. this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(d))},createModel:function(a,c,d){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,b,j,l,t;h=0;for(b=a.vertices.length;h<b;h+=3){j=a.vertices[h];l=a.vertices[h+1];t=a.vertices[h+2];THREE.Loader.prototype.v(f,j,l,t)}if(a.colors){h=0;for(b=a.colors.length;h<b;h+=3){j=a.colors[h];l=
  326. a.colors[h+1];t=a.colors[h+2];THREE.Loader.prototype.vc(f,j,l,t)}}})();(function(){function h(p,C){THREE.Loader.prototype.f3(f,p[C],p[C+1],p[C+2],p[C+3])}function b(p,C){THREE.Loader.prototype.f3n(f,a.normals,p[C],p[C+1],p[C+2],p[C+3],p[C+4],p[C+5],p[C+6])}function j(p,C){THREE.Loader.prototype.f4(f,p[C],p[C+1],p[C+2],p[C+3],p[C+4])}function l(p,C){THREE.Loader.prototype.f4n(f,a.normals,p[C],p[C+1],p[C+2],p[C+3],p[C+4],p[C+5],p[C+6],p[C+7],p[C+8])}function t(p,C){var H,y,I,v,L,k,B,n,m;H=p[C];y=p[C+
  327. 1];I=p[C+2];v=a.uvs[H*2];B=a.uvs[H*2+1];L=a.uvs[y*2];n=a.uvs[y*2+1];k=a.uvs[I*2];m=a.uvs[I*2+1];THREE.Loader.prototype.uv3(f.uvs,v,B,L,n,k,m);if(a.uvs2){v=a.uvs2[H*2];B=a.uvs2[H*2+1];L=a.uvs2[y*2];n=a.uvs2[y*2+1];k=a.uvs2[I*2];m=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(f.uvs2,v,1-B,L,1-n,k,1-m)}}function A(p,C){var H,y,I,v,L,k,B,n,m,z,q,D;H=p[C];y=p[C+1];I=p[C+2];v=p[C+3];L=a.uvs[H*2];m=a.uvs[H*2+1];k=a.uvs[y*2];z=a.uvs[y*2+1];B=a.uvs[I*2];q=a.uvs[I*2+1];n=a.uvs[v*2];D=a.uvs[v*2+1];THREE.Loader.prototype.uv4(f.uvs,
  328. L,m,k,z,B,q,n,D);if(a.uvs2){L=a.uvs2[H*2];m=a.uvs2[H*2+1];k=a.uvs2[y*2];z=a.uvs2[y*2+1];B=a.uvs2[I*2];q=a.uvs2[I*2+1];n=a.uvs2[v*2];D=a.uvs2[v*2+1];THREE.Loader.prototype.uv4(f.uvs2,L,1-m,k,1-z,B,1-q,n,1-D)}}var w,o;w=0;for(o=a.triangles_uv.length;w<o;w+=7){h(a.triangles_uv,w);t(a.triangles_uv,w+4)}w=0;for(o=a.triangles_n_uv.length;w<o;w+=10){b(a.triangles_n_uv,w);t(a.triangles_n_uv,w+7)}w=0;for(o=a.quads_uv.length;w<o;w+=9){j(a.quads_uv,w);A(a.quads_uv,w+5)}w=0;for(o=a.quads_n_uv.length;w<o;w+=13){l(a.quads_n_uv,
  329. w);A(a.quads_n_uv,w+9)}w=0;for(o=a.triangles.length;w<o;w+=4)h(a.triangles,w);w=0;for(o=a.triangles_n.length;w<o;w+=7)b(a.triangles_n,w);w=0;for(o=a.quads.length;w<o;w+=5)j(a.quads,w);w=0;for(o=a.quads_n.length;w<o;w+=9)l(a.quads_n,w)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},vc:function(a,c,d,e){var g=new THREE.Color(16777215);
  330. g.setRGB(c,d,e);a.colors.push(g)},f3:function(a,c,d,e,g){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[g]))},f4:function(a,c,d,e,g,f){a.faces.push(new THREE.Face4(c,d,e,g,null,a.materials[f]))},f3n:function(a,c,d,e,g,f,h,b,j){f=a.materials[f];var l=c[b*3],t=c[b*3+1];b=c[b*3+2];var A=c[j*3],w=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(l,t,b),new THREE.Vector3(A,w,j)],f))},f4n:function(a,c,d,e,g,f,h,b,j,l,t){h=a.materials[h];
  331. var A=c[j*3],w=c[j*3+1];j=c[j*3+2];var o=c[l*3],p=c[l*3+1];l=c[l*3+2];var C=c[t*3],H=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(d,e,g,f,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(A,w,j),new THREE.Vector3(o,p,l),new THREE.Vector3(C,H,t)],h))},uv3:function(a,c,d,e,g,f,h){var b=[];b.push(new THREE.UV(c,d));b.push(new THREE.UV(e,g));b.push(new THREE.UV(f,h));a.push(b)},uv4:function(a,c,d,e,g,f,h,b,j){var l=[];l.push(new THREE.UV(c,d));l.push(new THREE.UV(e,g));l.push(new THREE.UV(f,
  332. h));l.push(new THREE.UV(b,j));a.push(l)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],d)]},createMaterial:function(a,c){function d(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function e(b,j){var l=new Image;l.onload=function(){if(!d(this.width)||!d(this.height)){var t=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),A=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=t;b.image.height=
  333. A;b.image.getContext("2d").drawImage(this,0,0,t,A)}else b.image=this;b.image.loaded=1};l.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&c){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=
  334. a.a_dbg_color;if(a.map_lightmap&&c){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,c+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};