ThreeExtras.js 159 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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,b,k,h;if(d==0)e=g=f=0;else{b=Math.floor(a*6);k=a*6-b;a=d*(1-c);h=d*(1-c*k);c=d*(1-c*(1-k));switch(b){case 1:e=h;g=d;f=a;break;case 2:e=a;g=d;f=c;break;case 3:e=a;g=h;f=d;break;case 4:e=c;g=a;f=d;break;case 5:e=d;g=a;f=h;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,b){return f.distance-b.distance});return g},intersectObject:function(a){function c(H,w,I,t){t=t.clone().subSelf(w);I=I.clone().subSelf(w);var L=H.clone().subSelf(w);H=t.dot(t);w=t.dot(I);t=t.dot(L);var l=I.dot(I);I=I.dot(L);L=1/(H*l-w*w);l=(l*t-w*I)*L;H=(H*I-w*t)*L;return l>0&&H>0&&l+H<1}var d,e,g,f,b,k,h,m,o,y,
  17. v,q=a.geometry,z=q.vertices,B=[];d=0;for(e=q.faces.length;d<e;d++){g=q.faces[d];y=this.origin.clone();v=this.direction.clone();f=a.matrix.multiplyVector3(z[g.a].position.clone());b=a.matrix.multiplyVector3(z[g.b].position.clone());k=a.matrix.multiplyVector3(z[g.c].position.clone());h=g instanceof THREE.Face4?a.matrix.multiplyVector3(z[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());o=v.dot(m);if(o<0){m=m.dot((new THREE.Vector3).sub(f,y))/o;y=y.addSelf(v.multiplyScalar(m));
  18. if(g instanceof THREE.Face3){if(c(y,f,b,k)){g={distance:this.origin.distanceTo(y),point:y,face:g,object:a};B.push(g)}}else if(g instanceof THREE.Face4)if(c(y,f,b,h)||c(y,b,k,h)){g={distance:this.origin.distanceTo(y),point:y,face:g,object:a};B.push(g)}}}return B}};
  19. THREE.Rectangle=function(){function a(){f=e-c;b=g-d}var c,d,e,g,f,b,k=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return b};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(h,m,o,y){k=false;c=h;d=m;e=o;g=y;a()};this.addPoint=function(h,m){if(k){k=false;c=h;d=m;e=h;g=m}else{c=c<h?c:h;d=d<m?d:m;e=e>h?e:h;g=g>m?
  20. g:m}a()};this.add3Points=function(h,m,o,y,v,q){if(k){k=false;c=h<o?h<v?h:v:o<v?o:v;d=m<y?m<q?m:q:y<q?y:q;e=h>o?h>v?h:v:o>v?o:v;g=m>y?m>q?m:q:y>q?y:q}else{c=h<o?h<v?h<c?h:c:v<c?v:c:o<v?o<c?o:c:v<c?v:c;d=m<y?m<q?m<d?m:d:q<d?q:d:y<q?y<d?y:d:q<d?q:d;e=h>o?h>v?h>e?h:e:v>e?v:e:o>v?o>e?o:e:v>e?v:e;g=m>y?m>q?m>g?m:g:q>g?q:g:y>q?y>g?y:g:q>g?q:g}a()};this.addRectangle=function(h){if(k){k=false;c=h.getLeft();d=h.getTop();e=h.getRight();g=h.getBottom()}else{c=c<h.getLeft()?c:h.getLeft();d=d<h.getTop()?d:h.getTop();
  21. e=e>h.getRight()?e:h.getRight();g=g>h.getBottom()?g:h.getBottom()}a()};this.inflate=function(h){c-=h;d-=h;e+=h;g+=h;a()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();e=e<h.getRight()?e:h.getRight();g=g<h.getBottom()?g:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(c,h.getLeft())>=0&&Math.min(g,h.getBottom())-Math.max(d,h.getTop())>=0};this.empty=function(){k=true;g=e=d=c=0;a()};this.isEmpty=function(){return k};this.toString=
  22. function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", height: "+b+" )"}};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}};
  23. THREE.Matrix4=function(a,c,d,e,g,f,b,k,h,m,o,y,v,q,z,B){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=b||0;this.n24=k||0;this.n31=h||0;this.n32=m||0;this.n33=o||1;this.n34=y||0;this.n41=v||0;this.n42=q||0;this.n43=z||0;this.n44=B||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,b,k,h,m,o,y,v,q,z,B){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=b;this.n24=k;this.n31=h;this.n32=m;this.n33=o;this.n34=y;this.n41=v;this.n42=q;this.n43=z;this.n44=B;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,b=a.n21,k=a.n22,h=a.n23,m=a.n24,o=a.n31,
  28. y=a.n32,v=a.n33,q=a.n34,z=a.n41,B=a.n42,H=a.n43,w=a.n44,I=c.n11,t=c.n12,L=c.n13,l=c.n14,A=c.n21,n=c.n22,j=c.n23,x=c.n24,u=c.n31,E=c.n32,C=c.n33,p=c.n34,F=c.n41,M=c.n42,G=c.n43,W=c.n44;this.n11=d*I+e*A+g*u+f*F;this.n12=d*t+e*n+g*E+f*M;this.n13=d*L+e*j+g*C+f*G;this.n14=d*l+e*x+g*p+f*W;this.n21=b*I+k*A+h*u+m*F;this.n22=b*t+k*n+h*E+m*M;this.n23=b*L+k*j+h*C+m*G;this.n24=b*l+k*x+h*p+m*W;this.n31=o*I+y*A+v*u+q*F;this.n32=o*t+y*n+v*E+q*M;this.n33=o*L+y*j+v*C+q*G;this.n34=o*l+y*x+v*p+q*W;this.n41=z*I+B*A+
  29. H*u+w*F;this.n42=z*t+B*n+H*E+w*M;this.n43=z*L+B*j+H*C+w*G;this.n44=z*l+B*x+H*p+w*W;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,b=this.n22,k=this.n23,h=this.n24,m=this.n31,o=this.n32,y=this.n33,v=this.n34,q=this.n41,z=this.n42,B=this.n43,H=this.n44,w=a.n11,I=a.n21,t=a.n31,L=a.n41,l=a.n12,A=a.n22,n=a.n32,j=a.n42,x=a.n13,u=a.n23,E=a.n33,C=a.n43,p=a.n14,F=a.n24,M=a.n34;a=a.n44;this.n11=c*w+d*I+e*t+g*L;this.n12=c*l+d*A+e*n+g*j;this.n13=c*x+d*u+e*E+g*
  30. C;this.n14=c*p+d*F+e*M+g*a;this.n21=f*w+b*I+k*t+h*L;this.n22=f*l+b*A+k*n+h*j;this.n23=f*x+b*u+k*E+h*C;this.n24=f*p+b*F+k*M+h*a;this.n31=m*w+o*I+y*t+v*L;this.n32=m*l+o*A+y*n+v*j;this.n33=m*x+o*u+y*E+v*C;this.n34=m*p+o*F+y*M+v*a;this.n41=q*w+z*I+B*t+H*L;this.n42=q*l+z*A+B*n+H*j;this.n43=q*x+z*u+B*E+H*C;this.n44=q*p+z*F+B*M+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*=
  31. a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,b=this.n23,k=this.n24,h=this.n31,m=this.n32,o=this.n33,y=this.n34,v=this.n41,q=this.n42,z=this.n43,B=this.n44;return e*b*m*v-d*k*m*v-e*f*o*v+c*k*o*v+d*f*y*v-c*b*y*v-e*b*h*q+d*k*h*q+e*g*o*q-a*k*o*q-d*g*y*q+a*b*y*q+e*f*h*z-c*k*h*z-e*g*m*z+a*k*m*z+c*g*y*z-a*f*y*z-d*f*h*B+c*b*h*B+d*g*m*B-a*b*m*B-c*g*o*B+a*f*o*B},transpose:function(){function a(c,d,
  32. e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
  33. a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
  34. 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,b=a.y,k=a.z,h=g*f,m=g*b;this.set(h*f+d,h*b-e*k,h*k+e*b,0,h*b+e*k,m*b+d,m*k-e*f,0,h*k-e*b,m*k+e*f,g*k*k+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
  35. this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
  36. 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};
  37. THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,b=a.n22,k=a.n23,h=a.n24,m=a.n31,o=a.n32,y=a.n33,v=a.n34,q=a.n41,z=a.n42,B=a.n43,H=a.n44,w=new THREE.Matrix4;w.n11=k*v*z-h*y*z+h*o*B-b*v*B-k*o*H+b*y*H;w.n12=g*y*z-e*v*z-g*o*B+d*v*B+e*o*H-d*y*H;w.n13=e*h*z-g*k*z+g*b*B-d*h*B-e*b*H+d*k*H;w.n14=g*k*o-e*h*o-g*b*y+d*h*y+e*b*v-d*k*v;w.n21=h*y*q-k*v*q-h*m*B+f*v*B+k*m*H-f*y*H;w.n22=e*v*q-g*y*q+g*m*B-c*v*B-e*m*H+c*y*H;w.n23=g*k*q-e*h*q-g*f*B+c*h*B+e*f*H-c*k*H;w.n24=e*h*m-g*k*m+
  38. g*f*y-c*h*y-e*f*v+c*k*v;w.n31=b*v*q-h*o*q+h*m*z-f*v*z-b*m*H+f*o*H;w.n32=g*o*q-d*v*q-g*m*z+c*v*z+d*m*H-c*o*H;w.n33=e*h*q-g*b*q+g*f*z-c*h*z-d*f*H+c*b*H;w.n34=g*b*m-d*h*m-g*f*o+c*h*o+d*f*v-c*b*v;w.n41=k*o*q-b*y*q-k*m*z+f*y*z+b*m*B-f*o*B;w.n42=d*y*q-e*o*q+e*m*z-c*y*z-d*m*B+c*o*B;w.n43=e*b*q-d*k*q-e*f*z+c*k*z+d*f*B-c*b*B;w.n44=d*k*m-e*b*m+e*f*o-c*k*o-d*f*y+c*b*y;w.multiplyScalar(1/a.determinant());return w};
  39. THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],g=-c[10]*c[1]+c[2]*c[9],f=c[6]*c[1]-c[2]*c[5],b=-c[10]*c[4]+c[6]*c[8],k=c[10]*c[0]-c[2]*c[8],h=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],o=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*b+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*g;d[2]=c*f;d[3]=c*b;d[4]=c*k;d[5]=c*h;d[6]=c*m;d[7]=c*o;d[8]=c*y;return a};
  40. THREE.Matrix4.makeFrustum=function(a,c,d,e,g,f){var b,k,h;b=new THREE.Matrix4;k=2*g/(c-a);h=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);b.n11=k;b.n12=0;b.n13=a;b.n14=0;b.n21=0;b.n22=h;b.n23=d;b.n24=0;b.n31=0;b.n32=0;b.n33=e;b.n34=g;b.n41=0;b.n42=0;b.n43=-1;b.n44=0;return b};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)};
  41. THREE.Matrix4.makeOrtho=function(a,c,d,e,g,f){var b,k,h,m;b=new THREE.Matrix4;k=c-a;h=d-e;m=f-g;a=(c+a)/k;d=(d+e)/h;g=(f+g)/m;b.n11=2/k;b.n12=0;b.n13=0;b.n14=-a;b.n21=0;b.n22=2/h;b.n23=0;b.n24=-d;b.n31=0;b.n32=0;b.n33=-2/m;b.n34=-g;b.n41=0;b.n42=0;b.n43=0;b.n44=1;return b};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  42. 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+" )"}};
  43. 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+" )"}};
  44. 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};
  45. 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};
  46. 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);
  47. d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,g,f,b,k=new THREE.Vector3,h=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){k.set(0,0,0);c=0;for(d=f.normal.length;c<d;c++)k.addSelf(f.vertexNormals[c]);k.divideScalar(3)}else{c=this.vertices[f.a];d=this.vertices[f.b];b=this.vertices[f.c];k.sub(b.position,
  48. d.position);h.sub(c.position,d.position);k.crossSelf(h)}k.isZero()||k.normalize();f.normal.copy(k)}},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,
  49. 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<
  50. 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(p,F,M,G,W,Q,O){f=p.vertices[F].position;b=p.vertices[M].position;k=p.vertices[G].position;h=g[W];m=g[Q];o=g[O];y=b.x-f.x;v=k.x-f.x;q=b.y-f.y;z=k.y-f.y;
  51. B=b.z-f.z;H=k.z-f.z;w=m.u-h.u;I=o.u-h.u;t=m.v-h.v;L=o.v-h.v;l=1/(w*L-I*t);j.set((L*y-t*v)*l,(L*q-t*z)*l,(L*B-t*H)*l);x.set((w*v-I*y)*l,(w*z-I*q)*l,(w*H-I*B)*l);A[F].addSelf(j);A[M].addSelf(j);A[G].addSelf(j);n[F].addSelf(x);n[M].addSelf(x);n[G].addSelf(x)}var c,d,e,g,f,b,k,h,m,o,y,v,q,z,B,H,w,I,t,L,l,A=[],n=[],j=new THREE.Vector3,x=new THREE.Vector3,u=new THREE.Vector3,E=new THREE.Vector3,C=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){A[c]=new THREE.Vector3;n[c]=new THREE.Vector3}c=0;
  52. 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]);
  53. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){C.copy(this.vertices[c].normal);e=A[c];u.copy(e);u.subSelf(C.multiplyScalar(C.dot(e))).normalize();E.cross(this.vertices[c].normal,e);e=E.dot(n[c]);e=e<0?-1:1;this.vertices[c].tangent.set(u.x,u.y,u.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],
  54. 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>
  55. 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(o){var y=[];c=0;for(d=o.length;c<d;c++)o[c]==undefined?y.push("undefined"):y.push(o[c].toString());return y.join("_")}var c,d,e,g,f,b,k,h,m={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
  56. b=f.materials;k=a(b);if(m[k]==undefined)m[k]={hash:k,counter:0};h=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:b,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[h].vertices+f>65535){m[k].counter+=1;h=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:b,vertices:0}}this.geometryChunks[h].faces.push(e);this.geometryChunks[h].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
  57. this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
  58. 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)};
  59. 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()};
  60. 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;
  61. 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;
  62. 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};
  63. 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};
  64. 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;
  65. 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()};
  66. 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;
  67. 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=
  68. 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}};
  69. 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};
  70. 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!==
  71. 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!==
  72. 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}};
  73. 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+
  74. "<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
  75. 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!==
  76. 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!==
  77. 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}};
  78. 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+
  79. "<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};
  80. 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=
  81. 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=
  82. 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=
  83. 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}};
  84. 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: "+
  85. 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};
  86. 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!==
  87. 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};
  88. 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!==
  89. 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"}};
  90. 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=
  91. 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!==
  92. undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  93. 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};
  94. 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;
  95. 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};
  96. 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/>)"}};
  97. 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};
  98. 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;
  99. 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;
  100. 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};
  101. 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(){};
  102. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  103. 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+" )"}};
  104. 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};
  105. THREE.Projector=function(){function a(n,j){return j.z-n.z}function c(n,j){var x=0,u=1,E=n.z+n.w,C=j.z+j.w,p=-n.z+n.w,F=-j.z+j.w;if(E>=0&&C>=0&&p>=0&&F>=0)return true;else if(E<0&&C<0||p<0&&F<0)return false;else{if(E<0)x=Math.max(x,E/(E-C));else if(C<0)u=Math.min(u,E/(E-C));if(p<0)x=Math.max(x,p/(p-F));else if(F<0)u=Math.min(u,p/(p-F));if(u<x)return false;else{n.lerpSelf(j,x);j.lerpSelf(n,1-u);return true}}}var d,e,g=[],f,b,k,h=[],m,o,y=[],v,q,z=[],B=new THREE.Vector4,H=new THREE.Vector4,w=new THREE.Matrix4,
  106. I=new THREE.Matrix4,t=[],L=new THREE.Vector4,l=new THREE.Vector4,A;this.projectObjects=function(n,j,x){var u=[],E,C;e=0;w.multiply(j.projectionMatrix,j.matrix);t[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);t[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);t[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);t[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);t[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
  107. w.n33,w.n44-w.n34);t[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);j=0;for(E=t.length;j<E;j++){C=t[j];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}E=n.objects;n=0;for(j=E.length;n<j;n++){C=E[n];var p;if(!(p=!C.visible)){if(p=C instanceof THREE.Mesh){a:{p=void 0;for(var F=C.position,M=-C.geometry.boundingSphere.radius*Math.max(C.scale.x,Math.max(C.scale.y,C.scale.z)),G=0;G<6;G++){p=t[G].x*F.x+t[G].y*F.y+t[G].z*F.z+t[G].w;if(p<=M){p=false;break a}}p=true}p=!p}p=p}if(!p){d=
  108. g[e]=g[e]||new THREE.RenderableObject;B.copy(C.position);w.multiplyVector3(B);d.object=C;d.z=B.z;u.push(d);e++}}x&&u.sort(a);return u};this.projectScene=function(n,j,x){var u=[],E=j.near,C=j.far,p,F,M,G,W,Q,O,ba,ca,U,R,X,Y,K,T,aa;k=o=q=0;j.autoUpdateMatrix&&j.updateMatrix();w.multiply(j.projectionMatrix,j.matrix);Q=this.projectObjects(n,j,true);n=0;for(p=Q.length;n<p;n++){O=Q[n].object;if(O.visible){O.autoUpdateMatrix&&O.updateMatrix();ba=O.matrix;ca=O.rotationMatrix;U=O.materials;R=O.overdraw;if(O instanceof
  109. THREE.Mesh){X=O.geometry;Y=X.vertices;F=0;for(M=Y.length;F<M;F++){K=Y[F];K.positionWorld.copy(K.position);ba.multiplyVector3(K.positionWorld);G=K.positionScreen;G.copy(K.positionWorld);w.multiplyVector4(G);G.x/=G.w;G.y/=G.w;K.__visible=G.z>E&&G.z<C}X=X.faces;F=0;for(M=X.length;F<M;F++){K=X[F];if(K instanceof THREE.Face3){G=Y[K.a];W=Y[K.b];T=Y[K.c];if(G.__visible&&W.__visible&&T.__visible)if(O.doubleSided||O.flipSided!=(T.positionScreen.x-G.positionScreen.x)*(W.positionScreen.y-G.positionScreen.y)-
  110. (T.positionScreen.y-G.positionScreen.y)*(W.positionScreen.x-G.positionScreen.x)<0){f=h[k]=h[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(G.positionWorld);f.v2.positionWorld.copy(W.positionWorld);f.v3.positionWorld.copy(T.positionWorld);f.v1.positionScreen.copy(G.positionScreen);f.v2.positionScreen.copy(W.positionScreen);f.v3.positionScreen.copy(T.positionScreen);f.normalWorld.copy(K.normal);ca.multiplyVector3(f.normalWorld);f.centroidWorld.copy(K.centroid);ba.multiplyVector3(f.centroidWorld);
  111. f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);T=K.vertexNormals;A=f.vertexNormalsWorld;G=0;for(W=T.length;G<W;G++){aa=A[G]=A[G]||new THREE.Vector3;aa.copy(T[G]);ca.multiplyVector3(aa)}f.z=f.centroidScreen.z;f.meshMaterials=U;f.faceMaterials=K.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]}u.push(f);k++}}else if(K instanceof THREE.Face4){G=Y[K.a];W=Y[K.b];T=Y[K.c];aa=Y[K.d];if(G.__visible&&
  112. W.__visible&&T.__visible&&aa.__visible)if(O.doubleSided||O.flipSided!=((aa.positionScreen.x-G.positionScreen.x)*(W.positionScreen.y-G.positionScreen.y)-(aa.positionScreen.y-G.positionScreen.y)*(W.positionScreen.x-G.positionScreen.x)<0||(W.positionScreen.x-T.positionScreen.x)*(aa.positionScreen.y-T.positionScreen.y)-(W.positionScreen.y-T.positionScreen.y)*(aa.positionScreen.x-T.positionScreen.x)<0)){f=h[k]=h[k]||new THREE.RenderableFace3;f.v1.positionWorld.copy(G.positionWorld);f.v2.positionWorld.copy(W.positionWorld);
  113. f.v3.positionWorld.copy(aa.positionWorld);f.v1.positionScreen.copy(G.positionScreen);f.v2.positionScreen.copy(W.positionScreen);f.v3.positionScreen.copy(aa.positionScreen);f.normalWorld.copy(K.normal);ca.multiplyVector3(f.normalWorld);f.centroidWorld.copy(K.centroid);ba.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);w.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=U;f.faceMaterials=K.materials;f.overdraw=R;if(O.geometry.uvs[F]){f.uvs[0]=O.geometry.uvs[F][0];
  114. f.uvs[1]=O.geometry.uvs[F][1];f.uvs[2]=O.geometry.uvs[F][3]}u.push(f);k++;b=h[k]=h[k]||new THREE.RenderableFace3;b.v1.positionWorld.copy(W.positionWorld);b.v2.positionWorld.copy(T.positionWorld);b.v3.positionWorld.copy(aa.positionWorld);b.v1.positionScreen.copy(W.positionScreen);b.v2.positionScreen.copy(T.positionScreen);b.v3.positionScreen.copy(aa.positionScreen);b.normalWorld.copy(f.normalWorld);b.centroidWorld.copy(f.centroidWorld);b.centroidScreen.copy(f.centroidScreen);b.z=b.centroidScreen.z;
  115. b.meshMaterials=U;b.faceMaterials=K.materials;b.overdraw=R;if(O.geometry.uvs[F]){b.uvs[0]=O.geometry.uvs[F][1];b.uvs[1]=O.geometry.uvs[F][2];b.uvs[2]=O.geometry.uvs[F][3]}u.push(b);k++}}}}else if(O instanceof THREE.Line){I.multiply(w,ba);Y=O.geometry.vertices;K=Y[0];K.positionScreen.copy(K.position);I.multiplyVector4(K.positionScreen);F=1;for(M=Y.length;F<M;F++){G=Y[F];G.positionScreen.copy(G.position);I.multiplyVector4(G.positionScreen);W=Y[F-1];L.copy(G.positionScreen);l.copy(W.positionScreen);
  116. if(c(L,l)){L.multiplyScalar(1/L.w);l.multiplyScalar(1/l.w);m=y[o]=y[o]||new THREE.RenderableLine;m.v1.positionScreen.copy(L);m.v2.positionScreen.copy(l);m.z=Math.max(L.z,l.z);m.materials=O.materials;u.push(m);o++}}}else if(O instanceof THREE.Particle){H.set(O.position.x,O.position.y,O.position.z,1);w.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){v=z[q]=z[q]||new THREE.RenderableParticle;v.x=H.x/H.w;v.y=H.y/H.w;v.z=H.z;v.rotation=O.rotation.z;v.scale.x=O.scale.x*Math.abs(v.x-(H.x+j.projectionMatrix.n11)/
  117. (H.w+j.projectionMatrix.n14));v.scale.y=O.scale.y*Math.abs(v.y-(H.y+j.projectionMatrix.n22)/(H.w+j.projectionMatrix.n24));v.materials=O.materials;u.push(v);q++}}}}x&&u.sort(a);return u};this.unprojectVector=function(n,j){var x=THREE.Matrix4.makeInvert(j.matrix);x.multiplySelf(THREE.Matrix4.makeInvert(j.projectionMatrix));x.multiplyVector3(n);return n}};
  118. 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(b,k){d=b;e=k;g=d/2;f=e/2};this.render=function(b,k){var h,m,o,y,v,q,z,B;a=c.projectScene(b,k);h=0;for(m=a.length;h<m;h++){v=a[h];if(v instanceof THREE.RenderableParticle){z=v.x*g+g;B=v.y*f+f;o=0;for(y=v.material.length;o<y;o++){q=v.material[o];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=B+"px"}}}}}};
  119. THREE.CanvasRenderer=function(){function a(ka){if(v!=ka)m.globalAlpha=v=ka}function c(ka){if(q!=ka){switch(ka){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=ka}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),f,b,k,h,m=g.getContext("2d"),o=new THREE.Color(0),y=0,v=1,q=0,z=null,B=null,H=1,w,I,t,L,l,A,n,j,x,u=new THREE.Color,
  120. E=new THREE.Color,C=new THREE.Color,p=new THREE.Color,F=new THREE.Color,M,G,W,Q,O,ba,ca,U,R,X=new THREE.Rectangle,Y=new THREE.Rectangle,K=new THREE.Rectangle,T=false,aa=new THREE.Color,ja=new THREE.Color,ha=new THREE.Color,D=new THREE.Color,J=Math.PI*2,N=new THREE.Vector3,V,da,ga,ia,ta,qa,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=
  121. ta.height=va;qa=ta.getContext("2d");qa.translate(-va/2,-va/2);qa.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,ra){f=ka;b=ra;k=f/2;h=b/2;g.width=f;g.height=b;X.set(-k,-h,k,h);v=1;q=0;B=z=null;H=1};this.setClearColor=function(ka,ra){o=ka;y=ra;Y.set(-k,-h,k,h);m.setTransform(1,0,0,-1,k,h);this.clear()};this.setClearColorHex=function(ka,ra){o.setHex(ka);y=ra;Y.set(-k,-h,k,h);m.setTransform(1,0,0,-1,k,h);this.clear()};this.clear=function(){m.setTransform(1,
  122. 0,0,-1,k,h);if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(X);if(o.hex==0&&y==0)m.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+y+")";m.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}Y.empty()}};this.render=function(ka,ra){function oa(P){var ea,$,S,Z=P.lights;ja.setRGB(0,0,0);ha.setRGB(0,0,0);D.setRGB(0,0,0);P=0;for(ea=Z.length;P<ea;P++){$=Z[P];S=$.color;if($ instanceof
  123. THREE.AmbientLight){ja.r+=S.r;ja.g+=S.g;ja.b+=S.b}else if($ instanceof THREE.DirectionalLight){ha.r+=S.r;ha.g+=S.g;ha.b+=S.b}else if($ instanceof THREE.PointLight){D.r+=S.r;D.g+=S.g;D.b+=S.b}}}function Aa(P,ea,$,S){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){S.r+=ma.r*fa;S.g+=ma.g*fa;S.b+=ma.b*fa}}else if(fa instanceof THREE.PointLight){N.sub(fa.position,ea);N.normalize();fa=
  124. $.dot(N)*na;if(fa>0){S.r+=ma.r*fa;S.g+=ma.g*fa;S.b+=ma.b*fa}}}}function Ja(P,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var S,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*k;fa=ea.scale.y*h;$=Z*na;S=fa*pa;K.set(P.x-$,P.y-S,P.x+$,P.y+S);if(X.instersects(K)){m.save();m.translate(P.x,P.y);m.rotate(-ea.rotation);m.scale(Z,-fa);m.translate(-na,-pa);m.drawImage(ma,0,0);m.restore()}}}else if($ instanceof
  125. THREE.ParticleCircleMaterial){if(T){aa.r=ja.r+ha.r+D.r;aa.g=ja.g+ha.g+D.g;aa.b=ja.b+ha.b+D.b;u.r=$.color.r*aa.r;u.g=$.color.g*aa.g;u.b=$.color.b*aa.b;u.updateStyleString()}else u.__styleString=$.color.__styleString;$=ea.scale.x*k;S=ea.scale.y*h;K.set(P.x-$,P.y-S,P.x+$,P.y+S);if(X.instersects(K)){Z=u.__styleString;if(B!=Z)m.fillStyle=B=Z;m.save();m.translate(P.x,P.y);m.rotate(-ea.rotation);m.scale($,S);m.beginPath();m.arc(0,0,1,0,J,true);m.closePath();m.fill();m.restore()}}}}function Ka(P,ea,$,S){if(S.opacity!=
  126. 0){a(S.opacity);c(S.blending);m.beginPath();m.moveTo(P.positionScreen.x,P.positionScreen.y);m.lineTo(ea.positionScreen.x,ea.positionScreen.y);m.closePath();if(S instanceof THREE.LineBasicMaterial){u.__styleString=S.color.__styleString;P=S.linewidth;if(H!=P)m.lineWidth=H=P;P=u.__styleString;if(z!=P)m.strokeStyle=z=P;m.stroke();K.inflate(S.linewidth*2)}}}function Ga(P,ea,$,S,Z,fa){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);L=P.positionScreen.x;l=P.positionScreen.y;A=ea.positionScreen.x;n=ea.positionScreen.y;
  127. j=$.positionScreen.x;x=$.positionScreen.y;m.beginPath();m.moveTo(L,l);m.lineTo(A,n);m.lineTo(j,x);m.lineTo(L,l);m.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Da(L,l,A,n,j,x,Z.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);else if(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=ra.matrix;N.copy(S.vertexNormalsWorld[0]);Q=(N.x*P.n11+N.y*
  128. 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(S.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(S.vertexNormalsWorld[2]);U=(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,l,A,n,j,x,Z.env_map.image,Q,O,ba,ca,U,R)}}else Z.wireframe?sa(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
  129. THREE.UVMapping&&Da(L,l,A,n,j,x,Z.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);c(THREE.SubtractiveBlending)}if(T)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&S.vertexNormalsWorld.length==3){E.r=C.r=p.r=ja.r;E.g=C.g=p.g=ja.g;E.b=C.b=p.b=ja.b;Aa(fa,S.v1.positionWorld,S.vertexNormalsWorld[0],E);Aa(fa,S.v2.positionWorld,S.vertexNormalsWorld[1],C);Aa(fa,S.v3.positionWorld,S.vertexNormalsWorld[2],p);F.r=(C.r+p.r)*0.5;F.g=(C.g+p.g)*0.5;F.b=(C.b+p.b)*0.5;W=Pa(E,C,p,F);
  130. Da(L,l,A,n,j,x,W,0,0,1,0,0,1)}else{aa.r=ja.r;aa.g=ja.g;aa.b=ja.b;Aa(fa,S.centroidWorld,S.normalWorld,aa);u.r=Z.color.r*aa.r;u.g=Z.color.g*aa.g;u.b=Z.color.b*aa.b;u.updateStyleString();Z.wireframe?sa(u.__styleString,Z.wireframe_linewidth):Ha(u.__styleString)}else Z.wireframe?sa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){M=ra.near;G=ra.far;E.r=E.g=E.b=1-La(P.positionScreen.z,M,G);C.r=C.g=C.b=1-La(ea.positionScreen.z,M,G);p.r=
  131. p.g=p.b=1-La($.positionScreen.z,M,G);F.r=(C.r+p.r)*0.5;F.g=(C.g+p.g)*0.5;F.b=(C.b+p.b)*0.5;W=Pa(E,C,p,F);Da(L,l,A,n,j,x,W,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){u.r=Ma(S.normalWorld.x);u.g=Ma(S.normalWorld.y);u.b=Ma(S.normalWorld.z);u.updateStyleString();Z.wireframe?sa(u.__styleString,Z.wireframe_linewidth):Ha(u.__styleString)}}}function sa(P,ea){if(z!=P)m.strokeStyle=z=P;if(H!=ea)m.lineWidth=H=ea;m.stroke();K.inflate(ea*2)}function Ha(P){if(B!=P)m.fillStyle=B=P;m.fill()}function Da(P,
  132. ea,$,S,Z,fa,ma,na,pa,xa,ua,ya,Ea){var Ba,za;Ba=ma.width-1;za=ma.height-1;na*=Ba;pa*=za;xa*=Ba;ua*=za;ya*=Ba;Ea*=za;$-=P;S-=ea;Z-=P;fa-=ea;xa-=na;ua-=pa;ya-=na;Ea-=pa;za=1/(xa*Ea-ya*ua);Ba=(Ea*$-ua*Z)*za;ua=(Ea*S-ua*fa)*za;$=(xa*Z-ya*$)*za;S=(xa*fa-ya*S)*za;P=P-Ba*na-$*pa;ea=ea-ua*na-S*pa;m.save();m.transform(Ba,ua,$,S,P,ea);m.clip();m.drawImage(ma,0,0);m.restore()}function Pa(P,ea,$,S){var Z=~~(P.r*255),fa=~~(P.g*255);P=~~(P.b*255);var ma=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);var pa=~~($.r*
  133. 255),xa=~~($.g*255);$=~~($.b*255);var ua=~~(S.r*255),ya=~~(S.g*255);S=~~(S.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]=xa<0?0:xa>255?255:xa;ia[10]=$<0?0:$>255?255:$;ia[12]=ua<0?0:ua>255?255:ua;ia[13]=ya<0?0:ya>255?255:ya;ia[14]=S<0?0:S>255?255:S;da.putImageData(ga,0,0);qa.drawImage(V,0,0);return ta}function La(P,ea,$){P=(P-ea)/($-ea);return P*P*(3-
  134. 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,S=ea.y-P.y,Z=1/Math.sqrt($*$+S*S);$*=Z;S*=Z;ea.x+=$;ea.y+=S;P.x-=$;P.y-=S}var Ia,Qa,la,wa,Ca,Oa,Ra,Fa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,h);d=e.projectScene(ka,ra,this.sortElements);(T=ka.lights.length>0)&&oa(ka);Ia=0;for(Qa=d.length;Ia<Qa;Ia++){la=d[Ia];K.empty();if(la instanceof THREE.RenderableParticle){w=la;w.x*=k;w.y*=h;wa=0;for(Ca=la.materials.length;wa<Ca;wa++)Ja(w,la,la.materials[wa],ka)}else if(la instanceof
  135. THREE.RenderableLine){w=la.v1;I=la.v2;w.positionScreen.x*=k;w.positionScreen.y*=h;I.positionScreen.x*=k;I.positionScreen.y*=h;K.addPoint(w.positionScreen.x,w.positionScreen.y);K.addPoint(I.positionScreen.x,I.positionScreen.y);if(X.instersects(K)){wa=0;for(Ca=la.materials.length;wa<Ca;)Ka(w,I,la,la.materials[wa++],ka)}}else if(la instanceof THREE.RenderableFace3){w=la.v1;I=la.v2;t=la.v3;w.positionScreen.x*=k;w.positionScreen.y*=h;I.positionScreen.x*=k;I.positionScreen.y*=h;t.positionScreen.x*=k;t.positionScreen.y*=
  136. h;if(la.overdraw){Na(w.positionScreen,I.positionScreen);Na(I.positionScreen,t.positionScreen);Na(t.positionScreen,w.positionScreen)}K.add3Points(w.positionScreen.x,w.positionScreen.y,I.positionScreen.x,I.positionScreen.y,t.positionScreen.x,t.positionScreen.y);if(X.instersects(K)){wa=0;for(Ca=la.meshMaterials.length;wa<Ca;){Fa=la.meshMaterials[wa++];if(Fa instanceof THREE.MeshFaceMaterial){Oa=0;for(Ra=la.faceMaterials.length;Oa<Ra;)(Fa=la.faceMaterials[Oa++])&&Ga(w,I,t,la,Fa,ka)}else Ga(w,I,t,la,Fa,
  137. ka)}}}Y.addRectangle(K)}m.setTransform(1,0,0,1,0,0)}};
  138. THREE.SVGRenderer=function(){function a(Q,O,ba){var ca,U,R,X;ca=0;for(U=Q.lights.length;ca<U;ca++){R=Q.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){x.sub(R.position,O.centroidWorld);x.normalize();X=O.normalWorld.dot(x)*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(Q,O,ba,ca,U,R){p=e(F++);p.setAttribute("d",
  139. "M "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(U instanceof THREE.MeshBasicMaterial)t.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshLambertMaterial)if(I){L.r=l.r;L.g=l.g;L.b=l.b;a(R,ca,L);t.r=U.color.r*L.r;t.g=U.color.g*L.g;t.b=U.color.b*L.b;t.updateStyleString()}else t.__styleString=U.color.__styleString;else if(U instanceof THREE.MeshDepthMaterial){j=1-U.__2near/(U.__farPlusNear-
  140. ca.z*U.__farMinusNear);t.setRGB(j,j,j)}else U instanceof THREE.MeshNormalMaterial&&t.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));U.wireframe?p.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+U.wireframe_linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.wireframe_linecap+"; stroke-linejoin: "+U.wireframe_linejoin):p.setAttribute("style","fill: "+t.__styleString+"; fill-opacity: "+U.opacity);k.appendChild(p)}function d(Q,O,ba,ca,U,
  141. R,X){p=e(F++);p.setAttribute("d","M "+Q.positionScreen.x+" "+Q.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)t.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(I){L.r=l.r;L.g=l.g;L.b=l.b;a(X,U,L);t.r=R.color.r*L.r;t.g=R.color.g*L.g;t.b=R.color.b*L.b;t.updateStyleString()}else t.__styleString=R.color.__styleString;
  142. else if(R instanceof THREE.MeshDepthMaterial){j=1-R.__2near/(R.__farPlusNear-U.z*R.__farMinusNear);t.setRGB(j,j,j)}else R instanceof THREE.MeshNormalMaterial&&t.setRGB(g(U.normalWorld.x),g(U.normalWorld.y),g(U.normalWorld.z));R.wireframe?p.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):p.setAttribute("style","fill: "+t.__styleString+
  143. "; fill-opacity: "+R.opacity);k.appendChild(p)}function e(Q){if(u[Q]==null){u[Q]=document.createElementNS("http://www.w3.org/2000/svg","path");W==0&&u[Q].setAttribute("shape-rendering","crispEdges");return u[Q]}return u[Q]}function g(Q){return Q<0?Math.min((1+Q)*0.5,0.5):0.5+Math.min(Q*0.5,0.5)}var f=null,b=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,m,o,y,v,q,z,B,H=new THREE.Rectangle,w=new THREE.Rectangle,I=false,t=new THREE.Color(16777215),L=new THREE.Color(16777215),
  144. l=new THREE.Color(0),A=new THREE.Color(0),n=new THREE.Color(0),j,x=new THREE.Vector3,u=[],E=[],C=[],p,F,M,G,W=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(Q){switch(Q){case "high":W=1;break;case "low":W=0}};this.setSize=function(Q,O){h=Q;m=O;o=h/2;y=m/2;k.setAttribute("viewBox",-o+" "+-y+" "+h+" "+m);k.setAttribute("width",h);k.setAttribute("height",m);H.set(-o,-y,o,y)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
  145. this.render=function(Q,O){var ba,ca,U,R,X,Y,K,T;this.autoClear&&this.clear();f=b.projectScene(Q,O,this.sortElements);G=M=F=0;if(I=Q.lights.length>0){K=Q.lights;l.setRGB(0,0,0);A.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(ca=K.length;ba<ca;ba++){U=K[ba];R=U.color;if(U instanceof THREE.AmbientLight){l.r+=R.r;l.g+=R.g;l.b+=R.b}else if(U instanceof THREE.DirectionalLight){A.r+=R.r;A.g+=R.g;A.b+=R.b}else if(U instanceof THREE.PointLight){n.r+=R.r;n.g+=R.g;n.b+=R.b}}}ba=0;for(ca=f.length;ba<ca;ba++){K=f[ba];
  146. w.empty();if(K instanceof THREE.RenderableParticle){v=K;v.x*=o;v.y*=-y;U=0;for(R=K.materials.length;U<R;U++)if(T=K.materials[U]){X=v;Y=K;T=T;var aa=M++;if(E[aa]==null){E[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");W==0&&E[aa].setAttribute("shape-rendering","crispEdges")}p=E[aa];p.setAttribute("cx",X.x);p.setAttribute("cy",X.y);p.setAttribute("r",Y.scale.x*o);if(T instanceof THREE.ParticleCircleMaterial){if(I){L.r=l.r+A.r+n.r;L.g=l.g+A.g+n.g;L.b=l.b+A.b+n.b;t.r=T.color.r*L.r;
  147. t.g=T.color.g*L.g;t.b=T.color.b*L.b;t.updateStyleString()}else t=T.color;p.setAttribute("style","fill: "+t.__styleString)}k.appendChild(p)}}else if(K instanceof THREE.RenderableLine){v=K.v1;q=K.v2;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(w)){U=0;for(R=K.materials.length;U<R;)if(T=K.materials[U++]){X=v;Y=q;T=T;aa=G++;if(C[aa]==null){C[aa]=
  148. document.createElementNS("http://www.w3.org/2000/svg","line");W==0&&C[aa].setAttribute("shape-rendering","crispEdges")}p=C[aa];p.setAttribute("x1",X.positionScreen.x);p.setAttribute("y1",X.positionScreen.y);p.setAttribute("x2",Y.positionScreen.x);p.setAttribute("y2",Y.positionScreen.y);if(T instanceof THREE.LineBasicMaterial){t.__styleString=T.color.__styleString;p.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+
  149. T.linecap+"; stroke-linejoin: "+T.linejoin);k.appendChild(p)}}}}else if(K instanceof THREE.RenderableFace3){v=K.v1;q=K.v2;z=K.v3;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(w)){U=0;for(R=K.meshMaterials.length;U<R;){T=K.meshMaterials[U++];if(T instanceof
  150. THREE.MeshFaceMaterial){X=0;for(Y=K.faceMaterials.length;X<Y;)(T=K.faceMaterials[X++])&&c(v,q,z,K,T,Q)}else T&&c(v,q,z,K,T,Q)}}}else if(K instanceof THREE.RenderableFace4){v=K.v1;q=K.v2;z=K.v3;B=K.v4;v.positionScreen.x*=o;v.positionScreen.y*=-y;q.positionScreen.x*=o;q.positionScreen.y*=-y;z.positionScreen.x*=o;z.positionScreen.y*=-y;B.positionScreen.x*=o;B.positionScreen.y*=-y;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(q.positionScreen.x,q.positionScreen.y);w.addPoint(z.positionScreen.x,
  151. z.positionScreen.y);w.addPoint(B.positionScreen.x,B.positionScreen.y);if(H.instersects(w)){U=0;for(R=K.meshMaterials.length;U<R;){T=K.meshMaterials[U++];if(T instanceof THREE.MeshFaceMaterial){X=0;for(Y=K.faceMaterials.length;X<Y;)(T=K.faceMaterials[X++])&&d(v,q,z,B,K,T,Q)}else T&&d(v,q,z,B,K,T,Q)}}}}}};
  152. THREE.WebGLRenderer=function(a){function c(l,A){l.fragment_shader=A.fragment_shader;l.vertex_shader=A.vertex_shader;l.uniforms=Uniforms.clone(A.uniforms)}function d(l){if(l.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);l.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}function e(l,A){var n;if(l=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(l=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,A);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));
  153. return null}return n}function g(l){switch(l){case THREE.RepeatWrapping:return b.REPEAT;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;
  154. case THREE.ByteType:return b.BYTE;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}
  155. var f=document.createElement("canvas"),b,k=null,h=null,m=new THREE.Matrix4,o,y=new Float32Array(16),v=new Float32Array(16),q=new Float32Array(16),z=new Float32Array(9),B=new Float32Array(16),H=new THREE.Matrix4,w=new THREE.Vector4,I=true,t=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)I=a.antialias;a.clearColor!==undefined&&t.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(l,A,n){try{b=f.getContext("experimental-webgl",{antialias:l})}catch(j){console.log(j)}if(!b){alert("WebGL not supported");
  156. 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(A.r,A.g,A.b,n)})(I,t,L);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,A){f.width=l;f.height=A;b.viewport(0,0,f.width,f.height)};this.setClearColorHex=
  157. function(l,A){var n=new THREE.Color(l);b.clearColor(n.r,n.g,n.b,A)};this.setClearColor=function(l,A){b.clearColor(l.r,l.g,l.b,A)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,A){var n,j,x,u=0,E=0,C=0,p,F,M,G=this.lights,W=G.directional.colors,Q=G.directional.positions,O=G.point.colors,ba=G.point.positions,ca=0,U=0;n=x=x=0;for(j=A.length;n<j;n++){x=A[n];p=x.color;F=x.position;M=x.intensity;if(x instanceof THREE.AmbientLight){u+=p.r;E+=p.g;C+=p.b}else if(x instanceof
  158. THREE.DirectionalLight){x=ca*3;W[x]=p.r*M;W[x+1]=p.g*M;W[x+2]=p.b*M;Q[x]=F.x;Q[x+1]=F.y;Q[x+2]=F.z;ca+=1}else if(x instanceof THREE.PointLight){x=U*3;O[x]=p.r*M;O[x+1]=p.g*M;O[x+2]=p.b*M;ba[x]=F.x;ba[x+1]=F.y;ba[x+2]=F.z;U+=1}}for(n=ca*3;n<W.length;n++)W[n]=0;for(n=U*3;n<O.length;n++)O[n]=0;G.point.length=U;G.directional.length=ca;G.ambient[0]=u;G.ambient[1]=E;G.ambient[2]=C};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer();l.__webGLParticleBuffer=
  159. b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};
  160. this.initLineBuffers=function(l){var A=l.vertices.length;l.__vertexArray=new Float32Array(A*3);l.__colorArray=new Float32Array(A*3);l.__lineArray=new Uint16Array(A);l.__webGLLineCount=A};this.initParticleBuffers=function(l){var A=l.vertices.length;l.__vertexArray=new Float32Array(A*3);l.__colorArray=new Float32Array(A*3);l.__particleArray=new Uint16Array(A);l.__sortArray=[];l.__webGLParticleCount=A};this.initMeshBuffers=function(l,A){var n,j,x=0,u=0,E=0,C=A.geometry.faces,p=l.faces;n=0;for(j=p.length;n<
  161. j;n++){fi=p[n];face=C[fi];if(face instanceof THREE.Face3){x+=3;u+=1;E+=3}else if(face instanceof THREE.Face4){x+=4;u+=2;E+=4}}l.__vertexArray=new Float32Array(x*3);l.__normalArray=new Float32Array(x*3);l.__tangentArray=new Float32Array(x*4);l.__colorArray=new Float32Array(x*3);l.__uvArray=new Float32Array(x*2);l.__uv2Array=new Float32Array(x*2);l.__faceArray=new Uint16Array(u*3);l.__lineArray=new Uint16Array(E*2);x=false;n=0;for(j=A.materials.length;n<j;n++){C=A.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=
  162. 0;for(p=l.materials.length;C<p;C++)if(l.materials[C]&&l.materials[C].shading!=undefined&&l.materials[C].shading==THREE.SmoothShading){x=true;break}}else if(C&&C.shading!=undefined&&C.shading==THREE.SmoothShading){x=true;break}if(x)break}l.__needsSmoothNormals=x;l.__webGLFaceCount=u*3;l.__webGLLineCount=E*2};this.setMeshBuffers=function(l,A,n){var j,x,u,E,C,p,F,M,G,W,Q=0,O=0,ba=0,ca=0,U=0,R=0,X=0,Y=0,K=0,T=l.__vertexArray,aa=l.__uvArray,ja=l.__uv2Array,ha=l.__normalArray,D=l.__tangentArray,J=l.__colorArray,
  163. N=l.__faceArray,V=l.__lineArray,da=l.__needsSmoothNormals,ga=A.geometry,ia=ga.__dirtyVertices,ta=ga.__dirtyElements,qa=ga.__dirtyUvs,va=ga.__dirtyNormals,ka=ga.__dirtyTangents,ra=ga.__dirtyColors,oa=ga.vertices,Aa=l.faces,Ja=ga.faces,Ka=ga.uvs,Ga=ga.uvs2,sa=ga.colors;A=0;for(j=Aa.length;A<j;A++){x=Aa[A];u=Ja[x];p=Ka[x];x=Ga[x];E=u.vertexNormals;C=u.normal;if(u instanceof THREE.Face3){if(ia){F=oa[u.a].position;M=oa[u.b].position;G=oa[u.c].position;T[O]=F.x;T[O+1]=F.y;T[O+2]=F.z;T[O+3]=M.x;T[O+4]=M.y;
  164. T[O+5]=M.z;T[O+6]=G.x;T[O+7]=G.y;T[O+8]=G.z;O+=9}if(ra&&sa.length){F=sa[u.a];M=sa[u.b];G=sa[u.c];J[K]=F.r;J[K+1]=F.g;J[K+2]=F.b;J[K+3]=M.r;J[K+4]=M.g;J[K+5]=M.b;J[K+6]=G.r;J[K+7]=G.g;J[K+8]=G.b;K+=9}if(ka&&ga.hasTangents){F=oa[u.a].tangent;M=oa[u.b].tangent;G=oa[u.c].tangent;D[X]=F.x;D[X+1]=F.y;D[X+2]=F.z;D[X+3]=F.w;D[X+4]=M.x;D[X+5]=M.y;D[X+6]=M.z;D[X+7]=M.w;D[X+8]=G.x;D[X+9]=G.y;D[X+10]=G.z;D[X+11]=G.w;X+=12}if(va)if(E.length==3&&da)for(u=0;u<3;u++){C=E[u];ha[R]=C.x;ha[R+1]=C.y;ha[R+2]=C.z;R+=3}else for(u=
  165. 0;u<3;u++){ha[R]=C.x;ha[R+1]=C.y;ha[R+2]=C.z;R+=3}if(qa&&p)for(u=0;u<3;u++){E=p[u];aa[ba]=E.u;aa[ba+1]=E.v;ba+=2}if(qa&&x)for(u=0;u<3;u++){p=x[u];ja[ca]=p.u;ja[ca+1]=p.v;ca+=2}if(ta){N[U]=Q;N[U+1]=Q+1;N[U+2]=Q+2;U+=3;V[Y]=Q;V[Y+1]=Q+1;V[Y+2]=Q;V[Y+3]=Q+2;V[Y+4]=Q+1;V[Y+5]=Q+2;Y+=6;Q+=3}}else if(u instanceof THREE.Face4){if(ia){F=oa[u.a].position;M=oa[u.b].position;G=oa[u.c].position;W=oa[u.d].position;T[O]=F.x;T[O+1]=F.y;T[O+2]=F.z;T[O+3]=M.x;T[O+4]=M.y;T[O+5]=M.z;T[O+6]=G.x;T[O+7]=G.y;T[O+8]=G.z;
  166. T[O+9]=W.x;T[O+10]=W.y;T[O+11]=W.z;O+=12}if(ra&&sa.length){F=sa[u.a];M=sa[u.b];G=sa[u.d];J[K]=F.r;J[K+1]=F.g;J[K+2]=F.b;J[K+3]=M.r;J[K+4]=M.g;J[K+5]=M.b;J[K+6]=G.r;J[K+7]=G.g;J[K+8]=G.b;J[K+9]=(void 0).r;J[K+10]=(void 0).g;J[K+11]=(void 0).b;K+=12}if(ka&&ga.hasTangents){F=oa[u.a].tangent;M=oa[u.b].tangent;G=oa[u.c].tangent;u=oa[u.d].tangent;D[X]=F.x;D[X+1]=F.y;D[X+2]=F.z;D[X+3]=F.w;D[X+4]=M.x;D[X+5]=M.y;D[X+6]=M.z;D[X+7]=M.w;D[X+8]=G.x;D[X+9]=G.y;D[X+10]=G.z;D[X+11]=G.w;D[X+12]=u.x;D[X+13]=u.y;D[X+
  167. 14]=u.z;D[X+15]=u.w;X+=16}if(va)if(E.length==4&&da)for(u=0;u<4;u++){C=E[u];ha[R]=C.x;ha[R+1]=C.y;ha[R+2]=C.z;R+=3}else for(u=0;u<4;u++){ha[R]=C.x;ha[R+1]=C.y;ha[R+2]=C.z;R+=3}if(qa&&p)for(u=0;u<4;u++){E=p[u];aa[ba]=E.u;aa[ba+1]=E.v;ba+=2}if(qa&&x)for(u=0;u<4;u++){p=x[u];ja[ca]=p.u;ja[ca+1]=p.v;ca+=2}if(ta){N[U]=Q;N[U+1]=Q+1;N[U+2]=Q+2;N[U+3]=Q;N[U+4]=Q+2;N[U+5]=Q+3;U+=6;V[Y]=Q;V[Y+1]=Q+1;V[Y+2]=Q;V[Y+3]=Q+3;V[Y+4]=Q+1;V[Y+5]=Q+2;V[Y+6]=Q+2;V[Y+7]=Q+3;Y+=8;Q+=4}}}if(ia){b.bindBuffer(b.ARRAY_BUFFER,
  168. l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,T,n)}if(ra&&sa.length){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,J,n)}if(va){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,n)}if(ka&&ga.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,D,n)}if(qa&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,aa,n)}if(qa&&ca>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);
  169. b.bufferData(b.ARRAY_BUFFER,ja,n)}if(ta){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,V,n)}};this.setLineBuffers=function(l,A){var n,j,x,u=l.vertices,E=l.colors,C=u.length,p=E.length,F=l.__vertexArray,M=l.__colorArray,G=l.__lineArray,W=l.__dirtyColors,Q=l.__dirtyElements;if(l.__dirtyVertices){for(n=0;n<C;n++){j=u[n].position;x=n*3;F[x]=j.x;F[x+1]=j.y;F[x+
  170. 2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,A)}if(W){for(n=0;n<p;n++){color=E[n];x=n*3;M[x]=color.r;M[x+1]=color.g;M[x+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,M,A)}if(Q){for(n=0;n<C;n++)G[n]=n;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,G,A)}};this.setParticleBuffers=function(l,A,n,j){var x,u,E;u=l.vertices;var C=u.length,p=l.colors,F=p.length,M=l.__vertexArray,
  171. G=l.__particleArray,W=l.__colorArray,Q=l.__sortArray,O=l.__dirtyVertices,ba=l.__dirtyElements,ca=l.__dirtyColors;if(n.sortParticles){H.multiply(j.projectionMatrix,j.matrix);H.multiplySelf(n.matrix);for(x=0;x<C;x++){E=u[x].position;w.copy(E);H.multiplyVector3(w);Q[x]=[w.z,x]}Q.sort(function(U,R){return R[0]-U[0]});for(x=0;x<C;x++){E=u[Q[x][1]].position;j=x*3;M[j]=E.x;M[j+1]=E.y;M[j+2]=E.z}for(u=0;u<F;u++){j=u*3;color=p[Q[u][1]];W[j]=color.r;W[j+1]=color.g;W[j+2]=color.b}}else{if(O)for(x=0;x<C;x++){E=
  172. u[x].position;j=x*3;M[j]=E.x;M[j+1]=E.y;M[j+2]=E.z}if(ca)for(u=0;u<F;u++){color=p[u];j=u*3;W[j]=color.r;W[j+1]=color.g;W[j+2]=color.b}}if(ba){for(x=0;x<C;x++)G[x]=x;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,G,A)}if(O||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,M,A)}if(ca||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,W,A)}};this.initMaterial=
  173. function(l,A,n){if(!l.program){var j,x;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&
  174. c(l,THREE.ShaderLib.particle_basic);var u,E,C,p;x=C=p=0;for(u=A.length;x<u;x++){E=A[x];E instanceof THREE.DirectionalLight&&C++;E instanceof THREE.PointLight&&p++}if(p+C<=4){A=C;p=p}else{A=Math.ceil(4*C/(p+C));p=4-A}x={directional:A,point:p};p=l.fragment_shader;A=l.vertex_shader;u={fog:n,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:x.directional,maxPointLights:x.point};n=b.createProgram();x=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
  175. u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.fog?"#define USE_FOG":"",u.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",u.map?"#define USE_MAP":"",u.env_map?"#define USE_ENVMAP":"",u.light_map?"#define USE_LIGHTMAP":"",u.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");u=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+
  176. u.maxPointLights,u.map?"#define USE_MAP":"",u.env_map?"#define USE_ENVMAP":"",u.light_map?"#define USE_LIGHTMAP":"",u.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,e("fragment",x+p));b.attachShader(n,
  177. e("vertex",u+A));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={};l.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in l.uniforms)n.push(j);j=l.program;p=0;for(A=n.length;p<A;p++){x=n[p];j.uniforms[x]=b.getUniformLocation(j,x)}l=l.program;j=["position","normal",
  178. "uv","uv2","tangent","color"];n=0;for(p=j.length;n<p;n++){A=j[n];l.attributes[A]=b.getAttribLocation(l,A)}}};this.setProgram=function(l,A,n,j){this.initMaterial(j,A,n);var x=j.program;if(x!=k){b.useProgram(x);k=x}this.loadCamera(x,l);this.loadMatrices(x);if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(x,A);A=this.lights;j.uniforms.enableLighting.value=A.directional.length+A.point.length;j.uniforms.ambientLightColor.value=A.ambient;j.uniforms.directionalLightColor.value=
  179. A.directional.colors;j.uniforms.directionalLightDirection.value=A.directional.positions;j.uniforms.pointLightColor.value=A.point.colors;j.uniforms.pointLightPosition.value=A.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){j.uniforms.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;j.uniforms.map.texture=j.map;j.uniforms.light_map.texture=j.light_map;
  180. j.uniforms.env_map.texture=j.env_map;j.uniforms.reflectivity.value=j.reflectivity;j.uniforms.refraction_ratio.value=j.refraction_ratio;j.uniforms.combine.value=j.combine;j.uniforms.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping;if(n){j.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){j.uniforms.fogNear.value=n.near;j.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)j.uniforms.fogDensity.value=n.density}}if(j instanceof THREE.LineBasicMaterial){j.uniforms.diffuse.value.setRGB(j.color.r*
  181. j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;if(n){j.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){j.uniforms.fogNear.value=n.near;j.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)j.uniforms.fogDensity.value=n.density}}if(j instanceof THREE.ParticleBasicMaterial){j.uniforms.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);j.uniforms.opacity.value=j.opacity;j.uniforms.size.value=j.size;
  182. j.uniforms.map.texture=j.map;if(n){j.uniforms.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){j.uniforms.fogNear.value=n.near;j.uniforms.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)j.uniforms.fogDensity.value=n.density}}if(j instanceof THREE.MeshPhongMaterial){j.uniforms.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);j.uniforms.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);j.uniforms.shininess.value=j.shininess}if(j instanceof THREE.MeshDepthMaterial){j.uniforms.mNear.value=
  183. l.near;j.uniforms.mFar.value=l.far;j.uniforms.opacity.value=j.opacity}if(j instanceof THREE.MeshNormalMaterial)j.uniforms.opacity.value=j.opacity;l=j.uniforms;var u,E;for(u in l)if(E=x.uniforms[u]){j=l[u];A=j.type;n=j.value;if(A=="i")b.uniform1i(E,n);else if(A=="f")b.uniform1f(E,n);else if(A=="fv1")b.uniform1fv(E,n);else if(A=="fv")b.uniform3fv(E,n);else if(A=="v2")b.uniform2f(E,n.x,n.y);else if(A=="v3")b.uniform3f(E,n.x,n.y,n.z);else if(A=="c")b.uniform3f(E,n.r,n.g,n.b);else if(A=="t"){b.uniform1i(E,
  184. n);if(j=j.texture)if(j.image instanceof Array&&j.image.length==6){j=j;n=n;if(j.image.length==6){if(!j.image.__webGLTextureCube&&!j.image.__cubeMapInitialized&&j.image.loadCount==6){j.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,j.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,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,
  185. b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(A=0;A<6;++A)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image[A]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);j.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_CUBE_MAP,j.image.__webGLTextureCube)}}else{j=j;n=n;if(!j.__webGLTexture&&j.image.loaded){j.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,j.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
  186. 0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,j.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,g(j.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g(j.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,g(j.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,g(j.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_2D,j.__webGLTexture)}}}return x};this.renderBuffer=function(l,A,n,j,x,u){l=this.setProgram(l,
  187. A,n,j,u).attributes;b.bindBuffer(b.ARRAY_BUFFER,x.__webGLVertexBuffer);b.vertexAttribPointer(l.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.position);if(l.color>=0){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLColorBuffer);b.vertexAttribPointer(l.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.color)}if(l.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLNormalBuffer);b.vertexAttribPointer(l.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.normal)}if(l.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,
  188. x.__webGLTangentBuffer);b.vertexAttribPointer(l.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(x.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLUVBuffer);b.vertexAttribPointer(l.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.uv)}else b.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(x.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,x.__webGLUV2Buffer);b.vertexAttribPointer(l.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.uv2)}else b.disableVertexAttribArray(l.uv2);
  189. if(j.wireframe||j instanceof THREE.LineBasicMaterial){l=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:j.linewidth!==undefined?j.linewidth:1;j=j instanceof THREE.LineBasicMaterial&&u.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(l);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);b.drawElements(j,x.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(j instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,x.__webGLParticleBuffer);b.drawElements(b.POINTS,x.__webGLParticleCount,
  190. b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,x.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(l,A,n,j,x,u,E){var C,p,F,M,G;F=0;for(M=j.materials.length;F<M;F++){C=j.materials[F];if(C instanceof THREE.MeshFaceMaterial){C=0;for(p=x.materials.length;C<p;C++)if((G=x.materials[C])&&G.blending==u&&G.opacity<1==E){this.setBlending(G.blending);this.setDepthTest(G.depth_test);this.renderBuffer(l,A,n,G,x,j)}}else if((G=C)&&G.blending==
  191. u&&G.opacity<1==E){this.setBlending(G.blending);this.setDepthTest(G.depth_test);this.renderBuffer(l,A,n,G,x,j)}}};this.renderPassImmediate=function(l,A,n,j,x,u){var E,C,p,F;E=0;for(C=j.materials.length;E<C;E++)if((p=j.materials[E])&&p.blending==x&&p.opacity<1==u){this.setBlending(p.blending);this.setDepthTest(p.depth_test);F=this.setProgram(l,A,n,p,j);j.render(function(M){var G=F;if(!M.__webGLVertexBuffer)M.__webGLVertexBuffer=b.createBuffer();if(!M.__webGLNormalBuffer)M.__webGLNormalBuffer=b.createBuffer();
  192. if(M.hasPos){b.bindBuffer(b.ARRAY_BUFFER,M.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,M.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(G.attributes.position);b.vertexAttribPointer(G.attributes.position,3,b.FLOAT,false,0,0)}if(M.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,M.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,M.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,M.count);
  193. M.count=0})}};this.render=function(l,A,n,j){var x,u,E,C,p=l.lights,F=l.fog;A.autoUpdateMatrix&&A.updateMatrix();y.set(A.matrix.flatten());q.set(A.projectionMatrix.flatten());this.initWebGLObjects(l,A);j=j!==undefined?j: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);
  194. b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,g(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,g(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,g(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,g(n.format),n.width,n.height,0,g(n.format),g(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,
  195. n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){x=n.__webGLFramebuffer;C=n.width;u=n.height}else{x=null;C=f.width;u=f.height}if(x!=h){b.bindFramebuffer(b.FRAMEBUFFER,x);b.viewport(0,0,C,u);j&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);h=x}this.autoClear&&this.clear();x=l.__webGLObjects.length;for(j=0;j<x;j++){E=
  196. l.__webGLObjects[j];C=E.object;C.visible&&C.autoUpdateMatrix&&C.updateMatrix()}u=l.__webGLObjectsImmediate.length;for(j=0;j<u;j++){E=l.__webGLObjectsImmediate[j];C=E.object;C.visible&&C.autoUpdateMatrix&&C.updateMatrix()}for(j=0;j<x;j++){E=l.__webGLObjects[j];C=E.object;u=E.buffer;if(C.visible){d(C);this.setupMatrices(C,A);this.renderPass(A,p,F,C,u,THREE.NormalBlending,false)}}for(j=0;j<l.__webGLObjectsImmediate.length;j++){E=l.__webGLObjectsImmediate[j];C=E.object;if(C.visible){d(C);this.setupMatrices(C,
  197. A);this.renderPassImmediate(A,p,F,C,THREE.NormalBlending,false)}}for(j=0;j<x;j++){E=l.__webGLObjects[j];C=E.object;u=E.buffer;if(C.visible){d(C);this.setupMatrices(C,A);this.renderPass(A,p,F,C,u,THREE.AdditiveBlending,false);this.renderPass(A,p,F,C,u,THREE.SubtractiveBlending,false);this.renderPass(A,p,F,C,u,THREE.AdditiveBlending,true);this.renderPass(A,p,F,C,u,THREE.SubtractiveBlending,true);this.renderPass(A,p,F,C,u,THREE.NormalBlending,true);this.renderPass(A,p,F,C,u,THREE.BillboardBlending,false)}}for(j=
  198. 0;j<l.__webGLObjectsImmediate.length;j++){E=l.__webGLObjectsImmediate[j];C=E.object;if(C.visible){d(C);this.setupMatrices(C,A);this.renderPassImmediate(A,p,F,C,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=function(l,A){function n(G,W,Q,O){if(G[W]==undefined){l.__webGLObjects.push({buffer:Q,object:O});G[W]=1}}
  199. function j(G,W,Q){if(G[W]==undefined){l.__webGLObjectsImmediate.push({object:Q});G[W]=1}}var x,u,E,C,p,F,M;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}x=0;for(u=l.objects.length;x<u;x++){E=l.objects[x];p=E.geometry;if(l.__webGLObjectsMap[E.id]==undefined)l.__webGLObjectsMap[E.id]={};M=l.__webGLObjectsMap[E.id];if(E instanceof THREE.Mesh){for(C in p.geometryChunks){F=p.geometryChunks[C];if(!F.__webGLVertexBuffer){this.createMeshBuffers(F);this.initMeshBuffers(F,
  200. E);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true;p.__dirtyColors=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs||p.__dirtyNormals||p.__dirtyColors||p.__dirtyTangents)this.setMeshBuffers(F,E,b.DYNAMIC_DRAW);n(M,C,F,E)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false;p.__dirtyColors=false}else if(E instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);
  201. this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyColors=true}if(p.__dirtyVertices||p.__dirtyColors)this.setLineBuffers(p,b.DYNAMIC_DRAW);n(M,0,p,E);p.__dirtyVertices=false;p.__dirtyElements=false}else if(E instanceof THREE.ParticleSystem){if(!p.__webGLVertexBuffer){this.createParticleBuffers(p);this.initParticleBuffers(p);p.__dirtyVertices=true;p.__dirtyColors=true;p.__dirtyElements=true}if(p.__dirtyVertices||p.__dirtyColors||E.sortParticles)this.setParticleBuffers(p,
  202. b.DYNAMIC_DRAW,E,A);n(M,0,p,E);p.__dirtyVertices=false;p.__dirtyColors=false;p.__dirtyElements=false}else E instanceof THREE.MarchingCubes&&j(M,0,E)}};this.removeObject=function(l,A){var n,j;for(n=l.__webGLObjects.length-1;n>=0;n--){j=l.__webGLObjects[n].object;A==j&&l.__webGLObjects.splice(n,1)}};this.setupMatrices=function(l,A){m.multiply(A.matrix,l.matrix);v.set(m.flatten());o=THREE.Matrix4.makeInvert3x3(m).transpose();z.set(o.m);B.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,
  203. false,y);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,false,v);b.uniformMatrix4fv(l.uniforms.projectionMatrix,false,q);b.uniformMatrix3fv(l.uniforms.normalMatrix,false,z);b.uniformMatrix4fv(l.uniforms.objectMatrix,false,B)};this.loadCamera=function(l,A){b.uniform3f(l.uniforms.cameraPosition,A.position.x,A.position.y,A.position.z)};this.setDepthTest=function(l){l?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setBlending=function(l){switch(l){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);
  204. b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,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)}};this.setFaceCulling=function(l,A){if(l){!A||A=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(l=="back")b.cullFace(b.BACK);else l=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};
  205. this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  206. 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",
  207. 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",
  208. 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",
  209. 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",
  210. 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}",
  211. 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;",
  212. 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"};
  213. 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",
  214. 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)}}};
  215. 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",
  216. 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,
  217. 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,
  218. "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,
  219. 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,
  220. 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,
  221. 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,
  222. 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,
  223. 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,
  224. "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,
  225. "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};
  226. 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};
  227. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
  228. var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,g=d?c.geometry:c,f=a.vertices,b=g.vertices,k=a.faces,h=g.faces,m=a.uvs;g=g.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var o=0,y=b.length;o<y;o++){var v=new THREE.Vertex(b[o].position.clone());d&&c.matrix.multiplyVector3(v.position);f.push(v)}o=0;for(y=h.length;o<y;o++){b=h[o];var q,z=b.vertexNormals;if(b instanceof THREE.Face3)q=new THREE.Face3(b.a+e,b.b+e,b.c+e);else if(b instanceof THREE.Face4)q=new THREE.Face4(b.a+
  229. e,b.b+e,b.c+e,b.d+e);q.centroid.copy(b.centroid);q.normal.copy(b.normal);d=0;for(f=z.length;d<f;d++){v=z[d];q.vertexNormals.push(v.clone())}q.materials=b.materials.slice();k.push(q)}o=0;for(y=g.length;o<y;o++){e=g[o];k=[];d=0;for(f=e.length;d<f;d++)k.push(new THREE.UV(e[d].u,e[d].v));m.push(k)}}},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=
  230. 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(o in n.objects)if(!p.objects[o]){B=n.objects[o];if(t=p.geometries[B.geometry]){A=[];for(i=0;i<B.materials.length;i++)A[i]=p.materials[B.materials[i]];H=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(t,A);object.position.set(H[0],H[1],H[2]);
  231. object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;p.scene.addObject(object);p.objects[o]=object}}}function b(F){return function(M){p.geometries[F]=M;f();x-=1;k()}}function k(){e({total_models:E,total_textures:C,loaded_models:E-x,loaded_textures:C-u},p);x==0&&u==0&&d(p)}var h,m,o,y,v,q,z,B,H,w,I,t,L,l,A,n,j,x,u,E,C,p;n=g.data;j=new THREE.Loader;u=x=0;p={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
  232. g=function(){u-=1;k()};for(v in n.cameras){w=n.cameras[v];if(w.type=="perspective")L=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){L=new THREE.Camera;L.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}H=w.position;w=w.target;L.position.set(H[0],H[1],H[2]);L.target.position.set(w[0],w[1],w[2]);p.cameras[v]=L}for(y in n.lights){v=n.lights[y];if(v.type=="directional"){H=v.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
  233. H[2]);light.position.normalize()}else if(v.type=="point"){H=v.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}w=v.color;i=v.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);p.scene.addLight(light);p.lights[y]=light}for(q in n.fogs){y=n.fogs[q];if(y.type=="linear")l=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")l=new THREE.FogExp2(0,y.density);w=y.color;l.color.setRGB(w[0],w[1],w[2]);p.fogs[q]=l}if(p.cameras&&n.defaults.camera)p.currentCamera=p.cameras[n.defaults.camera];
  234. if(p.fogs&&n.defaults.fog)p.scene.fog=p.fogs[n.defaults.fog];w=n.defaults.bgcolor;p.bgColor=new THREE.Color;p.bgColor.setRGB(w[0],w[1],w[2]);p.bgColorAlpha=n.defaults.bgalpha;for(h in n.geometries){q=n.geometries[h];if(q.type=="bin_mesh"||q.type=="ascii_mesh")x+=1}E=x;for(h in n.geometries){q=n.geometries[h];if(q.type=="cube"){t=new Cube(q.width,q.height,q.depth,q.segments_width,q.segments_height,null,q.flipped,q.sides);p.geometries[h]=t}else if(q.type=="plane"){t=new Plane(q.width,q.height,q.segments_width,
  235. q.segments_height);p.geometries[h]=t}else if(q.type=="sphere"){t=new Sphere(q.radius,q.segments_width,q.segments_height);p.geometries[h]=t}else if(q.type=="cylinder"){t=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);p.geometries[h]=t}else if(q.type=="torus"){t=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);p.geometries[h]=t}else if(q.type=="icosahedron"){t=new Icosahedron(q.subdivisions);p.geometries[h]=t}else if(q.type=="bin_mesh")j.loadBinary({model:q.url,callback:b(h)});
  236. else q.type=="ascii_mesh"&&j.loadAscii({model:q.url,callback:b(h)})}for(z in n.textures){h=n.textures[z];u+=h.url instanceof Array?h.url.length:1}C=u;for(z in n.textures){h=n.textures[z];if(h.mapping!=undefined&&THREE[h.mapping]!=undefined)h.mapping=new THREE[h.mapping];if(h.url instanceof Array){q=ImageUtils.loadArray(h.url,g);q=new THREE.Texture(q,h.mapping)}else{q=ImageUtils.loadTexture(h.url,h.mapping,g);if(THREE[h.min_filter]!=undefined)q.min_filter=THREE[h.min_filter];if(THREE[h.mag_filter]!=
  237. undefined)q.mag_filter=THREE[h.mag_filter]}p.textures[z]=q}for(m in n.materials){z=n.materials[m];for(I in z.parameters)if(I=="env_map"||I=="map"||I=="light_map")z.parameters[I]=p.textures[z.parameters[I]];else if(I=="shading")z.parameters[I]=z.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")z.parameters[I]=THREE[z.parameters[I]]?THREE[z.parameters[I]]:THREE.NormalBlending;else if(I=="combine")z.parameters[I]=z.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
  238. z=new THREE[z.type](z.parameters);p.materials[m]=z}f();c(p)}},addMesh:function(a,c,d,e,g,f,b,k,h,m){c=new THREE.Mesh(c,m);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=b;c.rotation.y=k;c.rotation.z=h;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,
  239. 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,
  240. 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])}));
  241. 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}",
  242. 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}"},
  243. 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},
  244. 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}",
  245. 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}"},
  246. 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",
  247. 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}"},
  248. 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}"},
  249. 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}",
  250. 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,b,k){function h(B,H,w,I,t,L,l,A){var n,j,x=e||1,u=g||1,E=x+1,C=u+1,p=t/2,F=L/2;t=t/x;var M=L/u,G=m.vertices.length;if(B=="x"&&H=="y"||B=="y"&&H=="x")n="z";else if(B=="x"&&H=="z"||B=="z"&&H=="x")n="y";else if(B==
  251. "z"&&H=="y"||B=="y"&&H=="z")n="x";for(j=0;j<C;j++)for(L=0;L<E;L++){var W=new THREE.Vector3;W[B]=(L*t-p)*w;W[H]=(j*M-F)*I;W[n]=l;m.vertices.push(new THREE.Vertex(W))}for(j=0;j<u;j++)for(L=0;L<x;L++){m.faces.push(new THREE.Face4(L+E*j+G,L+E*(j+1)+G,L+1+E*(j+1)+G,L+1+E*j+G,null,A));m.uvs.push([new THREE.UV(L/x,j/u),new THREE.UV(L/x,(j+1)/u),new THREE.UV((L+1)/x,(j+1)/u),new THREE.UV((L+1)/x,j/u)])}}THREE.Geometry.call(this);var m=this,o=a/2,y=c/2,v=d/2;b=b?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=
  252. f;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(k!=undefined)for(var z in k)if(this.sides[z]!=undefined)this.sides[z]=k[z];this.sides.px&&h("z","y",1*b,-1,d,c,-o,this.materials[0]);this.sides.nx&&h("z","y",-1*b,-1,d,c,o,this.materials[1]);this.sides.py&&h("x","z",1*b,1,a,d,y,this.materials[2]);this.sides.ny&&h("x","z",1*b,-1,a,d,-y,this.materials[3]);this.sides.pz&&h("x","y",1*b,-1,a,c,v,this.materials[4]);
  253. this.sides.nz&&h("x","y",-1*b,-1,a,c,-v,this.materials[5]);(function(){for(var B=[],H=[],w=0,I=m.vertices.length;w<I;w++){for(var t=m.vertices[w],L=false,l=0,A=B.length;l<A;l++){var n=B[l];if(t.position.x==n.position.x&&t.position.y==n.position.y&&t.position.z==n.position.z){H[w]=l;L=true;break}}if(!L){H[w]=B.length;B.push(new THREE.Vertex(t.position.clone()))}}w=0;for(I=m.faces.length;w<I;w++){t=m.faces[w];t.a=H[t.a];t.b=H[t.b];t.c=H[t.c];t.d=H[t.d]}m.vertices=B})();this.computeCentroids();this.computeFaceNormals();
  254. this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  255. var Cylinder=function(a,c,d,e,g){function f(m,o,y){b.vertices.push(new THREE.Vertex(new THREE.Vector3(m,o,y)))}THREE.Geometry.call(this);var b=this,k=Math.PI,h;for(h=0;h<a;h++)f(Math.sin(2*k*h/a)*c,Math.cos(2*k*h/a)*c,0);for(h=0;h<a;h++)f(Math.sin(2*k*h/a)*d,Math.cos(2*k*h/a)*d,e);for(h=0;h<a;h++)b.faces.push(new THREE.Face4(h,h+a,a+(h+1)%a,(h+1)%a));if(d!=0){f(0,0,-g);for(h=a;h<a+a/2;h++)b.faces.push(new THREE.Face4(2*a,(2*h-2*a)%a,(2*h-2*a+1)%a,(2*h-2*a+2)%a))}if(c!=0){f(0,0,e+g);for(h=a+a/2;h<
  256. 2*a;h++)b.faces.push(new THREE.Face4((2*h-2*a+2)%a+a,(2*h-2*a+1)%a+a,(2*h-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  257. var Plane=function(a,c,d,e){THREE.Geometry.call(this);var g,f=a/2,b=c/2;d=d||1;e=e||1;var k=d+1,h=e+1;a=a/d;var m=c/e;for(g=0;g<h;g++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(g*m-b),0)));for(g=0;g<e;g++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+k*g,c+k*(g+1),c+1+k*(g+1),c+1+k*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()};
  258. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  259. var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,c||8),b=Math.max(2,d||6);c=[];for(d=0;d<b+1;d++){e=d/b;var k=a*Math.cos(e*g),h=a*Math.sin(e*g),m=[],o=0;for(e=0;e<f;e++){var y=2*e/f,v=h*Math.sin(y*g);y=h*Math.cos(y*g);(d==0||d==b)&&e>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,k,v)))-1);m.push(o)}c.push(m)}var q,z,B;g=c.length;for(d=0;d<g;d++){f=c[d].length;if(d>0)for(e=0;e<f;e++){m=e==f-1;b=c[d][m?0:e+1];k=c[d][m?f-1:e];h=c[d-1][m?f-1:e];m=c[d-1][m?
  260. 0:e+1];v=d/(g-1);q=(d-1)/(g-1);z=(e+1)/f;y=e/f;o=new THREE.UV(1-z,v);v=new THREE.UV(1-y,v);y=new THREE.UV(1-y,q);var H=new THREE.UV(1-z,q);if(d<c.length-1){q=this.vertices[b].position.clone();z=this.vertices[k].position.clone();B=this.vertices[h].position.clone();q.normalize();z.normalize();B.normalize();this.faces.push(new THREE.Face3(b,k,h,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([o,v,y])}if(d>1){q=this.vertices[b].position.clone();
  261. z=this.vertices[h].position.clone();B=this.vertices[m].position.clone();q.normalize();z.normalize();B.normalize();this.faces.push(new THREE.Face3(b,h,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([o,y,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  262. 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=
  263. 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,b=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,b));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[b][0],a[b][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
  264. var Icosahedron=function(a){function c(y,v,q){var z=Math.sqrt(y*y+v*v+q*q);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(y/z,v/z,q/z)))-1}function d(y,v,q,z){z.faces.push(new THREE.Face3(y,v,q))}function e(y,v){var q=g.vertices[y].position,z=g.vertices[v].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var g=this,f=new THREE.Geometry,b;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,
  265. 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++){b=new THREE.Geometry;for(var k in f.faces){var h=e(f.faces[k].a,f.faces[k].b),m=e(f.faces[k].b,f.faces[k].c),o=e(f.faces[k].c,f.faces[k].a);d(f.faces[k].a,h,o,b);d(f.faces[k].b,m,h,b);d(f.faces[k].c,
  266. o,m,b);d(h,m,o,b)}f.faces=b.faces}g.faces=f.faces;delete f;delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
  267. 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=[],b=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));g[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var h=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(k=0;k<e.length;k++)if(m<d){e[k]=h.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));f[k]=this.vertices.length-1}else f=b;if(m==0)b=g;for(k=0;k<g.length-1;k++){this.faces.push(new THREE.Face4(f[k],
  268. f[k+1],g[k+1],g[k]));this.uvs.push([new THREE.UV(m/d,k/a.length),new THREE.UV(m/d,(k+1)/a.length),new THREE.UV((m-c)/d,(k+1)/a.length),new THREE.UV((m-c)/d,k/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}
  269. 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=
  270. 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,b,k,h,m,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[f]=k+b*this.delta;e[f+1]=h;e[f+2]=m;g[f]=this.lerp(o[d],o[d+3],b);g[f+1]=this.lerp(o[d+1],o[d+4],b);g[f+2]=this.lerp(o[d+2],o[d+5],b)};this.VIntY=function(d,e,g,f,b,k,h,m,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[f]=k;e[f+1]=h+b*this.delta;e[f+
  271. 2]=m;e=d+this.yd*3;g[f]=this.lerp(o[d],o[e],b);g[f+1]=this.lerp(o[d+1],o[e+1],b);g[f+2]=this.lerp(o[d+2],o[e+2],b)};this.VIntZ=function(d,e,g,f,b,k,h,m,o,y){b=(b-o)/(y-o);o=this.normal_cache;e[f]=k;e[f+1]=h;e[f+2]=m+b*this.delta;e=d+this.zd*3;g[f]=this.lerp(o[d],o[e],b);g[f+1]=this.lerp(o[d+1],o[e+1],b);g[f+2]=this.lerp(o[d+2],o[e+2],b)};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]-
  272. 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,b,k){var h=f+1,m=f+this.yd,o=f+this.zd,y=h+this.yd,v=h+this.zd,q=f+this.yd+this.zd,z=h+this.yd+this.zd,B=0,H=this.field[f],w=this.field[h],I=this.field[m],t=this.field[y],L=this.field[o],l=this.field[v],A=this.field[q],n=this.field[z];if(H<b)B|=1;if(w<b)B|=2;if(I<b)B|=8;if(t<b)B|=4;if(L<b)B|=16;if(l<b)B|=32;if(A<b)B|=128;if(n<b)B|=64;var j=THREE.edgeTable[B];if(j==0)return 0;
  273. var x=this.delta,u=d+x,E=e+x;x=g+x;if(j&1){this.compNorm(f);this.compNorm(h);this.VIntX(f*3,this.vlist,this.nlist,0,b,d,e,g,H,w)}if(j&2){this.compNorm(h);this.compNorm(y);this.VIntY(h*3,this.vlist,this.nlist,3,b,u,e,g,w,t)}if(j&4){this.compNorm(m);this.compNorm(y);this.VIntX(m*3,this.vlist,this.nlist,6,b,d,E,g,I,t)}if(j&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,b,d,e,g,H,I)}if(j&16){this.compNorm(o);this.compNorm(v);this.VIntX(o*3,this.vlist,this.nlist,12,b,d,e,x,
  274. L,l)}if(j&32){this.compNorm(v);this.compNorm(z);this.VIntY(v*3,this.vlist,this.nlist,15,b,u,e,x,l,n)}if(j&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,b,d,E,x,A,n)}if(j&128){this.compNorm(o);this.compNorm(q);this.VIntY(o*3,this.vlist,this.nlist,21,b,d,e,x,L,A)}if(j&256){this.compNorm(f);this.compNorm(o);this.VIntZ(f*3,this.vlist,this.nlist,24,b,d,e,g,H,L)}if(j&512){this.compNorm(h);this.compNorm(v);this.VIntZ(h*3,this.vlist,this.nlist,27,b,u,e,g,w,l)}if(j&1024){this.compNorm(y);
  275. this.compNorm(z);this.VIntZ(y*3,this.vlist,this.nlist,30,b,u,E,g,t,n)}if(j&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,b,d,E,g,I,A)}B<<=4;for(b=f=0;THREE.triTable[B+b]!=-1;){d=B+b;e=d+1;g=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[g],k);b+=3;f++}return f};this.posnormtriv=function(d,e,g,f,b,k){var h=this.count*3;this.positionArray[h]=d[g];this.positionArray[h+1]=d[g+1];this.positionArray[h+2]=d[g+2];this.positionArray[h+
  276. 3]=d[f];this.positionArray[h+4]=d[f+1];this.positionArray[h+5]=d[f+2];this.positionArray[h+6]=d[b];this.positionArray[h+7]=d[b+1];this.positionArray[h+8]=d[b+2];this.normalArray[h]=e[g];this.normalArray[h+1]=e[g+1];this.normalArray[h+2]=e[g+2];this.normalArray[h+3]=e[f];this.normalArray[h+4]=e[f+1];this.normalArray[h+5]=e[f+2];this.normalArray[h+6]=e[b];this.normalArray[h+7]=e[b+1];this.normalArray[h+8]=e[b+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
  277. 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,b){var k=this.size*Math.sqrt(f/b),h=g*this.size,m=e*this.size,o=d*this.size,y=Math.floor(h-k);if(y<1)y=1;h=Math.floor(h+k);if(h>this.size-1)h=this.size-1;var v=Math.floor(m-k);if(v<1)v=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var q=Math.floor(o-k);if(q<1)q=1;k=Math.floor(o+k);
  278. if(k>this.size-1)k=this.size-1;var z,B,H,w,I,t;for(y=y;y<h;y++){o=this.size2*y;B=y/this.size-g;I=B*B;for(B=v;B<m;B++){H=o+this.size*B;z=B/this.size-e;t=z*z;for(z=q;z<k;z++){w=z/this.size-d;w=f/(1.0E-6+w*w+t+I)-b;if(w>0)this.field[H+z]+=w}}}};this.addPlaneX=function(d,e){var g,f,b,k,h,m=this.size,o=this.yd,y=this.zd,v=this.field,q=m*Math.sqrt(d/e);if(q>m)q=m;for(g=0;g<q;g++){f=g/m;f=f*f;k=d/(1.0E-4+f)-e;if(k>0)for(f=0;f<m;f++){h=g+f*o;for(b=0;b<m;b++)v[y*b+h]+=k}}};this.addPlaneY=function(d,e){var g,
  279. f,b,k,h,m,o=this.size,y=this.yd,v=this.zd,q=this.field,z=o*Math.sqrt(d/e);if(z>o)z=o;for(f=0;f<z;f++){g=f/o;g=g*g;k=d/(1.0E-4+g)-e;if(k>0){h=f*y;for(g=0;g<o;g++){m=h+g;for(b=0;b<o;b++)q[v*b+m]+=k}}}};this.addPlaneZ=function(d,e){var g,f,b,k,h,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(b=0;b<dist;b++){g=b/size;g=g*g;k=d/(1.0E-4+g)-e;if(k>0){h=zd*b;for(f=0;f<size;f++){m=h+f*yd;for(g=0;g<size;g++)field[m+g]+=k}}}};this.reset=function(){var d;
  280. 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,b,k,h,m,o,y,v=this.size-2;for(b=1;b<v;b++){y=this.size2*b;m=(b-this.halfsize)/this.halfsize;for(f=1;f<v;f++){o=y+this.size*f;h=(f-this.halfsize)/this.halfsize;for(g=1;g<v;g++){k=(g-this.halfsize)/this.halfsize;e=o+g;this.polygonize(k,h,m,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(g){var f,b,k,h,m,o,y,v;for(f=
  281. 0;f<g.count;f++){m=f*3;y=m+1;v=m+2;b=g.positionArray[m];k=g.positionArray[y];h=g.positionArray[v];o=new THREE.Vector3(b,k,h);b=g.normalArray[m];k=g.normalArray[y];h=g.normalArray[v];m=new THREE.Vector3(b,k,h);m.normalize();m=new THREE.Vertex(o,m);e.vertices.push(m)}nfaces=g.count/3;for(f=0;f<nfaces;f++){m=(d+f)*3;y=m+1;v=m+2;o=e.vertices[m].normal;b=e.vertices[y].normal;k=e.vertices[v].normal;m=new THREE.Face3(m,y,v,[o,b,k]);e.faces.push(m)}d+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
  282. this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  283. 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,
  284. 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,
  285. 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]);
  286. 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,
  287. -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,
  288. -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,
  289. -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,
  290. 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,
  291. -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,
  292. 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,
  293. -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,
  294. 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,
  295. 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,
  296. 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,
  297. 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,
  298. -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,
  299. -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,
  300. -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,
  301. 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,
  302. -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,
  303. 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,
  304. 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,
  305. -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,
  306. 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};
  307. 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=
  308. 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:
  309. 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(b){THREE.Loader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,d,g,e,f)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,g,f){var b=new XMLHttpRequest,k=e+"/"+a,h=0;
  310. b.onreadystatechange=function(){if(b.readyState==4)b.status==200||b.status==0?THREE.Loader.prototype.createBinModel(b.responseText,d,g,c):alert("Couldn't load ["+k+"] ["+b.status+"]");else if(b.readyState==3){if(f){if(h==0)h=b.getResponseHeader("Content-Length");f({total:h,loaded:b.responseText.length})}}else if(b.readyState==2)h=b.getResponseHeader("Content-Length")};b.open("GET",k,true);b.overrideMimeType("text/plain; charset=x-user-defined");b.setRequestHeader("Content-Type","text/plain");b.send(null)},
  311. createBinModel:function(a,c,d,e){var g=function(f){function b(D,J){var N=o(D,J),V=o(D,J+1),da=o(D,J+2),ga=o(D,J+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 k(D,J){var N=o(D,J),V=o(D,J+1),da=o(D,J+2);return(o(D,J+3)<<24)+(da<<16)+(V<<8)+N}function h(D,J){var N=o(D,J);return(o(D,J+1)<<8)+N}function m(D,J){var N=o(D,J);return N>127?N-256:N}function o(D,J){return D.charCodeAt(J)&255}function y(D){var J,
  312. N,V;J=k(a,D);N=k(a,D+A);V=k(a,D+n);D=h(a,D+j);THREE.Loader.prototype.f3(w,J,N,V,D)}function v(D){var J,N,V,da,ga,ia;J=k(a,D);N=k(a,D+A);V=k(a,D+n);da=h(a,D+j);ga=k(a,D+x);ia=k(a,D+u);D=k(a,D+E);THREE.Loader.prototype.f3n(w,L,J,N,V,da,ga,ia,D)}function q(D){var J,N,V,da;J=k(a,D);N=k(a,D+C);V=k(a,D+p);da=k(a,D+F);D=h(a,D+M);THREE.Loader.prototype.f4(w,J,N,V,da,D)}function z(D){var J,N,V,da,ga,ia,ta,qa;J=k(a,D);N=k(a,D+C);V=k(a,D+p);da=k(a,D+F);ga=h(a,D+M);ia=k(a,D+G);ta=k(a,D+W);qa=k(a,D+Q);D=k(a,D+
  313. O);THREE.Loader.prototype.f4n(w,L,J,N,V,da,ga,ia,ta,qa,D)}function B(D){var J,N;J=k(a,D);N=k(a,D+ba);D=k(a,D+ca);THREE.Loader.prototype.uv3(w.uvs,l[J*2],l[J*2+1],l[N*2],l[N*2+1],l[D*2],l[D*2+1])}function H(D){var J,N,V;J=k(a,D);N=k(a,D+U);V=k(a,D+R);D=k(a,D+X);THREE.Loader.prototype.uv4(w.uvs,l[J*2],l[J*2+1],l[N*2],l[N*2+1],l[V*2],l[V*2+1],l[D*2],l[D*2+1])}var w=this,I=0,t,L=[],l=[],A,n,j,x,u,E,C,p,F,M,G,W,Q,O,ba,ca,U,R,X,Y,K,T,aa,ja,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
  314. e,f);t={signature:a.substr(I,8),header_bytes:o(a,I+8),vertex_coordinate_bytes:o(a,I+9),normal_coordinate_bytes:o(a,I+10),uv_coordinate_bytes:o(a,I+11),vertex_index_bytes:o(a,I+12),normal_index_bytes:o(a,I+13),uv_index_bytes:o(a,I+14),material_index_bytes:o(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),
  315. nquad_smooth_uv:k(a,I+16+40)};I+=t.header_bytes;A=t.vertex_index_bytes;n=t.vertex_index_bytes*2;j=t.vertex_index_bytes*3;x=t.vertex_index_bytes*3+t.material_index_bytes;u=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;E=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;p=t.vertex_index_bytes*2;F=t.vertex_index_bytes*3;M=t.vertex_index_bytes*4;G=t.vertex_index_bytes*4+t.material_index_bytes;W=t.vertex_index_bytes*4+t.material_index_bytes+
  316. t.normal_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;O=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;ba=t.uv_index_bytes;ca=t.uv_index_bytes*2;U=t.uv_index_bytes;R=t.uv_index_bytes*2;X=t.uv_index_bytes*3;f=t.vertex_index_bytes*3+t.material_index_bytes;ha=t.vertex_index_bytes*4+t.material_index_bytes;Y=t.ntri_flat*f;K=t.ntri_smooth*(f+t.normal_index_bytes*3);T=t.ntri_flat_uv*(f+t.uv_index_bytes*3);aa=t.ntri_smooth_uv*(f+t.normal_index_bytes*
  317. 3+t.uv_index_bytes*3);ja=t.nquad_flat*ha;f=t.nquad_smooth*(ha+t.normal_index_bytes*4);ha=t.nquad_flat_uv*(ha+t.uv_index_bytes*4);I+=function(D){var J,N,V,da=t.vertex_coordinate_bytes*3,ga=D+t.nvertices*da;for(D=D;D<ga;D+=da){J=b(a,D);N=b(a,D+t.vertex_coordinate_bytes);V=b(a,D+t.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,J,N,V)}return t.nvertices*da}(I);I+=function(D){var J,N,V,da=t.normal_coordinate_bytes*3,ga=D+t.nnormals*da;for(D=D;D<ga;D+=da){J=m(a,D);N=m(a,D+t.normal_coordinate_bytes);
  318. V=m(a,D+t.normal_coordinate_bytes*2);L.push(J/127,N/127,V/127)}return t.nnormals*da}(I);I+=function(D){var J,N,V=t.uv_coordinate_bytes*2,da=D+t.nuvs*V;for(D=D;D<da;D+=V){J=b(a,D);N=b(a,D+t.uv_coordinate_bytes);l.push(J,N)}return t.nuvs*V}(I);I=I;Y=I+Y;K=Y+K;T=K+T;aa=T+aa;ja=aa+ja;f=ja+f;ha=f+ha;(function(D){var J,N=t.vertex_index_bytes*3+t.material_index_bytes,V=N+t.uv_index_bytes*3,da=D+t.ntri_flat_uv*V;for(J=D;J<da;J+=V){y(J);B(J+N)}return da-D})(K);(function(D){var J,N=t.vertex_index_bytes*3+t.material_index_bytes+
  319. t.normal_index_bytes*3,V=N+t.uv_index_bytes*3,da=D+t.ntri_smooth_uv*V;for(J=D;J<da;J+=V){v(J);B(J+N)}return da-D})(T);(function(D){var J,N=t.vertex_index_bytes*4+t.material_index_bytes,V=N+t.uv_index_bytes*4,da=D+t.nquad_flat_uv*V;for(J=D;J<da;J+=V){q(J);H(J+N)}return da-D})(f);(function(D){var J,N=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,V=N+t.uv_index_bytes*4,da=D+t.nquad_smooth_uv*V;for(J=D;J<da;J+=V){z(J);H(J+N)}return da-D})(ha);(function(D){var J,N=t.vertex_index_bytes*
  320. 3+t.material_index_bytes,V=D+t.ntri_flat*N;for(J=D;J<V;J+=N)y(J);return V-D})(I);(function(D){var J,N=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,V=D+t.ntri_smooth*N;for(J=D;J<V;J+=N)v(J);return V-D})(Y);(function(D){var J,N=t.vertex_index_bytes*4+t.material_index_bytes,V=D+t.nquad_flat*N;for(J=D;J<V;J+=N)q(J);return V-D})(aa);(function(D){var J,N=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,V=D+t.nquad_smooth*N;for(J=D;J<V;J+=N)z(J);return V-D})(ja);
  321. 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 b,k,h,m,o;b=0;for(k=a.vertices.length;b<k;b+=3){h=a.vertices[b];m=a.vertices[b+1];o=a.vertices[b+2];THREE.Loader.prototype.v(f,h,m,o)}})();(function(){function b(z,B){THREE.Loader.prototype.f3(f,z[B],
  322. z[B+1],z[B+2],z[B+3])}function k(z,B){THREE.Loader.prototype.f3n(f,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6])}function h(z,B){THREE.Loader.prototype.f4(f,z[B],z[B+1],z[B+2],z[B+3],z[B+4])}function m(z,B){THREE.Loader.prototype.f4n(f,a.normals,z[B],z[B+1],z[B+2],z[B+3],z[B+4],z[B+5],z[B+6],z[B+7],z[B+8])}function o(z,B){var H,w,I,t,L,l,A,n,j;H=z[B];w=z[B+1];I=z[B+2];t=a.uvs[H*2];A=a.uvs[H*2+1];L=a.uvs[w*2];n=a.uvs[w*2+1];l=a.uvs[I*2];j=a.uvs[I*2+1];THREE.Loader.prototype.uv3(f.uvs,t,
  323. A,L,n,l,j);if(a.uvs2){t=a.uvs2[H*2];A=a.uvs2[H*2+1];L=a.uvs2[w*2];n=a.uvs2[w*2+1];l=a.uvs2[I*2];j=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(f.uvs2,t,1-A,L,1-n,l,1-j)}}function y(z,B){var H,w,I,t,L,l,A,n,j,x,u,E;H=z[B];w=z[B+1];I=z[B+2];t=z[B+3];L=a.uvs[H*2];j=a.uvs[H*2+1];l=a.uvs[w*2];x=a.uvs[w*2+1];A=a.uvs[I*2];u=a.uvs[I*2+1];n=a.uvs[t*2];E=a.uvs[t*2+1];THREE.Loader.prototype.uv4(f.uvs,L,j,l,x,A,u,n,E);if(a.uvs2){L=a.uvs2[H*2];j=a.uvs2[H*2+1];l=a.uvs2[w*2];x=a.uvs2[w*2+1];A=a.uvs2[I*2];u=a.uvs2[I*
  324. 2+1];n=a.uvs2[t*2];E=a.uvs2[t*2+1];THREE.Loader.prototype.uv4(f.uvs2,L,1-j,l,1-x,A,1-u,n,1-E)}}var v,q;v=0;for(q=a.triangles_uv.length;v<q;v+=7){b(a.triangles_uv,v);o(a.triangles_uv,v+4)}v=0;for(q=a.triangles_n_uv.length;v<q;v+=10){k(a.triangles_n_uv,v);o(a.triangles_n_uv,v+7)}v=0;for(q=a.quads_uv.length;v<q;v+=9){h(a.quads_uv,v);y(a.quads_uv,v+5)}v=0;for(q=a.quads_n_uv.length;v<q;v+=13){m(a.quads_n_uv,v);y(a.quads_n_uv,v+9)}v=0;for(q=a.triangles.length;v<q;v+=4)b(a.triangles,v);v=0;for(q=a.triangles_n.length;v<
  325. q;v+=7)k(a.triangles_n,v);v=0;for(q=a.quads.length;v<q;v+=5)h(a.quads,v);v=0;for(q=a.quads_n.length;v<q;v+=9)m(a.quads_n,v)})();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)))},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,
  326. a.materials[f]))},f3n:function(a,c,d,e,g,f,b,k,h){f=a.materials[f];var m=c[k*3],o=c[k*3+1];k=c[k*3+2];var y=c[h*3],v=c[h*3+1];h=c[h*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(m,o,k),new THREE.Vector3(y,v,h)],f))},f4n:function(a,c,d,e,g,f,b,k,h,m,o){b=a.materials[b];var y=c[h*3],v=c[h*3+1];h=c[h*3+2];var q=c[m*3],z=c[m*3+1];m=c[m*3+2];var B=c[o*3],H=c[o*3+1];o=c[o*3+2];a.faces.push(new THREE.Face4(d,e,g,f,[new THREE.Vector3(c[k*3],c[k*3+1],
  327. c[k*3+2]),new THREE.Vector3(y,v,h),new THREE.Vector3(q,z,m),new THREE.Vector3(B,H,o)],b))},uv3:function(a,c,d,e,g,f,b){var k=[];k.push(new THREE.UV(c,d));k.push(new THREE.UV(e,g));k.push(new THREE.UV(f,b));a.push(k)},uv4:function(a,c,d,e,g,f,b,k,h){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,g));m.push(new THREE.UV(f,b));m.push(new THREE.UV(k,h));a.push(m)},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],
  328. d)]},createMaterial:function(a,c){function d(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function e(b,k){var h=new Image;h.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),o=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=m;b.image.height=o;b.image.getContext("2d").drawImage(this,0,0,m,o)}else b.image=this;b.image.loaded=1};h.src=k}var g,f;if(a.map_diffuse&&c){f=document.createElement("canvas");g=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});
  329. e(g.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;g=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else g=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){f=document.createElement("canvas");g.light_map=new THREE.Texture(f);e(g.light_map,c+"/"+a.map_lightmap)}return g},extractUrlbase:function(a){a=a.split("/");a.pop();
  330. return a.join("/")}};