Three.js 204 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. // Three.js r37 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
  3. THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,k,j;if(b==0)d=e=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);j=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=j;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=j;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;
  4. g=j;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
  5. 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,c){this.set(a||0,c||0)};
  6. THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
  7. this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)};
  8. THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
  9. c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.set(b*a.z-d*a.y,d*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
  10. a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
  11. this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var c=Math.cos(this.y);if(Math.abs(c)>1.0E-5){this.x=Math.atan2(-a.n23/c,a.n33/c);this.z=Math.atan2(-a.n13/c,a.n11/c)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
  12. 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)};
  13. THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
  14. a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(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)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
  15. THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(b)))}e.sort(function(g,h){return g.distance-h.distance});return e},intersectObject:function(a){function c(H,E,I,A){A=A.clone().subSelf(E);I=I.clone().subSelf(E);var S=H.clone().subSelf(E);H=A.dot(A);E=A.dot(I);A=A.dot(S);var Q=I.dot(I);I=I.dot(S);S=1/(H*Q-E*E);Q=(Q*A-E*I)*S;H=(H*I-E*A)*S;return Q>0&&H>0&&Q+H<1}var b,d,e,g,h,k,j,m,t,x,
  16. y,q=a.geometry,z=q.vertices,G=[];b=0;for(d=q.faces.length;b<d;b++){e=q.faces[b];x=this.origin.clone();y=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(z[e.a].position.clone());h=j.multiplyVector3(z[e.b].position.clone());k=j.multiplyVector3(z[e.c].position.clone());j=e instanceof THREE.Face4?j.multiplyVector3(z[e.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(e.normal.clone());t=y.dot(m);if(t<0){m=m.dot((new THREE.Vector3).sub(g,x))/t;x=x.addSelf(y.multiplyScalar(m));
  17. if(e instanceof THREE.Face3){if(c(x,g,h,k)){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};G.push(e)}}else if(e instanceof THREE.Face4&&(c(x,g,h,j)||c(x,h,k,j))){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};G.push(e)}}}return G}};
  18. THREE.Rectangle=function(){function a(){g=d-c;h=e-b}var c,b,d,e,g,h,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(j,m,t,x){k=!1;c=j;b=m;d=t;e=x;a()};this.addPoint=function(j,m){if(k){k=!1;c=j;b=m;d=j;e=m}else{c=c<j?c:j;b=b<m?b:m;d=d>j?d:j;e=e>m?e:m}a()};
  19. this.add3Points=function(j,m,t,x,y,q){if(k){k=!1;c=j<t?j<y?j:y:t<y?t:y;b=m<x?m<q?m:q:x<q?x:q;d=j>t?j>y?j:y:t>y?t:y;e=m>x?m>q?m:q:x>q?x:q}else{c=j<t?j<y?j<c?j:c:y<c?y:c:t<y?t<c?t:c:y<c?y:c;b=m<x?m<q?m<b?m:b:q<b?q:b:x<q?x<b?x:b:q<b?q:b;d=j>t?j>y?j>d?j:d:y>d?y:d:t>y?t>d?t:d:y>d?y:d;e=m>x?m>q?m>e?m:e:q>e?q:e:x>q?x>e?x:e:q>e?q:e}a()};this.addRectangle=function(j){if(k){k=!1;c=j.getLeft();b=j.getTop();d=j.getRight();e=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();b=b<j.getTop()?b:j.getTop();d=d>j.getRight()?
  20. d:j.getRight();e=e>j.getBottom()?e:j.getBottom()}a()};this.inflate=function(j){c-=j;b-=j;d+=j;e+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();b=b>j.getTop()?b:j.getTop();d=d<j.getRight()?d:j.getRight();e=e<j.getBottom()?e:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(e,j.getBottom())-Math.max(b,j.getTop())>=0};this.empty=function(){k=!0;e=d=b=c=0;a()};this.isEmpty=function(){return k}};
  21. THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={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}};
  22. THREE.Matrix4=function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,k||0,j||0,m||0,t||1,x||0,y||0,q||0,z||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  23. THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=t;this.n34=x;this.n41=y;this.n42=q;this.n43=z;this.n44=G;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,c,b){var d=THREE.Matrix4.__v1,
  24. e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=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)*e;a.y=(this.n21*c+this.n22*b+this.n23*
  25. d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;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();
  26. 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*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},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44,I=c.n11,A=c.n12,S=c.n13,Q=c.n14,O=c.n21,X=c.n22,
  27. f=c.n23,ea=c.n24,ka=c.n31,W=c.n32,T=c.n33,xa=c.n34;this.n11=b*I+d*O+e*ka;this.n12=b*A+d*X+e*W;this.n13=b*S+d*f+e*T;this.n14=b*Q+d*ea+e*xa+g;this.n21=h*I+k*O+j*ka;this.n22=h*A+k*X+j*W;this.n23=h*S+k*f+j*T;this.n24=h*Q+k*ea+j*xa+m;this.n31=t*I+x*O+y*ka;this.n32=t*A+x*X+y*W;this.n33=t*S+x*f+y*T;this.n34=t*Q+x*ea+y*xa+q;this.n41=z*I+G*O+H*ka;this.n42=z*A+G*X+H*W;this.n43=z*S+G*f+H*T;this.n44=z*Q+G*ea+H*xa+E;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=
  28. 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},multiplySelf:function(a){this.multiply(this,a);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*=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},
  29. determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,t=this.n33,x=this.n34,y=this.n41,q=this.n42,z=this.n43,G=this.n44;return d*h*m*y-b*k*m*y-d*g*t*y+c*k*t*y+b*g*x*y-c*h*x*y-d*h*j*q+b*k*j*q+d*e*t*q-a*k*t*q-b*e*x*q+a*h*x*q+d*g*j*z-c*k*j*z-d*e*m*z+a*k*m*z+c*e*x*z-a*g*x*z-b*g*j*G+c*h*j*G+b*e*m*G-a*h*m*G-c*e*t*G+a*g*t*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=
  30. 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;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;
  31. 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;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;
  32. 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},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},
  33. 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},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,k=
  34. a.z,j=e*g,m=e*h;this.set(j*g+b,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+b,m*k-d*g,0,j*k-d*h,m*k+d*g,e*k*k+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},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},
  35. setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var j=c*h;c*=k;var m=b*h;b*=k;d*=k;g*=e;h*=e;e*=k;this.n11=1-(m+d);this.n12=j-e;this.n13=c+h;this.n21=j+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=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},extractPosition:function(a){this.n14=
  36. a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;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*e;this.n23=a.n23*e;this.n33=a.n33*e}};
  37. THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=j*q*G-m*y*G+m*x*H-k*q*H-j*x*E+k*y*E;c.n12=g*y*G-e*q*G-g*x*H+d*q*H+e*x*E-d*y*E;c.n13=e*m*G-g*j*G+g*k*H-d*m*H-e*k*E+d*j*E;c.n14=g*j*x-e*m*x-g*k*y+d*m*y+e*k*q-d*j*q;c.n21=m*y*z-j*q*z-m*t*H+h*q*H+j*t*E-h*y*E;c.n22=e*q*z-g*y*z+g*t*H-b*q*H-e*t*E+b*y*E;c.n23=g*j*z-e*m*z-g*h*H+b*m*H+e*h*E-b*j*E;
  38. c.n24=e*m*t-g*j*t+g*h*y-b*m*y-e*h*q+b*j*q;c.n31=k*q*z-m*x*z+m*t*G-h*q*G-k*t*E+h*x*E;c.n32=g*x*z-d*q*z-g*t*G+b*q*G+d*t*E-b*x*E;c.n33=e*m*z-g*k*z+g*h*G-b*m*G-d*h*E+b*k*E;c.n34=g*k*t-d*m*t-g*h*x+b*m*x+d*h*q-b*k*q;c.n41=j*x*z-k*y*z-j*t*G+h*y*G+k*t*H-h*x*H;c.n42=d*y*z-e*x*z+e*t*G-b*y*G-d*t*H+b*x*H;c.n43=e*k*z-d*j*z-e*h*G+b*j*G+d*h*H-b*k*H;c.n44=d*j*t-e*k*t+e*h*x-b*j*x-d*h*y+b*k*y;c.multiplyScalar(1/a.determinant());return c};
  39. THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*k;b[5]=a*j;b[6]=a*m;b[7]=a*t;b[8]=a*x;return c};
  40. THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)};
  41. THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,k,j,m;h=new THREE.Matrix4;k=c-a;j=b-d;m=g-e;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((b+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
  42. THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
  43. !0;this._vector=new THREE.Vector3};
  44. THREE.Object3D.prototype={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(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
  45. undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
  46. 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
  47. c,b)}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==undefined?d:1)};
  48. THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,e=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(b);b=Math.sin(b);var h=a*c,k=d*e;this.w=h*g-k*b;this.x=h*b+k*g;this.y=d*c*g+a*e*b;this.z=a*e*g-d*c*b;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*=
  49. -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,e=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=c*a+e*g+b*k-d*h;this.y=b*a+e*h+d*g-c*k;this.z=d*a+e*k+c*h-b*g;this.w=e*a-c*g-b*h-d*k;return this},
  50. multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*b+h*e-k*d,t=j*d+k*b-g*e,x=j*e+g*d-h*b;b=-g*b-h*d-k*e;c.x=m*j+b*-g+t*-k-x*-h;c.y=t*j+b*-h+x*-g-m*-k;c.z=x*j+b*-k+m*-h-t*-g;return c}};
  51. THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){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);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
  52. THREE.Face3=function(a,c,b,d,e,g){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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
  53. THREE.Face4=function(a,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};
  54. THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
  55. THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];b.centroid.set(0,0,0);if(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)}else if(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);
  56. b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,e,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);c=0;for(b=g.vertexNormals.length;c<b;c++)k.addSelf(g.vertexNormals[c]);k.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,b.position);j.sub(c.position,b.position);k.crossSelf(j)}k.isZero()||
  57. k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=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++){b=this.faces[a];if(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=
  58. 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];if(b instanceof THREE.Face3){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal)}else if(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];if(b instanceof THREE.Face3){b.vertexNormals[0].copy(d[b.a]);
  59. b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);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(oa,la,aa,P,M,da,sa){k=oa.vertices[la].position;j=oa.vertices[aa].position;m=oa.vertices[P].position;t=h[M];x=h[da];y=h[sa];q=j.x-k.x;z=m.x-k.x;G=j.y-k.y;H=m.y-k.y;E=j.z-k.z;I=m.z-k.z;A=x.u-t.u;S=y.u-t.u;Q=x.v-t.v;O=y.v-t.v;X=1/(A*O-S*
  60. Q);W.set((O*q-Q*z)*X,(O*G-Q*H)*X,(O*E-Q*I)*X);T.set((A*z-S*q)*X,(A*H-S*G)*X,(A*I-S*E)*X);ea[la].addSelf(W);ea[aa].addSelf(W);ea[P].addSelf(W);ka[la].addSelf(T);ka[aa].addSelf(T);ka[P].addSelf(T)}var c,b,d,e,g,h,k,j,m,t,x,y,q,z,G,H,E,I,A,S,Q,O,X,f,ea=[],ka=[],W=new THREE.Vector3,T=new THREE.Vector3,xa=new THREE.Vector3,ca=new THREE.Vector3,Da=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){ea[c]=new THREE.Vector3;ka[c]=new THREE.Vector3}c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];
  61. h=this.faceVertexUvs[0][c];if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var ja=["a","b","c","d"];c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];for(d=0;d<g.vertexNormals.length;d++){Da.copy(g.vertexNormals[d]);e=g[ja[d]];f=ea[e];xa.copy(f);xa.subSelf(Da.multiplyScalar(Da.dot(f))).normalize();ca.cross(g.vertexNormals[d],f);e=ca.dot(ka[e]);e=e<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(xa.x,xa.y,
  62. xa.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],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;
  63. if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere=
  64. {radius:a}}};THREE.GeometryIdCounter=0;
  65. THREE.Spline=function(a){function c(q,z,G,H,E,I,A){q=(G-q)*0.5;H=(H-z)*0.5;return(2*(z-G)+q+H)*A+(-3*(z-G)-2*q-H)*I+q*E+z}this.points=a;var b=[],d={x:0,y:0,z:0},e,g,h,k,j,m,t,x,y;this.initFromArray=function(q){this.points=[];for(var z=0;z<q.length;z++)this.points[z]={x:q[z][0],y:q[z][1],z:q[z][2]}};this.getPoint=function(q){e=(this.points.length-1)*q;g=Math.floor(e);h=e-g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>this.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;m=this.points[b[0]];t=this.points[b[1]];
  66. x=this.points[b[2]];y=this.points[b[3]];k=h*h;j=h*k;d.x=c(m.x,t.x,x.x,y.x,h,k,j);d.y=c(m.y,t.y,x.y,y.y,h,k,j);d.z=c(m.z,t.z,x.z,y.z,h,k,j);return d};this.getControlPointsArray=function(){var q,z,G=this.points.length,H=[];for(q=0;q<G;q++){z=this.points[q];H[q]=[z.x,z.y,z.z]}return H};this.getLength=function(q){var z,G,H=z=z=0,E=new THREE.Vector3,I=new THREE.Vector3,A=[],S=0;A[0]=0;q||(q=100);G=this.points.length*q;E.copy(this.points[0]);for(q=1;q<G;q++){z=q/G;position=this.getPoint(z);I.copy(position);
  67. S+=I.distanceTo(E);E.copy(position);z*=this.points.length-1;z=Math.floor(z);if(z!=H){A[z]=S;H=z}}A[A.length]=S;return{chunks:A,total:S}};this.reparametrizeByArcLength=function(q){var z,G,H,E,I,A,S=[],Q=new THREE.Vector3,O=this.getLength();S.push(Q.copy(this.points[0]).clone());for(z=1;z<this.points.length;z++){G=O.chunks[z]-O.chunks[z-1];A=Math.ceil(q*G/O.total);E=(z-1)/(this.points.length-1);I=z/(this.points.length-1);for(G=1;G<A-1;G++){H=E+G*(1/A)*(I-E);position=this.getPoint(H);S.push(Q.copy(position).clone())}S.push(Q.copy(this.points[z]).clone())}this.points=
  68. S}};
  69. THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;g<a.length;g++)a[g].update(e)};b.addToUpdate=function(e){a.indexOf(e)===-1&&a.push(e)};b.removeFromUpdate=function(e){e=a.indexOf(e);e!==-1&&a.splice(e,1)};b.add=function(e){c[e.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+e.name+" already exists in library. Overwriting.");c[e.name]=e;if(e.initialized!==!0){for(var g=0;g<e.hierarchy.length;g++){for(var h=0;h<e.hierarchy[g].keys.length;h++){if(e.hierarchy[g].keys[h].time<0)e.hierarchy[g].keys[h].time=
  70. 0;if(e.hierarchy[g].keys[h].rot!==undefined&&!(e.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var k=e.hierarchy[g].keys[h].rot;e.hierarchy[g].keys[h].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(e.hierarchy[g].keys[0].morphTargets!==undefined){k={};for(h=0;h<e.hierarchy[g].keys.length;h++)for(var j=0;j<e.hierarchy[g].keys[h].morphTargets.length;j++){var m=e.hierarchy[g].keys[h].morphTargets[j];k[m]=-1}e.hierarchy[g].usedMorphTargets=k;for(h=0;h<e.hierarchy[g].keys.length;h++){var t=
  71. {};for(m in k){for(j=0;j<e.hierarchy[g].keys[h].morphTargets.length;j++)if(e.hierarchy[g].keys[h].morphTargets[j]===m){t[m]=e.hierarchy[g].keys[h].morphTargetsInfluences[j];break}j===e.hierarchy[g].keys[h].morphTargets.length&&(t[m]=0)}e.hierarchy[g].keys[h].morphTargetsInfluences=t}}for(h=1;h<e.hierarchy[g].keys.length;h++)if(e.hierarchy[g].keys[h].time===e.hierarchy[g].keys[h-1].time){e.hierarchy[g].keys.splice(h,1);h--}for(h=1;h<e.hierarchy[g].keys.length;h++)e.hierarchy[g].keys[h].index=h}h=parseInt(e.length*
  72. e.fps,10);e.JIT={};e.JIT.hierarchy=[];for(g=0;g<e.hierarchy.length;g++)e.JIT.hierarchy.push(Array(h));e.initialized=!0}};b.get=function(e){if(typeof e==="string")if(c[e])return c[e];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+e);return null}};b.parse=function(e){var g=[];if(e instanceof THREE.SkinnedMesh)for(var h=0;h<e.bones.length;h++)g.push(e.bones[h]);else d(e,g);return g};var d=function(e,g){g.push(e);for(var h=0;h<e.children.length;h++)d(e.children[h],g)};b.LINEAR=
  73. 0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=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.isPaused=!0;this.loop=!0;this.interpolationType=b!==undefined?b:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==undefined?d:!0;this.points=[];this.target=new THREE.Vector3};
  74. THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;var b,d=this.hierarchy.length,e;for(b=0;b<d;b++){e=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(e.animationCache===undefined){e.animationCache={};e.animationCache.prevKey={pos:0,rot:0,scl:0};e.animationCache.nextKey={pos:0,rot:0,scl:0};e.animationCache.originalMatrix=
  75. e instanceof THREE.Bone?e.skinMatrix:e.matrix}var g=e.animationCache.prevKey;e=e.animationCache.nextKey;g.pos=this.data.hierarchy[b].keys[0];g.rot=this.data.hierarchy[b].keys[0];g.scl=this.data.hierarchy[b].keys[0];e.pos=this.getNextKeyWith("pos",b,1);e.rot=this.getNextKeyWith("rot",b,1);e.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
  76. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  77. THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
  78. THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,k,j,m,t=this.data.JIT.hierarchy,x,y;this.currentTime+=a*this.timeScale;y=this.currentTime;x=this.currentTime%=this.data.length;m=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,z=this.hierarchy.length;q<z;q++){a=this.hierarchy[q];j=a.animationCache;if(this.JITCompile&&t[q][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
  79. !1}else{a.matrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var G=0;G<3;G++){b=c[G];h=j.prevKey[b];k=j.nextKey[b];if(k.time<=y){if(x<y)if(this.loop){h=this.data.hierarchy[q].keys[0];for(k=this.getNextKeyWith(b,q,1);k.time<x;){h=k;k=this.getNextKeyWith(b,q,k.index+1)}}else{this.stop();return}else{do{h=k;k=this.getNextKeyWith(b,q,k.index+1)}while(k.time<
  80. x)}j.prevKey[b]=h;j.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(x-h.time)/(k.time-h.time);e=h[b];g=k[b];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+q);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
  81. this.getPrevKeyWith("pos",q,h.index-1).pos;this.points[1]=e;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",q,k.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);b.x=e[0];b.y=e[1];b.z=e[2];if(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===
  82. "rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&t[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;q<this.hierarchy.length;q++)t[q][m]=this.hierarchy[q]instanceof THREE.Bone?this.hierarchy[q].skinMatrix.clone():this.hierarchy[q].matrix.clone()}}};
  83. THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],e,g,h,k,j,m;e=(a.length-1)*c;g=Math.floor(e);e-=g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>a.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];j=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],k[0],j[0],m[0],e,b,h);d[1]=this.interpolate(g[1],k[1],j[1],m[1],e,b,h);d[2]=this.interpolate(g[2],k[2],j[2],m[2],e,b,h);return d};
  84. THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b<d.length-1?b:d.length-1;else b%=d.length;for(;b<d.length;b++)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[0]};
  85. THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(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]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]};
  86. THREE.Camera=function(a,c,b,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
  87. THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
  88. THREE.Camera.prototype.update=function(a,c,b){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
  89. !1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};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;
  90. THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
  91. 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.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};
  92. THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  93. THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
  94. a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
  95. THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;
  96. if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;
  97. if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;
  98. if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  99. THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=
  100. !1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;
  101. if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;
  102. if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  103. THREE.MeshPhongMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=
  104. this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.map!==undefined)this.map=a.map;if(a.envMap!==undefined)this.envMap=
  105. a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;
  106. if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  107. THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
  108. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
  109. THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
  110. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
  111. THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=!1;this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==
  112. undefined)this.vertexShader=a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;
  113. if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.lights!==undefined)this.lights=a.lights;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  114. THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=
  115. a.sizeAttenuation;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
  116. THREE.ParticleCanvasMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.program=function(){};this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.program!==undefined)this.program=a.program;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};
  117. THREE.Texture=function(a,c,b,d,e,g){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrapS=b!==undefined?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
  118. THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;
  119. THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
  120. THREE.RenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==undefined?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==undefined?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==undefined?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==undefined?b.minFilter:THREE.LinearMipMapLinearFilter;this.format=b.format!==undefined?b.format:THREE.RGBFormat;this.type=b.type!==undefined?b.type:THREE.UnsignedByteType};
  121. var Uniforms={clone:function(a){var c,b,d,e={};for(c in a){e[c]={};for(b in a[c]){d=a[c][b];e[c][b]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return e},merge:function(a){var c,b,d,e={};for(c=0;c<a.length;c++){d=this.clone(a[c]);for(b in d)e[b]=d[b]}return e}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
  122. THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,c,b){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=b!=undefined?b:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
  123. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  124. THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c&&c.length?c:[c];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius;if(this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var b=0;b<this.geometry.morphTargets.length;b++){this.morphTargetInfluences.push(0);
  125. 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;THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==undefined)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
  126. THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  127. THREE.Bone.prototype.update=function(a,c,b){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 d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,c,b):a.update(this.matrixWorld,!0,b)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
  128. c,b)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
  129. THREE.SkinnedMesh=function(a,c){THREE.Mesh.call(this,a,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var b,d,e,g,h,k;if(this.geometry.bones!==undefined){for(b=0;b<this.geometry.bones.length;b++){e=this.geometry.bones[b];g=e.pos;h=e.rotq;k=e.scl;d=this.addBone();d.name=e.name;d.position.set(g[0],g[1],g[2]);d.quaternion.set(h[0],h[1],h[2],h[3]);d.useQuaternion=!0;k!==undefined?d.scale.set(k[0],k[1],k[2]):d.scale.set(1,1,1)}for(b=0;b<this.bones.length;b++){e=this.geometry.bones[b];
  130. d=this.bones[b];e.parent===-1?this.addChild(d):this.bones[e.parent].addChild(d)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  131. THREE.SkinnedMesh.prototype.update=function(a,c,b){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d,e=this.children.length;for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,b):a.update(this.matrixWorld,c,b)}b=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<b;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
  132. c*16)}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  133. THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,c=[],b=0;b<this.bones.length;b++){a=this.bones[b];c.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,b*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var d;for(a=0;a<this.geometry.skinIndices.length;a++){b=this.geometry.vertices[a].position;var e=this.geometry.skinIndices[a].x,g=this.geometry.skinIndices[a].y;
  134. d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesA.push(c[e].multiplyVector3(d));d=new THREE.Vector3(b.x,b.y,b.z);this.geometry.skinVerticesB.push(c[g].multiplyVector3(d));if(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}}}};
  135. THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
  136. THREE.Sound=function(a,c,b,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=c!==undefined?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,b!==undefined?b:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;b=this.sources.length;for(a=0;a<b;a++){c=this.sources[a];c.toLowerCase();if(c.indexOf(".mp3")!==-1)e=
  137. "audio/mpeg";else if(c.indexOf(".ogg")!==-1)e="audio/ogg";else c.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
  138. THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
  139. THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
  140. THREE.Sound.prototype.update=function(a,c,b){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);c=!0}if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
  141. THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(a,c){c===undefined&&(c=0);c=Math.abs(c);for(var b=0;b<this.LODs.length;b++)if(c<this.LODs[b].visibleAtDistance)break;this.LODs.splice(b,0,{visibleAtDistance:c,object3D:a});this.addChild(a)};
  142. THREE.LOD.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;c=!0}if(this.LODs.length>1){a=b.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 d=1;d<this.LODs.length;d++)if(a>=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible=
  143. !1;this.LODs[d].object3D.visible=!0}else break;for(;d<this.LODs.length;d++)this.LODs[d].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,c,b)};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
  144. THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var c=0;c<a.children.length;c++)this.addChildRecurse(a.children[c])};
  145. THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else if(a instanceof THREE.Sound){c=this.sounds.indexOf(a);c!==-1&&this.sounds.splice(c,1)}else if(!(a instanceof THREE.Camera)){c=this.objects.indexOf(a);if(c!==-1){this.objects.splice(c,1);this.__objectsRemoved.push(a)}}for(c=0;c<a.children.length;c++)this.removeChildRecurse(a.children[c])};
  146. THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c||1;this.far=b||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c!==undefined?c:2.5E-4};
  147. THREE.Projector=function(){function a(){var W=j[k]=j[k]||new THREE.RenderableVertex;k++;return W}function c(W,T){return T.z-W.z}function b(W,T){var xa=0,ca=1,Da=W.z+W.w,ja=T.z+T.w,oa=-W.z+W.w,la=-T.z+T.w;if(Da>=0&&ja>=0&&oa>=0&&la>=0)return!0;else if(Da<0&&ja<0||oa<0&&la<0)return!1;else{if(Da<0)xa=Math.max(xa,Da/(Da-ja));else ja<0&&(ca=Math.min(ca,Da/(Da-ja)));if(oa<0)xa=Math.max(xa,oa/(oa-la));else la<0&&(ca=Math.min(ca,oa/(oa-la)));if(ca<xa)return!1;else{W.lerpSelf(T,xa);T.lerpSelf(W,1-ca);return!0}}}
  148. var d,e,g=[],h,k,j=[],m,t,x=[],y,q=[],z,G,H=[],E,I,A=[],S=new THREE.Vector4,Q=new THREE.Vector4,O=new THREE.Matrix4,X=new THREE.Matrix4,f=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ea=new THREE.Vector4,ka=new THREE.Vector4;this.projectVector=function(W,T){O.multiply(T.projectionMatrix,T.matrixWorldInverse);O.multiplyVector3(W);return W};this.unprojectVector=function(W,T){O.multiply(T.matrixWorld,THREE.Matrix4.makeInvert(T.projectionMatrix));
  149. O.multiplyVector3(W);return W};this.projectObjects=function(W,T,xa){T=[];var ca,Da,ja;e=0;Da=W.objects;W=0;for(ca=Da.length;W<ca;W++){ja=Da[W];var oa;if(!(oa=!ja.visible))if(oa=ja instanceof THREE.Mesh){a:{oa=void 0;for(var la=ja.matrixWorld,aa=-ja.geometry.boundingSphere.radius*Math.max(ja.scale.x,Math.max(ja.scale.y,ja.scale.z)),P=0;P<6;P++){oa=f[P].x*la.n14+f[P].y*la.n24+f[P].z*la.n34+f[P].w;if(oa<=aa){oa=!1;break a}}oa=!0}oa=!oa}if(!oa){oa=g[e]=g[e]||new THREE.RenderableObject;e++;d=oa;S.copy(ja.position);
  150. O.multiplyVector3(S);d.object=ja;d.z=S.z;T.push(d)}}xa&&T.sort(c);return T};this.projectScene=function(W,T,xa){var ca=[],Da=T.near,ja=T.far,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C,p,o,w;I=G=y=t=0;T.matrixAutoUpdate&&T.updateMatrix();W.update(undefined,!1,T);O.multiply(T.projectionMatrix,T.matrixWorldInverse);f[0].set(O.n41-O.n11,O.n42-O.n12,O.n43-O.n13,O.n44-O.n14);f[1].set(O.n41+O.n11,O.n42+O.n12,O.n43+O.n13,O.n44+O.n14);f[2].set(O.n41+O.n21,O.n42+O.n22,O.n43+O.n23,O.n44+O.n24);f[3].set(O.n41-O.n21,
  151. O.n42-O.n22,O.n43-O.n23,O.n44-O.n24);f[4].set(O.n41-O.n31,O.n42-O.n32,O.n43-O.n33,O.n44-O.n34);f[5].set(O.n41+O.n31,O.n42+O.n32,O.n43+O.n33,O.n44+O.n34);for(oa=0;oa<6;oa++){ta=f[oa];ta.divideScalar(Math.sqrt(ta.x*ta.x+ta.y*ta.y+ta.z*ta.z))}ta=this.projectObjects(W,T,!0);W=0;for(oa=ta.length;W<oa;W++){ya=ta[W].object;if(ya.visible){La=ya.matrixWorld;ab=ya.matrixRotationWorld;n=ya.materials;C=ya.overdraw;k=0;if(ya instanceof THREE.Mesh){p=ya.geometry;P=p.vertices;o=p.faces;p=p.faceVertexUvs;la=0;for(aa=
  152. P.length;la<aa;la++){h=a();h.positionWorld.copy(P[la].position);La.multiplyVector3(h.positionWorld);h.positionScreen.copy(h.positionWorld);O.multiplyVector4(h.positionScreen);h.positionScreen.x/=h.positionScreen.w;h.positionScreen.y/=h.positionScreen.w;h.visible=h.positionScreen.z>Da&&h.positionScreen.z<ja}P=0;for(la=o.length;P<la;P++){aa=o[P];if(aa instanceof THREE.Face3){M=j[aa.a];da=j[aa.b];sa=j[aa.c];if(M.visible&&da.visible&&sa.visible&&(ya.doubleSided||ya.flipSided!=(sa.positionScreen.x-M.positionScreen.x)*
  153. (da.positionScreen.y-M.positionScreen.y)-(sa.positionScreen.y-M.positionScreen.y)*(da.positionScreen.x-M.positionScreen.x)<0)){ia=x[t]=x[t]||new THREE.RenderableFace3;t++;m=ia;m.v1.copy(M);m.v2.copy(da);m.v3.copy(sa)}else continue}else if(aa instanceof THREE.Face4){M=j[aa.a];da=j[aa.b];sa=j[aa.c];ia=j[aa.d];if(M.visible&&da.visible&&sa.visible&&ia.visible&&(ya.doubleSided||ya.flipSided!=((ia.positionScreen.x-M.positionScreen.x)*(da.positionScreen.y-M.positionScreen.y)-(ia.positionScreen.y-M.positionScreen.y)*
  154. (da.positionScreen.x-M.positionScreen.x)<0||(da.positionScreen.x-sa.positionScreen.x)*(ia.positionScreen.y-sa.positionScreen.y)-(da.positionScreen.y-sa.positionScreen.y)*(ia.positionScreen.x-sa.positionScreen.x)<0))){w=q[y]=q[y]||new THREE.RenderableFace4;y++;m=w;m.v1.copy(M);m.v2.copy(da);m.v3.copy(sa);m.v4.copy(ia)}else continue}m.normalWorld.copy(aa.normal);ab.multiplyVector3(m.normalWorld);m.centroidWorld.copy(aa.centroid);La.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);
  155. O.multiplyVector3(m.centroidScreen);sa=aa.vertexNormals;M=0;for(da=sa.length;M<da;M++){ia=m.vertexNormalsWorld[M];ia.copy(sa[M]);ab.multiplyVector3(ia)}M=0;for(da=p.length;M<da;M++)if(w=p[M][P]){sa=0;for(ia=w.length;sa<ia;sa++)m.uvs[M][sa]=w[sa]}m.meshMaterials=n;m.faceMaterials=aa.materials;m.overdraw=C;m.z=m.centroidScreen.z;ca.push(m)}}else if(ya instanceof THREE.Line){X.multiply(O,La);P=ya.geometry.vertices;M=a();M.positionScreen.copy(P[0].position);X.multiplyVector4(M.positionScreen);la=1;for(aa=
  156. P.length;la<aa;la++){M=a();M.positionScreen.copy(P[la].position);X.multiplyVector4(M.positionScreen);da=j[k-2];ea.copy(M.positionScreen);ka.copy(da.positionScreen);if(b(ea,ka)){ea.multiplyScalar(1/ea.w);ka.multiplyScalar(1/ka.w);La=H[G]=H[G]||new THREE.RenderableLine;G++;z=La;z.v1.positionScreen.copy(ea);z.v2.positionScreen.copy(ka);z.z=Math.max(ea.z,ka.z);z.materials=ya.materials;ca.push(z)}}}else if(ya instanceof THREE.Particle){Q.set(ya.position.x,ya.position.y,ya.position.z,1);O.multiplyVector4(Q);
  157. Q.z/=Q.w;if(Q.z>0&&Q.z<1){La=A[I]=A[I]||new THREE.RenderableParticle;I++;E=La;E.x=Q.x/Q.w;E.y=Q.y/Q.w;E.z=Q.z;E.rotation=ya.rotation.z;E.scale.x=ya.scale.x*Math.abs(E.x-(Q.x+T.projectionMatrix.n11)/(Q.w+T.projectionMatrix.n14));E.scale.y=ya.scale.y*Math.abs(E.y-(Q.y+T.projectionMatrix.n22)/(Q.w+T.projectionMatrix.n24));E.materials=ya.materials;ca.push(E)}}}}xa&&ca.sort(c);return ca}};
  158. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;e=b/2;g=d/2};this.render=function(h,k){var j,m,t,x,y,q,z,G;a=c.projectScene(h,k);j=0;for(m=a.length;j<m;j++){y=a[j];if(y instanceof THREE.RenderableParticle){z=y.x*e+e;G=y.y*g+g;t=0;for(x=y.material.length;t<x;t++){q=y.material[t];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=G+"px"}}}}}};
  159. THREE.CanvasRenderer=function(){function a(Ca){if(y!=Ca)m.globalAlpha=y=Ca}function c(Ca){if(q!=Ca){switch(Ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=Ca}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,k,j,m=e.getContext("2d"),t=new THREE.Color(0),x=0,y=1,q=0,z=null,G=null,H=1,E,I,A,S,Q=new THREE.RenderableVertex,
  160. O=new THREE.RenderableVertex,X,f,ea,ka,W,T,xa,ca,Da,ja,oa,la,aa=new THREE.Color,P=new THREE.Color,M=new THREE.Color,da=new THREE.Color,sa=new THREE.Color,ia,ta,ya,La,ab,n,C,p,o,w,D=new THREE.Rectangle,B=new THREE.Rectangle,F=new THREE.Rectangle,Z=!1,N=new THREE.Color,K=new THREE.Color,ra=new THREE.Color,Ea=new THREE.Color,$=new THREE.Vector3,Aa,ma,Ga,Ma,wa,Ia,V=16;Aa=document.createElement("canvas");Aa.width=Aa.height=2;ma=Aa.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);Ga=ma.getImageData(0,
  161. 0,2,2);Ma=Ga.data;wa=document.createElement("canvas");wa.width=wa.height=V;Ia=wa.getContext("2d");Ia.translate(-V/2,-V/2);Ia.scale(V,V);V--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(Ca,Ba){g=Ca;h=Ba;k=g/2;j=h/2;e.width=g;e.height=h;D.set(-k,-j,k,j);y=1;q=0;G=z=null;H=1};this.setClearColor=function(Ca,Ba){t=Ca;x=Ba};this.setClearColorHex=function(Ca,Ba){t.setHex(Ca);x=Ba};this.clear=function(){m.setTransform(1,0,0,-1,k,j);if(!B.isEmpty()){B.inflate(1);
  162. B.minSelf(D);if(t.hex==0&&x==0)m.clearRect(B.getX(),B.getY(),B.getWidth(),B.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+x+")";m.fillRect(B.getX(),B.getY(),B.getWidth(),B.getHeight())}B.empty()}};this.render=function(Ca,Ba){function Ya(J){var Y,U,fa,za=J.lights;K.setRGB(0,0,0);ra.setRGB(0,0,0);Ea.setRGB(0,0,0);J=0;for(Y=za.length;J<Y;J++){U=za[J];fa=U.color;if(U instanceof THREE.AmbientLight){K.r+=fa.r;K.g+=
  163. fa.g;K.b+=fa.b}else if(U instanceof THREE.DirectionalLight){ra.r+=fa.r;ra.g+=fa.g;ra.b+=fa.b}else if(U instanceof THREE.PointLight){Ea.r+=fa.r;Ea.g+=fa.g;Ea.b+=fa.b}}}function ua(J,Y,U,fa){var za,qa,pa,R,Ka=J.lights;J=0;for(za=Ka.length;J<za;J++){qa=Ka[J];pa=qa.color;R=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=U.dot(qa.position)*R;if(qa>0){fa.r+=pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}else if(qa instanceof THREE.PointLight){$.sub(qa.position,Y);$.normalize();qa=U.dot($)*R;if(qa>0){fa.r+=
  164. pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}}}function ga(J,Y,U){a(U.opacity);c(U.blending);var fa,za,qa,pa,R,Ka;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){pa=U.map.image;R=pa.width>>1;Ka=pa.height>>1;U=Y.scale.x*k;qa=Y.scale.y*j;fa=U*R;za=qa*Ka;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(U,-qa);m.translate(-R,-Ka);m.drawImage(pa,0,0);m.restore()}}}else if(U instanceof THREE.ParticleCanvasMaterial){if(Z){N.r=K.r+ra.r+Ea.r;
  165. N.g=K.g+ra.g+Ea.g;N.b=K.b+ra.b+Ea.b;aa.r=U.color.r*N.r;aa.g=U.color.g*N.g;aa.b=U.color.b*N.b;aa.updateStyleString()}else aa.__styleString=U.color.__styleString;fa=Y.scale.x*k;za=Y.scale.y*j;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(fa,za);U.program(m,aa);m.restore()}}}function ha(J,Y,U,fa){a(fa.opacity);c(fa.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo(Y.positionScreen.x,Y.positionScreen.y);
  166. m.closePath();if(fa instanceof THREE.LineBasicMaterial){aa.__styleString=fa.color.__styleString;J=fa.linewidth;if(H!=J)m.lineWidth=H=J;J=aa.__styleString;if(z!=J)m.strokeStyle=z=J;m.stroke();F.inflate(fa.linewidth*2)}}function na(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;Sa(X,f,ea,ka,W,T);if(R instanceof THREE.MeshBasicMaterial)if(R.map){if(R.map.mapping instanceof
  167. THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}}else if(R.envMap){if(R.envMap.mapping instanceof THREE.SphericalReflectionMapping){J=Ba.matrixWorldInverse;$.copy(pa.vertexNormalsWorld[0]);ab=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;n=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[1]);C=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;p=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[2]);o=($.x*J.n11+
  168. $.y*J.n12+$.z*J.n13)*0.5+0.5;w=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;Ta(X,f,ea,ka,W,T,R.envMap.image,ab,n,C,p,o,w)}}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){if(R.map.mapping instanceof THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}c(THREE.SubtractiveBlending)}if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&
  169. pa.vertexNormalsWorld.length==3){P.r=M.r=da.r=K.r;P.g=M.g=da.g=K.g;P.b=M.b=da.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],M);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],da);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();
  170. R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta);da.r=da.g=da.b=1-Va(U.positionScreen.z,ia,ta);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){aa.r=
  171. Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}}function Pa(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);if(R.map||R.envMap){na(J,Y,fa,0,1,3,pa,R,Ka);na(za,U,qa,1,2,3,pa,R,Ka)}else{X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;xa=fa.positionScreen.x;ca=fa.positionScreen.y;Da=za.positionScreen.x;
  172. ja=za.positionScreen.y;oa=qa.positionScreen.x;la=qa.positionScreen.y;if(R instanceof THREE.MeshBasicMaterial){fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshLambertMaterial)if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&pa.vertexNormalsWorld.length==4){P.r=M.r=da.r=sa.r=K.r;P.g=M.g=da.g=sa.g=K.g;P.b=M.b=da.b=sa.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],
  173. M);ua(Ka,pa.v4.positionWorld,pa.vertexNormalsWorld[3],da);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],sa);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else{fb(X,f,
  174. ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshNormalMaterial){aa.r=Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta);
  175. da.r=da.g=da.b=1-Va(fa.positionScreen.z,ia,ta);sa.r=sa.g=sa.b=1-Va(U.positionScreen.z,ia,ta);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}}}function Sa(J,Y,U,fa,za,qa){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(J,Y);m.closePath()}function fb(J,Y,U,fa,za,qa,pa,R){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(pa,R);m.lineTo(J,Y);m.closePath()}function Na(J,Y){if(z!=J)m.strokeStyle=
  176. z=J;if(H!=Y)m.lineWidth=H=Y;m.stroke();F.inflate(Y*2)}function Xa(J){if(G!=J)m.fillStyle=G=J;m.fill()}function Ta(J,Y,U,fa,za,qa,pa,R,Ka,cb,Za,db,hb){var bb,eb;bb=pa.width-1;eb=pa.height-1;R*=bb;Ka*=eb;cb*=bb;Za*=eb;db*=bb;hb*=eb;U-=J;fa-=Y;za-=J;qa-=Y;cb-=R;Za-=Ka;db-=R;hb-=Ka;bb=cb*hb-db*Za;if(bb!=0){eb=1/bb;bb=(hb*U-Za*za)*eb;Za=(hb*fa-Za*qa)*eb;U=(cb*za-db*U)*eb;fa=(cb*qa-db*fa)*eb;J=J-bb*R-U*Ka;Y=Y-Za*R-fa*Ka;m.save();m.transform(bb,Za,U,fa,J,Y);m.clip();m.drawImage(pa,0,0);m.restore()}}function Ja(J,
  177. Y,U,fa){var za=~~(J.r*255),qa=~~(J.g*255);J=~~(J.b*255);var pa=~~(Y.r*255),R=~~(Y.g*255);Y=~~(Y.b*255);var Ka=~~(U.r*255),cb=~~(U.g*255);U=~~(U.b*255);var Za=~~(fa.r*255),db=~~(fa.g*255);fa=~~(fa.b*255);Ma[0]=za<0?0:za>255?255:za;Ma[1]=qa<0?0:qa>255?255:qa;Ma[2]=J<0?0:J>255?255:J;Ma[4]=pa<0?0:pa>255?255:pa;Ma[5]=R<0?0:R>255?255:R;Ma[6]=Y<0?0:Y>255?255:Y;Ma[8]=Ka<0?0:Ka>255?255:Ka;Ma[9]=cb<0?0:cb>255?255:cb;Ma[10]=U<0?0:U>255?255:U;Ma[12]=Za<0?0:Za>255?255:Za;Ma[13]=db<0?0:db>255?255:db;Ma[14]=fa<
  178. 0?0:fa>255?255:fa;ma.putImageData(Ga,0,0);Ia.drawImage(Aa,0,0);return wa}function Va(J,Y,U){J=(J-Y)/(U-Y);return J*J*(3-2*J)}function Oa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function L(J,Y){var U=Y.x-J.x,fa=Y.y-J.y,za=1/Math.sqrt(U*U+fa*fa);U*=za;fa*=za;Y.x+=U;Y.y+=fa;J.x-=U;J.y-=fa}var Qa,Ua,Fa,$a,Wa,Ha,Ra,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);b=d.projectScene(Ca,Ba,this.sortElements);(Z=Ca.lights.length>0)&&Ya(Ca);Qa=0;for(Ua=b.length;Qa<Ua;Qa++){Fa=b[Qa];F.empty();if(Fa instanceof
  179. THREE.RenderableParticle){E=Fa;E.x*=k;E.y*=j;$a=0;for(Wa=Fa.materials.length;$a<Wa;){va=Fa.materials[$a++];va.opacity!=0&&ga(E,Fa,va,Ca)}}else if(Fa instanceof THREE.RenderableLine){E=Fa.v1;I=Fa.v2;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.materials.length;$a<Wa;){va=Fa.materials[$a++];va.opacity!=0&&ha(E,I,Fa,va,Ca)}}}else if(Fa instanceof
  180. THREE.RenderableFace3){E=Fa.v1;I=Fa.v2;A=Fa.v3;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;A.positionScreen.x*=k;A.positionScreen.y*=j;if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,A.positionScreen);L(A.positionScreen,E.positionScreen)}F.add3Points(E.positionScreen.x,E.positionScreen.y,I.positionScreen.x,I.positionScreen.y,A.positionScreen.x,A.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<Wa;){va=
  181. Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&na(E,I,A,0,1,2,Fa,va,Ca)}else va.opacity!=0&&na(E,I,A,0,1,2,Fa,va,Ca)}}}else if(Fa instanceof THREE.RenderableFace4){E=Fa.v1;I=Fa.v2;A=Fa.v3;S=Fa.v4;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;A.positionScreen.x*=k;A.positionScreen.y*=j;S.positionScreen.x*=k;S.positionScreen.y*=j;Q.positionScreen.copy(I.positionScreen);
  182. O.positionScreen.copy(S.positionScreen);if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,S.positionScreen);L(S.positionScreen,E.positionScreen);L(A.positionScreen,Q.positionScreen);L(A.positionScreen,O.positionScreen)}F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);F.addPoint(A.positionScreen.x,A.positionScreen.y);F.addPoint(S.positionScreen.x,S.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<
  183. Wa;){va=Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&Pa(E,I,A,S,Q,O,Fa,va,Ca)}else va.opacity!=0&&Pa(E,I,A,S,Q,O,Fa,va,Ca)}}}B.addRectangle(F)}m.setTransform(1,0,0,1,0,0)}};
  184. THREE.SVGRenderer=function(){function a(ja,oa,la){var aa,P,M,da;aa=0;for(P=ja.lights.length;aa<P;aa++){M=ja.lights[aa];if(M instanceof THREE.DirectionalLight){da=oa.normalWorld.dot(M.position)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}else if(M instanceof THREE.PointLight){ea.sub(M.position,oa.centroidWorld);ea.normalize();da=oa.normalWorld.dot(ea)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}}}function c(ja,oa,la,aa,P,M){T=d(xa++);
  185. T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(M,aa,S);A.r=P.color.r*S.r;A.g=P.color.g*S.g;A.b=P.color.b*S.b;A.updateStyleString()}else A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){f=
  186. 1-P.__2near/(P.__farPlusNear-aa.z*P.__farMinusNear);A.setRGB(f,f,f)}else P instanceof THREE.MeshNormalMaterial&&A.setRGB(e(aa.normalWorld.x),e(aa.normalWorld.y),e(aa.normalWorld.z));P.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+P.wireframeLinewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframeLinecap+"; stroke-linejoin: "+P.wireframeLinejoin):T.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+P.opacity);k.appendChild(T)}
  187. function b(ja,oa,la,aa,P,M,da){T=d(xa++);T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)A.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(da,P,S);A.r=M.color.r*S.r;A.g=M.color.g*S.g;A.b=M.color.b*S.b;A.updateStyleString()}else A.__styleString=
  188. M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){f=1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);A.setRGB(f,f,f)}else M instanceof THREE.MeshNormalMaterial&&A.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));M.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):T.setAttribute("style","fill: "+
  189. A.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(T)}function d(ja){if(ka[ja]==null){ka[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");Da==0&&ka[ja].setAttribute("shape-rendering","crispEdges")}return ka[ja]}function e(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,t,x,y,q,z,G,H=new THREE.Rectangle,E=new THREE.Rectangle,I=!1,A=new THREE.Color(16777215),
  190. S=new THREE.Color(16777215),Q=new THREE.Color(0),O=new THREE.Color(0),X=new THREE.Color(0),f,ea=new THREE.Vector3,ka=[],W=[],T,xa,ca,Da=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":Da=1;break;case "low":Da=0}};this.setSize=function(ja,oa){j=ja;m=oa;t=j/2;x=m/2;k.setAttribute("viewBox",-t+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-t,-x,t,x)};this.clear=function(){for(;k.childNodes.length>
  191. 0;)k.removeChild(k.childNodes[0])};this.render=function(ja,oa){var la,aa,P,M,da,sa,ia,ta;this.autoClear&&this.clear();g=h.projectScene(ja,oa,this.sortElements);ca=xa=0;if(I=ja.lights.length>0){ia=ja.lights;Q.setRGB(0,0,0);O.setRGB(0,0,0);X.setRGB(0,0,0);la=0;for(aa=ia.length;la<aa;la++){P=ia[la];M=P.color;if(P instanceof THREE.AmbientLight){Q.r+=M.r;Q.g+=M.g;Q.b+=M.b}else if(P instanceof THREE.DirectionalLight){O.r+=M.r;O.g+=M.g;O.b+=M.b}else if(P instanceof THREE.PointLight){X.r+=M.r;X.g+=M.g;X.b+=
  192. M.b}}}la=0;for(aa=g.length;la<aa;la++){ia=g[la];E.empty();if(ia instanceof THREE.RenderableParticle){y=ia;y.x*=t;y.y*=-x;P=0;for(M=ia.materials.length;P<M;)P++}else if(ia instanceof THREE.RenderableLine){y=ia.v1;q=ia.v2;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.materials.length;P<M;)if((ta=ia.materials[P++])&&ta.opacity!=
  193. 0){da=y;sa=q;var ya=ca++;if(W[ya]==null){W[ya]=document.createElementNS("http://www.w3.org/2000/svg","line");Da==0&&W[ya].setAttribute("shape-rendering","crispEdges")}T=W[ya];T.setAttribute("x1",da.positionScreen.x);T.setAttribute("y1",da.positionScreen.y);T.setAttribute("x2",sa.positionScreen.x);T.setAttribute("y2",sa.positionScreen.y);if(ta instanceof THREE.LineBasicMaterial){A.__styleString=ta.color.__styleString;T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+
  194. ta.linewidth+"; stroke-opacity: "+ta.opacity+"; stroke-linecap: "+ta.linecap+"; stroke-linejoin: "+ta.linejoin);k.appendChild(T)}}}}else if(ia instanceof THREE.RenderableFace3){y=ia.v1;q=ia.v2;z=ia.v3;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;z.positionScreen.x*=t;z.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(E)){P=
  195. 0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&c(y,q,z,ia,ta,ja)}else ta&&ta.opacity!=0&&c(y,q,z,ia,ta,ja)}}}else if(ia instanceof THREE.RenderableFace4){y=ia.v1;q=ia.v2;z=ia.v3;G=ia.v4;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;z.positionScreen.x*=t;z.positionScreen.y*=-x;G.positionScreen.x*=t;G.positionScreen.y*=
  196. -x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(z.positionScreen.x,z.positionScreen.y);E.addPoint(G.positionScreen.x,G.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&b(y,q,z,G,ia,ta,ja)}else ta&&ta.opacity!=0&&b(y,q,z,G,ia,ta,ja)}}}}}};
  197. 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",
  198. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
  199. envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
  200. map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
  201. lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
  202. lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
  203. lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
  204. color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif",
  205. 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",
  206. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};
  207. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",
  208. value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},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",
  209. value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  210. THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
  211. value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
  212. THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
  213. THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
  214. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
  215. THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  216. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
  217. THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),
  218. vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  219. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
  220. THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
  221. THREE.WebGLRenderer=function(a){function c(n,C,p){var o,w,D,B=n.vertices,F=B.length,Z=n.colors,N=Z.length,K=n.__vertexArray,ra=n.__colorArray,Ea=n.__sortArray,$=n.__dirtyVertices,Aa=n.__dirtyColors;if(p.sortParticles){M.multiplySelf(p.matrixWorld);for(o=0;o<F;o++){w=B[o].position;ia.copy(w);M.multiplyVector3(ia);Ea[o]=[ia.z,o]}Ea.sort(function(ma,Ga){return Ga[0]-ma[0]});for(o=0;o<F;o++){w=B[Ea[o][1]].position;D=o*3;K[D]=w.x;K[D+1]=w.y;K[D+2]=w.z}for(o=0;o<N;o++){D=o*3;color=Z[Ea[o][1]];ra[D]=color.r;
  222. ra[D+1]=color.g;ra[D+2]=color.b}}else{if($)for(o=0;o<F;o++){w=B[o].position;D=o*3;K[D]=w.x;K[D+1]=w.y;K[D+2]=w.z}if(Aa)for(o=0;o<N;o++){color=Z[o];D=o*3;ra[D]=color.r;ra[D+1]=color.g;ra[D+2]=color.b}}if($||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,K,C)}if(Aa||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,ra,C)}}function b(n,C){n.fragmentShader=C.fragmentShader;n.vertexShader=C.vertexShader;n.uniforms=
  223. Uniforms.clone(C.uniforms)}function d(n,C,p,o,w){o.program||W.initMaterial(o,C,p,w);var D=o.program,B=D.uniforms,F=o.uniforms;if(D!=ea){f.useProgram(D);ea=D}f.uniformMatrix4fv(B.projectionMatrix,!1,da);if(p&&(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial||o instanceof THREE.LineBasicMaterial||o instanceof THREE.ParticleBasicMaterial)){F.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){F.fogNear.value=p.near;F.fogFar.value=
  224. p.far}else if(p instanceof THREE.FogExp2)F.fogDensity.value=p.density}if(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o.lights){var Z,N,K=0,ra=0,Ea=0,$,Aa,ma,Ga=ta,Ma=Ga.directional.colors,wa=Ga.directional.positions,Ia=Ga.point.colors,V=Ga.point.positions,Ca=0,Ba=0;p=N=N=0;for(Z=C.length;p<Z;p++){N=C[p];$=N.color;Aa=N.position;ma=N.intensity;if(N instanceof THREE.AmbientLight){K+=$.r;ra+=$.g;Ea+=$.b}else if(N instanceof THREE.DirectionalLight){N=Ca*3;Ma[N]=$.r*ma;
  225. Ma[N+1]=$.g*ma;Ma[N+2]=$.b*ma;wa[N]=Aa.x;wa[N+1]=Aa.y;wa[N+2]=Aa.z;Ca+=1}else if(N instanceof THREE.PointLight){N=Ba*3;Ia[N]=$.r*ma;Ia[N+1]=$.g*ma;Ia[N+2]=$.b*ma;V[N]=Aa.x;V[N+1]=Aa.y;V[N+2]=Aa.z;Ba+=1}}for(p=Ca*3;p<Ma.length;p++)Ma[p]=0;for(p=Ba*3;p<Ia.length;p++)Ia[p]=0;Ga.point.length=Ba;Ga.directional.length=Ca;Ga.ambient[0]=K;Ga.ambient[1]=ra;Ga.ambient[2]=Ea;C=ta;F.enableLighting.value=C.directional.length+C.point.length;F.ambientLightColor.value=C.ambient;F.directionalLightColor.value=C.directional.colors;
  226. F.directionalLightDirection.value=C.directional.positions;F.pointLightColor.value=C.point.colors;F.pointLightPosition.value=C.point.positions}if(o instanceof THREE.MeshBasicMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshPhongMaterial){F.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity;F.map.texture=o.map;F.lightMap.texture=o.lightMap;F.envMap.texture=o.envMap;F.reflectivity.value=o.reflectivity;F.refractionRatio.value=
  227. o.refractionRatio;F.combine.value=o.combine;F.useRefract.value=o.envMap&&o.envMap.mapping instanceof THREE.CubeRefractionMapping}if(o instanceof THREE.LineBasicMaterial){F.diffuse.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity}else if(o instanceof THREE.ParticleBasicMaterial){F.psColor.value.setRGB(o.color.r*o.opacity,o.color.g*o.opacity,o.color.b*o.opacity);F.opacity.value=o.opacity;F.size.value=o.size;F.scale.value=X.height/2;F.map.texture=o.map}else if(o instanceof
  228. THREE.MeshPhongMaterial){F.ambient.value.setRGB(o.ambient.r,o.ambient.g,o.ambient.b);F.specular.value.setRGB(o.specular.r,o.specular.g,o.specular.b);F.shininess.value=o.shininess}else if(o instanceof THREE.MeshDepthMaterial){F.mNear.value=n.near;F.mFar.value=n.far;F.opacity.value=o.opacity}else if(o instanceof THREE.MeshNormalMaterial)F.opacity.value=o.opacity;for(var Ya in F)if(K=D.uniforms[Ya]){p=F[Ya];Z=p.type;C=p.value;if(Z=="i")f.uniform1i(K,C);else if(Z=="f")f.uniform1f(K,C);else if(Z=="fv1")f.uniform1fv(K,
  229. C);else if(Z=="fv")f.uniform3fv(K,C);else if(Z=="v2")f.uniform2f(K,C.x,C.y);else if(Z=="v3")f.uniform3f(K,C.x,C.y,C.z);else if(Z=="c")f.uniform3f(K,C.r,C.g,C.b);else if(Z=="t"){f.uniform1i(K,C);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(p.needsUpdate){if(p.__wasSetOnce){f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(Z=0;Z<6;++Z)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,f.RGBA,f.UNSIGNED_BYTE,p.image[Z])}else{p.image.__webGLTextureCube=
  230. f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(Z=0;Z<6;++Z)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,p.image[Z]);p.__wasSetOnce=!0}I(f.TEXTURE_CUBE_MAP,p,p.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+C);f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(p.needsUpdate){if(p.__wasSetOnce){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.texSubImage2D(f.TEXTURE_2D,
  231. 0,0,0,f.RGBA,f.UNSIGNED_BYTE,p.image)}else{p.__webGLTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,p.image);p.__wasSetOnce=!0}I(f.TEXTURE_2D,p,p.image);f.bindTexture(f.TEXTURE_2D,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+C);f.bindTexture(f.TEXTURE_2D,p.__webGLTexture)}}}f.uniformMatrix4fv(B.modelViewMatrix,!1,w._modelViewMatrixArray);f.uniformMatrix3fv(B.normalMatrix,!1,w._normalMatrixArray);(o instanceof THREE.MeshShaderMaterial||
  232. o instanceof THREE.MeshPhongMaterial||o.envMap)&&f.uniform3f(B.cameraPosition,n.position.x,n.position.y,n.position.z);(o instanceof THREE.MeshShaderMaterial||o.envMap||o.skinning)&&f.uniformMatrix4fv(B.objectMatrix,!1,w._objectMatrixArray);(o instanceof THREE.MeshPhongMaterial||o instanceof THREE.MeshLambertMaterial||o instanceof THREE.MeshShaderMaterial||o.skinning)&&f.uniformMatrix4fv(B.viewMatrix,!1,sa);if(o.skinning){f.uniformMatrix4fv(B.cameraInverseMatrix,!1,sa);f.uniformMatrix4fv(B.boneGlobalMatrices,
  233. !1,w.boneMatrices)}return D}function e(n,C,p,o,w,D){if(o.opacity!=0){n=d(n,C,p,o,D).attributes;if(o.morphTargets){C=o.program.attributes;D.morphTargetBase!==-1?f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[D.morphTargetBase]):f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(C.position,3,f.FLOAT,!1,0,0);if(D.morphTargetForcedOrder.length){p=0;for(var B=D.morphTargetForcedOrder,F=D.morphTargetInfluences;p<o.numSupportedMorphTargets&&p<B.length;){f.bindBuffer(f.ARRAY_BUFFER,
  234. w.__webGLMorphTargetsBuffers[B[p]]);f.vertexAttribPointer(C["morphTarget"+p],3,f.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[p]=F[B[p]];p++}}else{B=[];var Z=-1,N=0;F=D.morphTargetInfluences;var K,ra=F.length;p=0;for(D.morphTargetBase!==-1&&(B[D.morphTargetBase]=!0);p<o.numSupportedMorphTargets;){for(K=0;K<ra;K++)if(!B[K]&&F[K]>Z){N=K;Z=F[N]}f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[N]);f.vertexAttribPointer(C["morphTarget"+p],3,f.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[p]=Z;B[N]=
  235. 1;Z=-1;p++}}f.uniform1fv(o.program.uniforms.morphTargetInfluences,D.__webGLMorphTargetInfluences)}else{f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(n.position,3,f.FLOAT,!1,0,0)}if(n.color>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLColorBuffer);f.vertexAttribPointer(n.color,3,f.FLOAT,!1,0,0)}if(n.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLNormalBuffer);f.vertexAttribPointer(n.normal,3,f.FLOAT,!1,0,0)}if(n.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLTangentBuffer);
  236. f.vertexAttribPointer(n.tangent,4,f.FLOAT,!1,0,0)}if(n.uv>=0)if(w.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUVBuffer);f.vertexAttribPointer(n.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(n.uv)}else f.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(w.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUV2Buffer);f.vertexAttribPointer(n.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(n.uv2)}else f.disableVertexAttribArray(n.uv2);if(o.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=
  237. 0&&n.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexABuffer);f.vertexAttribPointer(n.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexBBuffer);f.vertexAttribPointer(n.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinIndicesBuffer);f.vertexAttribPointer(n.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinWeightsBuffer);f.vertexAttribPointer(n.skinWeight,4,f.FLOAT,!1,0,0)}if(D instanceof THREE.Mesh)if(o.wireframe){f.lineWidth(o.wireframeLinewidth);
  238. f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);f.drawElements(f.LINES,w.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,w.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(D instanceof THREE.Line){D=D.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(o.linewidth);f.drawArrays(D,0,w.__webGLLineCount)}else if(D instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,w.__webGLParticleCount);else D instanceof THREE.Ribbon&&
  239. f.drawArrays(f.TRIANGLE_STRIP,0,w.__webGLVertexCount)}}function g(n,C){if(!n.__webGLVertexBuffer)n.__webGLVertexBuffer=f.createBuffer();if(!n.__webGLNormalBuffer)n.__webGLNormalBuffer=f.createBuffer();if(n.hasPos){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,n.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.position);f.vertexAttribPointer(C.attributes.position,3,f.FLOAT,!1,0,0)}if(n.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,n.__webGLNormalBuffer);
  240. f.bufferData(f.ARRAY_BUFFER,n.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.normal);f.vertexAttribPointer(C.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,n.count);n.count=0}function h(n){if(T!=n.doubleSided){n.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);T=n.doubleSided}if(xa!=n.flipSided){n.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);xa=n.flipSided}}function k(n){if(Da!=n){n?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);Da=n}}function j(n){P[0].set(n.n41-
  241. n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);P[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);P[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);P[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);P[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);P[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var C;for(n=0;n<6;n++){C=P[n];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function m(n){for(var C=n.matrixWorld,p=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,
  242. Math.max(n.scale.y,n.scale.z)),o=0;o<6;o++){n=P[o].x*C.n14+P[o].y*C.n24+P[o].z*C.n34+P[o].w;if(n<=p)return!1}return!0}function t(n,C){n.list[n.count]=C;n.count+=1}function x(n){var C,p,o=n.object,w=n.opaque,D=n.transparent;D.count=0;n=w.count=0;for(C=o.materials.length;n<C;n++){p=o.materials[n];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?t(D,p):t(w,p)}}function y(n){var C,p,o,w,D=n.object,B=n.buffer,F=n.opaque,Z=n.transparent;Z.count=0;n=F.count=0;for(o=D.materials.length;n<o;n++){C=
  243. D.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=0;for(p=B.materials.length;C<p;C++)(w=B.materials[C])&&(w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w))}else{w=C;w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w)}}}function q(n,C){return C.z-n.z}function z(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function G(n){function C(Ea){var $=
  244. [];p=0;for(o=Ea.length;p<o;p++)Ea[p]==undefined?$.push("undefined"):$.push(Ea[p].id);return $.join("_")}var p,o,w,D,B,F,Z,N,K={},ra=n.morphTargets!==undefined?n.morphTargets.length:0;n.geometryGroups={};w=0;for(D=n.faces.length;w<D;w++){B=n.faces[w];F=B.materials;Z=C(F);K[Z]==undefined&&(K[Z]={hash:Z,counter:0});N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra});B=B instanceof THREE.Face3?3:4;if(n.geometryGroups[N].vertices+
  245. B>65535){K[Z].counter+=1;N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra})}n.geometryGroups[N].faces.push(w);n.geometryGroups[N].vertices+=B}}function H(n,C,p){n.push({buffer:C,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function E(n){if(n!=ca){switch(n){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,
  246. f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ca=n}}function I(n,C,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(n,f.TEXTURE_WRAP_S,O(C.wrapS));f.texParameteri(n,f.TEXTURE_WRAP_T,O(C.wrapT));f.texParameteri(n,f.TEXTURE_MAG_FILTER,
  247. O(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,O(C.minFilter));f.generateMipmap(n)}else{f.texParameteri(n,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_MAG_FILTER,Q(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,Q(C.minFilter))}}function A(n){if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=f.createFramebuffer();n.__webGLRenderbuffer=f.createRenderbuffer();n.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,
  248. n.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,n.width,n.height);f.bindTexture(f.TEXTURE_2D,n.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,O(n.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,O(n.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,O(n.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,O(n.minFilter));f.texImage2D(f.TEXTURE_2D,0,O(n.format),n.width,n.height,0,O(n.format),O(n.type),null);f.bindFramebuffer(f.FRAMEBUFFER,
  249. n.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,n.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,n.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var C,p;if(n){C=n.__webGLFramebuffer;p=n.width;n=n.height}else{C=null;p=la;n=aa}if(C!=ka){f.bindFramebuffer(f.FRAMEBUFFER,C);f.viewport(ja,oa,p,n);ka=C}}function S(n,C){var p;if(n==
  250. "fragment")p=f.createShader(f.FRAGMENT_SHADER);else n=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,C);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));console.error(C);return null}return p}function Q(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}
  251. function O(n){switch(n){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;
  252. case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}
  253. var X=document.createElement("canvas"),f,ea=null,ka=null,W=this,T=null,xa=null,ca=null,Da=null,ja=0,oa=0,la=0,aa=0,P=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Matrix4,da=new Float32Array(16),sa=new Float32Array(16),ia=new THREE.Vector4,ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},ya=!0,La=new THREE.Color(0),ab=0;if(a){if(a.antialias!==undefined)ya=a.antialias;
  254. a.clearColor!==undefined&&La.setHex(a.clearColor);if(a.clearAlpha!==undefined)ab=a.clearAlpha}this.maxMorphTargets=8;this.domElement=X;this.autoClear=!0;this.sortObjects=!0;(function(n,C,p){try{if(!(f=X.getContext("experimental-webgl",{antialias:n})))throw"Error creating WebGL context.";}catch(o){console.error(o)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);
  255. f.clearColor(C.r,C.g,C.b,p);_cullEnabled=!0})(ya,La,ab);this.context=f;this.setSize=function(n,C){X.width=n;X.height=C;this.setViewport(0,0,X.width,X.height)};this.setViewport=function(n,C,p,o){ja=n;oa=C;la=p;aa=o;f.viewport(ja,oa,la,aa)};this.setScissor=function(n,C,p,o){f.scissor(n,C,p,o)};this.enableScissorTest=function(n){n?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){f.depthMask(n)};this.setClearColorHex=function(n,C){var p=new THREE.Color(n);f.clearColor(p.r,
  256. p.g,p.b,C)};this.setClearColor=function(n,C){f.clearColor(n.r,n.g,n.b,C)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(n,C,p,o){var w,D,B;if(n instanceof THREE.MeshDepthMaterial)b(n,THREE.ShaderLib.depth);else if(n instanceof THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial)b(n,THREE.ShaderLib.basic);else if(n instanceof THREE.MeshLambertMaterial)b(n,THREE.ShaderLib.lambert);else if(n instanceof THREE.MeshPhongMaterial)b(n,
  257. THREE.ShaderLib.phong);else if(n instanceof THREE.LineBasicMaterial)b(n,THREE.ShaderLib.basic);else n instanceof THREE.ParticleBasicMaterial&&b(n,THREE.ShaderLib.particle_basic);var F,Z,N,K;B=N=K=0;for(F=C.length;B<F;B++){Z=C[B];Z instanceof THREE.DirectionalLight&&N++;Z instanceof THREE.PointLight&&K++}if(K+N<=4)C=N;else{C=Math.ceil(4*N/(K+N));K=4-C}B={directional:C,point:K};F=50;if(o!==undefined&&o instanceof THREE.SkinnedMesh)F=o.bones.length;K=n.fragmentShader;C=n.vertexShader;F={fog:p,map:n.map,
  258. envMap:n.envMap,lightMap:n.lightMap,vertexColors:n.vertexColors,sizeAttenuation:n.sizeAttenuation,skinning:n.skinning,morphTargets:n.morphTargets,maxDirLights:B.directional,maxPointLights:B.point,maxBones:F};p=f.createProgram();B=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.fog?"#define USE_FOG":"",F.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":
  259. "",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");F=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,"#define MAX_BONES "+F.maxBones,F.map?"#define USE_MAP":"",F.envMap?"#define USE_ENVMAP":"",F.lightMap?"#define USE_LIGHTMAP":"",F.vertexColors?"#define USE_COLOR":"",F.skinning?"#define USE_SKINNING":
  260. "",F.morphTargets?"#define USE_MORPHTARGETS":"",F.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 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
  261. f.attachShader(p,S("fragment",B+K));f.attachShader(p,S("vertex",F+C));f.linkProgram(p);f.getProgramParameter(p,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};n.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in n.uniforms)p.push(w);
  262. w=n.program;K=0;for(C=p.length;K<C;K++){B=p[K];w.uniforms[B]=f.getUniformLocation(w,B)}p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<this.maxMorphTargets;w++)p.push("morphTarget"+w);for(D in n.attributes)p.push(D);D=n.program;w=p;p=0;for(K=w.length;p<K;p++){C=w[p];D.attributes[C]=f.getAttribLocation(D,C)}D=n.program.attributes;f.enableVertexAttribArray(D.position);D.color>=0&&f.enableVertexAttribArray(D.color);D.normal>=0&&f.enableVertexAttribArray(D.normal);
  263. D.tangent>=0&&f.enableVertexAttribArray(D.tangent);if(n.skinning&&D.skinVertexA>=0&&D.skinVertexB>=0&&D.skinIndex>=0&&D.skinWeight>=0){f.enableVertexAttribArray(D.skinVertexA);f.enableVertexAttribArray(D.skinVertexB);f.enableVertexAttribArray(D.skinIndex);f.enableVertexAttribArray(D.skinWeight)}if(n.morphTargets){n.numSupportedMorphTargets=0;if(D.morphTarget0>=0){f.enableVertexAttribArray(D.morphTarget0);n.numSupportedMorphTargets++}if(D.morphTarget1>=0){f.enableVertexAttribArray(D.morphTarget1);
  264. n.numSupportedMorphTargets++}if(D.morphTarget2>=0){f.enableVertexAttribArray(D.morphTarget2);n.numSupportedMorphTargets++}if(D.morphTarget3>=0){f.enableVertexAttribArray(D.morphTarget3);n.numSupportedMorphTargets++}if(D.morphTarget4>=0){f.enableVertexAttribArray(D.morphTarget4);n.numSupportedMorphTargets++}if(D.morphTarget5>=0){f.enableVertexAttribArray(D.morphTarget5);n.numSupportedMorphTargets++}if(D.morphTarget6>=0){f.enableVertexAttribArray(D.morphTarget6);n.numSupportedMorphTargets++}if(D.morphTarget7>=
  265. 0){f.enableVertexAttribArray(D.morphTarget7);n.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(w=0;w<this.maxMorphTargets;w++)o.__webGLMorphTargetInfluences[w]=0}};this.render=function(n,C,p,o){var w,D,B,F,Z,N,K,ra,Ea=n.lights,$=n.fog;C.matrixAutoUpdate&&C.updateMatrix();n.update(undefined,!1,C);C.matrixWorldInverse.flattenToArray(sa);C.projectionMatrix.flattenToArray(da);M.multiply(C.projectionMatrix,C.matrixWorldInverse);j(M);this.initWebGLObjects(n);
  266. A(p);(this.autoClear||o)&&this.clear();Z=n.__webglObjects.length;for(o=0;o<Z;o++){w=n.__webglObjects[o];K=w.object;if(K.visible)if(!(K instanceof THREE.Mesh)||m(K)){K.matrixWorld.flattenToArray(K._objectMatrixArray);z(K,C);y(w);w.render=!0;if(this.sortObjects){ia.copy(K.position);M.multiplyVector3(ia);w.z=ia.z}}else w.render=!1;else w.render=!1}this.sortObjects&&n.__webglObjects.sort(q);N=n.__webglObjectsImmediate.length;for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){K.matrixAutoUpdate&&
  267. K.matrixWorld.flattenToArray(K._objectMatrixArray);z(K,C);x(w)}}E(THREE.NormalBlending);for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=w.buffer;B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=
  268. w.buffer;B=w.transparent;h(K);for(w=0;w<B.count;w++){F=B.list[w];E(F.blending);k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.transparent;h(K);for(w=0;w<B.count;w++){F=B.list[w];E(F.blending);k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}if(p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}};
  269. this.initWebGLObjects=function(n){if(!n.__webglObjects){n.__webglObjects=[];n.__webglObjectsImmediate=[]}for(;n.__objectsAdded.length;){var C=n.__objectsAdded[0],p=n,o=void 0,w=void 0,D=void 0;if(C._modelViewMatrix==undefined){C._modelViewMatrix=new THREE.Matrix4;C._normalMatrixArray=new Float32Array(9);C._modelViewMatrixArray=new Float32Array(16);C._objectMatrixArray=new Float32Array(16);C.matrixWorld.flattenToArray(C._objectMatrixArray)}if(C instanceof THREE.Mesh){w=C.geometry;w.geometryGroups==
  270. undefined&&G(w);for(o in w.geometryGroups){D=w.geometryGroups[o];if(!D.__webGLVertexBuffer){var B=D;B.__webGLVertexBuffer=f.createBuffer();B.__webGLNormalBuffer=f.createBuffer();B.__webGLTangentBuffer=f.createBuffer();B.__webGLColorBuffer=f.createBuffer();B.__webGLUVBuffer=f.createBuffer();B.__webGLUV2Buffer=f.createBuffer();B.__webGLSkinVertexABuffer=f.createBuffer();B.__webGLSkinVertexBBuffer=f.createBuffer();B.__webGLSkinIndicesBuffer=f.createBuffer();B.__webGLSkinWeightsBuffer=f.createBuffer();
  271. B.__webGLFaceBuffer=f.createBuffer();B.__webGLLineBuffer=f.createBuffer();if(B.numMorphTargets){var F=void 0,Z=void 0;B.__webGLMorphTargetsBuffers=[];F=0;for(Z=B.numMorphTargets;F<Z;F++)B.__webGLMorphTargetsBuffers.push(f.createBuffer())}B=D;var N=C,K=void 0,ra=void 0,Ea=Z=F=0;K=void 0;ra=void 0;var $=void 0;ra=void 0;var Aa=N.geometry;$=Aa.faces;var ma=B.faces;K=0;for(ra=ma.length;K<ra;K++){fi=ma[K];face=$[fi];if(face instanceof THREE.Face3){F+=3;Z+=1;Ea+=3}else if(face instanceof THREE.Face4){F+=
  272. 4;Z+=2;Ea+=4}}K=B;ra=N;$=void 0;ma=void 0;var Ga=void 0,Ma=void 0;Ga=void 0;var wa=[];$=0;for(ma=ra.materials.length;$<ma;$++){Ga=ra.materials[$];if(Ga instanceof THREE.MeshFaceMaterial){Ga=0;for(l=K.materials.length;Ga<l;Ga++)(Ma=K.materials[Ga])&&wa.push(Ma)}else(Ma=Ga)&&wa.push(Ma)}ra=wa;a:{K=void 0;$=void 0;ma=ra.length;for(K=0;K<ma;K++){$=ra[K];if($.map||$.lightMap||$ instanceof THREE.MeshShaderMaterial){K=!0;break a}}K=!1}a:{$=ra;ma=void 0;wa=void 0;Ga=$.length;for(ma=0;ma<Ga;ma++){wa=$[ma];
  273. if(!(wa instanceof THREE.MeshBasicMaterial&&!wa.envMap||wa instanceof THREE.MeshDepthMaterial)){$=wa&&wa.shading!=undefined&&wa.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}$=!1}a:{ma=void 0;wa=void 0;Ga=ra.length;for(ma=0;ma<Ga;ma++){wa=ra[ma];if(wa.vertexColors){ra=wa.vertexColors;break a}}ra=!1}B.__vertexArray=new Float32Array(F*3);if($)B.__normalArray=new Float32Array(F*3);if(Aa.hasTangents)B.__tangentArray=new Float32Array(F*4);if(ra)B.__colorArray=new Float32Array(F*
  274. 3);if(K){if(Aa.faceUvs.length>0||Aa.faceVertexUvs.length>0)B.__uvArray=new Float32Array(F*2);if(Aa.faceUvs.length>1||Aa.faceVertexUvs.length>1)B.__uv2Array=new Float32Array(F*2)}if(N.geometry.skinWeights.length&&N.geometry.skinIndices.length){B.__skinVertexAArray=new Float32Array(F*4);B.__skinVertexBArray=new Float32Array(F*4);B.__skinIndexArray=new Float32Array(F*4);B.__skinWeightArray=new Float32Array(F*4)}B.__faceArray=new Uint16Array(Z*3);B.__lineArray=new Uint16Array(Ea*2);if(B.numMorphTargets){N=
  275. void 0;Aa=void 0;B.__morphTargetsArrays=[];N=0;for(Aa=B.numMorphTargets;N<Aa;N++)B.__morphTargetsArrays.push(new Float32Array(F*3))}B.__needsSmoothNormals=$==THREE.SmoothShading;B.__uvType=K;B.__vertexColorType=ra;B.__normalType=$;B.__webGLFaceCount=Z*3;B.__webGLLineCount=Ea*2;w.__dirtyVertices=!0;w.__dirtyMorphTargets=!0;w.__dirtyElements=!0;w.__dirtyUvs=!0;w.__dirtyNormals=!0;w.__dirtyTangents=!0;w.__dirtyColors=!0}H(p.__webglObjects,D,C)}}else if(C instanceof THREE.Ribbon){w=C.geometry;if(!w.__webGLVertexBuffer){o=
  276. w;o.__webGLVertexBuffer=f.createBuffer();o.__webGLColorBuffer=f.createBuffer();o=w;D=o.vertices.length;o.__vertexArray=new Float32Array(D*3);o.__colorArray=new Float32Array(D*3);o.__webGLVertexCount=D;w.__dirtyVertices=!0;w.__dirtyColors=!0}H(p.__webglObjects,w,C)}else if(C instanceof THREE.Line){w=C.geometry;if(!w.__webGLVertexBuffer){o=w;o.__webGLVertexBuffer=f.createBuffer();o.__webGLColorBuffer=f.createBuffer();o=w;D=o.vertices.length;o.__vertexArray=new Float32Array(D*3);o.__colorArray=new Float32Array(D*
  277. 3);o.__webGLLineCount=D;w.__dirtyVertices=!0;w.__dirtyColors=!0}H(p.__webglObjects,w,C)}else if(C instanceof THREE.ParticleSystem){w=C.geometry;if(!w.__webGLVertexBuffer){o=w;o.__webGLVertexBuffer=f.createBuffer();o.__webGLColorBuffer=f.createBuffer();o=w;D=o.vertices.length;o.__vertexArray=new Float32Array(D*3);o.__colorArray=new Float32Array(D*3);o.__sortArray=[];o.__webGLParticleCount=D;w.__dirtyVertices=!0;w.__dirtyColors=!0}H(p.__webglObjects,w,C)}else THREE.MarchingCubes!==undefined&&C instanceof
  278. THREE.MarchingCubes&&p.__webglObjectsImmediate.push({object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}});n.__objectsAdded.splice(0,1)}for(;n.__objectsRemoved.length;){C=n.__objectsRemoved[0];p=n;w=void 0;o=void 0;for(w=p.__webglObjects.length-1;w>=0;w--){o=p.__webglObjects[w].object;C==o&&p.__webglObjects.splice(w,1)}n.__objectsRemoved.splice(0,1)}C=0;for(p=n.__webglObjects.length;C<p;C++){o=n.__webglObjects[C].object;D=void 0;w=void 0;B=void 0;if(o instanceof THREE.Mesh){w=o.geometry;
  279. for(D in w.geometryGroups){B=w.geometryGroups[D];if(w.__dirtyVertices||w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents){F=f.DYNAMIC_DRAW;Z=void 0;Ea=void 0;var Ia=void 0,V=void 0;Ia=void 0;var Ca=void 0,Ba=void 0,Ya=void 0,ua=void 0;N=void 0;Aa=void 0;K=void 0;ra=void 0;$=void 0;var ga=void 0,ha=void 0,na=void 0,Pa=void 0;Ba=void 0;Ya=void 0;V=void 0;ua=void 0;V=void 0;ga=void 0;ha=void 0;Ba=void 0;ga=void 0;ha=void 0;na=void 0;Pa=void 0;
  280. ga=void 0;ha=void 0;na=void 0;Pa=void 0;ga=void 0;ha=void 0;na=void 0;Pa=void 0;ga=void 0;ha=void 0;na=void 0;V=void 0;ua=void 0;Ca=void 0;Ia=void 0;Ia=void 0;var Sa=void 0,fb=void 0,Na=void 0,Xa=Ma=Ga=wa=ma=0,Ta=0,Ja=0,Va=0,Oa=0,L=0,Qa=0,Ua=B.__vertexArray,Fa=B.__uvArray,$a=B.__uv2Array,Wa=B.__normalArray,Ha=B.__tangentArray,Ra=B.__colorArray,va=B.__skinVertexAArray,J=B.__skinVertexBArray,Y=B.__skinIndexArray,U=B.__skinWeightArray,fa=B.__morphTargetsArrays,za=B.__faceArray,qa=B.__lineArray,pa=B.__needsSmoothNormals;
  281. Aa=B.__vertexColorType;N=B.__uvType;K=B.__normalType;var R=o.geometry,Ka=R.__dirtyVertices,cb=R.__dirtyElements,Za=R.__dirtyUvs,db=R.__dirtyNormals,hb=R.__dirtyTangents,bb=R.__dirtyColors,eb=R.__dirtyMorphTargets,jb=R.vertices,nb=B.faces,qb=R.faces,ob=R.faceVertexUvs[0],pb=R.faceVertexUvs[1],kb=R.skinVerticesA,lb=R.skinVerticesB,mb=R.skinIndices,ib=R.skinWeights,gb=R.morphTargets;Z=0;for(Ea=nb.length;Z<Ea;Z++){Ia=nb[Z];V=qb[Ia];ob&&(ra=ob[Ia]);pb&&($=pb[Ia]);Ia=V.vertexNormals;Ca=V.normal;Ba=V.vertexColors;
  282. Ya=V.color;ua=V.vertexTangents;if(V instanceof THREE.Face3){if(Ka){ga=jb[V.a].position;ha=jb[V.b].position;na=jb[V.c].position;Ua[wa]=ga.x;Ua[wa+1]=ga.y;Ua[wa+2]=ga.z;Ua[wa+3]=ha.x;Ua[wa+4]=ha.y;Ua[wa+5]=ha.z;Ua[wa+6]=na.x;Ua[wa+7]=na.y;Ua[wa+8]=na.z;wa+=9}if(eb){Sa=0;for(fb=gb.length;Sa<fb;Sa++){ga=gb[Sa].vertices[V.a].position;ha=gb[Sa].vertices[V.b].position;na=gb[Sa].vertices[V.c].position;Na=fa[Sa];Na[Qa+0]=ga.x;Na[Qa+1]=ga.y;Na[Qa+2]=ga.z;Na[Qa+3]=ha.x;Na[Qa+4]=ha.y;Na[Qa+5]=ha.z;Na[Qa+6]=na.x;
  283. Na[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(cb){za[Xa]=ma;za[Xa+1]=ma+1;za[Xa+2]=ma+3;za[Xa+3]=ma+1;za[Xa+4]=ma+2;za[Xa+5]=ma+3;Xa+=6;qa[Va]=ma;qa[Va+1]=ma+1;qa[Va+2]=ma;qa[Va+3]=ma+3;qa[Va+4]=ma+1;qa[Va+5]=ma+2;qa[Va+6]=ma+2;qa[Va+7]=ma+3;Va+=8;ma+=4}}}if(Ka){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Ua,
  292. F)}if(eb){Sa=0;for(fb=gb.length;Sa<fb;Sa++){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLMorphTargetsBuffers[Sa]);f.bufferData(f.ARRAY_BUFFER,fa[Sa],F)}}if(bb&&Oa>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ra,F)}if(db){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Wa,F)}if(hb&&R.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Ha,F)}if(Za&&Ga>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUVBuffer);
  293. f.bufferData(f.ARRAY_BUFFER,Fa,F)}if(Za&&Ma>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,$a,F)}if(cb){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,za,F);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,qa,F)}if(L>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,va,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,
  294. J,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,Y,F);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,U,F)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(o instanceof THREE.Ribbon){w=o.geometry;if(w.__dirtyVertices||w.__dirtyColors){o=w;D=f.DYNAMIC_DRAW;N=void 0;N=void 0;Aa=void 0;B=void 0;K=o.vertices;F=o.colors;ra=K.length;
  295. Z=F.length;$=o.__vertexArray;Ea=o.__colorArray;ma=o.__dirtyColors;if(o.__dirtyVertices){for(N=0;N<ra;N++){Aa=K[N].position;B=N*3;$[B]=Aa.x;$[B+1]=Aa.y;$[B+2]=Aa.z}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,$,D)}if(ma){for(N=0;N<Z;N++){color=F[N];B=N*3;Ea[B]=color.r;Ea[B+1]=color.g;Ea[B+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ea,D)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(o instanceof THREE.Line){w=o.geometry;
  296. if(w.__dirtyVertices||w.__dirtyColors){o=w;D=f.DYNAMIC_DRAW;N=void 0;N=void 0;Aa=void 0;B=void 0;K=o.vertices;F=o.colors;ra=K.length;Z=F.length;$=o.__vertexArray;Ea=o.__colorArray;ma=o.__dirtyColors;if(o.__dirtyVertices){for(N=0;N<ra;N++){Aa=K[N].position;B=N*3;$[B]=Aa.x;$[B+1]=Aa.y;$[B+2]=Aa.z}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,$,D)}if(ma){for(N=0;N<Z;N++){color=F[N];B=N*3;Ea[B]=color.r;Ea[B+1]=color.g;Ea[B+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);
  297. f.bufferData(f.ARRAY_BUFFER,Ea,D)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(o instanceof THREE.ParticleSystem){w=o.geometry;(w.__dirtyVertices||w.__dirtyColors||o.sortParticles)&&c(w,f.DYNAMIC_DRAW,o);w.__dirtyVertices=!1;w.__dirtyColors=!1}}};this.setFaceCulling=function(n,C){if(n){!C||C=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW);if(n=="back")f.cullFace(f.BACK);else n=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK);f.enable(f.CULL_FACE)}else f.disable(f.CULL_FACE)};this.supportsVertexTextures=
  298. function(){return f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  299. THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,e=b.length;for(d=0;d<e;d++){a=b[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(c.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
  300. 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)};
  301. THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
  302. THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
  303. THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
  304. var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,k=a.faces,j=e.faces,m=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,x=h.length;t<x;t++){var y=new THREE.Vertex(h[t].position.clone());b&&c.matrix.multiplyVector3(y.position);g.push(y)}t=0;for(x=j.length;t<x;t++){h=j[t];var q,z,G=h.vertexNormals;y=h.vertexColors;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+
  305. d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));q.normal.copy(h.normal);b=0;for(g=G.length;b<g;b++){z=G[b];q.vertexNormals.push(z.clone())}q.color.copy(h.color);b=0;for(g=y.length;b<g;b++){z=y[b];q.vertexColors.push(z.clone())}q.materials=h.materials.slice();q.centroid.copy(h.centroid);k.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];k=[];b=0;for(g=d.length;b<g;b++)k.push(new THREE.UV(d[b].u,d[b].v));m.push(k)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=
  306. new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,c,b){var d,e=[],g=new THREE.Texture(e,c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(t in X.objects)if(!ca.objects[t]){G=X.objects[t];if(A=ca.geometries[G.geometry]){O=
  307. [];for(i=0;i<G.materials.length;i++)O[i]=ca.materials[G.materials[i]];H=G.position;r=G.rotation;s=G.scale;object=new THREE.Mesh(A,O);object.position.set(H[0],H[1],H[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=G.visible;ca.scene.addObject(object);ca.objects[t]=object}}}function h(Da){return function(ja){ca.geometries[Da]=ja;g();ka-=1;k()}}function k(){d({total_models:T,total_textures:xa,loaded_models:T-ka,loaded_textures:xa-W},ca);ka==0&&W==0&&b(ca)}var j,
  308. m,t,x,y,q,z,G,H,E,I,A,S,Q,O,X,f,ea,ka,W,T,xa,ca;X=e.data;f=new THREE.BinaryLoader;ea=new THREE.JSONLoader;W=ka=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};e=function(){W-=1;k()};for(y in X.cameras){E=X.cameras[y];if(E.type=="perspective")S=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho"){S=new THREE.Camera;S.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far)}H=E.position;E=E.target;
  309. S.position.set(H[0],H[1],H[2]);S.target.position.set(E[0],E[1],E[2]);ca.cameras[y]=S}for(x in X.lights){y=X.lights[x];if(y.type=="directional"){H=y.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],H[2]);light.position.normalize()}else if(y.type=="point"){H=y.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}E=y.color;i=y.intensity||1;light.color.setRGB(E[0]*i,E[1]*i,E[2]*i);ca.scene.addLight(light);ca.lights[x]=light}for(q in X.fogs){x=X.fogs[q];if(x.type==
  310. "linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));E=x.color;Q.color.setRGB(E[0],E[1],E[2]);ca.fogs[q]=Q}if(ca.cameras&&X.defaults.camera)ca.currentCamera=ca.cameras[X.defaults.camera];if(ca.fogs&&X.defaults.fog)ca.scene.fog=ca.fogs[X.defaults.fog];E=X.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(E[0],E[1],E[2]);ca.bgColorAlpha=X.defaults.bgalpha;for(j in X.geometries){q=X.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")ka+=
  311. 1}T=ka;for(j in X.geometries){q=X.geometries[j];if(q.type=="cube"){A=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);ca.geometries[j]=A}else if(q.type=="plane"){A=new Plane(q.width,q.height,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=A}else if(q.type=="sphere"){A=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=A}else if(q.type=="cylinder"){A=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);
  312. ca.geometries[j]=A}else if(q.type=="torus"){A=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);ca.geometries[j]=A}else if(q.type=="icosahedron"){A=new Icosahedron(q.subdivisions);ca.geometries[j]=A}else if(q.type=="bin_mesh")f.load({model:q.url,callback:h(j)});else q.type=="ascii_mesh"&&ea.load({model:q.url,callback:h(j)})}for(z in X.textures){j=X.textures[z];W+=j.url instanceof Array?j.url.length:1}xa=W;for(z in X.textures){j=X.textures[z];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=
  313. new THREE[j.mapping];if(j.url instanceof Array)q=ImageUtils.loadTextureCube(j.url,j.mapping,e);else{q=ImageUtils.loadTexture(j.url,j.mapping,e);if(THREE[j.minFilter]!=undefined)q.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)q.magFilter=THREE[j.magFilter]}ca.textures[z]=q}for(m in X.materials){z=X.materials[m];for(I in z.parameters)if(I=="envMap"||I=="map"||I=="lightMap")z.parameters[I]=ca.textures[z.parameters[I]];else if(I=="shading")z.parameters[I]=z.parameters[I]=="flat"?THREE.FlatShading:
  314. THREE.SmoothShading;else if(I=="blending")z.parameters[I]=THREE[z.parameters[I]]?THREE[z.parameters[I]]:THREE.NormalBlending;else I=="combine"&&(z.parameters[I]=z.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);z=new THREE[z.type](z.parameters);ca.materials[m]=z}g();c(ca)}},addMesh:function(a,c,b,d,e,g,h,k,j,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=k;c.rotation.z=j;a.addObject(c);return c},
  315. addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
  316. d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,
  317. c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,e=a.children.length;
  318. for(d=0;d<e;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},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}",
  319. 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}"},
  320. normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
  321. uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
  322. vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
  323. cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
  324. value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
  325. film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
  326. screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
  327. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,d,e,g=2*Math.ceil(a*3)+1;g>25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c<g;++c){b[c]=Math.exp(-((c-e)*(c-e))/(2*a*a));d+=b[c]}for(c=0;c<g;++c)b[c]/=d;return b}};
  328. THREE.QuakeCamera=function(a){function c(b,d){return function(){d.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
  329. a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
  330. this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=
  331. !1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
  332. !1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);
  333. var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(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;b=this.target.position;var d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},
  334. !1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
  335. THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
  336. THREE.PathCamera=function(a){function c(m,t,x,y){var q={name:x,fps:0.6,length:y,hierarchy:[]},z,G=t.getControlPointsArray(),H=t.getLength(),E=G.length,I=0;z=E-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[z]={time:y,pos:G[z],rot:[0,0,0,1],scl:[1,1,1]};for(z=1;z<E-1;z++){I=y*H.chunks[z]/H.total;t.keys[z]={time:I,pos:G[z]}}q.hierarchy[0]=t;THREE.AnimationHandler.add(q);return new THREE.Animation(m,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,t){var x,
  337. y,q=new THREE.Geometry;for(x=0;x<m.points.length*t;x++){y=x/(m.points.length*t);y=m.getPoint(y);q.vertices[x]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return q}function d(m,t){var x=b(t,10),y=b(t,10),q=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(x,q);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);m.addChild(lineObj);particleObj.scale.set(1,1,1);m.addChild(particleObj);y=new Sphere(1,
  338. 16,8);q=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<t.points.length;i++){x=new THREE.Mesh(y,q);x.position.copy(t.points[i]);x.updateMatrix();m.addChild(x)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
  339. !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
  340. if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
  341. this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,g=Math.PI/180;this.update=function(m,t,x){var y,q;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;y=this.phi%e;this.phi=y>=0?y:y+e;y=this.verticalAngleMap.srcRange;q=this.verticalAngleMap.dstRange;
  342. this.phi=(this.phi-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.horizontalAngleMap.srcRange;q=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,m,t,x)};this.onMouseMove=function(m){this.mouseX=m.clientX-this.windowHalfX;this.mouseY=m.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
  343. this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
  344. c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(m,t){return function(){t.apply(m,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
  345. var Cube=function(a,c,b,d,e,g,h,k,j){function m(H,E,I,A,S,Q,O,X){var f,ea,ka=d||1,W=e||1,T=S/2,xa=Q/2,ca=t.vertices.length;if(H=="x"&&E=="y"||H=="y"&&E=="x")f="z";else if(H=="x"&&E=="z"||H=="z"&&E=="x"){f="y";W=g||1}else if(H=="z"&&E=="y"||H=="y"&&E=="z"){f="x";ka=g||1}var Da=ka+1,ja=W+1;S/=ka;var oa=Q/W;for(ea=0;ea<ja;ea++)for(Q=0;Q<Da;Q++){var la=new THREE.Vector3;la[H]=(Q*S-T)*I;la[E]=(ea*oa-xa)*A;la[f]=O;t.vertices.push(new THREE.Vertex(la))}for(ea=0;ea<W;ea++)for(Q=0;Q<ka;Q++){t.faces.push(new THREE.Face4(Q+
  346. Da*ea+ca,Q+Da*(ea+1)+ca,Q+1+Da*(ea+1)+ca,Q+1+Da*ea+ca,null,null,X));t.faceVertexUvs[0].push([new THREE.UV(Q/ka,ea/W),new THREE.UV(Q/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,ea/W)])}}THREE.Geometry.call(this);var t=this,x=a/2,y=c/2,q=b/2;k=k?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var z=0;z<6;z++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var G in j)this.sides[G]!=
  347. undefined&&(this.sides[G]=j[G]);this.sides.px&&m("z","y",1*k,-1,b,c,-x,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,b,c,x,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,b,y,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,b,-y,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,c,q,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,c,-q,this.materials[5]);(function(){for(var H=[],E=[],I=0,A=t.vertices.length;I<A;I++){for(var S=t.vertices[I],Q=!1,O=0,X=H.length;O<X;O++){var f=H[O];
  348. if(S.position.x==f.position.x&&S.position.y==f.position.y&&S.position.z==f.position.z){E[I]=O;Q=!0;break}}if(!Q){E[I]=H.length;H.push(new THREE.Vertex(S.position.clone()))}}I=0;for(A=t.faces.length;I<A;I++){S=t.faces[I];S.a=E[S.a];S.b=E[S.b];S.c=E[S.c];S.d=E[S.d]}t.vertices=H})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  349. var Cylinder=function(a,c,b,d,e,g){function h(t,x,y){k.vertices.push(new THREE.Vertex(new THREE.Vector3(t,x,y)))}THREE.Geometry.call(this);var k=this,j=Math.PI,m=d/2;for(d=0;d<a;d++)h(Math.sin(2*j*d/a)*c,Math.cos(2*j*d/a)*c,-m);for(d=0;d<a;d++)h(Math.sin(2*j*d/a)*b,Math.cos(2*j*d/a)*b,m);for(d=0;d<a;d++)k.faces.push(new THREE.Face4(d,d+a,a+(d+1)%a,(d+1)%a));if(b>0){h(0,0,-m-(g||0));for(d=a;d<a+a/2;d++)k.faces.push(new THREE.Face4(2*a,(2*d-2*a)%a,(2*d-2*a+1)%a,(2*d-2*a+2)%a))}if(c>0){h(0,0,m+(e||0));
  350. for(d=a+a/2;d<2*a;d++)k.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  351. var Icosahedron=function(a){function c(x,y,q){var z=Math.sqrt(x*x+y*y+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/z,y/z,q/z)))-1}function b(x,y,q,z){z.faces.push(new THREE.Face3(x,y,q))}function d(x,y){var q=e.vertices[x].position,z=e.vertices[y].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var e=this,g=new THREE.Geometry,h;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,-a);c(0,
  352. 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),t=d(g.faces[k].c,g.faces[k].a);b(g.faces[k].a,j,t,h);b(g.faces[k].b,m,j,h);b(g.faces[k].c,
  353. t,m,h);b(j,m,t,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
  354. function Lathe(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;for(var d=[],e=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));d[k]=a[k].clone();e[k]=this.vertices.length-1}for(var j=(new THREE.Matrix4).setRotationZ(c),m=0;m<=this.angle+0.001;m+=c){for(k=0;k<d.length;k++)if(m<this.angle){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=e);for(k=
  355. 0;k<e.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],e[k+1],e[k]));this.faceVertexUvs[0].push([new THREE.UV(m/b,k/a.length),new THREE.UV(m/b,(k+1)/a.length),new THREE.UV((m-c)/b,(k+1)/a.length),new THREE.UV((m-c)/b,k/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
  356. var Plane=function(a,c,b,d){THREE.Geometry.call(this);var e,g=a/2,h=c/2;b=b||1;d=d||1;var k=b+1,j=d+1;a/=b;var m=c/d;for(e=0;e<j;e++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*m-h),0)));for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+k*e,c+k*(e+1),c+1+k*(e+1),c+1+k*e));this.faceVertexUvs[0].push([new THREE.UV(c/b,e/d),new THREE.UV(c/b,(e+1)/d),new THREE.UV((c+1)/b,(e+1)/d),new THREE.UV((c+1)/b,e/d)])}this.computeCentroids();this.computeFaceNormals()};
  357. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  358. var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var k=a*Math.cos(d*e),j=a*Math.sin(d*e),m=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=j*Math.sin(x*e);x=j*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);m.push(t)}c.push(m)}var q,z,G;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){m=d==g-1;h=c[b][m?0:d+1];k=c[b][m?g-1:d];j=c[b-1][m?g-1:d];m=c[b-1][m?
  359. 0:d+1];y=b/(e-1);q=(b-1)/(e-1);z=(d+1)/g;x=d/g;t=new THREE.UV(1-z,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-z,q);if(b<c.length-1){q=this.vertices[h].position.clone();z=this.vertices[k].position.clone();G=this.vertices[j].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,y,x])}if(b>1){q=this.vertices[h].position.clone();
  360. z=this.vertices[j].position.clone();G=this.vertices[m].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  361. var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
  362. 1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
  363. var TorusKnot=function(a,c,b,d,e,g,h){function k(x,y,q,z,G,H){y=q/z*x;q=Math.cos(y);return new THREE.Vector3(G*(2+q)*0.5*Math.cos(x),G*(2+q)*Math.sin(x)*0.5,H*G*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var j=
  364. a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;e=k(j,h,this.q,this.p,this.radius,this.heightScale);j=k(j+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=j.x-e.x;b.y=j.y-e.y;b.z=j.z-e.z;d.x=j.x+e.x;d.y=j.y+e.y;d.z=j.z+e.z;g.cross(b,d);d.cross(g,b);g.normalize();d.normalize();j=this.tube*Math.cos(h);h=this.tube*Math.sin(h);e.x+=j*d.x+h*g.x;e.y+=j*d.y+h*g.y;e.z+=j*d.z+h*g.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
  365. 0;c<this.segmentsT;++c){g=(a+1)%this.segmentsR;h=(c+1)%this.segmentsT;e=this.grid[a][c];b=this.grid[g][c];d=this.grid[a][h];g=this.grid[g][h];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);j=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var m=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT),t=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,d));this.faceVertexUvs[0].push([h,j,m]);this.faces.push(new THREE.Face3(g,d,b));this.faceVertexUvs[0].push([t,
  366. m,j])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
  367. THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
  368. c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var d=0;d<c.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(c[d],b)]},createMaterial:function(a,c){function b(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var t=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));
  369. k.image.width=t;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,t,x)}else k.image=this;k.needsUpdate=!0};m.src=j}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors?THREE.VertexColors:!1};if(a.shading)if(a.shading=="Phong")e="MeshPhongMaterial";else a.shading=="Basic"&&(e="MeshBasicMaterial");if(a.mapDiffuse&&c){h=document.createElement("canvas");g.map=new THREE.Texture(h);g.map.sourceFile=a.mapDiffuse;d(g.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=
  370. (a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);g.lightMap.sourceFile=a.mapLightmap;d(g.lightMap,c+"/"+a.mapLightmap)}return new THREE[e](g)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
  371. THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
  372. THREE.JSONLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(e){THREE.JSONLoader.prototype.createModel(e.data,b,d)};c.postMessage(a)},createModel:function(a,c,b){var d=function(e){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,e);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");
  373. else{var h,k,j,m,t,x,y,q,z,G,H=a.faces;q=a.vertices;var E=a.normals,I=a.colors,A=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&A++;for(h=0;h<A;h++){g.faceUvs[h]=[];g.faceVertexUvs[h]=[]}j=0;for(m=q.length;j<m;){z=new THREE.Vertex;z.position.x=q[j++];z.position.y=q[j++];z.position.z=q[j++];g.vertices.push(z)}j=0;for(m=H.length;j<m;){t=H[j++];x=t&1;h=t&2;y=t&4;k=t&8;q=t&16;z=t&32;G=t&64;t&=128;if(x){x=new THREE.Face4;x.a=H[j++];x.b=H[j++];x.c=H[j++];x.d=H[j++];nVertices=4}else{x=new THREE.Face3;x.a=
  374. H[j++];x.b=H[j++];x.c=H[j++];nVertices=3}if(h){materialIndex=H[j++];x.materials=g.materials[materialIndex]}if(y)for(h=0;h<A;h++){uvLayer=a.uvs[h];uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];g.faceUvs[h].push(new THREE.UV(u,v))}if(k)for(h=0;h<A;h++){uvLayer=a.uvs[h];uvs=[];for(k=0;k<nVertices;k++){uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[k]=new THREE.UV(u,v)}k=g.faces.length;g.faceVertexUvs[h][k]=uvs}if(q){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=
  375. E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.normal=normal}if(z)for(h=0;h<nVertices;h++){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.vertexNormals.push(normal)}if(G){color=new THREE.Color(H[j++]);x.color=color}if(t)for(h=0;h<nVertices;h++){colorIndex=H[j++];color=new THREE.Color(I[colorIndex]);x.vertexColors.push(color)}g.faces.push(x)}}})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<
  376. k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];g.skinWeights.push(new THREE.Vector4(j,m,0,0))}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];g.skinIndices.push(new THREE.Vector4(j,m,0,0))}}g.bones=a.bones;g.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var h,k,j,m;h=0;for(k=a.morphTargets.length;h<k;h++){g.morphTargets[h]={};g.morphTargets[h].name=a.morphTargets[h].name;g.morphTargets[h].vertices=[];dstVertices=g.morphTargets[h].vertices;
  377. srcVertices=a.morphTargets[h].vertices;j=0;for(m=srcVertices.length;j<m;j+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[j],srcVertices[j+1],srcVertices[j+2])))}}})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(b))}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
  378. THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
  379. THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.BinaryLoader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,e,d,g)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};
  380. c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,e,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,b,e,c):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
  381. h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,d){var e=function(g){function h(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2),F=t(p,o+3),Z=(F<<1&255|B>>7)-127;w|=(B&127)<<16|D<<8;if(w==0&&Z==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,Z)}function k(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2);return(t(p,o+3)<<24)+(B<<16)+(D<<8)+w}function j(p,o){var w=t(p,o);return(t(p,o+1)<<8)+w}function m(p,o){var w=t(p,o);return w>127?w-256:w}function t(p,
  382. o){return p.charCodeAt(o)&255}function x(p){var o,w,D;o=k(a,p);w=k(a,p+O);D=k(a,p+X);p=j(a,p+f);THREE.BinaryLoader.prototype.f3(E,o,w,D,p)}function y(p){var o,w,D,B,F,Z;o=k(a,p);w=k(a,p+O);D=k(a,p+X);B=j(a,p+f);F=k(a,p+ea);Z=k(a,p+ka);p=k(a,p+W);THREE.BinaryLoader.prototype.f3n(E,S,o,w,D,B,F,Z,p)}function q(p){var o,w,D,B;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);p=j(a,p+Da);THREE.BinaryLoader.prototype.f4(E,o,w,D,B,p)}function z(p){var o,w,D,B,F,Z,N,K;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);
  383. F=j(a,p+Da);Z=k(a,p+ja);N=k(a,p+oa);K=k(a,p+la);p=k(a,p+aa);THREE.BinaryLoader.prototype.f4n(E,S,o,w,D,B,F,Z,N,K,p)}function G(p){var o,w;o=k(a,p);w=k(a,p+P);p=k(a,p+M);THREE.BinaryLoader.prototype.uv3(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[p*2],Q[p*2+1])}function H(p){var o,w,D;o=k(a,p);w=k(a,p+da);D=k(a,p+sa);p=k(a,p+ia);THREE.BinaryLoader.prototype.uv4(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[D*2],Q[D*2+1],Q[p*2],Q[p*2+1])}var E=this,I=0,A,S=[],Q=[],O,X,f,ea,ka,W,T,xa,
  384. ca,Da,ja,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,d,g);A={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,
  385. I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)};I+=A.header_bytes;O=A.vertex_index_bytes;X=A.vertex_index_bytes*2;f=A.vertex_index_bytes*3;ea=A.vertex_index_bytes*3+A.material_index_bytes;ka=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;W=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;T=A.vertex_index_bytes;xa=A.vertex_index_bytes*2;ca=A.vertex_index_bytes*3;Da=
  386. A.vertex_index_bytes*4;ja=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;la=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;aa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;P=A.uv_index_bytes;M=A.uv_index_bytes*2;da=A.uv_index_bytes;sa=A.uv_index_bytes*2;ia=A.uv_index_bytes*3;g=A.vertex_index_bytes*3+A.material_index_bytes;C=A.vertex_index_bytes*4+A.material_index_bytes;ta=A.ntri_flat*
  387. g;ya=A.ntri_smooth*(g+A.normal_index_bytes*3);La=A.ntri_flat_uv*(g+A.uv_index_bytes*3);ab=A.ntri_smooth_uv*(g+A.normal_index_bytes*3+A.uv_index_bytes*3);n=A.nquad_flat*C;g=A.nquad_smooth*(C+A.normal_index_bytes*4);C=A.nquad_flat_uv*(C+A.uv_index_bytes*4);I+=function(p){for(var o,w,D,B=A.vertex_coordinate_bytes*3,F=p+A.nvertices*B;p<F;p+=B){o=h(a,p);w=h(a,p+A.vertex_coordinate_bytes);D=h(a,p+A.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(E,o,w,D)}return A.nvertices*B}(I);I+=function(p){for(var o,
  388. w,D,B=A.normal_coordinate_bytes*3,F=p+A.nnormals*B;p<F;p+=B){o=m(a,p);w=m(a,p+A.normal_coordinate_bytes);D=m(a,p+A.normal_coordinate_bytes*2);S.push(o/127,w/127,D/127)}return A.nnormals*B}(I);I+=function(p){for(var o,w,D=A.uv_coordinate_bytes*2,B=p+A.nuvs*D;p<B;p+=D){o=h(a,p);w=h(a,p+A.uv_coordinate_bytes);Q.push(o,w)}return A.nuvs*D}(I);ta=I+ta;ya=ta+ya;La=ya+La;ab=La+ab;n=ab+n;g=n+g;C=g+C;(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes,D=w+A.uv_index_bytes*3,B=p+A.ntri_flat_uv*
  389. D;for(o=p;o<B;o+=D){x(o);G(o+w)}return B-p})(ya);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,D=w+A.uv_index_bytes*3,B=p+A.ntri_smooth_uv*D;for(o=p;o<B;o+=D){y(o);G(o+w)}return B-p})(La);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes,D=w+A.uv_index_bytes*4,B=p+A.nquad_flat_uv*D;for(o=p;o<B;o+=D){q(o);H(o+w)}return B-p})(g);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*4,D=w+A.uv_index_bytes*
  390. 4,B=p+A.nquad_smooth_uv*D;for(o=p;o<B;o+=D){z(o);H(o+w)}return B-p})(C);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes,D=p+A.ntri_flat*w;for(o=p;o<D;o+=w)x(o);return D-p})(I);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,D=p+A.ntri_smooth*w;for(o=p;o<D;o+=w)y(o);return D-p})(ta);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes,D=p+A.nquad_flat*w;for(o=p;o<D;o+=w)q(o);return D-p})(ab);(function(p){var o,w=A.vertex_index_bytes*
  391. 4+A.material_index_bytes+A.normal_index_bytes*4,D=p+A.nquad_smooth*w;for(o=p;o<D;o+=w)z(o);return D-p})(n);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(b))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,d)))},f3:function(a,c,b,d,e){a.faces.push(new THREE.Face3(c,b,d,null,null,a.materials[e]))},f4:function(a,c,b,d,e,g){a.faces.push(new THREE.Face4(c,b,d,e,null,null,a.materials[g]))},f3n:function(a,c,
  392. b,d,e,g,h,k,j){g=a.materials[g];var m=c[k*3],t=c[k*3+1];k=c[k*3+2];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(b,d,e,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,t,k),new THREE.Vector3(x,y,j)],null,g))},f4n:function(a,c,b,d,e,g,h,k,j,m,t){h=a.materials[h];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];var q=c[m*3],z=c[m*3+1];m=c[m*3+2];var G=c[t*3],H=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(b,d,e,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(x,
  393. y,j),new THREE.Vector3(q,z,m),new THREE.Vector3(G,H,t)],null,h))},uv3:function(a,c,b,d,e,g,h){var k=[];k.push(new THREE.UV(c,b));k.push(new THREE.UV(d,e));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,c,b,d,e,g,h,k,j){var m=[];m.push(new THREE.UV(c,b));m.push(new THREE.UV(d,e));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  394. THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
  395. 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,d,e){return b+(d-b)*e};this.VIntX=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;e[g]=this.lerp(t[b],t[b+3],h);e[g+1]=this.lerp(t[b+1],t[b+4],h);e[g+2]=this.lerp(t[b+2],t[b+5],h)};this.VIntY=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
  396. 2]=m;d=b+this.yd*3;e[g]=this.lerp(t[b],t[d],h);e[g+1]=this.lerp(t[b+1],t[d+1],h);e[g+2]=this.lerp(t[b+2],t[d+2],h)};this.VIntZ=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=b+this.zd*3;e[g]=this.lerp(t[b],t[d],h);e[g+1]=this.lerp(t[b+1],t[d+1],h);e[g+2]=this.lerp(t[b+2],t[d+2],h)};this.compNorm=function(b){var d=b*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[b-1]-this.field[b+1];this.normal_cache[d+1]=this.field[b-this.yd]-
  397. this.field[b+this.yd];this.normal_cache[d+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,d,e,g,h,k){var j=g+1,m=g+this.yd,t=g+this.zd,x=j+this.yd,y=j+this.zd,q=g+this.yd+this.zd,z=j+this.yd+this.zd,G=0,H=this.field[g],E=this.field[j],I=this.field[m],A=this.field[x],S=this.field[t],Q=this.field[y],O=this.field[q],X=this.field[z];H<h&&(G|=1);E<h&&(G|=2);I<h&&(G|=8);A<h&&(G|=4);S<h&&(G|=16);Q<h&&(G|=32);O<h&&(G|=128);X<h&&(G|=64);var f=THREE.edgeTable[G];if(f==0)return 0;
  398. var ea=this.delta,ka=b+ea,W=d+ea;ea=e+ea;if(f&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,H,E)}if(f&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,ka,d,e,E,A)}if(f&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,W,e,I,A)}if(f&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,H,I)}if(f&16){this.compNorm(t);this.compNorm(y);this.VIntX(t*3,this.vlist,this.nlist,12,
  399. h,b,d,ea,S,Q)}if(f&32){this.compNorm(y);this.compNorm(z);this.VIntY(y*3,this.vlist,this.nlist,15,h,ka,d,ea,Q,X)}if(f&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,h,b,W,ea,O,X)}if(f&128){this.compNorm(t);this.compNorm(q);this.VIntY(t*3,this.vlist,this.nlist,21,h,b,d,ea,S,O)}if(f&256){this.compNorm(g);this.compNorm(t);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,H,S)}if(f&512){this.compNorm(j);this.compNorm(y);this.VIntZ(j*3,this.vlist,this.nlist,27,h,ka,d,e,E,Q)}if(f&
  400. 1024){this.compNorm(x);this.compNorm(z);this.VIntZ(x*3,this.vlist,this.nlist,30,h,ka,W,e,A,X)}if(f&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,W,e,I,O)}G<<=4;for(h=g=0;THREE.triTable[G+h]!=-1;){b=G+h;d=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[e],k);h+=3;g++}return g};this.posnormtriv=function(b,d,e,g,h,k){var j=this.count*3;this.positionArray[j]=b[e];this.positionArray[j+1]=b[e+1];this.positionArray[j+
  401. 2]=b[e+2];this.positionArray[j+3]=b[g];this.positionArray[j+4]=b[g+1];this.positionArray[j+5]=b[g+2];this.positionArray[j+6]=b[h];this.positionArray[j+7]=b[h+1];this.positionArray[j+8]=b[h+2];this.normalArray[j]=d[e];this.normalArray[j+1]=d[e+1];this.normalArray[j+2]=d[e+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=
  402. this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;b(this)}};this.addBall=function(b,d,e,g,h){var k=this.size*Math.sqrt(g/h),j=e*this.size,m=d*this.size,t=b*this.size,x=Math.floor(j-k);x<1&&(x=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var y=Math.floor(m-k);y<1&&(y=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var q=Math.floor(t-
  403. k);q<1&&(q=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var z,G,H,E,I,A;x<j;x++){t=this.size2*x;G=x/this.size-e;I=G*G;for(G=y;G<m;G++){H=t+this.size*G;z=G/this.size-d;A=z*z;for(z=q;z<k;z++){E=z/this.size-b;E=g/(1.0E-6+E*E+A+I)-h;E>0&&(this.field[H+z]+=E)}}}};this.addPlaneX=function(b,d){var e,g,h,k,j,m=this.size,t=this.yd,x=this.zd,y=this.field,q=m*Math.sqrt(b/d);q>m&&(q=m);for(e=0;e<q;e++){g=e/m;g*=g;k=b/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=e+g*t;for(h=0;h<m;h++)y[x*h+j]+=k}}};this.addPlaneY=
  404. function(b,d){var e,g,h,k,j,m,t=this.size,x=this.yd,y=this.zd,q=this.field,z=t*Math.sqrt(b/d);z>t&&(z=t);for(g=0;g<z;g++){e=g/t;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=g*x;for(e=0;e<t;e++){m=j+e;for(h=0;h<t;h++)q[y*h+m]+=k}}}};this.addPlaneZ=function(b,d){var e,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/d);dist>size&&(dist=size);for(h=0;h<dist;h++){e=h/size;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(e=0;e<size;e++)field[m+e]+=k}}}};this.reset=
  405. function(){var b;for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var d,e,g,h,k,j,m,t,x,y=this.size-2;for(h=1;h<y;h++){x=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<y;g++){t=x+this.size*g;j=(g-this.halfsize)/this.halfsize;for(e=1;e<y;e++){k=(e-this.halfsize)/this.halfsize;d=t+e;this.polygonize(k,j,m,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(e){var g,h,k,
  406. j,m,t,x,y;for(g=0;g<e.count;g++){m=g*3;x=m+1;y=m+2;h=e.positionArray[m];k=e.positionArray[x];j=e.positionArray[y];t=new THREE.Vector3(h,k,j);h=e.normalArray[m];k=e.normalArray[x];j=e.normalArray[y];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(t,m);d.vertices.push(m)}nfaces=e.count/3;for(g=0;g<nfaces;g++){m=(b+g)*3;x=m+1;y=m+2;t=d.vertices[m].normal;h=d.vertices[x].normal;k=d.vertices[y].normal;m=new THREE.Face3(m,x,y,[t,h,k]);d.faces.push(m)}b+=nfaces;e.count=0});return d};this.init(a)};
  407. THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  408. 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,
  409. 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,
  410. 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]);
  411. 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,
  412. -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,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