Three.js 340 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. // Three.js r46dev - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Clock=function(a){this.autoStart=a!==void 0?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){this.elapsedTime+=this.getDelta();return this.elapsedTime};
  3. THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var c=Date.now(),a=0.0010*(c-this.oldTime);this.oldTime=c;this.elapsedTime+=a}return a};THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
  4. THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;return this},setHSV:function(a,c,b){var d,h,e;if(b===0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),h=a*6-d,a=b*(1-c),e=b*(1-
  5. c*h),c=b*(1-c*(1-h)),d){case 1:this.r=e;this.g=b;this.b=a;break;case 2:this.r=a;this.g=b;this.b=c;break;case 3:this.r=a;this.g=e;this.b=b;break;case 4:this.r=c;this.g=a;this.b=b;break;case 5:this.r=b;this.g=a;this.b=e;break;case 6:case 0:this.r=b,this.g=c,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+
  6. 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)}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
  7. THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
  8. divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.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(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,a=this.y-a.y;return c*c+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},
  9. equals:function(a){return a.x===this.x&&a.y===this.y}};THREE.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};
  10. THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},
  11. addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},
  12. divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.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(a){return this.normalize().multiplyScalar(a)},
  13. cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){return this.set(this.y*a.z-this.z*a.y,this.z*a.x-this.x*a.z,this.x*a.y-this.y*a.x)},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var c=Math.cos(this.y);this.y=Math.asin(a.n13);
  14. Math.abs(c)>1.0E-5?(this.x=Math.atan2(-a.n23/c,a.n33/c),this.z=Math.atan2(-a.n12/c,a.n11/c)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,c,b,d){this.x=a||0;this.y=c||0;this.z=b||0;this.w=d!==void 0?d:1};
  15. THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-
  16. c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
  17. normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  18. THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var c,b,d=[];c=0;for(b=a.length;c<b;c++)Array.prototype.push.apply(d,this.intersectObject(a[c]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function c(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function b(a,b,c,p){d.copy(p).subSelf(b);
  19. h.copy(c).subSelf(b);e.copy(a).subSelf(b);f=d.dot(d);i=d.dot(h);j=d.dot(e);n=h.dot(h);o=h.dot(e);l=1/(f*n-i*i);q=(n*j-i*o)*l;r=(f*o-i*j)*l;return q>=0&&r>=0&&q+r<1}for(var d=new THREE.Vector3,h=new THREE.Vector3,e=new THREE.Vector3,f,i,j,n,o,l,q,r,s,p=[],v=0,w=a.children.length;v<w;v++)Array.prototype.push.apply(p,this.intersectObject(a.children[v]));if(a instanceof THREE.Particle){v=c(this.origin,this.direction,a.matrixWorld.getPosition());if(v===null||v>a.scale.x)return[];s={distance:v,point:a.position,
  20. face:null,object:a};p.push(s)}else if(a instanceof THREE.Mesh){v=c(this.origin,this.direction,a.matrixWorld.getPosition());if(v===null||v>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var x,t,B,G,P,C,L,z,y=a.geometry,F=y.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);v=0;for(w=y.faces.length;v<w;v++)if(s=y.faces[v],L=this.origin.clone(),z=this.direction.clone(),G=a.matrixWorld,x=G.multiplyVector3(s.centroid.clone()).subSelf(L),C=x.dot(z),
  21. !(C<=0)&&(x=G.multiplyVector3(F[s.a].position.clone()),t=G.multiplyVector3(F[s.b].position.clone()),B=G.multiplyVector3(F[s.c].position.clone()),G=s instanceof THREE.Face4?G.multiplyVector3(F[s.d].position.clone()):null,P=a.matrixRotationWorld.multiplyVector3(s.normal.clone()),C=z.dot(P),a.doubleSided||(a.flipSided?C>0:C<0)))if(C=P.dot((new THREE.Vector3).sub(x,L))/C,L=L.addSelf(z.multiplyScalar(C)),s instanceof THREE.Face3)b(L,x,t,B)&&(s={distance:this.origin.distanceTo(L),point:L,face:s,object:a},
  22. p.push(s));else if(s instanceof THREE.Face4&&(b(L,x,t,G)||b(L,t,B,G)))s={distance:this.origin.distanceTo(L),point:L,face:s,object:a},p.push(s)}return p}};
  23. THREE.Rectangle=function(){function a(){e=d-c;f=h-b}var c,b,d,h,e,f,i=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return e};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(e,f,o,l){i=!1;c=e;b=f;d=o;h=l;a()};this.addPoint=function(e,f){i?(i=!1,c=e,b=f,d=e,h=f):(c=c<e?c:e,b=b<f?b:f,d=d>e?d:e,h=h>f?h:f);a()};this.add3Points=
  24. function(e,f,o,l,q,r){i?(i=!1,c=e<o?e<q?e:q:o<q?o:q,b=f<l?f<r?f:r:l<r?l:r,d=e>o?e>q?e:q:o>q?o:q,h=f>l?f>r?f:r:l>r?l:r):(c=e<o?e<q?e<c?e:c:q<c?q:c:o<q?o<c?o:c:q<c?q:c,b=f<l?f<r?f<b?f:b:r<b?r:b:l<r?l<b?l:b:r<b?r:b,d=e>o?e>q?e>d?e:d:q>d?q:d:o>q?o>d?o:d:q>d?q:d,h=f>l?f>r?f>h?f:h:r>h?r:h:l>r?l>h?l:h:r>h?r:h);a()};this.addRectangle=function(e){i?(i=!1,c=e.getLeft(),b=e.getTop(),d=e.getRight(),h=e.getBottom()):(c=c<e.getLeft()?c:e.getLeft(),b=b<e.getTop()?b:e.getTop(),d=d>e.getRight()?d:e.getRight(),h=h>
  25. e.getBottom()?h:e.getBottom());a()};this.inflate=function(e){c-=e;b-=e;d+=e;h+=e;a()};this.minSelf=function(e){c=c>e.getLeft()?c:e.getLeft();b=b>e.getTop()?b:e.getTop();d=d<e.getRight()?d:e.getRight();h=h<e.getBottom()?h:e.getBottom();a()};this.intersects=function(a){return Math.min(d,a.getRight())-Math.max(c,a.getLeft())>=0&&Math.min(h,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){i=!0;h=d=b=c=0;a()};this.isEmpty=function(){return i}};
  26. THREE.Math={clamp:function(a,c,b){return a<c?c:a>b?b:a},clampBottom:function(a,c){return a<c?c:a},mapLinear:function(a,c,b,d,h){return d+(a-c)*(h-d)/(b-c)},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.Matrix3=function(){this.m=[]};
  27. THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
  28. THREE.Matrix4=function(a,c,b,d,h,e,f,i,j,n,o,l,q,r,s,p){this.set(a!==void 0?a:1,c||0,b||0,d||0,h||0,e!==void 0?e:1,f||0,i||0,j||0,n||0,o!==void 0?o:1,l||0,q||0,r||0,s||0,p!==void 0?p:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  29. THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,d,h,e,f,i,j,n,o,l,q,r,s,p){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=h;this.n22=e;this.n23=f;this.n24=i;this.n31=j;this.n32=n;this.n33=o;this.n34=l;this.n41=q;this.n42=r;this.n43=s;this.n44=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
  30. c,b){var d=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,c).normalize();if(e.length()===0)e.z=1;d.cross(b,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(b,e).normalize());h.cross(e,d).normalize();this.n11=d.x;this.n12=h.x;this.n13=e.x;this.n21=d.y;this.n22=h.y;this.n23=e.y;this.n31=d.z;this.n32=h.z;this.n33=e.z;return this},multiply:function(a,c){var b=a.n11,d=a.n12,h=a.n13,e=a.n14,f=a.n21,i=a.n22,j=a.n23,n=a.n24,o=a.n31,l=a.n32,q=a.n33,r=a.n34,s=a.n41,p=a.n42,v=a.n43,
  31. w=a.n44,x=c.n11,t=c.n12,B=c.n13,G=c.n14,P=c.n21,C=c.n22,L=c.n23,z=c.n24,y=c.n31,F=c.n32,O=c.n33,U=c.n34,ea=c.n41,N=c.n42,R=c.n43,k=c.n44;this.n11=b*x+d*P+h*y+e*ea;this.n12=b*t+d*C+h*F+e*N;this.n13=b*B+d*L+h*O+e*R;this.n14=b*G+d*z+h*U+e*k;this.n21=f*x+i*P+j*y+n*ea;this.n22=f*t+i*C+j*F+n*N;this.n23=f*B+i*L+j*O+n*R;this.n24=f*G+i*z+j*U+n*k;this.n31=o*x+l*P+q*y+r*ea;this.n32=o*t+l*C+q*F+r*N;this.n33=o*B+l*L+q*O+r*R;this.n34=o*G+l*z+q*U+r*k;this.n41=s*x+p*P+v*y+w*ea;this.n42=s*t+p*C+v*F+w*N;this.n43=s*
  32. B+p*L+v*O+w*R;this.n44=s*G+p*z+v*U+w*k;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
  33. a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,h=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*h;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*h;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,h=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*h;a.y=this.n21*c+this.n22*
  34. b+this.n23*d+this.n24*h;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*h;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*h;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*
  35. a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,h=this.n21,e=this.n22,f=this.n23,i=this.n24,j=this.n31,n=this.n32,o=this.n33,l=this.n34,q=this.n41,r=this.n42,s=this.n43,p=this.n44;return d*f*n*q-b*i*n*q-d*e*o*q+c*i*o*q+b*e*l*q-c*f*l*q-d*f*j*r+b*i*j*r+d*h*o*r-a*i*o*r-b*h*l*r+a*f*l*r+d*e*j*s-c*i*j*s-d*h*n*s+a*i*n*s+c*h*l*s-a*e*l*s-b*e*j*p+c*f*j*p+b*h*n*p-a*f*n*p-c*h*o*p+a*e*o*p},transpose:function(){var a;
  36. a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;
  37. a.n43=this.n43;a.n44=this.n44;return a},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(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
  38. a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},
  39. setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},
  40. setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),h=1-b,e=a.x,f=a.y,i=a.z,j=h*e,n=h*f;this.set(j*e+b,j*f-d*i,j*i+d*f,0,j*f+d*i,n*f+b,n*i-d*e,0,j*i-d*f,n*i+d*e,h*i*i+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
  41. this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var c=a.n11,b=a.n12,d=a.n13,h=a.n14,e=a.n21,f=a.n22,i=a.n23,j=a.n24,n=a.n31,o=a.n32,l=a.n33,q=a.n34,r=a.n41,s=a.n42,p=a.n43,v=a.n44;this.n11=i*q*s-j*l*s+j*o*p-f*q*p-i*o*v+f*l*v;this.n12=h*l*s-d*q*s-h*o*p+b*q*p+d*o*v-b*l*v;this.n13=d*j*s-h*i*s+h*f*p-b*j*p-d*f*v+b*i*v;this.n14=h*i*o-d*j*o-h*f*l+b*j*l+d*f*q-b*i*q;this.n21=j*l*r-i*q*r-j*n*p+e*q*p+i*n*v-e*l*v;this.n22=d*q*r-h*l*r+
  42. h*n*p-c*q*p-d*n*v+c*l*v;this.n23=h*i*r-d*j*r-h*e*p+c*j*p+d*e*v-c*i*v;this.n24=d*j*n-h*i*n+h*e*l-c*j*l-d*e*q+c*i*q;this.n31=f*q*r-j*o*r+j*n*s-e*q*s-f*n*v+e*o*v;this.n32=h*o*r-b*q*r-h*n*s+c*q*s+b*n*v-c*o*v;this.n33=d*j*r-h*f*r+h*e*s-c*j*s-b*e*v+c*f*v;this.n34=h*f*n-b*j*n-h*e*o+c*j*o+b*e*q-c*f*q;this.n41=i*o*r-f*l*r-i*n*s+e*l*s+f*n*p-e*o*p;this.n42=b*l*r-d*o*r+d*n*s-c*l*s-b*n*p+c*o*p;this.n43=d*f*r-b*i*r-d*e*s+c*i*s+b*e*p-c*f*p;this.n44=b*i*n-d*f*n+d*e*o-c*i*o-b*e*l+c*f*l;this.multiplyScalar(1/a.determinant());
  43. return this},setRotationFromEuler:function(a,c){var b=a.x,d=a.y,h=a.z,e=Math.cos(b),b=Math.sin(b),f=Math.cos(d),d=Math.sin(d),i=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var j=f*i,n=f*h,o=d*i,l=d*h;this.n11=j+l*b;this.n12=o*b-n;this.n13=e*d;this.n21=e*h;this.n22=e*i;this.n23=-b;this.n31=n*b-o;this.n32=l+j*b;this.n33=e*f;break;case "ZXY":j=f*i;n=f*h;o=d*i;l=d*h;this.n11=j-l*b;this.n12=-e*h;this.n13=o+n*b;this.n21=n+o*b;this.n22=e*i;this.n23=l-j*b;this.n31=-e*d;this.n32=b;this.n33=e*f;break;case "ZYX":j=
  44. e*i;n=e*h;o=b*i;l=b*h;this.n11=f*i;this.n12=o*d-n;this.n13=j*d+l;this.n21=f*h;this.n22=l*d+j;this.n23=n*d-o;this.n31=-d;this.n32=b*f;this.n33=e*f;break;case "YZX":j=e*f;n=e*d;o=b*f;l=b*d;this.n11=f*i;this.n12=l-j*h;this.n13=o*h+n;this.n21=h;this.n22=e*i;this.n23=-b*i;this.n31=-d*i;this.n32=n*h+o;this.n33=j-l*h;break;case "XZY":j=e*f;n=e*d;o=b*f;l=b*d;this.n11=f*i;this.n12=-h;this.n13=d*i;this.n21=j*h+l;this.n22=e*i;this.n23=n*h-o;this.n31=o*h-n;this.n32=b*i;this.n33=l*h+j;break;default:j=e*i,n=e*
  45. h,o=b*i,l=b*h,this.n11=f*i,this.n12=-f*h,this.n13=d,this.n21=n+o*d,this.n22=j-l*d,this.n23=-b*f,this.n31=l-j*d,this.n32=o+n*d,this.n33=e*f}return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,h=a.w,e=c+c,f=b+b,i=d+d,a=c*e,j=c*f;c*=i;var n=b*f;b*=i;d*=i;e*=h;f*=h;h*=i;this.n11=1-(n+d);this.n12=j-h;this.n13=c+f;this.n21=j+h;this.n22=1-(a+d);this.n23=b-e;this.n31=c-f;this.n32=b+e;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y,a=a.z;this.n11*=c;this.n12*=b;this.n13*=
  46. a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},compose:function(a,c,b){var d=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(c);h.setScale(b.x,b.y,b.z);this.multiply(d,h);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,c,b){var d=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);e.set(this.n13,
  47. this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;b=b instanceof THREE.Vector3?b:new THREE.Vector3;b.x=d.length();b.y=h.length();b.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=b.x;d.n21/=b.x;d.n31/=b.x;d.n12/=b.y;d.n22/=b.y;d.n32/=b.y;d.n13/=b.z;d.n23/=b.z;d.n33/=b.z;c.setFromRotationMatrix(d);return[a,c,b]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
  48. return this},extractRotation:function(a){var c=THREE.Matrix4.__v1,b=1/c.set(a.n11,a.n21,a.n31).length(),d=1/c.set(a.n12,a.n22,a.n32).length(),c=1/c.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*c;this.n23=a.n23*c;this.n33=a.n33*c;return this}};
  49. THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*n;a===0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;b[0]=a*d;b[1]=a*h;b[2]=a*e;b[3]=a*f;b[4]=a*i;b[5]=a*j;b[6]=a*n;b[7]=a*o;b[8]=a*l;return c};
  50. THREE.Matrix4.makeFrustum=function(a,c,b,d,h,e){var f;f=new THREE.Matrix4;f.n11=2*h/(c-a);f.n12=0;f.n13=(c+a)/(c-a);f.n14=0;f.n21=0;f.n22=2*h/(d-b);f.n23=(d+b)/(d-b);f.n24=0;f.n31=0;f.n32=0;f.n33=-(e+h)/(e-h);f.n34=-2*e*h/(e-h);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,c,b,d){var h,a=b*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,b,d)};
  51. THREE.Matrix4.makeOrtho=function(a,c,b,d,h,e){var f,i,j,n;f=new THREE.Matrix4;i=c-a;j=b-d;n=e-h;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((c+a)/i);f.n21=0;f.n22=2/j;f.n23=0;f.n24=-((b+d)/j);f.n31=0;f.n32=0;f.n33=-2/n;f.n34=-((e+h)/n);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
  52. THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;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=
  53. !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
  54. THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(this.children.indexOf(a)===
  55. -1){a.parent!==void 0&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addObject(a)}},remove:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=void 0;this.children.splice(c,1);for(c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.removeObject(a)}},getChildByName:function(a,c){var b,d,h;b=0;for(d=this.children.length;b<d;b++){h=this.children[b];if(h.name===a)return h;
  56. if(c&&(h=h.getChildByName(a,c),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);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},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
  57. this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var c=0,b=this.children.length;c<b;c++)this.children[c].updateMatrixWorld(a)}};THREE.Object3DCount=0;
  58. THREE.Projector=function(){function a(){var a=f[e]=f[e]||new THREE.RenderableObject;e++;return a}function c(){var a=n[j]=n[j]||new THREE.RenderableVertex;j++;return a}function b(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,h=b.z+b.w,f=-a.z+a.w,i=-b.z+b.w;return e>=0&&h>=0&&f>=0&&i>=0?!0:e<0&&h<0||f<0&&i<0?!1:(e<0?c=Math.max(c,e/(e-h)):h<0&&(d=Math.min(d,e/(e-h))),f<0?c=Math.max(c,f/(f-i)):i<0&&(d=Math.min(d,f/(f-i))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var h,e,f=[],i,j,n=[],
  59. o,l,q=[],r,s=[],p,v,w=[],x,t,B=[],G={objects:[],sprites:[],lights:[],elements:[]},P=new THREE.Vector3,C=new THREE.Vector4,L=new THREE.Matrix4,z=new THREE.Matrix4,y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,O=new THREE.Vector4;this.computeFrustum=function(a){y[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);y[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);y[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+
  60. a.n23,a.n44+a.n24);y[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);y[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);y[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=y[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);L.multiply(b.projectionMatrix,b.matrixWorldInverse);L.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);
  61. L.multiply(b.matrixWorld,b.projectionMatrixInverse);L.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(c,d){e=0;G.objects.length=0;G.sprites.length=0;G.lights.length=0;var f=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld,
  62. e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),i=0;i<6;i++)if(c=y[i].x*d.n14+y[i].y*d.n24+y[i].z*d.n34+y[i].w,c<=e){c=!1;break a}c=!0}c?(L.multiplyVector3(P.copy(b.position)),h=a(),h.object=b,h.z=P.z,G.objects.push(h)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(L.multiplyVector3(P.copy(b.position)),h=a(),h.object=b,h.z=P.z,G.sprites.push(h)):b instanceof THREE.Light&&G.lights.push(b);c=0;for(d=b.children.length;c<d;c++)f(b.children[c])}};f(c);d&&
  63. G.objects.sort(b);return G};this.projectScene=function(a,e,h){var f=e.near,k=e.far,P,y,H,D,T,$,Q,ia,ba,Z,ca,da,X,E,K,aa;t=v=r=l=0;G.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);L.multiply(e.projectionMatrix,e.matrixWorldInverse);this.computeFrustum(L);G=this.projectGraph(a,!1);a=0;for(P=G.objects.length;a<P;a++)if(ba=G.objects[a].object,Z=ba.matrixWorld,
  64. da=ba.material,j=0,ba instanceof THREE.Mesh){ca=ba.geometry;X=ba.geometry.materials;D=ca.vertices;E=ca.faces;K=ca.faceVertexUvs;ca=ba.matrixRotationWorld.extractRotation(Z);y=0;for(H=D.length;y<H;y++)i=c(),i.positionWorld.copy(D[y].position),Z.multiplyVector3(i.positionWorld),i.positionScreen.copy(i.positionWorld),L.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>f&&i.positionScreen.z<k;D=0;for(y=E.length;D<
  65. y;D++){H=E[D];if(H instanceof THREE.Face3)if(T=n[H.a],$=n[H.b],Q=n[H.c],T.visible&&$.visible&&Q.visible&&(ba.doubleSided||ba.flipSided!=(Q.positionScreen.x-T.positionScreen.x)*($.positionScreen.y-T.positionScreen.y)-(Q.positionScreen.y-T.positionScreen.y)*($.positionScreen.x-T.positionScreen.x)<0))ia=q[l]=q[l]||new THREE.RenderableFace3,l++,o=ia,o.v1.copy(T),o.v2.copy($),o.v3.copy(Q);else continue;else if(H instanceof THREE.Face4)if(T=n[H.a],$=n[H.b],Q=n[H.c],ia=n[H.d],T.visible&&$.visible&&Q.visible&&
  66. ia.visible&&(ba.doubleSided||ba.flipSided!=((ia.positionScreen.x-T.positionScreen.x)*($.positionScreen.y-T.positionScreen.y)-(ia.positionScreen.y-T.positionScreen.y)*($.positionScreen.x-T.positionScreen.x)<0||($.positionScreen.x-Q.positionScreen.x)*(ia.positionScreen.y-Q.positionScreen.y)-($.positionScreen.y-Q.positionScreen.y)*(ia.positionScreen.x-Q.positionScreen.x)<0)))aa=s[r]=s[r]||new THREE.RenderableFace4,r++,o=aa,o.v1.copy(T),o.v2.copy($),o.v3.copy(Q),o.v4.copy(ia);else continue;o.normalWorld.copy(H.normal);
  67. ca.multiplyVector3(o.normalWorld);o.centroidWorld.copy(H.centroid);Z.multiplyVector3(o.centroidWorld);o.centroidScreen.copy(o.centroidWorld);L.multiplyVector3(o.centroidScreen);Q=H.vertexNormals;T=0;for($=Q.length;T<$;T++)ia=o.vertexNormalsWorld[T],ia.copy(Q[T]),ca.multiplyVector3(ia);T=0;for($=K.length;T<$;T++)if(aa=K[T][D]){Q=0;for(ia=aa.length;Q<ia;Q++)o.uvs[T][Q]=aa[Q]}o.material=da;o.faceMaterial=H.materialIndex!==null?X[H.materialIndex]:null;o.z=o.centroidScreen.z;G.elements.push(o)}}else if(ba instanceof
  68. THREE.Line){z.multiply(L,Z);D=ba.geometry.vertices;T=c();T.positionScreen.copy(D[0].position);z.multiplyVector4(T.positionScreen);y=1;for(H=D.length;y<H;y++)if(T=c(),T.positionScreen.copy(D[y].position),z.multiplyVector4(T.positionScreen),$=n[j-2],F.copy(T.positionScreen),O.copy($.positionScreen),d(F,O))F.multiplyScalar(1/F.w),O.multiplyScalar(1/O.w),ba=w[v]=w[v]||new THREE.RenderableLine,v++,p=ba,p.v1.positionScreen.copy(F),p.v2.positionScreen.copy(O),p.z=Math.max(F.z,O.z),p.material=da,G.elements.push(p)}a=
  69. 0;for(P=G.sprites.length;a<P;a++)if(ba=G.sprites[a].object,Z=ba.matrixWorld,ba instanceof THREE.Particle&&(C.set(Z.n14,Z.n24,Z.n34,1),L.multiplyVector4(C),C.z/=C.w,C.z>0&&C.z<1))f=B[t]=B[t]||new THREE.RenderableParticle,t++,x=f,x.x=C.x/C.w,x.y=C.y/C.w,x.z=C.z,x.rotation=ba.rotation.z,x.scale.x=ba.scale.x*Math.abs(x.x-(C.x+e.projectionMatrix.n11)/(C.w+e.projectionMatrix.n14)),x.scale.y=ba.scale.y*Math.abs(x.y-(C.y+e.projectionMatrix.n22)/(C.w+e.projectionMatrix.n24)),x.material=ba.material,G.elements.push(x);
  70. h&&G.elements.sort(b);return G}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)};
  71. THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,d=a.y*c,h=a.z*c,a=Math.cos(d),d=Math.sin(d),c=Math.cos(-h),h=Math.sin(-h),e=Math.cos(b),b=Math.sin(b),f=a*c,i=d*h;this.w=f*e-i*b;this.x=f*b+i*e;this.y=d*c*e+a*h*b;this.z=a*h*e-d*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,d=Math.sin(b);
  72. this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
  73. this.normalize();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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var c=
  74. this.x,b=this.y,d=this.z,h=this.w,e=a.x,f=a.y,i=a.z,a=a.w;this.x=c*a+h*e+b*i-d*f;this.y=b*a+h*f+d*e-c*i;this.z=d*a+h*i+c*f-b*e;this.w=h*a-c*e-b*f-d*i;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,h=a.z,e=this.x,f=this.y,i=this.z,j=this.w,n=j*b+f*h-i*d,o=j*d+i*b-e*h,l=j*h+e*d-f*b,b=-e*
  75. b-f*d-i*h;c.x=n*j+b*-e+o*-i-l*-f;c.y=o*j+b*-f+l*-e-n*-i;c.z=l*j+b*-i+n*-f-o*-e;return c}};
  76. THREE.Quaternion.slerp=function(a,c,b,d){var h=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;h<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,h=-h):b.copy(c);if(Math.abs(h)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var e=Math.acos(h),h=Math.sqrt(1-h*h);if(Math.abs(h)<0.0010)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-d)*e)/h;d=Math.sin(d*e)/h;b.w=a.w*c+b.w*d;b.x=a.x*c+b.x*d;b.y=a.y*c+b.y*d;b.z=a.z*c+b.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
  77. THREE.Face3=function(a,c,b,d,h,e){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};
  78. THREE.Face4=function(a,c,b,d,h,e,f){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
  79. THREE.UV.prototype={constructor:THREE.UV,set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
  80. THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
  81. THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var c=new THREE.Matrix4;c.extractRotation(a,new THREE.Vector3(1,1,1));for(var b=0,d=this.vertices.length;b<d;b++)a.multiplyVector3(this.vertices[b].position);b=0;for(d=this.faces.length;b<d;b++){var h=this.faces[b];c.multiplyVector3(h.normal);for(var e=0,f=h.vertexNormals.length;e<f;e++)c.multiplyVector3(h.vertexNormals[e]);a.multiplyVector3(h.centroid)}},computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a<
  82. c;a++)b=this.faces[a],b.centroid.set(0,0,0),b instanceof THREE.Face3?(b.centroid.addSelf(this.vertices[b.a].position),b.centroid.addSelf(this.vertices[b.b].position),b.centroid.addSelf(this.vertices[b.c].position),b.centroid.divideScalar(3)):b instanceof THREE.Face4&&(b.centroid.addSelf(this.vertices[b.a].position),b.centroid.addSelf(this.vertices[b.b].position),b.centroid.addSelf(this.vertices[b.c].position),b.centroid.addSelf(this.vertices[b.d].position),b.centroid.divideScalar(4))},computeFaceNormals:function(a){var c,
  83. b,d,h,e,f,i=new THREE.Vector3,j=new THREE.Vector3;d=0;for(h=this.faces.length;d<h;d++){e=this.faces[d];if(a&&e.vertexNormals.length){i.set(0,0,0);c=0;for(b=e.vertexNormals.length;c<b;c++)i.addSelf(e.vertexNormals[c]);i.divideScalar(3)}else c=this.vertices[e.a],b=this.vertices[e.b],f=this.vertices[e.c],i.sub(f.position,b.position),j.sub(c.position,b.position),i.crossSelf(j);i.isZero()||i.normalize();e.normal.copy(i)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices===void 0){d=this.__tmpVertices=
  84. Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)d[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++)if(b=this.faces[a],b instanceof THREE.Face3)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(b instanceof THREE.Face4)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)d[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++)b=this.faces[a],b instanceof
  85. THREE.Face3?(d[b.a].addSelf(b.normal),d[b.b].addSelf(b.normal),d[b.c].addSelf(b.normal)):b instanceof THREE.Face4&&(d[b.a].addSelf(b.normal),d[b.b].addSelf(b.normal),d[b.c].addSelf(b.normal),d[b.d].addSelf(b.normal));a=0;for(c=this.vertices.length;a<c;a++)d[a].normalize();a=0;for(c=this.faces.length;a<c;a++)b=this.faces[a],b instanceof THREE.Face3?(b.vertexNormals[0].copy(d[b.a]),b.vertexNormals[1].copy(d[b.b]),b.vertexNormals[2].copy(d[b.c])):b instanceof THREE.Face4&&(b.vertexNormals[0].copy(d[b.a]),
  86. b.vertexNormals[1].copy(d[b.b]),b.vertexNormals[2].copy(d[b.c]),b.vertexNormals[3].copy(d[b.d]))},computeTangents:function(){function a(a,b,c,d,e,h,R){i=a.vertices[b].position;j=a.vertices[c].position;n=a.vertices[d].position;o=f[e];l=f[h];q=f[R];r=j.x-i.x;s=n.x-i.x;p=j.y-i.y;v=n.y-i.y;w=j.z-i.z;x=n.z-i.z;t=l.u-o.u;B=q.u-o.u;G=l.v-o.v;P=q.v-o.v;C=1/(t*P-B*G);F.set((P*r-G*s)*C,(P*p-G*v)*C,(P*w-G*x)*C);O.set((t*s-B*r)*C,(t*v-B*p)*C,(t*x-B*w)*C);z[b].addSelf(F);z[c].addSelf(F);z[d].addSelf(F);y[b].addSelf(O);
  87. y[c].addSelf(O);y[d].addSelf(O)}var c,b,d,h,e,f,i,j,n,o,l,q,r,s,p,v,w,x,t,B,G,P,C,L,z=[],y=[],F=new THREE.Vector3,O=new THREE.Vector3,U=new THREE.Vector3,ea=new THREE.Vector3,N=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++)z[c]=new THREE.Vector3,y[c]=new THREE.Vector3;c=0;for(b=this.faces.length;c<b;c++)e=this.faces[c],f=this.faceVertexUvs[0][c],e instanceof THREE.Face3?a(this,e.a,e.b,e.c,0,1,2):e instanceof THREE.Face4&&(a(this,e.a,e.b,e.c,0,1,2),a(this,e.a,e.b,e.d,0,1,3));var R=["a",
  88. "b","c","d"];c=0;for(b=this.faces.length;c<b;c++){e=this.faces[c];for(d=0;d<e.vertexNormals.length;d++)N.copy(e.vertexNormals[d]),h=e[R[d]],L=z[h],U.copy(L),U.subSelf(N.multiplyScalar(N.dot(L))).normalize(),ea.cross(e.vertexNormals[d],L),h=ea.dot(y[h]),h=h<0?-1:1,e.vertexTangents[d]=new THREE.Vector4(U.x,U.y,U.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,
  89. this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
  90. a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},c=[],b=[],d,h=Math.pow(10,4),e,f;e=0;for(f=this.vertices.length;e<f;e++)d=this.vertices[e].position,d=[Math.round(d.x*h),Math.round(d.y*h),Math.round(d.z*h)].join("_"),a[d]===void 0?(a[d]=e,c.push(this.vertices[e]),
  91. b[e]=c.length-1):b[e]=b[a[d]];e=0;for(f=this.faces.length;e<f;e++)if(a=this.faces[e],a instanceof THREE.Face3)a.a=b[a.a],a.b=b[a.b],a.c=b[a.c];else if(a instanceof THREE.Face4)a.a=b[a.a],a.b=b[a.b],a.c=b[a.c],a.d=b[a.d];this.vertices=c}};THREE.GeometryCount=0;
  92. THREE.Spline=function(a){function c(a,b,c,d,e,h,f){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*h+a*e+b}this.points=a;var b=[],d={x:0,y:0,z:0},h,e,f,i,j,n,o,l,q;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){h=(this.points.length-1)*a;e=Math.floor(h);f=h-e;b[0]=e===0?e:e-1;b[1]=e;b[2]=e>this.points.length-2?e:e+1;b[3]=e>this.points.length-3?e:e+2;n=this.points[b[0]];o=this.points[b[1]];
  93. l=this.points[b[2]];q=this.points[b[3]];i=f*f;j=f*i;d.x=c(n.x,o.x,l.x,q.x,f,i,j);d.y=c(n.y,o.y,l.y,q.y,f,i,j);d.z=c(n.z,o.z,l.z,q.z,f,i,j);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,h=new THREE.Vector3,f=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;h.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),f.copy(d),j+=f.distanceTo(h),
  94. h.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=j,e=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,e,h,f,i=[],j=new THREE.Vector3,n=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=n.chunks[b]-n.chunks[b-1];f=Math.ceil(a*c/n.total);e=(b-1)/(this.points.length-1);h=b/(this.points.length-1);for(c=1;c<f-1;c++)d=e+c*(1/f)*(h-e),d=this.getPoint(d),i.push(j.copy(d).clone());i.push(j.copy(this.points[b]).clone())}this.points=
  95. i}};THREE.Edge=function(a,c,b,d){this.vertices=[a,c];this.vertexIndices=[b,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
  96. THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,c,b,d,h,e){THREE.Camera.call(this);this.left=a;this.right=c;this.top=b;this.bottom=d;this.near=h!==void 0?h:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
  97. THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,c,b,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=c!==void 0?c:1;this.near=b!==void 0?b:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
  98. THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,c){this.fov=2*Math.atan((c!==void 0?c:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,c,b,d,h,e){this.fullWidth=a;this.fullHeight=c;this.x=b;this.y=d;this.width=h;this.height=e;this.updateProjectionMatrix()};
  99. THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,b=-c,d=a*b,a=Math.abs(a*c-d),b=Math.abs(c-b);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,c-(this.y+this.height)*b/this.fullHeight,c-this.y*b/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
  100. this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
  101. THREE.DirectionalLight=function(a,c,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c!==void 0?c:1;this.distance=b!==void 0?b:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=c!==void 0?c:1;this.distance=b!==void 0?b:0};THREE.PointLight.prototype=new THREE.Light;
  102. THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.SpotLight=function(a,c,b,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=c!==void 0?c:1;this.distance=b!==void 0?b:0;this.castShadow=d!==void 0?d:!1};THREE.SpotLight.prototype=new THREE.Light;THREE.SpotLight.prototype.constructor=THREE.SpotLight;
  103. THREE.Material=function(a){this.name="";this.id=THREE.MaterialCount++;a=a||{};this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:!1;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.depthTest=a.depthTest!==void 0?a.depthTest:!0;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:!0;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:!1;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=
  104. a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:!1};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;
  105. THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==void 0?a.linewidth:1;this.linecap=a.linecap!==void 0?a.linecap:"round";this.linejoin=a.linejoin!==void 0?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1;this.fog=a.fog!==void 0?a.fog:!0};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
  106. THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:
  107. !0;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:
  108. !1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
  109. THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(328965);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=
  110. a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:!0;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=
  111. a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.MeshLambertMaterial.prototype=new THREE.Material;THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
  112. THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(328965);this.specular=a.specular!==void 0?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=a.shininess!==void 0?a.shininess:30;this.metal=a.metal!==void 0?a.metal:!1;this.perPixel=a.perPixel!==void 0?a.perPixel:!1;this.map=a.map!==void 0?a.map:null;this.lightMap=
  113. a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:!0;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=
  114. a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.MeshPhongMaterial.prototype=new THREE.Material;THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;
  115. THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
  116. THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
  117. THREE.MeshShaderMaterial=function(a){console.warn("DEPRECATED: MeshShaderMaterial() is now ShaderMaterial().");return new THREE.ShaderMaterial(a)};
  118. THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.fog=a.fog!==void 0?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
  119. THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==void 0?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};
  120. THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=a.fog!==
  121. void 0?a.fog:!1;this.lights=a.lights!==void 0?a.lights:!1;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1;this.skinning=a.skinning!==void 0?a.skinning:!1;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
  122. THREE.Texture=function(a,c,b,d,h,e){this.id=THREE.TextureCount++;this.image=a;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=b!==void 0?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=h!==void 0?h:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
  123. THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  124. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;
  125. THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,c,b,d,h,e,f,i,j){THREE.Texture.call(this,null,h,e,f,i,j);this.image={data:a,width:c,height:b};this.format=d!==void 0?d:THREE.RGBAFormat};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
  126. THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c;this.sortParticles=!1};
  127. THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,b){THREE.Object3D.call(this);this.geometry=a;this.material=c;this.type=b!==void 0?b:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  128. THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c;if(c instanceof Array)console.warn("DEPRECATED: Mesh material can no longer be an Array. Using material at index 0..."),this.material=c[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};
  129. for(var b=0;b<this.geometry.morphTargets.length;b++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[b].name]=b}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
  130. THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  131. THREE.Bone.prototype.update=function(a,c){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var b,d=this.children.length;for(b=0;b<d;b++)this.children[b].update(this.skinMatrix,c)};
  132. THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,d,h,e,f,i;if(this.geometry.bones!==void 0){for(b=0;b<this.geometry.bones.length;b++)h=this.geometry.bones[b],e=h.pos,f=h.rotq,i=h.scl,d=this.addBone(),d.name=h.name,d.position.set(e[0],e[1],e[2]),d.quaternion.set(f[0],f[1],f[2],f[3]),d.useQuaternion=!0,i!==void 0?d.scale.set(i[0],i[1],i[2]):d.scale.set(1,1,1);for(b=0;b<this.bones.length;b++)h=this.geometry.bones[b],
  133. d=this.bones[b],h.parent===-1?this.add(d):this.bones[h.parent].add(d);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){a===void 0&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  134. THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,c=this.children.length;a<c;a++){var b=this.children[a];b instanceof THREE.Bone?b.update(this.identityMatrix,!1):b.updateMatrixWorld(!0)}for(var c=this.bones.length,b=this.bones,d=this.boneMatrices,a=0;a<c;a++)b[a].skinMatrix.flattenToArrayOffset(d,
  135. a*16)};
  136. THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];var d=new THREE.Matrix4;d.getInverse(a.skinMatrix);c.push(d);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.vertices[a].position,h=this.geometry.skinIndices[a].x,e=this.geometry.skinIndices[a].y,d=
  137. new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[h].multiplyVector3(d));d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[e].multiplyVector3(d));this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1&&(b=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5,this.geometry.skinWeights[a].x+=b,this.geometry.skinWeights[a].y+=b)}}};
  138. THREE.MorphAnimMesh=function(a,c){THREE.Mesh.call(this,a,c);this.duration=1E3;this.mirroredLoop=!1;this.currentKeyframe=this.lastKeyframe=this.time=0;this.direction=1;this.directionBackwards=!1};THREE.MorphAnimMesh.prototype=new THREE.Mesh;THREE.MorphAnimMesh.prototype.constructor=THREE.MorphAnimMesh;
  139. THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var c=this.duration/(this.geometry.morphTargets.length-1);this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration;a=THREE.Math.clamp(Math.floor(this.time/c),0,this.geometry.morphTargets.length-1);if(a!=this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]=
  140. 0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a;c=this.time%c/c;this.directionBackwards&&(c=1-c);this.morphTargetInfluences[this.currentKeyframe]=c;this.morphTargetInfluences[this.lastKeyframe]=1-c};THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
  141. 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.addLevel=function(a,c){c===void 0&&(c=0);for(var c=Math.abs(c),b=0;b<this.LODs.length;b++)if(c<this.LODs[b].visibleAtDistance)break;this.LODs.splice(b,0,{visibleAtDistance:c,object3D:a});this.add(a)};
  142. THREE.LOD.prototype.update=function(a){if(this.LODs.length>1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var c=1;c<this.LODs.length;c++)if(a>=this.LODs[c].visibleAtDistance)this.LODs[c-1].object3D.visible=!1,this.LODs[c].object3D.visible=!0;else break;for(;c<this.LODs.length;c++)this.LODs[c].object3D.visible=!1}};
  143. THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map instanceof THREE.Texture?a.map:THREE.ImageUtils.loadTexture(a.map);this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.useScreenCoordinates=a.useScreenCoordinates!==void 0?a.useScreenCoordinates:!0;this.mergeWith3D=a.mergeWith3D!==void 0?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=a.affectedByDistance!==void 0?a.affectedByDistance:
  144. !this.useScreenCoordinates;this.scaleByViewport=a.scaleByViewport!==void 0?a.scaleByViewport:!this.affectedByDistance;this.alignment=a.alignment instanceof THREE.Vector2?a.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;
  145. THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
  146. 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);
  147. THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
  148. THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a);var c=this.__objectsRemoved.indexOf(a);c!==-1&&this.__objectsRemoved.splice(c,1)}for(c=0;c<a.children.length;c++)this.addObject(a.children[c])};
  149. THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else a instanceof THREE.Camera||(c=this.objects.indexOf(a),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(a),c=this.__objectsAdded.indexOf(a),c!==-1&&this.__objectsAdded.splice(c,1)));for(c=0;c<a.children.length;c++)this.removeObject(a.children[c])};
  150. THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c!==void 0?c:1;this.far=b!==void 0?b:1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c!==void 0?c:2.5E-4};
  151. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,h,e;this.domElement=document.createElement("div");this.setSize=function(a,c){b=a;d=c;h=b/2;e=d/2};this.render=function(b,d){var j,n,o,l,q,r,s,p;a=c.projectScene(b,d);j=0;for(n=a.length;j<n;j++)if(q=a[j],q instanceof THREE.RenderableParticle){s=q.x*h+h;p=q.y*e+e;o=0;for(l=q.material.length;o<l;o++)if(r=q.material[o],r instanceof THREE.ParticleDOMMaterial)r=r.domElement,r.style.left=s+"px",r.style.top=p+"px"}}};
  152. THREE.CanvasRenderer=function(a){function c(a){if(x!=a)p.globalAlpha=x=a}function b(a){if(t!=a){switch(a){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}t=a}}function d(a){if(B!=a)p.strokeStyle=B=a}function h(a){if(G!=a)p.fillStyle=G=a}var e=this,f,i,j,n=new THREE.Projector,a=a||{},o=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
  153. l,q,r,s,p=o.getContext("2d"),v=new THREE.Color(0),w=0,x=1,t=0,B=null,G=null,P=null,C=null,L=null,z,y,F,O,U=new THREE.RenderableVertex,ea=new THREE.RenderableVertex,N,R,k,ga,ja,H,D,T,$,Q,ia,ba,Z=new THREE.Color,ca=new THREE.Color,da=new THREE.Color,X=new THREE.Color,E=new THREE.Color,K=[],aa,fa,la,pa,qa,ua,ta,wa,za,S,I=new THREE.Rectangle,J=new THREE.Rectangle,W=new THREE.Rectangle,ha=!1,na=new THREE.Color,ma=new THREE.Color,oa=new THREE.Color,Y=new THREE.Vector3,xa,ka,Aa,ra,ya,Ea,a=16;xa=document.createElement("canvas");
  154. xa.width=xa.height=2;ka=xa.getContext("2d");ka.fillStyle="rgba(0,0,0,1)";ka.fillRect(0,0,2,2);Aa=ka.getImageData(0,0,2,2);ra=Aa.data;ya=document.createElement("canvas");ya.width=ya.height=a;Ea=ya.getContext("2d");Ea.translate(-a/2,-a/2);Ea.scale(a,a);a--;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){l=a;q=b;r=Math.floor(l/2);s=Math.floor(q/2);o.width=l;o.height=q;I.set(-r,-s,r,s);J.set(-r,-s,r,s);x=1;t=0;L=
  155. C=P=G=B=null};this.setClearColor=function(a,b){v.copy(a);w=b;J.set(-r,-s,r,s)};this.setClearColorHex=function(a,b){v.setHex(a);w=b;J.set(-r,-s,r,s)};this.clear=function(){p.setTransform(1,0,0,-1,r,s);J.isEmpty()||(J.minSelf(I),J.inflate(2),w<1&&p.clearRect(Math.floor(J.getX()),Math.floor(J.getY()),Math.floor(J.getWidth()),Math.floor(J.getHeight())),w>0&&(b(THREE.NormalBlending),c(1),h("rgba("+Math.floor(v.r*255)+","+Math.floor(v.g*255)+","+Math.floor(v.b*255)+","+w+")"),p.fillRect(Math.floor(J.getX()),
  156. Math.floor(J.getY()),Math.floor(J.getWidth()),Math.floor(J.getHeight()))),J.empty())};this.render=function(a,o){function l(a){var b,c,d,e;na.setRGB(0,0,0);ma.setRGB(0,0,0);oa.setRGB(0,0,0);b=0;for(c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(na.r+=e.r,na.g+=e.g,na.b+=e.b):d instanceof THREE.DirectionalLight?(ma.r+=e.r,ma.g+=e.g,ma.b+=e.b):d instanceof THREE.PointLight&&(oa.r+=e.r,oa.g+=e.g,oa.b+=e.b)}function q(a,b,c,d){var e,h,f,k,i,j;e=0;for(h=a.length;e<h;e++)f=a[e],k=f.color,
  157. f instanceof THREE.DirectionalLight?(i=f.matrixWorld.getPosition(),j=c.dot(i),j<=0||(j*=f.intensity,d.r+=k.r*j,d.g+=k.g*j,d.b+=k.b*j)):f instanceof THREE.PointLight&&(i=f.matrixWorld.getPosition(),j=c.dot(Y.sub(i,b).normalize()),j<=0||(j*=f.distance==0?1:1-Math.min(b.distanceTo(i)/f.distance,1),j!=0&&(j*=f.intensity,d.r+=k.r*j,d.g+=k.g*j,d.b+=k.b*j)))}function v(a,e,f){c(f.opacity);b(f.blending);var k,i,j,n,o,l;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)n=f.map.image,o=n.width>>1,l=n.height>>
  158. 1,f=e.scale.x*r,j=e.scale.y*s,k=f*o,i=j*l,W.set(a.x-k,a.y-i,a.x+k,a.y+i),I.intersects(W)&&(p.save(),p.translate(a.x,a.y),p.rotate(-e.rotation),p.scale(f,-j),p.translate(-o,-l),p.drawImage(n,0,0),p.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(k=e.scale.x*r,i=e.scale.y*s,W.set(a.x-k,a.y-i,a.x+k,a.y+i),I.intersects(W)&&(d(f.color.getContextStyle()),h(f.color.getContextStyle()),p.save(),p.translate(a.x,a.y),p.rotate(-e.rotation),p.scale(k,i),f.program(p),p.restore()))}function Ma(a,e,h,
  159. f){c(f.opacity);b(f.blending);p.beginPath();p.moveTo(a.positionScreen.x,a.positionScreen.y);p.lineTo(e.positionScreen.x,e.positionScreen.y);p.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(P!=a)p.lineWidth=P=a;a=f.linecap;if(C!=a)p.lineCap=C=a;a=f.linejoin;if(L!=a)p.lineJoin=L=a;d(f.color.getContextStyle());p.stroke();W.inflate(f.linewidth*2)}}function t(a,d,f,h,i,n,r,l){e.info.render.vertices+=3;e.info.render.faces++;c(l.opacity);b(l.blending);N=a.positionScreen.x;R=a.positionScreen.y;
  160. k=d.positionScreen.x;ga=d.positionScreen.y;ja=f.positionScreen.x;H=f.positionScreen.y;w(N,R,k,ga,ja,H);if(l instanceof THREE.MeshBasicMaterial)if(l.map)l.map.mapping instanceof THREE.UVMapping&&(pa=r.uvs[0],Ca(N,R,k,ga,ja,H,pa[h].u,pa[h].v,pa[i].u,pa[i].v,pa[n].u,pa[n].v,l.map));else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=o.matrixWorldInverse,Y.copy(r.vertexNormalsWorld[h]),qa=(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)*0.5+0.5,ua=-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)*0.5+0.5,
  161. Y.copy(r.vertexNormalsWorld[i]),ta=(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)*0.5+0.5,wa=-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)*0.5+0.5,Y.copy(r.vertexNormalsWorld[n]),za=(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)*0.5+0.5,S=-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)*0.5+0.5,Ca(N,R,k,ga,ja,H,qa,ua,ta,wa,za,S,l.envMap)}else l.wireframe?x(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(l.color);else if(l instanceof THREE.MeshLambertMaterial)l.map&&!l.wireframe&&(l.map.mapping instanceof THREE.UVMapping&&(pa=r.uvs[0],
  162. Ca(N,R,k,ga,ja,H,pa[h].u,pa[h].v,pa[i].u,pa[i].v,pa[n].u,pa[n].v,l.map)),b(THREE.SubtractiveBlending)),ha?!l.wireframe&&l.shading==THREE.SmoothShading&&r.vertexNormalsWorld.length==3?(ca.r=da.r=X.r=na.r,ca.g=da.g=X.g=na.g,ca.b=da.b=X.b=na.b,q(j,r.v1.positionWorld,r.vertexNormalsWorld[0],ca),q(j,r.v2.positionWorld,r.vertexNormalsWorld[1],da),q(j,r.v3.positionWorld,r.vertexNormalsWorld[2],X),ca.r=Math.max(0,Math.min(l.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(l.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(l.color.b*
  163. ca.b,1)),da.r=Math.max(0,Math.min(l.color.r*da.r,1)),da.g=Math.max(0,Math.min(l.color.g*da.g,1)),da.b=Math.max(0,Math.min(l.color.b*da.b,1)),X.r=Math.max(0,Math.min(l.color.r*X.r,1)),X.g=Math.max(0,Math.min(l.color.g*X.g,1)),X.b=Math.max(0,Math.min(l.color.b*X.b,1)),E.r=(da.r+X.r)*0.5,E.g=(da.g+X.g)*0.5,E.b=(da.b+X.b)*0.5,la=G(ca,da,X,E),Ga(N,R,k,ga,ja,H,0,0,1,0,0,1,la)):(Z.r=na.r,Z.g=na.g,Z.b=na.b,q(j,r.centroidWorld,r.normalWorld,Z),Z.r=Math.max(0,Math.min(l.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(l.color.g*
  164. Z.g,1)),Z.b=Math.max(0,Math.min(l.color.b*Z.b,1)),l.wireframe?x(Z,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(Z)):l.wireframe?x(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(l.color);else if(l instanceof THREE.MeshDepthMaterial)aa=o.near,fa=o.far,ca.r=ca.g=ca.b=1-Fa(a.positionScreen.z,aa,fa),da.r=da.g=da.b=1-Fa(d.positionScreen.z,aa,fa),X.r=X.g=X.b=1-Fa(f.positionScreen.z,aa,fa),E.r=(da.r+X.r)*0.5,E.g=(da.g+X.g)*0.5,E.b=(da.b+X.b)*0.5,la=G(ca,da,X,E),Ga(N,
  165. R,k,ga,ja,H,0,0,1,0,0,1,la);else if(l instanceof THREE.MeshNormalMaterial)Z.r=Ha(r.normalWorld.x),Z.g=Ha(r.normalWorld.y),Z.b=Ha(r.normalWorld.z),l.wireframe?x(Z,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(Z)}function Na(a,d,f,h,i,r,n,l,sa){e.info.render.vertices+=4;e.info.render.faces++;c(l.opacity);b(l.blending);if(l.map||l.envMap)t(a,d,h,0,1,3,n,l,sa),t(i,f,r,1,2,3,n,l,sa);else if(N=a.positionScreen.x,R=a.positionScreen.y,k=d.positionScreen.x,ga=d.positionScreen.y,ja=f.positionScreen.x,
  166. H=f.positionScreen.y,D=h.positionScreen.x,T=h.positionScreen.y,$=i.positionScreen.x,Q=i.positionScreen.y,ia=r.positionScreen.x,ba=r.positionScreen.y,l instanceof THREE.MeshBasicMaterial)Ia(N,R,k,ga,ja,H,D,T),l.wireframe?x(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(l.color);else if(l instanceof THREE.MeshLambertMaterial)ha?!l.wireframe&&l.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(ca.r=da.r=X.r=E.r=na.r,ca.g=da.g=X.g=E.g=na.g,ca.b=da.b=X.b=E.b=na.b,q(j,
  167. n.v1.positionWorld,n.vertexNormalsWorld[0],ca),q(j,n.v2.positionWorld,n.vertexNormalsWorld[1],da),q(j,n.v4.positionWorld,n.vertexNormalsWorld[3],X),q(j,n.v3.positionWorld,n.vertexNormalsWorld[2],E),ca.r=Math.max(0,Math.min(l.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(l.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(l.color.b*ca.b,1)),da.r=Math.max(0,Math.min(l.color.r*da.r,1)),da.g=Math.max(0,Math.min(l.color.g*da.g,1)),da.b=Math.max(0,Math.min(l.color.b*da.b,1)),X.r=Math.max(0,Math.min(l.color.r*X.r,1)),
  168. X.g=Math.max(0,Math.min(l.color.g*X.g,1)),X.b=Math.max(0,Math.min(l.color.b*X.b,1)),E.r=Math.max(0,Math.min(l.color.r*E.r,1)),E.g=Math.max(0,Math.min(l.color.g*E.g,1)),E.b=Math.max(0,Math.min(l.color.b*E.b,1)),la=G(ca,da,X,E),w(N,R,k,ga,D,T),Ga(N,R,k,ga,D,T,0,0,1,0,0,1,la),w($,Q,ja,H,ia,ba),Ga($,Q,ja,H,ia,ba,1,0,1,1,0,1,la)):(Z.r=na.r,Z.g=na.g,Z.b=na.b,q(j,n.centroidWorld,n.normalWorld,Z),Z.r=Math.max(0,Math.min(l.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(l.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(l.color.b*
  169. Z.b,1)),Ia(N,R,k,ga,ja,H,D,T),l.wireframe?x(Z,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(Z)):(Ia(N,R,k,ga,ja,H,D,T),l.wireframe?x(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(l.color));else if(l instanceof THREE.MeshNormalMaterial)Z.r=Ha(n.normalWorld.x),Z.g=Ha(n.normalWorld.y),Z.b=Ha(n.normalWorld.z),Ia(N,R,k,ga,ja,H,D,T),l.wireframe?x(Z,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):B(Z);else if(l instanceof THREE.MeshDepthMaterial)aa=
  170. o.near,fa=o.far,ca.r=ca.g=ca.b=1-Fa(a.positionScreen.z,aa,fa),da.r=da.g=da.b=1-Fa(d.positionScreen.z,aa,fa),X.r=X.g=X.b=1-Fa(h.positionScreen.z,aa,fa),E.r=E.g=E.b=1-Fa(f.positionScreen.z,aa,fa),la=G(ca,da,X,E),w(N,R,k,ga,D,T),Ga(N,R,k,ga,D,T,0,0,1,0,0,1,la),w($,Q,ja,H,ia,ba),Ga($,Q,ja,H,ia,ba,1,0,1,1,0,1,la)}function w(a,b,c,d,e,f){p.beginPath();p.moveTo(a,b);p.lineTo(c,d);p.lineTo(e,f);p.lineTo(a,b);p.closePath()}function Ia(a,b,c,d,e,f,h,i){p.beginPath();p.moveTo(a,b);p.lineTo(c,d);p.lineTo(e,f);
  171. p.lineTo(h,i);p.lineTo(a,b);p.closePath()}function x(a,b,c,e){if(P!=b)p.lineWidth=P=b;if(C!=c)p.lineCap=C=c;if(L!=e)p.lineJoin=L=e;d(a.getContextStyle());p.stroke();W.inflate(b*2)}function B(a){h(a.getContextStyle());p.fill()}function Ca(a,b,c,d,e,f,i,k,j,l,n,r,o){if(o.image.width!=0){if(o.needsUpdate==!0||K[o.id]==void 0){var sa=o.wrapS==THREE.RepeatWrapping,q=o.wrapT==THREE.RepeatWrapping;K[o.id]=p.createPattern(o.image,sa&&q?"repeat":sa&&!q?"repeat-x":!sa&&q?"repeat-y":"no-repeat");o.needsUpdate=
  172. !1}h(K[o.id]);var sa=o.offset.x/o.repeat.x,q=o.offset.y/o.repeat.y,S=(o.image.width-1)*o.repeat.x,o=(o.image.height-1)*o.repeat.y,i=(i+sa)*S,k=(k+q)*o,j=(j+sa)*S,l=(l+q)*o,n=(n+sa)*S,r=(r+q)*o;c-=a;d-=b;e-=a;f-=b;j-=i;l-=k;n-=i;r-=k;sa=1/(j*r-n*l);o=(r*c-l*e)*sa;l=(r*d-l*f)*sa;c=(j*e-n*c)*sa;d=(j*f-n*d)*sa;a=a-o*i-c*k;b=b-l*i-d*k;p.save();p.transform(o,l,c,d,a,b);p.fill();p.restore()}}function Ga(a,b,c,d,e,f,h,i,k,j,l,n,r){var o,sa;o=r.width-1;sa=r.height-1;h*=o;i*=sa;k*=o;j*=sa;l*=o;n*=sa;c-=a;d-=
  173. b;e-=a;f-=b;k-=h;j-=i;l-=h;n-=i;sa=1/(k*n-l*j);o=(n*c-j*e)*sa;j=(n*d-j*f)*sa;c=(k*e-l*c)*sa;d=(k*f-l*d)*sa;a=a-o*h-c*i;b=b-j*h-d*i;p.save();p.transform(o,j,c,d,a,b);p.clip();p.drawImage(r,0,0);p.restore()}function G(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),h=~~(b.r*255),i=~~(b.g*255),b=~~(b.b*255),k=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),l=~~(d.r*255),n=~~(d.g*255),d=~~(d.b*255);ra[0]=e<0?0:e>255?255:e;ra[1]=f<0?0:f>255?255:f;ra[2]=a<0?0:a>255?255:a;ra[4]=h<0?0:h>255?255:h;ra[5]=i<
  174. 0?0:i>255?255:i;ra[6]=b<0?0:b>255?255:b;ra[8]=k<0?0:k>255?255:k;ra[9]=j<0?0:j>255?255:j;ra[10]=c<0?0:c>255?255:c;ra[12]=l<0?0:l>255?255:l;ra[13]=n<0?0:n>255?255:n;ra[14]=d<0?0:d>255?255:d;ka.putImageData(Aa,0,0);Ea.drawImage(xa,0,0);return ya}function Fa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ha(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Da(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ja,La,va,Ba;this.autoClear?this.clear():
  175. p.setTransform(1,0,0,-1,r,s);e.info.render.vertices=0;e.info.render.faces=0;f=n.projectScene(a,o,this.sortElements);i=f.elements;j=f.lights;(ha=j.length>0)&&l(j);Ja=0;for(La=i.length;Ja<La;Ja++)if(va=i[Ja],Ba=va.material,Ba=Ba instanceof THREE.MeshFaceMaterial?va.faceMaterial:Ba,!(Ba==null||Ba.opacity==0)){W.empty();if(va instanceof THREE.RenderableParticle)z=va,z.x*=r,z.y*=s,v(z,va,Ba,a);else if(va instanceof THREE.RenderableLine)z=va.v1,y=va.v2,z.positionScreen.x*=r,z.positionScreen.y*=s,y.positionScreen.x*=
  176. r,y.positionScreen.y*=s,W.addPoint(z.positionScreen.x,z.positionScreen.y),W.addPoint(y.positionScreen.x,y.positionScreen.y),I.intersects(W)&&Ma(z,y,va,Ba,a);else if(va instanceof THREE.RenderableFace3)z=va.v1,y=va.v2,F=va.v3,z.positionScreen.x*=r,z.positionScreen.y*=s,y.positionScreen.x*=r,y.positionScreen.y*=s,F.positionScreen.x*=r,F.positionScreen.y*=s,Ba.overdraw&&(Da(z.positionScreen,y.positionScreen),Da(y.positionScreen,F.positionScreen),Da(F.positionScreen,z.positionScreen)),W.add3Points(z.positionScreen.x,
  177. z.positionScreen.y,y.positionScreen.x,y.positionScreen.y,F.positionScreen.x,F.positionScreen.y),I.intersects(W)&&t(z,y,F,0,1,2,va,Ba,a);else if(va instanceof THREE.RenderableFace4)z=va.v1,y=va.v2,F=va.v3,O=va.v4,z.positionScreen.x*=r,z.positionScreen.y*=s,y.positionScreen.x*=r,y.positionScreen.y*=s,F.positionScreen.x*=r,F.positionScreen.y*=s,O.positionScreen.x*=r,O.positionScreen.y*=s,U.positionScreen.copy(y.positionScreen),ea.positionScreen.copy(O.positionScreen),Ba.overdraw&&(Da(z.positionScreen,
  178. y.positionScreen),Da(y.positionScreen,O.positionScreen),Da(O.positionScreen,z.positionScreen),Da(F.positionScreen,U.positionScreen),Da(F.positionScreen,ea.positionScreen)),W.addPoint(z.positionScreen.x,z.positionScreen.y),W.addPoint(y.positionScreen.x,y.positionScreen.y),W.addPoint(F.positionScreen.x,F.positionScreen.y),W.addPoint(O.positionScreen.x,O.positionScreen.y),I.intersects(W)&&Na(z,y,F,O,U,ea,va,Ba,a);J.addRectangle(W)}p.setTransform(1,0,0,1,0,0)}};
  179. THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,h,i,j,l;e=0;for(f=a.length;e<f;e++)h=a[e],i=h.color,h instanceof THREE.DirectionalLight?(j=h.matrixWorld.getPosition(),l=c.dot(j),l<=0||(l*=h.intensity,d.r+=i.r*l,d.g+=i.g*l,d.b+=i.b*l)):h instanceof THREE.PointLight&&(j=h.matrixWorld.getPosition(),l=c.dot(z.sub(j,b).normalize()),l<=0||(l*=h.distance==0?1:1-Math.min(b.distanceTo(j)/h.distance,1),l!=0&&(l*=h.intensity,d.r+=i.r*l,d.g+=i.g*l,d.b+=i.b*l)))}function c(a){y[a]==null&&(y[a]=document.createElementNS("http://www.w3.org/2000/svg",
  180. "path"),N==0&&y[a].setAttribute("shape-rendering","crispEdges"));return y[a]}function b(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var d=this,h,e,f,i=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,o,l,q,r,s,p,v,w=new THREE.Rectangle,x=new THREE.Rectangle,t=!1,B=new THREE.Color,G=new THREE.Color,P=new THREE.Color,C=new THREE.Color,L,z=new THREE.Vector3,y=[],F=[],O,U,ea,N=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
  181. faces:0}};this.setQuality=function(a){switch(a){case "high":N=1;break;case "low":N=0}};this.setSize=function(a,b){n=a;o=b;l=n/2;q=o/2;j.setAttribute("viewBox",-l+" "+-q+" "+n+" "+o);j.setAttribute("width",n);j.setAttribute("height",o);w.set(-l,-q,l,q)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(n,k){var o,z,H,D;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;h=i.projectScene(n,k,this.sortElements);e=h.elements;
  182. f=h.lights;ea=U=0;if(t=f.length>0){G.setRGB(0,0,0);P.setRGB(0,0,0);C.setRGB(0,0,0);o=0;for(z=f.length;o<z;o++)D=f[o],H=D.color,D instanceof THREE.AmbientLight?(G.r+=H.r,G.g+=H.g,G.b+=H.b):D instanceof THREE.DirectionalLight?(P.r+=H.r,P.g+=H.g,P.b+=H.b):D instanceof THREE.PointLight&&(C.r+=H.r,C.g+=H.g,C.b+=H.b)}o=0;for(z=e.length;o<z;o++)if(H=e[o],D=H.material,D=D instanceof THREE.MeshFaceMaterial?H.faceMaterial:D,!(D==null||D.opacity==0))if(x.empty(),H instanceof THREE.RenderableParticle)r=H,r.x*=
  183. l,r.y*=-q,m=0,ml=H.materials.length;else if(H instanceof THREE.RenderableLine){if(r=H.v1,s=H.v2,r.positionScreen.x*=l,r.positionScreen.y*=-q,s.positionScreen.x*=l,s.positionScreen.y*=-q,x.addPoint(r.positionScreen.x,r.positionScreen.y),x.addPoint(s.positionScreen.x,s.positionScreen.y),w.intersects(x)){H=r;var y=s,$=ea++;F[$]==null&&(F[$]=document.createElementNS("http://www.w3.org/2000/svg","line"),N==0&&F[$].setAttribute("shape-rendering","crispEdges"));O=F[$];O.setAttribute("x1",H.positionScreen.x);
  184. O.setAttribute("y1",H.positionScreen.y);O.setAttribute("x2",y.positionScreen.x);O.setAttribute("y2",y.positionScreen.y);D instanceof THREE.LineBasicMaterial&&(O.setAttribute("style","fill: none; stroke: "+D.color.getContextStyle()+"; stroke-width: "+D.linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.linecap+"; stroke-linejoin: "+D.linejoin),j.appendChild(O))}}else if(H instanceof THREE.RenderableFace3){if(r=H.v1,s=H.v2,p=H.v3,r.positionScreen.x*=l,r.positionScreen.y*=-q,s.positionScreen.x*=
  185. l,s.positionScreen.y*=-q,p.positionScreen.x*=l,p.positionScreen.y*=-q,x.addPoint(r.positionScreen.x,r.positionScreen.y),x.addPoint(s.positionScreen.x,s.positionScreen.y),x.addPoint(p.positionScreen.x,p.positionScreen.y),w.intersects(x)){var y=r,$=s,Q=p;d.info.render.vertices+=3;d.info.render.faces++;O=c(U++);O.setAttribute("d","M "+y.positionScreen.x+" "+y.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");D instanceof THREE.MeshBasicMaterial?
  186. B.copy(D.color):D instanceof THREE.MeshLambertMaterial?t?(B.r=G.r,B.g=G.g,B.b=G.b,a(f,H.centroidWorld,H.normalWorld,B),B.r=Math.max(0,Math.min(D.color.r*B.r,1)),B.g=Math.max(0,Math.min(D.color.g*B.g,1)),B.b=Math.max(0,Math.min(D.color.b*B.b,1))):B.copy(D.color):D instanceof THREE.MeshDepthMaterial?(L=1-D.__2near/(D.__farPlusNear-H.z*D.__farMinusNear),B.setRGB(L,L,L)):D instanceof THREE.MeshNormalMaterial&&B.setRGB(b(H.normalWorld.x),b(H.normalWorld.y),b(H.normalWorld.z));D.wireframe?O.setAttribute("style",
  187. "fill: none; stroke: "+B.getContextStyle()+"; stroke-width: "+D.wireframeLinewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframeLinecap+"; stroke-linejoin: "+D.wireframeLinejoin):O.setAttribute("style","fill: "+B.getContextStyle()+"; fill-opacity: "+D.opacity);j.appendChild(O)}}else if(H instanceof THREE.RenderableFace4&&(r=H.v1,s=H.v2,p=H.v3,v=H.v4,r.positionScreen.x*=l,r.positionScreen.y*=-q,s.positionScreen.x*=l,s.positionScreen.y*=-q,p.positionScreen.x*=l,p.positionScreen.y*=
  188. -q,v.positionScreen.x*=l,v.positionScreen.y*=-q,x.addPoint(r.positionScreen.x,r.positionScreen.y),x.addPoint(s.positionScreen.x,s.positionScreen.y),x.addPoint(p.positionScreen.x,p.positionScreen.y),x.addPoint(v.positionScreen.x,v.positionScreen.y),w.intersects(x))){var y=r,$=s,Q=p,ia=v;d.info.render.vertices+=4;d.info.render.faces++;O=c(U++);O.setAttribute("d","M "+y.positionScreen.x+" "+y.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+
  189. " L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");D instanceof THREE.MeshBasicMaterial?B.copy(D.color):D instanceof THREE.MeshLambertMaterial?t?(B.r=G.r,B.g=G.g,B.b=G.b,a(f,H.centroidWorld,H.normalWorld,B),B.r=Math.max(0,Math.min(D.color.r*B.r,1)),B.g=Math.max(0,Math.min(D.color.g*B.g,1)),B.b=Math.max(0,Math.min(D.color.b*B.b,1))):B.copy(D.color):D instanceof THREE.MeshDepthMaterial?(L=1-D.__2near/(D.__farPlusNear-H.z*D.__farMinusNear),B.setRGB(L,L,L)):D instanceof THREE.MeshNormalMaterial&&
  190. B.setRGB(b(H.normalWorld.x),b(H.normalWorld.y),b(H.normalWorld.z));D.wireframe?O.setAttribute("style","fill: none; stroke: "+B.getContextStyle()+"; stroke-width: "+D.wireframeLinewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframeLinecap+"; stroke-linejoin: "+D.wireframeLinejoin):O.setAttribute("style","fill: "+B.getContextStyle()+"; fill-opacity: "+D.opacity);j.appendChild(O)}}};
  191. THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
  192. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform float flipEnvMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\n}\n#endif",
  193. 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",
  194. 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\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",
  195. 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_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform 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#endif",
  196. lights_lambert_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = vec3( 0.0 );\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}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;\n}",
  197. lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\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#endif",
  198. lights_phong_pars_fragment:"uniform 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 ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
  199. lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDistance = lDistance;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );\nfloat pointSpecularWeight = pow( pointDotNormalHalf, shininess );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = pow( dirDotNormalHalf, shininess );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif",
  200. 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\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\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",
  201. 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",
  202. 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",
  203. 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\nvec3 shadowColor = vec3( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\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 )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif",
  204. 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",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"};
  205. THREE.UniformsUtils={merge:function(a){var c,b,d,h={};for(c=0;c<a.length;c++)for(b in d=this.clone(a[c]),d)h[b]=d[b];return h},clone:function(a){var c,b,d,h={};for(c in a)for(b in h[c]={},a[c])d=a[c][b],h[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector2||d instanceof THREE.Vector3||d instanceof THREE.Vector4||d instanceof THREE.Matrix4||d instanceof THREE.Texture?d.clone():d instanceof Array?d.slice():d;return h}};
  206. 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},flipEnvMap:{type:"f",value:-1},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",
  207. value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",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",
  208. value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:6,texture:[]},shadowMatrix:{type:"m4v",value:[]},shadowBias:{type:"f",value:0.0039},shadowDarkness:{type:"f",value:0.2}}};
  209. THREE.ShaderLib={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}",fragmentShader:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\n}"},
  210. depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",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}"},normal:{uniforms:{opacity:{type:"f",value:1}},
  211. vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex,
  212. 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,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
  213. THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),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,
  214. THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)}}]),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,
  215. THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_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,"vec3 transformedNormal = normalize( normalMatrix * normal );",
  216. THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",
  217. THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",
  218. value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),vertexShader:["varying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_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 );",
  219. 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 = -mvPosition.xyz;\nvec3 transformedNormal = normalMatrix * normal;\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,
  220. "}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;",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_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,
  221. THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,
  222. 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;",THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,
  223. THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"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")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,
  224. THREE.ShaderChunk.default_vertex,"}"].join("\n"),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}"}};
  225. THREE.WebGLRenderer=function(a){function c(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(a.__webglCustomAttributesList===void 0)a.__webglCustomAttributesList=[];for(var e in d.attributes){var h=d.attributes[e];if(!h.__webglInitialized||h.createUniqueBuffers){h.__webglInitialized=!0;var f=1;h.type==="v2"?f=2:h.type==="v3"?f=3:h.type==="v4"?f=4:h.type==="c"&&(f=3);h.size=f;h.array=new Float32Array(c*f);h.buffer=k.createBuffer();h.buffer.belongsToAttribute=e;h.needsUpdate=!0}a.__webglCustomAttributesList.push(h)}}}
  226. function b(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,h,f,i=a.vertices;f=i.length;var j=a.colors,l=j.length,n=a.__vertexArray,o=a.__colorArray,r=a.__sortArray,p=a.__dirtyVertices,q=a.__dirtyColors,S=a.__webglCustomAttributesList;if(c.sortParticles){ua.multiplySelf(c.matrixWorld);for(d=0;d<f;d++)e=i[d].position,za.copy(e),ua.multiplyVector3(za),r[d]=[za.z,d];
  227. r.sort(function(a,b){return b[0]-a[0]});for(d=0;d<f;d++)e=i[r[d][1]].position,h=d*3,n[h]=e.x,n[h+1]=e.y,n[h+2]=e.z;for(d=0;d<l;d++)h=d*3,e=j[r[d][1]],o[h]=e.r,o[h+1]=e.g,o[h+2]=e.b;if(S){j=0;for(l=S.length;j<l;j++)if(i=S[j],i.boundTo===void 0||i.boundTo==="vertices")if(h=0,e=i.value.length,i.size===1)for(d=0;d<e;d++)f=r[d][1],i.array[d]=i.value[f];else if(i.size===2)for(d=0;d<e;d++)f=r[d][1],f=i.value[f],i.array[h]=f.x,i.array[h+1]=f.y,h+=2;else if(i.size===3)if(i.type==="c")for(d=0;d<e;d++)f=r[d][1],
  228. f=i.value[f],i.array[h]=f.r,i.array[h+1]=f.g,i.array[h+2]=f.b,h+=3;else for(d=0;d<e;d++)f=r[d][1],f=i.value[f],i.array[h]=f.x,i.array[h+1]=f.y,i.array[h+2]=f.z,h+=3;else if(i.size===4)for(d=0;d<e;d++)f=r[d][1],f=i.value[f],i.array[h]=f.x,i.array[h+1]=f.y,i.array[h+2]=f.z,i.array[h+3]=f.w,h+=4}}else{if(p)for(d=0;d<f;d++)e=i[d].position,h=d*3,n[h]=e.x,n[h+1]=e.y,n[h+2]=e.z;if(q)for(d=0;d<l;d++)e=j[d],h=d*3,o[h]=e.r,o[h+1]=e.g,o[h+2]=e.b;if(S){j=0;for(l=S.length;j<l;j++)if(i=S[j],i.needsUpdate&&(i.boundTo===
  229. void 0||i.boundTo==="vertices"))if(e=i.value.length,h=0,i.size===1)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(i.size===2)for(d=0;d<e;d++)f=i.value[d],i.array[h]=f.x,i.array[h+1]=f.y,h+=2;else if(i.size===3)if(i.type==="c")for(d=0;d<e;d++)f=i.value[d],i.array[h]=f.r,i.array[h+1]=f.g,i.array[h+2]=f.b,h+=3;else for(d=0;d<e;d++)f=i.value[d],i.array[h]=f.x,i.array[h+1]=f.y,i.array[h+2]=f.z,h+=3;else if(i.size===4)for(d=0;d<e;d++)f=i.value[d],i.array[h]=f.x,i.array[h+1]=f.y,i.array[h+2]=f.z,i.array[h+
  230. 3]=f.w,h+=4}}if(p||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,n,b);if(q||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,o,b);if(S){j=0;for(l=S.length;j<l;j++)if(i=S[j],i.needsUpdate||c.sortParticles)k.bindBuffer(k.ARRAY_BUFFER,i.buffer),k.bufferData(k.ARRAY_BUFFER,i.array,b)}}function h(a,b,c,d,e){d.program||R.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=
  231. new Float32Array(R.maxMorphTargets);for(var h=0,f=R.maxMorphTargets;h<f;h++)e.__webglMorphTargetInfluences[h]=0}var i=!1,h=d.program,f=h.uniforms,j=d.uniforms;h!==ja&&(k.useProgram(h),ja=h,i=!0);if(d.id!==D)D=d.id,i=!0;if(i){k.uniformMatrix4fv(f.projectionMatrix,!1,ta);if(c&&d.fog)if(j.fogColor.value=c.color,c instanceof THREE.Fog)j.fogNear.value=c.near,j.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||
  232. d.lights){for(var l,n,o=0,r=0,p=0,q,s,J,v=S,t=v.directional.colors,w=v.directional.positions,x=v.point.colors,B=v.point.positions,W=v.point.distances,E=0,G=0,c=l=J=0,i=b.length;c<i;c++)if(l=b[c],n=l.color,q=l.position,s=l.intensity,J=l.distance,l instanceof THREE.AmbientLight)R.gammaInput?(o+=n.r*n.r,r+=n.g*n.g,p+=n.b*n.b):(o+=n.r,r+=n.g,p+=n.b);else if(l instanceof THREE.DirectionalLight)J=E*3,R.gammaInput?(t[J]=n.r*n.r*s*s,t[J+1]=n.g*n.g*s*s,t[J+2]=n.b*n.b*s*s):(t[J]=n.r*s,t[J+1]=n.g*s,t[J+2]=n.b*
  233. s),w[J]=q.x,w[J+1]=q.y,w[J+2]=q.z,E+=1;else if(l instanceof THREE.SpotLight)J=E*3,R.gammaInput?(t[J]=n.r*n.r*s*s,t[J+1]=n.g*n.g*s*s,t[J+2]=n.b*n.b*s*s):(t[J]=n.r*s,t[J+1]=n.g*s,t[J+2]=n.b*s),n=1/q.length(),w[J]=q.x*n,w[J+1]=q.y*n,w[J+2]=q.z*n,E+=1;else if(l instanceof THREE.PointLight)l=G*3,R.gammaInput?(x[l]=n.r*n.r*s*s,x[l+1]=n.g*n.g*s*s,x[l+2]=n.b*n.b*s*s):(x[l]=n.r*s,x[l+1]=n.g*s,x[l+2]=n.b*s),B[l]=q.x,B[l+1]=q.y,B[l+2]=q.z,W[G]=J,G+=1;c=E*3;for(i=t.length;c<i;c++)t[c]=0;c=G*3;for(i=x.length;c<
  234. i;c++)x[c]=0;v.point.length=G;v.directional.length=E;v.ambient[0]=o;v.ambient[1]=r;v.ambient[2]=p;b=S;j.enableLighting.value=b.directional.length+b.point.length;j.ambientLightColor.value=b.ambient;j.directionalLightColor.value=b.directional.colors;j.directionalLightDirection.value=b.directional.positions;j.pointLightColor.value=b.point.colors;j.pointLightPosition.value=b.point.positions;j.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||
  235. d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,R.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color,(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),j.lightMap.texture=d.lightMap,j.envMap.texture=d.envMap,j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,j.reflectivity.value=d.reflectivity,j.refractionRatio.value=d.refractionRatio,j.combine.value=d.combine,j.useRefract.value=
  236. d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)j.diffuse.value=d.color,j.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)j.psColor.value=d.color,j.opacity.value=d.opacity,j.size.value=d.size,j.scale.value=I.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=d.shininess,R.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),j.specular.value.copyGammaToLinear(d.specular)):
  237. (j.ambient.value=d.ambient,j.specular.value=d.specular);else if(d instanceof THREE.MeshLambertMaterial)R.gammaInput?j.ambient.value.copyGammaToLinear(d.ambient):j.ambient.value=d.ambient;else if(d instanceof THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&j.shadowMatrix){for(b=0;b<xa.length;b++)j.shadowMatrix.value[b]=xa[b],j.shadowMap.texture[b]=R.shadowMap[b];
  238. j.shadowDarkness.value=R.shadowMapDarkness;j.shadowBias.value=R.shadowMapBias}b=d.uniformsList;j=0;for(c=b.length;j<c;j++)if(r=h.uniforms[b[j][1]])if(o=b[j][0],p=o.type,i=o.value,p==="i")k.uniform1i(r,i);else if(p==="f")k.uniform1f(r,i);else if(p==="v2")k.uniform2f(r,i.x,i.y);else if(p==="v3")k.uniform3f(r,i.x,i.y,i.z);else if(p==="v4")k.uniform4f(r,i.x,i.y,i.z,i.w);else if(p==="c")k.uniform3f(r,i.r,i.g,i.b);else if(p==="fv1")k.uniform1fv(r,i);else if(p==="fv")k.uniform3fv(r,i);else if(p==="v3v"){if(!o._array)o._array=
  239. new Float32Array(3*i.length);p=0;for(q=i.length;p<q;p++)v=p*3,o._array[v]=i[p].x,o._array[v+1]=i[p].y,o._array[v+2]=i[p].z;k.uniform3fv(r,o._array)}else if(p==="m4"){if(!o._array)o._array=new Float32Array(16);i.flattenToArray(o._array);k.uniformMatrix4fv(r,!1,o._array)}else if(p==="m4v"){if(!o._array)o._array=new Float32Array(16*i.length);p=0;for(q=i.length;p<q;p++)i[p].flattenToArrayOffset(o._array,p*16);k.uniformMatrix4fv(r,!1,o._array)}else if(p==="t"){if(k.uniform1i(r,i),r=o.texture)if(r.image instanceof
  240. Array&&r.image.length===6){if(o=r,o.image.length===6)if(o.needsUpdate){if(!o.image.__webglTextureCube)o.image.__webglTextureCube=k.createTexture();k.activeTexture(k.TEXTURE0+i);k.bindTexture(k.TEXTURE_CUBE_MAP,o.image.__webglTextureCube);for(i=0;i<6;i++)k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,o.image[i]);L(k.TEXTURE_CUBE_MAP,o,o.image[0]);o.needsUpdate=!1}else k.activeTexture(k.TEXTURE0+i),k.bindTexture(k.TEXTURE_CUBE_MAP,o.image.__webglTextureCube)}else r instanceof
  241. THREE.WebGLRenderTargetCube?(o=r,k.activeTexture(k.TEXTURE0+i),k.bindTexture(k.TEXTURE_CUBE_MAP,o.__webglTexture)):z(r,i)}else if(p==="tv"){if(!o._array){o._array=[];p=0;for(q=o.texture.length;p<q;p++)o._array[p]=i+p}k.uniform1iv(r,o._array);p=0;for(q=o.texture.length;p<q;p++)(r=o.texture[p])&&z(r,o._array[p])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&f.cameraPosition!==null&&k.uniform3f(f.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof
  242. THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&f.viewMatrix!==null&&k.uniformMatrix4fv(f.viewMatrix,!1,wa);d.skinning&&(k.uniformMatrix4fv(f.cameraInverseMatrix,!1,wa),k.uniformMatrix4fv(f.boneGlobalMatrices,!1,e.boneMatrices))}k.uniformMatrix4fv(f.modelViewMatrix,!1,e._modelViewMatrixArray);f.normalMatrix&&k.uniformMatrix3fv(f.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&
  243. f.objectMatrix!==null&&k.uniformMatrix4fv(f.objectMatrix,!1,e._objectMatrixArray);return h}function e(a,b,c,d,e,f){if(d.opacity!==0){var i,j,c=h(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==T&&(T=c,a=!0);if(!d.morphTargets&&b.position>=0)a&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),
  244. k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){i=0;var l=f.morphTargetForcedOrder;for(j=f.morphTargetInfluences;i<d.numSupportedMorphTargets&&i<l.length;)k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l[i]]),k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,!1,0,0),f.__webglMorphTargetInfluences[i]=j[l[i]],i++}else{var l=[],n=-1,
  245. o=0;j=f.morphTargetInfluences;var r,p=j.length;i=0;for(f.morphTargetBase!==-1&&(l[f.morphTargetBase]=!0);i<d.numSupportedMorphTargets;){for(r=0;r<p;r++)!l[r]&&j[r]>n&&(o=r,n=j[o]);k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[o]);k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[i]=n;l[o]=1;n=-1;i++}}d.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){i=
  246. 0;for(j=e.__webglCustomAttributesList.length;i<j;i++)c=e.__webglCustomAttributesList[i],b[c.buffer.belongsToAttribute]>=0&&(k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,k.FLOAT,!1,0,0))}b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglColorBuffer),k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER,
  247. e.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=
  248. 0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?
  249. (d=d.wireframeLinewidth,d!==K&&(k.lineWidth(d),K=d),a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),k.drawElements(k.LINES,e.__webglLineCount,k.UNSIGNED_SHORT,0)):(a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),k.drawElements(k.TRIANGLES,e.__webglFaceCount,k.UNSIGNED_SHORT,0)),R.info.render.calls++,R.info.render.vertices+=e.__webglFaceCount,R.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?k.LINE_STRIP:k.LINES,d=d.linewidth,d!==
  250. K&&(k.lineWidth(d),K=d),k.drawArrays(f,0,e.__webglLineCount),R.info.render.calls++):f instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,e.__webglParticleCount),R.info.render.calls++):f instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,e.__webglVertexCount),R.info.render.calls++)}}function f(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=k.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=k.createBuffer();a.hasPos&&(k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer),
  251. k.bufferData(k.ARRAY_BUFFER,a.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(b.attributes.position),k.vertexAttribPointer(b.attributes.position,3,k.FLOAT,!1,0,0));if(a.hasNormal){k.bindBuffer(k.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,h,i,j,l,n,o,r,p=a.count*3;for(r=0;r<p;r+=9)c=a.normalArray,d=c[r],e=c[r+1],f=c[r+2],h=c[r+3],j=c[r+4],n=c[r+5],i=c[r+6],l=c[r+7],o=c[r+8],d=(d+h+i)/3,e=(e+j+l)/3,f=(f+n+o)/3,c[r]=d,c[r+1]=e,c[r+2]=f,c[r+3]=d,c[r+4]=e,c[r+5]=f,
  252. c[r+6]=d,c[r+7]=e,c[r+8]=f}k.bufferData(k.ARRAY_BUFFER,a.normalArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.normal);k.vertexAttribPointer(b.attributes.normal,3,k.FLOAT,!1,0,0)}k.drawArrays(k.TRIANGLES,0,a.count);a.count=0}function i(a){if(Q!==a.doubleSided)a.doubleSided?k.disable(k.CULL_FACE):k.enable(k.CULL_FACE),Q=a.doubleSided;if(ia!==a.flipSided)a.flipSided?k.frontFace(k.CW):k.frontFace(k.CCW),ia=a.flipSided}function j(a){Z!==a&&(a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST),
  253. Z=a)}function n(a){ca!==a&&(k.depthMask(a),ca=a)}function o(a,b,c){da!==a&&(a?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL),da=a);if(a&&(X!==b||E!==c))k.polygonOffset(b,c),X=b,E=c}function l(a){qa[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);qa[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);qa[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);qa[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);qa[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-
  254. a.n34);qa[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=qa[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function q(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),d=0;d<6;d++)if(a=qa[d].x*b.n14+qa[d].y*b.n24+qa[d].z*b.n34+qa[d].w,a<=c)return!1;return!0}function r(a){var b=a.object.material;b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function s(a){var b=a.object,
  255. c=a.buffer,d;d=b.material;if(d instanceof THREE.MeshFaceMaterial){if(c=c.materialIndex,c>=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=d)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function p(a,b){return b.z-a.z}function v(a){var b,c,d,n=0,o,r,p,s,S,J,v=a.lights;Y||(Y=new THREE.PerspectiveCamera(R.shadowCameraFov,R.shadowMapWidth/R.shadowMapHeight,R.shadowCameraNear,R.shadowCameraFar));b=0;for(c=
  256. v.length;b<c;b++)if(d=v[b],d instanceof THREE.SpotLight&&d.castShadow){D=-1;R.shadowMap[n]||(R.shadowMap[n]=new THREE.WebGLRenderTarget(R.shadowMapWidth,R.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));xa[n]||(xa[n]=new THREE.Matrix4);o=R.shadowMap[n];r=xa[n];Y.position.copy(d.position);Y.lookAt(d.target.position);Y.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."),a.add(Y));this.autoUpdateScene&&a.updateMatrixWorld();Y.matrixWorldInverse.getInverse(Y.matrixWorld);
  257. r.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);r.multiplySelf(Y.projectionMatrix);r.multiplySelf(Y.matrixWorldInverse);Y.matrixWorldInverse.flattenToArray(wa);Y.projectionMatrix.flattenToArray(ta);ua.multiply(Y.projectionMatrix,Y.matrixWorldInverse);l(ua);F(o);k.clearColor(1,1,1,1);R.clear();k.clearColor(na.r,na.g,na.b,ma);r=a.__webglObjects.length;d=a.__webglObjectsImmediate.length;for(o=0;o<r;o++)p=a.__webglObjects[o],J=p.object,J.visible&&J.castShadow?!(J instanceof THREE.Mesh)||!J.frustumCulled||
  258. q(J)?(J.matrixWorld.flattenToArray(J._objectMatrixArray),x(J,Y,!1),p.render=!0):p.render=!1:p.render=!1;j(!0);C(THREE.NormalBlending);for(o=0;o<r;o++)if(p=a.__webglObjects[o],p.render)J=p.object,S=p.buffer,i(J),p=J.customDepthMaterial?J.customDepthMaterial:J.geometry.morphTargets.length?ra:Aa,e(Y,v,null,p,S,J);for(o=0;o<d;o++)p=a.__webglObjectsImmediate[o],J=p.object,J.visible&&J.castShadow&&(J.matrixAutoUpdate&&J.matrixWorld.flattenToArray(J._objectMatrixArray),T=-1,x(J,Y,!1),i(J),s=h(Y,v,null,Aa,
  259. J),J.immediateRenderCallback?J.immediateRenderCallback(s,k,qa):J.render(function(a){f(a,s,Aa.shading)}));n++}}function w(a,b){var c,d,e;c=M.attributes;var f=M.uniforms,h=pa/la,i,j=[],l=la*0.5,n=pa*0.5,o=!0;k.useProgram(M.program);ja=M.program;T=Z=ba=-1;Ka||(k.enableVertexAttribArray(M.attributes.position),k.enableVertexAttribArray(M.attributes.uv),Ka=!0);k.disable(k.CULL_FACE);k.enable(k.BLEND);k.depthMask(!0);k.bindBuffer(k.ARRAY_BUFFER,M.vertexBuffer);k.vertexAttribPointer(c.position,2,k.FLOAT,
  260. !1,16,0);k.vertexAttribPointer(c.uv,2,k.FLOAT,!1,16,8);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,M.elementBuffer);k.uniformMatrix4fv(f.projectionMatrix,!1,ta);k.activeTexture(k.TEXTURE0);k.uniform1i(f.map,0);c=0;for(d=a.__webglSprites.length;c<d;c++)if(e=a.__webglSprites[c],e.visible&&e.opacity!==0)e.useScreenCoordinates?e.z=-e.position.z:(e._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,e.matrixWorld,e._modelViewMatrixArray),e.z=-e._modelViewMatrix.n34);a.__webglSprites.sort(p);c=0;for(d=a.__webglSprites.length;c<
  261. d;c++)e=a.__webglSprites[c],e.visible&&e.opacity!==0&&e.map&&e.map.image&&e.map.image.width&&(e.useScreenCoordinates?(k.uniform1i(f.useScreenCoordinates,1),k.uniform3f(f.screenPosition,(e.position.x-l)/l,(n-e.position.y)/n,Math.max(0,Math.min(1,e.position.z)))):(k.uniform1i(f.useScreenCoordinates,0),k.uniform1i(f.affectedByDistance,e.affectedByDistance?1:0),k.uniformMatrix4fv(f.modelViewMatrix,!1,e._modelViewMatrixArray)),i=e.map.image.width/(e.scaleByViewport?pa:1),j[0]=i*h*e.scale.x,j[1]=i*e.scale.y,
  262. k.uniform2f(f.uvScale,e.uvScale.x,e.uvScale.y),k.uniform2f(f.uvOffset,e.uvOffset.x,e.uvOffset.y),k.uniform2f(f.alignment,e.alignment.x,e.alignment.y),k.uniform1f(f.opacity,e.opacity),k.uniform3f(f.color,e.color.r,e.color.g,e.color.b),k.uniform1f(f.rotation,e.rotation),k.uniform2fv(f.scale,j),e.mergeWith3D&&!o?(k.enable(k.DEPTH_TEST),o=!0):!e.mergeWith3D&&o&&(k.disable(k.DEPTH_TEST),o=!1),C(e.blending),z(e.map,0),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0));k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);
  263. k.depthMask(ca)}function x(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function t(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function B(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function G(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function P(a,b,c){a.push({buffer:b,object:c,
  264. opaque:null,transparent:null})}function C(a){if(a!==ba){switch(a){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)}ba=
  265. a}}function L(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(k.texParameteri(a,k.TEXTURE_WRAP_S,N(b.wrapS)),k.texParameteri(a,k.TEXTURE_WRAP_T,N(b.wrapT)),k.texParameteri(a,k.TEXTURE_MAG_FILTER,N(b.magFilter)),k.texParameteri(a,k.TEXTURE_MIN_FILTER,N(b.minFilter)),k.generateMipmap(a)):(k.texParameteri(a,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(a,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(a,k.TEXTURE_MAG_FILTER,ea(b.magFilter)),k.texParameteri(a,k.TEXTURE_MIN_FILTER,ea(b.minFilter)))}
  266. function z(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=k.createTexture(),R.info.memory.textures++;k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?k.texImage2D(k.TEXTURE_2D,0,N(a.format),a.image.width,a.image.height,0,N(a.format),k.UNSIGNED_BYTE,a.image.data):k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,a.image);L(k.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else k.activeTexture(k.TEXTURE0+b),k.bindTexture(k.TEXTURE_2D,
  267. a.__webglTexture)}function y(a,b){k.bindRenderbuffer(k.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_STENCIL,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,a)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height)}
  268. function F(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=k.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture);L(k.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=k.createFramebuffer();a.__webglRenderbuffer[c]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+
  269. c,0,N(a.format),a.width,a.height,0,N(a.format),N(a.type),null);var d=a,e=k.TEXTURE_CUBE_MAP_POSITIVE_X+c;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer[c]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,e,d.__webglTexture,0);y(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=k.createFramebuffer(),a.__webglRenderbuffer=k.createRenderbuffer(),k.bindTexture(k.TEXTURE_2D,a.__webglTexture),L(k.TEXTURE_2D,a,a),k.texImage2D(k.TEXTURE_2D,0,N(a.format),a.width,a.height,0,N(a.format),
  270. N(a.type),null),c=k.TEXTURE_2D,k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer),k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,c,a.__webglTexture,0),k.bindRenderbuffer(k.RENDERBUFFER,a.__webglRenderbuffer),y(a.__webglRenderbuffer,a);b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,
  271. c=la,a=pa,d=aa,e=fa);b!==H&&(k.bindFramebuffer(k.FRAMEBUFFER,b),k.viewport(d,e,c,a),H=b)}function O(a){a instanceof THREE.WebGLRenderTargetCube?(k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture),k.generateMipmap(k.TEXTURE_CUBE_MAP),k.bindTexture(k.TEXTURE_CUBE_MAP,null)):(k.bindTexture(k.TEXTURE_2D,a.__webglTexture),k.generateMipmap(k.TEXTURE_2D),k.bindTexture(k.TEXTURE_2D,null))}function U(a,b){var c;a==="fragment"?c=k.createShader(k.FRAGMENT_SHADER):a==="vertex"&&(c=k.createShader(k.VERTEX_SHADER));
  272. k.shaderSource(c,b);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS))return console.error(k.getShaderInfoLog(c)),console.error(b),null;return c}function ea(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST;default:return k.LINEAR}}function N(a){switch(a){case THREE.RepeatWrapping:return k.REPEAT;case THREE.ClampToEdgeWrapping:return k.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return k.MIRRORED_REPEAT;
  273. 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;
  274. 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 R=this,k,ga=[],ja=null,H=null,D=-1,T=null,$=0,Q=null,ia=null,ba=null,Z=null,ca=null,da=null,X=null,E=null,K=null,aa=0,fa=0,la=0,pa=0,qa=[new THREE.Vector4,new THREE.Vector4,
  275. new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ua=new THREE.Matrix4,ta=new Float32Array(16),wa=new Float32Array(16),za=new THREE.Vector4,S={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},I=a.canvas!==void 0?a.canvas:document.createElement("canvas"),J=a.stencil!==void 0?a.stencil:!0,W=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ha=a.antialias!==void 0?a.antialias:!1,na=a.clearColor!==
  276. void 0?new THREE.Color(a.clearColor):new THREE.Color(0),ma=a.clearAlpha!==void 0?a.clearAlpha:0,oa=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=I;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=
  277. 0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;var Y,xa=[],a=THREE.ShaderLib.depthRGBA,ka=THREE.UniformsUtils.clone(a.uniforms),Aa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ka}),ra=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ka,morphTargets:!0});
  278. Aa._shadowPass=!0;ra._shadowPass=!0;try{if(!(k=I.getContext("experimental-webgl",{antialias:ha,stencil:J,preserveDrawingBuffer:W})))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(ya){console.error(ya)}k.clearColor(0,0,0,1);k.clearDepth(1);k.clearStencil(0);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);
  279. 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(na.r,na.g,na.b,ma);this.context=k;var Ea=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,M={};M.vertices=new Float32Array(16);M.faces=new Uint16Array(6);J=0;M.vertices[J++]=-1;M.vertices[J++]=-1;M.vertices[J++]=0;M.vertices[J++]=1;M.vertices[J++]=1;M.vertices[J++]=-1;M.vertices[J++]=1;M.vertices[J++]=1;M.vertices[J++]=1;M.vertices[J++]=1;M.vertices[J++]=1;M.vertices[J++]=
  280. 0;M.vertices[J++]=-1;M.vertices[J++]=1;M.vertices[J++]=0;J=M.vertices[J++]=0;M.faces[J++]=0;M.faces[J++]=1;M.faces[J++]=2;M.faces[J++]=0;M.faces[J++]=2;M.faces[J++]=3;M.vertexBuffer=k.createBuffer();M.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,M.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,M.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,M.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,M.faces,k.STATIC_DRAW);M.program=k.createProgram();k.attachShader(M.program,U("fragment",
  281. THREE.ShaderLib.sprite.fragmentShader));k.attachShader(M.program,U("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(M.program);M.attributes={};M.uniforms={};M.attributes.position=k.getAttribLocation(M.program,"position");M.attributes.uv=k.getAttribLocation(M.program,"uv");M.uniforms.uvOffset=k.getUniformLocation(M.program,"uvOffset");M.uniforms.uvScale=k.getUniformLocation(M.program,"uvScale");M.uniforms.rotation=k.getUniformLocation(M.program,"rotation");M.uniforms.scale=k.getUniformLocation(M.program,
  282. "scale");M.uniforms.alignment=k.getUniformLocation(M.program,"alignment");M.uniforms.color=k.getUniformLocation(M.program,"color");M.uniforms.map=k.getUniformLocation(M.program,"map");M.uniforms.opacity=k.getUniformLocation(M.program,"opacity");M.uniforms.useScreenCoordinates=k.getUniformLocation(M.program,"useScreenCoordinates");M.uniforms.affectedByDistance=k.getUniformLocation(M.program,"affectedByDistance");M.uniforms.screenPosition=k.getUniformLocation(M.program,"screenPosition");M.uniforms.modelViewMatrix=
  283. k.getUniformLocation(M.program,"modelViewMatrix");M.uniforms.projectionMatrix=k.getUniformLocation(M.program,"projectionMatrix");var Ka=!1;this.setSize=function(a,b){I.width=a;I.height=b;this.setViewport(0,0,I.width,I.height)};this.setViewport=function(a,b,c,d){aa=a;fa=b;la=c;pa=d;k.viewport(aa,fa,la,pa)};this.setScissor=function(a,b,c,d){k.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.setClearColorHex=function(a,b){na.setHex(a);ma=
  284. b;k.clearColor(na.r,na.g,na.b,ma)};this.setClearColor=function(a,b){na.copy(a);ma=b;k.clearColor(na.r,na.g,na.b,ma)};this.getClearColor=function(){return na};this.getClearAlpha=function(){return ma};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=k.COLOR_BUFFER_BIT;if(b===void 0||b)d|=k.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=k.STENCIL_BUFFER_BIT;k.clear(d)};this.getContext=function(){return k};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,
  285. delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(g in a.geometry.geometryGroups){var b=a.geometry.geometryGroups[g];k.deleteBuffer(b.__webglVertexBuffer);k.deleteBuffer(b.__webglNormalBuffer);k.deleteBuffer(b.__webglTangentBuffer);k.deleteBuffer(b.__webglColorBuffer);k.deleteBuffer(b.__webglUVBuffer);k.deleteBuffer(b.__webglUV2Buffer);k.deleteBuffer(b.__webglSkinVertexABuffer);k.deleteBuffer(b.__webglSkinVertexBBuffer);k.deleteBuffer(b.__webglSkinIndicesBuffer);
  286. k.deleteBuffer(b.__webglSkinWeightsBuffer);k.deleteBuffer(b.__webglFaceBuffer);k.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=0,d=b.numMorphTargets;c<d;c++)k.deleteBuffer(b.__webglMorphTargetsBuffers[c]);R.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,k.deleteBuffer(a.__webglVertexBuffer),k.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,k.deleteBuffer(a.__webglVertexBuffer),k.deleteBuffer(a.__webglColorBuffer),
  287. R.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,k.deleteBuffer(a.__webglVertexBuffer),k.deleteBuffer(a.__webglColorBuffer),R.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,k.deleteTexture(a.__webglTexture),R.info.memory.textures--};this.initMaterial=function(a,b,c,d){var e,f,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof THREE.MeshBasicMaterial?i="basic":
  288. a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(j.uniforms);a.vertexShader=j.vertexShader;a.fragmentShader=j.fragmentShader}var l,o,n;l=n=j=0;for(o=b.length;l<o;l++)h=b[l],h instanceof THREE.SpotLight&&n++,h instanceof THREE.DirectionalLight&&n++,h instanceof THREE.PointLight&&
  289. j++;j+n<=oa?l=n:(l=Math.ceil(oa*n/(j+n)),j=oa-l);h={directional:l,point:j};j=n=0;for(l=b.length;j<l;j++)o=b[j],o instanceof THREE.SpotLight&&o.castShadow&&n++;var r=50;if(d!==void 0&&d instanceof THREE.SkinnedMesh)r=d.bones.length;var p;a:{l=a.fragmentShader;o=a.vertexShader;var j=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,
  290. maxDirLights:h.directional,maxPointLights:h.point,maxBones:r,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel},q,d=[];i?d.push(i):(d.push(l),d.push(o));for(q in c)d.push(q),d.push(c[q]);i=d.join();q=0;for(d=ga.length;q<d;q++)if(ga[q].code===i){p=ga[q].program;break a}q=k.createProgram();d=[Ea?"#define VERTEX_TEXTURES":
  291. "",R.gammaInput?"#define GAMMA_INPUT":"",R.gammaOutput?"#define GAMMA_OUTPUT":"",R.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#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?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":
  292. "",c.perPixel?"#define PHONG_PER_PIXEL":"",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");
  293. h=["#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:"",R.gammaInput?"#define GAMMA_INPUT":"",R.gammaOutput?"#define GAMMA_OUTPUT":"",R.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":
  294. "",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",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(q,U("fragment",h+l));k.attachShader(q,
  295. U("vertex",d+o));k.linkProgram(q);k.getProgramParameter(q,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(q,k.VALIDATE_STATUS)+", gl error ["+k.getError()+"]");q.uniforms={};q.attributes={};var J,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(J in j)d.push(J);J=d;d=0;for(j=J.length;d<j;d++)l=J[d],q.uniforms[l]=k.getUniformLocation(q,
  296. l);d=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(J=0;J<c.maxMorphTargets;J++)d.push("morphTarget"+J);for(p in b)d.push(p);p=d;J=0;for(b=p.length;J<b;J++)c=p[J],q.attributes[c]=k.getAttribLocation(q,c);q.id=ga.length;ga.push({program:q,code:i});R.info.memory.programs=ga.length;p=q}a.program=p;p=a.program.attributes;p.position>=0&&k.enableVertexAttribArray(p.position);p.color>=0&&k.enableVertexAttribArray(p.color);p.normal>=0&&k.enableVertexAttribArray(p.normal);
  297. p.tangent>=0&&k.enableVertexAttribArray(p.tangent);a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(k.enableVertexAttribArray(p.skinVertexA),k.enableVertexAttribArray(p.skinVertexB),k.enableVertexAttribArray(p.skinIndex),k.enableVertexAttribArray(p.skinWeight));if(a.attributes)for(f in a.attributes)p[f]!==void 0&&p[f]>=0&&k.enableVertexAttribArray(p[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f<this.maxMorphTargets;f++)J="morphTarget"+f,p[J]>=0&&(k.enableVertexAttribArray(p[J]),
  298. a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.clearTarget=function(a,b,c,d){F(a);this.clear(b,c,d)};this.updateShadowMap=function(a,b){v(a,b)};this.render=function(a,b,c,d){var J,S,t,I,B,W,Ca,E=a.lights,G=a.fog;D=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&v(a,b);R.info.render.calls=0;R.info.render.vertices=0;R.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
  299. a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(wa);b.projectionMatrix.flattenToArray(ta);ua.multiply(b.projectionMatrix,b.matrixWorldInverse);l(ua);F(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);t=a.__webglObjects.length;for(d=0;d<t;d++)if(B=a.__webglObjects[d],W=B.object,W.visible)if(!(W instanceof THREE.Mesh)||!W.frustumCulled||q(W)){if(W.matrixWorld.flattenToArray(W._objectMatrixArray),
  300. x(W,b,!0),s(B),B.render=!0,this.sortObjects)W.renderDepth?B.z=W.renderDepth:(za.copy(W.position),ua.multiplyVector3(za),B.z=za.z)}else B.render=!1;else B.render=!1;this.sortObjects&&a.__webglObjects.sort(p);I=a.__webglObjectsImmediate.length;for(d=0;d<I;d++)B=a.__webglObjectsImmediate[d],W=B.object,W.visible&&(W.matrixAutoUpdate&&W.matrixWorld.flattenToArray(W._objectMatrixArray),x(W,b,!0),r(B));if(a.overrideMaterial){j(a.overrideMaterial.depthTest);C(a.overrideMaterial.blending);for(d=0;d<t;d++)if(B=
  301. a.__webglObjects[d],B.render)W=B.object,Ca=B.buffer,i(W),e(b,E,G,a.overrideMaterial,Ca,W);for(d=0;d<I;d++)B=a.__webglObjectsImmediate[d],W=B.object,W.visible&&(T=-1,i(W),J=h(b,E,G,a.overrideMaterial,W),W.immediateRenderCallback?W.immediateRenderCallback(J,k,qa):W.render(function(b){f(b,J,a.overrideMaterial.shading)}))}else{C(THREE.NormalBlending);for(d=t-1;d>=0;d--)if(B=a.__webglObjects[d],B.render&&(W=B.object,Ca=B.buffer,S=B.opaque))i(W),j(S.depthTest),n(S.depthWrite),o(S.polygonOffset,S.polygonOffsetFactor,
  302. S.polygonOffsetUnits),e(b,E,G,S,Ca,W);for(d=0;d<I;d++)if(B=a.__webglObjectsImmediate[d],W=B.object,W.visible&&(T=-1,S=B.opaque))i(W),j(S.depthTest),n(S.depthWrite),o(S.polygonOffset,S.polygonOffsetFactor,S.polygonOffsetUnits),J=h(b,E,G,S,W),W.immediateRenderCallback?W.immediateRenderCallback(J,k,qa):W.render(function(a){f(a,J,S.shading)});for(d=0;d<t;d++)if(B=a.__webglObjects[d],B.render&&(W=B.object,Ca=B.buffer,S=B.transparent))i(W),C(S.blending),j(S.depthTest),n(S.depthWrite),o(S.polygonOffset,
  303. S.polygonOffsetFactor,S.polygonOffsetUnits),e(b,E,G,S,Ca,W);for(d=0;d<I;d++)if(B=a.__webglObjectsImmediate[d],W=B.object,W.visible&&(T=-1,S=B.transparent))i(W),C(S.blending),j(S.depthTest),n(S.depthWrite),o(S.polygonOffset,S.polygonOffsetFactor,S.polygonOffsetUnits),J=h(b,E,G,S,W),W.immediateRenderCallback?W.immediateRenderCallback(J,k,qa):W.render(function(a){f(a,J,S.shading)})}a.__webglSprites.length&&w(a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&O(c)};this.initWebGLObjects=
  304. function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[];for(;a.__objectsAdded.length;){var e=a.__objectsAdded[0],f=a,h=void 0,i=void 0,j=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh){i=e.geometry;if(i.geometryGroups===
  305. void 0){var j=i,l=void 0,n=void 0,o=void 0,r=void 0,p=void 0,q=void 0,J=void 0,S={},s=j.morphTargets.length;j.geometryGroups={};l=0;for(n=j.faces.length;l<n;l++)o=j.faces[l],r=o.materialIndex,q=r!==void 0?r:-1,S[q]===void 0&&(S[q]={hash:q,counter:0}),J=S[q].hash+"_"+S[q].counter,j.geometryGroups[J]===void 0&&(j.geometryGroups[J]={faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:s}),p=o instanceof THREE.Face3?3:4,j.geometryGroups[J].vertices+p>65535&&(S[q].counter+=1,J=S[q].hash+"_"+
  306. S[q].counter,j.geometryGroups[J]===void 0&&(j.geometryGroups[J]={faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:s})),o instanceof THREE.Face3?j.geometryGroups[J].faces3.push(l):j.geometryGroups[J].faces4.push(l),j.geometryGroups[J].vertices+=p;j.geometryGroupsList=[];l=void 0;for(l in j.geometryGroups)j.geometryGroups[l].id=$++,j.geometryGroupsList.push(j.geometryGroups[l])}for(h in i.geometryGroups)if(j=i.geometryGroups[h],!j.__webglVertexBuffer){l=j;l.__webglVertexBuffer=k.createBuffer();
  307. l.__webglNormalBuffer=k.createBuffer();l.__webglTangentBuffer=k.createBuffer();l.__webglColorBuffer=k.createBuffer();l.__webglUVBuffer=k.createBuffer();l.__webglUV2Buffer=k.createBuffer();l.__webglSkinVertexABuffer=k.createBuffer();l.__webglSkinVertexBBuffer=k.createBuffer();l.__webglSkinIndicesBuffer=k.createBuffer();l.__webglSkinWeightsBuffer=k.createBuffer();l.__webglFaceBuffer=k.createBuffer();l.__webglLineBuffer=k.createBuffer();if(l.numMorphTargets){o=n=void 0;l.__webglMorphTargetsBuffers=[];
  308. n=0;for(o=l.numMorphTargets;n<o;n++)l.__webglMorphTargetsBuffers.push(k.createBuffer())}R.info.memory.geometries++;r=e;p=r.geometry;n=j.faces3;q=j.faces4;l=n.length*3+q.length*4;o=n.length*1+q.length*2;q=n.length*3+q.length*4;n=b(r,j);J=n.map||n.lightMap||n instanceof THREE.ShaderMaterial?!0:!1;S=n instanceof THREE.MeshBasicMaterial&&!n.envMap||n instanceof THREE.MeshDepthMaterial?!1:n&&n.shading!==void 0&&n.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;s=n.vertexColors?n.vertexColors:
  309. !1;j.__vertexArray=new Float32Array(l*3);if(S)j.__normalArray=new Float32Array(l*3);if(p.hasTangents)j.__tangentArray=new Float32Array(l*4);if(s)j.__colorArray=new Float32Array(l*3);if(J){if(p.faceUvs.length>0||p.faceVertexUvs.length>0)j.__uvArray=new Float32Array(l*2);if(p.faceUvs.length>1||p.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(l*2)}if(r.geometry.skinWeights.length&&r.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(l*4),j.__skinVertexBArray=new Float32Array(l*4),
  310. j.__skinIndexArray=new Float32Array(l*4),j.__skinWeightArray=new Float32Array(l*4);j.__faceArray=new Uint16Array(o*3);j.__lineArray=new Uint16Array(q*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];r=0;for(p=j.numMorphTargets;r<p;r++)j.__morphTargetsArrays.push(new Float32Array(l*3))}j.__needsSmoothNormals=S===THREE.SmoothShading;j.__uvType=J;j.__vertexColorType=s;j.__normalType=S;j.__webglFaceCount=o*3;j.__webglLineCount=q*2;if(n.attributes){if(j.__webglCustomAttributesList===void 0)j.__webglCustomAttributesList=
  311. [];o=void 0;for(o in n.attributes){var r=n.attributes[o],p={},v;for(v in r)p[v]=r[v];if(!p.__webglInitialized||p.createUniqueBuffers)p.__webglInitialized=!0,q=1,p.type==="v2"?q=2:p.type==="v3"?q=3:p.type==="v4"?q=4:p.type==="c"&&(q=3),p.size=q,p.array=new Float32Array(l*q),p.buffer=k.createBuffer(),p.buffer.belongsToAttribute=o,r.needsUpdate=!0,p.__original=r;j.__webglCustomAttributesList.push(p)}}j.__inittedArrays=!0;i.__dirtyVertices=!0;i.__dirtyMorphTargets=!0;i.__dirtyElements=!0;i.__dirtyUvs=
  312. !0;i.__dirtyNormals=!0;i.__dirtyTangents=!0;i.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(i=e.geometry,!i.__webglVertexBuffer)j=i,j.__webglVertexBuffer=k.createBuffer(),j.__webglColorBuffer=k.createBuffer(),R.info.memory.geometries++,j=i,l=j.vertices.length,j.__vertexArray=new Float32Array(l*3),j.__colorArray=new Float32Array(l*3),j.__webglVertexCount=l,i.__dirtyVertices=!0,i.__dirtyColors=!0}else if(e instanceof THREE.Line){if(i=e.geometry,!i.__webglVertexBuffer)j=i,j.__webglVertexBuffer=
  313. k.createBuffer(),j.__webglColorBuffer=k.createBuffer(),R.info.memory.geometries++,j=i,l=e,n=j.vertices.length,j.__vertexArray=new Float32Array(n*3),j.__colorArray=new Float32Array(n*3),j.__webglLineCount=n,c(j,l),i.__dirtyVertices=!0,i.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(i=e.geometry,!i.__webglVertexBuffer))j=i,j.__webglVertexBuffer=k.createBuffer(),j.__webglColorBuffer=k.createBuffer(),R.info.geometries++,j=i,l=e,n=j.vertices.length,j.__vertexArray=new Float32Array(n*3),
  314. j.__colorArray=new Float32Array(n*3),j.__sortArray=[],j.__webglParticleCount=n,c(j,l),i.__dirtyVertices=!0,i.__dirtyColors=!0;if(!e.__webglActive){if(e instanceof THREE.Mesh)for(h in i=e.geometry,i.geometryGroups)j=i.geometryGroups[h],P(f.__webglObjects,j,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(i=e.geometry,P(f.__webglObjects,i,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes||e.immediateRenderCallback?f.__webglObjectsImmediate.push({object:e,
  315. opaque:null,transparent:null}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);e.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){e=a.__objectsRemoved[0];f=a;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)G(f.__webglObjects,e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;for(i=f.length-1;i>=0;i--)f[i]===h&&f.splice(i,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&
  316. G(f.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(f=a.__webglObjects.length;e<f;e++)if(v=a.__webglObjects[e].object,h=v.geometry,i=o=n=void 0,v instanceof THREE.Mesh){j=0;for(l=h.geometryGroupsList.length;j<l;j++)if(n=h.geometryGroupsList[j],i=b(v,n),o=i.attributes&&t(i),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||o)if(o=k.DYNAMIC_DRAW,r=!h.dynamic,n.__inittedArrays){var w=q=
  317. p=void 0,I=void 0,x=void 0,W=void 0,E=void 0,D=void 0,F=void 0,na=void 0,C=w=W=F=void 0,z=void 0,K=void 0,y=void 0,H=void 0,L=void 0,N=I=void 0,ha=I=F=void 0,aa=void 0,Q=I=y=K=z=H=y=K=z=H=y=K=z=H=y=K=z=E=void 0,Y=void 0,U=W=void 0,O=w=void 0,fa=void 0,ma=void 0,V=C=O=Y=0,Z=0,T=Q=w=0,oa=E=L=0,A=0,M=0,ba=void 0,fa=n.__vertexArray,ca=n.__uvArray,A=n.__uv2Array,U=n.__normalArray,x=n.__tangentArray,N=n.__colorArray,ha=n.__skinVertexAArray,aa=n.__skinVertexBArray,D=n.__skinIndexArray,X=n.__skinWeightArray,
  318. da=n.__morphTargetsArrays,J=n.__webglCustomAttributesList,u=void 0,u=n.__faceArray,M=n.__lineArray,ia=n.__needsSmoothNormals,F=n.__vertexColorType,na=n.__uvType,W=n.__normalType,la=v.geometry,ba=la.__dirtyElements,ga=la.__dirtyUvs,ea=la.__dirtyNormals,ja=la.__dirtyTangents,pa=la.__dirtyColors,ma=la.__dirtyMorphTargets,xa=la.vertices,S=n.faces3,s=n.faces4,ka=la.faces,Aa=la.faceVertexUvs[0],qa=la.faceVertexUvs[1],ua=la.skinVerticesA,ya=la.skinVerticesB,wa=la.skinIndices,ra=la.skinWeights,ta=la.morphTargets;
  319. if(la.__dirtyVertices){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],z=xa[I.a].position,K=xa[I.b].position,y=xa[I.c].position,fa[O]=z.x,fa[O+1]=z.y,fa[O+2]=z.z,fa[O+3]=K.x,fa[O+4]=K.y,fa[O+5]=K.z,fa[O+6]=y.x,fa[O+7]=y.y,fa[O+8]=y.z,O+=9;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],z=xa[I.a].position,K=xa[I.b].position,y=xa[I.c].position,H=xa[I.d].position,fa[O]=z.x,fa[O+1]=z.y,fa[O+2]=z.z,fa[O+3]=K.x,fa[O+4]=K.y,fa[O+5]=K.z,fa[O+6]=y.x,fa[O+7]=y.y,fa[O+8]=y.z,fa[O+9]=H.x,fa[O+10]=H.y,fa[O+11]=H.z,O+=12;k.bindBuffer(k.ARRAY_BUFFER,
  320. n.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,fa,o)}if(ma){p=0;for(q=S.length;p<q;p++){I=ka[S[p]];O=0;for(fa=ta.length;O<fa;O++)z=ta[O].vertices[I.a].position,K=ta[O].vertices[I.b].position,y=ta[O].vertices[I.c].position,ma=da[O],ma[oa]=z.x,ma[oa+1]=z.y,ma[oa+2]=z.z,ma[oa+3]=K.x,ma[oa+4]=K.y,ma[oa+5]=K.z,ma[oa+6]=y.x,ma[oa+7]=y.y,ma[oa+8]=y.z;oa+=9}p=0;for(q=s.length;p<q;p++){I=ka[s[p]];O=0;for(fa=ta.length;O<fa;O++)z=ta[O].vertices[I.a].position,K=ta[O].vertices[I.b].position,y=ta[O].vertices[I.c].position,
  321. H=ta[O].vertices[I.d].position,ma=da[O],ma[oa]=z.x,ma[oa+1]=z.y,ma[oa+2]=z.z,ma[oa+3]=K.x,ma[oa+4]=K.y,ma[oa+5]=K.z,ma[oa+6]=y.x,ma[oa+7]=y.y,ma[oa+8]=y.z,ma[oa+9]=H.x,ma[oa+10]=H.y,ma[oa+11]=H.z;oa+=12}O=0;for(fa=ta.length;O<fa;O++)k.bindBuffer(k.ARRAY_BUFFER,n.__webglMorphTargetsBuffers[O]),k.bufferData(k.ARRAY_BUFFER,da[O],o)}if(ra.length){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],z=ra[I.a],K=ra[I.b],y=ra[I.c],X[E]=z.x,X[E+1]=z.y,X[E+2]=z.z,X[E+3]=z.w,X[E+4]=K.x,X[E+5]=K.y,X[E+6]=K.z,X[E+7]=K.w,X[E+
  322. 8]=y.x,X[E+9]=y.y,X[E+10]=y.z,X[E+11]=y.w,z=wa[I.a],K=wa[I.b],y=wa[I.c],D[E]=z.x,D[E+1]=z.y,D[E+2]=z.z,D[E+3]=z.w,D[E+4]=K.x,D[E+5]=K.y,D[E+6]=K.z,D[E+7]=K.w,D[E+8]=y.x,D[E+9]=y.y,D[E+10]=y.z,D[E+11]=y.w,z=ua[I.a],K=ua[I.b],y=ua[I.c],ha[E]=z.x,ha[E+1]=z.y,ha[E+2]=z.z,ha[E+3]=1,ha[E+4]=K.x,ha[E+5]=K.y,ha[E+6]=K.z,ha[E+7]=1,ha[E+8]=y.x,ha[E+9]=y.y,ha[E+10]=y.z,ha[E+11]=1,z=ya[I.a],K=ya[I.b],y=ya[I.c],aa[E]=z.x,aa[E+1]=z.y,aa[E+2]=z.z,aa[E+3]=1,aa[E+4]=K.x,aa[E+5]=K.y,aa[E+6]=K.z,aa[E+7]=1,aa[E+8]=y.x,
  323. aa[E+9]=y.y,aa[E+10]=y.z,aa[E+11]=1,E+=12;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],z=ra[I.a],K=ra[I.b],y=ra[I.c],H=ra[I.d],X[E]=z.x,X[E+1]=z.y,X[E+2]=z.z,X[E+3]=z.w,X[E+4]=K.x,X[E+5]=K.y,X[E+6]=K.z,X[E+7]=K.w,X[E+8]=y.x,X[E+9]=y.y,X[E+10]=y.z,X[E+11]=y.w,X[E+12]=H.x,X[E+13]=H.y,X[E+14]=H.z,X[E+15]=H.w,z=wa[I.a],K=wa[I.b],y=wa[I.c],H=wa[I.d],D[E]=z.x,D[E+1]=z.y,D[E+2]=z.z,D[E+3]=z.w,D[E+4]=K.x,D[E+5]=K.y,D[E+6]=K.z,D[E+7]=K.w,D[E+8]=y.x,D[E+9]=y.y,D[E+10]=y.z,D[E+11]=y.w,D[E+12]=H.x,D[E+13]=H.y,D[E+14]=
  324. H.z,D[E+15]=H.w,z=ua[I.a],K=ua[I.b],y=ua[I.c],H=ua[I.d],ha[E]=z.x,ha[E+1]=z.y,ha[E+2]=z.z,ha[E+3]=1,ha[E+4]=K.x,ha[E+5]=K.y,ha[E+6]=K.z,ha[E+7]=1,ha[E+8]=y.x,ha[E+9]=y.y,ha[E+10]=y.z,ha[E+11]=1,ha[E+12]=H.x,ha[E+13]=H.y,ha[E+14]=H.z,ha[E+15]=1,z=ya[I.a],K=ya[I.b],y=ya[I.c],I=ya[I.d],aa[E]=z.x,aa[E+1]=z.y,aa[E+2]=z.z,aa[E+3]=1,aa[E+4]=K.x,aa[E+5]=K.y,aa[E+6]=K.z,aa[E+7]=1,aa[E+8]=y.x,aa[E+9]=y.y,aa[E+10]=y.z,aa[E+11]=1,aa[E+12]=I.x,aa[E+13]=I.y,aa[E+14]=I.z,aa[E+15]=1,E+=16;E>0&&(k.bindBuffer(k.ARRAY_BUFFER,
  325. n.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,ha,o),k.bindBuffer(k.ARRAY_BUFFER,n.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,aa,o),k.bindBuffer(k.ARRAY_BUFFER,n.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,D,o),k.bindBuffer(k.ARRAY_BUFFER,n.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,X,o))}if(pa&&F){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],E=I.vertexColors,D=I.color,E.length===3&&F===THREE.VertexColors?(I=E[0],ha=E[1],aa=E[2]):aa=ha=I=D,N[L]=I.r,N[L+1]=I.g,N[L+
  326. 2]=I.b,N[L+3]=ha.r,N[L+4]=ha.g,N[L+5]=ha.b,N[L+6]=aa.r,N[L+7]=aa.g,N[L+8]=aa.b,L+=9;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],E=I.vertexColors,D=I.color,E.length===4&&F===THREE.VertexColors?(I=E[0],ha=E[1],aa=E[2],E=E[3]):E=aa=ha=I=D,N[L]=I.r,N[L+1]=I.g,N[L+2]=I.b,N[L+3]=ha.r,N[L+4]=ha.g,N[L+5]=ha.b,N[L+6]=aa.r,N[L+7]=aa.g,N[L+8]=aa.b,N[L+9]=E.r,N[L+10]=E.g,N[L+11]=E.b,L+=12;L>0&&(k.bindBuffer(k.ARRAY_BUFFER,n.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,N,o))}if(ja&&la.hasTangents){p=0;for(q=S.length;p<
  327. q;p++)I=ka[S[p]],F=I.vertexTangents,L=F[0],I=F[1],N=F[2],x[Q]=L.x,x[Q+1]=L.y,x[Q+2]=L.z,x[Q+3]=L.w,x[Q+4]=I.x,x[Q+5]=I.y,x[Q+6]=I.z,x[Q+7]=I.w,x[Q+8]=N.x,x[Q+9]=N.y,x[Q+10]=N.z,x[Q+11]=N.w,Q+=12;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],F=I.vertexTangents,L=F[0],I=F[1],N=F[2],F=F[3],x[Q]=L.x,x[Q+1]=L.y,x[Q+2]=L.z,x[Q+3]=L.w,x[Q+4]=I.x,x[Q+5]=I.y,x[Q+6]=I.z,x[Q+7]=I.w,x[Q+8]=N.x,x[Q+9]=N.y,x[Q+10]=N.z,x[Q+11]=N.w,x[Q+12]=F.x,x[Q+13]=F.y,x[Q+14]=F.z,x[Q+15]=F.w,Q+=16;k.bindBuffer(k.ARRAY_BUFFER,n.__webglTangentBuffer);
  328. k.bufferData(k.ARRAY_BUFFER,x,o)}if(ea&&W){p=0;for(q=S.length;p<q;p++)if(I=ka[S[p]],x=I.vertexNormals,W=I.normal,x.length===3&&ia)for(Q=0;Q<3;Q++)W=x[Q],U[w]=W.x,U[w+1]=W.y,U[w+2]=W.z,w+=3;else for(Q=0;Q<3;Q++)U[w]=W.x,U[w+1]=W.y,U[w+2]=W.z,w+=3;p=0;for(q=s.length;p<q;p++)if(I=ka[s[p]],x=I.vertexNormals,W=I.normal,x.length===4&&ia)for(Q=0;Q<4;Q++)W=x[Q],U[w]=W.x,U[w+1]=W.y,U[w+2]=W.z,w+=3;else for(Q=0;Q<4;Q++)U[w]=W.x,U[w+1]=W.y,U[w+2]=W.z,w+=3;k.bindBuffer(k.ARRAY_BUFFER,n.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,
  329. U,o)}if(ga&&Aa&&na){p=0;for(q=S.length;p<q;p++)if(w=S[p],w=Aa[w],w!==void 0)for(Q=0;Q<3;Q++)U=w[Q],ca[C]=U.u,ca[C+1]=U.v,C+=2;p=0;for(q=s.length;p<q;p++)if(w=s[p],w=Aa[w],w!==void 0)for(Q=0;Q<4;Q++)U=w[Q],ca[C]=U.u,ca[C+1]=U.v,C+=2;C>0&&(k.bindBuffer(k.ARRAY_BUFFER,n.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,ca,o))}if(ga&&qa&&na){p=0;for(q=S.length;p<q;p++)if(w=S[p],C=qa[w],C!==void 0)for(Q=0;Q<3;Q++)w=C[Q],A[V]=w.u,A[V+1]=w.v,V+=2;p=0;for(q=s.length;p<q;p++)if(w=s[p],C=qa[w],C!==void 0)for(Q=
  330. 0;Q<4;Q++)w=C[Q],A[V]=w.u,A[V+1]=w.v,V+=2;V>0&&(k.bindBuffer(k.ARRAY_BUFFER,n.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,A,o))}if(ba){p=0;for(q=S.length;p<q;p++)u[Z]=Y,u[Z+1]=Y+1,u[Z+2]=Y+2,Z+=3,M[T]=Y,M[T+1]=Y+1,M[T+2]=Y,M[T+3]=Y+2,M[T+4]=Y+1,M[T+5]=Y+2,T+=6,Y+=3;p=0;for(q=s.length;p<q;p++)u[Z]=Y,u[Z+1]=Y+1,u[Z+2]=Y+3,u[Z+3]=Y+1,u[Z+4]=Y+2,u[Z+5]=Y+3,Z+=6,M[T]=Y,M[T+1]=Y+1,M[T+2]=Y,M[T+3]=Y+3,M[T+4]=Y+1,M[T+5]=Y+2,M[T+6]=Y+2,M[T+7]=Y+3,T+=8,Y+=4;k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer);
  331. k.bufferData(k.ELEMENT_ARRAY_BUFFER,u,o);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,M,o)}if(J){Q=0;for(Y=J.length;Q<Y;Q++)if(u=J[Q],u.__original.needsUpdate){M=A=0;if(u.size===1)if(u.boundTo===void 0||u.boundTo==="vertices"){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],u.array[A]=u.value[I.a],u.array[A+1]=u.value[I.b],u.array[A+2]=u.value[I.c],A+=3;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],u.array[A]=u.value[I.a],u.array[A+1]=u.value[I.b],u.array[A+2]=u.value[I.c],
  332. u.array[A+3]=u.value[I.d],A+=4}else if(u.boundTo==="faces"){p=0;for(q=S.length;p<q;p++)ba=u.value[M],u.array[A]=ba,u.array[A+1]=ba,u.array[A+2]=ba,A+=3,M+=1;p=0;for(q=s.length;p<q;p++)ba=u.value[M],u.array[A]=ba,u.array[A+1]=ba,u.array[A+2]=ba,u.array[A+3]=ba,A+=4,M+=1}else{if(u.boundTo==="faceVertices"){p=0;for(q=S.length;p<q;p++)u.array[A]=u.value[M],u.array[A+1]=u.value[M+1],u.array[A+2]=u.value[M+2],A+=3,M+=3;p=0;for(q=s.length;p<q;p++)u.array[A]=u.value[M],u.array[A+1]=u.value[M+1],u.array[A+
  333. 2]=u.value[M+2],u.array[A+3]=u.value[M+3],A+=4,M+=4}}else if(u.size===2)if(u.boundTo===void 0||u.boundTo==="vertices"){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],z=u.value[I.a],K=u.value[I.b],y=u.value[I.c],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=K.x,u.array[A+3]=K.y,u.array[A+4]=y.x,u.array[A+5]=y.y,A+=6;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],z=u.value[I.a],K=u.value[I.b],y=u.value[I.c],H=u.value[I.d],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=K.x,u.array[A+3]=K.y,u.array[A+4]=y.x,u.array[A+5]=
  334. y.y,u.array[A+6]=H.x,u.array[A+7]=H.y,A+=8}else if(u.boundTo==="faces"){p=0;for(q=S.length;p<q;p++)y=K=z=ba=u.value[M],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=K.x,u.array[A+3]=K.y,u.array[A+4]=y.x,u.array[A+5]=y.y,A+=6,M+=1;p=0;for(q=s.length;p<q;p++)H=y=K=z=ba=u.value[M],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=K.x,u.array[A+3]=K.y,u.array[A+4]=y.x,u.array[A+5]=y.y,u.array[A+6]=H.x,u.array[A+7]=H.y,A+=8,M+=1}else{if(u.boundTo==="faceVertices"){p=0;for(q=S.length;p<q;p++)z=u.value[M],K=u.value[M+
  335. 1],y=u.value[M+2],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=K.x,u.array[A+3]=K.y,u.array[A+4]=y.x,u.array[A+5]=y.y,A+=6,M+=3;p=0;for(q=s.length;p<q;p++)z=u.value[M],K=u.value[M+1],y=u.value[M+2],H=u.value[M+3],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=K.x,u.array[A+3]=K.y,u.array[A+4]=y.x,u.array[A+5]=y.y,u.array[A+6]=H.x,u.array[A+7]=H.y,A+=8,M+=4}}else if(u.size===3)if(V=u.type==="c"?["r","g","b"]:["x","y","z"],u.boundTo===void 0||u.boundTo==="vertices"){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],
  336. z=u.value[I.a],K=u.value[I.b],y=u.value[I.c],u.array[A]=z[V[0]],u.array[A+1]=z[V[1]],u.array[A+2]=z[V[2]],u.array[A+3]=K[V[0]],u.array[A+4]=K[V[1]],u.array[A+5]=K[V[2]],u.array[A+6]=y[V[0]],u.array[A+7]=y[V[1]],u.array[A+8]=y[V[2]],A+=9;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],z=u.value[I.a],K=u.value[I.b],y=u.value[I.c],H=u.value[I.d],u.array[A]=z[V[0]],u.array[A+1]=z[V[1]],u.array[A+2]=z[V[2]],u.array[A+3]=K[V[0]],u.array[A+4]=K[V[1]],u.array[A+5]=K[V[2]],u.array[A+6]=y[V[0]],u.array[A+7]=y[V[1]],
  337. u.array[A+8]=y[V[2]],u.array[A+9]=H[V[0]],u.array[A+10]=H[V[1]],u.array[A+11]=H[V[2]],A+=12,M+=1}else if(u.boundTo==="faces"){p=0;for(q=S.length;p<q;p++)y=K=z=ba=u.value[M],u.array[A]=z[V[0]],u.array[A+1]=z[V[1]],u.array[A+2]=z[V[2]],u.array[A+3]=K[V[0]],u.array[A+4]=K[V[1]],u.array[A+5]=K[V[2]],u.array[A+6]=y[V[0]],u.array[A+7]=y[V[1]],u.array[A+8]=y[V[2]],A+=9,M+=1;p=0;for(q=s.length;p<q;p++)H=y=K=z=ba=u.value[M],u.array[A]=z[V[0]],u.array[A+1]=z[V[1]],u.array[A+2]=z[V[2]],u.array[A+3]=K[V[0]],
  338. u.array[A+4]=K[V[1]],u.array[A+5]=K[V[2]],u.array[A+6]=y[V[0]],u.array[A+7]=y[V[1]],u.array[A+8]=y[V[2]],u.array[A+9]=H[V[0]],u.array[A+10]=H[V[1]],u.array[A+11]=H[V[2]],A+=12,M+=1}else{if(u.boundTo==="faceVertices"){p=0;for(q=S.length;p<q;p++)z=u.value[M],K=u.value[M+1],y=u.value[M+2],u.array[A]=z[V[0]],u.array[A+1]=z[V[1]],u.array[A+2]=z[V[2]],u.array[A+3]=K[V[0]],u.array[A+4]=K[V[1]],u.array[A+5]=K[V[2]],u.array[A+6]=y[V[0]],u.array[A+7]=y[V[1]],u.array[A+8]=y[V[2]],A+=9,M+=3;p=0;for(q=s.length;p<
  339. q;p++)z=u.value[M],K=u.value[M+1],y=u.value[M+2],H=u.value[M+3],u.array[A]=z[V[0]],u.array[A+1]=z[V[1]],u.array[A+2]=z[V[2]],u.array[A+3]=K[V[0]],u.array[A+4]=K[V[1]],u.array[A+5]=K[V[2]],u.array[A+6]=y[V[0]],u.array[A+7]=y[V[1]],u.array[A+8]=y[V[2]],u.array[A+9]=H[V[0]],u.array[A+10]=H[V[1]],u.array[A+11]=H[V[2]],A+=12,M+=4}}else if(u.size===4)if(u.boundTo===void 0||u.boundTo==="vertices"){p=0;for(q=S.length;p<q;p++)I=ka[S[p]],z=u.value[I.a],K=u.value[I.b],y=u.value[I.c],u.array[A]=z.x,u.array[A+
  340. 1]=z.y,u.array[A+2]=z.z,u.array[A+3]=z.w,u.array[A+4]=K.x,u.array[A+5]=K.y,u.array[A+6]=K.z,u.array[A+7]=K.w,u.array[A+8]=y.x,u.array[A+9]=y.y,u.array[A+10]=y.z,u.array[A+11]=y.w,A+=12;p=0;for(q=s.length;p<q;p++)I=ka[s[p]],z=u.value[I.a],K=u.value[I.b],y=u.value[I.c],H=u.value[I.d],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=z.z,u.array[A+3]=z.w,u.array[A+4]=K.x,u.array[A+5]=K.y,u.array[A+6]=K.z,u.array[A+7]=K.w,u.array[A+8]=y.x,u.array[A+9]=y.y,u.array[A+10]=y.z,u.array[A+11]=y.w,u.array[A+12]=
  341. H.x,u.array[A+13]=H.y,u.array[A+14]=H.z,u.array[A+15]=H.w,A+=16}else if(u.boundTo==="faces"){p=0;for(q=S.length;p<q;p++)y=K=z=ba=u.value[M],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=z.z,u.array[A+3]=z.w,u.array[A+4]=K.x,u.array[A+5]=K.y,u.array[A+6]=K.z,u.array[A+7]=K.w,u.array[A+8]=y.x,u.array[A+9]=y.y,u.array[A+10]=y.z,u.array[A+11]=y.w,A+=12,M+=1;p=0;for(q=s.length;p<q;p++)H=y=K=z=ba=u.value[M],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=z.z,u.array[A+3]=z.w,u.array[A+4]=K.x,u.array[A+5]=K.y,
  342. u.array[A+6]=K.z,u.array[A+7]=K.w,u.array[A+8]=y.x,u.array[A+9]=y.y,u.array[A+10]=y.z,u.array[A+11]=y.w,u.array[A+12]=H.x,u.array[A+13]=H.y,u.array[A+14]=H.z,u.array[A+15]=H.w,A+=16,M+=1}else if(u.boundTo==="faceVertices"){p=0;for(q=S.length;p<q;p++)z=u.value[M],K=u.value[M+1],y=u.value[M+2],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=z.z,u.array[A+3]=z.w,u.array[A+4]=K.x,u.array[A+5]=K.y,u.array[A+6]=K.z,u.array[A+7]=K.w,u.array[A+8]=y.x,u.array[A+9]=y.y,u.array[A+10]=y.z,u.array[A+11]=y.w,A+=12,
  343. M+=3;p=0;for(q=s.length;p<q;p++)z=u.value[M],K=u.value[M+1],y=u.value[M+2],H=u.value[M+3],u.array[A]=z.x,u.array[A+1]=z.y,u.array[A+2]=z.z,u.array[A+3]=z.w,u.array[A+4]=K.x,u.array[A+5]=K.y,u.array[A+6]=K.z,u.array[A+7]=K.w,u.array[A+8]=y.x,u.array[A+9]=y.y,u.array[A+10]=y.z,u.array[A+11]=y.w,u.array[A+12]=H.x,u.array[A+13]=H.y,u.array[A+14]=H.z,u.array[A+15]=H.w,A+=16,M+=4}k.bindBuffer(k.ARRAY_BUFFER,u.buffer);k.bufferData(k.ARRAY_BUFFER,u.array,o)}}r&&(delete n.__inittedArrays,delete n.__colorArray,
  344. delete n.__normalArray,delete n.__tangentArray,delete n.__uvArray,delete n.__uv2Array,delete n.__faceArray,delete n.__vertexArray,delete n.__lineArray,delete n.__skinVertexAArray,delete n.__skinVertexBArray,delete n.__skinIndexArray,delete n.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyColors=!1;h.__dirtyTangents=!1;i.attributes&&B(i)}else if(v instanceof THREE.Ribbon){if(h.__dirtyVertices||h.__dirtyColors){i=h;
  345. v=k.DYNAMIC_DRAW;p=j=p=r=r=void 0;q=i.vertices;l=i.colors;J=q.length;n=l.length;S=i.__vertexArray;o=i.__colorArray;s=i.__dirtyColors;if(i.__dirtyVertices){for(r=0;r<J;r++)p=q[r].position,j=r*3,S[j]=p.x,S[j+1]=p.y,S[j+2]=p.z;k.bindBuffer(k.ARRAY_BUFFER,i.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,S,v)}if(s){for(r=0;r<n;r++)p=l[r],j=r*3,o[j]=p.r,o[j+1]=p.g,o[j+2]=p.b;k.bindBuffer(k.ARRAY_BUFFER,i.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,o,v)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(v instanceof
  346. THREE.Line){i=b(v,n);o=i.attributes&&t(i);if(h.__dirtyVertices||h.__dirtyColors||o){v=h;j=k.DYNAMIC_DRAW;J=l=Y=q=ka=void 0;q=v.vertices;n=v.colors;J=q.length;o=n.length;S=v.__vertexArray;r=v.__colorArray;s=v.__dirtyColors;p=v.__webglCustomAttributesList;C=T=Z=V=Y=ka=void 0;if(v.__dirtyVertices){for(ka=0;ka<J;ka++)Y=q[ka].position,l=ka*3,S[l]=Y.x,S[l+1]=Y.y,S[l+2]=Y.z;k.bindBuffer(k.ARRAY_BUFFER,v.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,S,j)}if(s){for(q=0;q<o;q++)J=n[q],l=q*3,r[l]=J.r,r[l+
  347. 1]=J.g,r[l+2]=J.b;k.bindBuffer(k.ARRAY_BUFFER,v.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,r,j)}if(p){ka=0;for(Y=p.length;ka<Y;ka++)if(C=p[ka],C.needsUpdate&&(C.boundTo===void 0||C.boundTo==="vertices")){l=0;Z=C.value.length;if(C.size===1)for(V=0;V<Z;V++)C.array[V]=C.value[V];else if(C.size===2)for(V=0;V<Z;V++)T=C.value[V],C.array[l]=T.x,C.array[l+1]=T.y,l+=2;else if(C.size===3)if(C.type==="c")for(V=0;V<Z;V++)T=C.value[V],C.array[l]=T.r,C.array[l+1]=T.g,C.array[l+2]=T.b,l+=3;else for(V=0;V<Z;V++)T=
  348. C.value[V],C.array[l]=T.x,C.array[l+1]=T.y,C.array[l+2]=T.z,l+=3;else if(C.size===4)for(V=0;V<Z;V++)T=C.value[V],C.array[l]=T.x,C.array[l+1]=T.y,C.array[l+2]=T.z,C.array[l+3]=T.w,l+=4;k.bindBuffer(k.ARRAY_BUFFER,C.buffer);k.bufferData(k.ARRAY_BUFFER,C.array,j)}}}h.__dirtyVertices=!1;h.__dirtyColors=!1;i.attributes&&B(i)}else if(v instanceof THREE.ParticleSystem)i=b(v,n),o=i.attributes&&t(i),(h.__dirtyVertices||h.__dirtyColors||v.sortParticles||o)&&d(h,k.DYNAMIC_DRAW,v),h.__dirtyVertices=!1,h.__dirtyColors=
  349. !1,i.attributes&&B(i)};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW),a==="back"?k.cullFace(k.BACK):a==="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK),k.enable(k.CULL_FACE)):k.disable(k.CULL_FACE)};this.supportsVertexTextures=function(){return Ea}};
  350. THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type:
  351. THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0};
  352. THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,c,b){THREE.WebGLRenderTarget.call(this,a,c,b);this.activeCubeFace=0};
  353. THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
  354. 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.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};
  355. 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.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
  356. THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
  357. THREE.ColorUtils={adjustHSV:function(a,c,b,d){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,h);h.h=THREE.Math.clamp(h.h+c,0,1);h.s=THREE.Math.clamp(h.s+b,0,1);h.v=THREE.Math.clamp(h.v+d,0,1);a.setHSV(h.h,h.s,h.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,h=a.b,e=Math.max(Math.max(b,d),h),f=Math.min(Math.min(b,d),h);if(f===e)f=b=0;else{var i=e-f,f=i/e,b=b===e?(d-h)/i:d===e?2+(h-b)/i:4+(b-d)/i;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=f;c.v=e;return c}};
  358. THREE.ColorUtils.__hsv={h:0,s:0,v:0};
  359. THREE.GeometryUtils={merge:function(a,c){for(var b,d,h=a.vertices.length,e=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,i=e.vertices,j=a.faces,n=e.faces,o=a.faceVertexUvs[0],l=e.faceVertexUvs[0],q={},r=0;r<a.materials.length;r++)q[a.materials[r].id]=r;if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),b=c.matrix,d=new THREE.Matrix4,d.extractRotation(b,c.scale);for(var r=0,s=i.length;r<s;r++){var p=new THREE.Vertex(i[r].position.clone());b&&b.multiplyVector3(p.position);f.push(p)}r=
  360. 0;for(s=n.length;r<s;r++){var f=n[r],v,w,x=f.vertexNormals,t=f.vertexColors;f instanceof THREE.Face3?v=new THREE.Face3(f.a+h,f.b+h,f.c+h):f instanceof THREE.Face4&&(v=new THREE.Face4(f.a+h,f.b+h,f.c+h,f.d+h));v.normal.copy(f.normal);d&&d.multiplyVector3(v.normal);i=0;for(p=x.length;i<p;i++)w=x[i].clone(),d&&d.multiplyVector3(w),v.vertexNormals.push(w);v.color.copy(f.color);i=0;for(p=t.length;i<p;i++)w=t[i],v.vertexColors.push(w.clone());if(f.materialIndex!==void 0){i=e.materials[f.materialIndex];
  361. p=q[i.id];if(p===void 0)p=a.materials.length,a.materials.push(i);v.materialIndex=p}v.centroid.copy(f.centroid);b&&b.multiplyVector3(v.centroid);j.push(v)}r=0;for(s=l.length;r<s;r++){b=l[r];d=[];i=0;for(p=b.length;i<p;i++)d.push(new THREE.UV(b[i].u,b[i].v));o.push(d)}},clone:function(a){var c=new THREE.Geometry,b,d=a.vertices,h=a.faces,e=a.faceVertexUvs[0];if(a.materials)c.materials=a.materials.slice();a=0;for(b=d.length;a<b;a++){var f=new THREE.Vertex(d[a].position.clone());c.vertices.push(f)}a=0;
  362. for(b=h.length;a<b;a++){var i=h[a],j,n,o=i.vertexNormals,l=i.vertexColors;i instanceof THREE.Face3?j=new THREE.Face3(i.a,i.b,i.c):i instanceof THREE.Face4&&(j=new THREE.Face4(i.a,i.b,i.c,i.d));j.normal.copy(i.normal);d=0;for(f=o.length;d<f;d++)n=o[d],j.vertexNormals.push(n.clone());j.color.copy(i.color);d=0;for(f=l.length;d<f;d++)n=l[d],j.vertexColors.push(n.clone());j.materialIndex=i.materialIndex;j.centroid.copy(i.centroid);c.faces.push(j)}a=0;for(b=e.length;a<b;a++){h=e[a];j=[];d=0;for(f=h.length;d<
  363. f;d++)j.push(new THREE.UV(h[d].u,h[d].v));c.faceVertexUvs[0].push(j)}return c},randomPointInTriangle:function(a,c,b){var d,h,e,f=new THREE.Vector3,i=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();h=THREE.GeometryUtils.random();d+h>1&&(d=1-d,h=1-h);e=1-d-h;f.copy(a);f.multiplyScalar(d);i.copy(c);i.multiplyScalar(h);f.addSelf(i);i.copy(b);i.multiplyScalar(e);f.addSelf(i);return f},randomPointInFace:function(a,c,b){var d,h,e;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,h=c.vertices[a.b].position,
  364. e=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,h,e);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;h=c.vertices[a.b].position;e=c.vertices[a.c].position;var c=c.vertices[a.d].position,f;b?a._area1&&a._area2?(b=a._area1,f=a._area2):(b=THREE.GeometryUtils.triangleArea(d,h,c),f=THREE.GeometryUtils.triangleArea(h,e,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(d,h,c),f=THREE.GeometryUtils.triangleArea(h,e,c));return THREE.GeometryUtils.random()*(b+
  365. f)<b?THREE.GeometryUtils.randomPointInTriangle(d,h,c):THREE.GeometryUtils.randomPointInTriangle(h,e,c)}},randomPointsInGeometry:function(a,c){function b(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return n[e]>a?b(c,e-1):n[e]<a?b(e+1,d):e}return b(0,n.length-1)}var d,h,e=a.faces,f=a.vertices,i=e.length,j=0,n=[],o,l,q,r;for(h=0;h<i;h++){d=e[h];if(d instanceof THREE.Face3)o=f[d.a].position,l=f[d.b].position,q=f[d.c].position,d._area=THREE.GeometryUtils.triangleArea(o,l,q);else if(d instanceof
  366. THREE.Face4)o=f[d.a].position,l=f[d.b].position,q=f[d.c].position,r=f[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(o,l,r),d._area2=THREE.GeometryUtils.triangleArea(l,q,r),d._area=d._area1+d._area2;j+=d._area;n[h]=j}d=[];f={};for(h=0;h<c;h++)i=THREE.GeometryUtils.random()*j,i=b(i),d[h]=THREE.GeometryUtils.randomPointInFace(e[i],a,!0),f[i]?f[i]+=1:f[i]=1;return d},triangleArea:function(a,c,b){var d,h=THREE.GeometryUtils.__v1;h.sub(a,c);d=h.length();h.sub(a,b);a=h.length();h.sub(c,b);b=h.length();
  367. c=0.5*(d+a+b);return Math.sqrt(c*(c-d)*(c-a)*(c-b))},center:function(a){a.computeBoundingBox();var c=new THREE.Matrix4;c.setTranslation(-0.5*(a.boundingBox.x[1]+a.boundingBox.x[0]),-0.5*(a.boundingBox.y[1]+a.boundingBox.y[0]),-0.5*(a.boundingBox.z[1]+a.boundingBox.z[0]));a.applyMatrix(c);a.computeBoundingBox()}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
  368. THREE.ImageUtils={loadTexture:function(a,c,b){var d=new Image,h=new THREE.Texture(d,c);d.onload=function(){h.needsUpdate=!0;b&&b(this)};d.crossOrigin="";d.src=a;return h},loadTextureCube:function(a,c,b){var d,h=[],e=new THREE.Texture(h,c),c=h.loadCount=0;for(d=a.length;c<d;++c)h[c]=new Image,h[c].onload=function(){h.loadCount+=1;if(h.loadCount===6)e.needsUpdate=!0;b&&b(this)},h[c].crossOrigin="",h[c].src=a[c];return e},getNormalMap:function(a,c){var b=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+
  369. a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};c|=1;var d=a.width,h=a.height,e=document.createElement("canvas");e.width=d;e.height=h;var f=e.getContext("2d");f.drawImage(a,0,0);for(var i=f.getImageData(0,0,d,h).data,j=f.createImageData(d,h),n=j.data,o=0;o<d;o++)for(var l=1;l<h;l++){var q=l-1<0?h-1:l-1,r=(l+1)%h,s=o-1<0?d-1:o-1,p=(o+1)%d,v=[],w=[0,0,i[(l*d+o)*4]/255*c];v.push([-1,0,i[(l*d+s)*4]/255*c]);v.push([-1,-1,i[(q*d+s)*4]/255*c]);v.push([0,-1,i[(q*d+o)*4]/255*c]);v.push([1,-1,i[(q*d+p)*4]/255*c]);
  370. v.push([1,0,i[(l*d+p)*4]/255*c]);v.push([1,1,i[(r*d+p)*4]/255*c]);v.push([0,1,i[(r*d+o)*4]/255*c]);v.push([-1,1,i[(r*d+s)*4]/255*c]);q=[];s=v.length;for(r=0;r<s;r++){var p=v[r],x=v[(r+1)%s],p=[p[0]-w[0],p[1]-w[1],p[2]-w[2]],x=[x[0]-w[0],x[1]-w[1],x[2]-w[2]];q.push(b([p[1]*x[2]-p[2]*x[1],p[2]*x[0]-p[0]*x[2],p[0]*x[1]-p[1]*x[0]]))}v=[0,0,0];for(r=0;r<q.length;r++)v[0]+=q[r][0],v[1]+=q[r][1],v[2]+=q[r][2];v[0]/=q.length;v[1]/=q.length;v[2]/=q.length;w=(l*d+o)*4;n[w]=(v[0]+1)/2*255|0;n[w+1]=(v[1]+0.5)*
  371. 255|0;n[w+2]=v[2]*255|0;n[w+3]=255}f.putImageData(j,0,0);return e}};THREE.SceneUtils={showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=c})},traverseHierarchy:function(a,c){var b,d,h=a.children.length;for(d=0;d<h;d++)b=a.children[d],c(b),THREE.SceneUtils.traverseHierarchy(b,c)},createMultiMaterialObject:function(a,c){var b,d=c.length,h=new THREE.Object3D;for(b=0;b<d;b++){var e=new THREE.Mesh(a,c[b]);h.add(e)}return h}};
  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}",
  373. 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}"},
  374. normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tCube:{type:"t",value:1,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},tDisplacement:{type:"t",value:5,texture:null},uNormalScale:{type:"f",
  375. value:1},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1},uReflectivity:{type:"f",value:0.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,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 bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform float uNormalScale;\nuniform float uReflectivity;\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;",
  376. THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), 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.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor) + totalSpecular;\nif ( enableReflection ) {\nvec3 wPos = cameraPosition - vViewPosition;\nvec3 vReflect = reflect( normalize( wPos ), normal );\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, uReflectivity );\n}",
  377. THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\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;",
  378. THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv * uRepeat + uOffset;\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",
  379. THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},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;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}};
  380. THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPoint(c/a));return b};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b};
  381. THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var c=[],b,d=this.getPoint(0),h,e=0;c.push(0);for(h=1;h<=a;h++)b=this.getPoint(h/a),e+=b.distanceTo(d),c.push(e),d=b;return this.cacheArcLengths=c};
  382. THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),d=0,h=b.length,e;e=c?c:a*b[h-1];Date.now();for(var f=0,i=h-1,j;f<=i;)if(d=Math.floor(f+(i-f)/2),j=b[d]-e,j<0)f=d+1;else if(j>0)i=d-1;else{i=d;break}d=i;if(b[d]==e)return d/(h-1);f=b[d];return b=(d+(e-f)/(b[d+1]-f))/(h-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
  383. THREE.Curve.prototype.getTangent=function(a){var c=a-1.0E-4;a+=1.0E-4;c<0&&(c=0);a>1&&(a=1);var c=this.getPoint(c),a=this.getPoint(a),b=new THREE.Vector2;b.sub(a,c);return b.unit()};THREE.LineCurve=function(a,c){a instanceof THREE.Vector2?(this.v1=a,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,c,b,d){this.constructor(new THREE.Vector2(a,c),new THREE.Vector2(b,d))};THREE.LineCurve.prototype=new THREE.Curve;
  384. THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(a).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a};
  385. THREE.QuadraticBezierCurve=function(a,c,b){if(!(c instanceof THREE.Vector2))var d=Array.prototype.slice.call(arguments),a=new THREE.Vector2(d[0],d[1]),c=new THREE.Vector2(d[2],d[3]),b=new THREE.Vector2(d[4],d[5]);this.v0=a;this.v1=c;this.v2=b};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;
  386. THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(c,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);c=new THREE.Vector2(c,a);c.normalize();return c};
  387. THREE.CubicBezierCurve=function(a,c,b,d){if(!(c instanceof THREE.Vector2))var h=Array.prototype.slice.call(arguments),a=new THREE.Vector2(h[0],h[1]),c=new THREE.Vector2(h[2],h[3]),b=new THREE.Vector2(h[4],h[5]),d=new THREE.Vector2(h[6],h[7]);this.v0=a;this.v1=c;this.v2=b;this.v3=d};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;
  388. THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(c,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);c=new THREE.Vector2(c,a);c.normalize();return c};
  389. THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
  390. THREE.SplineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2,b=[],d=this.points,h;h=(d.length-1)*a;a=Math.floor(h);h-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,h);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,h);return c};THREE.ArcCurve=function(a,c,b,d,h,e){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=d;this.aEndAngle=h;this.aClockwise=e};
  391. THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))};
  392. THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,d){return 2*(1-a)*(b-c)+2*a*(d-b)},tangentCubicBezier:function(a,c,b,d,h){return-3*c*(1-a)*(1-a)+3*b*(1-a)*(1-a)-6*a*b*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*h},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,c,b,d,h){var a=(b-a)*0.5,d=(d-c)*0.5,e=h*h;return(2*c-2*b+a+d)*h*e+(-3*c+3*b-2*a-d)*e+a*h+c}};
  393. THREE.Curve.create=function(a,c){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=c;return a};THREE.LineCurve3=THREE.Curve.create(function(a,c){this.v1=a;this.v2=c},function(a){var c=new THREE.Vector3;c.sub(this.v2,this.v1);c.multiplyScalar(a);c.addSelf(this.v1);return c});
  394. THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,c,b){this.v0=a;this.v1=c;this.v2=b},function(a){var c,b;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,b,a)});
  395. THREE.CubicBezierCurve3=THREE.Curve.create(function(a,c,b,d){this.v0=a;this.v1=c;this.v2=b;this.v3=d},function(a){var c,b;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(c,b,a)});
  396. THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a},function(a){var c=new THREE.Vector3,b=[],d=this.points,h;h=(d.length-1)*a;a=Math.floor(h);h-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,h);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,h);c.z=THREE.Curve.Utils.interpolate(d[b[0]].z,d[b[1]].z,d[b[2]].z,d[b[3]].z,h);return c});
  397. THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){};
  398. THREE.CurvePath.prototype.getPoint=function(a){for(var c=a*this.getLength(),b=this.getCurveLengths(),a=0;a<b.length;){if(b[a]>=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
  399. THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],c=0,b,d=this.curves.length;for(b=0;b<d;b++)c+=this.curves[b].getLength(),a.push(c);return this.cacheLengths=a};
  400. THREE.CurvePath.prototype.getBoundingBox=function(){var a=this.getPoints(),c,b,d,h;c=b=Number.NEGATIVE_INFINITY;d=h=Number.POSITIVE_INFINITY;var e,f,i,j;j=new THREE.Vector2;f=0;for(i=a.length;f<i;f++){e=a[f];if(e.x>c)c=e.x;else if(e.x<d)d=e.x;if(e.y>b)b=e.y;else if(e.y<b)h=e.y;j.addSelf(e.x,e.y)}return{minX:d,minY:h,maxX:c,maxY:b,centroid:j.divideScalar(i)}};THREE.CurvePath.prototype.createPointsGeometry=function(a){return this.createGeometry(this.getPoints(a,!0))};
  401. THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){return this.createGeometry(this.getSpacedPoints(a,!0))};THREE.CurvePath.prototype.createGeometry=function(a){for(var c=new THREE.Geometry,b=0;b<a.length;b++)c.vertices.push(new THREE.Vertex(new THREE.Vector3(a[b].x,a[b].y,0)));return c};THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)};
  402. THREE.CurvePath.prototype.getTransformedPoints=function(a,c){var b=this.getPoints(a),d,h;if(!c)c=this.bends;d=0;for(h=c.length;d<h;d++)b=this.getWrapPoints(b,c[d]);return b};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,c){var b=this.getSpacedPoints(a),d,h;if(!c)c=this.bends;d=0;for(h=c.length;d<h;d++)b=this.getWrapPoints(b,c[d]);return b};
  403. THREE.CurvePath.prototype.getWrapPoints=function(a,c){var b=this.getBoundingBox(),d,h,e,f,i,j;d=0;for(h=a.length;d<h;d++)e=a[d],f=e.x,i=e.y,j=f/b.maxX,j=c.getUtoTmapping(j,f),f=c.getPoint(j),i=c.getNormalVector(j).multiplyScalar(i),e.x=f.x+i.x,e.y=f.y+i.y;return a};THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;
  404. 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(a){this.moveTo(a[0].x,a[0].y);var c,b=a.length;for(c=1;c<b;c++)this.lineTo(a[c].x,a[c].y)};THREE.Path.prototype.moveTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:a})};
  405. THREE.Path.prototype.lineTo=function(a,c){var b=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args;this.curves.push(new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,c)));this.actions.push({action:THREE.PathActions.LINE_TO,args:b})};
  406. THREE.Path.prototype.quadraticCurveTo=function(a,c,b,d){var h=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args;this.curves.push(new THREE.QuadraticBezierCurve(new THREE.Vector2(e[e.length-2],e[e.length-1]),new THREE.Vector2(a,c),new THREE.Vector2(b,d)));this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:h})};
  407. THREE.Path.prototype.bezierCurveTo=function(a,c,b,d,h,e){var f=Array.prototype.slice.call(arguments),i=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(i[i.length-2],i[i.length-1]),new THREE.Vector2(a,c),new THREE.Vector2(b,d),new THREE.Vector2(h,e)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:f})};
  408. THREE.Path.prototype.splineThru=function(a){var c=Array.prototype.slice.call(arguments),b=this.actions[this.actions.length-1].args,b=[new THREE.Vector2(b[b.length-2],b[b.length-1])];Array.prototype.push.apply(b,a);this.curves.push(new THREE.SplineCurve(b));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c})};
  409. THREE.Path.prototype.arc=function(a,c,b,d,h,e){var f=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,c,b,d,h,e));this.actions.push({action:THREE.PathActions.ARC,args:f})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var c=[],b=0;b<a;b++)c.push(this.getPoint(b/a));return c};
  410. THREE.Path.prototype.getPoints=function(a,c){var a=a||12,b=[],d,h,e,f,i,j,n,o,l,q,r,s,p;d=0;for(h=this.actions.length;d<h;d++)switch(e=this.actions[d],f=e.action,e=e.args,f){case THREE.PathActions.LINE_TO:b.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:i=e[2];j=e[3];l=e[0];q=e[1];b.length>0?(f=b[b.length-1],r=f.x,s=f.y):(f=this.actions[d-1].args,r=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)p=f/a,e=THREE.Shape.Utils.b2(p,r,l,i),p=THREE.Shape.Utils.b2(p,s,q,
  411. j),b.push(new THREE.Vector2(e,p));break;case THREE.PathActions.BEZIER_CURVE_TO:i=e[4];j=e[5];l=e[0];q=e[1];n=e[2];o=e[3];b.length>0?(f=b[b.length-1],r=f.x,s=f.y):(f=this.actions[d-1].args,r=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)p=f/a,e=THREE.Shape.Utils.b3(p,r,l,n,i),p=THREE.Shape.Utils.b3(p,s,q,o,j),b.push(new THREE.Vector2(e,p));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];p=a*e[0].length;f=f.concat(e[0]);e=new THREE.SplineCurve(f);
  412. for(f=1;f<=p;f++)b.push(e.getPointAt(f/p));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;i=e[0];j=e[1];n=e[2];l=e[3];p=e[4];q=!!e[5];o=f[f.length-2];r=f[f.length-1];f.length==0&&(o=r=0);s=p-l;var v=a*2;for(f=1;f<=v;f++)p=f/v,q||(p=1-p),p=l+p*s,e=o+i+n*Math.cos(p),p=r+j+n*Math.sin(p),b.push(new THREE.Vector2(e,p))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)};
  413. THREE.Path.prototype.nltransform=function(a,c,b,d,h,e){var f=this.getPoints(),i,j,n,o,l;i=0;for(j=f.length;i<j;i++)n=f[i],o=n.x,l=n.y,n.x=a*o+c*l+b,n.y=d*l+h*o+e;return f};
  414. THREE.Path.prototype.debug=function(a){var c=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",c.maxX+100),a.setAttribute("height",c.maxY+100),document.body.appendChild(a));c=a.getContext("2d");c.fillStyle="white";c.fillRect(0,0,a.width,a.height);c.strokeStyle="black";c.beginPath();var b,d,h,a=0;for(b=this.actions.length;a<b;a++)d=this.actions[a],h=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&c[d].apply(c,h);c.stroke();c.closePath();c.strokeStyle="red";d=
  415. this.getPoints();a=0;for(b=d.length;a<b;a++)h=d[a],c.beginPath(),c.arc(h.x,h.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
  416. THREE.Path.prototype.toShapes=function(){var a,c,b,d,h=[],e=new THREE.Path;a=0;for(c=this.actions.length;a<c;a++)b=this.actions[a],d=b.args,b=b.action,b==THREE.PathActions.MOVE_TO&&e.actions.length!=0&&(h.push(e),e=new THREE.Path),e[b].apply(e,d);e.actions.length!=0&&h.push(e);if(h.length==0)return[];var f,e=[];if(THREE.Shape.Utils.isClockWise(h[0].getPoints())){a=0;for(c=h.length;a<c;a++)d=h[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(f&&e.push(f),f=new THREE.Shape,f.actions=d.actions,f.curves=
  417. d.curves):f.holes.push(d);e.push(f)}else{f=new THREE.Shape;a=0;for(c=h.length;a<c;a++)d=h[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(f.actions=d.actions,f.curves=d.curves,e.push(f),f=new THREE.Shape):f.holes.push(d)}return e};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(a){return new THREE.ExtrudeGeometry(this,a)};
  418. THREE.Shape.prototype.getPointsHoles=function(a){var c,b=this.holes.length,d=[];for(c=0;c<b;c++)d[c]=this.holes[c].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var c,b=this.holes.length,d=[];for(c=0;c<b;c++)d[c]=this.holes[c].getTransformedSpacedPoints(a,this.bends);return d};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};
  419. THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
  420. THREE.Shape.Utils={removeHoles:function(a,c){var b=a.concat(),d=b.concat(),h,e,f,i,j,n,o,l,q,r,s=[];for(j=0;j<c.length;j++){n=c[j];Array.prototype.push.apply(d,n);e=Number.POSITIVE_INFINITY;for(h=0;h<n.length;h++){q=n[h];r=[];for(l=0;l<b.length;l++)o=b[l],o=q.distanceToSquared(o),r.push(o),o<e&&(e=o,f=h,i=l)}h=i-1>=0?i-1:b.length-1;e=f-1>=0?f-1:n.length-1;var p=[n[f],b[i],b[h]];l=THREE.FontUtils.Triangulate.area(p);var v=[n[f],n[e],b[i]];q=THREE.FontUtils.Triangulate.area(v);r=i;o=f;i+=1;f+=-1;i<
  421. 0&&(i+=b.length);i%=b.length;f<0&&(f+=n.length);f%=n.length;h=i-1>=0?i-1:b.length-1;e=f-1>=0?f-1:n.length-1;p=[n[f],b[i],b[h]];p=THREE.FontUtils.Triangulate.area(p);v=[n[f],n[e],b[i]];v=THREE.FontUtils.Triangulate.area(v);l+q>p+v&&(i=r,f=o,i<0&&(i+=b.length),i%=b.length,f<0&&(f+=n.length),f%=n.length,h=i-1>=0?i-1:b.length-1,e=f-1>=0?f-1:n.length-1);l=b.slice(0,i);q=b.slice(i);r=n.slice(f);o=n.slice(0,f);e=[n[f],n[e],b[i]];s.push([n[f],b[i],b[h]]);s.push(e);b=l.concat(r).concat(o).concat(q)}return{shape:b,
  422. isolatedPts:s,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,h=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),e,f,i,j,n={};e=0;for(f=d.length;e<f;e++)j=d[e].x+":"+d[e].y,n[j]!==void 0&&console.log("Duplicate point",j),n[j]=e;e=0;for(f=b.length;e<f;e++){i=b[e];for(d=0;d<3;d++)j=i[d].x+":"+i[d].y,j=n[j],j!==void 0&&(i[d]=j)}e=0;for(f=h.length;e<f;e++){i=h[e];for(d=0;d<3;d++)j=i[d].x+":"+i[d].y,j=n[j],j!==void 0&&(i[d]=j)}return b.concat(h)},
  423. isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,d){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,d)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*(1-a)*a*a*c},b3p3:function(a,c){return a*a*a*c},b3:function(a,c,b,d,h){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,d)+
  424. this.b3p3(a,h)}};THREE.TextPath=function(a,c){THREE.Path.call(this);this.parameters=c||{};this.set(a)};THREE.TextPath.prototype.set=function(a,c){this.text=a;var c=c||this.parameters,b=c.curveSegments!==void 0?c.curveSegments:4,d=c.font!==void 0?c.font:"helvetiker",h=c.weight!==void 0?c.weight:"normal",e=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=b;THREE.FontUtils.face=d;THREE.FontUtils.weight=h;THREE.FontUtils.style=e};
  425. THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,c=[],b=0,d=a.length;b<d;b++)Array.prototype.push.apply(c,a[b].toShapes());return c};
  426. THREE.AnimationHandler=function(){var a=[],c={},b={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){c[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");c[a.name]=a;if(a.initialized!==!0){for(var b=0;b<a.hierarchy.length;b++){for(var d=0;d<a.hierarchy[b].keys.length;d++){if(a.hierarchy[b].keys[d].time<
  427. 0)a.hierarchy[b].keys[d].time=0;if(a.hierarchy[b].keys[d].rot!==void 0&&!(a.hierarchy[b].keys[d].rot instanceof THREE.Quaternion)){var i=a.hierarchy[b].keys[d].rot;a.hierarchy[b].keys[d].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(a.hierarchy[b].keys[0].morphTargets!==void 0){i={};for(d=0;d<a.hierarchy[b].keys.length;d++)for(var j=0;j<a.hierarchy[b].keys[d].morphTargets.length;j++){var n=a.hierarchy[b].keys[d].morphTargets[j];i[n]=-1}a.hierarchy[b].usedMorphTargets=i;for(d=0;d<a.hierarchy[b].keys.length;d++){var o=
  428. {};for(n in i){for(j=0;j<a.hierarchy[b].keys[d].morphTargets.length;j++)if(a.hierarchy[b].keys[d].morphTargets[j]===n){o[n]=a.hierarchy[b].keys[d].morphTargetsInfluences[j];break}j===a.hierarchy[b].keys[d].morphTargets.length&&(o[n]=0)}a.hierarchy[b].keys[d].morphTargetsInfluences=o}}for(d=1;d<a.hierarchy[b].keys.length;d++)a.hierarchy[b].keys[d].time===a.hierarchy[b].keys[d-1].time&&(a.hierarchy[b].keys.splice(d,1),d--);for(d=1;d<a.hierarchy[b].keys.length;d++)a.hierarchy[b].keys[d].index=d}d=parseInt(a.length*
  429. a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(b=0;b<a.hierarchy.length;b++)a.JIT.hierarchy.push(Array(d));a.initialized=!0}},get:function(a){if(typeof a==="string")return c[a]?c[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};b.LINEAR=0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=
  430. 2;return b}();THREE.Animation=function(a,c,b,d){this.root=a;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=b!==void 0?b:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==void 0?d:!0;this.points=[];this.target=new THREE.Vector3};
  431. THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=c!==void 0?c:0;var b,d=this.hierarchy.length,h;for(b=0;b<d;b++){h=this.hierarchy[b];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
  432. THREE.Bone?h.skinMatrix:h.matrix;var e=h.animationCache.prevKey;h=h.animationCache.nextKey;e.pos=this.data.hierarchy[b].keys[0];e.rot=this.data.hierarchy[b].keys[0];e.scl=this.data.hierarchy[b].keys[0];h.pos=this.getNextKeyWith("pos",b,1);h.rot=this.getNextKeyWith("rot",b,1);h.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
  433. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  434. THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
  435. THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,h,e,f,i,j,n,o=this.data.JIT.hierarchy,l,q;this.currentTime+=a*this.timeScale;q=this.currentTime;l=this.currentTime%=this.data.length;n=parseInt(Math.min(l*this.data.fps,this.data.length*this.data.fps),10);for(var r=0,s=this.hierarchy.length;r<s;r++)if(a=this.hierarchy[r],j=a.animationCache,this.JITCompile&&o[r][n]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=o[r][n],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
  436. !1):(a.matrix=o[r][n],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var p=0;p<3;p++){b=c[p];f=j.prevKey[b];i=j.nextKey[b];if(i.time<=q){if(l<q)if(this.loop){f=this.data.hierarchy[r].keys[0];for(i=this.getNextKeyWith(b,r,1);i.time<l;)f=i,i=this.getNextKeyWith(b,r,i.index+1)}else{this.stop();return}else{do f=i,i=this.getNextKeyWith(b,r,i.index+1);while(i.time<
  437. l)}j.prevKey[b]=f;j.nextKey[b]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(l-f.time)/(i.time-f.time);h=f[b];e=i[b];if(d<0||d>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+r),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=h[0]+(e[0]-h[0])*d,b.y=h[1]+(e[1]-h[1])*d,b.z=h[2]+(e[2]-h[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
  438. this.getPrevKeyWith("pos",r,f.index-1).pos,this.points[1]=h,this.points[2]=e,this.points[3]=this.getNextKeyWith("pos",r,i.index+1).pos,d=d*0.33+0.33,h=this.interpolateCatmullRom(this.points,d),b.x=h[0],b.y=h[1],b.z=h[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b===
  439. "rot")THREE.Quaternion.slerp(h,e,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=h[0]+(e[0]-h[0])*d,b.y=h[1]+(e[1]-h[1])*d,b.z=h[2]+(e[2]-h[2])*d}}if(this.JITCompile&&o[0][n]===void 0){this.hierarchy[0].update(null,!0);for(r=0;r<this.hierarchy.length;r++)o[r][n]=this.hierarchy[r]instanceof THREE.Bone?this.hierarchy[r].skinMatrix.clone():this.hierarchy[r].matrix.clone()}}};
  440. THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],h,e,f,i,j,n;h=(a.length-1)*c;e=Math.floor(h);h-=e;b[0]=e===0?e:e-1;b[1]=e;b[2]=e>a.length-2?e:e+1;b[3]=e>a.length-3?e:e+2;e=a[b[0]];i=a[b[1]];j=a[b[2]];n=a[b[3]];b=h*h;f=h*b;d[0]=this.interpolate(e[0],i[0],j[0],n[0],h,b,f);d[1]=this.interpolate(e[1],i[1],j[1],n[1],h,b,f);d[2]=this.interpolate(e[2],i[2],j[2],n[2],h,b,f);return d};
  441. THREE.Animation.prototype.interpolate=function(a,c,b,d,h,e,f){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*f+(-3*(c-b)-2*a-d)*e+a*h+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<d.length-1?b:d.length-1:b%=d.length;b<d.length;b++)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[0]};
  442. THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var d=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[d.length-1]};
  443. THREE.CubeCamera=function(a,c,b,d){this.heightOffset=b;this.position=new THREE.Vector3(0,b,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=
  444. this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ=
  445. new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+=
  446. 1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var c=this.renderTarget;c.activeCubeFace=0;a.render(b,this.cameraPX,c);c.activeCubeFace=1;a.render(b,this.cameraNX,c);c.activeCubeFace=2;a.render(b,this.cameraPY,c);c.activeCubeFace=3;a.render(b,
  447. this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")};
  448. THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,c,b,d,h,e,f){THREE.Camera.call(this);this.fov=b;this.left=-a/2;this.right=a/2;this.top=c/2;this.bottom=-c/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,e,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,d,h);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
  449. THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1};
  450. THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov/2)*((this.cameraP.near+this.cameraP.far)/2),c=2*a*this.cameraP.aspect/2;a/=this.zoom;c/=this.zoom;this.cameraO.left=-c;this.cameraO.right=c;this.cameraO.top=a;this.cameraO.bottom=-a;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0};
  451. THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
  452. THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
  453. THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
  454. THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
  455. 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
  456. !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
  457. function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.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=
  458. !1;break;case 70:this.moveDown=!1}};this.update=function(a){if(!this.freeze){if(this.heightSpeed){var b=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*b*this.heightCoef}else this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&&this.object.translateX(b);
  459. this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);b=a*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*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;var a=this.target,c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&&
  460. (a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b*a);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=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);
  461. this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};
  462. THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function h(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,h=b.getControlPointsArray(),i=b.getLength(),v=h.length,w=0;f=v-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:h[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<v-1;f++)w=d*i.chunks[f]/i.total,b.keys[f]={time:w,pos:h[f]};e.hierarchy[0]=
  463. b;THREE.AnimationHandler.add(e);return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}this.object=a;this.domElement=c!==void 0?c:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=
  464. new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
  465. this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var f=Math.PI*2,i=Math.PI/180;this.update=function(a){var c;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);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)*i;this.theta=this.lon*i;a=this.phi%f;this.phi=a>=0?a:a+f;c=this.verticalAngleMap.srcRange;
  466. a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var d=a[1]-a[0];this.phi=b((c-a[0])/d)*d+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);d=a[1]-a[0];this.theta=b((c-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=
  467. function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
  468. c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=h(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=h(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
  469. this.debugPath,b=this.spline,f=e(b,10),c=e(b,10),i=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,i),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),i=new THREE.MeshBasicMaterial({color:65280}),r=0;r<b.points.length;r++)c=new THREE.Mesh(f,i),c.position.copy(b.points[r]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
  470. !1)}};THREE.PathControlsIdCounter=0;
  471. THREE.FlyControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=c!==void 0?c:document;c&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;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,
  472. 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=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=
  473. 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()}};this.keyup=function(a){switch(a.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=
  474. 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;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
  475. !0;break;case 2:this.object.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),c=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=
  476. !1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion);
  477. this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||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=-a+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=
  478. -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=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",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,
  479. this.mouseup),!1);this.domElement.addEventListener("keydown",b(this,this.keydown),!1);this.domElement.addEventListener("keyup",b(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};
  480. THREE.RollControls=function(a,c){this.object=a;this.domElement=c!==void 0?c:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var b=new THREE.Vector3,d=new THREE.Vector3,h=new THREE.Vector3,e=new THREE.Matrix4,f=!1,i=1,j=0,n=0,o=0,l=0,q=0,r=window.innerWidth/2,s=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed;
  481. this.rotateHorizontally(c*l);this.rotateVertically(c*q)}c=a*this.movementSpeed;this.object.translateZ(-c*(j>0||this.autoForward&&!(j<0)?1:j));this.object.translateX(c*n);this.object.translateY(c*o);f&&(this.roll+=this.rollSpeed*a*i);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();h.copy(this.forward);d.set(0,1,0);b.cross(d,
  482. h).normalize();d.cross(h,b).normalize();this.object.matrix.n11=b.x;this.object.matrix.n12=d.x;this.object.matrix.n13=h.x;this.object.matrix.n21=b.y;this.object.matrix.n22=d.y;this.object.matrix.n23=h.y;this.object.matrix.n31=b.z;this.object.matrix.n32=d.z;this.object.matrix.n33=h.z;e.identity();e.n11=Math.cos(this.roll);e.n12=-Math.sin(this.roll);e.n21=Math.sin(this.roll);e.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(e);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
  483. this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
  484. a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){b.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);b.multiplyScalar(a);this.forward.subSelf(b);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
  485. function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){l=(a.clientX-r)/window.innerWidth;q=(a.clientY-s)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:j=1;break;case 2:j=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:j=0;break;case 2:j=0}},!1);this.domElement.addEventListener("keydown",
  486. function(a){switch(a.keyCode){case 38:case 87:j=1;break;case 37:case 65:n=-1;break;case 40:case 83:j=-1;break;case 39:case 68:n=1;break;case 81:f=!0;i=1;break;case 69:f=!0;i=-1;break;case 82:o=1;break;case 70:o=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:j=0;break;case 37:case 65:n=0;break;case 40:case 83:j=0;break;case 39:case 68:n=0;break;case 81:f=!1;break;case 69:f=!1;break;case 82:o=0;break;case 70:o=0}},!1)};
  487. THREE.TrackballControls=function(a,c){var b=this,d={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};this.object=a;this.domElement=c!==void 0?c:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=
  488. new THREE.Vector3(0,0,0);var h=!1,e=d.NONE,f=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector2,o=new THREE.Vector2,l=new THREE.Vector2,q=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a-b.screen.offsetLeft)/b.radius*0.5,(c-b.screen.offsetTop)/b.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var d=new THREE.Vector3((a-b.screen.width*0.5-b.screen.offsetLeft)/
  489. b.radius,(b.screen.height*0.5+b.screen.offsetTop-c)/b.radius,0),e=d.length();e>1?d.normalize():d.z=Math.sqrt(1-e*e);f.copy(b.object.position).subSelf(b.target);e=b.object.up.clone().setLength(d.y);e.addSelf(b.object.up.clone().crossSelf(f).setLength(d.x));e.addSelf(f.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(i.dot(j)/i.length()/j.length());if(a){var c=(new THREE.Vector3).cross(i,j).normalize(),d=new THREE.Quaternion;a*=b.rotateSpeed;d.setFromAxisAngle(c,-a);d.multiplyVector3(f);
  490. d.multiplyVector3(b.object.up);d.multiplyVector3(j);b.staticMoving?i=j:(d.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),d.multiplyVector3(i))}};this.zoomCamera=function(){var a=1+(o.y-n.y)*b.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),b.staticMoving?n=o:n.y+=(o.y-n.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=q.clone().subSelf(l);if(a.lengthSq()){a.multiplyScalar(f.length()*b.panSpeed);var c=f.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y));
  491. b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?l=q:l.addSelf(a.sub(q,l).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),f.lengthSq()<b.minDistance*b.minDistance&&b.object.position.add(b.target,f.setLength(b.minDistance))};this.update=function(){f.copy(b.object.position).subSelf(this.target);b.rotateCamera();b.noZoom||b.zoomCamera();b.noPan||
  492. b.panCamera();b.object.position.add(b.target,f);b.checkDistances();b.object.lookAt(b.target)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){b.enabled&&(h&&(i=j=b.getMouseProjectionOnBall(a.clientX,a.clientY),n=o=b.getMouseOnScreen(a.clientX,a.clientY),l=q=b.getMouseOnScreen(a.clientX,a.clientY),h=!1),e!==d.NONE&&(e===d.ROTATE?j=b.getMouseProjectionOnBall(a.clientX,a.clientY):e===d.ZOOM&&!b.noZoom?o=b.getMouseOnScreen(a.clientX,
  493. a.clientY):e===d.PAN&&!b.noPan&&(q=b.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(b.enabled&&(a.preventDefault(),a.stopPropagation(),e===d.NONE))e=a.button,e===d.ROTATE?i=j=b.getMouseProjectionOnBall(a.clientX,a.clientY):e===d.ZOOM&&!b.noZoom?n=o=b.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(l=q=b.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",function(a){if(b.enabled)a.preventDefault(),a.stopPropagation(),
  494. e=d.NONE},!1);window.addEventListener("keydown",function(a){if(b.enabled&&e===d.NONE){if(a.keyCode===b.keys[d.ROTATE])e=d.ROTATE;else if(a.keyCode===b.keys[d.ZOOM]&&!b.noZoom)e=d.ZOOM;else if(a.keyCode===b.keys[d.PAN]&&!b.noPan)e=d.PAN;e!==d.NONE&&(h=!0)}},!1);window.addEventListener("keyup",function(){if(b.enabled&&e!==d.NONE)e=d.NONE},!1)};
  495. THREE.CubeGeometry=function(a,c,b,d,h,e,f,i){function j(a,b,c,f,i,j,l,o){var p,r,q=d||1,s=h||1,v=i/2,k=j/2,w=n.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")p="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x")p="y",s=e||1;else if(a==="z"&&b==="y"||a==="y"&&b==="z")p="x",q=e||1;var t=q+1,x=s+1;i/=q;var D=j/s;for(r=0;r<x;r++)for(j=0;j<t;j++){var T=new THREE.Vector3;T[a]=(j*i-v)*c;T[b]=(r*D-k)*f;T[p]=l;n.vertices.push(new THREE.Vertex(T))}for(r=0;r<s;r++)for(j=0;j<q;j++)n.faces.push(new THREE.Face4(j+
  496. t*r+w,j+t*(r+1)+w,j+1+t*(r+1)+w,j+1+t*r+w,null,null,o)),n.faceVertexUvs[0].push([new THREE.UV(j/q,r/s),new THREE.UV(j/q,(r+1)/s),new THREE.UV((j+1)/q,(r+1)/s),new THREE.UV((j+1)/q,r/s)])}THREE.Geometry.call(this);var n=this,o=a/2,l=c/2,q=b/2,r,s,p,v,w,x;if(f!==void 0){if(f instanceof Array)this.materials=f;else{this.materials=[];for(r=0;r<6;r++)this.materials.push(f)}r=0;v=1;s=2;w=3;p=4;x=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(i!=void 0)for(var t in i)this.sides[t]!=
  497. void 0&&(this.sides[t]=i[t]);this.sides.px&&j("z","y",-1,-1,b,c,o,r);this.sides.nx&&j("z","y",1,-1,b,c,-o,v);this.sides.py&&j("x","z",1,1,a,b,l,s);this.sides.ny&&j("x","z",1,-1,a,b,-l,w);this.sides.pz&&j("x","y",1,-1,a,c,q,p);this.sides.nz&&j("x","y",-1,-1,a,c,-q,x);this.mergeVertices();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
  498. THREE.CylinderGeometry=function(a,c,b,d,h,e){THREE.Geometry.call(this);var a=a!=null?a:20,c=c!=null?c:20,b=b||100,f=b/2,d=d||8,h=h||1,i,j,n=[],o=[];for(j=0;j<=h;j++){var l=[],q=[],r=j/h,s=r*(c-a)+a;for(i=0;i<=d;i++){var p=i/d;this.vertices.push(new THREE.Vertex(new THREE.Vector3(s*Math.sin(p*Math.PI*2),-r*b+f,s*Math.cos(p*Math.PI*2))));l.push(this.vertices.length-1);q.push(new THREE.UV(p,r))}n.push(l);o.push(q)}for(j=0;j<h;j++)for(i=0;i<d;i++){var b=n[j][i],l=n[j+1][i],q=n[j+1][i+1],r=n[j][i+1],s=
  499. this.vertices[b].position.clone().setY(0).normalize(),p=this.vertices[l].position.clone().setY(0).normalize(),v=this.vertices[q].position.clone().setY(0).normalize(),w=this.vertices[r].position.clone().setY(0).normalize(),x=o[j][i].clone(),t=o[j+1][i].clone(),B=o[j+1][i+1].clone(),G=o[j][i+1].clone();this.faces.push(new THREE.Face4(b,l,q,r,[s,p,v,w]));this.faceVertexUvs[0].push([x,t,B,G])}if(!e&&a>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(i=0;i<d;i++)b=n[0][i],l=n[0][i+
  500. 1],q=this.vertices.length-1,s=new THREE.Vector3(0,1,0),p=new THREE.Vector3(0,1,0),v=new THREE.Vector3(0,1,0),x=o[0][i].clone(),t=o[0][i+1].clone(),B=new THREE.UV(t.u,0),this.faces.push(new THREE.Face3(b,l,q,[s,p,v])),this.faceVertexUvs[0].push([x,t,B])}if(!e&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(i=0;i<d;i++)b=n[j][i+1],l=n[j][i],q=this.vertices.length-1,s=new THREE.Vector3(0,-1,0),p=new THREE.Vector3(0,-1,0),v=new THREE.Vector3(0,-1,0),x=o[j][i+1].clone(),t=o[j][i].clone(),
  501. B=new THREE.UV(t.u,1),this.faces.push(new THREE.Face3(b,l,q,[s,p,v])),this.faceVertexUvs[0].push([x,t,B])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
  502. THREE.ExtrudeGeometry=function(a,c){if(typeof a!=="undefined"){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],b,d=a.length,h;this.shapebb=a[d-1].getBoundingBox();for(b=0;b<d;b++)h=a[b],this.addShape(h,c);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
  503. THREE.ExtrudeGeometry.prototype.addShape=function(a,c){function b(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,h=THREE.ExtrudeGeometry.__v4,i=THREE.ExtrudeGeometry.__v5,j=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);h.set(e.y,-e.x);i.copy(a).addSelf(f);j.copy(a).addSelf(h);if(i.equals(j))return h.clone();
  504. i.copy(b).addSelf(f);j.copy(c).addSelf(h);f=d.dot(h);h=j.subSelf(i).dot(h);f===0&&(console.log("Either infinite or no solutions!"),h===0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));h/=f;if(h<0)return b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(h).addSelf(i).subSelf(a).clone()}function h(a){for(F=a.length;--F>=0;){$=F;Q=F-1;Q<0&&(Q=a.length-1);for(var b=
  505. 0,c=r+o*2,b=0;b<c;b++){var d=k*b,e=k*(b+1),f=ia+$+d,h=ia+$+e,l=f,d=ia+Q+d,e=ia+Q+e,n=h;l+=y;d+=y;e+=y;n+=y;z.faces.push(new THREE.Face4(l,d,e,n,null,null,B));B&&(l=b/c,d=(b+1)/c,e=i+j*2,f=(z.vertices[f].position.z+j)/e,h=(z.vertices[h].position.z+j)/e,z.faceVertexUvs[0].push([new THREE.UV(f,l),new THREE.UV(h,l),new THREE.UV(h,d),new THREE.UV(f,d)]))}}}function e(a,b,c){z.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=y;b+=y;c+=y;z.faces.push(new THREE.Face3(a,b,c,null,
  506. null,t));if(t){var d=G.maxY,e=G.maxX,f=z.vertices[b].position.x,b=z.vertices[b].position.y,h=z.vertices[c].position.x,c=z.vertices[c].position.y;z.faceVertexUvs[0].push([new THREE.UV(z.vertices[a].position.x/e,z.vertices[a].position.y/d),new THREE.UV(f/e,b/d),new THREE.UV(h/e,c/d)])}}var i=c.amount!==void 0?c.amount:100,j=c.bevelThickness!==void 0?c.bevelThickness:6,n=c.bevelSize!==void 0?c.bevelSize:j-2,o=c.bevelSegments!==void 0?c.bevelSegments:3,l=c.bevelEnabled!==void 0?c.bevelEnabled:!0,q=c.curveSegments!==
  507. void 0?c.curveSegments:12,r=c.steps!==void 0?c.steps:1,s=c.bendPath,p=c.extrudePath,v,w=!1,x=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,t=c.material,B=c.extrudeMaterial,G=this.shapebb;if(p)v=p.getPoints(q),r=v.length,w=!0,l=!1;l||(n=j=o=0);var P,C,L,z=this,y=this.vertices.length;s&&a.addWrapPath(s);q=x?a.extractAllSpacedPoints(q):a.extractAllPoints(q);s=q.shape;q=q.holes;if(p=!THREE.Shape.Utils.isClockWise(s)){s=s.reverse();C=0;for(L=q.length;C<L;C++)P=q[C],THREE.Shape.Utils.isClockWise(P)&&
  508. (q[C]=P.reverse());p=!1}p=THREE.Shape.Utils.triangulateShape(s,q);x=s;C=0;for(L=q.length;C<L;C++)P=q[C],s=s.concat(P);var F,O,U,ea,N,R,k=s.length,ga=p.length,ja=[];F=0;O=x.length;$=O-1;for(Q=F+1;F<O;F++,$++,Q++)$===O&&($=0),Q===O&&(Q=0),ja[F]=d(x[F],x[$],x[Q]);var H=[],D,T=ja.concat();C=0;for(L=q.length;C<L;C++){P=q[C];D=[];F=0;O=P.length;$=O-1;for(Q=F+1;F<O;F++,$++,Q++)$===O&&($=0),Q===O&&(Q=0),D[F]=d(P[F],P[$],P[Q]);H.push(D);T=T.concat(D)}for(U=0;U<o;U++){ea=U/o;N=j*(1-ea);ea=n*Math.sin(ea*Math.PI/
  509. 2);F=0;for(O=x.length;F<O;F++)R=b(x[F],ja[F],ea),e(R.x,R.y,-N);C=0;for(L=q.length;C<L;C++){P=q[C];D=H[C];F=0;for(O=P.length;F<O;F++)R=b(P[F],D[F],ea),e(R.x,R.y,-N)}}ea=n;for(F=0;F<k;F++)R=l?b(s[F],T[F],ea):s[F],w?e(R.x,R.y+v[0].y,v[0].x):e(R.x,R.y,0);for(U=1;U<=r;U++)for(F=0;F<k;F++)R=l?b(s[F],T[F],ea):s[F],w?e(R.x,R.y+v[U-1].y,v[U-1].x):e(R.x,R.y,i/r*U);for(U=o-1;U>=0;U--){ea=U/o;N=j*(1-ea);ea=n*Math.sin(ea*Math.PI/2);F=0;for(O=x.length;F<O;F++)R=b(x[F],ja[F],ea),e(R.x,R.y,i+N);C=0;for(L=q.length;C<
  510. L;C++){P=q[C];D=H[C];F=0;for(O=P.length;F<O;F++)R=b(P[F],D[F],ea),w?e(R.x,R.y+v[r-1].y,v[r-1].x+N):e(R.x,R.y,i+N)}}if(l){l=k*0;for(F=0;F<ga;F++)n=p[F],f(n[2]+l,n[1]+l,n[0]+l);l=k*(r+o*2);for(F=0;F<ga;F++)n=p[F],f(n[0]+l,n[1]+l,n[2]+l)}else{for(F=0;F<ga;F++)n=p[F],f(n[2],n[1],n[0]);for(F=0;F<ga;F++)n=p[F],f(n[0]+k*r,n[1]+k*r,n[2]+k*r)}var $,Q,ia=0;h(x);ia+=x.length;C=0;for(L=q.length;C<L;C++)P=q[C],h(P),ia+=P.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
  511. THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
  512. THREE.IcosahedronGeometry=function(a){function c(a,b,c){var d=Math.sqrt(a*a+b*b+c*c);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(a/d,b/d,c/d)))-1}function b(a,b,c,d){d.faces.push(new THREE.Face3(a,b,c))}function d(a,b){var d=h.vertices[a].position,e=h.vertices[b].position;return c((d.x+e.x)/2,(d.y+e.y)/2,(d.z+e.z)/2)}var h=this,e=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,
  513. -a);c(0,1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,e);b(0,5,1,e);b(0,1,7,e);b(0,7,10,e);b(0,10,11,e);b(1,5,9,e);b(5,11,4,e);b(11,10,2,e);b(10,7,6,e);b(7,1,8,e);b(3,9,4,e);b(3,4,2,e);b(3,2,6,e);b(3,6,8,e);b(3,8,9,e);b(4,9,5,e);b(2,4,11,e);b(6,2,10,e);b(8,6,7,e);b(9,8,1,e);for(var f=0;f<this.subdivisions;f++){var a=new THREE.Geometry,i;for(i in e.faces){var j=d(e.faces[i].a,e.faces[i].b),n=d(e.faces[i].b,e.faces[i].c),o=d(e.faces[i].c,e.faces[i].a);b(e.faces[i].a,j,o,a);b(e.faces[i].b,n,
  514. j,a);b(e.faces[i].c,o,n,a);b(j,n,o,a)}e.faces=a.faces}h.faces=e.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
  515. THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],d=[],h=[],e=[],f=(new THREE.Matrix4).setRotationZ(c),i=0;i<a.length;i++)this.vertices.push(new THREE.Vertex(a[i])),b[i]=a[i].clone(),d[i]=this.vertices.length-1;for(var j=0;j<=this.angle+0.0010;j+=c){for(i=0;i<b.length;i++)j<this.angle?(b[i]=f.multiplyVector3(b[i].clone()),this.vertices.push(new THREE.Vertex(b[i])),h[i]=this.vertices.length-1):h=e;j==0&&(e=d);
  516. for(i=0;i<d.length-1;i++)this.faces.push(new THREE.Face4(h[i],h[i+1],d[i+1],d[i])),this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,i/a.length),new THREE.UV(1-j/this.angle,(i+1)/a.length),new THREE.UV(1-(j-c)/this.angle,(i+1)/a.length),new THREE.UV(1-(j-c)/this.angle,i/a.length)]);d=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
  517. THREE.OctahedronGeometry=function(a,c){function b(b){var c=b.clone().normalize(),c=new THREE.Vertex(c.clone().multiplyScalar(a));c.index=f.vertices.push(c)-1;c.uv=new THREE.UV(Math.atan2(b.z,-b.x)/2/Math.PI+0.5,Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))/Math.PI+0.5);return c}function d(a,b,c,i){i<1?(i=new THREE.Face3(a.index,b.index,c.index,[a.position,b.position,c.position]),i.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),i.normal=i.centroid.clone().normalize(),
  518. f.faces.push(i),i=Math.atan2(i.centroid.z,-i.centroid.x),f.faceVertexUvs[0].push([e(a.uv,a.position,i),e(b.uv,b.position,i),e(c.uv,c.position,i)])):(i-=1,d(a,h(a,b),h(a,c),i),d(h(a,b),b,h(b,c),i),d(h(a,c),h(b,c),c,i),d(h(a,b),h(b,c),h(a,c),i))}function h(a,c){i[a.index]||(i[a.index]=[]);i[c.index]||(i[c.index]=[]);var d=i[a.index][c.index];d===void 0&&(i[a.index][c.index]=i[c.index][a.index]=d=b((new THREE.Vector3).add(a.position,c.position).divideScalar(2)));return d}function e(a,b,c){c<0&&a.u===
  519. 1&&(a=new THREE.UV(a.u-1,a.v));b.x===0&&b.z===0&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);var c=c||0,f=this;b(new THREE.Vector3(1,0,0));b(new THREE.Vector3(-1,0,0));b(new THREE.Vector3(0,1,0));b(new THREE.Vector3(0,-1,0));b(new THREE.Vector3(0,0,1));b(new THREE.Vector3(0,0,-1));var i=[],j=this.vertices;d(j[0],j[2],j[4],c);d(j[0],j[4],j[3],c);d(j[0],j[3],j[5],c);d(j[0],j[5],j[2],c);d(j[1],j[2],j[5],c);d(j[1],j[5],j[3],c);d(j[1],j[3],j[4],c);d(j[1],j[4],j[2],c);this.boundingSphere=
  520. {radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
  521. THREE.PlaneGeometry=function(a,c,b,d){THREE.Geometry.call(this);var h,e=a/2,f=c/2,b=b||1,d=d||1,i=b+1,j=d+1;a/=b;var n=c/d;for(h=0;h<j;h++)for(c=0;c<i;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-e,-(h*n-f),0)));for(h=0;h<d;h++)for(c=0;c<b;c++)this.faces.push(new THREE.Face4(c+i*h,c+i*(h+1),c+1+i*(h+1),c+1+i*h)),this.faceVertexUvs[0].push([new THREE.UV(c/b,h/d),new THREE.UV(c/b,(h+1)/d),new THREE.UV((c+1)/b,(h+1)/d),new THREE.UV((c+1)/b,h/d)]);this.computeCentroids();this.computeFaceNormals()};
  522. THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
  523. THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,d,h=Math.PI,e=Math.max(3,c||8),f=Math.max(2,b||6),c=[],b=0;b<f+1;b++){d=b/f;var i=a*Math.cos(d*h),j=a*Math.sin(d*h),n=[],o=0;for(d=0;d<e;d++){var l=2*d/e,q=j*Math.sin(l*h),l=j*Math.cos(l*h);(b==0||b==f)&&d>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(l,i,q)))-1);n.push(o)}c.push(n)}for(var r,s,p,h=c.length,b=0;b<h;b++)if(e=c[b].length,b>0)for(d=0;d<e;d++){n=d==e-1;f=c[b][n?0:d+1];i=c[b][n?e-1:d];j=c[b-1][n?
  524. e-1:d];n=c[b-1][n?0:d+1];q=b/(h-1);r=(b-1)/(h-1);s=(d+1)/e;var l=d/e,o=new THREE.UV(1-s,q),q=new THREE.UV(1-l,q),l=new THREE.UV(1-l,r),v=new THREE.UV(1-s,r);b<c.length-1&&(r=this.vertices[f].position.clone(),s=this.vertices[i].position.clone(),p=this.vertices[j].position.clone(),r.normalize(),s.normalize(),p.normalize(),this.faces.push(new THREE.Face3(f,i,j,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(p.x,p.y,p.z)])),this.faceVertexUvs[0].push([o,q,l]));b>1&&(r=
  525. this.vertices[f].position.clone(),s=this.vertices[j].position.clone(),p=this.vertices[n].position.clone(),r.normalize(),s.normalize(),p.normalize(),this.faces.push(new THREE.Face3(f,j,n,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(p.x,p.y,p.z)])),this.faceVertexUvs[0].push([o,l,v]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
  526. THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
  527. THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,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;if(c.bend){var d=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
  528. THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
  529. 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(a,c){return(new THREE.TextPath(a,c)).toShapes()},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},
  530. drawText:function(a){for(var c=this.getFace(),b=this.size/c.resolution,d=0,h=String(a).split(""),e=h.length,f=[],a=0;a<e;a++){var i=new THREE.Path,i=this.extractGlyphPoints(h[a],c,b,d,i);d+=i.offset;f.push(i.path)}return{paths:f,offset:d/2}},extractGlyphPoints:function(a,c,b,d,h){var e=[],f,i,j,n,o,l,q,r,s,p,v,w=c.glyphs[a]||c.glyphs["?"];if(w){if(w.o){c=w._cachedOutline||(w._cachedOutline=w.o.split(" "));n=c.length;for(a=0;a<n;)switch(j=c[a++],j){case "m":j=c[a++]*b+d;o=c[a++]*b;e.push(new THREE.Vector2(j,
  531. o));h.moveTo(j,o);break;case "l":j=c[a++]*b+d;o=c[a++]*b;e.push(new THREE.Vector2(j,o));h.lineTo(j,o);break;case "q":j=c[a++]*b+d;o=c[a++]*b;r=c[a++]*b+d;s=c[a++]*b;h.quadraticCurveTo(r,s,j,o);if(f=e[e.length-1]){l=f.x;q=f.y;f=1;for(i=this.divisions;f<=i;f++){var x=f/i,t=THREE.Shape.Utils.b2(x,l,r,j),x=THREE.Shape.Utils.b2(x,q,s,o);e.push(new THREE.Vector2(t,x))}}break;case "b":if(j=c[a++]*b+d,o=c[a++]*b,r=c[a++]*b+d,s=c[a++]*-b,p=c[a++]*b+d,v=c[a++]*-b,h.bezierCurveTo(j,o,r,s,p,v),f=e[e.length-1]){l=
  532. f.x;q=f.y;f=1;for(i=this.divisions;f<=i;f++)x=f/i,t=THREE.Shape.Utils.b3(x,l,r,p,j),x=THREE.Shape.Utils.b3(x,q,s,v,o),e.push(new THREE.Vector2(t,x))}}}return{offset:w.ha*b,points:e,path:h}}}};
  533. (function(a){var c=function(a){for(var c=a.length,h=0,e=c-1,f=0;f<c;e=f++)h+=a[e].x*a[f].y-a[f].x*a[e].y;return h*0.5};a.Triangulate=function(a,d){var h=a.length;if(h<3)return null;var e=[],f=[],i=[],j,n,o;if(c(a)>0)for(n=0;n<h;n++)f[n]=n;else for(n=0;n<h;n++)f[n]=h-1-n;var l=2*h;for(n=h-1;h>2;){if(l--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return i;return e}j=n;h<=j&&(j=0);n=j+1;h<=n&&(n=0);o=n+1;h<=o&&(o=0);var q;a:{q=a;var r=j,s=n,p=o,v=h,w=f,x=void 0,t=void 0,B=void 0,
  534. G=void 0,P=void 0,C=void 0,L=void 0,z=void 0,y=void 0,t=q[w[r]].x,B=q[w[r]].y,G=q[w[s]].x,P=q[w[s]].y,C=q[w[p]].x,L=q[w[p]].y;if(1.0E-10>(G-t)*(L-B)-(P-B)*(C-t))q=!1;else{for(x=0;x<v;x++)if(!(x==r||x==s||x==p)){var z=q[w[x]].x,y=q[w[x]].y,F=void 0,O=void 0,U=void 0,ea=void 0,N=void 0,R=void 0,k=void 0,ga=void 0,ja=void 0,H=void 0,D=void 0,T=void 0,F=U=N=void 0,F=C-G,O=L-P,U=t-C,ea=B-L,N=G-t,R=P-B,k=z-t,ga=y-B,ja=z-G,H=y-P,D=z-C,T=y-L,F=F*H-O*ja,N=N*ga-R*k,U=U*T-ea*D;if(F>=0&&U>=0&&N>=0){q=!1;break a}}q=
  535. !0}}if(q){e.push([a[f[j]],a[f[n]],a[f[o]]]);i.push([f[j],f[n],f[o]]);j=n;for(o=n+1;o<h;j++,o++)f[j]=f[o];h--;l=2*h}}if(d)return i;return e};a.Triangulate.area=c;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
  536. THREE.TorusGeometry=function(a,c,b,d,h){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;this.arc=h||Math.PI*2;h=new THREE.Vector3;a=[];c=[];for(b=0;b<=this.segmentsR;b++)for(d=0;d<=this.segmentsT;d++){var e=d/this.segmentsT*this.arc,f=b/this.segmentsR*Math.PI*2;h.x=this.radius*Math.cos(e);h.y=this.radius*Math.sin(e);var i=new THREE.Vector3;i.x=(this.radius+this.tube*Math.cos(f))*Math.cos(e);i.y=(this.radius+this.tube*Math.cos(f))*Math.sin(e);i.z=
  537. this.tube*Math.sin(f);this.vertices.push(new THREE.Vertex(i));a.push(new THREE.UV(d/this.segmentsT,1-b/this.segmentsR));c.push(i.clone().subSelf(h).normalize())}for(b=1;b<=this.segmentsR;b++)for(d=1;d<=this.segmentsT;d++){var h=(this.segmentsT+1)*b+d-1,e=(this.segmentsT+1)*(b-1)+d-1,f=(this.segmentsT+1)*(b-1)+d,i=(this.segmentsT+1)*b+d,j=new THREE.Face4(h,e,f,i,[c[h],c[e],c[f],c[i]]);j.normal.addSelf(c[h]);j.normal.addSelf(c[e]);j.normal.addSelf(c[f]);j.normal.addSelf(c[i]);j.normal.normalize();this.faces.push(j);
  538. this.faceVertexUvs[0].push([a[h].clone(),a[e].clone(),a[f].clone(),a[i].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
  539. THREE.TorusKnotGeometry=function(a,c,b,d,h,e,f){function i(a,b,c,d,e,f){b=c/d*a;c=Math.cos(b);return new THREE.Vector3(e*(2+c)*0.5*Math.cos(a),e*(2+c)*Math.sin(a)*0.5,f*e*Math.sin(b)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=h||2;this.q=e||3;this.heightScale=f||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<
  540. this.segmentsT;++c){var j=a/this.segmentsR*2*this.p*Math.PI,f=c/this.segmentsT*2*Math.PI,h=i(j,f,this.q,this.p,this.radius,this.heightScale),j=i(j+0.01,f,this.q,this.p,this.radius,this.heightScale);b.x=j.x-h.x;b.y=j.y-h.y;b.z=j.z-h.z;d.x=j.x+h.x;d.y=j.y+h.y;d.z=j.z+h.z;e.cross(b,d);d.cross(e,b);e.normalize();d.normalize();j=-this.tube*Math.cos(f);f=this.tube*Math.sin(f);h.x+=j*d.x+f*e.x;h.y+=j*d.y+f*e.y;h.z+=j*d.z+f*e.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(h.x,h.y,
  541. h.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=0;c<this.segmentsT;++c){var d=(a+1)%this.segmentsR,e=(c+1)%this.segmentsT,h=this.grid[a][c],b=this.grid[d][c],d=this.grid[d][e],e=this.grid[a][e],f=new THREE.UV(a/this.segmentsR,c/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT),n=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),o=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(h,b,d,e));this.faceVertexUvs[0].push([f,j,n,o])}this.computeCentroids();
  542. this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var c=this.subdivisions;c-- >0;)this.smooth(a)};
  543. THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,i,j){var l=new THREE.Face4(a,b,c,d,null,i.color,i.material);if(f.useOldVertexColors){l.vertexColors=[];for(var n,p,o,r=0;r<4;r++){o=j[r];n=new THREE.Color;n.setRGB(0,0,0);for(var s=0;s<o.length;s++)p=i.vertexColors[o[s]-1],n.r+=p.r,n.g+=p.g,n.b+=p.b;n.r/=o.length;n.g/=o.length;n.b/=o.length;l.vertexColors[r]=n}}h.push(l);(!f.supportUVs||q.length!=0)&&e.push([q[a],q[b],q[c],q[d]])}function b(a,b){return Math.min(a,b)+"_"+Math.max(a,
  544. b)}var d=[],h=[],e=[],f=this,i=a.vertices,d=a.faces,j=i.concat(),n=[],o={},l={},q=[],r,s,p,v,w,x=a.faceVertexUvs[0];r=0;for(s=x.length;r<s;r++){p=0;for(v=x[r].length;p<v;p++)w=d[r]["abcd".charAt(p)],q[w]||(q[w]=x[r][p])}var t;r=0;for(s=d.length;r<s;r++)if(w=d[r],n.push(w.centroid),j.push(new THREE.Vertex(w.centroid)),f.supportUVs&&q.length!=0){t=new THREE.UV;if(w instanceof THREE.Face3)t.u=q[w.a].u+q[w.b].u+q[w.c].u,t.v=q[w.a].v+q[w.b].v+q[w.c].v,t.u/=3,t.v/=3;else if(w instanceof THREE.Face4)t.u=
  545. q[w.a].u+q[w.b].u+q[w.c].u+q[w.d].u,t.v=q[w.a].v+q[w.b].v+q[w.c].v+q[w.d].v,t.u/=4,t.v/=4;q.push(t)}s=function(a){function c(a,b,d){a[b]===void 0&&(a[b]=[]);a[b].push(d)}var d,e,f,h,i={};d=0;for(e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(h=b(f.a,f.b),c(i,h,d),h=b(f.b,f.c),c(i,h,d),h=b(f.c,f.a),c(i,h,d)):f instanceof THREE.Face4&&(h=b(f.a,f.b),c(i,h,d),h=b(f.b,f.c),c(i,h,d),h=b(f.c,f.d),c(i,h,d),h=b(f.d,f.a),c(i,h,d));return i}(a);var B=0,x=i.length,G,P,C={},L={},z=function(a,
  546. b){C[a]===void 0&&(C[a]=[]);C[a].push(b)},y=function(a,b){L[a]===void 0&&(L[a]={});L[a][b]=null};for(r in s){t=s[r];G=r.split("_");P=G[0];G=G[1];z(P,[P,G]);z(G,[P,G]);p=0;for(v=t.length;p<v;p++)w=t[p],y(P,w,r),y(G,w,r);t.length<2&&(l[r]=!0)}for(r in s)if(t=s[r],w=t[0],t=t[1],G=r.split("_"),P=G[0],G=G[1],v=new THREE.Vector3,l[r]?(v.addSelf(i[P].position),v.addSelf(i[G].position),v.multiplyScalar(0.5)):(v.addSelf(n[w]),v.addSelf(n[t]),v.addSelf(i[P].position),v.addSelf(i[G].position),v.multiplyScalar(0.25)),
  547. o[r]=x+d.length+B,j.push(new THREE.Vertex(v)),B++,f.supportUVs&&q.length!=0)t=new THREE.UV,t.u=q[P].u+q[G].u,t.v=q[P].v+q[G].v,t.u/=2,t.v/=2,q.push(t);var F,O;G=["123","12","2","23"];v=["123","23","3","31"];var z=["123","31","1","12"],y=["1234","12","2","23"],U=["1234","23","3","34"],ea=["1234","34","4","41"],N=["1234","41","1","12"];r=0;for(s=n.length;r<s;r++)w=d[r],t=x+r,w instanceof THREE.Face3?(B=b(w.a,w.b),P=b(w.b,w.c),F=b(w.c,w.a),c(t,o[B],w.b,o[P],w,G),c(t,o[P],w.c,o[F],w,v),c(t,o[F],w.a,o[B],
  548. w,z)):w instanceof THREE.Face4?(B=b(w.a,w.b),P=b(w.b,w.c),F=b(w.c,w.d),O=b(w.d,w.a),c(t,o[B],w.b,o[P],w,y),c(t,o[P],w.c,o[F],w,U),c(t,o[F],w.d,o[O],w,ea),c(t,o[O],w.a,o[B],w,N)):console.log("face should be a face!",w);d=j;j=new THREE.Vector3;o=new THREE.Vector3;r=0;for(s=i.length;r<s;r++)if(C[r]!==void 0){j.set(0,0,0);o.set(0,0,0);w=new THREE.Vector3(0,0,0);t=0;for(p in L[r])j.addSelf(n[p]),t++;B=0;x=C[r].length;for(p=0;p<x;p++)l[b(C[r][p][0],C[r][p][1])]&&B++;if(B!=2){j.divideScalar(t);for(p=0;p<
  549. x;p++)t=C[r][p],t=i[t[0]].position.clone().addSelf(i[t[1]].position).divideScalar(2),o.addSelf(t);o.divideScalar(x);w.addSelf(i[r].position);w.multiplyScalar(x-3);w.addSelf(j);w.addSelf(o.multiplyScalar(2));w.divideScalar(x);d[r].position=w}}a.vertices=d;a.faces=h;a.faceVertexUvs[0]=e;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
  550. THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
  551. THREE.Loader.prototype={constructor:THREE.Loader,addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/
  552. 1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.length<1?"":a.join("/")+"/"},initMaterials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(c[d],b)},hasNormals:function(a){var c,b,d=a.materials.length;for(b=0;b<d;b++)if(c=a.materials[b],c instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,c){function b(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==
  553. a}function d(a,c){var d=new Image;d.onload=function(){if(!b(this.width)||!b(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),d=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));a.image.width=c;a.image.height=d;a.image.getContext("2d").drawImage(this,0,0,c,d)}else a.image=this;a.needsUpdate=!0};d.src=c}function h(a,b,e,f,h,i){var j=document.createElement("canvas");a[b]=new THREE.Texture(j);a[b].sourceFile=e;if(f){a[b].repeat.set(f[0],f[1]);if(f[0]!=1)a[b].wrapS=THREE.RepeatWrapping;
  554. if(f[1]!=1)a[b].wrapT=THREE.RepeatWrapping}h&&a[b].offset.set(h[0],h[1]);if(i){f={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(f[i[0]]!==void 0)a[b].wrapS=f[i[0]];if(f[i[1]]!==void 0)a[b].wrapT=f[i[1]]}d(a[b],c+"/"+e)}function e(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var f,i,j;i="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?i="MeshPhongMaterial":a.shading=="Basic"&&(i="MeshBasicMaterial"));
  555. if(a.blending)if(a.blending=="Additive")f.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")f.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")f.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)f.transparent=a.transparent;if(a.depthTest!==void 0)f.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")f.vertexColors=THREE.FaceColors;else if(a.vertexColors)f.vertexColors=THREE.VertexColors;if(a.colorDiffuse)f.color=e(a.colorDiffuse);
  556. else if(a.DbgColor)f.color=a.DbgColor;if(a.colorSpecular)f.specular=e(a.colorSpecular);if(a.colorAmbient)f.ambient=e(a.colorAmbient);if(a.transparency)f.opacity=a.transparency;if(a.specularCoef)f.shininess=a.specularCoef;a.mapDiffuse&&c&&h(f,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&c&&h(f,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&c&&h(f,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);
  557. a.mapSpecular&&c&&h(f,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var n=THREE.ShaderUtils.lib.normal,o=THREE.UniformsUtils.clone(n.uniforms),l=f.color;i=f.specular;j=f.ambient;var q=f.shininess;o.tNormal.texture=f.normalMap;if(a.mapNormalFactor)o.uNormalScale.value=a.mapNormalFactor;if(f.map)o.tDiffuse.texture=f.map,o.enableDiffuse.value=!0;if(f.specularMap)o.tSpecular.texture=f.specularMap,o.enableSpecular.value=!0;if(f.lightMap)o.tAO.texture=
  558. f.lightMap,o.enableAO.value=!0;o.uDiffuseColor.value.setHex(l);o.uSpecularColor.value.setHex(i);o.uAmbientColor.value.setHex(j);o.uShininess.value=q;if(f.opacity)o.uOpacity.value=f.opacity;f=new THREE.ShaderMaterial({fragmentShader:n.fragmentShader,vertexShader:n.vertexShader,uniforms:o,lights:!0,fog:!0})}else f=new THREE[i](f);return f}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
  559. THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
  560. THREE.BinaryLoader.prototype.load=function(a,c,b,d){if(a instanceof Object){console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath ).");var h=a,a=h.model,c=h.callback,b=h.texture_path,d=h.bin_path}var b=b?b:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),h=Date.now(),a=new Worker(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(a){THREE.BinaryLoader.prototype.loadAjaxBuffers(a.data.buffers,a.data.materials,
  561. c,d,b,e)};a.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);a.preventDefault()};a.postMessage(h)};
  562. THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,c,b,d,h,e){var f=new XMLHttpRequest,i=d+"/"+a,j=0;f.onreadystatechange=function(){f.readyState==4?f.status==200||f.status==0?THREE.BinaryLoader.prototype.createBinModel(f.responseText,b,h,c):alert("Couldn't load ["+i+"] ["+f.status+"]"):f.readyState==3?e&&(j==0&&(j=f.getResponseHeader("Content-Length")),e({total:j,loaded:f.responseText.length})):f.readyState==2&&(j=f.getResponseHeader("Content-Length"))};f.open("GET",i,!0);f.overrideMimeType("text/plain; charset=x-user-defined");
  563. f.setRequestHeader("Content-Type","text/plain");f.send(null)};
  564. THREE.BinaryLoader.prototype.createBinModel=function(a,c,b,d){var h=function(b){function c(a,b){var d=o(a,b),e=o(a,b+1),f=o(a,b+2),h=o(a,b+3),i=(h<<1&255|f>>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&i==-127)return 0;return(1-2*(h>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,i)}function h(a,b){var c=o(a,b),d=o(a,b+1),e=o(a,b+2);return(o(a,b+3)<<24)+(e<<16)+(d<<8)+c}function j(a,b){var c=o(a,b);return(o(a,b+1)<<8)+c}function n(a,b){var c=o(a,b);return c>127?c-256:c}function o(a,b){return a.charCodeAt(b)&255}function l(b){var c,
  565. d,e;c=h(a,b);d=h(a,b+P);e=h(a,b+C);b=j(a,b+L);w.faces.push(new THREE.Face3(c,d,e,null,null,b))}function q(b){var c,d,e,f,k,l,n;c=h(a,b);d=h(a,b+P);e=h(a,b+C);f=j(a,b+L);k=h(a,b+z);l=h(a,b+y);n=h(a,b+F);var b=B[l*3],p=B[l*3+1];l=B[l*3+2];var o=B[n*3],r=B[n*3+1];n=B[n*3+2];w.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(B[k*3],B[k*3+1],B[k*3+2]),new THREE.Vector3(b,p,l),new THREE.Vector3(o,r,n)],null,f))}function r(b){var c,d,e,f;c=h(a,b);d=h(a,b+O);e=h(a,b+U);f=h(a,b+ea);b=j(a,b+N);w.faces.push(new THREE.Face4(c,
  566. d,e,f,null,null,b))}function s(b){var c,d,e,f,l,n,p,o,r;c=h(a,b);d=h(a,b+O);e=h(a,b+U);f=h(a,b+ea);l=j(a,b+N);n=h(a,b+R);p=h(a,b+k);o=h(a,b+ga);r=h(a,b+ja);var b=B[p*3],q=B[p*3+1];p=B[p*3+2];var S=B[o*3],I=B[o*3+1];o=B[o*3+2];var J=B[r*3],s=B[r*3+1];r=B[r*3+2];w.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(B[n*3],B[n*3+1],B[n*3+2]),new THREE.Vector3(b,q,p),new THREE.Vector3(S,I,o),new THREE.Vector3(J,s,r)],null,l))}function p(b){var c,d,e,f;c=h(a,b);d=h(a,b+H);e=h(a,b+D);b=G[c*2];f=G[c*2+
  567. 1];c=G[d*2];var j=w.faceVertexUvs[0];d=G[d*2+1];var k=G[e*2];e=G[e*2+1];var l=[];l.push(new THREE.UV(b,f));l.push(new THREE.UV(c,d));l.push(new THREE.UV(k,e));j.push(l)}function v(b){var c,d,e,f,j,k;c=h(a,b);d=h(a,b+T);e=h(a,b+$);f=h(a,b+Q);b=G[c*2];j=G[c*2+1];c=G[d*2];k=G[d*2+1];d=G[e*2];var l=w.faceVertexUvs[0];e=G[e*2+1];var n=G[f*2];f=G[f*2+1];var p=[];p.push(new THREE.UV(b,j));p.push(new THREE.UV(c,k));p.push(new THREE.UV(d,e));p.push(new THREE.UV(n,f));l.push(p)}var w=this,x=0,t,B=[],G=[],P,
  568. C,L,z,y,F,O,U,ea,N,R,k,ga,ja,H,D,T,$,Q,ia,ba,Z,ca,da,X;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(w,d,b);t={signature:a.substr(x,8),header_bytes:o(a,x+8),vertex_coordinate_bytes:o(a,x+9),normal_coordinate_bytes:o(a,x+10),uv_coordinate_bytes:o(a,x+11),vertex_index_bytes:o(a,x+12),normal_index_bytes:o(a,x+13),uv_index_bytes:o(a,x+14),material_index_bytes:o(a,x+15),nvertices:h(a,x+16),nnormals:h(a,x+16+4),nuvs:h(a,x+16+8),ntri_flat:h(a,x+16+12),ntri_smooth:h(a,x+16+16),ntri_flat_uv:h(a,
  569. x+16+20),ntri_smooth_uv:h(a,x+16+24),nquad_flat:h(a,x+16+28),nquad_smooth:h(a,x+16+32),nquad_flat_uv:h(a,x+16+36),nquad_smooth_uv:h(a,x+16+40)};x+=t.header_bytes;P=t.vertex_index_bytes;C=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;z=t.vertex_index_bytes*3+t.material_index_bytes;y=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;O=t.vertex_index_bytes;U=t.vertex_index_bytes*2;ea=t.vertex_index_bytes*3;N=t.vertex_index_bytes*
  570. 4;R=t.vertex_index_bytes*4+t.material_index_bytes;k=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;ga=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;ja=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;H=t.uv_index_bytes;D=t.uv_index_bytes*2;T=t.uv_index_bytes;$=t.uv_index_bytes*2;Q=t.uv_index_bytes*3;b=t.vertex_index_bytes*3+t.material_index_bytes;X=t.vertex_index_bytes*4+t.material_index_bytes;ia=t.ntri_flat*b;ba=t.ntri_smooth*(b+t.normal_index_bytes*
  571. 3);Z=t.ntri_flat_uv*(b+t.uv_index_bytes*3);ca=t.ntri_smooth_uv*(b+t.normal_index_bytes*3+t.uv_index_bytes*3);da=t.nquad_flat*X;b=t.nquad_smooth*(X+t.normal_index_bytes*4);X=t.nquad_flat_uv*(X+t.uv_index_bytes*4);x+=function(b){for(var d,e,h,i=t.vertex_coordinate_bytes*3,j=b+t.nvertices*i;b<j;b+=i)d=c(a,b),e=c(a,b+t.vertex_coordinate_bytes),h=c(a,b+t.vertex_coordinate_bytes*2),w.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,h)));return t.nvertices*i}(x);x+=function(b){for(var c,d,e,f=t.normal_coordinate_bytes*
  572. 3,h=b+t.nnormals*f;b<h;b+=f)c=n(a,b),d=n(a,b+t.normal_coordinate_bytes),e=n(a,b+t.normal_coordinate_bytes*2),B.push(c/127,d/127,e/127);return t.nnormals*f}(x);x+=function(b){for(var d,e,h=t.uv_coordinate_bytes*2,i=b+t.nuvs*h;b<i;b+=h)d=c(a,b),e=c(a,b+t.uv_coordinate_bytes),G.push(d,e);return t.nuvs*h}(x);ia=x+ia;ba=ia+ba;Z=ba+Z;ca=Z+ca;da=ca+da;b=da+b;X=b+X;(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes,d=c+t.uv_index_bytes*3,e=a+t.ntri_flat_uv*d;for(b=a;b<e;b+=d)l(b),p(b+c);return e-
  573. a})(ba);(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,d=c+t.uv_index_bytes*3,e=a+t.ntri_smooth_uv*d;for(b=a;b<e;b+=d)q(b),p(b+c);return e-a})(Z);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes,d=c+t.uv_index_bytes*4,e=a+t.nquad_flat_uv*d;for(b=a;b<e;b+=d)r(b),v(b+c);return e-a})(b);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,d=c+t.uv_index_bytes*4,e=a+t.nquad_smooth_uv*d;for(b=a;b<e;b+=d)s(b),
  574. v(b+c);return e-a})(X);(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes,d=a+t.ntri_flat*c;for(b=a;b<d;b+=c)l(b);return d-a})(x);(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,d=a+t.ntri_smooth*c;for(b=a;b<d;b+=c)q(b);return d-a})(ia);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes,d=a+t.nquad_flat*c;for(b=a;b<d;b+=c)r(b);return d-a})(ca);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*
  575. 4,d=a+t.nquad_smooth*c;for(b=a;b<d;b+=c)s(b);return d-a})(da);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h(b))};
  576. THREE.ColladaLoader=function(){function a(a,d,h){ba=a;d=d||da;h!==void 0&&(a=h.split("/"),a.pop(),ua=a.length<1?"":a.join("/")+"/");E=c("//dae:library_images/dae:image",f,"image");la=c("//dae:library_materials/dae:material",L,"material");pa=c("//dae:library_effects/dae:effect",U,"effect");fa=c("//dae:library_geometries/dae:geometry",v,"geometry");aa=c("//dae:library_controllers/dae:controller",i,"controller");K=c("//dae:library_animations/dae:animation",N,"animation");qa=c(".//dae:library_visual_scenes/dae:visual_scene",
  577. o,"visual_scene");ta=[];wa=[];(a=ba.evaluate(".//dae:scene/dae:instance_visual_scene",ba,ja,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),ca=qa[a]):ca=null;Z=new THREE.Object3D;for(a=0;a<ca.nodes.length;a++)Z.add(e(ca.nodes[a]));b();for(var j in K);j={scene:Z,morphs:ta,skins:wa,dae:{images:E,materials:la,effects:pa,geometries:fa,controllers:aa,animations:K,visualScenes:qa,scene:ca}};d&&d(j);return j}function c(a,b,c){for(var a=ba.evaluate(a,
  578. ba,ja,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(e.id.length==0)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function b(){var a=1E6,b=-a,c=0,d;for(d in K)for(var e=K[d],f=0;f<e.sampler.length;f++){var h=e.sampler[f];h.create();a=Math.min(a,h.startTime);b=Math.max(b,h.endTime);c=Math.max(c,h.input.length)}return{start:a,end:b,frames:c}}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=
  579. a.channels[0].sampler.output[c];f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function h(a,c,e){var f=aa[c.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!c.skeleton||!c.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var h=b(),c=ca.getChildById(c.skeleton[0],!0)||ca.getChildBySid(c.skeleton[0],!0),i,j,k,l,n=new THREE.Vector3,
  580. p;for(i=0;i<a.vertices.length;i++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[i].position);for(e=0;e<h.frames;e++){var o=[],r=[];for(i=0;i<a.vertices.length;i++)r.push(new THREE.Vertex(new THREE.Vector3));d(c,o,e);i=o;j=f.skin;for(l=0;l<i.length;l++)if(k=i[l],p=-1,k.type=="JOINT"){for(var q=0;q<j.joints.length;q++)if(k.sid==j.joints[q]){p=q;break}if(p>=0){q=j.invBindMatrices[p];k.invBindMatrix=q;k.skinningMatrix=new THREE.Matrix4;k.skinningMatrix.multiply(k.world,q);k.weights=[];for(q=0;q<j.weights.length;q++)for(var s=
  581. 0;s<j.weights[q].length;s++){var v=j.weights[q][s];v.joint==p&&k.weights.push(v)}}else throw"ColladaLoader: Could not find joint '"+k.sid+"'.";}for(i=0;i<o.length;i++)if(o[i].type=="JOINT")for(j=0;j<o[i].weights.length;j++)k=o[i].weights[j],l=k.index,k=k.weight,p=a.vertices[l],l=r[l],n.x=p.position.x,n.y=p.position.y,n.z=p.position.z,o[i].skinningMatrix.multiplyVector3(n),l.position.x+=n.x*k,l.position.y+=n.y*k,l.position.z+=n.z*k;a.morphTargets.push({name:"target_"+e,vertices:r})}}}function e(a){var b=
  582. new THREE.Object3D,c,d,f,i;for(f=0;f<a.controllers.length;f++){var j=aa[a.controllers[f].url];switch(j.type){case "skin":if(fa[j.skin.source]){var k=new p;k.url=j.skin.source;k.instance_material=a.controllers[f].instance_material;a.geometries.push(k);c=a.controllers[f]}else if(aa[j.skin.source]&&(d=j=aa[j.skin.source],j.morph&&fa[j.morph.source]))k=new p,k.url=j.morph.source,k.instance_material=a.controllers[f].instance_material,a.geometries.push(k);break;case "morph":if(fa[j.morph.source])k=new p,
  583. k.url=j.morph.source,k.instance_material=a.controllers[f].instance_material,a.geometries.push(k),d=a.controllers[f];console.log("ColladaLoader: Morph-controller partially supported.")}}for(f=0;f<a.geometries.length;f++){var j=a.geometries[f],k=j.instance_material,j=fa[j.url],l={},n=0,o;if(j&&j.mesh&&j.mesh.primitives){if(b.name.length==0)b.name=j.id;if(k)for(i=0;i<k.length;i++){o=k[i];var q=pa[la[o.target].instance_effect.url].shader;q.material.opacity=!q.material.opacity?1:q.material.opacity;o=l[o.symbol]=
  584. q.material;n++}k=o||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});j=j.mesh.geometry3js;if(n>1){k=new THREE.MeshFaceMaterial;for(i=0;i<j.faces.length;i++)n=j.faces[i],n.materials=[l[n.daeMaterial]]}if(c!==void 0)h(j,c),k.morphTargets=!0,k=new THREE.SkinnedMesh(j,k),k.skeleton=c.skeleton,k.skinController=aa[c.url],k.skinInstanceController=c,k.name="skin_"+wa.length,wa.push(k);else if(d!==void 0){i=j;l=d instanceof r?aa[d.url]:d;if(!l||!l.morph)console.log("could not find morph controller!");
  585. else{l=l.morph;for(n=0;n<l.targets.length;n++)if(q=fa[l.targets[n]],q.mesh&&q.mesh.primitives&&q.mesh.primitives.length)q=q.mesh.primitives[0].geometry,q.vertices.length===i.vertices.length&&i.morphTargets.push({name:"target_1",vertices:q.vertices});i.morphTargets.push({name:"target_Z",vertices:i.vertices})}k.morphTargets=!0;k=new THREE.Mesh(j,k);k.name="morph_"+ta.length;ta.push(k)}else k=new THREE.Mesh(j,k);a.geometries.length>1?b.add(k):b=k}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,
  586. b.scale);for(f=0;f<a.nodes.length;f++)b.add(e(a.nodes[f],a));return b}function f(){this.init_from=this.id=""}function i(){this.type=this.name=this.id="";this.morph=this.skin=null}function j(){this.weights=this.targets=this.source=this.method=null}function n(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function o(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function l(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=
  587. [];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function q(){this.type=this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function r(){this.url="";this.skeleton=[];this.instance_material=[]}function s(){this.target=this.symbol=""}function p(){this.url="";this.instance_material=[]}function v(){this.id="";this.mesh=null}function w(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function x(){}function t(){this.material="";this.count=
  588. 0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function B(){this.source="";this.stride=this.count=0;this.params=[]}function G(){this.input={}}function P(){this.semantic="";this.offset=0;this.source="";this.set=0}function C(a){this.id=a;this.type=null}function L(){this.name=this.id="";this.instance_effect=null}function z(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function y(a,
  589. b){this.type=a;this.effect=b;this.material=null}function F(a){this.effect=a;this.format=this.init_from=null}function O(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function U(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function ea(){this.url=""}function N(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function R(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=
  590. this.dotSyntax=this.sid=null}function k(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ga(a){var b=a.getAttribute("id");if(X[b]!=void 0)return X[b];X[b]=(new C(b)).parse(a);return X[b]}function ja(a){if(a=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function H(a){for(var a=T(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function D(a){for(var a=T(a),b=[],c=0;c<
  591. a.length;c++)b.push(parseInt(a[c],10));return b}function T(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function $(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function Q(a,b){if(a===void 0){for(var c="0.";c.length<b+2;)c+="0";return c}b=b||2;c=a.toString().split(".");for(c[1]=c.length>1?c[1].substr(0,b):"0";c[1].length<b;)c[1]+="0";return c.join(".")}function ia(a,b){var c="";c+=Q(a.x,b)+",";c+=Q(a.y,b)+",";c+=Q(a.z,b);return c}var ba=null,Z=null,ca,da=null,
  592. X={},E={},K={},aa={},fa={},la={},pa={},qa,ua,ta,wa,za=THREE.SmoothShading;f.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="init_from")this.init_from=c.textContent}return this};i.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new n).parse(c);this.type=
  593. c.nodeName;break;case "morph":this.morph=(new j).parse(c),this.type=c.nodeName}}return this};j.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,"");for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(e.nodeType==1)switch(e.nodeName){case "source":e=(new C).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=
  594. e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};j.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":b.push((new P).parse(d))}}return b};n.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "bind_shape_matrix":f=
  595. H(f.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9],f[10],f[11],f[12],f[13],f[14],f[15]);break;case "source":f=(new C).parse(f);b[f.id]=f;break;case "joints":c=f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,b);return this};n.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "input":var d=
  596. (new P).parse(d),e=b[d.source];if(d.semantic=="JOINT")this.joints=e.read();else if(d.semantic=="INV_BIND_MATRIX")this.invBindMatrices=e.read()}}};n.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var h=a.childNodes[f];if(h.nodeType==1)switch(h.nodeName){case "input":e.push((new P).parse(h));break;case "v":c=D(h.textContent);break;case "vcount":d=D(h.textContent)}}for(f=h=0;f<d.length;f++){for(var i=d[f],j=[],k=0;k<i;k++){for(var l={},n=0;n<e.length;n++){var p=
  597. e[n],o=c[h+p.offset];switch(p.semantic){case "JOINT":l.joint=o;break;case "WEIGHT":l.weight=b[p.source].data[o]}}j.push(l);h+=e.length}for(k=0;k<j.length;k++)j[k].index=f;this.weights.push(j)}};o.prototype.getChildById=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};o.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};o.prototype.parse=function(a){this.id=
  598. a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new l).parse(c))}}return this};l.prototype.getChannelForTransform=function(a){for(var b=0;b<this.channels.length;b++){var c=this.channels[b],d=c.target.split("/");d.shift();var e=d.shift(),f=e.indexOf(".")>=0,h=e.indexOf("(")>=0,i;if(f)d=e.split("."),e=d.shift(),d.shift();else if(h){i=e.split("(");e=i.shift();
  599. for(d=0;d<i.length;d++)i[d]=parseInt(i[d].replace(/\)/,""))}if(e==a)return c.info={sid:e,dotSyntax:f,arrSyntax:h,arrIndices:i},c}return null};l.prototype.getChildById=function(a,b){if(this.id==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};l.prototype.getChildBySid=function(a,b){if(this.sid==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};l.prototype.getTransformBySid=
  600. function(a){for(var b=0;b<this.transforms.length;b++)if(this.transforms[b].sid==a)return this.transforms[b];return null};l.prototype.parse=function(a){var b;this.id=a.getAttribute("id");this.sid=a.getAttribute("sid");this.name=a.getAttribute("name");this.type=a.getAttribute("type");this.type=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],b.nodeType==
  601. 1)switch(b.nodeName){case "node":this.nodes.push((new l).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new r).parse(b));break;case "instance_geometry":this.geometries.push((new p).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,"");(b=ba.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",ba,ja,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new l).parse(b));break;
  602. case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new q).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in K)for(var e=K[d],f=0;f<e.channel.length;f++){var h=e.channel[f],i=e.sampler[f];d=h.target.split("/")[0];if(d==this.id)i.create(),h.sampler=i,c=Math.min(c,i.startTime),b=Math.max(b,i.endTime),a.push(h)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=
  603. 1E7;for(a=0;a<this.channels.length;a++){c=this.channels[a].sampler;for(b=0;b<c.input.length-1;b++)d=Math.min(d,c.input[b+1]-c.input[b])}c=[];for(a=this.startTime;a<this.endTime;a+=d){b=a;for(var e={},j=f=void 0,f=0;f<this.channels.length;f++)j=this.channels[f],e[j.sid]=j;h=new THREE.Matrix4;for(f=0;f<this.transforms.length;f++)if(i=this.transforms[f],j=e[i.sid],j!==void 0){for(var k=j.sampler,n,j=0;j<k.input.length-1;j++)if(k.input[j+1]>b){n=k.output[j];break}h=n!==void 0?n instanceof THREE.Matrix4?
  604. h.multiply(h,n):h.multiply(h,i.matrix):h.multiply(h,i.matrix)}else h=h.multiply(h,i.matrix);b=h;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};l.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.matrix.multiply(this.matrix,this.transforms[a].matrix)};q.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=H(a.textContent);this.updateMatrix();return this};
  605. q.prototype.updateMatrix=function(){var a=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],this.data[1],this.data[2],this.data[3],this.data[4],this.data[5],this.data[6],this.data[7],this.data[8],this.data[9],this.data[10],this.data[11],this.data[12],this.data[13],this.data[14],this.data[15]);break;case "translate":this.matrix.setTranslation(this.data[0],this.data[1],this.data[2]);break;case "rotate":a=this.data[3]*(Math.PI/180);this.matrix.setRotationAxis(new THREE.Vector3(this.data[0],
  606. this.data[1],this.data[2]),a);break;case "scale":this.matrix.setScale(this.data[0],this.data[1],this.data[2])}return this.matrix};r.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=ba.evaluate(".//dae:instance_material",c,ja,XPathResult.ORDERED_NODE_ITERATOR_TYPE,
  607. null))for(var d=c.iterateNext();d;)this.instance_material.push((new s).parse(d)),d=c.iterateNext()}}return this};s.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,"");return this};p.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1&&c.nodeName=="bind_material"){if(a=ba.evaluate(".//dae:instance_material",
  608. c,ja,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new s).parse(b)),b=a.iterateNext();break}}return this};v.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=(new w(this)).parse(c)}}return this};w.prototype.parse=function(a){function b(a,c){var d=ia(a.position);e[d]===void 0&&(e[d]={v:a,index:c});return e[d]}this.primitives=[];var c;for(c=
  609. 0;c<a.childNodes.length;c++){var d=a.childNodes[c];switch(d.nodeName){case "source":ga(d);break;case "vertices":this.vertices=(new G).parse(d);break;case "triangles":this.primitives.push((new t).parse(d));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new x).parse(d))}}var e={};this.geometry3js=new THREE.Geometry;d=X[this.vertices.input.POSITION.source].data;for(a=c=0;c<d.length;c+=3,a++){var f=new THREE.Vertex(new THREE.Vector3(d[c],d[c+
  610. 1],d[c+2]));b(f,a);this.geometry3js.vertices.push(f)}for(c=0;c<this.primitives.length;c++)a=this.primitives[c],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js,e);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};w.prototype.handlePrimitive=function(a,b,c){var d=0,e,f,h=a.p,i=a.inputs,j,k,l,n,p=0,o=3,r=[];for(e=0;e<i.length;e++)switch(j=i[e],j.semantic){case "TEXCOORD":r.push(j.set)}for(;d<
  611. h.length;){var q=[],s=[],v={},t=[];a.vcount&&(o=a.vcount[p++]);for(e=0;e<o;e++)for(f=0;f<i.length;f++)switch(j=i[f],n=X[j.source],k=h[d+e*i.length+j.offset],l=n.accessor.params.length,l*=k,j.semantic){case "VERTEX":j=ia(b.vertices[k].position);q.push(c[j].index);break;case "NORMAL":s.push(new THREE.Vector3(n.data[l],n.data[l+1],n.data[l+2]));break;case "TEXCOORD":v[j.set]===void 0&&(v[j.set]=[]);v[j.set].push(new THREE.UV(n.data[l],n.data[l+1]));break;case "COLOR":t.push((new THREE.Color).setRGB(n.data[l],
  612. n.data[l+1],n.data[l+2]))}var w;o==3?w=new THREE.Face3(q[0],q[1],q[2],[s[0],s[1],s[2]],t.length?t:new THREE.Color):o==4&&(w=new THREE.Face4(q[0],q[1],q[2],q[3],[s[0],s[1],s[2],s[3]],t.length?t:new THREE.Color));w.daeMaterial=a.material;b.faces.push(w);for(f=0;f<r.length;f++)e=v[r[f]],b.faceVertexUvs[f].push([e[0],e[1],e[2]]);d+=i.length*o}};x.prototype=new t;x.prototype.constructor=x;t.prototype.setVertices=function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=
  613. a.input.POSITION.source};t.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=$(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new P).parse(a.childNodes[b]));break;case "vcount":this.vcount=D(c.textContent);break;case "p":this.p=D(c.textContent)}}return this};B.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=$(a,"count",0);this.stride=
  614. $(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeName=="param"){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};G.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="input"){var c=(new P).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};P.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,
  615. "");this.set=$(a,"set",-1);this.offset=$(a,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};C.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=T(c.textContent),e=[],f=0;f<d.length;f++)e.push(d[f]=="true"||d[f]=="1"?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=H(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
  616. D(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=T(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if(c.childNodes[d].nodeName=="accessor"){this.accessor=(new B).parse(c.childNodes[d]);break}}}return this};C.prototype.read=function(){var a=[],b=this.accessor.params[0];switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=
  617. this.data.slice(b,b+16),d=new THREE.Matrix4;d.set(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15]);a.push(d)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};L.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if(a.childNodes[b].nodeName=="instance_effect"){this.instance_effect=(new ea).parse(a.childNodes[b]);break}return this};z.prototype.isColor=
  618. function(){return this.texture==null};z.prototype.isTexture=function(){return this.texture!=null};z.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "color":c=H(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord")}}return this};y.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=
  619. a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new z).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=ba.evaluate(".//dae:float",c,ja,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};y.prototype.create=function(){var a=
  620. {},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof z)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=E[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(ua+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=
  621. d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=za;return this.material=new THREE.MeshLambertMaterial(a)};F.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+
  622. c.nodeName)}}return this};O.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};
  623. U.prototype.create=function(){if(this.shader==null)return null};U.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};U.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "surface":this.surface=
  624. (new F(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new O(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};U.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(d.nodeType==1)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};
  625. U.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new y(c.nodeName,this)).parse(c)}}};ea.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};N.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==
  626. 1)switch(c.nodeName){case "source":c=(new C).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new k(this)).parse(c));break;case "channel":this.channel.push((new R(this)).parse(c))}}return this};R.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");b.shift();var a=b.shift(),c=a.indexOf(".")>=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");
  627. a=e.shift();for(b=0;b<e.length;b++)e[b]=parseInt(e[b].replace(/\)/,""))}this.sid=a;this.dotSyntax=c;this.arrSyntax=d;this.arrIndices=e;this.member=f;return this};k.prototype.parse=function(a){this.id=a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new P).parse(c))}}return this};k.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=this.inputs[a],c=this.animation.source[b.source];
  628. switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=0;a<this.input.length;a++)this.startTime=Math.min(this.startTime,this.input[a]),this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-
  629. this.startTime}};return{load:function(b,c){if(document.implementation&&document.implementation.createDocument){document.implementation.createDocument("http://www.collada.org/2005/11/COLLADASchema","COLLADA",null);b+="?rnd="+Math.random();var d=new XMLHttpRequest;d.overrideMimeType&&d.overrideMimeType("text/xml");d.onreadystatechange=function(){if(d.readyState==4&&(d.status==0||d.status==200))da=c,a(d.responseXML,void 0,b)};d.open("GET",b,!0);d.send(null)}else alert("Don't know how to parse XML!")},
  630. parse:a,setPreferredShading:function(a){za=a},applySkin:h,geometries:fa}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
  631. THREE.JSONLoader.prototype.load=function(a,c,b){var d,h=this;if(a instanceof Object)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),d=a,a=d.model,c=d.callback,b=d.texture_path;d=new Worker(a);b=b?b:this.extractUrlbase(a);d.onmessage=function(a){h.createModel(a.data,c,b);h.onLoadComplete()};this.onLoadStart();d.postMessage(Date.now())};
  632. THREE.JSONLoader.prototype.createModel=function(a,c,b){var d=new THREE.Geometry,h=a.scale!==void 0?1/a.scale:1;this.initMaterials(d,a.materials,b);(function(b){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var c,h,j,n,o,l,q,r,s,p,v,w,x,t,B=a.faces;l=a.vertices;var G=a.normals,P=a.colors,C=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&C++;for(c=0;c<C;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];n=0;for(o=l.length;n<o;)q=new THREE.Vertex,q.position.x=l[n++]*b,q.position.y=
  633. l[n++]*b,q.position.z=l[n++]*b,d.vertices.push(q);n=0;for(o=B.length;n<o;){b=B[n++];l=b&1;j=b&2;c=b&4;h=b&8;r=b&16;q=b&32;p=b&64;b&=128;l?(v=new THREE.Face4,v.a=B[n++],v.b=B[n++],v.c=B[n++],v.d=B[n++],l=4):(v=new THREE.Face3,v.a=B[n++],v.b=B[n++],v.c=B[n++],l=3);if(j)j=B[n++],v.materialIndex=j;j=d.faces.length;if(c)for(c=0;c<C;c++)w=a.uvs[c],s=B[n++],t=w[s*2],s=w[s*2+1],d.faceUvs[c][j]=new THREE.UV(t,s);if(h)for(c=0;c<C;c++){w=a.uvs[c];x=[];for(h=0;h<l;h++)s=B[n++],t=w[s*2],s=w[s*2+1],x[h]=new THREE.UV(t,
  634. s);d.faceVertexUvs[c][j]=x}if(r)r=B[n++]*3,h=new THREE.Vector3,h.x=G[r++],h.y=G[r++],h.z=G[r],v.normal=h;if(q)for(c=0;c<l;c++)r=B[n++]*3,h=new THREE.Vector3,h.x=G[r++],h.y=G[r++],h.z=G[r],v.vertexNormals.push(h);if(p)q=B[n++],q=new THREE.Color(P[q]),v.color=q;if(b)for(c=0;c<l;c++)q=B[n++],q=new THREE.Color(P[q]),v.vertexColors.push(q);d.faces.push(v)}}})(h);(function(){var b,c,h,j;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=2)h=a.skinWeights[b],j=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(h,
  635. j,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)h=a.skinIndices[b],j=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(h,j,0,0))}d.bones=a.bones;d.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,h,j,n,o,l,q,r,s;c=0;for(h=a.morphTargets.length;c<h;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];r=d.morphTargets[c].vertices;s=a.morphTargets[c].vertices;j=0;for(n=s.length;j<n;j+=3)o=s[j]*b,l=s[j+1]*
  636. b,q=s[j+2]*b,r.push(new THREE.Vertex(new THREE.Vector3(o,l,q)))}}if(a.morphColors!==void 0){c=0;for(h=a.morphColors.length;c<h;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];n=d.morphColors[c].colors;o=a.morphColors[c].colors;b=0;for(j=o.length;b<j;b+=3)l=new THREE.Color(16755200),l.setRGB(o[b],o[b+1],o[b+2]),n.push(l)}}})(h);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&d.computeTangents();c(d)};
  637. THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
  638. THREE.SceneLoader.prototype={load:function(a,c){var b=this,d=new Worker(a);d.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(a);d.onmessage=function(a){function d(a,b){return b=="relativeToHTML"?a:h+"/"+a}function i(){var a;for(r in N.objects)if(!D.objects[r])if(x=N.objects[r],x.geometry!==void 0){if(y=D.geometries[x.geometry]){a=!1;for($=0;$<x.materials.length;$++)ea=D.materials[x.materials[$]],a=ea instanceof THREE.ShaderMaterial;a&&y.computeTangents();G=x.position;P=x.rotation;C=x.quaternion;
  639. L=x.scale;C=0;ea.length==0&&(ea=new THREE.MeshFaceMaterial);ea.length>1&&(ea=new THREE.MeshFaceMaterial);a=new THREE.Mesh(y,ea);a.name=r;a.position.set(G[0],G[1],G[2]);C?(a.quaternion.set(C[0],C[1],C[2],C[3]),a.useQuaternion=!0):a.rotation.set(P[0],P[1],P[2]);a.scale.set(L[0],L[1],L[2]);a.visible=x.visible;D.scene.add(a);D.objects[r]=a;if(x.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);D.scene.collisions.colliders.push(b)}if(x.castsShadow)b=new THREE.ShadowVolume(y),D.scene.add(b),
  640. b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;x.trigger&&x.trigger.toLowerCase()!="none"&&(b={type:x.trigger,object:x},D.triggers[a.name]=b)}}else G=x.position,P=x.rotation,C=x.quaternion,L=x.scale,C=0,a=new THREE.Object3D,a.name=r,a.position.set(G[0],G[1],G[2]),C?(a.quaternion.set(C[0],C[1],C[2],C[3]),a.useQuaternion=!0):a.rotation.set(P[0],P[1],P[2]),a.scale.set(L[0],L[1],L[2]),a.visible=x.visible!==void 0?x.visible:!1,D.scene.add(a),D.objects[r]=a,D.empties[r]=a,x.trigger&&x.trigger.toLowerCase()!=
  641. "none"&&(b={type:x.trigger,object:x},D.triggers[a.name]=b)}function j(a){return function(c){D.geometries[a]=c;i();k-=1;b.onLoadComplete();o()}}function n(a){return function(b){D.geometries[a]=b}}function o(){b.callbackProgress({totalModels:ja,totalTextures:H,loadedModels:ja-k,loadedTextures:H-ga},D);b.onLoadProgress();k==0&&ga==0&&c(D)}var l,q,r,s,p,v,w,x,t,B,G,P,C,L,z,y,F,O,U,ea,N,R,k,ga,ja,H,D;N=a.data;U=new THREE.BinaryLoader;R=new THREE.JSONLoader;ga=k=0;D={scene:new THREE.Scene,geometries:{},
  642. materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(r in N.objects)if(x=N.objects[r],x.meshCollider){a=!0;break}if(a)D.scene.collisions=new THREE.CollisionSystem;if(N.transform){a=N.transform.position;t=N.transform.rotation;var T=N.transform.scale;a&&D.scene.position.set(a[0],a[1],a[2]);t&&D.scene.rotation.set(t[0],t[1],t[2]);T&&D.scene.scale.set(T[0],T[1],T[2]);(a||t||T)&&D.scene.updateMatrix()}a=function(){ga-=1;o();b.onLoadComplete()};for(p in N.cameras)t=
  643. N.cameras[p],t.type=="perspective"?F=new THREE.PerspectiveCamera(t.fov,t.aspect,t.near,t.far):t.type=="ortho"&&(F=new THREE.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far)),G=t.position,t=t.target,F.position.set(G[0],G[1],G[2]),F.target=new THREE.Vector3(t[0],t[1],t[2]),D.cameras[p]=F;for(s in N.lights)t=N.lights[s],p=t.color!==void 0?t.color:16777215,F=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(G=t.direction,B=new THREE.DirectionalLight(p,F),B.position.set(G[0],G[1],
  644. G[2]),B.position.normalize()):t.type=="point"?(G=t.position,B=t.distance,B=new THREE.PointLight(p,F,B),B.position.set(G[0],G[1],G[2])):t.type=="ambient"&&(B=new THREE.AmbientLight(p)),D.scene.add(B),D.lights[s]=B;for(v in N.fogs)s=N.fogs[v],s.type=="linear"?O=new THREE.Fog(0,s.near,s.far):s.type=="exp2"&&(O=new THREE.FogExp2(0,s.density)),t=s.color,O.color.setRGB(t[0],t[1],t[2]),D.fogs[v]=O;if(D.cameras&&N.defaults.camera)D.currentCamera=D.cameras[N.defaults.camera];if(D.fogs&&N.defaults.fog)D.scene.fog=
  645. D.fogs[N.defaults.fog];t=N.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(t[0],t[1],t[2]);D.bgColorAlpha=N.defaults.bgalpha;for(l in N.geometries)if(v=N.geometries[l],v.type=="bin_mesh"||v.type=="ascii_mesh")k+=1,b.onLoadStart();ja=k;for(l in N.geometries)v=N.geometries[l],v.type=="cube"?(y=new THREE.CubeGeometry(v.width,v.height,v.depth,v.segmentsWidth,v.segmentsHeight,v.segmentsDepth,null,v.flipped,v.sides),D.geometries[l]=y):v.type=="plane"?(y=new THREE.PlaneGeometry(v.width,v.height,
  646. v.segmentsWidth,v.segmentsHeight),D.geometries[l]=y):v.type=="sphere"?(y=new THREE.SphereGeometry(v.radius,v.segmentsWidth,v.segmentsHeight),D.geometries[l]=y):v.type=="cylinder"?(y=new THREE.CylinderGeometry(v.topRad,v.botRad,v.height,v.radSegs,v.heightSegs),D.geometries[l]=y):v.type=="torus"?(y=new THREE.TorusGeometry(v.radius,v.tube,v.segmentsR,v.segmentsT),D.geometries[l]=y):v.type=="icosahedron"?(y=new THREE.IcosahedronGeometry(v.subdivisions),D.geometries[l]=y):v.type=="bin_mesh"?U.load(d(v.url,
  647. N.urlBaseType),j(l)):v.type=="ascii_mesh"?R.load(d(v.url,N.urlBaseType),j(l)):v.type=="embedded_mesh"&&(v=N.embeds[v.id])&&R.createModel(v,n(l),"");for(w in N.textures)if(l=N.textures[w],l.url instanceof Array){ga+=l.url.length;for(U=0;U<l.url.length;U++)b.onLoadStart()}else ga+=1,b.onLoadStart();H=ga;for(w in N.textures){l=N.textures[w];if(l.mapping!=void 0&&THREE[l.mapping]!=void 0)l.mapping=new THREE[l.mapping];if(l.url instanceof Array){U=[];for(var $=0;$<l.url.length;$++)U[$]=d(l.url[$],N.urlBaseType);
  648. U=THREE.ImageUtils.loadTextureCube(U,l.mapping,a)}else{U=THREE.ImageUtils.loadTexture(d(l.url,N.urlBaseType),l.mapping,a);if(THREE[l.minFilter]!=void 0)U.minFilter=THREE[l.minFilter];if(THREE[l.magFilter]!=void 0)U.magFilter=THREE[l.magFilter];if(l.repeat){U.repeat.set(l.repeat[0],l.repeat[1]);if(l.repeat[0]!=1)U.wrapS=THREE.RepeatWrapping;if(l.repeat[1]!=1)U.wrapT=THREE.RepeatWrapping}l.offset&&U.offset.set(l.offset[0],l.offset[1]);if(l.wrap){R={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};
  649. if(R[l.wrap[0]]!==void 0)U.wrapS=R[l.wrap[0]];if(R[l.wrap[1]]!==void 0)U.wrapT=R[l.wrap[1]]}}D.textures[w]=U}for(q in N.materials){w=N.materials[q];for(z in w.parameters)if(z=="envMap"||z=="map"||z=="lightMap")w.parameters[z]=D.textures[w.parameters[z]];else if(z=="shading")w.parameters[z]=w.parameters[z]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(z=="blending")w.parameters[z]=THREE[w.parameters[z]]?THREE[w.parameters[z]]:THREE.NormalBlending;else if(z=="combine")w.parameters[z]=w.parameters[z]==
  650. "MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(z=="vertexColors")if(w.parameters[z]=="face")w.parameters[z]=THREE.FaceColors;else if(w.parameters[z])w.parameters[z]=THREE.VertexColors;if(w.parameters.opacity!==void 0&&w.parameters.opacity<1)w.parameters.transparent=!0;if(w.parameters.normalMap){l=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(l.uniforms);U=w.parameters.color;R=w.parameters.specular;v=w.parameters.ambient;O=w.parameters.shininess;a.tNormal.texture=D.textures[w.parameters.normalMap];
  651. if(w.parameters.normalMapFactor)a.uNormalScale.value=w.parameters.normalMapFactor;if(w.parameters.map)a.tDiffuse.texture=w.parameters.map,a.enableDiffuse.value=!0;if(w.parameters.lightMap)a.tAO.texture=w.parameters.lightMap,a.enableAO.value=!0;if(w.parameters.specularMap)a.tSpecular.texture=D.textures[w.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(U);a.uSpecularColor.value.setHex(R);a.uAmbientColor.value.setHex(v);a.uShininess.value=O;if(w.parameters.opacity)a.uOpacity.value=
  652. w.parameters.opacity;w=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:a,lights:!0,fog:!0})}else w=new THREE[w.type](w.parameters);D.materials[q]=w}i();b.callbackSync(D);o()}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
  653. THREE.UTF8Loader.prototype.load=function(a,c,b){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),b=a,a=b.model,c=b.callback,b={scale:b.scale,offsetX:b.offsetX,offsetY:b.offsetY,offsetZ:b.offsetZ};var d=new XMLHttpRequest,h=b.scale!==void 0?b.scale:1,e=b.offsetX!==void 0?b.offsetX:0,f=b.offsetY!==void 0?b.offsetY:0,i=b.offsetZ!==void 0?b.offsetZ:0;d.onreadystatechange=function(){d.readyState==4?d.status==200||d.status==0?THREE.UTF8Loader.prototype.createModel(d.responseText,
  654. c,h,e,f,i):alert("Couldn't load ["+a+"] ["+d.status+"]"):d.readyState!=3&&d.readyState==2&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var c=a.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,h=0;h<8;h++){for(var e=0,f=0;f<c;++f){var i=a.charCodeAt(f+d);e+=i>>1^-(i&1);b[8*f+h]=e}d+=c}c=a.length-d;e=new Uint16Array(c);for(h=f=0;h<c;h++)i=a.charCodeAt(h+d),e[h]=f-i,i==0&&f++;return[b,e]};
  655. THREE.UTF8Loader.prototype.createModel=function(a,c,b,d,h,e){var f=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var f=THREE.UTF8Loader.prototype.decompressMesh(a),n=[],o=[];(function(a,f,j){for(var n,p,o,w=a.length;j<w;j+=f)n=a[j],p=a[j+1],o=a[j+2],n=n/16383*b,p=p/16383*b,o=o/16383*b,n+=d,p+=h,o+=e,c.vertices.push(new THREE.Vertex(new THREE.Vector3(n,p,o)))})(f[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,o.push(d,1-e)})(f[0],8,3);(function(a,
  656. b,c){for(var d,e,f,h=a.length;c<h;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,n.push(d,e,f)})(f[0],8,5);(function(a){var b,d,e,f,h,j,x,t,B,G=a.length;for(b=0;b<G;b+=3){d=a[b];e=a[b+1];f=a[b+2];h=c;t=d;B=e;j=f;x=d;var P=e,C=f,L=h.materials[0],z=n[P*3],y=n[P*3+1],P=n[P*3+2],F=n[C*3],O=n[C*3+1],C=n[C*3+2];x=new THREE.Vector3(n[x*3],n[x*3+1],n[x*3+2]);P=new THREE.Vector3(z,y,P);C=new THREE.Vector3(F,O,C);h.faces.push(new THREE.Face3(t,B,j,[x,P,C],null,L));h=o[d*2];d=o[d*2+
  657. 1];j=o[e*2];x=o[e*2+1];t=o[f*2];B=o[f*2+1];f=c.faceVertexUvs[0];e=j;j=x;x=[];x.push(new THREE.UV(h,d));x.push(new THREE.UV(e,j));x.push(new THREE.UV(t,B));f.push(x)}})(f[1]);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f)};
  658. THREE.Axes=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var c=new THREE.CylinderGeometry(0,5,25,5,1),b=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));b.rotation.z=-Math.PI/2;this.add(b);b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:16711680}));b.position.x=100;b.rotation.z=-Math.PI/2;this.add(b);b=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(b);
  659. b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:65280}));b.position.y=100;this.add(b);b=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));b.rotation.x=Math.PI/2;this.add(b);b=new THREE.Mesh(c,new THREE.MeshBasicMaterial({color:255}));b.position.z=100;b.rotation.x=Math.PI/2;this.add(b)};THREE.Axes.prototype=new THREE.Object3D;THREE.Axes.prototype.constructor=THREE.Axes;
  660. THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(a){this.isolation=80;this.size=a;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=
  661. 0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,c,h){return a+(c-a)*h};this.VIntX=function(a,c,h,e,f,i,j,n,o,l){f=(f-o)/(l-o);o=this.normal_cache;c[e]=i+f*this.delta;c[e+1]=j;c[e+2]=n;h[e]=this.lerp(o[a],o[a+3],f);h[e+1]=this.lerp(o[a+1],o[a+4],f);h[e+2]=this.lerp(o[a+2],o[a+5],f)};this.VIntY=function(a,c,h,e,f,i,j,n,o,l){f=(f-o)/(l-o);o=this.normal_cache;c[e]=i;c[e+1]=j+f*this.delta;c[e+
  662. 2]=n;c=a+this.yd*3;h[e]=this.lerp(o[a],o[c],f);h[e+1]=this.lerp(o[a+1],o[c+1],f);h[e+2]=this.lerp(o[a+2],o[c+2],f)};this.VIntZ=function(a,c,h,e,f,i,j,n,o,l){f=(f-o)/(l-o);o=this.normal_cache;c[e]=i;c[e+1]=j;c[e+2]=n+f*this.delta;c=a+this.zd*3;h[e]=this.lerp(o[a],o[c],f);h[e+1]=this.lerp(o[a+1],o[c+1],f);h[e+2]=this.lerp(o[a+2],o[c+2],f)};this.compNorm=function(a){var c=a*3;this.normal_cache[c]===0&&(this.normal_cache[c]=this.field[a-1]-this.field[a+1],this.normal_cache[c+1]=this.field[a-this.yd]-
  663. this.field[a+this.yd],this.normal_cache[c+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,c,h,e,f,i){var j=e+1,n=e+this.yd,o=e+this.zd,l=j+this.yd,q=j+this.zd,r=e+this.yd+this.zd,s=j+this.yd+this.zd,p=0,v=this.field[e],w=this.field[j],x=this.field[n],t=this.field[l],B=this.field[o],G=this.field[q],P=this.field[r],C=this.field[s];v<f&&(p|=1);w<f&&(p|=2);x<f&&(p|=8);t<f&&(p|=4);B<f&&(p|=16);G<f&&(p|=32);P<f&&(p|=128);C<f&&(p|=64);var L=THREE.edgeTable[p];if(L===0)return 0;
  664. var z=this.delta,y=a+z,F=c+z,z=h+z;L&1&&(this.compNorm(e),this.compNorm(j),this.VIntX(e*3,this.vlist,this.nlist,0,f,a,c,h,v,w));L&2&&(this.compNorm(j),this.compNorm(l),this.VIntY(j*3,this.vlist,this.nlist,3,f,y,c,h,w,t));L&4&&(this.compNorm(n),this.compNorm(l),this.VIntX(n*3,this.vlist,this.nlist,6,f,a,F,h,x,t));L&8&&(this.compNorm(e),this.compNorm(n),this.VIntY(e*3,this.vlist,this.nlist,9,f,a,c,h,v,x));L&16&&(this.compNorm(o),this.compNorm(q),this.VIntX(o*3,this.vlist,this.nlist,12,f,a,c,z,B,G));
  665. L&32&&(this.compNorm(q),this.compNorm(s),this.VIntY(q*3,this.vlist,this.nlist,15,f,y,c,z,G,C));L&64&&(this.compNorm(r),this.compNorm(s),this.VIntX(r*3,this.vlist,this.nlist,18,f,a,F,z,P,C));L&128&&(this.compNorm(o),this.compNorm(r),this.VIntY(o*3,this.vlist,this.nlist,21,f,a,c,z,B,P));L&256&&(this.compNorm(e),this.compNorm(o),this.VIntZ(e*3,this.vlist,this.nlist,24,f,a,c,h,v,B));L&512&&(this.compNorm(j),this.compNorm(q),this.VIntZ(j*3,this.vlist,this.nlist,27,f,y,c,h,w,G));L&1024&&(this.compNorm(l),
  666. this.compNorm(s),this.VIntZ(l*3,this.vlist,this.nlist,30,f,y,F,h,t,C));L&2048&&(this.compNorm(n),this.compNorm(r),this.VIntZ(n*3,this.vlist,this.nlist,33,f,a,F,h,x,P));p<<=4;for(f=e=0;THREE.triTable[p+f]!=-1;)a=p+f,c=a+1,h=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[c],3*THREE.triTable[h],i),f+=3,e++;return e};this.posnormtriv=function(a,c,h,e,f,i){var j=this.count*3;this.positionArray[j]=a[h];this.positionArray[j+1]=a[h+1];this.positionArray[j+2]=a[h+2];this.positionArray[j+
  667. 3]=a[e];this.positionArray[j+4]=a[e+1];this.positionArray[j+5]=a[e+2];this.positionArray[j+6]=a[f];this.positionArray[j+7]=a[f+1];this.positionArray[j+8]=a[f+2];this.normalArray[j]=c[h];this.normalArray[j+1]=c[h+1];this.normalArray[j+2]=c[h+2];this.normalArray[j+3]=c[e];this.normalArray[j+4]=c[e+1];this.normalArray[j+5]=c[e+2];this.normalArray[j+6]=c[f];this.normalArray[j+7]=c[f+1];this.normalArray[j+8]=c[f+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&i(this)};this.begin=
  668. function(){this.count=0;this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;a(this)}};this.addBall=function(a,c,h,e,f){var i=this.size*Math.sqrt(e/f),j=h*this.size,n=c*this.size,o=a*this.size,l=Math.floor(j-i);l<1&&(l=1);j=Math.floor(j+i);j>this.size-1&&(j=this.size-1);var q=Math.floor(n-i);q<1&&(q=1);n=Math.floor(n+i);n>this.size-1&&(n=this.size-1);var r=Math.floor(o-i);r<1&&(r=1);i=Math.floor(o+i);
  669. i>this.size-1&&(i=this.size-1);for(var s,p,v,w,x,t;l<j;l++){o=this.size2*l;p=l/this.size-h;x=p*p;for(p=q;p<n;p++){v=o+this.size*p;s=p/this.size-c;t=s*s;for(s=r;s<i;s++)w=s/this.size-a,w=e/(1.0E-6+w*w+t+x)-f,w>0&&(this.field[v+s]+=w)}}};this.addPlaneX=function(a,c){var h,e,f,i,j,n=this.size,o=this.yd,l=this.zd,q=this.field,r=n*Math.sqrt(a/c);r>n&&(r=n);for(h=0;h<r;h++)if(e=h/n,e*=e,i=a/(1.0E-4+e)-c,i>0)for(e=0;e<n;e++){j=h+e*o;for(f=0;f<n;f++)q[l*f+j]+=i}};this.addPlaneY=function(a,c){var h,e,f,i,
  670. j,n,o=this.size,l=this.yd,q=this.zd,r=this.field,s=o*Math.sqrt(a/c);s>o&&(s=o);for(e=0;e<s;e++)if(h=e/o,h*=h,i=a/(1.0E-4+h)-c,i>0){j=e*l;for(h=0;h<o;h++){n=j+h;for(f=0;f<o;f++)r[q*f+n]+=i}}};this.addPlaneZ=function(a,c){var h,e,f,i,j,n,o=this.size,l=this.yd,q=this.zd,r=this.field,s=o*Math.sqrt(a/c);s>o&&(s=o);for(f=0;f<s;f++)if(h=f/o,h*=h,i=a/(1.0E-4+h)-c,i>0){j=q*f;for(e=0;e<o;e++){n=j+e*l;for(h=0;h<o;h++)r[n+h]+=i}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*3]=0,
  671. this.field[a]=0};this.render=function(a){this.begin();var c,h,e,f,i,j,n,o,l,q=this.size-2;for(f=1;f<q;f++){l=this.size2*f;n=(f-this.halfsize)/this.halfsize;for(e=1;e<q;e++){o=l+this.size*e;j=(e-this.halfsize)/this.halfsize;for(h=1;h<q;h++)i=(h-this.halfsize)/this.halfsize,c=o+h,this.polygonize(i,j,n,c,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,c=new THREE.Geometry,h=[];this.render(function(e){var f,i,j,n,o,l,q,r;for(f=0;f<e.count;f++)q=f*3,o=q+1,r=q+2,i=e.positionArray[q],
  672. j=e.positionArray[o],n=e.positionArray[r],l=new THREE.Vector3(i,j,n),i=e.normalArray[q],j=e.normalArray[o],n=e.normalArray[r],q=new THREE.Vector3(i,j,n),q.normalize(),o=new THREE.Vertex(l),c.vertices.push(o),h.push(q);l=e.count/3;for(f=0;f<l;f++)q=(a+f)*3,o=q+1,r=q+2,i=h[q],j=h[o],n=h[r],q=new THREE.Face3(q,o,r,[i,j,n]),c.faces.push(q);a+=l;e.count=0});return c};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  673. 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,
  674. 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,
  675. 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]);
  676. 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,
  677. -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,
  678. -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,
  679. -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,
  680. 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,
  681. -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,
  682. 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,
  683. -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,
  684. 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,
  685. 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,
  686. 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,
  687. 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,
  688. -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,
  689. -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,
  690. -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,
  691. 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,
  692. -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,
  693. 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,
  694. 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,
  695. -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,
  696. 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.PlaneCollider=function(a,c){this.point=a;this.normal=c};THREE.SphereCollider=function(a,c){this.center=a;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(a,c){this.min=a;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
  697. THREE.MeshCollider=function(a,c){this.mesh=a;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(a){Array.prototype.push.apply(this.colliders,a.colliders);Array.prototype.push.apply(this.hits,a.hits)};
  698. THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,d,h,e=0;c=0;for(b=this.colliders.length;c<b;c++)if(h=this.colliders[c],d=this.rayCast(a,h),d<Number.MAX_VALUE)h.distance=d,d>e?this.hits.push(h):this.hits.unshift(h),e=d;return this.hits};
  699. THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var d=this.rayMesh(a,c[b]);if(d.dist<Number.MAX_VALUE){c[b].distance=d.dist;c[b].faceIndex=d.faceIndex;break}b++}if(b>c.length)return null;return c[b]};
  700. THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)};
  701. THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),d=Number.MAX_VALUE,h,e=0;e<c.numFaces;e++){var f=c.mesh.geometry.faces[e],i=c.mesh.geometry.vertices[f.a].position,j=c.mesh.geometry.vertices[f.b].position,n=c.mesh.geometry.vertices[f.c].position,o=f instanceof THREE.Face4?c.mesh.geometry.vertices[f.d].position:null;f instanceof THREE.Face3?(f=this.rayTriangle(b,i,j,n,d,this.collisionNormal,c.mesh),f<d&&(d=f,h=e,c.normal.copy(this.collisionNormal),c.normal.normalize())):
  702. f instanceof THREE.Face4&&(f=this.rayTriangle(b,i,j,o,d,this.collisionNormal,c.mesh),f<d&&(d=f,h=e,c.normal.copy(this.collisionNormal),c.normal.normalize()),f=this.rayTriangle(b,j,n,o,d,this.collisionNormal,c.mesh),f<d&&(d=f,h=e,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:d,faceIndex:h}};
  703. THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,d,h,e,f){var i=THREE.CollisionSystem.__v1,j=THREE.CollisionSystem.__v2;e.set(0,0,0);i.sub(b,c);j.sub(d,b);e.cross(i,j);i=e.dot(a.direction);if(!(i<0))if(f.doubleSided||f.flipSided)e.multiplyScalar(-1),i*=-1;else return Number.MAX_VALUE;f=e.dot(c)-e.dot(a.origin);if(!(f<=0))return Number.MAX_VALUE;if(!(f>=i*h))return Number.MAX_VALUE;f/=i;i=THREE.CollisionSystem.__v3;i.copy(a.direction);i.multiplyScalar(f);i.addSelf(a.origin);Math.abs(e.x)>
  704. Math.abs(e.y)?Math.abs(e.x)>Math.abs(e.z)?(a=i.y-c.y,e=b.y-c.y,h=d.y-c.y,i=i.z-c.z,b=b.z-c.z,d=d.z-c.z):(a=i.x-c.x,e=b.x-c.x,h=d.x-c.x,i=i.y-c.y,b=b.y-c.y,d=d.y-c.y):Math.abs(e.y)>Math.abs(e.z)?(a=i.x-c.x,e=b.x-c.x,h=d.x-c.x,i=i.z-c.z,b=b.z-c.z,d=d.z-c.z):(a=i.x-c.x,e=b.x-c.x,h=d.x-c.x,i=i.y-c.y,b=b.y-c.y,d=d.y-c.y);c=e*d-b*h;if(c==0)return Number.MAX_VALUE;c=1/c;d=(a*d-i*h)*c;if(!(d>=0))return Number.MAX_VALUE;c*=e*i-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-d-c>=0))return Number.MAX_VALUE;return f};
  705. THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;b.getInverse(c.matrixWorld);var d=THREE.CollisionSystem.__r;d.origin.copy(a.origin);d.direction.copy(a.direction);b.multiplyVector3(d.origin);b.rotateAxis(d.direction);d.direction.normalize();return d};
  706. THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;c.dynamic&&c.mesh&&c.mesh.matrixWorld?b=this.makeRayLocal(a,c.mesh):(b=THREE.CollisionSystem.__r,b.origin.copy(a.origin),b.direction.copy(a.direction));var d=0,h=0,e=0,f=0,i=0,j=0,n=!0;b.origin.x<c.min.x?(d=c.min.x-b.origin.x,d/=b.direction.x,n=!1,f=-1):b.origin.x>c.max.x&&(d=c.max.x-b.origin.x,d/=b.direction.x,n=!1,f=1);b.origin.y<c.min.y?(h=c.min.y-b.origin.y,h/=b.direction.y,n=!1,i=-1):b.origin.y>c.max.y&&(h=c.max.y-b.origin.y,h/=b.direction.y,
  707. n=!1,i=1);b.origin.z<c.min.z?(e=c.min.z-b.origin.z,e/=b.direction.z,n=!1,j=-1):b.origin.z>c.max.z&&(e=c.max.z-b.origin.z,e/=b.direction.z,n=!1,j=1);if(n)return-1;n=0;h>d&&(n=1,d=h);e>d&&(n=2,d=e);switch(n){case 0:i=b.origin.y+b.direction.y*d;if(i<c.min.y||i>c.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*d;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(f,0,0);break;case 1:f=b.origin.x+b.direction.x*d;if(f<c.min.x||f>c.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*
  708. d;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,i,0);break;case 2:f=b.origin.x+b.direction.x*d;if(f<c.min.x||f>c.max.x)return Number.MAX_VALUE;i=b.origin.y+b.direction.y*d;if(i<c.min.y||i>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,j)}return d};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),d=c.point.dot(c.normal);if(b<0)b=(d-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE};
  709. THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq<c.radiusSq)return-1;var d=b.dot(a.direction.clone());if(d<=0)return Number.MAX_VALUE;b=c.radiusSq-(b.lengthSq()-d*d);if(b>=0)return Math.abs(d)-Math.sqrt(b);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;
  710. THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=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]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c};
  711. THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};
  712. if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,h=new THREE.PerspectiveCamera,e=new THREE.PerspectiveCamera,f=new THREE.Matrix4,i=new THREE.Matrix4,j,n,o,l;h.matrixAutoUpdate=e.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},q=new THREE.WebGLRenderTarget(512,512,a),r=new THREE.WebGLRenderTarget(512,512,a),s=new THREE.PerspectiveCamera(53,
  713. 1,1,1E4);s.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:q},mapRight:{type:"t",value:1,texture:r}},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}"}),
  714. p=new THREE.Scene;p.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));p.add(s);this.setSize=function(a,d){b.call(c,a,d);q.width=a;q.height=d;r.width=a;r.height=d};this.render=function(a,b){a.updateMatrixWorld();if(j!==b.aspect||n!==b.near||o!==b.far||l!==b.fov){j=b.aspect;n=b.near;o=b.far;l=b.fov;var x=b.projectionMatrix.clone(),t=125/30*0.5,B=t*n/125,G=n*Math.tan(l*Math.PI/360),P;f.n14=t;i.n14=-t;t=-G*j+B;P=G*j+B;x.n11=2*n/(P-t);x.n13=(P+t)/(P-t);h.projectionMatrix.copy(x);t=-G*j-B;P=G*j-B;x.n11=
  715. 2*n/(P-t);x.n13=(P+t)/(P-t);e.projectionMatrix.copy(x)}h.matrixWorld.copy(b.matrixWorld).multiplySelf(i);h.position.copy(b.position);h.near=b.near;h.far=b.far;d.call(c,a,h,q,!0);e.matrixWorld.copy(b.matrixWorld).multiplySelf(f);e.position.copy(b.position);e.near=b.near;e.far=b.far;d.call(c,a,e,r,!0);p.updateMatrixWorld();d.call(c,p,s)}};
  716. if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,d=this.render,h,e,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var i=new THREE.PerspectiveCamera;i.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,d){b.call(c,a,d);h=a/2;e=d};this.render=function(a,b){this.clear();f.fov=b.fov;f.aspect=0.5*b.aspect;f.near=b.near;f.far=
  717. b.far;f.updateProjectionMatrix();f.position.copy(b.position);f.target.copy(b.target);f.translateX(c.separation);f.lookAt(f.target);i.projectionMatrix=f.projectionMatrix;i.position.copy(b.position);i.target.copy(b.target);i.translateX(-c.separation);i.lookAt(i.target);this.setViewport(0,0,h,e);d.call(c,a,f);this.setViewport(h,0,h,e);d.call(c,a,i,!1)}};