Three.js 254 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // Three.js r41/ROME - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){this.setHex(b)};
  3. THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,c,d){this.r=b;this.g=c;this.b=d;this.updateHex()},setHSV:function(b,c,d){var e,g,h,j,k,m;if(d==0)e=g=h=0;else switch(j=Math.floor(b*6),k=b*6-j,b=d*(1-c),m=d*(1-c*k),c=d*(1-c*(1-k)),j){case 1:e=m;g=d;h=b;break;case 2:e=b;g=d;h=c;break;case 3:e=b;g=m;h=d;break;case 4:e=c;g=b;h=d;break;case 5:e=d;g=b;h=m;break;case 6:case 0:e=d,g=c,h=b}this.setRGB(e,
  4. g,h)},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},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,c){this.set(b||0,c||0)};
  5. THREE.Vector2.prototype={set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,c){this.set(b.x+c.x,b.y+c.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,c){this.set(b.x-c.x,b.y-c.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
  6. 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(b,c,d){this.set(b||0,c||0,d||0)};
  7. THREE.Vector3.prototype={set:function(b,c,d){this.x=b;this.y=c;this.z=d;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,c){this.set(b.x+c.x,b.y+c.y,b.z+c.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,c){this.set(b.x-c.x,b.y-c.y,b.z-c.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b,
  8. c){this.set(b.y*c.z-b.z*c.y,b.z*c.x-b.x*c.z,b.x*c.y-b.y*c.x);return this},crossSelf:function(b){var c=this.x,d=this.y,e=this.z;this.set(d*b.z-e*b.y,e*b.x-c*b.z,c*b.y-d*b.x);return this},multiply:function(b,c){this.set(b.x*c.x,b.y*c.y,b.z*c.z);return this},multiplySelf:function(b){this.set(this.x*b.x,this.y*b.y,this.z*b.z);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b,this.z*b);return this},divideSelf:function(b){this.set(this.x/b.x,this.y/b.y,this.z/b.z);return this},divideScalar:function(b){this.set(this.x/
  9. b,this.y/b,this.z/b);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,d=this.y-b.y,b=this.z-b.z;return c*c+d*d+b*b},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 b=
  10. this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13);Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&
  11. Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,c,d,e){this.set(b||0,c||0,d||0,e||1)};
  12. THREE.Vector4.prototype={set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,c){this.set(b.x+c.x,b.y+c.y,b.z+c.z,b.w+c.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,c){this.set(b.x-c.x,b.y-c.y,b.z-c.z,b.w-c.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
  13. b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,c){this.set(this.x+(b.x-this.x)*c,this.y+(b.y-this.y)*c,this.z+(b.z-this.z)*c,this.w+(b.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  14. THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,d,e=[];c=0;for(d=b.length;c<d;c++)e=e.concat(this.intersectObject(b[c]));e.sort(function(b,d){return b.distance-d.distance});return e},intersectObject:function(b){function c(b,d,c){var e;e=c.position.clone().subSelf(b).dot(d);if(e<0)return!1;b=b.clone().addSelf(d.clone().multiplyScalar(e));return c.position.distanceTo(b)}function d(b,d,c,e){var e=e.clone().subSelf(d),c=c.clone().subSelf(d),
  15. g=b.clone().subSelf(d),b=e.dot(e),d=e.dot(c),e=e.dot(g),h=c.dot(c),c=c.dot(g),g=1/(b*h-d*d),h=(h*e-d*c)*g,b=(b*c-d*e)*g;return h>0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var e=[],g=c(this.origin,this.direction,b);g&&g<b.scale.x&&e.push({distance:g,point:b.position,object:b});return e}else if(b instanceof THREE.Mesh){var h,j,k,m,n,o,t,u,p,v,C=b.geometry,E=C.vertices,e=[],g=0;for(h=C.faces.length;g<h;g++)if(j=C.faces[g],p=this.origin.clone(),v=this.direction.clone(),o=b.matrixWorld,k=o.multiplyVector3(E[j.a].position.clone()),
  16. m=o.multiplyVector3(E[j.b].position.clone()),n=o.multiplyVector3(E[j.c].position.clone()),o=j instanceof THREE.Face4?o.multiplyVector3(E[j.d].position.clone()):null,t=b.matrixRotationWorld.multiplyVector3(j.normal.clone()),u=v.dot(t),b.doubleSided||(b.flipSided?u>0:u<0))if(t=t.dot((new THREE.Vector3).sub(k,p))/u,p=p.addSelf(v.multiplyScalar(t)),j instanceof THREE.Face3)d(p,k,m,n)&&(j={distance:this.origin.distanceTo(p),point:p,face:j,object:b},e.push(j));else if(j instanceof THREE.Face4&&(d(p,k,m,
  17. o)||d(p,m,n,o)))j={distance:this.origin.distanceTo(p),point:p,face:j,object:b},e.push(j);return e}}};
  18. THREE.Rectangle=function(){function b(){h=e-c;j=g-d}var c,d,e,g,h,j,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(h,j,o,t){k=!1;c=h;d=j;e=o;g=t;b()};this.addPoint=function(h,j){k?(k=!1,c=h,d=j,e=h,g=j):(c=c<h?c:h,d=d<j?d:j,e=e>h?e:h,g=g>j?g:j);b()};this.add3Points=
  19. function(h,j,o,t,u,p){k?(k=!1,c=h<o?h<u?h:u:o<u?o:u,d=j<t?j<p?j:p:t<p?t:p,e=h>o?h>u?h:u:o>u?o:u,g=j>t?j>p?j:p:t>p?t:p):(c=h<o?h<u?h<c?h:c:u<c?u:c:o<u?o<c?o:c:u<c?u:c,d=j<t?j<p?j<d?j:d:p<d?p:d:t<p?t<d?t:d:p<d?p:d,e=h>o?h>u?h>e?h:e:u>e?u:e:o>u?o>e?o:e:u>e?u:e,g=j>t?j>p?j>g?j:g:p>g?p:g:t>p?t>g?t:g:p>g?p:g);b()};this.addRectangle=function(h){k?(k=!1,c=h.getLeft(),d=h.getTop(),e=h.getRight(),g=h.getBottom()):(c=c<h.getLeft()?c:h.getLeft(),d=d<h.getTop()?d:h.getTop(),e=e>h.getRight()?e:h.getRight(),g=g>
  20. h.getBottom()?g:h.getBottom());b()};this.inflate=function(h){c-=h;d-=h;e+=h;g+=h;b()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();e=e<h.getRight()?e:h.getRight();g=g<h.getBottom()?g:h.getBottom();b()};this.instersects=function(b){return Math.min(e,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(g,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;g=e=d=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]};
  21. THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,e,g,h,j,k,m,n,o,t,u,p,v,C){this.set(b||1,c||0,d||0,e||0,g||0,h||1,j||0,k||0,m||0,n||0,o||1,t||0,u||0,p||0,v||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  22. THREE.Matrix4.prototype={set:function(b,c,d,e,g,h,j,k,m,n,o,t,u,p,v,C){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=n;this.n33=o;this.n34=t;this.n41=u;this.n42=p;this.n43=v;this.n44=C;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,d){var e=THREE.Matrix4.__v1,
  23. g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;e.cross(d,h).normalize();e.length()===0&&(h.x+=1.0E-4,e.cross(d,h).normalize());g.cross(h,e).normalize();this.n11=e.x;this.n12=g.x;this.n13=h.x;this.n21=e.y;this.n22=g.y;this.n23=h.y;this.n31=e.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;b.y=(this.n21*c+this.n22*d+this.n23*
  24. e+this.n24)*g;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,g=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*g;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+d*this.n32+e*this.n33;b.normalize();
  25. return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,e=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,n=b.n24,o=b.n31,t=b.n32,u=b.n33,p=b.n34,v=b.n41,C=b.n42,E=b.n43,y=b.n44,D=c.n11,x=c.n12,I=c.n13,A=c.n14,z=c.n21,S=c.n22,
  26. G=c.n23,M=c.n24,F=c.n31,N=c.n32,f=c.n33,Y=c.n34;this.n11=d*D+e*z+g*F;this.n12=d*x+e*S+g*N;this.n13=d*I+e*G+g*f;this.n14=d*A+e*M+g*Y+h;this.n21=j*D+k*z+m*F;this.n22=j*x+k*S+m*N;this.n23=j*I+k*G+m*f;this.n24=j*A+k*M+m*Y+n;this.n31=o*D+t*z+u*F;this.n32=o*x+t*S+u*N;this.n33=o*I+t*G+u*f;this.n34=o*A+t*M+u*Y+p;this.n41=v*D+C*z+E*F;this.n42=v*x+C*S+E*N;this.n43=v*I+C*G+E*f;this.n44=v*A+C*M+E*Y+y;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=
  27. this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=
  28. this.n11,c=this.n12,d=this.n13,e=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,n=this.n32,o=this.n33,t=this.n34,u=this.n41,p=this.n42,v=this.n43,C=this.n44;return e*j*n*u-d*k*n*u-e*h*o*u+c*k*o*u+d*h*t*u-c*j*t*u-e*j*m*p+d*k*m*p+e*g*o*p-b*k*o*p-d*g*t*p+b*j*t*p+e*h*m*v-c*k*m*v-e*g*n*v+b*k*n*v+c*g*t*v-b*h*t*v-d*h*m*C+c*j*m*C+d*g*n*C-b*j*n*C-c*g*o*C+b*h*o*C},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=
  29. this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
  30. this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=
  31. this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,
  32. c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,h=b.x,j=b.y,k=b.z,m=g*h,n=g*j;this.set(m*
  33. h+d,m*j-e*k,m*k+e*j,0,m*j+e*k,n*j+d,n*k-e*h,0,m*k-e*j,n*k+e*h,g*k*k+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
  34. this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b){var c=b.x,d=b.y,e=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e),j=b*d,k=c*d;this.n11=g*h;this.n12=-g*e;this.n13=d;this.n21=k*h+b*e;this.n22=-k*e+b*h;this.n23=-c*g;this.n31=-j*h+c*e;this.n32=j*e+c*h;this.n33=b*g;return this},
  35. setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,g=b.w,h=c+c,j=d+d,k=e+e,b=c*h,m=c*j;c*=k;var n=d*j;d*=k;e*=k;h*=g;j*=g;g*=k;this.n11=1-(n+e);this.n12=m-g;this.n13=c+j;this.n21=m+g;this.n22=1-(b+e);this.n23=d-h;this.n31=c-j;this.n32=d+h;this.n33=1-(b+n);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14=
  36. b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,e=1/c.y,g=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
  37. THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,n=b.n24,o=b.n31,t=b.n32,u=b.n33,p=b.n34,v=b.n41,C=b.n42,E=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=m*p*C-n*u*C+n*t*E-k*p*E-m*t*y+k*u*y;c.n12=h*u*C-g*p*C-h*t*E+e*p*E+g*t*y-e*u*y;c.n13=g*n*C-h*m*C+h*k*E-e*n*E-g*k*y+e*m*y;c.n14=h*m*t-g*n*t-h*k*u+e*n*u+g*k*p-e*m*p;c.n21=n*u*v-m*p*v-n*o*E+j*p*E+m*o*y-j*u*y;c.n22=g*p*v-h*u*v+h*o*E-d*p*E-g*o*y+d*u*y;c.n23=h*m*v-g*n*v-h*j*E+d*n*E+g*j*y-d*m*y;c.n24=
  38. g*n*o-h*m*o+h*j*u-d*n*u-g*j*p+d*m*p;c.n31=k*p*v-n*t*v+n*o*C-j*p*C-k*o*y+j*t*y;c.n32=h*t*v-e*p*v-h*o*C+d*p*C+e*o*y-d*t*y;c.n33=g*n*v-h*k*v+h*j*C-d*n*C-e*j*y+d*k*y;c.n34=h*k*o-e*n*o-h*j*t+d*n*t+e*j*p-d*k*p;c.n41=m*t*v-k*u*v-m*o*C+j*u*C+k*o*E-j*t*E;c.n42=e*u*v-g*t*v+g*o*C-d*u*C-e*o*E+d*t*E;c.n43=g*k*v-e*m*v-g*j*C+d*m*C+e*j*E-d*k*E;c.n44=e*m*o-g*k*o+g*j*t-d*m*t-e*j*u+d*k*u;c.multiplyScalar(1/b.determinant());return c};
  39. THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,n=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*j+b.n31*n;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*g;d[2]=b*h;d[3]=b*j;d[4]=b*k;d[5]=b*m;d[6]=b*n;d[7]=b*o;d[8]=b*t;return c};
  40. THREE.Matrix4.makeFrustum=function(b,c,d,e,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*g/(e-d);j.n23=(e+d)/(e-d);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,d,e){var g,b=d*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,d,e)};
  41. THREE.Matrix4.makeOrtho=function(b,c,d,e,g,h){var j,k,m,n;j=new THREE.Matrix4;k=c-b;m=d-e;n=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((d+e)/m);j.n31=0;j.n32=0;j.n33=-2/n;j.n34=-((h+g)/n);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
  42. THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.dynamic=!1;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
  43. this.visible=!0;this._vector=new THREE.Vector3;this.name=""};
  44. THREE.Object3D.prototype={translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===
  45. -1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var d,e,g;d=0;for(e=this.children.length;d<e;d++){g=this.children[d];if(g.name===b)return g;if(c&&(g=g.getChildByName(b,c),g!==void 0))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);
  46. this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,d){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,
  47. this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,e=this.children.length;b<e;b++)this.children[b].update(this.matrixWorld,c,d)}};THREE.Quaternion=function(b,c,d,e){this.set(b||0,c||0,d||0,e!==void 0?e:1)};
  48. THREE.Quaternion.prototype={set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,e=b.y*c,g=b.z*c,b=Math.cos(e),e=Math.sin(e),c=Math.cos(-g),g=Math.sin(-g),h=Math.cos(d),d=Math.sin(d),j=b*c,k=e*g;this.w=j*h-k*d;this.x=j*d+k*h;this.y=e*c*h+b*g*d;this.z=b*g*h-e*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,e=Math.sin(d);this.x=b.x*e;this.y=b.y*
  49. e;this.z=b.z*e;this.w=Math.cos(d);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*=-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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},
  50. multiplySelf:function(b){var c=this.x,d=this.y,e=this.z,g=this.w,h=b.x,j=b.y,k=b.z,b=b.w;this.x=c*b+g*h+d*k-e*j;this.y=d*b+g*j+e*h-c*k;this.z=e*b+g*k+c*j-d*h;this.w=g*b-c*h-d*j-e*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,e=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,n=m*d+j*g-k*e,o=
  51. m*e+k*d-h*g,t=m*g+h*e-j*d,d=-h*d-j*e-k*g;c.x=n*m+d*-h+o*-k-t*-j;c.y=o*m+d*-j+t*-h-n*-k;c.z=t*m+d*-k+n*-j-o*-h;return c}};
  52. THREE.Quaternion.slerp=function(b,c,d,e){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;g=Math.sin((1-e)*h)/j;e=Math.sin(e*h)/j;d.w=b.w*g+c.w*e;d.x=b.x*g+c.x*e;d.y=b.y*g+c.y*e;d.z=b.z*g+c.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
  53. THREE.Face3=function(b,c,d,e,g,h){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
  54. THREE.Face4=function(b,c,d,e,g,h,j){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)};
  55. THREE.UV.prototype={set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
  56. THREE.Geometry.prototype={computeCentroids:function(){var b,c,d;b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d.centroid.set(0,0,0),d instanceof THREE.Face3?(d.centroid.addSelf(this.vertices[d.a].position),d.centroid.addSelf(this.vertices[d.b].position),d.centroid.addSelf(this.vertices[d.c].position),d.centroid.divideScalar(3)):d instanceof THREE.Face4&&(d.centroid.addSelf(this.vertices[d.a].position),d.centroid.addSelf(this.vertices[d.b].position),d.centroid.addSelf(this.vertices[d.c].position),
  57. d.centroid.addSelf(this.vertices[d.d].position),d.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,d,e,g,h,j,k=new THREE.Vector3,m=new THREE.Vector3;e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];if(b&&h.vertexNormals.length){k.set(0,0,0);c=0;for(d=h.vertexNormals.length;c<d;c++)k.addSelf(h.vertexNormals[c]);k.divideScalar(3)}else c=this.vertices[h.a],d=this.vertices[h.b],j=this.vertices[h.c],k.sub(j.position,d.position),m.sub(c.position,d.position),k.crossSelf(m);k.isZero()||
  58. k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var b,c,d,e;if(this.__tmpVertices==void 0){e=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)e[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(d=this.faces[b],d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{e=
  59. this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)e[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal)):d instanceof THREE.Face4&&(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal),e[d.d].addSelf(d.normal));b=0;for(c=this.vertices.length;b<c;b++)e[b].normalize();b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(d.vertexNormals[0].copy(e[d.a]),
  60. d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c])):d instanceof THREE.Face4&&(d.vertexNormals[0].copy(e[d.a]),d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c]),d.vertexNormals[3].copy(e[d.d]))},computeTangents:function(){function b(b,d,c,e,g,h,G){k=b.vertices[d].position;m=b.vertices[c].position;n=b.vertices[e].position;o=j[g];t=j[h];u=j[G];p=m.x-k.x;v=n.x-k.x;C=m.y-k.y;E=n.y-k.y;y=m.z-k.z;D=n.z-k.z;x=t.u-o.u;I=u.u-o.u;A=t.v-o.v;z=u.v-o.v;S=1/(x*z-I*A);N.set((z*p-A*v)*
  61. S,(z*C-A*E)*S,(z*y-A*D)*S);f.set((x*v-I*p)*S,(x*E-I*C)*S,(x*D-I*y)*S);M[d].addSelf(N);M[c].addSelf(N);M[e].addSelf(N);F[d].addSelf(f);F[c].addSelf(f);F[e].addSelf(f)}var c,d,e,g,h,j,k,m,n,o,t,u,p,v,C,E,y,D,x,I,A,z,S,G,M=[],F=[],N=new THREE.Vector3,f=new THREE.Vector3,Y=new THREE.Vector3,O=new THREE.Vector3,V=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++)M[c]=new THREE.Vector3,F[c]=new THREE.Vector3;c=0;for(d=this.faces.length;c<d;c++)h=this.faces[c],j=this.faceVertexUvs[0][c],h instanceof
  62. THREE.Face3?b(this,h.a,h.b,h.c,0,1,2):h instanceof THREE.Face4&&(b(this,h.a,h.b,h.c,0,1,2),b(this,h.a,h.b,h.d,0,1,3));var L=["a","b","c","d"];c=0;for(d=this.faces.length;c<d;c++){h=this.faces[c];for(e=0;e<h.vertexNormals.length;e++)V.copy(h.vertexNormals[e]),g=h[L[e]],G=M[g],Y.copy(G),Y.subSelf(V.multiplyScalar(V.dot(G))).normalize(),O.cross(h.vertexNormals[e],G),g=O.dot(F[g]),g=g<0?-1:1,h.vertexTangents[e]=new THREE.Vector4(Y.x,Y.y,Y.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var b;
  63. 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],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;
  64. else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,d){return Math.min(b,
  65. d)+"_"+Math.max(b,d)}function c(b,d,c){b[d]===void 0?(b[d]={set:{},array:[]},b[d].set[c]=1,b[d].array.push(c)):b[d].set[c]===void 0&&(b[d].set[c]=1,b[d].array.push(c))}var d,e,g,h,j,k={};d=0;for(e=this.faces.length;d<e;d++)j=this.faces[d],j instanceof THREE.Face3?(g=b(j.a,j.b),c(k,g,d),g=b(j.b,j.c),c(k,g,d),g=b(j.a,j.c),c(k,g,d)):j instanceof THREE.Face4&&(g=b(j.b,j.d),c(k,g,d),g=b(j.a,j.b),c(k,g,d),g=b(j.a,j.d),c(k,g,d),g=b(j.b,j.c),c(k,g,d),g=b(j.c,j.d),c(k,g,d));d=0;for(e=this.edges.length;d<e;d++){j=
  66. this.edges[d];g=j.vertexIndices[0];h=j.vertexIndices[1];j.faceIndices=k[b(g,h)].array;for(g=0;g<j.faceIndices.length;g++)h=j.faceIndices[g],j.faces.push(this.faces[h])}}};THREE.GeometryIdCounter=0;
  67. THREE.Spline=function(b){function c(b,d,c,e,g,h,j){b=(c-b)*0.5;e=(e-d)*0.5;return(2*(d-c)+b+e)*j+(-3*(d-c)-2*b-e)*h+b*g+d}this.points=b;var d=[],e={x:0,y:0,z:0},g,h,j,k,m,n,o,t,u;this.initFromArray=function(b){this.points=[];for(var d=0;d<b.length;d++)this.points[d]={x:b[d][0],y:b[d][1],z:b[d][2]}};this.getPoint=function(b){g=(this.points.length-1)*b;h=Math.floor(g);j=g-h;d[0]=h==0?h:h-1;d[1]=h;d[2]=h>this.points.length-2?h:h+1;d[3]=h>this.points.length-3?h:h+2;n=this.points[d[0]];o=this.points[d[1]];
  68. t=this.points[d[2]];u=this.points[d[3]];k=j*j;m=j*k;e.x=c(n.x,o.x,t.x,u.x,j,k,m);e.y=c(n.y,o.y,t.y,u.y,j,k,m);e.z=c(n.z,o.z,t.z,u.z,j,k,m);return e};this.getControlPointsArray=function(){var b,d,c=this.points.length,e=[];for(b=0;b<c;b++)d=this.points[b],e[b]=[d.x,d.y,d.z];return e};this.getLength=function(b){var d,c,e=d=d=0,g=new THREE.Vector3,h=new THREE.Vector3,j=[],k=0;j[0]=0;b||(b=100);c=this.points.length*b;g.copy(this.points[0]);for(b=1;b<c;b++)d=b/c,position=this.getPoint(d),h.copy(position),
  69. k+=h.distanceTo(g),g.copy(position),d*=this.points.length-1,d=Math.floor(d),d!=e&&(j[d]=k,e=d);j[j.length]=k;return{chunks:j,total:k}};this.reparametrizeByArcLength=function(b){var d,c,e,g,h,j,k=[],m=new THREE.Vector3,n=this.getLength();k.push(m.copy(this.points[0]).clone());for(d=1;d<this.points.length;d++){c=n.chunks[d]-n.chunks[d-1];j=Math.ceil(b*c/n.total);g=(d-1)/(this.points.length-1);h=d/(this.points.length-1);for(c=1;c<j-1;c++)e=g+c*(1/j)*(h-g),position=this.getPoint(e),k.push(m.copy(position).clone());
  70. k.push(m.copy(this.points[d]).clone())}this.points=k}};THREE.Edge=function(b,c,d,e){this.vertices=[b,c];this.vertexIndices=[d,e];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,d,e,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=d||0.1;this.far=e||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
  71. THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
  72. THREE.Camera.prototype.update=function(b,c,d){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),c=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
  73. !1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
  74. THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=d||0;this.castShadow=e!==void 0?e:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,d){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=d||0};
  75. THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.LensFlare=function(b,c,d,e){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,c,d,e)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
  76. THREE.LensFlare.prototype.add=function(b,c,d,e){c===void 0&&(c=-1);d===void 0&&(d=0);if(e===void 0)e=THREE.BillboardBlending;d=Math.min(d,Math.max(0,d));this.lensFlares.push({texture:b,size:c,distance:d,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:e})};
  77. THREE.LensFlare.prototype.updateLensFlares=function(){var b,c=this.lensFlares.length,d,e=-this.positionScreen.x*2,g=-this.positionScreen.y*2;for(b=0;b<c;b++)d=this.lensFlares[b],d.x=this.positionScreen.x+e*d.distance,d.y=this.positionScreen.y+g*d.distance,d.wantedRotation=d.x*Math.PI*0.25,d.rotation+=(d.wantedRotation-d.rotation)*0.25};
  78. THREE.Material=function(b){this.id=THREE.MaterialCounter.value++;b=b||{};this.opacity=b.opacity!==void 0?b.opacity:1;this.transparent=b.transparent!==void 0?b.transparent:!1;this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==void 0?b.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
  79. THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  80. THREE.LineBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.linewidth=b.linewidth!==void 0?b.linewidth:1;this.linecap=b.linecap!==void 0?b.linecap:"round";this.linejoin=b.linejoin!==void 0?b.linejoin:"round";this.vertexColors=b.vertexColors?b.vertexColors:!1};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  81. THREE.MeshBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
  82. void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
  83. THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  84. THREE.MeshLambertMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
  85. void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
  86. THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  87. THREE.MeshPhongMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.ambient=b.ambient!==void 0?new THREE.Color(b.ambient):new THREE.Color(328965);this.specular=b.specular!==void 0?new THREE.Color(b.specular):new THREE.Color(1118481);this.shininess=b.shininess!==void 0?b.shininess:30;this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;
  88. this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==
  89. void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;
  90. THREE.MeshDepthMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
  91. THREE.MeshNormalMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading?b.shading:THREE.FlatShading;this.wireframe=b.wireframe?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth?b.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
  92. THREE.MeshShaderMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.fragmentShader=b.fragmentShader!==void 0?b.fragmentShader:"void main() {}";this.vertexShader=b.vertexShader!==void 0?b.vertexShader:"void main() {}";this.uniforms=b.uniforms!==void 0?b.uniforms:{};this.attributes=b.attributes;this.shading=b.shading!==void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.fog=
  93. b.fog!==void 0?b.fog:!1;this.lights=b.lights!==void 0?b.lights:!1;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};THREE.MeshShaderMaterial.prototype=new THREE.Material;THREE.MeshShaderMaterial.prototype.constructor=THREE.MeshShaderMaterial;
  94. THREE.ShadowVolumeDynamicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.lightMap=b.lightMap!==void 0?b.lightMap:null;this.envMap=b.envMap!==void 0?b.envMap:null;this.combine=b.combine!==void 0?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==void 0?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==void 0?b.refractionRatio:0.98;this.shading=b.shading!==
  95. void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==void 0?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==void 0?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==void 0?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1;this.skinning=b.skinning!==void 0?b.skinning:!1;this.morphTargets=b.morphTargets!==void 0?b.morphTargets:!1};
  96. THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
  97. THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.size=b.size!==void 0?b.size:1;this.sizeAttenuation=b.sizeAttenuation!==void 0?b.sizeAttenuation:!0;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
  98. THREE.ParticleCanvasMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.program=b.program!==void 0?b.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(b){THREE.Material.call(this);this.domElement=b};
  99. THREE.Texture=function(b,c,d,e,g,h){this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=d!==void 0?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==void 0?e:THREE.ClampToEdgeWrapping;this.magFilter=g!==void 0?g:THREE.LinearFilter;this.minFilter=h!==void 0?h:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;
  100. 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;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;
  101. THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b]};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
  102. THREE.Line=function(b,c,d){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=d!=void 0?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  103. THREE.Mesh=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c&&c.length?c:[c];this.overdraw=this.doubleSided=this.flipSided=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=b.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var d=0;d<this.geometry.morphTargets.length;d++)this.morphTargetInfluences.push(0),
  104. this.morphTargetDictionary[this.geometry.morphTargets[d].name]=d}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(b){if(this.morphTargetDictionary[b]!==void 0)return this.morphTargetDictionary[b];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+b+" does not exist. Returning 0.");return 0};
  105. THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;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;
  106. THREE.Bone.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<g;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.skinMatrix,c,d):b.update(this.matrixWorld,!0,d)}else for(e=0;e<g;e++)this.children[e].update(this.skinMatrix,
  107. c,d)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
  108. THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,g,h,j,k;if(this.geometry.bones!==void 0){for(d=0;d<this.geometry.bones.length;d++)g=this.geometry.bones[d],h=g.pos,j=g.rotq,k=g.scl,e=this.addBone(),e.name=g.name,e.position.set(h[0],h[1],h[2]),e.quaternion.set(j[0],j[1],j[2],j[3]),e.useQuaternion=!0,k!==void 0?e.scale.set(k[0],k[1],k[2]):e.scale.set(1,1,1);for(d=0;d<this.bones.length;d++)g=this.geometry.bones[d],
  109. e=this.bones[d],g.parent===-1?this.addChild(e):this.bones[g.parent].addChild(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  110. THREE.SkinnedMesh.prototype.update=function(b,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,g=this.children.length;for(e=0;e<g;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,d):b.update(this.matrixWorld,c,d);d=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<d;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
  111. c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
  112. THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],d=0;d<this.bones.length;d++)b=this.bones[d],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,d*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(b=0;b<this.geometry.skinIndices.length;b++){var d=this.geometry.vertices[b].position,g=this.geometry.skinIndices[b].x,h=this.geometry.skinIndices[b].y;e=new THREE.Vector3(d.x,
  113. d.y,d.z);this.geometry.skinVerticesA.push(c[g].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(c[h].multiplyVector3(e));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(d=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=d,this.geometry.skinWeights[b].y+=d)}}};
  114. THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.doubleSided=this.flipSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
  115. THREE.Sound=function(b,c,d,e){THREE.Object3D.call(this);this.isPlaying=this.isAddedToDOM=this.isLoaded=!1;this.duration=-1;this.radius=c!==void 0?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,d!==void 0?d:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==void 0?e:!0;this.sources=b instanceof Array?b:[b];for(var g,d=this.sources.length,b=0;b<d;b++)if(c=this.sources[b],c.toLowerCase(),c.indexOf(".mp3")!==-1?g="audio/mpeg":
  116. c.indexOf(".ogg")!==-1?g="audio/ogg":c.indexOf(".wav")!==-1&&(g="audio/wav"),this.domElement.canPlayType(g)){g=document.createElement("source");g.src=this.sources[b];this.domElement.THREESound=this;this.domElement.appendChild(g);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;
  117. THREE.Sound.prototype.onLoad=function(){var b=this.THREESound;if(!b.isLoaded)this.removeEventListener("canplay",this.onLoad,!0),b.isLoaded=!0,b.duration=this.duration,b.isPlaying&&b.play()};THREE.Sound.prototype.addToDOM=function(b){this.isAddedToDOM=!0;b.appendChild(this.domElement)};THREE.Sound.prototype.play=function(b){this.isPlaying=!0;if(this.isLoaded&&(this.domElement.play(),b))this.domElement.currentTime=b%this.duration};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
  118. THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(b){b=b.length();this.domElement.volume=b<=this.radius?this.volume*(1-b/this.radius):0};
  119. THREE.Sound.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(this.matrix.setPosition(this.position),c=!0);if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;for(var e=this.children.length,b=0;b<e;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
  120. THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),d=0;d<this.LODs.length;d++)if(c<this.LODs[d].visibleAtDistance)break;this.LODs.splice(d,0,{visibleAtDistance:c,object3D:b});this.addChild(b)};
  121. THREE.LOD.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e<this.LODs.length;e++)if(b>=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1,
  122. this.LODs[e].object3D.visible=!0;else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.ShadowVolume=function(b,c){b instanceof THREE.Mesh?(THREE.Mesh.call(this,b.geometry,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]),b.addChild(this)):THREE.Mesh.call(this,b,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);this.calculateShadowVolumeGeometry()};
  123. THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
  124. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,c,d,e,g,h,j,k,m,n,o,t,u,p,v=new THREE.Geometry;v.vertices=this.geometry.vertices;e=v.faces=this.geometry.faces;var C=v.egdes=this.geometry.edges,E=v.edgeFaces=[];g=0;var y=[];b=0;for(c=e.length;b<c;b++)if(d=e[b],y.push(g),g+=d instanceof THREE.Face3?3:4,d.vertexNormals[0]=d.normal,d.vertexNormals[1]=d.normal,d.vertexNormals[2]=d.normal,d instanceof THREE.Face4)d.vertexNormals[3]=
  125. d.normal;b=0;for(c=C.length;b<c;b++)k=C[b],d=k.faces[0],e=k.faces[1],g=k.faceIndices[0],h=k.faceIndices[1],j=k.vertexIndices[0],k=k.vertexIndices[1],d.a===j?(m="a",o=y[g]+0):d.b===j?(m="b",o=y[g]+1):d.c===j?(m="c",o=y[g]+2):d.d===j&&(m="d",o=y[g]+3),d.a===k?(m+="a",t=y[g]+0):d.b===k?(m+="b",t=y[g]+1):d.c===k?(m+="c",t=y[g]+2):d.d===k&&(m+="d",t=y[g]+3),e.a===j?(n="a",u=y[h]+0):e.b===j?(n="b",u=y[h]+1):e.c===j?(n="c",u=y[h]+2):e.d===j&&(n="d",u=y[h]+3),e.a===k?(n+="a",p=y[h]+0):e.b===k?(n+="b",p=y[h]+
  126. 1):e.c===k?(n+="c",p=y[h]+2):e.d===k&&(n+="d",p=y[h]+3),m==="ac"||m==="ad"||m==="ca"||m==="da"?o>t&&(d=o,o=t,t=d):o<t&&(d=o,o=t,t=d),n==="ac"||n==="ad"||n==="ca"||n==="da"?u>p&&(d=u,u=p,p=d):u<p&&(d=u,u=p,p=d),d=new THREE.Face4(o,t,u,p),d.normal.set(1,0,0),E.push(d);this.geometry=v}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
  127. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var c=this.geometry.vertices,d=this.geometry.faces,e=this.geometry.edgeFaces,g=b.faces,b=b.vertices,h=g.length,j,k,m,n,o,t=["a","b","c","d"];for(m=0;m<h;m++){k=c.length;j=g[m];j instanceof THREE.Face4?(n=4,k=new THREE.Face4(k,k+1,k+2,k+3)):(n=3,k=new THREE.Face3(k,k+1,k+2));k.normal.copy(j.normal);d.push(k);
  128. for(k=0;k<n;k++)o=b[j[t[k]]],c.push(new THREE.Vertex(o.position.clone()))}for(h=0;h<g.length-1;h++){b=d[h];for(j=h+1;j<g.length;j++)k=d[j],k=this.facesShareEdge(c,b,k),k!==void 0&&(k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]),k.normal.set(1,0,0),e.push(k))}};
  129. THREE.ShadowVolume.prototype.facesShareEdge=function(b,c,d){var e,g,h,j,k,m,n,o,t,u,p,v,C,E=0,y=["a","b","c","d"];e=c instanceof THREE.Face4?4:3;g=d instanceof THREE.Face4?4:3;for(v=0;v<e;v++){h=c[y[v]];k=b[h];for(C=0;C<g;C++)if(j=d[y[C]],m=b[j],Math.abs(k.position.x-m.position.x)<1.0E-4&&Math.abs(k.position.y-m.position.y)<1.0E-4&&Math.abs(k.position.z-m.position.z)<1.0E-4&&(E++,E===1&&(n=k,o=m,t=h,u=j,p=y[v]),E===2))return p+=y[v],p==="ad"||p==="ac"?{faces:[c,d],vertices:[n,o,m,k],indices:[t,u,
  130. j,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,d],vertices:[n,k,m,o],indices:[t,h,j,u],vertexTypes:[1,1,2,2],extrudable:!0}}};
  131. THREE.Sprite=function(b){THREE.Object3D.call(this);if(b.material!==void 0)this.material=b.material,this.map=void 0,this.blending=material.blending;else if(b.map!==void 0)this.map=b.map instanceof THREE.Texture?b.map:ImageUtils.loadTexture(b.map),this.material=void 0,this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.useScreenCoordinates=b.useScreenCoordinates!==void 0?b.useScreenCoordinates:!0;this.mergeWith3D=b.mergeWith3D!==void 0?b.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=
  132. b.affectedByDistance!==void 0?b.affectedByDistance:!this.useScreenCoordinates;this.alignment=b.alignment instanceof THREE.Vector2?b.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.supr=THREE.Object3D.prototype;
  133. THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
  134. THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.centerLeft=new THREE.Vector2(1,0);THREE.SpriteAlignment.center=new THREE.Vector2(0,0);THREE.SpriteAlignment.centerRight=new THREE.Vector2(-1,0);THREE.SpriteAlignment.bottomLeft=new THREE.Vector2(1,1);THREE.SpriteAlignment.bottomCenter=new THREE.Vector2(0,1);THREE.SpriteAlignment.bottomRight=new THREE.Vector2(-1,1);
  135. THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};
  136. THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1)this.objects.push(b),this.__objectsAdded.push(b);for(var c=0;c<b.children.length;c++)this.addChildRecurse(b.children[c])};
  137. THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var c=this.lights.indexOf(b);c!==-1&&this.lights.splice(c,1)}else b instanceof THREE.Sound?(c=this.sounds.indexOf(b),c!==-1&&this.sounds.splice(c,1)):b instanceof THREE.Camera||(c=this.objects.indexOf(b),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(b)));for(c=0;c<b.children.length;c++)this.removeChildRecurse(b.children[c])};
  138. THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;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(b,c,d){this.color=new THREE.Color(b);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
  139. THREE.Projector=function(){function b(){var b=m[k]=m[k]||new THREE.RenderableVertex;k++;return b}function c(b,d){return d.z-b.z}function d(b,d){var c=0,e=1,g=b.z+b.w,h=d.z+d.w,j=-b.z+b.w,k=-d.z+d.w;return g>=0&&h>=0&&j>=0&&k>=0?!0:g<0&&h<0||j<0&&k<0?!1:(g<0?c=Math.max(c,g/(g-h)):h<0&&(e=Math.min(e,g/(g-h))),j<0?c=Math.max(c,j/(j-k)):k<0&&(e=Math.min(e,j/(j-k))),e<c?!1:(b.lerpSelf(d,c),d.lerpSelf(b,1-e),!0))}var e,g,h=[],j,k,m=[],n,o,t=[],u,p=[],v,C,E=[],y,D,x=[],I=new THREE.Vector4,A=new THREE.Vector4,
  140. z=new THREE.Matrix4,S=new THREE.Matrix4,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,F=new THREE.Vector4;this.projectVector=function(b,d){z.multiply(d.projectionMatrix,d.matrixWorldInverse);z.multiplyVector3(b);return b};this.unprojectVector=function(b,d){z.multiply(d.matrixWorld,THREE.Matrix4.makeInvert(d.projectionMatrix));z.multiplyVector3(b);return b};this.projectObjects=function(b,d,j){var d=[],k,m,n;g=0;m=
  141. b.objects;b=0;for(k=m.length;b<k;b++){n=m[b];var o;if(!(o=!n.visible))if(o=n instanceof THREE.Mesh){a:{o=void 0;for(var p=n.matrixWorld,u=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),t=0;t<6;t++)if(o=G[t].x*p.n14+G[t].y*p.n24+G[t].z*p.n34+G[t].w,o<=u){o=!1;break a}o=!0}o=!o}if(!o)o=h[g]=h[g]||new THREE.RenderableObject,g++,e=o,I.copy(n.position),z.multiplyVector3(I),e.object=n,e.z=I.z,d.push(e)}j&&d.sort(c);return d};this.projectScene=function(e,f,g){var h=[],
  142. I=f.near,L=f.far,$,T,Q,fa,U,ka,ga,ca,aa,R,P,W,X,ea,ha,J,da;D=C=u=o=0;f.matrixAutoUpdate&&f.update(void 0,!0);e.update(void 0,!1,f);z.multiply(f.projectionMatrix,f.matrixWorldInverse);G[0].set(z.n41-z.n11,z.n42-z.n12,z.n43-z.n13,z.n44-z.n14);G[1].set(z.n41+z.n11,z.n42+z.n12,z.n43+z.n13,z.n44+z.n14);G[2].set(z.n41+z.n21,z.n42+z.n22,z.n43+z.n23,z.n44+z.n24);G[3].set(z.n41-z.n21,z.n42-z.n22,z.n43-z.n23,z.n44-z.n24);G[4].set(z.n41-z.n31,z.n42-z.n32,z.n43-z.n33,z.n44-z.n34);G[5].set(z.n41+z.n31,z.n42+z.n32,
  143. z.n43+z.n33,z.n44+z.n34);for($=0;$<6;$++)aa=G[$],aa.divideScalar(Math.sqrt(aa.x*aa.x+aa.y*aa.y+aa.z*aa.z));aa=this.projectObjects(e,f,!0);e=0;for($=aa.length;e<$;e++)if(R=aa[e].object,R.visible)if(P=R.matrixWorld,W=R.matrixRotationWorld,X=R.materials,ea=R.overdraw,k=0,R instanceof THREE.Mesh){ha=R.geometry;fa=ha.vertices;J=ha.faces;ha=ha.faceVertexUvs;T=0;for(Q=fa.length;T<Q;T++)j=b(),j.positionWorld.copy(fa[T].position),P.multiplyVector3(j.positionWorld),j.positionScreen.copy(j.positionWorld),z.multiplyVector4(j.positionScreen),
  144. j.positionScreen.x/=j.positionScreen.w,j.positionScreen.y/=j.positionScreen.w,j.visible=j.positionScreen.z>I&&j.positionScreen.z<L;fa=0;for(T=J.length;fa<T;fa++){Q=J[fa];if(Q instanceof THREE.Face3)if(U=m[Q.a],ka=m[Q.b],ga=m[Q.c],U.visible&&ka.visible&&ga.visible&&(R.doubleSided||R.flipSided!=(ga.positionScreen.x-U.positionScreen.x)*(ka.positionScreen.y-U.positionScreen.y)-(ga.positionScreen.y-U.positionScreen.y)*(ka.positionScreen.x-U.positionScreen.x)<0))ca=t[o]=t[o]||new THREE.RenderableFace3,
  145. o++,n=ca,n.v1.copy(U),n.v2.copy(ka),n.v3.copy(ga);else continue;else if(Q instanceof THREE.Face4)if(U=m[Q.a],ka=m[Q.b],ga=m[Q.c],ca=m[Q.d],U.visible&&ka.visible&&ga.visible&&ca.visible&&(R.doubleSided||R.flipSided!=((ca.positionScreen.x-U.positionScreen.x)*(ka.positionScreen.y-U.positionScreen.y)-(ca.positionScreen.y-U.positionScreen.y)*(ka.positionScreen.x-U.positionScreen.x)<0||(ka.positionScreen.x-ga.positionScreen.x)*(ca.positionScreen.y-ga.positionScreen.y)-(ka.positionScreen.y-ga.positionScreen.y)*
  146. (ca.positionScreen.x-ga.positionScreen.x)<0)))da=p[u]=p[u]||new THREE.RenderableFace4,u++,n=da,n.v1.copy(U),n.v2.copy(ka),n.v3.copy(ga),n.v4.copy(ca);else continue;n.normalWorld.copy(Q.normal);W.multiplyVector3(n.normalWorld);n.centroidWorld.copy(Q.centroid);P.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld);z.multiplyVector3(n.centroidScreen);ga=Q.vertexNormals;U=0;for(ka=ga.length;U<ka;U++)ca=n.vertexNormalsWorld[U],ca.copy(ga[U]),W.multiplyVector3(ca);U=0;for(ka=ha.length;U<
  147. ka;U++)if(da=ha[U][fa]){ga=0;for(ca=da.length;ga<ca;ga++)n.uvs[U][ga]=da[ga]}n.meshMaterials=X;n.faceMaterials=Q.materials;n.overdraw=ea;n.z=n.centroidScreen.z;h.push(n)}}else if(R instanceof THREE.Line){S.multiply(z,P);fa=R.geometry.vertices;U=b();U.positionScreen.copy(fa[0].position);S.multiplyVector4(U.positionScreen);T=1;for(Q=fa.length;T<Q;T++)if(U=b(),U.positionScreen.copy(fa[T].position),S.multiplyVector4(U.positionScreen),ka=m[k-2],M.copy(U.positionScreen),F.copy(ka.positionScreen),d(M,F))M.multiplyScalar(1/
  148. M.w),F.multiplyScalar(1/F.w),P=E[C]=E[C]||new THREE.RenderableLine,C++,v=P,v.v1.positionScreen.copy(M),v.v2.positionScreen.copy(F),v.z=Math.max(M.z,F.z),v.materials=R.materials,h.push(v)}else if(R instanceof THREE.Particle&&(A.set(R.matrixWorld.n14,R.matrixWorld.n24,R.matrixWorld.n34,1),z.multiplyVector4(A),A.z/=A.w,A.z>0&&A.z<1))P=x[D]=x[D]||new THREE.RenderableParticle,D++,y=P,y.x=A.x/A.w,y.y=A.y/A.w,y.z=A.z,y.rotation=R.rotation.z,y.scale.x=R.scale.x*Math.abs(y.x-(A.x+f.projectionMatrix.n11)/(A.w+
  149. f.projectionMatrix.n14)),y.scale.y=R.scale.y*Math.abs(y.y-(A.y+f.projectionMatrix.n22)/(A.w+f.projectionMatrix.n24)),y.materials=R.materials,h.push(y);g&&h.sort(c);return h}};
  150. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,d,e,g,h;this.domElement=document.createElement("div");this.setSize=function(b,c){d=b;e=c;g=d/2;h=e/2};this.render=function(d,e){var m,n,o,t,u,p,v,C;b=c.projectScene(d,e);m=0;for(n=b.length;m<n;m++)if(u=b[m],u instanceof THREE.RenderableParticle){v=u.x*g+g;C=u.y*h+h;o=0;for(t=u.material.length;o<t;o++)if(p=u.material[o],p instanceof THREE.ParticleDOMMaterial)p=p.domElement,p.style.left=v+"px",p.style.top=C+"px"}}};
  151. THREE.CanvasRenderer=function(b){function c(b){if(y!=b)v.globalAlpha=y=b}function d(b){if(D!=b){switch(b){case THREE.NormalBlending:v.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:v.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:v.globalCompositeOperation="darker"}D=b}}function e(b){if(x!=b.hex)x=b.hex,v.strokeStyle="#"+h(x.toString(16))}function g(b){if(I!=b.hex)I=b.hex,v.fillStyle="#"+h(I.toString(16))}function h(b){for(;b.length<6;)b="0"+b;return b}
  152. var j=this,k=null,m=new THREE.Projector,b=b||{},n=b.canvas!==void 0?b.canvas:document.createElement("canvas"),o,t,u,p,v=n.getContext("2d"),C=new THREE.Color(0),E=0,y=1,D=0,x=null,I=null,A=null,z=null,S=null,G,M,F,N,f=new THREE.RenderableVertex,Y=new THREE.RenderableVertex,O,V,L,$,T,Q,fa,U,ka,ga,ca,aa,R=new THREE.Color(0),P=new THREE.Color(0),W=new THREE.Color(0),X=new THREE.Color(0),ea=new THREE.Color(0),ha,J,da,la,ma,ya,va,Z,K,wa,ra=new THREE.Rectangle,ia=new THREE.Rectangle,qa=new THREE.Rectangle,
  153. Sa=!1,na=new THREE.Color,sa=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,oa=new THREE.Vector3,Ja,Ka,Ta,ta,La,Oa,b=16;Ja=document.createElement("canvas");Ja.width=Ja.height=2;Ka=Ja.getContext("2d");Ka.fillStyle="rgba(0,0,0,1)";Ka.fillRect(0,0,2,2);Ta=Ka.getImageData(0,0,2,2);ta=Ta.data;La=document.createElement("canvas");La.width=La.height=b;Oa=La.getContext("2d");Oa.translate(-b/2,-b/2);Oa.scale(b,b);b--;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,
  154. faces:0};this.setSize=function(b,d){o=b;t=d;u=o/2;p=t/2;n.width=o;n.height=t;ra.set(-u,-p,u,p);y=1;D=0;S=z=A=I=x=null};this.setClearColor=function(b,d){C=b;E=d};this.setClearColorHex=function(b,d){C.setHex(b);E=d};this.clear=function(){v.setTransform(1,0,0,-1,u,p);if(!ia.isEmpty())ia.inflate(1),ia.minSelf(ra),C.hex==0&&E==0?v.clearRect(ia.getX(),ia.getY(),ia.getWidth(),ia.getHeight()):(d(THREE.NormalBlending),c(1),v.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*
  155. 255)+","+E+")",v.fillRect(ia.getX(),ia.getY(),ia.getWidth(),ia.getHeight())),ia.empty()};this.render=function(b,h){function n(b){var d,c,f,e=b.lights;sa.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);b=0;for(d=e.length;b<d;b++)c=e[b],f=c.color,c instanceof THREE.AmbientLight?(sa.r+=f.r,sa.g+=f.g,sa.b+=f.b):c instanceof THREE.DirectionalLight?(Ma.r+=f.r,Ma.g+=f.g,Ma.b+=f.b):c instanceof THREE.PointLight&&(Na.r+=f.r,Na.g+=f.g,Na.b+=f.b)}function o(b,d,c,f){var e,h,g,j,k=b.lights,b=0;for(e=k.length;b<
  156. e;b++)h=k[b],g=h.color,h instanceof THREE.DirectionalLight?(j=c.dot(h.position),j<=0||(j*=h.intensity,f.r+=g.r*j,f.g+=g.g*j,f.b+=g.b*j)):h instanceof THREE.PointLight&&(j=c.dot(oa.sub(h.position,d).normalize()),j<=0||(j*=h.distance==0?1:1-Math.min(d.distanceTo(h.position)/h.distance,1),j!=0&&(j*=h.intensity,f.r+=g.r*j,f.g+=g.g*j,f.b+=g.b*j)))}function t(b,f,h){c(h.opacity);d(h.blending);var j,k,ia,m,o,n;if(h instanceof THREE.ParticleBasicMaterial){if(h.map)m=h.map.image,o=m.width>>1,n=m.height>>1,
  157. h=f.scale.x*u,ia=f.scale.y*p,j=h*o,k=ia*n,qa.set(b.x-j,b.y-k,b.x+j,b.y+k),ra.instersects(qa)&&(v.save(),v.translate(b.x,b.y),v.rotate(-f.rotation),v.scale(h,-ia),v.translate(-o,-n),v.drawImage(m,0,0),v.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(j=f.scale.x*u,k=f.scale.y*p,qa.set(b.x-j,b.y-k,b.x+j,b.y+k),ra.instersects(qa)&&(e(h.color),g(h.color),v.save(),v.translate(b.x,b.y),v.rotate(-f.rotation),v.scale(j,k),h.program(v),v.restore()))}function y(b,f,h,g){c(g.opacity);d(g.blending);
  158. v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(f.positionScreen.x,f.positionScreen.y);v.closePath();if(g instanceof THREE.LineBasicMaterial){b=g.linewidth;if(A!=b)v.lineWidth=A=b;b=g.linecap;if(z!=b)v.lineCap=z=b;b=g.linejoin;if(S!=b)v.lineJoin=S=b;e(g.color);v.stroke();qa.inflate(g.linewidth*2)}}function x(b,f,e,g,k,ia,m,n,p){j.data.vertices+=3;j.data.faces++;c(n.opacity);d(n.blending);O=b.positionScreen.x;V=b.positionScreen.y;L=f.positionScreen.x;$=f.positionScreen.y;T=e.positionScreen.x;
  159. Q=e.positionScreen.y;E(O,V,L,$,T,Q);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(la=m.uvs[0],w(O,V,L,$,T,Q,n.map.image,la[g].u,la[g].v,la[k].u,la[k].v,la[ia].u,la[ia].v));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=h.matrixWorldInverse,oa.copy(m.vertexNormalsWorld[0]),ma=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,ya=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(m.vertexNormalsWorld[1]),va=(oa.x*b.n11+oa.y*
  160. b.n12+oa.z*b.n13)*0.5+0.5,Z=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(m.vertexNormalsWorld[2]),K=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,wa=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,w(O,V,L,$,T,Q,n.envMap.image,ma,ya,va,Z,K,wa)}else n.wireframe?B(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(n.color);else if(n instanceof THREE.MeshLambertMaterial)n.map&&!n.wireframe&&(n.map.mapping instanceof THREE.UVMapping&&(la=m.uvs[0],w(O,V,L,$,T,Q,n.map.image,la[g].u,la[g].v,
  161. la[k].u,la[k].v,la[ia].u,la[ia].v)),d(THREE.SubtractiveBlending)),Sa?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(P.r=W.r=X.r=sa.r,P.g=W.g=X.g=sa.g,P.b=W.b=X.b=sa.b,o(p,m.v1.positionWorld,m.vertexNormalsWorld[0],P),o(p,m.v2.positionWorld,m.vertexNormalsWorld[1],W),o(p,m.v3.positionWorld,m.vertexNormalsWorld[2],X),ea.r=(W.r+X.r)*0.5,ea.g=(W.g+X.g)*0.5,ea.b=(W.b+X.b)*0.5,da=Pa(P,W,X,ea),w(O,V,L,$,T,Q,da,0,0,1,0,0,1)):(na.r=sa.r,na.g=sa.g,na.b=sa.b,o(p,m.centroidWorld,
  162. m.normalWorld,na),R.r=Math.max(0,Math.min(n.color.r*na.r,1)),R.g=Math.max(0,Math.min(n.color.g*na.g,1)),R.b=Math.max(0,Math.min(n.color.b*na.b,1)),R.updateHex(),n.wireframe?B(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(R)):n.wireframe?B(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(n.color);else if(n instanceof THREE.MeshDepthMaterial)ha=h.near,J=h.far,P.r=P.g=P.b=1-Ca(b.positionScreen.z,ha,J),W.r=W.g=W.b=1-Ca(f.positionScreen.z,ha,J),X.r=X.g=X.b=1-Ca(e.positionScreen.z,
  163. ha,J),ea.r=(W.r+X.r)*0.5,ea.g=(W.g+X.g)*0.5,ea.b=(W.b+X.b)*0.5,da=Pa(P,W,X,ea),w(O,V,L,$,T,Q,da,0,0,1,0,0,1);else if(n instanceof THREE.MeshNormalMaterial)R.r=Ha(m.normalWorld.x),R.g=Ha(m.normalWorld.y),R.b=Ha(m.normalWorld.z),R.updateHex(),n.wireframe?B(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(R)}function C(b,f,e,g,k,ia,m,n,p){j.data.vertices+=4;j.data.faces++;c(n.opacity);d(n.blending);if(n.map||n.envMap)x(b,f,g,0,1,3,m,n,p),x(k,e,ia,1,2,3,m,n,p);else if(O=b.positionScreen.x,
  164. V=b.positionScreen.y,L=f.positionScreen.x,$=f.positionScreen.y,T=e.positionScreen.x,Q=e.positionScreen.y,fa=g.positionScreen.x,U=g.positionScreen.y,ka=k.positionScreen.x,ga=k.positionScreen.y,ca=ia.positionScreen.x,aa=ia.positionScreen.y,n instanceof THREE.MeshBasicMaterial)I(O,V,L,$,T,Q,fa,U),n.wireframe?B(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(n.color);else if(n instanceof THREE.MeshLambertMaterial)Sa?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==
  165. 4?(P.r=W.r=X.r=ea.r=sa.r,P.g=W.g=X.g=ea.g=sa.g,P.b=W.b=X.b=ea.b=sa.b,o(p,m.v1.positionWorld,m.vertexNormalsWorld[0],P),o(p,m.v2.positionWorld,m.vertexNormalsWorld[1],W),o(p,m.v4.positionWorld,m.vertexNormalsWorld[3],X),o(p,m.v3.positionWorld,m.vertexNormalsWorld[2],ea),da=Pa(P,W,X,ea),E(O,V,L,$,fa,U),w(O,V,L,$,fa,U,da,0,0,1,0,0,1),E(ka,ga,T,Q,ca,aa),w(ka,ga,T,Q,ca,aa,da,1,0,1,1,0,1)):(na.r=sa.r,na.g=sa.g,na.b=sa.b,o(p,m.centroidWorld,m.normalWorld,na),R.r=Math.max(0,Math.min(n.color.r*na.r,1)),R.g=
  166. Math.max(0,Math.min(n.color.g*na.g,1)),R.b=Math.max(0,Math.min(n.color.b*na.b,1)),R.updateHex(),I(O,V,L,$,T,Q,fa,U),n.wireframe?B(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(R)):(I(O,V,L,$,T,Q,fa,U),n.wireframe?B(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):D(n.color));else if(n instanceof THREE.MeshNormalMaterial)R.r=Ha(m.normalWorld.x),R.g=Ha(m.normalWorld.y),R.b=Ha(m.normalWorld.z),R.updateHex(),I(O,V,L,$,T,Q,fa,U),n.wireframe?B(R,n.wireframeLinewidth,
  167. n.wireframeLinecap,n.wireframeLinejoin):D(R);else if(n instanceof THREE.MeshDepthMaterial)ha=h.near,J=h.far,P.r=P.g=P.b=1-Ca(b.positionScreen.z,ha,J),W.r=W.g=W.b=1-Ca(f.positionScreen.z,ha,J),X.r=X.g=X.b=1-Ca(g.positionScreen.z,ha,J),ea.r=ea.g=ea.b=1-Ca(e.positionScreen.z,ha,J),da=Pa(P,W,X,ea),E(O,V,L,$,fa,U),w(O,V,L,$,fa,U,da,0,0,1,0,0,1),E(ka,ga,T,Q,ca,aa),w(ka,ga,T,Q,ca,aa,da,1,0,1,1,0,1)}function E(b,d,c,f,e,h){v.beginPath();v.moveTo(b,d);v.lineTo(c,f);v.lineTo(e,h);v.lineTo(b,d);v.closePath()}
  168. function I(b,d,c,f,e,h,g,j){v.beginPath();v.moveTo(b,d);v.lineTo(c,f);v.lineTo(e,h);v.lineTo(g,j);v.lineTo(b,d);v.closePath()}function B(b,d,c,f){if(A!=d)v.lineWidth=A=d;if(z!=c)v.lineCap=z=c;if(S!=f)v.lineJoin=S=f;e(b);v.stroke();qa.inflate(d*2)}function D(b){g(b);v.fill()}function w(b,d,c,f,e,h,g,j,k,ia,n,m,o){var p,na;p=g.width-1;na=g.height-1;j*=p;k*=na;ia*=p;n*=na;m*=p;o*=na;c-=b;f-=d;e-=b;h-=d;ia-=j;n-=k;m-=j;o-=k;p=ia*o-m*n;p!=0&&(na=1/p,p=(o*c-n*e)*na,n=(o*f-n*h)*na,c=(ia*e-m*c)*na,f=(ia*
  169. h-m*f)*na,b=b-p*j-c*k,d=d-n*j-f*k,v.save(),v.transform(p,n,c,f,b,d),v.clip(),v.drawImage(g,0,0),v.restore())}function Pa(b,d,c,f){var e=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),g=~~(d.r*255),j=~~(d.g*255),d=~~(d.b*255),k=~~(c.r*255),ia=~~(c.g*255),c=~~(c.b*255),n=~~(f.r*255),m=~~(f.g*255),f=~~(f.b*255);ta[0]=e<0?0:e>255?255:e;ta[1]=h<0?0:h>255?255:h;ta[2]=b<0?0:b>255?255:b;ta[4]=g<0?0:g>255?255:g;ta[5]=j<0?0:j>255?255:j;ta[6]=d<0?0:d>255?255:d;ta[8]=k<0?0:k>255?255:k;ta[9]=ia<0?0:ia>255?255:ia;ta[10]=
  170. c<0?0:c>255?255:c;ta[12]=n<0?0:n>255?255:n;ta[13]=m<0?0:m>255?255:m;ta[14]=f<0?0:f>255?255:f;Ka.putImageData(Ta,0,0);Oa.drawImage(Ja,0,0);return La}function Ca(b,d,c){b=(b-d)/(c-d);return b*b*(3-2*b)}function Ha(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function za(b,d){var c=d.x-b.x,f=d.y-b.y,e=1/Math.sqrt(c*c+f*f);c*=e;f*=e;d.x+=c;d.y+=f;b.x-=c;b.y-=f}var Qa,Ya,ja,ua,Aa,Ia,Ra,H;this.autoClear?this.clear():v.setTransform(1,0,0,-1,u,p);j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,h,this.sortElements);
  171. (Sa=b.lights.length>0)&&n(b);Qa=0;for(Ya=k.length;Qa<Ya;Qa++){ja=k[Qa];qa.empty();if(ja instanceof THREE.RenderableParticle){G=ja;G.x*=u;G.y*=p;ua=0;for(Aa=ja.materials.length;ua<Aa;)H=ja.materials[ua++],H.opacity!=0&&t(G,ja,H,b)}else if(ja instanceof THREE.RenderableLine){if(G=ja.v1,M=ja.v2,G.positionScreen.x*=u,G.positionScreen.y*=p,M.positionScreen.x*=u,M.positionScreen.y*=p,qa.addPoint(G.positionScreen.x,G.positionScreen.y),qa.addPoint(M.positionScreen.x,M.positionScreen.y),ra.instersects(qa)){ua=
  172. 0;for(Aa=ja.materials.length;ua<Aa;)H=ja.materials[ua++],H.opacity!=0&&y(G,M,ja,H,b)}}else if(ja instanceof THREE.RenderableFace3){if(G=ja.v1,M=ja.v2,F=ja.v3,G.positionScreen.x*=u,G.positionScreen.y*=p,M.positionScreen.x*=u,M.positionScreen.y*=p,F.positionScreen.x*=u,F.positionScreen.y*=p,ja.overdraw&&(za(G.positionScreen,M.positionScreen),za(M.positionScreen,F.positionScreen),za(F.positionScreen,G.positionScreen)),qa.add3Points(G.positionScreen.x,G.positionScreen.y,M.positionScreen.x,M.positionScreen.y,
  173. F.positionScreen.x,F.positionScreen.y),ra.instersects(qa)){ua=0;for(Aa=ja.meshMaterials.length;ua<Aa;)if(H=ja.meshMaterials[ua++],H instanceof THREE.MeshFaceMaterial){Ia=0;for(Ra=ja.faceMaterials.length;Ia<Ra;)(H=ja.faceMaterials[Ia++])&&H.opacity!=0&&x(G,M,F,0,1,2,ja,H,b)}else H.opacity!=0&&x(G,M,F,0,1,2,ja,H,b)}}else if(ja instanceof THREE.RenderableFace4&&(G=ja.v1,M=ja.v2,F=ja.v3,N=ja.v4,G.positionScreen.x*=u,G.positionScreen.y*=p,M.positionScreen.x*=u,M.positionScreen.y*=p,F.positionScreen.x*=
  174. u,F.positionScreen.y*=p,N.positionScreen.x*=u,N.positionScreen.y*=p,f.positionScreen.copy(M.positionScreen),Y.positionScreen.copy(N.positionScreen),ja.overdraw&&(za(G.positionScreen,M.positionScreen),za(M.positionScreen,N.positionScreen),za(N.positionScreen,G.positionScreen),za(F.positionScreen,f.positionScreen),za(F.positionScreen,Y.positionScreen)),qa.addPoint(G.positionScreen.x,G.positionScreen.y),qa.addPoint(M.positionScreen.x,M.positionScreen.y),qa.addPoint(F.positionScreen.x,F.positionScreen.y),
  175. qa.addPoint(N.positionScreen.x,N.positionScreen.y),ra.instersects(qa))){ua=0;for(Aa=ja.meshMaterials.length;ua<Aa;)if(H=ja.meshMaterials[ua++],H instanceof THREE.MeshFaceMaterial){Ia=0;for(Ra=ja.faceMaterials.length;Ia<Ra;)(H=ja.faceMaterials[Ia++])&&H.opacity!=0&&C(G,M,F,N,f,Y,ja,H,b)}else H.opacity!=0&&C(G,M,F,N,f,Y,ja,H,b)}ia.addRectangle(qa)}v.setTransform(1,0,0,1,0,0)}};
  176. THREE.SVGRenderer=function(){function b(b,d,c){var f,e,h,g;f=0;for(e=b.lights.length;f<e;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(g=d.normalWorld.dot(h.position)*h.intensity,g>0&&(c.r+=h.color.r*g,c.g+=h.color.g*g,c.b+=h.color.b*g)):h instanceof THREE.PointLight&&(N.sub(h.position,d.centroidWorld),N.normalize(),g=d.normalWorld.dot(N)*h.intensity,g>0&&(c.r+=h.color.r*g,c.g+=h.color.g*g,c.b+=h.color.b*g))}function c(d,c,f,k,m,o){j.data.vertices+=3;j.data.faces++;O=e(V++);O.setAttribute("d",
  177. "M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+f.positionScreen.x+","+f.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?A.hex=m.color.hex:m instanceof THREE.MeshLambertMaterial?I?(z.r=S.r,z.g=S.g,z.b=S.b,b(o,k,z),A.r=Math.max(0,Math.min(m.color.r*z.r,1)),A.g=Math.max(0,Math.min(m.color.g*z.g,1)),A.b=Math.max(0,Math.min(m.color.b*z.b,1)),A.updateHex()):A.hex=m.color.hex:m instanceof THREE.MeshDepthMaterial?(F=1-m.__2near/(m.__farPlusNear-
  178. k.z*m.__farMinusNear),A.setRGB(F,F,F)):m instanceof THREE.MeshNormalMaterial&&A.setRGB(g(k.normalWorld.x),g(k.normalWorld.y),g(k.normalWorld.z));m.wireframe?O.setAttribute("style","fill: none; stroke: #"+h(A.hex.toString(16))+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):O.setAttribute("style","fill: #"+h(A.hex.toString(16))+"; fill-opacity: "+m.opacity);n.appendChild(O)}function d(d,c,f,k,
  179. m,o,p){j.data.vertices+=4;j.data.faces++;O=e(V++);O.setAttribute("d","M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+f.positionScreen.x+","+f.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");o instanceof THREE.MeshBasicMaterial?A.hex=o.color.hex:o instanceof THREE.MeshLambertMaterial?I?(z.r=S.r,z.g=S.g,z.b=S.b,b(p,m,z),A.r=Math.max(0,Math.min(o.color.r*z.r,1)),A.g=Math.max(0,Math.min(o.color.g*z.g,1)),A.b=Math.max(0,Math.min(o.color.b*
  180. z.b,1)),A.updateHex()):A.hex=o.color.hex:o instanceof THREE.MeshDepthMaterial?(F=1-o.__2near/(o.__farPlusNear-m.z*o.__farMinusNear),A.setRGB(F,F,F)):o instanceof THREE.MeshNormalMaterial&&A.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));o.wireframe?O.setAttribute("style","fill: none; stroke: #"+h(A.hex.toString(16))+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):O.setAttribute("style",
  181. "fill: #"+h(A.hex.toString(16))+"; fill-opacity: "+o.opacity);n.appendChild(O)}function e(b){f[b]==null&&(f[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),$==0&&f[b].setAttribute("shape-rendering","crispEdges"));return f[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function h(b){for(;b.length<6;)b="0"+b;return b}var j=this,k=null,m=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,u,p,v,C,E,y,D=new THREE.Rectangle,x=new THREE.Rectangle,I=
  182. !1,A=new THREE.Color(16777215),z=new THREE.Color(16777215),S=new THREE.Color(0),G=new THREE.Color(0),M=new THREE.Color(0),F,N=new THREE.Vector3,f=[],Y=[],O,V,L,$=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":$=1;break;case "low":$=0}};this.setSize=function(b,d){o=b;t=d;u=o/2;p=t/2;n.setAttribute("viewBox",-u+" "+-p+" "+o+" "+t);n.setAttribute("width",o);n.setAttribute("height",t);D.set(-u,-p,
  183. u,p)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(b,f){var e,g,o,t,z,A,F,P;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,f,this.sortElements);L=V=0;if(I=b.lights.length>0){F=b.lights;S.setRGB(0,0,0);G.setRGB(0,0,0);M.setRGB(0,0,0);e=0;for(g=F.length;e<g;e++)o=F[e],t=o.color,o instanceof THREE.AmbientLight?(S.r+=t.r,S.g+=t.g,S.b+=t.b):o instanceof THREE.DirectionalLight?(G.r+=t.r,G.g+=t.g,G.b+=t.b):o instanceof
  184. THREE.PointLight&&(M.r+=t.r,M.g+=t.g,M.b+=t.b)}e=0;for(g=k.length;e<g;e++)if(F=k[e],x.empty(),F instanceof THREE.RenderableParticle){v=F;v.x*=u;v.y*=-p;o=0;for(t=F.materials.length;o<t;)o++}else if(F instanceof THREE.RenderableLine){if(v=F.v1,C=F.v2,v.positionScreen.x*=u,v.positionScreen.y*=-p,C.positionScreen.x*=u,C.positionScreen.y*=-p,x.addPoint(v.positionScreen.x,v.positionScreen.y),x.addPoint(C.positionScreen.x,C.positionScreen.y),D.instersects(x)){o=0;for(t=F.materials.length;o<t;)if((P=F.materials[o++])&&
  185. P.opacity!=0){z=v;A=C;var N=L++;Y[N]==null&&(Y[N]=document.createElementNS("http://www.w3.org/2000/svg","line"),$==0&&Y[N].setAttribute("shape-rendering","crispEdges"));O=Y[N];O.setAttribute("x1",z.positionScreen.x);O.setAttribute("y1",z.positionScreen.y);O.setAttribute("x2",A.positionScreen.x);O.setAttribute("y2",A.positionScreen.y);P instanceof THREE.LineBasicMaterial&&(O.setAttribute("style","fill: none; stroke: ##"+h(P.color.hex.toString(16))+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+
  186. P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin),n.appendChild(O))}}}else if(F instanceof THREE.RenderableFace3){if(v=F.v1,C=F.v2,E=F.v3,v.positionScreen.x*=u,v.positionScreen.y*=-p,C.positionScreen.x*=u,C.positionScreen.y*=-p,E.positionScreen.x*=u,E.positionScreen.y*=-p,x.addPoint(v.positionScreen.x,v.positionScreen.y),x.addPoint(C.positionScreen.x,C.positionScreen.y),x.addPoint(E.positionScreen.x,E.positionScreen.y),D.instersects(x)){o=0;for(t=F.meshMaterials.length;o<
  187. t;)if(P=F.meshMaterials[o++],P instanceof THREE.MeshFaceMaterial){z=0;for(A=F.faceMaterials.length;z<A;)(P=F.faceMaterials[z++])&&P.opacity!=0&&c(v,C,E,F,P,b)}else P&&P.opacity!=0&&c(v,C,E,F,P,b)}}else if(F instanceof THREE.RenderableFace4&&(v=F.v1,C=F.v2,E=F.v3,y=F.v4,v.positionScreen.x*=u,v.positionScreen.y*=-p,C.positionScreen.x*=u,C.positionScreen.y*=-p,E.positionScreen.x*=u,E.positionScreen.y*=-p,y.positionScreen.x*=u,y.positionScreen.y*=-p,x.addPoint(v.positionScreen.x,v.positionScreen.y),x.addPoint(C.positionScreen.x,
  188. C.positionScreen.y),x.addPoint(E.positionScreen.x,E.positionScreen.y),x.addPoint(y.positionScreen.x,y.positionScreen.y),D.instersects(x))){o=0;for(t=F.meshMaterials.length;o<t;)if(P=F.meshMaterials[o++],P instanceof THREE.MeshFaceMaterial){z=0;for(A=F.faceMaterials.length;z<A;)(P=F.faceMaterials[z++])&&P.opacity!=0&&d(v,C,E,y,F,P,b)}else P&&P.opacity!=0&&d(v,C,E,y,F,P,b)}}};
  189. THREE.ShaderChunk={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",
  190. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, 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 refractionRatio;\nuniform bool useRefract;\n#endif",
  191. 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 ), refractionRatio );\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",
  192. 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 lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
  193. lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, 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 ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
  194. 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 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef PHONG\nvPointLight[ i ] = vec4( lVector, lDistance );\n#endif\n}\n#endif\n}",
  195. lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ 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( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\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 * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\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;",
  196. 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[ MAX_BONES ];\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 * viewMatrix * objectMatrix * gl_Position;\n#endif",
  197. morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
  198. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var c,d,e,g={};for(c=0;c<b.length;c++)for(d in e=this.clone(b[c]),e)g[d]=e[d];return g},clone:function(b){var c,d,e,g={};for(c in b)for(d in g[c]={},b[c])e=b[c][d],g[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e;return g}};
  199. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{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)},morphTargetInfluences:{type:"f",
  200. value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},
  201. fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  202. THREE.ShaderLib={lensFlareVertexTexture:{vertexShader:"uniform \tvec3 \tscreenPosition;\nuniform\tvec2\tscale;\nuniform\tfloat\trotation;\nuniform int renderType;\nuniform\tsampler2D\tocclusionMap;\nattribute \tvec2 \tposition;\nattribute vec2\tUV;\nvarying\tvec2\tvUV;\nvarying\tfloat\tvVisibility;\nvoid main(void)\n{\nvUV = UV;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 )) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 )) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 )) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 )) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 )) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 )) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 )) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 )) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ));\nvVisibility = ( visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n( visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4(( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform\tsampler2D\tmap;\nuniform\tfloat\t\topacity;\nuniform int renderType;\nvarying\tvec2\t\tvUV;\nvarying\tfloat\t\tvVisibility;\nvoid main( void )\n{\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity * vVisibility;\ngl_FragColor = color;\n}\n}"},
  203. lensFlare:{vertexShader:"uniform \tvec3 \tscreenPosition;\nuniform\tvec2\tscale;\nuniform\tfloat\trotation;\nuniform int renderType;\nattribute \tvec2 \tposition;\nattribute vec2\tUV;\nvarying\tvec2\tvUV;\nvoid main(void)\n{\nvUV = UV;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4(( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
  204. fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform\tsampler2D\tmap;\nuniform\tsampler2D\tocclusionMap;\nuniform\tfloat\t\topacity;\nuniform int renderType;\nvarying\tvec2\t\tvUV;\nvoid main( void )\n{\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 )).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 )).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 )).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 )).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity * visibility;\ngl_FragColor = color;\n}\n}"},
  205. sprite:{vertexShader:"uniform\tint\t\tuseScreenCoordinates;\nuniform int affectedByDistance;\nuniform\tvec3\tscreenPosition;\nuniform \tmat4 \tmodelViewMatrix;\nuniform \tmat4 \tprojectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform\tvec2 uvScale;\nattribute \tvec2 \tposition;\nattribute vec2\tuv;\nvarying\tvec2\tvUV;\nvoid main(void)\n{\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
  206. fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform\tsampler2D\tmap;\nuniform\tfloat\t\topacity;\nvarying\tvec2\t\tvUV;\nvoid main( void )\n{\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity;\ngl_FragColor = color;\n}"},shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main(void)\n{\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform \tfloat \tdarkness;\nvoid main( void )\n{\ngl_FragColor = vec4( 0, 0, 0, darkness );\n}"},
  207. shadowVolumeDynamic:{uniforms:{directionalLightDirection:{type:"fv",value:[]}},vertexShader:"uniform \tvec3 \tdirectionalLightDirection;\nvoid main() {\nvec4 pos = objectMatrix * vec4( position, 1.0 );\nvec3 norm = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 extruded = vec4( directionalLightDirection * 5000.0 * step( 0.0, dot( directionalLightDirection, norm )), 0.0 );\ngl_Position = projectionMatrix * viewMatrix * ( pos + extruded );\n}",fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0 );\n}"},
  208. depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"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}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",value:1}},
  209. fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
  210. THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,
  211. THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
  212. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
  213. THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  214. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),
  215. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,
  216. THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,
  217. "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
  218. THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
  219. THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
  220. THREE.WebGLRenderer=function(b){function c(b,d,c){var e,h,g,j=b.vertices,k=j.length,m=b.colors,n=m.length,o=b.__vertexArray,p=b.__colorArray,t=b.__sortArray,u=b.__dirtyVertices,v=b.__dirtyColors;if(c.sortParticles){R.multiplySelf(c.matrixWorld);for(e=0;e<k;e++)h=j[e].position,X.copy(h),R.multiplyVector3(X),t[e]=[X.z,e];t.sort(function(b,d){return d[0]-b[0]});for(e=0;e<k;e++)h=j[t[e][1]].position,g=e*3,o[g]=h.x,o[g+1]=h.y,o[g+2]=h.z;for(e=0;e<n;e++)g=e*3,color=m[t[e][1]],p[g]=color.r,p[g+1]=color.g,
  221. p[g+2]=color.b}else{if(u)for(e=0;e<k;e++)h=j[e].position,g=e*3,o[g]=h.x,o[g+1]=h.y,o[g+2]=h.z;if(v)for(e=0;e<n;e++)color=m[e],g=e*3,p[g]=color.r,p[g+1]=color.g,p[g+2]=color.b}if(u||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,o,d);if(v||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,b.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,p,d)}function d(b,d,c,e,g){e.program||N.initMaterial(e,d,c,g);var h=e.program,j=h.uniforms,k=e.uniforms;h!=O&&(f.useProgram(h),
  222. O=h);f.uniformMatrix4fv(j.projectionMatrix,!1,P);if(c&&(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial||e instanceof THREE.LineBasicMaterial||e instanceof THREE.ParticleBasicMaterial||e.fog))if(k.fogColor.value=c.color,c instanceof THREE.Fog)k.fogNear.value=c.near,k.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){var m,
  223. n,o=0,p=0,t=0,u,v,y,x,E=ea,C=E.directional.colors,F=E.directional.positions,D=E.point.colors,I=E.point.positions,J=E.point.distances,G=0,B=0,c=n=x=0;for(m=d.length;c<m;c++)if(n=d[c],u=n.color,v=n.position,y=n.intensity,x=n.distance,n instanceof THREE.AmbientLight)o+=u.r,p+=u.g,t+=u.b;else if(n instanceof THREE.DirectionalLight)x=G*3,C[x]=u.r*y,C[x+1]=u.g*y,C[x+2]=u.b*y,F[x]=v.x,F[x+1]=v.y,F[x+2]=v.z,G+=1;else if(n instanceof THREE.PointLight)n=B*3,D[n]=u.r*y,D[n+1]=u.g*y,D[n+2]=u.b*y,I[n]=v.x,I[n+
  224. 1]=v.y,I[n+2]=v.z,J[B]=x,B+=1;for(c=G*3;c<C.length;c++)C[c]=0;for(c=B*3;c<D.length;c++)D[c]=0;E.point.length=B;E.directional.length=G;E.ambient[0]=o;E.ambient[1]=p;E.ambient[2]=t;c=ea;k.enableLighting.value=c.directional.length+c.point.length;k.ambientLightColor.value=c.ambient;k.directionalLightColor.value=c.directional.colors;k.directionalLightDirection.value=c.directional.positions;k.pointLightColor.value=c.point.colors;k.pointLightPosition.value=c.point.positions;k.pointLightDistance.value=c.point.distances}if(e instanceof
  225. THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)k.diffuse.value=e.color,k.opacity.value=e.opacity,k.map.texture=e.map,k.lightMap.texture=e.lightMap,k.envMap.texture=e.envMap,k.reflectivity.value=e.reflectivity,k.refractionRatio.value=e.refractionRatio,k.combine.value=e.combine,k.useRefract.value=e.envMap&&e.envMap.mapping instanceof THREE.CubeRefractionMapping;if(e instanceof THREE.LineBasicMaterial)k.diffuse.value=e.color,k.opacity.value=e.opacity;
  226. else if(e instanceof THREE.ParticleBasicMaterial)k.psColor.value=e.color,k.opacity.value=e.opacity,k.size.value=e.size,k.scale.value=ha.height/2,k.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)k.ambient.value=e.ambient,k.specular.value=e.specular,k.shininess.value=e.shininess;else if(e instanceof THREE.MeshDepthMaterial)k.mNear.value=b.near,k.mFar.value=b.far,k.opacity.value=e.opacity;else if(e instanceof THREE.MeshNormalMaterial)k.opacity.value=e.opacity;for(var Xa in k)if(p=h.uniforms[Xa])if(m=
  227. k[Xa],o=m.type,c=m.value,o=="i")f.uniform1i(p,c);else if(o=="f")f.uniform1f(p,c);else if(o=="fv1")f.uniform1fv(p,c);else if(o=="fv")f.uniform3fv(p,c);else if(o=="v2")f.uniform2f(p,c.x,c.y);else if(o=="v3")f.uniform3f(p,c.x,c.y,c.z);else if(o=="v4")f.uniform4f(p,c.x,c.y,c.z,c.w);else if(o=="c")f.uniform3f(p,c.r,c.g,c.b);else if(o=="t"&&(f.uniform1i(p,c),m=m.texture))if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(m.__webglInit){f.bindTexture(f.TEXTURE_CUBE_MAP,
  228. m.image.__webglTextureCube);for(o=0;o<6;++o)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,0,0,f.RGBA,f.UNSIGNED_BYTE,m.image[o])}else{m.image.__webglTextureCube=f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(o=0;o<6;++o)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,m.image[o]);m.__webglInit=!0}A(f.TEXTURE_CUBE_MAP,m,m.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}f.activeTexture(f.TEXTURE0+c);f.bindTexture(f.TEXTURE_CUBE_MAP,
  229. m.image.__webglTextureCube)}}else z(m,c);f.uniformMatrix4fv(j.modelViewMatrix,!1,g._modelViewMatrixArray);f.uniformMatrix3fv(j.normalMatrix,!1,g._normalMatrixArray);(e instanceof THREE.MeshShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&j.cameraPosition!==null&&f.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(e instanceof THREE.MeshShaderMaterial||e.envMap||e.skinning)&&j.objectMatrix!==null&&f.uniformMatrix4fv(j.objectMatrix,!1,g._objectMatrixArray);(e instanceof
  230. THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshShaderMaterial||e.skinning)&&j.viewMatrix!==null&&f.uniformMatrix4fv(j.viewMatrix,!1,W);if(e instanceof THREE.ShadowVolumeDynamicMaterial)b=k.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,f.uniform3fv(j.directionalLightDirection,b),f.uniformMatrix4fv(j.objectMatrix,!1,g._objectMatrixArray),f.uniformMatrix4fv(j.viewMatrix,!1,W);e.skinning&&(f.uniformMatrix4fv(j.cameraInverseMatrix,
  231. !1,W),f.uniformMatrix4fv(j.boneGlobalMatrices,!1,g.boneMatrices));return h}function e(b,c,e,g,h,j){if(g.opacity!=0){var k,b=d(b,c,e,g,j).attributes;if(!g.morphTargets&&b.position>=0)f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.vertexAttribPointer(b.position,3,f.FLOAT,!1,0,0);else{c=g.program.attributes;j.morphTargetBase!==-1?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0)):c.position>=0&&(f.bindBuffer(f.ARRAY_BUFFER,
  232. h.__webglVertexBuffer),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var e=0,m=j.morphTargetForcedOrder,n=j.morphTargetInfluences;e<g.numSupportedMorphTargets&&e<m.length;)f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m[e]]),f.vertexAttribPointer(c["morphTarget"+e],3,f.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[e]=n[m[e]],e++;else{var m=[],o=-1,p=0,n=j.morphTargetInfluences,t,u=n.length,e=0;for(j.morphTargetBase!==-1&&(m[j.morphTargetBase]=
  233. !0);e<g.numSupportedMorphTargets;){for(t=0;t<u;t++)!m[t]&&n[t]>o&&(p=t,o=n[p]);f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[p]);f.vertexAttribPointer(c["morphTarget"+e],3,f.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[e]=o;m[p]=1;o=-1;e++}}g.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(g.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(k in h.__webglCustomAttributes)b[k]>=0&&(c=h.__webglCustomAttributes[k],f.bindBuffer(f.ARRAY_BUFFER,
  234. c.buffer),f.vertexAttribPointer(b[k],c.size,f.FLOAT,!1,0,0));b.color>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));b.normal>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglNormalBuffer),f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));b.tangent>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglTangentBuffer),f.vertexAttribPointer(b.tangent,4,f.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUVBuffer),f.vertexAttribPointer(b.uv,
  235. 2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv)):f.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUV2Buffer),f.vertexAttribPointer(b.uv2,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv2)):f.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexABuffer),f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),
  236. f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0));j instanceof THREE.Mesh?(g.wireframe?(f.lineWidth(g.wireframeLinewidth),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),f.drawElements(f.LINES,h.__webglLineCount,f.UNSIGNED_SHORT,0)):(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,
  237. h.__webglFaceBuffer),f.drawElements(f.TRIANGLES,h.__webglFaceCount,f.UNSIGNED_SHORT,0)),N.data.vertices+=h.__webglFaceCount,N.data.faces+=h.__webglFaceCount/3,N.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?f.LINE_STRIP:f.LINES,f.lineWidth(g.linewidth),f.drawArrays(j,0,h.__webglLineCount),N.data.drawCalls++):j instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,h.__webglParticleCount),N.data.drawCalls++):j instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,h.__webglVertexCount),
  238. N.data.drawCalls++)}}function g(b,d,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=f.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=f.createBuffer();b.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,b.positionArray,f.DYNAMIC_DRAW),f.enableVertexAttribArray(d.attributes.position),f.vertexAttribPointer(d.attributes.position,3,f.FLOAT,!1,0,0));if(b.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var e,
  239. h,g,j,k,m,n,o,p,t,u=b.count*3;for(t=0;t<u;t+=9)c=b.normalArray,e=c[t],h=c[t+1],g=c[t+2],j=c[t+3],m=c[t+4],o=c[t+5],k=c[t+6],n=c[t+7],p=c[t+8],e=(e+j+k)/3,h=(h+m+n)/3,g=(g+o+p)/3,c[t]=e,c[t+1]=h,c[t+2]=g,c[t+3]=e,c[t+4]=h,c[t+5]=g,c[t+6]=e,c[t+7]=h,c[t+8]=g}f.bufferData(f.ARRAY_BUFFER,b.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(d.attributes.normal);f.vertexAttribPointer(d.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,b.count);b.count=0}function h(b){if($!=b.doubleSided)b.doubleSided?
  240. f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),$=b.doubleSided;if(T!=b.flipSided)b.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),T=b.flipSided}function j(b){fa!=b&&(b?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),fa=b)}function k(b){aa[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);aa[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);aa[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);aa[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);aa[4].set(b.n41-b.n31,b.n42-b.n32,
  241. b.n43-b.n33,b.n44-b.n34);aa[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var d,b=0;b<6;b++)d=aa[b],d.divideScalar(Math.sqrt(d.x*d.x+d.y*d.y+d.z*d.z))}function m(b){for(var d=b.matrixWorld,c=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),e=0;e<6;e++)if(b=aa[e].x*d.n14+aa[e].y*d.n24+aa[e].z*d.n34+aa[e].w,b<=c)return!1;return!0}function n(b,d){b.list[b.count]=d;b.count+=1}function o(b){var d,c,e=b.object,f=b.opaque,h=b.transparent;h.count=0;b=f.count=
  242. 0;for(d=e.materials.length;b<d;b++)c=e.materials[b],c.transparent?n(h,c):n(f,c)}function t(b){var d,c,e,f,h=b.object,g=b.buffer,j=b.opaque,k=b.transparent;k.count=0;b=j.count=0;for(e=h.materials.length;b<e;b++)if(d=h.materials[b],d instanceof THREE.MeshFaceMaterial){d=0;for(c=g.materials.length;d<c;d++)(f=g.materials[d])&&(f.transparent?n(k,f):n(j,f))}else(f=d)&&(f.transparent?n(k,f):n(j,f))}function u(b,d){return d.z-b.z}function p(b){f.enable(f.POLYGON_OFFSET_FILL);f.polygonOffset(0.1,1);f.enable(f.STENCIL_TEST);
  243. f.enable(f.DEPTH_TEST);f.depthMask(!1);f.colorMask(!1,!1,!1,!1);f.stencilFunc(f.ALWAYS,1,255);f.stencilOpSeparate(f.BACK,f.KEEP,f.INCR,f.KEEP);f.stencilOpSeparate(f.FRONT,f.KEEP,f.DECR,f.KEEP);var d,c=b.lights.length,e,h=b.lights,g=[],j,k,m,n,o,p=b.__webglShadowVolumes.length;for(d=0;d<c;d++)if(e=b.lights[d],e instanceof THREE.DirectionalLight&&e.castShadow){g[0]=-e.position.x;g[1]=-e.position.y;g[2]=-e.position.z;for(o=0;o<p;o++)e=b.__webglShadowVolumes[o].object,j=b.__webglShadowVolumes[o].buffer,
  244. k=e.materials[0],k.program||N.initMaterial(k,h,void 0,e),k=k.program,m=k.uniforms,n=k.attributes,O!==k&&(f.useProgram(k),O=k,f.uniformMatrix4fv(m.projectionMatrix,!1,P),f.uniformMatrix4fv(m.viewMatrix,!1,W),f.uniform3fv(m.directionalLightDirection,g)),e.matrixWorld.flattenToArray(e._objectMatrixArray),f.uniformMatrix4fv(m.objectMatrix,!1,e._objectMatrixArray),f.bindBuffer(f.ARRAY_BUFFER,j.__webglVertexBuffer),f.vertexAttribPointer(n.position,3,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,j.__webglNormalBuffer),
  245. f.vertexAttribPointer(n.normal,3,f.FLOAT,!1,0,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,j.__webglFaceBuffer),f.cullFace(f.FRONT),f.drawElements(f.TRIANGLES,j.__webglFaceCount,f.UNSIGNED_SHORT,0),f.cullFace(f.BACK),f.drawElements(f.TRIANGLES,j.__webglFaceCount,f.UNSIGNED_SHORT,0)}f.disable(f.POLYGON_OFFSET_FILL);f.colorMask(!0,!0,!0,!0);f.stencilFunc(f.NOTEQUAL,0,255);f.stencilOp(f.KEEP,f.KEEP,f.KEEP);f.disable(f.DEPTH_TEST);Q=-1;O=Z.program;f.useProgram(Z.program);f.uniformMatrix4fv(Z.projectionLocation,
  246. !1,P);f.uniform1f(Z.darknessLocation,Z.darkness);f.bindBuffer(f.ARRAY_BUFFER,Z.vertexBuffer);f.vertexAttribPointer(Z.vertexLocation,3,f.FLOAT,!1,0,0);f.enableVertexAttribArray(Z.vertexLocation);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.blendEquation(f.FUNC_ADD);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0);f.disable(f.STENCIL_TEST);f.enable(f.DEPTH_TEST);f.depthMask(L)}function v(b,d){var c,e,h;c=_sprite.attributes;var g=_sprite.uniforms,j=
  247. ca/ga,k,m=[],n=ga*0.5,o=ca*0.5,p=!0;f.useProgram(_sprite.program);O=_sprite.program;Q=-1;ra||(f.enableVertexAttribArray(_sprite.attributes.position),f.enableVertexAttribArray(_sprite.attributes.uv),ra=!0);f.disable(f.CULL_FACE);f.enable(f.BLEND);f.depthMask(!0);f.bindBuffer(f.ARRAY_BUFFER,_sprite.vertexBuffer);f.vertexAttribPointer(c.position,2,f.FLOAT,!1,16,0);f.vertexAttribPointer(c.uv,2,f.FLOAT,!1,16,8);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);f.uniformMatrix4fv(g.projectionMatrix,
  248. !1,P);f.activeTexture(f.TEXTURE0);f.uniform1i(g.map,0);c=0;for(e=b.__webglSprites.length;c<e;c++)h=b.__webglSprites[c],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(u);c=0;for(e=b.__webglSprites.length;c<e;c++)h=b.__webglSprites[c],h.material===void 0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(f.uniform1i(g.useScreenCoordinates,1),f.uniform3f(g.screenPosition,
  249. (h.position.x-n)/n,(o-h.position.y)/o,Math.max(0,Math.min(1,h.position.z)))):(f.uniform1i(g.useScreenCoordinates,0),f.uniform1i(g.affectedByDistance,h.affectedByDistance?1:0),f.uniformMatrix4fv(g.modelViewMatrix,!1,h._modelViewMatrixArray)),k=h.map.image.width/(h.affectedByDistance?1:ca),m[0]=k*j*h.scale.x,m[1]=k*h.scale.y,f.uniform2f(g.uvScale,h.uvScale.x,h.uvScale.y),f.uniform2f(g.uvOffset,h.uvOffset.x,h.uvOffset.y),f.uniform2f(g.alignment,h.alignment.x,h.alignment.y),f.uniform1f(g.opacity,h.opacity),
  250. f.uniform1f(g.rotation,h.rotation),f.uniform2fv(g.scale,m),h.mergeWith3D&&!p?(f.enable(f.DEPTH_TEST),p=!0):!h.mergeWith3D&&p&&(f.disable(f.DEPTH_TEST),p=!1),I(h.blending),z(h.map,0),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0));f.enable(f.CULL_FACE);f.enable(f.DEPTH_TEST);f.depthMask(L)}function C(b,d){var c,e,h=b.__webglLensFlares.length,g,j,k,m=new THREE.Vector3,n=ca/ga,o=ga*0.5,p=ca*0.5,t=16/ca,u=[t*n,t],v=[1,1,0],y=[1,1],x=K.uniforms;c=K.attributes;f.useProgram(K.program);O=K.program;Q=-1;
  251. wa||(f.enableVertexAttribArray(K.attributes.vertex),f.enableVertexAttribArray(K.attributes.uv),wa=!0);f.uniform1i(x.occlusionMap,0);f.uniform1i(x.map,1);f.bindBuffer(f.ARRAY_BUFFER,K.vertexBuffer);f.vertexAttribPointer(c.vertex,2,f.FLOAT,!1,16,0);f.vertexAttribPointer(c.uv,2,f.FLOAT,!1,16,8);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,K.elementBuffer);f.disable(f.CULL_FACE);f.depthMask(!1);f.activeTexture(f.TEXTURE0);f.bindTexture(f.TEXTURE_2D,K.occlusionTexture);f.activeTexture(f.TEXTURE1);for(e=0;e<h;e++)if(c=
  252. b.__webglLensFlares[e].object,m.set(c.matrixWorld.n14,c.matrixWorld.n24,c.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(m),d.projectionMatrix.multiplyVector3(m),v[0]=m.x,v[1]=m.y,v[2]=m.z,y[0]=v[0]*o+o,y[1]=v[1]*p+p,K.hasVertexTexture||y[0]>0&&y[0]<ga&&y[1]>0&&y[1]<ca){f.bindTexture(f.TEXTURE_2D,K.tempTexture);f.copyTexImage2D(f.TEXTURE_2D,0,f.RGB,y[0]-8,y[1]-8,16,16,0);f.uniform1i(x.renderType,0);f.uniform2fv(x.scale,u);f.uniform3fv(x.screenPosition,v);f.disable(f.BLEND);f.enable(f.DEPTH_TEST);
  253. f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0);f.bindTexture(f.TEXTURE_2D,K.occlusionTexture);f.copyTexImage2D(f.TEXTURE_2D,0,f.RGBA,y[0]-8,y[1]-8,16,16,0);f.uniform1i(x.renderType,1);f.disable(f.DEPTH_TEST);f.bindTexture(f.TEXTURE_2D,K.tempTexture);f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0);c.positionScreen.x=v[0];c.positionScreen.y=v[1];c.positionScreen.z=v[2];c.customUpdateCallback?c.customUpdateCallback(c):c.updateLensFlares();f.uniform1i(x.renderType,2);f.enable(f.BLEND);g=0;for(j=c.lensFlares.length;g<
  254. j;g++)if(k=c.lensFlares[g],k.opacity>0.001&&k.scale>0.001)v[0]=k.x,v[1]=k.y,v[2]=k.z,t=k.size*k.scale/ca,u[0]=t*n,u[1]=t,f.uniform3fv(x.screenPosition,v),f.uniform2fv(x.scale,u),f.uniform1f(x.rotation,k.rotation),f.uniform1f(x.opacity,k.opacity),I(k.blending),z(k.texture,1),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0)}f.enable(f.CULL_FACE);f.enable(f.DEPTH_TEST);f.depthMask(L)}function E(b,d){b._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}
  255. function y(b){var d,e,h,g,j;if(b instanceof THREE.Mesh){e=b.geometry;for(d in e.geometryGroups){h=e.geometryGroups[d];j=!1;for(g in h.__webglCustomAttributes)if(h.__webglCustomAttributes[g].needsUpdate){j=!0;break}if(e.__dirtyVertices||e.__dirtyMorphTargets||e.__dirtyElements||e.__dirtyUvs||e.__dirtyNormals||e.__dirtyColors||e.__dirtyTangents||j){j=b;var k=f.DYNAMIC_DRAW;if(h.__inittedArrays){var m=void 0,n=void 0,o=void 0,p=void 0,t=o=void 0,u=void 0,v=void 0,y=void 0,x=void 0,E=void 0,C=void 0,
  256. F=void 0,ha=void 0,z=void 0,A=void 0,D=void 0,I=void 0,B=p=y=p=v=u=void 0,J=void 0,w=J=B=u=void 0,G=void 0,M=w=J=B=o=o=t=y=p=w=J=B=G=w=J=B=G=w=J=B=void 0,da=0,K=0,la=0,L=0,P=0,S=0,N=0,R=0,O=0,H=0,Q=0,J=B=0,U=h.__vertexArray,Z=h.__uvArray,$=h.__uv2Array,fa=h.__normalArray,T=h.__tangentArray,ma=h.__colorArray,V=h.__skinVertexAArray,W=h.__skinVertexBArray,X=h.__skinIndexArray,Y=h.__skinWeightArray,ga=h.__morphTargetsArrays,ca=h.__webglCustomAttributes,w=void 0,aa=h.__faceArray,ea=h.__lineArray,ka=h.__needsSmoothNormals,
  257. E=h.__vertexColorType,x=h.__uvType,C=h.__normalType,pa=j.geometry,ya=pa.__dirtyVertices,va=pa.__dirtyElements,ra=pa.__dirtyUvs,wa=pa.__dirtyNormals,Ua=pa.__dirtyTangents,Va=pa.__dirtyColors,Wa=pa.__dirtyMorphTargets,Da=pa.vertices,Za=h.faces,bb=pa.faces,$a=pa.faceVertexUvs[0],ab=pa.faceVertexUvs[1],Ea=pa.skinVerticesA,Fa=pa.skinVerticesB,Ga=pa.skinIndices,xa=pa.skinWeights,Ba=j instanceof THREE.ShadowVolume?pa.edgeFaces:void 0;morphTargets=pa.morphTargets;if(ca)for(M in ca)ca[M].offset=0,ca[M].offsetSrc=
  258. 0;m=0;for(n=Za.length;m<n;m++)if(o=Za[m],p=bb[o],$a&&(F=$a[o]),ab&&(ha=ab[o]),o=p.vertexNormals,t=p.normal,u=p.vertexColors,v=p.color,y=p.vertexTangents,p instanceof THREE.Face3){if(ya)z=Da[p.a].position,A=Da[p.b].position,D=Da[p.c].position,U[K]=z.x,U[K+1]=z.y,U[K+2]=z.z,U[K+3]=A.x,U[K+4]=A.y,U[K+5]=A.z,U[K+6]=D.x,U[K+7]=D.y,U[K+8]=D.z,K+=9;if(ca)for(M in ca)if(w=ca[M],w.needsUpdate)B=w.offset,J=w.offsetSrc,w.size===1?(w.boundTo===void 0||w.boundTo==="vertices"?(w.array[B+0]=w.value[p.a],w.array[B+
  259. 1]=w.value[p.b],w.array[B+2]=w.value[p.c]):w.boundTo==="faces"?(w.array[B+0]=w.value[J],w.array[B+1]=w.value[J],w.array[B+2]=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(w.array[B+0]=w.value[J+0],w.array[B+1]=w.value[J+1],w.array[B+2]=w.value[J+2],w.offsetSrc+=3),w.offset+=3):(w.boundTo===void 0||w.boundTo==="vertices"?(z=w.value[p.a],A=w.value[p.b],D=w.value[p.c]):w.boundTo==="faces"?(z=w.value[J],A=w.value[J],D=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(z=w.value[J+0],A=w.value[J+
  260. 1],D=w.value[J+2],w.offsetSrc+=3),w.size===2?(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=A.x,w.array[B+3]=A.y,w.array[B+4]=D.x,w.array[B+5]=D.y,w.offset+=6):w.size===3?(w.type==="c"?(w.array[B+0]=z.r,w.array[B+1]=z.g,w.array[B+2]=z.b,w.array[B+3]=A.r,w.array[B+4]=A.g,w.array[B+5]=A.b,w.array[B+6]=D.r,w.array[B+7]=D.g,w.array[B+8]=D.b):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=A.x,w.array[B+4]=A.y,w.array[B+5]=A.z,w.array[B+6]=D.x,w.array[B+7]=D.y,w.array[B+8]=D.z),w.offset+=
  261. 9):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=z.w,w.array[B+4]=A.x,w.array[B+5]=A.y,w.array[B+6]=A.z,w.array[B+7]=A.w,w.array[B+8]=D.x,w.array[B+9]=D.y,w.array[B+10]=D.z,w.array[B+11]=D.w,w.offset+=12));if(Wa){B=0;for(J=morphTargets.length;B<J;B++)z=morphTargets[B].vertices[p.a].position,A=morphTargets[B].vertices[p.b].position,D=morphTargets[B].vertices[p.c].position,w=ga[B],w[Q+0]=z.x,w[Q+1]=z.y,w[Q+2]=z.z,w[Q+3]=A.x,w[Q+4]=A.y,w[Q+5]=A.z,w[Q+6]=D.x,w[Q+7]=D.y,w[Q+8]=D.z;Q+=
  262. 9}if(xa.length)B=xa[p.a],J=xa[p.b],w=xa[p.c],Y[H]=B.x,Y[H+1]=B.y,Y[H+2]=B.z,Y[H+3]=B.w,Y[H+4]=J.x,Y[H+5]=J.y,Y[H+6]=J.z,Y[H+7]=J.w,Y[H+8]=w.x,Y[H+9]=w.y,Y[H+10]=w.z,Y[H+11]=w.w,B=Ga[p.a],J=Ga[p.b],w=Ga[p.c],X[H]=B.x,X[H+1]=B.y,X[H+2]=B.z,X[H+3]=B.w,X[H+4]=J.x,X[H+5]=J.y,X[H+6]=J.z,X[H+7]=J.w,X[H+8]=w.x,X[H+9]=w.y,X[H+10]=w.z,X[H+11]=w.w,B=Ea[p.a],J=Ea[p.b],w=Ea[p.c],V[H]=B.x,V[H+1]=B.y,V[H+2]=B.z,V[H+3]=1,V[H+4]=J.x,V[H+5]=J.y,V[H+6]=J.z,V[H+7]=1,V[H+8]=w.x,V[H+9]=w.y,V[H+10]=w.z,V[H+11]=1,B=Fa[p.a],
  263. J=Fa[p.b],w=Fa[p.c],W[H]=B.x,W[H+1]=B.y,W[H+2]=B.z,W[H+3]=1,W[H+4]=J.x,W[H+5]=J.y,W[H+6]=J.z,W[H+7]=1,W[H+8]=w.x,W[H+9]=w.y,W[H+10]=w.z,W[H+11]=1,H+=12;if(Va&&E)u.length==3&&E==THREE.VertexColors?(p=u[0],B=u[1],J=u[2]):J=B=p=v,ma[O]=p.r,ma[O+1]=p.g,ma[O+2]=p.b,ma[O+3]=B.r,ma[O+4]=B.g,ma[O+5]=B.b,ma[O+6]=J.r,ma[O+7]=J.g,ma[O+8]=J.b,O+=9;if(Ua&&pa.hasTangents)u=y[0],v=y[1],p=y[2],T[N]=u.x,T[N+1]=u.y,T[N+2]=u.z,T[N+3]=u.w,T[N+4]=v.x,T[N+5]=v.y,T[N+6]=v.z,T[N+7]=v.w,T[N+8]=p.x,T[N+9]=p.y,T[N+10]=p.z,
  264. T[N+11]=p.w,N+=12;if(wa&&C)if(o.length==3&&ka)for(y=0;y<3;y++)t=o[y],fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;else for(y=0;y<3;y++)fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;if(ra&&F!==void 0&&x)for(y=0;y<3;y++)o=F[y],Z[la]=o.u,Z[la+1]=o.v,la+=2;if(ra&&ha!==void 0&&x)for(y=0;y<3;y++)o=ha[y],$[L]=o.u,$[L+1]=o.v,L+=2;va&&(aa[P]=da,aa[P+1]=da+1,aa[P+2]=da+2,P+=3,ea[R]=da,ea[R+1]=da+1,ea[R+2]=da,ea[R+3]=da+2,ea[R+4]=da+1,ea[R+5]=da+2,R+=6,da+=3)}else if(p instanceof THREE.Face4){if(ya)z=Da[p.a].position,A=
  265. Da[p.b].position,D=Da[p.c].position,I=Da[p.d].position,U[K]=z.x,U[K+1]=z.y,U[K+2]=z.z,U[K+3]=A.x,U[K+4]=A.y,U[K+5]=A.z,U[K+6]=D.x,U[K+7]=D.y,U[K+8]=D.z,U[K+9]=I.x,U[K+10]=I.y,U[K+11]=I.z,K+=12;if(ca)for(M in ca)if(w=ca[M],w.needsUpdate)B=w.offset,J=w.offsetSrc,w.size===1?(w.boundTo===void 0||w.boundTo==="vertices"?(w.array[B+0]=w.value[p.a],w.array[B+1]=w.value[p.b],w.array[B+2]=w.value[p.c],w.array[B+3]=w.value[p.d]):w.boundTo==="faces"?(w.array[B+0]=w.value[J],w.array[B+1]=w.value[J],w.array[B+
  266. 2]=w.value[J],w.array[B+3]=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(w.array[B+0]=w.value[J+0],w.array[B+1]=w.value[J+1],w.array[B+2]=w.value[J+2],w.array[B+3]=w.value[J+3],w.offsetSrc+=4),w.offset+=4):(w.boundTo===void 0||w.boundTo==="vertices"?(z=w.value[p.a],A=w.value[p.b],D=w.value[p.c],I=w.value[p.d]):w.boundTo==="faces"?(z=w.value[J],A=w.value[J],D=w.value[J],I=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(z=w.value[J+0],A=w.value[J+1],D=w.value[J+2],I=w.value[J+3],w.offsetSrc+=
  267. 4),w.size===2?(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=A.x,w.array[B+3]=A.y,w.array[B+4]=D.x,w.array[B+5]=D.y,w.array[B+6]=I.x,w.array[B+7]=I.y,w.offset+=8):w.size===3?(w.type==="c"?(w.array[B+0]=z.r,w.array[B+1]=z.g,w.array[B+2]=z.b,w.array[B+3]=A.r,w.array[B+4]=A.g,w.array[B+5]=A.b,w.array[B+6]=D.r,w.array[B+7]=D.g,w.array[B+8]=D.b,w.array[B+9]=I.r,w.array[B+10]=I.g,w.array[B+11]=I.b):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=A.x,w.array[B+4]=A.y,w.array[B+5]=A.z,w.array[B+
  268. 6]=D.x,w.array[B+7]=D.y,w.array[B+8]=D.z,w.array[B+9]=I.x,w.array[B+10]=I.y,w.array[B+11]=I.z),w.offset+=12):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=z.w,w.array[B+4]=A.x,w.array[B+5]=A.y,w.array[B+6]=A.z,w.array[B+7]=A.w,w.array[B+8]=D.x,w.array[B+9]=D.y,w.array[B+10]=D.z,w.array[B+11]=D.w,w.array[B+12]=I.x,w.array[B+13]=I.y,w.array[B+14]=I.z,w.array[B+15]=I.w,w.offset+=16));if(Wa){B=0;for(J=morphTargets.length;B<J;B++)z=morphTargets[B].vertices[p.a].position,A=morphTargets[B].vertices[p.b].position,
  269. D=morphTargets[B].vertices[p.c].position,I=morphTargets[B].vertices[p.d].position,w=ga[B],w[Q+0]=z.x,w[Q+1]=z.y,w[Q+2]=z.z,w[Q+3]=A.x,w[Q+4]=A.y,w[Q+5]=A.z,w[Q+6]=D.x,w[Q+7]=D.y,w[Q+8]=D.z,w[Q+9]=I.x,w[Q+10]=I.y,w[Q+11]=I.z;Q+=12}if(xa.length)B=xa[p.a],J=xa[p.b],w=xa[p.c],G=xa[p.d],Y[H]=B.x,Y[H+1]=B.y,Y[H+2]=B.z,Y[H+3]=B.w,Y[H+4]=J.x,Y[H+5]=J.y,Y[H+6]=J.z,Y[H+7]=J.w,Y[H+8]=w.x,Y[H+9]=w.y,Y[H+10]=w.z,Y[H+11]=w.w,Y[H+12]=G.x,Y[H+13]=G.y,Y[H+14]=G.z,Y[H+15]=G.w,B=Ga[p.a],J=Ga[p.b],w=Ga[p.c],G=Ga[p.d],
  270. X[H]=B.x,X[H+1]=B.y,X[H+2]=B.z,X[H+3]=B.w,X[H+4]=J.x,X[H+5]=J.y,X[H+6]=J.z,X[H+7]=J.w,X[H+8]=w.x,X[H+9]=w.y,X[H+10]=w.z,X[H+11]=w.w,X[H+12]=G.x,X[H+13]=G.y,X[H+14]=G.z,X[H+15]=G.w,B=Ea[p.a],J=Ea[p.b],w=Ea[p.c],G=Ea[p.d],V[H]=B.x,V[H+1]=B.y,V[H+2]=B.z,V[H+3]=1,V[H+4]=J.x,V[H+5]=J.y,V[H+6]=J.z,V[H+7]=1,V[H+8]=w.x,V[H+9]=w.y,V[H+10]=w.z,V[H+11]=1,V[H+12]=G.x,V[H+13]=G.y,V[H+14]=G.z,V[H+15]=1,B=Fa[p.a],J=Fa[p.b],w=Fa[p.c],p=Fa[p.d],W[H]=B.x,W[H+1]=B.y,W[H+2]=B.z,W[H+3]=1,W[H+4]=J.x,W[H+5]=J.y,W[H+6]=
  271. J.z,W[H+7]=1,W[H+8]=w.x,W[H+9]=w.y,W[H+10]=w.z,W[H+11]=1,W[H+12]=p.x,W[H+13]=p.y,W[H+14]=p.z,W[H+15]=1,H+=16;if(Va&&E)u.length==4&&E==THREE.VertexColors?(p=u[0],B=u[1],J=u[2],u=u[3]):u=J=B=p=v,ma[O]=p.r,ma[O+1]=p.g,ma[O+2]=p.b,ma[O+3]=B.r,ma[O+4]=B.g,ma[O+5]=B.b,ma[O+6]=J.r,ma[O+7]=J.g,ma[O+8]=J.b,ma[O+9]=u.r,ma[O+10]=u.g,ma[O+11]=u.b,O+=12;if(Ua&&pa.hasTangents)u=y[0],v=y[1],p=y[2],y=y[3],T[N]=u.x,T[N+1]=u.y,T[N+2]=u.z,T[N+3]=u.w,T[N+4]=v.x,T[N+5]=v.y,T[N+6]=v.z,T[N+7]=v.w,T[N+8]=p.x,T[N+9]=p.y,
  272. T[N+10]=p.z,T[N+11]=p.w,T[N+12]=y.x,T[N+13]=y.y,T[N+14]=y.z,T[N+15]=y.w,N+=16;if(wa&&C)if(o.length==4&&ka)for(y=0;y<4;y++)t=o[y],fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;else for(y=0;y<4;y++)fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;if(ra&&F!==void 0&&x)for(y=0;y<4;y++)o=F[y],Z[la]=o.u,Z[la+1]=o.v,la+=2;if(ra&&ha!==void 0&&x)for(y=0;y<4;y++)o=ha[y],$[L]=o.u,$[L+1]=o.v,L+=2;va&&(aa[P]=da,aa[P+1]=da+1,aa[P+2]=da+3,aa[P+3]=da+1,aa[P+4]=da+2,aa[P+5]=da+3,P+=6,ea[R]=da,ea[R+1]=da+1,ea[R+2]=da,ea[R+3]=da+3,
  273. ea[R+4]=da+1,ea[R+5]=da+2,ea[R+6]=da+2,ea[R+7]=da+3,R+=8,da+=4)}if(Ba){m=0;for(n=Ba.length;m<n;m++)aa[P]=Ba[m].a,aa[P+1]=Ba[m].b,aa[P+2]=Ba[m].c,aa[P+3]=Ba[m].a,aa[P+4]=Ba[m].c,aa[P+5]=Ba[m].d,P+=6}ya&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,U,k));if(ca)for(M in ca)if(w=ca[M],w.needsUpdate)f.bindBuffer(f.ARRAY_BUFFER,w.buffer),f.bufferData(f.ARRAY_BUFFER,w.array,k),w.needsUpdate=!1;if(Wa){B=0;for(J=morphTargets.length;B<J;B++)f.bindBuffer(f.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[B]),
  274. f.bufferData(f.ARRAY_BUFFER,ga[B],k)}Va&&O>0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,ma,k));wa&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglNormalBuffer),f.bufferData(f.ARRAY_BUFFER,fa,k));Ua&&pa.hasTangents&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglTangentBuffer),f.bufferData(f.ARRAY_BUFFER,T,k));ra&&la>0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,Z,k));ra&&L>0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,
  275. $,k));va&&(f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,aa,k),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,ea,k));H>0&&(f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,V,k),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,W,k),f.bindBuffer(f.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,X,k),f.bindBuffer(f.ARRAY_BUFFER,
  276. h.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,Y,k));j.dynamic||(delete h.__inittedArrays,delete h.__colorArray,delete h.__normalArray,delete h.__tangentArray,delete h.__uvArray,delete h.__uv2Array,delete h.__faceArray,delete h.__vertexArray,delete h.__lineArray,delete h.__skinVertexAArray,delete h.__skinVertexBArray,delete h.__skinIndexArray,delete h.__skinWeightArray)}}}e.__dirtyVertices=!1;e.__dirtyMorphTargets=!1;e.__dirtyElements=!1;e.__dirtyUvs=!1;e.__dirtyNormals=!1;e.__dirtyTangents=
  277. !1;e.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){e=b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=f.DYNAMIC_DRAW;x=b.vertices;h=b.colors;E=x.length;j=h.length;C=b.__vertexArray;k=b.__colorArray;F=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m<E;m++)n=x[m].position,g=m*3,C[g]=n.x,C[g+1]=n.y,C[g+2]=n.z;f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,C,d)}if(F){for(m=0;m<j;m++)color=h[m],g=m*3,k[g]=color.r,k[g+1]=color.g,k[g+2]=color.b;f.bindBuffer(f.ARRAY_BUFFER,
  278. b.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,k,d)}}e.__dirtyVertices=!1;e.__dirtyColors=!1}else if(b instanceof THREE.Line){e=b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=f.DYNAMIC_DRAW;x=b.vertices;h=b.colors;E=x.length;j=h.length;C=b.__vertexArray;k=b.__colorArray;F=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m<E;m++)n=x[m].position,g=m*3,C[g]=n.x,C[g+1]=n.y,C[g+2]=n.z;f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,C,d)}if(F){for(m=0;m<j;m++)color=
  279. h[m],g=m*3,k[g]=color.r,k[g+1]=color.g,k[g+2]=color.b;f.bindBuffer(f.ARRAY_BUFFER,b.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,k,d)}}e.__dirtyVertices=!1;e.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)e=b.geometry,(e.__dirtyVertices||e.__dirtyColors||b.sortParticles)&&c(e,f.DYNAMIC_DRAW,b),e.__dirtyVertices=!1,e.__dirtyColors=!1}function D(b){function d(b){var f=[];c=0;for(e=b.length;c<e;c++)b[c]==void 0?f.push("undefined"):f.push(b[c].id);return f.join("_")}var c,e,f,h,g,j,k,m,
  280. n={},o=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)g=b.faces[f],j=g.materials,k=d(j),n[k]==void 0&&(n[k]={hash:k,counter:0}),m=n[k].hash+"_"+n[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,vertices:0,numMorphTargets:o}),g=g instanceof THREE.Face3?3:4,b.geometryGroups[m].vertices+g>65535&&(n[k].counter+=1,m=n[k].hash+"_"+n[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,
  281. vertices:0,numMorphTargets:o})),b.geometryGroups[m].faces.push(f),b.geometryGroups[m].vertices+=g}function x(b,d,c){b.push({buffer:d,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=Q){switch(b){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,
  282. f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}Q=b}}function A(b,d,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(f.texParameteri(b,f.TEXTURE_WRAP_S,F(d.wrapS)),f.texParameteri(b,f.TEXTURE_WRAP_T,F(d.wrapT)),f.texParameteri(b,f.TEXTURE_MAG_FILTER,F(d.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,F(d.minFilter)),f.generateMipmap(b)):(f.texParameteri(b,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),
  283. f.texParameteri(b,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(b,f.TEXTURE_MAG_FILTER,M(d.magFilter)),f.texParameteri(b,f.TEXTURE_MIN_FILTER,M(d.minFilter)))}function z(b,d){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=f.deleteTexture(b.__webglTexture);b.__webglTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,b.__webglTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,b.image);A(f.TEXTURE_2D,b,b.image);f.bindTexture(f.TEXTURE_2D,null);b.needsUpdate=!1}f.activeTexture(f.TEXTURE0+
  284. d);f.bindTexture(f.TEXTURE_2D,b.__webglTexture)}function S(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=f.createFramebuffer();b.__webglRenderbuffer=f.createRenderbuffer();b.__webglTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,b.__webglTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,F(b.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,F(b.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,
  285. F(b.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,F(b.minFilter));f.texImage2D(f.TEXTURE_2D,0,F(b.format),b.width,b.height,0,F(b.format),F(b.type),null);f.bindRenderbuffer(f.RENDERBUFFER,b.__webglRenderbuffer);f.bindFramebuffer(f.FRAMEBUFFER,b.__webglFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,
  286. f.DEPTH_ATTACHMENT,f.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,b.__webglRenderbuffer)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var d,c;b?(d=b.__webglFramebuffer,c=b.width,b=b.height):(d=null,
  287. c=ga,b=ca);d!=V&&(f.bindFramebuffer(f.FRAMEBUFFER,d),f.viewport(U,ka,c,b),V=d)}function G(b,d){var c;b=="fragment"?c=f.createShader(f.FRAGMENT_SHADER):b=="vertex"&&(c=f.createShader(f.VERTEX_SHADER));f.shaderSource(c,d);f.compileShader(c);if(!f.getShaderParameter(c,f.COMPILE_STATUS))return console.error(f.getShaderInfoLog(c)),console.error(d),null;return c}function M(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}
  288. function F(b){switch(b){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;
  289. case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}
  290. var N=this,f,Y=[],O=null,V=null,L=!0,$=null,T=null,Q=null,fa=null,U=0,ka=0,ga=0,ca=0,aa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],R=new THREE.Matrix4,P=new Float32Array(16),W=new Float32Array(16),X=new THREE.Vector4,ea={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ha=b.canvas!==void 0?b.canvas:document.createElement("canvas"),J=b.stencil!==void 0?b.stencil:
  291. !0,da=b.antialias!==void 0?b.antialias:!1,la=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ma=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=ha;this.sortObjects=this.autoClear=!0;try{if(!(f=ha.getContext("experimental-webgl",{antialias:da,stencil:J})))throw"Error creating WebGL context.";}catch(ya){console.error(ya)}console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+
  292. " | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION));f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(la.r,la.g,la.b,ma);this.context=f;var va=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(J){var Z={};Z.vertices=new Float32Array(12);Z.faces=new Uint16Array(6);Z.darkness=
  293. 0.5;Z.vertices[0]=-20;Z.vertices[1]=-20;Z.vertices[2]=-1;Z.vertices[3]=20;Z.vertices[4]=-20;Z.vertices[5]=-1;Z.vertices[6]=20;Z.vertices[7]=20;Z.vertices[8]=-1;Z.vertices[9]=-20;Z.vertices[10]=20;Z.vertices[11]=-1;Z.faces[0]=0;Z.faces[1]=1;Z.faces[2]=2;Z.faces[3]=0;Z.faces[4]=2;Z.faces[5]=3;Z.vertexBuffer=f.createBuffer();Z.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,Z.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,Z.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);
  294. f.bufferData(f.ELEMENT_ARRAY_BUFFER,Z.faces,f.STATIC_DRAW);Z.program=f.createProgram();f.attachShader(Z.program,G("fragment",THREE.ShaderLib.shadowPost.fragmentShader));f.attachShader(Z.program,G("vertex",THREE.ShaderLib.shadowPost.vertexShader));f.linkProgram(Z.program);Z.vertexLocation=f.getAttribLocation(Z.program,"position");Z.projectionLocation=f.getUniformLocation(Z.program,"projectionMatrix");Z.darknessLocation=f.getUniformLocation(Z.program,"darkness")}var K={};K.vertices=new Float32Array(16);
  295. K.faces=new Uint16Array(6);b=0;K.vertices[b++]=-1;K.vertices[b++]=-1;K.vertices[b++]=0;K.vertices[b++]=0;K.vertices[b++]=1;K.vertices[b++]=-1;K.vertices[b++]=1;K.vertices[b++]=0;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=-1;K.vertices[b++]=1;K.vertices[b++]=0;K.vertices[b++]=1;b=0;K.faces[b++]=0;K.faces[b++]=1;K.faces[b++]=2;K.faces[b++]=0;K.faces[b++]=2;K.faces[b++]=3;K.vertexBuffer=f.createBuffer();K.elementBuffer=f.createBuffer();K.tempTexture=f.createTexture();
  296. K.occlusionTexture=f.createTexture();f.bindBuffer(f.ARRAY_BUFFER,K.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,K.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,K.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,K.faces,f.STATIC_DRAW);f.bindTexture(f.TEXTURE_2D,K.tempTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGB,16,16,0,f.RGB,f.UNSIGNED_BYTE,null);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,
  297. f.TEXTURE_MAG_FILTER,f.NEAREST);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST);f.bindTexture(f.TEXTURE_2D,K.occlusionTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,16,16,0,f.RGBA,f.UNSIGNED_BYTE,null);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST);f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=
  298. 0?(K.hasVertexTexture=!1,K.program=f.createProgram(),f.attachShader(K.program,G("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),f.attachShader(K.program,G("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(K.hasVertexTexture=!0,K.program=f.createProgram(),f.attachShader(K.program,G("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),f.attachShader(K.program,G("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));f.linkProgram(K.program);K.attributes={};K.uniforms={};
  299. K.attributes.vertex=f.getAttribLocation(K.program,"position");K.attributes.uv=f.getAttribLocation(K.program,"UV");K.uniforms.renderType=f.getUniformLocation(K.program,"renderType");K.uniforms.map=f.getUniformLocation(K.program,"map");K.uniforms.occlusionMap=f.getUniformLocation(K.program,"occlusionMap");K.uniforms.opacity=f.getUniformLocation(K.program,"opacity");K.uniforms.scale=f.getUniformLocation(K.program,"scale");K.uniforms.rotation=f.getUniformLocation(K.program,"rotation");K.uniforms.screenPosition=
  300. f.getUniformLocation(K.program,"screenPosition");var wa=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=
  301. 0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=f.createBuffer();_sprite.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,_sprite.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,_sprite.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,_sprite.faces,f.STATIC_DRAW);_sprite.program=f.createProgram();
  302. f.attachShader(_sprite.program,G("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(_sprite.program,G("vertex",THREE.ShaderLib.sprite.vertexShader));f.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=f.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=f.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=f.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=f.getUniformLocation(_sprite.program,
  303. "uvScale");_sprite.uniforms.rotation=f.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=f.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=f.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=f.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=f.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=f.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=
  304. f.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=f.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=f.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=f.getUniformLocation(_sprite.program,"projectionMatrix");var ra=!1;this.setSize=function(b,d){ha.width=b;ha.height=d;this.setViewport(0,0,ha.width,ha.height)};this.setViewport=function(b,d,c,e){U=b;ka=d;ga=c;ca=e;f.viewport(U,ka,ga,
  305. ca)};this.setScissor=function(b,d,c,e){f.scissor(b,d,c,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){L=b;f.depthMask(b)};this.setClearColorHex=function(b,d){la.setHex(b);ma=d;f.clearColor(la.r,la.g,la.b,ma)};this.setClearColor=function(b,d){la.copy(b);ma=d;f.clearColor(la.r,la.g,la.b,ma)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){Z.darkness=
  306. b};this.getContext=function(){return f};this.initMaterial=function(b,d,c,e){var h,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");
  307. if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,n,o;m=o=k=0;for(n=d.length;m<n;m++)g=d[m],g instanceof THREE.DirectionalLight&&o++,g instanceof THREE.PointLight&&k++;k+o<=4?d=o:(d=Math.ceil(4*o/(k+o)),k=4-d);g={directional:d,point:k};o=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)o=e.bones.length;var p;a:{m=b.fragmentShader;n=b.vertexShader;var k=b.uniforms,d=b.attributes,c={map:!!b.map,envMap:!!b.envMap,
  308. lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:c,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:o},t;g=[];j?g.push(j):(g.push(m),g.push(n));for(t in c)g.push(t),g.push(c[t]);j=g.join();t=0;for(g=Y.length;t<g;t++)if(Y[t].code==j){p=Y[t].program;break a}t=f.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,
  309. "#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.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[va?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_BONES "+c.maxBones,c.map?
  310. "#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","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 vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
  311. f.attachShader(t,G("fragment",prefix_fragment+m));f.attachShader(t,G("vertex",prefix_vertex+n));f.linkProgram(t);f.getProgramParameter(t,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(t,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");t.uniforms={};t.attributes={};var u;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(u in k)m.push(u);
  312. u=m;k=0;for(m=u.length;k<m;k++)n=u[k],t.uniforms[n]=f.getUniformLocation(t,n);m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(u=0;u<c.maxMorphTargets;u++)m.push("morphTarget"+u);for(p in d)m.push(p);p=m;u=0;for(d=p.length;u<d;u++)c=p[u],t.attributes[c]=f.getAttribLocation(t,c);Y.push({program:t,code:j});p=t}b.program=p;p=b.program.attributes;p.position>=0&&f.enableVertexAttribArray(p.position);p.color>=0&&f.enableVertexAttribArray(p.color);
  313. p.normal>=0&&f.enableVertexAttribArray(p.normal);p.tangent>=0&&f.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(f.enableVertexAttribArray(p.skinVertexA),f.enableVertexAttribArray(p.skinVertexB),f.enableVertexAttribArray(p.skinIndex),f.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(h in b.attributes)p[h]!==void 0&&p[h]>=0&&f.enableVertexAttribArray(p[h]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=
  314. 0&&(f.enableVertexAttribArray(p.morphTarget0),b.numSupportedMorphTargets++);p.morphTarget1>=0&&(f.enableVertexAttribArray(p.morphTarget1),b.numSupportedMorphTargets++);p.morphTarget2>=0&&(f.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(f.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(f.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(f.enableVertexAttribArray(p.morphTarget5),
  315. b.numSupportedMorphTargets++);p.morphTarget6>=0&&(f.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>=0&&(f.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);e.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(h=this.maxMorphTargets;b<h;b++)e.__webglMorphTargetInfluences[b]=0}};this.render=function(b,c,n,y){var x,z,A,D,F,ha,G,da,K=b.lights,M=b.fog;N.data.vertices=0;N.data.faces=0;N.data.drawCalls=0;c.matrixAutoUpdate&&
  316. c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(W);c.projectionMatrix.flattenToArray(P);R.multiply(c.projectionMatrix,c.matrixWorldInverse);k(R);this.initWebGLObjects(b);S(n);(this.autoClear||y)&&this.clear();F=b.__webglObjects.length;for(y=0;y<F;y++)if(x=b.__webglObjects[y],G=x.object,G.visible)if(!(G instanceof THREE.Mesh)||m(G)){if(G.matrixWorld.flattenToArray(G._objectMatrixArray),E(G,c),t(x),x.render=!0,this.sortObjects)X.copy(G.position),R.multiplyVector3(X),x.z=
  317. X.z}else x.render=!1;else x.render=!1;this.sortObjects&&b.__webglObjects.sort(u);ha=b.__webglObjectsImmediate.length;for(y=0;y<ha;y++)x=b.__webglObjectsImmediate[y],G=x.object,G.visible&&(G.matrixAutoUpdate&&G.matrixWorld.flattenToArray(G._objectMatrixArray),E(G,c),o(x));I(THREE.NormalBlending);for(y=0;y<F;y++)if(x=b.__webglObjects[y],x.render){G=x.object;da=x.buffer;A=x.opaque;h(G);for(x=0;x<A.count;x++)D=A.list[x],j(D.depthTest),e(c,K,M,D,da,G)}for(y=0;y<ha;y++)if(x=b.__webglObjectsImmediate[y],
  318. G=x.object,G.visible){A=x.opaque;h(G);for(x=0;x<A.count;x++)D=A.list[x],j(D.depthTest),z=d(c,K,M,D,G),G.render(function(b){g(b,z,D.shading)})}for(y=0;y<F;y++)if(x=b.__webglObjects[y],x.render){G=x.object;da=x.buffer;A=x.transparent;h(G);for(x=0;x<A.count;x++)D=A.list[x],I(D.blending),j(D.depthTest),e(c,K,M,D,da,G)}for(y=0;y<ha;y++)if(x=b.__webglObjectsImmediate[y],G=x.object,G.visible){A=x.transparent;h(G);for(x=0;x<A.count;x++)D=A.list[x],I(D.blending),j(D.depthTest),z=d(c,K,M,D,G),G.render(function(b){g(b,
  319. z,D.shading)})}b.__webglSprites.length&&v(b,c);J&&b.__webglShadowVolumes.length&&b.lights.length&&p(b);b.__webglLensFlares.length&&C(b,c);n&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter&&(f.bindTexture(f.TEXTURE_2D,n.__webglTexture),f.generateMipmap(f.TEXTURE_2D),f.bindTexture(f.TEXTURE_2D,null));f.finish()};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=
  320. [];for(;b.__objectsAdded.length;){var d=b.__objectsAdded[0],c=b,e=void 0,h=void 0,g=void 0;if(d._modelViewMatrix==void 0)d._modelViewMatrix=new THREE.Matrix4,d._normalMatrixArray=new Float32Array(9),d._modelViewMatrixArray=new Float32Array(16),d._objectMatrixArray=new Float32Array(16),d.matrixWorld.flattenToArray(d._objectMatrixArray);if(d instanceof THREE.Mesh)for(e in h=d.geometry,h.geometryGroups==void 0&&D(h),h.geometryGroups){g=h.geometryGroups[e];if(!g.__webglVertexBuffer){var j=g;j.__webglVertexBuffer=
  321. f.createBuffer();j.__webglNormalBuffer=f.createBuffer();j.__webglTangentBuffer=f.createBuffer();j.__webglColorBuffer=f.createBuffer();j.__webglUVBuffer=f.createBuffer();j.__webglUV2Buffer=f.createBuffer();j.__webglSkinVertexABuffer=f.createBuffer();j.__webglSkinVertexBBuffer=f.createBuffer();j.__webglSkinIndicesBuffer=f.createBuffer();j.__webglSkinWeightsBuffer=f.createBuffer();j.__webglFaceBuffer=f.createBuffer();j.__webglLineBuffer=f.createBuffer();if(j.numMorphTargets){var k=void 0,m=void 0;j.__webglMorphTargetsBuffers=
  322. [];k=0;for(m=j.numMorphTargets;k<m;k++)j.__webglMorphTargetsBuffers.push(f.createBuffer())}for(var j=g,k=d,n=void 0,p=void 0,o=void 0,t=o=void 0,u=void 0,v=void 0,J=v=m=0,A=o=p=void 0,p=n=void 0,t=k.geometry,A=t.faces,u=j.faces,n=0,p=u.length;n<p;n++)o=u[n],o=A[o],o instanceof THREE.Face3?(m+=3,v+=1,J+=3):o instanceof THREE.Face4&&(m+=4,v+=2,J+=4);for(var n=j,p=k,z=u=A=void 0,E=void 0,z=void 0,o=[],A=0,u=p.materials.length;A<u;A++)if(z=p.materials[A],z instanceof THREE.MeshFaceMaterial){z=0;for(l=
  323. n.materials.length;z<l;z++)(E=n.materials[z])&&o.push(E)}else(E=z)&&o.push(E);n=o;a:{A=p=void 0;u=n.length;for(p=0;p<u;p++)if(A=n[p],A.map||A.lightMap||A instanceof THREE.MeshShaderMaterial){p=!0;break a}p=!1}a:{A=n;o=u=void 0;z=A.length;for(u=0;u<z;u++)if(o=A[u],!(o instanceof THREE.MeshBasicMaterial&&!o.envMap||o instanceof THREE.MeshDepthMaterial)){A=o&&o.shading!=void 0&&o.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}A=!1}a:{o=u=void 0;z=n.length;for(u=0;u<z;u++)if(o=
  324. n[u],o.vertexColors){o=o.vertexColors;break a}o=!1}j.__vertexArray=new Float32Array(m*3);if(A)j.__normalArray=new Float32Array(m*3);if(t.hasTangents)j.__tangentArray=new Float32Array(m*4);if(o)j.__colorArray=new Float32Array(m*3);if(p){if(t.faceUvs.length>0||t.faceVertexUvs.length>0)j.__uvArray=new Float32Array(m*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(m*2)}if(k.geometry.skinWeights.length&&k.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(m*
  325. 4),j.__skinVertexBArray=new Float32Array(m*4),j.__skinIndexArray=new Float32Array(m*4),j.__skinWeightArray=new Float32Array(m*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(J*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];t=0;for(u=j.numMorphTargets;t<u;t++)j.__morphTargetsArrays.push(new Float32Array(m*3))}j.__needsSmoothNormals=A==THREE.SmoothShading;j.__uvType=p;j.__vertexColorType=o;j.__normalType=A;j.__webglFaceCount=
  326. v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0);j.__webglLineCount=J*2;t=0;for(u=n.length;t<u;t++)if(n[t].attributes)for(a in j.__webglCustomAttributes={},n[t].attributes){p={};for(prop in n[t].attributes[a])p[prop]=n[t].attributes[a][prop];if(!p.__webglInitialized||p.createUniqueBuffers)p.__webglInitialized=!0,v=1,p.type==="v2"?v=2:p.type==="v3"?v=3:p.type==="v4"?v=4:p.type==="c"&&(v=3),p.size=v,p.needsUpdate=!0,p.array=new Float32Array(m*v),p.buffer=f.createBuffer(),p.buffer.belongsToAttribute=
  327. a;j.__webglCustomAttributes[a]=p}j.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}d instanceof THREE.ShadowVolume?x(c.__webglShadowVolumes,g,d):x(c.__webglObjects,g,d)}else if(d instanceof THREE.LensFlare)x(c.__webglLensFlares,void 0,d);else if(d instanceof THREE.Ribbon){h=d.geometry;if(!h.__webglVertexBuffer)e=h,e.__webglVertexBuffer=f.createBuffer(),e.__webglColorBuffer=f.createBuffer(),
  328. e=h,g=e.vertices.length,e.__vertexArray=new Float32Array(g*3),e.__colorArray=new Float32Array(g*3),e.__webglVertexCount=g,h.__dirtyVertices=!0,h.__dirtyColors=!0;x(c.__webglObjects,h,d)}else if(d instanceof THREE.Line){h=d.geometry;if(!h.__webglVertexBuffer)e=h,e.__webglVertexBuffer=f.createBuffer(),e.__webglColorBuffer=f.createBuffer(),e=h,g=e.vertices.length,e.__vertexArray=new Float32Array(g*3),e.__colorArray=new Float32Array(g*3),e.__webglLineCount=g,h.__dirtyVertices=!0,h.__dirtyColors=!0;x(c.__webglObjects,
  329. h,d)}else if(d instanceof THREE.ParticleSystem){h=d.geometry;if(!h.__webglVertexBuffer)e=h,e.__webglVertexBuffer=f.createBuffer(),e.__webglColorBuffer=f.createBuffer(),e=h,g=e.vertices.length,e.__vertexArray=new Float32Array(g*3),e.__colorArray=new Float32Array(g*3),e.__sortArray=[],e.__webglParticleCount=g,h.__dirtyVertices=!0,h.__dirtyColors=!0;x(c.__webglObjects,h,d)}else THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?c.__webglObjectsImmediate.push({object:d,opaque:{list:[],count:0},
  330. transparent:{list:[],count:0}}):d instanceof THREE.Sprite&&c.__webglSprites.push(d);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){d=b.__objectsRemoved[0];c=b;e=h=void 0;if(d instanceof THREE.Mesh)for(h=c.__webglObjects.length-1;h>=0;h--){if(e=c.__webglObjects[h].object,d==e){c.__webglObjects.splice(h,1);break}}else if(d instanceof THREE.Sprite)for(h=c.__webglSprites.length-1;h>=0;h--)if(e=c.__webglSprites[h],d==e){c.__webglSprites.splice(h,1);break}b.__objectsRemoved.splice(0,1)}d=
  331. 0;for(c=b.__webglObjects.length;d<c;d++)y(b.__webglObjects[d].object,b);d=0;for(c=b.__webglShadowVolumes.length;d<c;d++)y(b.__webglShadowVolumes[d].object,b);d=0;for(c=b.__webglLensFlares.length;d<c;d++)y(b.__webglLensFlares[d].object,b)};this.setFaceCulling=function(b,d){b?(!d||d=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW),b=="back"?f.cullFace(f.BACK):b=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK),f.enable(f.CULL_FACE)):f.disable(f.CULL_FACE)};this.supportsVertexTextures=function(){return va}};
  332. THREE.WebGLRenderTarget=function(b,c,d){this.width=b;this.height=c;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:
  333. !0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};
  334. 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(b,c,d){d&&b.update(void 0,!1,c);var d=b.sounds,e,g=d.length;for(e=0;e<g;e++)b=d[e],this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34),this.soundPosition.subSelf(c.position),b.isPlaying&&b.isLoaded&&(b.isAddedToDOM||b.addToDOM(this.domElement),b.calculateVolumeAndPan(this.soundPosition))}};
  335. THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(b){this.positionWorld.copy(b.positionWorld);this.positionScreen.copy(b.positionScreen)};
  336. THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
  337. THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
  338. THREE.RenderableObject=function(){this.z=this.object=null};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.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
  339. THREE.ColorUtils={adjustHSV:function(b,c,d,e){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,g);g.h=THREE.ColorUtils.clamp(g.h+c,0,1);g.s=THREE.ColorUtils.clamp(g.s+d,0,1);g.v=THREE.ColorUtils.clamp(g.v+e,0,1);b.setHSV(g.h,g.s,g.v)},rgbToHsv:function(b,c){var d=b.r,e=b.g,g=b.b,h=Math.max(Math.max(d,e),g),j=Math.min(Math.min(d,e),g);if(j==h)j=d=0;else{var k=h-j,j=k/h,d=d==h?(e-g)/k:e==h?2+(g-d)/k:4+(d-e)/k;d/=6;d<0&&(d+=1);d>1&&(d-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=d;c.s=j;c.v=h;return c},
  340. clamp:function(b,c,d){return b<c?c:b>d?d:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
  341. var GeometryUtils={merge:function(b,c){var d=c instanceof THREE.Mesh,e=b.vertices.length,g=d?c.geometry:c,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,n=b.faceVertexUvs[0],g=g.faceVertexUvs[0];d&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,t=j.length;o<t;o++){var u=new THREE.Vertex(j[o].position.clone());d&&c.matrix.multiplyVector3(u.position);h.push(u)}o=0;for(t=m.length;o<t;o++){var j=m[o],p,v,C=j.vertexNormals,u=j.vertexColors;j instanceof THREE.Face3?p=new THREE.Face3(j.a+e,j.b+e,j.c+e):
  342. j instanceof THREE.Face4&&(p=new THREE.Face4(j.a+e,j.b+e,j.c+e,j.d+e));p.normal.copy(j.normal);d=0;for(h=C.length;d<h;d++)v=C[d],p.vertexNormals.push(v.clone());p.color.copy(j.color);d=0;for(h=u.length;d<h;d++)v=u[d],p.vertexColors.push(v.clone());p.materials=j.materials.slice();p.centroid.copy(j.centroid);k.push(p)}o=0;for(t=g.length;o<t;o++){e=g[o];k=[];d=0;for(h=e.length;d<h;d++)k.push(new THREE.UV(e[d].u,e[d].v));n.push(k)}}};
  343. THREE.ImageUtils={loadTexture:function(b,c,d){var e=new Image,g=new THREE.Texture(e,c);e.onload=function(){g.needsUpdate=!0;d&&d(this)};e.src=b;return g},loadTextureCube:function(b,c,d){var e,g=[],h=new THREE.Texture(g,c),c=g.loadCount=0;for(e=b.length;c<e;++c)g[c]=new Image,g[c].onload=function(){g.loadCount+=1;if(g.loadCount==6)h.needsUpdate=!0;d&&d(this)},g[c].src=b[c];return h}};
  344. THREE.SceneUtils={addMesh:function(b,c,d,e,g,h,j,k,m,n){c=new THREE.Mesh(c,n);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=g;c.position.z=h;c.rotation.x=j;c.rotation.y=k;c.rotation.z=m;b.addObject(c);return c},addPanoramaCubeWebGL:function(b,c,d){var e=THREE.ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:e.uniforms});c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,1,null,!0),d);b.addObject(c);
  345. return c},addPanoramaCube:function(b,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,e,!0),
  346. new THREE.MeshFaceMaterial);b.addObject(c);return c},addPanoramaCubePlanes:function(b,c,d){var e=c/2,c=new THREE.Plane(c,c),g=Math.PI,h=Math.PI/2;THREE.SceneUtils.addMesh(b,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));THREE.SceneUtils.addMesh(b,c,1,-e,0,0,0,h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));THREE.SceneUtils.addMesh(b,c,1,e,0,0,0,-h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));THREE.SceneUtils.addMesh(b,c,1,0,e,0,h,0,g,
  347. new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));THREE.SceneUtils.addMesh(b,c,1,0,-e,0,-h,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))},showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var d,e,g=b.children.length;for(e=0;e<g;e++)d=b.children[e],c(d),THREE.SceneUtils.traverseHierarchy(d,c)}};
  348. THREE.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}},fragmentShader:"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}",
  349. vertexShader:"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}"},
  350. normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",
  351. value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},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}},fragmentShader:"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 enableSpecular;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\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 specularTex = 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;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, 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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight * pointDiffuseWeight;\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 = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight * dirDiffuseWeight;\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}",
  352. vertexShader:"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}"},
  353. cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"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}",fragmentShader:"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",
  354. value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"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}",fragmentShader:"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}"},
  355. 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}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"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}"},
  356. screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
  357. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var c,d,e,g,h=2*Math.ceil(b*3)+1;h>25&&(h=25);g=(h-1)*0.5;d=Array(h);for(c=e=0;c<h;++c)d[c]=Math.exp(-((c-g)*(c-g))/(2*b*b)),e+=d[c];for(c=0;c<h;++c)d[c]/=e;return d}};
  358. THREE.AnimationHandler=function(){var b=[],c={},d={update:function(d){for(var c=0;c<b.length;c++)b[c].update(d)},addToUpdate:function(d){b.indexOf(d)===-1&&b.push(d)},removeFromUpdate:function(d){d=b.indexOf(d);d!==-1&&b.splice(d,1)},add:function(b){c[b.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+b.name+" already exists in library. Overwriting.");c[b.name]=b;if(b.initialized!==!0){for(var d=0;d<b.hierarchy.length;d++){for(var e=0;e<b.hierarchy[d].keys.length;e++){if(b.hierarchy[d].keys[e].time<
  359. 0)b.hierarchy[d].keys[e].time=0;if(b.hierarchy[d].keys[e].rot!==void 0&&!(b.hierarchy[d].keys[e].rot instanceof THREE.Quaternion)){var k=b.hierarchy[d].keys[e].rot;b.hierarchy[d].keys[e].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(b.hierarchy[d].keys[0].morphTargets!==void 0){k={};for(e=0;e<b.hierarchy[d].keys.length;e++)for(var m=0;m<b.hierarchy[d].keys[e].morphTargets.length;m++){var n=b.hierarchy[d].keys[e].morphTargets[m];k[n]=-1}b.hierarchy[d].usedMorphTargets=k;for(e=0;e<b.hierarchy[d].keys.length;e++){var o=
  360. {};for(n in k){for(m=0;m<b.hierarchy[d].keys[e].morphTargets.length;m++)if(b.hierarchy[d].keys[e].morphTargets[m]===n){o[n]=b.hierarchy[d].keys[e].morphTargetsInfluences[m];break}m===b.hierarchy[d].keys[e].morphTargets.length&&(o[n]=0)}b.hierarchy[d].keys[e].morphTargetsInfluences=o}}for(e=1;e<b.hierarchy[d].keys.length;e++)b.hierarchy[d].keys[e].time===b.hierarchy[d].keys[e-1].time&&(b.hierarchy[d].keys.splice(e,1),e--);for(e=1;e<b.hierarchy[d].keys.length;e++)b.hierarchy[d].keys[e].index=e}e=parseInt(b.length*
  361. b.fps,10);b.JIT={};b.JIT.hierarchy=[];for(d=0;d<b.hierarchy.length;d++)b.JIT.hierarchy.push(Array(e));b.initialized=!0}},get:function(b){if(typeof b==="string")return c[b]?c[b]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+b),null)},parse:function(b){var d=[];if(b instanceof THREE.SkinnedMesh)for(var c=0;c<b.bones.length;c++)d.push(b.bones[c]);else e(b,d);return d}},e=function(b,d){d.push(b);for(var c=0;c<b.children.length;c++)e(b.children[c],d)};d.LINEAR=0;d.CATMULLROM=1;d.CATMULLROM_FORWARD=
  362. 2;return d}();THREE.Animation=function(b,c,d,e){this.root=b;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=d!==void 0?d:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==void 0?e:!0;this.points=[];this.target=new THREE.Vector3};
  363. THREE.Animation.prototype.play=function(b,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==void 0?b:!0;this.currentTime=c!==void 0?c:0;var d,e=this.hierarchy.length,g;for(d=0;d<e;d++){g=this.hierarchy[d];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===void 0)g.animationCache={},g.animationCache.prevKey={pos:0,rot:0,scl:0},g.animationCache.nextKey={pos:0,rot:0,scl:0},g.animationCache.originalMatrix=g instanceof
  364. THREE.Bone?g.skinMatrix:g.matrix;var h=g.animationCache.prevKey;g=g.animationCache.nextKey;h.pos=this.data.hierarchy[d].keys[0];h.rot=this.data.hierarchy[d].keys[0];h.scl=this.data.hierarchy[d].keys[0];g.pos=this.getNextKeyWith("pos",d,1);g.rot=this.getNextKeyWith("rot",d,1);g.scl=this.getNextKeyWith("scl",d,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
  365. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  366. THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==void 0)this.hierarchy[b]instanceof THREE.Bone?this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix:this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix,delete this.hierarchy[b].animationCache};
  367. THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],d,e,g,h,j,k,m,n,o=this.data.JIT.hierarchy,t,u;this.currentTime+=b*this.timeScale;u=this.currentTime;t=this.currentTime%=this.data.length;n=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,v=this.hierarchy.length;p<v;p++)if(b=this.hierarchy[p],m=b.animationCache,this.JITCompile&&o[p][n]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=o[p][n],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
  368. !1):(b.matrix=o[p][n],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)b instanceof THREE.Bone?b.skinMatrix=b.animationCache.originalMatrix:b.matrix=b.animationCache.originalMatrix;for(var C=0;C<3;C++){d=c[C];j=m.prevKey[d];k=m.nextKey[d];if(k.time<=u){if(t<u)if(this.loop){j=this.data.hierarchy[p].keys[0];for(k=this.getNextKeyWith(d,p,1);k.time<t;)j=k,k=this.getNextKeyWith(d,p,k.index+1)}else{this.stop();return}else{do j=k,k=this.getNextKeyWith(d,p,k.index+1);while(k.time<
  369. t)}m.prevKey[d]=j;m.nextKey[d]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;e=(t-j.time)/(k.time-j.time);g=j[d];h=k[d];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+p),e=e<0?0:1;if(d==="pos")if(d=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)d.x=g[0]+(h[0]-g[0])*e,d.y=g[1]+(h[1]-g[1])*e,d.z=g[2]+(h[2]-g[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
  370. this.getPrevKeyWith("pos",p,j.index-1).pos,this.points[1]=g,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos,e=e*0.33+0.33,g=this.interpolateCatmullRom(this.points,e),d.x=g[0],d.y=g[1],d.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(d),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,e,0)}else if(d===
  371. "rot")THREE.Quaternion.slerp(g,h,b.quaternion,e);else if(d==="scl")d=b.scale,d.x=g[0]+(h[0]-g[0])*e,d.y=g[1]+(h[1]-g[1])*e,d.z=g[2]+(h[2]-g[2])*e}}if(this.JITCompile&&o[0][n]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;p<this.hierarchy.length;p++)o[p][n]=this.hierarchy[p]instanceof THREE.Bone?this.hierarchy[p].skinMatrix.clone():this.hierarchy[p].matrix.clone()}}};
  372. THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var d=[],e=[],g,h,j,k,m,n;g=(b.length-1)*c;h=Math.floor(g);g-=h;d[0]=h==0?h:h-1;d[1]=h;d[2]=h>b.length-2?h:h+1;d[3]=h>b.length-3?h:h+2;h=b[d[0]];k=b[d[1]];m=b[d[2]];n=b[d[3]];d=g*g;j=g*d;e[0]=this.interpolate(h[0],k[0],m[0],n[0],g,d,j);e[1]=this.interpolate(h[1],k[1],m[1],n[1],g,d,j);e[2]=this.interpolate(h[2],k[2],m[2],n[2],g,d,j);return e};
  373. THREE.Animation.prototype.interpolate=function(b,c,d,e,g,h,j){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*j+(-3*(c-d)-2*b-e)*h+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,d){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d=d<e.length-1?d:e.length-1:d%=e.length;d<e.length;d++)if(e[d][b]!==void 0)return e[d];return this.data.hierarchy[c].keys[0]};
  374. THREE.Animation.prototype.getPrevKeyWith=function(b,c,d){for(var e=this.data.hierarchy[c].keys,d=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d>0?d:0:d>=0?d:d+e.length;d>=0;d--)if(e[d][b]!==void 0)return e[d];return this.data.hierarchy[c].keys[e.length-1]};
  375. THREE.QuakeCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=
  376. b.movementSpeed;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.noFly!==void 0)this.noFly=b.noFly;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.autoForward!==void 0)this.autoForward=b.autoForward;if(b.activeLook!==void 0)this.activeLook=b.activeLook;if(b.heightSpeed!==void 0)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==void 0)this.heightCoef=b.heightCoef;if(b.heightMin!==void 0)this.heightMin=b.heightMin;if(b.heightMax!==void 0)this.heightMax=b.heightMax;if(b.constrainVertical!==
  377. void 0)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==void 0)this.verticalMin=b.verticalMin;if(b.verticalMax!==void 0)this.verticalMax=b.verticalMax;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();
  378. b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=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=
  379. !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;break;case 81:this.freeze=!this.freeze}};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=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=
  380. this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&
  381. (this.lat-=this.mouseY*c);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,g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);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;if(this.constrainVertical)this.phi=
  382. (this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.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",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),
  383. !1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
  384. THREE.QuakeCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))};
  385. THREE.PathCamera=function(b){function c(b,d,c,e){var h={name:c,fps:0.6,length:e,hierarchy:[]},g,j=d.getControlPointsArray(),k=d.getLength(),m=j.length,D=0;g=m-1;d={parent:-1,keys:[]};d.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};d.keys[g]={time:e,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g<m-1;g++)D=e*k.chunks[g]/k.total,d.keys[g]={time:D,pos:j[g]};h.hierarchy[0]=d;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function d(b,d){var c,
  386. e,h=new THREE.Geometry;for(c=0;c<b.points.length*d;c++)e=c/(b.points.length*d),e=b.getPoint(e),h.vertices[c]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return h}function e(b,c){var e=d(c,10),h=d(c,10),g=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,g);particleObj=new THREE.ParticleSystem(h,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);h=new THREE.Sphere(1,
  387. 16,8);g=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)e=new THREE.Mesh(h,g),e.position.copy(c.points[i]),e.updateMatrix(),b.addChild(e)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=
  388. this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(b){if(b.duration!==void 0)this.duration=b.duration*1E3;if(b.waypoints!==void 0)this.waypoints=b.waypoints;if(b.useConstantSpeed!==void 0)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==void 0)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==void 0)this.createDebugPath=b.createDebugPath;if(b.createDebugDummy!==
  389. void 0)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==void 0)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==void 0)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==void 0)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=
  390. window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(b,d,c){var e,j;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;e=this.phi%g;this.phi=e>=0?e:e+g;e=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var k=j[1]-j[0];this.phi=
  391. TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;k=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,d,c)};this.onMouseMove=function(b){this.mouseX=
  392. b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10,0);this.animation=c(this.animationParent,
  393. this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,d){return function(){d.apply(b,arguments)}}(this,this.onMouseMove),!1)};
  394. THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
  395. THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward=
  396. b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=
  397. 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
  398. this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
  399. case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),g=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY-
  400. c.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff*
  401. this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward||
  402. this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
  403. document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this,
  404. this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
  405. THREE.RollCamera=function(b,c,d,e){THREE.Camera.call(this,b,c,d,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,n=1,o=0,t=0,u=0,p=0,v=0,C=window.innerWidth/2,E=window.innerHeight/2;this.update=
  406. function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*p),this.rotateVertically(b*v));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);this.translateY(b*u);m&&(this.roll+=this.rollSpeed*this.delta*n);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
  407. else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();j.copy(this.forward);h.set(0,1,0);g.cross(h,j).normalize();h.cross(j,g).normalize();this.matrix.n11=g.x;this.matrix.n12=h.x;this.matrix.n13=j.x;this.matrix.n21=g.y;this.matrix.n22=h.y;this.matrix.n23=j.y;this.matrix.n31=g.z;this.matrix.n32=h.z;this.matrix.n33=j.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k);
  408. this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(b){this.position.x+=this.matrix.n11*b;this.position.y+=this.matrix.n21*b;this.position.z+=this.matrix.n31*b};this.translateY=function(b){this.position.x+=this.matrix.n12*b;this.position.y+=this.matrix.n22*b;this.position.z+=this.matrix.n32*b};this.translateZ=function(b){this.position.x-=this.matrix.n13*b;this.position.y-=
  409. this.matrix.n23*b;this.position.z-=this.matrix.n33*b};this.rotateHorizontally=function(b){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(b);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(b){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(b);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
  410. function(b){p=(b.clientX-C)/window.innerWidth;v=(b.clientY-E)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=1;break;case 2:o=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=0;break;case 2:o=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:o=1;break;case 37:case 65:t=-1;break;
  411. case 40:case 83:o=-1;break;case 39:case 68:t=1;break;case 81:m=!0;n=1;break;case 69:m=!0;n=-1;break;case 82:u=1;break;case 70:u=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:o=0;break;case 37:case 65:t=0;break;case 40:case 83:o=0;break;case 39:case 68:t=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:u=0;break;case 70:u=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
  412. THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
  413. THREE.Cube=function(b,c,d,e,g,h,j,k,m){function n(b,c,d,j,k,m,n,p){var t,u,v=e||1,C=g||1,f=k/2,Y=m/2,O=o.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")t="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")t="y",C=h||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")t="x",v=h||1;var V=v+1,L=C+1;k/=v;var $=m/C;for(u=0;u<L;u++)for(m=0;m<V;m++){var T=new THREE.Vector3;T[b]=(m*k-f)*d;T[c]=(u*$-Y)*j;T[t]=n;o.vertices.push(new THREE.Vertex(T))}for(u=0;u<C;u++)for(m=0;m<v;m++)o.faces.push(new THREE.Face4(m+V*u+O,m+V*(u+
  414. 1)+O,m+1+V*(u+1)+O,m+1+V*u+O,null,null,p)),o.faceVertexUvs[0].push([new THREE.UV(m/v,u/C),new THREE.UV(m/v,(u+1)/C),new THREE.UV((m+1)/v,(u+1)/C),new THREE.UV((m+1)/v,u/C)])}THREE.Geometry.call(this);var o=this,t=b/2,u=c/2,p=d/2,k=k?-1:1;if(j!==void 0)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=void 0)for(var C in m)this.sides[C]!=void 0&&(this.sides[C]=m[C]);
  415. this.sides.px&&n("z","y",1*k,-1,d,c,-t,this.materials[0]);this.sides.nx&&n("z","y",-1*k,-1,d,c,t,this.materials[1]);this.sides.py&&n("x","z",1*k,1,b,d,u,this.materials[2]);this.sides.ny&&n("x","z",1*k,-1,b,d,-u,this.materials[3]);this.sides.pz&&n("x","y",1*k,-1,b,c,p,this.materials[4]);this.sides.nz&&n("x","y",-1*k,-1,b,c,-p,this.materials[5]);(function(){for(var b=[],c=[],d=0,e=o.vertices.length;d<e;d++){for(var h=o.vertices[d],g=!1,j=0,k=b.length;j<k;j++){var m=b[j];if(h.position.x==m.position.x&&
  416. h.position.y==m.position.y&&h.position.z==m.position.z){c[d]=j;g=!0;break}}if(!g)c[d]=b.length,b.push(new THREE.Vertex(h.position.clone()))}d=0;for(e=o.faces.length;d<e;d++)h=o.faces[d],h.a=c[h.a],h.b=c[h.b],h.c=c[h.c],h.d=c[h.d];o.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
  417. THREE.Cylinder=function(b,c,d,e,g,h){function j(b,c,d){k.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,d)))}THREE.Geometry.call(this);var k=this,m,n=Math.PI*2,o=e/2;for(m=0;m<b;m++)j(Math.sin(n*m/b)*c,Math.cos(n*m/b)*c,-o);for(m=0;m<b;m++)j(Math.sin(n*m/b)*d,Math.cos(n*m/b)*d,o);for(m=0;m<b;m++)k.faces.push(new THREE.Face4(m,m+b,b+(m+1)%b,(m+1)%b));if(d>0){j(0,0,-o-(h||0));for(m=b;m<b+b/2;m++)k.faces.push(new THREE.Face4(2*b,(2*m-2*b)%b,(2*m-2*b+1)%b,(2*m-2*b+2)%b))}if(c>0){j(0,0,o+(g||0));
  418. for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m<b;m++){var c=[],d=this.faces[m],g=this.vertices[d.a],h=this.vertices[d.b],o=this.vertices[d.c],t=this.vertices[d.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/n,0.5+g.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/n,0.5+h.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/n,0.5+o.position.z/
  419. e));d instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(t.position.x,t.position.y)/n,0.5+t.position.z/e));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
  420. THREE.Icosahedron=function(b){function c(b,c,d){var e=Math.sqrt(b*b+c*c+d*d);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(b/e,c/e,d/e)))-1}function d(b,c,d,e){e.faces.push(new THREE.Face3(b,c,d))}function e(b,d){var e=g.vertices[b].position,h=g.vertices[d].position;return c((e.x+h.x)/2,(e.y+h.y)/2,(e.z+h.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,-b);c(0,
  421. 1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);d(0,11,5,h);d(0,5,1,h);d(0,1,7,h);d(0,7,10,h);d(0,10,11,h);d(1,5,9,h);d(5,11,4,h);d(11,10,2,h);d(10,7,6,h);d(7,1,8,h);d(3,9,4,h);d(3,4,2,h);d(3,2,6,h);d(3,6,8,h);d(3,8,9,h);d(4,9,5,h);d(2,4,11,h);d(6,2,10,h);d(8,6,7,h);d(9,8,1,h);for(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var m=e(h.faces[k].a,h.faces[k].b),n=e(h.faces[k].b,h.faces[k].c),o=e(h.faces[k].c,h.faces[k].a);d(h.faces[k].a,m,o,j);d(h.faces[k].b,n,m,j);d(h.faces[k].c,
  422. o,n,j);d(m,n,o,j)}h.faces=j.faces}g.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
  423. THREE.Lathe=function(b,c,d){THREE.Geometry.call(this);this.steps=c||12;this.angle=d||2*Math.PI;for(var c=this.angle/this.steps,d=[],e=[],g=[],h=[],j=(new THREE.Matrix4).setRotationZ(c),k=0;k<b.length;k++)this.vertices.push(new THREE.Vertex(b[k])),d[k]=b[k].clone(),e[k]=this.vertices.length-1;for(var m=0;m<=this.angle+0.001;m+=c){for(k=0;k<d.length;k++)m<this.angle?(d[k]=j.multiplyVector3(d[k].clone()),this.vertices.push(new THREE.Vertex(d[k])),g[k]=this.vertices.length-1):g=h;m==0&&(h=e);for(k=0;k<
  424. e.length-1;k++)this.faces.push(new THREE.Face4(g[k],g[k+1],e[k+1],e[k])),this.faceVertexUvs[0].push([new THREE.UV(1-m/this.angle,k/b.length),new THREE.UV(1-m/this.angle,(k+1)/b.length),new THREE.UV(1-(m-c)/this.angle,(k+1)/b.length),new THREE.UV(1-(m-c)/this.angle,k/b.length)]);e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
  425. THREE.Plane=function(b,c,d,e){THREE.Geometry.call(this);var g,h=b/2,j=c/2,d=d||1,e=e||1,k=d+1,m=e+1;b/=d;var n=c/e;for(g=0;g<m;g++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-h,-(g*n-j),0)));for(g=0;g<e;g++)for(c=0;c<d;c++)this.faces.push(new THREE.Face4(c+k*g,c+k*(g+1),c+1+k*(g+1),c+1+k*g)),this.faceVertexUvs[0].push([new THREE.UV(c/d,g/e),new THREE.UV(c/d,(g+1)/e),new THREE.UV((c+1)/d,(g+1)/e),new THREE.UV((c+1)/d,g/e)]);this.computeCentroids();this.computeFaceNormals()};
  426. THREE.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
  427. THREE.Sphere=function(b,c,d){THREE.Geometry.call(this);for(var e,g=Math.PI,h=Math.max(3,c||8),j=Math.max(2,d||6),c=[],d=0;d<j+1;d++){e=d/j;var k=b*Math.cos(e*g),m=b*Math.sin(e*g),n=[],o=0;for(e=0;e<h;e++){var t=2*e/h,u=m*Math.sin(t*g),t=m*Math.cos(t*g);(d==0||d==j)&&e>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,u)))-1);n.push(o)}c.push(n)}for(var p,v,C,g=c.length,d=0;d<g;d++)if(h=c[d].length,d>0)for(e=0;e<h;e++){n=e==h-1;j=c[d][n?0:e+1];k=c[d][n?h-1:e];m=c[d-1][n?h-1:e];n=c[d-
  428. 1][n?0:e+1];u=d/(g-1);p=(d-1)/(g-1);v=(e+1)/h;var t=e/h,o=new THREE.UV(1-v,u),u=new THREE.UV(1-t,u),t=new THREE.UV(1-t,p),E=new THREE.UV(1-v,p);d<c.length-1&&(p=this.vertices[j].position.clone(),v=this.vertices[k].position.clone(),C=this.vertices[m].position.clone(),p.normalize(),v.normalize(),C.normalize(),this.faces.push(new THREE.Face3(j,k,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(C.x,C.y,C.z)])),this.faceVertexUvs[0].push([o,u,t]));d>1&&(p=this.vertices[j].position.clone(),
  429. v=this.vertices[m].position.clone(),C=this.vertices[n].position.clone(),p.normalize(),v.normalize(),C.normalize(),this.faces.push(new THREE.Face3(j,m,n,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(C.x,C.y,C.z)])),this.faceVertexUvs[0].push([o,t,E]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
  430. THREE.Torus=function(b,c,d,e){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;b=[];for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){var e=d/this.segmentsT*2*Math.PI,g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));b.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
  431. 1;d<=this.segmentsT;++d){var e=(this.segmentsT+1)*c+d,g=(this.segmentsT+1)*c+d-1,h=(this.segmentsT+1)*(c-1)+d-1,j=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[e][0],b[e][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
  432. THREE.TorusKnot=function(b,c,d,e,g,h,j){function k(b,c,d,e,h,g){c=d/e*b;d=Math.cos(c);return new THREE.Vector3(h*(2+d)*0.5*Math.cos(b),h*(2+d)*Math.sin(b)*0.5,g*h*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=d||64;this.segmentsT=e||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);d=new THREE.Vector3;e=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var m=
  433. b/this.segmentsR*2*this.p*Math.PI,j=c/this.segmentsT*2*Math.PI,g=k(m,j,this.q,this.p,this.radius,this.heightScale),m=k(m+0.01,j,this.q,this.p,this.radius,this.heightScale);d.x=m.x-g.x;d.y=m.y-g.y;d.z=m.z-g.z;e.x=m.x+g.x;e.y=m.y+g.y;e.z=m.z+g.z;h.cross(d,e);e.cross(h,d);h.normalize();e.normalize();m=-this.tube*Math.cos(j);j=this.tube*Math.sin(j);g.x+=m*e.x+j*h.x;g.y+=m*e.y+j*h.y;g.z+=m*e.z+j*h.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=
  434. 0;c<this.segmentsT;++c){var e=(b+1)%this.segmentsR,h=(c+1)%this.segmentsT,g=this.grid[b][c],d=this.grid[e][c],e=this.grid[e][h],h=this.grid[b][h],j=new THREE.UV(b/this.segmentsR,c/this.segmentsT),m=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),n=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),o=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,d,e,h));this.faceVertexUvs[0].push([j,m,n,o])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
  435. THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
  436. THREE.Loader.prototype={addStatusElement:function(){var b=document.createElement("div");b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="rgba(0,0,0,0.25)";b.style.color="#fff";b.style.width="120px";b.style.padding="0.5em 0.5em 0.5em 0.5em";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var c="Loaded ";c+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/1E3).toFixed(2)+" KB";
  437. this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,c,d){b.materials=[];for(var e=0;e<c.length;++e)b.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],d)]},createMaterial:function(b,c){function d(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function e(b,c){var e=new Image;e.onload=function(){if(!d(this.width)||!d(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),e=Math.pow(2,Math.round(Math.log(this.height)/
  438. Math.LN2));b.image.width=c;b.image.height=e;b.image.getContext("2d").drawImage(this,0,0,c,e)}else b.image=this;b.needsUpdate=!0};e.src=c}var g,h,j;g="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?g="MeshPhongMaterial":b.shading=="Basic"&&(g="MeshBasicMaterial"));if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(b.blending==
  439. "Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)h.transparent=b.transparent;if(b.depthTest!==void 0)h.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(b.vertexColors)h.vertexColors=THREE.VertexColors;if(b.mapDiffuse&&c)j=document.createElement("canvas"),h.map=new THREE.Texture(j),h.map.sourceFile=b.mapDiffuse,e(h.map,c+"/"+b.mapDiffuse);else if(b.colorDiffuse)j=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*
  440. 255<<8)+b.colorDiffuse[2]*255,h.color=j,h.opacity=b.transparency;else if(b.DbgColor)h.color=b.DbgColor;if(b.mapLightmap&&c)j=document.createElement("canvas"),h.lightMap=new THREE.Texture(j),h.lightMap.sourceFile=b.mapLightmap,e(h.lightMap,c+"/"+b.mapLightmap);return new THREE[g](h)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
  441. THREE.JSONLoader.prototype.load=function(b){var c=this,d=b.model,e=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(d),b=new Worker(d);b.onmessage=function(b){c.createModel(b.data,e,g);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
  442. THREE.JSONLoader.prototype.createModel=function(b,c,d){var e=new THREE.Geometry,g=b.scale!==void 0?1/b.scale:1;this.init_materials(e,b.materials,d);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var d,g,m,n,o,t,u,p,v,C,E,y,D,x,I=b.faces;t=b.vertices;var A=b.normals,z=b.colors,S=0;for(d=0;d<b.uvs.length;d++)b.uvs[d].length&&S++;for(d=0;d<S;d++)e.faceUvs[d]=[],e.faceVertexUvs[d]=[];n=0;for(o=t.length;n<o;)u=new THREE.Vertex,u.position.x=t[n++]*c,u.position.y=
  443. t[n++]*c,u.position.z=t[n++]*c,e.vertices.push(u);n=0;for(o=I.length;n<o;){c=I[n++];t=c&1;m=c&2;d=c&4;g=c&8;p=c&16;u=c&32;C=c&64;c&=128;t?(E=new THREE.Face4,E.a=I[n++],E.b=I[n++],E.c=I[n++],E.d=I[n++],t=4):(E=new THREE.Face3,E.a=I[n++],E.b=I[n++],E.c=I[n++],t=3);if(m)m=I[n++],E.materials=e.materials[m];m=e.faces.length;if(d)for(d=0;d<S;d++)y=b.uvs[d],v=I[n++],x=y[v*2],v=y[v*2+1],e.faceUvs[d][m]=new THREE.UV(x,v);if(g)for(d=0;d<S;d++){y=b.uvs[d];D=[];for(g=0;g<t;g++)v=I[n++],x=y[v*2],v=y[v*2+1],D[g]=
  444. new THREE.UV(x,v);e.faceVertexUvs[d][m]=D}if(p)p=I[n++]*3,g=new THREE.Vector3,g.x=A[p++],g.y=A[p++],g.z=A[p],E.normal=g;if(u)for(d=0;d<t;d++)p=I[n++]*3,g=new THREE.Vector3,g.x=A[p++],g.y=A[p++],g.z=A[p],E.vertexNormals.push(g);if(C)u=I[n++],u=new THREE.Color(z[u]),E.color=u;if(c)for(d=0;d<t;d++)u=I[n++],u=new THREE.Color(z[u]),E.vertexColors.push(u);e.faces.push(E)}}})(g);(function(){var c,d,g,m;if(b.skinWeights){c=0;for(d=b.skinWeights.length;c<d;c+=2)g=b.skinWeights[c],m=b.skinWeights[c+1],e.skinWeights.push(new THREE.Vector4(g,
  445. m,0,0))}if(b.skinIndices){c=0;for(d=b.skinIndices.length;c<d;c+=2)g=b.skinIndices[c],m=b.skinIndices[c+1],e.skinIndices.push(new THREE.Vector4(g,m,0,0))}e.bones=b.bones;e.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var d,g,m,n,o,t,u,p,v;d=0;for(g=b.morphTargets.length;d<g;d++){e.morphTargets[d]={};e.morphTargets[d].name=b.morphTargets[d].name;e.morphTargets[d].vertices=[];p=e.morphTargets[d].vertices;v=b.morphTargets[d].vertices;m=0;for(n=v.length;m<n;m+=3)o=v[m]*c,t=v[m+1]*
  446. c,u=v[m+2]*c,p.push(new THREE.Vertex(new THREE.Vector3(o,t,u)))}}if(b.morphColors!==void 0){d=0;for(g=b.morphColors.length;d<g;d++){e.morphColors[d]={};e.morphColors[d].name=b.morphColors[d].name;e.morphColors[d].colors=[];n=e.morphColors[d].colors;o=b.morphColors[d].colors;c=0;for(m=o.length;c<m;c+=3)t=new THREE.Color(16755200),t.setRGB(o[c],o[c+1],o[c+2]),n.push(t)}}})(g);(function(){if(b.edges!==void 0){var c,d,g;for(c=0;c<b.edges.length;c+=2)d=b.edges[c],g=b.edges[c+1],e.edges.push(new THREE.Edge(e.vertices[d],
  447. e.vertices[g],d,g))}})();e.computeFaceNormals();c(e)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
  448. THREE.BinaryLoader.prototype={load:function(b){var c=b.model,d=b.callback,e=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(c),g=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),h=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,d,g,e,h)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
  449. c.postMessage(b)},loadAjaxBuffers:function(b,c,d,e,g,h){var j=new XMLHttpRequest,k=e+"/"+b,m=0;j.onreadystatechange=function(){j.readyState==4?j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,d,g,c):alert("Couldn't load ["+k+"] ["+j.status+"]"):j.readyState==3?h&&(m==0&&(m=j.getResponseHeader("Content-Length")),h({total:m,loaded:j.responseText.length})):j.readyState==2&&(m=j.getResponseHeader("Content-Length"))};j.open("GET",k,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
  450. j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,c,d,e){var g=function(c){function d(b,c){var e=o(b,c),f=o(b,c+1),g=o(b,c+2),h=o(b,c+3),j=(h<<1&255|g>>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function g(b,c){var d=o(b,c),e=o(b,c+1),f=o(b,c+2);return(o(b,c+3)<<24)+(f<<16)+(e<<8)+d}function m(b,c){var d=o(b,c);return(o(b,c+1)<<8)+d}function n(b,c){var d=o(b,c);return d>127?d-256:d}function o(b,
  451. c){return b.charCodeAt(c)&255}function t(c){var d,e,f;d=g(b,c);e=g(b,c+z);f=g(b,c+S);c=m(b,c+G);THREE.BinaryLoader.prototype.f3(y,d,e,f,c)}function u(c){var d,e,f,h,j,n;d=g(b,c);e=g(b,c+z);f=g(b,c+S);h=m(b,c+G);j=g(b,c+M);n=g(b,c+F);c=g(b,c+N);THREE.BinaryLoader.prototype.f3n(y,I,d,e,f,h,j,n,c)}function p(c){var d,e,h,j;d=g(b,c);e=g(b,c+f);h=g(b,c+Y);j=g(b,c+O);c=m(b,c+V);THREE.BinaryLoader.prototype.f4(y,d,e,h,j,c)}function v(c){var d,e,h,j,n,o,p,t;d=g(b,c);e=g(b,c+f);h=g(b,c+Y);j=g(b,c+O);n=m(b,
  452. c+V);o=g(b,c+L);p=g(b,c+$);t=g(b,c+T);c=g(b,c+Q);THREE.BinaryLoader.prototype.f4n(y,I,d,e,h,j,n,o,p,t,c)}function C(c){var d,e;d=g(b,c);e=g(b,c+fa);c=g(b,c+U);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],A[d*2],A[d*2+1],A[e*2],A[e*2+1],A[c*2],A[c*2+1])}function E(c){var d,e,f;d=g(b,c);e=g(b,c+ka);f=g(b,c+ga);c=g(b,c+ca);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],A[d*2],A[d*2+1],A[e*2],A[e*2+1],A[f*2],A[f*2+1],A[c*2],A[c*2+1])}var y=this,D=0,x,I=[],A=[],z,S,G,M,F,N,f,Y,O,V,L,$,T,Q,
  453. fa,U,ka,ga,ca,aa,R,P,W,X,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,c);x={signature:b.substr(D,8),header_bytes:o(b,D+8),vertex_coordinate_bytes:o(b,D+9),normal_coordinate_bytes:o(b,D+10),uv_coordinate_bytes:o(b,D+11),vertex_index_bytes:o(b,D+12),normal_index_bytes:o(b,D+13),uv_index_bytes:o(b,D+14),material_index_bytes:o(b,D+15),nvertices:g(b,D+16),nnormals:g(b,D+16+4),nuvs:g(b,D+16+8),ntri_flat:g(b,D+16+12),ntri_smooth:g(b,D+16+16),ntri_flat_uv:g(b,D+16+20),ntri_smooth_uv:g(b,
  454. D+16+24),nquad_flat:g(b,D+16+28),nquad_smooth:g(b,D+16+32),nquad_flat_uv:g(b,D+16+36),nquad_smooth_uv:g(b,D+16+40)};D+=x.header_bytes;z=x.vertex_index_bytes;S=x.vertex_index_bytes*2;G=x.vertex_index_bytes*3;M=x.vertex_index_bytes*3+x.material_index_bytes;F=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;N=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;f=x.vertex_index_bytes;Y=x.vertex_index_bytes*2;O=x.vertex_index_bytes*3;V=x.vertex_index_bytes*4;L=x.vertex_index_bytes*
  455. 4+x.material_index_bytes;$=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;T=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;Q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;fa=x.uv_index_bytes;U=x.uv_index_bytes*2;ka=x.uv_index_bytes;ga=x.uv_index_bytes*2;ca=x.uv_index_bytes*3;c=x.vertex_index_bytes*3+x.material_index_bytes;ea=x.vertex_index_bytes*4+x.material_index_bytes;aa=x.ntri_flat*c;R=x.ntri_smooth*(c+x.normal_index_bytes*3);P=x.ntri_flat_uv*
  456. (c+x.uv_index_bytes*3);W=x.ntri_smooth_uv*(c+x.normal_index_bytes*3+x.uv_index_bytes*3);X=x.nquad_flat*ea;c=x.nquad_smooth*(ea+x.normal_index_bytes*4);ea=x.nquad_flat_uv*(ea+x.uv_index_bytes*4);D+=function(c){for(var e,f,g,h=x.vertex_coordinate_bytes*3,k=c+x.nvertices*h;c<k;c+=h)e=d(b,c),f=d(b,c+x.vertex_coordinate_bytes),g=d(b,c+x.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(y,e,f,g);return x.nvertices*h}(D);D+=function(c){for(var d,e,f,g=x.normal_coordinate_bytes*3,h=c+x.nnormals*g;c<
  457. h;c+=g)d=n(b,c),e=n(b,c+x.normal_coordinate_bytes),f=n(b,c+x.normal_coordinate_bytes*2),I.push(d/127,e/127,f/127);return x.nnormals*g}(D);D+=function(c){for(var e,f,g=x.uv_coordinate_bytes*2,h=c+x.nuvs*g;c<h;c+=g)e=d(b,c),f=d(b,c+x.uv_coordinate_bytes),A.push(e,f);return x.nuvs*g}(D);aa=D+aa;R=aa+R;P=R+P;W=P+W;X=W+X;c=X+c;ea=c+ea;(function(b){var c,d=x.vertex_index_bytes*3+x.material_index_bytes,e=d+x.uv_index_bytes*3,f=b+x.ntri_flat_uv*e;for(c=b;c<f;c+=e)t(c),C(c+d);return f-b})(R);(function(b){var c,
  458. d=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,e=d+x.uv_index_bytes*3,f=b+x.ntri_smooth_uv*e;for(c=b;c<f;c+=e)u(c),C(c+d);return f-b})(P);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes,e=d+x.uv_index_bytes*4,f=b+x.nquad_flat_uv*e;for(c=b;c<f;c+=e)p(c),E(c+d);return f-b})(c);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,e=d+x.uv_index_bytes*4,f=b+x.nquad_smooth_uv*e;for(c=b;c<f;c+=e)v(c),E(c+d);return f-b})(ea);
  459. (function(b){var c,d=x.vertex_index_bytes*3+x.material_index_bytes,e=b+x.ntri_flat*d;for(c=b;c<e;c+=d)t(c);return e-b})(D);(function(b){var c,d=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,e=b+x.ntri_smooth*d;for(c=b;c<e;c+=d)u(c);return e-b})(aa);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes,e=b+x.nquad_flat*d;for(c=b;c<e;c+=d)p(c);return e-b})(W);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,e=b+x.nquad_smooth*
  460. d;for(c=b;c<e;c+=d)v(c);return e-b})(X);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(d))},v:function(b,c,d,e){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(b,c,d,e,g){b.faces.push(new THREE.Face3(c,d,e,null,null,b.materials[g]))},f4:function(b,c,d,e,g,h){b.faces.push(new THREE.Face4(c,d,e,g,null,null,b.materials[h]))},f3n:function(b,c,d,e,g,h,j,k,m){var h=b.materials[h],n=c[k*3],o=c[k*3+1],k=c[k*3+2],
  461. t=c[m*3],u=c[m*3+1],m=c[m*3+2];b.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(t,u,m)],null,h))},f4n:function(b,c,d,e,g,h,j,k,m,n,o){var j=b.materials[j],t=c[m*3],u=c[m*3+1],m=c[m*3+2],p=c[n*3],v=c[n*3+1],n=c[n*3+2],C=c[o*3],E=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face4(d,e,g,h,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(t,u,m),new THREE.Vector3(p,v,n),new THREE.Vector3(C,E,o)],null,j))},uv3:function(b,
  462. c,d,e,g,h,j){var k=[];k.push(new THREE.UV(c,d));k.push(new THREE.UV(e,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,c,d,e,g,h,j,k,m){var n=[];n.push(new THREE.UV(c,d));n.push(new THREE.UV(e,g));n.push(new THREE.UV(h,j));n.push(new THREE.UV(k,m));b.push(n)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
  463. THREE.SceneLoader.prototype={load:function(b,c){var d=this,e=new Worker(b);e.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(b);e.onmessage=function(b){function e(b,c){return c=="relativeToHTML"?b:g+"/"+b}function k(){for(p in F.objects)if(!L.objects[p])if(D=F.objects[p],D.geometry!==void 0){if(z=L.geometries[D.geometry]){M=[];for(Q=0;Q<D.materials.length;Q++)M[Q]=L.materials[D.materials[Q]];x=D.position;r=D.rotation;q=D.quaternion;s=D.scale;q=0;M.length==0&&(M[0]=new THREE.MeshFaceMaterial);
  464. M.length>1&&(M=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(z,M);object.name=p;object.position.set(x[0],x[1],x[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;L.scene.addObject(object);L.objects[p]=object;if(D.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);L.scene.collisions.colliders.push(b)}if(D.castsShadow)b=new THREE.ShadowVolume(z),L.scene.addChild(b),
  465. b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},L.triggers[object.name]=b)}}else x=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(x[0],x[1],x[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=D.visible!==void 0?D.visible:!1,L.scene.addObject(object),
  466. L.objects[p]=object,L.empties[p]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},L.triggers[object.name]=b)}function m(b){return function(c){L.geometries[b]=c;k();f-=1;d.onLoadComplete();o()}}function n(b){return function(c){L.geometries[b]=c}}function o(){d.callbackProgress({totalModels:O,totalTextures:V,loadedModels:O-f,loadedTextures:V-Y},L);d.onLoadProgress();f==0&&Y==0&&c(L)}var t,u,p,v,C,E,y,D,x,I,A,z,S,G,M,F,N,f,Y,O,V,L;F=b.data;b=new THREE.BinaryLoader;N=new THREE.JSONLoader;
  467. Y=f=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var $=!1;for(p in F.objects)if(D=F.objects[p],D.meshCollider){$=!0;break}if($)L.scene.collisions=new THREE.CollisionSystem;if(F.transform){$=F.transform.position;I=F.transform.rotation;var T=F.transform.scale;$&&L.scene.position.set($[0],$[1],$[2]);I&&L.scene.rotation.set(I[0],I[1],I[2]);T&&L.scene.scale.set(T[0],T[1],T[2]);($||I||T)&&L.scene.updateMatrix()}$=function(){Y-=
  468. 1;o();d.onLoadComplete()};for(C in F.cameras){I=F.cameras[C];if(I.type=="perspective")S=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")S=new THREE.Camera,S.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);x=I.position;I=I.target;S.position.set(x[0],x[1],x[2]);S.target.position.set(I[0],I[1],I[2]);L.cameras[C]=S}for(v in F.lights){C=F.lights[v];S=C.color!==void 0?C.color:16777215;I=C.intensity!==void 0?C.intensity:1;if(C.type=="directional")x=
  469. C.direction,light=new THREE.DirectionalLight(S,I),light.position.set(x[0],x[1],x[2]),light.position.normalize();else if(C.type=="point")x=C.position,light=new THREE.PointLight(S,I),light.position.set(x[0],x[1],x[2]);L.scene.addLight(light);L.lights[v]=light}for(E in F.fogs)v=F.fogs[E],v.type=="linear"?G=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(G=new THREE.FogExp2(0,v.density)),I=v.color,G.color.setRGB(I[0],I[1],I[2]),L.fogs[E]=G;if(L.cameras&&F.defaults.camera)L.currentCamera=L.cameras[F.defaults.camera];
  470. if(L.fogs&&F.defaults.fog)L.scene.fog=L.fogs[F.defaults.fog];I=F.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(I[0],I[1],I[2]);L.bgColorAlpha=F.defaults.bgalpha;for(t in F.geometries)if(E=F.geometries[t],E.type=="bin_mesh"||E.type=="ascii_mesh")f+=1,d.onLoadStart();O=f;for(t in F.geometries)E=F.geometries[t],E.type=="cube"?(z=new THREE.Cube(E.width,E.height,E.depth,E.segmentsWidth,E.segmentsHeight,E.segmentsDepth,null,E.flipped,E.sides),L.geometries[t]=z):E.type=="plane"?(z=new THREE.Plane(E.width,
  471. E.height,E.segmentsWidth,E.segmentsHeight),L.geometries[t]=z):E.type=="sphere"?(z=new THREE.Sphere(E.radius,E.segmentsWidth,E.segmentsHeight),L.geometries[t]=z):E.type=="cylinder"?(z=new THREE.Cylinder(E.numSegs,E.topRad,E.botRad,E.height,E.topOffset,E.botOffset),L.geometries[t]=z):E.type=="torus"?(z=new THREE.Torus(E.radius,E.tube,E.segmentsR,E.segmentsT),L.geometries[t]=z):E.type=="icosahedron"?(z=new THREE.Icosahedron(E.subdivisions),L.geometries[t]=z):E.type=="bin_mesh"?b.load({model:e(E.url,
  472. F.urlBaseType),callback:m(t)}):E.type=="ascii_mesh"?N.load({model:e(E.url,F.urlBaseType),callback:m(t)}):E.type=="embedded_mesh"&&(E=F.embeds[E.id])&&N.createModel(E,n(t),"");for(y in F.textures)if(t=F.textures[y],t.url instanceof Array){Y+=t.url.length;for(b=0;b<t.url.length;b++)d.onLoadStart()}else Y+=1,d.onLoadStart();V=Y;for(y in F.textures){t=F.textures[y];if(t.mapping!=void 0&&THREE[t.mapping]!=void 0)t.mapping=new THREE[t.mapping];if(t.url instanceof Array){for(var b=[],Q=0;Q<t.url.length;Q++)b[Q]=
  473. e(t.url[Q],F.urlBaseType);b=THREE.ImageUtils.loadTextureCube(b,t.mapping,$)}else{b=THREE.ImageUtils.loadTexture(e(t.url,F.urlBaseType),t.mapping,$);if(THREE[t.minFilter]!=void 0)b.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=void 0)b.magFilter=THREE[t.magFilter]}L.textures[y]=b}for(u in F.materials){y=F.materials[u];for(A in y.parameters)if(A=="envMap"||A=="map"||A=="lightMap")y.parameters[A]=L.textures[y.parameters[A]];else if(A=="shading")y.parameters[A]=y.parameters[A]=="flat"?THREE.FlatShading:
  474. THREE.SmoothShading;else if(A=="blending")y.parameters[A]=THREE[y.parameters[A]]?THREE[y.parameters[A]]:THREE.NormalBlending;else if(A=="combine")y.parameters[A]=y.parameters[A]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(A=="vertexColors")if(y.parameters[A]=="face")y.parameters[A]=THREE.FaceColors;else if(y.parameters[A])y.parameters[A]=THREE.VertexColors;if(y.parameters.opacity!==void 0&&y.parameters.opacity<1)y.parameters.transparent=!0;y=new THREE[y.type](y.parameters);
  475. L.materials[u]=y}k();d.callbackSync(L)}}};
  476. THREE.MarchingCubes=function(b,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;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=
  477. 0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,g){return b+(c-b)*g};this.VIntX=function(b,c,g,h,j,k,m,n,o,t){j=(j-o)/(t-o);o=this.normal_cache;c[h]=k+j*this.delta;c[h+1]=m;c[h+2]=n;g[h]=this.lerp(o[b],o[b+3],j);g[h+1]=this.lerp(o[b+1],o[b+4],j);g[h+2]=this.lerp(o[b+2],o[b+5],j)};this.VIntY=function(b,c,g,h,j,k,m,n,o,t){j=(j-o)/(t-o);o=this.normal_cache;c[h]=k;c[h+1]=m+j*this.delta;c[h+
  478. 2]=n;c=b+this.yd*3;g[h]=this.lerp(o[b],o[c],j);g[h+1]=this.lerp(o[b+1],o[c+1],j);g[h+2]=this.lerp(o[b+2],o[c+2],j)};this.VIntZ=function(b,c,g,h,j,k,m,n,o,t){j=(j-o)/(t-o);o=this.normal_cache;c[h]=k;c[h+1]=m;c[h+2]=n+j*this.delta;c=b+this.zd*3;g[h]=this.lerp(o[b],o[c],j);g[h+1]=this.lerp(o[b+1],o[c+1],j);g[h+2]=this.lerp(o[b+2],o[c+2],j)};this.compNorm=function(b){var c=b*3;this.normal_cache[c]==0&&(this.normal_cache[c]=this.field[b-1]-this.field[b+1],this.normal_cache[c+1]=this.field[b-this.yd]-this.field[b+
  479. this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,g,h,j,k){var m=h+1,n=h+this.yd,o=h+this.zd,t=m+this.yd,u=m+this.zd,p=h+this.yd+this.zd,v=m+this.yd+this.zd,C=0,E=this.field[h],y=this.field[m],D=this.field[n],x=this.field[t],I=this.field[o],A=this.field[u],z=this.field[p],S=this.field[v];E<j&&(C|=1);y<j&&(C|=2);D<j&&(C|=8);x<j&&(C|=4);I<j&&(C|=16);A<j&&(C|=32);z<j&&(C|=128);S<j&&(C|=64);var G=THREE.edgeTable[C];if(G==0)return 0;var M=this.delta,
  480. F=b+M,N=c+M,M=g+M;G&1&&(this.compNorm(h),this.compNorm(m),this.VIntX(h*3,this.vlist,this.nlist,0,j,b,c,g,E,y));G&2&&(this.compNorm(m),this.compNorm(t),this.VIntY(m*3,this.vlist,this.nlist,3,j,F,c,g,y,x));G&4&&(this.compNorm(n),this.compNorm(t),this.VIntX(n*3,this.vlist,this.nlist,6,j,b,N,g,D,x));G&8&&(this.compNorm(h),this.compNorm(n),this.VIntY(h*3,this.vlist,this.nlist,9,j,b,c,g,E,D));G&16&&(this.compNorm(o),this.compNorm(u),this.VIntX(o*3,this.vlist,this.nlist,12,j,b,c,M,I,A));G&32&&(this.compNorm(u),
  481. this.compNorm(v),this.VIntY(u*3,this.vlist,this.nlist,15,j,F,c,M,A,S));G&64&&(this.compNorm(p),this.compNorm(v),this.VIntX(p*3,this.vlist,this.nlist,18,j,b,N,M,z,S));G&128&&(this.compNorm(o),this.compNorm(p),this.VIntY(o*3,this.vlist,this.nlist,21,j,b,c,M,I,z));G&256&&(this.compNorm(h),this.compNorm(o),this.VIntZ(h*3,this.vlist,this.nlist,24,j,b,c,g,E,I));G&512&&(this.compNorm(m),this.compNorm(u),this.VIntZ(m*3,this.vlist,this.nlist,27,j,F,c,g,y,A));G&1024&&(this.compNorm(t),this.compNorm(v),this.VIntZ(t*
  482. 3,this.vlist,this.nlist,30,j,F,N,g,x,S));G&2048&&(this.compNorm(n),this.compNorm(p),this.VIntZ(n*3,this.vlist,this.nlist,33,j,b,N,g,D,z));C<<=4;for(j=h=0;THREE.triTable[C+j]!=-1;)b=C+j,c=b+1,g=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],k),j+=3,h++;return h};this.posnormtriv=function(b,c,g,h,j,k){var m=this.count*3;this.positionArray[m]=b[g];this.positionArray[m+1]=b[g+1];this.positionArray[m+2]=b[g+2];this.positionArray[m+3]=b[h];this.positionArray[m+
  483. 4]=b[h+1];this.positionArray[m+5]=b[h+2];this.positionArray[m+6]=b[j];this.positionArray[m+7]=b[j+1];this.positionArray[m+8]=b[j+2];this.normalArray[m]=c[g];this.normalArray[m+1]=c[g+1];this.normalArray[m+2]=c[g+2];this.normalArray[m+3]=c[h];this.normalArray[m+4]=c[h+1];this.normalArray[m+5]=c[h+2];this.normalArray[m+6]=c[j];this.normalArray[m+7]=c[j+1];this.normalArray[m+8]=c[j+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;
  484. this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,g,h,j){var k=this.size*Math.sqrt(h/j),m=g*this.size,n=c*this.size,o=b*this.size,t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var u=Math.floor(n-k);u<1&&(u=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var p=Math.floor(o-k);p<1&&(p=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-
  485. 1);for(var v,C,E,y,D,x;t<m;t++){o=this.size2*t;C=t/this.size-g;D=C*C;for(C=u;C<n;C++){E=o+this.size*C;v=C/this.size-c;x=v*v;for(v=p;v<k;v++)y=v/this.size-b,y=h/(1.0E-6+y*y+x+D)-j,y>0&&(this.field[E+v]+=y)}}};this.addPlaneX=function(b,c){var g,h,j,k,m,n=this.size,o=this.yd,t=this.zd,u=this.field,p=n*Math.sqrt(b/c);p>n&&(p=n);for(g=0;g<p;g++)if(h=g/n,h*=h,k=b/(1.0E-4+h)-c,k>0)for(h=0;h<n;h++){m=g+h*o;for(j=0;j<n;j++)u[t*j+m]+=k}};this.addPlaneY=function(b,c){var g,h,j,k,m,n,o=this.size,t=this.yd,u=
  486. this.zd,p=this.field,v=o*Math.sqrt(b/c);v>o&&(v=o);for(h=0;h<v;h++)if(g=h/o,g*=g,k=b/(1.0E-4+g)-c,k>0){m=h*t;for(g=0;g<o;g++){n=m+g;for(j=0;j<o;j++)p[u*j+n]+=k}}};this.addPlaneZ=function(b,c){var g,h,j,k,m,n;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(j=0;j<dist;j++)if(g=j/size,g*=g,k=b/(1.0E-4+g)-c,k>0){m=zd*j;for(h=0;h<size;h++){n=m+h*yd;for(g=0;g<size;g++)field[n+g]+=k}}};this.reset=function(){var b;for(b=0;b<this.size3;b++)this.normal_cache[b*
  487. 3]=0,this.field[b]=0};this.render=function(b){this.begin();var c,g,h,j,k,m,n,o,t,u=this.size-2;for(j=1;j<u;j++){t=this.size2*j;n=(j-this.halfsize)/this.halfsize;for(h=1;h<u;h++){o=t+this.size*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<u;g++)k=(g-this.halfsize)/this.halfsize,c=o+g,this.polygonize(k,m,n,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,g=[];this.render(function(h){var j,k,m,n,o,t,u,p;for(j=0;j<h.count;j++)u=j*3,o=u+1,p=u+2,k=h.positionArray[u],
  488. m=h.positionArray[o],n=h.positionArray[p],t=new THREE.Vector3(k,m,n),k=h.normalArray[u],m=h.normalArray[o],n=h.normalArray[p],u=new THREE.Vector3(k,m,n),u.normalize(),o=new THREE.Vertex(t),c.vertices.push(o),g.push(u);nfaces=h.count/3;for(j=0;j<nfaces;j++)u=(b+j)*3,o=u+1,p=u+2,t=g[u],k=g[o],m=g[p],u=new THREE.Face3(u,o,p,[t,k,m]),c.faces.push(u);b+=nfaces;h.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  489. 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,
  490. 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,
  491. 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]);
  492. 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,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,
  493. -1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
  494. -1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
  495. -1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
  496. 8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
  497. -1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
  498. 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
  499. -1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
  500. 10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
  501. 6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
  502. 8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
  503. 2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
  504. -1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
  505. -1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
  506. -1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
  507. 1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
  508. -1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
  509. 2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
  510. 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
  511. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
  512. 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]);
  513. THREE.Trident=function(b){function c(c){return new THREE.Mesh(new THREE.Cylinder(30,0.1,b.length/20,b.length/5),new THREE.MeshBasicMaterial({color:c}))}function d(b,c){var d=new THREE.Geometry;d.vertices=[new THREE.Vertex,new THREE.Vertex(b)];return new THREE.Line(d,new THREE.LineBasicMaterial({color:c}))}THREE.Object3D.call(this);var e=Math.PI/2,g,b=b||THREE.Trident.defaultParams;if(b!==THREE.Trident.defaultParams)for(g in THREE.Trident.defaultParams)b.hasOwnProperty(g)||(b[g]=THREE.Trident.defaultParams[g]);
  514. this.scale=new THREE.Vector3(b.scale,b.scale,b.scale);this.addChild(d(new THREE.Vector3(b.length,0,0),b.xAxisColor));this.addChild(d(new THREE.Vector3(0,b.length,0),b.yAxisColor));this.addChild(d(new THREE.Vector3(0,0,b.length),b.zAxisColor));if(b.showArrows)g=c(b.xAxisColor),g.rotation.y=-e,g.position.x=b.length,this.addChild(g),g=c(b.yAxisColor),g.rotation.x=e,g.position.y=b.length,this.addChild(g),g=c(b.zAxisColor),g.rotation.y=Math.PI,g.position.z=b.length,this.addChild(g)};
  515. THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(b,c){this.point=b;this.normal=c};THREE.SphereCollider=function(b,c){this.center=b;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(b,c){this.min=b;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
  516. THREE.MeshCollider=function(b,c){this.mesh=b;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(b){this.colliders=this.colliders.concat(b.colliders);this.hits=this.hits.concat(b.hits)};
  517. THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,d,e,g,h=0;c=0;for(d=this.colliders.length;c<d;c++)if(g=this.colliders[c],e=this.rayCast(b,g),e<Number.MAX_VALUE)g.distance=e,e>h?this.hits.push(g):this.hits.unshift(g),h=e;return this.hits};
  518. THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var d=0;c[d]instanceof THREE.MeshCollider;){var e=this.rayMesh(b,c[d]);if(e.dist<Number.MAX_VALUE){c[d].distance=e.dist;c[d].faceIndex=e.faceIndex;break}d++}if(d>c.length)return null;return c[d]};
  519. THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)};
  520. THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var d=this.makeRayLocal(b,c.mesh),e=Number.MAX_VALUE,g,h=0;h<c.numFaces;h++){var j=c.mesh.geometry.faces[h],k=c.mesh.geometry.vertices[j.a].position,m=c.mesh.geometry.vertices[j.b].position,n=c.mesh.geometry.vertices[j.c].position,o=j instanceof THREE.Face4?c.mesh.geometry.vertices[j.d].position:null;j instanceof THREE.Face3?(j=this.rayTriangle(d,k,m,n,e,this.collisionNormal),j<e&&(e=j,g=h,c.normal.copy(this.collisionNormal),c.normal.normalize())):
  521. j instanceof THREE.Face4&&(j=this.rayTriangle(d,k,m,o,e,this.collisionNormal),j<e&&(e=j,g=h,c.normal.copy(this.collisionNormal),c.normal.normalize()),j=this.rayTriangle(d,m,n,o,e,this.collisionNormal),j<e&&(e=j,g=h,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:e,faceIndex:g}};
  522. THREE.CollisionSystem.prototype.rayTriangle=function(b,c,d,e,g,h){var j=THREE.CollisionSystem.__v1,k=THREE.CollisionSystem.__v2;h.set(0,0,0);j.sub(d,c);k.sub(e,d);h.cross(j,k);k=h.dot(b.direction);if(!(k<0))return Number.MAX_VALUE;j=h.dot(c)-h.dot(b.origin);if(!(j<=0))return Number.MAX_VALUE;if(!(j>=k*g))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);Math.abs(h.x)>Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=k.y-c.y,h=d.y-c.y,
  523. g=e.y-c.y,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,h=d.x-c.x,g=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(b=k.x-c.x,h=d.x-c.x,g=e.x-c.x,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,h=d.x-c.x,g=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y);c=h*e-d*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(b*e-k*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=h*k-d*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return j};
  524. THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var d=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,d);var e=THREE.CollisionSystem.__r;e.origin.copy(b.origin);e.direction.copy(b.direction);d.multiplyVector3(e.origin);d.rotateAxis(e.direction);e.direction.normalize();return e};
  525. THREE.CollisionSystem.prototype.rayBox=function(b,c){var d;c.dynamic&&c.mesh&&c.mesh.matrixWorld?d=this.makeRayLocal(b,c.mesh):(d=THREE.CollisionSystem.__r,d.origin.copy(b.origin),d.direction.copy(b.direction));var e=0,g=0,h=0,j=0,k=0,m=0,n=!0;d.origin.x<c.min.x?(e=c.min.x-d.origin.x,e/=d.direction.x,n=!1,j=-1):d.origin.x>c.max.x&&(e=c.max.x-d.origin.x,e/=d.direction.x,n=!1,j=1);d.origin.y<c.min.y?(g=c.min.y-d.origin.y,g/=d.direction.y,n=!1,k=-1):d.origin.y>c.max.y&&(g=c.max.y-d.origin.y,g/=d.direction.y,
  526. n=!1,k=1);d.origin.z<c.min.z?(h=c.min.z-d.origin.z,h/=d.direction.z,n=!1,m=-1):d.origin.z>c.max.z&&(h=c.max.z-d.origin.z,h/=d.direction.z,n=!1,m=1);if(n)return-1;n=0;g>e&&(n=1,e=g);h>e&&(n=2,e=h);switch(n){case 0:k=d.origin.y+d.direction.y*e;if(k<c.min.y||k>c.max.y)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*e;if(d<c.min.z||d>c.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=d.origin.x+d.direction.x*e;if(j<c.min.x||j>c.max.x)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*
  527. e;if(d<c.min.z||d>c.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:j=d.origin.x+d.direction.x*e;if(j<c.min.x||j>c.max.x)return Number.MAX_VALUE;k=d.origin.y+d.direction.y*e;if(k<c.min.y||k>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,m)}return e};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var d=b.direction.dot(c.normal),e=c.point.dot(c.normal);if(d<0)d=(e-b.origin.dot(c.normal))/d;else return Number.MAX_VALUE;return d>0?d:Number.MAX_VALUE};
  528. THREE.CollisionSystem.prototype.raySphere=function(b,c){var d=c.center.clone().subSelf(b.origin);if(d.lengthSq<c.radiusSq)return-1;var e=d.dot(b.direction.clone());if(e<=0)return Number.MAX_VALUE;d=c.radiusSq-(d.lengthSq()-e*e);if(d>=0)return Math.abs(e)-Math.sqrt(d);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
  529. THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,d=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),d=new THREE.BoxCollider(d,c);d.mesh=b;return d};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c};
  530. THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};