ThreeDebug.js 102 KB

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