Three.js 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. // Three.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,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var f,k,l,p,q,m;if(e==0)f=k=l=0;else{p=Math.floor(a*6);q=a*6-p;a=e*(1-c);m=e*(1-c*q);c=e*(1-c*(1-q));switch(p){case 1:f=m;k=e;l=a;break;case 2:f=a;k=e;l=c;break;case 3:f=a;k=m;l=e;break;case 4:f=c;k=a;l=e;break;case 5:f=e;k=a;l=m;break;case 6:case 0:f=e;k=c;l=a}}this.r=f;this.g=k;this.b=l;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,e){this.x=a||0;this.y=c||0;this.z=e||0};
  8. THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,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,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-e*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,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
  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,e,f){this.x=a||0;this.y=c||0;this.z=e||0;this.w=f||1};
  13. THREE.Vector4.prototype={set:function(a,c,e,f){this.x=a;this.y=c;this.z=e;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,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,e,f=a.objects,k=[];a=0;for(c=f.length;a<c;a++){e=f[a];if(e instanceof THREE.Mesh)k=k.concat(this.intersectObject(e))}k.sort(function(l,p){return l.distance-p.distance});return k},intersectObject:function(a){function c(I,s,R,E){E=E.clone().subSelf(s);R=R.clone().subSelf(s);var J=I.clone().subSelf(s);I=E.dot(E);s=E.dot(R);E=E.dot(J);var O=R.dot(R);R=R.dot(J);J=1/(I*O-s*s);O=(O*E-s*R)*J;I=(I*R-s*E)*J;return O>0&&I>0&&O+I<1}var e,f,k,l,p,q,m,o,C,B,
  17. u,x=a.geometry,b=x.vertices,H=[];e=0;for(f=x.faces.length;e<f;e++){k=x.faces[e];B=this.origin.clone();u=this.direction.clone();l=a.matrix.multiplyVector3(b[k.a].position.clone());p=a.matrix.multiplyVector3(b[k.b].position.clone());q=a.matrix.multiplyVector3(b[k.c].position.clone());m=k instanceof THREE.Face4?a.matrix.multiplyVector3(b[k.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(k.normal.clone());C=u.dot(o);if(C<0){o=o.dot((new THREE.Vector3).sub(l,B))/C;B=B.addSelf(u.multiplyScalar(o));
  18. if(k instanceof THREE.Face3){if(c(B,l,p,q)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}else if(k instanceof THREE.Face4)if(c(B,l,p,m)||c(B,p,q,m)){k={distance:this.origin.distanceTo(B),point:B,face:k,object:a};H.push(k)}}}return H}};
  19. THREE.Rectangle=function(){function a(){l=f-c;p=k-e}var c,e,f,k,l,p,q=true;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return l};this.getHeight=function(){return p};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return k};this.set=function(m,o,C,B){q=false;c=m;e=o;f=C;k=B;a()};this.addPoint=function(m,o){if(q){q=false;c=m;e=o;f=m;k=o}else{c=c<m?c:m;e=e<o?e:o;f=f>m?f:m;k=k>o?
  20. k:o}a()};this.add3Points=function(m,o,C,B,u,x){if(q){q=false;c=m<C?m<u?m:u:C<u?C:u;e=o<B?o<x?o:x:B<x?B:x;f=m>C?m>u?m:u:C>u?C:u;k=o>B?o>x?o:x:B>x?B:x}else{c=m<C?m<u?m<c?m:c:u<c?u:c:C<u?C<c?C:c:u<c?u:c;e=o<B?o<x?o<e?o:e:x<e?x:e:B<x?B<e?B:e:x<e?x:e;f=m>C?m>u?m>f?m:f:u>f?u:f:C>u?C>f?C:f:u>f?u:f;k=o>B?o>x?o>k?o:k:x>k?x:k:B>x?B>k?B:k:x>k?x:k}a()};this.addRectangle=function(m){if(q){q=false;c=m.getLeft();e=m.getTop();f=m.getRight();k=m.getBottom()}else{c=c<m.getLeft()?c:m.getLeft();e=e<m.getTop()?e:m.getTop();
  21. f=f>m.getRight()?f:m.getRight();k=k>m.getBottom()?k:m.getBottom()}a()};this.inflate=function(m){c-=m;e-=m;f+=m;k+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();e=e>m.getTop()?e:m.getTop();f=f<m.getRight()?f:m.getRight();k=k<m.getBottom()?k:m.getBottom();a()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(c,m.getLeft())>=0&&Math.min(k,m.getBottom())-Math.max(e,m.getTop())>=0};this.empty=function(){q=true;k=f=e=c=0;a()};this.isEmpty=function(){return q};this.toString=
  22. function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+e+", bottom: "+k+", width: "+l+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
  23. THREE.Matrix4=function(a,c,e,f,k,l,p,q,m,o,C,B,u,x,b,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=f||0;this.n21=k||0;this.n22=l||1;this.n23=p||0;this.n24=q||0;this.n31=m||0;this.n32=o||0;this.n33=C||1;this.n34=B||0;this.n41=u||0;this.n42=x||0;this.n43=b||0;this.n44=H||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,e,f,k,l,p,q,m,o,C,B,u,x,b,H){this.n11=a;this.n12=c;this.n13=e;this.n14=f;this.n21=k;this.n22=l;this.n23=p;this.n24=q;this.n31=m;this.n32=o;this.n33=C;this.n34=B;this.n41=u;this.n42=x;this.n43=b;this.n44=H;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,e){var f=THREE.Matrix4.__tmpVec1,k=THREE.Matrix4.__tmpVec2,l=THREE.Matrix4.__tmpVec3;l.sub(a,c).normalize();f.cross(e,l).normalize();k.cross(l,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=k.x;this.n22=k.y;this.n23=k.z;this.n24=-k.dot(a);
  26. this.n31=l.x;this.n32=l.y;this.n33=l.z;this.n34=-l.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,f=a.z,k=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*k;a.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*k;a.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*k;return a},multiplyVector4:function(a){var c=a.x,e=a.y,f=a.z,k=a.w;a.x=this.n11*c+this.n12*e+this.n13*f+this.n14*k;a.y=this.n21*c+this.n22*e+this.n23*
  27. f+this.n24*k;a.z=this.n31*c+this.n32*e+this.n33*f+this.n34*k;a.w=this.n41*c+this.n42*e+this.n43*f+this.n44*k;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 e=a.n11,f=a.n12,k=a.n13,l=a.n14,p=a.n21,q=a.n22,m=a.n23,o=a.n24,C=a.n31,
  28. B=a.n32,u=a.n33,x=a.n34,b=a.n41,H=a.n42,I=a.n43,s=a.n44,R=c.n11,E=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,K=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43,n=c.n44;this.n11=e*R+f*Y+k*M+l*i;this.n12=e*E+f*P+k*U+l*j;this.n13=e*J+f*K+k*d+l*g;this.n14=e*O+f*V+k*h+l*n;this.n21=p*R+q*Y+m*M+o*i;this.n22=p*E+q*P+m*U+o*j;this.n23=p*J+q*K+m*d+o*g;this.n24=p*O+q*V+m*h+o*n;this.n31=C*R+B*Y+u*M+x*i;this.n32=C*E+B*P+u*U+x*j;this.n33=C*J+B*K+u*d+x*g;this.n34=C*O+B*V+u*h+x*n;this.n41=b*R+H*Y+
  29. I*M+s*i;this.n42=b*E+H*P+I*U+s*j;this.n43=b*J+H*K+I*d+s*g;this.n44=b*O+H*V+I*h+s*n;return this},multiplyToArray:function(a,c,e){var f=a.n11,k=a.n12,l=a.n13,p=a.n14,q=a.n21,m=a.n22,o=a.n23,C=a.n24,B=a.n31,u=a.n32,x=a.n33,b=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var R=c.n11,E=c.n12,J=c.n13,O=c.n14,Y=c.n21,P=c.n22,K=c.n23,V=c.n24,M=c.n31,U=c.n32,d=c.n33,h=c.n34,i=c.n41,j=c.n42,g=c.n43;c=c.n44;this.n11=f*R+k*Y+l*M+p*i;this.n12=f*E+k*P+l*U+p*j;this.n13=f*J+k*K+l*d+p*g;this.n14=f*O+k*V+l*h+p*c;this.n21=
  30. q*R+m*Y+o*M+C*i;this.n22=q*E+m*P+o*U+C*j;this.n23=q*J+m*K+o*d+C*g;this.n24=q*O+m*V+o*h+C*c;this.n31=B*R+u*Y+x*M+b*i;this.n32=B*E+u*P+x*U+b*j;this.n33=B*J+u*K+x*d+b*g;this.n34=B*O+u*V+x*h+b*c;this.n41=H*R+I*Y+s*M+a*i;this.n42=H*E+I*P+s*U+a*j;this.n43=H*J+I*K+s*d+a*g;this.n44=H*O+I*V+s*h+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;
  31. e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,f=this.n13,k=this.n14,l=this.n21,p=this.n22,q=this.n23,m=this.n24,o=this.n31,C=this.n32,B=this.n33,u=this.n34,x=this.n41,b=this.n42,H=this.n43,I=this.n44,s=a.n11,R=a.n21,E=a.n31,J=a.n41,O=a.n12,Y=a.n22,P=a.n32,K=a.n42,V=a.n13,M=a.n23,U=a.n33,d=a.n43,h=a.n14,i=a.n24,j=a.n34;a=a.n44;this.n11=c*s+e*R+f*E+k*J;this.n12=c*O+e*Y+f*P+k*K;this.n13=c*V+e*M+f*U+k*d;this.n14=c*h+e*i+f*j+k*a;this.n21=l*s+p*R+q*E+m*J;this.n22=l*O+p*
  32. Y+q*P+m*K;this.n23=l*V+p*M+q*U+m*d;this.n24=l*h+p*i+q*j+m*a;this.n31=o*s+C*R+B*E+u*J;this.n32=o*O+C*Y+B*P+u*K;this.n33=o*V+C*M+B*U+u*d;this.n34=o*h+C*i+B*j+u*a;this.n41=x*s+b*R+H*E+I*J;this.n42=x*O+b*Y+H*P+I*K;this.n43=x*V+b*M+H*U+I*d;this.n44=x*h+b*i+H*j+I*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},
  33. determinant:function(){var a=this.n11,c=this.n12,e=this.n13,f=this.n14,k=this.n21,l=this.n22,p=this.n23,q=this.n24,m=this.n31,o=this.n32,C=this.n33,B=this.n34,u=this.n41,x=this.n42,b=this.n43,H=this.n44;return f*p*o*u-e*q*o*u-f*l*C*u+c*q*C*u+e*l*B*u-c*p*B*u-f*p*m*x+e*q*m*x+f*k*C*x-a*q*C*x-e*k*B*x+a*p*B*x+f*l*m*b-c*q*m*b-f*k*o*b+a*q*o*b+c*k*B*b-a*l*B*b-e*l*m*H+c*p*m*H+e*k*o*H-a*p*o*H-c*k*C*H+a*l*C*H},transpose:function(){function a(c,e,f){var k=c[e];c[e]=c[f];c[f]=k}a(this,"n21","n12");a(this,"n31",
  34. "n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=
  35. this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1,0,0,a,0,1,0,c,0,0,1,e,0,0,0,
  36. 1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),f=Math.sin(c),k=1-e,l=a.x,p=a.y,q=a.z,
  37. m=k*l,o=k*p;this.set(m*l+e,m*p-f*q,m*q+f*p,0,m*p+f*q,o*p+e,o*q-f*l,0,m*q-f*p,o*q+f*l,k*q*q+e,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,e){var f=new THREE.Matrix4;f.setTranslation(a,c,e);return f};
  38. THREE.Matrix4.scaleMatrix=function(a,c,e){var f=new THREE.Matrix4;f.setScale(a,c,e);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e};
  39. THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,f=a.n13,k=a.n14,l=a.n21,p=a.n22,q=a.n23,m=a.n24,o=a.n31,C=a.n32,B=a.n33,u=a.n34,x=a.n41,b=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=q*u*b-m*B*b+m*C*H-p*u*H-q*C*I+p*B*I;s.n12=k*B*b-f*u*b-k*C*H+e*u*H+f*C*I-e*B*I;s.n13=f*m*b-k*q*b+k*p*H-e*m*H-f*p*I+e*q*I;s.n14=k*q*C-f*m*C-k*p*B+e*m*B+f*p*u-e*q*u;s.n21=m*B*x-q*u*x-m*o*H+l*u*H+q*o*I-l*B*I;s.n22=f*u*x-k*B*x+k*o*H-c*u*H-f*o*I+c*B*I;s.n23=k*q*x-f*m*x-k*l*H+c*m*H+f*l*I-c*q*I;s.n24=f*m*o-k*q*o+
  40. k*l*B-c*m*B-f*l*u+c*q*u;s.n31=p*u*x-m*C*x+m*o*b-l*u*b-p*o*I+l*C*I;s.n32=k*C*x-e*u*x-k*o*b+c*u*b+e*o*I-c*C*I;s.n33=f*m*x-k*p*x+k*l*b-c*m*b-e*l*I+c*p*I;s.n34=k*p*o-e*m*o-k*l*C+c*m*C+e*l*u-c*p*u;s.n41=q*C*x-p*B*x-q*o*b+l*B*b+p*o*H-l*C*H;s.n42=e*B*x-f*C*x+f*o*b-c*B*b-e*o*H+c*C*H;s.n43=f*p*x-e*q*x-f*l*b+c*q*b+e*l*H-c*p*H;s.n44=e*q*o-f*p*o+f*l*C-c*q*C-e*l*B+c*p*B;s.multiplyScalar(1/a.determinant());return s};
  41. THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,f=a.n33*a.n22-a.n32*a.n23,k=-a.n33*a.n21+a.n31*a.n23,l=a.n32*a.n21-a.n31*a.n22,p=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,C=-a.n23*a.n11+a.n21*a.n13,B=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*p+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*f;e[1]=a*k;e[2]=a*l;e[3]=a*p;e[4]=a*q;e[5]=a*m;e[6]=a*o;e[7]=a*C;e[8]=a*B;return c};
  42. THREE.Matrix4.makeFrustum=function(a,c,e,f,k,l){var p,q,m;p=new THREE.Matrix4;q=2*k/(c-a);m=2*k/(f-e);a=(c+a)/(c-a);e=(f+e)/(f-e);f=-(l+k)/(l-k);k=-2*l*k/(l-k);p.n11=q;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=m;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=k;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,c,e,f){var k;a=e*Math.tan(a*Math.PI/360);k=-a;return THREE.Matrix4.makeFrustum(k*c,a*c,k,a,e,f)};
  43. THREE.Matrix4.makeOrtho=function(a,c,e,f,k,l){var p,q,m,o;p=new THREE.Matrix4;q=c-a;m=e-f;o=l-k;a=(c+a)/q;e=(e+f)/m;k=(l+k)/o;p.n11=2/q;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/m;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/o;p.n34=-k;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  44. THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
  45. THREE.Face3=function(a,c,e,f,k){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=k instanceof Array?k:[k]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  46. THREE.Face4=function(a,c,e,f,k,l){this.a=a;this.b=c;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=k instanceof THREE.Vector3?k:new THREE.Vector3;this.vertexNormals=k instanceof Array?k:[];this.materials=l instanceof Array?l:[l]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
  47. THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
  48. THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
  49. e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,e,f,k,l,p,q=new THREE.Vector3,m=new THREE.Vector3;f=0;for(k=this.vertices.length;f<k;f++){l=this.vertices[f];l.normal.set(0,0,0)}f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];if(a&&l.vertexNormals.length){q.set(0,0,0);c=0;for(e=l.normal.length;c<e;c++)q.addSelf(l.vertexNormals[c]);q.divideScalar(3)}else{c=this.vertices[l.a];e=this.vertices[l.b];p=this.vertices[l.c];q.sub(p.position,
  50. e.position);m.sub(c.position,e.position);q.crossSelf(m)}q.isZero()||q.normalize();l.normal.copy(q)}},computeVertexNormals:function(){var a,c,e,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,
  51. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
  52. c;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(f[e.a]);e.vertexNormals[1].copy(f[e.b]);e.vertexNormals[2].copy(f[e.c]);e.vertexNormals[3].copy(f[e.d])}}},computeTangents:function(){function a(h,i,j,g,n,z,r){l=h.vertices[i].position;p=h.vertices[j].position;q=h.vertices[g].position;m=k[n];o=k[z];C=k[r];B=p.x-l.x;u=q.x-l.x;x=p.y-l.y;b=q.y-l.y;
  53. H=p.z-l.z;I=q.z-l.z;s=o.u-m.u;R=C.u-m.u;E=o.v-m.v;J=C.v-m.v;O=1/(s*J-R*E);K.set((J*B-E*u)*O,(J*x-E*b)*O,(J*H-E*I)*O);V.set((s*u-R*B)*O,(s*b-R*x)*O,(s*I-R*H)*O);Y[i].addSelf(K);Y[j].addSelf(K);Y[g].addSelf(K);P[i].addSelf(V);P[j].addSelf(V);P[g].addSelf(V)}var c,e,f,k,l,p,q,m,o,C,B,u,x,b,H,I,s,R,E,J,O,Y=[],P=[],K=new THREE.Vector3,V=new THREE.Vector3,M=new THREE.Vector3,U=new THREE.Vector3,d=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++){Y[c]=new THREE.Vector3;P[c]=new THREE.Vector3}c=0;
  54. for(e=this.faces.length;c<e;c++){f=this.faces[c];k=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
  55. this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(e=this.vertices.length;c<e;c++){d.copy(this.vertices[c].normal);f=Y[c];M.copy(f);M.subSelf(d.multiplyScalar(d.dot(f))).normalize();U.cross(this.vertices[c].normal,f);f=U.dot(P[c]);f=f<0?-1:1;this.vertices[c].tangent.set(M.x,M.y,M.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
  56. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,e=this.vertices.length;c<e;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
  57. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c<e;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(C){var B=[];c=0;for(e=C.length;c<e;c++)C[c]==undefined?B.push("undefined"):B.push(C[c].toString());return B.join("_")}var c,e,f,k,l,p,q,m,o={};f=0;for(k=this.faces.length;f<k;f++){l=this.faces[f];
  58. p=l.materials;q=a(p);if(o[q]==undefined)o[q]={hash:q,counter:0};m=o[q].hash+"_"+o[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0};l=l instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+l>65535){o[q].counter+=1;m=o[q].hash+"_"+o[q].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:p,vertices:0}}this.geometryChunks[m].faces.push(f);this.geometryChunks[m].vertices+=l}},toString:function(){return"THREE.Geometry ( vertices: "+
  59. this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
  60. THREE.Camera=function(a,c,e,f){this.fov=a;this.aspect=c;this.near=e;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
  61. this.translateZ=function(k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
  62. THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
  63. THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
  64. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
  65. THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(e.x!=0||e.y!=0||e.z!=0){f.setScale(e.x,e.y,e.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
  66. THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
  67. THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
  68. THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
  69. THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
  70. a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  71. THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.LineBasicMaterialCounter={value:0};
  72. THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){a.color!==
  73. undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==
  74. undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  75. THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+
  76. "<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
  77. THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){a.color!==
  78. undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==
  79. undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  80. THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+
  81. "<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
  82. THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=
  83. 1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=
  84. a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
  85. a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  86. THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+
  87. this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
  88. THREE.MeshDepthMaterial=function(a){this.id=THREE.MeshDepthMaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
  89. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshDepthMaterialCounter={value:0};
  90. THREE.MeshNormalMaterial=function(a){this.id=THREE.MeshNormalMaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
  91. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshNormalMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
  92. THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=true;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=false;if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=
  93. a.vertex_shader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
  94. undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  95. THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
  96. THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;
  97. if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};THREE.ParticleBasicMaterialCounter={value:0};
  98. THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
  99. THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,f,k,l){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=k!==undefined?k:THREE.LinearFilter;this.min_filter=l!==undefined?l:THREE.LinearMipMapLinearFilter};
  100. THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
  101. THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
  102. THREE.RenderTarget=function(a,c,e){this.width=a;this.height=c;e=e||{};this.wrap_s=e.wrap_s!==undefined?e.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=e.wrap_t!==undefined?e.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=e.mag_filter!==undefined?e.mag_filter:THREE.LinearFilter;this.min_filter=e.min_filter!==undefined?e.min_filter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
  103. var Uniforms={clone:function(a){var c,e,f,k={};for(c in a){k[c]={};for(e in a[c]){f=a[c][e];k[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return k},merge:function(a){var c,e,f,k={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(e in f)k[e]=f[e]}return k}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  104. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  105. THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
  106. THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
  107. THREE.Projector=function(){function a(P,K){return K.z-P.z}function c(P,K){var V=0,M=1,U=P.z+P.w,d=K.z+K.w,h=-P.z+P.w,i=-K.z+K.w;if(U>=0&&d>=0&&h>=0&&i>=0)return true;else if(U<0&&d<0||h<0&&i<0)return false;else{if(U<0)V=Math.max(V,U/(U-d));else if(d<0)M=Math.min(M,U/(U-d));if(h<0)V=Math.max(V,h/(h-i));else if(i<0)M=Math.min(M,h/(h-i));if(M<V)return false;else{P.lerpSelf(K,V);K.lerpSelf(P,1-M);return true}}}var e,f,k=[],l,p,q,m=[],o,C,B=[],u,x,b=[],H=new THREE.Vector4,I=new THREE.Vector4,s=new THREE.Matrix4,
  108. R=new THREE.Matrix4,E=[],J=new THREE.Vector4,O=new THREE.Vector4,Y;this.projectObjects=function(P,K,V){var M=[],U,d;f=0;s.multiply(K.projectionMatrix,K.matrix);E[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);E[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);E[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);E[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);E[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
  109. s.n33,s.n44-s.n34);E[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);K=0;for(U=E.length;K<U;K++){d=E[K];d.divideScalar(Math.sqrt(d.x*d.x+d.y*d.y+d.z*d.z))}U=P.objects;P=0;for(K=U.length;P<K;P++){d=U[P];var h;if(!(h=!d.visible)){if(h=d instanceof THREE.Mesh){a:{h=void 0;for(var i=d.position,j=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,Math.max(d.scale.y,d.scale.z)),g=0;g<6;g++){h=E[g].x*i.x+E[g].y*i.y+E[g].z*i.z+E[g].w;if(h<=j){h=false;break a}}h=true}h=!h}h=h}if(!h){e=
  110. k[f]=k[f]||new THREE.RenderableObject;H.copy(d.position);s.multiplyVector3(H);e.object=d;e.z=H.z;M.push(e);f++}}V&&M.sort(a);return M};this.projectScene=function(P,K,V){var M=[],U=K.near,d=K.far,h,i,j,g,n,z,r,t,v,w,y,L,F,A,N,T;q=C=x=0;K.autoUpdateMatrix&&K.updateMatrix();s.multiply(K.projectionMatrix,K.matrix);z=this.projectObjects(P,K,true);P=0;for(h=z.length;P<h;P++){r=z[P].object;if(r.visible){r.autoUpdateMatrix&&r.updateMatrix();t=r.matrix;v=r.rotationMatrix;w=r.materials;y=r.overdraw;if(r instanceof
  111. THREE.Mesh){L=r.geometry;F=L.vertices;i=0;for(j=F.length;i<j;i++){A=F[i];A.positionWorld.copy(A.position);t.multiplyVector3(A.positionWorld);g=A.positionScreen;g.copy(A.positionWorld);s.multiplyVector4(g);g.x/=g.w;g.y/=g.w;A.__visible=g.z>U&&g.z<d}L=L.faces;i=0;for(j=L.length;i<j;i++){A=L[i];if(A instanceof THREE.Face3){g=F[A.a];n=F[A.b];N=F[A.c];if(g.__visible&&n.__visible&&N.__visible)if(r.doubleSided||r.flipSided!=(N.positionScreen.x-g.positionScreen.x)*(n.positionScreen.y-g.positionScreen.y)-
  112. (N.positionScreen.y-g.positionScreen.y)*(n.positionScreen.x-g.positionScreen.x)<0){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(n.positionWorld);l.v3.positionWorld.copy(N.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(n.positionScreen);l.v3.positionScreen.copy(N.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);
  113. l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);N=A.vertexNormals;Y=l.vertexNormalsWorld;g=0;for(n=N.length;g<n;g++){T=Y[g]=Y[g]||new THREE.Vector3;T.copy(N[g]);v.multiplyVector3(T)}l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][2]}M.push(l);q++}}else if(A instanceof THREE.Face4){g=F[A.a];n=F[A.b];N=F[A.c];T=F[A.d];if(g.__visible&&
  114. n.__visible&&N.__visible&&T.__visible)if(r.doubleSided||r.flipSided!=((T.positionScreen.x-g.positionScreen.x)*(n.positionScreen.y-g.positionScreen.y)-(T.positionScreen.y-g.positionScreen.y)*(n.positionScreen.x-g.positionScreen.x)<0||(n.positionScreen.x-N.positionScreen.x)*(T.positionScreen.y-N.positionScreen.y)-(n.positionScreen.y-N.positionScreen.y)*(T.positionScreen.x-N.positionScreen.x)<0)){l=m[q]=m[q]||new THREE.RenderableFace3;l.v1.positionWorld.copy(g.positionWorld);l.v2.positionWorld.copy(n.positionWorld);
  115. l.v3.positionWorld.copy(T.positionWorld);l.v1.positionScreen.copy(g.positionScreen);l.v2.positionScreen.copy(n.positionScreen);l.v3.positionScreen.copy(T.positionScreen);l.normalWorld.copy(A.normal);v.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);t.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);s.multiplyVector3(l.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=w;l.faceMaterials=A.materials;l.overdraw=y;if(r.geometry.uvs[i]){l.uvs[0]=r.geometry.uvs[i][0];
  116. l.uvs[1]=r.geometry.uvs[i][1];l.uvs[2]=r.geometry.uvs[i][3]}M.push(l);q++;p=m[q]=m[q]||new THREE.RenderableFace3;p.v1.positionWorld.copy(n.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(T.positionWorld);p.v1.positionScreen.copy(n.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(T.positionScreen);p.normalWorld.copy(l.normalWorld);p.centroidWorld.copy(l.centroidWorld);p.centroidScreen.copy(l.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
  117. w;p.faceMaterials=A.materials;p.overdraw=y;if(r.geometry.uvs[i]){p.uvs[0]=r.geometry.uvs[i][1];p.uvs[1]=r.geometry.uvs[i][2];p.uvs[2]=r.geometry.uvs[i][3]}M.push(p);q++}}}}else if(r instanceof THREE.Line){R.multiply(s,t);F=r.geometry.vertices;A=F[0];A.positionScreen.copy(A.position);R.multiplyVector4(A.positionScreen);i=1;for(j=F.length;i<j;i++){g=F[i];g.positionScreen.copy(g.position);R.multiplyVector4(g.positionScreen);n=F[i-1];J.copy(g.positionScreen);O.copy(n.positionScreen);if(c(J,O)){J.multiplyScalar(1/
  118. J.w);O.multiplyScalar(1/O.w);o=B[C]=B[C]||new THREE.RenderableLine;o.v1.positionScreen.copy(J);o.v2.positionScreen.copy(O);o.z=Math.max(J.z,O.z);o.materials=r.materials;M.push(o);C++}}}else if(r instanceof THREE.Particle){I.set(r.position.x,r.position.y,r.position.z,1);s.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){u=b[x]=b[x]||new THREE.RenderableParticle;u.x=I.x/I.w;u.y=I.y/I.w;u.z=I.z;u.rotation=r.rotation.z;u.scale.x=r.scale.x*Math.abs(u.x-(I.x+K.projectionMatrix.n11)/(I.w+K.projectionMatrix.n14));
  119. u.scale.y=r.scale.y*Math.abs(u.y-(I.y+K.projectionMatrix.n22)/(I.w+K.projectionMatrix.n24));u.materials=r.materials;M.push(u);x++}}}}V&&M.sort(a);return M};this.unprojectVector=function(P,K){var V=THREE.Matrix4.makeInvert(K.matrix);V.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));V.multiplyVector3(P);return P}};
  120. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,f,k,l;this.domElement=document.createElement("div");this.setSize=function(p,q){e=p;f=q;k=e/2;l=f/2};this.render=function(p,q){var m,o,C,B,u,x,b,H;a=c.projectScene(p,q);m=0;for(o=a.length;m<o;m++){u=a[m];if(u instanceof THREE.RenderableParticle){b=u.x*k+k;H=u.y*l+l;C=0;for(B=u.material.length;C<B;C++){x=u.material[C];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=b+"px";x.style.top=H+"px"}}}}}};
  121. THREE.CanvasRenderer=function(){function a($){if(u!=$)o.globalAlpha=u=$}function c($){if(x!=$){switch($){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}x=$}}var e=null,f=new THREE.Projector,k=document.createElement("canvas"),l,p,q,m,o=k.getContext("2d"),C=new THREE.Color(0),B=0,u=1,x=0,b=null,H=null,I=1,s,R,E,J,O,Y,P,K,V,M=new THREE.Color,
  122. U=new THREE.Color,d=new THREE.Color,h=new THREE.Color,i=new THREE.Color,j,g,n,z,r,t,v,w,y,L=new THREE.Rectangle,F=new THREE.Rectangle,A=new THREE.Rectangle,N=false,T=new THREE.Color,ca=new THREE.Color,ga=new THREE.Color,Z=new THREE.Color,ka=Math.PI*2,W=new THREE.Vector3,da,sa,va,ea,aa,fa,la=16;da=document.createElement("canvas");da.width=da.height=2;sa=da.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);va=sa.getImageData(0,0,2,2);ea=va.data;aa=document.createElement("canvas");aa.width=
  123. aa.height=la;fa=aa.getContext("2d");fa.translate(-la/2,-la/2);fa.scale(la,la);la--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function($,qa){l=$;p=qa;q=l/2;m=p/2;k.width=l;k.height=p;L.set(-q,-m,q,m);u=1;x=0;H=b=null;I=1};this.setClearColor=function($,qa){C=$;B=qa;F.set(-q,-m,q,m);o.setTransform(1,0,0,-1,q,m);this.clear()};this.setClearColorHex=function($,qa){C.setHex($);B=qa;F.set(-q,-m,q,m);o.setTransform(1,0,0,-1,q,m);this.clear()};this.clear=function(){o.setTransform(1,
  124. 0,0,-1,q,m);if(!F.isEmpty()){F.inflate(1);F.minSelf(L);if(C.hex==0&&B==0)o.clearRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());else{c(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*255)+","+B+")";o.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight())}F.empty()}};this.render=function($,qa){function na(D){var X,S,G,Q=D.lights;ca.setRGB(0,0,0);ga.setRGB(0,0,0);Z.setRGB(0,0,0);D=0;for(X=Q.length;D<X;D++){S=Q[D];G=S.color;if(S instanceof
  125. THREE.AmbientLight){ca.r+=G.r;ca.g+=G.g;ca.b+=G.b}else if(S instanceof THREE.DirectionalLight){ga.r+=G.r;ga.g+=G.g;ga.b+=G.b}else if(S instanceof THREE.PointLight){Z.r+=G.r;Z.g+=G.g;Z.b+=G.b}}}function za(D,X,S,G){var Q,ba,ia,ma,oa=D.lights;D=0;for(Q=oa.length;D<Q;D++){ba=oa[D];ia=ba.color;ma=ba.intensity;if(ba instanceof THREE.DirectionalLight){ba=S.dot(ba.position)*ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}else if(ba instanceof THREE.PointLight){W.sub(ba.position,X);W.normalize();ba=S.dot(W)*
  126. ma;if(ba>0){G.r+=ia.r*ba;G.g+=ia.g*ba;G.b+=ia.b*ba}}}}function Fa(D,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);var G,Q,ba,ia,ma,oa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){ia=S.map.image;ma=ia.width>>1;oa=ia.height>>1;Q=X.scale.x*q;ba=X.scale.y*m;S=Q*ma;G=ba*oa;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(L.instersects(A)){o.save();o.translate(D.x,D.y);o.rotate(-X.rotation);o.scale(Q,-ba);o.translate(-ma,-oa);o.drawImage(ia,0,0);o.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(N){T.r=
  127. ca.r+ga.r+Z.r;T.g=ca.g+ga.g+Z.g;T.b=ca.b+ga.b+Z.b;M.r=S.color.r*T.r;M.g=S.color.g*T.g;M.b=S.color.b*T.b;M.updateStyleString()}else M.__styleString=S.color.__styleString;S=X.scale.x*q;G=X.scale.y*m;A.set(D.x-S,D.y-G,D.x+S,D.y+G);if(L.instersects(A)){Q=M.__styleString;if(H!=Q)o.fillStyle=H=Q;o.save();o.translate(D.x,D.y);o.rotate(-X.rotation);o.scale(S,G);o.beginPath();o.arc(0,0,1,0,ka,true);o.closePath();o.fill();o.restore()}}}}function Aa(D,X,S,G){if(G.opacity!=0){a(G.opacity);c(G.blending);o.beginPath();
  128. o.moveTo(D.positionScreen.x,D.positionScreen.y);o.lineTo(X.positionScreen.x,X.positionScreen.y);o.closePath();if(G instanceof THREE.LineBasicMaterial){M.__styleString=G.color.__styleString;D=G.linewidth;if(I!=D)o.lineWidth=I=D;D=M.__styleString;if(b!=D)o.strokeStyle=b=D;o.stroke();A.inflate(G.linewidth*2)}}}function Da(D,X,S,G,Q,ba){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);J=D.positionScreen.x;O=D.positionScreen.y;Y=X.positionScreen.x;P=X.positionScreen.y;K=S.positionScreen.x;V=S.positionScreen.y;
  129. o.beginPath();o.moveTo(J,O);o.lineTo(Y,P);o.lineTo(K,V);o.lineTo(J,O);o.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&ja(J,O,Y,P,K,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){D=qa.matrix;W.copy(G.vertexNormalsWorld[0]);z=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;r=-(W.x*D.n21+W.y*
  130. D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[1]);t=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;v=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;W.copy(G.vertexNormalsWorld[2]);w=(W.x*D.n11+W.y*D.n12+W.z*D.n13)*0.5+0.5;y=-(W.x*D.n21+W.y*D.n22+W.z*D.n23)*0.5+0.5;ja(J,O,Y,P,K,V,Q.env_map.image,z,r,t,v,w,y)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&
  131. ja(J,O,Y,P,K,V,Q.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);c(THREE.SubtractiveBlending)}if(N)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==3){U.r=d.r=h.r=ca.r;U.g=d.g=h.g=ca.g;U.b=d.b=h.b=ca.b;za(ba,G.v1.positionWorld,G.vertexNormalsWorld[0],U);za(ba,G.v2.positionWorld,G.vertexNormalsWorld[1],d);za(ba,G.v3.positionWorld,G.vertexNormalsWorld[2],h);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;n=Ga(U,d,h,i);ja(J,O,Y,P,K,V,n,
  132. 0,0,1,0,0,1)}else{T.r=ca.r;T.g=ca.g;T.b=ca.b;za(ba,G.centroidWorld,G.normalWorld,T);M.r=Q.color.r*T.r;M.g=Q.color.g*T.g;M.b=Q.color.b*T.b;M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){j=qa.near;g=qa.far;U.r=U.g=U.b=1-Ha(D.positionScreen.z,j,g);d.r=d.g=d.b=1-Ha(X.positionScreen.z,j,g);h.r=h.g=h.b=1-Ha(S.positionScreen.z,
  133. j,g);i.r=(d.r+h.r)*0.5;i.g=(d.g+h.g)*0.5;i.b=(d.b+h.b)*0.5;n=Ga(U,d,h,i);ja(J,O,Y,P,K,V,n,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Ia(G.normalWorld.x);M.g=Ia(G.normalWorld.y);M.b=Ia(G.normalWorld.z);M.updateStyleString();Q.wireframe?Ba(M.__styleString,Q.wireframe_linewidth):Ca(M.__styleString)}}}function Ba(D,X){if(b!=D)o.strokeStyle=b=D;if(I!=X)o.lineWidth=I=X;o.stroke();A.inflate(X*2)}function Ca(D){if(H!=D)o.fillStyle=H=D;o.fill()}function ja(D,X,S,G,Q,ba,ia,ma,oa,wa,ra,
  134. xa,Ja){var ta,ya;ta=ia.width-1;ya=ia.height-1;ma*=ta;oa*=ya;wa*=ta;ra*=ya;xa*=ta;Ja*=ya;S-=D;G-=X;Q-=D;ba-=X;wa-=ma;ra-=oa;xa-=ma;Ja-=oa;ta=wa*Ja-xa*ra;if(ta!=0){ya=1/ta;ta=(Ja*S-ra*Q)*ya;ra=(Ja*G-ra*ba)*ya;S=(wa*Q-xa*S)*ya;G=(wa*ba-xa*G)*ya;D=D-ta*ma-S*oa;X=X-ra*ma-G*oa;o.save();o.transform(ta,ra,S,G,D,X);o.clip();o.drawImage(ia,0,0);o.restore()}}function Ga(D,X,S,G){var Q=~~(D.r*255),ba=~~(D.g*255);D=~~(D.b*255);var ia=~~(X.r*255),ma=~~(X.g*255);X=~~(X.b*255);var oa=~~(S.r*255),wa=~~(S.g*255);S=
  135. ~~(S.b*255);var ra=~~(G.r*255),xa=~~(G.g*255);G=~~(G.b*255);ea[0]=Q<0?0:Q>255?255:Q;ea[1]=ba<0?0:ba>255?255:ba;ea[2]=D<0?0:D>255?255:D;ea[4]=ia<0?0:ia>255?255:ia;ea[5]=ma<0?0:ma>255?255:ma;ea[6]=X<0?0:X>255?255:X;ea[8]=oa<0?0:oa>255?255:oa;ea[9]=wa<0?0:wa>255?255:wa;ea[10]=S<0?0:S>255?255:S;ea[12]=ra<0?0:ra>255?255:ra;ea[13]=xa<0?0:xa>255?255:xa;ea[14]=G<0?0:G>255?255:G;sa.putImageData(va,0,0);fa.drawImage(da,0,0);return aa}function Ha(D,X,S){D=(D-X)/(S-X);return D*D*(3-2*D)}function Ia(D){D=(D+1)*
  136. 0.5;return D<0?0:D>1?1:D}function Ka(D,X){var S=X.x-D.x,G=X.y-D.y,Q=1/Math.sqrt(S*S+G*G);S*=Q;G*=Q;X.x+=S;X.y+=G;D.x-=S;D.y-=G}var pa,Na,ha,ua,Ea,Ma,Oa,La;this.autoClear?this.clear():o.setTransform(1,0,0,-1,q,m);e=f.projectScene($,qa,this.sortElements);(N=$.lights.length>0)&&na($);pa=0;for(Na=e.length;pa<Na;pa++){ha=e[pa];A.empty();if(ha instanceof THREE.RenderableParticle){s=ha;s.x*=q;s.y*=m;ua=0;for(Ea=ha.materials.length;ua<Ea;ua++)Fa(s,ha,ha.materials[ua],$)}else if(ha instanceof THREE.RenderableLine){s=
  137. ha.v1;R=ha.v2;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;A.addPoint(s.positionScreen.x,s.positionScreen.y);A.addPoint(R.positionScreen.x,R.positionScreen.y);if(L.instersects(A)){ua=0;for(Ea=ha.materials.length;ua<Ea;)Aa(s,R,ha,ha.materials[ua++],$)}}else if(ha instanceof THREE.RenderableFace3){s=ha.v1;R=ha.v2;E=ha.v3;s.positionScreen.x*=q;s.positionScreen.y*=m;R.positionScreen.x*=q;R.positionScreen.y*=m;E.positionScreen.x*=q;E.positionScreen.y*=m;if(ha.overdraw){Ka(s.positionScreen,
  138. R.positionScreen);Ka(R.positionScreen,E.positionScreen);Ka(E.positionScreen,s.positionScreen)}A.add3Points(s.positionScreen.x,s.positionScreen.y,R.positionScreen.x,R.positionScreen.y,E.positionScreen.x,E.positionScreen.y);if(L.instersects(A)){ua=0;for(Ea=ha.meshMaterials.length;ua<Ea;){La=ha.meshMaterials[ua++];if(La instanceof THREE.MeshFaceMaterial){Ma=0;for(Oa=ha.faceMaterials.length;Ma<Oa;)(La=ha.faceMaterials[Ma++])&&Da(s,R,E,ha,La,$)}else Da(s,R,E,ha,La,$)}}}F.addRectangle(A)}o.setTransform(1,
  139. 0,0,1,0,0)}};
  140. THREE.SVGRenderer=function(){function a(z,r,t){var v,w,y,L;v=0;for(w=z.lights.length;v<w;v++){y=z.lights[v];if(y instanceof THREE.DirectionalLight){L=r.normalWorld.dot(y.position)*y.intensity;if(L>0){t.r+=y.color.r*L;t.g+=y.color.g*L;t.b+=y.color.b*L}}else if(y instanceof THREE.PointLight){V.sub(y.position,r.centroidWorld);V.normalize();L=r.normalWorld.dot(V)*y.intensity;if(L>0){t.r+=y.color.r*L;t.g+=y.color.g*L;t.b+=y.color.b*L}}}}function c(z,r,t,v,w,y){h=f(i++);h.setAttribute("d","M "+z.positionScreen.x+
  141. " "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(y,v,J);E.r=w.color.r*J.r;E.g=w.color.g*J.g;E.b=w.color.b*J.b;E.updateStyleString()}else E.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){K=1-w.__2near/(w.__farPlusNear-v.z*w.__farMinusNear);
  142. E.setRGB(K,K,K)}else w instanceof THREE.MeshNormalMaterial&&E.setRGB(k(v.normalWorld.x),k(v.normalWorld.y),k(v.normalWorld.z));w.wireframe?h.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):h.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+w.opacity);q.appendChild(h)}function e(z,r,t,v,w,y,L){h=f(i++);h.setAttribute("d",
  143. "M "+z.positionScreen.x+" "+z.positionScreen.y+" L "+r.positionScreen.x+" "+r.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+" L "+v.positionScreen.x+","+v.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(R){J.r=O.r;J.g=O.g;J.b=O.b;a(L,w,J);E.r=y.color.r*J.r;E.g=y.color.g*J.g;E.b=y.color.b*J.b;E.updateStyleString()}else E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){K=
  144. 1-y.__2near/(y.__farPlusNear-w.z*y.__farMinusNear);E.setRGB(K,K,K)}else y instanceof THREE.MeshNormalMaterial&&E.setRGB(k(w.normalWorld.x),k(w.normalWorld.y),k(w.normalWorld.z));y.wireframe?h.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):h.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+y.opacity);q.appendChild(h)}
  145. function f(z){if(M[z]==null){M[z]=document.createElementNS("http://www.w3.org/2000/svg","path");n==0&&M[z].setAttribute("shape-rendering","crispEdges");return M[z]}return M[z]}function k(z){return z<0?Math.min((1+z)*0.5,0.5):0.5+Math.min(z*0.5,0.5)}var l=null,p=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,o,C,B,u,x,b,H,I=new THREE.Rectangle,s=new THREE.Rectangle,R=false,E=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0),Y=new THREE.Color(0),
  146. P=new THREE.Color(0),K,V=new THREE.Vector3,M=[],U=[],d=[],h,i,j,g,n=1;this.domElement=q;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(z){switch(z){case "high":n=1;break;case "low":n=0}};this.setSize=function(z,r){m=z;o=r;C=m/2;B=o/2;q.setAttribute("viewBox",-C+" "+-B+" "+m+" "+o);q.setAttribute("width",m);q.setAttribute("height",o);I.set(-C,-B,C,B)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(z,r){var t,v,
  147. w,y,L,F,A,N;this.autoClear&&this.clear();l=p.projectScene(z,r,this.sortElements);g=j=i=0;if(R=z.lights.length>0){A=z.lights;O.setRGB(0,0,0);Y.setRGB(0,0,0);P.setRGB(0,0,0);t=0;for(v=A.length;t<v;t++){w=A[t];y=w.color;if(w instanceof THREE.AmbientLight){O.r+=y.r;O.g+=y.g;O.b+=y.b}else if(w instanceof THREE.DirectionalLight){Y.r+=y.r;Y.g+=y.g;Y.b+=y.b}else if(w instanceof THREE.PointLight){P.r+=y.r;P.g+=y.g;P.b+=y.b}}}t=0;for(v=l.length;t<v;t++){A=l[t];s.empty();if(A instanceof THREE.RenderableParticle){u=
  148. A;u.x*=C;u.y*=-B;w=0;for(y=A.materials.length;w<y;w++)if(N=A.materials[w]){L=u;F=A;N=N;var T=j++;if(U[T]==null){U[T]=document.createElementNS("http://www.w3.org/2000/svg","circle");n==0&&U[T].setAttribute("shape-rendering","crispEdges")}h=U[T];h.setAttribute("cx",L.x);h.setAttribute("cy",L.y);h.setAttribute("r",F.scale.x*C);if(N instanceof THREE.ParticleCircleMaterial){if(R){J.r=O.r+Y.r+P.r;J.g=O.g+Y.g+P.g;J.b=O.b+Y.b+P.b;E.r=N.color.r*J.r;E.g=N.color.g*J.g;E.b=N.color.b*J.b;E.updateStyleString()}else E=
  149. N.color;h.setAttribute("style","fill: "+E.__styleString)}q.appendChild(h)}}else if(A instanceof THREE.RenderableLine){u=A.v1;x=A.v2;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.materials.length;w<y;)if(N=A.materials[w++]){L=u;F=x;N=N;T=g++;if(d[T]==null){d[T]=document.createElementNS("http://www.w3.org/2000/svg","line");n==
  150. 0&&d[T].setAttribute("shape-rendering","crispEdges")}h=d[T];h.setAttribute("x1",L.positionScreen.x);h.setAttribute("y1",L.positionScreen.y);h.setAttribute("x2",F.positionScreen.x);h.setAttribute("y2",F.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){E.__styleString=N.color.__styleString;h.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);q.appendChild(h)}}}}else if(A instanceof
  151. THREE.RenderableFace3){u=A.v1;x=A.v2;b=A.v3;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);if(I.instersects(s)){w=0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){L=0;for(F=A.faceMaterials.length;L<F;)(N=A.faceMaterials[L++])&&
  152. c(u,x,b,A,N,z)}else N&&c(u,x,b,A,N,z)}}}else if(A instanceof THREE.RenderableFace4){u=A.v1;x=A.v2;b=A.v3;H=A.v4;u.positionScreen.x*=C;u.positionScreen.y*=-B;x.positionScreen.x*=C;x.positionScreen.y*=-B;b.positionScreen.x*=C;b.positionScreen.y*=-B;H.positionScreen.x*=C;H.positionScreen.y*=-B;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(b.positionScreen.x,b.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(I.instersects(s)){w=
  153. 0;for(y=A.meshMaterials.length;w<y;){N=A.meshMaterials[w++];if(N instanceof THREE.MeshFaceMaterial){L=0;for(F=A.faceMaterials.length;L<F;)(N=A.faceMaterials[L++])&&e(u,x,b,H,A,N,z)}else N&&e(u,x,b,H,A,N,z)}}}}}};
  154. THREE.WebGLRenderer=function(a){function c(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function e(d,h){if(!d.__webGLVertexBuffer)d.__webGLVertexBuffer=b.createBuffer();if(!d.__webGLNormalBuffer)d.__webGLNormalBuffer=b.createBuffer();if(d.hasPos){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.position);b.vertexAttribPointer(h.attributes.position,
  155. 3,b.FLOAT,false,0,0)}if(d.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,d.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(h.attributes.normal);b.vertexAttribPointer(h.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,d.count);d.count=0}function f(d){if(s!=d.doubleSided){d.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);s=d.doubleSided}if(R!=d.flipSided){d.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);R=d.flipSided}}function k(d){J[0].set(d.n41-
  156. d.n11,d.n42-d.n12,d.n43-d.n13,d.n44-d.n14);J[1].set(d.n41+d.n11,d.n42+d.n12,d.n43+d.n13,d.n44+d.n14);J[2].set(d.n41+d.n21,d.n42+d.n22,d.n43+d.n23,d.n44+d.n24);J[3].set(d.n41-d.n21,d.n42-d.n22,d.n43-d.n23,d.n44-d.n24);J[4].set(d.n41-d.n31,d.n42-d.n32,d.n43-d.n33,d.n44-d.n34);J[5].set(d.n41+d.n31,d.n42+d.n32,d.n43+d.n33,d.n44+d.n34);var h;for(d=0;d<5;d++){h=J[d];h.divideScalar(Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z))}}function l(d){for(var h=d.matrix,i=-d.geometry.boundingSphere.radius*Math.max(d.scale.x,
  157. Math.max(d.scale.y,d.scale.z)),j=0;j<6;j++){d=J[j].x*h.n14+J[j].y*h.n24+J[j].z*h.n34+J[j].w;if(d<=i)return false}return true}function p(d,h){d.list[d.count]=h;d.count+=1}function q(d){var h,i,j=d.object,g=d.opaque,n=d.transparent;n.count=0;d=g.count=0;for(h=j.materials.length;d<h;d++){i=j.materials[d];i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?p(n,i):p(g,i)}}function m(d){var h,i,j,g,n=d.object,z=d.buffer,r=d.opaque,t=d.transparent;t.count=0;d=r.count=0;for(j=n.materials.length;d<j;d++){h=
  158. n.materials[d];if(h instanceof THREE.MeshFaceMaterial){h=0;for(i=z.materials.length;h<i;h++)if(g=z.materials[h])g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}else{g=h;g.opacity&&g.opacity<1||g.blending!=THREE.NormalBlending?p(t,g):p(r,g)}}}function o(d){if(d!=E){switch(d){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);
  159. 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)}E=d}}function C(d,h){if(d&&!d.__webGLFramebuffer){d.__webGLFramebuffer=b.createFramebuffer();d.__webGLRenderbuffer=b.createRenderbuffer();d.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,d.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,d.width,d.height);b.bindTexture(b.TEXTURE_2D,d.__webGLTexture);b.texParameteri(b.TEXTURE_2D,
  160. b.TEXTURE_WRAP_S,u(d.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(d.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(d.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(d.min_filter));b.texImage2D(b.TEXTURE_2D,0,u(d.format),d.width,d.height,0,u(d.format),u(d.type),null);b.bindFramebuffer(b.FRAMEBUFFER,d.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,d.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,
  161. b.RENDERBUFFER,d.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var i,j,g;if(d){i=d.__webGLFramebuffer;j=d.width;g=d.height}else{i=null;j=x.width;g=x.height}if(i!=I){b.bindFramebuffer(b.FRAMEBUFFER,i);b.viewport(0,0,j,g);h&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);I=i}}function B(d,h){var i;if(d=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(d=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,
  162. h);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function u(d){switch(d){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;
  163. case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;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;
  164. case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var x=document.createElement("canvas"),b,H=null,I=null,s=null,R=null,E=null,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Matrix4,Y=new Float32Array(16),P=new Float32Array(16),K=new THREE.Vector4,V=true,M=new THREE.Color(0),U=0;if(a){if(a.antialias!==undefined)V=a.antialias;a.clearColor!==undefined&&M.setHex(a.clearColor);
  165. if(a.clearAlpha!==undefined)U=a.clearAlpha}this.domElement=x;this.autoClear=true;(function(d,h,i){try{b=x.getContext("experimental-webgl",{antialias:d})}catch(j){console.log(j)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(h.r,h.g,h.b,i);_cullEnabled=true})(V,
  166. M,U);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(d,h){x.width=d;x.height=h;b.viewport(0,0,x.width,x.height)};this.setClearColorHex=function(d,h){var i=new THREE.Color(d);b.clearColor(i.r,i.g,i.b,h)};this.setClearColor=function(d,h){b.clearColor(d.r,d.g,d.b,h)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var i,j,g,n=0,z=0,r=0,t,v,w,y=
  167. this.lights,L=y.directional.colors,F=y.directional.positions,A=y.point.colors,N=y.point.positions,T=0,ca=0;i=g=g=0;for(j=h.length;i<j;i++){g=h[i];t=g.color;v=g.position;w=g.intensity;if(g instanceof THREE.AmbientLight){n+=t.r;z+=t.g;r+=t.b}else if(g instanceof THREE.DirectionalLight){g=T*3;L[g]=t.r*w;L[g+1]=t.g*w;L[g+2]=t.b*w;F[g]=v.x;F[g+1]=v.y;F[g+2]=v.z;T+=1}else if(g instanceof THREE.PointLight){g=ca*3;A[g]=t.r*w;A[g+1]=t.g*w;A[g+2]=t.b*w;N[g]=v.x;N[g+1]=v.y;N[g+2]=v.z;ca+=1}}for(i=T*3;i<L.length;i++)L[i]=
  168. 0;for(i=ca*3;i<A.length;i++)A[i]=0;y.point.length=ca;y.directional.length=T;y.ambient[0]=n;y.ambient[1]=z;y.ambient[2]=r};this.createParticleBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(d){d.__webGLVertexBuffer=b.createBuffer();d.__webGLNormalBuffer=b.createBuffer();d.__webGLTangentBuffer=b.createBuffer();
  169. d.__webGLColorBuffer=b.createBuffer();d.__webGLUVBuffer=b.createBuffer();d.__webGLUV2Buffer=b.createBuffer();d.__webGLFaceBuffer=b.createBuffer();d.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__webGLLineCount=h};this.initParticleBuffers=function(d){var h=d.vertices.length;d.__vertexArray=new Float32Array(h*3);d.__colorArray=new Float32Array(h*3);d.__sortArray=[];d.__webGLParticleCount=
  170. h};this.initMeshBuffers=function(d,h){var i,j,g=0,n=0,z=0,r=h.geometry.faces,t=d.faces;i=0;for(j=t.length;i<j;i++){fi=t[i];face=r[fi];if(face instanceof THREE.Face3){g+=3;n+=1;z+=3}else if(face instanceof THREE.Face4){g+=4;n+=2;z+=4}}d.__vertexArray=new Float32Array(g*3);d.__normalArray=new Float32Array(g*3);d.__tangentArray=new Float32Array(g*4);d.__colorArray=new Float32Array(g*3);d.__uvArray=new Float32Array(g*2);d.__uv2Array=new Float32Array(g*2);d.__faceArray=new Uint16Array(n*3);d.__lineArray=
  171. new Uint16Array(z*2);g=false;i=0;for(j=h.materials.length;i<j;i++){r=h.materials[i];if(r instanceof THREE.MeshFaceMaterial){r=0;for(t=d.materials.length;r<t;r++)if(d.materials[r]&&d.materials[r].shading!=undefined&&d.materials[r].shading==THREE.SmoothShading){g=true;break}}else if(r&&r.shading!=undefined&&r.shading==THREE.SmoothShading){g=true;break}if(g)break}d.__needsSmoothNormals=g;d.__webGLFaceCount=n*3;d.__webGLLineCount=z*2};this.setMeshBuffers=function(d,h,i){var j,g,n,z,r,t,v,w,y,L,F=0,A=
  172. 0,N=0,T=0,ca=0,ga=0,Z=0,ka=0,W=0,da=d.__vertexArray,sa=d.__uvArray,va=d.__uv2Array,ea=d.__normalArray,aa=d.__tangentArray,fa=d.__colorArray,la=d.__faceArray,$=d.__lineArray,qa=d.__needsSmoothNormals,na=h.geometry,za=na.__dirtyVertices,Fa=na.__dirtyElements,Aa=na.__dirtyUvs,Da=na.__dirtyNormals,Ba=na.__dirtyTangents,Ca=na.__dirtyColors,ja=na.vertices,Ga=d.faces,Ha=na.faces,Ia=na.uvs,Ka=na.uvs2,pa=na.colors;h=0;for(j=Ga.length;h<j;h++){g=Ga[h];n=Ha[g];t=Ia[g];g=Ka[g];z=n.vertexNormals;r=n.normal;if(n instanceof
  173. THREE.Face3){if(za){v=ja[n.a].position;w=ja[n.b].position;y=ja[n.c].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;A+=9}if(Ca&&pa.length){v=pa[n.a];w=pa[n.b];y=pa[n.c];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;W+=9}if(Ba&&na.hasTangents){v=ja[n.a].tangent;w=ja[n.b].tangent;y=ja[n.c].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=
  174. w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;Z+=12}if(Da)if(z.length==3&&qa)for(n=0;n<3;n++){r=z[n];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(n=0;n<3;n++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(n=0;n<3;n++){z=t[n];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(n=0;n<3;n++){t=g[n];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=F;la[ca+1]=F+1;la[ca+2]=F+2;ca+=3;$[ka]=F;$[ka+1]=F+1;$[ka+2]=F;$[ka+3]=F+2;$[ka+4]=F+1;$[ka+5]=F+2;ka+=6;F+=3}}else if(n instanceof THREE.Face4){if(za){v=
  175. ja[n.a].position;w=ja[n.b].position;y=ja[n.c].position;L=ja[n.d].position;da[A]=v.x;da[A+1]=v.y;da[A+2]=v.z;da[A+3]=w.x;da[A+4]=w.y;da[A+5]=w.z;da[A+6]=y.x;da[A+7]=y.y;da[A+8]=y.z;da[A+9]=L.x;da[A+10]=L.y;da[A+11]=L.z;A+=12}if(Ca&&pa.length){v=pa[n.a];w=pa[n.b];y=pa[n.c];L=pa[n.d];fa[W]=v.r;fa[W+1]=v.g;fa[W+2]=v.b;fa[W+3]=w.r;fa[W+4]=w.g;fa[W+5]=w.b;fa[W+6]=y.r;fa[W+7]=y.g;fa[W+8]=y.b;fa[W+9]=L.r;fa[W+10]=L.g;fa[W+11]=L.b;W+=12}if(Ba&&na.hasTangents){v=ja[n.a].tangent;w=ja[n.b].tangent;y=ja[n.c].tangent;
  176. n=ja[n.d].tangent;aa[Z]=v.x;aa[Z+1]=v.y;aa[Z+2]=v.z;aa[Z+3]=v.w;aa[Z+4]=w.x;aa[Z+5]=w.y;aa[Z+6]=w.z;aa[Z+7]=w.w;aa[Z+8]=y.x;aa[Z+9]=y.y;aa[Z+10]=y.z;aa[Z+11]=y.w;aa[Z+12]=n.x;aa[Z+13]=n.y;aa[Z+14]=n.z;aa[Z+15]=n.w;Z+=16}if(Da)if(z.length==4&&qa)for(n=0;n<4;n++){r=z[n];ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}else for(n=0;n<4;n++){ea[ga]=r.x;ea[ga+1]=r.y;ea[ga+2]=r.z;ga+=3}if(Aa&&t)for(n=0;n<4;n++){z=t[n];sa[N]=z.u;sa[N+1]=z.v;N+=2}if(Aa&&g)for(n=0;n<4;n++){t=g[n];va[T]=t.u;va[T+1]=t.v;T+=2}if(Fa){la[ca]=
  177. F;la[ca+1]=F+1;la[ca+2]=F+2;la[ca+3]=F;la[ca+4]=F+2;la[ca+5]=F+3;ca+=6;$[ka]=F;$[ka+1]=F+1;$[ka+2]=F;$[ka+3]=F+3;$[ka+4]=F+1;$[ka+5]=F+2;$[ka+6]=F+2;$[ka+7]=F+3;ka+=8;F+=4}}}if(za){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,da,i)}if(Ca&&pa.length){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,fa,i)}if(Da){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ea,i)}if(Ba&&na.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,
  178. d.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,aa,i)}if(Aa&&N>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,sa,i)}if(Aa&&T>0){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,va,i)}if(Fa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,la,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,$,i)}};this.setLineBuffers=function(d,h){var i,j,g,n=d.vertices,
  179. z=d.colors,r=n.length,t=z.length,v=d.__vertexArray,w=d.__colorArray,y=d.__dirtyColors;if(d.__dirtyVertices){for(i=0;i<r;i++){j=n[i].position;g=i*3;v[g]=j.x;v[g+1]=j.y;v[g+2]=j.z}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,h)}if(y){for(i=0;i<t;i++){color=z[i];g=i*3;w[g]=color.r;w[g+1]=color.g;w[g+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}};this.setParticleBuffers=function(d,h,i){var j,g,n,z=d.vertices,r=z.length,
  180. t=d.colors,v=t.length,w=d.__vertexArray,y=d.__colorArray,L=d.__sortArray,F=d.__dirtyVertices,A=d.__dirtyColors;if(i.sortParticles){O.multiplySelf(i.matrix);for(j=0;j<r;j++){g=z[j].position;K.copy(g);O.multiplyVector3(K);L[j]=[K.z,j]}L.sort(function(N,T){return T[0]-N[0]});for(j=0;j<r;j++){g=z[L[j][1]].position;n=j*3;w[n]=g.x;w[n+1]=g.y;w[n+2]=g.z}for(j=0;j<v;j++){n=j*3;color=t[L[j][1]];y[n]=color.r;y[n+1]=color.g;y[n+2]=color.b}}else{if(F)for(j=0;j<r;j++){g=z[j].position;n=j*3;w[n]=g.x;w[n+1]=g.y;
  181. w[n+2]=g.z}if(A)for(j=0;j<v;j++){color=t[j];n=j*3;y[n]=color.r;y[n+1]=color.g;y[n+2]=color.b}}if(F||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,h)}if(A||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,d.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,y,h)}};this.initMaterial=function(d,h,i){var j,g;if(d instanceof THREE.MeshDepthMaterial)c(d,THREE.ShaderLib.depth);else if(d instanceof THREE.MeshNormalMaterial)c(d,THREE.ShaderLib.normal);else if(d instanceof
  182. THREE.MeshBasicMaterial)c(d,THREE.ShaderLib.basic);else if(d instanceof THREE.MeshLambertMaterial)c(d,THREE.ShaderLib.lambert);else if(d instanceof THREE.MeshPhongMaterial)c(d,THREE.ShaderLib.phong);else if(d instanceof THREE.LineBasicMaterial)c(d,THREE.ShaderLib.basic);else d instanceof THREE.ParticleBasicMaterial&&c(d,THREE.ShaderLib.particle_basic);var n,z,r,t;g=r=t=0;for(n=h.length;g<n;g++){z=h[g];z instanceof THREE.DirectionalLight&&r++;z instanceof THREE.PointLight&&t++}if(t+r<=4){h=r;t=t}else{h=
  183. Math.ceil(4*r/(t+r));t=4-h}g={directional:h,point:t};t=d.fragment_shader;h=d.vertex_shader;n={fog:i,map:d.map,env_map:d.env_map,light_map:d.light_map,vertex_colors:d.vertex_colors,maxDirLights:g.directional,maxPointLights:g.point};i=b.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.env_map?
  184. "#define USE_ENVMAP":"",n.light_map?"#define USE_LIGHTMAP":"",n.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");n=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.map?"#define USE_MAP":"",n.env_map?"#define USE_ENVMAP":"",n.light_map?"#define USE_LIGHTMAP":"",n.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");
  185. b.attachShader(i,B("fragment",g+t));b.attachShader(i,B("vertex",n+h));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};d.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in d.uniforms)i.push(j);j=d.program;t=0;for(h=i.length;t<h;t++){g=i[t];j.uniforms[g]=b.getUniformLocation(j,
  186. g)}d=d.program;j=["position","normal","uv","uv2","tangent","color"];i=0;for(t=j.length;i<t;i++){h=j[i];d.attributes[h]=b.getAttribLocation(d,h)}};this.setProgram=function(d,h,i,j,g){j.program||this.initMaterial(j,h,i);var n=j.program,z=n.uniforms,r=j.uniforms;if(n!=H){b.useProgram(n);H=n;b.uniformMatrix4fv(z.projectionMatrix,false,Y)}if(i&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof
  187. THREE.ParticleBasicMaterial)){r.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){r.fogNear.value=i.near;r.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)r.fogDensity.value=i.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(n,h);h=this.lights;r.enableLighting.value=h.directional.length+h.point.length;r.ambientLightColor.value=h.ambient;r.directionalLightColor.value=h.directional.colors;r.directionalLightDirection.value=h.directional.positions;
  188. r.pointLightColor.value=h.point.colors;r.pointLightPosition.value=h.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.map.texture=j.map;r.light_map.texture=j.light_map;r.env_map.texture=j.env_map;r.reflectivity.value=j.reflectivity;r.refraction_ratio.value=j.refraction_ratio;r.combine.value=j.combine;r.useRefract.value=
  189. j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){r.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.size.value=j.size;r.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){r.ambient.value.setRGB(j.ambient.r,j.ambient.g,
  190. j.ambient.b);r.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);r.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){r.mNear.value=d.near;r.mFar.value=d.far;r.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)r.opacity.value=j.opacity;var t,v,w;for(t in r)if(w=n.uniforms[t]){i=r[t];v=i.type;h=i.value;if(v=="i")b.uniform1i(w,h);else if(v=="f")b.uniform1f(w,h);else if(v=="fv1")b.uniform1fv(w,h);else if(v=="fv")b.uniform3fv(w,h);else if(v=="v2")b.uniform2f(w,
  191. h.x,h.y);else if(v=="v3")b.uniform3f(w,h.x,h.y,h.z);else if(v=="c")b.uniform3f(w,h.r,h.g,h.b);else if(v=="t"){b.uniform1i(w,h);if(i=i.texture)if(i.image instanceof Array&&i.image.length==6){i=i;h=h;if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,
  192. 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,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(v=0;v<6;++v)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image[v]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+h);b.bindTexture(b.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}else{i=i;h=h;if(!i.__webGLTexture&&
  193. i.image.loaded){i.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,i.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,u(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,u(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,u(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,u(i.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+
  194. h);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture)}}}b.uniformMatrix4fv(z.modelViewMatrix,false,g._modelViewMatrixArray);b.uniformMatrix3fv(z.normalMatrix,false,g._normalMatrixArray);if(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)b.uniform3f(z.cameraPosition,d.position.x,d.position.y,d.position.z);if(j instanceof THREE.MeshShaderMaterial||j.env_map)b.uniformMatrix4fv(z.objectMatrix,false,g._objectMatrixArray);if(j instanceof THREE.MeshPhongMaterial||j instanceof
  195. THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(z.viewMatrix,false,P);return n};this.renderBuffer=function(d,h,i,j,g,n){d=this.setProgram(d,h,i,j,n).attributes;b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.vertexAttribPointer(d.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.position);if(d.color>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>=
  196. 0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>=
  197. 0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(n instanceof THREE.Mesh)if(j.wireframe){b.lineWidth(j.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,
  198. 0)}else if(n instanceof THREE.Line){n=n.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(j.linewidth);b.drawArrays(n,0,g.__webGLLineCount)}else n instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(d,h,i,j){var g,n,z,r,t,v,w,y=d.lights,L=d.fog;h.autoUpdateMatrix&&h.updateMatrix();h.matrix.flattenToArray(P);h.projectionMatrix.flattenToArray(Y);O.multiply(h.projectionMatrix,h.matrix);k(O);this.initWebGLObjects(d,h);C(i,j!==undefined?j:true);this.autoClear&&
  199. this.clear();r=d.__webGLObjects.length;for(j=0;j<r;j++){g=d.__webGLObjects[j];v=g.object;if(v.visible&&(!(v instanceof THREE.Mesh)||l(v))){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,h);m(g);g.render=true}else g.render=false}t=d.__webGLObjectsImmediate.length;for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){if(v.autoUpdateMatrix){v.updateMatrix();v.matrix.flattenToArray(v._objectMatrixArray)}this.setupMatrices(v,
  200. h);q(g)}}o(THREE.NormalBlending);for(j=0;j<r;j++){g=d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);this.renderBuffer(h,y,L,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.opaque;f(v);for(g=0;g<z.count;g++){material=z.list[g];this.setDepthTest(material.depth_test);n=this.setProgram(h,y,L,material,v);v.render(function(F){e(F,n)})}}}for(j=0;j<r;j++){g=
  201. d.__webGLObjects[j];if(g.render){v=g.object;w=g.buffer;z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];o(material.blending);this.setDepthTest(material.depth_test);this.renderBuffer(h,y,L,material,w,v)}}}for(j=0;j<t;j++){g=d.__webGLObjectsImmediate[j];v=g.object;if(v.visible){z=g.transparent;f(v);for(g=0;g<z.count;g++){material=z.list[g];o(material.blending);this.setDepthTest(material.depth_test);n=this.setProgram(h,y,L,material,v);v.render(function(F){e(F,n)})}}}if(i&&i.min_filter!==
  202. THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(d,h){function i(y,L,F,A){if(y[L]==undefined){d.__webGLObjects.push({buffer:F,object:A,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[L]=1}}function j(y,L,F){if(y[L]==undefined){d.__webGLObjectsImmediate.push({object:F,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[L]=1}}var g,n,
  203. z,r,t,v,w;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={};d.__webGLObjectsImmediate=[]}g=0;for(n=d.objects.length;g<n;g++){z=d.objects[g];t=z.geometry;if(d.__webGLObjectsMap[z.id]==undefined){d.__webGLObjectsMap[z.id]={};z._modelViewMatrix=new THREE.Matrix4;z._normalMatrixArray=new Float32Array(9);z._modelViewMatrixArray=new Float32Array(16);z._objectMatrixArray=new Float32Array(16);z.matrix.flattenToArray(z._objectMatrixArray)}w=d.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(r in t.geometryChunks){v=
  204. t.geometryChunks[r];if(!v.__webGLVertexBuffer){this.createMeshBuffers(v);this.initMeshBuffers(v,z);t.__dirtyVertices=true;t.__dirtyElements=true;t.__dirtyUvs=true;t.__dirtyNormals=true;t.__dirtyTangents=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyElements||t.__dirtyUvs||t.__dirtyNormals||t.__dirtyColors||t.__dirtyTangents)this.setMeshBuffers(v,z,b.DYNAMIC_DRAW);i(w,r,v,z)}t.__dirtyVertices=false;t.__dirtyElements=false;t.__dirtyUvs=false;t.__dirtyNormals=false;t.__dirtyTangents=false;
  205. t.__dirtyColors=false}else if(z instanceof THREE.Line){if(!t.__webGLVertexBuffer){this.createLineBuffers(t);this.initLineBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||t.__dirtyColors)this.setLineBuffers(t,b.DYNAMIC_DRAW);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else if(z instanceof THREE.ParticleSystem){if(!t.__webGLVertexBuffer){this.createParticleBuffers(t);this.initParticleBuffers(t);t.__dirtyVertices=true;t.__dirtyColors=true}if(t.__dirtyVertices||
  206. t.__dirtyColors||z.sortParticles)this.setParticleBuffers(t,b.DYNAMIC_DRAW,z,h);i(w,0,t,z);t.__dirtyVertices=false;t.__dirtyColors=false}else z instanceof THREE.MarchingCubes&&j(w,0,z)}};this.removeObject=function(d,h){var i,j;for(i=d.__webGLObjects.length-1;i>=0;i--){j=d.__webGLObjects[i].object;h==j&&d.__webGLObjects.splice(i,1)}};this.setupMatrices=function(d,h){d._modelViewMatrix.multiplyToArray(h.matrix,d.matrix,d._modelViewMatrixArray);d._normalMatrix=THREE.Matrix4.makeInvert3x3(d._modelViewMatrix).transposeIntoArray(d._normalMatrixArray)};
  207. this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="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}};
  208. THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
  209. 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",
  210. 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",
  211. 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",
  212. 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",
  213. 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}",
  214. 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;",
  215. 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"};
  216. 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",
  217. 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)}}};
  218. 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",
  219. 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,
  220. 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,
  221. "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,
  222. 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,
  223. 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,
  224. 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,
  225. 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,
  226. 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,
  227. "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,
  228. "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};
  229. 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};
  230. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};