2
0

ThreeExtras.js 160 KB

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