Three.js 127 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. // Three.js r32 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=!0;this.setHex(a)};
  3. THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,h,l,m,k;if(c==0)e=g=h=0;else{l=Math.floor(a*6);m=a*6-l;a=c*(1-b);k=c*(1-b*m);b=c*(1-b*(1-m));switch(l){case 1:e=k;g=c;h=a;break;case 2:e=a;g=c;h=b;break;case 3:e=a;g=k;h=c;break;case 4:e=b;g=a;h=c;break;case 5:e=c;g=a;h=k;break;case 6:case 0:e=c;g=b;h=a}}this.r=e;this.g=g;this.b=h;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,b){this.x=a||0;this.y=b||0};
  6. THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
  8. THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
  9. cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,e=this.z;this.x=c*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.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 b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+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},lengthManhattan:function(){return this.x+
  11. this.y+this.z},negate:function(){this.x=-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 ( "+
  12. this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1};
  13. THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
  16. THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,l){return h.distance-l.distance});return g},intersectObject:function(a){function b(J,r,d,I){I=I.clone().subSelf(r);d=d.clone().subSelf(r);var S=J.clone().subSelf(r);J=I.dot(I);r=I.dot(d);I=I.dot(S);var V=d.dot(d);d=d.dot(S);S=1/(J*V-r*r);V=(V*I-r*d)*S;J=(J*d-r*I)*S;return V>0&&J>0&&V+J<1}var c,e,g,h,l,m,k,o,u,x,
  17. v,A=a.geometry,K=A.vertices,N=[];c=0;for(e=A.faces.length;c<e;c++){g=A.faces[c];x=this.origin.clone();v=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.rotationMatrix);h=k.multiplyVector3(K[g.a].position.clone());l=k.multiplyVector3(K[g.b].position.clone());m=k.multiplyVector3(K[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(K[g.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(g.normal.clone());u=v.dot(o);if(u<0){o=o.dot((new THREE.Vector3).sub(h,
  18. x))/u;x=x.addSelf(v.multiplyScalar(o));if(g instanceof THREE.Face3){if(b(x,h,l,m)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};N.push(g)}}else if(g instanceof THREE.Face4&&(b(x,h,l,k)||b(x,l,m,k))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};N.push(g)}}}return N}};
  19. THREE.Rectangle=function(){function a(){h=e-b;l=g-c}var b,c,e,g,h,l,m=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,o,u,x){m=!1;b=k;c=o;e=u;g=x;a()};this.addPoint=function(k,o){if(m){m=!1;b=k;c=o;e=k;g=o}else{b=b<k?b:k;c=c<o?c:o;e=e>k?e:k;g=g>o?g:o}a()};
  20. this.add3Points=function(k,o,u,x,v,A){if(m){m=!1;b=k<u?k<v?k:v:u<v?u:v;c=o<x?o<A?o:A:x<A?x:A;e=k>u?k>v?k:v:u>v?u:v;g=o>x?o>A?o:A:x>A?x:A}else{b=k<u?k<v?k<b?k:b:v<b?v:b:u<v?u<b?u:b:v<b?v:b;c=o<x?o<A?o<c?o:c:A<c?A:c:x<A?x<c?x:c:A<c?A:c;e=k>u?k>v?k>e?k:e:v>e?v:e:u>v?u>e?u:e:v>e?v:e;g=o>x?o>A?o>g?o:g:A>g?A:g:x>A?x>g?x:g:A>g?A:g}a()};this.addRectangle=function(k){if(m){m=!1;b=k.getLeft();c=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();e=e>k.getRight()?
  21. e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){m=!0;g=e=c=b=0;a()};this.isEmpty=function(){return m};this.toString=function(){return"THREE.Rectangle ( left: "+
  22. b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+h+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
  23. THREE.Matrix4=function(a,b,c,e,g,h,l,m,k,o,u,x,v,A,K,N){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=l||0;this.n24=m||0;this.n31=k||0;this.n32=o||0;this.n33=u||1;this.n34=x||0;this.n41=v||0;this.n42=A||0;this.n43=K||0;this.n44=N||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,b,c,e,g,h,l,m,k,o,u,x,v,A,K,N){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=h;this.n23=l;this.n24=m;this.n31=k;this.n32=o;this.n33=u;this.n34=x;this.n41=v;this.n42=A;this.n43=K;this.n44=N;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,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,h=THREE.Matrix4.__tmpVec3;h.sub(a,b).normalize();e.cross(c,h).normalize();g.cross(h,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
  26. this.n31=h.x;this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
  27. a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*
  28. a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,h=a.n14,l=a.n21,m=a.n22,k=a.n23,o=a.n24,u=a.n31,x=a.n32,v=a.n33,A=a.n34,K=a.n41,N=a.n42,J=a.n43,r=a.n44,d=b.n11,I=b.n12,S=b.n13,V=b.n14,ea=b.n21,T=b.n22,M=b.n23,aa=b.n24,R=b.n31,ca=b.n32,W=b.n33,E=b.n34,O=b.n41,ia=b.n42,Q=b.n43,f=b.n44;this.n11=c*d+e*ea+g*R+h*O;this.n12=c*I+e*T+g*ca+h*ia;this.n13=c*S+e*M+g*W+h*Q;this.n14=c*V+e*aa+g*E+h*f;this.n21=l*d+m*ea+k*R+o*O;this.n22=l*I+m*T+k*ca+o*ia;this.n23=
  29. l*S+m*M+k*W+o*Q;this.n24=l*V+m*aa+k*E+o*f;this.n31=u*d+x*ea+v*R+A*O;this.n32=u*I+x*T+v*ca+A*ia;this.n33=u*S+x*M+v*W+A*Q;this.n34=u*V+x*aa+v*E+A*f;this.n41=K*d+N*ea+J*R+r*O;this.n42=K*I+N*T+J*ca+r*ia;this.n43=K*S+N*M+J*W+r*Q;this.n44=K*V+N*aa+J*E+r*f;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,h=a.n13,l=a.n14,m=a.n21,k=a.n22,o=a.n23,u=a.n24,x=a.n31,v=a.n32,A=a.n33,K=a.n34,N=a.n41,J=a.n42,r=a.n43;a=a.n44;var d=b.n11,I=b.n12,S=b.n13,V=b.n14,ea=b.n21,T=b.n22,M=b.n23,aa=b.n24,R=b.n31,
  30. ca=b.n32,W=b.n33,E=b.n34,O=b.n41,ia=b.n42,Q=b.n43;b=b.n44;this.n11=e*d+g*ea+h*R+l*O;this.n12=e*I+g*T+h*ca+l*ia;this.n13=e*S+g*M+h*W+l*Q;this.n14=e*V+g*aa+h*E+l*b;this.n21=m*d+k*ea+o*R+u*O;this.n22=m*I+k*T+o*ca+u*ia;this.n23=m*S+k*M+o*W+u*Q;this.n24=m*V+k*aa+o*E+u*b;this.n31=x*d+v*ea+A*R+K*O;this.n32=x*I+v*T+A*ca+K*ia;this.n33=x*S+v*M+A*W+K*Q;this.n34=x*V+v*aa+A*E+K*b;this.n41=N*d+J*ea+r*R+a*O;this.n42=N*I+J*T+r*ca+a*ia;this.n43=N*S+J*M+r*W+a*Q;this.n44=N*V+J*aa+r*E+a*b;c[0]=this.n11;c[1]=this.n21;
  31. c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,h=this.n21,l=this.n22,m=this.n23,k=this.n24,o=this.n31,u=this.n32,x=this.n33,v=this.n34,A=this.n41,K=this.n42,N=this.n43,J=this.n44,r=a.n11,d=a.n21,I=a.n31,S=a.n41,V=a.n12,ea=a.n22,T=a.n32,M=a.n42,aa=a.n13,R=a.n23,
  32. ca=a.n33,W=a.n43,E=a.n14,O=a.n24,ia=a.n34;a=a.n44;this.n11=b*r+c*d+e*I+g*S;this.n12=b*V+c*ea+e*T+g*M;this.n13=b*aa+c*R+e*ca+g*W;this.n14=b*E+c*O+e*ia+g*a;this.n21=h*r+l*d+m*I+k*S;this.n22=h*V+l*ea+m*T+k*M;this.n23=h*aa+l*R+m*ca+k*W;this.n24=h*E+l*O+m*ia+k*a;this.n31=o*r+u*d+x*I+v*S;this.n32=o*V+u*ea+x*T+v*M;this.n33=o*aa+u*R+x*ca+v*W;this.n34=o*E+u*O+x*ia+v*a;this.n41=A*r+K*d+N*I+J*S;this.n42=A*V+K*ea+N*T+J*M;this.n43=A*aa+K*R+N*ca+J*W;this.n44=A*E+K*O+N*ia+J*a;return this},multiplyScalar:function(a){this.n11*=
  33. a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,h=this.n22,l=this.n23,m=this.n24,k=this.n31,o=this.n32,u=this.n33,x=this.n34,v=this.n41,A=this.n42,K=this.n43,N=this.n44;return e*l*o*v-c*m*o*v-e*h*u*v+b*m*u*v+c*h*x*v-b*l*x*v-e*l*k*A+c*m*k*A+e*g*u*A-a*m*u*A-c*g*x*A+a*l*x*A+
  34. e*h*k*K-b*m*k*K-e*g*o*K+a*m*o*K+b*g*x*K-a*h*x*K-c*h*k*N+b*l*k*N+c*g*o*N-a*l*o*N-b*g*u*N+a*h*u*N},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;
  35. a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=
  36. 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},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);
  37. return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),g=1-c,h=a.x,l=a.y,m=a.z,k=g*
  38. h,o=g*l;this.set(k*h+c,k*l-e*m,k*m+e*l,0,k*l+e*m,o*l+c,o*m-e*h,0,k*m-e*l,o*m+e*h,g*m*m+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(b);b=Math.sin(b);var l=a*e,m=c*e;this.n11=a*g;this.n12=c*b-l*h;this.n13=l*b+c*h;this.n21=e;this.n22=g*h;this.n23=-g*b;this.n31=-c*g;this.n32=m*h+a*b;this.n33=-m*b+a*h},setRotationFromQuaternion:function(a){var b=
  39. a.x,c=a.y,e=a.z,g=a.w,h=b+b,l=c+c,m=e+e;a=b*h;var k=b*l;b*=m;var o=c*l;c*=m;e*=m;h*=g;l*=g;g*=m;this.n11=1-(o+e);this.n12=k-g;this.n13=b+l;this.n21=k+g;this.n22=1-(a+e);this.n23=c-h;this.n31=b-l;this.n32=c+h;this.n33=1-(a+o)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
  40. a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
  41. THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
  42. THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,g=a.n13,h=a.n14,l=a.n21,m=a.n22,k=a.n23,o=a.n24,u=a.n31,x=a.n32,v=a.n33,A=a.n34,K=a.n41,N=a.n42,J=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*A*N-o*v*N+o*x*J-m*A*J-k*x*r+m*v*r;b.n12=h*v*N-g*A*N-h*x*J+e*A*J+g*x*r-e*v*r;b.n13=g*o*N-h*k*N+h*m*J-e*o*J-g*m*r+e*k*r;b.n14=h*k*x-g*o*x-h*m*v+e*o*v+g*m*A-e*k*A;b.n21=o*v*K-k*A*K-o*u*J+l*A*J+k*u*r-l*v*r;b.n22=g*A*K-h*v*K+h*u*J-c*A*J-g*u*r+c*v*r;b.n23=h*k*K-g*o*K-h*l*J+c*o*J+g*l*r-c*k*r;
  43. b.n24=g*o*u-h*k*u+h*l*v-c*o*v-g*l*A+c*k*A;b.n31=m*A*K-o*x*K+o*u*N-l*A*N-m*u*r+l*x*r;b.n32=h*x*K-e*A*K-h*u*N+c*A*N+e*u*r-c*x*r;b.n33=g*o*K-h*m*K+h*l*N-c*o*N-e*l*r+c*m*r;b.n34=h*m*u-e*o*u-h*l*x+c*o*x+e*l*A-c*m*A;b.n41=k*x*K-m*v*K-k*u*N+l*v*N+m*u*J-l*x*J;b.n42=e*v*K-g*x*K+g*u*N-c*v*N-e*u*J+c*x*J;b.n43=g*m*K-e*k*K-g*l*N+c*k*N+e*l*J-c*m*J;b.n44=e*k*u-g*m*u+g*l*x-c*k*x-e*l*v+c*m*v;b.multiplyScalar(1/a.determinant());return b};
  44. THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,m=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,u=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*h;c[3]=a*l;c[4]=a*m;c[5]=a*k;c[6]=a*o;c[7]=a*u;c[8]=a*x;return b};
  45. THREE.Matrix4.makeFrustum=function(a,b,c,e,g,h){var l;l=new THREE.Matrix4;l.n11=2*g/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*g/(e-c);l.n23=(e+c)/(e-c);l.n24=0;l.n31=0;l.n32=0;l.n33=-(h+g)/(h-g);l.n34=-2*h*g/(h-g);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
  46. THREE.Matrix4.makeOrtho=function(a,b,c,e,g,h){var l,m,k,o;l=new THREE.Matrix4;m=b-a;k=c-e;o=h-g;l.n11=2/m;l.n12=0;l.n13=0;l.n14=-((b+a)/m);l.n21=0;l.n22=2/k;l.n23=0;l.n24=-((c+e)/k);l.n31=0;l.n32=0;l.n33=-2/o;l.n34=-((h+g)/o);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  47. THREE.Quaternion=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e!==undefined?e:1;this.api={isDirty:!1,that:this,get x(){return this.that.x},get y(){return this.that.y},get z(){return this.that.z},get w(){return this.that.w},set x(g){this.that.x=g;this.isDirty=!0},set y(g){this.that.y=g;this.isDirty=!0},set z(g){this.that.z=g;this.isDirty=!0},set w(g){this.that.w=g;this.isDirty=!0}};this.api.__proto__=THREE.Quaternion.prototype;return this.api};
  48. THREE.Quaternion.prototype.set=function(a,b,c,e){var g=this.that;g.x=a;g.y=b;g.z=c;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var l=a*b,m=e*g,k=this.that;k.w=l*h-m*c;k.x=l*c+m*h;k.y=e*b*h+a*g*c;k.z=a*g*h-e*b*c;this.isDirty=!0;return this};
  49. THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,c=a.y,e=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-c*c-e*e));this.isDirty=!0;return this};THREE.Quaternion.prototype.inverse=function(){var a=this.that;a.x*=-1;a.y*=-1;a.z*=-1;this.isDirty=!0;return this};THREE.Quaternion.prototype.length=function(){var a=this.that;return Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w)};
  50. THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,e=a.z,g=a.w,h=Math.sqrt(b*b+c*c+e*e+g*g);if(h==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}h=1/h;a.x=b*h;a.y=c*h;a.z=e*h;a.w=g*h;this.isDirty=!0;return this};
  51. THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.that;qax=b.x;qay=b.y;qaz=b.z;qaw=b.w;qbx=a.x;qby=a.y;qbz=a.z;qbw=a.w;b.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;b.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;b.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;b.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this.isDirty=!0;return this};
  52. THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,e=a.x,g=a.y,h=a.z,l=c.x,m=c.y,k=c.z;c=c.w;var o=c*e+m*h-k*g,u=c*g+k*e-l*h,x=c*h+l*g-m*e;e=-l*e-m*g-k*h;b.x=o*c+e*-l+u*-k-x*-m;b.y=u*c+e*-m+x*-l-o*-k;b.z=x*c+e*-k+o*-m-u*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
  53. THREE.Quaternion.slerp=function(a,b,c,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}g=Math.sin((1-e)*h)/l;e=Math.sin(e*h)/l;c.w=a.w*g+b.w*e;c.x=a.x*g+b.x*e;c.y=a.y*g+b.y*e;c.z=a.z*g+b.z*e;return c};
  54. THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
  55. THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  56. THREE.Face4=function(a,b,c,e,g,h){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
  57. 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.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
  58. THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
  59. c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,h,l,m=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(a&&h.vertexNormals.length){m.set(0,0,0);b=0;for(c=h.normal.length;b<c;b++)m.addSelf(h.vertexNormals[b]);m.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];l=this.vertices[h.c];m.sub(l.position,
  60. c.position);k.sub(b.position,c.position);m.crossSelf(k)}m.isZero()||m.normalize();h.normal.copy(m)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
  61. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
  62. b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(E,O,ia,Q,f,p,n){h=E.vertices[O].position;l=E.vertices[ia].position;m=E.vertices[Q].position;k=g[f];o=g[p];u=g[n];x=l.x-h.x;v=m.x-h.x;A=l.y-h.y;K=m.y-h.y;
  63. N=l.z-h.z;J=m.z-h.z;r=o.u-k.u;d=u.u-k.u;I=o.v-k.v;S=u.v-k.v;V=1/(r*S-d*I);M.set((S*x-I*v)*V,(S*A-I*K)*V,(S*N-I*J)*V);aa.set((r*v-d*x)*V,(r*K-d*A)*V,(r*J-d*N)*V);ea[O].addSelf(M);ea[ia].addSelf(M);ea[Q].addSelf(M);T[O].addSelf(aa);T[ia].addSelf(aa);T[Q].addSelf(aa)}var b,c,e,g,h,l,m,k,o,u,x,v,A,K,N,J,r,d,I,S,V,ea=[],T=[],M=new THREE.Vector3,aa=new THREE.Vector3,R=new THREE.Vector3,ca=new THREE.Vector3,W=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ea[b]=new THREE.Vector3;T[b]=new THREE.Vector3}b=
  64. 0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];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]);
  65. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){W.copy(this.vertices[b].normal);e=ea[b];R.copy(e);R.subSelf(W.multiplyScalar(W.dot(e))).normalize();ca.cross(this.vertices[b].normal,e);e=ca.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.z,e)}this.hasTangents=!0},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],
  66. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];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>
  67. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(u){var x=[];b=0;for(c=u.length;b<c;b++)u[b]==undefined?x.push("undefined"):x.push(u[b].id);return x.join("_")}var b,c,e,g,h,l,m,k,o={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
  68. l=h.materials;m=a(l);o[m]==undefined&&(o[m]={hash:m,counter:0});k=o[m].hash+"_"+o[m].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0});h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+h>65535){o[m].counter+=1;k=o[m].hash+"_"+o[m].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
  69. this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
  70. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix=
  71. new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.globalMatrix,b,c)}};
  72. THREE.Object3D.prototype.updateMatrix=function(){this.localMatrix.setPosition(this.position);if(this.useQuaternion){if(this.quaternion.isDirty){this.localMatrix.setRotationFromQuaternion(this.quaternion);this.quaternion.isDirty=!1}}else this.localMatrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.localMatrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0};
  73. THREE.Object3D.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a)}};THREE.Object3D.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1){this.children.splice(b,1);a.parent=undefined}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=!1};THREE.Particle.prototype=new THREE.Object3D;
  74. THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
  75. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose();this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;
  76. THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
  77. THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};
  78. THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  79. THREE.Bone.prototype.update=function(a,b,c){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;if(this.hasNoneBoneChildren){this.globalMatrix.multiply(this.skin.globalMatrix,this.skinMatrix);for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.globalMatrix,!0,c)}}else for(e=
  80. 0;e<g;e++)this.children[e].update(this.skinMatrix,b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
  81. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,g,h,l,m;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){g=this.geometry.bones[c];h=g.pos;l=g.rotq;m=g.scl;e=this.addBone();e.name=g.name;e.position.set(h[0],h[1],h[2]);e.quaternion.set(l[0],l[1],l[2],l[3]);m!==undefined?e.scale.set(m[0],m[1],m[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){g=this.geometry.bones[c];e=this.bones[c];
  82. g.parent===-1?this.addChild(e):this.bones[g.parent].addChild(e)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  83. THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;this.normalMatrix=THREE.Matrix4.makeInvert3x3(this.globalMatrix).transpose()}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,
  84. c)}}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  85. THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y;
  86. e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[h].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
  87. THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var e=0;e<a.length;e++)a[e].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var e=0;e<c.hierarchy.length;e++)for(var g=0;g<c.hierarchy[e].keys.length;g++){if(c.hierarchy[e].keys[g].time<0)c.hierarchy[e].keys[g].time=0;c.hierarchy[e].keys[g].index=g;if(c.hierarchy[e].keys[g].rot!==undefined&&!(c.hierarchy[e].keys[g].rot instanceof
  88. THREE.Quaternion)){var h=c.hierarchy[e].keys[g].rot;c.hierarchy[e].keys[g].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}g=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(g));c.initialized=!0}};return b}();
  89. THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
  90. THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.0010;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].autoUpdateMatrix=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
  91. this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
  92. THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,g,h,l,m=this.data.JIT.hierarchy,k=(new Date).getTime()*0.0010-this.startTime+this.offset,o=k;if(k>this.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.0010-k;k=(new Date).getTime()*0.0010-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var u=0,x=this.hierarchy.length;u<x;u++){h=this.hierarchy[u];if(m[u][l]!==
  93. undefined){h.skinMatrix=m[u][l];h.autoUpdateMatrix=!1;h.matrixNeedsToUpdate=!1;h.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,u*16)}else for(var v=0;v<3;v++){c=a[v];e=h.prevKey[c];g=h.nextKey[c];if(g.time<o){if(k<o)if(this.loop){e=this.data.hierarchy[u].keys[0];g=this.getNextKeyWith(c,u,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(c,u,g.index+1)}while(g.time<k)}h.prevKey[c]=e;h.nextKey[c]=g}h.autoUpdateMatrix=!0;h.matrixNeedsToUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[c];
  94. g=g[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,h.quaternion,b)}else{c=c==="pos"?h.position:h.scale;c.x=e[0]+(g[0]-e[0])*b;c.y=e[1]+(g[1]-e[1])*b;c.z=e[2]+(g[2]-e[2])*b}}}if(m[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u<this.hierarchy.length;u++)m[u][l]=this.hierarchy[u].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
  95. THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var e=this.data.hierarchy[b].keys;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
  96. THREE.Camera=function(a,b,c,e,g,h){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=h||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
  97. this.target.position.addSelf(this.tmpVec)};this.translateZ=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
  98. THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.FOV,this.aspect,this.zNear,this.zFar)};
  99. THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
  100. this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
  101. THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,h=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*c+g.n33*e+g.n34;if(l-h>-this.zNear)return!1;if(l+h<-this.zFar)return!1;l-=h;var m=this.projectionMatrix,k=1/(m.n43*l),o=k*this.screenCenterX,u=(g.n11*b+g.n12*c+g.n13*e+g.n14)*m.n11*o;h=m.n11*h*o;if(u+h<-this.screenCenterX)return!1;if(u-h>this.screenCenterX)return!1;b=(g.n21*b+g.n22*c+g.n23*e+g.n24)*m.n22*k*this.screenCenterY;
  102. if(b+h<-this.screenCenterY)return!1;if(b-h>this.screenCenterY)return!1;a.screenPosition.set(u,b,l,h);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
  103. THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
  104. THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.MaterialCounter={value:0};
  105. THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
  106. a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  107. THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
  108. THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){a.color!==
  109. undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==
  110. undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  111. THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+
  112. "<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  113. THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){a.color!==
  114. undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==
  115. undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  116. THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+
  117. "<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/> )"}};
  118. THREE.MeshPhongMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=
  119. this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map;
  120. if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;
  121. if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  122. THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+
  123. this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  124. THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
  125. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};
  126. THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
  127. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
  128. THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=
  129. a.vertex_shader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
  130. undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  131. THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  132. THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.offset=new THREE.Vector2;this.vertex_colors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==
  133. undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
  134. THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;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}};
  135. THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
  136. THREE.Texture=function(a,b,c,e,g,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter};
  137. 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;
  138. 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;
  139. THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
  140. var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]){e=a[b][c];g[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,c,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)g[c]=e[c]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  141. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.fog=null};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};
  142. THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
  143. THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;
  144. THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
  145. THREE.Projector=function(){function a(T,M){return M.z-T.z}function b(T,M){var aa=0,R=1,ca=T.z+T.w,W=M.z+M.w,E=-T.z+T.w,O=-M.z+M.w;if(ca>=0&&W>=0&&E>=0&&O>=0)return!0;else if(ca<0&&W<0||E<0&&O<0)return!1;else{if(ca<0)aa=Math.max(aa,ca/(ca-W));else W<0&&(R=Math.min(R,ca/(ca-W)));if(E<0)aa=Math.max(aa,E/(E-O));else O<0&&(R=Math.min(R,E/(E-O)));if(R<aa)return!1;else{T.lerpSelf(M,aa);M.lerpSelf(T,1-R);return!0}}}var c,e,g=[],h,l,m,k=[],o,u,x=[],v,A,K=[],N=new THREE.Vector4,J=new THREE.Vector4,r=new THREE.Matrix4,
  146. d=new THREE.Matrix4,I=[],S=new THREE.Vector4,V=new THREE.Vector4,ea;this.projectObjects=function(T,M,aa){M=[];var R,ca,W;e=0;ca=T.objects;T=0;for(R=ca.length;T<R;T++){W=ca[T];var E;if(!(E=!W.visible))if(E=W instanceof THREE.Mesh){a:{E=void 0;for(var O=W.globalMatrix,ia=-W.geometry.boundingSphere.radius*Math.max(W.scale.x,Math.max(W.scale.y,W.scale.z)),Q=0;Q<6;Q++){E=I[Q].x*O.n14+I[Q].y*O.n24+I[Q].z*O.n34+I[Q].w;if(E<=ia){E=!1;break a}}E=!0}E=!E}if(!E){c=g[e]=g[e]||new THREE.RenderableObject;N.copy(W.position);
  147. r.multiplyVector3(N);c.object=W;c.z=N.z;M.push(c);e++}}aa&&M.sort(a);return M};this.projectScene=function(T,M,aa){var R=[],ca=M.near,W=M.far,E,O,ia,Q,f,p,n,j,i,q,s,w,F,t,y,B;m=u=A=0;M.autoUpdateMatrix&&M.update();r.multiply(M.projectionMatrix,M.globalMatrix);I[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);I[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);I[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);I[3]=new THREE.Vector4(r.n41-
  148. r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);I[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);I[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);E=0;for(p=I.length;E<p;E++){n=I[E];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}T.update(undefined,!1,M);p=this.projectObjects(T,M,!0);T=0;for(E=p.length;T<E;T++){n=p[T].object;n.autoUpdateMatrix&&n.updateMatrix();j=n.globalMatrix;j.extractRotationMatrix(n.rotationMatrix);s=n.rotationMatrix;i=n.materials;q=
  149. n.overdraw;if(n instanceof THREE.Mesh){w=n.geometry;F=w.vertices;O=0;for(ia=F.length;O<ia;O++){t=F[O];t.positionWorld.copy(t.position);j.multiplyVector3(t.positionWorld);Q=t.positionScreen;Q.copy(t.positionWorld);r.multiplyVector4(Q);Q.x/=Q.w;Q.y/=Q.w;t.__visible=Q.z>ca&&Q.z<W}w=w.faces;O=0;for(ia=w.length;O<ia;O++){t=w[O];if(t instanceof THREE.Face3){Q=F[t.a];f=F[t.b];y=F[t.c];if(Q.__visible&&f.__visible&&y.__visible&&(n.doubleSided||n.flipSided!=(y.positionScreen.x-Q.positionScreen.x)*(f.positionScreen.y-
  150. Q.positionScreen.y)-(y.positionScreen.y-Q.positionScreen.y)*(f.positionScreen.x-Q.positionScreen.x)<0)){h=k[m]=k[m]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(f.positionWorld);h.v3.positionWorld.copy(y.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(f.positionScreen);h.v3.positionScreen.copy(y.positionScreen);h.normalWorld.copy(t.normal);s.multiplyVector3(h.normalWorld);h.centroidWorld.copy(t.centroid);j.multiplyVector3(h.centroidWorld);
  151. h.centroidScreen.copy(h.centroidWorld);r.multiplyVector3(h.centroidScreen);y=t.vertexNormals;ea=h.vertexNormalsWorld;Q=0;for(f=y.length;Q<f;Q++){B=ea[Q]=ea[Q]||new THREE.Vector3;B.copy(y[Q]);s.multiplyVector3(B)}h.z=h.centroidScreen.z;h.meshMaterials=i;h.faceMaterials=t.materials;h.overdraw=q;if(n.geometry.uvs[O]){h.uvs[0]=n.geometry.uvs[O][0];h.uvs[1]=n.geometry.uvs[O][1];h.uvs[2]=n.geometry.uvs[O][2]}R.push(h);m++}}else if(t instanceof THREE.Face4){Q=F[t.a];f=F[t.b];y=F[t.c];B=F[t.d];if(Q.__visible&&
  152. f.__visible&&y.__visible&&B.__visible&&(n.doubleSided||n.flipSided!=((B.positionScreen.x-Q.positionScreen.x)*(f.positionScreen.y-Q.positionScreen.y)-(B.positionScreen.y-Q.positionScreen.y)*(f.positionScreen.x-Q.positionScreen.x)<0||(f.positionScreen.x-y.positionScreen.x)*(B.positionScreen.y-y.positionScreen.y)-(f.positionScreen.y-y.positionScreen.y)*(B.positionScreen.x-y.positionScreen.x)<0))){h=k[m]=k[m]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(f.positionWorld);
  153. h.v3.positionWorld.copy(B.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(f.positionScreen);h.v3.positionScreen.copy(B.positionScreen);h.normalWorld.copy(t.normal);s.multiplyVector3(h.normalWorld);h.centroidWorld.copy(t.centroid);j.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);r.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=i;h.faceMaterials=t.materials;h.overdraw=q;if(n.geometry.uvs[O]){h.uvs[0]=n.geometry.uvs[O][0];
  154. h.uvs[1]=n.geometry.uvs[O][1];h.uvs[2]=n.geometry.uvs[O][3]}R.push(h);m++;l=k[m]=k[m]||new THREE.RenderableFace3;l.v1.positionWorld.copy(f.positionWorld);l.v2.positionWorld.copy(y.positionWorld);l.v3.positionWorld.copy(B.positionWorld);l.v1.positionScreen.copy(f.positionScreen);l.v2.positionScreen.copy(y.positionScreen);l.v3.positionScreen.copy(B.positionScreen);l.normalWorld.copy(h.normalWorld);l.centroidWorld.copy(h.centroidWorld);l.centroidScreen.copy(h.centroidScreen);l.z=l.centroidScreen.z;l.meshMaterials=
  155. i;l.faceMaterials=t.materials;l.overdraw=q;if(n.geometry.uvs[O]){l.uvs[0]=n.geometry.uvs[O][1];l.uvs[1]=n.geometry.uvs[O][2];l.uvs[2]=n.geometry.uvs[O][3]}R.push(l);m++}}}}else if(n instanceof THREE.Line){d.multiply(r,j);F=n.geometry.vertices;t=F[0];t.positionScreen.copy(t.position);d.multiplyVector4(t.positionScreen);O=1;for(ia=F.length;O<ia;O++){Q=F[O];Q.positionScreen.copy(Q.position);d.multiplyVector4(Q.positionScreen);f=F[O-1];S.copy(Q.positionScreen);V.copy(f.positionScreen);if(b(S,V)){S.multiplyScalar(1/
  156. S.w);V.multiplyScalar(1/V.w);o=x[u]=x[u]||new THREE.RenderableLine;o.v1.positionScreen.copy(S);o.v2.positionScreen.copy(V);o.z=Math.max(S.z,V.z);o.materials=n.materials;R.push(o);u++}}}else if(n instanceof THREE.Particle){J.set(n.position.x,n.position.y,n.position.z,1);r.multiplyVector4(J);J.z/=J.w;if(J.z>0&&J.z<1){v=K[A]=K[A]||new THREE.RenderableParticle;v.x=J.x/J.w;v.y=J.y/J.w;v.z=J.z;v.rotation=n.rotation.z;v.scale.x=n.scale.x*Math.abs(v.x-(J.x+M.projectionMatrix.n11)/(J.w+M.projectionMatrix.n14));
  157. v.scale.y=n.scale.y*Math.abs(v.y-(J.y+M.projectionMatrix.n22)/(J.w+M.projectionMatrix.n24));v.materials=n.materials;R.push(v);A++}}}aa&&R.sort(a);return R};this.unprojectVector=function(T,M){var aa=THREE.Matrix4.makeInvert(M.globalMatrix);aa.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));aa.multiplyVector3(T);return T}};
  158. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,h;this.domElement=document.createElement("div");this.setSize=function(l,m){c=l;e=m;g=c/2;h=e/2};this.render=function(l,m){var k,o,u,x,v,A,K,N;a=b.projectScene(l,m);k=0;for(o=a.length;k<o;k++){v=a[k];if(v instanceof THREE.RenderableParticle){K=v.x*g+g;N=v.y*h+h;u=0;for(x=v.material.length;u<x;u++){A=v.material[u];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=K+"px";A.style.top=N+"px"}}}}}};
  159. THREE.CanvasRenderer=function(){function a(G){if(v!=G)o.globalAlpha=v=G}function b(G){if(A!=G){switch(G){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}A=G}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),h,l,m,k,o=g.getContext("2d"),u=new THREE.Color(0),x=0,v=1,A=0,K=null,N=null,J=1,r,d,I,S,V,ea,T,M,aa,R=new THREE.Color,
  160. ca=new THREE.Color,W=new THREE.Color,E=new THREE.Color,O=new THREE.Color,ia,Q,f,p,n,j,i,q,s,w=new THREE.Rectangle,F=new THREE.Rectangle,t=new THREE.Rectangle,y=!1,B=new THREE.Color,Y=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,ua=Math.PI*2,Z=new THREE.Vector3,fa,ha,Ia,C,Ca,wa,za=16;fa=document.createElement("canvas");fa.width=fa.height=2;ha=fa.getContext("2d");ha.fillStyle="rgba(0,0,0,1)";ha.fillRect(0,0,2,2);Ia=ha.getImageData(0,0,2,2);C=Ia.data;Ca=document.createElement("canvas");Ca.width=
  161. Ca.height=za;wa=Ca.getContext("2d");wa.translate(-za/2,-za/2);wa.scale(za,za);za--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(G,L){h=G;l=L;m=h/2;k=l/2;g.width=h;g.height=l;w.set(-m,-k,m,k);v=1;A=0;N=K=null;J=1};this.setClearColor=function(G,L){u=G;x=L;F.set(-m,-k,m,k);o.setTransform(1,0,0,-1,m,k);this.clear()};this.setClearColorHex=function(G,L){u.setHex(G);x=L;F.set(-m,-k,m,k);o.setTransform(1,0,0,-1,m,k);this.clear()};this.clear=function(){o.setTransform(1,
  162. 0,0,-1,m,k);if(!F.isEmpty()){F.inflate(1);F.minSelf(w);if(u.hex==0&&x==0)o.clearRect(F.getX(),F.getY(),F.getWidth(),F.getHeight());else{b(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(u.r*255)+","+Math.floor(u.g*255)+","+Math.floor(u.b*255)+","+x+")";o.fillRect(F.getX(),F.getY(),F.getWidth(),F.getHeight())}F.empty()}};this.render=function(G,L){function P(D){var ba,X,H,U=D.lights;Y.setRGB(0,0,0);ga.setRGB(0,0,0);na.setRGB(0,0,0);D=0;for(ba=U.length;D<ba;D++){X=U[D];H=X.color;if(X instanceof
  163. THREE.AmbientLight){Y.r+=H.r;Y.g+=H.g;Y.b+=H.b}else if(X instanceof THREE.DirectionalLight){ga.r+=H.r;ga.g+=H.g;ga.b+=H.b}else if(X instanceof THREE.PointLight){na.r+=H.r;na.g+=H.g;na.b+=H.b}}}function ja(D,ba,X,H){var U,da,sa,Aa,Da=D.lights;D=0;for(U=Da.length;D<U;D++){da=Da[D];sa=da.color;Aa=da.intensity;if(da instanceof THREE.DirectionalLight){da=X.dot(da.position)*Aa;if(da>0){H.r+=sa.r*da;H.g+=sa.g*da;H.b+=sa.b*da}}else if(da instanceof THREE.PointLight){Z.sub(da.position,ba);Z.normalize();da=
  164. X.dot(Z)*Aa;if(da>0){H.r+=sa.r*da;H.g+=sa.g*da;H.b+=sa.b*da}}}}function Ea(D,ba,X){if(X.opacity!=0){a(X.opacity);b(X.blending);var H,U,da,sa,Aa,Da;if(X instanceof THREE.ParticleBasicMaterial){if(X.map&&X.map.image.loaded){sa=X.map.image;Aa=sa.width>>1;Da=sa.height>>1;U=ba.scale.x*m;da=ba.scale.y*k;X=U*Aa;H=da*Da;t.set(D.x-X,D.y-H,D.x+X,D.y+H);if(w.instersects(t)){o.save();o.translate(D.x,D.y);o.rotate(-ba.rotation);o.scale(U,-da);o.translate(-Aa,-Da);o.drawImage(sa,0,0);o.restore()}}}else if(X instanceof
  165. THREE.ParticleCircleMaterial){if(y){B.r=Y.r+ga.r+na.r;B.g=Y.g+ga.g+na.g;B.b=Y.b+ga.b+na.b;R.r=X.color.r*B.r;R.g=X.color.g*B.g;R.b=X.color.b*B.b;R.updateStyleString()}else R.__styleString=X.color.__styleString;X=ba.scale.x*m;H=ba.scale.y*k;t.set(D.x-X,D.y-H,D.x+X,D.y+H);if(w.instersects(t)){U=R.__styleString;if(N!=U)o.fillStyle=N=U;o.save();o.translate(D.x,D.y);o.rotate(-ba.rotation);o.scale(X,H);o.beginPath();o.arc(0,0,1,0,ua,!0);o.closePath();o.fill();o.restore()}}}}function ra(D,ba,X,H){if(H.opacity!=
  166. 0){a(H.opacity);b(H.blending);o.beginPath();o.moveTo(D.positionScreen.x,D.positionScreen.y);o.lineTo(ba.positionScreen.x,ba.positionScreen.y);o.closePath();if(H instanceof THREE.LineBasicMaterial){R.__styleString=H.color.__styleString;D=H.linewidth;if(J!=D)o.lineWidth=J=D;D=R.__styleString;if(K!=D)o.strokeStyle=K=D;o.stroke();t.inflate(H.linewidth*2)}}}function z(D,ba,X,H,U,da){if(U.opacity!=0){a(U.opacity);b(U.blending);S=D.positionScreen.x;V=D.positionScreen.y;ea=ba.positionScreen.x;T=ba.positionScreen.y;
  167. M=X.positionScreen.x;aa=X.positionScreen.y;o.beginPath();o.moveTo(S,V);o.lineTo(ea,T);o.lineTo(M,aa);o.lineTo(S,V);o.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ka(S,V,ea,T,M,aa,U.map.image,H.uvs[0].u,H.uvs[0].v,H.uvs[1].u,H.uvs[1].v,H.uvs[2].u,H.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&U.env_map.mapping instanceof THREE.SphericalReflectionMapping){D=L.globalMatrix;Z.copy(H.vertexNormalsWorld[0]);p=(Z.x*
  168. D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;n=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(H.vertexNormalsWorld[1]);j=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;i=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Z.copy(H.vertexNormalsWorld[2]);q=(Z.x*D.n11+Z.y*D.n12+Z.z*D.n13)*0.5+0.5;s=-(Z.x*D.n21+Z.y*D.n22+Z.z*D.n23)*0.5+0.5;Ka(S,V,ea,T,M,aa,U.env_map.image,p,n,j,i,q,s)}}else U.wireframe?pa(U.color.__styleString,U.wireframe_linewidth):Ma(U.color.__styleString);else if(U instanceof THREE.MeshLambertMaterial){if(U.map&&
  169. !U.wireframe){U.map.mapping instanceof THREE.UVMapping&&Ka(S,V,ea,T,M,aa,U.map.image,H.uvs[0].u,H.uvs[0].v,H.uvs[1].u,H.uvs[1].v,H.uvs[2].u,H.uvs[2].v);b(THREE.SubtractiveBlending)}if(y)if(!U.wireframe&&U.shading==THREE.SmoothShading&&H.vertexNormalsWorld.length==3){ca.r=W.r=E.r=Y.r;ca.g=W.g=E.g=Y.g;ca.b=W.b=E.b=Y.b;ja(da,H.v1.positionWorld,H.vertexNormalsWorld[0],ca);ja(da,H.v2.positionWorld,H.vertexNormalsWorld[1],W);ja(da,H.v3.positionWorld,H.vertexNormalsWorld[2],E);O.r=(W.r+E.r)*0.5;O.g=(W.g+
  170. E.g)*0.5;O.b=(W.b+E.b)*0.5;f=Ha(ca,W,E,O);Ka(S,V,ea,T,M,aa,f,0,0,1,0,0,1)}else{B.r=Y.r;B.g=Y.g;B.b=Y.b;ja(da,H.centroidWorld,H.normalWorld,B);R.r=U.color.r*B.r;R.g=U.color.g*B.g;R.b=U.color.b*B.b;R.updateStyleString();U.wireframe?pa(R.__styleString,U.wireframe_linewidth):Ma(R.__styleString)}else U.wireframe?pa(U.color.__styleString,U.wireframe_linewidth):Ma(U.color.__styleString)}else if(U instanceof THREE.MeshDepthMaterial){ia=L.near;Q=L.far;ca.r=ca.g=ca.b=1-la(D.positionScreen.z,ia,Q);W.r=W.g=W.b=
  171. 1-la(ba.positionScreen.z,ia,Q);E.r=E.g=E.b=1-la(X.positionScreen.z,ia,Q);O.r=(W.r+E.r)*0.5;O.g=(W.g+E.g)*0.5;O.b=(W.b+E.b)*0.5;f=Ha(ca,W,E,O);Ka(S,V,ea,T,M,aa,f,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){R.r=qa(H.normalWorld.x);R.g=qa(H.normalWorld.y);R.b=qa(H.normalWorld.z);R.updateStyleString();U.wireframe?pa(R.__styleString,U.wireframe_linewidth):Ma(R.__styleString)}}}function pa(D,ba){if(K!=D)o.strokeStyle=K=D;if(J!=ba)o.lineWidth=J=ba;o.stroke();t.inflate(ba*2)}function Ma(D){if(N!=
  172. D)o.fillStyle=N=D;o.fill()}function Ka(D,ba,X,H,U,da,sa,Aa,Da,La,ta,Ga,Ja){var Fa,Ba;Fa=sa.width-1;Ba=sa.height-1;Aa*=Fa;Da*=Ba;La*=Fa;ta*=Ba;Ga*=Fa;Ja*=Ba;X-=D;H-=ba;U-=D;da-=ba;La-=Aa;ta-=Da;Ga-=Aa;Ja-=Da;Fa=La*Ja-Ga*ta;if(Fa!=0){Ba=1/Fa;Fa=(Ja*X-ta*U)*Ba;ta=(Ja*H-ta*da)*Ba;X=(La*U-Ga*X)*Ba;H=(La*da-Ga*H)*Ba;D=D-Fa*Aa-X*Da;ba=ba-ta*Aa-H*Da;o.save();o.transform(Fa,ta,X,H,D,ba);o.clip();o.drawImage(sa,0,0);o.restore()}}function Ha(D,ba,X,H){var U=~~(D.r*255),da=~~(D.g*255);D=~~(D.b*255);var sa=~~(ba.r*
  173. 255),Aa=~~(ba.g*255);ba=~~(ba.b*255);var Da=~~(X.r*255),La=~~(X.g*255);X=~~(X.b*255);var ta=~~(H.r*255),Ga=~~(H.g*255);H=~~(H.b*255);C[0]=U<0?0:U>255?255:U;C[1]=da<0?0:da>255?255:da;C[2]=D<0?0:D>255?255:D;C[4]=sa<0?0:sa>255?255:sa;C[5]=Aa<0?0:Aa>255?255:Aa;C[6]=ba<0?0:ba>255?255:ba;C[8]=Da<0?0:Da>255?255:Da;C[9]=La<0?0:La>255?255:La;C[10]=X<0?0:X>255?255:X;C[12]=ta<0?0:ta>255?255:ta;C[13]=Ga<0?0:Ga>255?255:Ga;C[14]=H<0?0:H>255?255:H;ha.putImageData(Ia,0,0);wa.drawImage(fa,0,0);return Ca}function la(D,
  174. ba,X){D=(D-ba)/(X-ba);return D*D*(3-2*D)}function qa(D){D=(D+1)*0.5;return D<0?0:D>1?1:D}function ma(D,ba){var X=ba.x-D.x,H=ba.y-D.y,U=1/Math.sqrt(X*X+H*H);X*=U;H*=U;ba.x+=X;ba.y+=H;D.x-=X;D.y-=H}var ka,oa,$,xa,va,Oa,ya,Na;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,k);c=e.projectScene(G,L,this.sortElements);(y=G.lights.length>0)&&P(G);ka=0;for(oa=c.length;ka<oa;ka++){$=c[ka];t.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=m;r.y*=k;xa=0;for(va=$.materials.length;xa<va;xa++)Ea(r,
  175. $,$.materials[xa],G)}else if($ instanceof THREE.RenderableLine){r=$.v1;d=$.v2;r.positionScreen.x*=m;r.positionScreen.y*=k;d.positionScreen.x*=m;d.positionScreen.y*=k;t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(d.positionScreen.x,d.positionScreen.y);if(w.instersects(t)){xa=0;for(va=$.materials.length;xa<va;)ra(r,d,$,$.materials[xa++],G)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;d=$.v2;I=$.v3;r.positionScreen.x*=m;r.positionScreen.y*=k;d.positionScreen.x*=m;d.positionScreen.y*=
  176. k;I.positionScreen.x*=m;I.positionScreen.y*=k;if($.overdraw){ma(r.positionScreen,d.positionScreen);ma(d.positionScreen,I.positionScreen);ma(I.positionScreen,r.positionScreen)}t.add3Points(r.positionScreen.x,r.positionScreen.y,d.positionScreen.x,d.positionScreen.y,I.positionScreen.x,I.positionScreen.y);if(w.instersects(t)){xa=0;for(va=$.meshMaterials.length;xa<va;){Na=$.meshMaterials[xa++];if(Na instanceof THREE.MeshFaceMaterial){Oa=0;for(ya=$.faceMaterials.length;Oa<ya;)(Na=$.faceMaterials[Oa++])&&
  177. z(r,d,I,$,Na,G)}else z(r,d,I,$,Na,G)}}}F.addRectangle(t)}o.setTransform(1,0,0,1,0,0)}};
  178. THREE.SVGRenderer=function(){function a(p,n,j){var i,q,s,w;i=0;for(q=p.lights.length;i<q;i++){s=p.lights[i];if(s instanceof THREE.DirectionalLight){w=n.normalWorld.dot(s.position)*s.intensity;if(w>0){j.r+=s.color.r*w;j.g+=s.color.g*w;j.b+=s.color.b*w}}else if(s instanceof THREE.PointLight){aa.sub(s.position,n.centroidWorld);aa.normalize();w=n.normalWorld.dot(aa)*s.intensity;if(w>0){j.r+=s.color.r*w;j.g+=s.color.g*w;j.b+=s.color.b*w}}}}function b(p,n,j,i,q,s){E=e(O++);E.setAttribute("d","M "+p.positionScreen.x+
  179. " "+p.positionScreen.y+" L "+n.positionScreen.x+" "+n.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)I.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(d){S.r=V.r;S.g=V.g;S.b=V.b;a(s,i,S);I.r=q.color.r*S.r;I.g=q.color.g*S.g;I.b=q.color.b*S.b;I.updateStyleString()}else I.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){M=1-q.__2near/(q.__farPlusNear-i.z*q.__farMinusNear);
  180. I.setRGB(M,M,M)}else q instanceof THREE.MeshNormalMaterial&&I.setRGB(g(i.normalWorld.x),g(i.normalWorld.y),g(i.normalWorld.z));q.wireframe?E.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+q.wireframe_linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframe_linecap+"; stroke-linejoin: "+q.wireframe_linejoin):E.setAttribute("style","fill: "+I.__styleString+"; fill-opacity: "+q.opacity);m.appendChild(E)}function c(p,n,j,i,q,s,w){E=e(O++);E.setAttribute("d",
  181. "M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+n.positionScreen.x+" "+n.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+i.positionScreen.x+","+i.positionScreen.y+"z");if(s instanceof THREE.MeshBasicMaterial)I.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshLambertMaterial)if(d){S.r=V.r;S.g=V.g;S.b=V.b;a(w,q,S);I.r=s.color.r*S.r;I.g=s.color.g*S.g;I.b=s.color.b*S.b;I.updateStyleString()}else I.__styleString=s.color.__styleString;else if(s instanceof THREE.MeshDepthMaterial){M=
  182. 1-s.__2near/(s.__farPlusNear-q.z*s.__farMinusNear);I.setRGB(M,M,M)}else s instanceof THREE.MeshNormalMaterial&&I.setRGB(g(q.normalWorld.x),g(q.normalWorld.y),g(q.normalWorld.z));s.wireframe?E.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+s.wireframe_linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframe_linecap+"; stroke-linejoin: "+s.wireframe_linejoin):E.setAttribute("style","fill: "+I.__styleString+"; fill-opacity: "+s.opacity);m.appendChild(E)}
  183. function e(p){if(R[p]==null){R[p]=document.createElementNS("http://www.w3.org/2000/svg","path");f==0&&R[p].setAttribute("shape-rendering","crispEdges")}return R[p]}function g(p){return p<0?Math.min((1+p)*0.5,0.5):0.5+Math.min(p*0.5,0.5)}var h=null,l=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,o,u,x,v,A,K,N,J=new THREE.Rectangle,r=new THREE.Rectangle,d=!1,I=new THREE.Color(16777215),S=new THREE.Color(16777215),V=new THREE.Color(0),ea=new THREE.Color(0),T=new THREE.Color(0),
  184. M,aa=new THREE.Vector3,R=[],ca=[],W=[],E,O,ia,Q,f=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(p){switch(p){case "high":f=1;break;case "low":f=0}};this.setSize=function(p,n){k=p;o=n;u=k/2;x=o/2;m.setAttribute("viewBox",-u+" "+-x+" "+k+" "+o);m.setAttribute("width",k);m.setAttribute("height",o);J.set(-u,-x,u,x)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(p,n){var j,i,q,s,w,F,t,y;this.autoClear&&
  185. this.clear();h=l.projectScene(p,n,this.sortElements);Q=ia=O=0;if(d=p.lights.length>0){t=p.lights;V.setRGB(0,0,0);ea.setRGB(0,0,0);T.setRGB(0,0,0);j=0;for(i=t.length;j<i;j++){q=t[j];s=q.color;if(q instanceof THREE.AmbientLight){V.r+=s.r;V.g+=s.g;V.b+=s.b}else if(q instanceof THREE.DirectionalLight){ea.r+=s.r;ea.g+=s.g;ea.b+=s.b}else if(q instanceof THREE.PointLight){T.r+=s.r;T.g+=s.g;T.b+=s.b}}}j=0;for(i=h.length;j<i;j++){t=h[j];r.empty();if(t instanceof THREE.RenderableParticle){v=t;v.x*=u;v.y*=-x;
  186. q=0;for(s=t.materials.length;q<s;q++)if(y=t.materials[q]){w=v;F=t;var B=ia++;if(ca[B]==null){ca[B]=document.createElementNS("http://www.w3.org/2000/svg","circle");f==0&&ca[B].setAttribute("shape-rendering","crispEdges")}E=ca[B];E.setAttribute("cx",w.x);E.setAttribute("cy",w.y);E.setAttribute("r",F.scale.x*u);if(y instanceof THREE.ParticleCircleMaterial){if(d){S.r=V.r+ea.r+T.r;S.g=V.g+ea.g+T.g;S.b=V.b+ea.b+T.b;I.r=y.color.r*S.r;I.g=y.color.g*S.g;I.b=y.color.b*S.b;I.updateStyleString()}else I=y.color;
  187. E.setAttribute("style","fill: "+I.__styleString)}m.appendChild(E)}}else if(t instanceof THREE.RenderableLine){v=t.v1;A=t.v2;v.positionScreen.x*=u;v.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);if(J.instersects(r)){q=0;for(s=t.materials.length;q<s;)if(y=t.materials[q++]){w=v;F=A;B=Q++;if(W[B]==null){W[B]=document.createElementNS("http://www.w3.org/2000/svg","line");f==0&&W[B].setAttribute("shape-rendering",
  188. "crispEdges")}E=W[B];E.setAttribute("x1",w.positionScreen.x);E.setAttribute("y1",w.positionScreen.y);E.setAttribute("x2",F.positionScreen.x);E.setAttribute("y2",F.positionScreen.y);if(y instanceof THREE.LineBasicMaterial){I.__styleString=y.color.__styleString;E.setAttribute("style","fill: none; stroke: "+I.__styleString+"; stroke-width: "+y.linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.linecap+"; stroke-linejoin: "+y.linejoin);m.appendChild(E)}}}}else if(t instanceof THREE.RenderableFace3){v=
  189. t.v1;A=t.v2;K=t.v3;v.positionScreen.x*=u;v.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;K.positionScreen.x*=u;K.positionScreen.y*=-x;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(K.positionScreen.x,K.positionScreen.y);if(J.instersects(r)){q=0;for(s=t.meshMaterials.length;q<s;){y=t.meshMaterials[q++];if(y instanceof THREE.MeshFaceMaterial){w=0;for(F=t.faceMaterials.length;w<F;)(y=t.faceMaterials[w++])&&b(v,A,K,t,
  190. y,p)}else y&&b(v,A,K,t,y,p)}}}else if(t instanceof THREE.RenderableFace4){v=t.v1;A=t.v2;K=t.v3;N=t.v4;v.positionScreen.x*=u;v.positionScreen.y*=-x;A.positionScreen.x*=u;A.positionScreen.y*=-x;K.positionScreen.x*=u;K.positionScreen.y*=-x;N.positionScreen.x*=u;N.positionScreen.y*=-x;r.addPoint(v.positionScreen.x,v.positionScreen.y);r.addPoint(A.positionScreen.x,A.positionScreen.y);r.addPoint(K.positionScreen.x,K.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);if(J.instersects(r)){q=
  191. 0;for(s=t.meshMaterials.length;q<s;){y=t.meshMaterials[q++];if(y instanceof THREE.MeshFaceMaterial){w=0;for(F=t.faceMaterials.length;w<F;)(y=t.faceMaterials[w++])&&c(v,A,K,N,t,y,p)}else y&&c(v,A,K,N,t,y,p)}}}}}};
  192. THREE.WebGLRenderer=function(a){function b(f,p,n){var j,i,q,s=f.vertices,w=s.length,F=f.colors,t=F.length,y=f.__vertexArray,B=f.__colorArray,Y=f.__sortArray,ga=f.__dirtyVertices,na=f.__dirtyColors;if(n.sortParticles){aa.multiplySelf(n.globalMatrix);for(j=0;j<w;j++){i=s[j].position;E.copy(i);aa.multiplyVector3(E);Y[j]=[E.z,j]}Y.sort(function(ua,Z){return Z[0]-ua[0]});for(j=0;j<w;j++){i=s[Y[j][1]].position;q=j*3;y[q]=i.x;y[q+1]=i.y;y[q+2]=i.z}for(j=0;j<t;j++){q=j*3;color=F[Y[j][1]];B[q]=color.r;B[q+
  193. 1]=color.g;B[q+2]=color.b}}else{if(ga)for(j=0;j<w;j++){i=s[j].position;q=j*3;y[q]=i.x;y[q+1]=i.y;y[q+2]=i.z}if(na)for(j=0;j<t;j++){color=F[j];q=j*3;B[q]=color.r;B[q+1]=color.g;B[q+2]=color.b}}if(ga||n.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,y,p)}if(na||n.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,B,p)}}function c(f,p){f.fragment_shader=p.fragment_shader;f.vertex_shader=p.vertex_shader;f.uniforms=
  194. Uniforms.clone(p.uniforms)}function e(f,p){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=d.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=d.createBuffer();if(f.hasPos){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,f.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(p.attributes.position);d.vertexAttribPointer(p.attributes.position,3,d.FLOAT,!1,0,0)}if(f.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,
  195. f.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(p.attributes.normal);d.vertexAttribPointer(p.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,f.count);f.count=0}function g(f){if(V!=f.doubleSided){f.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);V=f.doubleSided}if(ea!=f.flipSided){f.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);ea=f.flipSided}}function h(f){M[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);M[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+
  196. f.n14);M[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);M[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);M[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);M[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var p;for(f=0;f<5;f++){p=M[f];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}}function l(f){for(var p=f.globalMatrix,n=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),j=0;j<6;j++){f=M[j].x*p.n14+M[j].y*p.n24+M[j].z*p.n34+M[j].w;
  197. if(f<=n)return!1}return!0}function m(f,p){f.list[f.count]=p;f.count+=1}function k(f){var p,n,j=f.object,i=f.opaque,q=f.transparent;q.count=0;f=i.count=0;for(p=j.materials.length;f<p;f++){n=j.materials[f];n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?m(q,n):m(i,n)}}function o(f){var p,n,j,i,q=f.object,s=f.buffer,w=f.opaque,F=f.transparent;F.count=0;f=w.count=0;for(j=q.materials.length;f<j;f++){p=q.materials[f];if(p instanceof THREE.MeshFaceMaterial){p=0;for(n=s.materials.length;p<n;p++)(i=
  198. s.materials[p])&&(i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?m(F,i):m(w,i))}else{i=p;i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?m(F,i):m(w,i)}}}function u(f,p){return p.z-f.z}function x(f,p,n,j,i){if(p[n]==undefined){f.push({buffer:j,object:i,opaque:{list:[],count:0},transparent:{list:[],count:0}});p[n]=1}}function v(f,p){f._modelViewMatrix.multiplyToArray(p.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);f._normalMatrix=THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}
  199. function A(f){if(f!=T){switch(f){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}T=f}}function K(f,p){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=d.createFramebuffer();f.__webGLRenderbuffer=d.createRenderbuffer();
  200. f.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,f.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,f.width,f.height);d.bindTexture(d.TEXTURE_2D,f.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,J(f.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,J(f.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,J(f.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,J(f.min_filter));d.texImage2D(d.TEXTURE_2D,0,J(f.format),
  201. f.width,f.height,0,J(f.format),J(f.type),null);d.bindFramebuffer(d.FRAMEBUFFER,f.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,f.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,f.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var n,j,i;if(f){n=f.__webGLFramebuffer;j=f.width;i=f.height}else{n=null;j=r.width;i=r.height}if(n!=S){d.bindFramebuffer(d.FRAMEBUFFER,
  202. n);d.viewport(0,0,j,i);p&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);S=n}}function N(f,p){var n;if(f=="fragment")n=d.createShader(d.FRAGMENT_SHADER);else f=="vertex"&&(n=d.createShader(d.VERTEX_SHADER));d.shaderSource(n,p);d.compileShader(n);if(!d.getShaderParameter(n,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(n));return null}return n}function J(f){switch(f){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;
  203. case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;
  204. case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var r=document.createElement("canvas"),d,I=null,S=null,V=null,ea=null,T=null,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
  205. new THREE.Vector4],aa=new THREE.Matrix4,R=new Float32Array(16),ca=new Float32Array(16),W=new Float32Array(16),E=new THREE.Vector4,O=!0,ia=new THREE.Color(0),Q=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&ia.setHex(a.clearColor);if(a.clearAlpha!==undefined)Q=a.clearAlpha}this.domElement=r;this.autoClear=!0;this.sortObjects=!1;(function(f,p,n){try{d=r.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";
  206. }d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);d.clearColor(p.r,p.g,p.b,n);_cullEnabled=!0})(O,ia,Q);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,p){r.width=f;r.height=p;d.viewport(0,0,r.width,r.height)};this.setClearColorHex=function(f,
  207. p){var n=new THREE.Color(f);d.clearColor(n.r,n.g,n.b,p)};this.setClearColor=function(f,p){d.clearColor(f.r,f.g,f.b,p)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.setupLights=function(f,p){var n,j,i,q=0,s=0,w=0,F,t,y,B=this.lights,Y=B.directional.colors,ga=B.directional.positions,na=B.point.colors,ua=B.point.positions,Z=0,fa=0;n=i=i=0;for(j=p.length;n<j;n++){i=p[n];F=i.color;t=i.position;y=i.intensity;if(i instanceof THREE.AmbientLight){q+=F.r;s+=F.g;w+=F.b}else if(i instanceof
  208. THREE.DirectionalLight){i=Z*3;Y[i]=F.r*y;Y[i+1]=F.g*y;Y[i+2]=F.b*y;ga[i]=t.x;ga[i+1]=t.y;ga[i+2]=t.z;Z+=1}else if(i instanceof THREE.PointLight){i=fa*3;na[i]=F.r*y;na[i+1]=F.g*y;na[i+2]=F.b*y;ua[i]=t.x;ua[i+1]=t.y;ua[i+2]=t.z;fa+=1}}for(n=Z*3;n<Y.length;n++)Y[n]=0;for(n=fa*3;n<na.length;n++)na[n]=0;B.point.length=fa;B.directional.length=Z;B.ambient[0]=q;B.ambient[1]=s;B.ambient[2]=w};this.initMaterial=function(f,p,n){var j,i;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof
  209. 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 q,s,w,F;i=w=F=0;for(q=p.length;i<q;i++){s=p[i];s instanceof THREE.DirectionalLight&&
  210. w++;s instanceof THREE.PointLight&&F++}if(F+w<=4)p=w;else{p=Math.ceil(4*w/(F+w));F=4-p}i={directional:p,point:F};F=f.fragment_shader;p=f.vertex_shader;q={fog:n,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,skinning:f.skinning,maxDirLights:i.directional,maxPointLights:i.point};n=d.createProgram();i=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof
  211. THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":
  212. "",q.vertex_colors?"#define USE_COLOR":"",q.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
  213. d.attachShader(n,N("fragment",i+F));d.attachShader(n,N("vertex",q+p));d.linkProgram(n);d.getProgramParameter(n,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(n,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");n.uniforms={};n.attributes={};f.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(j in f.uniforms)n.push(j);j=f.program;F=0;for(p=n.length;F<
  214. p;F++){i=n[F];j.uniforms[i]=d.getUniformLocation(j,i)}f=f.program;j=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];n=0;for(F=j.length;n<F;n++){p=j[n];f.attributes[p]=d.getAttribLocation(f,p)}};this.setProgram=function(f,p,n,j,i){j.program||this.initMaterial(j,p,n);var q=j.program,s=q.uniforms,w=j.uniforms;if(q!=I){d.useProgram(q);I=q;d.uniformMatrix4fv(s.projectionMatrix,!1,R)}if(n&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||
  215. j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){w.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){w.fogNear.value=n.near;w.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)w.fogDensity.value=n.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){this.setupLights(q,p);p=this.lights;w.enableLighting.value=p.directional.length+p.point.length;w.ambientLightColor.value=p.ambient;
  216. w.directionalLightColor.value=p.directional.colors;w.directionalLightDirection.value=p.directional.positions;w.pointLightColor.value=p.point.colors;w.pointLightPosition.value=p.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){w.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);w.opacity.value=j.opacity;w.map.texture=j.map;w.light_map.texture=j.light_map;w.env_map.texture=j.env_map;
  217. w.reflectivity.value=j.reflectivity;w.refraction_ratio.value=j.refraction_ratio;w.combine.value=j.combine;w.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){w.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);w.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){w.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);w.opacity.value=j.opacity;
  218. w.size.value=j.size;w.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){w.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);w.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);w.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){w.mNear.value=f.near;w.mFar.value=f.far;w.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)w.opacity.value=j.opacity;var F,t,y;for(F in w)if(y=q.uniforms[F]){n=w[F];t=n.type;p=n.value;if(t=="i")d.uniform1i(y,
  219. p);else if(t=="f")d.uniform1f(y,p);else if(t=="fv1")d.uniform1fv(y,p);else if(t=="fv")d.uniform3fv(y,p);else if(t=="v2")d.uniform2f(y,p.x,p.y);else if(t=="v3")d.uniform3f(y,p.x,p.y,p.z);else if(t=="c")d.uniform3f(y,p.r,p.g,p.b);else if(t=="t"){d.uniform1i(y,p);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,
  220. n.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,n.image[t]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=
  221. !0}d.activeTexture(d.TEXTURE0+p);d.bindTexture(d.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,n.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,n.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,J(n.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,J(n.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,J(n.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,
  222. J(n.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+p);d.bindTexture(d.TEXTURE_2D,n.__webGLTexture)}}}d.uniformMatrix4fv(s.modelViewMatrix,!1,i._modelViewMatrixArray);d.uniformMatrix3fv(s.normalMatrix,!1,i._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&d.uniform3f(s.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&
  223. d.uniformMatrix4fv(s.objectMatrix,!1,i._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&d.uniformMatrix4fv(s.viewMatrix,!1,W);if(j.skinning){d.uniformMatrix4fv(s.cameraInverseMatrix,!1,ca);d.uniformMatrix4fv(s.uBoneGlobalMatrices,!1,i.boneMatrices)}return q};this.renderBuffer=function(f,p,n,j,i,q){f=this.setProgram(f,p,n,j,q).attributes;d.bindBuffer(d.ARRAY_BUFFER,i.__webGLVertexBuffer);d.vertexAttribPointer(f.position,
  224. 3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.position);if(f.color>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLColorBuffer);d.vertexAttribPointer(f.color,3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.color)}if(f.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLNormalBuffer);d.vertexAttribPointer(f.normal,3,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.normal)}if(f.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLTangentBuffer);d.vertexAttribPointer(f.tangent,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.tangent)}if(f.uv>=
  225. 0)if(i.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUVBuffer);d.vertexAttribPointer(f.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv)}else d.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(i.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUV2Buffer);d.vertexAttribPointer(f.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv2)}else d.disableVertexAttribArray(f.uv2);if(q instanceof THREE.SkinnedMesh){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);d.vertexAttribPointer(f.skinVertexA,
  226. 4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinVertexA);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);d.vertexAttribPointer(f.skinVertexB,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinVertexB);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);d.vertexAttribPointer(f.skinIndex,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinIndex);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);d.vertexAttribPointer(f.skinWeight,4,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.skinWeight)}if(q instanceof
  227. THREE.Mesh)if(j.wireframe){d.lineWidth(j.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);d.drawElements(d.LINES,i.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,i.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(j.linewidth);d.drawArrays(q,0,i.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,
  228. 0,i.__webGLParticleCount)};this.render=function(f,p,n,j){var i,q,s,w,F,t,y,B,Y=f.lights,ga=f.fog;p.autoUpdateMatrix&&p.update();p.globalMatrix.flattenToArray(W);p.projectionMatrix.flattenToArray(R);p.inverseMatrix.flattenToArray(ca);aa.multiply(p.projectionMatrix,p.globalMatrix);h(aa);THREE.AnimationHandler&&THREE.AnimationHandler.update();f.update(undefined,!1,p);this.initWebGLObjects(f,p);K(n,j!==undefined?j:!0);this.autoClear&&this.clear();F=f.__webGLObjects.length;for(j=0;j<F;j++){i=f.__webGLObjects[j];
  229. y=i.object;if(y.visible)if(!(y instanceof THREE.Mesh)||l(y)){y.globalMatrix.flattenToArray(y._objectMatrixArray);v(y,p);o(i);i.render=!0;if(this.sortObjects){E.copy(y.position);aa.multiplyVector3(E);i.z=E.z}}else i.render=!1;else i.render=!1}this.sortObjects&&f.__webGLObjects.sort(u);t=f.__webGLObjectsImmediate.length;for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){y.autoUpdateMatrix&&y.globalMatrix.flattenToArray(y._objectMatrixArray);v(y,p);k(i)}}A(THREE.NormalBlending);
  230. for(j=0;j<F;j++){i=f.__webGLObjects[j];if(i.render){y=i.object;B=i.buffer;s=i.opaque;g(y);for(i=0;i<s.count;i++){w=s.list[i];this.setDepthTest(w.depth_test);this.renderBuffer(p,Y,ga,w,B,y)}}}for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){s=i.opaque;g(y);for(i=0;i<s.count;i++){w=s.list[i];this.setDepthTest(w.depth_test);q=this.setProgram(p,Y,ga,w,y);y.render(function(na){e(na,q)})}}}for(j=0;j<F;j++){i=f.__webGLObjects[j];if(i.render){y=i.object;B=i.buffer;s=i.transparent;
  231. g(y);for(i=0;i<s.count;i++){w=s.list[i];A(w.blending);this.setDepthTest(w.depth_test);this.renderBuffer(p,Y,ga,w,B,y)}}}for(j=0;j<t;j++){i=f.__webGLObjectsImmediate[j];y=i.object;if(y.visible){s=i.transparent;g(y);for(i=0;i<s.count;i++){w=s.list[i];A(w.blending);this.setDepthTest(w.depth_test);q=this.setProgram(p,Y,ga,w,y);y.render(function(na){e(na,q)})}}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,n.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);
  232. d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){var p,n,j;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}p=0;for(n=f.objects.length;p<n;p++){j=f.objects[p];var i=f,q=void 0,s=void 0,w=void 0,F=void 0;s=j.geometry;if(i.__webGLObjectsMap[j.id]==undefined){i.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);
  233. j.globalMatrix.flattenToArray(j._objectMatrixArray)}F=i.__webGLObjectsMap[j.id];objlist=i.__webGLObjects;if(j instanceof THREE.Mesh){for(q in s.geometryChunks){w=s.geometryChunks[q];if(!w.__webGLVertexBuffer){i=w;i.__webGLVertexBuffer=d.createBuffer();i.__webGLNormalBuffer=d.createBuffer();i.__webGLTangentBuffer=d.createBuffer();i.__webGLColorBuffer=d.createBuffer();i.__webGLUVBuffer=d.createBuffer();i.__webGLUV2Buffer=d.createBuffer();i.__webGLSkinVertexABuffer=d.createBuffer();i.__webGLSkinVertexBBuffer=
  234. d.createBuffer();i.__webGLSkinIndicesBuffer=d.createBuffer();i.__webGLSkinWeightsBuffer=d.createBuffer();i.__webGLFaceBuffer=d.createBuffer();i.__webGLLineBuffer=d.createBuffer();i=w;var t=j,y=void 0,B=void 0,Y=0,ga=0,na=0,ua=t.geometry.faces,Z=i.faces;y=0;for(B=Z.length;y<B;y++){fi=Z[y];face=ua[fi];if(face instanceof THREE.Face3){Y+=3;ga+=1;na+=3}else if(face instanceof THREE.Face4){Y+=4;ga+=2;na+=4}}i.__vertexArray=new Float32Array(Y*3);i.__normalArray=new Float32Array(Y*3);i.__tangentArray=new Float32Array(Y*
  235. 4);i.__colorArray=new Float32Array(Y*3);i.__uvArray=new Float32Array(Y*2);i.__uv2Array=new Float32Array(Y*2);i.__skinVertexAArray=new Float32Array(Y*4);i.__skinVertexBArray=new Float32Array(Y*4);i.__skinIndexArray=new Float32Array(Y*4);i.__skinWeightArray=new Float32Array(Y*4);i.__faceArray=new Uint16Array(ga*3);i.__lineArray=new Uint16Array(na*2);B=y=i;Y=void 0;ua=void 0;var fa=void 0,ha=void 0;fa=void 0;Z=!1;Y=0;for(ua=t.materials.length;Y<ua;Y++){fa=t.materials[Y];if(fa instanceof THREE.MeshFaceMaterial){fa=
  236. 0;for(ha=B.materials.length;fa<ha;fa++)if(B.materials[fa]&&B.materials[fa].shading!=undefined&&B.materials[fa].shading==THREE.SmoothShading){Z=!0;break}}else if(fa&&fa.shading!=undefined&&fa.shading==THREE.SmoothShading){Z=!0;break}if(Z)break}y.__needsSmoothNormals=Z;i.__webGLFaceCount=ga*3;i.__webGLLineCount=na*2;s.__dirtyVertices=!0;s.__dirtyElements=!0;s.__dirtyUvs=!0;s.__dirtyNormals=!0;s.__dirtyTangents=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs||s.__dirtyNormals||
  237. s.__dirtyColors||s.__dirtyTangents){i=w;ga=d.DYNAMIC_DRAW;na=void 0;y=void 0;var Ia=void 0,C=void 0,Ca=void 0,wa=void 0,za=void 0;Ia=void 0;var G=void 0,L=void 0,P=void 0,ja=void 0;G=void 0;L=void 0;P=void 0;C=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;G=void 0;L=void 0;P=void 0;ja=void 0;C=void 0;wa=void 0;Ca=void 0;za=void 0;var Ea=ha=fa=Z=ua=Y=t=B=0,ra=0,z=0,pa=i.__vertexArray,Ma=i.__uvArray,
  238. Ka=i.__uv2Array,Ha=i.__normalArray,la=i.__tangentArray,qa=i.__colorArray,ma=i.__skinVertexAArray,ka=i.__skinVertexBArray,oa=i.__skinIndexArray,$=i.__skinWeightArray,xa=i.__faceArray,va=i.__lineArray,Oa=i.__needsSmoothNormals,ya=j.geometry,Na=ya.__dirtyVertices,D=ya.__dirtyElements,ba=ya.__dirtyUvs,X=ya.__dirtyNormals,H=ya.__dirtyTangents,U=ya.__dirtyColors,da=ya.vertices,sa=i.faces,Aa=ya.faces,Da=ya.uvs,La=ya.uvs2,ta=ya.colors,Ga=ya.skinVerticesA,Ja=ya.skinVerticesB,Fa=ya.skinIndices,Ba=ya.skinWeights;
  239. na=0;for(y=sa.length;na<y;na++){Ia=sa[na];C=Aa[Ia];za=Da[Ia];Ia=La[Ia];Ca=C.vertexNormals;wa=C.normal;if(C instanceof THREE.Face3){if(Na){G=da[C.a].position;L=da[C.b].position;P=da[C.c].position;pa[t]=G.x;pa[t+1]=G.y;pa[t+2]=G.z;pa[t+3]=L.x;pa[t+4]=L.y;pa[t+5]=L.z;pa[t+6]=P.x;pa[t+7]=P.y;pa[t+8]=P.z;t+=9}if(Ba.length){G=Ba[C.a];L=Ba[C.b];P=Ba[C.c];$[z]=G.x;$[z+1]=G.y;$[z+2]=G.z;$[z+3]=G.w;$[z+4]=L.x;$[z+5]=L.y;$[z+6]=L.z;$[z+7]=L.w;$[z+8]=P.x;$[z+9]=P.y;$[z+10]=P.z;$[z+11]=P.w;G=Fa[C.a];L=Fa[C.b];
  240. P=Fa[C.c];oa[z]=G.x;oa[z+1]=G.y;oa[z+2]=G.z;oa[z+3]=G.w;oa[z+4]=L.x;oa[z+5]=L.y;oa[z+6]=L.z;oa[z+7]=L.w;oa[z+8]=P.x;oa[z+9]=P.y;oa[z+10]=P.z;oa[z+11]=P.w;G=Ga[C.a];L=Ga[C.b];P=Ga[C.c];ma[z]=G.x;ma[z+1]=G.y;ma[z+2]=G.z;ma[z+3]=1;ma[z+4]=L.x;ma[z+5]=L.y;ma[z+6]=L.z;ma[z+7]=1;ma[z+8]=P.x;ma[z+9]=P.y;ma[z+10]=P.z;ma[z+11]=1;G=Ja[C.a];L=Ja[C.b];P=Ja[C.c];ka[z]=G.x;ka[z+1]=G.y;ka[z+2]=G.z;ka[z+3]=1;ka[z+4]=L.x;ka[z+5]=L.y;ka[z+6]=L.z;ka[z+7]=1;ka[z+8]=P.x;ka[z+9]=P.y;ka[z+10]=P.z;ka[z+11]=1;z+=12}if(U&&
  241. ta.length){G=ta[C.a];L=ta[C.b];P=ta[C.c];qa[ra]=G.r;qa[ra+1]=G.g;qa[ra+2]=G.b;qa[ra+3]=L.r;qa[ra+4]=L.g;qa[ra+5]=L.b;qa[ra+6]=P.r;qa[ra+7]=P.g;qa[ra+8]=P.b;ra+=9}if(H&&ya.hasTangents){G=da[C.a].tangent;L=da[C.b].tangent;P=da[C.c].tangent;la[ha]=G.x;la[ha+1]=G.y;la[ha+2]=G.z;la[ha+3]=G.w;la[ha+4]=L.x;la[ha+5]=L.y;la[ha+6]=L.z;la[ha+7]=L.w;la[ha+8]=P.x;la[ha+9]=P.y;la[ha+10]=P.z;la[ha+11]=P.w;ha+=12}if(X)if(Ca.length==3&&Oa)for(C=0;C<3;C++){wa=Ca[C];Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}else for(C=
  242. 0;C<3;C++){Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}if(ba&&za)for(C=0;C<3;C++){Ca=za[C];Ma[Y]=Ca.u;Ma[Y+1]=Ca.v;Y+=2}if(ba&&Ia)for(C=0;C<3;C++){za=Ia[C];Ka[ua]=za.u;Ka[ua+1]=za.v;ua+=2}if(D){xa[Z]=B;xa[Z+1]=B+1;xa[Z+2]=B+2;Z+=3;va[Ea]=B;va[Ea+1]=B+1;va[Ea+2]=B;va[Ea+3]=B+2;va[Ea+4]=B+1;va[Ea+5]=B+2;Ea+=6;B+=3}}else if(C instanceof THREE.Face4){if(Na){G=da[C.a].position;L=da[C.b].position;P=da[C.c].position;ja=da[C.d].position;pa[t]=G.x;pa[t+1]=G.y;pa[t+2]=G.z;pa[t+3]=L.x;pa[t+4]=L.y;pa[t+5]=
  243. L.z;pa[t+6]=P.x;pa[t+7]=P.y;pa[t+8]=P.z;pa[t+9]=ja.x;pa[t+10]=ja.y;pa[t+11]=ja.z;t+=12}if(Ba.length){G=Ba[C.a];L=Ba[C.b];P=Ba[C.c];ja=Ba[C.d];$[z]=G.x;$[z+1]=G.y;$[z+2]=G.z;$[z+3]=G.w;$[z+4]=L.x;$[z+5]=L.y;$[z+6]=L.z;$[z+7]=L.w;$[z+8]=P.x;$[z+9]=P.y;$[z+10]=P.z;$[z+11]=P.w;$[z+12]=ja.x;$[z+13]=ja.y;$[z+14]=ja.z;$[z+15]=ja.w;G=Fa[C.a];L=Fa[C.b];P=Fa[C.c];ja=Fa[C.d];oa[z]=G.x;oa[z+1]=G.y;oa[z+2]=G.z;oa[z+3]=G.w;oa[z+4]=L.x;oa[z+5]=L.y;oa[z+6]=L.z;oa[z+7]=L.w;oa[z+8]=P.x;oa[z+9]=P.y;oa[z+10]=P.z;oa[z+
  244. 11]=P.w;oa[z+12]=ja.x;oa[z+13]=ja.y;oa[z+14]=ja.z;oa[z+15]=ja.w;G=Ga[C.a];L=Ga[C.b];P=Ga[C.c];ja=Ga[C.d];ma[z]=G.x;ma[z+1]=G.y;ma[z+2]=G.z;ma[z+3]=1;ma[z+4]=L.x;ma[z+5]=L.y;ma[z+6]=L.z;ma[z+7]=1;ma[z+8]=P.x;ma[z+9]=P.y;ma[z+10]=P.z;ma[z+11]=1;ma[z+12]=ja.x;ma[z+13]=ja.y;ma[z+14]=ja.z;ma[z+15]=1;G=Ja[C.a];L=Ja[C.b];P=Ja[C.c];ja=Ja[C.d];ka[z]=G.x;ka[z+1]=G.y;ka[z+2]=G.z;ka[z+3]=1;ka[z+4]=L.x;ka[z+5]=L.y;ka[z+6]=L.z;ka[z+7]=1;ka[z+8]=P.x;ka[z+9]=P.y;ka[z+10]=P.z;ka[z+11]=1;ka[z+12]=ja.x;ka[z+13]=ja.y;
  245. ka[z+14]=ja.z;ka[z+15]=1;z+=16}if(U&&ta.length){G=ta[C.a];L=ta[C.b];P=ta[C.c];ja=ta[C.d];qa[ra]=G.r;qa[ra+1]=G.g;qa[ra+2]=G.b;qa[ra+3]=L.r;qa[ra+4]=L.g;qa[ra+5]=L.b;qa[ra+6]=P.r;qa[ra+7]=P.g;qa[ra+8]=P.b;qa[ra+9]=ja.r;qa[ra+10]=ja.g;qa[ra+11]=ja.b;ra+=12}if(H&&ya.hasTangents){G=da[C.a].tangent;L=da[C.b].tangent;P=da[C.c].tangent;C=da[C.d].tangent;la[ha]=G.x;la[ha+1]=G.y;la[ha+2]=G.z;la[ha+3]=G.w;la[ha+4]=L.x;la[ha+5]=L.y;la[ha+6]=L.z;la[ha+7]=L.w;la[ha+8]=P.x;la[ha+9]=P.y;la[ha+10]=P.z;la[ha+11]=
  246. P.w;la[ha+12]=C.x;la[ha+13]=C.y;la[ha+14]=C.z;la[ha+15]=C.w;ha+=16}if(X)if(Ca.length==4&&Oa)for(C=0;C<4;C++){wa=Ca[C];Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}else for(C=0;C<4;C++){Ha[fa]=wa.x;Ha[fa+1]=wa.y;Ha[fa+2]=wa.z;fa+=3}if(ba&&za)for(C=0;C<4;C++){Ca=za[C];Ma[Y]=Ca.u;Ma[Y+1]=Ca.v;Y+=2}if(ba&&Ia)for(C=0;C<4;C++){za=Ia[C];Ka[ua]=za.u;Ka[ua+1]=za.v;ua+=2}if(D){xa[Z]=B;xa[Z+1]=B+1;xa[Z+2]=B+2;xa[Z+3]=B;xa[Z+4]=B+2;xa[Z+5]=B+3;Z+=6;va[Ea]=B;va[Ea+1]=B+1;va[Ea+2]=B;va[Ea+3]=B+3;va[Ea+4]=B+1;
  247. va[Ea+5]=B+2;va[Ea+6]=B+2;va[Ea+7]=B+3;Ea+=8;B+=4}}}if(Na){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,pa,ga)}if(U&&ta.length){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,qa,ga)}if(X){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ha,ga)}if(H&&ya.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,la,ga)}if(ba&&Y>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUVBuffer);
  248. d.bufferData(d.ARRAY_BUFFER,Ma,ga)}if(ba&&ua>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ka,ga)}if(D){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ga);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,va,ga)}if(z>0){d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,ma,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,
  249. ka,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,oa,ga);d.bindBuffer(d.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,$,ga)}}x(objlist,F,q,w,j)}s.__dirtyVertices=!1;s.__dirtyElements=!1;s.__dirtyUvs=!1;s.__dirtyNormals=!1;s.__dirtyTangents=!1;s.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=s;w=q.vertices.length;q.__vertexArray=
  250. new Float32Array(w*3);q.__colorArray=new Float32Array(w*3);q.__webGLLineCount=w;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;w=d.DYNAMIC_DRAW;B=void 0;B=void 0;t=void 0;i=void 0;Y=q.vertices;ga=q.colors;ua=Y.length;na=ga.length;Z=q.__vertexArray;y=q.__colorArray;fa=q.__dirtyColors;if(q.__dirtyVertices){for(B=0;B<ua;B++){t=Y[B].position;i=B*3;Z[i]=t.x;Z[i+1]=t.y;Z[i+2]=t.z}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Z,w)}if(fa){for(B=
  251. 0;B<na;B++){color=ga[B];i=B*3;y[i]=color.r;y[i+1]=color.g;y[i+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,y,w)}}x(objlist,F,0,s,j);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=s;w=q.vertices.length;q.__vertexArray=new Float32Array(w*3);q.__colorArray=new Float32Array(w*3);q.__sortArray=[];q.__webGLParticleCount=
  252. w;s.__dirtyVertices=!0;s.__dirtyColors=!0}(s.__dirtyVertices||s.__dirtyColors||j.sortParticles)&&b(s,d.DYNAMIC_DRAW,j,camera);x(objlist,F,0,s,j);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){s=F;if(s[0]==undefined){i.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});s[0]=1}}}};this.removeObject=function(f,p){var n,j;for(n=f.__webGLObjects.length-1;n>=0;n--){j=f.__webGLObjects[n].object;p==j&&f.__webGLObjects.splice(n,
  253. 1)}};this.addToRenderList=function(){};this.removeFromRenderList=function(){};this.setDepthTest=function(f){f?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(f,p){if(f){!p||p=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(f=="back")d.cullFace(d.BACK);else f=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  254. 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",
  255. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
  256. envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
  257. map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
  258. lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
  259. 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}",
  260. lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
  261. color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 uBoneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( uBoneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
  262. 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",
  263. 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)}}};
  264. THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
  265. value:1}},fragment_shader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,
  266. THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex,
  267. THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,
  268. THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,
  269. THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,
  270. THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,
  271. THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,
  272. THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
  273. THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",
  274. 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};
  275. 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=!1;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};
  276. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};