1
0

Three.js 300 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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){b!==void 0&&this.setHex(b);return this};
  3. THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;return this},setHSV:function(b,c,e){var f,h,j;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),h=b*6-f,b=e*(1-c),j=e*(1-c*h),c=e*(1-c*(1-h)),f){case 1:this.r=j;this.g=e;this.b=b;break;case 2:this.r=b;this.g=e;this.b=c;break;case 3:this.r=b;this.g=j;this.b=e;break;case 4:this.r=c;this.g=b;this.b=e;break;case 5:this.r=
  4. e;this.g=b;this.b=j;break;case 6:case 0:this.r=e,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
  5. THREE.Vector2=function(b,c){this.set(b||0,c||0)};
  6. THREE.Vector2.prototype={constructor:THREE.Vector2,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},
  7. divideScalar:function(b){b?(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)},
  8. 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)};
  9. THREE.Vector3.prototype={constructor:THREE.Vector3,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=
  10. b.z-c.z;return this},subSelf:function(b){this.x-=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)},
  11. dot:function(b){return this.x*b.x+this.y*b.y+this.z*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*
  12. b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*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()<
  13. 1.0E-4}};THREE.Vector4=function(b,c,e,f){this.set(b||0,c||0,e||0,f||1)};
  14. THREE.Vector4.prototype={constructor:THREE.Vector4,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},
  15. subSelf:function(b){this.x-=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())},
  16. 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};
  17. THREE.Ray.prototype={constructor:THREE.Ray,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),
  18. c=c.clone().subSelf(e),h=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(h),g=c.dot(c),c=c.dot(h),h=1/(b*g-e*e),g=(g*f-e*c)*h,b=(b*c-e*f)*h;return g>0&&b>0&&g+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 h,j,g,m,
  19. n,p,o,t,v,u,w=b.geometry,B=w.vertices,x=[],f=0;for(h=w.faces.length;f<h;f++)if(j=w.faces[f],v=this.origin.clone(),u=this.direction.clone(),p=b.matrixWorld,g=p.multiplyVector3(B[j.a].position.clone()),m=p.multiplyVector3(B[j.b].position.clone()),n=p.multiplyVector3(B[j.c].position.clone()),p=j instanceof THREE.Face4?p.multiplyVector3(B[j.d].position.clone()):null,o=b.matrixRotationWorld.multiplyVector3(j.normal.clone()),t=u.dot(o),b.doubleSided||(b.flipSided?t>0:t<0))if(o=o.dot((new THREE.Vector3).sub(g,
  20. v))/t,v=v.addSelf(u.multiplyScalar(o)),j instanceof THREE.Face3)e(v,g,m,n)&&(j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},x.push(j));else if(j instanceof THREE.Face4&&(e(v,g,m,p)||e(v,m,n,p)))j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},x.push(j);return x}else return[]}};
  21. THREE.Rectangle=function(){function b(){j=f-c;g=h-e}var c,e,f,h,j,g,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return g};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(g,j,o,t){m=!1;c=g;e=j;f=o;h=t;b()};this.addPoint=function(g,j){m?(m=!1,c=g,e=j,f=g,h=j):(c=c<g?c:g,e=e<j?e:j,f=f>g?f:g,h=h>j?h:j);b()};this.add3Points=
  22. function(g,j,o,t,v,u){m?(m=!1,c=g<o?g<v?g:v:o<v?o:v,e=j<t?j<u?j:u:t<u?t:u,f=g>o?g>v?g:v:o>v?o:v,h=j>t?j>u?j:u:t>u?t:u):(c=g<o?g<v?g<c?g:c:v<c?v:c:o<v?o<c?o:c:v<c?v:c,e=j<t?j<u?j<e?j:e:u<e?u:e:t<u?t<e?t:e:u<e?u:e,f=g>o?g>v?g>f?g:f:v>f?v:f:o>v?o>f?o:f:v>f?v:f,h=j>t?j>u?j>h?j:h:u>h?u:h:t>u?t>h?t:h:u>h?u:h);b()};this.addRectangle=function(g){m?(m=!1,c=g.getLeft(),e=g.getTop(),f=g.getRight(),h=g.getBottom()):(c=c<g.getLeft()?c:g.getLeft(),e=e<g.getTop()?e:g.getTop(),f=f>g.getRight()?f:g.getRight(),h=h>
  23. g.getBottom()?h:g.getBottom());b()};this.inflate=function(g){c-=g;e-=g;f+=g;h+=g;b()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();e=e>g.getTop()?e:g.getTop();f=f<g.getRight()?f:g.getRight();h=h<g.getBottom()?h:g.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){m=!0;h=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]};
  24. THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,h,j,g,m,n,p,o,t,v,u,w,B){this.set(b||1,c||0,e||0,f||0,h||0,j||1,g||0,m||0,n||0,p||0,o||1,t||0,v||0,u||0,w||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  25. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,j,g,m,n,p,o,t,v,u,w,B){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=j;this.n23=g;this.n24=m;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=v;this.n42=u;this.n43=w;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,
  26. c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;f.cross(e,j).normalize();f.length()===0&&(j.x+=1.0E-4,f.cross(e,j).normalize());h.cross(j,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=j.x;this.n21=f.y;this.n22=h.y;this.n23=j.y;this.n31=f.z;this.n32=h.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=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)*h;
  27. b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;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+
  28. e*this.n32+f*this.n33;b.normalize();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,h=b.n13,j=b.n14,g=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,v=b.n33,u=b.n34,w=b.n41,B=b.n42,x=b.n43,A=b.n44,E=c.n11,F=c.n12,
  29. J=c.n13,C=c.n14,G=c.n21,O=c.n22,D=c.n23,I=c.n24,V=c.n31,da=c.n32,S=c.n33,z=c.n34,ea=c.n41,R=c.n42,P=c.n43,k=c.n44;this.n11=e*E+f*G+h*V+j*ea;this.n12=e*F+f*O+h*da+j*R;this.n13=e*J+f*D+h*S+j*P;this.n14=e*C+f*I+h*z+j*k;this.n21=g*E+m*G+n*V+p*ea;this.n22=g*F+m*O+n*da+p*R;this.n23=g*J+m*D+n*S+p*P;this.n24=g*C+m*I+n*z+p*k;this.n31=o*E+t*G+v*V+u*ea;this.n32=o*F+t*O+v*da+u*R;this.n33=o*J+t*D+v*S+u*P;this.n34=o*C+t*I+v*z+u*k;this.n41=w*E+B*G+x*V+A*ea;this.n42=w*F+B*O+x*da+A*R;this.n43=w*J+B*D+x*S+A*P;this.n44=
  30. w*C+B*I+x*z+A*k;return this},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*=
  31. b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,h=this.n21,j=this.n22,g=this.n23,m=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,v=this.n41,u=this.n42,w=this.n43,B=this.n44;return f*g*p*v-e*m*p*v-f*j*o*v+c*m*o*v+e*j*t*v-c*g*t*v-f*g*n*u+e*m*n*u+f*h*o*u-b*m*o*u-e*h*t*u+b*g*t*u+f*j*n*w-c*m*n*w-f*h*p*w+b*m*p*w+c*h*t*w-b*j*t*w-e*j*n*B+c*g*n*B+e*h*p*B-b*g*p*B-c*h*
  32. o*B+b*j*o*B},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=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=
  33. this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;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]=
  34. this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=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]=
  35. this.n34;b[c+15]=this.n44;return b},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,
  36. 0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),h=1-e,j=b.x,g=b.y,m=b.z,n=h*j,p=h*g;this.set(n*j+e,n*g-f*m,n*m+f*g,0,n*g+f*m,p*g+e,p*m-f*j,0,n*m-f*g,p*m+f*j,h*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=
  37. new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;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,h=b.z,j=Math.cos(e),e=Math.sin(e),g=Math.cos(f),f=Math.sin(f),m=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var n=
  38. g*m,p=g*h,o=f*m,t=f*h;this.n11=n+t*e;this.n12=o*e-p;this.n13=j*f;this.n21=j*h;this.n22=j*m;this.n23=-e;this.n31=p*e-o;this.n32=t+n*e;this.n33=j*g;break;case "ZXY":n=g*m;p=g*h;o=f*m;t=f*h;this.n11=n-t*e;this.n12=-j*h;this.n13=o+p*e;this.n21=p+o*e;this.n22=j*m;this.n23=t-n*e;this.n31=-j*f;this.n32=e;this.n33=j*g;break;case "ZYX":n=j*m;p=j*h;o=e*m;t=e*h;this.n11=g*m;this.n12=o*f-p;this.n13=n*f+t;this.n21=g*h;this.n22=t*f+n;this.n23=p*f-o;this.n31=-f;this.n32=e*g;this.n33=j*g;break;case "YZX":n=j*g;p=
  39. j*f;o=e*g;t=e*f;this.n11=g*m;this.n12=t-n*h;this.n13=o*h+p;this.n21=h;this.n22=j*m;this.n23=-e*m;this.n31=-f*m;this.n32=p*h+o;this.n33=n-t*h;break;case "XZY":n=j*g;p=j*f;o=e*g;t=e*f;this.n11=g*m;this.n12=-h;this.n13=f*m;this.n21=n*h+t;this.n22=j*m;this.n23=p*h-o;this.n31=o*h-p;this.n32=e*m;this.n33=t*h+n;break;default:n=j*m,p=j*h,o=e*m,t=e*h,this.n11=g*m,this.n12=-g*h,this.n13=f,this.n21=p+o*f,this.n22=n-t*f,this.n23=-e*g,this.n31=t-n*f,this.n32=o+p*f,this.n33=j*g}return this},setRotationFromQuaternion:function(b){var c=
  40. b.x,e=b.y,f=b.z,h=b.w,j=c+c,g=e+e,m=f+f,b=c*j,n=c*g;c*=m;var p=e*g;e*=m;f*=m;j*=h;g*=h;h*=m;this.n11=1-(p+f);this.n12=n-h;this.n13=c+g;this.n21=n+h;this.n22=1-(b+f);this.n23=e-j;this.n31=c-g;this.n32=e+j;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},
  41. extractRotation:function(b,c){var e=1/c.x,f=1/c.y,h=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*h;this.n23=b.n23*h;this.n33=b.n33*h}};
  42. THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,j=b.n14,g=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,v=b.n33,u=b.n34,w=b.n41,B=b.n42,x=b.n43,A=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*u*B-p*v*B+p*t*x-m*u*x-n*t*A+m*v*A;c.n12=j*v*B-h*u*B-j*t*x+f*u*x+h*t*A-f*v*A;c.n13=h*p*B-j*n*B+j*m*x-f*p*x-h*m*A+f*n*A;c.n14=j*n*t-h*p*t-j*m*v+f*p*v+h*m*u-f*n*u;c.n21=p*v*w-n*u*w-p*o*x+g*u*x+n*o*A-g*v*A;c.n22=h*u*w-j*v*w+j*o*x-e*u*x-h*o*A+e*v*A;c.n23=j*n*w-h*p*w-j*g*x+e*p*x+h*g*A-e*n*A;c.n24=
  43. h*p*o-j*n*o+j*g*v-e*p*v-h*g*u+e*n*u;c.n31=m*u*w-p*t*w+p*o*B-g*u*B-m*o*A+g*t*A;c.n32=j*t*w-f*u*w-j*o*B+e*u*B+f*o*A-e*t*A;c.n33=h*p*w-j*m*w+j*g*B-e*p*B-f*g*A+e*m*A;c.n34=j*m*o-f*p*o-j*g*t+e*p*t+f*g*u-e*m*u;c.n41=n*t*w-m*v*w-n*o*B+g*v*B+m*o*x-g*t*x;c.n42=f*v*w-h*t*w+h*o*B-e*v*B-f*o*x+e*t*x;c.n43=h*m*w-f*n*w-h*g*B+e*n*B+f*g*x-e*m*x;c.n44=f*n*o-h*m*o+h*g*t-e*n*t-f*g*v+e*m*v;c.multiplyScalar(1/b.determinant());return c};
  44. THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,g=-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,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*g+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*j;e[3]=b*g;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*t;return c};
  45. THREE.Matrix4.makeFrustum=function(b,c,e,f,h,j){var g;g=new THREE.Matrix4;g.n11=2*h/(c-b);g.n12=0;g.n13=(c+b)/(c-b);g.n14=0;g.n21=0;g.n22=2*h/(f-e);g.n23=(f+e)/(f-e);g.n24=0;g.n31=0;g.n32=0;g.n33=-(j+h)/(j-h);g.n34=-2*j*h/(j-h);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)};
  46. THREE.Matrix4.makeOrtho=function(b,c,e,f,h,j){var g,m,n,p;g=new THREE.Matrix4;m=c-b;n=e-f;p=j-h;g.n11=2/m;g.n12=0;g.n13=0;g.n14=-((c+b)/m);g.n21=0;g.n22=2/n;g.n23=0;g.n24=-((e+f)/n);g.n31=0;g.n32=0;g.n33=-2/p;g.n34=-((j+h)/p);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
  47. 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;
  48. this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""};
  49. THREE.Object3D.prototype={constructor:THREE.Object3D,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)===
  50. -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,h;e=0;for(f=this.children.length;e<f;e++){h=this.children[e];if(h.name===b)return h;if(c&&(h=h.getChildByName(b,c),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);
  51. 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),
  52. 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)};
  53. THREE.Quaternion.prototype={constructor:THREE.Quaternion,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,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),j=Math.cos(e),e=Math.sin(e),g=b*c,m=f*h;this.w=g*j-m*e;this.x=g*e+m*j;this.y=f*c*j+b*h*e;this.z=b*h*j-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);
  54. this.x=b.x*f;this.y=b.y*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*=
  55. b,this.w*=b);return this},multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,h=this.w,j=b.x,g=b.y,m=b.z,b=b.w;this.x=c*b+h*j+e*m-f*g;this.y=e*b+h*g+f*j-c*m;this.z=f*b+h*m+c*g-e*j;this.w=h*b-c*j-e*g-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,h=b.z,j=this.x,g=this.y,m=this.z,
  56. n=this.w,p=n*e+g*h-m*f,o=n*f+m*e-j*h,t=n*h+j*f-g*e,e=-j*e-g*f-m*h;c.x=p*n+e*-j+o*-m-t*-g;c.y=o*n+e*-g+t*-j-p*-m;c.z=t*n+e*-m+p*-g-o*-j;return c}};
  57. THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.001)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;h=Math.sin((1-f)*j)/g;f=Math.sin(f*j)/g;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
  58. THREE.Face3=function(b,c,e,f,h,j){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=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};
  59. THREE.Face4=function(b,c,e,f,h,j,g){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)};
  60. THREE.UV.prototype={constructor:THREE.UV,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};
  61. THREE.Geometry.prototype={constructor:THREE.Geometry,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),
  62. e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,h,j,g,m=new THREE.Vector3,n=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){j=this.faces[f];if(b&&j.vertexNormals.length){m.set(0,0,0);c=0;for(e=j.vertexNormals.length;c<e;c++)m.addSelf(j.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[j.a],e=this.vertices[j.b],g=this.vertices[j.c],m.sub(g.position,e.position),n.sub(c.position,e.position),m.crossSelf(n);m.isZero()||
  63. m.normalize();j.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=
  64. 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]),
  65. 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,j,h,D){m=b.vertices[e].position;n=b.vertices[c].position;p=b.vertices[f].position;o=g[j];t=g[h];v=g[D];u=n.x-m.x;w=p.x-m.x;B=n.y-m.y;x=p.y-m.y;A=n.z-m.z;E=p.z-m.z;F=t.u-o.u;J=v.u-o.u;C=t.v-o.v;G=v.v-o.v;O=1/(F*G-J*C);da.set((G*u-C*w)*
  66. O,(G*B-C*x)*O,(G*A-C*E)*O);S.set((F*w-J*u)*O,(F*x-J*B)*O,(F*E-J*A)*O);I[e].addSelf(da);I[c].addSelf(da);I[f].addSelf(da);V[e].addSelf(S);V[c].addSelf(S);V[f].addSelf(S)}var c,e,f,h,j,g,m,n,p,o,t,v,u,w,B,x,A,E,F,J,C,G,O,D,I=[],V=[],da=new THREE.Vector3,S=new THREE.Vector3,z=new THREE.Vector3,ea=new THREE.Vector3,R=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)I[c]=new THREE.Vector3,V[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)j=this.faces[c],g=this.faceVertexUvs[0][c],j instanceof
  67. THREE.Face3?b(this,j.a,j.b,j.c,0,1,2):j instanceof THREE.Face4&&(b(this,j.a,j.b,j.c,0,1,2),b(this,j.a,j.b,j.d,0,1,3));var P=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){j=this.faces[c];for(f=0;f<j.vertexNormals.length;f++)R.copy(j.vertexNormals[f]),h=j[P[f]],D=I[h],z.copy(D),z.subSelf(R.multiplyScalar(R.dot(D))).normalize(),ea.cross(j.vertexNormals[f],D),h=ea.dot(V[h]),h=h<0?-1:1,j.vertexTangents[f]=new THREE.Vector4(z.x,z.y,z.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var b;
  68. 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;
  69. 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]===
  70. 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,h,j,g,m={};e=0;for(f=this.faces.length;e<f;e++)g=this.faces[e],g instanceof THREE.Face3?(h=b(g.a,g.b),c(m,h,e),h=b(g.b,g.c),c(m,h,e),h=b(g.a,g.c),c(m,h,e)):g instanceof THREE.Face4&&(h=b(g.b,g.d),c(m,h,e),h=b(g.a,g.b),c(m,h,e),h=b(g.a,g.d),c(m,h,e),h=b(g.b,g.c),c(m,h,e),h=b(g.c,g.d),c(m,h,e));e=0;for(f=this.edges.length;e<f;e++){g=this.edges[e];h=g.vertexIndices[0];j=g.vertexIndices[1];
  71. g.faceIndices=m[b(h,j)].array;for(h=0;h<g.faceIndices.length;h++)j=g.faceIndices[h],g.faces.push(this.faces[j])}}};THREE.GeometryIdCounter=0;
  72. THREE.Spline=function(b){function c(b,e,c,f,g,j,h){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*h+(-3*(e-c)-2*b-f)*j+b*g+e}this.points=b;var e=[],f={x:0,y:0,z:0},h,j,g,m,n,p,o,t,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){h=(this.points.length-1)*b;j=Math.floor(h);g=h-j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>this.points.length-2?j:j+1;e[3]=j>this.points.length-3?j:j+2;p=this.points[e[0]];o=this.points[e[1]];
  73. t=this.points[e[2]];v=this.points[e[3]];m=g*g;n=g*m;f.x=c(p.x,o.x,t.x,v.x,g,m,n);f.y=c(p.y,o.y,t.y,v.y,g,m,n);f.z=c(p.z,o.z,t.z,v.z,g,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,j=new THREE.Vector3,h=[],m=0;h[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),j.copy(position),
  74. m+=j.distanceTo(g),g.copy(position),e*=this.points.length-1,e=Math.floor(e),e!=f&&(h[e]=m,f=e);h[h.length]=m;return{chunks:h,total:m}};this.reparametrizeByArcLength=function(b){var e,c,f,g,h,j,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];j=Math.ceil(b*c/p.total);g=(e-1)/(this.points.length-1);h=e/(this.points.length-1);for(c=1;c<j-1;c++)f=g+c*(1/j)*(h-g),position=this.getPoint(f),m.push(n.copy(position).clone());
  75. 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,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
  76. 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)};
  77. 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)};
  78. THREE.Camera.prototype.setViewOffset=function(b,c,e,f,h,j){this.fullWidth=b;this.fullHeight=c;this.x=e;this.y=f;this.width=h;this.height=j;this.updateProjectionMatrix()};
  79. 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=
  80. !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;
  81. 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};
  82. THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(b,c,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=c||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
  83. 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;
  84. 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})};
  85. THREE.LensFlare.prototype.updateLensFlares=function(){var b,c=this.lensFlares.length,e,f=-this.positionScreen.x*2,h=-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+h*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
  86. THREE.Material=function(b){this.id=THREE.MaterialCount++;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:
  87. 0;this.alphaTest=b.alphaTest!==void 0?b.alphaTest:0};THREE.MaterialCount=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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  88. THREE.SphericalReflectionMapping=function(){};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};
  89. THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  90. 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!==
  91. 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};
  92. THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  93. 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!==
  94. 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};
  95. THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  96. 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;
  97. 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!==
  98. 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;
  99. 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;
  100. 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(){};
  101. 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=
  102. 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;
  103. 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!==
  104. 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};
  105. THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
  106. 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;
  107. 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};
  108. THREE.Texture=function(b,c,e,f,h,j){this.id=THREE.TextureCount++;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=h!==void 0?h:THREE.LinearFilter;this.minFilter=j!==void 0?j:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
  109. THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var b=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.TextureCount=0;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;
  110. THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(b,c,e,f,h,j,g,m,n){THREE.Texture.call(this,null,h,j,g,m,n);this.image={data:b,width:c,height:e};this.format=f!==void 0?f:THREE.RGBAFormat};
  111. THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;THREE.DataTexture.prototype={clone:function(){var b=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b]};THREE.Particle.prototype=new THREE.Object3D;
  112. THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;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;
  113. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  114. 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]=
  115. 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};
  116. 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;
  117. 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,h=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<h;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<h;f++)this.children[f].update(this.skinMatrix,
  118. 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};
  119. THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,h,j,g,m;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)h=this.geometry.bones[e],j=h.pos,g=h.rotq,m=h.scl,f=this.addBone(),f.name=h.name,f.position.set(j[0],j[1],j[2]),f.quaternion.set(g[0],g[1],g[2],g[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++)h=this.geometry.bones[e],
  120. f=this.bones[e],h.parent===-1?this.addChild(f):this.bones[h.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;
  121. 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,h=this.children.length;for(f=0;f<h;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,
  122. c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
  123. 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,h=this.geometry.skinIndices[b].x,j=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
  124. e.y,e.z);this.geometry.skinVerticesA.push(c[h].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(c[j].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]};
  125. 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)};
  126. 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,
  127. 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()};
  128. THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
  129. THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,c,e,f,h,j,g,m,n,p,o,t,v,u,w=new THREE.Geometry;w.vertices=this.geometry.vertices;f=w.faces=this.geometry.faces;var B=w.egdes=this.geometry.edges,x=w.edgeFaces=[];h=0;var A=[];b=0;for(c=f.length;b<c;b++)if(e=f[b],A.push(h),h+=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]=
  130. e.normal;b=0;for(c=B.length;b<c;b++)m=B[b],e=m.faces[0],f=m.faces[1],h=m.faceIndices[0],j=m.faceIndices[1],g=m.vertexIndices[0],m=m.vertexIndices[1],e.a===g?(n="a",o=A[h]+0):e.b===g?(n="b",o=A[h]+1):e.c===g?(n="c",o=A[h]+2):e.d===g&&(n="d",o=A[h]+3),e.a===m?(n+="a",t=A[h]+0):e.b===m?(n+="b",t=A[h]+1):e.c===m?(n+="c",t=A[h]+2):e.d===m&&(n+="d",t=A[h]+3),f.a===g?(p="a",v=A[j]+0):f.b===g?(p="b",v=A[j]+1):f.c===g?(p="c",v=A[j]+2):f.d===g&&(p="d",v=A[j]+3),f.a===m?(p+="a",u=A[j]+0):f.b===m?(p+="b",u=A[j]+
  131. 1):f.c===m?(p+="c",u=A[j]+2):f.d===m&&(p+="d",u=A[j]+3),n==="ac"||n==="ad"||n==="ca"||n==="da"?o>t&&(e=o,o=t,t=e):o<t&&(e=o,o=t,t=e),p==="ac"||p==="ad"||p==="ca"||p==="da"?v>u&&(e=v,v=u,u=e):v<u&&(e=v,v=u,u=e),e=new THREE.Face4(o,t,v,u),e.normal.set(1,0,0),x.push(e);this.geometry=w}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
  132. 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,h=b.faces,b=b.vertices,j=h.length,g,m,n,p,o,t=["a","b","c","d"];for(n=0;n<j;n++){m=c.length;g=h[n];g 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(g.normal);e.push(m);
  133. for(m=0;m<p;m++)o=b[g[t[m]]],c.push(new THREE.Vertex(o.position.clone()))}for(j=0;j<h.length-1;j++){b=e[j];for(g=j+1;g<h.length;g++)m=e[g],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))}};
  134. THREE.ShadowVolume.prototype.facesShareEdge=function(b,c,e){var f,h,j,g,m,n,p,o,t,v,u,w,B,x=0,A=["a","b","c","d"];f=c instanceof THREE.Face4?4:3;h=e instanceof THREE.Face4?4:3;for(w=0;w<f;w++){j=c[A[w]];m=b[j];for(B=0;B<h;B++)if(g=e[A[B]],n=b[g],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&&(x++,x===1&&(p=m,o=n,t=j,v=g,u=A[w]),x===2))return u+=A[w],u==="ad"||u==="ac"?{faces:[c,e],vertices:[p,o,n,m],indices:[t,v,
  135. g,j],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,e],vertices:[p,m,n,o],indices:[t,j,g,v],vertexTypes:[1,1,2,2],extrudable:!0}}};
  136. 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;
  137. 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;
  138. 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);
  139. 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);
  140. 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)};
  141. 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)};
  142. 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;
  143. 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};
  144. 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,j=e.z+e.w,k=-b.z+b.w,h=-e.z+e.w;return g>=0&&j>=0&&k>=0&&h>=0?!0:g<0&&j<0||k<0&&h<0?!1:(g<0?c=Math.max(c,g/(g-j)):j<0&&(f=Math.min(f,g/(g-j))),k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,h,j=[],g,m,n=[],p,o,t=[],v,u=[],w,B,x=[],A,E,F=[],J=new THREE.Vector4,C=new THREE.Vector4,
  145. G=new THREE.Matrix4,O=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,V=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,g){var e=[],m,n,p;h=0;n=
  146. b.objects;b=0;for(m=n.length;b<m;b++){p=n[b];var k;if(!(k=!p.visible))if(k=p instanceof THREE.Mesh){a:{k=void 0;for(var t=p.matrixWorld,u=-p.geometry.boundingSphere.radius*Math.max(p.scale.x,Math.max(p.scale.y,p.scale.z)),o=0;o<6;o++)if(k=D[o].x*t.n14+D[o].y*t.n24+D[o].z*t.n34+D[o].w,k<=u){k=!1;break a}k=!0}k=!k}if(!k)k=j[h]=j[h]||new THREE.RenderableObject,h++,f=k,J.copy(p.position),G.multiplyVector3(J),f.object=p,f.z=J.z,e.push(f)}g&&e.sort(c);return e};this.projectScene=function(f,j,h){var J=[],
  147. R=j.near,P=j.far,k,K,X,$,Y,ha,ja,fa,M,W,ca,ma,ka,na,la,T,ga;E=B=v=o=0;j.matrixAutoUpdate&&j.update(void 0,!0);f.update(void 0,!1,j);G.multiply(j.projectionMatrix,j.matrixWorldInverse);D[0].set(G.n41-G.n11,G.n42-G.n12,G.n43-G.n13,G.n44-G.n14);D[1].set(G.n41+G.n11,G.n42+G.n12,G.n43+G.n13,G.n44+G.n14);D[2].set(G.n41+G.n21,G.n42+G.n22,G.n43+G.n23,G.n44+G.n24);D[3].set(G.n41-G.n21,G.n42-G.n22,G.n43-G.n23,G.n44-G.n24);D[4].set(G.n41-G.n31,G.n42-G.n32,G.n43-G.n33,G.n44-G.n34);D[5].set(G.n41+G.n31,G.n42+
  148. G.n32,G.n43+G.n33,G.n44+G.n34);for(k=0;k<6;k++)M=D[k],M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z));M=this.projectObjects(f,j,!0);f=0;for(k=M.length;f<k;f++)if(W=M[f].object,W.visible)if(ca=W.matrixWorld,ma=W.matrixRotationWorld,ka=W.materials,na=W.overdraw,m=0,W instanceof THREE.Mesh){la=W.geometry;$=la.vertices;T=la.faces;la=la.faceVertexUvs;K=0;for(X=$.length;K<X;K++)g=b(),g.positionWorld.copy($[K].position),ca.multiplyVector3(g.positionWorld),g.positionScreen.copy(g.positionWorld),G.multiplyVector4(g.positionScreen),
  149. g.positionScreen.x/=g.positionScreen.w,g.positionScreen.y/=g.positionScreen.w,g.visible=g.positionScreen.z>R&&g.positionScreen.z<P;$=0;for(K=T.length;$<K;$++){X=T[$];if(X instanceof THREE.Face3)if(Y=n[X.a],ha=n[X.b],ja=n[X.c],Y.visible&&ha.visible&&ja.visible&&(W.doubleSided||W.flipSided!=(ja.positionScreen.x-Y.positionScreen.x)*(ha.positionScreen.y-Y.positionScreen.y)-(ja.positionScreen.y-Y.positionScreen.y)*(ha.positionScreen.x-Y.positionScreen.x)<0))fa=t[o]=t[o]||new THREE.RenderableFace3,o++,
  150. p=fa,p.v1.copy(Y),p.v2.copy(ha),p.v3.copy(ja);else continue;else if(X instanceof THREE.Face4)if(Y=n[X.a],ha=n[X.b],ja=n[X.c],fa=n[X.d],Y.visible&&ha.visible&&ja.visible&&fa.visible&&(W.doubleSided||W.flipSided!=((fa.positionScreen.x-Y.positionScreen.x)*(ha.positionScreen.y-Y.positionScreen.y)-(fa.positionScreen.y-Y.positionScreen.y)*(ha.positionScreen.x-Y.positionScreen.x)<0||(ha.positionScreen.x-ja.positionScreen.x)*(fa.positionScreen.y-ja.positionScreen.y)-(ha.positionScreen.y-ja.positionScreen.y)*
  151. (fa.positionScreen.x-ja.positionScreen.x)<0)))ga=u[v]=u[v]||new THREE.RenderableFace4,v++,p=ga,p.v1.copy(Y),p.v2.copy(ha),p.v3.copy(ja),p.v4.copy(fa);else continue;p.normalWorld.copy(X.normal);ma.multiplyVector3(p.normalWorld);p.centroidWorld.copy(X.centroid);ca.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);G.multiplyVector3(p.centroidScreen);ja=X.vertexNormals;Y=0;for(ha=ja.length;Y<ha;Y++)fa=p.vertexNormalsWorld[Y],fa.copy(ja[Y]),ma.multiplyVector3(fa);Y=0;for(ha=la.length;Y<
  152. ha;Y++)if(ga=la[Y][$]){ja=0;for(fa=ga.length;ja<fa;ja++)p.uvs[Y][ja]=ga[ja]}p.meshMaterials=ka;p.faceMaterials=X.materials;p.overdraw=na;p.z=p.centroidScreen.z;J.push(p)}}else if(W instanceof THREE.Line){O.multiply(G,ca);$=W.geometry.vertices;Y=b();Y.positionScreen.copy($[0].position);O.multiplyVector4(Y.positionScreen);K=1;for(X=$.length;K<X;K++)if(Y=b(),Y.positionScreen.copy($[K].position),O.multiplyVector4(Y.positionScreen),ha=n[m-2],I.copy(Y.positionScreen),V.copy(ha.positionScreen),e(I,V))I.multiplyScalar(1/
  153. I.w),V.multiplyScalar(1/V.w),ca=x[B]=x[B]||new THREE.RenderableLine,B++,w=ca,w.v1.positionScreen.copy(I),w.v2.positionScreen.copy(V),w.z=Math.max(I.z,V.z),w.materials=W.materials,J.push(w)}else if(W instanceof THREE.Particle&&(C.set(W.matrixWorld.n14,W.matrixWorld.n24,W.matrixWorld.n34,1),G.multiplyVector4(C),C.z/=C.w,C.z>0&&C.z<1))ca=F[E]=F[E]||new THREE.RenderableParticle,E++,A=ca,A.x=C.x/C.w,A.y=C.y/C.w,A.z=C.z,A.rotation=W.rotation.z,A.scale.x=W.scale.x*Math.abs(A.x-(C.x+j.projectionMatrix.n11)/
  154. (C.w+j.projectionMatrix.n14)),A.scale.y=W.scale.y*Math.abs(A.y-(C.y+j.projectionMatrix.n22)/(C.w+j.projectionMatrix.n24)),A.materials=W.materials,J.push(A);h&&J.sort(c);return J}};
  155. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,h,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;h=e/2;j=f/2};this.render=function(e,f){var n,p,o,t,v,u,w,B;b=c.projectScene(e,f);n=0;for(p=b.length;n<p;n++)if(v=b[n],v instanceof THREE.RenderableParticle){w=v.x*h+h;B=v.y*j+j;o=0;for(t=v.material.length;o<t;o++)if(u=v.material[o],u instanceof THREE.ParticleDOMMaterial)u=u.domElement,u.style.left=w+"px",u.style.top=B+"px"}}};
  156. THREE.CanvasRenderer=function(b){function c(b){if(x!=b)u.globalAlpha=x=b}function e(b){if(A!=b){switch(b){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}A=b}}function f(b){if(E!=b)u.strokeStyle=E=b}function h(b){if(F!=b)u.fillStyle=F=b}var j=this,g=null,m=new THREE.Projector,b=b||{},n=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
  157. p,o,t,v,u=n.getContext("2d"),w=new THREE.Color(0),B=0,x=1,A=0,E=null,F=null,J=null,C=null,G=null,O,D,I,V,da=new THREE.RenderableVertex,S=new THREE.RenderableVertex,z,ea,R,P,k,K,X,$,Y,ha,ja,fa,M=new THREE.Color(0),W=new THREE.Color(0),ca=new THREE.Color(0),ma=new THREE.Color(0),ka=new THREE.Color(0),na=[],la,T,ga,ia,sa,xa,Aa,Ha,Ba,Oa,U=new THREE.Rectangle,pa=new THREE.Rectangle,qa=new THREE.Rectangle,ta=!1,ua=new THREE.Color,wa=new THREE.Color,Da=new THREE.Color,ya=new THREE.Color,ra=new THREE.Vector3,
  158. Ea,Z,Q,va,N,za,b=16;Ea=document.createElement("canvas");Ea.width=Ea.height=2;Z=Ea.getContext("2d");Z.fillStyle="rgba(0,0,0,1)";Z.fillRect(0,0,2,2);Q=Z.getImageData(0,0,2,2);va=Q.data;N=document.createElement("canvas");N.width=N.height=b;za=N.getContext("2d");za.translate(-b/2,-b/2);za.scale(b,b);b--;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(b,e){p=b;o=e;t=p/2;v=o/2;n.width=p;n.height=o;U.set(-t,-v,t,v);pa.set(-t,-v,
  159. t,v);x=1;A=0;G=C=J=F=E=null};this.setClearColor=function(b,e){w=b;B=e;pa.set(-t,-v,t,v)};this.setClearColorHex=function(b,e){w.setHex(b);B=e;pa.set(-t,-v,t,v)};this.clear=function(){u.setTransform(1,0,0,-1,t,v);pa.isEmpty()||(pa.inflate(1),pa.minSelf(U),B==0?u.clearRect(pa.getX(),pa.getY(),pa.getWidth(),pa.getHeight()):(e(THREE.NormalBlending),c(1),setContextFillStyle("rgba("+Math.floor(w.r*255)+","+Math.floor(w.g*255)+","+Math.floor(w.b*255)+","+B+")"),u.fillRect(pa.getX(),pa.getY(),pa.getWidth(),
  160. pa.getHeight())),pa.empty())};this.render=function(b,n){function p(b){var e,c,f,g=b.lights;wa.setRGB(0,0,0);Da.setRGB(0,0,0);ya.setRGB(0,0,0);b=0;for(e=g.length;b<e;b++)c=g[b],f=c.color,c instanceof THREE.AmbientLight?(wa.r+=f.r,wa.g+=f.g,wa.b+=f.b):c instanceof THREE.DirectionalLight?(Da.r+=f.r,Da.g+=f.g,Da.b+=f.b):c instanceof THREE.PointLight&&(ya.r+=f.r,ya.g+=f.g,ya.b+=f.b)}function o(b,e,c,f){var g,k,j,h,m=b.lights,b=0;for(g=m.length;b<g;b++)k=m[b],j=k.color,k instanceof THREE.DirectionalLight?
  161. (h=c.dot(k.position),h<=0||(h*=k.intensity,f.r+=j.r*h,f.g+=j.g*h,f.b+=j.b*h)):k instanceof THREE.PointLight&&(h=c.dot(ra.sub(k.position,e).normalize()),h<=0||(h*=k.distance==0?1:1-Math.min(e.distanceTo(k.position)/k.distance,1),h!=0&&(h*=k.intensity,f.r+=j.r*h,f.g+=j.g*h,f.b+=j.b*h)))}function Xa(b,g,k){c(k.opacity);e(k.blending);var j,m,n,p,aa,o;if(k instanceof THREE.ParticleBasicMaterial){if(k.map)p=k.map.image,aa=p.width>>1,o=p.height>>1,k=g.scale.x*t,n=g.scale.y*v,j=k*aa,m=n*o,qa.set(b.x-j,b.y-
  162. m,b.x+j,b.y+m),U.instersects(qa)&&(u.save(),u.translate(b.x,b.y),u.rotate(-g.rotation),u.scale(k,-n),u.translate(-aa,-o),u.drawImage(p,0,0),u.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(j=g.scale.x*t,m=g.scale.y*v,qa.set(b.x-j,b.y-m,b.x+j,b.y+m),U.instersects(qa)&&(f(k.color.getContextStyle()),h(k.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-g.rotation),u.scale(j,m),k.program(u),u.restore()))}function A(b,g,k,j){c(j.opacity);e(j.blending);u.beginPath();u.moveTo(b.positionScreen.x,
  163. b.positionScreen.y);u.lineTo(g.positionScreen.x,g.positionScreen.y);u.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(J!=b)u.lineWidth=J=b;b=j.linecap;if(C!=b)u.lineCap=C=b;b=j.linejoin;if(G!=b)u.lineJoin=G=b;f(j.color.getContextStyle());u.stroke();qa.inflate(j.linewidth*2)}}function w(b,f,g,h,m,p,aa,t,u){j.data.vertices+=3;j.data.faces++;c(t.opacity);e(t.blending);z=b.positionScreen.x;ea=b.positionScreen.y;R=f.positionScreen.x;P=f.positionScreen.y;k=g.positionScreen.x;K=g.positionScreen.y;
  164. x(z,ea,R,P,k,K);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(ia=aa.uvs[0],Va(z,ea,R,P,k,K,ia[h].u,ia[h].v,ia[m].u,ia[m].v,ia[p].u,ia[p].v,t.map));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=n.matrixWorldInverse,ra.copy(aa.vertexNormalsWorld[0]),sa=(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(aa.vertexNormalsWorld[1]),Aa=(ra.x*b.n11+ra.y*b.n12+ra.z*b.n13)*0.5+
  165. 0.5,Ha=-(ra.x*b.n21+ra.y*b.n22+ra.z*b.n23)*0.5+0.5,ra.copy(aa.vertexNormalsWorld[2]),Ba=(ra.x*b.n11+ra.y*b.n12+ra.z*b.n13)*0.5+0.5,Oa=-(ra.x*b.n21+ra.y*b.n22+ra.z*b.n23)*0.5+0.5,Va(z,ea,R,P,k,K,sa,xa,Aa,Ha,Ba,Oa,t.envMap)}else t.wireframe?Ia(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):E(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof THREE.UVMapping&&(ia=aa.uvs[0],Va(z,ea,R,P,k,K,ia[h].u,ia[h].v,ia[m].u,ia[m].v,ia[p].u,
  166. ia[p].v,t.map)),e(THREE.SubtractiveBlending)),ta?!t.wireframe&&t.shading==THREE.SmoothShading&&aa.vertexNormalsWorld.length==3?(W.r=ca.r=ma.r=wa.r,W.g=ca.g=ma.g=wa.g,W.b=ca.b=ma.b=wa.b,o(u,aa.v1.positionWorld,aa.vertexNormalsWorld[0],W),o(u,aa.v2.positionWorld,aa.vertexNormalsWorld[1],ca),o(u,aa.v3.positionWorld,aa.vertexNormalsWorld[2],ma),ka.r=(ca.r+ma.r)*0.5,ka.g=(ca.g+ma.g)*0.5,ka.b=(ca.b+ma.b)*0.5,ga=Sa(W,ca,ma,ka),Pa(z,ea,R,P,k,K,0,0,1,0,0,1,ga)):(ua.r=wa.r,ua.g=wa.g,ua.b=wa.b,o(u,aa.centroidWorld,
  167. aa.normalWorld,ua),M.r=Math.max(0,Math.min(t.color.r*ua.r,1)),M.g=Math.max(0,Math.min(t.color.g*ua.g,1)),M.b=Math.max(0,Math.min(t.color.b*ua.b,1)),t.wireframe?Ia(M,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):E(M)):t.wireframe?Ia(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):E(t.color);else if(t instanceof THREE.MeshDepthMaterial)la=n.near,T=n.far,W.r=W.g=W.b=1-Ma(b.positionScreen.z,la,T),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,la,T),ma.r=ma.g=ma.b=1-Ma(g.positionScreen.z,
  168. la,T),ka.r=(ca.r+ma.r)*0.5,ka.g=(ca.g+ma.g)*0.5,ka.b=(ca.b+ma.b)*0.5,ga=Sa(W,ca,ma,ka),Pa(z,ea,R,P,k,K,0,0,1,0,0,1,ga);else if(t instanceof THREE.MeshNormalMaterial)M.r=Qa(aa.normalWorld.x),M.g=Qa(aa.normalWorld.y),M.b=Qa(aa.normalWorld.z),t.wireframe?Ia(M,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):E(M)}function B(b,f,g,h,m,t,p,aa,u){j.data.vertices+=4;j.data.faces++;c(aa.opacity);e(aa.blending);if(aa.map||aa.envMap)w(b,f,h,0,1,3,p,aa,u),w(m,g,t,1,2,3,p,aa,u);else if(z=b.positionScreen.x,
  169. ea=b.positionScreen.y,R=f.positionScreen.x,P=f.positionScreen.y,k=g.positionScreen.x,K=g.positionScreen.y,X=h.positionScreen.x,$=h.positionScreen.y,Y=m.positionScreen.x,ha=m.positionScreen.y,ja=t.positionScreen.x,fa=t.positionScreen.y,aa instanceof THREE.MeshBasicMaterial)F(z,ea,R,P,k,K,X,$),aa.wireframe?Ia(aa.color,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):E(aa.color);else if(aa instanceof THREE.MeshLambertMaterial)ta?!aa.wireframe&&aa.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==
  170. 4?(W.r=ca.r=ma.r=ka.r=wa.r,W.g=ca.g=ma.g=ka.g=wa.g,W.b=ca.b=ma.b=ka.b=wa.b,o(u,p.v1.positionWorld,p.vertexNormalsWorld[0],W),o(u,p.v2.positionWorld,p.vertexNormalsWorld[1],ca),o(u,p.v4.positionWorld,p.vertexNormalsWorld[3],ma),o(u,p.v3.positionWorld,p.vertexNormalsWorld[2],ka),ga=Sa(W,ca,ma,ka),x(z,ea,R,P,X,$),Pa(z,ea,R,P,X,$,0,0,1,0,0,1,ga),x(Y,ha,k,K,ja,fa),Pa(Y,ha,k,K,ja,fa,1,0,1,1,0,1,ga)):(ua.r=wa.r,ua.g=wa.g,ua.b=wa.b,o(u,p.centroidWorld,p.normalWorld,ua),M.r=Math.max(0,Math.min(aa.color.r*
  171. ua.r,1)),M.g=Math.max(0,Math.min(aa.color.g*ua.g,1)),M.b=Math.max(0,Math.min(aa.color.b*ua.b,1)),F(z,ea,R,P,k,K,X,$),aa.wireframe?Ia(M,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):E(M)):(F(z,ea,R,P,k,K,X,$),aa.wireframe?Ia(aa.color,aa.wireframeLinewidth,aa.wireframeLinecap,aa.wireframeLinejoin):E(aa.color));else if(aa instanceof THREE.MeshNormalMaterial)M.r=Qa(p.normalWorld.x),M.g=Qa(p.normalWorld.y),M.b=Qa(p.normalWorld.z),F(z,ea,R,P,k,K,X,$),aa.wireframe?Ia(M,aa.wireframeLinewidth,
  172. aa.wireframeLinecap,aa.wireframeLinejoin):E(M);else if(aa instanceof THREE.MeshDepthMaterial)la=n.near,T=n.far,W.r=W.g=W.b=1-Ma(b.positionScreen.z,la,T),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,la,T),ma.r=ma.g=ma.b=1-Ma(h.positionScreen.z,la,T),ka.r=ka.g=ka.b=1-Ma(g.positionScreen.z,la,T),ga=Sa(W,ca,ma,ka),x(z,ea,R,P,X,$),Pa(z,ea,R,P,X,$,0,0,1,0,0,1,ga),x(Y,ha,k,K,ja,fa),Pa(Y,ha,k,K,ja,fa,1,0,1,1,0,1,ga)}function x(b,e,c,f,g,k){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(g,k);u.lineTo(b,e);u.closePath()}
  173. function F(b,e,c,f,g,k,j,h){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(g,k);u.lineTo(j,h);u.lineTo(b,e);u.closePath()}function Ia(b,e,c,g){if(J!=e)u.lineWidth=J=e;if(C!=c)u.lineCap=C=c;if(G!=g)u.lineJoin=G=g;f(b.getContextStyle());u.stroke();qa.inflate(e*2)}function E(b){h(b.getContextStyle());u.fill()}function Va(b,e,c,f,g,k,j,m,n,aa,p,t,o){if(o.image.width!=0){if(o.needsUpdate==!0||na[o.id]==void 0){var v=o.wrapS==THREE.RepeatWrapping,Ua=o.wrapT==THREE.RepeatWrapping;na[o.id]=u.createPattern(o.image,
  174. v&&Ua?"repeat":v&&!Ua?"repeat-x":!v&&Ua?"repeat-y":"no-repeat");o.needsUpdate=!1}h(na[o.id]);v=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;j*=v;m*=o;n*=v;aa*=o;p*=v;t*=o;c-=b;f-=e;g-=b;k-=e;n-=j;aa-=m;p-=j;t-=m;v=1/(n*t-p*aa);o=(t*c-aa*g)*v;aa=(t*f-aa*k)*v;c=(n*g-p*c)*v;f=(n*k-p*f)*v;b=b-o*j-c*m;e=e-aa*j-f*m;u.save();u.transform(o,aa,c,f,b,e);u.fill();u.restore()}}function Pa(b,e,c,f,g,k,j,h,m,n,aa,p,t){var o,v;o=t.width-1;v=t.height-1;j*=o;h*=v;m*=o;n*=v;aa*=o;p*=v;c-=b;f-=e;g-=
  175. b;k-=e;m-=j;n-=h;aa-=j;p-=h;v=1/(m*p-aa*n);o=(p*c-n*g)*v;n=(p*f-n*k)*v;c=(m*g-aa*c)*v;f=(m*k-aa*f)*v;b=b-o*j-c*h;e=e-n*j-f*h;u.save();u.transform(o,n,c,f,b,e);u.clip();u.drawImage(t,0,0);u.restore()}function Sa(b,e,c,f){var g=~~(b.r*255),k=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),h=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),aa=~~(f.r*255),p=~~(f.g*255),f=~~(f.b*255);va[0]=g<0?0:g>255?255:g;va[1]=k<0?0:k>255?255:k;va[2]=b<0?0:b>255?255:b;va[4]=j<0?0:j>255?255:j;va[5]=h<0?0:
  176. h>255?255:h;va[6]=e<0?0:e>255?255:e;va[8]=m<0?0:m>255?255:m;va[9]=n<0?0:n>255?255:n;va[10]=c<0?0:c>255?255:c;va[12]=aa<0?0:aa>255?255:aa;va[13]=p<0?0:p>255?255:p;va[14]=f<0?0:f>255?255:f;Z.putImageData(Q,0,0);za.drawImage(Ea,0,0);return N}function Ma(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Qa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ja(b,e){var c=e.x-b.x,f=e.y-b.y,g=c*c+f*f;g!=0&&(g=1/Math.sqrt(g),c*=g,f*=g,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ta,Wa,oa,Ca,Ka,Ra,H,y;this.autoClear?this.clear():
  177. u.setTransform(1,0,0,-1,t,v);j.data.vertices=0;j.data.faces=0;g=m.projectScene(b,n,this.sortElements);(ta=b.lights.length>0)&&p(b);Ta=0;for(Wa=g.length;Ta<Wa;Ta++){oa=g[Ta];qa.empty();if(oa instanceof THREE.RenderableParticle){O=oa;O.x*=t;O.y*=v;Ca=0;for(Ka=oa.materials.length;Ca<Ka;)y=oa.materials[Ca++],y.opacity!=0&&Xa(O,oa,y,b)}else if(oa instanceof THREE.RenderableLine){if(O=oa.v1,D=oa.v2,O.positionScreen.x*=t,O.positionScreen.y*=v,D.positionScreen.x*=t,D.positionScreen.y*=v,qa.addPoint(O.positionScreen.x,
  178. O.positionScreen.y),qa.addPoint(D.positionScreen.x,D.positionScreen.y),U.instersects(qa)){Ca=0;for(Ka=oa.materials.length;Ca<Ka;)y=oa.materials[Ca++],y.opacity!=0&&A(O,D,oa,y,b)}}else if(oa instanceof THREE.RenderableFace3){if(O=oa.v1,D=oa.v2,I=oa.v3,O.positionScreen.x*=t,O.positionScreen.y*=v,D.positionScreen.x*=t,D.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,oa.overdraw&&(Ja(O.positionScreen,D.positionScreen),Ja(D.positionScreen,I.positionScreen),Ja(I.positionScreen,O.positionScreen)),
  179. qa.add3Points(O.positionScreen.x,O.positionScreen.y,D.positionScreen.x,D.positionScreen.y,I.positionScreen.x,I.positionScreen.y),U.instersects(qa)){Ca=0;for(Ka=oa.meshMaterials.length;Ca<Ka;)if(y=oa.meshMaterials[Ca++],y instanceof THREE.MeshFaceMaterial){Ra=0;for(H=oa.faceMaterials.length;Ra<H;)(y=oa.faceMaterials[Ra++])&&y.opacity!=0&&w(O,D,I,0,1,2,oa,y,b)}else y.opacity!=0&&w(O,D,I,0,1,2,oa,y,b)}}else if(oa instanceof THREE.RenderableFace4&&(O=oa.v1,D=oa.v2,I=oa.v3,V=oa.v4,O.positionScreen.x*=
  180. t,O.positionScreen.y*=v,D.positionScreen.x*=t,D.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,V.positionScreen.x*=t,V.positionScreen.y*=v,da.positionScreen.copy(D.positionScreen),S.positionScreen.copy(V.positionScreen),oa.overdraw&&(Ja(O.positionScreen,D.positionScreen),Ja(D.positionScreen,V.positionScreen),Ja(V.positionScreen,O.positionScreen),Ja(I.positionScreen,da.positionScreen),Ja(I.positionScreen,S.positionScreen)),qa.addPoint(O.positionScreen.x,O.positionScreen.y),qa.addPoint(D.positionScreen.x,
  181. D.positionScreen.y),qa.addPoint(I.positionScreen.x,I.positionScreen.y),qa.addPoint(V.positionScreen.x,V.positionScreen.y),U.instersects(qa))){Ca=0;for(Ka=oa.meshMaterials.length;Ca<Ka;)if(y=oa.meshMaterials[Ca++],y instanceof THREE.MeshFaceMaterial){Ra=0;for(H=oa.faceMaterials.length;Ra<H;)(y=oa.faceMaterials[Ra++])&&y.opacity!=0&&B(O,D,I,V,da,S,oa,y,b)}else y.opacity!=0&&B(O,D,I,V,da,S,oa,y,b)}pa.addRectangle(qa)}u.setTransform(1,0,0,1,0,0)}};
  182. THREE.SVGRenderer=function(){function b(b,e,c){var f,g,j,h;f=0;for(g=b.lights.length;f<g;f++)j=b.lights[f],j instanceof THREE.DirectionalLight?(h=e.normalWorld.dot(j.position)*j.intensity,h>0&&(c.r+=j.color.r*h,c.g+=j.color.g*h,c.b+=j.color.b*h)):j instanceof THREE.PointLight&&(V.sub(j.position,e.centroidWorld),V.normalize(),h=e.normalWorld.dot(V)*j.intensity,h>0&&(c.r+=j.color.r*h,c.g+=j.color.g*h,c.b+=j.color.b*h))}function c(e,c,g,m,p,t){j.data.vertices+=3;j.data.faces++;z=f(ea++);z.setAttribute("d",
  183. "M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+g.positionScreen.x+","+g.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?J.copy(p.color):p instanceof THREE.MeshLambertMaterial?F?(C.r=G.r,C.g=G.g,C.b=G.b,b(t,m,C),J.r=Math.max(0,Math.min(p.color.r*C.r,1)),J.g=Math.max(0,Math.min(p.color.g*C.g,1)),J.b=Math.max(0,Math.min(p.color.b*C.b,1))):J.copy(p.color):p instanceof THREE.MeshDepthMaterial?(I=1-p.__2near/(p.__farPlusNear-m.z*p.__farMinusNear),
  184. J.setRGB(I,I,I)):p instanceof THREE.MeshNormalMaterial&&J.setRGB(h(m.normalWorld.x),h(m.normalWorld.y),h(m.normalWorld.z));p.wireframe?z.setAttribute("style","fill: none; stroke: "+J.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):z.setAttribute("style","fill: "+J.getContextStyle()+"; fill-opacity: "+p.opacity);n.appendChild(z)}function e(e,c,g,m,p,t,o){j.data.vertices+=4;j.data.faces++;
  185. z=f(ea++);z.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+g.positionScreen.x+","+g.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?J.copy(t.color):t instanceof THREE.MeshLambertMaterial?F?(C.r=G.r,C.g=G.g,C.b=G.b,b(o,p,C),J.r=Math.max(0,Math.min(t.color.r*C.r,1)),J.g=Math.max(0,Math.min(t.color.g*C.g,1)),J.b=Math.max(0,Math.min(t.color.b*C.b,1))):J.copy(t.color):t instanceof
  186. THREE.MeshDepthMaterial?(I=1-t.__2near/(t.__farPlusNear-p.z*t.__farMinusNear),J.setRGB(I,I,I)):t instanceof THREE.MeshNormalMaterial&&J.setRGB(h(p.normalWorld.x),h(p.normalWorld.y),h(p.normalWorld.z));t.wireframe?z.setAttribute("style","fill: none; stroke: "+J.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):z.setAttribute("style","fill: "+J.getContextStyle()+"; fill-opacity: "+
  187. t.opacity);n.appendChild(z)}function f(b){da[b]==null&&(da[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),P==0&&da[b].setAttribute("shape-rendering","crispEdges"));return da[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var j=this,g=null,m=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,o,t,v,u,w,B,x,A=new THREE.Rectangle,E=new THREE.Rectangle,F=!1,J=new THREE.Color(16777215),C=new THREE.Color(16777215),G=new THREE.Color(0),O=new THREE.Color(0),
  188. D=new THREE.Color(0),I,V=new THREE.Vector3,da=[],S=[],z,ea,R,P=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":P=1;break;case "low":P=0}};this.setSize=function(b,e){p=b;o=e;t=p/2;v=o/2;n.setAttribute("viewBox",-t+" "+-v+" "+p+" "+o);n.setAttribute("width",p);n.setAttribute("height",o);A.set(-t,-v,t,v)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=
  189. function(b,f){var h,p,o,J,C,I,M,W;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;g=m.projectScene(b,f,this.sortElements);R=ea=0;if(F=b.lights.length>0){M=b.lights;G.setRGB(0,0,0);O.setRGB(0,0,0);D.setRGB(0,0,0);h=0;for(p=M.length;h<p;h++)o=M[h],J=o.color,o instanceof THREE.AmbientLight?(G.r+=J.r,G.g+=J.g,G.b+=J.b):o instanceof THREE.DirectionalLight?(O.r+=J.r,O.g+=J.g,O.b+=J.b):o instanceof THREE.PointLight&&(D.r+=J.r,D.g+=J.g,D.b+=J.b)}h=0;for(p=g.length;h<p;h++)if(M=g[h],E.empty(),
  190. M instanceof THREE.RenderableParticle){u=M;u.x*=t;u.y*=-v;o=0;for(J=M.materials.length;o<J;)o++}else if(M instanceof THREE.RenderableLine){if(u=M.v1,w=M.v2,u.positionScreen.x*=t,u.positionScreen.y*=-v,w.positionScreen.x*=t,w.positionScreen.y*=-v,E.addPoint(u.positionScreen.x,u.positionScreen.y),E.addPoint(w.positionScreen.x,w.positionScreen.y),A.instersects(E)){o=0;for(J=M.materials.length;o<J;)if((W=M.materials[o++])&&W.opacity!=0){C=u;I=w;var V=R++;S[V]==null&&(S[V]=document.createElementNS("http://www.w3.org/2000/svg",
  191. "line"),P==0&&S[V].setAttribute("shape-rendering","crispEdges"));z=S[V];z.setAttribute("x1",C.positionScreen.x);z.setAttribute("y1",C.positionScreen.y);z.setAttribute("x2",I.positionScreen.x);z.setAttribute("y2",I.positionScreen.y);W instanceof THREE.LineBasicMaterial&&(z.setAttribute("style","fill: none; stroke: "+W.color.getContextStyle()+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin),n.appendChild(z))}}}else if(M instanceof
  192. THREE.RenderableFace3){if(u=M.v1,w=M.v2,B=M.v3,u.positionScreen.x*=t,u.positionScreen.y*=-v,w.positionScreen.x*=t,w.positionScreen.y*=-v,B.positionScreen.x*=t,B.positionScreen.y*=-v,E.addPoint(u.positionScreen.x,u.positionScreen.y),E.addPoint(w.positionScreen.x,w.positionScreen.y),E.addPoint(B.positionScreen.x,B.positionScreen.y),A.instersects(E)){o=0;for(J=M.meshMaterials.length;o<J;)if(W=M.meshMaterials[o++],W instanceof THREE.MeshFaceMaterial){C=0;for(I=M.faceMaterials.length;C<I;)(W=M.faceMaterials[C++])&&
  193. W.opacity!=0&&c(u,w,B,M,W,b)}else W&&W.opacity!=0&&c(u,w,B,M,W,b)}}else if(M instanceof THREE.RenderableFace4&&(u=M.v1,w=M.v2,B=M.v3,x=M.v4,u.positionScreen.x*=t,u.positionScreen.y*=-v,w.positionScreen.x*=t,w.positionScreen.y*=-v,B.positionScreen.x*=t,B.positionScreen.y*=-v,x.positionScreen.x*=t,x.positionScreen.y*=-v,E.addPoint(u.positionScreen.x,u.positionScreen.y),E.addPoint(w.positionScreen.x,w.positionScreen.y),E.addPoint(B.positionScreen.x,B.positionScreen.y),E.addPoint(x.positionScreen.x,x.positionScreen.y),
  194. A.instersects(E))){o=0;for(J=M.meshMaterials.length;o<J;)if(W=M.meshMaterials[o++],W instanceof THREE.MeshFaceMaterial){C=0;for(I=M.faceMaterials.length;C<I;)(W=M.faceMaterials[C++])&&W.opacity!=0&&e(u,w,B,x,M,W,b)}else W&&W.opacity!=0&&e(u,w,B,x,M,W,b)}}};
  195. 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",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
  196. 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",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",
  197. map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",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",
  198. lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",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",
  199. 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}",
  200. 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( vec3( 0.0 ), 1.0 );\nvec4 pointSpecular = vec4( vec3( 0.0 ), 1.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( vec3( 0.0 ), 1.0 );\nvec4 dirSpecular = vec4( vec3( 0.0 ), 1.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;",
  201. 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",
  202. 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",
  203. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",
  204. shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec4 shadowColor = vec4( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec4( vec3( ( 1.0 - shadowDarkness * shadow ) ), 1.0 );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < ( shadowCoord.z + shadowBias ) )\nshadowColor = shadowColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif\n}\n}\ngl_FragColor = gl_FragColor * shadowColor;\n#endif",
  205. shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif"};
  206. THREE.UniformsUtils={merge:function(b){var c,e,f,h={};for(c=0;c<b.length;c++)for(e in f=this.clone(b[c]),f)h[e]=f[e];return h},clone:function(b){var c,e,f,h={};for(c in b)for(e in h[c]={},b[c])f=b[c][e],h[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector2||f instanceof THREE.Vector3||f instanceof THREE.Vector4||f instanceof THREE.Matrix4||f instanceof THREE.Texture?f.clone():f instanceof Array?f.slice():f;return h}};
  207. 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",
  208. 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",
  209. 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)}},shadowmap:{shadowMap:{type:"tv",value:3,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
  210. 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}"},
  211. 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}"},
  212. 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}",
  213. 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}"},
  214. 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}",
  215. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0 );\n}"},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}"},
  216. normal:{uniforms:{opacity:{type:"f",value:1}},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,THREE.UniformsLib.shadowmap]),
  217. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",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.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,
  218. THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  219. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
  220. THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"gl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,
  221. "}"].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,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  222. 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,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},
  223. specular:{type:"c",value:new THREE.Color(1118481)},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,THREE.ShaderChunk.shadowmap_pars_fragment,
  224. "void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_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,
  225. 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,THREE.ShaderChunk.shadowmap_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;",
  226. THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
  227. "void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_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;",
  228. THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},depthRGBA:{uniforms:{},fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}",vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,
  229. "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}};
  230. THREE.WebGLRenderer=function(b){function c(b,e,c){var f,g,j,h=b.vertices,m=h.length,p=b.colors,n=p.length,t=b.__vertexArray,o=b.__colorArray,u=b.__sortArray,v=b.__dirtyVertices,w=b.__dirtyColors,A=b.__webglCustomAttributes,B,x;if(A)for(B in A)A[B].offset=0;if(c.sortParticles){ia.multiplySelf(c.matrixWorld);for(f=0;f<m;f++)g=h[f].position,Aa.copy(g),ia.multiplyVector3(Aa),u[f]=[Aa.z,f];u.sort(function(b,e){return e[0]-b[0]});for(f=0;f<m;f++)g=h[u[f][1]].position,j=f*3,t[j]=g.x,t[j+1]=g.y,t[j+2]=g.z;
  231. for(f=0;f<n;f++)j=f*3,color=p[u[f][1]],o[j]=color.r,o[j+1]=color.g,o[j+2]=color.b;if(A)for(B in A){f=A[B];p=f.value.length;for(j=0;j<p;j++){index=u[j][1];n=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[n]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")x=f.value[index];f.size===2?(f.array[n]=x.x,f.array[n+1]=x.y):f.size===3?f.type==="c"?(f.array[n]=x.r,f.array[n+1]=x.g,f.array[n+2]=x.b):(f.array[n]=x.x,f.array[n+1]=x.y,f.array[n+2]=x.z):(f.array[n]=
  232. x.x,f.array[n+1]=x.y,f.array[n+2]=x.z,f.array[n+3]=x.w)}f.offset+=f.size}}}else{if(v)for(f=0;f<m;f++)g=h[f].position,j=f*3,t[j]=g.x,t[j+1]=g.y,t[j+2]=g.z;if(w)for(f=0;f<n;f++)color=p[f],j=f*3,o[j]=color.r,o[j+1]=color.g,o[j+2]=color.b;if(A)for(B in A)if(f=A[B],f.__original.needsUpdate){p=f.value.length;for(j=0;j<p;j++){n=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[n]=f.value[j]}else{if(f.boundTo===void 0||f.boundTo==="vertices")x=f.value[j];f.size===2?(f.array[n]=
  233. x.x,f.array[n+1]=x.y):f.size===3?f.type==="c"?(f.array[n]=x.r,f.array[n+1]=x.g,f.array[n+2]=x.b):(f.array[n]=x.x,f.array[n+1]=x.y,f.array[n+2]=x.z):(f.array[n]=x.x,f.array[n+1]=x.y,f.array[n+2]=x.z,f.array[n+3]=x.w)}f.offset+=f.size}}}if(v||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,t,e);if(w||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,b.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,o,e);if(A)for(B in A)if(f=A[B],f.__original.needsUpdate||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,
  234. f.buffer),k.bufferData(k.ARRAY_BUFFER,f.array,e)}function e(b,e,c,f,g){f.program||P.initMaterial(f,e,c,g);if(f.morphTargets&&!g.__webglMorphTargetInfluences){g.__webglMorphTargetInfluences=new Float32Array(P.maxMorphTargets);for(var j=0,h=P.maxMorphTargets;j<h;j++)g.__webglMorphTargetInfluences[j]=0}var j=f.program,h=j.uniforms,m=f.uniforms;j!=X&&(k.useProgram(j),X=j);k.uniformMatrix4fv(h.projectionMatrix,!1,sa);if(c&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||
  235. 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,p,t,o=0,u=0,v=0,A,w,x,B=Ha,E=B.directional.colors,F=B.directional.positions,D=B.point.colors,J=B.point.positions,C=B.point.distances,
  236. la=0,H=0,c=p=x=0;for(n=e.length;c<n;c++)if(p=e[c],t=p.color,A=p.position,w=p.intensity,x=p.distance,p instanceof THREE.AmbientLight)o+=t.r,u+=t.g,v+=t.b;else if(p instanceof THREE.DirectionalLight)x=la*3,E[x]=t.r*w,E[x+1]=t.g*w,E[x+2]=t.b*w,F[x]=A.x,F[x+1]=A.y,F[x+2]=A.z,la+=1;else if(p instanceof THREE.SpotLight)x=la*3,E[x]=t.r*w,E[x+1]=t.g*w,E[x+2]=t.b*w,t=1/A.length(),F[x]=A.x*t,F[x+1]=A.y*t,F[x+2]=A.z*t,la+=1;else if(p instanceof THREE.PointLight)p=H*3,D[p]=t.r*w,D[p+1]=t.g*w,D[p+2]=t.b*w,J[p]=
  237. A.x,J[p+1]=A.y,J[p+2]=A.z,C[H]=x,H+=1;for(c=la*3;c<E.length;c++)E[c]=0;for(c=H*3;c<D.length;c++)D[c]=0;B.point.length=H;B.directional.length=la;B.ambient[0]=o;B.ambient[1]=u;B.ambient[2]=v;c=Ha;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=
  238. c.point.distances}if(f instanceof 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
  239. THREE.CubeRefractionMapping;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=Ba.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=
  240. f.opacity;else if(f instanceof THREE.MeshNormalMaterial)m.opacity.value=f.opacity;if(g.receiveShadow&&!f._shadowPass&&m.shadowMatrix){for(c=0;c<ua.length;c++)m.shadowMatrix.value[c]=ua[c],m.shadowMap.texture[c]=P.shadowMap[c];m.shadowDarkness.value=P.shadowMapDarkness;m.shadowBias.value=P.shadowMapBias}for(var y in m)if(o=j.uniforms[y])if(n=m[y],u=n.type,c=n.value,u=="i")k.uniform1i(o,c);else if(u=="f")k.uniform1f(o,c);else if(u=="fv1")k.uniform1fv(o,c);else if(u=="fv")k.uniform3fv(o,c);else if(u==
  241. "v2")k.uniform2f(o,c.x,c.y);else if(u=="v3")k.uniform3f(o,c.x,c.y,c.z);else if(u=="v4")k.uniform4f(o,c.x,c.y,c.z,c.w);else if(u=="m4"){if(!n._array)n._array=new Float32Array(16);c.flattenToArray(n._array);k.uniformMatrix4fv(o,!1,n._array)}else if(u=="m4v"){if(!n._array)n._array=new Float32Array(16*c.length);u=0;for(v=c.length;u<v;u++)c[u].flattenToArrayOffset(n._array,u*16);k.uniformMatrix4fv(o,!1,n._array)}else if(u=="c")k.uniform3f(o,c.r,c.g,c.b);else if(u=="t"){if(k.uniform1i(o,c),o=n.texture)if(o.image instanceof
  242. Array&&o.image.length==6){if(n=o,n.image.length==6){if(n.needsUpdate){if(n.__webglInit){k.bindTexture(k.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(o=0;o<6;++o)k.texSubImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,0,0,k.RGBA,k.UNSIGNED_BYTE,n.image[o])}else{n.image.__webglTextureCube=k.createTexture();k.bindTexture(k.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(o=0;o<6;++o)k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,n.image[o]);n.__webglInit=!0}V(k.TEXTURE_CUBE_MAP,
  243. n,n.image[0]);k.bindTexture(k.TEXTURE_CUBE_MAP,null);n.needsUpdate=!1}k.activeTexture(k.TEXTURE0+c);k.bindTexture(k.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}}else da(o,c)}else if(u=="tv"){if(!n._array){n._array=[];u=0;for(v=n.texture.length;u<v;u++)n._array[u]=c+u}k.uniform1iv(o,n._array);u=0;for(v=n.texture.length;u<v;u++)(o=n.texture[u])&&da(o,n._array[u])}k.uniformMatrix4fv(h.modelViewMatrix,!1,g._modelViewMatrixArray);k.uniformMatrix3fv(h.normalMatrix,!1,g._normalMatrixArray);(f instanceof
  244. THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&h.cameraPosition!==null&&k.uniform3f(h.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||g.receiveShadow)&&h.objectMatrix!==null&&k.uniformMatrix4fv(h.objectMatrix,!1,g._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&h.viewMatrix!==null&&k.uniformMatrix4fv(h.viewMatrix,
  245. !1,xa);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,k.uniform3fv(h.directionalLightDirection,b),k.uniformMatrix4fv(h.objectMatrix,!1,g._objectMatrixArray),k.uniformMatrix4fv(h.viewMatrix,!1,xa);f.skinning&&(k.uniformMatrix4fv(h.cameraInverseMatrix,!1,xa),k.uniformMatrix4fv(h.boneGlobalMatrices,!1,g.boneMatrices));return j}function f(b,c,f,g,j,h){if(g.opacity!=0){var m,b=e(b,c,f,g,h).attributes;
  246. if(!g.morphTargets&&b.position>=0)k.bindBuffer(k.ARRAY_BUFFER,j.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0);else if(h.morphTargetBase){c=g.program.attributes;h.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[h.morphTargetBase]),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,j.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length)for(var f=
  247. 0,n=h.morphTargetForcedOrder,p=h.morphTargetInfluences;f<g.numSupportedMorphTargets&&f<n.length;)k.bindBuffer(k.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[n[f]]),k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0),h.__webglMorphTargetInfluences[f]=p[n[f]],f++;else{var n=[],t=-1,o=0,p=h.morphTargetInfluences,u,v=p.length,f=0;for(h.morphTargetBase!==-1&&(n[h.morphTargetBase]=!0);f<g.numSupportedMorphTargets;){for(u=0;u<v;u++)!n[u]&&p[u]>t&&(o=u,t=p[o]);k.bindBuffer(k.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[o]);
  248. k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0);h.__webglMorphTargetInfluences[f]=t;n[o]=1;t=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(g.program.uniforms.morphTargetInfluences,h.__webglMorphTargetInfluences)}if(j.__webglCustomAttributes)for(m in j.__webglCustomAttributes)b[m]>=0&&(c=j.__webglCustomAttributes[m],k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[m],c.size,k.FLOAT,!1,0,0));b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,j.__webglColorBuffer),
  249. k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER,j.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER,j.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(j.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,j.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));b.uv2>=0&&(j.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,
  250. j.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,j.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,j.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,j.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,
  251. 4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,j.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0));h instanceof THREE.Mesh?(g.wireframe?(k.lineWidth(g.wireframeLinewidth),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,j.__webglLineBuffer),k.drawElements(k.LINES,j.__webglLineCount,k.UNSIGNED_SHORT,0)):(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,j.__webglFaceBuffer),k.drawElements(k.TRIANGLES,j.__webglFaceCount,k.UNSIGNED_SHORT,0)),P.data.vertices+=j.__webglFaceCount,P.data.faces+=j.__webglFaceCount/
  252. 3,P.data.drawCalls++):h instanceof THREE.Line?(h=h.type==THREE.LineStrip?k.LINE_STRIP:k.LINES,k.lineWidth(g.linewidth),k.drawArrays(h,0,j.__webglLineCount),P.data.drawCalls++):h instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,j.__webglParticleCount),P.data.drawCalls++):h instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,j.__webglVertexCount),P.data.drawCalls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=k.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=
  253. k.createBuffer();b.hasPos&&(k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,b.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(e.attributes.position),k.vertexAttribPointer(e.attributes.position,3,k.FLOAT,!1,0,0));if(b.hasNormal){k.bindBuffer(k.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,j,g,h,m,n,p,t,o,u,v=b.count*3;for(u=0;u<v;u+=9)c=b.normalArray,f=c[u],j=c[u+1],g=c[u+2],h=c[u+3],n=c[u+4],t=c[u+5],m=c[u+6],p=c[u+7],o=c[u+8],f=(f+h+m)/
  254. 3,j=(j+n+p)/3,g=(g+t+o)/3,c[u]=f,c[u+1]=j,c[u+2]=g,c[u+3]=f,c[u+4]=j,c[u+5]=g,c[u+6]=f,c[u+7]=j,c[u+8]=g}k.bufferData(k.ARRAY_BUFFER,b.normalArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(e.attributes.normal);k.vertexAttribPointer(e.attributes.normal,3,k.FLOAT,!1,0,0)}k.drawArrays(k.TRIANGLES,0,b.count);b.count=0}function j(b){if(ha!=b.doubleSided)b.doubleSided?k.disable(k.CULL_FACE):k.enable(k.CULL_FACE),ha=b.doubleSided;if(ja!=b.flipSided)b.flipSided?k.frontFace(k.CW):k.frontFace(k.CCW),ja=b.flipSided}
  255. function g(b){M!=b&&(b?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST),M=b)}function m(b,e,c){W!=b&&(b?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL),W=b);if(b&&(ca!=e||ma!=c))k.polygonOffset(e,c),ca=e,ma=c}function n(b){ga[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);ga[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);ga[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);ga[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);ga[4].set(b.n41-b.n31,b.n42-
  256. b.n32,b.n43-b.n33,b.n44-b.n34);ga[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=ga[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,b.scale.z)),f=0;f<6;f++)if(b=ga[f].x*e.n14+ga[f].y*e.n24+ga[f].z*e.n34+ga[f].w,b<=c)return!1;return!0}function o(b,e){b.list[b.count]=e;b.count+=1}function t(b){var e,c,f=b.object,j=b.opaque,g=b.transparent;g.count=0;b=
  257. j.count=0;for(e=f.materials.length;b<e;b++)c=f.materials[b],c.transparent?o(g,c):o(j,c)}function v(b){var e,c,f,j,g=b.object,h=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=h.materials.length;e<c;e++)(j=h.materials[e])&&(j.transparent?o(m,j):o(k,j))}else(j=e)&&(j.transparent?o(m,j):o(k,j))}function u(b,e){return e.z-b.z}function w(b,c){var m,t,o,u=0,v,A,w,x,B=b.lights;ta||(ta=new THREE.Camera(P.shadowCameraFov,
  258. c.aspect,P.shadowCameraNear,P.shadowCameraFar));m=0;for(t=B.length;m<t;m++)if(o=B[m],o instanceof THREE.SpotLight&&o.castShadow){P.shadowMap[u]||(P.shadowMap[u]=new THREE.WebGLRenderTarget(P.shadowMapWidth,P.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ua[u]||(ua[u]=new THREE.Matrix4);v=P.shadowMap[u];A=ua[u];ta.position.copy(o.position);ta.target.position.copy(o.target.position);ta.update(void 0,!0);b.update(void 0,!1,ta);A.set(0.5,0,0,0.5,
  259. 0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);A.multiplySelf(ta.projectionMatrix);A.multiplySelf(ta.matrixWorldInverse);ta.matrixWorldInverse.flattenToArray(xa);ta.projectionMatrix.flattenToArray(sa);ia.multiply(ta.projectionMatrix,ta.matrixWorldInverse);n(ia);P.initWebGLObjects(b);S(v);k.clearColor(1,1,1,1);P.clear();k.clearColor(pa.r,pa.g,pa.b,qa);A=b.__webglObjects.length;o=b.__webglObjectsImmediate.length;for(v=0;v<A;v++)w=b.__webglObjects[v],x=w.object,x.visible&&x.castShadow?!(x instanceof THREE.Mesh)||
  260. p(x)?(x.matrixWorld.flattenToArray(x._objectMatrixArray),E(x,ta,!1),w.render=!0):w.render=!1:w.render=!1;g(!0);I(THREE.NormalBlending);for(v=0;v<A;v++)if(w=b.__webglObjects[v],w.render)x=w.object,buffer=w.buffer,j(x),w=x.customDepthMaterial?x.customDepthMaterial:x.geometry.morphTargets.length?ya:Da,f(ta,B,null,w,buffer,x);for(v=0;v<o;v++)w=b.__webglObjectsImmediate[v],x=w.object,x.visible&&x.castShadow&&(x.matrixAutoUpdate&&x.matrixWorld.flattenToArray(x._objectMatrixArray),E(x,ta,!1),j(x),program=
  261. e(ta,B,null,Da,x),x.render(function(b){h(b,program,Da.shading)}));u++}}function B(b){k.enable(k.POLYGON_OFFSET_FILL);k.polygonOffset(0.1,1);k.enable(k.STENCIL_TEST);k.enable(k.DEPTH_TEST);k.depthMask(!1);k.colorMask(!1,!1,!1,!1);k.stencilFunc(k.ALWAYS,1,255);k.stencilOpSeparate(k.BACK,k.KEEP,k.INCR,k.KEEP);k.stencilOpSeparate(k.FRONT,k.KEEP,k.DECR,k.KEEP);var e,c=b.lights.length,f,j=b.lights,g=[],h,m,n,p,t,o=b.__webglShadowVolumes.length;for(e=0;e<c;e++)if(f=b.lights[e],f instanceof THREE.DirectionalLight&&
  262. f.castShadow){g[0]=-f.position.x;g[1]=-f.position.y;g[2]=-f.position.z;for(t=0;t<o;t++)f=b.__webglShadowVolumes[t].object,h=b.__webglShadowVolumes[t].buffer,m=f.materials[0],m.program||P.initMaterial(m,j,void 0,f),m=m.program,n=m.uniforms,p=m.attributes,X!==m&&(k.useProgram(m),X=m,k.uniformMatrix4fv(n.projectionMatrix,!1,sa),k.uniformMatrix4fv(n.viewMatrix,!1,xa),k.uniform3fv(n.directionalLightDirection,g)),f.matrixWorld.flattenToArray(f._objectMatrixArray),k.uniformMatrix4fv(n.objectMatrix,!1,f._objectMatrixArray),
  263. k.bindBuffer(k.ARRAY_BUFFER,h.__webglVertexBuffer),k.vertexAttribPointer(p.position,3,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglNormalBuffer),k.vertexAttribPointer(p.normal,3,k.FLOAT,!1,0,0),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),k.cullFace(k.FRONT),k.drawElements(k.TRIANGLES,h.__webglFaceCount,k.UNSIGNED_SHORT,0),k.cullFace(k.BACK),k.drawElements(k.TRIANGLES,h.__webglFaceCount,k.UNSIGNED_SHORT,0)}k.disable(k.POLYGON_OFFSET_FILL);k.colorMask(!0,!0,!0,!0);k.stencilFunc(k.NOTEQUAL,
  264. 0,255);k.stencilOp(k.KEEP,k.KEEP,k.KEEP);k.disable(k.DEPTH_TEST);M=fa=-1;X=Z.program;k.useProgram(Z.program);k.uniformMatrix4fv(Z.projectionLocation,!1,sa);k.uniform1f(Z.darknessLocation,Z.darkness);k.bindBuffer(k.ARRAY_BUFFER,Z.vertexBuffer);k.vertexAttribPointer(Z.vertexLocation,3,k.FLOAT,!1,0,0);k.enableVertexAttribArray(Z.vertexLocation);k.blendFunc(k.ONE,k.ONE_MINUS_SRC_ALPHA);k.blendEquation(k.FUNC_ADD);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,
  265. 0);k.disable(k.STENCIL_TEST);k.enable(k.DEPTH_TEST);k.depthMask(Y)}function x(b,e){var c,f,j;c=N.attributes;var g=N.uniforms,h=T/la,m,n=[],p=la*0.5,t=T*0.5,o=!0;k.useProgram(N.program);X=N.program;M=fa=-1;za||(k.enableVertexAttribArray(N.attributes.position),k.enableVertexAttribArray(N.attributes.uv),za=!0);k.disable(k.CULL_FACE);k.enable(k.BLEND);k.depthMask(!0);k.bindBuffer(k.ARRAY_BUFFER,N.vertexBuffer);k.vertexAttribPointer(c.position,2,k.FLOAT,!1,16,0);k.vertexAttribPointer(c.uv,2,k.FLOAT,!1,
  266. 16,8);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,N.elementBuffer);k.uniformMatrix4fv(g.projectionMatrix,!1,sa);k.activeTexture(k.TEXTURE0);k.uniform1i(g.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)j=b.__webglSprites[c],j.useScreenCoordinates?j.z=-j.position.z:(j._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,j.matrixWorld,j._modelViewMatrixArray),j.z=-j._modelViewMatrix.n34);b.__webglSprites.sort(u);c=0;for(f=b.__webglSprites.length;c<f;c++)j=b.__webglSprites[c],j.material===void 0&&j.map&&j.map.image&&
  267. j.map.image.width&&(j.useScreenCoordinates?(k.uniform1i(g.useScreenCoordinates,1),k.uniform3f(g.screenPosition,(j.position.x-p)/p,(t-j.position.y)/t,Math.max(0,Math.min(1,j.position.z)))):(k.uniform1i(g.useScreenCoordinates,0),k.uniform1i(g.affectedByDistance,j.affectedByDistance?1:0),k.uniformMatrix4fv(g.modelViewMatrix,!1,j._modelViewMatrixArray)),m=j.map.image.width/(j.scaleByViewport?T:1),n[0]=m*h*j.scale.x,n[1]=m*j.scale.y,k.uniform2f(g.uvScale,j.uvScale.x,j.uvScale.y),k.uniform2f(g.uvOffset,
  268. j.uvOffset.x,j.uvOffset.y),k.uniform2f(g.alignment,j.alignment.x,j.alignment.y),k.uniform1f(g.opacity,j.opacity),k.uniform1f(g.rotation,j.rotation),k.uniform2fv(g.scale,n),j.mergeWith3D&&!o?(k.enable(k.DEPTH_TEST),o=!0):!j.mergeWith3D&&o&&(k.disable(k.DEPTH_TEST),o=!1),I(j.blending),da(j.map,0),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0));k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(Y)}function A(b,e){var c,f,j=b.__webglLensFlares.length,g,h,m,n=new THREE.Vector3,p=T/la,t=la*0.5,
  269. o=T*0.5,u=16/T,v=[u*p,u],A=[1,1,0],w=[1,1],x=Q.uniforms;c=Q.attributes;k.useProgram(Q.program);X=Q.program;M=fa=-1;va||(k.enableVertexAttribArray(Q.attributes.vertex),k.enableVertexAttribArray(Q.attributes.uv),va=!0);k.uniform1i(x.occlusionMap,0);k.uniform1i(x.map,1);k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.vertexAttribPointer(c.vertex,2,k.FLOAT,!1,16,0);k.vertexAttribPointer(c.uv,2,k.FLOAT,!1,16,8);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.disable(k.CULL_FACE);k.depthMask(!1);k.activeTexture(k.TEXTURE0);
  270. k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.activeTexture(k.TEXTURE1);for(f=0;f<j;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),A[0]=n.x,A[1]=n.y,A[2]=n.z,w[0]=A[0]*t+t,w[1]=A[1]*o+o,Q.hasVertexTexture||w[0]>0&&w[0]<la&&w[1]>0&&w[1]<T){k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.copyTexImage2D(k.TEXTURE_2D,0,k.RGB,w[0]-8,w[1]-8,16,16,0);k.uniform1i(x.renderType,
  271. 0);k.uniform2fv(x.scale,v);k.uniform3fv(x.screenPosition,A);k.disable(k.BLEND);k.enable(k.DEPTH_TEST);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0);k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.copyTexImage2D(k.TEXTURE_2D,0,k.RGBA,w[0]-8,w[1]-8,16,16,0);k.uniform1i(x.renderType,1);k.disable(k.DEPTH_TEST);k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0);c.positionScreen.x=A[0];c.positionScreen.y=A[1];c.positionScreen.z=A[2];c.customUpdateCallback?c.customUpdateCallback(c):
  272. c.updateLensFlares();k.uniform1i(x.renderType,2);k.enable(k.BLEND);g=0;for(h=c.lensFlares.length;g<h;g++)if(m=c.lensFlares[g],m.opacity>0.001&&m.scale>0.001)A[0]=m.x,A[1]=m.y,A[2]=m.z,u=m.size*m.scale/T,v[0]=u*p,v[1]=u,k.uniform3fv(x.screenPosition,A),k.uniform2fv(x.scale,v),k.uniform1f(x.rotation,m.rotation),k.uniform1f(x.opacity,m.opacity),I(m.blending),da(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(Y)}function E(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,
  273. b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function F(b){var e,c,f,j;j=b.__materials;b=0;for(c=j.length;b<c;b++)if(f=j[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function J(b){var e,c,f,j;j=b.__materials;b=0;for(c=j.length;b<c;b++)if(f=j[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function C(b){var e,f,j,g;if(b instanceof THREE.Mesh){f=b.geometry;
  274. for(e in f.geometryGroups)if(j=f.geometryGroups[e],g=F(j),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||g){g=j;var h=b,m=k.DYNAMIC_DRAW;if(g.__inittedArrays){var n=void 0,p=void 0,t=void 0,o=void 0,u=t=void 0,v=void 0,A=void 0,w=void 0,x=void 0,B=void 0,E=void 0,D=void 0,la=void 0,C=void 0,G=void 0,I=void 0,T=void 0,H=o=w=o=A=v=void 0,y=void 0,z=y=H=v=void 0,K=void 0,O=z=y=H=t=t=u=w=o=z=y=H=K=z=y=H=K=z=y=H=void 0,M=
  275. 0,ga=0,W=0,V=0,Y=0,Q=0,N=0,S=0,ia=0,L=0,P=0,z=H=0,z=void 0,R=g.__vertexArray,da=g.__uvArray,ea=g.__uv2Array,ja=g.__normalArray,U=g.__tangentArray,$=g.__colorArray,X=g.__skinVertexAArray,Z=g.__skinVertexBArray,fa=g.__skinIndexArray,ca=g.__skinWeightArray,ma=g.__morphTargetsArrays,ha=g.__webglCustomAttributes,y=void 0,sa=g.__faceArray,ka=g.__lineArray,pa=g.__needsSmoothNormals,B=g.__vertexColorType,x=g.__uvType,E=g.__normalType,na=h.geometry,qa=na.__dirtyVertices,ra=na.__dirtyElements,xa=na.__dirtyUvs,
  276. ta=na.__dirtyNormals,ua=na.__dirtyTangents,wa=na.__dirtyColors,Aa=na.__dirtyMorphTargets,va=na.vertices,Ba=g.faces,Da=na.faces,Ha=na.faceVertexUvs[0],Ea=na.faceVertexUvs[1],ya=na.skinVerticesA,za=na.skinVerticesB,Na=na.skinIndices,Ga=na.skinWeights,La=h instanceof THREE.ShadowVolume?na.edgeFaces:void 0,Fa=na.morphTargets;if(ha)for(O in ha)ha[O].offset=0,ha[O].offsetSrc=0;n=0;for(p=Ba.length;n<p;n++)if(t=Ba[n],o=Da[t],Ha&&(D=Ha[t]),Ea&&(la=Ea[t]),t=o.vertexNormals,u=o.normal,v=o.vertexColors,A=o.color,
  277. w=o.vertexTangents,o instanceof THREE.Face3){if(qa)C=va[o.a].position,G=va[o.b].position,I=va[o.c].position,R[ga]=C.x,R[ga+1]=C.y,R[ga+2]=C.z,R[ga+3]=G.x,R[ga+4]=G.y,R[ga+5]=G.z,R[ga+6]=I.x,R[ga+7]=I.y,R[ga+8]=I.z,ga+=9;if(ha)for(O in ha)if(y=ha[O],y.__original.needsUpdate)H=y.offset,z=y.offsetSrc,y.size===1?(y.boundTo===void 0||y.boundTo==="vertices"?(y.array[H]=y.value[o.a],y.array[H+1]=y.value[o.b],y.array[H+2]=y.value[o.c]):y.boundTo==="faces"?(z=y.value[z],y.array[H]=z,y.array[H+1]=z,y.array[H+
  278. 2]=z,y.offsetSrc++):y.boundTo==="faceVertices"&&(y.array[H]=y.value[z],y.array[H+1]=y.value[z+1],y.array[H+2]=y.value[z+2],y.offsetSrc+=3),y.offset+=3):(y.boundTo===void 0||y.boundTo==="vertices"?(C=y.value[o.a],G=y.value[o.b],I=y.value[o.c]):y.boundTo==="faces"?(I=G=C=z=y.value[z],y.offsetSrc++):y.boundTo==="faceVertices"&&(C=y.value[z],G=y.value[z+1],I=y.value[z+2],y.offsetSrc+=3),y.size===2?(y.array[H]=C.x,y.array[H+1]=C.y,y.array[H+2]=G.x,y.array[H+3]=G.y,y.array[H+4]=I.x,y.array[H+5]=I.y,y.offset+=
  279. 6):y.size===3?(y.type==="c"?(y.array[H]=C.r,y.array[H+1]=C.g,y.array[H+2]=C.b,y.array[H+3]=G.r,y.array[H+4]=G.g,y.array[H+5]=G.b,y.array[H+6]=I.r,y.array[H+7]=I.g,y.array[H+8]=I.b):(y.array[H]=C.x,y.array[H+1]=C.y,y.array[H+2]=C.z,y.array[H+3]=G.x,y.array[H+4]=G.y,y.array[H+5]=G.z,y.array[H+6]=I.x,y.array[H+7]=I.y,y.array[H+8]=I.z),y.offset+=9):(y.array[H]=C.x,y.array[H+1]=C.y,y.array[H+2]=C.z,y.array[H+3]=C.w,y.array[H+4]=G.x,y.array[H+5]=G.y,y.array[H+6]=G.z,y.array[H+7]=G.w,y.array[H+8]=I.x,y.array[H+
  280. 9]=I.y,y.array[H+10]=I.z,y.array[H+11]=I.w,y.offset+=12));if(Aa){H=0;for(y=Fa.length;H<y;H++)C=Fa[H].vertices[o.a].position,G=Fa[H].vertices[o.b].position,I=Fa[H].vertices[o.c].position,z=ma[H],z[P]=C.x,z[P+1]=C.y,z[P+2]=C.z,z[P+3]=G.x,z[P+4]=G.y,z[P+5]=G.z,z[P+6]=I.x,z[P+7]=I.y,z[P+8]=I.z;P+=9}if(Ga.length)H=Ga[o.a],y=Ga[o.b],z=Ga[o.c],ca[L]=H.x,ca[L+1]=H.y,ca[L+2]=H.z,ca[L+3]=H.w,ca[L+4]=y.x,ca[L+5]=y.y,ca[L+6]=y.z,ca[L+7]=y.w,ca[L+8]=z.x,ca[L+9]=z.y,ca[L+10]=z.z,ca[L+11]=z.w,H=Na[o.a],y=Na[o.b],
  281. z=Na[o.c],fa[L]=H.x,fa[L+1]=H.y,fa[L+2]=H.z,fa[L+3]=H.w,fa[L+4]=y.x,fa[L+5]=y.y,fa[L+6]=y.z,fa[L+7]=y.w,fa[L+8]=z.x,fa[L+9]=z.y,fa[L+10]=z.z,fa[L+11]=z.w,H=ya[o.a],y=ya[o.b],z=ya[o.c],X[L]=H.x,X[L+1]=H.y,X[L+2]=H.z,X[L+3]=1,X[L+4]=y.x,X[L+5]=y.y,X[L+6]=y.z,X[L+7]=1,X[L+8]=z.x,X[L+9]=z.y,X[L+10]=z.z,X[L+11]=1,H=za[o.a],y=za[o.b],z=za[o.c],Z[L]=H.x,Z[L+1]=H.y,Z[L+2]=H.z,Z[L+3]=1,Z[L+4]=y.x,Z[L+5]=y.y,Z[L+6]=y.z,Z[L+7]=1,Z[L+8]=z.x,Z[L+9]=z.y,Z[L+10]=z.z,Z[L+11]=1,L+=12;if(wa&&B)v.length==3&&B==THREE.VertexColors?
  282. (o=v[0],H=v[1],y=v[2]):y=H=o=A,$[ia]=o.r,$[ia+1]=o.g,$[ia+2]=o.b,$[ia+3]=H.r,$[ia+4]=H.g,$[ia+5]=H.b,$[ia+6]=y.r,$[ia+7]=y.g,$[ia+8]=y.b,ia+=9;if(ua&&na.hasTangents)v=w[0],A=w[1],o=w[2],U[N]=v.x,U[N+1]=v.y,U[N+2]=v.z,U[N+3]=v.w,U[N+4]=A.x,U[N+5]=A.y,U[N+6]=A.z,U[N+7]=A.w,U[N+8]=o.x,U[N+9]=o.y,U[N+10]=o.z,U[N+11]=o.w,N+=12;if(ta&&E)if(t.length==3&&pa)for(w=0;w<3;w++)u=t[w],ja[Q]=u.x,ja[Q+1]=u.y,ja[Q+2]=u.z,Q+=3;else for(w=0;w<3;w++)ja[Q]=u.x,ja[Q+1]=u.y,ja[Q+2]=u.z,Q+=3;if(xa&&D!==void 0&&x)for(w=
  283. 0;w<3;w++)t=D[w],da[W]=t.u,da[W+1]=t.v,W+=2;if(xa&&la!==void 0&&x)for(w=0;w<3;w++)t=la[w],ea[V]=t.u,ea[V+1]=t.v,V+=2;ra&&(sa[Y]=M,sa[Y+1]=M+1,sa[Y+2]=M+2,Y+=3,ka[S]=M,ka[S+1]=M+1,ka[S+2]=M,ka[S+3]=M+2,ka[S+4]=M+1,ka[S+5]=M+2,S+=6,M+=3)}else if(o instanceof THREE.Face4){if(qa)C=va[o.a].position,G=va[o.b].position,I=va[o.c].position,T=va[o.d].position,R[ga]=C.x,R[ga+1]=C.y,R[ga+2]=C.z,R[ga+3]=G.x,R[ga+4]=G.y,R[ga+5]=G.z,R[ga+6]=I.x,R[ga+7]=I.y,R[ga+8]=I.z,R[ga+9]=T.x,R[ga+10]=T.y,R[ga+11]=T.z,ga+=12;
  284. if(ha)for(O in ha)if(y=ha[O],y.__original.needsUpdate)H=y.offset,z=y.offsetSrc,y.size===1?(y.boundTo===void 0||y.boundTo==="vertices"?(y.array[H]=y.value[o.a],y.array[H+1]=y.value[o.b],y.array[H+2]=y.value[o.c],y.array[H+3]=y.value[o.d]):y.boundTo==="faces"?(z=y.value[z],y.array[H]=z,y.array[H+1]=z,y.array[H+2]=z,y.array[H+3]=z,y.offsetSrc++):y.boundTo==="faceVertices"&&(y.array[H]=y.value[z],y.array[H+1]=y.value[z+1],y.array[H+2]=y.value[z+2],y.array[H+3]=y.value[z+3],y.offsetSrc+=4),y.offset+=4):
  285. (y.boundTo===void 0||y.boundTo==="vertices"?(C=y.value[o.a],G=y.value[o.b],I=y.value[o.c],T=y.value[o.d]):y.boundTo==="faces"?(T=I=G=C=z=y.value[z],y.offsetSrc++):y.boundTo==="faceVertices"&&(C=y.value[z],G=y.value[z+1],I=y.value[z+2],T=y.value[z+3],y.offsetSrc+=4),y.size===2?(y.array[H]=C.x,y.array[H+1]=C.y,y.array[H+2]=G.x,y.array[H+3]=G.y,y.array[H+4]=I.x,y.array[H+5]=I.y,y.array[H+6]=T.x,y.array[H+7]=T.y,y.offset+=8):y.size===3?(y.type==="c"?(y.array[H]=C.r,y.array[H+1]=C.g,y.array[H+2]=C.b,y.array[H+
  286. 3]=G.r,y.array[H+4]=G.g,y.array[H+5]=G.b,y.array[H+6]=I.r,y.array[H+7]=I.g,y.array[H+8]=I.b,y.array[H+9]=T.r,y.array[H+10]=T.g,y.array[H+11]=T.b):(y.array[H]=C.x,y.array[H+1]=C.y,y.array[H+2]=C.z,y.array[H+3]=G.x,y.array[H+4]=G.y,y.array[H+5]=G.z,y.array[H+6]=I.x,y.array[H+7]=I.y,y.array[H+8]=I.z,y.array[H+9]=T.x,y.array[H+10]=T.y,y.array[H+11]=T.z),y.offset+=12):(y.array[H]=C.x,y.array[H+1]=C.y,y.array[H+2]=C.z,y.array[H+3]=C.w,y.array[H+4]=G.x,y.array[H+5]=G.y,y.array[H+6]=G.z,y.array[H+7]=G.w,
  287. y.array[H+8]=I.x,y.array[H+9]=I.y,y.array[H+10]=I.z,y.array[H+11]=I.w,y.array[H+12]=T.x,y.array[H+13]=T.y,y.array[H+14]=T.z,y.array[H+15]=T.w,y.offset+=16));if(Aa){H=0;for(y=Fa.length;H<y;H++)C=Fa[H].vertices[o.a].position,G=Fa[H].vertices[o.b].position,I=Fa[H].vertices[o.c].position,T=Fa[H].vertices[o.d].position,z=ma[H],z[P]=C.x,z[P+1]=C.y,z[P+2]=C.z,z[P+3]=G.x,z[P+4]=G.y,z[P+5]=G.z,z[P+6]=I.x,z[P+7]=I.y,z[P+8]=I.z,z[P+9]=T.x,z[P+10]=T.y,z[P+11]=T.z;P+=12}if(Ga.length)H=Ga[o.a],y=Ga[o.b],z=Ga[o.c],
  288. K=Ga[o.d],ca[L]=H.x,ca[L+1]=H.y,ca[L+2]=H.z,ca[L+3]=H.w,ca[L+4]=y.x,ca[L+5]=y.y,ca[L+6]=y.z,ca[L+7]=y.w,ca[L+8]=z.x,ca[L+9]=z.y,ca[L+10]=z.z,ca[L+11]=z.w,ca[L+12]=K.x,ca[L+13]=K.y,ca[L+14]=K.z,ca[L+15]=K.w,H=Na[o.a],y=Na[o.b],z=Na[o.c],K=Na[o.d],fa[L]=H.x,fa[L+1]=H.y,fa[L+2]=H.z,fa[L+3]=H.w,fa[L+4]=y.x,fa[L+5]=y.y,fa[L+6]=y.z,fa[L+7]=y.w,fa[L+8]=z.x,fa[L+9]=z.y,fa[L+10]=z.z,fa[L+11]=z.w,fa[L+12]=K.x,fa[L+13]=K.y,fa[L+14]=K.z,fa[L+15]=K.w,H=ya[o.a],y=ya[o.b],z=ya[o.c],K=ya[o.d],X[L]=H.x,X[L+1]=H.y,
  289. X[L+2]=H.z,X[L+3]=1,X[L+4]=y.x,X[L+5]=y.y,X[L+6]=y.z,X[L+7]=1,X[L+8]=z.x,X[L+9]=z.y,X[L+10]=z.z,X[L+11]=1,X[L+12]=K.x,X[L+13]=K.y,X[L+14]=K.z,X[L+15]=1,H=za[o.a],y=za[o.b],z=za[o.c],o=za[o.d],Z[L]=H.x,Z[L+1]=H.y,Z[L+2]=H.z,Z[L+3]=1,Z[L+4]=y.x,Z[L+5]=y.y,Z[L+6]=y.z,Z[L+7]=1,Z[L+8]=z.x,Z[L+9]=z.y,Z[L+10]=z.z,Z[L+11]=1,Z[L+12]=o.x,Z[L+13]=o.y,Z[L+14]=o.z,Z[L+15]=1,L+=16;if(wa&&B)v.length==4&&B==THREE.VertexColors?(o=v[0],H=v[1],y=v[2],v=v[3]):v=y=H=o=A,$[ia]=o.r,$[ia+1]=o.g,$[ia+2]=o.b,$[ia+3]=H.r,$[ia+
  290. 4]=H.g,$[ia+5]=H.b,$[ia+6]=y.r,$[ia+7]=y.g,$[ia+8]=y.b,$[ia+9]=v.r,$[ia+10]=v.g,$[ia+11]=v.b,ia+=12;if(ua&&na.hasTangents)v=w[0],A=w[1],o=w[2],w=w[3],U[N]=v.x,U[N+1]=v.y,U[N+2]=v.z,U[N+3]=v.w,U[N+4]=A.x,U[N+5]=A.y,U[N+6]=A.z,U[N+7]=A.w,U[N+8]=o.x,U[N+9]=o.y,U[N+10]=o.z,U[N+11]=o.w,U[N+12]=w.x,U[N+13]=w.y,U[N+14]=w.z,U[N+15]=w.w,N+=16;if(ta&&E)if(t.length==4&&pa)for(w=0;w<4;w++)u=t[w],ja[Q]=u.x,ja[Q+1]=u.y,ja[Q+2]=u.z,Q+=3;else for(w=0;w<4;w++)ja[Q]=u.x,ja[Q+1]=u.y,ja[Q+2]=u.z,Q+=3;if(xa&&D!==void 0&&
  291. x)for(w=0;w<4;w++)t=D[w],da[W]=t.u,da[W+1]=t.v,W+=2;if(xa&&la!==void 0&&x)for(w=0;w<4;w++)t=la[w],ea[V]=t.u,ea[V+1]=t.v,V+=2;ra&&(sa[Y]=M,sa[Y+1]=M+1,sa[Y+2]=M+3,sa[Y+3]=M+1,sa[Y+4]=M+2,sa[Y+5]=M+3,Y+=6,ka[S]=M,ka[S+1]=M+1,ka[S+2]=M,ka[S+3]=M+3,ka[S+4]=M+1,ka[S+5]=M+2,ka[S+6]=M+2,ka[S+7]=M+3,S+=8,M+=4)}if(La){n=0;for(p=La.length;n<p;n++)sa[Y]=La[n].a,sa[Y+1]=La[n].b,sa[Y+2]=La[n].c,sa[Y+3]=La[n].a,sa[Y+4]=La[n].c,sa[Y+5]=La[n].d,Y+=6}qa&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,
  292. R,m));if(ha)for(O in ha)y=ha[O],y.__original.needsUpdate&&(k.bindBuffer(k.ARRAY_BUFFER,y.buffer),k.bufferData(k.ARRAY_BUFFER,y.array,m));if(Aa){H=0;for(y=Fa.length;H<y;H++)k.bindBuffer(k.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[H]),k.bufferData(k.ARRAY_BUFFER,ma[H],m)}wa&&ia>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,$,m));ta&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglNormalBuffer),k.bufferData(k.ARRAY_BUFFER,ja,m));ua&&na.hasTangents&&(k.bindBuffer(k.ARRAY_BUFFER,
  293. g.__webglTangentBuffer),k.bufferData(k.ARRAY_BUFFER,U,m));xa&&W>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,da,m));xa&&V>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,ea,m));ra&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,sa,m),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ka,m));L>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexABuffer),
  294. k.bufferData(k.ARRAY_BUFFER,X,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,Z,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,fa,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,ca,m));h.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,
  295. 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;J(j)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;x=b.vertices;g=b.colors;B=x.length;h=g.length;E=b.__vertexArray;m=b.__colorArray;D=b.__dirtyColors;if(b.__dirtyVertices){for(n=0;n<B;n++)p=
  296. x[n].position,j=n*3,E[j]=p.x,E[j+1]=p.y,E[j+2]=p.z;k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,E,e)}if(D){for(n=0;n<h;n++)color=g[n],j=n*3,m[j]=color.r,m[j+1]=color.g,m[j+2]=color.b;k.bindBuffer(k.ARRAY_BUFFER,b.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,m,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;x=b.vertices;g=b.colors;B=x.length;h=g.length;E=b.__vertexArray;
  297. m=b.__colorArray;D=b.__dirtyColors;if(b.__dirtyVertices){for(n=0;n<B;n++)p=x[n].position,j=n*3,E[j]=p.x,E[j+1]=p.y,E[j+2]=p.z;k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,E,e)}if(D){for(n=0;n<h;n++)color=g[n],j=n*3,m[j]=color.r,m[j+1]=color.g,m[j+2]=color.b;k.bindBuffer(k.ARRAY_BUFFER,b.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,m,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=b.geometry,g=F(f),(f.__dirtyVertices||f.__dirtyColors||
  298. b.sortParticles||g)&&c(f,k.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1,J(f)}function G(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function O(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,j,h,k,m,n,o={},p=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};g=0;for(j=b.faces.length;g<j;g++)h=b.faces[g],k=h.materials,m=e(k),o[m]==void 0&&(o[m]={hash:m,counter:0}),n=
  299. o[m].hash+"_"+o[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:p}),h=h instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+h>65535&&(o[m].counter+=1,n=o[m].hash+"_"+o[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(g),b.geometryGroups[n].vertices+=h}function D(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],
  300. count:0}})}function I(b){if(b!=fa){switch(b){case THREE.AdditiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR);break;default:k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}fa=b}}function V(b,e,c){(c.width&
  301. c.width-1)==0&&(c.height&c.height-1)==0?(k.texParameteri(b,k.TEXTURE_WRAP_S,R(e.wrapS)),k.texParameteri(b,k.TEXTURE_WRAP_T,R(e.wrapT)),k.texParameteri(b,k.TEXTURE_MAG_FILTER,R(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,R(e.minFilter)),k.generateMipmap(b)):(k.texParameteri(b,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_MAG_FILTER,ea(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,ea(e.minFilter)))}function da(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture=
  302. k.createTexture(),b.__webglInit=!0;k.bindTexture(k.TEXTURE_2D,b.__webglTexture);b.image.data?k.texImage2D(k.TEXTURE_2D,0,R(b.format),b.image.width,b.image.height,0,R(b.format),k.UNSIGNED_BYTE,b.image.data):k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image);V(k.TEXTURE_2D,b,b.image);k.bindTexture(k.TEXTURE_2D,null);b.needsUpdate=!1}k.activeTexture(k.TEXTURE0+e);k.bindTexture(k.TEXTURE_2D,b.__webglTexture)}function S(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=
  303. !0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=k.createFramebuffer();b.__webglRenderbuffer=k.createRenderbuffer();b.__webglTexture=k.createTexture();k.bindTexture(k.TEXTURE_2D,b.__webglTexture);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,R(b.wrapS));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,R(b.wrapT));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,R(b.magFilter));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,R(b.minFilter));k.texImage2D(k.TEXTURE_2D,0,R(b.format),
  304. b.width,b.height,0,R(b.format),R(b.type),null);k.bindRenderbuffer(k.RENDERBUFFER,b.__webglRenderbuffer);k.bindFramebuffer(k.FRAMEBUFFER,b.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,
  305. k.DEPTH_STENCIL,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height);k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=la,b=T);e!=$&&(k.bindFramebuffer(k.FRAMEBUFFER,e),k.viewport(ka,na,c,b),$=e)}function z(b,e){var c;b=="fragment"?c=k.createShader(k.FRAGMENT_SHADER):
  306. b=="vertex"&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,e);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS))return console.error(k.getShaderInfoLog(c)),console.error(e),null;return c}function ea(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST;default:return k.LINEAR}}function R(b){switch(b){case THREE.RepeatWrapping:return k.REPEAT;case THREE.ClampToEdgeWrapping:return k.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return k.MIRRORED_REPEAT;
  307. case THREE.NearestFilter:return k.NEAREST;case THREE.NearestMipMapNearestFilter:return k.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return k.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return k.LINEAR;case THREE.LinearMipMapNearestFilter:return k.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return k.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return k.BYTE;case THREE.UnsignedByteType:return k.UNSIGNED_BYTE;case THREE.ShortType:return k.SHORT;case THREE.UnsignedShortType:return k.UNSIGNED_SHORT;
  308. case THREE.IntType:return k.INT;case THREE.UnsignedShortType:return k.UNSIGNED_INT;case THREE.FloatType:return k.FLOAT;case THREE.AlphaFormat:return k.ALPHA;case THREE.RGBFormat:return k.RGB;case THREE.RGBAFormat:return k.RGBA;case THREE.LuminanceFormat:return k.LUMINANCE;case THREE.LuminanceAlphaFormat:return k.LUMINANCE_ALPHA}return 0}var P=this,k,K=[],X=null,$=null,Y=!0,ha=null,ja=null,fa=null,M=null,W=null,ca=null,ma=null,ka=0,na=0,la=0,T=0,ga=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
  309. new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ia=new THREE.Matrix4,sa=new Float32Array(16),xa=new Float32Array(16),Aa=new THREE.Vector4,Ha={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ba=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Oa=b.stencil!==void 0?b.stencil:!0,U=b.antialias!==void 0?b.antialias:!1,pa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),qa=b.clearAlpha!==
  310. void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ba;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ta,ua=[],b=THREE.ShaderLib.depthRGBA,wa=THREE.UniformsUtils.clone(b.uniforms),Da=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,
  311. vertexShader:b.vertexShader,uniforms:wa}),ya=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:wa,morphTargets:!0});Da._shadowPass=!0;ya._shadowPass=!0;try{if(!(k=Ba.getContext("experimental-webgl",{antialias:U,stencil:Oa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+k.getParameter(k.VERSION)+" | "+k.getParameter(k.VENDOR)+" | "+k.getParameter(k.RENDERER)+" | "+k.getParameter(k.SHADING_LANGUAGE_VERSION))}catch(ra){console.error(ra)}k.clearColor(0,
  312. 0,0,1);k.clearDepth(1);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(pa.r,pa.g,pa.b,qa);this.context=k;var Ea=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Oa){var Z={};Z.vertices=new Float32Array(12);Z.faces=new Uint16Array(6);Z.darkness=0.5;Z.vertices[0]=-20;Z.vertices[1]=-20;Z.vertices[2]=-1;Z.vertices[3]=20;Z.vertices[4]=-20;
  313. Z.vertices[5]=-1;Z.vertices[6]=20;Z.vertices[7]=20;Z.vertices[8]=-1;Z.vertices[9]=-20;Z.vertices[10]=20;Z.vertices[11]=-1;Z.faces[0]=0;Z.faces[1]=1;Z.faces[2]=2;Z.faces[3]=0;Z.faces[4]=2;Z.faces[5]=3;Z.vertexBuffer=k.createBuffer();Z.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,Z.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,Z.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Z.faces,k.STATIC_DRAW);Z.program=k.createProgram();
  314. k.attachShader(Z.program,z("fragment",THREE.ShaderLib.shadowPost.fragmentShader));k.attachShader(Z.program,z("vertex",THREE.ShaderLib.shadowPost.vertexShader));k.linkProgram(Z.program);Z.vertexLocation=k.getAttribLocation(Z.program,"position");Z.projectionLocation=k.getUniformLocation(Z.program,"projectionMatrix");Z.darknessLocation=k.getUniformLocation(Z.program,"darkness")}var Q={};Q.vertices=new Float32Array(16);Q.faces=new Uint16Array(6);U=0;Q.vertices[U++]=-1;Q.vertices[U++]=-1;Q.vertices[U++]=
  315. 0;Q.vertices[U++]=0;Q.vertices[U++]=1;Q.vertices[U++]=-1;Q.vertices[U++]=1;Q.vertices[U++]=0;Q.vertices[U++]=1;Q.vertices[U++]=1;Q.vertices[U++]=1;Q.vertices[U++]=1;Q.vertices[U++]=-1;Q.vertices[U++]=1;Q.vertices[U++]=0;Q.vertices[U++]=1;U=0;Q.faces[U++]=0;Q.faces[U++]=1;Q.faces[U++]=2;Q.faces[U++]=0;Q.faces[U++]=2;Q.faces[U++]=3;Q.vertexBuffer=k.createBuffer();Q.elementBuffer=k.createBuffer();Q.tempTexture=k.createTexture();Q.occlusionTexture=k.createTexture();k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);
  316. k.bufferData(k.ARRAY_BUFFER,Q.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Q.faces,k.STATIC_DRAW);k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGB,16,16,0,k.RGB,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,
  317. k.NEAREST);k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGBA,16,16,0,k.RGBA,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(Q.hasVertexTexture=!1,Q.program=k.createProgram(),k.attachShader(Q.program,
  318. z("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),k.attachShader(Q.program,z("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(Q.hasVertexTexture=!0,Q.program=k.createProgram(),k.attachShader(Q.program,z("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),k.attachShader(Q.program,z("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));k.linkProgram(Q.program);Q.attributes={};Q.uniforms={};Q.attributes.vertex=k.getAttribLocation(Q.program,"position");Q.attributes.uv=
  319. k.getAttribLocation(Q.program,"UV");Q.uniforms.renderType=k.getUniformLocation(Q.program,"renderType");Q.uniforms.map=k.getUniformLocation(Q.program,"map");Q.uniforms.occlusionMap=k.getUniformLocation(Q.program,"occlusionMap");Q.uniforms.opacity=k.getUniformLocation(Q.program,"opacity");Q.uniforms.scale=k.getUniformLocation(Q.program,"scale");Q.uniforms.rotation=k.getUniformLocation(Q.program,"rotation");Q.uniforms.screenPosition=k.getUniformLocation(Q.program,"screenPosition");var va=!1,N={};N.vertices=
  320. new Float32Array(16);N.faces=new Uint16Array(6);U=0;N.vertices[U++]=-1;N.vertices[U++]=-1;N.vertices[U++]=0;N.vertices[U++]=1;N.vertices[U++]=1;N.vertices[U++]=-1;N.vertices[U++]=1;N.vertices[U++]=1;N.vertices[U++]=1;N.vertices[U++]=1;N.vertices[U++]=1;N.vertices[U++]=0;N.vertices[U++]=-1;N.vertices[U++]=1;N.vertices[U++]=0;U=N.vertices[U++]=0;N.faces[U++]=0;N.faces[U++]=1;N.faces[U++]=2;N.faces[U++]=0;N.faces[U++]=2;N.faces[U++]=3;N.vertexBuffer=k.createBuffer();N.elementBuffer=k.createBuffer();
  321. k.bindBuffer(k.ARRAY_BUFFER,N.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,N.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,N.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,N.faces,k.STATIC_DRAW);N.program=k.createProgram();k.attachShader(N.program,z("fragment",THREE.ShaderLib.sprite.fragmentShader));k.attachShader(N.program,z("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(N.program);N.attributes={};N.uniforms={};N.attributes.position=k.getAttribLocation(N.program,"position");
  322. N.attributes.uv=k.getAttribLocation(N.program,"uv");N.uniforms.uvOffset=k.getUniformLocation(N.program,"uvOffset");N.uniforms.uvScale=k.getUniformLocation(N.program,"uvScale");N.uniforms.rotation=k.getUniformLocation(N.program,"rotation");N.uniforms.scale=k.getUniformLocation(N.program,"scale");N.uniforms.alignment=k.getUniformLocation(N.program,"alignment");N.uniforms.map=k.getUniformLocation(N.program,"map");N.uniforms.opacity=k.getUniformLocation(N.program,"opacity");N.uniforms.useScreenCoordinates=
  323. k.getUniformLocation(N.program,"useScreenCoordinates");N.uniforms.affectedByDistance=k.getUniformLocation(N.program,"affectedByDistance");N.uniforms.screenPosition=k.getUniformLocation(N.program,"screenPosition");N.uniforms.modelViewMatrix=k.getUniformLocation(N.program,"modelViewMatrix");N.uniforms.projectionMatrix=k.getUniformLocation(N.program,"projectionMatrix");var za=!1;this.setSize=function(b,e){Ba.width=b;Ba.height=e;this.setViewport(0,0,Ba.width,Ba.height)};this.setViewport=function(b,e,
  324. c,f){ka=b;na=e;la=c;T=f;k.viewport(ka,na,la,T)};this.setScissor=function(b,e,c,f){k.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){Y=b;k.depthMask(b)};this.setClearColorHex=function(b,e){pa.setHex(b);qa=e;k.clearColor(pa.r,pa.g,pa.b,qa)};this.setClearColor=function(b,e){pa.copy(b);qa=e;k.clearColor(pa.r,pa.g,pa.b,qa)};this.clear=function(){k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT|k.STENCIL_BUFFER_BIT)};
  325. this.setStencilShadowDarkness=function(b){Z.darkness=b};this.getContext=function(){return k};this.initMaterial=function(b,e,c,f){var g,j,h;b instanceof THREE.MeshDepthMaterial?h="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?h="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?h="normal":b instanceof THREE.MeshBasicMaterial?h="basic":b instanceof THREE.MeshLambertMaterial?h="lambert":b instanceof THREE.MeshPhongMaterial?h="phong":b instanceof THREE.LineBasicMaterial?h="basic":b instanceof
  326. THREE.ParticleBasicMaterial&&(h="particle_basic");if(h){var m=THREE.ShaderLib[h];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var n,o,p;n=p=m=0;for(o=e.length;n<o;n++)j=e[n],j instanceof THREE.SpotLight&&p++,j instanceof THREE.DirectionalLight&&p++,j instanceof THREE.PointLight&&m++;m+p<=4?n=p:(n=Math.ceil(4*p/(m+p)),m=4-n);j={directional:n,point:m};m=p=0;for(n=e.length;m<n;m++)o=e[m],o instanceof THREE.SpotLight&&o.castShadow&&p++;
  327. var t=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)t=f.bones.length;var u;a:{n=b.fragmentShader;o=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:j.directional,maxPointLights:j.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,
  328. shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:p,alphaTest:b.alphaTest},v,f=[];h?f.push(h):(f.push(n),f.push(o));for(v in c)f.push(v),f.push(c[v]);h=f.join();v=0;for(f=K.length;v<f;v++)if(K[v].code==h){u=K[v].program;break a}v=k.createProgram();f=[Ea?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?
  329. "#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",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");
  330. j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",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":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":
  331. "",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k.attachShader(v,z("fragment",j+n));k.attachShader(v,z("vertex",f+o));k.linkProgram(v);k.getProgramParameter(v,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(v,k.VALIDATE_STATUS)+", gl error ["+k.getError()+"]");v.uniforms=
  332. {};v.attributes={};var w,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in m)f.push(w);w=f;f=0;for(m=w.length;f<m;f++)n=w[f],v.uniforms[n]=k.getUniformLocation(v,n);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<c.maxMorphTargets;w++)f.push("morphTarget"+w);for(u in e)f.push(u);u=f;w=0;for(e=u.length;w<e;w++)c=
  333. u[w],v.attributes[c]=k.getAttribLocation(v,c);K.push({program:v,code:h});u=v}b.program=u;u=b.program.attributes;u.position>=0&&k.enableVertexAttribArray(u.position);u.color>=0&&k.enableVertexAttribArray(u.color);u.normal>=0&&k.enableVertexAttribArray(u.normal);u.tangent>=0&&k.enableVertexAttribArray(u.tangent);b.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(k.enableVertexAttribArray(u.skinVertexA),k.enableVertexAttribArray(u.skinVertexB),k.enableVertexAttribArray(u.skinIndex),
  334. k.enableVertexAttribArray(u.skinWeight));if(b.attributes)for(g in b.attributes)u[g]!==void 0&&u[g]>=0&&k.enableVertexAttribArray(u[g]);if(b.morphTargets)for(g=b.numSupportedMorphTargets=0;g<this.maxMorphTargets;g++)w="morphTarget"+g,u[w]>=0&&(k.enableVertexAttribArray(u[w]),b.numSupportedMorphTargets++)};this.render=function(b,c,o,C){var z,F,G,D,J,la,T,M,K=b.lights,ga=b.fog;this.shadowMapEnabled&&w(b,c);P.data.vertices=0;P.data.faces=0;P.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,
  335. !1,c);c.matrixWorldInverse.flattenToArray(xa);c.projectionMatrix.flattenToArray(sa);ia.multiply(c.projectionMatrix,c.matrixWorldInverse);n(ia);this.initWebGLObjects(b);S(o);(this.autoClear||C)&&this.clear();J=b.__webglObjects.length;for(C=0;C<J;C++)if(z=b.__webglObjects[C],T=z.object,T.visible)if(!(T instanceof THREE.Mesh)||p(T)){if(T.matrixWorld.flattenToArray(T._objectMatrixArray),E(T,c,!0),v(z),z.render=!0,this.sortObjects)z.object.renderDepth?z.z=z.object.renderDepth:(Aa.copy(T.position),ia.multiplyVector3(Aa),
  336. z.z=Aa.z)}else z.render=!1;else z.render=!1;this.sortObjects&&b.__webglObjects.sort(u);la=b.__webglObjectsImmediate.length;for(C=0;C<la;C++)z=b.__webglObjectsImmediate[C],T=z.object,T.visible&&(T.matrixAutoUpdate&&T.matrixWorld.flattenToArray(T._objectMatrixArray),E(T,c,!0),t(z));if(b.overrideMaterial){g(b.overrideMaterial.depthTest);I(b.overrideMaterial.blending);for(C=0;C<J;C++)if(z=b.__webglObjects[C],z.render)T=z.object,M=z.buffer,j(T),f(c,K,ga,b.overrideMaterial,M,T);for(C=0;C<la;C++)z=b.__webglObjectsImmediate[C],
  337. T=z.object,T.visible&&(j(T),F=e(c,K,ga,b.overrideMaterial,T),T.render(function(c){h(c,F,b.overrideMaterial.shading)}))}else{I(THREE.NormalBlending);for(C=J-1;C>=0;C--)if(z=b.__webglObjects[C],z.render){T=z.object;M=z.buffer;G=z.opaque;j(T);for(z=0;z<G.count;z++)D=G.list[z],g(D.depthTest),m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),f(c,K,ga,D,M,T)}for(C=0;C<la;C++)if(z=b.__webglObjectsImmediate[C],T=z.object,T.visible){G=z.opaque;j(T);for(z=0;z<G.count;z++)D=G.list[z],g(D.depthTest),
  338. m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),F=e(c,K,ga,D,T),T.render(function(b){h(b,F,D.shading)})}for(C=0;C<J;C++)if(z=b.__webglObjects[C],z.render){T=z.object;M=z.buffer;G=z.transparent;j(T);for(z=0;z<G.count;z++)D=G.list[z],I(D.blending),g(D.depthTest),m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),f(c,K,ga,D,M,T)}for(C=0;C<la;C++)if(z=b.__webglObjectsImmediate[C],T=z.object,T.visible){G=z.transparent;j(T);for(z=0;z<G.count;z++)D=G.list[z],I(D.blending),g(D.depthTest),
  339. m(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),F=e(c,K,ga,D,T),T.render(function(b){h(b,F,D.shading)})}}b.__webglSprites.length&&x(b,c);Oa&&b.__webglShadowVolumes.length&&b.lights.length&&B(b);b.__webglLensFlares.length&&A(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&(k.bindTexture(k.TEXTURE_2D,o.__webglTexture),k.generateMipmap(k.TEXTURE_2D),k.bindTexture(k.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],
  340. b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var c=b.__objectsAdded[0],e=b,f=void 0,g=void 0,j=void 0;if(c._modelViewMatrix==void 0)c._modelViewMatrix=new THREE.Matrix4,c._normalMatrixArray=new Float32Array(9),c._modelViewMatrixArray=new Float32Array(16),c._objectMatrixArray=new Float32Array(16),c.matrixWorld.flattenToArray(c._objectMatrixArray);if(c instanceof THREE.Mesh)for(f in g=c.geometry,g.geometryGroups==void 0&&
  341. O(g),g.geometryGroups){j=g.geometryGroups[f];if(!j.__webglVertexBuffer){var h=j;h.__webglVertexBuffer=k.createBuffer();h.__webglNormalBuffer=k.createBuffer();h.__webglTangentBuffer=k.createBuffer();h.__webglColorBuffer=k.createBuffer();h.__webglUVBuffer=k.createBuffer();h.__webglUV2Buffer=k.createBuffer();h.__webglSkinVertexABuffer=k.createBuffer();h.__webglSkinVertexBBuffer=k.createBuffer();h.__webglSkinIndicesBuffer=k.createBuffer();h.__webglSkinWeightsBuffer=k.createBuffer();h.__webglFaceBuffer=
  342. k.createBuffer();h.__webglLineBuffer=k.createBuffer();if(h.numMorphTargets){var m=void 0,n=void 0;h.__webglMorphTargetsBuffers=[];m=0;for(n=h.numMorphTargets;m<n;m++)h.__webglMorphTargetsBuffers.push(k.createBuffer())}for(var h=j,m=c,o=void 0,p=void 0,t=void 0,u=t=void 0,v=void 0,w=void 0,A=w=n=0,x=t=p=void 0,B=x=p=o=void 0,t=void 0,u=m.geometry,v=u.faces,x=h.faces,o=0,p=x.length;o<p;o++)t=x[o],t=v[t],t instanceof THREE.Face3?(n+=3,w+=1,A+=3):t instanceof THREE.Face4&&(n+=4,w+=2,A+=4);for(var o=h,
  343. p=m,z=x=v=void 0,E=void 0,z=void 0,t=[],v=0,x=p.materials.length;v<x;v++)if(z=p.materials[v],z instanceof THREE.MeshFaceMaterial){z=0;for(l=o.materials.length;z<l;z++)(E=o.materials[z])&&t.push(E)}else(E=z)&&t.push(E);o=t;h.__materials=o;a:{v=p=void 0;x=o.length;for(p=0;p<x;p++)if(v=o[p],v.map||v.lightMap||v instanceof THREE.MeshShaderMaterial){p=!0;break a}p=!1}a:{x=v=void 0;t=o.length;for(v=0;v<t;v++)if(x=o[v],!(x instanceof THREE.MeshBasicMaterial&&!x.envMap||x instanceof THREE.MeshDepthMaterial)){x=
  344. x&&x.shading!=void 0&&x.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}x=!1}a:{t=v=void 0;z=o.length;for(v=0;v<z;v++)if(t=o[v],t.vertexColors){t=t.vertexColors;break a}t=!1}h.__vertexArray=new Float32Array(n*3);if(x)h.__normalArray=new Float32Array(n*3);if(u.hasTangents)h.__tangentArray=new Float32Array(n*4);if(t)h.__colorArray=new Float32Array(n*3);if(p){if(u.faceUvs.length>0||u.faceVertexUvs.length>0)h.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>
  345. 1)h.__uv2Array=new Float32Array(n*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)h.__skinVertexAArray=new Float32Array(n*4),h.__skinVertexBArray=new Float32Array(n*4),h.__skinIndexArray=new Float32Array(n*4),h.__skinWeightArray=new Float32Array(n*4);h.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));h.__lineArray=new Uint16Array(A*2);if(h.numMorphTargets){h.__morphTargetsArrays=[];u=0;for(v=h.numMorphTargets;u<v;u++)h.__morphTargetsArrays.push(new Float32Array(n*
  346. 3))}h.__needsSmoothNormals=x==THREE.SmoothShading;h.__uvType=p;h.__vertexColorType=t;h.__normalType=x;h.__webglFaceCount=w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0);h.__webglLineCount=A*2;u=0;for(v=o.length;u<v;u++)if(p=o[u],p.attributes){if(h.__webglCustomAttributes===void 0)h.__webglCustomAttributes={};for(a in p.attributes){t=p.attributes[a];x={};for(B in t)x[B]=t[B];if(!x.__webglInitialized||x.createUniqueBuffers)x.__webglInitialized=!0,w=1,x.type==="v2"?w=2:x.type==="v3"?w=3:x.type===
  347. "v4"?w=4:x.type==="c"&&(w=3),x.size=w,x.array=new Float32Array(n*w),x.buffer=k.createBuffer(),x.buffer.belongsToAttribute=a,t.needsUpdate=!0,x.__original=t;h.__webglCustomAttributes[a]=x}}h.__inittedArrays=!0;g.__dirtyVertices=!0;g.__dirtyMorphTargets=!0;g.__dirtyElements=!0;g.__dirtyUvs=!0;g.__dirtyNormals=!0;g.__dirtyTangents=!0;g.__dirtyColors=!0}c instanceof THREE.ShadowVolume?D(e.__webglShadowVolumes,j,c):D(e.__webglObjects,j,c)}else if(c instanceof THREE.LensFlare)D(e.__webglLensFlares,void 0,
  348. c);else if(c instanceof THREE.Ribbon){g=c.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=k.createBuffer(),f.__webglColorBuffer=k.createBuffer(),f=g,j=f.vertices.length,f.__vertexArray=new Float32Array(j*3),f.__colorArray=new Float32Array(j*3),f.__webglVertexCount=j,g.__dirtyVertices=!0,g.__dirtyColors=!0;D(e.__webglObjects,g,c)}else if(c instanceof THREE.Line){g=c.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=k.createBuffer(),f.__webglColorBuffer=k.createBuffer(),f=g,
  349. j=f.vertices.length,f.__vertexArray=new Float32Array(j*3),f.__colorArray=new Float32Array(j*3),f.__webglLineCount=j,g.__dirtyVertices=!0,g.__dirtyColors=!0;D(e.__webglObjects,g,c)}else if(c instanceof THREE.ParticleSystem){g=c.geometry;if(!g.__webglVertexBuffer){f=g;f.__webglVertexBuffer=k.createBuffer();f.__webglColorBuffer=k.createBuffer();f=g;j=c;h=f.vertices.length;f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__sortArray=[];f.__webglParticleCount=h;f.__materials=
  350. j.materials;B=n=m=void 0;m=0;for(n=j.materials.length;m<n;m++)if(B=j.materials[m],B.attributes){if(f.__webglCustomAttributes===void 0)f.__webglCustomAttributes={};for(a in B.attributes){originalAttribute=B.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=
  351. 4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(h*size),attribute.buffer=k.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;f.__webglCustomAttributes[a]=attribute}}g.__dirtyVertices=!0;g.__dirtyColors=!0}D(e.__webglObjects,g,c)}else THREE.MarchingCubes!==void 0&&c instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}}):
  352. c instanceof THREE.Sprite&&e.__webglSprites.push(c);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];c=b;if(e instanceof THREE.ShadowVolume)G(c.__webglShadowVolumes,e);else if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)G(c.__webglObjects,e);else if(e instanceof THREE.Sprite){c=c.__webglSprites;g=void 0;for(g=c.length-1;g>=0;g--)c[g]==e&&c.splice(g,1)}else e instanceof THREE.LensFlare?G(c.__webglLensFlares,
  353. e):e instanceof THREE.MarchingCubes&&G(c.__webglObjectsImmediate,e);b.__objectsRemoved.splice(0,1)}c=0;for(e=b.__webglObjects.length;c<e;c++)C(b.__webglObjects[c].object,b);c=0;for(e=b.__webglShadowVolumes.length;c<e;c++)C(b.__webglShadowVolumes[c].object,b);c=0;for(e=b.__webglLensFlares.length;c<e;c++)C(b.__webglLensFlares[c].object,b)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW),b=="back"?k.cullFace(k.BACK):b=="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK),
  354. k.enable(k.CULL_FACE)):k.disable(k.CULL_FACE)};this.supportsVertexTextures=function(){return Ea}};
  355. 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:
  356. 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)};
  357. 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};
  358. 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};
  359. 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};
  360. THREE.ColorUtils={adjustHSV:function(b,c,e,f){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,h);h.h=THREE.ColorUtils.clamp(h.h+c,0,1);h.s=THREE.ColorUtils.clamp(h.s+e,0,1);h.v=THREE.ColorUtils.clamp(h.v+f,0,1);b.setHSV(h.h,h.s,h.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,h=b.b,j=Math.max(Math.max(e,f),h),g=Math.min(Math.min(e,f),h);if(g==j)g=e=0;else{var m=j-g,g=m/j,e=e==j?(f-h)/m:f==j?2+(h-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=g;c.v=j;return c},
  361. clamp:function(b,c,e){return b<c?c:b>e?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
  362. THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,h=e?c.geometry:c,j=b.vertices,g=h.vertices,m=b.faces,n=h.faces,p=b.faceVertexUvs[0],h=h.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,t=g.length;o<t;o++){var v=new THREE.Vertex(g[o].position.clone());e&&c.matrix.multiplyVector3(v.position);j.push(v)}o=0;for(t=n.length;o<t;o++){var g=n[o],u,w,B=g.vertexNormals,v=g.vertexColors;g instanceof THREE.Face3?u=new THREE.Face3(g.a+f,g.b+f,g.c+
  363. f):g instanceof THREE.Face4&&(u=new THREE.Face4(g.a+f,g.b+f,g.c+f,g.d+f));u.normal.copy(g.normal);e=0;for(j=B.length;e<j;e++)w=B[e],u.vertexNormals.push(w.clone());u.color.copy(g.color);e=0;for(j=v.length;e<j;e++)w=v[e],u.vertexColors.push(w.clone());u.materials=g.materials.slice();u.centroid.copy(g.centroid);m.push(u)}o=0;for(t=h.length;o<t;o++){f=h[o];m=[];e=0;for(j=f.length;e<j;e++)m.push(new THREE.UV(f[e].u,f[e].v));p.push(m)}},clone:function(b){var c=new THREE.Geometry,e,f=b.vertices,h=b.faces,
  364. j=b.faceVertexUvs[0],b=0;for(e=f.length;b<e;b++){var g=new THREE.Vertex(f[b].position.clone());c.vertices.push(g)}b=0;for(e=h.length;b<e;b++){var m=h[b],n,p,o=m.vertexNormals,t=m.vertexColors;m instanceof THREE.Face3?n=new THREE.Face3(m.a,m.b,m.c):m instanceof THREE.Face4&&(n=new THREE.Face4(m.a,m.b,m.c,m.d));n.normal.copy(m.normal);f=0;for(g=o.length;f<g;f++)p=o[f],n.vertexNormals.push(p.clone());n.color.copy(m.color);f=0;for(g=t.length;f<g;f++)p=t[f],n.vertexColors.push(p.clone());n.materials=m.materials.slice();
  365. n.centroid.copy(m.centroid);c.faces.push(n)}b=0;for(e=j.length;b<e;b++){h=j[b];n=[];f=0;for(g=h.length;f<g;f++)n.push(new THREE.UV(h[f].u,h[f].v));c.faceVertexUvs[0].push(n)}return c},randomPointInTriangle:function(b,c,e){var f,h,j,g=new THREE.Vector3,m=THREE.GeometryUtils.__v1;f=THREE.GeometryUtils.random();h=THREE.GeometryUtils.random();f+h>1&&(f=1-f,h=1-h);j=1-f-h;g.copy(b);g.multiplyScalar(f);m.copy(c);m.multiplyScalar(h);g.addSelf(m);m.copy(e);m.multiplyScalar(j);g.addSelf(m);return g},randomPointInFace:function(b,
  366. c,e){var f,h,j;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,j=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,j);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;j=c.vertices[b.c].position;var c=c.vertices[b.d].position,g;e?b._area1&&b._area2?(e=b._area1,g=b._area2):(e=THREE.GeometryUtils.triangleArea(f,h,c),g=THREE.GeometryUtils.triangleArea(h,j,c),b._area1=e,b._area2=g):(e=THREE.GeometryUtils.triangleArea(f,
  367. h,c),g=THREE.GeometryUtils.triangleArea(h,j,c));return THREE.GeometryUtils.random()*(e+g)<e?THREE.GeometryUtils.randomPointInTriangle(f,h,c):THREE.GeometryUtils.randomPointInTriangle(h,j,c)}},randomPointsInGeometry:function(b,c){function e(b){function c(e,f){if(f<e)return e;var g=e+Math.floor((f-e)/2);return p[g]>b?c(e,g-1):p[g]<b?c(g+1,f):g}return c(0,p.length-1)}var f,h,j=b.faces,g=b.vertices,m=j.length,n=0,p=[],o,t,v,u;for(h=0;h<m;h++){f=j[h];if(f instanceof THREE.Face3)o=g[f.a].position,t=g[f.b].position,
  368. v=g[f.c].position,f._area=THREE.GeometryUtils.triangleArea(o,t,v);else if(f instanceof THREE.Face4)o=g[f.a].position,t=g[f.b].position,v=g[f.c].position,u=g[f.d].position,f._area1=THREE.GeometryUtils.triangleArea(o,t,u),f._area2=THREE.GeometryUtils.triangleArea(t,v,u),f._area=f._area1+f._area2;n+=f._area;p[h]=n}f=[];g={};for(h=0;h<c;h++)m=THREE.GeometryUtils.random()*n,m=e(m),f[h]=THREE.GeometryUtils.randomPointInFace(j[m],b,!0),g[m]?g[m]+=1:g[m]=1;return f},triangleArea:function(b,c,e){var f,h=THREE.GeometryUtils.__v1;
  369. h.sub(b,c);f=h.length();h.sub(b,e);b=h.length();h.sub(c,e);e=h.length();c=0.5*(f+b+e);return Math.sqrt(c*(c-f)*(c-b)*(c-e))},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.GeometryUtils.random=THREE.GeometryUtils.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
  370. THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,h=new THREE.Texture(f,c);f.onload=function(){h.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return h},loadTextureCube:function(b,c,e){var f,h=[],j=new THREE.Texture(h,c),c=h.loadCount=0;for(f=b.length;c<f;++c)h[c]=new Image,h[c].onload=function(){h.loadCount+=1;if(h.loadCount==6)j.needsUpdate=!0;e&&e(this)},h[c].crossOrigin="",h[c].src=b[c];return j}};
  371. THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
  372. 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}"},
  373. 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",
  374. 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;",
  375. 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( vec3( 0.0 ), 1.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( vec3( 0.0 ), 1.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;",
  376. 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}"},
  377. 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",
  378. 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}"},
  379. 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}"},
  380. 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}",
  381. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var c,e,f,h,j=2*Math.ceil(b*3)+1;j>25&&(j=25);h=(j-1)*0.5;e=Array(j);for(c=f=0;c<j;++c)e[c]=Math.exp(-((c-h)*(c-h))/(2*b*b)),f+=e[c];for(c=0;c<j;++c)e[c]/=f;return e}};
  382. THREE.AnimationHandler=function(){var b=[],c={},e={update:function(c){for(var e=0;e<b.length;e++)b[e].update(c)},addToUpdate:function(c){b.indexOf(c)===-1&&b.push(c)},removeFromUpdate:function(c){c=b.indexOf(c);c!==-1&&b.splice(c,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<
  383. 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=
  384. {};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*
  385. 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 c=[];if(b instanceof THREE.SkinnedMesh)for(var e=0;e<b.bones.length;e++)c.push(b.bones[e]);else f(b,c);return c}},f=function(b,c){c.push(b);for(var e=0;e<b.children.length;e++)f(b.children[e],c)};e.LINEAR=0;e.CATMULLROM=1;e.CATMULLROM_FORWARD=
  386. 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};
  387. 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,h;for(e=0;e<f;e++){h=this.hierarchy[e];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)h.useQuaternion=!0;h.matrixAutoUpdate=!0;if(h.animationCache===void 0)h.animationCache={},h.animationCache.prevKey={pos:0,rot:0,scl:0},h.animationCache.nextKey={pos:0,rot:0,scl:0},h.animationCache.originalMatrix=h instanceof
  388. THREE.Bone?h.skinMatrix:h.matrix;var j=h.animationCache.prevKey;h=h.animationCache.nextKey;j.pos=this.data.hierarchy[e].keys[0];j.rot=this.data.hierarchy[e].keys[0];j.scl=this.data.hierarchy[e].keys[0];h.pos=this.getNextKeyWith("pos",e,1);h.rot=this.getNextKeyWith("rot",e,1);h.scl=this.getNextKeyWith("scl",e,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
  389. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  390. 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};
  391. THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,h,j,g,m,n,p,o=this.data.JIT.hierarchy,t,v;this.currentTime+=b*this.timeScale;v=this.currentTime;t=this.currentTime%=this.data.length;p=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,w=this.hierarchy.length;u<w;u++)if(b=this.hierarchy[u],n=b.animationCache,this.JITCompile&&o[u][p]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=o[u][p],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
  392. !1):(b.matrix=o[u][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];g=n.prevKey[e];m=n.nextKey[e];if(m.time<=v){if(t<v)if(this.loop){g=this.data.hierarchy[u].keys[0];for(m=this.getNextKeyWith(e,u,1);m.time<t;)g=m,m=this.getNextKeyWith(e,u,m.index+1)}else{this.stop();return}else{do g=m,m=this.getNextKeyWith(e,u,m.index+1);while(m.time<
  393. t)}n.prevKey[e]=g;n.nextKey[e]=m}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(t-g.time)/(m.time-g.time);h=g[e];j=m[e];if(f<0||f>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(j[0]-h[0])*f,e.y=h[1]+(j[1]-h[1])*f,e.z=h[2]+(j[2]-h[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
  394. this.getPrevKeyWith("pos",u,g.index-1).pos,this.points[1]=h,this.points[2]=j,this.points[3]=this.getNextKeyWith("pos",u,m.index+1).pos,f=f*0.33+0.33,h=this.interpolateCatmullRom(this.points,f),e.x=h[0],e.y=h[1],e.z=h[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===
  395. "rot")THREE.Quaternion.slerp(h,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(j[0]-h[0])*f,e.y=h[1]+(j[1]-h[1])*f,e.z=h[2]+(j[2]-h[2])*f}}if(this.JITCompile&&o[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;u<this.hierarchy.length;u++)o[u][p]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
  396. THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],h,j,g,m,n,p;h=(b.length-1)*c;j=Math.floor(h);h-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=h*h;g=h*e;f[0]=this.interpolate(j[0],m[0],n[0],p[0],h,e,g);f[1]=this.interpolate(j[1],m[1],n[1],p[1],h,e,g);f[2]=this.interpolate(j[2],m[2],n[2],p[2],h,e,g);return f};
  397. THREE.Animation.prototype.interpolate=function(b,c,e,f,h,j,g){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*g+(-3*(c-e)-2*b-f)*j+b*h+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]};
  398. 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]};
  399. 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.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=
  400. 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!==
  401. 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();
  402. 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=
  403. !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 82:this.moveUp=!0;break;case 70:this.moveDown=!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;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=
  404. function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=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);
  405. this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown&&this.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);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;var b=this.target.position,h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=
  406. 1;this.constrainVertical&&(b=3.14/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*b);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=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.z+100*Math.sin(this.phi)*
  407. 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),!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)};
  408. THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;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))};
  409. THREE.PathCamera=function(b){function c(b,c,e,f){var g={name:e,fps:0.6,length:f,hierarchy:[]},j,h=c.getControlPointsArray(),m=c.getLength(),n=h.length,E=0;j=n-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[j]={time:f,pos:h[j],rot:[0,0,0,1],scl:[1,1,1]};for(j=1;j<n-1;j++)E=f*m.chunks[j]/m.total,c.keys[j]={time:E,pos:h[j]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(b,e,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,c){var e,
  410. f,g=new THREE.Geometry;for(e=0;e<b.points.length*c;e++)f=e/(b.points.length*c),f=b.getPoint(f),g.vertices[e]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return g}function f(b,c){var f=e(c,10),g=e(c,10),j=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,j);particleObj=new THREE.ParticleSystem(g,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);g=new THREE.SphereGeometry(1,
  411. 16,8);j=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(g,j),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.005;this.lookHorizontal=
  412. 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!==
  413. 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=
  414. window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var h=Math.PI*2,j=Math.PI/180;this.update=function(b,c,e){var f,g;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)*j;this.theta=this.lon*j;f=this.phi%h;this.phi=f>=0?f:f+h;f=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var m=g[1]-g[0];this.phi=
  415. TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/m)*m+g[0];f=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;m=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/m)*m+g[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,c,e)};this.onMouseMove=function(b){this.mouseX=
  416. 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}),g=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,g);b.position.set(0,10,0);this.animation=
  417. 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,c){return function(){c.apply(b,arguments)}}(this,this.onMouseMove),
  418. !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
  419. THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward=
  420. 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=
  421. 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()}};
  422. 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;
  423. 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(),h=c.size[0]/2,j=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-h)/h;this.moveState.pitchDown=(b.clientY-
  424. c.offset[1]-j)/j;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*
  425. 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||
  426. 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!=
  427. 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,
  428. 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;
  429. 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 h=new THREE.Vector3,j=new THREE.Vector3,g=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,o=0,t=0,v=0,u=0,w=0,B=window.innerWidth/2,x=window.innerHeight/2;this.update=
  430. 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*u),this.rotateVertically(b*w));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);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();
  431. else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();g.copy(this.forward);j.set(0,1,0);h.cross(j,g).normalize();j.cross(g,h).normalize();this.matrix.n11=h.x;this.matrix.n12=j.x;this.matrix.n13=g.x;this.matrix.n21=h.y;this.matrix.n22=j.y;this.matrix.n23=g.y;this.matrix.n31=h.z;this.matrix.n32=j.z;this.matrix.n33=g.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);
  432. 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-=
  433. this.matrix.n23*b;this.position.z-=this.matrix.n33*b};this.rotateHorizontally=function(b){h.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);h.multiplyScalar(b);this.forward.subSelf(h);this.forward.normalize()};this.rotateVertically=function(b){j.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);j.multiplyScalar(b);this.forward.addSelf(j);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
  434. function(b){u=(b.clientX-B)/window.innerWidth;w=(b.clientY-x)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=1;break;case 2:o=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=0;break;case 2:o=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:o=1;break;case 37:case 65:t=-1;break;
  435. case 40:case 83:o=-1;break;case 39:case 68:t=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:t=0;break;case 40:case 83:o=0;break;case 39:case 68:t=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;
  436. THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
  437. THREE.TrackballCamera=function(b){function c(b,c){return function(){c.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||
  438. !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,h=new THREE.Vector3,j=new THREE.Vector3,g=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,c){return new THREE.Vector2((b-
  439. this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(b,c){var e=new THREE.Vector3((b-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),f=e.length();f>1?e.normalize():e.z=Math.sqrt(1-f*f);h=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(h).setLength(e.x));f.addSelf(h.setLength(e.z));return f};
  440. this.rotateCamera=function(){var b=Math.acos(j.dot(g)/j.length()/g.length());if(b){var c=(new THREE.Vector3).cross(j,g).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(h);e.multiplyVector3(this.up);e.multiplyVector3(g);this.staticMoving?j=g:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(n.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(h.multiplyScalar(b),this.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)};
  441. this.panCamera=function(){var b=o.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(h.length()*this.panSpeed);var c=h.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);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),
  442. h.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,h.setLength(this.minDistance))};this.update=function(b,c,e){h=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,h);this.checkDistances();this.supr.update.call(this,b,c,e)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
  443. c(this,function(b){e&&(j=g=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?g=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();
  444. b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?j=g=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=
  445. 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;
  446. 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};
  447. 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;var c=[],e,f=this.getPoint(0),h,j=0;for(h=1;h<=b;h++)e=this.getPoint(h/b),j+=e.distanceTo(f),c.push(j),f=e;return this.cacheLengths=c};
  448. THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,h=e.length,j;for(j=c?c:b*e[h-1];f<h;){if(e[f]>j)break;f++}return f/h};THREE.LineCurve=function(b,c,e,f){this.x1=b;this.y1=c;this.x2=e;this.y2=f};THREE.LineCurve.prototype=new THREE.Curve;THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){return new THREE.Vector2(this.x1+(this.x2-this.x1)*b,this.y1+(this.y2-this.y1)*b)};
  449. THREE.QuadraticBezierCurve=function(b,c,e,f,h,j){this.x0=b;this.y0=c;this.x1=e;this.y1=f;this.x2=h;this.y2=j};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;THREE.QuadraticBezierCurve.prototype.getPoint=function(b){var c;c=THREE.Shape.Utils.b2(b,this.x0,this.x1,this.x2);b=THREE.Shape.Utils.b2(b,this.y0,this.y1,this.y2);return new THREE.Vector2(c,b)};
  450. 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,h,j,g,m){this.x0=b;this.y0=c;this.x1=e;this.y1=f;this.x2=h;this.y2=j;this.x3=g;this.y3=m};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;
  451. THREE.CubicBezierCurve.prototype.getPoint=function(b){var c;c=THREE.Shape.Utils.b3(b,this.x0,this.x1,this.x2,this.x3);b=THREE.Shape.Utils.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;
  452. THREE.SplineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2,e=[],f=this.points,h;h=(f.length-1)*b;b=Math.floor(h);h-=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,h);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,h);return c};THREE.ArcCurve=function(b,c,e,f,h,j){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=h;this.aClockwise=j};
  453. 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))};
  454. 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,h){var b=(e-b)*0.5,f=(f-c)*0.5,j=h*h;return(2*c-2*e+b+f)*h*j+(-3*c+3*e-2*b-f)*j+b*h+c}};THREE.Curve.create=function(b,c){b.prototype=new THREE.Curve;b.prototype.constructor=b;b.prototype.getPoint=c;return b};
  455. THREE.LineCurve3=THREE.Curve.create(function(b,c){this.v1=b;this.v2=c},function(b){var c=new THREE.Vector3;c.sub(v2,v1);c.multiplyScalar(b);c.addSelf(this.v1);return c});THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,c,e){this.v0=b;this.v1=c;this.v2=e},function(b){var c,e;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);e=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,e,b)});
  456. 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"};THREE.Path.prototype.fromPoints=function(b){this.moveTo(b[0].x,b[0].y);var c,e=b.length;for(c=1;c<e;c++)this.lineTo(b[c].x,b[c].y)};
  457. THREE.Path.prototype.moveTo=function(){var b=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:b})};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.LineCurve(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})};
  458. THREE.Path.prototype.quadraticCurveTo=function(b,c,e,f){var h=Array.prototype.slice.call(arguments),j=this.actions[this.actions.length-1].args,j=new THREE.QuadraticBezierCurve(j[j.length-2],j[j.length-1],b,c,e,f);this.curves.push(j);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:h,curve:j})};
  459. THREE.Path.prototype.bezierCurveTo=function(b,c,e,f,h,j){var g=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,h,j);this.curves.push(m);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g,curve:m})};
  460. 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})};
  461. THREE.Path.prototype.arc=function(b,c,e,f,h,j){var g=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(b,c,e,f,h,j));this.actions.push({action:THREE.PathActions.ARC,args:g})};THREE.Path.prototype.getSpacedPoints=function(b,c){b||(b=40);for(var e=[],f=0;f<b;f++)e.push(this.getPoint(f/b));c&&e.push(e[0]);return e};
  462. THREE.Path.prototype.getPoints=function(b,c){var b=b||12,e=[],f,h,j,g,m,n,p,o,t,v,u,w,B;f=0;for(h=this.actions.length;f<h;f++)switch(j=this.actions[f],g=j.action,j=j.args,g){case THREE.PathActions.LINE_TO:e.push(new THREE.Vector2(j[0],j[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:m=j[2];n=j[3];t=j[0];v=j[1];e.length>0?(g=e[e.length-1],u=g.x,w=g.y):(g=this.actions[f-1].args,u=g[g.length-2],w=g[g.length-1]);for(g=1;g<=b;g++)B=g/b,j=THREE.Shape.Utils.b2(B,u,t,m),B=THREE.Shape.Utils.b2(B,w,v,
  463. n),e.push(new THREE.Vector2(j,B));break;case THREE.PathActions.BEZIER_CURVE_TO:m=j[4];n=j[5];t=j[0];v=j[1];p=j[2];o=j[3];e.length>0?(g=e[e.length-1],u=g.x,w=g.y):(g=this.actions[f-1].args,u=g[g.length-2],w=g[g.length-1]);for(g=1;g<=b;g++)B=g/b,j=THREE.Shape.Utils.b3(B,u,t,p,m),B=THREE.Shape.Utils.b3(B,w,v,o,n),e.push(new THREE.Vector2(j,B));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[f-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];B=b*j[0].length;g=g.concat(j[0]);j=new THREE.SplineCurve(g);
  464. for(g=1;g<=B;g++)e.push(j.getPointAt(g/B));break;case THREE.PathActions.ARC:g=this.actions[f-1].args;m=j[0];n=j[1];p=j[2];t=j[3];B=j[4];v=!!j[5];o=g[g.length-2];u=g[g.length-1];g.length==0&&(o=u=0);w=B-t;var x=b*2;for(g=1;g<=x;g++)B=g/x,v||(B=1-B),B=t+B*w,j=o+m+p*Math.cos(B),B=u+n+p*Math.sin(B),e.push(new THREE.Vector2(j,B))}c&&e.push(e[0]);return e};
  465. THREE.Path.prototype.getBoundingBox=function(){var b=this.getPoints(),c,e,f,h;c=e=Number.NEGATIVE_INFINITY;f=h=Number.POSITIVE_INFINITY;var j,g,m,n;n=new THREE.Vector2;g=0;for(m=b.length;g<m;g++){j=b[g];if(j.x>c)c=j.x;else if(j.x<f)f=j.x;if(j.y>e)e=j.y;else if(j.y<e)h=j.y;n.addSelf(j.x,j.y)}return{minX:f,minY:h,maxX:c,maxY:e,centroid:n.divideScalar(m)}};
  466. 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};THREE.Path.prototype.getLength=function(){var b=[],c=0,e,f=this.curves.length;for(e=0;e<f;e++)c+=this.curves[e].getLength(),b.push(c);this.sums=b;return c};THREE.Path.prototype.createPointsGeometry=function(b){return this.createGeometry(this.getPoints(b,!0))};
  467. THREE.Path.prototype.createSpacedPointsGeometry=function(b){return this.createGeometry(this.getSpacedPoints(b,!0))};THREE.Path.prototype.createGeometry=function(b){for(var c=new THREE.Geometry,e=0;e<b.length;e++)c.vertices.push(new THREE.Vertex(new THREE.Vector3(b[e].x,b[e].y,0)));return c};
  468. 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.getBoundingBox(),e=this.getPoints(),f,h,j,g,m,n;f=0;for(h=e.length;f<h;f++)j=e[f],g=j.x,m=j.y,n=g/c.maxX,g=b.getPoint(n),m=b.getNormalVector(n).multiplyScalar(m),j.x=g.x+m.x,j.y=g.y+m.y;return e};
  469. THREE.Path.prototype.nltransform=function(b,c,e,f,h,j){var g=this.getPoints(),m,n,p,o,t;m=0;for(n=g.length;m<n;m++)p=g[m],o=p.x,t=p.y,p.x=b*o+c*t+e,p.y=f*t+h*o+j;return g};
  470. THREE.Path.prototype.debug=function(b){var c=this.getBoundingBox();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,h,b=0;for(e=this.actions.length;b<e;b++)f=this.actions[b],h=f.args,f=f.action,f!=THREE.PathActions.CSPLINE_THRU&&c[f].apply(c,h);c.stroke();c.closePath();c.strokeStyle="red";f=
  471. this.getPoints();b=0;for(e=f.length;b<e;b++)h=f[b],c.beginPath(),c.arc(h.x,h.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
  472. THREE.Path.prototype.toShapes=function(){var b,c,e,f,h=[],j=new THREE.Path;b=0;for(c=this.actions.length;b<c;b++)e=this.actions[b],f=e.args,e=e.action,e==THREE.PathActions.MOVE_TO&&j.actions.length!=0&&(h.push(j),j=new THREE.Path),j[e].apply(j,f);j.actions.length!=0&&h.push(j);if(h.length==0)return[];var g,j=[];if(THREE.Shape.Utils.isClockWise(h[0].getPoints())){b=0;for(c=h.length;b<c;b++)f=h[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(g&&j.push(g),g=new THREE.Shape,g.actions=f.actions,g.curves=
  473. f.curves):g.holes.push(f);j.push(g)}else{g=new THREE.Shape;b=0;for(c=h.length;b<c;b++)f=h[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(g.actions=f.actions,g.curves=f.curves,j.push(g),g=new THREE.Shape):g.holes.push(f)}return j};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)};
  474. THREE.Shape.prototype.getPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getPoints(b);return f};THREE.Shape.prototype.getSpacedPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getSpacedPoints(b);return f};THREE.Shape.prototype.extractAllPoints=function(b){return{shape:this.getPoints(b),holes:this.getPointsHoles(b)}};THREE.Shape.prototype.extractAllSpacedPoints=function(b){return{shape:this.getSpacedPoints(b),holes:this.getSpacedPointsHoles(b)}};
  475. THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),h,j,g,m,n,p,o,t,v,u,w=[];for(n=0;n<c.length;n++){p=c[n];f=f.concat(p);j=Number.POSITIVE_INFINITY;for(h=0;h<p.length;h++){v=p[h];u=[];for(t=0;t<e.length;t++)o=e[t],o=v.distanceToSquared(o),u.push(o),o<j&&(j=o,g=h,m=t)}h=m-1>=0?m-1:e.length-1;j=g-1>=0?g-1:p.length-1;var B=[p[g],e[m],e[h]];t=THREE.FontUtils.Triangulate.area(B);var x=[p[g],p[j],e[m]];v=THREE.FontUtils.Triangulate.area(x);u=m;o=g;m+=1;g+=-1;m<0&&(m+=e.length);m%=
  476. e.length;g<0&&(g+=p.length);g%=p.length;h=m-1>=0?m-1:e.length-1;j=g-1>=0?g-1:p.length-1;B=[p[g],e[m],e[h]];B=THREE.FontUtils.Triangulate.area(B);x=[p[g],p[j],e[m]];x=THREE.FontUtils.Triangulate.area(x);t+v>B+x&&(m=u,g=o,m<0&&(m+=e.length),m%=e.length,g<0&&(g+=p.length),g%=p.length,h=m-1>=0?m-1:e.length-1,j=g-1>=0?g-1:p.length-1);t=e.slice(0,m);v=e.slice(m);u=p.slice(g);o=p.slice(0,g);j=[p[g],p[j],e[m]];w.push([p[g],e[m],e[h]]);w.push(j);e=t.concat(u).concat(o).concat(v)}return{shape:e,isolatedPts:w,
  477. allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),j,g,m,n,p={};j=0;for(g=f.length;j<g;j++)n=f[j].x+":"+f[j].y,p[n]!==void 0&&console.log("Duplicate point",n),p[n]=j;j=0;for(g=e.length;j<g;j++){m=e[j];for(f=0;f<3;f++)n=m[f].x+":"+m[f].y,n=p[n],n!==void 0&&(m[f]=n)}j=0;for(g=h.length;j<g;j++){m=h[j];for(f=0;f<3;f++)n=m[f].x+":"+m[f].y,n=p[n],n!==void 0&&(m[f]=n)}return e.concat(h)},isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<
  478. 0},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*(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,h){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,h)}};
  479. THREE.TextPath=function(b,c){THREE.Path.call(this);this.parameters=c||{};this.set(b)};THREE.TextPath.prototype.set=function(b,c){this.text=b;var c=c||this.parameters,e=c.curveSegments!==void 0?c.curveSegments:4,f=c.font!==void 0?c.font:"helvetiker",h=c.weight!==void 0?c.weight:"normal",j=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=e;THREE.FontUtils.face=f;THREE.FontUtils.weight=h;THREE.FontUtils.style=j};
  480. THREE.TextPath.prototype.toShapes=function(){for(var b=THREE.FontUtils.drawText(this.text).paths,c=[],e=0,f=b.length;e<f;e++)c=c.concat(b[e].toShapes());return c};
  481. THREE.CubeGeometry=function(b,c,e,f,h,j,g,m,n){function p(b,c,e,g,m,n,p,t){var u,v,w=f||1,B=h||1,S=m/2,z=n/2,ea=o.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")u="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")u="y",B=j||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")u="x",w=j||1;var R=w+1,P=B+1;m/=w;var k=n/B;for(v=0;v<P;v++)for(n=0;n<R;n++){var K=new THREE.Vector3;K[b]=(n*m-S)*e;K[c]=(v*k-z)*g;K[u]=p;o.vertices.push(new THREE.Vertex(K))}for(v=0;v<B;v++)for(n=0;n<w;n++)o.faces.push(new THREE.Face4(n+R*
  482. v+ea,n+R*(v+1)+ea,n+1+R*(v+1)+ea,n+1+R*v+ea,null,null,t)),o.faceVertexUvs[0].push([new THREE.UV(n/w,v/B),new THREE.UV(n/w,(v+1)/B),new THREE.UV((n+1)/w,(v+1)/B),new THREE.UV((n+1)/w,v/B)])}THREE.Geometry.call(this);var o=this,t=b/2,v=c/2,u=e/2,m=m?-1:1;if(g!==void 0)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([g])}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]=
  483. n[B]);this.sides.px&&p("z","y",1*m,-1,e,c,-t,this.materials[0]);this.sides.nx&&p("z","y",-1*m,-1,e,c,t,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,u,this.materials[4]);this.sides.nz&&p("x","y",-1*m,-1,b,c,-u,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=o.vertices.length;e<f;e++){for(var g=o.vertices[e],j=!1,h=0,m=b.length;h<m;h++){var n=b[h];if(g.position.x==n.position.x&&
  484. g.position.y==n.position.y&&g.position.z==n.position.z){c[e]=h;j=!0;break}}if(!j)c[e]=b.length,b.push(new THREE.Vertex(g.position.clone()))}e=0;for(f=o.faces.length;e<f;e++)g=o.faces[e],g.a=c[g.a],g.b=c[g.b],g.c=c[g.c],g.d=c[g.d];o.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
  485. THREE.CylinderGeometry=function(b,c,e,f,h,j){function g(b,c,e){m.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}THREE.Geometry.call(this);var m=this,n,p=Math.PI*2,o=f/2;for(n=0;n<b;n++)g(Math.sin(p*n/b)*c,Math.cos(p*n/b)*c,-o);for(n=0;n<b;n++)g(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){g(0,0,-o-(j||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){g(0,0,o+
  486. (h||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],h=this.vertices[e.a],j=this.vertices[e.b],o=this.vertices[e.c],t=this.vertices[e.d];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(j.position.x,j.position.y)/p,0.5+j.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/p,0.5+o.position.z/
  487. f));e instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(t.position.x,t.position.y)/p,0.5+t.position.z/f));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,h;for(e=0;e<f;e++)h=b[e],this.addShape(h,c)}};
  488. THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
  489. THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,g=THREE.ExtrudeGeometry.__v2,j=THREE.ExtrudeGeometry.__v3,h=THREE.ExtrudeGeometry.__v4,k=THREE.ExtrudeGeometry.__v5,m=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);g.set(b.x-e.x,b.y-e.y);f=f.normalize();g=g.normalize();j.set(-f.y,f.x);h.set(g.y,-g.x);k.copy(b).addSelf(j);m.copy(b).addSelf(h);if(k.equals(m))return h.clone();
  490. k.copy(c).addSelf(j);m.copy(e).addSelf(h);j=f.dot(h);h=m.subSelf(k).dot(h);j==0&&(console.log("Either infinite or no solutions!"),h==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));h/=j;if(h<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(h).addSelf(k).subSelf(b).clone()}function h(b){for(D=b.length;--D>=0;){$=D;Y=D-1;Y<0&&(Y=b.length-
  491. 1);for(var c=0,c=0;c<u+o*2;c++){var e=ea*c,f=ea*(c+1),g=ha+$+e,e=ha+Y+e,j=ha+Y+f,f=ha+$+f;g+=C;e+=C;j+=C;f+=C;J.faces.push(new THREE.Face4(g,e,j,f))}}}function j(b,c,e){J.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function g(b,c,e){b+=C;c+=C;e+=C;J.faces.push(new THREE.Face3(b,c,e))}var m=c.amount!==void 0?c.amount:100,n=c.bevelThickness!==void 0?c.bevelThickness:6,p=c.bevelSize!==void 0?c.bevelSize:n-2,o=c.bevelSegments!==void 0?c.bevelSegments:3,t=c.bevelEnabled!==void 0?c.bevelEnabled:
  492. !0,v=c.curveSegments!==void 0?c.curveSegments:12,u=c.steps!==void 0?c.steps:1,w=c.path!==void 0?c.path:null,B,x=!1;if(w)B=w.getPoints(v),u=B.length,x=!0,t=!1;t||(p=n=o=0);var A,E,F,J=this,C=this.vertices.length,v=b.extractAllPoints(v),w=v.shape,v=v.holes,G=!THREE.Shape.Utils.isClockWise(w);if(G){w=w.reverse();E=0;for(F=v.length;E<F;E++)A=v[E],THREE.Shape.Utils.isClockWise(A)&&(v[E]=A.reverse());G=!1}var G=THREE.Shape.Utils.triangulateShape(w,v),O=w;E=0;for(F=v.length;E<F;E++)A=v[E],w=w.concat(A);
  493. var D,I,V,da,S,z,ea=w.length,R=G.length,P=[];D=0;I=O.length;$=I-1;for(Y=D+1;D<I;D++,$++,Y++)$==I&&($=0),Y==I&&(Y=0),P[D]=f(O[D],O[$],O[Y]);var k=[],K,X=P.concat();E=0;for(F=v.length;E<F;E++){A=v[E];K=[];D=0;I=A.length;$=I-1;for(Y=D+1;D<I;D++,$++,Y++)$==I&&($=0),Y==I&&(Y=0),K[D]=f(A[D],A[$],A[Y]);k.push(K);X=X.concat(K)}for(V=0;V<o;V++){da=V/o;S=n*(1-da);da=p*Math.sin(da*Math.PI/2);D=0;for(I=O.length;D<I;D++)z=e(O[D],P[D],da),j(z.x,z.y,-S);E=0;for(F=v.length;E<F;E++){A=v[E];K=k[E];D=0;for(I=A.length;D<
  494. I;D++)z=e(A[D],K[D],da),j(z.x,z.y,-S)}}da=p;for(D=0;D<ea;D++)z=t?e(w[D],X[D],da):w[D],x?j(z.x,z.y+B[0].y,B[0].x):j(z.x,z.y,0);for(V=1;V<=u;V++)for(D=0;D<ea;D++)z=t?e(w[D],X[D],da):w[D],x?j(z.x,z.y+B[V-1].y,B[V-1].x):j(z.x,z.y,m/u*V);for(V=o-1;V>=0;V--){da=V/o;S=n*(1-da);da=p*Math.sin(da*Math.PI/2);D=0;for(I=O.length;D<I;D++)z=e(O[D],P[D],da),j(z.x,z.y,m+S);E=0;for(F=v.length;E<F;E++){A=v[E];K=k[E];D=0;for(I=A.length;D<I;D++)z=e(A[D],K[D],da),x?j(z.x,z.y+B[u-1].y,B[u-1].x+S):j(z.x,z.y,m+S)}}if(t){n=
  495. ea*0;for(D=0;D<R;D++)m=G[D],g(m[2]+n,m[1]+n,m[0]+n);n=ea*(u+o*2);for(D=0;D<R;D++)m=G[D],g(m[0]+n,m[1]+n,m[2]+n)}else{for(D=0;D<R;D++)m=G[D],g(m[2],m[1],m[0]);for(D=0;D<R;D++)m=G[D],g(m[0]+ea*u,m[1]+ea*u,m[2]+ea*u)}var $,Y,ha=0;h(O);ha+=O.length;E=0;for(F=v.length;E<F;E++)A=v[E],h(A),ha+=A.length;this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;
  496. THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
  497. THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=h.vertices[b].position,g=h.vertices[e].position;return c((f.x+g.x)/2,(f.y+g.y)/2,(f.z+g.z)/2)}var h=this,j=new THREE.Geometry,g;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,
  498. -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,j);e(0,5,1,j);e(0,1,7,j);e(0,7,10,j);e(0,10,11,j);e(1,5,9,j);e(5,11,4,j);e(11,10,2,j);e(10,7,6,j);e(7,1,8,j);e(3,9,4,j);e(3,4,2,j);e(3,2,6,j);e(3,6,8,j);e(3,8,9,j);e(4,9,5,j);e(2,4,11,j);e(6,2,10,j);e(8,6,7,j);e(9,8,1,j);for(b=0;b<this.subdivisions;b++){g=new THREE.Geometry;for(var m in j.faces){var n=f(j.faces[m].a,j.faces[m].b),p=f(j.faces[m].b,j.faces[m].c),o=f(j.faces[m].c,j.faces[m].a);e(j.faces[m].a,n,o,g);e(j.faces[m].b,p,n,g);
  499. e(j.faces[m].c,o,p,g);e(n,p,o,g)}j.faces=g.faces}h.faces=j.faces;delete j;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
  500. 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=[],h=[],j=[],g=(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.001;n+=c){for(m=0;m<e.length;m++)n<this.angle?(e[m]=g.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),h[m]=this.vertices.length-1):h=j;n==0&&(j=f);
  501. for(m=0;m<f.length-1;m++)this.faces.push(new THREE.Face4(h[m],h[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=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
  502. THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var h,j=b/2,g=c/2,e=e||1,f=f||1,m=e+1,n=f+1;b/=e;var p=c/f;for(h=0;h<n;h++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-j,-(h*p-g),0)));for(h=0;h<f;h++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*h,c+m*(h+1),c+1+m*(h+1),c+1+m*h)),this.faceVertexUvs[0].push([new THREE.UV(c/e,h/f),new THREE.UV(c/e,(h+1)/f),new THREE.UV((c+1)/e,(h+1)/f),new THREE.UV((c+1)/e,h/f)]);this.computeCentroids();this.computeFaceNormals()};
  503. THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
  504. THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,h=Math.PI,j=Math.max(3,c||8),g=Math.max(2,e||6),c=[],e=0;e<g+1;e++){f=e/g;var m=b*Math.cos(f*h),n=b*Math.sin(f*h),p=[],o=0;for(f=0;f<j;f++){var t=2*f/j,v=n*Math.sin(t*h),t=n*Math.cos(t*h);(e==0||e==g)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,v)))-1);p.push(o)}c.push(p)}for(var u,w,B,h=c.length,e=0;e<h;e++)if(j=c[e].length,e>0)for(f=0;f<j;f++){p=f==j-1;g=c[e][p?0:f+1];m=c[e][p?j-1:f];n=c[e-1][p?
  505. j-1:f];p=c[e-1][p?0:f+1];v=e/(h-1);u=(e-1)/(h-1);w=(f+1)/j;var t=f/j,o=new THREE.UV(1-w,v),v=new THREE.UV(1-t,v),t=new THREE.UV(1-t,u),x=new THREE.UV(1-w,u);e<c.length-1&&(u=this.vertices[g].position.clone(),w=this.vertices[m].position.clone(),B=this.vertices[n].position.clone(),u.normalize(),w.normalize(),B.normalize(),this.faces.push(new THREE.Face3(g,m,n,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(B.x,B.y,B.z)])),this.faceVertexUvs[0].push([o,v,t]));e>1&&(u=
  506. this.vertices[g].position.clone(),w=this.vertices[n].position.clone(),B=this.vertices[p].position.clone(),u.normalize(),w.normalize(),B.normalize(),this.faces.push(new THREE.Face3(g,n,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(B.x,B.y,B.z)])),this.faceVertexUvs[0].push([o,t,x]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
  507. THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
  508. THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},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},drawText:function(b){for(var c=
  509. this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),j=h.length,g=[],b=0;b<j;b++){var m=new THREE.Path,m=this.extractGlyphPoints(h[b],c,e,f,m);f+=m.offset;g.push(m.path)}return{paths:g,offset:f/2}},extractGlyphPoints:function(b,c,e,f,h){var j=[],g,m,n,p,o,t,v,u,w,B,x=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(x){if(x.o){c=x._cachedOutline||(x._cachedOutline=x.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;j.push(new THREE.Vector2(m,
  510. p));h.moveTo(m,p);break;case "l":m=c[b++]*e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,p));h.lineTo(m,p);break;case "q":m=c[b++]*e+f;p=c[b++]*e;v=c[b++]*e+f;u=c[b++]*e;h.quadraticCurveTo(v,u,m,p);if(g=j[j.length-1]){o=g.x;t=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var A=g/divisions,E=THREE.Shape.Utils.b2(A,o,v,m),A=THREE.Shape.Utils.b2(A,t,u,p);j.push(new THREE.Vector2(E,A))}}break;case "b":if(m=c[b++]*e+f,p=c[b++]*e,v=c[b++]*e+f,u=c[b++]*-e,w=c[b++]*e+f,B=c[b++]*-e,h.bezierCurveTo(m,p,
  511. v,u,w,B),g=j[j.length-1]){o=g.x;t=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)A=g/divisions,E=THREE.Shape.Utils.b3(A,o,v,w,m),A=THREE.Shape.Utils.b3(A,t,u,B,p),j.push(new THREE.Vector2(E,A))}}}return{offset:x.ha*e,points:j,path:h}}}};
  512. (function(b){var c=function(b){for(var c=b.length,h=0,j=c-1,g=0;g<c;j=g++)h+=b[j].x*b[g].y-b[g].x*b[j].y;return h*0.5};b.Triangulate=function(b,f){var h=b.length;if(h<3)return null;var j=[],g=[],m=[],n,p,o;if(c(b)>0)for(p=0;p<h;p++)g[p]=p;else for(p=0;p<h;p++)g[p]=h-1-p;var t=2*h;for(p=h-1;h>2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return j}n=p;h<=n&&(n=0);p=n+1;h<=p&&(p=0);o=p+1;h<=o&&(o=0);var v;a:{v=b;var u=n,w=p,B=o,x=h,A=g,E=void 0,F=void 0,J=void 0,
  513. C=void 0,G=void 0,O=void 0,D=void 0,I=void 0,V=void 0,F=v[A[u]].x,J=v[A[u]].y,C=v[A[w]].x,G=v[A[w]].y,O=v[A[B]].x,D=v[A[B]].y;if(1.0E-10>(C-F)*(D-J)-(G-J)*(O-F))v=!1;else{for(E=0;E<x;E++)if(!(E==u||E==w||E==B)){var I=v[A[E]].x,V=v[A[E]].y,da=void 0,S=void 0,z=void 0,ea=void 0,R=void 0,P=void 0,k=void 0,K=void 0,X=void 0,$=void 0,Y=void 0,ha=void 0,da=z=R=void 0,da=O-C,S=D-G,z=F-O,ea=J-D,R=C-F,P=G-J,k=I-F,K=V-J,X=I-C,$=V-G,Y=I-O,ha=V-D,da=da*$-S*X,R=R*K-P*k,z=z*ha-ea*Y;if(da>=0&&z>=0&&R>=0){v=!1;break a}}v=
  514. !0}}if(v){j.push([b[g[n]],b[g[p]],b[g[o]]]);m.push([g[n],g[p],g[o]]);n=p;for(o=p+1;o<h;n++,o++)g[n]=g[o];h--;t=2*h}}if(f)return m;return j};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
  515. 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,h=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(h))*Math.cos(f),(this.radius+this.tube*Math.cos(h))*Math.sin(f),this.tube*Math.sin(h))));b.push([e/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(e=
  516. 1;e<=this.segmentsT;++e){var f=(this.segmentsT+1)*c+e,h=(this.segmentsT+1)*c+e-1,j=(this.segmentsT+1)*(c-1)+e-1,g=(this.segmentsT+1)*(c-1)+e;this.faces.push(new THREE.Face4(f,h,j,g));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1]),new THREE.UV(b[g][0],b[g][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
  517. THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
  518. THREE.TorusKnotGeometry=function(b,c,e,f,h,j,g){function m(b,c,e,f,g,j){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(g*(2+e)*0.5*Math.cos(b),g*(2+e)*Math.sin(b)*0.5,j*g*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=h||2;this.q=j||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;j=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
  519. this.segmentsT;++c){var n=b/this.segmentsR*2*this.p*Math.PI,g=c/this.segmentsT*2*Math.PI,h=m(n,g,this.q,this.p,this.radius,this.heightScale),n=m(n+0.01,g,this.q,this.p,this.radius,this.heightScale);e.x=n.x-h.x;e.y=n.y-h.y;e.z=n.z-h.z;f.x=n.x+h.x;f.y=n.y+h.y;f.z=n.z+h.z;j.cross(e,f);f.cross(j,e);j.normalize();f.normalize();n=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);h.x+=n*f.x+g*j.x;h.y+=n*f.y+g*j.y;h.z+=n*f.z+g*j.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(h.x,h.y,
  520. h.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,j=(c+1)%this.segmentsT,h=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][j],j=this.grid[b][j],g=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(h,e,f,j));this.faceVertexUvs[0].push([g,n,p,o])}this.computeCentroids();
  521. 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(){}};
  522. 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";
  523. 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=
  524. 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 h(b,e,g,j,h,m){var n=document.createElement("canvas");b[e]=new THREE.Texture(n);b[e].sourceFile=g;if(j){b[e].repeat.set(j[0],j[1]);if(j[0]!=1)b[e].wrapS=THREE.RepeatWrapping;if(j[1]!=
  525. 1)b[e].wrapT=THREE.RepeatWrapping}h&&b[e].offset.set(h[0],h[1]);if(m){j={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(j[m[0]]!==void 0)b[e].wrapS=j[m[0]];if(j[m[1]]!==void 0)b[e].wrapT=j[m[1]]}f(b[e],c+"/"+g)}function j(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var g,m,n;m="MeshLambertMaterial";g={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"));
  526. if(b.blending)if(b.blending=="Additive")g.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")g.blending=THREE.SubtractiveBlending;else if(b.blending=="Multiply")g.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)g.transparent=b.transparent;if(b.depthTest!==void 0)g.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")g.vertexColors=THREE.FaceColors;else if(b.vertexColors)g.vertexColors=THREE.VertexColors;if(b.colorDiffuse)g.color=j(b.colorDiffuse);
  527. else if(b.DbgColor)g.color=b.DbgColor;if(b.colorSpecular)g.specular=j(b.colorSpecular);if(b.colorAmbient)g.ambient=j(b.colorAmbient);if(b.transparency)g.opacity=b.transparency;if(b.specularCoef)g.shininess=b.specularCoef;b.mapDiffuse&&c&&h(g,"map",b.mapDiffuse,b.mapDiffuseRepeat,b.mapDiffuseOffset,b.mapDiffuseWrap);b.mapLight&&c&&h(g,"lightMap",b.mapLight,b.mapLightRepeat,b.mapLightOffset,b.mapLightWrap);b.mapNormal&&c&&h(g,"normalMap",b.mapNormal,b.mapNormalRepeat,b.mapNormalOffset,b.mapNormalWrap);
  528. b.mapSpecular&&c&&h(g,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var p=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(p.uniforms),t=g.color;m=g.specular;n=g.ambient;var v=g.shininess;o.tNormal.texture=g.normalMap;if(b.mapNormalFactor)o.uNormalScale.value=b.mapNormalFactor;if(g.map)o.tDiffuse.texture=g.map,o.enableDiffuse.value=!0;if(g.specularMap)o.tSpecular.texture=g.specularMap,o.enableSpecular.value=!0;if(g.lightMap)o.tAO.texture=
  529. g.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(t);o.uSpecularColor.value.setHex(m);o.uAmbientColor.value.setHex(n);o.uShininess.value=v;if(g.opacity)o.uOpacity.value=g.opacity;g=new THREE.MeshShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,uniforms:o,lights:!0,fog:!0})}else g=new THREE[m](g);return g},constructor:THREE.Loader};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;
  530. THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(b){var c=this,e=b.model,f=b.callback,h=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,h);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
  531. THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,h=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,h,n,p,o,t,v,u,w,B,x,A,E,F,J=b.faces;t=b.vertices;var C=b.normals,G=b.colors,O=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&O++;for(e=0;e<O;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];p=0;for(o=t.length;p<o;)v=new THREE.Vertex,v.position.x=t[p++]*c,v.position.y=
  532. t[p++]*c,v.position.z=t[p++]*c,f.vertices.push(v);p=0;for(o=J.length;p<o;){c=J[p++];t=c&1;n=c&2;e=c&4;h=c&8;u=c&16;v=c&32;B=c&64;c&=128;t?(x=new THREE.Face4,x.a=J[p++],x.b=J[p++],x.c=J[p++],x.d=J[p++],t=4):(x=new THREE.Face3,x.a=J[p++],x.b=J[p++],x.c=J[p++],t=3);if(n)n=J[p++],x.materials=f.materials[n];n=f.faces.length;if(e)for(e=0;e<O;e++)A=b.uvs[e],w=J[p++],F=A[w*2],w=A[w*2+1],f.faceUvs[e][n]=new THREE.UV(F,w);if(h)for(e=0;e<O;e++){A=b.uvs[e];E=[];for(h=0;h<t;h++)w=J[p++],F=A[w*2],w=A[w*2+1],E[h]=
  533. new THREE.UV(F,w);f.faceVertexUvs[e][n]=E}if(u)u=J[p++]*3,h=new THREE.Vector3,h.x=C[u++],h.y=C[u++],h.z=C[u],x.normal=h;if(v)for(e=0;e<t;e++)u=J[p++]*3,h=new THREE.Vector3,h.x=C[u++],h.y=C[u++],h.z=C[u],x.vertexNormals.push(h);if(B)v=J[p++],v=new THREE.Color(G[v]),x.color=v;if(c)for(e=0;e<t;e++)v=J[p++],v=new THREE.Color(G[v]),x.vertexColors.push(v);f.faces.push(x)}}})(h);(function(){var c,e,h,n;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)h=b.skinWeights[c],n=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(h,
  534. n,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)h=b.skinIndices[c],n=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(h,n,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,h,n,p,o,t,v,u,w;e=0;for(h=b.morphTargets.length;e<h;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];u=f.morphTargets[e].vertices;w=b.morphTargets[e].vertices;n=0;for(p=w.length;n<p;n+=3)o=w[n]*c,t=w[n+1]*
  535. c,v=w[n+2]*c,u.push(new THREE.Vertex(new THREE.Vector3(o,t,v)))}}if(b.morphColors!==void 0){e=0;for(h=b.morphColors.length;e<h;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];p=f.morphColors[e].colors;o=b.morphColors[e].colors;c=0;for(n=o.length;c<n;c+=3)t=new THREE.Color(16755200),t.setRGB(o[c],o[c+1],o[c+2]),p.push(t)}}})(h);(function(){if(b.edges!==void 0){var c,e,h;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],h=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
  536. f.vertices[h],e,h))}})();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;
  537. 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),h=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),j=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,e,h,f,j)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
  538. c.postMessage(b)},loadAjaxBuffers:function(b,c,e,f,h,j){var g=new XMLHttpRequest,m=f+"/"+b,n=0;g.onreadystatechange=function(){g.readyState==4?g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,e,h,c):alert("Couldn't load ["+m+"] ["+g.status+"]"):g.readyState==3?j&&(n==0&&(n=g.getResponseHeader("Content-Length")),j({total:n,loaded:g.responseText.length})):g.readyState==2&&(n=g.getResponseHeader("Content-Length"))};g.open("GET",m,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
  539. g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(b,c,e,f){var h=function(c){function e(b,c){var f=o(b,c),g=o(b,c+1),h=o(b,c+2),j=o(b,c+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 h(b,c){var e=o(b,c),f=o(b,c+1),g=o(b,c+2);return(o(b,c+3)<<24)+(g<<16)+(f<<8)+e}function n(b,c){var e=o(b,c);return(o(b,c+1)<<8)+e}function p(b,c){var e=o(b,c);return e>127?e-256:e}function o(b,
  540. c){return b.charCodeAt(c)&255}function t(c){var e,f,g;e=h(b,c);f=h(b,c+G);g=h(b,c+O);c=n(b,c+D);THREE.BinaryLoader.prototype.f3(A,e,f,g,c)}function v(c){var e,f,g,j,k,o;e=h(b,c);f=h(b,c+G);g=h(b,c+O);j=n(b,c+D);k=h(b,c+I);o=h(b,c+V);c=h(b,c+da);THREE.BinaryLoader.prototype.f3n(A,J,e,f,g,j,k,o,c)}function u(c){var e,f,g,j;e=h(b,c);f=h(b,c+S);g=h(b,c+z);j=h(b,c+ea);c=n(b,c+R);THREE.BinaryLoader.prototype.f4(A,e,f,g,j,c)}function w(c){var e,f,g,j,o,p,t,u;e=h(b,c);f=h(b,c+S);g=h(b,c+z);j=h(b,c+ea);o=
  541. n(b,c+R);p=h(b,c+P);t=h(b,c+k);u=h(b,c+K);c=h(b,c+X);THREE.BinaryLoader.prototype.f4n(A,J,e,f,g,j,o,p,t,u,c)}function B(c){var e,f;e=h(b,c);f=h(b,c+$);c=h(b,c+Y);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],C[e*2],C[e*2+1],C[f*2],C[f*2+1],C[c*2],C[c*2+1])}function x(c){var e,f,g;e=h(b,c);f=h(b,c+ha);g=h(b,c+ja);c=h(b,c+fa);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],C[e*2],C[e*2+1],C[f*2],C[f*2+1],C[g*2],C[g*2+1],C[c*2],C[c*2+1])}var A=this,E=0,F,J=[],C=[],G,O,D,I,V,da,S,z,ea,R,P,k,
  542. K,X,$,Y,ha,ja,fa,M,W,ca,ma,ka,na;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,f,c);F={signature:b.substr(E,8),header_bytes:o(b,E+8),vertex_coordinate_bytes:o(b,E+9),normal_coordinate_bytes:o(b,E+10),uv_coordinate_bytes:o(b,E+11),vertex_index_bytes:o(b,E+12),normal_index_bytes:o(b,E+13),uv_index_bytes:o(b,E+14),material_index_bytes:o(b,E+15),nvertices:h(b,E+16),nnormals:h(b,E+16+4),nuvs:h(b,E+16+8),ntri_flat:h(b,E+16+12),ntri_smooth:h(b,E+16+16),ntri_flat_uv:h(b,E+16+20),ntri_smooth_uv:h(b,
  543. E+16+24),nquad_flat:h(b,E+16+28),nquad_smooth:h(b,E+16+32),nquad_flat_uv:h(b,E+16+36),nquad_smooth_uv:h(b,E+16+40)};E+=F.header_bytes;G=F.vertex_index_bytes;O=F.vertex_index_bytes*2;D=F.vertex_index_bytes*3;I=F.vertex_index_bytes*3+F.material_index_bytes;V=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes;da=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*2;S=F.vertex_index_bytes;z=F.vertex_index_bytes*2;ea=F.vertex_index_bytes*3;R=F.vertex_index_bytes*4;P=F.vertex_index_bytes*
  544. 4+F.material_index_bytes;k=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes;K=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*2;X=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*3;$=F.uv_index_bytes;Y=F.uv_index_bytes*2;ha=F.uv_index_bytes;ja=F.uv_index_bytes*2;fa=F.uv_index_bytes*3;c=F.vertex_index_bytes*3+F.material_index_bytes;na=F.vertex_index_bytes*4+F.material_index_bytes;M=F.ntri_flat*c;W=F.ntri_smooth*(c+F.normal_index_bytes*3);ca=F.ntri_flat_uv*
  545. (c+F.uv_index_bytes*3);ma=F.ntri_smooth_uv*(c+F.normal_index_bytes*3+F.uv_index_bytes*3);ka=F.nquad_flat*na;c=F.nquad_smooth*(na+F.normal_index_bytes*4);na=F.nquad_flat_uv*(na+F.uv_index_bytes*4);E+=function(c){for(var f,h,j,k=F.vertex_coordinate_bytes*3,m=c+F.nvertices*k;c<m;c+=k)f=e(b,c),h=e(b,c+F.vertex_coordinate_bytes),j=e(b,c+F.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(A,f,h,j);return F.nvertices*k}(E);E+=function(c){for(var e,f,g,h=F.normal_coordinate_bytes*3,j=c+F.nnormals*
  546. h;c<j;c+=h)e=p(b,c),f=p(b,c+F.normal_coordinate_bytes),g=p(b,c+F.normal_coordinate_bytes*2),J.push(e/127,f/127,g/127);return F.nnormals*h}(E);E+=function(c){for(var f,h,j=F.uv_coordinate_bytes*2,k=c+F.nuvs*j;c<k;c+=j)f=e(b,c),h=e(b,c+F.uv_coordinate_bytes),C.push(f,h);return F.nuvs*j}(E);M=E+M;W=M+W;ca=W+ca;ma=ca+ma;ka=ma+ka;c=ka+c;na=c+na;(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes,f=e+F.uv_index_bytes*3,g=b+F.ntri_flat_uv*f;for(c=b;c<g;c+=f)t(c),B(c+e);return g-b})(W);(function(b){var c,
  547. e=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=e+F.uv_index_bytes*3,g=b+F.ntri_smooth_uv*f;for(c=b;c<g;c+=f)v(c),B(c+e);return g-b})(ca);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes,f=e+F.uv_index_bytes*4,g=b+F.nquad_flat_uv*f;for(c=b;c<g;c+=f)u(c),x(c+e);return g-b})(c);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*4,f=e+F.uv_index_bytes*4,g=b+F.nquad_smooth_uv*f;for(c=b;c<g;c+=f)w(c),x(c+e);return g-b})(na);
  548. (function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes,f=b+F.ntri_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(E);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=b+F.ntri_smooth*e;for(c=b;c<f;c+=e)v(c);return f-b})(M);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes,f=b+F.nquad_flat*e;for(c=b;c<f;c+=e)u(c);return f-b})(ma);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*4,f=b+F.nquad_smooth*
  549. e;for(c=b;c<f;c+=e)w(c);return f-b})(ka);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h(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,h){b.faces.push(new THREE.Face3(c,e,f,null,null,b.materials[h]))},f4:function(b,c,e,f,h,j){b.faces.push(new THREE.Face4(c,e,f,h,null,null,b.materials[j]))},f3n:function(b,c,e,
  550. f,h,j,g,m,n){var j=b.materials[j],p=c[m*3],o=c[m*3+1],m=c[m*3+2],t=c[n*3],v=c[n*3+1],n=c[n*3+2];b.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(p,o,m),new THREE.Vector3(t,v,n)],null,j))},f4n:function(b,c,e,f,h,j,g,m,n,p,o){var g=b.materials[g],t=c[n*3],v=c[n*3+1],n=c[n*3+2],u=c[p*3],w=c[p*3+1],p=c[p*3+2],B=c[o*3],x=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face4(e,f,h,j,[new THREE.Vector3(c[m*3],c[m*3+1],c[m*3+2]),new THREE.Vector3(t,v,n),new THREE.Vector3(u,
  551. w,p),new THREE.Vector3(B,x,o)],null,g))},uv3:function(b,c,e,f,h,j,g){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,h));m.push(new THREE.UV(j,g));b.push(m)},uv4:function(b,c,e,f,h,j,g,m,n){var p=[];p.push(new THREE.UV(c,e));p.push(new THREE.UV(f,h));p.push(new THREE.UV(j,g));p.push(new THREE.UV(m,n));b.push(p)},constructor:THREE.BinaryLoader};
  552. THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
  553. THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:h+"/"+b}function m(){for(u in S.objects)if(!K.objects[u])if(E=S.objects[u],E.geometry!==void 0){if(G=K.geometries[E.geometry]){var b=!1;V=[];for($=0;$<E.materials.length;$++)V[$]=K.materials[E.materials[$]],b=V[$]instanceof THREE.MeshShaderMaterial;b&&G.computeTangents();F=E.position;r=E.rotation;
  554. q=E.quaternion;s=E.scale;q=0;V.length==0&&(V[0]=new THREE.MeshFaceMaterial);V.length>1&&(V=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(G,V);object.name=u;object.position.set(F[0],F[1],F[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=E.visible;K.scene.addObject(object);K.objects[u]=object;E.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),K.scene.collisions.colliders.push(b));
  555. if(E.castsShadow)b=new THREE.ShadowVolume(G),K.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},K.triggers[object.name]=b)}}else F=E.position,r=E.rotation,q=E.quaternion,s=E.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(F[0],F[1],F[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],
  556. s[1],s[2]),object.visible=E.visible!==void 0?E.visible:!1,K.scene.addObject(object),K.objects[u]=object,K.empties[u]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},K.triggers[object.name]=b)}function n(b){return function(c){K.geometries[b]=c;m();ea-=1;e.onLoadComplete();o()}}function p(b){return function(c){K.geometries[b]=c}}function o(){e.callbackProgress({totalModels:P,totalTextures:k,loadedModels:P-ea,loadedTextures:k-R},K);e.onLoadProgress();ea==0&&R==0&&c(K)}
  557. var t,v,u,w,B,x,A,E,F,J,C,G,O,D,I,V,da,S,z,ea,R,P,k,K;S=b.data;I=new THREE.BinaryLoader;z=new THREE.JSONLoader;R=ea=0;K={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(u in S.objects)if(E=S.objects[u],E.meshCollider){b=!0;break}if(b)K.scene.collisions=new THREE.CollisionSystem;if(S.transform){b=S.transform.position;J=S.transform.rotation;var X=S.transform.scale;b&&K.scene.position.set(b[0],b[1],b[2]);J&&K.scene.rotation.set(J[0],
  558. J[1],J[2]);X&&K.scene.scale.set(X[0],X[1],X[2]);(b||J||X)&&K.scene.updateMatrix()}b=function(){R-=1;o();e.onLoadComplete()};for(B in S.cameras){J=S.cameras[B];if(J.type=="perspective")O=new THREE.Camera(J.fov,J.aspect,J.near,J.far);else if(J.type=="ortho")O=new THREE.Camera,O.projectionMatrix=THREE.Matrix4.makeOrtho(J.left,J.right,J.top,J.bottom,J.near,J.far);F=J.position;J=J.target;O.position.set(F[0],F[1],F[2]);O.target.position.set(J[0],J[1],J[2]);K.cameras[B]=O}for(w in S.lights)B=S.lights[w],
  559. O=B.color!==void 0?B.color:16777215,J=B.intensity!==void 0?B.intensity:1,B.type=="directional"?(F=B.direction,da=new THREE.DirectionalLight(O,J),da.position.set(F[0],F[1],F[2]),da.position.normalize()):B.type=="point"?(F=B.position,d=B.distance,da=new THREE.PointLight(O,J,d),da.position.set(F[0],F[1],F[2])):B.type=="ambient"&&(da=new THREE.AmbientLight(O)),K.scene.addLight(da),K.lights[w]=da;for(x in S.fogs)w=S.fogs[x],w.type=="linear"?D=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(D=new THREE.FogExp2(0,
  560. w.density)),J=w.color,D.color.setRGB(J[0],J[1],J[2]),K.fogs[x]=D;if(K.cameras&&S.defaults.camera)K.currentCamera=K.cameras[S.defaults.camera];if(K.fogs&&S.defaults.fog)K.scene.fog=K.fogs[S.defaults.fog];J=S.defaults.bgcolor;K.bgColor=new THREE.Color;K.bgColor.setRGB(J[0],J[1],J[2]);K.bgColorAlpha=S.defaults.bgalpha;for(t in S.geometries)if(x=S.geometries[t],x.type=="bin_mesh"||x.type=="ascii_mesh")ea+=1,e.onLoadStart();P=ea;for(t in S.geometries)x=S.geometries[t],x.type=="cube"?(G=new THREE.CubeGeometry(x.width,
  561. x.height,x.depth,x.segmentsWidth,x.segmentsHeight,x.segmentsDepth,null,x.flipped,x.sides),K.geometries[t]=G):x.type=="plane"?(G=new THREE.PlaneGeometry(x.width,x.height,x.segmentsWidth,x.segmentsHeight),K.geometries[t]=G):x.type=="sphere"?(G=new THREE.SphereGeometry(x.radius,x.segmentsWidth,x.segmentsHeight),K.geometries[t]=G):x.type=="cylinder"?(G=new THREE.CylinderGeometry(x.numSegs,x.topRad,x.botRad,x.height,x.topOffset,x.botOffset),K.geometries[t]=G):x.type=="torus"?(G=new THREE.TorusGeometry(x.radius,
  562. x.tube,x.segmentsR,x.segmentsT),K.geometries[t]=G):x.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(x.subdivisions),K.geometries[t]=G):x.type=="bin_mesh"?I.load({model:f(x.url,S.urlBaseType),callback:n(t)}):x.type=="ascii_mesh"?z.load({model:f(x.url,S.urlBaseType),callback:n(t)}):x.type=="embedded_mesh"&&(x=S.embeds[x.id])&&z.createModel(x,p(t),"");for(A in S.textures)if(t=S.textures[A],t.url instanceof Array){R+=t.url.length;for(I=0;I<t.url.length;I++)e.onLoadStart()}else R+=1,e.onLoadStart();
  563. k=R;for(A in S.textures){t=S.textures[A];if(t.mapping!=void 0&&THREE[t.mapping]!=void 0)t.mapping=new THREE[t.mapping];if(t.url instanceof Array){I=[];for(var $=0;$<t.url.length;$++)I[$]=f(t.url[$],S.urlBaseType);I=THREE.ImageUtils.loadTextureCube(I,t.mapping,b)}else{I=THREE.ImageUtils.loadTexture(f(t.url,S.urlBaseType),t.mapping,b);if(THREE[t.minFilter]!=void 0)I.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=void 0)I.magFilter=THREE[t.magFilter];if(t.repeat){I.repeat.set(t.repeat[0],t.repeat[1]);
  564. if(t.repeat[0]!=1)I.wrapS=THREE.RepeatWrapping;if(t.repeat[1]!=1)I.wrapT=THREE.RepeatWrapping}t.offset&&I.offset.set(t.offset[0],t.offset[1]);if(t.wrap){z={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(z[t.wrap[0]]!==void 0)I.wrapS=z[t.wrap[0]];if(z[t.wrap[1]]!==void 0)I.wrapT=z[t.wrap[1]]}}K.textures[A]=I}for(v in S.materials){A=S.materials[v];for(C in A.parameters)if(C=="envMap"||C=="map"||C=="lightMap")A.parameters[C]=K.textures[A.parameters[C]];else if(C=="shading")A.parameters[C]=
  565. A.parameters[C]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(C=="blending")A.parameters[C]=THREE[A.parameters[C]]?THREE[A.parameters[C]]:THREE.NormalBlending;else if(C=="combine")A.parameters[C]=A.parameters[C]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(C=="vertexColors")if(A.parameters[C]=="face")A.parameters[C]=THREE.FaceColors;else if(A.parameters[C])A.parameters[C]=THREE.VertexColors;if(A.parameters.opacity!==void 0&&A.parameters.opacity<1)A.parameters.transparent=
  566. !0;if(A.parameters.normalMap){t=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(t.uniforms);I=A.parameters.color;z=A.parameters.specular;x=A.parameters.ambient;D=A.parameters.shininess;b.tNormal.texture=K.textures[A.parameters.normalMap];if(A.parameters.normalMapFactor)b.uNormalScale.value=A.parameters.normalMapFactor;if(A.parameters.map)b.tDiffuse.texture=A.parameters.map,b.enableDiffuse.value=!0;if(A.parameters.lightMap)b.tAO.texture=A.parameters.lightMap,b.enableAO.value=!0;if(A.parameters.specularMap)b.tSpecular.texture=
  567. K.textures[A.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(I);b.uSpecularColor.value.setHex(z);b.uAmbientColor.value.setHex(x);b.uShininess.value=D;if(A.parameters.opacity)b.uOpacity.value=A.parameters.opacity;A=new THREE.MeshShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:b,lights:!0,fog:!0})}else A=new THREE[A.type](A.parameters);K.materials[v]=A}m();e.callbackSync(K)}},constructor:THREE.SceneLoader};
  568. 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=
  569. 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,h){return b+(c-b)*h};this.VIntX=function(b,c,h,j,g,m,n,p,o,t){g=(g-o)/(t-o);o=this.normal_cache;c[j]=m+g*this.delta;c[j+1]=n;c[j+2]=p;h[j]=this.lerp(o[b],o[b+3],g);h[j+1]=this.lerp(o[b+1],o[b+4],g);h[j+2]=this.lerp(o[b+2],o[b+5],g)};this.VIntY=function(b,c,h,j,g,m,n,p,o,t){g=(g-o)/(t-o);o=this.normal_cache;c[j]=m;c[j+1]=n+g*this.delta;c[j+
  570. 2]=p;c=b+this.yd*3;h[j]=this.lerp(o[b],o[c],g);h[j+1]=this.lerp(o[b+1],o[c+1],g);h[j+2]=this.lerp(o[b+2],o[c+2],g)};this.VIntZ=function(b,c,h,j,g,m,n,p,o,t){g=(g-o)/(t-o);o=this.normal_cache;c[j]=m;c[j+1]=n;c[j+2]=p+g*this.delta;c=b+this.zd*3;h[j]=this.lerp(o[b],o[c],g);h[j+1]=this.lerp(o[b+1],o[c+1],g);h[j+2]=this.lerp(o[b+2],o[c+2],g)};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+
  571. this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,h,j,g,m){var n=j+1,p=j+this.yd,o=j+this.zd,t=n+this.yd,v=n+this.zd,u=j+this.yd+this.zd,w=n+this.yd+this.zd,B=0,x=this.field[j],A=this.field[n],E=this.field[p],F=this.field[t],J=this.field[o],C=this.field[v],G=this.field[u],O=this.field[w];x<g&&(B|=1);A<g&&(B|=2);E<g&&(B|=8);F<g&&(B|=4);J<g&&(B|=16);C<g&&(B|=32);G<g&&(B|=128);O<g&&(B|=64);var D=THREE.edgeTable[B];if(D==0)return 0;var I=this.delta,
  572. V=b+I,da=c+I,I=h+I;D&1&&(this.compNorm(j),this.compNorm(n),this.VIntX(j*3,this.vlist,this.nlist,0,g,b,c,h,x,A));D&2&&(this.compNorm(n),this.compNorm(t),this.VIntY(n*3,this.vlist,this.nlist,3,g,V,c,h,A,F));D&4&&(this.compNorm(p),this.compNorm(t),this.VIntX(p*3,this.vlist,this.nlist,6,g,b,da,h,E,F));D&8&&(this.compNorm(j),this.compNorm(p),this.VIntY(j*3,this.vlist,this.nlist,9,g,b,c,h,x,E));D&16&&(this.compNorm(o),this.compNorm(v),this.VIntX(o*3,this.vlist,this.nlist,12,g,b,c,I,J,C));D&32&&(this.compNorm(v),
  573. this.compNorm(w),this.VIntY(v*3,this.vlist,this.nlist,15,g,V,c,I,C,O));D&64&&(this.compNorm(u),this.compNorm(w),this.VIntX(u*3,this.vlist,this.nlist,18,g,b,da,I,G,O));D&128&&(this.compNorm(o),this.compNorm(u),this.VIntY(o*3,this.vlist,this.nlist,21,g,b,c,I,J,G));D&256&&(this.compNorm(j),this.compNorm(o),this.VIntZ(j*3,this.vlist,this.nlist,24,g,b,c,h,x,J));D&512&&(this.compNorm(n),this.compNorm(v),this.VIntZ(n*3,this.vlist,this.nlist,27,g,V,c,h,A,C));D&1024&&(this.compNorm(t),this.compNorm(w),this.VIntZ(t*
  574. 3,this.vlist,this.nlist,30,g,V,da,h,F,O));D&2048&&(this.compNorm(p),this.compNorm(u),this.VIntZ(p*3,this.vlist,this.nlist,33,g,b,da,h,E,G));B<<=4;for(g=j=0;THREE.triTable[B+g]!=-1;)b=B+g,c=b+1,h=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[h],m),g+=3,j++;return j};this.posnormtriv=function(b,c,h,j,g,m){var n=this.count*3;this.positionArray[n]=b[h];this.positionArray[n+1]=b[h+1];this.positionArray[n+2]=b[h+2];this.positionArray[n+3]=b[j];this.positionArray[n+
  575. 4]=b[j+1];this.positionArray[n+5]=b[j+2];this.positionArray[n+6]=b[g];this.positionArray[n+7]=b[g+1];this.positionArray[n+8]=b[g+2];this.normalArray[n]=c[h];this.normalArray[n+1]=c[h+1];this.normalArray[n+2]=c[h+2];this.normalArray[n+3]=c[j];this.normalArray[n+4]=c[j+1];this.normalArray[n+5]=c[j+2];this.normalArray[n+6]=c[g];this.normalArray[n+7]=c[g+1];this.normalArray[n+8]=c[g+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&m(this)};this.begin=function(){this.count=0;
  576. 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,h,j,g){var m=this.size*Math.sqrt(j/g),n=h*this.size,p=c*this.size,o=b*this.size,t=Math.floor(n-m);t<1&&(t=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 u=Math.floor(o-m);u<1&&(u=1);m=Math.floor(o+m);m>this.size-1&&(m=this.size-
  577. 1);for(var w,B,x,A,E,F;t<n;t++){o=this.size2*t;B=t/this.size-h;E=B*B;for(B=v;B<p;B++){x=o+this.size*B;w=B/this.size-c;F=w*w;for(w=u;w<m;w++)A=w/this.size-b,A=j/(1.0E-6+A*A+F+E)-g,A>0&&(this.field[x+w]+=A)}}};this.addPlaneX=function(b,c){var h,j,g,m,n,p=this.size,o=this.yd,t=this.zd,v=this.field,u=p*Math.sqrt(b/c);u>p&&(u=p);for(h=0;h<u;h++)if(j=h/p,j*=j,m=b/(1.0E-4+j)-c,m>0)for(j=0;j<p;j++){n=h+j*o;for(g=0;g<p;g++)v[t*g+n]+=m}};this.addPlaneY=function(b,c){var h,j,g,m,n,p,o=this.size,t=this.yd,v=
  578. this.zd,u=this.field,w=o*Math.sqrt(b/c);w>o&&(w=o);for(j=0;j<w;j++)if(h=j/o,h*=h,m=b/(1.0E-4+h)-c,m>0){n=j*t;for(h=0;h<o;h++){p=n+h;for(g=0;g<o;g++)u[v*g+p]+=m}}};this.addPlaneZ=function(b,c){var h,j,g,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(g=0;g<dist;g++)if(h=g/size,h*=h,m=b/(1.0E-4+h)-c,m>0){n=zd*g;for(j=0;j<size;j++){p=n+j*yd;for(h=0;h<size;h++)field[p+h]+=m}}};this.reset=function(){var b;for(b=0;b<this.size3;b++)this.normal_cache[b*
  579. 3]=0,this.field[b]=0};this.render=function(b){this.begin();var c,h,j,g,m,n,p,o,t,v=this.size-2;for(g=1;g<v;g++){t=this.size2*g;p=(g-this.halfsize)/this.halfsize;for(j=1;j<v;j++){o=t+this.size*j;n=(j-this.halfsize)/this.halfsize;for(h=1;h<v;h++)m=(h-this.halfsize)/this.halfsize,c=o+h,this.polygonize(m,n,p,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,h=[];this.render(function(j){var g,m,n,p,o,t,v,u;for(g=0;g<j.count;g++)v=g*3,o=v+1,u=v+2,m=j.positionArray[v],
  580. n=j.positionArray[o],p=j.positionArray[u],t=new THREE.Vector3(m,n,p),m=j.normalArray[v],n=j.normalArray[o],p=j.normalArray[u],v=new THREE.Vector3(m,n,p),v.normalize(),o=new THREE.Vertex(t),c.vertices.push(o),h.push(v);nfaces=j.count/3;for(g=0;g<nfaces;g++)v=(b+g)*3,o=v+1,u=v+2,t=h[v],m=h[o],n=h[u],v=new THREE.Face3(v,o,u,[t,m,n]),c.faces.push(v);b+=nfaces;j.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  581. 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,
  582. 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,
  583. 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]);
  584. 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,
  585. -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,
  586. -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,
  587. -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,
  588. 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,
  589. -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,
  590. 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,
  591. -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,
  592. 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,
  593. 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,
  594. 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,
  595. 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,
  596. -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,
  597. -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,
  598. -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,
  599. 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,
  600. -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,
  601. 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,
  602. 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,
  603. -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,
  604. 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]);
  605. 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,h,b=b||THREE.Trident.defaultParams;if(b!==THREE.Trident.defaultParams)for(h in THREE.Trident.defaultParams)b.hasOwnProperty(h)||(b[h]=THREE.Trident.defaultParams[h]);
  606. 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)h=c(b.xAxisColor),h.rotation.y=-f,h.position.x=b.length,this.addChild(h),h=c(b.yAxisColor),h.rotation.x=f,h.position.y=b.length,this.addChild(h),h=c(b.zAxisColor),h.rotation.y=Math.PI,h.position.z=b.length,this.addChild(h)};
  607. 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};
  608. 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)};
  609. THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,h,j=0;c=0;for(e=this.colliders.length;c<e;c++)if(h=this.colliders[c],f=this.rayCast(b,h),f<Number.MAX_VALUE)h.distance=f,f>j?this.hits.push(h):this.hits.unshift(h),j=f;return this.hits};
  610. 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]};
  611. 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)};
  612. THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,j=0;j<c.numFaces;j++){var g=c.mesh.geometry.faces[j],m=c.mesh.geometry.vertices[g.a].position,n=c.mesh.geometry.vertices[g.b].position,p=c.mesh.geometry.vertices[g.c].position,o=g instanceof THREE.Face4?c.mesh.geometry.vertices[g.d].position:null;g instanceof THREE.Face3?(g=this.rayTriangle(e,m,n,p,f,this.collisionNormal,c.mesh),g<f&&(f=g,h=j,c.normal.copy(this.collisionNormal),c.normal.normalize())):
  613. g instanceof THREE.Face4&&(g=this.rayTriangle(e,m,n,o,f,this.collisionNormal,c.mesh),g<f&&(f=g,h=j,c.normal.copy(this.collisionNormal),c.normal.normalize()),g=this.rayTriangle(e,n,p,o,f,this.collisionNormal,c.mesh),g<f&&(f=g,h=j,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:h}};
  614. THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,h,j,g){var m=THREE.CollisionSystem.__v1,n=THREE.CollisionSystem.__v2;j.set(0,0,0);m.sub(e,c);n.sub(f,e);j.cross(m,n);m=j.dot(b.direction);if(!(m<0))if(g.doubleSided||g.flipSided)j.multiplyScalar(-1),m*=-1;else return Number.MAX_VALUE;g=j.dot(c)-j.dot(b.origin);if(!(g<=0))return Number.MAX_VALUE;if(!(g>=m*h))return Number.MAX_VALUE;g/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(g);m.addSelf(b.origin);Math.abs(j.x)>
  615. Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=m.y-c.y,j=e.y-c.y,h=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,h=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(j.y)>Math.abs(j.z)?(b=m.x-c.x,j=e.x-c.x,h=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,h=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=j*f-e*h;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*h)*c;if(!(f>=0))return Number.MAX_VALUE;c*=j*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return g};
  616. 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};
  617. 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,h=0,j=0,g=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,g=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,g=1);e.origin.y<c.min.y?(h=c.min.y-e.origin.y,h/=e.direction.y,p=!1,m=-1):e.origin.y>c.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y,
  618. p=!1,m=1);e.origin.z<c.min.z?(j=c.min.z-e.origin.z,j/=e.direction.z,p=!1,n=-1):e.origin.z>c.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;h>f&&(p=1,f=h);j>f&&(p=2,f=j);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(g,0,0);break;case 1:g=e.origin.x+e.direction.x*f;if(g<c.min.x||g>c.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*
  619. f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:g=e.origin.x+e.direction.x*f;if(g<c.min.x||g>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};
  620. 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;
  621. 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};
  622. THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};
  623. if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,j=new THREE.Camera,g=new THREE.Matrix4,m=new THREE.Matrix4,n,p,o;h.useTarget=j.useTarget=!1;h.matrixAutoUpdate=j.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.Camera(53,1,1,1E4);u.position.z=
  624. 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},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}"});
  625. var w=new THREE.Scene;w.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.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 A=e.projectionMatrix.clone(),E=125/30*0.5,F=E*p/125,J=p*Math.tan(o*Math.PI/360),C;g.n14=E;m.n14=-E;E=-J*n+F;C=J*n+F;A.n11=2*p/(C-E);A.n13=(C+E)/(C-E);h.projectionMatrix=A.clone();E=-J*n-F;C=J*n-F;A.n11=2*p/(C-E);
  626. A.n13=(C+E)/(C-E);j.projectionMatrix=A.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(m);h.update(null,!0);h.position.copy(e.position);h.near=p;h.far=e.far;f.call(c,b,h,t,!0);j.matrix=e.matrixWorld.clone().multiplySelf(g);j.update(null,!0);j.position.copy(e.position);j.near=p;j.far=e.far;f.call(c,b,j,v,!0);f.call(c,w,u)}};
  627. if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,h,j,g=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);h=b/2;j=f};this.render=function(b,e){this.clear();g.fov=e.fov;g.aspect=0.5*e.aspect;g.near=e.near;g.far=e.far;
  628. g.updateProjectionMatrix();g.position.copy(e.position);g.target.position.copy(e.target.position);g.translateX(c.separation);m.projectionMatrix=g.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,h,j);f.call(c,b,g);this.setViewport(h,0,h,j);f.call(c,b,m,!1)}};
粤ICP备19079148号