Three.js 180 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. // Three.js r33 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
  3. THREE.Color.prototype={autoUpdate:!0,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,f,g,h,k,j;if(c==0)e=f=g=0;else{h=Math.floor(a*6);k=a*6-h;a=c*(1-b);j=c*(1-b*k);b=c*(1-b*(1-k));switch(h){case 1:e=j;f=c;g=a;break;case 2:e=a;f=c;g=b;break;case 3:e=a;f=j;g=c;break;case 4:e=b;f=a;g=c;break;case 5:e=c;f=a;g=j;break;case 6:case 0:e=c;f=b;g=a}}this.r=e;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();
  4. this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB: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)}};
  5. THREE.Vector2=function(a,b){this.set(a||0,b||0)};
  6. THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
  7. this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,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.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
  9. b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.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.set(c*a.z-e*a.y,e*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
  10. a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(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.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
  11. this.length();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)}};THREE.Vector4=function(a,b,c,e){this.set(a||0,b||0,c||0,e||1)};
  12. 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.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
  13. a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
  14. THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,f=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(H,q,G,d){d=d.clone().subSelf(q);G=G.clone().subSelf(q);var M=H.clone().subSelf(q);H=d.dot(d);q=d.dot(G);d=d.dot(M);var Q=G.dot(G);G=G.dot(M);M=1/(H*Q-q*q);Q=(Q*d-q*G)*M;H=(H*G-q*d)*M;return Q>0&&H>0&&Q+H<1}var c,e,f,g,h,k,j,l,m,v,
  15. p,o=a.geometry,x=o.vertices,z=[];c=0;for(e=o.faces.length;c<e;c++){f=o.faces[c];v=this.origin.clone();p=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(x[f.a].position.clone());h=j.multiplyVector3(x[f.b].position.clone());k=j.multiplyVector3(x[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(x[f.d].position.clone()):null;l=a.matrixRotation.multiplyVector3(f.normal.clone());m=p.dot(l);if(m<0){l=l.dot((new THREE.Vector3).sub(g,v))/m;v=v.addSelf(p.multiplyScalar(l));if(f instanceof
  16. THREE.Face3){if(b(v,g,h,k)){f={distance:this.origin.distanceTo(v),point:v,face:f,object:a};z.push(f)}}else if(f instanceof THREE.Face4&&(b(v,g,h,j)||b(v,h,k,j))){f={distance:this.origin.distanceTo(v),point:v,face:f,object:a};z.push(f)}}}return z}};
  17. THREE.Rectangle=function(){function a(){g=e-b;h=f-c}var b,c,e,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(j,l,m,v){k=!1;b=j;c=l;e=m;f=v;a()};this.addPoint=function(j,l){if(k){k=!1;b=j;c=l;e=j;f=l}else{b=b<j?b:j;c=c<l?c:l;e=e>j?e:j;f=f>l?f:l}a()};
  18. this.add3Points=function(j,l,m,v,p,o){if(k){k=!1;b=j<m?j<p?j:p:m<p?m:p;c=l<v?l<o?l:o:v<o?v:o;e=j>m?j>p?j:p:m>p?m:p;f=l>v?l>o?l:o:v>o?v:o}else{b=j<m?j<p?j<b?j:b:p<b?p:b:m<p?m<b?m:b:p<b?p:b;c=l<v?l<o?l<c?l:c:o<c?o:c:v<o?v<c?v:c:o<c?o:c;e=j>m?j>p?j>e?j:e:p>e?p:e:m>p?m>e?m:e:p>e?p:e;f=l>v?l>o?l>f?l:f:o>f?o:f:v>o?v>f?v:f:o>f?o:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();e=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();e=e>j.getRight()?
  19. e:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e<j.getRight()?e:j.getRight();f=f<j.getBottom()?f:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(f,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=!0;f=e=c=b=0;a()};this.isEmpty=function(){return k}};
  20. 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}};
  21. THREE.Matrix4=function(a,b,c,e,f,g,h,k,j,l,m,v,p,o,x,z){this.set(a||1,b||0,c||0,e||0,f||0,g||1,h||0,k||0,j||0,l||0,m||1,v||0,p||0,o||0,x||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  22. THREE.Matrix4.prototype={set:function(a,b,c,e,f,g,h,k,j,l,m,v,p,o,x,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=l;this.n33=m;this.n34=v;this.n41=p;this.n42=o;this.n43=x;this.n44=z;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,
  23. f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();e.cross(c,g).normalize();f.cross(g,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=g.x;this.n14=a.x;this.n21=e.y;this.n22=f.y;this.n23=g.y;this.n24=a.y;this.n31=e.z;this.n32=f.z;this.n33=g.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,f=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)*f;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*f;a.z=(this.n31*
  24. b+this.n32*c+this.n33*e+this.n34)*f;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*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;
  25. 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*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,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,l=a.n24,m=a.n31,v=a.n32,p=a.n33,o=a.n34,x=a.n41,z=a.n42,H=a.n43,q=a.n44,G=b.n11,d=b.n12,M=b.n13,Q=b.n14,aa=b.n21,K=b.n22,L=b.n23,W=b.n24,T=b.n31,Y=b.n32,fa=b.n33,I=b.n34;this.n11=
  26. c*G+e*aa+f*T;this.n12=c*d+e*K+f*Y;this.n13=c*M+e*L+f*fa;this.n14=c*Q+e*W+f*I+g;this.n21=h*G+k*aa+j*T;this.n22=h*d+k*K+j*Y;this.n23=h*M+k*L+j*fa;this.n24=h*Q+k*W+j*I+l;this.n31=m*G+v*aa+p*T;this.n32=m*d+v*K+p*Y;this.n33=m*M+v*L+p*fa;this.n34=m*Q+v*W+p*I+o;this.n41=x*G+z*aa+H*T;this.n42=x*d+z*K+H*Y;this.n43=x*M+z*L+H*fa;this.n44=x*Q+z*W+H*I+q;return this},multiplyToArray:function(a,b,c){var e=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,l=a.n23,m=a.n24,v=a.n31,p=a.n32,o=a.n33,x=a.n34,z=a.n41,H=a.n42,
  27. q=a.n43;a=a.n44;var G=b.n11,d=b.n12,M=b.n13,Q=b.n14,aa=b.n21,K=b.n22,L=b.n23,W=b.n24,T=b.n31,Y=b.n32,fa=b.n33,I=b.n34,ea=b.n41,ra=b.n42,ba=b.n43;b=b.n44;this.n11=e*G+f*aa+g*T+h*ea;this.n12=e*d+f*K+g*Y+h*ra;this.n13=e*M+f*L+g*fa+h*ba;this.n14=e*Q+f*W+g*I+h*b;this.n21=k*G+j*aa+l*T+m*ea;this.n22=k*d+j*K+l*Y+m*ra;this.n23=k*M+j*L+l*fa+m*ba;this.n24=k*Q+j*W+l*I+m*b;this.n31=v*G+p*aa+o*T+x*ea;this.n32=v*d+p*K+o*Y+x*ra;this.n33=v*M+p*L+o*fa+x*ba;this.n34=v*Q+p*W+o*I+x*b;this.n41=z*G+H*aa+q*T+a*ea;this.n42=
  28. z*d+H*K+q*Y+a*ra;this.n43=z*M+H*L+q*fa+a*ba;this.n44=z*Q+H*W+q*I+a*b;c[0]=this.n11;c[1]=this.n21;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,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,l=this.n31,m=this.n32,v=this.n33,p=this.n34,o=this.n41,x=this.n42,z=this.n43,
  29. H=this.n44,q=a.n11,G=a.n21,d=a.n31,M=a.n12,Q=a.n22,aa=a.n32,K=a.n13,L=a.n23,W=a.n33,T=a.n14,Y=a.n24;a=a.n34;this.n11=b*q+c*G+e*d;this.n12=b*M+c*Q+e*aa;this.n13=b*K+c*L+e*W;this.n14=b*T+c*Y+e*a+f;this.n21=g*q+h*G+k*d;this.n22=g*M+h*Q+k*aa;this.n23=g*K+h*L+k*W;this.n24=g*T+h*Y+k*a+j;this.n31=l*q+m*G+v*d;this.n32=l*M+m*Q+v*aa;this.n33=l*K+m*L+v*W;this.n34=l*T+m*Y+v*a+p;this.n41=o*q+x*G+z*d;this.n42=o*M+x*Q+z*aa;this.n43=o*K+x*L+z*W;this.n44=o*T+x*Y+z*a+H;return this},multiplyScalar:function(a){this.n11*=
  30. 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,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,l=this.n32,m=this.n33,v=this.n34,p=this.n41,o=this.n42,x=this.n43,z=this.n44;return e*h*l*p-c*k*l*p-e*g*m*p+b*k*m*p+c*g*v*p-b*h*v*p-e*h*j*o+c*k*j*o+e*f*m*o-a*k*m*o-c*f*v*o+a*h*v*o+
  31. e*g*j*x-b*k*j*x-e*f*l*x+a*k*l*x+b*f*v*x-a*g*v*x-c*g*j*z+b*h*j*z+c*f*l*z-a*h*l*z-b*f*m*z+a*g*m*z},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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;
  32. a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,
  33. 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);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,
  34. 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),f=1-c,g=a.x,h=a.y,k=a.z,j=f*g,l=f*h;this.set(j*g+c,j*h-e*k,j*k+e*h,0,j*h+e*k,l*h+c,l*k-e*g,0,j*k-e*h,l*k+e*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=
  35. a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(e);e=Math.sin(e);var h=a*c,k=b*c;this.n11=f*g;this.n12=-f*e;this.n13=c;this.n21=k*g+a*e;this.n22=-k*e+a*g;this.n23=-b*f;this.n31=-h*g+b*e;this.n32=h*e+b*g;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,e=a.z,f=a.w,g=b+b,h=c+c,k=e+e;a=b*g;var j=b*h;b*=k;var l=c*h;c*=k;e*=k;g*=f;h*=f;f*=k;this.n11=1-(l+e);this.n12=j-f;this.n13=
  36. b+h;this.n21=j+f;this.n22=1-(a+e);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+l)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};
  37. 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};
  38. THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,l=a.n24,m=a.n31,v=a.n32,p=a.n33,o=a.n34,x=a.n41,z=a.n42,H=a.n43,q=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*o*z-l*p*z+l*v*H-k*o*H-j*v*q+k*p*q;b.n12=g*p*z-f*o*z-g*v*H+e*o*H+f*v*q-e*p*q;b.n13=f*l*z-g*j*z+g*k*H-e*l*H-f*k*q+e*j*q;b.n14=g*j*v-f*l*v-g*k*p+e*l*p+f*k*o-e*j*o;b.n21=l*p*x-j*o*x-l*m*H+h*o*H+j*m*q-h*p*q;b.n22=f*o*x-g*p*x+g*m*H-c*o*H-f*m*q+c*p*q;b.n23=g*j*x-f*l*x-g*h*H+c*l*H+f*h*q-c*j*q;
  39. b.n24=f*l*m-g*j*m+g*h*p-c*l*p-f*h*o+c*j*o;b.n31=k*o*x-l*v*x+l*m*z-h*o*z-k*m*q+h*v*q;b.n32=g*v*x-e*o*x-g*m*z+c*o*z+e*m*q-c*v*q;b.n33=f*l*x-g*k*x+g*h*z-c*l*z-e*h*q+c*k*q;b.n34=g*k*m-e*l*m-g*h*v+c*l*v+e*h*o-c*k*o;b.n41=j*v*x-k*p*x-j*m*z+h*p*z+k*m*H-h*v*H;b.n42=e*p*x-f*v*x+f*m*z-c*p*z-e*m*H+c*v*H;b.n43=f*k*x-e*j*x-f*h*z+c*j*z+e*h*H-c*k*H;b.n44=e*j*m-f*k*m+f*h*v-c*j*v-e*h*p+c*k*p;b.multiplyScalar(1/a.determinant());return b};
  40. THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,v=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*l;c[7]=a*m;c[8]=a*v;return b};
  41. THREE.Matrix4.makeFrustum=function(a,b,c,e,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(e-c);h.n23=(e+c)/(e-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,e)};
  42. THREE.Matrix4.makeOrtho=function(a,b,c,e,f,g){var h,k,j,l;h=new THREE.Matrix4;k=b-a;j=c-e;l=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+e)/j);h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-((g+f)/l);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  43. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotation=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=
  44. 0;this.boundRadiusScale=1;this.visible=!0};
  45. 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);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrixRotation.setRotationFromQuaternion(this.quaternion):
  46. this.matrixRotation.setRotationFromEuler(this.rotation);this.matrix.n11=this.matrixRotation.n11;this.matrix.n12=this.matrixRotation.n12;this.matrix.n13=this.matrixRotation.n13;this.matrix.n21=this.matrixRotation.n21;this.matrix.n22=this.matrixRotation.n22;this.matrix.n23=this.matrixRotation.n23;this.matrix.n31=this.matrixRotation.n31;this.matrix.n32=this.matrixRotation.n32;this.matrix.n33=this.matrixRotation.n33;if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);
  47. this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}a=0;for(var e=this.children.length;a<e;a++)this.children[a].update(this.matrixWorld,b,c)}}};THREE.Object3DCounter={value:0};
  48. THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?e:1)};
  49. THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,f=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(c);c=Math.sin(c);var h=a*b,k=e*f;this.w=h*g-k*c;this.x=h*c+k*g;this.y=e*b*g+a*f*c;this.z=a*f*g-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
  50. -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=b*a+f*g+c*k-e*h;this.y=c*a+f*h+e*g-b*k;this.z=e*a+f*k+b*h-c*g;this.w=f*a-b*g-c*h-e*k;return this},
  51. multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,f=a.z,g=this.x,h=this.y,k=this.z,j=this.w,l=j*c+h*f-k*e,m=j*e+k*c-g*f,v=j*f+g*e-h*c;c=-g*c-h*e-k*f;b.x=l*j+c*-g+m*-k-v*-h;b.y=m*j+c*-h+v*-g-l*-k;b.z=v*j+c*-k+l*-h-m*-g;return b}};
  52. THREE.Quaternion.slerp=function(a,b,c,e){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<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}f=Math.sin((1-e)*g)/h;e=Math.sin(e*g)/h;c.w=a.w*f+b.w*e;c.x=a.x*f+b.x*e;c.y=a.y*f+b.y*e;c.z=a.z*f+b.z*e;return c};
  53. 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};
  54. THREE.Face3=function(a,b,c,e,f){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=f instanceof Array?f:[f]};THREE.Face4=function(a,b,c,e,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};
  55. THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};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};
  56. 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);
  57. c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,f,g,h,k=new THREE.Vector3,j=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){g=this.vertices[e];g.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){g=this.faces[e];if(a&&g.vertexNormals.length){k.set(0,0,0);b=0;for(c=g.normal.length;b<c;b++)k.addSelf(g.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,
  58. c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();g.normal.copy(k)}},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,
  59. 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<
  60. 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(I,ea,ra,ba,na,n,A){g=I.vertices[ea].position;h=I.vertices[ra].position;k=I.vertices[ba].position;j=f[na];l=f[n];m=f[A];v=h.x-g.x;p=k.x-g.x;o=h.y-g.y;x=
  61. k.y-g.y;z=h.z-g.z;H=k.z-g.z;q=l.u-j.u;G=m.u-j.u;d=l.v-j.v;M=m.v-j.v;Q=1/(q*M-G*d);L.set((M*v-d*p)*Q,(M*o-d*x)*Q,(M*z-d*H)*Q);W.set((q*p-G*v)*Q,(q*x-G*o)*Q,(q*H-G*z)*Q);aa[ea].addSelf(L);aa[ra].addSelf(L);aa[ba].addSelf(L);K[ea].addSelf(W);K[ra].addSelf(W);K[ba].addSelf(W)}var b,c,e,f,g,h,k,j,l,m,v,p,o,x,z,H,q,G,d,M,Q,aa=[],K=[],L=new THREE.Vector3,W=new THREE.Vector3,T=new THREE.Vector3,Y=new THREE.Vector3,fa=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;K[b]=new THREE.Vector3}b=
  62. 0;for(c=this.faces.length;b<c;b++){e=this.faces[b];f=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]);
  63. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){fa.copy(this.vertices[b].normal);e=aa[b];T.copy(e);T.subSelf(fa.multiplyScalar(fa.dot(e))).normalize();Y.cross(this.vertices[b].normal,e);e=Y.dot(K[b]);e=e<0?-1:1;this.vertices[b].tangent.set(T.x,T.y,T.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],
  64. 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>
  65. 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(m){var v=[];b=0;for(c=m.length;b<c;b++)m[b]==undefined?v.push("undefined"):v.push(m[b].id);return v.join("_")}var b,c,e,f,g,h,k,j,l={};e=0;for(f=this.faces.length;e<f;e++){g=this.faces[e];
  66. h=g.materials;k=a(h);l[k]==undefined&&(l[k]={hash:k,counter:0});j=l[k].hash+"_"+l[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0});g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+g>65535){l[k].counter+=1;j=l[k].hash+"_"+l[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=g}}};THREE.GeometryIdCounter=0;
  67. 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 f=0;f<c.hierarchy[e].keys.length;f++){if(c.hierarchy[e].keys[f].time<0)c.hierarchy[e].keys[f].time=0;c.hierarchy[e].keys[f].index=f;if(c.hierarchy[e].keys[f].rot!==undefined&&!(c.hierarchy[e].keys[f].rot instanceof
  68. THREE.Quaternion)){var g=c.hierarchy[e].keys[f].rot;c.hierarchy[e].keys[f].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}}f=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(f));c.initialized=!0}};return b}();
  69. 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])};
  70. 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].matrixAutoUpdate=!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=
  71. 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)};
  72. THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.0010-this.startTime+this.offset,l=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.0010-j;j=(new Date).getTime()*0.0010-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var m=0,v=this.hierarchy.length;m<v;m++){g=this.hierarchy[m];if(k[m][h]!==
  73. undefined){g.skinMatrix=k[m][h];g.matrixAutoUpdate=!1;g.matrixNeedsUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,m*16)}else for(var p=0;p<3;p++){c=a[p];e=g.prevKey[c];f=g.nextKey[c];if(f.time<l){if(j<l)if(this.loop){e=this.data.hierarchy[m].keys[0];f=this.getNextKeyWith(c,m,1)}else{this.stop();return}else{do{e=f;f=this.getNextKeyWith(c,m,f.index+1)}while(f.time<j)}g.prevKey[c]=e;g.nextKey[c]=f}g.matrixAutoUpdate=!0;g.matrixNeedsUpdate=!0;b=(j-e.time)/(f.time-e.time);e=e[c];f=
  74. f[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,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=e[0]+(f[0]-e[0])*b;c.y=e[1]+(f[1]-e[1])*b;c.z=e[2]+(f[2]-e[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(m=0;m<this.hierarchy.length;m++)k[m][h]=this.hierarchy[m].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
  75. 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]};
  76. THREE.Camera=function(a,b,c,e,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=f||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y=
  77. 0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);if(h)this.tmpVec.y=0;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;
  78. THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
  79. THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
  80. this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
  81. THREE.Camera.prototype.frustumContains=function(a){var b=a.matrixWorld.n14,c=a.matrixWorld.n24,e=a.matrixWorld.n34,f=this.matrixWorldInverse,g=a.boundRadius*a.boundRadiusScale,h=f.n31*b+f.n32*c+f.n33*e+f.n34;if(h-g>-this.near)return!1;if(h+g<-this.far)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),l=j*this.screenCenterX,m=(f.n11*b+f.n12*c+f.n13*e+f.n14)*k.n11*l;g=k.n11*g*l;if(m+g<-this.screenCenterX)return!1;if(m-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*e+f.n24)*k.n22*j*this.screenCenterY;
  82. if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.positionScreen.set(m,b,h,g);return!0};function bind(a,b){return function(){b.apply(a,arguments)}}
  83. THREE.QuakeCamera=function(a){THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movement_speed=1;this.look_speed=0.0050;this.nofly=!1;this.look_vertical=!0;this.domElement=document;if(a){if(a.movement_speed!==undefined)this.movement_speed=a.movement_speed;if(a.look_speed!==undefined)this.look_speed=a.look_speed;if(a.nofly!==undefined)this.nofly=a.nofly;if(a.look_vertical!==undefined)this.look_vertical=a.look_vertical;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=
  84. this.phy=this.lon=this.lat=this.mouseY=this.mouseX=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=
  85. function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=
  86. function(){this.moveForward&&this.translateZ(-this.movement_speed,this.nofly);this.moveBackward&&this.translateZ(this.movement_speed,this.nofly);this.moveLeft&&this.translateX(-this.movement_speed,this.nofly);this.moveRight&&this.translateX(this.movement_speed,this.nofly);this.lon+=this.mouseX*this.look_speed;this.look_vertical&&(this.lat-=this.mouseY*this.look_speed);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,
  87. c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",bind(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",bind(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",bind(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",
  88. bind(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",bind(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;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;
  89. THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,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;
  90. 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;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};
  91. THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  92. 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=
  93. 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}};
  94. 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!==
  95. 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!==
  96. 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}};
  97. 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!==
  98. 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!==
  99. 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}};
  100. 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=
  101. 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;
  102. 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;
  103. 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}};
  104. 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!==
  105. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};
  106. 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!==
  107. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshFaceMaterial=function(){};
  108. 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=
  109. 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!==
  110. 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.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!==
  112. undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};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}};
  113. THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,b,c,e,f,g){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=f!==undefined?f:THREE.LinearFilter;this.min_filter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};
  114. 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)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
  115. 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;
  116. 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};
  117. var Uniforms={clone:function(a){var b,c,e,f={};for(b in a){f[b]={};for(c in a[b]){e=a[b][c];f[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var b,c,e,f={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)f[c]=e[c]}return f}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
  118. 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;
  119. 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.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;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
  120. 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;
  121. THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var e,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<f;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(e=0;e<f;e++)this.children[e].update(this.skinMatrix,
  122. 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;
  123. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,f,g,h,k;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){f=this.geometry.bones[c];g=f.pos;h=f.rotq;k=f.scl;e=this.addBone();e.name=f.name;e.position.set(g[0],g[1],g[2]);e.quaternion.set(h[0],h[1],h[2],h[3]);k!==undefined?e.scale.set(k[0],k[1],k[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){f=this.geometry.bones[c];e=this.bones[c];
  124. f.parent===-1?this.addChild(e):this.bones[f.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;
  125. THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var e,f=this.children.length;for(e=0;e<f;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.matrixWorld,b,c)}}};
  126. THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  127. 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 f=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
  128. e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[f].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[g].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}}}};
  129. THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
  130. THREE.Sound=function(a,b,c,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var f;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)f=
  131. "audio/mpeg";else if(b.indexOf(".ogg")!==-1)f="audio/ogg";else b.indexOf(".wav")!==-1&&(f="audio/wav");if(this.domElement.canPlayType(f)){f=document.createElement("source");f.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(f);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
  132. THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
  133. THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
  134. THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.sounds=[];this.fog=null;this.matrixAutoUpdate=!1};
  135. 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)};
  136. THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||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)};
  137. 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.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.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;
  138. THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;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};
  139. THREE.Projector=function(){function a(K,L){return L.z-K.z}function b(K,L){var W=0,T=1,Y=K.z+K.w,fa=L.z+L.w,I=-K.z+K.w,ea=-L.z+L.w;if(Y>=0&&fa>=0&&I>=0&&ea>=0)return!0;else if(Y<0&&fa<0||I<0&&ea<0)return!1;else{if(Y<0)W=Math.max(W,Y/(Y-fa));else fa<0&&(T=Math.min(T,Y/(Y-fa)));if(I<0)W=Math.max(W,I/(I-ea));else ea<0&&(T=Math.min(T,I/(I-ea)));if(T<W)return!1;else{K.lerpSelf(L,W);L.lerpSelf(K,1-T);return!0}}}var c,e,f=[],g,h,k,j=[],l,m,v=[],p,o,x=[],z=new THREE.Vector4,H=new THREE.Vector4,q=new THREE.Matrix4,
  140. G=new THREE.Matrix4,d=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,Q=new THREE.Vector4,aa;this.projectObjects=function(K,L,W){L=[];var T,Y,fa;e=0;Y=K.objects;K=0;for(T=Y.length;K<T;K++){fa=Y[K];var I;if(!(I=!fa.visible))if(I=fa instanceof THREE.Mesh){a:{I=void 0;for(var ea=fa.matrixWorld,ra=-fa.geometry.boundingSphere.radius*Math.max(fa.scale.x,Math.max(fa.scale.y,fa.scale.z)),ba=0;ba<6;ba++){I=d[ba].x*ea.n14+d[ba].y*
  141. ea.n24+d[ba].z*ea.n34+d[ba].w;if(I<=ra){I=!1;break a}}I=!0}I=!I}if(!I){c=f[e]=f[e]||new THREE.RenderableObject;z.copy(fa.position);q.multiplyVector3(z);c.object=fa;c.z=z.z;L.push(c);e++}}W&&L.sort(a);return L};this.projectScene=function(K,L,W){var T=[],Y=L.near,fa=L.far,I,ea,ra,ba,na,n,A,B,t,w,C,E,D,y,P,S;k=m=o=0;L.matrixAutoUpdate&&L.update();q.multiply(L.projectionMatrix,L.matrixWorld);d[0].set(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);d[1].set(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);
  142. d[2].set(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);d[3].set(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);d[4].set(q.n41-q.n31,q.n42-q.n32,q.n43-q.n33,q.n44-q.n34);d[5].set(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);for(I=0;I<6;I++){n=d[I];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}K.update(undefined,!1,L);n=this.projectObjects(K,L,!0);K=0;for(I=n.length;K<I;K++){A=n[K].object;if(A.visible){A.matrixAutoUpdate&&A.updateMatrix();B=A.matrixWorld;C=A.matrixRotation;t=A.materials;
  143. w=A.overdraw;if(A instanceof THREE.Mesh){E=A.geometry;D=E.vertices;ea=0;for(ra=D.length;ea<ra;ea++){y=D[ea];y.positionWorld.copy(y.position);B.multiplyVector3(y.positionWorld);ba=y.positionScreen;ba.copy(y.positionWorld);q.multiplyVector4(ba);ba.x/=ba.w;ba.y/=ba.w;y.__visible=ba.z>Y&&ba.z<fa}E=E.faces;ea=0;for(ra=E.length;ea<ra;ea++){y=E[ea];if(y instanceof THREE.Face3){ba=D[y.a];na=D[y.b];P=D[y.c];if(ba.__visible&&na.__visible&&P.__visible&&(A.doubleSided||A.flipSided!=(P.positionScreen.x-ba.positionScreen.x)*
  144. (na.positionScreen.y-ba.positionScreen.y)-(P.positionScreen.y-ba.positionScreen.y)*(na.positionScreen.x-ba.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(ba.positionWorld);g.v2.positionWorld.copy(na.positionWorld);g.v3.positionWorld.copy(P.positionWorld);g.v1.positionScreen.copy(ba.positionScreen);g.v2.positionScreen.copy(na.positionScreen);g.v3.positionScreen.copy(P.positionScreen);g.normalWorld.copy(y.normal);C.multiplyVector3(g.normalWorld);g.centroidWorld.copy(y.centroid);
  145. B.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);q.multiplyVector3(g.centroidScreen);P=y.vertexNormals;aa=g.vertexNormalsWorld;ba=0;for(na=P.length;ba<na;ba++){S=aa[ba]=aa[ba]||new THREE.Vector3;S.copy(P[ba]);C.multiplyVector3(S)}g.z=g.centroidScreen.z;g.meshMaterials=t;g.faceMaterials=y.materials;g.overdraw=w;if(A.geometry.uvs[ea]){g.uvs[0]=A.geometry.uvs[ea][0];g.uvs[1]=A.geometry.uvs[ea][1];g.uvs[2]=A.geometry.uvs[ea][2]}T.push(g);k++}}else if(y instanceof THREE.Face4){ba=
  146. D[y.a];na=D[y.b];P=D[y.c];S=D[y.d];if(ba.__visible&&na.__visible&&P.__visible&&S.__visible&&(A.doubleSided||A.flipSided!=((S.positionScreen.x-ba.positionScreen.x)*(na.positionScreen.y-ba.positionScreen.y)-(S.positionScreen.y-ba.positionScreen.y)*(na.positionScreen.x-ba.positionScreen.x)<0||(na.positionScreen.x-P.positionScreen.x)*(S.positionScreen.y-P.positionScreen.y)-(na.positionScreen.y-P.positionScreen.y)*(S.positionScreen.x-P.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(ba.positionWorld);
  147. g.v2.positionWorld.copy(na.positionWorld);g.v3.positionWorld.copy(S.positionWorld);g.v1.positionScreen.copy(ba.positionScreen);g.v2.positionScreen.copy(na.positionScreen);g.v3.positionScreen.copy(S.positionScreen);g.normalWorld.copy(y.normal);C.multiplyVector3(g.normalWorld);g.centroidWorld.copy(y.centroid);B.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);q.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=t;g.faceMaterials=y.materials;g.overdraw=w;
  148. if(A.geometry.uvs[ea]){g.uvs[0]=A.geometry.uvs[ea][0];g.uvs[1]=A.geometry.uvs[ea][1];g.uvs[2]=A.geometry.uvs[ea][3]}T.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(na.positionWorld);h.v2.positionWorld.copy(P.positionWorld);h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(na.positionScreen);h.v2.positionScreen.copy(P.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);
  149. h.z=h.centroidScreen.z;h.meshMaterials=t;h.faceMaterials=y.materials;h.overdraw=w;if(A.geometry.uvs[ea]){h.uvs[0]=A.geometry.uvs[ea][1];h.uvs[1]=A.geometry.uvs[ea][2];h.uvs[2]=A.geometry.uvs[ea][3]}T.push(h);k++}}}}else if(A instanceof THREE.Line){G.multiply(q,B);D=A.geometry.vertices;y=D[0];y.positionScreen.copy(y.position);G.multiplyVector4(y.positionScreen);ea=1;for(ra=D.length;ea<ra;ea++){ba=D[ea];ba.positionScreen.copy(ba.position);G.multiplyVector4(ba.positionScreen);na=D[ea-1];M.copy(ba.positionScreen);
  150. Q.copy(na.positionScreen);if(b(M,Q)){M.multiplyScalar(1/M.w);Q.multiplyScalar(1/Q.w);l=v[m]=v[m]||new THREE.RenderableLine;l.v1.positionScreen.copy(M);l.v2.positionScreen.copy(Q);l.z=Math.max(M.z,Q.z);l.materials=A.materials;T.push(l);m++}}}else if(A instanceof THREE.Particle){H.set(A.position.x,A.position.y,A.position.z,1);q.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){p=x[o]=x[o]||new THREE.RenderableParticle;p.x=H.x/H.w;p.y=H.y/H.w;p.z=H.z;p.rotation=A.rotation.z;p.scale.x=A.scale.x*Math.abs(p.x-
  151. (H.x+L.projectionMatrix.n11)/(H.w+L.projectionMatrix.n14));p.scale.y=A.scale.y*Math.abs(p.y-(H.y+L.projectionMatrix.n22)/(H.w+L.projectionMatrix.n24));p.materials=A.materials;T.push(p);o++}}}}W&&T.sort(a);return T};this.unprojectVector=function(K,L){var W=THREE.Matrix4.makeInvert(L.matrixWorld);W.multiplySelf(THREE.Matrix4.makeInvert(L.projectionMatrix));W.multiplyVector3(K);return K}};
  152. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;f=c/2;g=e/2};this.render=function(h,k){var j,l,m,v,p,o,x,z;a=b.projectScene(h,k);j=0;for(l=a.length;j<l;j++){p=a[j];if(p instanceof THREE.RenderableParticle){x=p.x*f+f;z=p.y*g+g;m=0;for(v=p.material.length;m<v;m++){o=p.material[m];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=x+"px";o.style.top=z+"px"}}}}}};
  153. THREE.CanvasRenderer=function(){function a(oa){if(p!=oa)l.globalAlpha=p=oa}function b(oa){if(o!=oa){switch(oa){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}o=oa}}var c=null,e=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,l=f.getContext("2d"),m=new THREE.Color(0),v=0,p=1,o=0,x=null,z=null,H=1,q,G,d,M,Q,aa,K,L,W,T=new THREE.Color,
  154. Y=new THREE.Color,fa=new THREE.Color,I=new THREE.Color,ea=new THREE.Color,ra,ba,na,n,A,B,t,w,C,E=new THREE.Rectangle,D=new THREE.Rectangle,y=new THREE.Rectangle,P=!1,S=new THREE.Color,Z=new THREE.Color,la=new THREE.Color,u=new THREE.Color,F=Math.PI*2,N=new THREE.Vector3,V,X,ja,ga,Ca,R,Aa=16;V=document.createElement("canvas");V.width=V.height=2;X=V.getContext("2d");X.fillStyle="rgba(0,0,0,1)";X.fillRect(0,0,2,2);ja=X.getImageData(0,0,2,2);ga=ja.data;Ca=document.createElement("canvas");Ca.width=Ca.height=
  155. Aa;R=Ca.getContext("2d");R.translate(-Aa/2,-Aa/2);R.scale(Aa,Aa);Aa--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(oa,Da){g=oa;h=Da;k=g/2;j=h/2;f.width=g;f.height=h;E.set(-k,-j,k,j);p=1;o=0;z=x=null;H=1};this.setClearColor=function(oa,Da){m=oa;v=Da;D.set(-k,-j,k,j);l.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(oa,Da){m.setHex(oa);v=Da;D.set(-k,-j,k,j);l.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){l.setTransform(1,
  156. 0,0,-1,k,j);if(!D.isEmpty()){D.inflate(1);D.minSelf(E);if(m.hex==0&&v==0)l.clearRect(D.getX(),D.getY(),D.getWidth(),D.getHeight());else{b(THREE.NormalBlending);a(1);l.fillStyle="rgba("+Math.floor(m.r*255)+","+Math.floor(m.g*255)+","+Math.floor(m.b*255)+","+v+")";l.fillRect(D.getX(),D.getY(),D.getWidth(),D.getHeight())}D.empty()}};this.render=function(oa,Da){function ca(O){var ma,ia,U,ha=O.lights;Z.setRGB(0,0,0);la.setRGB(0,0,0);u.setRGB(0,0,0);O=0;for(ma=ha.length;O<ma;O++){ia=ha[O];U=ia.color;if(ia instanceof
  157. THREE.AmbientLight){Z.r+=U.r;Z.g+=U.g;Z.b+=U.b}else if(ia instanceof THREE.DirectionalLight){la.r+=U.r;la.g+=U.g;la.b+=U.b}else if(ia instanceof THREE.PointLight){u.r+=U.r;u.g+=U.g;u.b+=U.b}}}function $(O,ma,ia,U){var ha,qa,Ba,va,Ea=O.lights;O=0;for(ha=Ea.length;O<ha;O++){qa=Ea[O];Ba=qa.color;va=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ia.dot(qa.position)*va;if(qa>0){U.r+=Ba.r*qa;U.g+=Ba.g*qa;U.b+=Ba.b*qa}}else if(qa instanceof THREE.PointLight){N.sub(qa.position,ma);N.normalize();
  158. qa=ia.dot(N)*va;if(qa>0){U.r+=Ba.r*qa;U.g+=Ba.g*qa;U.b+=Ba.b*qa}}}}function da(O,ma,ia){if(ia.opacity!=0){a(ia.opacity);b(ia.blending);var U,ha,qa,Ba,va,Ea;if(ia instanceof THREE.ParticleBasicMaterial){if(ia.map){Ba=ia.map.image;va=Ba.width>>1;Ea=Ba.height>>1;ha=ma.scale.x*k;qa=ma.scale.y*j;ia=ha*va;U=qa*Ea;y.set(O.x-ia,O.y-U,O.x+ia,O.y+U);if(E.instersects(y)){l.save();l.translate(O.x,O.y);l.rotate(-ma.rotation);l.scale(ha,-qa);l.translate(-va,-Ea);l.drawImage(Ba,0,0);l.restore()}}}else if(ia instanceof
  159. THREE.ParticleCircleMaterial){if(P){S.r=Z.r+la.r+u.r;S.g=Z.g+la.g+u.g;S.b=Z.b+la.b+u.b;T.r=ia.color.r*S.r;T.g=ia.color.g*S.g;T.b=ia.color.b*S.b;T.updateStyleString()}else T.__styleString=ia.color.__styleString;ia=ma.scale.x*k;U=ma.scale.y*j;y.set(O.x-ia,O.y-U,O.x+ia,O.y+U);if(E.instersects(y)){ha=T.__styleString;if(z!=ha)l.fillStyle=z=ha;l.save();l.translate(O.x,O.y);l.rotate(-ma.rotation);l.scale(ia,U);l.beginPath();l.arc(0,0,1,0,F,!0);l.closePath();l.fill();l.restore()}}}}function ta(O,ma,ia,U){if(U.opacity!=
  160. 0){a(U.opacity);b(U.blending);l.beginPath();l.moveTo(O.positionScreen.x,O.positionScreen.y);l.lineTo(ma.positionScreen.x,ma.positionScreen.y);l.closePath();if(U instanceof THREE.LineBasicMaterial){T.__styleString=U.color.__styleString;O=U.linewidth;if(H!=O)l.lineWidth=H=O;O=T.__styleString;if(x!=O)l.strokeStyle=x=O;l.stroke();y.inflate(U.linewidth*2)}}}function Fa(O,ma,ia,U,ha,qa){if(ha.opacity!=0){a(ha.opacity);b(ha.blending);M=O.positionScreen.x;Q=O.positionScreen.y;aa=ma.positionScreen.x;K=ma.positionScreen.y;
  161. L=ia.positionScreen.x;W=ia.positionScreen.y;l.beginPath();l.moveTo(M,Q);l.lineTo(aa,K);l.lineTo(L,W);l.lineTo(M,Q);l.closePath();if(ha instanceof THREE.MeshBasicMaterial)if(ha.map)ha.map.mapping instanceof THREE.UVMapping&&xa(M,Q,aa,K,L,W,ha.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);else if(ha.env_map){if(ha.env_map.mapping instanceof THREE.SphericalReflectionMapping){O=Da.matrixWorld;N.copy(U.vertexNormalsWorld[0]);n=(N.x*O.n11+N.y*O.n12+N.z*O.n13)*0.5+0.5;A=-(N.x*
  162. O.n21+N.y*O.n22+N.z*O.n23)*0.5+0.5;N.copy(U.vertexNormalsWorld[1]);B=(N.x*O.n11+N.y*O.n12+N.z*O.n13)*0.5+0.5;t=-(N.x*O.n21+N.y*O.n22+N.z*O.n23)*0.5+0.5;N.copy(U.vertexNormalsWorld[2]);w=(N.x*O.n11+N.y*O.n12+N.z*O.n13)*0.5+0.5;C=-(N.x*O.n21+N.y*O.n22+N.z*O.n23)*0.5+0.5;xa(M,Q,aa,K,L,W,ha.env_map.image,n,A,B,t,w,C)}}else ha.wireframe?ya(ha.color.__styleString,ha.wireframe_linewidth):J(ha.color.__styleString);else if(ha instanceof THREE.MeshLambertMaterial){if(ha.map&&!ha.wireframe){ha.map.mapping instanceof
  163. THREE.UVMapping&&xa(M,Q,aa,K,L,W,ha.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);b(THREE.SubtractiveBlending)}if(P)if(!ha.wireframe&&ha.shading==THREE.SmoothShading&&U.vertexNormalsWorld.length==3){Y.r=fa.r=I.r=Z.r;Y.g=fa.g=I.g=Z.g;Y.b=fa.b=I.b=Z.b;$(qa,U.v1.positionWorld,U.vertexNormalsWorld[0],Y);$(qa,U.v2.positionWorld,U.vertexNormalsWorld[1],fa);$(qa,U.v3.positionWorld,U.vertexNormalsWorld[2],I);ea.r=(fa.r+I.r)*0.5;ea.g=(fa.g+I.g)*0.5;ea.b=(fa.b+I.b)*0.5;na=Ra(Y,
  164. fa,I,ea);xa(M,Q,aa,K,L,W,na,0,0,1,0,0,1)}else{S.r=Z.r;S.g=Z.g;S.b=Z.b;$(qa,U.centroidWorld,U.normalWorld,S);T.r=ha.color.r*S.r;T.g=ha.color.g*S.g;T.b=ha.color.b*S.b;T.updateStyleString();ha.wireframe?ya(T.__styleString,ha.wireframe_linewidth):J(T.__styleString)}else ha.wireframe?ya(ha.color.__styleString,ha.wireframe_linewidth):J(ha.color.__styleString)}else if(ha instanceof THREE.MeshDepthMaterial){ra=Da.near;ba=Da.far;Y.r=Y.g=Y.b=1-Pa(O.positionScreen.z,ra,ba);fa.r=fa.g=fa.b=1-Pa(ma.positionScreen.z,
  165. ra,ba);I.r=I.g=I.b=1-Pa(ia.positionScreen.z,ra,ba);ea.r=(fa.r+I.r)*0.5;ea.g=(fa.g+I.g)*0.5;ea.b=(fa.b+I.b)*0.5;na=Ra(Y,fa,I,ea);xa(M,Q,aa,K,L,W,na,0,0,1,0,0,1)}else if(ha instanceof THREE.MeshNormalMaterial){T.r=Ia(U.normalWorld.x);T.g=Ia(U.normalWorld.y);T.b=Ia(U.normalWorld.z);T.updateStyleString();ha.wireframe?ya(T.__styleString,ha.wireframe_linewidth):J(T.__styleString)}}}function ya(O,ma){if(x!=O)l.strokeStyle=x=O;if(H!=ma)l.lineWidth=H=ma;l.stroke();y.inflate(ma*2)}function J(O){if(z!=O)l.fillStyle=
  166. z=O;l.fill()}function xa(O,ma,ia,U,ha,qa,Ba,va,Ea,Na,La,Oa,Ka){var Ga,Ja;Ga=Ba.width-1;Ja=Ba.height-1;va*=Ga;Ea*=Ja;Na*=Ga;La*=Ja;Oa*=Ga;Ka*=Ja;ia-=O;U-=ma;ha-=O;qa-=ma;Na-=va;La-=Ea;Oa-=va;Ka-=Ea;Ga=Na*Ka-Oa*La;if(Ga!=0){Ja=1/Ga;Ga=(Ka*ia-La*ha)*Ja;La=(Ka*U-La*qa)*Ja;ia=(Na*ha-Oa*ia)*Ja;U=(Na*qa-Oa*U)*Ja;O=O-Ga*va-ia*Ea;ma=ma-La*va-U*Ea;l.save();l.transform(Ga,La,ia,U,O,ma);l.clip();l.drawImage(Ba,0,0);l.restore()}}function Ra(O,ma,ia,U){var ha=~~(O.r*255),qa=~~(O.g*255);O=~~(O.b*255);var Ba=~~(ma.r*
  167. 255),va=~~(ma.g*255);ma=~~(ma.b*255);var Ea=~~(ia.r*255),Na=~~(ia.g*255);ia=~~(ia.b*255);var La=~~(U.r*255),Oa=~~(U.g*255);U=~~(U.b*255);ga[0]=ha<0?0:ha>255?255:ha;ga[1]=qa<0?0:qa>255?255:qa;ga[2]=O<0?0:O>255?255:O;ga[4]=Ba<0?0:Ba>255?255:Ba;ga[5]=va<0?0:va>255?255:va;ga[6]=ma<0?0:ma>255?255:ma;ga[8]=Ea<0?0:Ea>255?255:Ea;ga[9]=Na<0?0:Na>255?255:Na;ga[10]=ia<0?0:ia>255?255:ia;ga[12]=La<0?0:La>255?255:La;ga[13]=Oa<0?0:Oa>255?255:Oa;ga[14]=U<0?0:U>255?255:U;X.putImageData(ja,0,0);R.drawImage(V,0,0);
  168. return Ca}function Pa(O,ma,ia){O=(O-ma)/(ia-ma);return O*O*(3-2*O)}function Ia(O){O=(O+1)*0.5;return O<0?0:O>1?1:O}function ua(O,ma){var ia=ma.x-O.x,U=ma.y-O.y,ha=1/Math.sqrt(ia*ia+U*U);ia*=ha;U*=ha;ma.x+=ia;ma.y+=U;O.x-=ia;O.y-=U}var za,wa,ka,pa,sa,Ma,Ha,Sa;this.autoClear?this.clear():l.setTransform(1,0,0,-1,k,j);c=e.projectScene(oa,Da,this.sortElements);(P=oa.lights.length>0)&&ca(oa);za=0;for(wa=c.length;za<wa;za++){ka=c[za];y.empty();if(ka instanceof THREE.RenderableParticle){q=ka;q.x*=k;q.y*=
  169. j;pa=0;for(sa=ka.materials.length;pa<sa;pa++)da(q,ka,ka.materials[pa],oa)}else if(ka instanceof THREE.RenderableLine){q=ka.v1;G=ka.v2;q.positionScreen.x*=k;q.positionScreen.y*=j;G.positionScreen.x*=k;G.positionScreen.y*=j;y.addPoint(q.positionScreen.x,q.positionScreen.y);y.addPoint(G.positionScreen.x,G.positionScreen.y);if(E.instersects(y)){pa=0;for(sa=ka.materials.length;pa<sa;)ta(q,G,ka,ka.materials[pa++],oa)}}else if(ka instanceof THREE.RenderableFace3){q=ka.v1;G=ka.v2;d=ka.v3;q.positionScreen.x*=
  170. k;q.positionScreen.y*=j;G.positionScreen.x*=k;G.positionScreen.y*=j;d.positionScreen.x*=k;d.positionScreen.y*=j;if(ka.overdraw){ua(q.positionScreen,G.positionScreen);ua(G.positionScreen,d.positionScreen);ua(d.positionScreen,q.positionScreen)}y.add3Points(q.positionScreen.x,q.positionScreen.y,G.positionScreen.x,G.positionScreen.y,d.positionScreen.x,d.positionScreen.y);if(E.instersects(y)){pa=0;for(sa=ka.meshMaterials.length;pa<sa;){Sa=ka.meshMaterials[pa++];if(Sa instanceof THREE.MeshFaceMaterial){Ma=
  171. 0;for(Ha=ka.faceMaterials.length;Ma<Ha;)(Sa=ka.faceMaterials[Ma++])&&Fa(q,G,d,ka,Sa,oa)}else Fa(q,G,d,ka,Sa,oa)}}}D.addRectangle(y)}l.setTransform(1,0,0,1,0,0)}};
  172. THREE.SVGRenderer=function(){function a(n,A,B){var t,w,C,E;t=0;for(w=n.lights.length;t<w;t++){C=n.lights[t];if(C instanceof THREE.DirectionalLight){E=A.normalWorld.dot(C.position)*C.intensity;if(E>0){B.r+=C.color.r*E;B.g+=C.color.g*E;B.b+=C.color.b*E}}else if(C instanceof THREE.PointLight){W.sub(C.position,A.centroidWorld);W.normalize();E=A.normalWorld.dot(W)*C.intensity;if(E>0){B.r+=C.color.r*E;B.g+=C.color.g*E;B.b+=C.color.b*E}}}}function b(n,A,B,t,w,C){I=e(ea++);I.setAttribute("d","M "+n.positionScreen.x+
  173. " "+n.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+B.positionScreen.x+","+B.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)d.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(G){M.r=Q.r;M.g=Q.g;M.b=Q.b;a(C,t,M);d.r=w.color.r*M.r;d.g=w.color.g*M.g;d.b=w.color.b*M.b;d.updateStyleString()}else d.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){L=1-w.__2near/(w.__farPlusNear-t.z*w.__farMinusNear);
  174. d.setRGB(L,L,L)}else w instanceof THREE.MeshNormalMaterial&&d.setRGB(f(t.normalWorld.x),f(t.normalWorld.y),f(t.normalWorld.z));w.wireframe?I.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):I.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+w.opacity);k.appendChild(I)}function c(n,A,B,t,w,C,E){I=e(ea++);I.setAttribute("d",
  175. "M "+n.positionScreen.x+" "+n.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+B.positionScreen.x+","+B.positionScreen.y+" L "+t.positionScreen.x+","+t.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)d.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(G){M.r=Q.r;M.g=Q.g;M.b=Q.b;a(E,w,M);d.r=C.color.r*M.r;d.g=C.color.g*M.g;d.b=C.color.b*M.b;d.updateStyleString()}else d.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){L=
  176. 1-C.__2near/(C.__farPlusNear-w.z*C.__farMinusNear);d.setRGB(L,L,L)}else C instanceof THREE.MeshNormalMaterial&&d.setRGB(f(w.normalWorld.x),f(w.normalWorld.y),f(w.normalWorld.z));C.wireframe?I.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):I.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+C.opacity);k.appendChild(I)}
  177. function e(n){if(T[n]==null){T[n]=document.createElementNS("http://www.w3.org/2000/svg","path");na==0&&T[n].setAttribute("shape-rendering","crispEdges")}return T[n]}function f(n){return n<0?Math.min((1+n)*0.5,0.5):0.5+Math.min(n*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,m,v,p,o,x,z,H=new THREE.Rectangle,q=new THREE.Rectangle,G=!1,d=new THREE.Color(16777215),M=new THREE.Color(16777215),Q=new THREE.Color(0),aa=new THREE.Color(0),K=new THREE.Color(0),
  178. L,W=new THREE.Vector3,T=[],Y=[],fa=[],I,ea,ra,ba,na=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(n){switch(n){case "high":na=1;break;case "low":na=0}};this.setSize=function(n,A){j=n;l=A;m=j/2;v=l/2;k.setAttribute("viewBox",-m+" "+-v+" "+j+" "+l);k.setAttribute("width",j);k.setAttribute("height",l);H.set(-m,-v,m,v)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(n,A){var B,t,w,C,E,D,y,
  179. P;this.autoClear&&this.clear();g=h.projectScene(n,A,this.sortElements);ba=ra=ea=0;if(G=n.lights.length>0){y=n.lights;Q.setRGB(0,0,0);aa.setRGB(0,0,0);K.setRGB(0,0,0);B=0;for(t=y.length;B<t;B++){w=y[B];C=w.color;if(w instanceof THREE.AmbientLight){Q.r+=C.r;Q.g+=C.g;Q.b+=C.b}else if(w instanceof THREE.DirectionalLight){aa.r+=C.r;aa.g+=C.g;aa.b+=C.b}else if(w instanceof THREE.PointLight){K.r+=C.r;K.g+=C.g;K.b+=C.b}}}B=0;for(t=g.length;B<t;B++){y=g[B];q.empty();if(y instanceof THREE.RenderableParticle){p=
  180. y;p.x*=m;p.y*=-v;w=0;for(C=y.materials.length;w<C;w++)if(P=y.materials[w]){E=p;D=y;var S=ra++;if(Y[S]==null){Y[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");na==0&&Y[S].setAttribute("shape-rendering","crispEdges")}I=Y[S];I.setAttribute("cx",E.x);I.setAttribute("cy",E.y);I.setAttribute("r",D.scale.x*m);if(P instanceof THREE.ParticleCircleMaterial){if(G){M.r=Q.r+aa.r+K.r;M.g=Q.g+aa.g+K.g;M.b=Q.b+aa.b+K.b;d.r=P.color.r*M.r;d.g=P.color.g*M.g;d.b=P.color.b*M.b;d.updateStyleString()}else d=
  181. P.color;I.setAttribute("style","fill: "+d.__styleString)}k.appendChild(I)}}else if(y instanceof THREE.RenderableLine){p=y.v1;o=y.v2;p.positionScreen.x*=m;p.positionScreen.y*=-v;o.positionScreen.x*=m;o.positionScreen.y*=-v;q.addPoint(p.positionScreen.x,p.positionScreen.y);q.addPoint(o.positionScreen.x,o.positionScreen.y);if(H.instersects(q)){w=0;for(C=y.materials.length;w<C;)if(P=y.materials[w++]){E=p;D=o;S=ba++;if(fa[S]==null){fa[S]=document.createElementNS("http://www.w3.org/2000/svg","line");na==
  182. 0&&fa[S].setAttribute("shape-rendering","crispEdges")}I=fa[S];I.setAttribute("x1",E.positionScreen.x);I.setAttribute("y1",E.positionScreen.y);I.setAttribute("x2",D.positionScreen.x);I.setAttribute("y2",D.positionScreen.y);if(P instanceof THREE.LineBasicMaterial){d.__styleString=P.color.__styleString;I.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin);k.appendChild(I)}}}}else if(y instanceof
  183. THREE.RenderableFace3){p=y.v1;o=y.v2;x=y.v3;p.positionScreen.x*=m;p.positionScreen.y*=-v;o.positionScreen.x*=m;o.positionScreen.y*=-v;x.positionScreen.x*=m;x.positionScreen.y*=-v;q.addPoint(p.positionScreen.x,p.positionScreen.y);q.addPoint(o.positionScreen.x,o.positionScreen.y);q.addPoint(x.positionScreen.x,x.positionScreen.y);if(H.instersects(q)){w=0;for(C=y.meshMaterials.length;w<C;){P=y.meshMaterials[w++];if(P instanceof THREE.MeshFaceMaterial){E=0;for(D=y.faceMaterials.length;E<D;)(P=y.faceMaterials[E++])&&
  184. b(p,o,x,y,P,n)}else P&&b(p,o,x,y,P,n)}}}else if(y instanceof THREE.RenderableFace4){p=y.v1;o=y.v2;x=y.v3;z=y.v4;p.positionScreen.x*=m;p.positionScreen.y*=-v;o.positionScreen.x*=m;o.positionScreen.y*=-v;x.positionScreen.x*=m;x.positionScreen.y*=-v;z.positionScreen.x*=m;z.positionScreen.y*=-v;q.addPoint(p.positionScreen.x,p.positionScreen.y);q.addPoint(o.positionScreen.x,o.positionScreen.y);q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(q)){w=
  185. 0;for(C=y.meshMaterials.length;w<C;){P=y.meshMaterials[w++];if(P instanceof THREE.MeshFaceMaterial){E=0;for(D=y.faceMaterials.length;E<D;)(P=y.faceMaterials[E++])&&c(p,o,x,z,y,P,n)}else P&&c(p,o,x,z,y,P,n)}}}}}};
  186. THREE.WebGLRenderer=function(a){function b(n,A,B){var t,w,C,E=n.vertices,D=E.length,y=n.colors,P=y.length,S=n.__vertexArray,Z=n.__colorArray,la=n.__sortArray,u=n.__dirtyVertices,F=n.__dirtyColors;if(B.sortParticles){Y.multiplySelf(B.matrixWorld);for(t=0;t<D;t++){w=E[t].position;ea.copy(w);Y.multiplyVector3(ea);la[t]=[ea.z,t]}la.sort(function(N,V){return V[0]-N[0]});for(t=0;t<D;t++){w=E[la[t][1]].position;C=t*3;S[C]=w.x;S[C+1]=w.y;S[C+2]=w.z}for(t=0;t<P;t++){C=t*3;color=y[la[t][1]];Z[C]=color.r;Z[C+
  187. 1]=color.g;Z[C+2]=color.b}}else{if(u)for(t=0;t<D;t++){w=E[t].position;C=t*3;S[C]=w.x;S[C+1]=w.y;S[C+2]=w.z}if(F)for(t=0;t<P;t++){color=y[t];C=t*3;Z[C]=color.r;Z[C+1]=color.g;Z[C+2]=color.b}}if(u||B.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,S,A)}if(F||B.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,Z,A)}}function c(n,A){n.fragment_shader=A.fragment_shader;n.vertex_shader=A.vertex_shader;n.uniforms=Uniforms.clone(A.uniforms)}
  188. function e(n,A,B,t,w){t.program||aa.initMaterial(t,A,B);var C=t.program,E=C.uniforms,D=t.uniforms;if(C!=M){d.useProgram(C);M=C;d.uniformMatrix4fv(E.projectionMatrix,!1,fa);d.uniformMatrix4fv(E.cameraInverseMatrix,!1,I)}if(B&&(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial||t instanceof THREE.LineBasicMaterial||t instanceof THREE.ParticleBasicMaterial)){D.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){D.fogNear.value=
  189. B.near;D.fogFar.value=B.far}else if(B instanceof THREE.FogExp2)D.fogDensity.value=B.density}if(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial){var y,P,S=0,Z=0,la=0,u,F,N,V=aa.lights,X=V.directional.colors,ja=V.directional.positions,ga=V.point.colors,Ca=V.point.positions,R=0,Aa=0;B=P=P=0;for(y=A.length;B<y;B++){P=A[B];u=P.color;F=P.position;N=P.intensity;if(P instanceof THREE.AmbientLight){S+=u.r;Z+=u.g;la+=u.b}else if(P instanceof THREE.DirectionalLight){P=R*3;X[P]=u.r*
  190. N;X[P+1]=u.g*N;X[P+2]=u.b*N;ja[P]=F.x;ja[P+1]=F.y;ja[P+2]=F.z;R+=1}else if(P instanceof THREE.PointLight){P=Aa*3;ga[P]=u.r*N;ga[P+1]=u.g*N;ga[P+2]=u.b*N;Ca[P]=F.x;Ca[P+1]=F.y;Ca[P+2]=F.z;Aa+=1}}for(B=R*3;B<X.length;B++)X[B]=0;for(B=Aa*3;B<ga.length;B++)ga[B]=0;V.point.length=Aa;V.directional.length=R;V.ambient[0]=S;V.ambient[1]=Z;V.ambient[2]=la;A=aa.lights;D.enableLighting.value=A.directional.length+A.point.length;D.ambientLightColor.value=A.ambient;D.directionalLightColor.value=A.directional.colors;
  191. D.directionalLightDirection.value=A.directional.positions;D.pointLightColor.value=A.point.colors;D.pointLightPosition.value=A.point.positions}if(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial){D.diffuse.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);D.opacity.value=t.opacity;D.map.texture=t.map;D.light_map.texture=t.light_map;D.env_map.texture=t.env_map;D.reflectivity.value=t.reflectivity;D.refraction_ratio.value=
  192. t.refraction_ratio;D.combine.value=t.combine;D.useRefract.value=t.env_map&&t.env_map.mapping instanceof THREE.CubeRefractionMapping}if(t instanceof THREE.LineBasicMaterial){D.diffuse.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);D.opacity.value=t.opacity}else if(t instanceof THREE.ParticleBasicMaterial){D.psColor.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);D.opacity.value=t.opacity;D.size.value=t.size;D.map.texture=t.map}else if(t instanceof
  193. THREE.MeshPhongMaterial){D.ambient.value.setRGB(t.ambient.r,t.ambient.g,t.ambient.b);D.specular.value.setRGB(t.specular.r,t.specular.g,t.specular.b);D.shininess.value=t.shininess}else if(t instanceof THREE.MeshDepthMaterial){D.mNear.value=n.near;D.mFar.value=n.far;D.opacity.value=t.opacity}else if(t instanceof THREE.MeshNormalMaterial)D.opacity.value=t.opacity;for(var oa in D)if(S=C.uniforms[oa]){B=D[oa];y=B.type;A=B.value;if(y=="i")d.uniform1i(S,A);else if(y=="f")d.uniform1f(S,A);else if(y=="fv1")d.uniform1fv(S,
  194. A);else if(y=="fv")d.uniform3fv(S,A);else if(y=="v2")d.uniform2f(S,A.x,A.y);else if(y=="v3")d.uniform3f(S,A.x,A.y,A.z);else if(y=="c")d.uniform3f(S,A.r,A.g,A.b);else if(y=="t"){d.uniform1i(S,A);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){if(B.image.length==6){if(B.needsUpdate){if(!B.image.__webGLTextureCube)B.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);
  195. 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(y=0;y<6;++y)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,B.image[y]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);B.needsUpdate=!1}d.activeTexture(d.TEXTURE0+A);d.bindTexture(d.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{if(B.needsUpdate){if(B.__wasSetOnce){d.bindTexture(d.TEXTURE_2D,
  196. B.__webGLTexture);d.texSubImage2D(d.TEXTURE_2D,0,0,0,d.RGBA,d.UNSIGNED_BYTE,B.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,q(B.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,q(B.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,q(B.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,q(B.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}else{B.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,B.__webGLTexture);d.texImage2D(d.TEXTURE_2D,
  197. 0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,B.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,q(B.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,q(B.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,q(B.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,q(B.min_filter));d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null);B.__wasSetOnce=!0}B.needsUpdate=!1}d.activeTexture(d.TEXTURE0+A);d.bindTexture(d.TEXTURE_2D,B.__webGLTexture)}}}d.uniformMatrix4fv(E.modelViewMatrix,
  198. !1,w._modelViewMatrixArray);d.uniformMatrix3fv(E.normalMatrix,!1,w._normalMatrixArray);(t instanceof THREE.MeshShaderMaterial||t instanceof THREE.MeshPhongMaterial||t.env_map)&&d.uniform3f(E.cameraPosition,n.position.x,n.position.y,n.position.z);(t instanceof THREE.MeshShaderMaterial||t.env_map||t.skinning)&&d.uniformMatrix4fv(E.objectMatrix,!1,w._objectMatrixArray);(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshShaderMaterial||t.skinning)&&d.uniformMatrix4fv(E.viewMatrix,
  199. !1,I);if(t.skinning){d.uniformMatrix4fv(E.cameraInverseMatrix,!1,I);d.uniformMatrix4fv(E.boneGlobalMatrices,!1,w.boneMatrices)}return C}function f(n,A,B,t,w,C){n=e(n,A,B,t,C).attributes;d.bindBuffer(d.ARRAY_BUFFER,w.__webGLVertexBuffer);d.vertexAttribPointer(n.position,3,d.FLOAT,!1,0,0);if(n.color>=0){d.bindBuffer(d.ARRAY_BUFFER,w.__webGLColorBuffer);d.vertexAttribPointer(n.color,3,d.FLOAT,!1,0,0)}if(n.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,w.__webGLNormalBuffer);d.vertexAttribPointer(n.normal,3,
  200. d.FLOAT,!1,0,0)}if(n.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,w.__webGLTangentBuffer);d.vertexAttribPointer(n.tangent,4,d.FLOAT,!1,0,0)}if(n.uv>=0)if(w.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,w.__webGLUVBuffer);d.vertexAttribPointer(n.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(n.uv)}else d.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(w.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,w.__webGLUV2Buffer);d.vertexAttribPointer(n.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(n.uv2)}else d.disableVertexAttribArray(n.uv2);
  201. if(t.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,w.__webGLSkinVertexABuffer);d.vertexAttribPointer(n.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,w.__webGLSkinVertexBBuffer);d.vertexAttribPointer(n.skinVertexB,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,w.__webGLSkinIndicesBuffer);d.vertexAttribPointer(n.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,w.__webGLSkinWeightsBuffer);d.vertexAttribPointer(n.skinWeight,
  202. 4,d.FLOAT,!1,0,0)}if(C instanceof THREE.Mesh)if(t.wireframe){d.lineWidth(t.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);d.drawElements(d.LINES,w.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,w.__webGLFaceCount,d.UNSIGNED_SHORT,0)}else if(C instanceof THREE.Line){C=C.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(t.linewidth);d.drawArrays(C,0,w.__webGLLineCount)}else if(C instanceof
  203. THREE.ParticleSystem)d.drawArrays(d.POINTS,0,w.__webGLParticleCount);else C instanceof THREE.Ribbon&&d.drawArrays(d.TRIANGLE_STRIP,0,w.__webGLVertexCount)}function g(n,A){if(!n.__webGLVertexBuffer)n.__webGLVertexBuffer=d.createBuffer();if(!n.__webGLNormalBuffer)n.__webGLNormalBuffer=d.createBuffer();if(n.hasPos){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,n.positionArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(A.attributes.position);d.vertexAttribPointer(A.attributes.position,
  204. 3,d.FLOAT,!1,0,0)}if(n.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,n.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(A.attributes.normal);d.vertexAttribPointer(A.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,n.count);n.count=0}function h(n){if(K!=n.doubleSided){n.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);K=n.doubleSided}if(L!=n.flipSided){n.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);L=n.flipSided}}function k(n){if(T!=
  205. n){n?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);T=n}}function j(n,A){n.list[n.count]=A;n.count+=1}function l(n){var A,B,t=n.object,w=n.opaque,C=n.transparent;C.count=0;n=w.count=0;for(A=t.materials.length;n<A;n++){B=t.materials[n];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?j(C,B):j(w,B)}}function m(n){var A,B,t,w,C=n.object,E=n.buffer,D=n.opaque,y=n.transparent;y.count=0;n=D.count=0;for(t=C.materials.length;n<t;n++){A=C.materials[n];if(A instanceof THREE.MeshFaceMaterial){A=0;for(B=
  206. E.materials.length;A<B;A++)(w=E.materials[A])&&(w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?j(y,w):j(D,w))}else{w=A;w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?j(y,w):j(D,w)}}}function v(n,A){return A.z-n.z}function p(n,A,B,t,w){if(A[B]==undefined){n.push({buffer:t,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}});A[B]=1}}function o(n){n.matrixWorld.flattenToArray(n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n.matrixWorld).transposeIntoArray(n._normalMatrixArray)}
  207. function x(n){if(n!=W){switch(n){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;case THREE.ReverseSubtractiveBlending:d.blendEquation(d.FUNC_REVERSE_SUBTRACT);d.blendFunc(d.ONE,d.ONE);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}W=n}}function z(n,
  208. A){if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=d.createFramebuffer();n.__webGLRenderbuffer=d.createRenderbuffer();n.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,n.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,n.width,n.height);d.bindTexture(d.TEXTURE_2D,n.__webGLTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,q(n.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,q(n.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,q(n.mag_filter));
  209. d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,q(n.min_filter));d.texImage2D(d.TEXTURE_2D,0,q(n.format),n.width,n.height,0,q(n.format),q(n.type),null);d.bindFramebuffer(d.FRAMEBUFFER,n.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,n.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,n.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var B,
  210. t,w;if(n){B=n.__webGLFramebuffer;t=n.width;w=n.height}else{B=null;t=G.width;w=G.height}if(B!=Q){d.bindFramebuffer(d.FRAMEBUFFER,B);d.viewport(0,0,t,w);A&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);Q=B}}function H(n,A){var B;if(n=="fragment")B=d.createShader(d.FRAGMENT_SHADER);else n=="vertex"&&(B=d.createShader(d.VERTEX_SHADER));d.shaderSource(B,A);d.compileShader(B);if(!d.getShaderParameter(B,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(B));return null}return B}function q(n){switch(n){case THREE.RepeatWrapping:return d.REPEAT;
  211. case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;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;
  212. case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;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 G=document.createElement("canvas"),
  213. d,M=null,Q=null,aa=this,K=null,L=null,W=null,T=null,Y=new THREE.Matrix4,fa=new Float32Array(16),I=new Float32Array(16),ea=new THREE.Vector4,ra=!0,ba=new THREE.Color(0),na=0;if(a){if(a.antialias!==undefined)ra=a.antialias;a.clearColor!==undefined&&ba.setHex(a.clearColor);if(a.clearAlpha!==undefined)na=a.clearAlpha}this.domElement=G;this.autoClear=!0;this.sortObjects=!1;(function(n,A,B){try{d=G.getContext("experimental-webgl",{antialias:n})}catch(t){console.log(t)}if(!d)throw"cannot create webgl context";
  214. 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.clearColor(A.r,A.g,A.b,B);_cullEnabled=!0})(ra,ba,na);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(n,A){G.width=n;G.height=A;d.viewport(0,0,G.width,G.height)};this.setClearColorHex=function(n,A){var B=new THREE.Color(n);d.clearColor(B.r,B.g,B.b,A)};
  215. this.setClearColor=function(n,A){d.clearColor(n.r,n.g,n.b,A)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.initMaterial=function(n,A,B){var t,w;if(n instanceof THREE.MeshDepthMaterial)c(n,THREE.ShaderLib.depth);else if(n instanceof THREE.MeshNormalMaterial)c(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial)c(n,THREE.ShaderLib.basic);else if(n instanceof THREE.MeshLambertMaterial)c(n,THREE.ShaderLib.lambert);else if(n instanceof THREE.MeshPhongMaterial)c(n,
  216. THREE.ShaderLib.phong);else if(n instanceof THREE.LineBasicMaterial)c(n,THREE.ShaderLib.basic);else n instanceof THREE.ParticleBasicMaterial&&c(n,THREE.ShaderLib.particle_basic);var C,E,D,y;w=D=y=0;for(C=A.length;w<C;w++){E=A[w];E instanceof THREE.DirectionalLight&&D++;E instanceof THREE.PointLight&&y++}if(y+D<=4)A=D;else{A=Math.ceil(4*D/(y+D));y=4-A}w={directional:A,point:y};y=n.fragment_shader;A=n.vertex_shader;C={fog:B,map:n.map,env_map:n.env_map,light_map:n.light_map,vertex_colors:n.vertex_colors,
  217. skinning:n.skinning,maxDirLights:w.directional,maxPointLights:w.point};B=d.createProgram();w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.fog?"#define USE_FOG":"",C.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",C.map?"#define USE_MAP":"",C.env_map?"#define USE_ENVMAP":"",C.light_map?"#define USE_LIGHTMAP":"",C.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
  218. C=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.map?"#define USE_MAP":"",C.env_map?"#define USE_ENVMAP":"",C.light_map?"#define USE_LIGHTMAP":"",C.vertex_colors?"#define USE_COLOR":"",C.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");
  219. d.attachShader(B,H("fragment",w+y));d.attachShader(B,H("vertex",C+A));d.linkProgram(B);d.getProgramParameter(B,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(B,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");B.uniforms={};B.attributes={};n.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(t in n.uniforms)B.push(t);t=n.program;y=0;for(A=B.length;y<
  220. A;y++){w=B[y];t.uniforms[w]=d.getUniformLocation(t,w)}t=n.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];y=0;for(A=B.length;y<A;y++){w=B[y];t.attributes[w]=d.getAttribLocation(t,w)}t=n.program.attributes;d.enableVertexAttribArray(t.position);t.color>=0&&d.enableVertexAttribArray(t.color);t.normal>=0&&d.enableVertexAttribArray(t.normal);t.tangent>=0&&d.enableVertexAttribArray(t.tangent);if(n.skinning&&t.skinVertexA>=0&&t.skinVertexB>=
  221. 0&&t.skinIndex>=0&&t.skinWeight>=0){d.enableVertexAttribArray(t.skinVertexA);d.enableVertexAttribArray(t.skinVertexB);d.enableVertexAttribArray(t.skinIndex);d.enableVertexAttribArray(t.skinWeight)}};this.render=function(n,A,B,t){var w,C,E,D,y,P,S,Z,la=n.lights,u=n.fog;M=null;A.matrixAutoUpdate&&A.update();A.matrixWorldInverse.flattenToArray(I);A.projectionMatrix.flattenToArray(fa);Y.multiply(A.projectionMatrix,A.matrixWorldInverse);THREE.AnimationHandler&&THREE.AnimationHandler.update();n.update(undefined,
  222. !1,A);this.initWebGLObjects(n,A);z(B,t!==undefined?t:!0);this.autoClear&&this.clear();y=n.__webGLObjects.length;for(t=0;t<y;t++){w=n.__webGLObjects[t];S=w.object;if(S.visible)if(!(S instanceof THREE.Mesh)||A.frustumContains(S)){S.matrixWorld.flattenToArray(S._objectMatrixArray);o(S,A);m(w);w.render=!0;if(this.sortObjects)w.z=S.positionScreen.z}else w.render=!1;else w.render=!1}this.sortObjects&&n.__webGLObjects.sort(v);P=n.__webGLObjectsImmediate.length;for(t=0;t<P;t++){w=n.__webGLObjectsImmediate[t];
  223. S=w.object;if(S.visible){S.matrixAutoUpdate&&S.matrixWorld.flattenToArray(S._objectMatrixArray);o(S,A);l(w)}}x(THREE.NormalBlending);for(t=0;t<y;t++){w=n.__webGLObjects[t];if(w.render){S=w.object;Z=w.buffer;E=w.opaque;h(S);for(w=0;w<E.count;w++){D=E.list[w];k(D.depth_test);f(A,la,u,D,Z,S)}}}for(t=0;t<P;t++){w=n.__webGLObjectsImmediate[t];S=w.object;if(S.visible){E=w.opaque;h(S);for(w=0;w<E.count;w++){D=E.list[w];k(D.depth_test);C=e(A,la,u,D,S);S.render(function(F){g(F,C)})}}}for(t=0;t<y;t++){w=n.__webGLObjects[t];
  224. if(w.render){S=w.object;Z=w.buffer;E=w.transparent;h(S);for(w=0;w<E.count;w++){D=E.list[w];x(D.blending);k(D.depth_test);f(A,la,u,D,Z,S)}}}for(t=0;t<P;t++){w=n.__webGLObjectsImmediate[t];S=w.object;if(S.visible){E=w.transparent;h(S);for(w=0;w<E.count;w++){D=E.list[w];x(D.blending);k(D.depth_test);C=e(A,la,u,D,S);S.render(function(F){g(F,C)})}}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,B.__webGLTexture);d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,
  225. null)}};this.initWebGLObjects=function(n,A){var B,t,w;if(!n.__webGLObjects){n.__webGLObjects=[];n.__webGLObjectsMap={};n.__webGLObjectsImmediate=[]}B=0;for(t=n.objects.length;B<t;B++){w=n.objects[B];var C=n,E=A,D=void 0,y=void 0,P=void 0,S=void 0;y=w.geometry;if(C.__webGLObjectsMap[w.id]==undefined){C.__webGLObjectsMap[w.id]={};w._modelViewMatrix=new THREE.Matrix4;w._normalMatrixArray=new Float32Array(9);w._modelViewMatrixArray=new Float32Array(16);w._objectMatrixArray=new Float32Array(16);w.matrixWorld.flattenToArray(w._objectMatrixArray)}S=
  226. C.__webGLObjectsMap[w.id];objlist=C.__webGLObjects;if(w instanceof THREE.Mesh){for(D in y.geometryChunks){P=y.geometryChunks[D];if(!P.__webGLVertexBuffer){E=P;E.__webGLVertexBuffer=d.createBuffer();E.__webGLNormalBuffer=d.createBuffer();E.__webGLTangentBuffer=d.createBuffer();E.__webGLColorBuffer=d.createBuffer();E.__webGLUVBuffer=d.createBuffer();E.__webGLUV2Buffer=d.createBuffer();E.__webGLSkinVertexABuffer=d.createBuffer();E.__webGLSkinVertexBBuffer=d.createBuffer();E.__webGLSkinIndicesBuffer=
  227. d.createBuffer();E.__webGLSkinWeightsBuffer=d.createBuffer();E.__webGLFaceBuffer=d.createBuffer();E.__webGLLineBuffer=d.createBuffer();E=P;var Z=w,la=void 0,u=void 0,F=0,N=C=0,V=Z.geometry.faces,X=E.faces;la=0;for(u=X.length;la<u;la++){fi=X[la];face=V[fi];if(face instanceof THREE.Face3){F+=3;C+=1;N+=3}else if(face instanceof THREE.Face4){F+=4;C+=2;N+=4}}E.__vertexArray=new Float32Array(F*3);E.__normalArray=new Float32Array(F*3);E.__tangentArray=new Float32Array(F*4);E.__colorArray=new Float32Array(F*
  228. 3);E.__uvArray=new Float32Array(F*2);E.__uv2Array=new Float32Array(F*2);E.__skinVertexAArray=new Float32Array(F*4);E.__skinVertexBArray=new Float32Array(F*4);E.__skinIndexArray=new Float32Array(F*4);E.__skinWeightArray=new Float32Array(F*4);E.__faceArray=new Uint16Array(C*3);E.__lineArray=new Uint16Array(N*2);u=la=E;F=void 0;V=void 0;var ja=void 0,ga=void 0;ja=void 0;X=!1;F=0;for(V=Z.materials.length;F<V;F++){ja=Z.materials[F];if(ja instanceof THREE.MeshFaceMaterial){ja=0;for(ga=u.materials.length;ja<
  229. ga;ja++)if(u.materials[ja]&&u.materials[ja].shading!=undefined&&u.materials[ja].shading==THREE.SmoothShading){X=!0;break}}else if(ja&&ja.shading!=undefined&&ja.shading==THREE.SmoothShading){X=!0;break}if(X)break}la.__needsSmoothNormals=X;E.__webGLFaceCount=C*3;E.__webGLLineCount=N*2;y.__dirtyVertices=!0;y.__dirtyElements=!0;y.__dirtyUvs=!0;y.__dirtyNormals=!0;y.__dirtyTangents=!0;y.__dirtyColors=!0}if(y.__dirtyVertices||y.__dirtyElements||y.__dirtyUvs||y.__dirtyNormals||y.__dirtyColors||y.__dirtyTangents){E=
  230. P;C=d.DYNAMIC_DRAW;N=void 0;la=void 0;var Ca=void 0,R=void 0,Aa=void 0,oa=void 0,Da=void 0;Ca=void 0;var ca=void 0,$=void 0,da=void 0,ta=void 0;ca=void 0;$=void 0;da=void 0;R=void 0;ca=void 0;$=void 0;da=void 0;ta=void 0;ca=void 0;$=void 0;da=void 0;ta=void 0;ca=void 0;$=void 0;da=void 0;ta=void 0;ca=void 0;$=void 0;da=void 0;ta=void 0;ca=void 0;$=void 0;da=void 0;ta=void 0;R=void 0;oa=void 0;Aa=void 0;Da=void 0;var Fa=ga=ja=X=V=F=Z=u=0,ya=0,J=0,xa=E.__vertexArray,Ra=E.__uvArray,Pa=E.__uv2Array,Ia=
  231. E.__normalArray,ua=E.__tangentArray,za=E.__colorArray,wa=E.__skinVertexAArray,ka=E.__skinVertexBArray,pa=E.__skinIndexArray,sa=E.__skinWeightArray,Ma=E.__faceArray,Ha=E.__lineArray,Sa=E.__needsSmoothNormals,O=w.geometry,ma=O.__dirtyVertices,ia=O.__dirtyElements,U=O.__dirtyUvs,ha=O.__dirtyNormals,qa=O.__dirtyTangents,Ba=O.__dirtyColors,va=O.vertices,Ea=E.faces,Na=O.faces,La=O.uvs,Oa=O.uvs2,Ka=O.colors,Ga=O.skinVerticesA,Ja=O.skinVerticesB,Ta=O.skinIndices,Qa=O.skinWeights;N=0;for(la=Ea.length;N<la;N++){Ca=
  232. Ea[N];R=Na[Ca];Da=La[Ca];Ca=Oa[Ca];Aa=R.vertexNormals;oa=R.normal;if(R instanceof THREE.Face3){if(ma){ca=va[R.a].position;$=va[R.b].position;da=va[R.c].position;xa[Z]=ca.x;xa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va[R.c].tangent;R=va[R.d].tangent;ua[ga]=ca.x;ua[ga+1]=ca.y;ua[ga+2]=ca.z;ua[ga+3]=
  239. ca.w;ua[ga+4]=$.x;ua[ga+5]=$.y;ua[ga+6]=$.z;ua[ga+7]=$.w;ua[ga+8]=da.x;ua[ga+9]=da.y;ua[ga+10]=da.z;ua[ga+11]=da.w;ua[ga+12]=R.x;ua[ga+13]=R.y;ua[ga+14]=R.z;ua[ga+15]=R.w;ga+=16}if(ha)if(Aa.length==4&&Sa)for(R=0;R<4;R++){oa=Aa[R];Ia[ja]=oa.x;Ia[ja+1]=oa.y;Ia[ja+2]=oa.z;ja+=3}else for(R=0;R<4;R++){Ia[ja]=oa.x;Ia[ja+1]=oa.y;Ia[ja+2]=oa.z;ja+=3}if(U&&Da)for(R=0;R<4;R++){Aa=Da[R];Ra[F]=Aa.u;Ra[F+1]=Aa.v;F+=2}if(U&&Ca)for(R=0;R<4;R++){Da=Ca[R];Pa[V]=Da.u;Pa[V+1]=Da.v;V+=2}if(ia){Ma[X]=u;Ma[X+1]=u+1;Ma[X+
  240. 2]=u+2;Ma[X+3]=u;Ma[X+4]=u+2;Ma[X+5]=u+3;X+=6;Ha[Fa]=u;Ha[Fa+1]=u+1;Ha[Fa+2]=u;Ha[Fa+3]=u+3;Ha[Fa+4]=u+1;Ha[Fa+5]=u+2;Ha[Fa+6]=u+2;Ha[Fa+7]=u+3;Fa+=8;u+=4}}}if(ma){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,xa,C)}if(Ba&&Ka.length){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,za,C)}if(ha){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ia,C)}if(qa&&O.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLTangentBuffer);
  241. d.bufferData(d.ARRAY_BUFFER,ua,C)}if(U&&F>0){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Ra,C)}if(U&&V>0){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Pa,C)}if(ia){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,E.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Ma,C);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Ha,C)}if(J>0){d.bindBuffer(d.ARRAY_BUFFER,E.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,
  242. wa,C);d.bindBuffer(d.ARRAY_BUFFER,E.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ka,C);d.bindBuffer(d.ARRAY_BUFFER,E.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,pa,C);d.bindBuffer(d.ARRAY_BUFFER,E.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,sa,C)}}p(objlist,S,D,P,w)}y.__dirtyVertices=!1;y.__dirtyElements=!1;y.__dirtyUvs=!1;y.__dirtyNormals=!1;y.__dirtyTangents=!1;y.__dirtyColors=!1}else if(w instanceof THREE.Ribbon){if(!y.__webGLVertexBuffer){D=y;D.__webGLVertexBuffer=
  243. d.createBuffer();D.__webGLColorBuffer=d.createBuffer();D=y;P=D.vertices.length;D.__vertexArray=new Float32Array(P*3);D.__colorArray=new Float32Array(P*3);D.__webGLVertexCount=P;y.__dirtyVertices=!0;y.__dirtyColors=!0}if(y.__dirtyVertices||y.__dirtyColors){D=y;P=d.DYNAMIC_DRAW;u=void 0;u=void 0;Z=void 0;E=void 0;F=D.vertices;C=D.colors;V=F.length;N=C.length;X=D.__vertexArray;la=D.__colorArray;ja=D.__dirtyColors;if(D.__dirtyVertices){for(u=0;u<V;u++){Z=F[u].position;E=u*3;X[E]=Z.x;X[E+1]=Z.y;X[E+2]=
  244. Z.z}d.bindBuffer(d.ARRAY_BUFFER,D.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,X,P)}if(ja){for(u=0;u<N;u++){color=C[u];E=u*3;la[E]=color.r;la[E+1]=color.g;la[E+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,D.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,la,P)}}p(objlist,S,0,y,w);y.__dirtyVertices=!1;y.__dirtyColors=!1}else if(w instanceof THREE.Line){if(!y.__webGLVertexBuffer){D=y;D.__webGLVertexBuffer=d.createBuffer();D.__webGLColorBuffer=d.createBuffer();D=y;P=D.vertices.length;D.__vertexArray=new Float32Array(P*
  245. 3);D.__colorArray=new Float32Array(P*3);D.__webGLLineCount=P;y.__dirtyVertices=!0;y.__dirtyColors=!0}if(y.__dirtyVertices||y.__dirtyColors){D=y;P=d.DYNAMIC_DRAW;u=void 0;u=void 0;Z=void 0;E=void 0;F=D.vertices;C=D.colors;V=F.length;N=C.length;X=D.__vertexArray;la=D.__colorArray;ja=D.__dirtyColors;if(D.__dirtyVertices){for(u=0;u<V;u++){Z=F[u].position;E=u*3;X[E]=Z.x;X[E+1]=Z.y;X[E+2]=Z.z}d.bindBuffer(d.ARRAY_BUFFER,D.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,X,P)}if(ja){for(u=0;u<N;u++){color=
  246. C[u];E=u*3;la[E]=color.r;la[E+1]=color.g;la[E+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,D.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,la,P)}}p(objlist,S,0,y,w);y.__dirtyVertices=!1;y.__dirtyColors=!1}else if(w instanceof THREE.ParticleSystem){if(!y.__webGLVertexBuffer){D=y;D.__webGLVertexBuffer=d.createBuffer();D.__webGLColorBuffer=d.createBuffer();D=y;P=D.vertices.length;D.__vertexArray=new Float32Array(P*3);D.__colorArray=new Float32Array(P*3);D.__sortArray=[];D.__webGLParticleCount=P;y.__dirtyVertices=
  247. !0;y.__dirtyColors=!0}(y.__dirtyVertices||y.__dirtyColors||w.sortParticles)&&b(y,d.DYNAMIC_DRAW,w,E);p(objlist,S,0,y,w);y.__dirtyVertices=!1;y.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&w instanceof THREE.MarchingCubes){y=S;if(y[0]==undefined){C.__webGLObjectsImmediate.push({object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}});y[0]=1}}}};this.removeObject=function(n,A){var B,t;for(B=n.__webGLObjects.length-1;B>=0;B--){t=n.__webGLObjects[B].object;A==t&&n.__webGLObjects.splice(B,
  248. 1)}};this.setFaceCulling=function(n,A){if(n){!A||A=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(n=="back")d.cullFace(d.BACK);else n=="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}};
  249. 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",
  250. 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",
  251. 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",
  252. 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",
  253. 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",
  254. 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}",
  255. 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;",
  256. 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 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * cameraInverseMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * cameraInverseMatrix * mvPosition;\n#endif"};
  257. 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",
  258. 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)}}};
  259. 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 * cameraInverseMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
  260. 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 * cameraInverseMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,
  261. 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,
  262. 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,
  263. 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,
  264. 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,
  265. 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,
  266. 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,
  267. 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;",
  268. 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;",
  269. THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * cameraInverseMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};
  270. THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var e,f=c.length;for(e=0;e<f;e++){a=c[e];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
  271. THREE.RenderableObject=function(){this.z=this.object=null};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]};
  272. THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
  273. var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,l=a.uvs;f=f.uvs;c&&b.matrixAutoUpdate&&b.updateMatrix();for(var m=0,v=h.length;m<v;m++){var p=new THREE.Vertex(h[m].position.clone());c&&b.matrix.multiplyVector3(p.position);g.push(p)}m=0;for(v=j.length;m<v;m++){h=j[m];var o,x=h.vertexNormals;if(h instanceof THREE.Face3)o=new THREE.Face3(h.a+e,h.b+e,h.c+e);else h instanceof THREE.Face4&&(o=new THREE.Face4(h.a+
  274. e,h.b+e,h.c+e,h.d+e));o.centroid.copy(h.centroid);o.normal.copy(h.normal);c=0;for(g=x.length;c<g;c++){p=x[c];o.vertexNormals.push(p.clone())}o.materials=h.materials.slice();k.push(o)}m=0;for(v=f.length;m<v;m++){e=f[m];k=[];c=0;for(g=e.length;c<g;c++)k.push(new THREE.UV(e[c].u,e[c].v));l.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var e=new Image,f=new THREE.Texture(e,b);e.onload=function(){f.needsUpdate=!0;c&&c(this)};e.src=a;return f},loadTextureCube:function(a,b,c){var e,f=[],g=new THREE.Texture(f,
  275. b);b=f.loadCount=0;for(e=a.length;b<e;++b){f[b]=new Image;f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;c&&c(this)};f[b].src=a[b]}return g}},SceneUtils={loadScene:function(a,b,c,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(m in K.objects)if(!I.objects[m]){z=K.objects[m];if(d=I.geometries[z.geometry]){aa=[];for(i=0;i<z.materials.length;i++)aa[i]=I.materials[z.materials[i]];H=z.position;r=z.rotation;s=z.scale;object=new THREE.Mesh(d,aa);object.position.set(H[0],
  276. H[1],H[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;I.scene.addObject(object);I.objects[m]=object}}}function h(ea){return function(ra){I.geometries[ea]=ra;g();W-=1;k()}}function k(){e({total_models:Y,total_textures:fa,loaded_models:Y-W,loaded_textures:fa-T},I);W==0&&T==0&&c(I)}var j,l,m,v,p,o,x,z,H,q,G,d,M,Q,aa,K,L,W,T,Y,fa,I;K=f.data;L=new THREE.Loader;T=W=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},
  277. lights:{},fogs:{}};f=function(){T-=1;k()};for(p in K.cameras){q=K.cameras[p];if(q.type=="perspective")M=new THREE.Camera(q.fov,q.aspect,q.near,q.far);else if(q.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(q.left,q.right,q.top,q.bottom,q.near,q.far)}H=q.position;q=q.target;M.position.set(H[0],H[1],H[2]);M.target.position.set(q[0],q[1],q[2]);I.cameras[p]=M}for(v in K.lights){p=K.lights[v];if(p.type=="directional"){H=p.direction;light=new THREE.DirectionalLight;light.position.set(H[0],
  278. H[1],H[2]);light.position.normalize()}else if(p.type=="point"){H=p.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}q=p.color;i=p.intensity||1;light.color.setRGB(q[0]*i,q[1]*i,q[2]*i);I.scene.addLight(light);I.lights[v]=light}for(o in K.fogs){v=K.fogs[o];if(v.type=="linear")Q=new THREE.Fog(0,v.near,v.far);else v.type=="exp2"&&(Q=new THREE.FogExp2(0,v.density));q=v.color;Q.color.setRGB(q[0],q[1],q[2]);I.fogs[o]=Q}if(I.cameras&&K.defaults.camera)I.currentCamera=I.cameras[K.defaults.camera];
  279. if(I.fogs&&K.defaults.fog)I.scene.fog=I.fogs[K.defaults.fog];q=K.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(q[0],q[1],q[2]);I.bgColorAlpha=K.defaults.bgalpha;for(j in K.geometries){o=K.geometries[j];if(o.type=="bin_mesh"||o.type=="ascii_mesh")W+=1}Y=W;for(j in K.geometries){o=K.geometries[j];if(o.type=="cube"){d=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);I.geometries[j]=d}else if(o.type=="plane"){d=new Plane(o.width,o.height,o.segments_width,
  280. o.segments_height);I.geometries[j]=d}else if(o.type=="sphere"){d=new Sphere(o.radius,o.segments_width,o.segments_height);I.geometries[j]=d}else if(o.type=="cylinder"){d=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);I.geometries[j]=d}else if(o.type=="torus"){d=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);I.geometries[j]=d}else if(o.type=="icosahedron"){d=new Icosahedron(o.subdivisions);I.geometries[j]=d}else if(o.type=="bin_mesh")L.loadBinary({model:o.url,callback:h(j)});
  281. else o.type=="ascii_mesh"&&L.loadAscii({model:o.url,callback:h(j)})}for(x in K.textures){j=K.textures[x];T+=j.url instanceof Array?j.url.length:1}fa=T;for(x in K.textures){j=K.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)o=ImageUtils.loadTextureCube(j.url,j.mapping,f);else{o=ImageUtils.loadTexture(j.url,j.mapping,f);if(THREE[j.min_filter]!=undefined)o.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=undefined)o.mag_filter=
  282. THREE[j.mag_filter]}I.textures[x]=o}for(l in K.materials){x=K.materials[l];for(G in x.parameters)if(G=="env_map"||G=="map"||G=="light_map")x.parameters[G]=I.textures[x.parameters[G]];else if(G=="shading")x.parameters[G]=x.parameters[G]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(G=="blending")x.parameters[G]=THREE[x.parameters[G]]?THREE[x.parameters[G]]:THREE.NormalBlending;else G=="combine"&&(x.parameters[G]=x.parameters[G]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=
  283. new THREE[x.type](x.parameters);I.materials[l]=x}g();b(I)}},addMesh:function(a,b,c,e,f,g,h,k,j,l){b=new THREE.Mesh(b,l);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});b=new THREE.Mesh(new Cube(b,
  284. b,b,1,1,null,!0),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
  285. b,b,1,1,e,!0),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2;b=new Plane(b,b);var f=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
  286. SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
  287. vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
  288. normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
  289. uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
  290. vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
  291. cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
  292. value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
  293. film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
  294. screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
  295. fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,e,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=e=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));e+=c[b]}for(b=0;b<g;++b)c[b]/=e;return c}},Cube=function(a,b,c,e,f,g,h,k){function j(z,H,q,G,d,M,Q,aa){var K,L,W=e||1,T=f||1,Y=W+1,fa=T+1,I=d/2,ea=M/2;d/=W;var ra=M/T,ba=l.vertices.length;if(z=="x"&&H=="y"||z=="y"&&H=="x")K="z";else if(z=="x"&&H=="z"||z=="z"&&H=="x")K="y";
  296. else if(z=="z"&&H=="y"||z=="y"&&H=="z")K="x";for(L=0;L<fa;L++)for(M=0;M<Y;M++){var na=new THREE.Vector3;na[z]=(M*d-I)*q;na[H]=(L*ra-ea)*G;na[K]=Q;l.vertices.push(new THREE.Vertex(na))}for(L=0;L<T;L++)for(M=0;M<W;M++){l.faces.push(new THREE.Face4(M+Y*L+ba,M+Y*(L+1)+ba,M+1+Y*(L+1)+ba,M+1+Y*L+ba,null,aa));l.uvs.push([new THREE.UV(M/W,L/T),new THREE.UV(M/W,(L+1)/T),new THREE.UV((M+1)/W,(L+1)/T),new THREE.UV((M+1)/W,L/T)])}}THREE.Geometry.call(this);var l=this,m=a/2,v=b/2,p=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
  297. Array)this.materials=g;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var x in k)this.sides[x]!=undefined&&(this.sides[x]=k[x]);this.sides.px&&j("z","y",1*h,-1,c,b,-m,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,m,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,v,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-v,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,
  298. a,b,p,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-p,this.materials[5]);(function(){for(var z=[],H=[],q=0,G=l.vertices.length;q<G;q++){for(var d=l.vertices[q],M=!1,Q=0,aa=z.length;Q<aa;Q++){var K=z[Q];if(d.position.x==K.position.x&&d.position.y==K.position.y&&d.position.z==K.position.z){H[q]=Q;M=!0;break}}if(!M){H[q]=z.length;z.push(new THREE.Vertex(d.position.clone()))}}q=0;for(G=l.faces.length;q<G;q++){d=l.faces[q];d.a=H[d.a];d.b=H[d.b];d.c=H[d.c];d.d=H[d.d]}l.vertices=z})();this.computeCentroids();
  299. this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  300. var Cylinder=function(a,b,c,e,f){function g(l,m,v){h.vertices.push(new THREE.Vertex(new THREE.Vector3(l,m,v)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){g(0,0,-f);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){g(0,0,e+f);for(j=a+a/2;j<
  301. 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  302. var Plane=function(a,b,c,e){THREE.Geometry.call(this);var f,g=a/2,h=b/2;c=c||1;e=e||1;var k=c+1,j=e+1;a/=c;var l=b/e;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*l-h),0)));for(f=0;f<e;f++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f));this.uvs.push([new THREE.UV(b/c,f/e),new THREE.UV(b/c,(f+1)/e),new THREE.UV((b+1)/c,(f+1)/e),new THREE.UV((b+1)/c,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
  303. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  304. var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*f),j=a*Math.sin(e*f),l=[],m=0;for(e=0;e<g;e++){var v=2*e/g,p=j*Math.sin(v*f);v=j*Math.cos(v*f);(c==0||c==h)&&e>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,p)))-1);l.push(m)}b.push(l)}var o,x,z;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(e=0;e<g;e++){l=e==g-1;h=b[c][l?0:e+1];k=b[c][l?g-1:e];j=b[c-1][l?g-1:e];l=b[c-1][l?
  305. 0:e+1];p=c/(f-1);o=(c-1)/(f-1);x=(e+1)/g;v=e/g;m=new THREE.UV(1-x,p);p=new THREE.UV(1-v,p);v=new THREE.UV(1-v,o);var H=new THREE.UV(1-x,o);if(c<b.length-1){o=this.vertices[h].position.clone();x=this.vertices[k].position.clone();z=this.vertices[j].position.clone();o.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([m,p,v])}if(c>1){o=this.vertices[h].position.clone();
  306. x=this.vertices[j].position.clone();z=this.vertices[l].position.clone();o.normalize();x.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([m,v,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  307. var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
  308. 1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,f,g,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
  309. var Icosahedron=function(a){function b(v,p,o){var x=Math.sqrt(v*v+p*p+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(v/x,p/x,o/x)))-1}function c(v,p,o,x){x.faces.push(new THREE.Face3(v,p,o))}function e(v,p){var o=f.vertices[v].position,x=f.vertices[p].position;return b((o.x+x.x)/2,(o.y+x.y)/2,(o.z+x.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
  310. 1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=e(g.faces[k].a,g.faces[k].b),l=e(g.faces[k].b,g.faces[k].c),m=e(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,m,h);c(g.faces[k].b,l,j,h);c(g.faces[k].c,
  311. m,l,h);c(j,l,m,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
  312. function LathedObject(a,b,c){THREE.Geometry.call(this);c=c||2*Math.PI;b=c/(b||12);for(var e=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;e[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),l=0;l<=c+0.0010;l+=b){for(k=0;k<e.length;k++)if(l<c){e[k]=j.multiplyVector3(e[k].clone());this.vertices.push(new THREE.Vertex(e[k]));g[k]=this.vertices.length-1}else g=h;l==0&&(h=f);for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],
  313. g[k+1],f[k+1],f[k]));this.uvs.push([new THREE.UV(l/c,k/a.length),new THREE.UV(l/c,(k+1)/a.length),new THREE.UV((l-b)/c,(k+1)/a.length),new THREE.UV((l-b)/c,k/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  314. THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
  315. 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,e,f){return c+(e-c)*f};this.VIntX=function(c,e,f,g,h,k,j,l,m,v){h=(h-m)/(v-m);m=this.normal_cache;e[g]=k+h*this.delta;e[g+1]=j;e[g+2]=l;f[g]=this.lerp(m[c],m[c+3],h);f[g+1]=this.lerp(m[c+1],m[c+4],h);f[g+2]=this.lerp(m[c+2],m[c+5],h)};this.VIntY=function(c,e,f,g,h,k,j,l,m,v){h=(h-m)/(v-m);m=this.normal_cache;e[g]=k;e[g+1]=j+h*this.delta;e[g+
  316. 2]=l;e=c+this.yd*3;f[g]=this.lerp(m[c],m[e],h);f[g+1]=this.lerp(m[c+1],m[e+1],h);f[g+2]=this.lerp(m[c+2],m[e+2],h)};this.VIntZ=function(c,e,f,g,h,k,j,l,m,v){h=(h-m)/(v-m);m=this.normal_cache;e[g]=k;e[g+1]=j;e[g+2]=l+h*this.delta;e=c+this.zd*3;f[g]=this.lerp(m[c],m[e],h);f[g+1]=this.lerp(m[c+1],m[e+1],h);f[g+2]=this.lerp(m[c+2],m[e+2],h)};this.compNorm=function(c){var e=c*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[c-1]-this.field[c+1];this.normal_cache[e+1]=this.field[c-this.yd]-
  317. this.field[c+this.yd];this.normal_cache[e+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,e,f,g,h,k){var j=g+1,l=g+this.yd,m=g+this.zd,v=j+this.yd,p=j+this.zd,o=g+this.yd+this.zd,x=j+this.yd+this.zd,z=0,H=this.field[g],q=this.field[j],G=this.field[l],d=this.field[v],M=this.field[m],Q=this.field[p],aa=this.field[o],K=this.field[x];H<h&&(z|=1);q<h&&(z|=2);G<h&&(z|=8);d<h&&(z|=4);M<h&&(z|=16);Q<h&&(z|=32);aa<h&&(z|=128);K<h&&(z|=64);var L=THREE.edgeTable[z];if(L==0)return 0;
  318. var W=this.delta,T=c+W,Y=e+W;W=f+W;if(L&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,e,f,H,q)}if(L&2){this.compNorm(j);this.compNorm(v);this.VIntY(j*3,this.vlist,this.nlist,3,h,T,e,f,q,d)}if(L&4){this.compNorm(l);this.compNorm(v);this.VIntX(l*3,this.vlist,this.nlist,6,h,c,Y,f,G,d)}if(L&8){this.compNorm(g);this.compNorm(l);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,e,f,H,G)}if(L&16){this.compNorm(m);this.compNorm(p);this.VIntX(m*3,this.vlist,this.nlist,12,h,c,e,W,
  319. M,Q)}if(L&32){this.compNorm(p);this.compNorm(x);this.VIntY(p*3,this.vlist,this.nlist,15,h,T,e,W,Q,K)}if(L&64){this.compNorm(o);this.compNorm(x);this.VIntX(o*3,this.vlist,this.nlist,18,h,c,Y,W,aa,K)}if(L&128){this.compNorm(m);this.compNorm(o);this.VIntY(m*3,this.vlist,this.nlist,21,h,c,e,W,M,aa)}if(L&256){this.compNorm(g);this.compNorm(m);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,e,f,H,M)}if(L&512){this.compNorm(j);this.compNorm(p);this.VIntZ(j*3,this.vlist,this.nlist,27,h,T,e,f,q,Q)}if(L&1024){this.compNorm(v);
  320. this.compNorm(x);this.VIntZ(v*3,this.vlist,this.nlist,30,h,T,Y,f,d,K)}if(L&2048){this.compNorm(l);this.compNorm(o);this.VIntZ(l*3,this.vlist,this.nlist,33,h,c,Y,f,G,aa)}z<<=4;for(h=g=0;THREE.triTable[z+h]!=-1;){c=z+h;e=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[e],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,e,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
  321. 3]=c[g];this.positionArray[j+4]=c[g+1];this.positionArray[j+5]=c[g+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=e[f];this.normalArray[j+1]=e[f+1];this.normalArray[j+2]=e[f+2];this.normalArray[j+3]=e[g];this.normalArray[j+4]=e[g+1];this.normalArray[j+5]=e[g+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
  322. function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;c(this)}};this.addBall=function(c,e,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,l=e*this.size,m=c*this.size,v=Math.floor(j-k);v<1&&(v=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var p=Math.floor(l-k);p<1&&(p=1);l=Math.floor(l+k);l>this.size-1&&(l=this.size-1);var o=Math.floor(m-k);o<1&&(o=1);k=Math.floor(m+k);
  323. k>this.size-1&&(k=this.size-1);for(var x,z,H,q,G,d;v<j;v++){m=this.size2*v;z=v/this.size-f;G=z*z;for(z=p;z<l;z++){H=m+this.size*z;x=z/this.size-e;d=x*x;for(x=o;x<k;x++){q=x/this.size-c;q=g/(1.0E-6+q*q+d+G)-h;q>0&&(this.field[H+x]+=q)}}}};this.addPlaneX=function(c,e){var f,g,h,k,j,l=this.size,m=this.yd,v=this.zd,p=this.field,o=l*Math.sqrt(c/e);o>l&&(o=l);for(f=0;f<o;f++){g=f/l;g*=g;k=c/(1.0E-4+g)-e;if(k>0)for(g=0;g<l;g++){j=f+g*m;for(h=0;h<l;h++)p[v*h+j]+=k}}};this.addPlaneY=function(c,e){var f,g,
  324. h,k,j,l,m=this.size,v=this.yd,p=this.zd,o=this.field,x=m*Math.sqrt(c/e);x>m&&(x=m);for(g=0;g<x;g++){f=g/m;f*=f;k=c/(1.0E-4+f)-e;if(k>0){j=g*v;for(f=0;f<m;f++){l=j+f;for(h=0;h<m;h++)o[p*h+l]+=k}}}};this.addPlaneZ=function(c,e){var f,g,h,k,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/e);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-e;if(k>0){j=zd*h;for(g=0;g<size;g++){l=j+g*yd;for(f=0;f<size;f++)field[l+f]+=k}}}};this.reset=function(){var c;
  325. for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var e,f,g,h,k,j,l,m,v,p=this.size-2;for(h=1;h<p;h++){v=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(g=1;g<p;g++){m=v+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++){k=(f-this.halfsize)/this.halfsize;e=m+f;this.polygonize(k,j,l,e,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,e=new THREE.Geometry;this.render(function(f){var g,h,k,j,l,m,v,p;for(g=
  326. 0;g<f.count;g++){l=g*3;v=l+1;p=l+2;h=f.positionArray[l];k=f.positionArray[v];j=f.positionArray[p];m=new THREE.Vector3(h,k,j);h=f.normalArray[l];k=f.normalArray[v];j=f.normalArray[p];l=new THREE.Vector3(h,k,j);l.normalize();l=new THREE.Vertex(m,l);e.vertices.push(l)}nfaces=f.count/3;for(g=0;g<nfaces;g++){l=(c+g)*3;v=l+1;p=l+2;m=e.vertices[l].normal;h=e.vertices[v].normal;k=e.vertices[p].normal;l=new THREE.Face3(l,v,p,[m,h,k]);e.faces.push(l)}c+=nfaces;f.count=0});e.sortFacesByMaterial();return e};
  327. this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  328. THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
  329. 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
  330. 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
  331. THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-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-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
  351. 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
  352. THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
  353. b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,c,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:
  354. THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,f,e,g)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,f,g){var h=new XMLHttpRequest,k=e+"/"+a,j=0;
  355. h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,f,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
  356. createBinModel:function(a,b,c,e){var f=function(g){function h(u,F){var N=m(u,F),V=m(u,F+1),X=m(u,F+2),ja=m(u,F+3),ga=(ja<<1&255|X>>7)-127;N|=(X&127)<<16|V<<8;if(N==0&&ga==-127)return 0;return(1-2*(ja>>7))*(1+N*Math.pow(2,-23))*Math.pow(2,ga)}function k(u,F){var N=m(u,F),V=m(u,F+1),X=m(u,F+2);return(m(u,F+3)<<24)+(X<<16)+(V<<8)+N}function j(u,F){var N=m(u,F);return(m(u,F+1)<<8)+N}function l(u,F){var N=m(u,F);return N>127?N-256:N}function m(u,F){return u.charCodeAt(F)&255}function v(u){var F,N,V;F=
  357. k(a,u);N=k(a,u+aa);V=k(a,u+K);u=j(a,u+L);THREE.Loader.prototype.f3(q,F,N,V,u)}function p(u){var F,N,V,X,ja,ga;F=k(a,u);N=k(a,u+aa);V=k(a,u+K);X=j(a,u+L);ja=k(a,u+W);ga=k(a,u+T);u=k(a,u+Y);THREE.Loader.prototype.f3n(q,M,F,N,V,X,ja,ga,u)}function o(u){var F,N,V,X;F=k(a,u);N=k(a,u+fa);V=k(a,u+I);X=k(a,u+ea);u=j(a,u+ra);THREE.Loader.prototype.f4(q,F,N,V,X,u)}function x(u){var F,N,V,X,ja,ga,Ca,R;F=k(a,u);N=k(a,u+fa);V=k(a,u+I);X=k(a,u+ea);ja=j(a,u+ra);ga=k(a,u+ba);Ca=k(a,u+na);R=k(a,u+n);u=k(a,u+A);THREE.Loader.prototype.f4n(q,
  358. M,F,N,V,X,ja,ga,Ca,R,u)}function z(u){var F,N;F=k(a,u);N=k(a,u+B);u=k(a,u+t);THREE.Loader.prototype.uv3(q.uvs,Q[F*2],Q[F*2+1],Q[N*2],Q[N*2+1],Q[u*2],Q[u*2+1])}function H(u){var F,N,V;F=k(a,u);N=k(a,u+w);V=k(a,u+C);u=k(a,u+E);THREE.Loader.prototype.uv4(q.uvs,Q[F*2],Q[F*2+1],Q[N*2],Q[N*2+1],Q[V*2],Q[V*2+1],Q[u*2],Q[u*2+1])}var q=this,G=0,d,M=[],Q=[],aa,K,L,W,T,Y,fa,I,ea,ra,ba,na,n,A,B,t,w,C,E,D,y,P,S,Z,la;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(q,e,g);d={signature:a.substr(G,
  359. 8),header_bytes:m(a,G+8),vertex_coordinate_bytes:m(a,G+9),normal_coordinate_bytes:m(a,G+10),uv_coordinate_bytes:m(a,G+11),vertex_index_bytes:m(a,G+12),normal_index_bytes:m(a,G+13),uv_index_bytes:m(a,G+14),material_index_bytes:m(a,G+15),nvertices:k(a,G+16),nnormals:k(a,G+16+4),nuvs:k(a,G+16+8),ntri_flat:k(a,G+16+12),ntri_smooth:k(a,G+16+16),ntri_flat_uv:k(a,G+16+20),ntri_smooth_uv:k(a,G+16+24),nquad_flat:k(a,G+16+28),nquad_smooth:k(a,G+16+32),nquad_flat_uv:k(a,G+16+36),nquad_smooth_uv:k(a,G+16+40)};
  360. G+=d.header_bytes;aa=d.vertex_index_bytes;K=d.vertex_index_bytes*2;L=d.vertex_index_bytes*3;W=d.vertex_index_bytes*3+d.material_index_bytes;T=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes;Y=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes*2;fa=d.vertex_index_bytes;I=d.vertex_index_bytes*2;ea=d.vertex_index_bytes*3;ra=d.vertex_index_bytes*4;ba=d.vertex_index_bytes*4+d.material_index_bytes;na=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes;n=
  361. d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*2;A=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*3;B=d.uv_index_bytes;t=d.uv_index_bytes*2;w=d.uv_index_bytes;C=d.uv_index_bytes*2;E=d.uv_index_bytes*3;g=d.vertex_index_bytes*3+d.material_index_bytes;la=d.vertex_index_bytes*4+d.material_index_bytes;D=d.ntri_flat*g;y=d.ntri_smooth*(g+d.normal_index_bytes*3);P=d.ntri_flat_uv*(g+d.uv_index_bytes*3);S=d.ntri_smooth_uv*(g+d.normal_index_bytes*3+d.uv_index_bytes*3);
  362. Z=d.nquad_flat*la;g=d.nquad_smooth*(la+d.normal_index_bytes*4);la=d.nquad_flat_uv*(la+d.uv_index_bytes*4);G+=function(u){for(var F,N,V,X=d.vertex_coordinate_bytes*3,ja=u+d.nvertices*X;u<ja;u+=X){F=h(a,u);N=h(a,u+d.vertex_coordinate_bytes);V=h(a,u+d.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(q,F,N,V)}return d.nvertices*X}(G);G+=function(u){for(var F,N,V,X=d.normal_coordinate_bytes*3,ja=u+d.nnormals*X;u<ja;u+=X){F=l(a,u);N=l(a,u+d.normal_coordinate_bytes);V=l(a,u+d.normal_coordinate_bytes*
  363. 2);M.push(F/127,N/127,V/127)}return d.nnormals*X}(G);G+=function(u){for(var F,N,V=d.uv_coordinate_bytes*2,X=u+d.nuvs*V;u<X;u+=V){F=h(a,u);N=h(a,u+d.uv_coordinate_bytes);Q.push(F,N)}return d.nuvs*V}(G);D=G+D;y=D+y;P=y+P;S=P+S;Z=S+Z;g=Z+g;la=g+la;(function(u){var F,N=d.vertex_index_bytes*3+d.material_index_bytes,V=N+d.uv_index_bytes*3,X=u+d.ntri_flat_uv*V;for(F=u;F<X;F+=V){v(F);z(F+N)}return X-u})(y);(function(u){var F,N=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes*3,V=N+d.uv_index_bytes*
  364. 3,X=u+d.ntri_smooth_uv*V;for(F=u;F<X;F+=V){p(F);z(F+N)}return X-u})(P);(function(u){var F,N=d.vertex_index_bytes*4+d.material_index_bytes,V=N+d.uv_index_bytes*4,X=u+d.nquad_flat_uv*V;for(F=u;F<X;F+=V){o(F);H(F+N)}return X-u})(g);(function(u){var F,N=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*4,V=N+d.uv_index_bytes*4,X=u+d.nquad_smooth_uv*V;for(F=u;F<X;F+=V){x(F);H(F+N)}return X-u})(la);(function(u){var F,N=d.vertex_index_bytes*3+d.material_index_bytes,V=u+d.ntri_flat*N;for(F=
  365. u;F<V;F+=N)v(F);return V-u})(G);(function(u){var F,N=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes*3,V=u+d.ntri_smooth*N;for(F=u;F<V;F+=N)p(F);return V-u})(D);(function(u){var F,N=d.vertex_index_bytes*4+d.material_index_bytes,V=u+d.nquad_flat*N;for(F=u;F<V;F+=N)o(F);return V-u})(S);(function(u){var F,N=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*4,V=u+d.nquad_smooth*N;for(F=u;F<V;F+=N)x(F);return V-u})(Z);this.computeCentroids();this.computeFaceNormals();
  366. this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var e=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,l,m;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];l=a.vertices[h+1];m=a.vertices[h+2];THREE.Loader.prototype.v(g,j,l,m)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];l=a.colors[h+1];m=a.colors[h+2];THREE.Loader.prototype.vc(g,
  367. j,l,m)}}})();(function(){function h(x,z){THREE.Loader.prototype.f3(g,x[z],x[z+1],x[z+2],x[z+3])}function k(x,z){THREE.Loader.prototype.f3n(g,a.normals,x[z],x[z+1],x[z+2],x[z+3],x[z+4],x[z+5],x[z+6])}function j(x,z){THREE.Loader.prototype.f4(g,x[z],x[z+1],x[z+2],x[z+3],x[z+4])}function l(x,z){THREE.Loader.prototype.f4n(g,a.normals,x[z],x[z+1],x[z+2],x[z+3],x[z+4],x[z+5],x[z+6],x[z+7],x[z+8])}function m(x,z){var H,q,G,d,M,Q,aa,K,L;H=x[z];q=x[z+1];G=x[z+2];d=a.uvs[H*2];aa=a.uvs[H*2+1];M=a.uvs[q*2];K=
  368. a.uvs[q*2+1];Q=a.uvs[G*2];L=a.uvs[G*2+1];THREE.Loader.prototype.uv3(g.uvs,d,aa,M,K,Q,L);if(a.uvs2&&a.uvs2.length){d=a.uvs2[H*2];aa=a.uvs2[H*2+1];M=a.uvs2[q*2];K=a.uvs2[q*2+1];Q=a.uvs2[G*2];L=a.uvs2[G*2+1];THREE.Loader.prototype.uv3(g.uvs2,d,1-aa,M,1-K,Q,1-L)}}function v(x,z){var H,q,G,d,M,Q,aa,K,L,W,T,Y;H=x[z];q=x[z+1];G=x[z+2];d=x[z+3];M=a.uvs[H*2];L=a.uvs[H*2+1];Q=a.uvs[q*2];W=a.uvs[q*2+1];aa=a.uvs[G*2];T=a.uvs[G*2+1];K=a.uvs[d*2];Y=a.uvs[d*2+1];THREE.Loader.prototype.uv4(g.uvs,M,L,Q,W,aa,T,K,Y);
  369. if(a.uvs2){M=a.uvs2[H*2];L=a.uvs2[H*2+1];Q=a.uvs2[q*2];W=a.uvs2[q*2+1];aa=a.uvs2[G*2];T=a.uvs2[G*2+1];K=a.uvs2[d*2];Y=a.uvs2[d*2+1];THREE.Loader.prototype.uv4(g.uvs2,M,1-L,Q,1-W,aa,1-T,K,1-Y)}}var p,o;p=0;for(o=a.triangles_uv.length;p<o;p+=7){h(a.triangles_uv,p);m(a.triangles_uv,p+4)}p=0;for(o=a.triangles_n_uv.length;p<o;p+=10){k(a.triangles_n_uv,p);m(a.triangles_n_uv,p+7)}p=0;for(o=a.quads_uv.length;p<o;p+=9){j(a.quads_uv,p);v(a.quads_uv,p+5)}p=0;for(o=a.quads_n_uv.length;p<o;p+=13){l(a.quads_n_uv,
  370. p);v(a.quads_n_uv,p+9)}p=0;for(o=a.triangles.length;p<o;p+=4)h(a.triangles,p);p=0;for(o=a.triangles_n.length;p<o;p+=7)k(a.triangles_n,p);p=0;for(o=a.quads.length;p<o;p+=5)j(a.quads,p);p=0;for(o=a.quads_n.length;p<o;p+=9)l(a.quads_n,p)})();(function(){var h,k,j,l;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];l=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,l,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];l=a.skinIndices[h+1];THREE.Loader.prototype.si(g,
  371. j,l,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,e,f){a.skinIndices.push(new THREE.Vector4(b,c,e,f))},sw:function(a,b,c,e,f){a.skinWeights.push(new THREE.Vector4(b,c,e,f))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,
  372. c,e)))},vc:function(a,b,c,e){var f=new THREE.Color(16777215);f.setRGB(b,c,e);a.colors.push(f)},f3:function(a,b,c,e,f){a.faces.push(new THREE.Face3(b,c,e,null,a.materials[f]))},f4:function(a,b,c,e,f,g){a.faces.push(new THREE.Face4(b,c,e,f,null,a.materials[g]))},f3n:function(a,b,c,e,f,g,h,k,j){g=a.materials[g];var l=b[k*3],m=b[k*3+1];k=b[k*3+2];var v=b[j*3],p=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,e,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(l,m,k),new THREE.Vector3(v,
  373. p,j)],g))},f4n:function(a,b,c,e,f,g,h,k,j,l,m){h=a.materials[h];var v=b[j*3],p=b[j*3+1];j=b[j*3+2];var o=b[l*3],x=b[l*3+1];l=b[l*3+2];var z=b[m*3],H=b[m*3+1];m=b[m*3+2];a.faces.push(new THREE.Face4(c,e,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(v,p,j),new THREE.Vector3(o,x,l),new THREE.Vector3(z,H,m)],h))},uv3:function(a,b,c,e,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,b,c,e,f,g,h,k,j){var l=[];l.push(new THREE.UV(b,
  374. c));l.push(new THREE.UV(e,f));l.push(new THREE.UV(g,h));l.push(new THREE.UV(k,j));a.push(l)},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function e(k,j){var l=new Image;l.onload=function(){if(!c(this.width)||!c(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),v=Math.pow(2,Math.round(Math.log(this.height)/
  375. Math.LN2));k.image.width=m;k.image.height=v;k.image.getContext("2d").drawImage(this,0,0,m,v)}else k.image=this;k.needsUpdate=!0};l.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.map_diffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);e(g.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*
  376. 255;g.color=h;g.opacity=a.transparency}else if(a.a_dbg_color)g.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");g.light_map=new THREE.Texture(h);e(g.light_map,b+"/"+a.map_lightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
粤ICP备19079148号