ThreeDebug.js 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 e,h,b,q,r,l;if(d==0)e=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:e=l;h=d;b=a;break;case 2:e=a;h=d;b=c;break;case 3:e=a;h=l;b=d;break;case 4:e=c;h=a;b=d;break;case 5:e=d;h=a;b=l;break;case 6:case 0:e=d;h=c;b=a}}this.r=e;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,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
  10. a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=
  11. -this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
  12. THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1};
  13. THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
  14. return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
  15. THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  16. THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,h=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(L,t,T,E){E=E.clone().subSelf(t);T=T.clone().subSelf(t);var f=L.clone().subSelf(t);L=E.dot(E);t=E.dot(T);E=E.dot(f);var k=T.dot(T);T=T.dot(f);f=1/(L*k-t*t);k=(k*E-t*T)*f;L=(L*T-t*E)*f;return k>0&&L>0&&k+L<1}var d,e,h,b,q,r,l,m,y,x,
  17. v,w=a.geometry,G=w.vertices,K=[];d=0;for(e=w.faces.length;d<e;d++){h=w.faces[d];x=this.origin.clone();v=this.direction.clone();b=a.matrix.multiplyVector3(G[h.a].position.clone());q=a.matrix.multiplyVector3(G[h.b].position.clone());r=a.matrix.multiplyVector3(G[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(G[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());y=v.dot(m);if(y<0){m=m.dot((new THREE.Vector3).sub(b,x))/y;x=x.addSelf(v.multiplyScalar(m));
  18. if(h instanceof THREE.Face3){if(c(x,b,q,r)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(x,b,q,l)||c(x,q,r,l)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};K.push(h)}}}return K}};
  19. THREE.Rectangle=function(){function a(){b=e-c;q=h-d}var c,d,e,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 e};this.getBottom=function(){return h};this.set=function(l,m,y,x){r=false;c=l;d=m;e=y;h=x;a()};this.addPoint=function(l,m){if(r){r=false;c=l;d=m;e=l;h=m}else{c=c<l?c:l;d=d<m?d:m;e=e>l?e:l;h=h>m?
  20. h:m}a()};this.add3Points=function(l,m,y,x,v,w){if(r){r=false;c=l<y?l<v?l:v:y<v?y:v;d=m<x?m<w?m:w:x<w?x:w;e=l>y?l>v?l:v:y>v?y:v;h=m>x?m>w?m:w:x>w?x:w}else{c=l<y?l<v?l<c?l:c:v<c?v:c:y<v?y<c?y:c:v<c?v:c;d=m<x?m<w?m<d?m:d:w<d?w:d:x<w?x<d?x:d:w<d?w:d;e=l>y?l>v?l>e?l:e:v>e?v:e:y>v?y>e?y:e:v>e?v:e;h=m>x?m>w?m>h?m:h:w>h?w:h:x>w?x>h?x:h:w>h?w:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();e=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
  21. e=e>l.getRight()?e:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;e+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();e=e<l.getRight()?e:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(e,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=e=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
  22. function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", 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,e,h,b,q,r,l,m,y,x,v,w,G,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||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=y||1;this.n34=x||0;this.n41=v||0;this.n42=w||0;this.n43=G||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,e,h,b,q,r,l,m,y,x,v,w,G,K){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=m;this.n33=y;this.n34=x;this.n41=v;this.n42=w;this.n43=G;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 e=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();h.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
  26. this.n31=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,e=a.z,h=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
  27. e+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,m=a.n24,y=a.n31,
  28. x=a.n32,v=a.n33,w=a.n34,G=a.n41,K=a.n42,L=a.n43,t=a.n44,T=c.n11,E=c.n12,f=c.n13,k=c.n14,i=c.n21,g=c.n22,n=c.n23,j=c.n24,o=c.n31,p=c.n32,s=c.n33,u=c.n34,z=c.n41,H=c.n42,F=c.n43,I=c.n44;this.n11=d*T+e*i+h*o+b*z;this.n12=d*E+e*g+h*p+b*H;this.n13=d*f+e*n+h*s+b*F;this.n14=d*k+e*j+h*u+b*I;this.n21=q*T+r*i+l*o+m*z;this.n22=q*E+r*g+l*p+m*H;this.n23=q*f+r*n+l*s+m*F;this.n24=q*k+r*j+l*u+m*I;this.n31=y*T+x*i+v*o+w*z;this.n32=y*E+x*g+v*p+w*H;this.n33=y*f+x*n+v*s+w*F;this.n34=y*k+x*j+v*u+w*I;this.n41=G*T+K*i+
  29. L*o+t*z;this.n42=G*E+K*g+L*p+t*H;this.n43=G*f+K*n+L*s+t*F;this.n44=G*k+K*j+L*u+t*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,m=this.n31,y=this.n32,x=this.n33,v=this.n34,w=this.n41,G=this.n42,K=this.n43,L=this.n44,t=a.n11,T=a.n21,E=a.n31,f=a.n41,k=a.n12,i=a.n22,g=a.n32,n=a.n42,j=a.n13,o=a.n23,p=a.n33,s=a.n43,u=a.n14,z=a.n24,H=a.n34;a=a.n44;this.n11=c*t+d*T+e*E+h*f;this.n12=c*k+d*i+e*g+h*n;this.n13=c*j+d*o+e*p+h*
  30. s;this.n14=c*u+d*z+e*H+h*a;this.n21=b*t+q*T+r*E+l*f;this.n22=b*k+q*i+r*g+l*n;this.n23=b*j+q*o+r*p+l*s;this.n24=b*u+q*z+r*H+l*a;this.n31=m*t+y*T+x*E+v*f;this.n32=m*k+y*i+x*g+v*n;this.n33=m*j+y*o+x*p+v*s;this.n34=m*u+y*z+x*H+v*a;this.n41=w*t+G*T+K*E+L*f;this.n42=w*k+G*i+K*g+L*n;this.n43=w*j+G*o+K*p+L*s;this.n44=w*u+G*z+K*H+L*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
  31. a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,m=this.n32,y=this.n33,x=this.n34,v=this.n41,w=this.n42,G=this.n43,K=this.n44;return e*q*m*v-d*r*m*v-e*b*y*v+c*r*y*v+d*b*x*v-c*q*x*v-e*q*l*w+d*r*l*w+e*h*y*w-a*r*y*w-d*h*x*w+a*q*x*w+e*b*l*G-c*r*l*G-e*h*m*G+a*r*m*G+c*h*x*G-a*b*x*G-d*b*l*K+c*q*l*K+d*h*m*K-a*q*m*K-c*h*y*K+a*b*y*K},transpose:function(){function a(c,d,
  32. e){var h=c[d];c[d]=c[e];c[e]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
  33. a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
  34. Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,m=h*q;this.set(l*b+d,l*q-e*r,l*r+e*q,0,l*q+e*r,m*q+d,m*r-e*b,0,l*r-e*q,m*r+e*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 e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
  36. THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
  37. THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,m=a.n31,y=a.n32,x=a.n33,v=a.n34,w=a.n41,G=a.n42,K=a.n43,L=a.n44,t=new THREE.Matrix4;t.n11=r*v*G-l*x*G+l*y*K-q*v*K-r*y*L+q*x*L;t.n12=h*x*G-e*v*G-h*y*K+d*v*K+e*y*L-d*x*L;t.n13=e*l*G-h*r*G+h*q*K-d*l*K-e*q*L+d*r*L;t.n14=h*r*y-e*l*y-h*q*x+d*l*x+e*q*v-d*r*v;t.n21=l*x*w-r*v*w-l*m*K+b*v*K+r*m*L-b*x*L;t.n22=e*v*w-h*x*w+h*m*K-c*v*K-e*m*L+c*x*L;t.n23=h*r*w-e*l*w-h*b*K+c*l*K+e*b*L-c*r*L;t.n24=e*l*m-h*r*m+
  38. h*b*x-c*l*x-e*b*v+c*r*v;t.n31=q*v*w-l*y*w+l*m*G-b*v*G-q*m*L+b*y*L;t.n32=h*y*w-d*v*w-h*m*G+c*v*G+d*m*L-c*y*L;t.n33=e*l*w-h*q*w+h*b*G-c*l*G-d*b*L+c*q*L;t.n34=h*q*m-d*l*m-h*b*y+c*l*y+d*b*v-c*q*v;t.n41=r*y*w-q*x*w-r*m*G+b*x*G+q*m*K-b*y*K;t.n42=d*x*w-e*y*w+e*m*G-c*x*G-d*m*K+c*y*K;t.n43=e*q*w-d*r*w-e*b*G+c*r*G+d*b*K-c*q*K;t.n44=d*r*m-e*q*m+e*b*y-c*r*y-d*b*x+c*q*x;t.multiplyScalar(1/a.determinant());return t};
  39. THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],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],y=-c[9]*c[0]+c[1]*c[8],x=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*q+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;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*y;d[8]=c*x;return a};
  40. THREE.Matrix4.makeFrustum=function(a,c,d,e,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(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=e;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,e)};
  41. THREE.Matrix4.makeOrtho=function(a,c,d,e,h,b){var q,r,l,m;q=new THREE.Matrix4;r=c-a;l=d-e;m=b-h;a=(c+a)/r;d=(d+e)/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,e,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  44. THREE.Face4=function(a,c,d,e,h,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=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,e,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){b=this.faces[e];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,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
  49. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
  50. c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(u,z,H,F,I,M,N){b=u.vertices[z].position;q=u.vertices[H].position;r=u.vertices[F].position;l=h[I];m=h[M];y=h[N];x=q.x-b.x;v=r.x-b.x;w=q.y-b.y;G=r.y-b.y;
  51. K=q.z-b.z;L=r.z-b.z;t=m.u-l.u;T=y.u-l.u;E=m.v-l.v;f=y.v-l.v;k=1/(t*f-T*E);n.set((f*x-E*v)*k,(f*w-E*G)*k,(f*K-E*L)*k);j.set((t*v-T*x)*k,(t*G-T*w)*k,(t*L-T*K)*k);i[z].addSelf(n);i[H].addSelf(n);i[F].addSelf(n);g[z].addSelf(j);g[H].addSelf(j);g[F].addSelf(j)}var c,d,e,h,b,q,r,l,m,y,x,v,w,G,K,L,t,T,E,f,k,i=[],g=[],n=new THREE.Vector3,j=new THREE.Vector3,o=new THREE.Vector3,p=new THREE.Vector3,s=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;g[c]=new THREE.Vector3}c=0;
  52. for(d=this.faces.length;c<d;c++){e=this.faces[c];h=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
  53. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){s.copy(this.vertices[c].normal);e=i[c];o.copy(e);o.subSelf(s.multiplyScalar(s.dot(e))).normalize();p.cross(this.vertices[c].normal,e);e=p.dot(g[c]);e=e<0?-1:1;this.vertices[c].tangent.set(o.x,o.y,o.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
  54. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
  55. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(y){var x=[];c=0;for(d=y.length;c<d;c++)y[c]==undefined?x.push("undefined"):x.push(y[c].toString());return x.join("_")}var c,d,e,h,b,q,r,l,m={};e=0;for(h=this.faces.length;e<h;e++){b=this.faces[e];
  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(e);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,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
  59. this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
  60. THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
  61. THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
  62. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
  63. THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0};
  64. THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
  65. THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
  66. THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
  67. THREE.LineBasicMaterial=function(a){this.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,e,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=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,e,h={};for(c in a){h[c]={};for(d in a[c]){e=a[c][d];h[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var c,d,e,h={};for(c=0;c<a.length;c++){e=this.clone(a[c]);for(d in e)h[d]=e[d]}return h}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  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(g,n){return n.z-g.z}function c(g,n){var j=0,o=1,p=g.z+g.w,s=n.z+n.w,u=-g.z+g.w,z=-n.z+n.w;if(p>=0&&s>=0&&u>=0&&z>=0)return true;else if(p<0&&s<0||u<0&&z<0)return false;else{if(p<0)j=Math.max(j,p/(p-s));else if(s<0)o=Math.min(o,p/(p-s));if(u<0)j=Math.max(j,u/(u-z));else if(z<0)o=Math.min(o,u/(u-z));if(o<j)return false;else{g.lerpSelf(n,j);n.lerpSelf(g,1-o);return true}}}var d,e,h=[],b,q,r,l=[],m,y,x=[],v,w,G=[],K=new THREE.Vector4,L=new THREE.Vector4,t=new THREE.Matrix4,
  102. T=new THREE.Matrix4,E=[],f=new THREE.Vector4,k=new THREE.Vector4,i;this.projectObjects=function(g,n,j){var o=[],p,s;e=0;t.multiply(n.projectionMatrix,n.matrix);E[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);E[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);E[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);E[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);E[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
  103. t.n33,t.n44-t.n34);E[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);n=0;for(p=E.length;n<p;n++){s=E[n];s.divideScalar(Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z))}p=g.objects;g=0;for(n=p.length;g<n;g++){s=p[g];var u;if(!(u=!s.visible)){if(u=s instanceof THREE.Mesh){a:{u=void 0;for(var z=s.position,H=-s.geometry.boundingSphere.radius*Math.max(s.scale.x,Math.max(s.scale.y,s.scale.z)),F=0;F<6;F++){u=E[F].x*z.x+E[F].y*z.y+E[F].z*z.z+E[F].w;if(u<=H){u=false;break a}}u=true}u=!u}u=u}if(!u){d=
  104. h[e]=h[e]||new THREE.RenderableObject;K.copy(s.position);t.multiplyVector3(K);d.object=s;d.z=K.z;o.push(d);e++}}j&&o.sort(a);return o};this.projectScene=function(g,n,j){var o=[],p=n.near,s=n.far,u,z,H,F,I,M,N,V,W,J,B,P,O,C,R,U;r=y=w=0;n.autoUpdateMatrix&&n.updateMatrix();t.multiply(n.projectionMatrix,n.matrix);M=this.projectObjects(g,n,true);g=0;for(u=M.length;g<u;g++){N=M[g].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;z=0;for(H=O.length;z<H;z++){C=O[z];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);F=C.positionScreen;F.copy(C.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;C.__visible=F.z>p&&F.z<s}P=P.faces;z=0;for(H=P.length;z<H;z++){C=P[z];if(C instanceof THREE.Face3){F=O[C.a];I=O[C.b];R=O[C.c];if(F.__visible&&I.__visible&&R.__visible)if(N.doubleSided||N.flipSided!=(R.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-
  106. (R.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(F.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(R.positionWorld);b.v1.positionScreen.copy(F.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);t.multiplyVector3(b.centroidScreen);R=C.vertexNormals;i=b.vertexNormalsWorld;F=0;for(I=R.length;F<I;F++){U=i[F]=i[F]||new THREE.Vector3;U.copy(R[F]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[z]){b.uvs[0]=N.geometry.uvs[z][0];b.uvs[1]=N.geometry.uvs[z][1];b.uvs[2]=N.geometry.uvs[z][2]}o.push(b);r++}}else if(C instanceof THREE.Face4){F=O[C.a];I=O[C.b];R=O[C.c];U=O[C.d];if(F.__visible&&
  108. I.__visible&&R.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-(U.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.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(F.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
  109. b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(F.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);t.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[z]){b.uvs[0]=N.geometry.uvs[z][0];
  110. b.uvs[1]=N.geometry.uvs[z][1];b.uvs[2]=N.geometry.uvs[z][3]}o.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[z]){q.uvs[0]=N.geometry.uvs[z][1];q.uvs[1]=N.geometry.uvs[z][2];q.uvs[2]=N.geometry.uvs[z][3]}o.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(t,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);z=1;for(H=O.length;z<H;z++){F=O[z];F.positionScreen.copy(F.position);T.multiplyVector4(F.positionScreen);I=O[z-1];f.copy(F.positionScreen);k.copy(I.positionScreen);if(c(f,k)){f.multiplyScalar(1/
  112. f.w);k.multiplyScalar(1/k.w);m=x[y]=x[y]||new THREE.RenderableLine;m.v1.positionScreen.copy(f);m.v2.positionScreen.copy(k);m.z=Math.max(f.z,k.z);m.materials=N.materials;o.push(m);y++}}}else if(N instanceof THREE.Particle){L.set(N.position.x,N.position.y,N.position.z,1);t.multiplyVector4(L);L.z/=L.w;if(L.z>0&&L.z<1){v=G[w]=G[w]||new THREE.RenderableParticle;v.x=L.x/L.w;v.y=L.y/L.w;v.z=L.z;v.rotation=N.rotation.z;v.scale.x=N.scale.x*Math.abs(v.x-(L.x+n.projectionMatrix.n11)/(L.w+n.projectionMatrix.n14));
  113. v.scale.y=N.scale.y*Math.abs(v.y-(L.y+n.projectionMatrix.n22)/(L.w+n.projectionMatrix.n24));v.materials=N.materials;o.push(v);w++}}}}j&&o.sort(a);return o};this.unprojectVector=function(g,n){var j=THREE.Matrix4.makeInvert(n.matrix);j.multiplySelf(THREE.Matrix4.makeInvert(n.projectionMatrix));j.multiplyVector3(g);return g}};
  114. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;e=r;h=d/2;b=e/2};this.render=function(q,r){var l,m,y,x,v,w,G,K;a=c.projectScene(q,r);l=0;for(m=a.length;l<m;l++){v=a[l];if(v instanceof THREE.RenderableParticle){G=v.x*h+h;K=v.y*b+b;y=0;for(x=v.material.length;y<x;y++){w=v.material[y];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=G+"px";w.style.top=K+"px"}}}}}};
  115. THREE.CanvasRenderer=function(){function a(ca){if(v!=ca)m.globalAlpha=v=ca}function c(ca){if(w!=ca){switch(ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}w=ca}}var d=null,e=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,m=h.getContext("2d"),y=new THREE.Color(0),x=0,v=1,w=0,G=null,K=null,L=1,t,T,E,f,k,i,g,n,j,o=new THREE.Color,
  116. p=new THREE.Color,s=new THREE.Color,u=new THREE.Color,z=new THREE.Color,H,F,I,M,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);v=1;w=0;K=G=null;L=1};this.setClearColor=function(ca,la){y.setHex(ca);x=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(y.hex==0&&x==0)m.clearRect(O.getX(),
  118. O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+x+")";m.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,D,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];D=S.color;if(S instanceof THREE.AmbientLight){Y.r+=D.r;Y.g+=D.g;Y.b+=D.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
  119. D.r;fa.g+=D.g;fa.b+=D.b}else if(S instanceof THREE.PointLight){aa.r+=D.r;aa.g+=D.g;aa.b+=D.b}}}function Aa(A,X,S,D){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){D.r+=da.r*$;D.g+=da.g*$;D.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){D.r+=da.r*$;D.g+=da.g*$;D.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
  120. var D,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;D=$*ia;C.set(A.x-S,A.y-D,A.x+S,A.y+D);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;o.r=S.color.r*U.r;o.g=S.color.g*U.g;o.b=S.color.b*U.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;S=X.scale.x*r;D=X.scale.y*l;C.set(A.x-S,A.y-D,A.x+S,A.y+D);if(P.instersects(C)){Q=o.__styleString;if(K!=Q)m.fillStyle=K=Q;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(S,D);m.beginPath();m.arc(0,0,1,0,za,true);m.closePath();m.fill();m.restore()}}}}
  122. function Oa(A,X,S,D){if(D.opacity!=0){a(D.opacity);c(D.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(D instanceof THREE.LineBasicMaterial){o.__styleString=D.color.__styleString;A=D.linewidth;if(L!=A)m.lineWidth=L=A;A=o.__styleString;if(G!=A)m.strokeStyle=G=A;m.stroke();C.inflate(D.linewidth*2)}}}function Ja(A,X,S,D,Q,$){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);f=A.positionScreen.x;k=A.positionScreen.y;i=
  123. X.positionScreen.x;g=X.positionScreen.y;n=S.positionScreen.x;j=S.positionScreen.y;m.beginPath();m.moveTo(f,k);m.lineTo(i,g);m.lineTo(n,j);m.lineTo(f,k);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&wa(f,k,i,g,n,j,Q.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.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(D.vertexNormalsWorld[0]);
  124. M=(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(D.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(D.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(f,k,i,g,n,j,Q.env_map.image,M,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(f,k,i,g,n,j,Q.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);c(THREE.SubtractiveBlending)}if(R)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){p.r=s.r=u.r=Y.r;p.g=s.g=u.g=Y.g;p.b=s.b=u.b=Y.b;Aa($,D.v1.positionWorld,D.vertexNormalsWorld[0],p);Aa($,D.v2.positionWorld,D.vertexNormalsWorld[1],s);Aa($,D.v3.positionWorld,D.vertexNormalsWorld[2],u);z.r=(s.r+u.r)*0.5;z.g=(s.g+u.g)*0.5;
  126. z.b=(s.b+u.b)*0.5;I=Ka(p,s,u,z);wa(f,k,i,g,n,j,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,D.centroidWorld,D.normalWorld,U);o.r=Q.color.r*U.r;o.g=Q.color.g*U.g;o.b=Q.color.b*U.b;o.updateStyleString();Q.wireframe?Ba(o.__styleString,Q.wireframe_linewidth):Ca(o.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){H=la.near;F=la.far;p.r=p.g=p.b=1-Fa(A.positionScreen.z,H,F);s.r=s.g=s.b=1-Fa(X.positionScreen.z,
  127. H,F);u.r=u.g=u.b=1-Fa(S.positionScreen.z,H,F);z.r=(s.r+u.r)*0.5;z.g=(s.g+u.g)*0.5;z.b=(s.b+u.b)*0.5;I=Ka(p,s,u,z);wa(f,k,i,g,n,j,I,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){o.r=Ga(D.normalWorld.x);o.g=Ga(D.normalWorld.y);o.b=Ga(D.normalWorld.z);o.updateStyleString();Q.wireframe?Ba(o.__styleString,Q.wireframe_linewidth):Ca(o.__styleString)}}}function Ba(A,X){if(G!=A)m.strokeStyle=G=A;if(L!=X)m.lineWidth=L=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,D,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;D-=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*D-ja*$)*ta;S=(ra*Q-sa*S)*ta;D=(ra*$-sa*D)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-D*ia;m.save();m.transform(ua,ja,S,D,A,X);m.clip();m.drawImage(da,0,0);m.restore()}function Ka(A,X,S,D){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=~~(D.r*255),sa=~~(D.g*255);D=~~(D.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]=D<0?0:D>255?255:D;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,D=X.y-A.y,Q=1/Math.sqrt(S*S+D*D);S*=Q;D*=Q;X.x+=S;X.y+=D;A.x-=S;A.y-=D}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():m.setTransform(1,0,0,-1,r,l);d=e.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){t=ba;t.x*=r;t.y*=l;
  131. ma=0;for(va=ba.materials.length;ma<va;ma++)Na(t,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){t=ba.v1;T=ba.v2;t.positionScreen.x*=r;t.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(t.positionScreen.x,t.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(t,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){t=ba.v1;T=ba.v2;E=ba.v3;t.positionScreen.x*=
  132. r;t.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;E.positionScreen.x*=r;E.positionScreen.y*=l;if(ba.overdraw){Ha(t.positionScreen,T.positionScreen);Ha(T.positionScreen,E.positionScreen);Ha(E.positionScreen,t.positionScreen)}C.add3Points(t.positionScreen.x,t.positionScreen.y,T.positionScreen.x,T.positionScreen.y,E.positionScreen.x,E.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(t,T,E,ba,ya,ca)}else Ja(t,T,E,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(M,N,V){var W,J,B,P;W=0;for(J=M.lights.length;W<J;W++){B=M.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){j.sub(B.position,N.centroidWorld);j.normalize();P=N.normalWorld.dot(j)*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(M,N,V,W,J,B){u=e(z++);u.setAttribute("d","M "+M.positionScreen.x+
  135. " "+M.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)E.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(B,W,f);E.r=J.color.r*f.r;E.g=J.color.g*f.g;E.b=J.color.b*f.b;E.updateStyleString()}else E.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){n=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
  136. E.setRGB(n,n,n)}else J instanceof THREE.MeshNormalMaterial&&E.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(u)}function d(M,N,V,W,J,B,P){u=e(z++);u.setAttribute("d",
  137. "M "+M.positionScreen.x+" "+M.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)E.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(P,J,f);E.r=B.color.r*f.r;E.g=B.color.g*f.g;E.b=B.color.b*f.b;E.updateStyleString()}else E.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){n=
  138. 1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);E.setRGB(n,n,n)}else B instanceof THREE.MeshNormalMaterial&&E.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(u)}
  139. function e(M){if(o[M]==null){o[M]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&o[M].setAttribute("shape-rendering","crispEdges");return o[M]}return o[M]}function h(M){return M<0?Math.min((1+M)*0.5,0.5):0.5+Math.min(M*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,y,x,v,w,G,K,L=new THREE.Rectangle,t=new THREE.Rectangle,T=false,E=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),i=new THREE.Color(0),
  140. g=new THREE.Color(0),n,j=new THREE.Vector3,o=[],p=[],s=[],u,z,H,F,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(M){switch(M){case "high":I=1;break;case "low":I=0}};this.setSize=function(M,N){l=M;m=N;y=l/2;x=m/2;r.setAttribute("viewBox",-y+" "+-x+" "+l+" "+m);r.setAttribute("width",l);r.setAttribute("height",m);L.set(-y,-x,y,x)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(M,N){var V,W,
  141. J,B,P,O,C,R;this.autoClear&&this.clear();b=q.projectScene(M,N,this.sortElements);F=H=z=0;if(T=M.lights.length>0){C=M.lights;k.setRGB(0,0,0);i.setRGB(0,0,0);g.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){k.r+=B.r;k.g+=B.g;k.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){g.r+=B.r;g.g+=B.g;g.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];t.empty();if(C instanceof THREE.RenderableParticle){v=
  142. C;v.x*=y;v.y*=-x;J=0;for(B=C.materials.length;J<B;J++)if(R=C.materials[J]){P=v;O=C;R=R;var U=H++;if(p[U]==null){p[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&p[U].setAttribute("shape-rendering","crispEdges")}u=p[U];u.setAttribute("cx",P.x);u.setAttribute("cy",P.y);u.setAttribute("r",O.scale.x*y);if(R instanceof THREE.ParticleCircleMaterial){if(T){f.r=k.r+i.r+g.r;f.g=k.g+i.g+g.g;f.b=k.b+i.b+g.b;E.r=R.color.r*f.r;E.g=R.color.g*f.g;E.b=R.color.b*f.b;E.updateStyleString()}else E=
  143. R.color;u.setAttribute("style","fill: "+E.__styleString)}r.appendChild(u)}}else if(C instanceof THREE.RenderableLine){v=C.v1;w=C.v2;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);if(L.instersects(t)){J=0;for(B=C.materials.length;J<B;)if(R=C.materials[J++]){P=v;O=w;R=R;U=F++;if(s[U]==null){s[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
  144. 0&&s[U].setAttribute("shape-rendering","crispEdges")}u=s[U];u.setAttribute("x1",P.positionScreen.x);u.setAttribute("y1",P.positionScreen.y);u.setAttribute("x2",O.positionScreen.x);u.setAttribute("y2",O.positionScreen.y);if(R instanceof THREE.LineBasicMaterial){E.__styleString=R.color.__styleString;u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+R.linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.linecap+"; stroke-linejoin: "+R.linejoin);r.appendChild(u)}}}}else if(C instanceof
  145. THREE.RenderableFace3){v=C.v1;w=C.v2;G=C.v3;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;G.positionScreen.x*=y;G.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(G.positionScreen.x,G.positionScreen.y);if(L.instersects(t)){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(v,w,G,C,R,M)}else R&&c(v,w,G,C,R,M)}}}else if(C instanceof THREE.RenderableFace4){v=C.v1;w=C.v2;G=C.v3;K=C.v4;v.positionScreen.x*=y;v.positionScreen.y*=-x;w.positionScreen.x*=y;w.positionScreen.y*=-x;G.positionScreen.x*=y;G.positionScreen.y*=-x;K.positionScreen.x*=y;K.positionScreen.y*=-x;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(G.positionScreen.x,G.positionScreen.y);t.addPoint(K.positionScreen.x,K.positionScreen.y);if(L.instersects(t)){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(v,w,G,K,C,R,M)}else R&&d(v,w,G,K,C,R,M)}}}}}};
  148. THREE.WebGLRenderer=function(a){function c(f,k){f.fragment_shader=k.fragment_shader;f.vertex_shader=k.vertex_shader;f.uniforms=Uniforms.clone(k.uniforms)}function d(f,k){var i;if(f=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,k);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function e(f){switch(f){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,y=new Float32Array(16),x=new Float32Array(16),
  151. v=new Float32Array(16),w=new Float32Array(9),G=new Float32Array(16),K=new THREE.Matrix4,L=new THREE.Vector4,t=true,T=new THREE.Color(0),E=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)E=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(f,k,i){try{b=h.getContext("experimental-webgl",{antialias:f})}catch(g){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);
  152. 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(k.r,k.g,k.b,i)})(t,T,E);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,k){h.width=f;h.height=k;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(f,k){var i=new THREE.Color(f);b.clearColor(i.r,i.g,i.b,k)};
  153. this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var i,g,n,j=0,o=0,p=0,s,u,z,H=this.lights,F=H.directional.colors,I=H.directional.positions,M=H.point.colors,N=H.point.positions,V=0,W=0;i=0;for(g=k.length;i<g;i++){n=k[i];s=n.color;u=n.position;z=n.intensity;if(n instanceof THREE.AmbientLight){j+=s.r;o+=s.g;p+=s.b}else if(n instanceof THREE.DirectionalLight){F[V*3]=s.r*z;F[V*3+1]=s.g*z;F[V*3+2]=s.b*z;I[V*3]=u.x;I[V*3+1]=u.y;I[V*3+2]=u.z;V+=1}else if(n instanceof
  154. THREE.PointLight){M[W*3]=s.r*z;M[W*3+1]=s.g*z;M[W*3+2]=s.b*z;N[W*3]=u.x;N[W*3+1]=u.y;N[W*3+2]=u.z;W+=1}}H.point.length=W;H.directional.length=V;H.ambient[0]=j;H.ambient[1]=o;H.ambient[2]=p};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLParticleBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=
  155. b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=b.createBuffer();f.__webGLUV2Buffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__lineArray=new Uint16Array(k);f.__webGLLineCount=k};this.initParticleBuffers=function(f){var k=f.vertices.length;f.__vertexArray=new Float32Array(k*3);f.__colorArray=
  156. new Float32Array(k*3);f.__particleArray=new Uint16Array(k);f.__sortArray=[];f.__webGLParticleCount=k};this.initMeshBuffers=function(f,k){var i,g,n=0,j=0,o=0,p=k.geometry.faces,s=f.faces;i=0;for(g=s.length;i<g;i++){fi=s[i];face=p[fi];if(face instanceof THREE.Face3){n+=3;j+=1;o+=3}else if(face instanceof THREE.Face4){n+=4;j+=2;o+=4}}f.__vertexArray=new Float32Array(n*3);f.__normalArray=new Float32Array(n*3);f.__tangentArray=new Float32Array(n*4);f.__uvArray=new Float32Array(n*2);f.__uv2Array=new Float32Array(n*
  157. 2);f.__faceArray=new Uint16Array(j*3);f.__lineArray=new Uint16Array(o*2);n=false;i=0;for(g=k.materials.length;i<g;i++){p=k.materials[i];if(p instanceof THREE.MeshFaceMaterial){p=0;for(s=f.materials.length;p<s;p++)if(f.materials[p]&&f.materials[p].shading!=undefined&&f.materials[p].shading==THREE.SmoothShading){n=true;break}}else if(p&&p.shading!=undefined&&p.shading==THREE.SmoothShading){n=true;break}if(n)break}f.__needsSmoothNormals=n;f.__webGLFaceCount=j*3;f.__webGLLineCount=o*2};this.setMeshBuffers=
  158. function(f,k,i){var g,n,j,o,p,s,u,z,H,F,I=0,M=0,N=0,V=0,W=0,J=0,B=0,P=0,O=f.__vertexArray,C=f.__uvArray,R=f.__uv2Array,U=f.__normalArray,Y=f.__tangentArray,fa=f.__faceArray,aa=f.__lineArray,za=f.__needsSmoothNormals,Z=k.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=f.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;k=0;for(g=qa.length;k<g;k++){n=qa[k];j=ca[n];s=la[n];n=Ea[n];o=j.vertexNormals;p=j.normal;if(j instanceof THREE.Face3){if(na){u=
  159. ea[j.a].position;z=ea[j.b].position;H=ea[j.c].position;O[M]=u.x;O[M+1]=u.y;O[M+2]=u.z;O[M+3]=z.x;O[M+4]=z.y;O[M+5]=z.z;O[M+6]=H.x;O[M+7]=H.y;O[M+8]=H.z;M+=9}if(pa&&Z.hasTangents){u=ea[j.a].tangent;z=ea[j.b].tangent;H=ea[j.c].tangent;Y[B]=u.x;Y[B+1]=u.y;Y[B+2]=u.z;Y[B+3]=u.w;Y[B+4]=z.x;Y[B+5]=z.y;Y[B+6]=z.z;Y[B+7]=z.w;Y[B+8]=H.x;Y[B+9]=H.y;Y[B+10]=H.z;Y[B+11]=H.w;B+=12}if(ga)if(o.length==3&&za)for(j=0;j<3;j++){p=o[j];U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}else for(j=0;j<3;j++){U[J]=p.x;U[J+1]=p.y;U[J+
  160. 2]=p.z;J+=3}if(ka&&s)for(j=0;j<3;j++){o=s[j];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&n)for(j=0;j<3;j++){s=n[j];R[V]=s.u;R[V+1]=s.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(j instanceof THREE.Face4){if(na){u=ea[j.a].position;z=ea[j.b].position;H=ea[j.c].position;F=ea[j.d].position;O[M]=u.x;O[M+1]=u.y;O[M+2]=u.z;O[M+3]=z.x;O[M+4]=z.y;O[M+5]=z.z;O[M+6]=H.x;O[M+7]=H.y;O[M+8]=H.z;O[M+9]=F.x;O[M+10]=F.y;O[M+11]=F.z;M+=
  161. 12}if(pa&&Z.hasTangents){u=ea[j.a].tangent;z=ea[j.b].tangent;H=ea[j.c].tangent;j=ea[j.d].tangent;Y[B]=u.x;Y[B+1]=u.y;Y[B+2]=u.z;Y[B+3]=u.w;Y[B+4]=z.x;Y[B+5]=z.y;Y[B+6]=z.z;Y[B+7]=z.w;Y[B+8]=H.x;Y[B+9]=H.y;Y[B+10]=H.z;Y[B+11]=H.w;Y[B+12]=j.x;Y[B+13]=j.y;Y[B+14]=j.z;Y[B+15]=j.w;B+=16}if(ga)if(o.length==4&&za)for(j=0;j<4;j++){p=o[j];U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}else for(j=0;j<4;j++){U[J]=p.x;U[J+1]=p.y;U[J+2]=p.z;J+=3}if(ka&&s)for(j=0;j<4;j++){o=s[j];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&n)for(j=0;j<
  162. 4;j++){s=n[j];R[V]=s.u;R[V+1]=s.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,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
  163. Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,R,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(f,k){var i,g,n,j=f.vertices,o=j.length,p=f.__vertexArray,s=f.__lineArray,u=
  164. f.__dirtyElements;if(f.__dirtyVertices){for(i=0;i<o;i++){g=j[i].position;n=i*3;p[n]=g.x;p[n+1]=g.y;p[n+2]=g.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,p,k)}if(u){for(i=0;i<o;i++)s[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,s,k)}};this.setParticleBuffers=function(f,k,i,g){var n,j,o;j=f.vertices;var p=j.length,s=f.colors,u=s.length,z=f.__vertexArray,H=f.__particleArray,F=f.__colorArray,I=f.__sortArray,M=f.__dirtyVertices,
  165. N=f.__dirtyElements,V=f.__dirtyColors;if(i.sortParticles){K.multiply(g.projectionMatrix,g.matrix);K.multiplySelf(i.matrix);for(n=0;n<p;n++){o=j[n].position;L.copy(o);K.multiplyVector3(L);I[n]=[L.z,n]}I.sort(function(W,J){return J[0]-W[0]});for(n=0;n<p;n++){o=j[I[n][1]].position;g=n*3;z[g]=o.x;z[g+1]=o.y;z[g+2]=o.z}for(j=0;j<u;j++){g=j*3;color=s[I[j][1]];F[g]=color.r;F[g+1]=color.g;F[g+2]=color.b}}else{if(M)for(n=0;n<p;n++){o=j[n].position;g=n*3;z[g]=o.x;z[g+1]=o.y;z[g+2]=o.z}if(V)for(j=0;j<u;j++){color=
  166. s[j];g=j*3;F[g]=color.r;F[g+1]=color.g;F[g+2]=color.b}}if(N){for(n=0;n<p;n++)H[n]=n;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,H,k)}if(M||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,k)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,F,k)}};this.initMaterial=function(f,k,i){if(!f.program){var g,n;if(f instanceof THREE.MeshDepthMaterial)c(f,
  167. THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);var j,o,p,s;n=p=s=0;for(j=k.length;n<
  168. j;n++){o=k[n];o instanceof THREE.DirectionalLight&&p++;o instanceof THREE.PointLight&&s++}if(s+p<=4){k=p;s=s}else{k=Math.ceil(4*p/(s+p));s=4-k}n={directional:k,point:s};s=f.fragment_shader;k=f.vertex_shader;j={fog:i,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:n.directional,maxPointLights:n.point};i=b.createProgram();n=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,
  169. j.fog?"#define USE_FOG":"",j.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",j.map?"#define USE_MAP":"",j.env_map?"#define USE_ENVMAP":"",j.light_map?"#define USE_LIGHTMAP":"",j.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,j.map?"#define USE_MAP":"",j.env_map?"#define USE_ENVMAP":
  170. "",j.light_map?"#define USE_LIGHTMAP":"",j.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",n+s));b.attachShader(i,d("vertex",j+k));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={};f.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(g in f.uniforms)i.push(g);g=f.program;s=0;for(k=i.length;s<k;s++){n=i[s];g.uniforms[n]=b.getUniformLocation(g,n)}f=f.program;g=["position","normal","uv","uv2","tangent","color"];i=0;for(s=g.length;i<s;i++){k=g[i];f.attributes[k]=
  172. b.getAttribLocation(f,k)}}};this.renderBuffer=function(f,k,i,g,n,j){var o;this.initMaterial(g,k,i);o=g.program;if(o!=q){b.useProgram(o);q=o}this.loadCamera(o,f);this.loadMatrices(o);if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial){this.setupLights(o,k);k=this.lights;g.uniforms.enableLighting.value=k.directional.length+k.point.length;g.uniforms.ambientLightColor.value=k.ambient;g.uniforms.directionalLightColor.value=k.directional.colors;g.uniforms.directionalLightDirection.value=
  173. k.directional.positions;g.uniforms.pointLightColor.value=k.point.colors;g.uniforms.pointLightPosition.value=k.point.positions}if(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial){g.uniforms.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.map.texture=g.map;g.uniforms.light_map.texture=g.light_map;g.uniforms.env_map.texture=g.env_map;g.uniforms.reflectivity.value=
  174. g.reflectivity;g.uniforms.refraction_ratio.value=g.refraction_ratio;g.uniforms.combine.value=g.combine;g.uniforms.useRefract.value=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.LineBasicMaterial){g.uniforms.diffuse.value.setRGB(g.color.r*g.opacity,
  175. g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.ParticleBasicMaterial){g.uniforms.psColor.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);g.uniforms.opacity.value=g.opacity;g.uniforms.size.value=g.size;g.uniforms.map.texture=
  176. g.map;if(i){g.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){g.uniforms.fogNear.value=i.near;g.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)g.uniforms.fogDensity.value=i.density}}if(g instanceof THREE.MeshPhongMaterial){g.uniforms.ambient.value.setRGB(g.ambient.r,g.ambient.g,g.ambient.b);g.uniforms.specular.value.setRGB(g.specular.r,g.specular.g,g.specular.b);g.uniforms.shininess.value=g.shininess}if(g instanceof THREE.MeshDepthMaterial){g.uniforms.mNear.value=
  177. f.near;g.uniforms.mFar.value=f.far}f=g.uniforms;var p,s,u;for(p in f)if(u=o.uniforms[p]){k=f[p];s=k.type;i=k.value;if(s=="i")b.uniform1i(u,i);else if(s=="f")b.uniform1f(u,i);else if(s=="fv1")b.uniform1fv(u,i);else if(s=="fv")b.uniform3fv(u,i);else if(s=="v2")b.uniform2f(u,i.x,i.y);else if(s=="v3")b.uniform3f(u,i.x,i.y,i.z);else if(s=="c")b.uniform3f(u,i.r,i.g,i.b);else if(s=="t"){b.uniform1i(u,i);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;i=i;if(k.image.length==6){if(!k.image.__webGLTextureCube&&
  178. !k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.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(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
  179. s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;i=i;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(k.wrap_s));
  180. b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(k.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}o=o.attributes;b.bindBuffer(b.ARRAY_BUFFER,n.__webGLVertexBuffer);b.vertexAttribPointer(o.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.position);if(o.color>=
  181. 0){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLColorBuffer);b.vertexAttribPointer(o.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.color)}if(o.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLNormalBuffer);b.vertexAttribPointer(o.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.normal)}if(o.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLTangentBuffer);b.vertexAttribPointer(o.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(n.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,
  182. n.__webGLUVBuffer);b.vertexAttribPointer(o.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.uv)}else b.disableVertexAttribArray(o.uv);if(o.uv2>=0)if(n.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,n.__webGLUV2Buffer);b.vertexAttribPointer(o.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(o.uv2)}else b.disableVertexAttribArray(o.uv2);if(g.wireframe||g instanceof THREE.LineBasicMaterial){o=g.wireframe_linewidth!==undefined?g.wireframe_linewidth:g.linewidth!==undefined?g.linewidth:1;g=g instanceof
  183. THREE.LineBasicMaterial&&j.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(o);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);b.drawElements(g,n.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(g instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,n.__webGLParticleBuffer);b.drawElements(b.POINTS,n.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,n.__webGLFaceCount,b.UNSIGNED_SHORT,
  184. 0)}};this.renderPass=function(f,k,i,g,n,j,o){var p,s,u,z,H;u=0;for(z=g.materials.length;u<z;u++){p=g.materials[u];if(p instanceof THREE.MeshFaceMaterial){p=0;for(s=n.materials.length;p<s;p++)if((H=n.materials[p])&&H.blending==j&&H.opacity<1==o){this.setBlending(H.blending);this.renderBuffer(f,k,i,H,n,g)}}else if((H=p)&&H.blending==j&&H.opacity<1==o){this.setBlending(H.blending);this.renderBuffer(f,k,i,H,n,g)}}};this.render=function(f,k,i,g){var n,j,o,p=f.lights,s=f.fog;k.autoUpdateMatrix&&k.updateMatrix();
  185. y.set(k.matrix.flatten());v.set(k.projectionMatrix.flatten());this.initWebGLObjects(f,k);g=g!==undefined?g: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,e(i.wrap_s));b.texParameteri(b.TEXTURE_2D,
  186. b.TEXTURE_WRAP_T,e(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(i.format),i.width,i.height,0,e(i.format),e(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,
  187. null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(i){n=i.__webGLFramebuffer;o=i.width;j=i.height}else{n=null;o=h.width;j=h.height}if(n!=r){b.bindFramebuffer(b.FRAMEBUFFER,n);b.viewport(0,0,o,j);g&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=n}this.autoClear&&this.clear();n=f.__webGLObjects.length;for(g=0;g<n;g++){j=f.__webGLObjects[g];o=j.object;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();if(o.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);
  188. o.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(g=0;g<n;g++){j=f.__webGLObjects[g];o=j.object;j=j.buffer;if(o.visible){this.setupMatrices(o,k);this.renderPass(k,p,s,o,j,THREE.NormalBlending,false)}}for(g=0;g<n;g++){j=f.__webGLObjects[g];o=j.object;j=j.buffer;if(o.visible){this.setupMatrices(o,k);this.renderPass(k,p,s,o,j,THREE.AdditiveBlending,false);this.renderPass(k,p,s,o,j,THREE.SubtractiveBlending,false);this.renderPass(k,p,s,o,j,THREE.AdditiveBlending,true);this.renderPass(k,p,s,o,j,THREE.SubtractiveBlending,
  189. true);this.renderPass(k,p,s,o,j,THREE.NormalBlending,true);this.renderPass(k,p,s,o,j,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(f,k){function i(z,H,F,I){if(z[H]==undefined){f.__webGLObjects.push({buffer:F,object:I});z[H]=1}}var g,n,j,o,p,s,u;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap=
  190. {}}g=0;for(n=f.objects.length;g<n;g++){j=f.objects[g];p=j.geometry;if(f.__webGLObjectsMap[j.id]==undefined)f.__webGLObjectsMap[j.id]={};u=f.__webGLObjectsMap[j.id];if(j instanceof THREE.Mesh){for(o in p.geometryChunks){s=p.geometryChunks[o];if(!s.__webGLVertexBuffer){this.createMeshBuffers(s);this.initMeshBuffers(s,j);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(s,
  191. j,b.DYNAMIC_DRAW);i(u,o,s,j)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(j instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,b.DYNAMIC_DRAW);i(u,0,p,j);p.__dirtyVertices=false;p.__dirtyElements=false}else if(j instanceof THREE.ParticleSystem){if(!p.__webGLVertexBuffer){this.createParticleBuffers(p);
  192. this.initParticleBuffers(p);p.__dirtyVertices=true;p.__dirtyColors=true;p.__dirtyElements=true}if(p.__dirtyVertices||p.__dirtyColors||j.sortParticles)this.setParticleBuffers(p,b.DYNAMIC_DRAW,j,k);i(u,0,p,j);p.__dirtyVertices=false;p.__dirtyColors=false;p.__dirtyElements=false}}};this.removeObject=function(f,k){var i,g;for(i=f.__webGLObjects.length-1;i>=0;i--){g=f.__webGLObjects[i].object;k==g&&f.__webGLObjects.splice(i,1)}};this.setupMatrices=function(f,k){l.multiply(k.matrix,f.matrix);x.set(l.flatten());
  193. m=THREE.Matrix4.makeInvert3x3(l).transpose();w.set(m.m);G.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,y);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,x);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,v);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,w);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,G)};this.loadCamera=function(f,k){b.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=
  194. function(f){switch(f){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);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(f,k){if(f){!k||k=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?
  195. 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}};
  196. THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
  197. 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",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",
  198. map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",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",
  199. lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",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",
  200. 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}",
  201. 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",
  202. 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"};
  203. 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",
  204. 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)}}};
  205. 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}",
  206. 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 );",
  207. 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")},
  208. 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,
  209. 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,
  210. 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;",
  211. 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 );",
  212. 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;",
  213. 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,
  214. "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};
  215. 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};
  216. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};