Three.js 286 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. // Three.js r42 - 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,e){this.r=b;this.g=c;this.b=e;this.updateHex()},setHSV:function(b,c,e){var f,g,h,k,m,n;if(e==0)f=g=h=0;else switch(k=Math.floor(b*6),m=b*6-k,b=e*(1-c),n=e*(1-c*m),c=e*(1-c*(1-m)),k){case 1:f=n;g=e;h=b;break;case 2:f=b;g=e;h=c;break;case 3:f=b;g=n;h=e;break;case 4:f=c;g=b;h=e;break;case 5:f=e;g=b;h=n;break;case 6:case 0:f=e,g=c,h=b}this.setRGB(f,
  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.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this},divideScalar:function(b){b?
  6. (this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)},
  7. unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.set(b||0,c||0,e||0)};
  8. THREE.Vector3.prototype={set:function(b,c,e){this.x=b;this.y=c;this.z=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=
  9. b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){return this.divide(this,b)},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*
  10. b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*
  11. b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},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))},isZero:function(){return this.lengthSq()<1.0E-4}};
  12. THREE.Vector4=function(b,c,e,f){this.set(b||0,c||0,e||0,f||1)};
  13. THREE.Vector4.prototype={set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=
  14. b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},
  15. setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){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;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  16. THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c<e;c++)f=f.concat(this.intersectObject(b[c]));f.sort(function(b,e){return b.distance-e.distance});return f},intersectObject:function(b){function c(b,e,c){var f,c=c.matrixWorld.getPosition();f=c.clone().subSelf(b).dot(e);b=b.clone().addSelf(e.clone().multiplyScalar(f));return c.distanceTo(b)}function e(b,e,c,f){var f=f.clone().subSelf(e),c=c.clone().subSelf(e),
  17. g=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(g),h=c.dot(c),c=c.dot(g),g=1/(b*h-e*e),h=(h*f-e*c)*g,b=(b*c-e*f)*g;return h>0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,h,k,m,n,p,o,u,v,w,x=b.geometry,
  18. B=x.vertices,A=[],f=0;for(g=x.faces.length;f<g;f++)if(h=x.faces[f],v=this.origin.clone(),w=this.direction.clone(),p=b.matrixWorld,k=p.multiplyVector3(B[h.a].position.clone()),m=p.multiplyVector3(B[h.b].position.clone()),n=p.multiplyVector3(B[h.c].position.clone()),p=h instanceof THREE.Face4?p.multiplyVector3(B[h.d].position.clone()):null,o=b.matrixRotationWorld.multiplyVector3(h.normal.clone()),u=w.dot(o),b.doubleSided||(b.flipSided?u>0:u<0))if(o=o.dot((new THREE.Vector3).sub(k,v))/u,v=v.addSelf(w.multiplyScalar(o)),
  19. h instanceof THREE.Face3)e(v,k,m,n)&&(h={distance:this.origin.distanceTo(v),point:v,face:h,object:b},A.push(h));else if(h instanceof THREE.Face4&&(e(v,k,m,p)||e(v,m,n,p)))h={distance:this.origin.distanceTo(v),point:v,face:h,object:b},A.push(h);return A}else return[]}};
  20. THREE.Rectangle=function(){function b(){h=f-c;k=g-e}var c,e,f,g,h,k,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,k,o,u){m=!1;c=h;e=k;f=o;g=u;b()};this.addPoint=function(h,k){m?(m=!1,c=h,e=k,f=h,g=k):(c=c<h?c:h,e=e<k?e:k,f=f>h?f:h,g=g>k?g:k);b()};this.add3Points=
  21. function(h,k,o,u,v,w){m?(m=!1,c=h<o?h<v?h:v:o<v?o:v,e=k<u?k<w?k:w:u<w?u:w,f=h>o?h>v?h:v:o>v?o:v,g=k>u?k>w?k:w:u>w?u:w):(c=h<o?h<v?h<c?h:c:v<c?v:c:o<v?o<c?o:c:v<c?v:c,e=k<u?k<w?k<e?k:e:w<e?w:e:u<w?u<e?u:e:w<e?w:e,f=h>o?h>v?h>f?h:f:v>f?v:f:o>v?o>f?o:f:v>f?v:f,g=k>u?k>w?k>g?k:g:w>g?w:g:u>w?u>g?u:g:w>g?w:g);b()};this.addRectangle=function(h){m?(m=!1,c=h.getLeft(),e=h.getTop(),f=h.getRight(),g=h.getBottom()):(c=c<h.getLeft()?c:h.getLeft(),e=e<h.getTop()?e:h.getTop(),f=f>h.getRight()?f:h.getRight(),g=g>
  22. h.getBottom()?g:h.getBottom());b()};this.inflate=function(h){c-=h;e-=h;f+=h;g+=h;b()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();e=e>h.getTop()?e:h.getTop();f=f<h.getRight()?f:h.getRight();g=g<h.getBottom()?g:h.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(g,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){m=!0;g=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]};
  23. 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,e,f,g,h,k,m,n,p,o,u,v,w,x,B){this.set(b||1,c||0,e||0,f||0,g||0,h||1,k||0,m||0,n||0,p||0,o||1,u||0,v||0,w||0,x||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  24. THREE.Matrix4.prototype={set:function(b,c,e,f,g,h,k,m,n,p,o,u,v,w,x,B){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=h;this.n23=k;this.n24=m;this.n31=n;this.n32=p;this.n33=o;this.n34=u;this.n41=v;this.n42=w;this.n43=x;this.n44=B;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,e){var f=THREE.Matrix4.__v1,
  25. g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;f.cross(e,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(e,h).normalize());g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g;b.y=(this.n21*c+this.n22*e+this.n23*
  26. f+this.n24)*g;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+e*this.n32+f*this.n33;b.normalize();
  27. 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 e=b.n11,f=b.n12,g=b.n13,h=b.n14,k=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,u=b.n32,v=b.n33,w=b.n34,x=b.n41,B=b.n42,A=b.n43,y=b.n44,K=c.n11,E=c.n12,J=c.n13,I=c.n14,G=c.n21,N=c.n22,
  28. M=c.n23,Q=c.n24,F=c.n31,U=c.n32,D=c.n33,da=c.n34,j=c.n41,ca=c.n42,V=c.n43,W=c.n44;this.n11=e*K+f*G+g*F+h*j;this.n12=e*E+f*N+g*U+h*ca;this.n13=e*J+f*M+g*D+h*V;this.n14=e*I+f*Q+g*da+h*W;this.n21=k*K+m*G+n*F+p*j;this.n22=k*E+m*N+n*U+p*ca;this.n23=k*J+m*M+n*D+p*V;this.n24=k*I+m*Q+n*da+p*W;this.n31=o*K+u*G+v*F+w*j;this.n32=o*E+u*N+v*U+w*ca;this.n33=o*J+u*M+v*D+w*V;this.n34=o*I+u*Q+v*da+w*W;this.n41=x*K+B*G+A*F+y*j;this.n42=x*E+B*N+A*U+y*ca;this.n43=x*J+B*M+A*D+y*V;this.n44=x*I+B*Q+A*da+y*W;return this},
  29. multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[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;
  30. this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,m=this.n24,n=this.n31,p=this.n32,o=this.n33,u=this.n34,v=this.n41,w=this.n42,x=this.n43,B=this.n44;return f*k*p*v-e*m*p*v-f*h*o*v+c*m*o*v+e*h*u*v-c*k*u*v-f*k*n*w+e*m*n*w+f*g*o*w-b*m*o*w-e*g*u*w+b*k*u*w+f*h*n*x-c*m*n*x-f*g*p*x+b*m*p*x+c*g*u*x-b*h*u*x-e*h*n*B+c*k*n*B+e*g*p*B-b*k*p*B-c*g*o*B+b*h*o*B},transpose:function(){var b;
  31. 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=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;
  32. b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;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;
  33. 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]=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},
  34. setTranslation:function(b,c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,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},
  35. setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),g=1-e,h=b.x,k=b.y,m=b.z,n=g*h,p=g*k;this.set(n*h+e,n*k-f*m,n*m+f*k,0,n*k+f*m,p*k+e,p*m-f*h,0,n*m-f*k,p*m+f*h,g*m*m+e,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,
  36. this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;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,c){var e=b.x,f=b.y,g=b.z,h=Math.cos(e),e=Math.sin(e),k=Math.cos(f),f=Math.sin(f),m=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var n=k*m,p=k*g,o=f*m,u=f*g;
  37. this.n11=n+u*e;this.n12=o*e-p;this.n13=h*f;this.n21=h*g;this.n22=h*m;this.n23=-e;this.n31=p*e-o;this.n32=u+n*e;this.n33=h*k;break;case "ZXY":n=k*m;p=k*g;o=f*m;u=f*g;this.n11=n-u*e;this.n12=-h*g;this.n13=o+p*e;this.n21=p+o*e;this.n22=h*m;this.n23=u-n*e;this.n31=-h*f;this.n32=e;this.n33=h*k;break;case "ZYX":n=h*m;p=h*g;o=e*m;u=e*g;this.n11=k*m;this.n12=o*f-p;this.n13=n*f+u;this.n21=k*g;this.n22=u*f+n;this.n23=p*f-o;this.n31=-f;this.n32=e*k;this.n33=h*k;break;case "YZX":n=h*k;p=h*f;o=e*k;u=e*f;this.n11=
  38. k*m;this.n12=u-n*g;this.n13=o*g+p;this.n21=g;this.n22=h*m;this.n23=-e*m;this.n31=-f*m;this.n32=p*g+o;this.n33=n-u*g;break;case "XZY":n=h*k;p=h*f;o=e*k;u=e*f;this.n11=k*m;this.n12=-g;this.n13=f*m;this.n21=n*g+u;this.n22=h*m;this.n23=p*g-o;this.n31=o*g-p;this.n32=e*m;this.n33=u*g+n;break;default:n=h*m,p=h*g,o=e*m,u=e*g,this.n11=k*m,this.n12=-k*g,this.n13=f,this.n21=p+o*f,this.n22=n-u*f,this.n23=-e*k,this.n31=u-n*f,this.n32=o+p*f,this.n33=h*k}return this},setRotationFromQuaternion:function(b){var c=
  39. b.x,e=b.y,f=b.z,g=b.w,h=c+c,k=e+e,m=f+f,b=c*h,n=c*k;c*=m;var p=e*k;e*=m;f*=m;h*=g;k*=g;g*=m;this.n11=1-(p+f);this.n12=n-g;this.n13=c+k;this.n21=n+g;this.n22=1-(b+f);this.n23=e-h;this.n31=c-k;this.n32=e+h;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},
  40. extractRotation:function(b,c){var e=1/c.x,f=1/c.y,g=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
  41. THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,h=b.n14,k=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,u=b.n32,v=b.n33,w=b.n34,x=b.n41,B=b.n42,A=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*w*B-p*v*B+p*u*A-m*w*A-n*u*y+m*v*y;c.n12=h*v*B-g*w*B-h*u*A+f*w*A+g*u*y-f*v*y;c.n13=g*p*B-h*n*B+h*m*A-f*p*A-g*m*y+f*n*y;c.n14=h*n*u-g*p*u-h*m*v+f*p*v+g*m*w-f*n*w;c.n21=p*v*x-n*w*x-p*o*A+k*w*A+n*o*y-k*v*y;c.n22=g*w*x-h*v*x+h*o*A-e*w*A-g*o*y+e*v*y;c.n23=h*n*x-g*p*x-h*k*A+e*p*A+g*k*y-e*n*y;c.n24=
  42. g*p*o-h*n*o+h*k*v-e*p*v-g*k*w+e*n*w;c.n31=m*w*x-p*u*x+p*o*B-k*w*B-m*o*y+k*u*y;c.n32=h*u*x-f*w*x-h*o*B+e*w*B+f*o*y-e*u*y;c.n33=g*p*x-h*m*x+h*k*B-e*p*B-f*k*y+e*m*y;c.n34=h*m*o-f*p*o-h*k*u+e*p*u+f*k*w-e*m*w;c.n41=n*u*x-m*v*x-n*o*B+k*v*B+m*o*A-k*u*A;c.n42=f*v*x-g*u*x+g*o*B-e*v*B-f*o*A+e*u*A;c.n43=g*m*x-f*n*x-g*k*B+e*n*B+f*k*A-e*m*A;c.n44=f*n*o-g*m*o+g*k*u-e*n*u-f*k*v+e*m*v;c.multiplyScalar(1/b.determinant());return c};
  43. THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=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,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*h;e[3]=b*k;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*u;return c};
  44. THREE.Matrix4.makeFrustum=function(b,c,e,f,g,h){var k;k=new THREE.Matrix4;k.n11=2*g/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*g/(f-e);k.n23=(f+e)/(f-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(h+g)/(h-g);k.n34=-2*h*g/(h-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,e,f)};
  45. THREE.Matrix4.makeOrtho=function(b,c,e,f,g,h){var k,m,n,p;k=new THREE.Matrix4;m=c-b;n=e-f;p=h-g;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((e+f)/n);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((h+g)/p);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
  46. 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.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;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;
  47. this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""};
  48. 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)===
  49. -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 e,f,g;e=0;for(f=this.children.length;e<f;e++){g=this.children[e];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);
  50. this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),
  51. this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,c,e)}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)};
  52. THREE.Quaternion.prototype={set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;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,e=b.x*c,f=b.y*c,g=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-g),g=Math.sin(-g),h=Math.cos(e),e=Math.sin(e),k=b*c,m=f*g;this.w=k*h-m*e;this.x=k*e+m*h;this.y=f*c*h+b*g*e;this.z=b*g*h-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);this.x=b.x*f;this.y=b.y*
  53. f;this.z=b.z*f;this.w=Math.cos(e);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},
  54. multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,g=this.w,h=b.x,k=b.y,m=b.z,b=b.w;this.x=c*b+g*h+e*m-f*k;this.y=e*b+g*k+f*h-c*m;this.z=f*b+g*m+c*k-e*h;this.w=g*b-c*h-e*k-f*m;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 e=b.x,f=b.y,g=b.z,h=this.x,k=this.y,m=this.z,n=this.w,p=n*e+k*g-m*f,o=
  55. n*f+m*e-h*g,u=n*g+h*f-k*e,e=-h*e-k*f-m*g;c.x=p*n+e*-h+o*-m-u*-k;c.y=o*n+e*-k+u*-h-p*-m;c.z=u*n+e*-m+p*-k-o*-h;return c}};
  56. THREE.Quaternion.slerp=function(b,c,e,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var h=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*h)/k;f=Math.sin(f*h)/k;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
  57. THREE.Face3=function(b,c,e,f,g,h){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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};
  58. THREE.Face4=function(b,c,e,f,g,h,k){this.a=b;this.b=c;this.c=e;this.d=f;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=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)};
  59. 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};
  60. THREE.Geometry.prototype={computeCentroids:function(){var b,c,e;b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),e.centroid.divideScalar(3)):e instanceof THREE.Face4&&(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),
  61. e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,g,h,k,m=new THREE.Vector3,n=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];if(b&&h.vertexNormals.length){m.set(0,0,0);c=0;for(e=h.vertexNormals.length;c<e;c++)m.addSelf(h.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[h.a],e=this.vertices[h.b],k=this.vertices[h.c],m.sub(k.position,e.position),n.sub(c.position,e.position),m.crossSelf(n);m.isZero()||
  62. m.normalize();h.normal.copy(m)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=
  63. this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),
  64. e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,g,h,j){m=b.vertices[e].position;n=b.vertices[c].position;p=b.vertices[f].position;o=k[g];u=k[h];v=k[j];w=n.x-m.x;x=p.x-m.x;B=n.y-m.y;A=p.y-m.y;y=n.z-m.z;K=p.z-m.z;E=u.u-o.u;J=v.u-o.u;I=u.v-o.v;G=v.v-o.v;N=1/(E*G-J*I);U.set((G*w-I*x)*
  65. N,(G*B-I*A)*N,(G*y-I*K)*N);D.set((E*x-J*w)*N,(E*A-J*B)*N,(E*K-J*y)*N);Q[e].addSelf(U);Q[c].addSelf(U);Q[f].addSelf(U);F[e].addSelf(D);F[c].addSelf(D);F[f].addSelf(D)}var c,e,f,g,h,k,m,n,p,o,u,v,w,x,B,A,y,K,E,J,I,G,N,M,Q=[],F=[],U=new THREE.Vector3,D=new THREE.Vector3,da=new THREE.Vector3,j=new THREE.Vector3,ca=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)Q[c]=new THREE.Vector3,F[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)h=this.faces[c],k=this.faceVertexUvs[0][c],h instanceof
  66. 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 V=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){h=this.faces[c];for(f=0;f<h.vertexNormals.length;f++)ca.copy(h.vertexNormals[f]),g=h[V[f]],M=Q[g],da.copy(M),da.subSelf(ca.multiplyScalar(ca.dot(M))).normalize(),j.cross(h.vertexNormals[f],M),g=j.dot(F[g]),g=g<0?-1:1,h.vertexTangents[f]=new THREE.Vector4(da.x,da.y,da.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var b;
  67. 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,e=this.vertices.length;c<e;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;
  68. 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=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}function c(b,e,c){b[e]===
  69. void 0?(b[e]={set:{},array:[]},b[e].set[c]=1,b[e].array.push(c)):b[e].set[c]===void 0&&(b[e].set[c]=1,b[e].array.push(c))}var e,f,g,h,k,m={};e=0;for(f=this.faces.length;e<f;e++)k=this.faces[e],k instanceof THREE.Face3?(g=b(k.a,k.b),c(m,g,e),g=b(k.b,k.c),c(m,g,e),g=b(k.a,k.c),c(m,g,e)):k instanceof THREE.Face4&&(g=b(k.b,k.d),c(m,g,e),g=b(k.a,k.b),c(m,g,e),g=b(k.a,k.d),c(m,g,e),g=b(k.b,k.c),c(m,g,e),g=b(k.c,k.d),c(m,g,e));e=0;for(f=this.edges.length;e<f;e++){k=this.edges[e];g=k.vertexIndices[0];h=k.vertexIndices[1];
  70. k.faceIndices=m[b(g,h)].array;for(g=0;g<k.faceIndices.length;g++)h=k.faceIndices[g],k.faces.push(this.faces[h])}}};THREE.GeometryIdCounter=0;
  71. THREE.Spline=function(b){function c(b,e,c,f,g,h,k){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*k+(-3*(e-c)-2*b-f)*h+b*g+e}this.points=b;var e=[],f={x:0,y:0,z:0},g,h,k,m,n,p,o,u,v;this.initFromArray=function(b){this.points=[];for(var e=0;e<b.length;e++)this.points[e]={x:b[e][0],y:b[e][1],z:b[e][2]}};this.getPoint=function(b){g=(this.points.length-1)*b;h=Math.floor(g);k=g-h;e[0]=h==0?h:h-1;e[1]=h;e[2]=h>this.points.length-2?h:h+1;e[3]=h>this.points.length-3?h:h+2;p=this.points[e[0]];o=this.points[e[1]];
  72. u=this.points[e[2]];v=this.points[e[3]];m=k*k;n=k*m;f.x=c(p.x,o.x,u.x,v.x,k,m,n);f.y=c(p.y,o.y,u.y,v.y,k,m,n);f.z=c(p.z,o.z,u.z,v.z,k,m,n);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b<c;b++)e=this.points[b],f[b]=[e.x,e.y,e.z];return f};this.getLength=function(b){var e,c,f=e=e=0,g=new THREE.Vector3,h=new THREE.Vector3,k=[],m=0;k[0]=0;b||(b=100);c=this.points.length*b;g.copy(this.points[0]);for(b=1;b<c;b++)e=b/c,position=this.getPoint(e),h.copy(position),
  73. m+=h.distanceTo(g),g.copy(position),e*=this.points.length-1,e=Math.floor(e),e!=f&&(k[e]=m,f=e);k[k.length]=m;return{chunks:k,total:m}};this.reparametrizeByArcLength=function(b){var e,c,f,g,h,k,m=[],n=new THREE.Vector3,p=this.getLength();m.push(n.copy(this.points[0]).clone());for(e=1;e<this.points.length;e++){c=p.chunks[e]-p.chunks[e-1];k=Math.ceil(b*c/p.total);g=(e-1)/(this.points.length-1);h=e/(this.points.length-1);for(c=1;c<k-1;c++)f=g+c*(1/k)*(h-g),position=this.getPoint(f),m.push(n.copy(position).clone());
  74. m.push(n.copy(this.points[e]).clone())}this.points=m}};THREE.Edge=function(b,c,e,f){this.vertices=[b,c];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,e,f,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||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;
  75. THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);c.multiplyScalar(b);this.position.addSelf(c);this.target.position.addSelf(c)};
  76. THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,e=-c,f=b*e,b=Math.abs(b*c-f),e=Math.abs(c-e);this.projectionMatrix=THREE.Matrix4.makeFrustum(f+this.x*b/this.fullWidth,f+(this.x+this.width)*b/this.fullWidth,c-(this.y+this.height)*e/this.fullHeight,c-this.y*e/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
  77. THREE.Camera.prototype.setViewOffset=function(b,c,e,f,g,h){this.fullWidth=b;this.fullHeight=c;this.x=e;this.y=f;this.width=g;this.height=h;this.updateProjectionMatrix()};
  78. THREE.Camera.prototype.update=function(b,c,e){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=
  79. !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,e)};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;
  80. THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=e||0};
  81. THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.LensFlare=function(b,c,e,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,c,e,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
  82. THREE.LensFlare.prototype.add=function(b,c,e,f){c===void 0&&(c=-1);e===void 0&&(e=0);if(f===void 0)f=THREE.BillboardBlending;e=Math.min(e,Math.max(0,e));this.lensFlares.push({texture:b,size:c,distance:e,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:f})};
  83. THREE.LensFlare.prototype.updateLensFlares=function(){var b,c=this.lensFlares.length,e,f=-this.positionScreen.x*2,g=-this.positionScreen.y*2;for(b=0;b<c;b++)e=this.lensFlares[b],e.x=this.positionScreen.x+f*e.distance,e.y=this.positionScreen.y+g*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
  84. 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;this.polygonOffset=b.polygonOffset!==void 0?b.polygonOffset:!1;this.polygonOffsetFactor=b.polygonOffsetFactor!==void 0?b.polygonOffsetFactor:0;this.polygonOffsetUnits=b.polygonOffsetUnits!==void 0?b.polygonOffsetUnits:
  85. 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;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(){};
  86. THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};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;
  87. THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  88. 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!==
  89. 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};
  90. THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  91. 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!==
  92. 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};
  93. THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  94. 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;
  95. 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!==
  96. 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;
  97. 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;
  98. 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(){};
  99. 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=
  100. 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;
  101. 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!==
  102. 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};
  103. THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
  104. 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;
  105. 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};
  106. THREE.Texture=function(b,c,e,f,g,h){this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=e!==void 0?e:THREE.ClampToEdgeWrapping;this.wrapT=f!==void 0?f:THREE.ClampToEdgeWrapping;this.magFilter=g!==void 0?g:THREE.LinearFilter;this.minFilter=h!==void 0?h:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
  107. THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
  108. THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;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;
  109. 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;THREE.Line=function(b,c,e){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=e!=void 0?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;
  110. THREE.Line.prototype.constructor=THREE.Line;
  111. THREE.Mesh=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c&&c.length?c:[c];this.overdraw=!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 e=0;e<this.geometry.morphTargets.length;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=
  112. e}};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};
  113. 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;
  114. THREE.Bone.prototype.update=function(b,c,e){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 f,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<g;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.skinMatrix,c,e):b.update(this.matrixWorld,!0,e)}else for(f=0;f<g;f++)this.children[f].update(this.skinMatrix,
  115. c,e)};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};
  116. THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,g,h,k,m;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)g=this.geometry.bones[e],h=g.pos,k=g.rotq,m=g.scl,f=this.addBone(),f.name=g.name,f.position.set(h[0],h[1],h[2]),f.quaternion.set(k[0],k[1],k[2],k[3]),f.useQuaternion=!0,m!==void 0?f.scale.set(m[0],m[1],m[2]):f.scale.set(1,1,1);for(e=0;e<this.bones.length;e++)g=this.geometry.bones[e],
  117. f=this.bones[e],g.parent===-1?this.addChild(f):this.bones[g.parent].addChild(f);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  118. THREE.SkinnedMesh.prototype.update=function(b,c,e){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 f,g=this.children.length;for(f=0;f<g;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,c,e);e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<e;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
  119. c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
  120. THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],e=0;e<this.bones.length;e++)b=this.bones[e],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var f;for(b=0;b<this.geometry.skinIndices.length;b++){var e=this.geometry.vertices[b].position,g=this.geometry.skinIndices[b].x,h=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
  121. e.y,e.z);this.geometry.skinVerticesA.push(c[g].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(c[h].multiplyVector3(f));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=e,this.geometry.skinWeights[b].y+=e)}}};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};
  122. THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;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),e=0;e<this.LODs.length;e++)if(c<this.LODs[e].visibleAtDistance)break;this.LODs.splice(e,0,{visibleAtDistance:c,object3D:b});this.addChild(b)};
  123. THREE.LOD.prototype.update=function(b,c,e){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=e.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 f=1;f<this.LODs.length;f++)if(b>=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1,
  124. this.LODs[f].object3D.visible=!0;else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};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()};
  125. THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
  126. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,c,e,f,g,h,k,m,n,p,o,u,v,w,x=new THREE.Geometry;x.vertices=this.geometry.vertices;f=x.faces=this.geometry.faces;var B=x.egdes=this.geometry.edges,A=x.edgeFaces=[];g=0;var y=[];b=0;for(c=f.length;b<c;b++)if(e=f[b],y.push(g),g+=e instanceof THREE.Face3?3:4,e.vertexNormals[0]=e.normal,e.vertexNormals[1]=e.normal,e.vertexNormals[2]=e.normal,e instanceof THREE.Face4)e.vertexNormals[3]=
  127. e.normal;b=0;for(c=B.length;b<c;b++)m=B[b],e=m.faces[0],f=m.faces[1],g=m.faceIndices[0],h=m.faceIndices[1],k=m.vertexIndices[0],m=m.vertexIndices[1],e.a===k?(n="a",o=y[g]+0):e.b===k?(n="b",o=y[g]+1):e.c===k?(n="c",o=y[g]+2):e.d===k&&(n="d",o=y[g]+3),e.a===m?(n+="a",u=y[g]+0):e.b===m?(n+="b",u=y[g]+1):e.c===m?(n+="c",u=y[g]+2):e.d===m&&(n+="d",u=y[g]+3),f.a===k?(p="a",v=y[h]+0):f.b===k?(p="b",v=y[h]+1):f.c===k?(p="c",v=y[h]+2):f.d===k&&(p="d",v=y[h]+3),f.a===m?(p+="a",w=y[h]+0):f.b===m?(p+="b",w=y[h]+
  128. 1):f.c===m?(p+="c",w=y[h]+2):f.d===m&&(p+="d",w=y[h]+3),n==="ac"||n==="ad"||n==="ca"||n==="da"?o>u&&(e=o,o=u,u=e):o<u&&(e=o,o=u,u=e),p==="ac"||p==="ad"||p==="ca"||p==="da"?v>w&&(e=v,v=w,w=e):v<w&&(e=v,v=w,w=e),e=new THREE.Face4(o,u,v,w),e.normal.set(1,0,0),A.push(e);this.geometry=x}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
  129. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var c=this.geometry.vertices,e=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces,b=b.vertices,h=g.length,k,m,n,p,o,u=["a","b","c","d"];for(n=0;n<h;n++){m=c.length;k=g[n];k instanceof THREE.Face4?(p=4,m=new THREE.Face4(m,m+1,m+2,m+3)):(p=3,m=new THREE.Face3(m,m+1,m+2));m.normal.copy(k.normal);e.push(m);
  130. for(m=0;m<p;m++)o=b[k[u[m]]],c.push(new THREE.Vertex(o.position.clone()))}for(h=0;h<g.length-1;h++){b=e[h];for(k=h+1;k<g.length;k++)m=e[k],m=this.facesShareEdge(c,b,m),m!==void 0&&(m=new THREE.Face4(m.indices[0],m.indices[3],m.indices[2],m.indices[1]),m.normal.set(1,0,0),f.push(m))}};
  131. THREE.ShadowVolume.prototype.facesShareEdge=function(b,c,e){var f,g,h,k,m,n,p,o,u,v,w,x,B,A=0,y=["a","b","c","d"];f=c instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(x=0;x<f;x++){h=c[y[x]];m=b[h];for(B=0;B<g;B++)if(k=e[y[B]],n=b[k],Math.abs(m.position.x-n.position.x)<1.0E-4&&Math.abs(m.position.y-n.position.y)<1.0E-4&&Math.abs(m.position.z-n.position.z)<1.0E-4&&(A++,A===1&&(p=m,o=n,u=h,v=k,w=y[x]),A===2))return w+=y[x],w==="ad"||w==="ac"?{faces:[c,e],vertices:[p,o,n,m],indices:[u,v,
  132. k,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,e],vertices:[p,m,n,o],indices:[u,h,k,v],vertexTypes:[1,1,2,2],extrudable:!0}}};
  133. 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:THREE.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;
  134. this.affectedByDistance=b.affectedByDistance!==void 0?b.affectedByDistance:!this.useScreenCoordinates;this.scaleByViewport=b.scaleByViewport!==void 0?b.scaleByViewport:!this.affectedByDistance;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;
  135. THREE.Sprite.prototype.supr=THREE.Object3D.prototype;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);
  136. THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);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);
  137. THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.overrideMaterial=this.fog=null;this.objects=[];this.lights=[];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)};
  138. 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.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])};THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};
  139. 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.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])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;
  140. THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,c,e){this.color=new THREE.Color(b);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
  141. THREE.Projector=function(){function b(){var b=n[m]=n[m]||new THREE.RenderableVertex;m++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,g=b.z+b.w,h=e.z+e.w,k=-b.z+b.w,m=-e.z+e.w;return g>=0&&h>=0&&k>=0&&m>=0?!0:g<0&&h<0||k<0&&m<0?!1:(g<0?c=Math.max(c,g/(g-h)):h<0&&(f=Math.min(f,g/(g-h))),k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,g,h=[],k,m,n=[],p,o,u=[],v,w=[],x,B,A=[],y,K,E=[],J=new THREE.Vector4,I=new THREE.Vector4,
  142. G=new THREE.Matrix4,N=new THREE.Matrix4,M=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Q=new THREE.Vector4,F=new THREE.Vector4;this.projectVector=function(b,e){G.multiply(e.projectionMatrix,e.matrixWorldInverse);G.multiplyVector3(b);return b};this.unprojectVector=function(b,e){G.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));G.multiplyVector3(b);return b};this.projectObjects=function(b,e,k){var e=[],j,m,n;g=0;m=
  143. b.objects;b=0;for(j=m.length;b<j;b++){n=m[b];var p;if(!(p=!n.visible))if(p=n instanceof THREE.Mesh){a:{p=void 0;for(var o=n.matrixWorld,u=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),v=0;v<6;v++)if(p=M[v].x*o.n14+M[v].y*o.n24+M[v].z*o.n34+M[v].w,p<=u){p=!1;break a}p=!0}p=!p}if(!p)p=h[g]=h[g]||new THREE.RenderableObject,g++,f=p,J.copy(n.position),G.multiplyVector3(J),f.object=n,f.z=J.z,e.push(f)}k&&e.sort(c);return e};this.projectScene=function(f,g,h){var j=[],
  144. J=g.near,V=g.far,W,L,fa,aa,X,ea,ia,oa,ja,R,ga,Z,Y,la,ha,pa,ma;K=B=v=o=0;g.matrixAutoUpdate&&g.update(void 0,!0);f.update(void 0,!1,g);G.multiply(g.projectionMatrix,g.matrixWorldInverse);M[0].set(G.n41-G.n11,G.n42-G.n12,G.n43-G.n13,G.n44-G.n14);M[1].set(G.n41+G.n11,G.n42+G.n12,G.n43+G.n13,G.n44+G.n14);M[2].set(G.n41+G.n21,G.n42+G.n22,G.n43+G.n23,G.n44+G.n24);M[3].set(G.n41-G.n21,G.n42-G.n22,G.n43-G.n23,G.n44-G.n24);M[4].set(G.n41-G.n31,G.n42-G.n32,G.n43-G.n33,G.n44-G.n34);M[5].set(G.n41+G.n31,G.n42+
  145. G.n32,G.n43+G.n33,G.n44+G.n34);for(W=0;W<6;W++)ja=M[W],ja.divideScalar(Math.sqrt(ja.x*ja.x+ja.y*ja.y+ja.z*ja.z));ja=this.projectObjects(f,g,!0);f=0;for(W=ja.length;f<W;f++)if(R=ja[f].object,R.visible)if(ga=R.matrixWorld,Z=R.matrixRotationWorld,Y=R.materials,la=R.overdraw,m=0,R instanceof THREE.Mesh){ha=R.geometry;aa=ha.vertices;pa=ha.faces;ha=ha.faceVertexUvs;L=0;for(fa=aa.length;L<fa;L++)k=b(),k.positionWorld.copy(aa[L].position),ga.multiplyVector3(k.positionWorld),k.positionScreen.copy(k.positionWorld),
  146. G.multiplyVector4(k.positionScreen),k.positionScreen.x/=k.positionScreen.w,k.positionScreen.y/=k.positionScreen.w,k.visible=k.positionScreen.z>J&&k.positionScreen.z<V;aa=0;for(L=pa.length;aa<L;aa++){fa=pa[aa];if(fa instanceof THREE.Face3)if(X=n[fa.a],ea=n[fa.b],ia=n[fa.c],X.visible&&ea.visible&&ia.visible&&(R.doubleSided||R.flipSided!=(ia.positionScreen.x-X.positionScreen.x)*(ea.positionScreen.y-X.positionScreen.y)-(ia.positionScreen.y-X.positionScreen.y)*(ea.positionScreen.x-X.positionScreen.x)<
  147. 0))oa=u[o]=u[o]||new THREE.RenderableFace3,o++,p=oa,p.v1.copy(X),p.v2.copy(ea),p.v3.copy(ia);else continue;else if(fa instanceof THREE.Face4)if(X=n[fa.a],ea=n[fa.b],ia=n[fa.c],oa=n[fa.d],X.visible&&ea.visible&&ia.visible&&oa.visible&&(R.doubleSided||R.flipSided!=((oa.positionScreen.x-X.positionScreen.x)*(ea.positionScreen.y-X.positionScreen.y)-(oa.positionScreen.y-X.positionScreen.y)*(ea.positionScreen.x-X.positionScreen.x)<0||(ea.positionScreen.x-ia.positionScreen.x)*(oa.positionScreen.y-ia.positionScreen.y)-
  148. (ea.positionScreen.y-ia.positionScreen.y)*(oa.positionScreen.x-ia.positionScreen.x)<0)))ma=w[v]=w[v]||new THREE.RenderableFace4,v++,p=ma,p.v1.copy(X),p.v2.copy(ea),p.v3.copy(ia),p.v4.copy(oa);else continue;p.normalWorld.copy(fa.normal);Z.multiplyVector3(p.normalWorld);p.centroidWorld.copy(fa.centroid);ga.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);G.multiplyVector3(p.centroidScreen);ia=fa.vertexNormals;X=0;for(ea=ia.length;X<ea;X++)oa=p.vertexNormalsWorld[X],oa.copy(ia[X]),
  149. Z.multiplyVector3(oa);X=0;for(ea=ha.length;X<ea;X++)if(ma=ha[X][aa]){ia=0;for(oa=ma.length;ia<oa;ia++)p.uvs[X][ia]=ma[ia]}p.meshMaterials=Y;p.faceMaterials=fa.materials;p.overdraw=la;p.z=p.centroidScreen.z;j.push(p)}}else if(R instanceof THREE.Line){N.multiply(G,ga);aa=R.geometry.vertices;X=b();X.positionScreen.copy(aa[0].position);N.multiplyVector4(X.positionScreen);L=1;for(fa=aa.length;L<fa;L++)if(X=b(),X.positionScreen.copy(aa[L].position),N.multiplyVector4(X.positionScreen),ea=n[m-2],Q.copy(X.positionScreen),
  150. F.copy(ea.positionScreen),e(Q,F))Q.multiplyScalar(1/Q.w),F.multiplyScalar(1/F.w),ga=A[B]=A[B]||new THREE.RenderableLine,B++,x=ga,x.v1.positionScreen.copy(Q),x.v2.positionScreen.copy(F),x.z=Math.max(Q.z,F.z),x.materials=R.materials,j.push(x)}else if(R instanceof THREE.Particle&&(I.set(R.matrixWorld.n14,R.matrixWorld.n24,R.matrixWorld.n34,1),G.multiplyVector4(I),I.z/=I.w,I.z>0&&I.z<1))ga=E[K]=E[K]||new THREE.RenderableParticle,K++,y=ga,y.x=I.x/I.w,y.y=I.y/I.w,y.z=I.z,y.rotation=R.rotation.z,y.scale.x=
  151. R.scale.x*Math.abs(y.x-(I.x+g.projectionMatrix.n11)/(I.w+g.projectionMatrix.n14)),y.scale.y=R.scale.y*Math.abs(y.y-(I.y+g.projectionMatrix.n22)/(I.w+g.projectionMatrix.n24)),y.materials=R.materials,j.push(y);h&&j.sort(c);return j}};
  152. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,h;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;h=f/2};this.render=function(e,f){var n,p,o,u,v,w,x,B;b=c.projectScene(e,f);n=0;for(p=b.length;n<p;n++)if(v=b[n],v instanceof THREE.RenderableParticle){x=v.x*g+g;B=v.y*h+h;o=0;for(u=v.material.length;o<u;o++)if(w=v.material[o],w instanceof THREE.ParticleDOMMaterial)w=w.domElement,w.style.left=x+"px",w.style.top=B+"px"}}};
  153. THREE.CanvasRenderer=function(b){function c(b){if(y!=b)x.globalAlpha=y=b}function e(b){if(K!=b){switch(b){case THREE.NormalBlending:x.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:x.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:x.globalCompositeOperation="darker"}K=b}}function f(b){if(E!=b.hex)E=b.hex,x.strokeStyle="#"+h(E.toString(16))}function g(b){if(J!=b.hex)J=b.hex,x.fillStyle="#"+h(J.toString(16))}function h(b){for(;b.length<6;)b="0"+b;return b}
  154. var k=this,m=null,n=new THREE.Projector,b=b||{},p=b.canvas!==void 0?b.canvas:document.createElement("canvas"),o,u,v,w,x=p.getContext("2d"),B=new THREE.Color(0),A=0,y=1,K=0,E=null,J=null,I=null,G=null,N=null,M,Q,F,U,D=new THREE.RenderableVertex,da=new THREE.RenderableVertex,j,ca,V,W,L,fa,aa,X,ea,ia,oa,ja,R=new THREE.Color(0),ga=new THREE.Color(0),Z=new THREE.Color(0),Y=new THREE.Color(0),la=new THREE.Color(0),ha,pa,ma,ka,va,xa,Da,Aa,wa,Ba,ya=new THREE.Rectangle,sa=new THREE.Rectangle,T=new THREE.Rectangle,
  155. S=!1,qa=new THREE.Color,O=new THREE.Color,Ea=new THREE.Color,$=new THREE.Color,ra=new THREE.Vector3,Ra,Sa,Ya,za,Ta,Ua,b=16;Ra=document.createElement("canvas");Ra.width=Ra.height=2;Sa=Ra.getContext("2d");Sa.fillStyle="rgba(0,0,0,1)";Sa.fillRect(0,0,2,2);Ya=Sa.getImageData(0,0,2,2);za=Ya.data;Ta=document.createElement("canvas");Ta.width=Ta.height=b;Ua=Ta.getContext("2d");Ua.translate(-b/2,-b/2);Ua.scale(b,b);b--;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,
  156. faces:0};this.setSize=function(b,e){o=b;u=e;v=o/2;w=u/2;p.width=o;p.height=u;ya.set(-v,-w,v,w);y=1;K=0;N=G=I=J=E=null};this.setClearColor=function(b,e){B=b;A=e};this.setClearColorHex=function(b,e){B.setHex(b);A=e};this.clear=function(){x.setTransform(1,0,0,-1,v,w);if(!sa.isEmpty())sa.inflate(1),sa.minSelf(ya),B.hex==0&&A==0?x.clearRect(sa.getX(),sa.getY(),sa.getWidth(),sa.getHeight()):(e(THREE.NormalBlending),c(1),x.fillStyle="rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*
  157. 255)+","+A+")",x.fillRect(sa.getX(),sa.getY(),sa.getWidth(),sa.getHeight())),sa.empty()};this.render=function(b,h){function p(b){var e,c,f,g=b.lights;O.setRGB(0,0,0);Ea.setRGB(0,0,0);$.setRGB(0,0,0);b=0;for(e=g.length;b<e;b++)c=g[b],f=c.color,c instanceof THREE.AmbientLight?(O.r+=f.r,O.g+=f.g,O.b+=f.b):c instanceof THREE.DirectionalLight?(Ea.r+=f.r,Ea.g+=f.g,Ea.b+=f.b):c instanceof THREE.PointLight&&($.r+=f.r,$.g+=f.g,$.b+=f.b)}function o(b,e,c,f){var g,h,j,k,m=b.lights,b=0;for(g=m.length;b<g;b++)h=
  158. m[b],j=h.color,h instanceof THREE.DirectionalLight?(k=c.dot(h.position),k<=0||(k*=h.intensity,f.r+=j.r*k,f.g+=j.g*k,f.b+=j.b*k)):h instanceof THREE.PointLight&&(k=c.dot(ra.sub(h.position,e).normalize()),k<=0||(k*=h.distance==0?1:1-Math.min(e.distanceTo(h.position)/h.distance,1),k!=0&&(k*=h.intensity,f.r+=j.r*k,f.g+=j.g*k,f.b+=j.b*k)))}function u(b,h,j){c(j.opacity);e(j.blending);var k,m,n,p,o,$;if(j instanceof THREE.ParticleBasicMaterial){if(j.map)p=j.map.image,o=p.width>>1,$=p.height>>1,j=h.scale.x*
  159. v,n=h.scale.y*w,k=j*o,m=n*$,T.set(b.x-k,b.y-m,b.x+k,b.y+m),ya.instersects(T)&&(x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(j,-n),x.translate(-o,-$),x.drawImage(p,0,0),x.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*v,m=h.scale.y*w,T.set(b.x-k,b.y-m,b.x+k,b.y+m),ya.instersects(T)&&(f(j.color),g(j.color),x.save(),x.translate(b.x,b.y),x.rotate(-h.rotation),x.scale(k,m),j.program(x),x.restore()))}function y(b,h,g,j){c(j.opacity);e(j.blending);x.beginPath();x.moveTo(b.positionScreen.x,
  160. b.positionScreen.y);x.lineTo(h.positionScreen.x,h.positionScreen.y);x.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(I!=b)x.lineWidth=I=b;b=j.linecap;if(G!=b)x.lineCap=G=b;b=j.linejoin;if(N!=b)x.lineJoin=N=b;f(j.color);x.stroke();T.inflate(j.linewidth*2)}}function A(b,f,g,m,n,p,u,$,v){k.data.vertices+=3;k.data.faces++;c($.opacity);e($.blending);j=b.positionScreen.x;ca=b.positionScreen.y;V=f.positionScreen.x;W=f.positionScreen.y;L=g.positionScreen.x;fa=g.positionScreen.y;E(j,
  161. ca,V,W,L,fa);if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.mapping instanceof THREE.UVMapping&&(ka=u.uvs[0],Ga(j,ca,V,W,L,fa,$.map.image,ka[m].u,ka[m].v,ka[n].u,ka[n].v,ka[p].u,ka[p].v));else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=h.matrixWorldInverse,ra.copy(u.vertexNormalsWorld[0]),va=(ra.x*b.n11+ra.y*b.n12+ra.z*b.n13)*0.5+0.5,xa=-(ra.x*b.n21+ra.y*b.n22+ra.z*b.n23)*0.5+0.5,ra.copy(u.vertexNormalsWorld[1]),Da=(ra.x*b.n11+ra.y*b.n12+ra.z*b.n13)*0.5+
  162. 0.5,Aa=-(ra.x*b.n21+ra.y*b.n22+ra.z*b.n23)*0.5+0.5,ra.copy(u.vertexNormalsWorld[2]),wa=(ra.x*b.n11+ra.y*b.n12+ra.z*b.n13)*0.5+0.5,Ba=-(ra.x*b.n21+ra.y*b.n22+ra.z*b.n23)*0.5+0.5,Ga(j,ca,V,W,L,fa,$.envMap.image,va,xa,Da,Aa,wa,Ba)}else $.wireframe?J($.color,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ia($.color);else if($ instanceof THREE.MeshLambertMaterial)$.map&&!$.wireframe&&($.map.mapping instanceof THREE.UVMapping&&(ka=u.uvs[0],Ga(j,ca,V,W,L,fa,$.map.image,ka[m].u,ka[m].v,ka[n].u,
  163. ka[n].v,ka[p].u,ka[p].v)),e(THREE.SubtractiveBlending)),S?!$.wireframe&&$.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3?(ga.r=Z.r=Y.r=O.r,ga.g=Z.g=Y.g=O.g,ga.b=Z.b=Y.b=O.b,o(v,u.v1.positionWorld,u.vertexNormalsWorld[0],ga),o(v,u.v2.positionWorld,u.vertexNormalsWorld[1],Z),o(v,u.v3.positionWorld,u.vertexNormalsWorld[2],Y),la.r=(Z.r+Y.r)*0.5,la.g=(Z.g+Y.g)*0.5,la.b=(Z.b+Y.b)*0.5,ma=Va(ga,Z,Y,la),Ga(j,ca,V,W,L,fa,ma,0,0,1,0,0,1)):(qa.r=O.r,qa.g=O.g,qa.b=O.b,o(v,u.centroidWorld,u.normalWorld,
  164. qa),R.r=Math.max(0,Math.min($.color.r*qa.r,1)),R.g=Math.max(0,Math.min($.color.g*qa.g,1)),R.b=Math.max(0,Math.min($.color.b*qa.b,1)),R.updateHex(),$.wireframe?J(R,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ia(R)):$.wireframe?J($.color,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ia($.color);else if($ instanceof THREE.MeshDepthMaterial)ha=h.near,pa=h.far,ga.r=ga.g=ga.b=1-La(b.positionScreen.z,ha,pa),Z.r=Z.g=Z.b=1-La(f.positionScreen.z,ha,pa),Y.r=Y.g=Y.b=1-La(g.positionScreen.z,
  165. ha,pa),la.r=(Z.r+Y.r)*0.5,la.g=(Z.g+Y.g)*0.5,la.b=(Z.b+Y.b)*0.5,ma=Va(ga,Z,Y,la),Ga(j,ca,V,W,L,fa,ma,0,0,1,0,0,1);else if($ instanceof THREE.MeshNormalMaterial)R.r=Pa(u.normalWorld.x),R.g=Pa(u.normalWorld.y),R.b=Pa(u.normalWorld.z),R.updateHex(),$.wireframe?J(R,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):Ia(R)}function B(b,f,g,m,n,p,$,u,v){k.data.vertices+=4;k.data.faces++;c(u.opacity);e(u.blending);if(u.map||u.envMap)A(b,f,m,0,1,3,$,u,v),A(n,g,p,1,2,3,$,u,v);else if(j=b.positionScreen.x,
  166. ca=b.positionScreen.y,V=f.positionScreen.x,W=f.positionScreen.y,L=g.positionScreen.x,fa=g.positionScreen.y,aa=m.positionScreen.x,X=m.positionScreen.y,ea=n.positionScreen.x,ia=n.positionScreen.y,oa=p.positionScreen.x,ja=p.positionScreen.y,u instanceof THREE.MeshBasicMaterial)K(j,ca,V,W,L,fa,aa,X),u.wireframe?J(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ia(u.color);else if(u instanceof THREE.MeshLambertMaterial)S?!u.wireframe&&u.shading==THREE.SmoothShading&&$.vertexNormalsWorld.length==
  167. 4?(ga.r=Z.r=Y.r=la.r=O.r,ga.g=Z.g=Y.g=la.g=O.g,ga.b=Z.b=Y.b=la.b=O.b,o(v,$.v1.positionWorld,$.vertexNormalsWorld[0],ga),o(v,$.v2.positionWorld,$.vertexNormalsWorld[1],Z),o(v,$.v4.positionWorld,$.vertexNormalsWorld[3],Y),o(v,$.v3.positionWorld,$.vertexNormalsWorld[2],la),ma=Va(ga,Z,Y,la),E(j,ca,V,W,aa,X),Ga(j,ca,V,W,aa,X,ma,0,0,1,0,0,1),E(ea,ia,L,fa,oa,ja),Ga(ea,ia,L,fa,oa,ja,ma,1,0,1,1,0,1)):(qa.r=O.r,qa.g=O.g,qa.b=O.b,o(v,$.centroidWorld,$.normalWorld,qa),R.r=Math.max(0,Math.min(u.color.r*qa.r,1)),
  168. R.g=Math.max(0,Math.min(u.color.g*qa.g,1)),R.b=Math.max(0,Math.min(u.color.b*qa.b,1)),R.updateHex(),K(j,ca,V,W,L,fa,aa,X),u.wireframe?J(R,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ia(R)):(K(j,ca,V,W,L,fa,aa,X),u.wireframe?J(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ia(u.color));else if(u instanceof THREE.MeshNormalMaterial)R.r=Pa($.normalWorld.x),R.g=Pa($.normalWorld.y),R.b=Pa($.normalWorld.z),R.updateHex(),K(j,ca,V,W,L,fa,aa,X),u.wireframe?J(R,u.wireframeLinewidth,
  169. u.wireframeLinecap,u.wireframeLinejoin):Ia(R);else if(u instanceof THREE.MeshDepthMaterial)ha=h.near,pa=h.far,ga.r=ga.g=ga.b=1-La(b.positionScreen.z,ha,pa),Z.r=Z.g=Z.b=1-La(f.positionScreen.z,ha,pa),Y.r=Y.g=Y.b=1-La(m.positionScreen.z,ha,pa),la.r=la.g=la.b=1-La(g.positionScreen.z,ha,pa),ma=Va(ga,Z,Y,la),E(j,ca,V,W,aa,X),Ga(j,ca,V,W,aa,X,ma,0,0,1,0,0,1),E(ea,ia,L,fa,oa,ja),Ga(ea,ia,L,fa,oa,ja,ma,1,0,1,1,0,1)}function E(b,e,c,f,g,h){x.beginPath();x.moveTo(b,e);x.lineTo(c,f);x.lineTo(g,h);x.lineTo(b,
  170. e);x.closePath()}function K(b,e,c,f,g,h,j,k){x.beginPath();x.moveTo(b,e);x.lineTo(c,f);x.lineTo(g,h);x.lineTo(j,k);x.lineTo(b,e);x.closePath()}function J(b,e,c,g){if(I!=e)x.lineWidth=I=e;if(G!=c)x.lineCap=G=c;if(N!=g)x.lineJoin=N=g;f(b);x.stroke();T.inflate(e*2)}function Ia(b){g(b);x.fill()}function Ga(b,e,c,f,g,h,j,k,m,n,p,u,$){var o,v;o=j.width-1;v=j.height-1;k*=o;m*=v;n*=o;p*=v;u*=o;$*=v;c-=b;f-=e;g-=b;h-=e;n-=k;p-=m;u-=k;$-=m;o=n*$-u*p;o!=0&&(v=1/o,o=($*c-p*g)*v,p=($*f-p*h)*v,c=(n*g-u*c)*v,f=
  171. (n*h-u*f)*v,b=b-o*k-c*m,e=e-p*k-f*m,x.save(),x.transform(o,p,c,f,b,e),x.clip(),x.drawImage(j,0,0),x.restore())}function Va(b,e,c,f){var g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),u=~~(f.g*255),f=~~(f.b*255);za[0]=g<0?0:g>255?255:g;za[1]=h<0?0:h>255?255:h;za[2]=b<0?0:b>255?255:b;za[4]=j<0?0:j>255?255:j;za[5]=k<0?0:k>255?255:k;za[6]=e<0?0:e>255?255:e;za[8]=m<0?0:m>255?255:m;za[9]=n<0?0:n>255?255:n;za[10]=
  172. c<0?0:c>255?255:c;za[12]=p<0?0:p>255?255:p;za[13]=u<0?0:u>255?255:u;za[14]=f<0?0:f>255?255:f;Sa.putImageData(Ya,0,0);Ua.drawImage(Ra,0,0);return Ta}function La(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Pa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function H(b,e){var c=e.x-b.x,f=e.y-b.y,g=1/Math.sqrt(c*c+f*f);c*=g;f*=g;e.x+=c;e.y+=f;b.x-=c;b.y-=f}var Wa,C,na,Ca,Ja,Qa,Xa,ta;this.autoClear?this.clear():x.setTransform(1,0,0,-1,v,w);k.data.vertices=0;k.data.faces=0;m=n.projectScene(b,h,this.sortElements);
  173. (S=b.lights.length>0)&&p(b);Wa=0;for(C=m.length;Wa<C;Wa++){na=m[Wa];T.empty();if(na instanceof THREE.RenderableParticle){M=na;M.x*=v;M.y*=w;Ca=0;for(Ja=na.materials.length;Ca<Ja;)ta=na.materials[Ca++],ta.opacity!=0&&u(M,na,ta,b)}else if(na instanceof THREE.RenderableLine){if(M=na.v1,Q=na.v2,M.positionScreen.x*=v,M.positionScreen.y*=w,Q.positionScreen.x*=v,Q.positionScreen.y*=w,T.addPoint(M.positionScreen.x,M.positionScreen.y),T.addPoint(Q.positionScreen.x,Q.positionScreen.y),ya.instersects(T)){Ca=
  174. 0;for(Ja=na.materials.length;Ca<Ja;)ta=na.materials[Ca++],ta.opacity!=0&&y(M,Q,na,ta,b)}}else if(na instanceof THREE.RenderableFace3){if(M=na.v1,Q=na.v2,F=na.v3,M.positionScreen.x*=v,M.positionScreen.y*=w,Q.positionScreen.x*=v,Q.positionScreen.y*=w,F.positionScreen.x*=v,F.positionScreen.y*=w,na.overdraw&&(H(M.positionScreen,Q.positionScreen),H(Q.positionScreen,F.positionScreen),H(F.positionScreen,M.positionScreen)),T.add3Points(M.positionScreen.x,M.positionScreen.y,Q.positionScreen.x,Q.positionScreen.y,
  175. F.positionScreen.x,F.positionScreen.y),ya.instersects(T)){Ca=0;for(Ja=na.meshMaterials.length;Ca<Ja;)if(ta=na.meshMaterials[Ca++],ta instanceof THREE.MeshFaceMaterial){Qa=0;for(Xa=na.faceMaterials.length;Qa<Xa;)(ta=na.faceMaterials[Qa++])&&ta.opacity!=0&&A(M,Q,F,0,1,2,na,ta,b)}else ta.opacity!=0&&A(M,Q,F,0,1,2,na,ta,b)}}else if(na instanceof THREE.RenderableFace4&&(M=na.v1,Q=na.v2,F=na.v3,U=na.v4,M.positionScreen.x*=v,M.positionScreen.y*=w,Q.positionScreen.x*=v,Q.positionScreen.y*=w,F.positionScreen.x*=
  176. v,F.positionScreen.y*=w,U.positionScreen.x*=v,U.positionScreen.y*=w,D.positionScreen.copy(Q.positionScreen),da.positionScreen.copy(U.positionScreen),na.overdraw&&(H(M.positionScreen,Q.positionScreen),H(Q.positionScreen,U.positionScreen),H(U.positionScreen,M.positionScreen),H(F.positionScreen,D.positionScreen),H(F.positionScreen,da.positionScreen)),T.addPoint(M.positionScreen.x,M.positionScreen.y),T.addPoint(Q.positionScreen.x,Q.positionScreen.y),T.addPoint(F.positionScreen.x,F.positionScreen.y),T.addPoint(U.positionScreen.x,
  177. U.positionScreen.y),ya.instersects(T))){Ca=0;for(Ja=na.meshMaterials.length;Ca<Ja;)if(ta=na.meshMaterials[Ca++],ta instanceof THREE.MeshFaceMaterial){Qa=0;for(Xa=na.faceMaterials.length;Qa<Xa;)(ta=na.faceMaterials[Qa++])&&ta.opacity!=0&&B(M,Q,F,U,D,da,na,ta,b)}else ta.opacity!=0&&B(M,Q,F,U,D,da,na,ta,b)}sa.addRectangle(T)}x.setTransform(1,0,0,1,0,0)}};
  178. THREE.SVGRenderer=function(){function b(b,e,c){var f,g,h,j;f=0;for(g=b.lights.length;f<g;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(j=e.normalWorld.dot(h.position)*h.intensity,j>0&&(c.r+=h.color.r*j,c.g+=h.color.g*j,c.b+=h.color.b*j)):h instanceof THREE.PointLight&&(U.sub(h.position,e.centroidWorld),U.normalize(),j=e.normalWorld.dot(U)*h.intensity,j>0&&(c.r+=h.color.r*j,c.g+=h.color.g*j,c.b+=h.color.b*j))}function c(e,c,m,n,u,o){k.data.vertices+=3;k.data.faces++;j=f(ca++);j.setAttribute("d",
  179. "M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");u instanceof THREE.MeshBasicMaterial?I.hex=u.color.hex:u instanceof THREE.MeshLambertMaterial?J?(G.r=N.r,G.g=N.g,G.b=N.b,b(o,n,G),I.r=Math.max(0,Math.min(u.color.r*G.r,1)),I.g=Math.max(0,Math.min(u.color.g*G.g,1)),I.b=Math.max(0,Math.min(u.color.b*G.b,1)),I.updateHex()):I.hex=u.color.hex:u instanceof THREE.MeshDepthMaterial?(F=1-u.__2near/(u.__farPlusNear-
  180. n.z*u.__farMinusNear),I.setRGB(F,F,F)):u instanceof THREE.MeshNormalMaterial&&I.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));u.wireframe?j.setAttribute("style","fill: none; stroke: #"+h(I.hex.toString(16))+"; stroke-width: "+u.wireframeLinewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: "+u.wireframeLinecap+"; stroke-linejoin: "+u.wireframeLinejoin):j.setAttribute("style","fill: #"+h(I.hex.toString(16))+"; fill-opacity: "+u.opacity);p.appendChild(j)}function e(e,c,m,n,
  181. u,o,v){k.data.vertices+=4;k.data.faces++;j=f(ca++);j.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");o instanceof THREE.MeshBasicMaterial?I.hex=o.color.hex:o instanceof THREE.MeshLambertMaterial?J?(G.r=N.r,G.g=N.g,G.b=N.b,b(v,u,G),I.r=Math.max(0,Math.min(o.color.r*G.r,1)),I.g=Math.max(0,Math.min(o.color.g*G.g,1)),I.b=Math.max(0,Math.min(o.color.b*
  182. G.b,1)),I.updateHex()):I.hex=o.color.hex:o instanceof THREE.MeshDepthMaterial?(F=1-o.__2near/(o.__farPlusNear-u.z*o.__farMinusNear),I.setRGB(F,F,F)):o instanceof THREE.MeshNormalMaterial&&I.setRGB(g(u.normalWorld.x),g(u.normalWorld.y),g(u.normalWorld.z));o.wireframe?j.setAttribute("style","fill: none; stroke: #"+h(I.hex.toString(16))+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):j.setAttribute("style",
  183. "fill: #"+h(I.hex.toString(16))+"; fill-opacity: "+o.opacity);p.appendChild(j)}function f(b){D[b]==null&&(D[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),W==0&&D[b].setAttribute("shape-rendering","crispEdges"));return D[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 k=this,m=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,u,v,w,x,B,A,y,K=new THREE.Rectangle,E=new THREE.Rectangle,J=
  184. !1,I=new THREE.Color(16777215),G=new THREE.Color(16777215),N=new THREE.Color(0),M=new THREE.Color(0),Q=new THREE.Color(0),F,U=new THREE.Vector3,D=[],da=[],j,ca,V,W=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":W=1;break;case "low":W=0}};this.setSize=function(b,e){o=b;u=e;v=o/2;w=u/2;p.setAttribute("viewBox",-v+" "+-w+" "+o+" "+u);p.setAttribute("width",o);p.setAttribute("height",u);K.set(-v,
  185. -w,v,w)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(b,f){var g,u,o,I,G,F,R,D;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;m=n.projectScene(b,f,this.sortElements);V=ca=0;if(J=b.lights.length>0){R=b.lights;N.setRGB(0,0,0);M.setRGB(0,0,0);Q.setRGB(0,0,0);g=0;for(u=R.length;g<u;g++)o=R[g],I=o.color,o instanceof THREE.AmbientLight?(N.r+=I.r,N.g+=I.g,N.b+=I.b):o instanceof THREE.DirectionalLight?(M.r+=I.r,M.g+=I.g,M.b+=I.b):o instanceof
  186. THREE.PointLight&&(Q.r+=I.r,Q.g+=I.g,Q.b+=I.b)}g=0;for(u=m.length;g<u;g++)if(R=m[g],E.empty(),R instanceof THREE.RenderableParticle){x=R;x.x*=v;x.y*=-w;o=0;for(I=R.materials.length;o<I;)o++}else if(R instanceof THREE.RenderableLine){if(x=R.v1,B=R.v2,x.positionScreen.x*=v,x.positionScreen.y*=-w,B.positionScreen.x*=v,B.positionScreen.y*=-w,E.addPoint(x.positionScreen.x,x.positionScreen.y),E.addPoint(B.positionScreen.x,B.positionScreen.y),K.instersects(E)){o=0;for(I=R.materials.length;o<I;)if((D=R.materials[o++])&&
  187. D.opacity!=0){G=x;F=B;var U=V++;da[U]==null&&(da[U]=document.createElementNS("http://www.w3.org/2000/svg","line"),W==0&&da[U].setAttribute("shape-rendering","crispEdges"));j=da[U];j.setAttribute("x1",G.positionScreen.x);j.setAttribute("y1",G.positionScreen.y);j.setAttribute("x2",F.positionScreen.x);j.setAttribute("y2",F.positionScreen.y);D instanceof THREE.LineBasicMaterial&&(j.setAttribute("style","fill: none; stroke: ##"+h(D.color.hex.toString(16))+"; stroke-width: "+D.linewidth+"; stroke-opacity: "+
  188. D.opacity+"; stroke-linecap: "+D.linecap+"; stroke-linejoin: "+D.linejoin),p.appendChild(j))}}}else if(R instanceof THREE.RenderableFace3){if(x=R.v1,B=R.v2,A=R.v3,x.positionScreen.x*=v,x.positionScreen.y*=-w,B.positionScreen.x*=v,B.positionScreen.y*=-w,A.positionScreen.x*=v,A.positionScreen.y*=-w,E.addPoint(x.positionScreen.x,x.positionScreen.y),E.addPoint(B.positionScreen.x,B.positionScreen.y),E.addPoint(A.positionScreen.x,A.positionScreen.y),K.instersects(E)){o=0;for(I=R.meshMaterials.length;o<
  189. I;)if(D=R.meshMaterials[o++],D instanceof THREE.MeshFaceMaterial){G=0;for(F=R.faceMaterials.length;G<F;)(D=R.faceMaterials[G++])&&D.opacity!=0&&c(x,B,A,R,D,b)}else D&&D.opacity!=0&&c(x,B,A,R,D,b)}}else if(R instanceof THREE.RenderableFace4&&(x=R.v1,B=R.v2,A=R.v3,y=R.v4,x.positionScreen.x*=v,x.positionScreen.y*=-w,B.positionScreen.x*=v,B.positionScreen.y*=-w,A.positionScreen.x*=v,A.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,E.addPoint(x.positionScreen.x,x.positionScreen.y),E.addPoint(B.positionScreen.x,
  190. B.positionScreen.y),E.addPoint(A.positionScreen.x,A.positionScreen.y),E.addPoint(y.positionScreen.x,y.positionScreen.y),K.instersects(E))){o=0;for(I=R.meshMaterials.length;o<I;)if(D=R.meshMaterials[o++],D instanceof THREE.MeshFaceMaterial){G=0;for(F=R.faceMaterials.length;G<F;)(D=R.faceMaterials[G++])&&D.opacity!=0&&e(x,B,A,y,R,D,b)}else D&&D.opacity!=0&&e(x,B,A,y,R,D,b)}}};
  191. 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",
  192. 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",
  193. 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",
  194. map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
  195. lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",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",
  196. 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}",
  197. 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 + viewPosition );\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 + viewPosition );\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;",
  198. 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",
  199. 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",
  200. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var c,e,f,g={};for(c=0;c<b.length;c++)for(e in f=this.clone(b[c]),f)g[e]=f[e];return g},clone:function(b){var c,e,f,g={};for(c in b)for(e in g[c]={},b[c])f=b[c][e],g[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f;return g}};
  201. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},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},morphTargetInfluences:{type:"f",value:0}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",
  202. value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},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",
  203. value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  204. THREE.ShaderLib={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 UV;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\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 sampler2D map;\nuniform float opacity;\nuniform int renderType;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\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}"},
  205. lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 UV;\nvarying vec2 vUV;\nvoid main() {\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}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nvarying vec2 vUV;\nvoid main() {\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}"},
  206. sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\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}",
  207. fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 color = texture2D( map, vUV );\ncolor.a *= opacity;\ngl_FragColor = color;\n}"},shadowPost:{vertexShader:"uniform \tmat4 \tprojectionMatrix;\nattribute \tvec3 \tposition;\nvoid main() {\ngl_Position = projectionMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform \tfloat \tdarkness;\nvoid main() {\ngl_FragColor = vec4( 0, 0, 0, darkness );\n}"},
  208. 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}"},
  209. 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}},
  210. 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.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",
  211. 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 );",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,
  212. THREE.ShaderChunk.envmap_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,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,
  213. THREE.UniformsLib.fog,THREE.UniformsLib.lights]),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,
  214. THREE.ShaderChunk.color_fragment,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,
  215. THREE.ShaderChunk.lightmap_vertex,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.fog,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},
  216. shininess:{type:"f",value:30}}]),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,
  217. THREE.ShaderChunk.map_fragment,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,
  218. 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,"#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,
  219. THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,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,
  220. "}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",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")}};
  221. THREE.WebGLRenderer=function(b){function c(b,e,c){var f,g,h,k=b.vertices,m=k.length,n=b.colors,u=n.length,p=b.__vertexArray,o=b.__colorArray,v=b.__sortArray,w=b.__dirtyVertices,x=b.__dirtyColors;if(c.sortParticles){ha.multiplySelf(c.matrixWorld);for(f=0;f<m;f++)g=k[f].position,ka.copy(g),ha.multiplyVector3(ka),v[f]=[ka.z,f];v.sort(function(b,e){return e[0]-b[0]});for(f=0;f<m;f++)g=k[v[f][1]].position,h=f*3,p[h]=g.x,p[h+1]=g.y,p[h+2]=g.z;for(f=0;f<u;f++)h=f*3,color=n[v[f][1]],o[h]=color.r,o[h+1]=color.g,
  222. o[h+2]=color.b}else{if(w)for(f=0;f<m;f++)g=k[f].position,h=f*3,p[h]=g.x,p[h+1]=g.y,p[h+2]=g.z;if(x)for(f=0;f<u;f++)color=n[f],h=f*3,o[h]=color.r,o[h+1]=color.g,o[h+2]=color.b}if(w||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,b.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,p,e);if(x||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,b.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,o,e)}function e(b,e,c,f,g){f.program||da.initMaterial(f,e,c,g);var h=f.program,k=h.uniforms,m=f.uniforms;h!=V&&(j.useProgram(h),
  223. V=h);j.uniformMatrix4fv(k.projectionMatrix,!1,pa);if(c&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(m.fogColor.value=c.color,c instanceof THREE.Fog)m.fogNear.value=c.near,m.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)m.fogDensity.value=c.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var n,
  224. u,p=0,o=0,v=0,w,x,y,A,B=va,E=B.directional.colors,I=B.directional.positions,K=B.point.colors,G=B.point.positions,F=B.point.distances,J=0,H=0,c=u=A=0;for(n=e.length;c<n;c++)if(u=e[c],w=u.color,x=u.position,y=u.intensity,A=u.distance,u instanceof THREE.AmbientLight)p+=w.r,o+=w.g,v+=w.b;else if(u instanceof THREE.DirectionalLight)A=J*3,E[A]=w.r*y,E[A+1]=w.g*y,E[A+2]=w.b*y,I[A]=x.x,I[A+1]=x.y,I[A+2]=x.z,J+=1;else if(u instanceof THREE.PointLight)u=H*3,K[u]=w.r*y,K[u+1]=w.g*y,K[u+2]=w.b*y,G[u]=x.x,G[u+
  225. 1]=x.y,G[u+2]=x.z,F[H]=A,H+=1;for(c=J*3;c<E.length;c++)E[c]=0;for(c=H*3;c<K.length;c++)K[c]=0;B.point.length=H;B.directional.length=J;B.ambient[0]=p;B.ambient[1]=o;B.ambient[2]=v;c=va;m.enableLighting.value=c.directional.length+c.point.length;m.ambientLightColor.value=c.ambient;m.directionalLightColor.value=c.directional.colors;m.directionalLightDirection.value=c.directional.positions;m.pointLightColor.value=c.point.colors;m.pointLightPosition.value=c.point.positions;m.pointLightDistance.value=c.point.distances}if(f instanceof
  226. THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)m.diffuse.value=f.color,m.opacity.value=f.opacity,(m.map.texture=f.map)&&m.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),m.lightMap.texture=f.lightMap,m.envMap.texture=f.envMap,m.reflectivity.value=f.reflectivity,m.refractionRatio.value=f.refractionRatio,m.combine.value=f.combine,m.useRefract.value=f.envMap&&f.envMap.mapping instanceof THREE.CubeRefractionMapping;
  227. if(f instanceof THREE.LineBasicMaterial)m.diffuse.value=f.color,m.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)m.psColor.value=f.color,m.opacity.value=f.opacity,m.size.value=f.size,m.scale.value=xa.height/2,m.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)m.ambient.value=f.ambient,m.specular.value=f.specular,m.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)m.mNear.value=b.near,m.mFar.value=b.far,m.opacity.value=f.opacity;else if(f instanceof
  228. THREE.MeshNormalMaterial)m.opacity.value=f.opacity;for(var ha in m)if(o=h.uniforms[ha])if(n=m[ha],p=n.type,c=n.value,p=="i")j.uniform1i(o,c);else if(p=="f")j.uniform1f(o,c);else if(p=="fv1")j.uniform1fv(o,c);else if(p=="fv")j.uniform3fv(o,c);else if(p=="v2")j.uniform2f(o,c.x,c.y);else if(p=="v3")j.uniform3f(o,c.x,c.y,c.z);else if(p=="v4")j.uniform4f(o,c.x,c.y,c.z,c.w);else if(p=="c")j.uniform3f(o,c.r,c.g,c.b);else if(p=="t"&&(j.uniform1i(o,c),n=n.texture))if(n.image instanceof Array&&n.image.length==
  229. 6){if(n.image.length==6){if(n.needsUpdate){if(n.__webglInit){j.bindTexture(j.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(p=0;p<6;++p)j.texSubImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,0,0,j.RGBA,j.UNSIGNED_BYTE,n.image[p])}else{n.image.__webglTextureCube=j.createTexture();j.bindTexture(j.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(p=0;p<6;++p)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,n.image[p]);n.__webglInit=!0}N(j.TEXTURE_CUBE_MAP,n,n.image[0]);j.bindTexture(j.TEXTURE_CUBE_MAP,
  230. null);n.needsUpdate=!1}j.activeTexture(j.TEXTURE0+c);j.bindTexture(j.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}}else M(n,c);j.uniformMatrix4fv(k.modelViewMatrix,!1,g._modelViewMatrixArray);j.uniformMatrix3fv(k.normalMatrix,!1,g._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&k.cameraPosition!==null&&j.uniform3f(k.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning)&&k.objectMatrix!==
  231. null&&j.uniformMatrix4fv(k.objectMatrix,!1,g._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&k.viewMatrix!==null&&j.uniformMatrix4fv(k.viewMatrix,!1,ma);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=m.directionalLightDirection.value,b[0]=-e[1].position.x,b[1]=-e[1].position.y,b[2]=-e[1].position.z,j.uniform3fv(k.directionalLightDirection,b),j.uniformMatrix4fv(k.objectMatrix,!1,g._objectMatrixArray),
  232. j.uniformMatrix4fv(k.viewMatrix,!1,ma);f.skinning&&(j.uniformMatrix4fv(k.cameraInverseMatrix,!1,ma),j.uniformMatrix4fv(k.boneGlobalMatrices,!1,g.boneMatrices));return h}function f(b,c,f,g,h,k){if(g.opacity!=0){var m,b=e(b,c,f,g,k).attributes;if(!g.morphTargets&&b.position>=0)j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0);else{c=g.program.attributes;k.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]),
  233. j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,n=k.morphTargetForcedOrder,p=k.morphTargetInfluences;f<g.numSupportedMorphTargets&&f<n.length;)j.bindBuffer(j.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[n[f]]),j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[f]=p[n[f]],f++;else{var n=[],u=-1,
  234. o=0,p=k.morphTargetInfluences,v,w=p.length,f=0;for(k.morphTargetBase!==-1&&(n[k.morphTargetBase]=!0);f<g.numSupportedMorphTargets;){for(v=0;v<w;v++)!n[v]&&p[v]>u&&(o=v,u=p[o]);j.bindBuffer(j.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[o]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=u;n[o]=1;u=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(g.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=
  235. 0&&(c=h.__webglCustomAttributes[m],j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[m],c.size,j.FLOAT,!1,0,0));b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglColorBuffer),j.vertexAttribPointer(b.color,3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,
  236. h.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,h.__webglUV2Buffer),j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,
  237. j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0));k instanceof THREE.Mesh?(g.wireframe?(j.lineWidth(g.wireframeLinewidth),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),j.drawElements(j.LINES,h.__webglLineCount,
  238. j.UNSIGNED_SHORT,0)):(j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),j.drawElements(j.TRIANGLES,h.__webglFaceCount,j.UNSIGNED_SHORT,0)),da.data.vertices+=h.__webglFaceCount,da.data.faces+=h.__webglFaceCount/3,da.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?j.LINE_STRIP:j.LINES,j.lineWidth(g.linewidth),j.drawArrays(k,0,h.__webglLineCount),da.data.drawCalls++):k instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,h.__webglParticleCount),da.data.drawCalls++):k instanceof
  239. THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,h.__webglVertexCount),da.data.drawCalls++)}}function g(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=j.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=j.createBuffer();b.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,b.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,b.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(e.attributes.position),j.vertexAttribPointer(e.attributes.position,3,j.FLOAT,!1,0,0));if(b.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,
  240. b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,g,k,m,n,p,u,o,v,w=b.count*3;for(v=0;v<w;v+=9)c=b.normalArray,f=c[v],h=c[v+1],g=c[v+2],k=c[v+3],n=c[v+4],u=c[v+5],m=c[v+6],p=c[v+7],o=c[v+8],f=(f+k+m)/3,h=(h+n+p)/3,g=(g+u+o)/3,c[v]=f,c[v+1]=h,c[v+2]=g,c[v+3]=f,c[v+4]=h,c[v+5]=g,c[v+6]=f,c[v+7]=h,c[v+8]=g}j.bufferData(j.ARRAY_BUFFER,b.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(e.attributes.normal);j.vertexAttribPointer(e.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,
  241. 0,b.count);b.count=0}function h(b){if(fa!=b.doubleSided)b.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),fa=b.doubleSided;if(aa!=b.flipSided)b.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),aa=b.flipSided}function k(b){ea!=b&&(b?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),ea=b)}function m(b,e,c){ia!=b&&(b?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),ia=b);if(b&&(oa!=e||ja!=c))j.polygonOffset(e,c),oa=e,ja=c}function n(b){la[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,
  242. b.n44-b.n14);la[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);la[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);la[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);la[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);la[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var e,b=0;b<6;b++)e=la[b],e.divideScalar(Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z))}function p(b){for(var e=b.matrixWorld,c=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,
  243. b.scale.z)),f=0;f<6;f++)if(b=la[f].x*e.n14+la[f].y*e.n24+la[f].z*e.n34+la[f].w,b<=c)return!1;return!0}function o(b,e){b.list[b.count]=e;b.count+=1}function u(b){var e,c,f=b.object,h=b.opaque,g=b.transparent;g.count=0;b=h.count=0;for(e=f.materials.length;b<e;b++)c=f.materials[b],c.transparent?o(g,c):o(h,c)}function v(b){var e,c,f,h,g=b.object,j=b.buffer,k=b.opaque,m=b.transparent;m.count=0;b=k.count=0;for(f=g.materials.length;b<f;b++)if(e=g.materials[b],e instanceof THREE.MeshFaceMaterial){e=0;for(c=
  244. j.materials.length;e<c;e++)(h=j.materials[e])&&(h.transparent?o(m,h):o(k,h))}else(h=e)&&(h.transparent?o(m,h):o(k,h))}function w(b,e){return e.z-b.z}function x(b){j.enable(j.POLYGON_OFFSET_FILL);j.polygonOffset(0.1,1);j.enable(j.STENCIL_TEST);j.enable(j.DEPTH_TEST);j.depthMask(!1);j.colorMask(!1,!1,!1,!1);j.stencilFunc(j.ALWAYS,1,255);j.stencilOpSeparate(j.BACK,j.KEEP,j.INCR,j.KEEP);j.stencilOpSeparate(j.FRONT,j.KEEP,j.DECR,j.KEEP);var e,c=b.lights.length,f,h=b.lights,g=[],k,m,n,p,u,o=b.__webglShadowVolumes.length;
  245. for(e=0;e<c;e++)if(f=b.lights[e],f instanceof THREE.DirectionalLight&&f.castShadow){g[0]=-f.position.x;g[1]=-f.position.y;g[2]=-f.position.z;for(u=0;u<o;u++)f=b.__webglShadowVolumes[u].object,k=b.__webglShadowVolumes[u].buffer,m=f.materials[0],m.program||da.initMaterial(m,h,void 0,f),m=m.program,n=m.uniforms,p=m.attributes,V!==m&&(j.useProgram(m),V=m,j.uniformMatrix4fv(n.projectionMatrix,!1,pa),j.uniformMatrix4fv(n.viewMatrix,!1,ma),j.uniform3fv(n.directionalLightDirection,g)),f.matrixWorld.flattenToArray(f._objectMatrixArray),
  246. j.uniformMatrix4fv(n.objectMatrix,!1,f._objectMatrixArray),j.bindBuffer(j.ARRAY_BUFFER,k.__webglVertexBuffer),j.vertexAttribPointer(p.position,3,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,k.__webglNormalBuffer),j.vertexAttribPointer(p.normal,3,j.FLOAT,!1,0,0),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),j.cullFace(j.FRONT),j.drawElements(j.TRIANGLES,k.__webglFaceCount,j.UNSIGNED_SHORT,0),j.cullFace(j.BACK),j.drawElements(j.TRIANGLES,k.__webglFaceCount,j.UNSIGNED_SHORT,0)}j.disable(j.POLYGON_OFFSET_FILL);
  247. j.colorMask(!0,!0,!0,!0);j.stencilFunc(j.NOTEQUAL,0,255);j.stencilOp(j.KEEP,j.KEEP,j.KEEP);j.disable(j.DEPTH_TEST);ea=X=-1;V=T.program;j.useProgram(T.program);j.uniformMatrix4fv(T.projectionLocation,!1,pa);j.uniform1f(T.darknessLocation,T.darkness);j.bindBuffer(j.ARRAY_BUFFER,T.vertexBuffer);j.vertexAttribPointer(T.vertexLocation,3,j.FLOAT,!1,0,0);j.enableVertexAttribArray(T.vertexLocation);j.blendFunc(j.ONE,j.ONE_MINUS_SRC_ALPHA);j.blendEquation(j.FUNC_ADD);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,T.elementBuffer);
  248. j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0);j.disable(j.STENCIL_TEST);j.enable(j.DEPTH_TEST);j.depthMask(L)}function B(b,e){var c,f,h;c=O.attributes;var g=O.uniforms,k=Y/Z,m,n=[],p=Z*0.5,u=Y*0.5,o=!0;j.useProgram(O.program);V=O.program;ea=X=-1;Ea||(j.enableVertexAttribArray(O.attributes.position),j.enableVertexAttribArray(O.attributes.uv),Ea=!0);j.disable(j.CULL_FACE);j.enable(j.BLEND);j.depthMask(!0);j.bindBuffer(j.ARRAY_BUFFER,O.vertexBuffer);j.vertexAttribPointer(c.position,2,j.FLOAT,!1,16,
  249. 0);j.vertexAttribPointer(c.uv,2,j.FLOAT,!1,16,8);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,O.elementBuffer);j.uniformMatrix4fv(g.projectionMatrix,!1,pa);j.activeTexture(j.TEXTURE0);j.uniform1i(g.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(w);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],
  250. h.material===void 0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(j.uniform1i(g.useScreenCoordinates,1),j.uniform3f(g.screenPosition,(h.position.x-p)/p,(u-h.position.y)/u,Math.max(0,Math.min(1,h.position.z)))):(j.uniform1i(g.useScreenCoordinates,0),j.uniform1i(g.affectedByDistance,h.affectedByDistance?1:0),j.uniformMatrix4fv(g.modelViewMatrix,!1,h._modelViewMatrixArray)),m=h.map.image.width/(h.scaleByViewport?Y:1),n[0]=m*k*h.scale.x,n[1]=m*h.scale.y,j.uniform2f(g.uvScale,h.uvScale.x,
  251. h.uvScale.y),j.uniform2f(g.uvOffset,h.uvOffset.x,h.uvOffset.y),j.uniform2f(g.alignment,h.alignment.x,h.alignment.y),j.uniform1f(g.opacity,h.opacity),j.uniform1f(g.rotation,h.rotation),j.uniform2fv(g.scale,n),h.mergeWith3D&&!o?(j.enable(j.DEPTH_TEST),o=!0):!h.mergeWith3D&&o&&(j.disable(j.DEPTH_TEST),o=!1),G(h.blending),M(h.map,0),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0));j.enable(j.CULL_FACE);j.enable(j.DEPTH_TEST);j.depthMask(L)}function A(b,e){var c,f,h=b.__webglLensFlares.length,g,k,m,n=
  252. new THREE.Vector3,p=Y/Z,u=Z*0.5,o=Y*0.5,v=16/Y,w=[v*p,v],x=[1,1,0],y=[1,1],A=S.uniforms;c=S.attributes;j.useProgram(S.program);V=S.program;ea=X=-1;qa||(j.enableVertexAttribArray(S.attributes.vertex),j.enableVertexAttribArray(S.attributes.uv),qa=!0);j.uniform1i(A.occlusionMap,0);j.uniform1i(A.map,1);j.bindBuffer(j.ARRAY_BUFFER,S.vertexBuffer);j.vertexAttribPointer(c.vertex,2,j.FLOAT,!1,16,0);j.vertexAttribPointer(c.uv,2,j.FLOAT,!1,16,8);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,S.elementBuffer);j.disable(j.CULL_FACE);
  253. j.depthMask(!1);j.activeTexture(j.TEXTURE0);j.bindTexture(j.TEXTURE_2D,S.occlusionTexture);j.activeTexture(j.TEXTURE1);for(f=0;f<h;f++)if(c=b.__webglLensFlares[f].object,n.set(c.matrixWorld.n14,c.matrixWorld.n24,c.matrixWorld.n34),e.matrixWorldInverse.multiplyVector3(n),e.projectionMatrix.multiplyVector3(n),x[0]=n.x,x[1]=n.y,x[2]=n.z,y[0]=x[0]*u+u,y[1]=x[1]*o+o,S.hasVertexTexture||y[0]>0&&y[0]<Z&&y[1]>0&&y[1]<Y){j.bindTexture(j.TEXTURE_2D,S.tempTexture);j.copyTexImage2D(j.TEXTURE_2D,0,j.RGB,y[0]-
  254. 8,y[1]-8,16,16,0);j.uniform1i(A.renderType,0);j.uniform2fv(A.scale,w);j.uniform3fv(A.screenPosition,x);j.disable(j.BLEND);j.enable(j.DEPTH_TEST);j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0);j.bindTexture(j.TEXTURE_2D,S.occlusionTexture);j.copyTexImage2D(j.TEXTURE_2D,0,j.RGBA,y[0]-8,y[1]-8,16,16,0);j.uniform1i(A.renderType,1);j.disable(j.DEPTH_TEST);j.bindTexture(j.TEXTURE_2D,S.tempTexture);j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0);c.positionScreen.x=x[0];c.positionScreen.y=x[1];c.positionScreen.z=
  255. x[2];c.customUpdateCallback?c.customUpdateCallback(c):c.updateLensFlares();j.uniform1i(A.renderType,2);j.enable(j.BLEND);g=0;for(k=c.lensFlares.length;g<k;g++)if(m=c.lensFlares[g],m.opacity>0.0010&&m.scale>0.0010)x[0]=m.x,x[1]=m.y,x[2]=m.z,v=m.size*m.scale/Y,w[0]=v*p,w[1]=v,j.uniform3fv(A.screenPosition,x),j.uniform2fv(A.scale,w),j.uniform1f(A.rotation,m.rotation),j.uniform1f(A.opacity,m.opacity),G(m.blending),M(m.texture,1),j.drawElements(j.TRIANGLES,6,j.UNSIGNED_SHORT,0)}j.enable(j.CULL_FACE);j.enable(j.DEPTH_TEST);
  256. j.depthMask(L)}function y(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function K(b){var e,f,h,g;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){h=f.geometryGroups[e];a:{for(var k=g=void 0,m=void 0,n=void 0,p=void 0,p=h.__materials,k=0,m=p.length;k<m;k++)if(n=p[k],n.attributes)for(g in n.attributes)if(n.attributes[g].needsUpdate){g=!0;
  257. break a}g=!1}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||g)if(g=h,k=b,m=j.DYNAMIC_DRAW,g.__inittedArrays){var u=p=n=void 0,o=void 0,v=u=void 0,w=void 0,x=void 0,y=void 0,A=void 0,B=void 0,E=void 0,I=void 0,K=void 0,G=void 0,J=void 0,F=void 0,ha=void 0,H=o=y=o=x=w=void 0,D=void 0,C=D=H=w=void 0,Q=void 0,pa=C=D=H=u=u=v=y=o=C=D=H=Q=C=D=H=Q=C=D=H=void 0,M=0,L=0,R=0,U=0,O=0,ma=0,N=0,S=0,ka=0,P=0,X=0,D=H=0,T=g.__vertexArray,
  258. ca=g.__uvArray,da=g.__uv2Array,fa=g.__normalArray,W=g.__tangentArray,V=g.__colorArray,aa=g.__skinVertexAArray,Y=g.__skinVertexBArray,Z=g.__skinIndexArray,ea=g.__skinWeightArray,la=g.__morphTargetsArrays,va=g.__webglCustomAttributes,C=void 0,ga=g.__faceArray,ia=g.__lineArray,oa=g.__needsSmoothNormals,B=g.__vertexColorType,A=g.__uvType,E=g.__normalType,ja=k.geometry,xa=ja.__dirtyVertices,wa=ja.__dirtyElements,qa=ja.__dirtyUvs,sa=ja.__dirtyNormals,Da=ja.__dirtyTangents,ya=ja.__dirtyColors,Ba=ja.__dirtyMorphTargets,
  259. Aa=ja.vertices,Ea=g.faces,ab=ja.faces,Za=ja.faceVertexUvs[0],$a=ja.faceVertexUvs[1],Ma=ja.skinVerticesA,Na=ja.skinVerticesB,Oa=ja.skinIndices,Ha=ja.skinWeights,Ka=k instanceof THREE.ShadowVolume?ja.edgeFaces:void 0,Fa=ja.morphTargets;if(va)for(pa in va)va[pa].offset=0,va[pa].offsetSrc=0;n=0;for(p=Ea.length;n<p;n++)if(u=Ea[n],o=ab[u],Za&&(I=Za[u]),$a&&(K=$a[u]),u=o.vertexNormals,v=o.normal,w=o.vertexColors,x=o.color,y=o.vertexTangents,o instanceof THREE.Face3){if(xa)G=Aa[o.a].position,J=Aa[o.b].position,
  260. F=Aa[o.c].position,T[L]=G.x,T[L+1]=G.y,T[L+2]=G.z,T[L+3]=J.x,T[L+4]=J.y,T[L+5]=J.z,T[L+6]=F.x,T[L+7]=F.y,T[L+8]=F.z,L+=9;if(va)for(pa in va)if(C=va[pa],C.__original.needsUpdate)H=C.offset,D=C.offsetSrc,C.size===1?(C.boundTo===void 0||C.boundTo==="vertices"?(C.array[H+0]=C.value[o.a],C.array[H+1]=C.value[o.b],C.array[H+2]=C.value[o.c]):C.boundTo==="faces"?(C.array[H+0]=C.value[D],C.array[H+1]=C.value[D],C.array[H+2]=C.value[D],C.offsetSrc++):C.boundTo==="faceVertices"&&(C.array[H+0]=C.value[D+0],C.array[H+
  261. 1]=C.value[D+1],C.array[H+2]=C.value[D+2],C.offsetSrc+=3),C.offset+=3):(C.boundTo===void 0||C.boundTo==="vertices"?(G=C.value[o.a],J=C.value[o.b],F=C.value[o.c]):C.boundTo==="faces"?(G=C.value[D],J=C.value[D],F=C.value[D],C.offsetSrc++):C.boundTo==="faceVertices"&&(G=C.value[D+0],J=C.value[D+1],F=C.value[D+2],C.offsetSrc+=3),C.size===2?(C.array[H+0]=G.x,C.array[H+1]=G.y,C.array[H+2]=J.x,C.array[H+3]=J.y,C.array[H+4]=F.x,C.array[H+5]=F.y,C.offset+=6):C.size===3?(C.type==="c"?(C.array[H+0]=G.r,C.array[H+
  262. 1]=G.g,C.array[H+2]=G.b,C.array[H+3]=J.r,C.array[H+4]=J.g,C.array[H+5]=J.b,C.array[H+6]=F.r,C.array[H+7]=F.g,C.array[H+8]=F.b):(C.array[H+0]=G.x,C.array[H+1]=G.y,C.array[H+2]=G.z,C.array[H+3]=J.x,C.array[H+4]=J.y,C.array[H+5]=J.z,C.array[H+6]=F.x,C.array[H+7]=F.y,C.array[H+8]=F.z),C.offset+=9):(C.array[H+0]=G.x,C.array[H+1]=G.y,C.array[H+2]=G.z,C.array[H+3]=G.w,C.array[H+4]=J.x,C.array[H+5]=J.y,C.array[H+6]=J.z,C.array[H+7]=J.w,C.array[H+8]=F.x,C.array[H+9]=F.y,C.array[H+10]=F.z,C.array[H+11]=F.w,
  263. C.offset+=12));if(Ba){H=0;for(D=Fa.length;H<D;H++)G=Fa[H].vertices[o.a].position,J=Fa[H].vertices[o.b].position,F=Fa[H].vertices[o.c].position,C=la[H],C[X+0]=G.x,C[X+1]=G.y,C[X+2]=G.z,C[X+3]=J.x,C[X+4]=J.y,C[X+5]=J.z,C[X+6]=F.x,C[X+7]=F.y,C[X+8]=F.z;X+=9}if(Ha.length)H=Ha[o.a],D=Ha[o.b],C=Ha[o.c],ea[P]=H.x,ea[P+1]=H.y,ea[P+2]=H.z,ea[P+3]=H.w,ea[P+4]=D.x,ea[P+5]=D.y,ea[P+6]=D.z,ea[P+7]=D.w,ea[P+8]=C.x,ea[P+9]=C.y,ea[P+10]=C.z,ea[P+11]=C.w,H=Oa[o.a],D=Oa[o.b],C=Oa[o.c],Z[P]=H.x,Z[P+1]=H.y,Z[P+2]=H.z,
  264. Z[P+3]=H.w,Z[P+4]=D.x,Z[P+5]=D.y,Z[P+6]=D.z,Z[P+7]=D.w,Z[P+8]=C.x,Z[P+9]=C.y,Z[P+10]=C.z,Z[P+11]=C.w,H=Ma[o.a],D=Ma[o.b],C=Ma[o.c],aa[P]=H.x,aa[P+1]=H.y,aa[P+2]=H.z,aa[P+3]=1,aa[P+4]=D.x,aa[P+5]=D.y,aa[P+6]=D.z,aa[P+7]=1,aa[P+8]=C.x,aa[P+9]=C.y,aa[P+10]=C.z,aa[P+11]=1,H=Na[o.a],D=Na[o.b],C=Na[o.c],Y[P]=H.x,Y[P+1]=H.y,Y[P+2]=H.z,Y[P+3]=1,Y[P+4]=D.x,Y[P+5]=D.y,Y[P+6]=D.z,Y[P+7]=1,Y[P+8]=C.x,Y[P+9]=C.y,Y[P+10]=C.z,Y[P+11]=1,P+=12;if(ya&&B)w.length==3&&B==THREE.VertexColors?(o=w[0],H=w[1],D=w[2]):D=H=
  265. o=x,V[ka]=o.r,V[ka+1]=o.g,V[ka+2]=o.b,V[ka+3]=H.r,V[ka+4]=H.g,V[ka+5]=H.b,V[ka+6]=D.r,V[ka+7]=D.g,V[ka+8]=D.b,ka+=9;if(Da&&ja.hasTangents)w=y[0],x=y[1],o=y[2],W[N]=w.x,W[N+1]=w.y,W[N+2]=w.z,W[N+3]=w.w,W[N+4]=x.x,W[N+5]=x.y,W[N+6]=x.z,W[N+7]=x.w,W[N+8]=o.x,W[N+9]=o.y,W[N+10]=o.z,W[N+11]=o.w,N+=12;if(sa&&E)if(u.length==3&&oa)for(y=0;y<3;y++)v=u[y],fa[ma]=v.x,fa[ma+1]=v.y,fa[ma+2]=v.z,ma+=3;else for(y=0;y<3;y++)fa[ma]=v.x,fa[ma+1]=v.y,fa[ma+2]=v.z,ma+=3;if(qa&&I!==void 0&&A)for(y=0;y<3;y++)u=I[y],ca[R]=
  266. u.u,ca[R+1]=u.v,R+=2;if(qa&&K!==void 0&&A)for(y=0;y<3;y++)u=K[y],da[U]=u.u,da[U+1]=u.v,U+=2;wa&&(ga[O]=M,ga[O+1]=M+1,ga[O+2]=M+2,O+=3,ia[S]=M,ia[S+1]=M+1,ia[S+2]=M,ia[S+3]=M+2,ia[S+4]=M+1,ia[S+5]=M+2,S+=6,M+=3)}else if(o instanceof THREE.Face4){if(xa)G=Aa[o.a].position,J=Aa[o.b].position,F=Aa[o.c].position,ha=Aa[o.d].position,T[L]=G.x,T[L+1]=G.y,T[L+2]=G.z,T[L+3]=J.x,T[L+4]=J.y,T[L+5]=J.z,T[L+6]=F.x,T[L+7]=F.y,T[L+8]=F.z,T[L+9]=ha.x,T[L+10]=ha.y,T[L+11]=ha.z,L+=12;if(va)for(pa in va)if(C=va[pa],C.__original.needsUpdate)H=
  267. C.offset,D=C.offsetSrc,C.size===1?(C.boundTo===void 0||C.boundTo==="vertices"?(C.array[H+0]=C.value[o.a],C.array[H+1]=C.value[o.b],C.array[H+2]=C.value[o.c],C.array[H+3]=C.value[o.d]):C.boundTo==="faces"?(C.array[H+0]=C.value[D],C.array[H+1]=C.value[D],C.array[H+2]=C.value[D],C.array[H+3]=C.value[D],C.offsetSrc++):C.boundTo==="faceVertices"&&(C.array[H+0]=C.value[D+0],C.array[H+1]=C.value[D+1],C.array[H+2]=C.value[D+2],C.array[H+3]=C.value[D+3],C.offsetSrc+=4),C.offset+=4):(C.boundTo===void 0||C.boundTo===
  268. "vertices"?(G=C.value[o.a],J=C.value[o.b],F=C.value[o.c],ha=C.value[o.d]):C.boundTo==="faces"?(G=C.value[D],J=C.value[D],F=C.value[D],ha=C.value[D],C.offsetSrc++):C.boundTo==="faceVertices"&&(G=C.value[D+0],J=C.value[D+1],F=C.value[D+2],ha=C.value[D+3],C.offsetSrc+=4),C.size===2?(C.array[H+0]=G.x,C.array[H+1]=G.y,C.array[H+2]=J.x,C.array[H+3]=J.y,C.array[H+4]=F.x,C.array[H+5]=F.y,C.array[H+6]=ha.x,C.array[H+7]=ha.y,C.offset+=8):C.size===3?(C.type==="c"?(C.array[H+0]=G.r,C.array[H+1]=G.g,C.array[H+
  269. 2]=G.b,C.array[H+3]=J.r,C.array[H+4]=J.g,C.array[H+5]=J.b,C.array[H+6]=F.r,C.array[H+7]=F.g,C.array[H+8]=F.b,C.array[H+9]=ha.r,C.array[H+10]=ha.g,C.array[H+11]=ha.b):(C.array[H+0]=G.x,C.array[H+1]=G.y,C.array[H+2]=G.z,C.array[H+3]=J.x,C.array[H+4]=J.y,C.array[H+5]=J.z,C.array[H+6]=F.x,C.array[H+7]=F.y,C.array[H+8]=F.z,C.array[H+9]=ha.x,C.array[H+10]=ha.y,C.array[H+11]=ha.z),C.offset+=12):(C.array[H+0]=G.x,C.array[H+1]=G.y,C.array[H+2]=G.z,C.array[H+3]=G.w,C.array[H+4]=J.x,C.array[H+5]=J.y,C.array[H+
  270. 6]=J.z,C.array[H+7]=J.w,C.array[H+8]=F.x,C.array[H+9]=F.y,C.array[H+10]=F.z,C.array[H+11]=F.w,C.array[H+12]=ha.x,C.array[H+13]=ha.y,C.array[H+14]=ha.z,C.array[H+15]=ha.w,C.offset+=16));if(Ba){H=0;for(D=Fa.length;H<D;H++)G=Fa[H].vertices[o.a].position,J=Fa[H].vertices[o.b].position,F=Fa[H].vertices[o.c].position,ha=Fa[H].vertices[o.d].position,C=la[H],C[X+0]=G.x,C[X+1]=G.y,C[X+2]=G.z,C[X+3]=J.x,C[X+4]=J.y,C[X+5]=J.z,C[X+6]=F.x,C[X+7]=F.y,C[X+8]=F.z,C[X+9]=ha.x,C[X+10]=ha.y,C[X+11]=ha.z;X+=12}if(Ha.length)H=
  271. Ha[o.a],D=Ha[o.b],C=Ha[o.c],Q=Ha[o.d],ea[P]=H.x,ea[P+1]=H.y,ea[P+2]=H.z,ea[P+3]=H.w,ea[P+4]=D.x,ea[P+5]=D.y,ea[P+6]=D.z,ea[P+7]=D.w,ea[P+8]=C.x,ea[P+9]=C.y,ea[P+10]=C.z,ea[P+11]=C.w,ea[P+12]=Q.x,ea[P+13]=Q.y,ea[P+14]=Q.z,ea[P+15]=Q.w,H=Oa[o.a],D=Oa[o.b],C=Oa[o.c],Q=Oa[o.d],Z[P]=H.x,Z[P+1]=H.y,Z[P+2]=H.z,Z[P+3]=H.w,Z[P+4]=D.x,Z[P+5]=D.y,Z[P+6]=D.z,Z[P+7]=D.w,Z[P+8]=C.x,Z[P+9]=C.y,Z[P+10]=C.z,Z[P+11]=C.w,Z[P+12]=Q.x,Z[P+13]=Q.y,Z[P+14]=Q.z,Z[P+15]=Q.w,H=Ma[o.a],D=Ma[o.b],C=Ma[o.c],Q=Ma[o.d],aa[P]=H.x,
  272. aa[P+1]=H.y,aa[P+2]=H.z,aa[P+3]=1,aa[P+4]=D.x,aa[P+5]=D.y,aa[P+6]=D.z,aa[P+7]=1,aa[P+8]=C.x,aa[P+9]=C.y,aa[P+10]=C.z,aa[P+11]=1,aa[P+12]=Q.x,aa[P+13]=Q.y,aa[P+14]=Q.z,aa[P+15]=1,H=Na[o.a],D=Na[o.b],C=Na[o.c],o=Na[o.d],Y[P]=H.x,Y[P+1]=H.y,Y[P+2]=H.z,Y[P+3]=1,Y[P+4]=D.x,Y[P+5]=D.y,Y[P+6]=D.z,Y[P+7]=1,Y[P+8]=C.x,Y[P+9]=C.y,Y[P+10]=C.z,Y[P+11]=1,Y[P+12]=o.x,Y[P+13]=o.y,Y[P+14]=o.z,Y[P+15]=1,P+=16;if(ya&&B)w.length==4&&B==THREE.VertexColors?(o=w[0],H=w[1],D=w[2],w=w[3]):w=D=H=o=x,V[ka]=o.r,V[ka+1]=o.g,
  273. V[ka+2]=o.b,V[ka+3]=H.r,V[ka+4]=H.g,V[ka+5]=H.b,V[ka+6]=D.r,V[ka+7]=D.g,V[ka+8]=D.b,V[ka+9]=w.r,V[ka+10]=w.g,V[ka+11]=w.b,ka+=12;if(Da&&ja.hasTangents)w=y[0],x=y[1],o=y[2],y=y[3],W[N]=w.x,W[N+1]=w.y,W[N+2]=w.z,W[N+3]=w.w,W[N+4]=x.x,W[N+5]=x.y,W[N+6]=x.z,W[N+7]=x.w,W[N+8]=o.x,W[N+9]=o.y,W[N+10]=o.z,W[N+11]=o.w,W[N+12]=y.x,W[N+13]=y.y,W[N+14]=y.z,W[N+15]=y.w,N+=16;if(sa&&E)if(u.length==4&&oa)for(y=0;y<4;y++)v=u[y],fa[ma]=v.x,fa[ma+1]=v.y,fa[ma+2]=v.z,ma+=3;else for(y=0;y<4;y++)fa[ma]=v.x,fa[ma+1]=v.y,
  274. fa[ma+2]=v.z,ma+=3;if(qa&&I!==void 0&&A)for(y=0;y<4;y++)u=I[y],ca[R]=u.u,ca[R+1]=u.v,R+=2;if(qa&&K!==void 0&&A)for(y=0;y<4;y++)u=K[y],da[U]=u.u,da[U+1]=u.v,U+=2;wa&&(ga[O]=M,ga[O+1]=M+1,ga[O+2]=M+3,ga[O+3]=M+1,ga[O+4]=M+2,ga[O+5]=M+3,O+=6,ia[S]=M,ia[S+1]=M+1,ia[S+2]=M,ia[S+3]=M+3,ia[S+4]=M+1,ia[S+5]=M+2,ia[S+6]=M+2,ia[S+7]=M+3,S+=8,M+=4)}if(Ka){n=0;for(p=Ka.length;n<p;n++)ga[O]=Ka[n].a,ga[O+1]=Ka[n].b,ga[O+2]=Ka[n].c,ga[O+3]=Ka[n].a,ga[O+4]=Ka[n].c,ga[O+5]=Ka[n].d,O+=6}xa&&(j.bindBuffer(j.ARRAY_BUFFER,
  275. g.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,T,m));if(va)for(pa in va)C=va[pa],C.__original.needsUpdate&&(j.bindBuffer(j.ARRAY_BUFFER,C.buffer),j.bufferData(j.ARRAY_BUFFER,C.array,m));if(Ba){H=0;for(D=Fa.length;H<D;H++)j.bindBuffer(j.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[H]),j.bufferData(j.ARRAY_BUFFER,la[H],m)}ya&&ka>0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,V,m));sa&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglNormalBuffer),j.bufferData(j.ARRAY_BUFFER,
  276. fa,m));Da&&ja.hasTangents&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglTangentBuffer),j.bufferData(j.ARRAY_BUFFER,W,m));qa&&R>0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,ca,m));qa&&U>0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,da,m));wa&&(j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),j.bufferData(j.ELEMENT_ARRAY_BUFFER,ga,m),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),j.bufferData(j.ELEMENT_ARRAY_BUFFER,ia,m));
  277. P>0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,aa,m),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,Y,m),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,Z,m),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,ea,m));k.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,
  278. delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;var ua;h=h.__materials;f=0;for(b=h.length;f<b;f++)if(e=h[f],e.attributes)for(ua in e.attributes)e.attributes[ua].needsUpdate=!1}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||
  279. f.__dirtyColors){ua=f;b=j.DYNAMIC_DRAW;p=ua.vertices;h=ua.colors;A=p.length;g=h.length;B=ua.__vertexArray;k=ua.__colorArray;E=ua.__dirtyColors;if(ua.__dirtyVertices){for(m=0;m<A;m++)n=p[m].position,e=m*3,B[e]=n.x,B[e+1]=n.y,B[e+2]=n.z;j.bindBuffer(j.ARRAY_BUFFER,ua.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,B,b)}if(E){for(m=0;m<g;m++)color=h[m],e=m*3,k[e]=color.r,k[e+1]=color.g,k[e+2]=color.b;j.bindBuffer(j.ARRAY_BUFFER,ua.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,k,b)}}f.__dirtyVertices=
  280. !1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){ua=f;b=j.DYNAMIC_DRAW;p=ua.vertices;h=ua.colors;A=p.length;g=h.length;B=ua.__vertexArray;k=ua.__colorArray;E=ua.__dirtyColors;if(ua.__dirtyVertices){for(m=0;m<A;m++)n=p[m].position,e=m*3,B[e]=n.x,B[e+1]=n.y,B[e+2]=n.z;j.bindBuffer(j.ARRAY_BUFFER,ua.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,B,b)}if(E){for(m=0;m<g;m++)color=h[m],e=m*3,k[e]=color.r,k[e+1]=color.g,k[e+2]=color.b;j.bindBuffer(j.ARRAY_BUFFER,
  281. ua.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,k,b)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=b.geometry,(f.__dirtyVertices||f.__dirtyColors||b.sortParticles)&&c(f,j.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1}function E(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function J(b){function e(b){var g=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?g.push("undefined"):g.push(b[c].id);return g.join("_")}var c,f,g,h,k,j,m,o,n=
  282. {},u=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};g=0;for(h=b.faces.length;g<h;g++)k=b.faces[g],j=k.materials,m=e(j),n[m]==void 0&&(n[m]={hash:m,counter:0}),o=n[m].hash+"_"+n[m].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:j,vertices:0,numMorphTargets:u}),k=k instanceof THREE.Face3?3:4,b.geometryGroups[o].vertices+k>65535&&(n[m].counter+=1,o=n[m].hash+"_"+n[m].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:j,vertices:0,
  283. numMorphTargets:u})),b.geometryGroups[o].faces.push(g),b.geometryGroups[o].vertices+=k}function I(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(b){if(b!=X){switch(b){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);
  284. break;default:j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}X=b}}function N(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(j.texParameteri(b,j.TEXTURE_WRAP_S,D(e.wrapS)),j.texParameteri(b,j.TEXTURE_WRAP_T,D(e.wrapT)),j.texParameteri(b,j.TEXTURE_MAG_FILTER,D(e.magFilter)),j.texParameteri(b,j.TEXTURE_MIN_FILTER,D(e.minFilter)),j.generateMipmap(b)):(j.texParameteri(b,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(b,
  285. j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(b,j.TEXTURE_MAG_FILTER,U(e.magFilter)),j.texParameteri(b,j.TEXTURE_MIN_FILTER,U(e.minFilter)))}function M(b,e){if(b.needsUpdate)b.__webglInit?(j.bindTexture(j.TEXTURE_2D,b.__webglTexture),j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,b.image)):(b.__webglTexture=j.createTexture(),j.bindTexture(j.TEXTURE_2D,b.__webglTexture),j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,b.image),b.__webglInit=!0),N(j.TEXTURE_2D,b,b.image),j.bindTexture(j.TEXTURE_2D,
  286. null),b.needsUpdate=!1;j.activeTexture(j.TEXTURE0+e);j.bindTexture(j.TEXTURE_2D,b.__webglTexture)}function Q(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=j.createFramebuffer();b.__webglRenderbuffer=j.createRenderbuffer();b.__webglTexture=j.createTexture();j.bindTexture(j.TEXTURE_2D,b.__webglTexture);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,D(b.wrapS));j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,
  287. D(b.wrapT));j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,D(b.magFilter));j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,D(b.minFilter));j.texImage2D(j.TEXTURE_2D,0,D(b.format),b.width,b.height,0,D(b.format),D(b.type),null);j.bindRenderbuffer(j.RENDERBUFFER,b.__webglRenderbuffer);j.bindFramebuffer(j.FRAMEBUFFER,b.__webglFramebuffer);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,j.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,
  288. j.DEPTH_COMPONENT16,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,b.__webglRenderbuffer)):j.renderbufferStorage(j.RENDERBUFFER,j.RGBA4,b.width,b.height);j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,
  289. null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=Z,b=Y);e!=W&&(j.bindFramebuffer(j.FRAMEBUFFER,e),j.viewport(R,ga,c,b),W=e)}function F(b,e){var c;b=="fragment"?c=j.createShader(j.FRAGMENT_SHADER):b=="vertex"&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,e);j.compileShader(c);if(!j.getShaderParameter(c,j.COMPILE_STATUS))return console.error(j.getShaderInfoLog(c)),console.error(e),null;return c}function U(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;
  290. default:return j.LINEAR}}function D(b){switch(b){case THREE.RepeatWrapping:return j.REPEAT;case THREE.ClampToEdgeWrapping:return j.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return j.MIRRORED_REPEAT;case THREE.NearestFilter:return j.NEAREST;case THREE.NearestMipMapNearestFilter:return j.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return j.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return j.LINEAR;case THREE.LinearMipMapNearestFilter:return j.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return j.LINEAR_MIPMAP_LINEAR;
  291. case THREE.ByteType:return j.BYTE;case THREE.UnsignedByteType:return j.UNSIGNED_BYTE;case THREE.ShortType:return j.SHORT;case THREE.UnsignedShortType:return j.UNSIGNED_SHORT;case THREE.IntType:return j.INT;case THREE.UnsignedShortType:return j.UNSIGNED_INT;case THREE.FloatType:return j.FLOAT;case THREE.AlphaFormat:return j.ALPHA;case THREE.RGBFormat:return j.RGB;case THREE.RGBAFormat:return j.RGBA;case THREE.LuminanceFormat:return j.LUMINANCE;case THREE.LuminanceAlphaFormat:return j.LUMINANCE_ALPHA}return 0}
  292. var da=this,j,ca=[],V=null,W=null,L=!0,fa=null,aa=null,X=null,ea=null,ia=null,oa=null,ja=null,R=0,ga=0,Z=0,Y=0,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ha=new THREE.Matrix4,pa=new Float32Array(16),ma=new Float32Array(16),ka=new THREE.Vector4,va={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},xa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
  293. Da=b.stencil!==void 0?b.stencil:!0,Aa=b.antialias!==void 0?b.antialias:!1,wa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ba=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=xa;this.sortObjects=this.autoClear=!0;try{if(!(j=xa.getContext("experimental-webgl",{antialias:Aa,stencil:Da})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+j.getParameter(j.VERSION)+" | "+j.getParameter(j.VENDOR)+
  294. " | "+j.getParameter(j.RENDERER)+" | "+j.getParameter(j.SHADING_LANGUAGE_VERSION))}catch(ya){console.error(ya)}j.clearColor(0,0,0,1);j.clearDepth(1);j.enable(j.DEPTH_TEST);j.depthFunc(j.LEQUAL);j.frontFace(j.CCW);j.cullFace(j.BACK);j.enable(j.CULL_FACE);j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA);j.clearColor(wa.r,wa.g,wa.b,Ba);this.context=j;var sa=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Da){var T={};T.vertices=new Float32Array(12);T.faces=
  295. new Uint16Array(6);T.darkness=0.5;T.vertices[0]=-20;T.vertices[1]=-20;T.vertices[2]=-1;T.vertices[3]=20;T.vertices[4]=-20;T.vertices[5]=-1;T.vertices[6]=20;T.vertices[7]=20;T.vertices[8]=-1;T.vertices[9]=-20;T.vertices[10]=20;T.vertices[11]=-1;T.faces[0]=0;T.faces[1]=1;T.faces[2]=2;T.faces[3]=0;T.faces[4]=2;T.faces[5]=3;T.vertexBuffer=j.createBuffer();T.elementBuffer=j.createBuffer();j.bindBuffer(j.ARRAY_BUFFER,T.vertexBuffer);j.bufferData(j.ARRAY_BUFFER,T.vertices,j.STATIC_DRAW);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,
  296. T.elementBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,T.faces,j.STATIC_DRAW);T.program=j.createProgram();j.attachShader(T.program,F("fragment",THREE.ShaderLib.shadowPost.fragmentShader));j.attachShader(T.program,F("vertex",THREE.ShaderLib.shadowPost.vertexShader));j.linkProgram(T.program);T.vertexLocation=j.getAttribLocation(T.program,"position");T.projectionLocation=j.getUniformLocation(T.program,"projectionMatrix");T.darknessLocation=j.getUniformLocation(T.program,"darkness")}var S={};S.vertices=
  297. new Float32Array(16);S.faces=new Uint16Array(6);b=0;S.vertices[b++]=-1;S.vertices[b++]=-1;S.vertices[b++]=0;S.vertices[b++]=0;S.vertices[b++]=1;S.vertices[b++]=-1;S.vertices[b++]=1;S.vertices[b++]=0;S.vertices[b++]=1;S.vertices[b++]=1;S.vertices[b++]=1;S.vertices[b++]=1;S.vertices[b++]=-1;S.vertices[b++]=1;S.vertices[b++]=0;S.vertices[b++]=1;b=0;S.faces[b++]=0;S.faces[b++]=1;S.faces[b++]=2;S.faces[b++]=0;S.faces[b++]=2;S.faces[b++]=3;S.vertexBuffer=j.createBuffer();S.elementBuffer=j.createBuffer();
  298. S.tempTexture=j.createTexture();S.occlusionTexture=j.createTexture();j.bindBuffer(j.ARRAY_BUFFER,S.vertexBuffer);j.bufferData(j.ARRAY_BUFFER,S.vertices,j.STATIC_DRAW);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,S.elementBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,S.faces,j.STATIC_DRAW);j.bindTexture(j.TEXTURE_2D,S.tempTexture);j.texImage2D(j.TEXTURE_2D,0,j.RGB,16,16,0,j.RGB,j.UNSIGNED_BYTE,null);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE);
  299. j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,j.NEAREST);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,j.NEAREST);j.bindTexture(j.TEXTURE_2D,S.occlusionTexture);j.texImage2D(j.TEXTURE_2D,0,j.RGBA,16,16,0,j.RGBA,j.UNSIGNED_BYTE,null);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MAG_FILTER,j.NEAREST);j.texParameteri(j.TEXTURE_2D,j.TEXTURE_MIN_FILTER,j.NEAREST);j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=
  300. 0?(S.hasVertexTexture=!1,S.program=j.createProgram(),j.attachShader(S.program,F("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),j.attachShader(S.program,F("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(S.hasVertexTexture=!0,S.program=j.createProgram(),j.attachShader(S.program,F("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),j.attachShader(S.program,F("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));j.linkProgram(S.program);S.attributes={};S.uniforms={};
  301. S.attributes.vertex=j.getAttribLocation(S.program,"position");S.attributes.uv=j.getAttribLocation(S.program,"UV");S.uniforms.renderType=j.getUniformLocation(S.program,"renderType");S.uniforms.map=j.getUniformLocation(S.program,"map");S.uniforms.occlusionMap=j.getUniformLocation(S.program,"occlusionMap");S.uniforms.opacity=j.getUniformLocation(S.program,"opacity");S.uniforms.scale=j.getUniformLocation(S.program,"scale");S.uniforms.rotation=j.getUniformLocation(S.program,"rotation");S.uniforms.screenPosition=
  302. j.getUniformLocation(S.program,"screenPosition");var qa=!1,O={};O.vertices=new Float32Array(16);O.faces=new Uint16Array(6);b=0;O.vertices[b++]=-1;O.vertices[b++]=-1;O.vertices[b++]=0;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=-1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=0;O.vertices[b++]=-1;O.vertices[b++]=1;O.vertices[b++]=0;b=O.vertices[b++]=0;O.faces[b++]=0;O.faces[b++]=1;O.faces[b++]=2;O.faces[b++]=0;O.faces[b++]=2;O.faces[b++]=
  303. 3;O.vertexBuffer=j.createBuffer();O.elementBuffer=j.createBuffer();j.bindBuffer(j.ARRAY_BUFFER,O.vertexBuffer);j.bufferData(j.ARRAY_BUFFER,O.vertices,j.STATIC_DRAW);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,O.elementBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,O.faces,j.STATIC_DRAW);O.program=j.createProgram();j.attachShader(O.program,F("fragment",THREE.ShaderLib.sprite.fragmentShader));j.attachShader(O.program,F("vertex",THREE.ShaderLib.sprite.vertexShader));j.linkProgram(O.program);O.attributes={};O.uniforms=
  304. {};O.attributes.position=j.getAttribLocation(O.program,"position");O.attributes.uv=j.getAttribLocation(O.program,"uv");O.uniforms.uvOffset=j.getUniformLocation(O.program,"uvOffset");O.uniforms.uvScale=j.getUniformLocation(O.program,"uvScale");O.uniforms.rotation=j.getUniformLocation(O.program,"rotation");O.uniforms.scale=j.getUniformLocation(O.program,"scale");O.uniforms.alignment=j.getUniformLocation(O.program,"alignment");O.uniforms.map=j.getUniformLocation(O.program,"map");O.uniforms.opacity=j.getUniformLocation(O.program,
  305. "opacity");O.uniforms.useScreenCoordinates=j.getUniformLocation(O.program,"useScreenCoordinates");O.uniforms.affectedByDistance=j.getUniformLocation(O.program,"affectedByDistance");O.uniforms.screenPosition=j.getUniformLocation(O.program,"screenPosition");O.uniforms.modelViewMatrix=j.getUniformLocation(O.program,"modelViewMatrix");O.uniforms.projectionMatrix=j.getUniformLocation(O.program,"projectionMatrix");var Ea=!1;this.setSize=function(b,e){xa.width=b;xa.height=e;this.setViewport(0,0,xa.width,
  306. xa.height)};this.setViewport=function(b,e,c,f){R=b;ga=e;Z=c;Y=f;j.viewport(R,ga,Z,Y)};this.setScissor=function(b,e,c,f){j.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){L=b;j.depthMask(b)};this.setClearColorHex=function(b,e){wa.setHex(b);Ba=e;j.clearColor(wa.r,wa.g,wa.b,Ba)};this.setClearColor=function(b,e){wa.copy(b);Ba=e;j.clearColor(wa.r,wa.g,wa.b,Ba)};this.clear=function(){j.clear(j.COLOR_BUFFER_BIT|
  307. j.DEPTH_BUFFER_BIT|j.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){T.darkness=b};this.getContext=function(){return j};this.initMaterial=function(b,e,c,f){var g,h,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?k="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof
  308. THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var o,n,u;o=u=m=0;for(n=e.length;o<n;o++)h=e[o],h instanceof THREE.DirectionalLight&&u++,h instanceof THREE.PointLight&&m++;m+u<=4?e=u:(e=Math.ceil(4*u/(m+u)),m=4-e);h={directional:e,point:m};u=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)u=f.bones.length;
  309. var p;a:{o=b.fragmentShader;n=b.vertexShader;var m=b.uniforms,e=b.attributes,c={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:c,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:h.directional,maxPointLights:h.point,maxBones:u},v;h=[];k?h.push(k):(h.push(o),h.push(n));for(v in c)h.push(v),h.push(c[v]);k=h.join();v=0;for(h=ca.length;v<h;v++)if(ca[v].code==k){p=ca[v].program;break a}v=
  310. j.createProgram();h=[sa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_BONES "+c.maxBones,c.map?"#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. u=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,c.fog?"#define USE_FOG":"",c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(v,F("fragment",u+o));j.attachShader(v,F("vertex",h+n));j.linkProgram(v);
  312. j.getProgramParameter(v,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(v,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");v.uniforms={};v.attributes={};var w;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in m)o.push(w);w=o;m=0;for(o=w.length;m<o;m++)n=w[m],v.uniforms[n]=j.getUniformLocation(v,n);o=["position","normal",
  313. "uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<c.maxMorphTargets;w++)o.push("morphTarget"+w);for(p in e)o.push(p);p=o;w=0;for(e=p.length;w<e;w++)c=p[w],v.attributes[c]=j.getAttribLocation(v,c);ca.push({program:v,code:k});p=v}b.program=p;p=b.program.attributes;p.position>=0&&j.enableVertexAttribArray(p.position);p.color>=0&&j.enableVertexAttribArray(p.color);p.normal>=0&&j.enableVertexAttribArray(p.normal);p.tangent>=0&&j.enableVertexAttribArray(p.tangent);
  314. b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(j.enableVertexAttribArray(p.skinVertexA),j.enableVertexAttribArray(p.skinVertexB),j.enableVertexAttribArray(p.skinIndex),j.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(g in b.attributes)p[g]!==void 0&&p[g]>=0&&j.enableVertexAttribArray(p[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=0&&(j.enableVertexAttribArray(p.morphTarget0),b.numSupportedMorphTargets++);p.morphTarget1>=0&&(j.enableVertexAttribArray(p.morphTarget1),
  315. b.numSupportedMorphTargets++);p.morphTarget2>=0&&(j.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(j.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(j.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(j.enableVertexAttribArray(p.morphTarget5),b.numSupportedMorphTargets++);p.morphTarget6>=0&&(j.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>=
  316. 0&&(j.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b<g;b++)f.__webglMorphTargetInfluences[b]=0}};this.render=function(b,c,o,E){var D,J,F,I,K,M,L,N,O=b.lights,R=b.fog;da.data.vertices=0;da.data.faces=0;da.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(ma);c.projectionMatrix.flattenToArray(pa);ha.multiply(c.projectionMatrix,
  317. c.matrixWorldInverse);n(ha);this.initWebGLObjects(b);Q(o);(this.autoClear||E)&&this.clear();K=b.__webglObjects.length;for(E=0;E<K;E++)if(D=b.__webglObjects[E],L=D.object,L.visible)if(!(L instanceof THREE.Mesh)||p(L)){if(L.matrixWorld.flattenToArray(L._objectMatrixArray),y(L,c),v(D),D.render=!0,this.sortObjects)D.object.renderDepth?D.z=D.object.renderDepth:(ka.copy(L.position),ha.multiplyVector3(ka),D.z=ka.z)}else D.render=!1;else D.render=!1;this.sortObjects&&b.__webglObjects.sort(w);M=b.__webglObjectsImmediate.length;
  318. for(E=0;E<M;E++)D=b.__webglObjectsImmediate[E],L=D.object,L.visible&&(L.matrixAutoUpdate&&L.matrixWorld.flattenToArray(L._objectMatrixArray),y(L,c),u(D));if(b.overrideMaterial){k(b.overrideMaterial.depthTest);G(b.overrideMaterial.blending);for(E=0;E<K;E++)if(D=b.__webglObjects[E],D.render)L=D.object,N=D.buffer,h(L),f(c,O,R,b.overrideMaterial,N,L);for(E=0;E<M;E++)D=b.__webglObjectsImmediate[E],L=D.object,L.visible&&(h(L),J=e(c,O,R,b.overrideMaterial,L),L.render(function(e){g(e,J,b.overrideMaterial.shading)}))}else{G(THREE.NormalBlending);
  319. for(E=0;E<K;E++)if(D=b.__webglObjects[E],D.render){L=D.object;N=D.buffer;F=D.opaque;h(L);for(D=0;D<F.count;D++)I=F.list[D],k(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),f(c,O,R,I,N,L)}for(E=0;E<M;E++)if(D=b.__webglObjectsImmediate[E],L=D.object,L.visible){F=D.opaque;h(L);for(D=0;D<F.count;D++)I=F.list[D],k(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),J=e(c,O,R,I,L),L.render(function(b){g(b,J,I.shading)})}for(E=0;E<K;E++)if(D=b.__webglObjects[E],
  320. D.render){L=D.object;N=D.buffer;F=D.transparent;h(L);for(D=0;D<F.count;D++)I=F.list[D],G(I.blending),k(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),f(c,O,R,I,N,L)}for(E=0;E<M;E++)if(D=b.__webglObjectsImmediate[E],L=D.object,L.visible){F=D.transparent;h(L);for(D=0;D<F.count;D++)I=F.list[D],G(I.blending),k(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),J=e(c,O,R,I,L),L.render(function(b){g(b,J,I.shading)})}}b.__webglSprites.length&&B(b,c);Da&&
  321. b.__webglShadowVolumes.length&&b.lights.length&&x(b);b.__webglLensFlares.length&&A(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&(j.bindTexture(j.TEXTURE_2D,o.__webglTexture),j.generateMipmap(j.TEXTURE_2D),j.bindTexture(j.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],
  322. c=b,f=void 0,g=void 0,h=void 0;if(e._modelViewMatrix==void 0)e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray);if(e instanceof THREE.Mesh)for(f in g=e.geometry,g.geometryGroups==void 0&&J(g),g.geometryGroups){h=g.geometryGroups[f];if(!h.__webglVertexBuffer){var k=h;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();
  323. k.__webglTangentBuffer=j.createBuffer();k.__webglColorBuffer=j.createBuffer();k.__webglUVBuffer=j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer=j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){var m=void 0,o=void 0;k.__webglMorphTargetsBuffers=[];m=0;for(o=k.numMorphTargets;m<
  324. o;m++)k.__webglMorphTargetsBuffers.push(j.createBuffer())}for(var k=h,m=e,n=void 0,p=void 0,u=void 0,v=u=void 0,w=void 0,x=void 0,y=x=o=0,A=u=p=void 0,B=A=p=n=void 0,u=void 0,v=m.geometry,w=v.faces,A=k.faces,n=0,p=A.length;n<p;n++)u=A[n],u=w[u],u instanceof THREE.Face3?(o+=3,x+=1,y+=3):u instanceof THREE.Face4&&(o+=4,x+=2,y+=4);for(var n=k,p=m,D=A=w=void 0,F=void 0,D=void 0,u=[],w=0,A=p.materials.length;w<A;w++)if(D=p.materials[w],D instanceof THREE.MeshFaceMaterial){D=0;for(l=n.materials.length;D<
  325. l;D++)(F=n.materials[D])&&u.push(F)}else(F=D)&&u.push(F);n=u;k.__materials=n;a:{w=p=void 0;A=n.length;for(p=0;p<A;p++)if(w=n[p],w.map||w.lightMap||w instanceof THREE.MeshShaderMaterial){p=!0;break a}p=!1}a:{A=w=void 0;u=n.length;for(w=0;w<u;w++)if(A=n[w],!(A instanceof THREE.MeshBasicMaterial&&!A.envMap||A instanceof THREE.MeshDepthMaterial)){A=A&&A.shading!=void 0&&A.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}A=!1}a:{u=w=void 0;D=n.length;for(w=0;w<D;w++)if(u=n[w],
  326. u.vertexColors){u=u.vertexColors;break a}u=!1}k.__vertexArray=new Float32Array(o*3);if(A)k.__normalArray=new Float32Array(o*3);if(v.hasTangents)k.__tangentArray=new Float32Array(o*4);if(u)k.__colorArray=new Float32Array(o*3);if(p){if(v.faceUvs.length>0||v.faceVertexUvs.length>0)k.__uvArray=new Float32Array(o*2);if(v.faceUvs.length>1||v.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(o*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(o*4),
  327. k.__skinVertexBArray=new Float32Array(o*4),k.__skinIndexArray=new Float32Array(o*4),k.__skinWeightArray=new Float32Array(o*4);k.__faceArray=new Uint16Array(x*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(y*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];v=0;for(w=k.numMorphTargets;v<w;v++)k.__morphTargetsArrays.push(new Float32Array(o*3))}k.__needsSmoothNormals=A==THREE.SmoothShading;k.__uvType=p;k.__vertexColorType=u;k.__normalType=A;k.__webglFaceCount=
  328. x*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0);k.__webglLineCount=y*2;v=0;for(w=n.length;v<w;v++)if(p=n[v],p.attributes)for(a in k.__webglCustomAttributes={},p.attributes){u=p.attributes[a];A={};for(B in u)A[B]=u[B];if(!A.__webglInitialized||A.createUniqueBuffers)A.__webglInitialized=!0,x=1,A.type==="v2"?x=2:A.type==="v3"?x=3:A.type==="v4"?x=4:A.type==="c"&&(x=3),A.size=x,A.array=new Float32Array(o*x),A.buffer=j.createBuffer(),A.buffer.belongsToAttribute=a,u.needsUpdate=!0,A.__original=
  329. u;k.__webglCustomAttributes[a]=A}k.__inittedArrays=!0;g.__dirtyVertices=!0;g.__dirtyMorphTargets=!0;g.__dirtyElements=!0;g.__dirtyUvs=!0;g.__dirtyNormals=!0;g.__dirtyTangents=!0;g.__dirtyColors=!0}e instanceof THREE.ShadowVolume?I(c.__webglShadowVolumes,h,e):I(c.__webglObjects,h,e)}else if(e instanceof THREE.LensFlare)I(c.__webglLensFlares,void 0,e);else if(e instanceof THREE.Ribbon){g=e.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=j.createBuffer(),f.__webglColorBuffer=j.createBuffer(),
  330. f=g,h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__webglVertexCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;I(c.__webglObjects,g,e)}else if(e instanceof THREE.Line){g=e.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=j.createBuffer(),f.__webglColorBuffer=j.createBuffer(),f=g,h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__webglLineCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;I(c.__webglObjects,
  331. g,e)}else if(e instanceof THREE.ParticleSystem){g=e.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=j.createBuffer(),f.__webglColorBuffer=j.createBuffer(),f=g,h=f.vertices.length,f.__vertexArray=new Float32Array(h*3),f.__colorArray=new Float32Array(h*3),f.__sortArray=[],f.__webglParticleCount=h,g.__dirtyVertices=!0,g.__dirtyColors=!0;I(c.__webglObjects,g,e)}else THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?c.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},
  332. transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&c.__webglSprites.push(e);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){c=b.__objectsRemoved[0];e=b;if(c instanceof THREE.ShadowVolume)E(e.__webglShadowVolumes,c);else if(c instanceof THREE.Mesh||c instanceof THREE.ParticleSystem||c instanceof THREE.Ribbon||c instanceof THREE.Line)E(e.__webglObjects,c);else if(c instanceof THREE.Sprite){e=e.__webglSprites;g=void 0;for(g=e.length-1;g>=0;g--)e[g]==c&&e.splice(g,1)}else c instanceof
  333. THREE.LensFlare?E(e.__webglLensFlares,c):c instanceof THREE.MarchingCubes&&E(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;e<c;e++)K(b.__webglObjects[e].object,b);e=0;for(c=b.__webglShadowVolumes.length;e<c;e++)K(b.__webglShadowVolumes[e].object,b);e=0;for(c=b.__webglLensFlares.length;e<c;e++)K(b.__webglLensFlares[e].object,b)};this.setFaceCulling=function(b,e){b?(!e||e=="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),b=="back"?j.cullFace(j.BACK):b=="front"?
  334. j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)};this.supportsVertexTextures=function(){return sa}};
  335. THREE.WebGLRenderTarget=function(b,c,e){this.width=b;this.height=c;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
  336. THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};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)};
  337. 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};
  338. 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};
  339. 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};
  340. THREE.ColorUtils={adjustHSV:function(b,c,e,f){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+e,0,1);g.v=THREE.ColorUtils.clamp(g.v+f,0,1);b.setHSV(g.h,g.s,g.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,g=b.b,h=Math.max(Math.max(e,f),g),k=Math.min(Math.min(e,f),g);if(k==h)k=e=0;else{var m=h-k,k=m/h,e=e==h?(f-g)/m:f==h?2+(g-e)/m:4+(e-f)/m;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=k;c.v=h;return c},
  341. clamp:function(b,c,e){return b<c?c:b>e?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
  342. var GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,h=b.vertices,k=g.vertices,m=b.faces,n=g.faces,p=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,u=k.length;o<u;o++){var v=new THREE.Vertex(k[o].position.clone());e&&c.matrix.multiplyVector3(v.position);h.push(v)}o=0;for(u=n.length;o<u;o++){var k=n[o],w,x,B=k.vertexNormals,v=k.vertexColors;k instanceof THREE.Face3?w=new THREE.Face3(k.a+f,k.b+f,k.c+f):
  343. k instanceof THREE.Face4&&(w=new THREE.Face4(k.a+f,k.b+f,k.c+f,k.d+f));w.normal.copy(k.normal);e=0;for(h=B.length;e<h;e++)x=B[e],w.vertexNormals.push(x.clone());w.color.copy(k.color);e=0;for(h=v.length;e<h;e++)x=v[e],w.vertexColors.push(x.clone());w.materials=k.materials.slice();w.centroid.copy(k.centroid);m.push(w)}o=0;for(u=g.length;o<u;o++){f=g[o];m=[];e=0;for(h=f.length;e<h;e++)m.push(new THREE.UV(f[e].u,f[e].v));p.push(m)}}};
  344. THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,g=new THREE.Texture(f,c);f.onload=function(){g.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return g},loadTextureCube:function(b,c,e){var f,g=[],h=new THREE.Texture(g,c),c=g.loadCount=0;for(f=b.length;c<f;++c)g[c]=new Image,g[c].onload=function(){g.loadCount+=1;if(g.loadCount==6)h.needsUpdate=!0;e&&e(this)},g[c].crossOrigin="",g[c].src=b[c];return h}};
  345. THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,g=b.children.length;for(f=0;f<g;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
  346. if(THREE.WebGLRenderer)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}",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}"},
  347. normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,{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},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",
  348. 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},uOpacity:{type:"f",value:1}}]),fragmentShader:["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\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;\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 ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
  349. THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\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 );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = 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 + viewPosition );\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 );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
  350. THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:"attribute vec4 tangent;\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;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\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;\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 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\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}"},
  351. 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",
  352. 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}"},
  353. 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}"},
  354. 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}",
  355. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var c,e,f,g,h=2*Math.ceil(b*3)+1;h>25&&(h=25);g=(h-1)*0.5;e=Array(h);for(c=f=0;c<h;++c)e[c]=Math.exp(-((c-g)*(c-g))/(2*b*b)),f+=e[c];for(c=0;c<h;++c)e[c]/=f;return e}};
  356. THREE.AnimationHandler=function(){var b=[],c={},e={update:function(e){for(var c=0;c<b.length;c++)b[c].update(e)},addToUpdate:function(e){b.indexOf(e)===-1&&b.push(e)},removeFromUpdate:function(e){e=b.indexOf(e);e!==-1&&b.splice(e,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 e=0;e<b.hierarchy.length;e++){for(var f=0;f<b.hierarchy[e].keys.length;f++){if(b.hierarchy[e].keys[f].time<
  357. 0)b.hierarchy[e].keys[f].time=0;if(b.hierarchy[e].keys[f].rot!==void 0&&!(b.hierarchy[e].keys[f].rot instanceof THREE.Quaternion)){var m=b.hierarchy[e].keys[f].rot;b.hierarchy[e].keys[f].rot=new THREE.Quaternion(m[0],m[1],m[2],m[3])}}if(b.hierarchy[e].keys[0].morphTargets!==void 0){m={};for(f=0;f<b.hierarchy[e].keys.length;f++)for(var n=0;n<b.hierarchy[e].keys[f].morphTargets.length;n++){var p=b.hierarchy[e].keys[f].morphTargets[n];m[p]=-1}b.hierarchy[e].usedMorphTargets=m;for(f=0;f<b.hierarchy[e].keys.length;f++){var o=
  358. {};for(p in m){for(n=0;n<b.hierarchy[e].keys[f].morphTargets.length;n++)if(b.hierarchy[e].keys[f].morphTargets[n]===p){o[p]=b.hierarchy[e].keys[f].morphTargetsInfluences[n];break}n===b.hierarchy[e].keys[f].morphTargets.length&&(o[p]=0)}b.hierarchy[e].keys[f].morphTargetsInfluences=o}}for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].time===b.hierarchy[e].keys[f-1].time&&(b.hierarchy[e].keys.splice(f,1),f--);for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].index=f}f=parseInt(b.length*
  359. b.fps,10);b.JIT={};b.JIT.hierarchy=[];for(e=0;e<b.hierarchy.length;e++)b.JIT.hierarchy.push(Array(f));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 e=[];if(b instanceof THREE.SkinnedMesh)for(var c=0;c<b.bones.length;c++)e.push(b.bones[c]);else f(b,e);return e}},f=function(b,e){e.push(b);for(var c=0;c<b.children.length;c++)f(b.children[c],e)};e.LINEAR=0;e.CATMULLROM=1;e.CATMULLROM_FORWARD=
  360. 2;return e}();THREE.Animation=function(b,c,e,f){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=e!==void 0?e:THREE.AnimationHandler.LINEAR;this.JITCompile=f!==void 0?f:!0;this.points=[];this.target=new THREE.Vector3};
  361. 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 e,f=this.hierarchy.length,g;for(e=0;e<f;e++){g=this.hierarchy[e];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
  362. THREE.Bone?g.skinMatrix:g.matrix;var h=g.animationCache.prevKey;g=g.animationCache.nextKey;h.pos=this.data.hierarchy[e].keys[0];h.rot=this.data.hierarchy[e].keys[0];h.scl=this.data.hierarchy[e].keys[0];g.pos=this.getNextKeyWith("pos",e,1);g.rot=this.getNextKeyWith("rot",e,1);g.scl=this.getNextKeyWith("scl",e,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
  363. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  364. 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};
  365. THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,g,h,k,m,n,p,o=this.data.JIT.hierarchy,u,v;this.currentTime+=b*this.timeScale;v=this.currentTime;u=this.currentTime%=this.data.length;p=parseInt(Math.min(u*this.data.fps,this.data.length*this.data.fps),10);for(var w=0,x=this.hierarchy.length;w<x;w++)if(b=this.hierarchy[w],n=b.animationCache,this.JITCompile&&o[w][p]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=o[w][p],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
  366. !1):(b.matrix=o[w][p],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 B=0;B<3;B++){e=c[B];k=n.prevKey[e];m=n.nextKey[e];if(m.time<=v){if(u<v)if(this.loop){k=this.data.hierarchy[w].keys[0];for(m=this.getNextKeyWith(e,w,1);m.time<u;)k=m,m=this.getNextKeyWith(e,w,m.index+1)}else{this.stop();return}else{do k=m,m=this.getNextKeyWith(e,w,m.index+1);while(m.time<
  367. u)}n.prevKey[e]=k;n.nextKey[e]=m}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(u-k.time)/(m.time-k.time);g=k[e];h=m[e];if(f<0||f>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+w),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(h[0]-g[0])*f,e.y=g[1]+(h[1]-g[1])*f,e.z=g[2]+(h[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
  368. this.getPrevKeyWith("pos",w,k.index-1).pos,this.points[1]=g,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",w,m.index+1).pos,f=f*0.33+0.33,g=this.interpolateCatmullRom(this.points,f),e.x=g[0],e.y=g[1],e.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e===
  369. "rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(h[0]-g[0])*f,e.y=g[1]+(h[1]-g[1])*f,e.z=g[2]+(h[2]-g[2])*f}}if(this.JITCompile&&o[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(w=0;w<this.hierarchy.length;w++)o[w][p]=this.hierarchy[w]instanceof THREE.Bone?this.hierarchy[w].skinMatrix.clone():this.hierarchy[w].matrix.clone()}}};
  370. THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],g,h,k,m,n,p;g=(b.length-1)*c;h=Math.floor(g);g-=h;e[0]=h==0?h:h-1;e[1]=h;e[2]=h>b.length-2?h:h+1;e[3]=h>b.length-3?h:h+2;h=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=g*g;k=g*e;f[0]=this.interpolate(h[0],m[0],n[0],p[0],g,e,k);f[1]=this.interpolate(h[1],m[1],n[1],p[1],g,e,k);f[2]=this.interpolate(h[2],m[2],n[2],p[2],g,e,k);return f};
  371. THREE.Animation.prototype.interpolate=function(b,c,e,f,g,h,k){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*k+(-3*(c-e)-2*b-f)*h+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e<f.length-1?e:f.length-1:e%=f.length;e<f.length;e++)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[0]};
  372. THREE.Animation.prototype.getPrevKeyWith=function(b,c,e){for(var f=this.data.hierarchy[c].keys,e=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e>0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]};
  373. THREE.FirstPersonCamera=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.0050;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=
  374. 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!==
  375. 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();
  376. 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=
  377. !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=
  378. 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&&
  379. (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=
  380. (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),
  381. !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.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;
  382. THREE.FirstPersonCamera.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))};
  383. THREE.PathCamera=function(b){function c(b,e,c,f){var g={name:c,fps:0.6,length:f,hierarchy:[]},h,k=e.getControlPointsArray(),m=e.getLength(),n=k.length,K=0;h=n-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[h]={time:f,pos:k[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<n-1;h++)K=f*m.chunks[h]/m.total,e.keys[h]={time:K,pos:k[h]};g.hierarchy[0]=e;THREE.AnimationHandler.add(g);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
  384. f,h=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),h.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return h}function f(b,c){var f=e(c,10),h=e(c,10),g=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,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.SphereGeometry(1,
  385. 16,8);g=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,g),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}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.0050;this.lookHorizontal=
  386. 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!==
  387. 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=
  388. window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(b,e,c){var f,k;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;f=this.phi%g;this.phi=f>=0?f:f+g;f=this.verticalAngleMap.srcRange;k=this.verticalAngleMap.dstRange;var m=k[1]-k[0];this.phi=
  389. TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.horizontalAngleMap.srcRange;k=this.horizontalAngleMap.dstRange;m=k[1]-k[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,e,c)};this.onMouseMove=function(b){this.mouseX=
  390. 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}),k=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),n=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,k);b.position.set(0,10,0);this.animation=
  391. c(this.animationParent,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&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.apply(b,arguments)}}(this,this.onMouseMove),
  392. !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
  393. 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.0050;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=
  394. 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=
  395. 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()}};
  396. 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;
  397. 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-
  398. 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*
  399. 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||
  400. 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!=
  401. 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,
  402. 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;
  403. THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);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,k=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,o=0,u=0,v=0,w=0,x=0,B=window.innerWidth/2,A=window.innerHeight/2;this.update=
  404. 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*w),this.rotateVertically(b*x));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*u);this.translateY(b*v);n&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
  405. else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();k.copy(this.forward);h.set(0,1,0);g.cross(h,k).normalize();h.cross(k,g).normalize();this.matrix.n11=g.x;this.matrix.n12=h.x;this.matrix.n13=k.x;this.matrix.n21=g.y;this.matrix.n22=h.y;this.matrix.n23=k.y;this.matrix.n31=g.z;this.matrix.n32=h.z;this.matrix.n33=k.z;m.identity();m.n11=Math.cos(this.roll);m.n12=-Math.sin(this.roll);m.n21=Math.sin(this.roll);m.n22=Math.cos(this.roll);this.matrix.multiplySelf(m);
  406. 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-=
  407. 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",
  408. function(b){w=(b.clientX-B)/window.innerWidth;x=(b.clientY-A)/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:u=-1;break;
  409. case 40:case 83:o=-1;break;case 39:case 68:u=1;break;case 81:n=!0;p=1;break;case 69:n=!0;p=-1;break;case 82:v=1;break;case 70:v=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:o=0;break;case 37:case 65:u=0;break;case 40:case 83:o=0;break;case 39:case 68:u=0;break;case 81:n=!1;break;case 69:n=!1;break;case 82:v=0;break;case 70:v=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
  410. THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
  411. THREE.TrackballCamera=function(b){function c(b,e){return function(){e.apply(b,arguments)}}b=b||{};THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.domElement=b.domElement||document;this.screen=b.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=b.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=b.rotateSpeed||1;this.zoomSpeed=b.zoomSpeed||1.2;this.panSpeed=b.panSpeed||0.3;this.noZoom=b.noZoom||!1;this.noPan=b.noPan||
  412. !1;this.staticMoving=b.staticMoving||!1;this.dynamicDampingFactor=b.dynamicDampingFactor||0.2;this.minDistance=b.minDistance||0;this.maxDistance=b.maxDistance||Infinity;this.keys=b.keys||[65,83,68];this.useTarget=!0;var e=!1,f=this.STATE.NONE,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector2,n=new THREE.Vector2,p=new THREE.Vector2,o=new THREE.Vector2;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.getMouseOnScreen=function(b,e){return new THREE.Vector2((b-
  413. this.screen.offsetLeft)/this.radius*0.5,(e-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(b,e){var c=new THREE.Vector3((b-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-e)/this.radius,0),f=c.length();f>1?c.normalize():c.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(c.y);f.addSelf(this.up.clone().crossSelf(g).setLength(c.x));f.addSelf(g.setLength(c.z));return f};
  414. this.rotateCamera=function(){var b=Math.acos(h.dot(k)/h.length()/k.length());if(b){var e=(new THREE.Vector3).cross(h,k).normalize(),c=new THREE.Quaternion;b*=this.rotateSpeed;c.setFromAxisAngle(e,-b);c.multiplyVector3(g);c.multiplyVector3(this.up);c.multiplyVector3(k);this.staticMoving?h=k:(c.setFromAxisAngle(e,b*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var b=1+(n.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)};
  415. this.panCamera=function(){var b=o.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var e=g.clone().crossSelf(this.up).setLength(b.x);e.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(e);this.target.position.addSelf(e);this.staticMoving?p=o:p.addSelf(b.sub(o,p).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
  416. g.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,g.setLength(this.minDistance))};this.update=function(b,e,c){g=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,g);this.checkDistances();this.supr.update.call(this,b,e,c)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
  417. c(this,function(b){e&&(h=k=this.getMouseProjectionOnBall(b.clientX,b.clientY),m=n=this.getMouseOnScreen(b.clientX,b.clientY),p=o=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?k=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?n=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(o=this.getMouseOnScreen(b.clientX,b.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(b){b.preventDefault();
  418. b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?h=k=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?m=n=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(p=o=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();f=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(f===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])f=
  419. this.STATE.ROTATE;else if(b.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)f=this.STATE.ZOOM;else if(b.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)f=this.STATE.PAN;f!==this.STATE.NONE&&(e=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(f!==this.STATE.NONE)f=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
  420. THREE.TrackballCamera.prototype.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};THREE.QuakeCamera=THREE.FirstPersonCamera;THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPoint(c/b));return e};
  421. THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPointAt(c/b));return e};THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheLengths&&this.cacheLengths.length==b)return this.cacheLengths;for(var c=[],e=1,f=this.getPoint(0),g,h=0;e<=b;e++)g=this.getPoint(e/b),h+=g.distanceTo(f),c.push(h),f=g;return this.cacheLengths=c};
  422. THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,g=e.length,h;for(h=c?c:b*e[g-1];f<g;){if(e[f]>h)break;f++}return f/g};THREE.StraightCurve=function(b,c,e,f){this.x1=b;this.y1=c;this.x2=e;this.y2=f};THREE.StraightCurve.prototype=new THREE.Curve;THREE.StraightCurve.prototype.constructor=THREE.StraightCurve;THREE.StraightCurve.prototype.getPoint=function(b){return new THREE.Vector2(this.x1+(this.x2-this.x1)*b,this.y1+(this.y2-this.y1)*b)};
  423. THREE.QuadraticBezierCurve=function(b,c,e,f,g,h){this.x0=b;this.y0=c;this.x1=e;this.y1=f;this.x2=g;this.y2=h};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;THREE.QuadraticBezierCurve.prototype.getPoint=function(b){var c;c=THREE.FontUtils.b2(b,this.x0,this.x1,this.x2);b=THREE.FontUtils.b2(b,this.y0,this.y1,this.y2);return new THREE.Vector2(c,b)};
  424. THREE.QuadraticBezierCurve.prototype.getNormalVector=function(b){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(b,this.x0,this.x1,this.x2);b=THREE.Curve.Utils.tangentQuadraticBezier(b,this.y0,this.y1,this.y2);return(new THREE.Vector2(-b,c)).unit()};THREE.CubicBezierCurve=function(b,c,e,f,g,h,k,m){this.x0=b;this.y0=c;this.x1=e;this.y1=f;this.x2=g;this.y2=h;this.x3=k;this.y3=m};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;
  425. THREE.CubicBezierCurve.prototype.getPoint=function(b){var c;c=THREE.FontUtils.b3(b,this.x0,this.x1,this.x2,this.x3);b=THREE.FontUtils.b3(b,this.y0,this.y1,this.y2,this.y3);return new THREE.Vector2(c,b)};THREE.SplineCurve=function(b){this.points=b};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
  426. THREE.SplineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2,e=[],f=this.points,g;g=(f.length-1)*b;b=Math.floor(g);g-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,g);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,g);return c};THREE.ArcCurve=function(b,c,e,f,g,h){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=g;this.aClockwise=h};
  427. THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(b){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(b=1-b);b=this.aStartAngle+b*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(b),this.aY+this.aRadius*Math.sin(b))};
  428. THREE.Curve.Utils={tangentQuadraticBezier:function(b,c,e,f){return 2*(1-b)*(e-c)+2*b*(f-e)},tangentSpline:function(){},interpolate:function(b,c,e,f,g){var b=(e-b)*0.5,f=(f-c)*0.5,h=g*g;return(2*c-2*e+b+f)*g*h+(-3*c+3*e-2*b-f)*h+b*g+c}};THREE.Path=function(b){this.actions=[];this.curves=[];b&&this.fromPoints(b)};THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"};
  429. THREE.Path.prototype.fromPoints=function(b){var c=0,e=b.length;this.moveTo(b[0].x,b[0].y);for(c=1;c<e;c++)this.lineTo(b[c].x,b[c].y)};THREE.Path.prototype.moveTo=function(){var b=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:b})};
  430. THREE.Path.prototype.lineTo=function(b,c){var e=Array.prototype.slice.call(arguments),f=this.actions[this.actions.length-1].args,f=new THREE.StraightCurve(f[f.length-2],f[f.length-1],b,c);this.curves.push(f);this.actions.push({action:THREE.PathActions.LINE_TO,args:e,curve:f})};
  431. THREE.Path.prototype.quadraticCurveTo=function(b,c,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,h=new THREE.QuadraticBezierCurve(h[h.length-2],h[h.length-1],b,c,e,f);this.curves.push(h);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:g,curve:h})};
  432. THREE.Path.prototype.bezierCurveTo=function(b,c,e,f,g,h){var k=Array.prototype.slice.call(arguments),m=this.actions[this.actions.length-1].args,m=new THREE.CubicBezierCurve(m[m.length-2],m[m.length-1],b,c,e,f,g,h);this.curves.push(m);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:k,curve:m})};
  433. THREE.Path.prototype.splineThru=function(b){var c=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args,e=[new THREE.Vector2(e[e.length-2],e[e.length-1])],e=e.concat(b),e=new THREE.SplineCurve(e);this.curves.push(e);this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c,curve:e})};
  434. THREE.Path.prototype.arc=function(b,c,e,f,g,h){var k=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(b,c,e,f,g,h));this.actions.push({action:THREE.PathActions.ARC,args:k})};THREE.Path.prototype.getSpacedPoints=function(b){b||(b=40);for(var c=[],e=0;e<b;e++)c.push(this.getPoint(e/b));return c};
  435. THREE.Path.prototype.getPoints=function(b){var b=b||12,c=[],e,f,g,h,k,m,n,p,o,u,v,w,x;e=0;for(f=this.actions.length;e<f;e++)switch(g=this.actions[e],h=g.action,g=g.args,h){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(g[0],g[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:k=g[2];m=g[3];o=g[0];u=g[1];c.length>0?(h=c[c.length-1],v=h.x,w=h.y):(h=this.actions[e-1].args,v=h[h.length-2],w=h[h.length-1]);for(h=1;h<=b;h++)x=h/b,g=THREE.FontUtils.b2(x,v,o,k),x=THREE.FontUtils.b2(x,w,u,m),c.push(new THREE.Vector2(g,
  436. x));break;case THREE.PathActions.BEZIER_CURVE_TO:k=g[4];m=g[5];o=g[0];u=g[1];n=g[2];p=g[3];c.length>0?(h=c[c.length-1],v=h.x,w=h.y):(h=this.actions[e-1].args,v=h[h.length-2],w=h[h.length-1]);for(h=1;h<=b;h++)x=h/b,g=THREE.FontUtils.b3(x,v,o,n,k),x=THREE.FontUtils.b3(x,w,u,p,m),c.push(new THREE.Vector2(g,x));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[e-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];x=b*g[0].length;h=h.concat(g[0]);g=new THREE.SplineCurve(h);for(h=1;h<=x;h++)c.push(g.getPointAt(h/
  437. x));break;case THREE.PathActions.ARC:h=this.actions[e-1].args;k=g[0];m=g[1];n=g[2];o=g[3];x=g[4];u=!!g[5];p=h[h.length-2];v=h[h.length-1];h.length==0&&(p=v=0);w=x-o;var B=b*2;for(h=1;h<=B;h++)x=h/B,u||(x=1-x),x=o+x*w,g=p+k+n*Math.cos(x),x=v+m+n*Math.sin(x),c.push(new THREE.Vector2(g,x))}return c};
  438. THREE.Path.prototype.getMinAndMax=function(){var b=this.getPoints(),c,e,f,g;c=e=Number.NEGATIVE_INFINITY;f=g=Number.POSITIVE_INFINITY;var h,k,m;k=0;for(m=b.length;k<m;k++){h=b[k];if(h.x>c)c=h.x;else if(h.x<f)f=h.x;if(h.y>e)e=h.y;else if(h.y<e)g=h.y}return{minX:f,minY:g,maxX:c,maxY:e}};THREE.Path.prototype.getPoint=function(b){for(var c=b*this.getLength(),e=this.sums,b=0;b<e.length;){if(e[b]>=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null};
  439. THREE.Path.prototype.getLength=function(){for(var b=[],c=0,e=0,f=this.curves.length;e<f;e++)c+=this.curves[e].getLength(),b.push(c);this.sums=b;return c};
  440. THREE.Path.prototype.createPathGeometry=function(b,c){var e=this.getPoints(b),f,g=new THREE.Object3D;c||(c=new THREE.LineBasicMaterial({color:0,opacity:0.7}));for(var h=1;h<e.length;h++)f=new THREE.Geometry,f.vertices.push(new THREE.Vertex(new THREE.Vector3(e[h-1].x,e[h-1].y,0))),f.vertices.push(new THREE.Vertex(new THREE.Vector3(e[h].x,e[h].y,0))),f=new THREE.Line(f,c),g.addChild(f);return g};
  441. THREE.Path.prototype.transform=function(b){b=new THREE.Path;b.moveTo(0,0);b.quadraticCurveTo(100,20,140,80);console.log(b.cacheArcLengths());var c=this.getMinAndMax(),e=this.getPoints(),f,g,h,k,m,n;f=0;for(g=e.length;f<g;f++)h=e[f],k=h.x,m=h.y,n=k/c.maxX,k=b.getPoint(n),m=b.getNormalVector(n).multiplyScalar(m),h.x=k.x+m.x,h.y=k.y+m.y;return e};
  442. THREE.Path.prototype.nltransform=function(b,c,e,f,g,h){var k=this.getPoints(),m,n,p,o,u;m=0;for(n=k.length;m<n;m++)p=k[m],o=p.x,u=p.y,p.x=b*o+c*u+e,p.y=f*u+g*o+h;return k};
  443. THREE.Path.prototype.debug=function(b){var c=this.getMinAndMax();b||(b=document.createElement("canvas"),b.setAttribute("width",c.maxX+100),b.setAttribute("height",c.maxY+100),document.body.appendChild(b));c=b.getContext("2d");c.fillStyle="white";c.fillRect(0,0,b.width,b.height);c.strokeStyle="black";c.beginPath();var e,f,g,b=0;for(e=this.actions.length;b<e;b++)f=this.actions[b],g=f.args,f=f.action,f!=THREE.PathActions.CSPLINE_THRU&&c[f].apply(c,g);c.stroke();c.closePath();c.strokeStyle="red";f=this.transform(0.866,
  444. -0.866,0,0.5,0.5,-50);b=0;for(e=f.length;b<e;b++)g=f[b],c.beginPath(),c.arc(g.x,g.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(b){return new THREE.ExtrudeGeometry(this,b)};
  445. THREE.Shape.prototype.getHoles=function(b){for(var b=b?"getSpacedPoints":"getPoints",c=[],e=0,f=this.holes.length;e<f;e++)c[e]=this.holes[e][b]();return c};THREE.Shape.prototype.extractAllPoints=function(b){return{shape:this[b?"getSpacedPoints":"getPoints"](),holes:this.getHoles(b)}};
  446. THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f,g=e.concat(),h,k,m,n,p,o,u,v,w,x=[];for(k=0;k<c.length;k++){f=c[k];g=g.concat(f);h=Number.POSITIVE_INFINITY;for(m=0;m<f.length;m++){v=f[m];w=[];for(u=0;u<e.length;u++)o=e[u],o=v.distanceTo(o),w.push(o),o<h&&(h=o,n=m,p=u)}h=p-1>=0?p-1:e.length-1;m=n-1>=0?n-1:f.length-1;var B=[f[n],e[p],e[h]];u=THREE.FontUtils.Triangulate.area(B);var A=[f[n],f[m],e[p]];v=THREE.FontUtils.Triangulate.area(A);w=p;o=n;p+=1;n+=-1;p<0&&(p+=e.length);p%=e.length;
  447. n<0&&(n+=f.length);n%=f.length;h=p-1>=0?p-1:e.length-1;m=n-1>=0?n-1:f.length-1;B=[f[n],e[p],e[h]];B=THREE.FontUtils.Triangulate.area(B);A=[f[n],f[m],e[p]];A=THREE.FontUtils.Triangulate.area(A);u+v>B+A&&(p=w,n=o,p<0&&(p+=e.length),p%=e.length,n<0&&(n+=f.length),n%=f.length,h=p-1>=0?p-1:e.length-1,m=n-1>=0?n-1:f.length-1);u=e.slice(0,p);v=e.slice(p);w=f.slice(n);o=f.slice(0,n);m=[f[n],f[m],e[p]];x.push([f[n],e[p],e[h]]);x.push(m);e=u.concat(w).concat(o).concat(v)}return{shape:e,isolatedPts:x,allpoints:g}},
  448. triangulateShape:function(b,c){for(var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,g=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),h=0;h<e.length;h++)for(var k=e[h],m=0;m<3;m++)for(var n=0;n<f.length;n++)f[n].equals(k[m])&&(k[m]=n);for(h=0;h<g.length;h++){k=g[h];for(m=0;m<3;m++)for(n=0;n<f.length;n++)f[n].equals(k[m])&&(k[m]=n)}return e.concat(g)},isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<0}};
  449. THREE.CubeGeometry=function(b,c,e,f,g,h,k,m,n){function p(b,e,c,k,m,n,p,u){var v,w,x=f||1,B=g||1,D=m/2,da=n/2,j=o.vertices.length;if(b=="x"&&e=="y"||b=="y"&&e=="x")v="z";else if(b=="x"&&e=="z"||b=="z"&&e=="x")v="y",B=h||1;else if(b=="z"&&e=="y"||b=="y"&&e=="z")v="x",x=h||1;var ca=x+1,V=B+1;m/=x;var W=n/B;for(w=0;w<V;w++)for(n=0;n<ca;n++){var L=new THREE.Vector3;L[b]=(n*m-D)*c;L[e]=(w*W-da)*k;L[v]=p;o.vertices.push(new THREE.Vertex(L))}for(w=0;w<B;w++)for(n=0;n<x;n++)o.faces.push(new THREE.Face4(n+
  450. ca*w+j,n+ca*(w+1)+j,n+1+ca*(w+1)+j,n+1+ca*w+j,null,null,u)),o.faceVertexUvs[0].push([new THREE.UV(n/x,w/B),new THREE.UV(n/x,(w+1)/B),new THREE.UV((n+1)/x,(w+1)/B),new THREE.UV((n+1)/x,w/B)])}THREE.Geometry.call(this);var o=this,u=b/2,v=c/2,w=e/2,m=m?-1:1;if(k!==void 0)if(k instanceof Array)this.materials=k;else{this.materials=[];for(var x=0;x<6;x++)this.materials.push([k])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=void 0)for(var B in n)this.sides[B]!=void 0&&(this.sides[B]=
  451. n[B]);this.sides.px&&p("z","y",1*m,-1,e,c,-u,this.materials[0]);this.sides.nx&&p("z","y",-1*m,-1,e,c,u,this.materials[1]);this.sides.py&&p("x","z",1*m,1,b,e,v,this.materials[2]);this.sides.ny&&p("x","z",1*m,-1,b,e,-v,this.materials[3]);this.sides.pz&&p("x","y",1*m,-1,b,c,w,this.materials[4]);this.sides.nz&&p("x","y",-1*m,-1,b,c,-w,this.materials[5]);(function(){for(var b=[],e=[],c=0,f=o.vertices.length;c<f;c++){for(var h=o.vertices[c],g=!1,k=0,m=b.length;k<m;k++){var n=b[k];if(h.position.x==n.position.x&&
  452. h.position.y==n.position.y&&h.position.z==n.position.z){e[c]=k;g=!0;break}}if(!g)e[c]=b.length,b.push(new THREE.Vertex(h.position.clone()))}c=0;for(f=o.faces.length;c<f;c++)h=o.faces[c],h.a=e[h.a],h.b=e[h.b],h.c=e[h.c],h.d=e[h.d];o.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
  453. THREE.CylinderGeometry=function(b,c,e,f,g,h){function k(b,e,c){m.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,c)))}THREE.Geometry.call(this);var m=this,n,p=Math.PI*2,o=f/2;for(n=0;n<b;n++)k(Math.sin(p*n/b)*c,Math.cos(p*n/b)*c,-o);for(n=0;n<b;n++)k(Math.sin(p*n/b)*e,Math.cos(p*n/b)*e,o);for(n=0;n<b;n++)m.faces.push(new THREE.Face4(n,n+b,b+(n+1)%b,(n+1)%b));if(e>0){k(0,0,-o-(h||0));for(n=b;n<b+b/2;n++)m.faces.push(new THREE.Face4(2*b,(2*n-2*b)%b,(2*n-2*b+1)%b,(2*n-2*b+2)%b))}if(c>0){k(0,0,o+
  454. (g||0));for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n<b;n++){var c=[],e=this.faces[n],g=this.vertices[e.a],h=this.vertices[e.b],o=this.vertices[e.c],u=this.vertices[e.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/p,0.5+g.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/p,0.5+h.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/p,0.5+o.position.z/
  455. f));e instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(u.position.x,u.position.y)/p,0.5+u.position.z/f));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
  456. THREE.ExtrudeGeometry=function(b,c){function e(b,e,c,f){vectorFromCentroid=b.clone().subSelf(e);adj=c/vectorFromCentroid.length();f?adj+=1:adj=1-adj;return vectorFromCentroid.multiplyScalar(adj).addSelf(e)}function f(b){for(F=b.length;--F>=0;){j=F;ca=F-1;ca<0&&(ca=b.length-1);for(var e=0;e<u+o*2;e++){var c=D*e,f=D*(e+1);K.faces.push(new THREE.Face4(V+j+c,V+ca+c,V+ca+f,V+j+f))}}}function g(b,e,c){K.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,c)))}function h(b,e,c){K.faces.push(new THREE.Face3(b,
  457. e,c))}var k=c.amount!==void 0?c.amount:100,m=c.bevelThickness!==void 0?c.bevelThickness:8,n=c.bevelSize!==void 0?c.bevelSize:m,p=c.bevelEnabled!==void 0?c.bevelEnabled:!0,o=c.bevelSegments!==void 0?c.bevelSegments:3;p||(o=0);var u=c.steps!==void 0?c.steps:1,v=c.path!==void 0?c.path:null,w,x=!1;if(v)w=v.getPoints(),u=w.length,x=!0;THREE.Geometry.call(this);var B,A,y,K=this,v=b.extractAllPoints(!1),E=v.shape,v=v.holes,J=!THREE.Shape.Utils.isClockWise(E);if(J){E=E.reverse();A=0;for(y=v.length;A<y;A++)B=
  458. v[A],THREE.Shape.Utils.isClockWise(B)&&(v[A]=B.reverse());J=!1}var J=THREE.Shape.Utils.triangulateShape(E,v),I=E;A=0;for(y=v.length;A<y;A++)B=v[A],E=E.concat(B);var G,N=new THREE.Vector2,M,Q,F=0;for(il=I.length;F<il;F++)N.addSelf(I[F]);M=N.divideScalar(I.length);Q=[];A=0;for(y=v.length;A<y;A++){N=new THREE.Vector2;B=v[A];F=0;for(il=B.length;F<il;F++)N.addSelf(B[F]);Q[A]=N.divideScalar(B.length)}var F,U,D=E.length,N=J.length,da;for(G=o;G>0;G--){t=G/o;z=m*t;da=n*(1-Math.sin((1-t)*Math.PI/2));F=0;for(il=
  459. I.length;F<il;F++)U=e(I[F],M,da,!1),g(U.x,U.y,-z);A=0;for(y=v.length;A<y;A++){B=v[A];F=0;for(il=B.length;F<il;F++)U=e(B[F],Q[A],da,!0),g(U.x,U.y,-z)}}for(F=0;F<D;F++)U=E[F],x?g(U.x,U.y+w[0].y,w[0].x):g(U.x,U.y,0);for(B=1;B<=u;B++)for(F=0;F<D;F++)U=E[F],x?g(U.x,U.y+w[B-1].y,w[B-1].x):g(U.x,U.y,k/u*B);for(G=1;G<=o;G++){t=G/o;z=m*t;da=n*(1-Math.sin((1-t)*Math.PI/2));F=0;for(il=I.length;F<il;F++)U=e(I[F],M,da,!1),g(U.x,U.y,k+z);A=0;for(y=v.length;A<y;A++){B=v[A];F=0;for(il=B.length;F<il;F++)U=e(B[F],
  460. Q[A],da,!0),x?g(U.x,U.y+w[u-1].y,w[u-1].x+z):g(U.x,U.y,k+z)}}if(p){m=D*0;for(F=0;F<N;F++)k=J[F],h(k[2]+m,k[1]+m,k[0]+m);m=D*(u+o*2);for(F=0;F<N;F++)k=J[F],h(k[0]+m,k[1]+m,k[2]+m)}else{for(F=0;F<N;F++)k=J[F],h(k[2],k[1],k[0]);for(F=0;F<N;F++)k=J[F],h(k[0]+D*u,k[1]+D*u,k[2]+D*u)}var j,ca,V=0;f(I);V+=I.length;A=0;for(y=v.length;A<y;A++)B=v[A],f(B),V+=B.length;this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;
  461. THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
  462. THREE.IcosahedronGeometry=function(b){function c(b,e,c){var f=Math.sqrt(b*b+e*e+c*c);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,e/f,c/f)))-1}function e(b,e,c,f){f.faces.push(new THREE.Face3(b,e,c))}function f(b,e){var f=g.vertices[b].position,h=g.vertices[e].position;return c((f.x+h.x)/2,(f.y+h.y)/2,(f.z+h.z)/2)}var g=this,h=new THREE.Geometry,k;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,
  463. -b);c(0,1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,h);e(0,5,1,h);e(0,1,7,h);e(0,7,10,h);e(0,10,11,h);e(1,5,9,h);e(5,11,4,h);e(11,10,2,h);e(10,7,6,h);e(7,1,8,h);e(3,9,4,h);e(3,4,2,h);e(3,2,6,h);e(3,6,8,h);e(3,8,9,h);e(4,9,5,h);e(2,4,11,h);e(6,2,10,h);e(8,6,7,h);e(9,8,1,h);for(b=0;b<this.subdivisions;b++){k=new THREE.Geometry;for(var m in h.faces){var n=f(h.faces[m].a,h.faces[m].b),p=f(h.faces[m].b,h.faces[m].c),o=f(h.faces[m].c,h.faces[m].a);e(h.faces[m].a,n,o,k);e(h.faces[m].b,p,n,k);
  464. e(h.faces[m].c,o,p,k);e(n,p,o,k)}h.faces=k.faces}g.faces=h.faces;delete h;delete k;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
  465. THREE.LatheGeometry=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],g=[],h=[],k=(new THREE.Matrix4).setRotationZ(c),m=0;m<b.length;m++)this.vertices.push(new THREE.Vertex(b[m])),e[m]=b[m].clone(),f[m]=this.vertices.length-1;for(var n=0;n<=this.angle+0.0010;n+=c){for(m=0;m<e.length;m++)n<this.angle?(e[m]=k.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),g[m]=this.vertices.length-1):g=h;n==0&&(h=f);
  466. for(m=0;m<f.length-1;m++)this.faces.push(new THREE.Face4(g[m],g[m+1],f[m+1],f[m])),this.faceVertexUvs[0].push([new THREE.UV(1-n/this.angle,m/b.length),new THREE.UV(1-n/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,m/b.length)]);f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
  467. THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var g,h=b/2,k=c/2,e=e||1,f=f||1,m=e+1,n=f+1;b/=e;var p=c/f;for(g=0;g<n;g++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-h,-(g*p-k),0)));for(g=0;g<f;g++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*g,c+m*(g+1),c+1+m*(g+1),c+1+m*g)),this.faceVertexUvs[0].push([new THREE.UV(c/e,g/f),new THREE.UV(c/e,(g+1)/f),new THREE.UV((c+1)/e,(g+1)/f),new THREE.UV((c+1)/e,g/f)]);this.computeCentroids();this.computeFaceNormals()};
  468. THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
  469. THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,g=Math.PI,h=Math.max(3,c||8),k=Math.max(2,e||6),c=[],e=0;e<k+1;e++){f=e/k;var m=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<h;f++){var u=2*f/h,v=n*Math.sin(u*g),u=n*Math.cos(u*g);(e==0||e==k)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,m,v)))-1);p.push(o)}c.push(p)}for(var w,x,B,g=c.length,e=0;e<g;e++)if(h=c[e].length,e>0)for(f=0;f<h;f++){p=f==h-1;k=c[e][p?0:f+1];m=c[e][p?h-1:f];n=c[e-1][p?
  470. h-1:f];p=c[e-1][p?0:f+1];v=e/(g-1);w=(e-1)/(g-1);x=(f+1)/h;var u=f/h,o=new THREE.UV(1-x,v),v=new THREE.UV(1-u,v),u=new THREE.UV(1-u,w),A=new THREE.UV(1-x,w);e<c.length-1&&(w=this.vertices[k].position.clone(),x=this.vertices[m].position.clone(),B=this.vertices[n].position.clone(),w.normalize(),x.normalize(),B.normalize(),this.faces.push(new THREE.Face3(k,m,n,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)])),this.faceVertexUvs[0].push([o,v,u]));e>1&&(w=
  471. this.vertices[k].position.clone(),x=this.vertices[n].position.clone(),B=this.vertices[p].position.clone(),w.normalize(),x.normalize(),B.normalize(),this.faces.push(new THREE.Face3(k,n,p,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)])),this.faceVertexUvs[0].push([o,u,A]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
  472. THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(b,c){THREE.Geometry.call(this);this.parameters=c||{};this.set(b)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
  473. THREE.TextGeometry.prototype.set=function(b,c){function e(b,e,c){x.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,c)))}function f(b,e,c,f){x.faces.push(new THREE.Face4(b,e,c,f))}this.text=b;var c=c||this.parameters,g=c.height!==void 0?c.height:50,h=c.curveSegments!==void 0?c.curveSegments:4,k=c.font!==void 0?c.font:"helvetiker",m=c.weight!==void 0?c.weight:"normal",n=c.style!==void 0?c.style:"normal",p=c.bezelThickness!==void 0?c.bezelThickness:10,o=c.bezelSize!==void 0?c.bezelSize:8,u=c.bezelEnabled!==
  474. void 0?c.bezelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=k;THREE.FontUtils.weight=m;THREE.FontUtils.style=n;THREE.FontUtils.bezelSize=o;var m=THREE.FontUtils.drawText(b),h=m.points,v=m.faces,k=m.contour,w=m.bezel,x=this;x.vertices=[];x.faces=[];for(var B,n=h.length,A=v.length,o=w.length,m=0;m<n;m++)B=h[m],e(B.x,B.y,0);for(m=0;m<n;m++)B=h[m],e(B.x,B.y,g);if(u){for(m=0;m<o;m++)B=w[m],e(B.x,B.y,p);for(m=0;m<o;m++)B=w[m],e(B.x,B.y,g-p)}for(m=
  475. 0;m<A;m++)g=v[m],x.faces.push(new THREE.Face3(g[2],g[1],g[0]));for(m=0;m<A;m++)g=v[m],x.faces.push(new THREE.Face3(g[0]+n,g[1]+n,g[2]+n));var y;if(u)for(m=w.length;--m>0;){if(y){if(y.equals(k[m])){y=null;continue}}else y=k[m];p=n*2+m;v=p-1;f(p,v,v+o,p+o);for(u=0;u<n;u++)if(h[u].equals(k[m]))break;for(g=0;g<n;g++)if(h[g].equals(k[m-1]))break;f(u,g,v,p);f(p+o,v+o,g+n,u+n)}else for(m=k.length;--m>0;){if(y){if(y.equals(k[m])){y=null;continue}}else y=k[m];for(u=0;u<n;u++)if(h[u].equals(k[m]))break;for(g=
  476. 0;g<n;g++)if(h[g].equals(k[m-1]))break;f(u,g,g+n,u+n)}this.computeCentroids();this.computeFaceNormals()};
  477. THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},extractPoints:function(b,c){if(b.length<3)return console.log("not valid polygon"),
  478. {points:b,faces:[]};for(var e,f,g,h,k,m=[],n=0;n<c.length;n++){k=c[n];h=[];for(e=0;e<k.length;e++)f=k[e],h.push(f.x+","+f.y);var p;e=h.slice(1).indexOf(h[0]);var o=this.Triangulate.area(k.slice(0,e+1))<0;f=[];for(e=-1;e<h.length;){p=e+1;e=h[p];e=h.slice(p+1).indexOf(e)+p;if(e<=p)break;var u=k.slice(p,e+1);o?this.Triangulate.area(u)<0?(p>0&&m.push({shape:g,holes:f}),g=u,f=[]):f.push(u):this.Triangulate.area(u)<0?(m.push({shape:u,holes:f}),f=[]):f.push(u);e++}o&&m.push({shape:g,holes:f})}var v,w,x,
  479. B,A,y;h=[];for(k=0;k<m.length;k++){n=m[k];g=n.shape;f=n.holes;for(p=0;p<f.length;p++){o=f[p];x=Number.POSITIVE_INFINITY;for(u=0;u<o.length;u++){A=o[u];for(e=0;e<g.length;e++)B=g[e],B=A.distanceTo(B),B<x&&(x=B,v=u,w=e)}e=w-1>=0?w-1:g.length-1;var u=v-1>=0?v-1:o.length-1,K=[];K.push(o[v]);K.push(g[w]);K.push(g[e]);x=this.Triangulate.area(K);var E=[];E.push(o[v]);E.push(o[u]);E.push(g[w]);A=this.Triangulate.area(E);B=w;y=v;w+=1;v+=-1;w<0&&(w+=g.length);w%=g.length;v<0&&(v+=o.length);v%=g.length;e=w-
  480. 1>=0?w-1:g.length-1;u=v-1>=0?v-1:o.length-1;K=[];K.push(o[v]);K.push(g[w]);K.push(g[e]);K=this.Triangulate.area(K);E=[];E.push(o[v]);E.push(o[u]);E.push(g[w]);E=this.Triangulate.area(E);x+A>K+E&&(w=B,v=y,w<0&&(w+=g.length),w%=g.length,v<0&&(v+=o.length),v%=g.length,e=w-1>=0?w-1:g.length-1,u=v-1>=0?v-1:o.length-1);x=g.slice(0,w);A=g.slice(w);B=o.slice(v);y=o.slice(0,v);h.push(o[v]);h.push(g[w]);h.push(g[e]);h.push(o[v]);h.push(o[u]);h.push(g[w]);g=x.concat(B).concat(y).concat(A)}n.shape=g}v=[];w=[];
  481. for(k=p=0;k<m.length;k++){n=m[k];g=n.shape;v=v.concat(g);o=THREE.FontUtils.Triangulate(g,!0);for(f=0;f<o.length;f++)n=o[f],n[0]+=p,n[1]+=p,n[2]+=p;w=w.concat(o);p+=g.length}var J;for(f=0;f<h.length/3;f++){n=[];for(m=0;m<3;m++){k=!1;for(g=0;g<v.length&&!k;g++)J=f*3+m,v[g].equals(h[J])&&(n.push(g),k=!0);k||(v.push(h[J]),n.push(v.length-1),console.log("not found"))}w.push(n)}return{points:v,faces:w}},drawText:function(b){var c=[],e=[],f,g=this.getFace(),h=this.size/g.resolution,k=0;f=String(b).split("");
  482. for(var m=f.length,n=new THREE.Path,b=0;b<m;b++){var p=this.extractGlyphPoints(f[b],g,h,k,n);k+=p.offset;c.push(p.points);e=e.concat(p.points)}console.log(n);b=k/2;for(f=0;f<e.length;f++)e[f].x-=b;c=this.extractPoints(e,c);c.contour=e;g=[];h=[];f=[];for(var k=[],m=new THREE.Vector2,o,b=e.length;--b>=0;){if(o){if(o.equals(e[b])){o=null;n=this.Triangulate.area(f)>0;k.push(n);h.push(m.divideScalar(f.length));f=[];m=new THREE.Vector2;continue}}else o=e[b];m.addSelf(e[b]);f.push(e[b])}b=e.length;for(f=
  483. 0;--b>=0;)n=e[b],m=h[f],n=n.clone().subSelf(m),p=this.bezelSize/n.length(),k[f]?p+=1:p=1-p,p=n.multiplyScalar(p).addSelf(m),g.unshift(p),o?o.equals(e[b])&&(o=null,f++):o=e[b];c.bezel=g;return c},b2p0:function(b,c){var e=1-b;return e*e*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,e,f){return this.b2p0(b,c)+this.b2p1(b,e)+this.b2p2(b,f)},b3p0:function(b,c){var e=1-b;return e*e*e*c},b3p1:function(b,c){var e=1-b;return 3*e*e*b*c},b3p2:function(b,c){return 3*
  484. (1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,g){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,g)},extractGlyphPoints:function(b,c,e,f,g){var h=[],k,m,n,p,o,u,v,w,x,B,A=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(A){if(A.o){c=A._cachedOutline||(A._cachedOutline=A.o.split(" "));n=c.length;for(b=0;b<n;)switch(m=c[b++],m){case "m":m=c[b++]*e+f;p=c[b++]*e;h.push(new THREE.Vector2(m,p));g.moveTo(m,p);break;case "l":m=c[b++]*e+f;p=c[b++]*e;h.push(new THREE.Vector2(m,
  485. p));g.lineTo(m,p);break;case "q":m=c[b++]*e+f;p=c[b++]*e;v=c[b++]*e+f;w=c[b++]*e;g.quadraticCurveTo(v,w,m,p);if(k=h[h.length-1]){o=k.x;u=k.y;k=1;for(divisions=this.divisions;k<=divisions;k++){var y=k/divisions,K=THREE.FontUtils.b2(y,o,v,m),y=THREE.FontUtils.b2(y,u,w,p);h.push(new THREE.Vector2(K,y))}}break;case "b":if(m=c[b++]*e+f,p=c[b++]*e,v=c[b++]*e+f,w=c[b++]*-e,x=c[b++]*e+f,B=c[b++]*-e,g.bezierCurveTo(m,p,v,w,x,B),k=h[h.length-1]){o=k.x;u=k.y;k=1;for(divisions=this.divisions;k<=divisions;k++)y=
  486. k/divisions,K=THREE.FontUtils.b3(y,o,v,x,m),y=THREE.FontUtils.b3(y,u,w,B,p),h.push(new THREE.Vector2(K,y))}}}return{offset:A.ha*e,points:h,path:g}}}};
  487. (function(b){var c=function(b){for(var c=b.length,g=0,h=c-1,k=0;k<c;h=k++)g+=b[h].x*b[k].y-b[k].x*b[h].y;return g*0.5};b.Triangulate=function(b,f){var g=b.length;if(g<3)return null;var h=[],k=[],m=[],n,p,o;if(c(b)>0)for(p=0;p<g;p++)k[p]=p;else for(p=0;p<g;p++)k[p]=g-1-p;var u=2*g;for(p=g-1;g>2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return h}n=p;g<=n&&(n=0);p=n+1;g<=p&&(p=0);o=p+1;g<=o&&(o=0);var v;a:{v=b;var w=n,x=p,B=o,A=g,y=k,K=void 0,E=void 0,J=void 0,
  488. I=void 0,G=void 0,N=void 0,M=void 0,Q=void 0,F=void 0,E=v[y[w]].x,J=v[y[w]].y,I=v[y[x]].x,G=v[y[x]].y,N=v[y[B]].x,M=v[y[B]].y;if(1.0E-10>(I-E)*(M-J)-(G-J)*(N-E))v=!1;else{for(K=0;K<A;K++)if(!(K==w||K==x||K==B)){var Q=v[y[K]].x,F=v[y[K]].y,U=void 0,D=void 0,da=void 0,j=void 0,ca=void 0,V=void 0,W=void 0,L=void 0,fa=void 0,aa=void 0,X=void 0,ea=void 0,U=da=ca=void 0,U=N-I,D=M-G,da=E-N,j=J-M,ca=I-E,V=G-J,W=Q-E,L=F-J,fa=Q-I,aa=F-G,X=Q-N,ea=F-M,U=U*aa-D*fa,ca=ca*L-V*W,da=da*ea-j*X;if(U>=0&&da>=0&&ca>=
  489. 0){v=!1;break a}}v=!0}}if(v){h.push([b[k[n]],b[k[p]],b[k[o]]]);m.push([k[n],k[p],k[o]]);n=p;for(o=p+1;o<g;n++,o++)k[n]=k[o];g--;u=2*g}}if(f)return m;return h};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
  490. THREE.TorusGeometry=function(b,c,e,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;b=[];for(c=0;c<=this.segmentsR;++c)for(e=0;e<=this.segmentsT;++e){var f=e/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(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([e/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(e=
  491. 1;e<=this.segmentsT;++e){var f=(this.segmentsT+1)*c+e,g=(this.segmentsT+1)*c+e-1,h=(this.segmentsT+1)*(c-1)+e-1,k=(this.segmentsT+1)*(c-1)+e;this.faces.push(new THREE.Face4(f,g,h,k));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[k][0],b[k][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
  492. THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
  493. THREE.TorusKnotGeometry=function(b,c,e,f,g,h,k){function m(b,e,c,f,h,g){e=c/f*b;c=Math.cos(e);return new THREE.Vector3(h*(2+c)*0.5*Math.cos(b),h*(2+c)*Math.sin(b)*0.5,g*h*Math.sin(e)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=k||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
  494. this.segmentsT;++c){var n=b/this.segmentsR*2*this.p*Math.PI,k=c/this.segmentsT*2*Math.PI,g=m(n,k,this.q,this.p,this.radius,this.heightScale),n=m(n+0.01,k,this.q,this.p,this.radius,this.heightScale);e.x=n.x-g.x;e.y=n.y-g.y;e.z=n.z-g.z;f.x=n.x+g.x;f.y=n.y+g.y;f.z=n.z+g.z;h.cross(e,f);f.cross(h,e);h.normalize();f.normalize();n=-this.tube*Math.cos(k);k=this.tube*Math.sin(k);g.x+=n*f.x+k*h.x;g.y+=n*f.y+k*h.y;g.z+=n*f.z+k*h.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,
  495. g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,h=(c+1)%this.segmentsT,g=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][h],h=this.grid[b][h],k=new THREE.UV(b/this.segmentsR,c/this.segmentsT),n=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),p=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,e,f,h));this.faceVertexUvs[0].push([k,n,p,o])}this.computeCentroids();
  496. this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
  497. 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";
  498. this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,c,e){b.materials=[];for(var f=0;f<c.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(c[f],e)]},hasNormals:function(b){var c,e,f=b.materials.length;for(e=0;e<f;e++)if(c=b.materials[e][0],c instanceof THREE.MeshShaderMaterial)return!0;return!1},createMaterial:function(b,c){function e(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function f(b,c){var f=
  499. new Image;f.onload=function(){if(!e(this.width)||!e(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=c;b.image.height=f;b.image.getContext("2d").drawImage(this,0,0,c,f)}else b.image=this;b.needsUpdate=!0};f.src=c}function g(b,e,h,g,k,m){var n=document.createElement("canvas");b[e]=new THREE.Texture(n);b[e].sourceFile=h;if(g){b[e].repeat.set(g[0],g[1]);if(g[0]!=1)b[e].wrapS=THREE.RepeatWrapping;if(g[1]!=
  500. 1)b[e].wrapT=THREE.RepeatWrapping}k&&b[e].offset.set(k[0],k[1]);if(m){g={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(g[m[0]]!==void 0)b[e].wrapS=g[m[0]];if(g[m[1]]!==void 0)b[e].wrapT=g[m[1]]}f(b[e],c+"/"+h)}function h(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var k,m,n;m="MeshLambertMaterial";k={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?m="MeshPhongMaterial":b.shading=="Basic"&&(m="MeshBasicMaterial"));
  501. if(b.blending)if(b.blending=="Additive")k.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")k.blending=THREE.SubtractiveBlending;else if(b.blending=="Multiply")k.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)k.transparent=b.transparent;if(b.depthTest!==void 0)k.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")k.vertexColors=THREE.FaceColors;else if(b.vertexColors)k.vertexColors=THREE.VertexColors;if(b.colorDiffuse)k.color=h(b.colorDiffuse);
  502. else if(b.DbgColor)k.color=b.DbgColor;if(b.colorSpecular)k.specular=h(b.colorSpecular);if(b.colorAmbient)k.ambient=h(b.colorAmbient);if(b.transparency)k.opacity=b.transparency;if(b.specularCoef)k.shininess=b.specularCoef;b.mapDiffuse&&c&&g(k,"map",b.mapDiffuse,b.mapDiffuseRepeat,b.mapDiffuseOffset,b.mapDiffuseWrap);b.mapLight&&c&&g(k,"lightMap",b.mapLight,b.mapLightRepeat,b.mapLightOffset,b.mapLightWrap);b.mapNormal&&c&&g(k,"normalMap",b.mapNormal,b.mapNormalRepeat,b.mapNormalOffset,b.mapNormalWrap);
  503. b.mapSpecular&&c&&g(k,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var p=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(p.uniforms),u=k.color;m=k.specular;n=k.ambient;var v=k.shininess;o.tNormal.texture=k.normalMap;if(b.mapNormalFactor)o.uNormalScale.value=b.mapNormalFactor;if(k.map)o.tDiffuse.texture=k.map,o.enableDiffuse.value=!0;if(k.specularMap)o.tSpecular.texture=k.specularMap,o.enableSpecular.value=!0;if(k.lightMap)o.tAO.texture=
  504. k.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(u);o.uSpecularColor.value.setHex(m);o.uAmbientColor.value.setHex(n);o.uShininess.value=v;if(k.opacity)o.uOpacity.value=k.opacity;k=new THREE.MeshShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:o,lights:!0,fog:!0})}else k=new THREE[m](k);return k}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
  505. THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(b){var c=this,e=b.model,f=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,g);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
  506. THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,g=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(e){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var c,g,n,p,o,u,v,w,x,B,A,y,K,E,J=b.faces;u=b.vertices;var I=b.normals,G=b.colors,N=0;for(c=0;c<b.uvs.length;c++)b.uvs[c].length&&N++;for(c=0;c<N;c++)f.faceUvs[c]=[],f.faceVertexUvs[c]=[];p=0;for(o=u.length;p<o;)v=new THREE.Vertex,v.position.x=u[p++]*e,v.position.y=
  507. u[p++]*e,v.position.z=u[p++]*e,f.vertices.push(v);p=0;for(o=J.length;p<o;){e=J[p++];u=e&1;n=e&2;c=e&4;g=e&8;w=e&16;v=e&32;B=e&64;e&=128;u?(A=new THREE.Face4,A.a=J[p++],A.b=J[p++],A.c=J[p++],A.d=J[p++],u=4):(A=new THREE.Face3,A.a=J[p++],A.b=J[p++],A.c=J[p++],u=3);if(n)n=J[p++],A.materials=f.materials[n];n=f.faces.length;if(c)for(c=0;c<N;c++)y=b.uvs[c],x=J[p++],E=y[x*2],x=y[x*2+1],f.faceUvs[c][n]=new THREE.UV(E,x);if(g)for(c=0;c<N;c++){y=b.uvs[c];K=[];for(g=0;g<u;g++)x=J[p++],E=y[x*2],x=y[x*2+1],K[g]=
  508. new THREE.UV(E,x);f.faceVertexUvs[c][n]=K}if(w)w=J[p++]*3,g=new THREE.Vector3,g.x=I[w++],g.y=I[w++],g.z=I[w],A.normal=g;if(v)for(c=0;c<u;c++)w=J[p++]*3,g=new THREE.Vector3,g.x=I[w++],g.y=I[w++],g.z=I[w],A.vertexNormals.push(g);if(B)v=J[p++],v=new THREE.Color(G[v]),A.color=v;if(e)for(c=0;c<u;c++)v=J[p++],v=new THREE.Color(G[v]),A.vertexColors.push(v);f.faces.push(A)}}})(g);(function(){var e,c,g,n;if(b.skinWeights){e=0;for(c=b.skinWeights.length;e<c;e+=2)g=b.skinWeights[e],n=b.skinWeights[e+1],f.skinWeights.push(new THREE.Vector4(g,
  509. n,0,0))}if(b.skinIndices){e=0;for(c=b.skinIndices.length;e<c;e+=2)g=b.skinIndices[e],n=b.skinIndices[e+1],f.skinIndices.push(new THREE.Vector4(g,n,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(e){if(b.morphTargets!==void 0){var c,g,n,p,o,u,v,w,x;c=0;for(g=b.morphTargets.length;c<g;c++){f.morphTargets[c]={};f.morphTargets[c].name=b.morphTargets[c].name;f.morphTargets[c].vertices=[];w=f.morphTargets[c].vertices;x=b.morphTargets[c].vertices;n=0;for(p=x.length;n<p;n+=3)o=x[n]*e,u=x[n+1]*
  510. e,v=x[n+2]*e,w.push(new THREE.Vertex(new THREE.Vector3(o,u,v)))}}if(b.morphColors!==void 0){c=0;for(g=b.morphColors.length;c<g;c++){f.morphColors[c]={};f.morphColors[c].name=b.morphColors[c].name;f.morphColors[c].colors=[];p=f.morphColors[c].colors;o=b.morphColors[c].colors;e=0;for(n=o.length;e<n;e+=3)u=new THREE.Color(16755200),u.setRGB(o[e],o[e+1],o[e+2]),p.push(u)}}})(g);(function(){if(b.edges!==void 0){var e,c,g;for(e=0;e<b.edges.length;e+=2)c=b.edges[e],g=b.edges[e+1],f.edges.push(new THREE.Edge(f.vertices[c],
  511. f.vertices[g],c,g))}})();f.computeCentroids();f.computeFaceNormals();this.hasNormals(f)&&f.computeTangents();c(f)};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;
  512. THREE.BinaryLoader.prototype={load:function(b){var c=b.model,e=b.callback,f=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,e,g,f,h)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
  513. c.postMessage(b)},loadAjaxBuffers:function(b,c,e,f,g,h){var k=new XMLHttpRequest,m=f+"/"+b,n=0;k.onreadystatechange=function(){k.readyState==4?k.status==200||k.status==0?THREE.BinaryLoader.prototype.createBinModel(k.responseText,e,g,c):alert("Couldn't load ["+m+"] ["+k.status+"]"):k.readyState==3?h&&(n==0&&(n=k.getResponseHeader("Content-Length")),h({total:n,loaded:k.responseText.length})):k.readyState==2&&(n=k.getResponseHeader("Content-Length"))};k.open("GET",m,!0);k.overrideMimeType("text/plain; charset=x-user-defined");
  514. k.setRequestHeader("Content-Type","text/plain");k.send(null)},createBinModel:function(b,c,e,f){var g=function(e){function c(b,e){var f=o(b,e),g=o(b,e+1),h=o(b,e+2),j=o(b,e+3),k=(j<<1&255|h>>7)-127;f|=(h&127)<<16|g<<8;if(f==0&&k==-127)return 0;return(1-2*(j>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,k)}function g(b,e){var c=o(b,e),f=o(b,e+1),h=o(b,e+2);return(o(b,e+3)<<24)+(h<<16)+(f<<8)+c}function n(b,e){var c=o(b,e);return(o(b,e+1)<<8)+c}function p(b,e){var c=o(b,e);return c>127?c-256:c}function o(b,
  515. e){return b.charCodeAt(e)&255}function u(e){var c,f,h;c=g(b,e);f=g(b,e+G);h=g(b,e+N);e=n(b,e+M);THREE.BinaryLoader.prototype.f3(y,c,f,h,e)}function v(e){var c,f,h,j,k,o;c=g(b,e);f=g(b,e+G);h=g(b,e+N);j=n(b,e+M);k=g(b,e+Q);o=g(b,e+F);e=g(b,e+U);THREE.BinaryLoader.prototype.f3n(y,J,c,f,h,j,k,o,e)}function w(e){var c,f,h,k;c=g(b,e);f=g(b,e+D);h=g(b,e+da);k=g(b,e+j);e=n(b,e+ca);THREE.BinaryLoader.prototype.f4(y,c,f,h,k,e)}function x(e){var c,f,h,k,o,p,u,v;c=g(b,e);f=g(b,e+D);h=g(b,e+da);k=g(b,e+j);o=
  516. n(b,e+ca);p=g(b,e+V);u=g(b,e+W);v=g(b,e+L);e=g(b,e+fa);THREE.BinaryLoader.prototype.f4n(y,J,c,f,h,k,o,p,u,v,e)}function B(e){var c,f;c=g(b,e);f=g(b,e+aa);e=g(b,e+X);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],I[c*2],I[c*2+1],I[f*2],I[f*2+1],I[e*2],I[e*2+1])}function A(e){var c,f,h;c=g(b,e);f=g(b,e+ea);h=g(b,e+ia);e=g(b,e+oa);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],I[c*2],I[c*2+1],I[f*2],I[f*2+1],I[h*2],I[h*2+1],I[e*2],I[e*2+1])}var y=this,K=0,E,J=[],I=[],G,N,M,Q,F,U,D,da,j,ca,
  517. V,W,L,fa,aa,X,ea,ia,oa,ja,R,ga,Z,Y,la;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,f,e);E={signature:b.substr(K,8),header_bytes:o(b,K+8),vertex_coordinate_bytes:o(b,K+9),normal_coordinate_bytes:o(b,K+10),uv_coordinate_bytes:o(b,K+11),vertex_index_bytes:o(b,K+12),normal_index_bytes:o(b,K+13),uv_index_bytes:o(b,K+14),material_index_bytes:o(b,K+15),nvertices:g(b,K+16),nnormals:g(b,K+16+4),nuvs:g(b,K+16+8),ntri_flat:g(b,K+16+12),ntri_smooth:g(b,K+16+16),ntri_flat_uv:g(b,K+16+20),
  518. ntri_smooth_uv:g(b,K+16+24),nquad_flat:g(b,K+16+28),nquad_smooth:g(b,K+16+32),nquad_flat_uv:g(b,K+16+36),nquad_smooth_uv:g(b,K+16+40)};K+=E.header_bytes;G=E.vertex_index_bytes;N=E.vertex_index_bytes*2;M=E.vertex_index_bytes*3;Q=E.vertex_index_bytes*3+E.material_index_bytes;F=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes;U=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes*2;D=E.vertex_index_bytes;da=E.vertex_index_bytes*2;j=E.vertex_index_bytes*3;ca=E.vertex_index_bytes*
  519. 4;V=E.vertex_index_bytes*4+E.material_index_bytes;W=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes;L=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*2;fa=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*3;aa=E.uv_index_bytes;X=E.uv_index_bytes*2;ea=E.uv_index_bytes;ia=E.uv_index_bytes*2;oa=E.uv_index_bytes*3;e=E.vertex_index_bytes*3+E.material_index_bytes;la=E.vertex_index_bytes*4+E.material_index_bytes;ja=E.ntri_flat*e;R=E.ntri_smooth*(e+E.normal_index_bytes*
  520. 3);ga=E.ntri_flat_uv*(e+E.uv_index_bytes*3);Z=E.ntri_smooth_uv*(e+E.normal_index_bytes*3+E.uv_index_bytes*3);Y=E.nquad_flat*la;e=E.nquad_smooth*(la+E.normal_index_bytes*4);la=E.nquad_flat_uv*(la+E.uv_index_bytes*4);K+=function(e){for(var f,g,h,j=E.vertex_coordinate_bytes*3,m=e+E.nvertices*j;e<m;e+=j)f=c(b,e),g=c(b,e+E.vertex_coordinate_bytes),h=c(b,e+E.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(y,f,g,h);return E.nvertices*j}(K);K+=function(e){for(var c,f,g,h=E.normal_coordinate_bytes*
  521. 3,j=e+E.nnormals*h;e<j;e+=h)c=p(b,e),f=p(b,e+E.normal_coordinate_bytes),g=p(b,e+E.normal_coordinate_bytes*2),J.push(c/127,f/127,g/127);return E.nnormals*h}(K);K+=function(e){for(var f,g,h=E.uv_coordinate_bytes*2,j=e+E.nuvs*h;e<j;e+=h)f=c(b,e),g=c(b,e+E.uv_coordinate_bytes),I.push(f,g);return E.nuvs*h}(K);ja=K+ja;R=ja+R;ga=R+ga;Z=ga+Z;Y=Z+Y;e=Y+e;la=e+la;(function(b){var e,c=E.vertex_index_bytes*3+E.material_index_bytes,f=c+E.uv_index_bytes*3,g=b+E.ntri_flat_uv*f;for(e=b;e<g;e+=f)u(e),B(e+c);return g-
  522. b})(R);(function(b){var e,c=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes*3,f=c+E.uv_index_bytes*3,g=b+E.ntri_smooth_uv*f;for(e=b;e<g;e+=f)v(e),B(e+c);return g-b})(ga);(function(b){var e,c=E.vertex_index_bytes*4+E.material_index_bytes,f=c+E.uv_index_bytes*4,g=b+E.nquad_flat_uv*f;for(e=b;e<g;e+=f)w(e),A(e+c);return g-b})(e);(function(b){var e,c=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*4,f=c+E.uv_index_bytes*4,g=b+E.nquad_smooth_uv*f;for(e=b;e<g;e+=f)x(e),
  523. A(e+c);return g-b})(la);(function(b){var e,c=E.vertex_index_bytes*3+E.material_index_bytes,f=b+E.ntri_flat*c;for(e=b;e<f;e+=c)u(e);return f-b})(K);(function(b){var e,c=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes*3,f=b+E.ntri_smooth*c;for(e=b;e<f;e+=c)v(e);return f-b})(ja);(function(b){var e,c=E.vertex_index_bytes*4+E.material_index_bytes,f=b+E.nquad_flat*c;for(e=b;e<f;e+=c)w(e);return f-b})(Z);(function(b){var e,c=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*
  524. 4,f=b+E.nquad_smooth*c;for(e=b;e<f;e+=c)x(e);return f-b})(Y);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(e))},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3:function(b,c,e,f,g){b.faces.push(new THREE.Face3(c,e,f,null,null,b.materials[g]))},f4:function(b,c,e,f,g,h){b.faces.push(new THREE.Face4(c,e,f,g,null,null,b.materials[h]))},
  525. f3n:function(b,c,e,f,g,h,k,m,n){var h=b.materials[h],p=c[m*3],o=c[m*3+1],m=c[m*3+2],u=c[n*3],v=c[n*3+1],n=c[n*3+2];b.faces.push(new THREE.Face3(e,f,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(p,o,m),new THREE.Vector3(u,v,n)],null,h))},f4n:function(b,c,e,f,g,h,k,m,n,p,o){var k=b.materials[k],u=c[n*3],v=c[n*3+1],n=c[n*3+2],w=c[p*3],x=c[p*3+1],p=c[p*3+2],B=c[o*3],A=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face4(e,f,g,h,[new THREE.Vector3(c[m*3],c[m*3+1],c[m*3+2]),new THREE.Vector3(u,
  526. v,n),new THREE.Vector3(w,x,p),new THREE.Vector3(B,A,o)],null,k))},uv3:function(b,c,e,f,g,h,k){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,g));m.push(new THREE.UV(h,k));b.push(m)},uv4:function(b,c,e,f,g,h,k,m,n){var p=[];p.push(new THREE.UV(c,e));p.push(new THREE.UV(f,g));p.push(new THREE.UV(h,k));p.push(new THREE.UV(m,n));b.push(p)}};
  527. THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
  528. THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,e){return e=="relativeToHTML"?b:g+"/"+b}function m(){for(w in D.objects)if(!L.objects[w])if(K=D.objects[w],K.geometry!==void 0){if(G=L.geometries[K.geometry]){var b=!1;F=[];for(aa=0;aa<K.materials.length;aa++)F[aa]=L.materials[K.materials[aa]],b=F[aa]instanceof THREE.MeshShaderMaterial;b&&G.computeTangents();E=K.position;r=
  529. K.rotation;q=K.quaternion;s=K.scale;q=0;F.length==0&&(F[0]=new THREE.MeshFaceMaterial);F.length>1&&(F=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(G,F);object.name=w;object.position.set(E[0],E[1],E[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=K.visible;L.scene.addObject(object);L.objects[w]=object;K.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),L.scene.collisions.colliders.push(b));
  530. if(K.castsShadow)b=new THREE.ShadowVolume(G),L.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;K.trigger&&K.trigger.toLowerCase()!="none"&&(b={type:K.trigger,object:K},L.triggers[object.name]=b)}}else E=K.position,r=K.rotation,q=K.quaternion,s=K.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(E[0],E[1],E[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],
  531. s[1],s[2]),object.visible=K.visible!==void 0?K.visible:!1,L.scene.addObject(object),L.objects[w]=object,L.empties[w]=object,K.trigger&&K.trigger.toLowerCase()!="none"&&(b={type:K.trigger,object:K},L.triggers[object.name]=b)}function n(b){return function(c){L.geometries[b]=c;m();j-=1;e.onLoadComplete();o()}}function p(b){return function(e){L.geometries[b]=e}}function o(){e.callbackProgress({totalModels:V,totalTextures:W,loadedModels:V-j,loadedTextures:W-ca},L);e.onLoadProgress();j==0&&ca==0&&c(L)}
  532. var u,v,w,x,B,A,y,K,E,J,I,G,N,M,Q,F,U,D,da,j,ca,V,W,L;D=b.data;Q=new THREE.BinaryLoader;da=new THREE.JSONLoader;ca=j=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in D.objects)if(K=D.objects[w],K.meshCollider){b=!0;break}if(b)L.scene.collisions=new THREE.CollisionSystem;if(D.transform){b=D.transform.position;J=D.transform.rotation;var fa=D.transform.scale;b&&L.scene.position.set(b[0],b[1],b[2]);J&&L.scene.rotation.set(J[0],
  533. J[1],J[2]);fa&&L.scene.scale.set(fa[0],fa[1],fa[2]);(b||J||fa)&&L.scene.updateMatrix()}b=function(){ca-=1;o();e.onLoadComplete()};for(B in D.cameras){J=D.cameras[B];if(J.type=="perspective")N=new THREE.Camera(J.fov,J.aspect,J.near,J.far);else if(J.type=="ortho")N=new THREE.Camera,N.projectionMatrix=THREE.Matrix4.makeOrtho(J.left,J.right,J.top,J.bottom,J.near,J.far);E=J.position;J=J.target;N.position.set(E[0],E[1],E[2]);N.target.position.set(J[0],J[1],J[2]);L.cameras[B]=N}for(x in D.lights)B=D.lights[x],
  534. N=B.color!==void 0?B.color:16777215,J=B.intensity!==void 0?B.intensity:1,B.type=="directional"?(E=B.direction,U=new THREE.DirectionalLight(N,J),U.position.set(E[0],E[1],E[2]),U.position.normalize()):B.type=="point"?(E=B.position,d=B.distance,U=new THREE.PointLight(N,J,d),U.position.set(E[0],E[1],E[2])):B.type=="ambient"&&(U=new THREE.AmbientLight(N)),L.scene.addLight(U),L.lights[x]=U;for(A in D.fogs)x=D.fogs[A],x.type=="linear"?M=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(M=new THREE.FogExp2(0,
  535. x.density)),J=x.color,M.color.setRGB(J[0],J[1],J[2]),L.fogs[A]=M;if(L.cameras&&D.defaults.camera)L.currentCamera=L.cameras[D.defaults.camera];if(L.fogs&&D.defaults.fog)L.scene.fog=L.fogs[D.defaults.fog];J=D.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(J[0],J[1],J[2]);L.bgColorAlpha=D.defaults.bgalpha;for(u in D.geometries)if(A=D.geometries[u],A.type=="bin_mesh"||A.type=="ascii_mesh")j+=1,e.onLoadStart();V=j;for(u in D.geometries)A=D.geometries[u],A.type=="cube"?(G=new THREE.CubeGeometry(A.width,
  536. A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides),L.geometries[u]=G):A.type=="plane"?(G=new THREE.PlaneGeometry(A.width,A.height,A.segmentsWidth,A.segmentsHeight),L.geometries[u]=G):A.type=="sphere"?(G=new THREE.SphereGeometry(A.radius,A.segmentsWidth,A.segmentsHeight),L.geometries[u]=G):A.type=="cylinder"?(G=new THREE.CylinderGeometry(A.numSegs,A.topRad,A.botRad,A.height,A.topOffset,A.botOffset),L.geometries[u]=G):A.type=="torus"?(G=new THREE.TorusGeometry(A.radius,
  537. A.tube,A.segmentsR,A.segmentsT),L.geometries[u]=G):A.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(A.subdivisions),L.geometries[u]=G):A.type=="bin_mesh"?Q.load({model:f(A.url,D.urlBaseType),callback:n(u)}):A.type=="ascii_mesh"?da.load({model:f(A.url,D.urlBaseType),callback:n(u)}):A.type=="embedded_mesh"&&(A=D.embeds[A.id])&&da.createModel(A,p(u),"");for(y in D.textures)if(u=D.textures[y],u.url instanceof Array){ca+=u.url.length;for(Q=0;Q<u.url.length;Q++)e.onLoadStart()}else ca+=1,e.onLoadStart();
  538. W=ca;for(y in D.textures){u=D.textures[y];if(u.mapping!=void 0&&THREE[u.mapping]!=void 0)u.mapping=new THREE[u.mapping];if(u.url instanceof Array){Q=[];for(var aa=0;aa<u.url.length;aa++)Q[aa]=f(u.url[aa],D.urlBaseType);Q=THREE.ImageUtils.loadTextureCube(Q,u.mapping,b)}else{Q=THREE.ImageUtils.loadTexture(f(u.url,D.urlBaseType),u.mapping,b);if(THREE[u.minFilter]!=void 0)Q.minFilter=THREE[u.minFilter];if(THREE[u.magFilter]!=void 0)Q.magFilter=THREE[u.magFilter];if(u.repeat){Q.repeat.set(u.repeat[0],
  539. u.repeat[1]);if(u.repeat[0]!=1)Q.wrapS=THREE.RepeatWrapping;if(u.repeat[1]!=1)Q.wrapT=THREE.RepeatWrapping}u.offset&&Q.offset.set(u.offset[0],u.offset[1]);if(u.wrap){da={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(da[u.wrap[0]]!==void 0)Q.wrapS=da[u.wrap[0]];if(da[u.wrap[1]]!==void 0)Q.wrapT=da[u.wrap[1]]}}L.textures[y]=Q}for(v in D.materials){y=D.materials[v];for(I in y.parameters)if(I=="envMap"||I=="map"||I=="lightMap")y.parameters[I]=L.textures[y.parameters[I]];else if(I==
  540. "shading")y.parameters[I]=y.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")y.parameters[I]=THREE[y.parameters[I]]?THREE[y.parameters[I]]:THREE.NormalBlending;else if(I=="combine")y.parameters[I]=y.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(I=="vertexColors")if(y.parameters[I]=="face")y.parameters[I]=THREE.FaceColors;else if(y.parameters[I])y.parameters[I]=THREE.VertexColors;if(y.parameters.opacity!==void 0&&y.parameters.opacity<
  541. 1)y.parameters.transparent=!0;if(y.parameters.normalMap){u=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(u.uniforms);Q=y.parameters.color;da=y.parameters.specular;A=y.parameters.ambient;M=y.parameters.shininess;b.tNormal.texture=L.textures[y.parameters.normalMap];if(y.parameters.normalMapFactor)b.uNormalScale.value=y.parameters.normalMapFactor;if(y.parameters.map)b.tDiffuse.texture=y.parameters.map,b.enableDiffuse.value=!0;if(y.parameters.lightMap)b.tAO.texture=y.parameters.lightMap,b.enableAO.value=
  542. !0;if(y.parameters.specularMap)b.tSpecular.texture=L.textures[y.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(Q);b.uSpecularColor.value.setHex(da);b.uAmbientColor.value.setHex(A);b.uShininess.value=M;if(y.parameters.opacity)b.uOpacity.value=y.parameters.opacity;y=new THREE.MeshShaderMaterial({fragmentShader:u.fragmentShader,vertexShader:u.vertexShader,uniforms:b,lights:!0,fog:!0})}else y=new THREE[y.type](y.parameters);L.materials[v]=y}m();e.callbackSync(L)}}};
  543. 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=
  544. 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,k,m,n,p,o,u){k=(k-o)/(u-o);o=this.normal_cache;c[h]=m+k*this.delta;c[h+1]=n;c[h+2]=p;g[h]=this.lerp(o[b],o[b+3],k);g[h+1]=this.lerp(o[b+1],o[b+4],k);g[h+2]=this.lerp(o[b+2],o[b+5],k)};this.VIntY=function(b,c,g,h,k,m,n,p,o,u){k=(k-o)/(u-o);o=this.normal_cache;c[h]=m;c[h+1]=n+k*this.delta;c[h+
  545. 2]=p;c=b+this.yd*3;g[h]=this.lerp(o[b],o[c],k);g[h+1]=this.lerp(o[b+1],o[c+1],k);g[h+2]=this.lerp(o[b+2],o[c+2],k)};this.VIntZ=function(b,c,g,h,k,m,n,p,o,u){k=(k-o)/(u-o);o=this.normal_cache;c[h]=m;c[h+1]=n;c[h+2]=p+k*this.delta;c=b+this.zd*3;g[h]=this.lerp(o[b],o[c],k);g[h+1]=this.lerp(o[b+1],o[c+1],k);g[h+2]=this.lerp(o[b+2],o[c+2],k)};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+
  546. this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,g,h,k,m){var n=h+1,p=h+this.yd,o=h+this.zd,u=n+this.yd,v=n+this.zd,w=h+this.yd+this.zd,x=n+this.yd+this.zd,B=0,A=this.field[h],y=this.field[n],K=this.field[p],E=this.field[u],J=this.field[o],I=this.field[v],G=this.field[w],N=this.field[x];A<k&&(B|=1);y<k&&(B|=2);K<k&&(B|=8);E<k&&(B|=4);J<k&&(B|=16);I<k&&(B|=32);G<k&&(B|=128);N<k&&(B|=64);var M=THREE.edgeTable[B];if(M==0)return 0;var Q=this.delta,
  547. F=b+Q,U=c+Q,Q=g+Q;M&1&&(this.compNorm(h),this.compNorm(n),this.VIntX(h*3,this.vlist,this.nlist,0,k,b,c,g,A,y));M&2&&(this.compNorm(n),this.compNorm(u),this.VIntY(n*3,this.vlist,this.nlist,3,k,F,c,g,y,E));M&4&&(this.compNorm(p),this.compNorm(u),this.VIntX(p*3,this.vlist,this.nlist,6,k,b,U,g,K,E));M&8&&(this.compNorm(h),this.compNorm(p),this.VIntY(h*3,this.vlist,this.nlist,9,k,b,c,g,A,K));M&16&&(this.compNorm(o),this.compNorm(v),this.VIntX(o*3,this.vlist,this.nlist,12,k,b,c,Q,J,I));M&32&&(this.compNorm(v),
  548. this.compNorm(x),this.VIntY(v*3,this.vlist,this.nlist,15,k,F,c,Q,I,N));M&64&&(this.compNorm(w),this.compNorm(x),this.VIntX(w*3,this.vlist,this.nlist,18,k,b,U,Q,G,N));M&128&&(this.compNorm(o),this.compNorm(w),this.VIntY(o*3,this.vlist,this.nlist,21,k,b,c,Q,J,G));M&256&&(this.compNorm(h),this.compNorm(o),this.VIntZ(h*3,this.vlist,this.nlist,24,k,b,c,g,A,J));M&512&&(this.compNorm(n),this.compNorm(v),this.VIntZ(n*3,this.vlist,this.nlist,27,k,F,c,g,y,I));M&1024&&(this.compNorm(u),this.compNorm(x),this.VIntZ(u*
  549. 3,this.vlist,this.nlist,30,k,F,U,g,E,N));M&2048&&(this.compNorm(p),this.compNorm(w),this.VIntZ(p*3,this.vlist,this.nlist,33,k,b,U,g,K,G));B<<=4;for(k=h=0;THREE.triTable[B+k]!=-1;)b=B+k,c=b+1,g=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],m),k+=3,h++;return h};this.posnormtriv=function(b,c,g,h,k,m){var n=this.count*3;this.positionArray[n]=b[g];this.positionArray[n+1]=b[g+1];this.positionArray[n+2]=b[g+2];this.positionArray[n+3]=b[h];this.positionArray[n+
  550. 4]=b[h+1];this.positionArray[n+5]=b[h+2];this.positionArray[n+6]=b[k];this.positionArray[n+7]=b[k+1];this.positionArray[n+8]=b[k+2];this.normalArray[n]=c[g];this.normalArray[n+1]=c[g+1];this.normalArray[n+2]=c[g+2];this.normalArray[n+3]=c[h];this.normalArray[n+4]=c[h+1];this.normalArray[n+5]=c[h+2];this.normalArray[n+6]=c[k];this.normalArray[n+7]=c[k+1];this.normalArray[n+8]=c[k+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&m(this)};this.begin=function(){this.count=0;
  551. 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,k){var m=this.size*Math.sqrt(h/k),n=g*this.size,p=c*this.size,o=b*this.size,u=Math.floor(n-m);u<1&&(u=1);n=Math.floor(n+m);n>this.size-1&&(n=this.size-1);var v=Math.floor(p-m);v<1&&(v=1);p=Math.floor(p+m);p>this.size-1&&(p=this.size-1);var w=Math.floor(o-m);w<1&&(w=1);m=Math.floor(o+m);m>this.size-1&&(m=this.size-
  552. 1);for(var x,B,A,y,K,E;u<n;u++){o=this.size2*u;B=u/this.size-g;K=B*B;for(B=v;B<p;B++){A=o+this.size*B;x=B/this.size-c;E=x*x;for(x=w;x<m;x++)y=x/this.size-b,y=h/(1.0E-6+y*y+E+K)-k,y>0&&(this.field[A+x]+=y)}}};this.addPlaneX=function(b,c){var g,h,k,m,n,p=this.size,o=this.yd,u=this.zd,v=this.field,w=p*Math.sqrt(b/c);w>p&&(w=p);for(g=0;g<w;g++)if(h=g/p,h*=h,m=b/(1.0E-4+h)-c,m>0)for(h=0;h<p;h++){n=g+h*o;for(k=0;k<p;k++)v[u*k+n]+=m}};this.addPlaneY=function(b,c){var g,h,k,m,n,p,o=this.size,u=this.yd,v=
  553. this.zd,w=this.field,x=o*Math.sqrt(b/c);x>o&&(x=o);for(h=0;h<x;h++)if(g=h/o,g*=g,m=b/(1.0E-4+g)-c,m>0){n=h*u;for(g=0;g<o;g++){p=n+g;for(k=0;k<o;k++)w[v*k+p]+=m}}};this.addPlaneZ=function(b,c){var g,h,k,m,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(k=0;k<dist;k++)if(g=k/size,g*=g,m=b/(1.0E-4+g)-c,m>0){n=zd*k;for(h=0;h<size;h++){p=n+h*yd;for(g=0;g<size;g++)field[p+g]+=m}}};this.reset=function(){var b;for(b=0;b<this.size3;b++)this.normal_cache[b*
  554. 3]=0,this.field[b]=0};this.render=function(b){this.begin();var c,g,h,k,m,n,p,o,u,v=this.size-2;for(k=1;k<v;k++){u=this.size2*k;p=(k-this.halfsize)/this.halfsize;for(h=1;h<v;h++){o=u+this.size*h;n=(h-this.halfsize)/this.halfsize;for(g=1;g<v;g++)m=(g-this.halfsize)/this.halfsize,c=o+g,this.polygonize(m,n,p,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,g=[];this.render(function(h){var k,m,n,p,o,u,v,w;for(k=0;k<h.count;k++)v=k*3,o=v+1,w=v+2,m=h.positionArray[v],
  555. n=h.positionArray[o],p=h.positionArray[w],u=new THREE.Vector3(m,n,p),m=h.normalArray[v],n=h.normalArray[o],p=h.normalArray[w],v=new THREE.Vector3(m,n,p),v.normalize(),o=new THREE.Vertex(u),c.vertices.push(o),g.push(v);nfaces=h.count/3;for(k=0;k<nfaces;k++)v=(b+k)*3,o=v+1,w=v+2,u=g[v],m=g[o],n=g[w],v=new THREE.Face3(v,o,w,[u,m,n]),c.faces.push(v);b+=nfaces;h.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  556. 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,
  557. 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,
  558. 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]);
  559. 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,
  560. -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,
  561. -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,
  562. -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,
  563. 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,
  564. -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,
  565. 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,
  566. -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,
  567. 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,
  568. 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,
  569. 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,
  570. 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,
  571. -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,
  572. -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,
  573. -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,
  574. 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,
  575. -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,
  576. 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,
  577. 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,
  578. -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,
  579. 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]);
  580. THREE.Trident=function(b){function c(c){return new THREE.Mesh(new THREE.CylinderGeometry(30,0.1,b.length/20,b.length/5),new THREE.MeshBasicMaterial({color:c}))}function e(b,c){var e=new THREE.Geometry;e.vertices=[new THREE.Vertex,new THREE.Vertex(b)];return new THREE.Line(e,new THREE.LineBasicMaterial({color:c}))}THREE.Object3D.call(this);var f=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]);
  581. this.scale=new THREE.Vector3(b.scale,b.scale,b.scale);this.addChild(e(new THREE.Vector3(b.length,0,0),b.xAxisColor));this.addChild(e(new THREE.Vector3(0,b.length,0),b.yAxisColor));this.addChild(e(new THREE.Vector3(0,0,b.length),b.zAxisColor));if(b.showArrows)g=c(b.xAxisColor),g.rotation.y=-f,g.position.x=b.length,this.addChild(g),g=c(b.yAxisColor),g.rotation.x=f,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)};
  582. 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};
  583. 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)};
  584. THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,g,h=0;c=0;for(e=this.colliders.length;c<e;c++)if(g=this.colliders[c],f=this.rayCast(b,g),f<Number.MAX_VALUE)g.distance=f,f>h?this.hits.push(g):this.hits.unshift(g),h=f;return this.hits};
  585. THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.dist<Number.MAX_VALUE){c[e].distance=f.dist;c[e].faceIndex=f.faceIndex;break}e++}if(e>c.length)return null;return c[e]};
  586. 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)};
  587. THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,h=0;h<c.numFaces;h++){var k=c.mesh.geometry.faces[h],m=c.mesh.geometry.vertices[k.a].position,n=c.mesh.geometry.vertices[k.b].position,p=c.mesh.geometry.vertices[k.c].position,o=k instanceof THREE.Face4?c.mesh.geometry.vertices[k.d].position:null;k instanceof THREE.Face3?(k=this.rayTriangle(e,m,n,p,f,this.collisionNormal,c.mesh),k<f&&(f=k,g=h,c.normal.copy(this.collisionNormal),c.normal.normalize())):
  588. k instanceof THREE.Face4&&(k=this.rayTriangle(e,m,n,o,f,this.collisionNormal,c.mesh),k<f&&(f=k,g=h,c.normal.copy(this.collisionNormal),c.normal.normalize()),k=this.rayTriangle(e,n,p,o,f,this.collisionNormal,c.mesh),k<f&&(f=k,g=h,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:g}};
  589. THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,g,h,k){var m=THREE.CollisionSystem.__v1,n=THREE.CollisionSystem.__v2;h.set(0,0,0);m.sub(e,c);n.sub(f,e);h.cross(m,n);m=h.dot(b.direction);if(!(m<0))if(k.doubleSided||k.flipSided)h.multiplyScalar(-1),m*=-1;else return Number.MAX_VALUE;k=h.dot(c)-h.dot(b.origin);if(!(k<=0))return Number.MAX_VALUE;if(!(k>=m*g))return Number.MAX_VALUE;k/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(k);m.addSelf(b.origin);Math.abs(h.x)>
  590. Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=m.y-c.y,h=e.y-c.y,g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,h=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(b=m.x-c.x,h=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,h=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=h*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=h*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return k};
  591. THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f};
  592. THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,h=0,k=0,m=0,n=0,p=!0;e.origin.x<c.min.x?(f=c.min.x-e.origin.x,f/=e.direction.x,p=!1,k=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,k=1);e.origin.y<c.min.y?(g=c.min.y-e.origin.y,g/=e.direction.y,p=!1,m=-1):e.origin.y>c.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y,
  593. p=!1,m=1);e.origin.z<c.min.z?(h=c.min.z-e.origin.z,h/=e.direction.z,p=!1,n=-1):e.origin.z>c.max.z&&(h=c.max.z-e.origin.z,h/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;g>f&&(p=1,f=g);h>f&&(p=2,f=h);switch(p){case 0:m=e.origin.y+e.direction.y*f;if(m<c.min.y||m>c.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(k,0,0);break;case 1:k=e.origin.x+e.direction.x*f;if(k<c.min.x||k>c.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*
  594. f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:k=e.origin.x+e.direction.x*f;if(k<c.min.x||k>c.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(m<c.min.y||m>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,n)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE};
  595. THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq<c.radiusSq)return-1;var f=e.dot(b.direction.clone());if(f<=0)return Number.MAX_VALUE;e=c.radiusSq-(e.lengthSq()-f*f);if(e>=0)return Math.abs(f)-Math.sqrt(e);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;
  596. THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,e=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]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};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};
  597. THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};
  598. if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,h=new THREE.Camera,k=new THREE.Matrix4,m=new THREE.Matrix4,n,p,o;g.useTarget=h.useTarget=!1;g.matrixAutoUpdate=h.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},u=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.Camera(53,1,1,1E4);w.position.z=
  599. 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:u},mapRight:{type:"t",value:1,texture:v}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});
  600. var x=new THREE.Scene;x.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);u.width=b;u.height=f;v.width=b;v.height=f};this.render=function(b,e){e.update(null,!0);if(n!==e.aspect||p!==e.near||o!==e.fov){n=e.aspect;p=e.near;o=e.fov;var y=e.projectionMatrix.clone(),K=125/30*0.5,E=K*p/125,J=p*Math.tan(o*Math.PI/360),I;k.n14=K;m.n14=-K;K=-J*n+E;I=J*n+E;y.n11=2*p/(I-K);y.n13=(I+K)/(I-K);g.projectionMatrix=y.clone();K=-J*n-E;I=J*n-E;y.n11=2*p/(I-K);
  601. y.n13=(I+K)/(I-K);h.projectionMatrix=y.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(m);g.update(null,!0);g.position.copy(e.position);g.near=p;g.far=e.far;f.call(c,b,g,u,!0);h.matrix=e.matrixWorld.clone().multiplySelf(k);h.update(null,!0);h.position.copy(e.position);h.near=p;h.far=e.far;f.call(c,b,h,v,!0);f.call(c,x,w)}};
  602. if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,h,k=new THREE.Camera,m=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);g=b/2;h=f};this.render=function(b,e){this.clear();k.fov=e.fov;k.aspect=0.5*e.aspect;k.near=e.near;k.far=e.far;
  603. k.updateProjectionMatrix();k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(c.separation);m.projectionMatrix=k.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,h);f.call(c,b,k);this.setViewport(g,0,g,h);f.call(c,b,m,!1)}};