Three.js 199 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. // Three.js r36 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
  3. THREE.Color.prototype={autoUpdate:!0,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,j,k;if(b==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);k=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=k;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=k;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;g=k;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();
  4. 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*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
  5. 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(J,F,K,z){z=z.clone().subSelf(F);K=K.clone().subSelf(F);var I=J.clone().subSelf(F);J=z.dot(z);F=z.dot(K);z=z.dot(I);var Q=K.dot(K);K=K.dot(I);I=1/(J*Q-F*F);Q=(Q*z-F*K)*I;J=(J*K-F*z)*I;return Q>0&&J>0&&Q+J<1}var b,d,e,g,h,j,k,o,t,x,
  16. y,q=a.geometry,A=q.vertices,H=[];b=0;for(d=q.faces.length;b<d;b++){e=q.faces[b];x=this.origin.clone();y=this.direction.clone();k=a.matrixWorld;g=k.multiplyVector3(A[e.a].position.clone());h=k.multiplyVector3(A[e.b].position.clone());j=k.multiplyVector3(A[e.c].position.clone());k=e instanceof THREE.Face4?k.multiplyVector3(A[e.d].position.clone()):null;o=a.matrixRotationWorld.multiplyVector3(e.normal.clone());t=y.dot(o);if(t<0){o=o.dot((new THREE.Vector3).sub(g,x))/t;x=x.addSelf(y.multiplyScalar(o));
  17. if(e instanceof THREE.Face3){if(c(x,g,h,j)){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};H.push(e)}}else if(e instanceof THREE.Face4&&(c(x,g,h,k)||c(x,h,j,k))){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};H.push(e)}}}return H}};
  18. THREE.Rectangle=function(){function a(){g=d-c;h=e-b}var c,b,d,e,g,h,j=!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(k,o,t,x){j=!1;c=k;b=o;d=t;e=x;a()};this.addPoint=function(k,o){if(j){j=!1;c=k;b=o;d=k;e=o}else{c=c<k?c:k;b=b<o?b:o;d=d>k?d:k;e=e>o?e:o}a()};
  19. this.add3Points=function(k,o,t,x,y,q){if(j){j=!1;c=k<t?k<y?k:y:t<y?t:y;b=o<x?o<q?o:q:x<q?x:q;d=k>t?k>y?k:y:t>y?t:y;e=o>x?o>q?o:q:x>q?x:q}else{c=k<t?k<y?k<c?k:c:y<c?y:c:t<y?t<c?t:c:y<c?y:c;b=o<x?o<q?o<b?o:b:q<b?q:b:x<q?x<b?x:b:q<b?q:b;d=k>t?k>y?k>d?k:d:y>d?y:d:t>y?t>d?t:d:y>d?y:d;e=o>x?o>q?o>e?o:e:q>e?q:e:x>q?x>e?x:e:q>e?q:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=c<k.getLeft()?c:k.getLeft();b=b<k.getTop()?b:k.getTop();d=d>k.getRight()?
  20. d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d<k.getRight()?d:k.getRight();e=e<k.getBottom()?e:k.getBottom();a()};this.instersects=function(k){return Math.min(d,k.getRight())-Math.max(c,k.getLeft())>=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}};
  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,j,k,o,t,x,y,q,A,H){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,o||0,t||1,x||0,y||0,q||0,A||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  23. THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,o,t,x,y,q,A,H){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=o;this.n33=t;this.n34=x;this.n41=y;this.n42=q;this.n43=A;this.n44=H;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,j=a.n22,k=a.n23,o=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,A=a.n41,H=a.n42,J=a.n43,F=a.n44,K=c.n11,z=c.n12,I=c.n13,Q=c.n14,Z=c.n21,V=c.n22,
  27. f=c.n23,fa=c.n24,R=c.n31,W=c.n32,na=c.n33,N=c.n34;this.n11=b*K+d*Z+e*R;this.n12=b*z+d*V+e*W;this.n13=b*I+d*f+e*na;this.n14=b*Q+d*fa+e*N+g;this.n21=h*K+j*Z+k*R;this.n22=h*z+j*V+k*W;this.n23=h*I+j*f+k*na;this.n24=h*Q+j*fa+k*N+o;this.n31=t*K+x*Z+y*R;this.n32=t*z+x*V+y*W;this.n33=t*I+x*f+y*na;this.n34=t*Q+x*fa+y*N+q;this.n41=A*K+H*Z+J*R;this.n42=A*z+H*V+J*W;this.n43=A*I+H*f+J*na;this.n44=A*Q+H*fa+J*N+F;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;
  28. 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},determinant:function(){var a=
  29. this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24,k=this.n31,o=this.n32,t=this.n33,x=this.n34,y=this.n41,q=this.n42,A=this.n43,H=this.n44;return d*h*o*y-b*j*o*y-d*g*t*y+c*j*t*y+b*g*x*y-c*h*x*y-d*h*k*q+b*j*k*q+d*e*t*q-a*j*t*q-b*e*x*q+a*h*x*q+d*g*k*A-c*j*k*A-d*e*o*A+a*j*o*A+c*e*x*A-a*g*x*A-b*g*k*H+c*h*k*H+b*e*o*H-a*h*o*H-c*e*t*H+a*g*t*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
  30. 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;this.flat[1]=this.n21;
  31. 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;a[9]=this.n23;a[10]=
  32. 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},setScale:function(a,
  33. 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,j=a.z,k=e*g,o=e*h;this.set(k*
  34. g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,o*h+b,o*j-d*g,0,k*j-d*h,o*j+d*g,e*j*j+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,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*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},setRotationFromQuaternion:function(a){var c=
  35. a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,j=d+d;a=c*g;var k=c*h;c*=j;var o=b*h;b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(o+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+o);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=a.n14;this.n24=a.n24;this.n34=
  36. 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,j=a.n22,k=a.n23,o=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,A=a.n41,H=a.n42,J=a.n43,F=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*q*H-o*y*H+o*x*J-j*q*J-k*x*F+j*y*F;c.n12=g*y*H-e*q*H-g*x*J+d*q*J+e*x*F-d*y*F;c.n13=e*o*H-g*k*H+g*j*J-d*o*J-e*j*F+d*k*F;c.n14=g*k*x-e*o*x-g*j*y+d*o*y+e*j*q-d*k*q;c.n21=o*y*A-k*q*A-o*t*J+h*q*J+k*t*F-h*y*F;c.n22=e*q*A-g*y*A+g*t*J-b*q*J-e*t*F+b*y*F;c.n23=g*k*A-e*o*A-g*h*J+b*o*J+e*h*F-b*k*F;
  38. c.n24=e*o*t-g*k*t+g*h*y-b*o*y-e*h*q+b*k*q;c.n31=j*q*A-o*x*A+o*t*H-h*q*H-j*t*F+h*x*F;c.n32=g*x*A-d*q*A-g*t*H+b*q*H+d*t*F-b*x*F;c.n33=e*o*A-g*j*A+g*h*H-b*o*H-d*h*F+b*j*F;c.n34=g*j*t-d*o*t-g*h*x+b*o*x+d*h*q-b*j*q;c.n41=k*x*A-j*y*A-k*t*H+h*y*H+j*t*J-h*x*J;c.n42=d*y*A-e*x*A+e*t*H-b*y*H-d*t*J+b*x*J;c.n43=e*j*A-d*k*A-e*h*H+b*k*H+d*h*J-b*j*J;c.n44=d*k*t-e*j*t+e*h*x-b*k*x-d*h*y+b*j*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,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,o=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*o;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*j;b[5]=a*k;b[6]=a*o;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,j,k,o;h=new THREE.Matrix4;j=c-a;k=b-d;o=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/o;h.n34=-((g+e)/o);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,j=d*e;this.w=h*g-j*b;this.x=h*b+j*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,j=a.z;a=a.w;this.x=c*a+e*g+b*j-d*h;this.y=b*a+e*h+d*g-c*j;this.z=d*a+e*j+c*h-b*g;this.w=e*a-c*g-b*h-d*j;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,j=this.z,k=this.w,o=k*b+h*e-j*d,t=k*d+j*b-g*e,x=k*e+g*d-h*b;b=-g*b-h*d-j*e;c.x=o*k+b*-g+t*-j-x*-h;c.y=t*k+b*-h+x*-g-o*-j;c.z=x*k+b*-j+o*-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.0010){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.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.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};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}};
  54. 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,j=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){j.set(0,0,0);c=0;for(b=g.vertexNormals.length;c<b;c++)j.addSelf(g.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];j.sub(h.position,b.position);k.sub(c.position,b.position);j.crossSelf(k)}j.isZero()||
  57. j.normalize();g.normal.copy(j)}},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(N,xa,ta,qa,ua,la,ka){g=N.vertices[xa].position;h=N.vertices[ta].position;j=N.vertices[qa].position;k=e[ua];o=e[la];t=e[ka];x=h.x-g.x;y=j.x-g.x;q=h.y-g.y;A=j.y-g.y;H=h.z-g.z;J=j.z-g.z;F=o.u-k.u;K=t.u-k.u;z=o.v-k.v;I=t.v-k.v;Q=1/(F*I-K*
  60. z);f.set((I*x-z*y)*Q,(I*q-z*A)*Q,(I*H-z*J)*Q);fa.set((F*y-K*x)*Q,(F*A-K*q)*Q,(F*J-K*H)*Q);Z[xa].addSelf(f);Z[ta].addSelf(f);Z[qa].addSelf(f);V[xa].addSelf(fa);V[ta].addSelf(fa);V[qa].addSelf(fa)}var c,b,d,e,g,h,j,k,o,t,x,y,q,A,H,J,F,K,z,I,Q,Z=[],V=[],f=new THREE.Vector3,fa=new THREE.Vector3,R=new THREE.Vector3,W=new THREE.Vector3,na=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){Z[c]=new THREE.Vector3;V[c]=new THREE.Vector3}c=0;for(b=this.faces.length;c<b;c++){d=this.faces[c];e=this.faceVertexUvs[c][0];
  61. if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}c=
  62. 0;for(b=this.vertices.length;c<b;c++){na.copy(this.vertices[c].normal);d=Z[c];R.copy(d);R.subSelf(na.multiplyScalar(na.dot(d))).normalize();W.cross(this.vertices[c].normal,d);d=W.dot(V[c]);d=d<0?-1:1;this.vertices[c].tangent.set(R.x,R.y,R.z,d)}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]};
  63. for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=
  64. 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={radius:a}}};THREE.GeometryIdCounter=0;
  65. THREE.Spline=function(a){function c(q,A,H,J,F,K,z){q=(H-q)*0.5;J=(J-A)*0.5;return(2*(A-H)+q+J)*z+(-3*(A-H)-2*q-J)*K+q*F+A}this.points=a;var b=[],d={x:0,y:0,z:0},e,g,h,j,k,o,t,x,y;this.initFromArray=function(q){this.points=[];for(var A=0;A<q.length;A++)this.points[A]={x:q[A][0],y:q[A][1],z:q[A][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;o=this.points[b[0]];t=this.points[b[1]];
  66. x=this.points[b[2]];y=this.points[b[3]];j=h*h;k=h*j;d.x=c(o.x,t.x,x.x,y.x,h,j,k);d.y=c(o.y,t.y,x.y,y.y,h,j,k);d.z=c(o.z,t.z,x.z,y.z,h,j,k);return d};this.getControlPointsArray=function(){var q,A,H=this.points.length,J=[];for(q=0;q<H;q++){A=this.points[q];J[q]=[A.x,A.y,A.z]}return J};this.getLength=function(q){var A,H,J=A=A=0,F=new THREE.Vector3,K=new THREE.Vector3,z=[],I=0;z[0]=0;q||(q=100);H=this.points.length*q;F.copy(this.points[0]);for(q=1;q<H;q++){A=q/H;position=this.getPoint(A);K.copy(position);
  67. I+=K.distanceTo(F);F.copy(position);A*=this.points.length-1;A=Math.floor(A);if(A!=J){z[A]=I;J=A}}z[z.length]=I;return{chunks:z,total:I}};this.reparametrizeByArcLength=function(q){var A,H,J,F,K,z,I=[],Q=new THREE.Vector3,Z=this.getLength();I.push(Q.copy(this.points[0]).clone());for(A=1;A<this.points.length;A++){H=Z.chunks[A]-Z.chunks[A-1];z=Math.ceil(q*H/Z.total);F=(A-1)/(this.points.length-1);K=A/(this.points.length-1);for(H=1;H<z-1;H++){J=F+H*(1/z)*(K-F);position=this.getPoint(J);I.push(Q.copy(position).clone())}I.push(Q.copy(this.points[A]).clone())}this.points=
  68. I}};
  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 j=e.hierarchy[g].keys[h].rot;e.hierarchy[g].keys[h].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}if(e.hierarchy[g].keys[0].morphTargets!==undefined){j={};for(h=0;h<e.hierarchy[g].keys.length;h++)for(var k=0;k<e.hierarchy[g].keys[h].morphTargets.length;k++){var o=e.hierarchy[g].keys[h].morphTargets[k];j[o]=-1}e.hierarchy[g].usedMorphTargets=j;for(h=0;h<e.hierarchy[g].keys.length;h++){var t=
  71. {};for(o in j){for(k=0;k<e.hierarchy[g].keys[h].morphTargets.length;k++)if(e.hierarchy[g].keys[h].morphTargets[k]===o){t[o]=e.hierarchy[g].keys[h].morphTargetsInfluences[k];break}k===e.hierarchy[g].keys[h].morphTargets.length&&(t[o]=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,j,k,o,t=this.data.JIT.hierarchy,x,y;this.currentTime+=a*this.timeScale;y=this.currentTime;x=this.currentTime%=this.data.length;o=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,A=this.hierarchy.length;q<A;q++){a=this.hierarchy[q];k=a.animationCache;if(this.JITCompile&&t[q][o]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=t[q][o];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
  79. !1}else{a.matrix=t[q][o];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 H=0;H<3;H++){b=c[H];h=k.prevKey[b];j=k.nextKey[b];if(j.time<=y){if(x<y)if(this.loop){h=this.data.hierarchy[q].keys[0];for(j=this.getNextKeyWith(b,q,1);j.time<x;){h=j;j=this.getNextKeyWith(b,q,j.index+1)}}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(b,q,j.index+1)}while(j.time<
  80. x)}k.prevKey[b]=h;k.nextKey[b]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(x-h.time)/(j.time-h.time);e=h[b];g=j[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,j.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][o]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;q<this.hierarchy.length;q++)t[q][o]=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,j,k,o;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]];j=a[b[1]];k=a[b[2]];o=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],o[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],o[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],o[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,j;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;j=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;j!==undefined?d.scale.set(j[0],j[1],j[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 R=k[j]=k[j]||new THREE.RenderableVertex;j++;return R}function c(R,W){return W.z-R.z}function b(R,W){var na=0,N=1,xa=R.z+R.w,ta=W.z+W.w,qa=-R.z+R.w,ua=-W.z+W.w;if(xa>=0&&ta>=0&&qa>=0&&ua>=0)return!0;else if(xa<0&&ta<0||qa<0&&ua<0)return!1;else{if(xa<0)na=Math.max(na,xa/(xa-ta));else ta<0&&(N=Math.min(N,xa/(xa-ta)));if(qa<0)na=Math.max(na,qa/(qa-ua));else ua<0&&(N=Math.min(N,qa/(qa-ua)));if(N<na)return!1;else{R.lerpSelf(W,na);W.lerpSelf(R,1-N);return!0}}}
  148. var d,e,g=[],h,j,k=[],o,t,x=[],y,q,A=[],H,J,F=[],K=new THREE.Vector4,z=new THREE.Vector4,I=new THREE.Matrix4,Q=new THREE.Matrix4,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],V=new THREE.Vector4,f=new THREE.Vector4,fa;this.projectVector=function(R,W){I.multiply(W.projectionMatrix,W.matrixWorldInverse);I.multiplyVector3(R);return R};this.unprojectVector=function(R,W){I.multiply(THREE.Matrix4.makeInvert(W.projectionMatrix),W.matrixWorld);
  149. I.multiplyVector3(R);return R};this.projectObjects=function(R,W,na){W=[];var N,xa,ta;e=0;xa=R.objects;R=0;for(N=xa.length;R<N;R++){ta=xa[R];var qa;if(!(qa=!ta.visible))if(qa=ta instanceof THREE.Mesh){a:{qa=void 0;for(var ua=ta.matrixWorld,la=-ta.geometry.boundingSphere.radius*Math.max(ta.scale.x,Math.max(ta.scale.y,ta.scale.z)),ka=0;ka<6;ka++){qa=Z[ka].x*ua.n14+Z[ka].y*ua.n24+Z[ka].z*ua.n34+Z[ka].w;if(qa<=la){qa=!1;break a}}qa=!0}qa=!qa}if(!qa){qa=g[e]=g[e]||new THREE.RenderableObject;e++;d=qa;K.copy(ta.position);
  150. I.multiplyVector3(K);d.object=ta;d.z=K.z;W.push(d)}}na&&W.sort(c);return W};this.projectScene=function(R,W,na){var N=[],xa=W.near,ta=W.far,qa,ua,la,ka,oa,pa,ea,da,sa,Ea,Y,ya,za,m;J=q=t=0;W.matrixAutoUpdate&&W.updateMatrix();R.update(undefined,!1,W);I.multiply(W.projectionMatrix,W.matrixWorldInverse);Z[0].set(I.n41-I.n11,I.n42-I.n12,I.n43-I.n13,I.n44-I.n14);Z[1].set(I.n41+I.n11,I.n42+I.n12,I.n43+I.n13,I.n44+I.n14);Z[2].set(I.n41+I.n21,I.n42+I.n22,I.n43+I.n23,I.n44+I.n24);Z[3].set(I.n41-I.n21,I.n42-
  151. I.n22,I.n43-I.n23,I.n44-I.n24);Z[4].set(I.n41-I.n31,I.n42-I.n32,I.n43-I.n33,I.n44-I.n34);Z[5].set(I.n41+I.n31,I.n42+I.n32,I.n43+I.n33,I.n44+I.n34);for(qa=0;qa<6;qa++){oa=Z[qa];oa.divideScalar(Math.sqrt(oa.x*oa.x+oa.y*oa.y+oa.z*oa.z))}oa=this.projectObjects(R,W,!0);R=0;for(qa=oa.length;R<qa;R++){pa=oa[R].object;if(pa.visible){ea=pa.matrixWorld;sa=pa.matrixRotationWorld;da=pa.materials;j=0;if(pa instanceof THREE.Mesh){Ea=pa.geometry;Y=Ea.vertices;ya=Ea.faces;ua=0;for(la=Y.length;ua<la;ua++){h=a();h.positionWorld.copy(Y[ua].position);
  152. ea.multiplyVector3(h.positionWorld);h.positionScreen.copy(h.positionWorld);I.multiplyVector4(h.positionScreen);h.positionScreen.x/=h.positionScreen.w;h.positionScreen.y/=h.positionScreen.w;h.visible=h.positionScreen.z>xa&&h.positionScreen.z<ta}ua=0;for(la=ya.length;ua<la;ua++){Y=ya[ua];if(Y instanceof THREE.Face3){ka=k[Y.a];za=k[Y.b];m=k[Y.c];if(ka.visible&&za.visible&&m.visible&&(pa.doubleSided||pa.flipSided!=(m.positionScreen.x-ka.positionScreen.x)*(za.positionScreen.y-ka.positionScreen.y)-(m.positionScreen.y-
  153. ka.positionScreen.y)*(za.positionScreen.x-ka.positionScreen.x)<0)){var D=x[t]=x[t]||new THREE.RenderableFace3;t++;o=D;o.v1.copy(ka);o.v2.copy(za);o.v3.copy(m);o.normalWorld.copy(Y.normal);sa.multiplyVector3(o.normalWorld);o.centroidWorld.copy(Y.centroid);ea.multiplyVector3(o.centroidWorld);o.centroidScreen.copy(o.centroidWorld);I.multiplyVector3(o.centroidScreen);za=Y.vertexNormals;fa=o.vertexNormalsWorld;for(ka=0;ka<3;ka++){m=fa[ka];m.copy(za[ka]);sa.multiplyVector3(m)}if(ka=Ea.faceVertexUvs[0][ua]){o.uvs[0]=
  154. ka[0];o.uvs[1]=ka[1];o.uvs[2]=ka[2]}o.meshMaterials=da;o.faceMaterials=Y.materials;o.z=o.centroidScreen.z;N.push(o)}}}}else if(pa instanceof THREE.Line){Q.multiply(I,ea);Y=pa.geometry.vertices;ka=a();ka.positionScreen.copy(Y[0].position);Q.multiplyVector4(ka.positionScreen);ua=1;for(la=Y.length;ua<la;ua++){ka=a();ka.positionScreen.copy(Y[ua].position);Q.multiplyVector4(ka.positionScreen);za=k[j-2];V.copy(ka.positionScreen);f.copy(za.positionScreen);if(b(V,f)){V.multiplyScalar(1/V.w);f.multiplyScalar(1/
  155. f.w);ea=A[q]=A[q]||new THREE.RenderableLine;q++;y=ea;y.v1.positionScreen.copy(V);y.v2.positionScreen.copy(f);y.z=Math.max(V.z,f.z);y.materials=pa.materials;N.push(y)}}}else if(pa instanceof THREE.Particle){z.set(pa.position.x,pa.position.y,pa.position.z,1);I.multiplyVector4(z);z.z/=z.w;if(z.z>0&&z.z<1){ea=F[J]=F[J]||new THREE.RenderableParticle;J++;H=ea;H.x=z.x/z.w;H.y=z.y/z.w;H.z=z.z;H.rotation=pa.rotation.z;H.scale.x=pa.scale.x*Math.abs(H.x-(z.x+W.projectionMatrix.n11)/(z.w+W.projectionMatrix.n14));
  156. H.scale.y=pa.scale.y*Math.abs(H.y-(z.y+W.projectionMatrix.n22)/(z.w+W.projectionMatrix.n24));H.materials=pa.materials;N.push(H)}}}}na&&N.sort(c);return N}};
  157. 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,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,o,t,x,y,q,A,H;a=c.projectScene(h,j);k=0;for(o=a.length;k<o;k++){y=a[k];if(y instanceof THREE.RenderableParticle){A=y.x*e+e;H=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=A+"px";q.style.top=H+"px"}}}}}};
  158. THREE.CanvasRenderer=function(){function a(ca){if(y!=ca)o.globalAlpha=y=ca}function c(ca){if(q!=ca){switch(ca){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}q=ca}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,j,k,o=e.getContext("2d"),t=new THREE.Color(0),x=0,y=1,q=0,A=null,H=null,J=1,F,K,z,I,Q,Z,V,f,fa,R=new THREE.Color,
  159. W=new THREE.Color,na=new THREE.Color,N=new THREE.Color,xa=new THREE.Color,ta,qa,ua,la,ka,oa,pa,ea,da,sa=new THREE.Rectangle,Ea=new THREE.Rectangle,Y=new THREE.Rectangle,ya=!1,za=new THREE.Color,m=new THREE.Color,D=new THREE.Color,p=new THREE.Color,n=new THREE.Vector3,w,E,C,G,S,P,M=16;w=document.createElement("canvas");w.width=w.height=2;E=w.getContext("2d");E.fillStyle="rgba(0,0,0,1)";E.fillRect(0,0,2,2);C=E.getImageData(0,0,2,2);G=C.data;S=document.createElement("canvas");S.width=S.height=M;P=S.getContext("2d");
  160. P.translate(-M/2,-M/2);P.scale(M,M);M--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ca,va){g=ca;h=va;j=g/2;k=h/2;e.width=g;e.height=h;sa.set(-j,-k,j,k);y=1;q=0;H=A=null;J=1};this.setClearColor=function(ca,va){t=ca;x=va};this.setClearColorHex=function(ca,va){t.setHex(ca);x=va};this.clear=function(){o.setTransform(1,0,0,-1,j,k);if(!Ea.isEmpty()){Ea.inflate(1);Ea.minSelf(sa);if(t.hex==0&&x==0)o.clearRect(Ea.getX(),Ea.getY(),Ea.getWidth(),Ea.getHeight());
  161. else{c(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+x+")";o.fillRect(Ea.getX(),Ea.getY(),Ea.getWidth(),Ea.getHeight())}Ea.empty()}};this.render=function(ca,va){function ha(L){var ga,X,B,T=L.lights;m.setRGB(0,0,0);D.setRGB(0,0,0);p.setRGB(0,0,0);L=0;for(ga=T.length;L<ga;L++){X=T[L];B=X.color;if(X instanceof THREE.AmbientLight){m.r+=B.r;m.g+=B.g;m.b+=B.b}else if(X instanceof THREE.DirectionalLight){D.r+=B.r;D.g+=B.g;D.b+=B.b}else if(X instanceof
  162. THREE.PointLight){p.r+=B.r;p.g+=B.g;p.b+=B.b}}}function wa(L,ga,X,B){var T,ja,Na,Pa,La=L.lights;L=0;for(T=La.length;L<T;L++){ja=La[L];Na=ja.color;Pa=ja.intensity;if(ja instanceof THREE.DirectionalLight){ja=X.dot(ja.position)*Pa;if(ja>0){B.r+=Na.r*ja;B.g+=Na.g*ja;B.b+=Na.b*ja}}else if(ja instanceof THREE.PointLight){n.sub(ja.position,ga);n.normalize();ja=X.dot(n)*Pa;if(ja>0){B.r+=Na.r*ja;B.g+=Na.g*ja;B.b+=Na.b*ja}}}}function ia(L,ga,X){if(X.opacity!=0){a(X.opacity);c(X.blending);var B,T,ja,Na,Pa,La;
  163. if(X instanceof THREE.ParticleBasicMaterial){if(X.map){Na=X.map.image;Pa=Na.width>>1;La=Na.height>>1;X=ga.scale.x*j;ja=ga.scale.y*k;B=X*Pa;T=ja*La;Y.set(L.x-B,L.y-T,L.x+B,L.y+T);if(sa.instersects(Y)){o.save();o.translate(L.x,L.y);o.rotate(-ga.rotation);o.scale(X,-ja);o.translate(-Pa,-La);o.drawImage(Na,0,0);o.restore()}}}else if(X instanceof THREE.ParticleCanvasMaterial){if(ya){za.r=m.r+D.r+p.r;za.g=m.g+D.g+p.g;za.b=m.b+D.b+p.b;R.r=X.color.r*za.r;R.g=X.color.g*za.g;R.b=X.color.b*za.b;R.updateStyleString()}else R.__styleString=
  164. X.color.__styleString;B=ga.scale.x*j;T=ga.scale.y*k;Y.set(L.x-B,L.y-T,L.x+B,L.y+T);if(sa.instersects(Y)){o.save();o.translate(L.x,L.y);o.rotate(-ga.rotation);o.scale(B,T);X.program(o,R);o.restore()}}}}function Ja(L,ga,X,B){if(B.opacity!=0){a(B.opacity);c(B.blending);o.beginPath();o.moveTo(L.positionScreen.x,L.positionScreen.y);o.lineTo(ga.positionScreen.x,ga.positionScreen.y);o.closePath();if(B instanceof THREE.LineBasicMaterial){R.__styleString=B.color.__styleString;L=B.linewidth;if(J!=L)o.lineWidth=
  165. J=L;L=R.__styleString;if(A!=L)o.strokeStyle=A=L;o.stroke();Y.inflate(B.linewidth*2)}}}function Ra(L,ga,X,B,T,ja){if(T.opacity!=0){a(T.opacity);c(T.blending);I=L.positionScreen.x;Q=L.positionScreen.y;Z=ga.positionScreen.x;V=ga.positionScreen.y;f=X.positionScreen.x;fa=X.positionScreen.y;o.beginPath();o.moveTo(I,Q);o.lineTo(Z,V);o.lineTo(f,fa);o.lineTo(I,Q);o.closePath();if(T instanceof THREE.MeshBasicMaterial)if(T.map)T.map.mapping instanceof THREE.UVMapping&&O(I,Q,Z,V,f,fa,T.map.image,B.uvs[0].u,B.uvs[0].v,
  166. B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(T.envMap){if(T.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=va.matrixWorldInverse;n.copy(B.vertexNormalsWorld[0]);la=(n.x*L.n11+n.y*L.n12+n.z*L.n13)*0.5+0.5;ka=-(n.x*L.n21+n.y*L.n22+n.z*L.n23)*0.5+0.5;n.copy(B.vertexNormalsWorld[1]);oa=(n.x*L.n11+n.y*L.n12+n.z*L.n13)*0.5+0.5;pa=-(n.x*L.n21+n.y*L.n22+n.z*L.n23)*0.5+0.5;n.copy(B.vertexNormalsWorld[2]);ea=(n.x*L.n11+n.y*L.n12+n.z*L.n13)*0.5+0.5;da=-(n.x*L.n21+n.y*L.n22+n.z*L.n23)*
  167. 0.5+0.5;O(I,Q,Z,V,f,fa,T.envMap.image,la,ka,oa,pa,ea,da)}}else T.wireframe?ra(T.color.__styleString,T.wireframeLinewidth):Ga(T.color.__styleString);else if(T instanceof THREE.MeshLambertMaterial){if(T.map&&!T.wireframe){T.map.mapping instanceof THREE.UVMapping&&O(I,Q,Z,V,f,fa,T.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);c(THREE.SubtractiveBlending)}if(ya)if(!T.wireframe&&T.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){W.r=na.r=N.r=m.r;W.g=na.g=N.g=
  168. m.g;W.b=na.b=N.b=m.b;wa(ja,B.v1.positionWorld,B.vertexNormalsWorld[0],W);wa(ja,B.v2.positionWorld,B.vertexNormalsWorld[1],na);wa(ja,B.v3.positionWorld,B.vertexNormalsWorld[2],N);xa.r=(na.r+N.r)*0.5;xa.g=(na.g+N.g)*0.5;xa.b=(na.b+N.b)*0.5;ua=Oa(W,na,N,xa);O(I,Q,Z,V,f,fa,ua,0,0,1,0,0,1)}else{za.r=m.r;za.g=m.g;za.b=m.b;wa(ja,B.centroidWorld,B.normalWorld,za);R.r=T.color.r*za.r;R.g=T.color.g*za.g;R.b=T.color.b*za.b;R.updateStyleString();T.wireframe?ra(R.__styleString,T.wireframeLinewidth):Ga(R.__styleString)}else T.wireframe?
  169. ra(T.color.__styleString,T.wireframeLinewidth):Ga(T.color.__styleString)}else if(T instanceof THREE.MeshDepthMaterial){ta=va.near;qa=va.far;W.r=W.g=W.b=1-Fa(L.positionScreen.z,ta,qa);na.r=na.g=na.b=1-Fa(ga.positionScreen.z,ta,qa);N.r=N.g=N.b=1-Fa(X.positionScreen.z,ta,qa);xa.r=(na.r+N.r)*0.5;xa.g=(na.g+N.g)*0.5;xa.b=(na.b+N.b)*0.5;ua=Oa(W,na,N,xa);O(I,Q,Z,V,f,fa,ua,0,0,1,0,0,1)}else if(T instanceof THREE.MeshNormalMaterial){R.r=Sa(B.normalWorld.x);R.g=Sa(B.normalWorld.y);R.b=Sa(B.normalWorld.z);R.updateStyleString();
  170. T.wireframe?ra(R.__styleString,T.wireframeLinewidth):Ga(R.__styleString)}}}function ra(L,ga){if(A!=L)o.strokeStyle=A=L;if(J!=ga)o.lineWidth=J=ga;o.stroke();Y.inflate(ga*2)}function Ga(L){if(H!=L)o.fillStyle=H=L;o.fill()}function O(L,ga,X,B,T,ja,Na,Pa,La,Ba,Ha,Ca,Ia){var Aa,Da;Aa=Na.width-1;Da=Na.height-1;Pa*=Aa;La*=Da;Ba*=Aa;Ha*=Da;Ca*=Aa;Ia*=Da;X-=L;B-=ga;T-=L;ja-=ga;Ba-=Pa;Ha-=La;Ca-=Pa;Ia-=La;Aa=Ba*Ia-Ca*Ha;if(Aa!=0){Da=1/Aa;Aa=(Ia*X-Ha*T)*Da;Ha=(Ia*B-Ha*ja)*Da;X=(Ba*T-Ca*X)*Da;B=(Ba*ja-Ca*B)*
  171. Da;L=L-Aa*Pa-X*La;ga=ga-Ha*Pa-B*La;o.save();o.transform(Aa,Ha,X,B,L,ga);o.clip();o.drawImage(Na,0,0);o.restore()}}function Oa(L,ga,X,B){var T=~~(L.r*255),ja=~~(L.g*255);L=~~(L.b*255);var Na=~~(ga.r*255),Pa=~~(ga.g*255);ga=~~(ga.b*255);var La=~~(X.r*255),Ba=~~(X.g*255);X=~~(X.b*255);var Ha=~~(B.r*255),Ca=~~(B.g*255);B=~~(B.b*255);G[0]=T<0?0:T>255?255:T;G[1]=ja<0?0:ja>255?255:ja;G[2]=L<0?0:L>255?255:L;G[4]=Na<0?0:Na>255?255:Na;G[5]=Pa<0?0:Pa>255?255:Pa;G[6]=ga<0?0:ga>255?255:ga;G[8]=La<0?0:La>255?255:
  172. La;G[9]=Ba<0?0:Ba>255?255:Ba;G[10]=X<0?0:X>255?255:X;G[12]=Ha<0?0:Ha>255?255:Ha;G[13]=Ca<0?0:Ca>255?255:Ca;G[14]=B<0?0:B>255?255:B;E.putImageData(C,0,0);P.drawImage(w,0,0);return S}function Fa(L,ga,X){L=(L-ga)/(X-ga);return L*L*(3-2*L)}function Sa(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function U(L,ga){var X=ga.x-L.x,B=ga.y-L.y,T=1/Math.sqrt(X*X+B*B);X*=T;B*=T;ga.x+=X;ga.y+=B;L.x-=X;L.y-=B}var $,aa,ma,Ka,Xa,Ma,Va,Qa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,j,k);b=d.projectScene(ca,va,this.sortElements);
  173. (ya=ca.lights.length>0)&&ha(ca);$=0;for(aa=b.length;$<aa;$++){ma=b[$];Y.empty();if(ma instanceof THREE.RenderableParticle){F=ma;F.x*=j;F.y*=k;Ka=0;for(Xa=ma.materials.length;Ka<Xa;Ka++)ia(F,ma,ma.materials[Ka],ca)}else if(ma instanceof THREE.RenderableLine){F=ma.v1;K=ma.v2;F.positionScreen.x*=j;F.positionScreen.y*=k;K.positionScreen.x*=j;K.positionScreen.y*=k;Y.addPoint(F.positionScreen.x,F.positionScreen.y);Y.addPoint(K.positionScreen.x,K.positionScreen.y);if(sa.instersects(Y)){Ka=0;for(Xa=ma.materials.length;Ka<
  174. Xa;)Ja(F,K,ma,ma.materials[Ka++],ca)}}else if(ma instanceof THREE.RenderableFace3){F=ma.v1;K=ma.v2;z=ma.v3;F.positionScreen.x*=j;F.positionScreen.y*=k;K.positionScreen.x*=j;K.positionScreen.y*=k;z.positionScreen.x*=j;z.positionScreen.y*=k;if(ma.overdraw){U(F.positionScreen,K.positionScreen);U(K.positionScreen,z.positionScreen);U(z.positionScreen,F.positionScreen)}Y.add3Points(F.positionScreen.x,F.positionScreen.y,K.positionScreen.x,K.positionScreen.y,z.positionScreen.x,z.positionScreen.y);if(sa.instersects(Y)){Ka=
  175. 0;for(Xa=ma.meshMaterials.length;Ka<Xa;){Qa=ma.meshMaterials[Ka++];if(Qa instanceof THREE.MeshFaceMaterial){Ma=0;for(Va=ma.faceMaterials.length;Ma<Va;)(Qa=ma.faceMaterials[Ma++])&&Ra(F,K,z,ma,Qa,ca)}else Ra(F,K,z,ma,Qa,ca)}}}Ea.addRectangle(Y)}o.setTransform(1,0,0,1,0,0)}};
  176. THREE.SVGRenderer=function(){function a(la,ka,oa){var pa,ea,da,sa;pa=0;for(ea=la.lights.length;pa<ea;pa++){da=la.lights[pa];if(da instanceof THREE.DirectionalLight){sa=ka.normalWorld.dot(da.position)*da.intensity;if(sa>0){oa.r+=da.color.r*sa;oa.g+=da.color.g*sa;oa.b+=da.color.b*sa}}else if(da instanceof THREE.PointLight){fa.sub(da.position,ka.centroidWorld);fa.normalize();sa=ka.normalWorld.dot(fa)*da.intensity;if(sa>0){oa.r+=da.color.r*sa;oa.g+=da.color.g*sa;oa.b+=da.color.b*sa}}}}function c(la,ka,
  177. oa,pa,ea,da){N=d(xa++);N.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+","+oa.positionScreen.y+"z");if(ea instanceof THREE.MeshBasicMaterial)z.__styleString=ea.color.__styleString;else if(ea instanceof THREE.MeshLambertMaterial)if(K){I.r=Q.r;I.g=Q.g;I.b=Q.b;a(da,pa,I);z.r=ea.color.r*I.r;z.g=ea.color.g*I.g;z.b=ea.color.b*I.b;z.updateStyleString()}else z.__styleString=ea.color.__styleString;else if(ea instanceof
  178. THREE.MeshDepthMaterial){f=1-ea.__2near/(ea.__farPlusNear-pa.z*ea.__farMinusNear);z.setRGB(f,f,f)}else ea instanceof THREE.MeshNormalMaterial&&z.setRGB(e(pa.normalWorld.x),e(pa.normalWorld.y),e(pa.normalWorld.z));ea.wireframe?N.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+ea.wireframeLinewidth+"; stroke-opacity: "+ea.opacity+"; stroke-linecap: "+ea.wireframeLinecap+"; stroke-linejoin: "+ea.wireframeLinejoin):N.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+
  179. ea.opacity);j.appendChild(N)}function b(la,ka,oa,pa,ea,da,sa){N=d(xa++);N.setAttribute("d","M "+la.positionScreen.x+" "+la.positionScreen.y+" L "+ka.positionScreen.x+" "+ka.positionScreen.y+" L "+oa.positionScreen.x+","+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(da instanceof THREE.MeshBasicMaterial)z.__styleString=da.color.__styleString;else if(da instanceof THREE.MeshLambertMaterial)if(K){I.r=Q.r;I.g=Q.g;I.b=Q.b;a(sa,ea,I);z.r=da.color.r*I.r;z.g=da.color.g*I.g;
  180. z.b=da.color.b*I.b;z.updateStyleString()}else z.__styleString=da.color.__styleString;else if(da instanceof THREE.MeshDepthMaterial){f=1-da.__2near/(da.__farPlusNear-ea.z*da.__farMinusNear);z.setRGB(f,f,f)}else da instanceof THREE.MeshNormalMaterial&&z.setRGB(e(ea.normalWorld.x),e(ea.normalWorld.y),e(ea.normalWorld.z));da.wireframe?N.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+da.wireframeLinewidth+"; stroke-opacity: "+da.opacity+"; stroke-linecap: "+da.wireframeLinecap+
  181. "; stroke-linejoin: "+da.wireframeLinejoin):N.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+da.opacity);j.appendChild(N)}function d(la){if(R[la]==null){R[la]=document.createElementNS("http://www.w3.org/2000/svg","path");ua==0&&R[la].setAttribute("shape-rendering","crispEdges")}return R[la]}function e(la){return la<0?Math.min((1+la)*0.5,0.5):0.5+Math.min(la*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,o,t,x,y,q,A,H,J=
  182. new THREE.Rectangle,F=new THREE.Rectangle,K=!1,z=new THREE.Color(16777215),I=new THREE.Color(16777215),Q=new THREE.Color(0),Z=new THREE.Color(0),V=new THREE.Color(0),f,fa=new THREE.Vector3,R=[],W=[],na=[],N,xa,ta,qa,ua=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(la){switch(la){case "high":ua=1;break;case "low":ua=0}};this.setSize=function(la,ka){k=la;o=ka;t=k/2;x=o/2;j.setAttribute("viewBox",-t+" "+-x+" "+k+" "+o);j.setAttribute("width",
  183. k);j.setAttribute("height",o);J.set(-t,-x,t,x)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(la,ka){var oa,pa,ea,da,sa,Ea,Y,ya;this.autoClear&&this.clear();g=h.projectScene(la,ka,this.sortElements);qa=ta=xa=0;if(K=la.lights.length>0){Y=la.lights;Q.setRGB(0,0,0);Z.setRGB(0,0,0);V.setRGB(0,0,0);oa=0;for(pa=Y.length;oa<pa;oa++){ea=Y[oa];da=ea.color;if(ea instanceof THREE.AmbientLight){Q.r+=da.r;Q.g+=da.g;Q.b+=da.b}else if(ea instanceof THREE.DirectionalLight){Z.r+=
  184. da.r;Z.g+=da.g;Z.b+=da.b}else if(ea instanceof THREE.PointLight){V.r+=da.r;V.g+=da.g;V.b+=da.b}}}oa=0;for(pa=g.length;oa<pa;oa++){Y=g[oa];F.empty();if(Y instanceof THREE.RenderableParticle){y=Y;y.x*=t;y.y*=-x;ea=0;for(da=Y.materials.length;ea<da;ea++)if(ya=Y.materials[ea]){sa=y;Ea=Y;var za=ta++;if(W[za]==null){W[za]=document.createElementNS("http://www.w3.org/2000/svg","circle");ua==0&&W[za].setAttribute("shape-rendering","crispEdges")}N=W[za];N.setAttribute("cx",sa.x);N.setAttribute("cy",sa.y);N.setAttribute("r",
  185. Ea.scale.x*t);if(ya instanceof THREE.ParticleCircleMaterial){if(K){I.r=Q.r+Z.r+V.r;I.g=Q.g+Z.g+V.g;I.b=Q.b+Z.b+V.b;z.r=ya.color.r*I.r;z.g=ya.color.g*I.g;z.b=ya.color.b*I.b;z.updateStyleString()}else z=ya.color;N.setAttribute("style","fill: "+z.__styleString)}j.appendChild(N)}}else if(Y instanceof THREE.RenderableLine){y=Y.v1;q=Y.v2;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;F.addPoint(y.positionScreen.x,y.positionScreen.y);F.addPoint(q.positionScreen.x,
  186. q.positionScreen.y);if(J.instersects(F)){ea=0;for(da=Y.materials.length;ea<da;)if(ya=Y.materials[ea++]){sa=y;Ea=q;za=qa++;if(na[za]==null){na[za]=document.createElementNS("http://www.w3.org/2000/svg","line");ua==0&&na[za].setAttribute("shape-rendering","crispEdges")}N=na[za];N.setAttribute("x1",sa.positionScreen.x);N.setAttribute("y1",sa.positionScreen.y);N.setAttribute("x2",Ea.positionScreen.x);N.setAttribute("y2",Ea.positionScreen.y);if(ya instanceof THREE.LineBasicMaterial){z.__styleString=ya.color.__styleString;
  187. N.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+ya.linewidth+"; stroke-opacity: "+ya.opacity+"; stroke-linecap: "+ya.linecap+"; stroke-linejoin: "+ya.linejoin);j.appendChild(N)}}}}else if(Y instanceof THREE.RenderableFace3){y=Y.v1;q=Y.v2;A=Y.v3;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;A.positionScreen.x*=t;A.positionScreen.y*=-x;F.addPoint(y.positionScreen.x,y.positionScreen.y);F.addPoint(q.positionScreen.x,q.positionScreen.y);
  188. F.addPoint(A.positionScreen.x,A.positionScreen.y);if(J.instersects(F)){ea=0;for(da=Y.meshMaterials.length;ea<da;){ya=Y.meshMaterials[ea++];if(ya instanceof THREE.MeshFaceMaterial){sa=0;for(Ea=Y.faceMaterials.length;sa<Ea;)(ya=Y.faceMaterials[sa++])&&c(y,q,A,Y,ya,la)}else ya&&c(y,q,A,Y,ya,la)}}}else if(Y instanceof THREE.RenderableFace4){y=Y.v1;q=Y.v2;A=Y.v3;H=Y.v4;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;A.positionScreen.x*=t;A.positionScreen.y*=-x;
  189. H.positionScreen.x*=t;H.positionScreen.y*=-x;F.addPoint(y.positionScreen.x,y.positionScreen.y);F.addPoint(q.positionScreen.x,q.positionScreen.y);F.addPoint(A.positionScreen.x,A.positionScreen.y);F.addPoint(H.positionScreen.x,H.positionScreen.y);if(J.instersects(F)){ea=0;for(da=Y.meshMaterials.length;ea<da;){ya=Y.meshMaterials[ea++];if(ya instanceof THREE.MeshFaceMaterial){sa=0;for(Ea=Y.faceMaterials.length;sa<Ea;)(ya=Y.faceMaterials[sa++])&&b(y,q,A,H,Y,ya,la)}else ya&&b(y,q,A,H,Y,ya,la)}}}}}};
  190. 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",
  191. 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",
  192. 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",
  193. 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",
  194. 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",
  195. 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}",
  196. 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;",
  197. 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",
  198. 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",
  199. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};
  200. 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",
  201. 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",
  202. value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  203. 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",
  204. 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,
  205. 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,
  206. 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]),
  207. 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,
  208. 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,
  209. 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;",
  210. 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"),
  211. 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,
  212. 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;",
  213. 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")}};
  214. THREE.WebGLRenderer=function(a){function c(m,D,p){var n,w,E,C=m.vertices,G=C.length,S=m.colors,P=S.length,M=m.__vertexArray,ca=m.__colorArray,va=m.__sortArray,ha=m.__dirtyVertices,wa=m.__dirtyColors;if(p.sortParticles){pa.multiplySelf(p.matrixWorld);for(n=0;n<G;n++){w=C[n].position;sa.copy(w);pa.multiplyVector3(sa);va[n]=[sa.z,n]}va.sort(function(ia,Ja){return Ja[0]-ia[0]});for(n=0;n<G;n++){w=C[va[n][1]].position;E=n*3;M[E]=w.x;M[E+1]=w.y;M[E+2]=w.z}for(n=0;n<P;n++){E=n*3;color=S[va[n][1]];ca[E]=
  215. color.r;ca[E+1]=color.g;ca[E+2]=color.b}}else{if(ha)for(n=0;n<G;n++){w=C[n].position;E=n*3;M[E]=w.x;M[E+1]=w.y;M[E+2]=w.z}if(wa)for(n=0;n<P;n++){color=S[n];E=n*3;ca[E]=color.r;ca[E+1]=color.g;ca[E+2]=color.b}}if(ha||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,M,D)}if(wa||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,ca,D)}}function b(m,D){m.fragmentShader=D.fragmentShader;m.vertexShader=D.vertexShader;
  216. m.uniforms=Uniforms.clone(D.uniforms)}function d(m,D,p,n,w){n.program||W.initMaterial(n,D,p,w);var E=n.program,C=E.uniforms,G=n.uniforms;if(E!=fa){f.useProgram(E);fa=E}f.uniformMatrix4fv(C.projectionMatrix,!1,ea);if(p&&(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial||n instanceof THREE.LineBasicMaterial||n instanceof THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){G.fogNear.value=p.near;
  217. G.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)G.fogDensity.value=p.density}if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n.lights){var S,P,M=0,ca=0,va=0,ha,wa,ia,Ja=Ea,Ra=Ja.directional.colors,ra=Ja.directional.positions,Ga=Ja.point.colors,O=Ja.point.positions,Oa=0,Fa=0;p=P=P=0;for(S=D.length;p<S;p++){P=D[p];ha=P.color;wa=P.position;ia=P.intensity;if(P instanceof THREE.AmbientLight){M+=ha.r;ca+=ha.g;va+=ha.b}else if(P instanceof THREE.DirectionalLight){P=
  218. Oa*3;Ra[P]=ha.r*ia;Ra[P+1]=ha.g*ia;Ra[P+2]=ha.b*ia;ra[P]=wa.x;ra[P+1]=wa.y;ra[P+2]=wa.z;Oa+=1}else if(P instanceof THREE.PointLight){P=Fa*3;Ga[P]=ha.r*ia;Ga[P+1]=ha.g*ia;Ga[P+2]=ha.b*ia;O[P]=wa.x;O[P+1]=wa.y;O[P+2]=wa.z;Fa+=1}}for(p=Oa*3;p<Ra.length;p++)Ra[p]=0;for(p=Fa*3;p<Ga.length;p++)Ga[p]=0;Ja.point.length=Fa;Ja.directional.length=Oa;Ja.ambient[0]=M;Ja.ambient[1]=ca;Ja.ambient[2]=va;D=Ea;G.enableLighting.value=D.directional.length+D.point.length;G.ambientLightColor.value=D.ambient;G.directionalLightColor.value=
  219. D.directional.colors;G.directionalLightDirection.value=D.directional.positions;G.pointLightColor.value=D.point.colors;G.pointLightPosition.value=D.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity;G.map.texture=n.map;G.lightMap.texture=n.lightMap;G.envMap.texture=n.envMap;G.reflectivity.value=n.reflectivity;
  220. G.refractionRatio.value=n.refractionRatio;G.combine.value=n.combine;G.useRefract.value=n.envMap&&n.envMap.mapping instanceof THREE.CubeRefractionMapping}if(n instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity}else if(n instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity;G.size.value=n.size;G.scale.value=V.height/
  221. 2;G.map.texture=n.map}else if(n instanceof THREE.MeshPhongMaterial){G.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);G.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);G.shininess.value=n.shininess}else if(n instanceof THREE.MeshDepthMaterial){G.mNear.value=m.near;G.mFar.value=m.far;G.opacity.value=n.opacity}else if(n instanceof THREE.MeshNormalMaterial)G.opacity.value=n.opacity;for(var Sa in G)if(M=E.uniforms[Sa]){p=G[Sa];S=p.type;D=p.value;if(S=="i")f.uniform1i(M,D);else if(S==
  222. "f")f.uniform1f(M,D);else if(S=="fv1")f.uniform1fv(M,D);else if(S=="fv")f.uniform3fv(M,D);else if(S=="v2")f.uniform2f(M,D.x,D.y);else if(S=="v3")f.uniform3f(M,D.x,D.y,D.z);else if(S=="c")f.uniform3f(M,D.r,D.g,D.b);else if(S=="t"){f.uniform1i(M,D);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(S=0;S<6;++S)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+S,0,0,0,f.RGBA,
  223. f.UNSIGNED_BYTE,p.image[S])}else{p.image.__webGLTextureCube=f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(S=0;S<6;++S)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+S,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,p.image[S]);p.__wasSetOnce=!0}K(f.TEXTURE_CUBE_MAP,p,p.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+D);f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(p.needsUpdate){if(p.__wasSetOnce){f.bindTexture(f.TEXTURE_2D,
  224. p.__webGLTexture);f.texSubImage2D(f.TEXTURE_2D,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}K(f.TEXTURE_2D,p,p.image);f.bindTexture(f.TEXTURE_2D,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+D);f.bindTexture(f.TEXTURE_2D,p.__webGLTexture)}}}f.uniformMatrix4fv(C.modelViewMatrix,!1,w._modelViewMatrixArray);f.uniformMatrix3fv(C.normalMatrix,
  225. !1,w._normalMatrixArray);(n instanceof THREE.MeshShaderMaterial||n instanceof THREE.MeshPhongMaterial||n.envMap)&&f.uniform3f(C.cameraPosition,m.position.x,m.position.y,m.position.z);(n instanceof THREE.MeshShaderMaterial||n.envMap||n.skinning)&&f.uniformMatrix4fv(C.objectMatrix,!1,w._objectMatrixArray);(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshShaderMaterial||n.skinning)&&f.uniformMatrix4fv(C.viewMatrix,!1,da);if(n.skinning){f.uniformMatrix4fv(C.cameraInverseMatrix,
  226. !1,da);f.uniformMatrix4fv(C.boneGlobalMatrices,!1,w.boneMatrices)}return E}function e(m,D,p,n,w,E){if(n.opacity!=0){m=d(m,D,p,n,E).attributes;if(n.morphTargets){D=n.program.attributes;E.morphTargetBase!==-1?f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[E.morphTargetBase]):f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(D.position,3,f.FLOAT,!1,0,0);if(E.morphTargetForcedOrder.length){p=0;for(var C=E.morphTargetForcedOrder,G=E.morphTargetInfluences;p<n.numSupportedMorphTargets&&
  227. p<C.length;){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[C[p]]);f.vertexAttribPointer(D["morphTarget"+p],3,f.FLOAT,!1,0,0);E.__webGLMorphTargetInfluences[p]=G[C[p]];p++}}else{C=[];var S=-1,P=0;G=E.morphTargetInfluences;var M,ca=G.length;p=0;for(E.morphTargetBase!==-1&&(C[E.morphTargetBase]=!0);p<n.numSupportedMorphTargets;){for(M=0;M<ca;M++)if(!C[M]&&G[M]>S){P=M;S=G[P]}f.bindBuffer(f.ARRAY_BUFFER,w.__webGLMorphTargetsBuffers[P]);f.vertexAttribPointer(D["morphTarget"+p],3,f.FLOAT,!1,0,
  228. 0);E.__webGLMorphTargetInfluences[p]=S;C[P]=1;S=-1;p++}}f.uniform1fv(n.program.uniforms.morphTargetInfluences,E.__webGLMorphTargetInfluences)}else{f.bindBuffer(f.ARRAY_BUFFER,w.__webGLVertexBuffer);f.vertexAttribPointer(m.position,3,f.FLOAT,!1,0,0)}if(m.color>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLColorBuffer);f.vertexAttribPointer(m.color,3,f.FLOAT,!1,0,0)}if(m.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLNormalBuffer);f.vertexAttribPointer(m.normal,3,f.FLOAT,!1,0,0)}if(m.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,
  229. w.__webGLTangentBuffer);f.vertexAttribPointer(m.tangent,4,f.FLOAT,!1,0,0)}if(m.uv>=0)if(w.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUVBuffer);f.vertexAttribPointer(m.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(m.uv)}else f.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(w.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLUV2Buffer);f.vertexAttribPointer(m.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(m.uv2)}else f.disableVertexAttribArray(m.uv2);if(n.skinning&&m.skinVertexA>=0&&
  230. m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexABuffer);f.vertexAttribPointer(m.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinVertexBBuffer);f.vertexAttribPointer(m.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinIndicesBuffer);f.vertexAttribPointer(m.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,w.__webGLSkinWeightsBuffer);f.vertexAttribPointer(m.skinWeight,4,f.FLOAT,!1,0,0)}if(E instanceof
  231. THREE.Mesh)if(n.wireframe){f.lineWidth(n.wireframeLinewidth);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(E instanceof THREE.Line){E=E.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(n.linewidth);f.drawArrays(E,0,w.__webGLLineCount)}else if(E instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,
  232. 0,w.__webGLParticleCount);else E instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,0,w.__webGLVertexCount)}}function g(m,D){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=f.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=f.createBuffer();if(m.hasPos){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,m.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(D.attributes.position);f.vertexAttribPointer(D.attributes.position,3,f.FLOAT,!1,0,0)}if(m.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,
  233. m.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,m.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(D.attributes.normal);f.vertexAttribPointer(D.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,m.count);m.count=0}function h(m){if(na!=m.doubleSided){m.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);na=m.doubleSided}if(N!=m.flipSided){m.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);N=m.flipSided}}function j(m){if(ta!=m){m?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);
  234. ta=m}}function k(m){oa[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);oa[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);oa[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);oa[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);oa[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);oa[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var D;for(m=0;m<6;m++){D=oa[m];D.divideScalar(Math.sqrt(D.x*D.x+D.y*D.y+D.z*D.z))}}function o(m){for(var D=m.matrixWorld,p=-m.geometry.boundingSphere.radius*
  235. Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),n=0;n<6;n++){m=oa[n].x*D.n14+oa[n].y*D.n24+oa[n].z*D.n34+oa[n].w;if(m<=p)return!1}return!0}function t(m,D){m.list[m.count]=D;m.count+=1}function x(m){var D,p,n=m.object,w=m.opaque,E=m.transparent;E.count=0;m=w.count=0;for(D=n.materials.length;m<D;m++){p=n.materials[m];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?t(E,p):t(w,p)}}function y(m){var D,p,n,w,E=m.object,C=m.buffer,G=m.opaque,S=m.transparent;S.count=0;m=G.count=0;for(n=E.materials.length;m<
  236. n;m++){D=E.materials[m];if(D instanceof THREE.MeshFaceMaterial){D=0;for(p=C.materials.length;D<p;D++)(w=C.materials[D])&&(w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(S,w):t(G,w))}else{w=D;w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(S,w):t(G,w)}}}function q(m,D){return D.z-m.z}function A(m,D){m._modelViewMatrix.multiplyToArray(D.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}
  237. function H(m){function D(va){var ha=[];p=0;for(n=va.length;p<n;p++)va[p]==undefined?ha.push("undefined"):ha.push(va[p].id);return ha.join("_")}var p,n,w,E,C,G,S,P,M={},ca=m.morphTargets!==undefined?m.morphTargets.length:0;m.geometryGroups={};w=0;for(E=m.faces.length;w<E;w++){C=m.faces[w];G=C.materials;S=D(G);M[S]==undefined&&(M[S]={hash:S,counter:0});P=M[S].hash+"_"+M[S].counter;m.geometryGroups[P]==undefined&&(m.geometryGroups[P]={faces:[],materials:G,vertices:0,numMorphTargets:ca});C=C instanceof
  238. THREE.Face3?3:4;if(m.geometryGroups[P].vertices+C>65535){M[S].counter+=1;P=M[S].hash+"_"+M[S].counter;m.geometryGroups[P]==undefined&&(m.geometryGroups[P]={faces:[],materials:G,vertices:0,numMorphTargets:ca})}m.geometryGroups[P].faces.push(w);m.geometryGroups[P].vertices+=C}}function J(m,D,p){m.push({buffer:D,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(m){if(m!=xa){switch(m){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,
  239. 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)}xa=m}}function K(m,D,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(m,f.TEXTURE_WRAP_S,Z(D.wrapS));f.texParameteri(m,f.TEXTURE_WRAP_T,Z(D.wrapT));f.texParameteri(m,f.TEXTURE_MAG_FILTER,
  240. Z(D.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,Z(D.minFilter));f.generateMipmap(m)}else{f.texParameteri(m,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_MAG_FILTER,Q(D.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,Q(D.minFilter))}}function z(m){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=f.createFramebuffer();m.__webGLRenderbuffer=f.createRenderbuffer();m.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,
  241. m.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,m.width,m.height);f.bindTexture(f.TEXTURE_2D,m.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,Z(m.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,Z(m.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,Z(m.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,Z(m.minFilter));f.texImage2D(f.TEXTURE_2D,0,Z(m.format),m.width,m.height,0,Z(m.format),Z(m.type),null);f.bindFramebuffer(f.FRAMEBUFFER,
  242. m.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,m.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var D,p;if(m){D=m.__webGLFramebuffer;p=m.width;m=m.height}else{D=null;p=la;m=ka}if(D!=R){f.bindFramebuffer(f.FRAMEBUFFER,D);f.viewport(qa,ua,p,m);R=D}}function I(m,D){var p;if(m=="fragment")p=
  243. f.createShader(f.FRAGMENT_SHADER);else m=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,D);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));console.error(D);return null}return p}function Q(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}
  244. function Z(m){switch(m){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;
  245. 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}
  246. var V=document.createElement("canvas"),f,fa=null,R=null,W=this,na=null,N=null,xa=null,ta=null,qa=0,ua=0,la=0,ka=0,oa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],pa=new THREE.Matrix4,ea=new Float32Array(16),da=new Float32Array(16),sa=new THREE.Vector4,Ea={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Y=!0,ya=new THREE.Color(0),za=0;if(a){if(a.antialias!==undefined)Y=a.antialias;
  247. a.clearColor!==undefined&&ya.setHex(a.clearColor);if(a.clearAlpha!==undefined)za=a.clearAlpha}this.maxMorphTargets=8;this.domElement=V;this.autoClear=!0;this.sortObjects=!0;(function(m,D,p){try{if(!(f=V.getContext("experimental-webgl",{antialias:m})))throw"Error creating WebGL context.";}catch(n){console.error(n)}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);
  248. f.clearColor(D.r,D.g,D.b,p);_cullEnabled=!0})(Y,ya,za);this.context=f;this.setSize=function(m,D){V.width=m;V.height=D;this.setViewport(0,0,V.width,V.height)};this.setViewport=function(m,D,p,n){qa=m;ua=D;la=p;ka=n;f.viewport(qa,ua,la,ka)};this.setScissor=function(m,D,p,n){f.scissor(m,D,p,n)};this.enableScissorTest=function(m){m?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){f.depthMask(m)};this.setClearColorHex=function(m,D){var p=new THREE.Color(m);f.clearColor(p.r,
  249. p.g,p.b,D)};this.setClearColor=function(m,D){f.clearColor(m.r,m.g,m.b,D)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,D,p,n){var w,E,C;if(m instanceof THREE.MeshDepthMaterial)b(m,THREE.ShaderLib.depth);else if(m instanceof THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)b(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)b(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)b(m,
  250. THREE.ShaderLib.phong);else if(m instanceof THREE.LineBasicMaterial)b(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&b(m,THREE.ShaderLib.particle_basic);var G,S,P,M;C=P=M=0;for(G=D.length;C<G;C++){S=D[C];S instanceof THREE.DirectionalLight&&P++;S instanceof THREE.PointLight&&M++}if(M+P<=4)D=P;else{D=Math.ceil(4*P/(M+P));M=4-D}C={directional:D,point:M};G=50;if(n!==undefined&&n instanceof THREE.SkinnedMesh)G=n.bones.length;M=m.fragmentShader;D=m.vertexShader;G={fog:p,map:m.map,
  251. envMap:m.envMap,lightMap:m.lightMap,vertexColors:m.vertexColors,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxDirLights:C.directional,maxPointLights:C.point,maxBones:G};p=f.createProgram();C=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+G.maxDirLights,"#define MAX_POINT_LIGHTS "+G.maxPointLights,G.fog?"#define USE_FOG":"",G.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",G.map?"#define USE_MAP":"",G.envMap?"#define USE_ENVMAP":
  252. "",G.lightMap?"#define USE_LIGHTMAP":"",G.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");G=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+G.maxDirLights,"#define MAX_POINT_LIGHTS "+G.maxPointLights,"#define MAX_BONES "+G.maxBones,G.map?"#define USE_MAP":"",G.envMap?"#define USE_ENVMAP":"",G.lightMap?"#define USE_LIGHTMAP":"",G.vertexColors?"#define USE_COLOR":"",G.skinning?"#define USE_SKINNING":
  253. "",G.morphTargets?"#define USE_MORPHTARGETS":"",G.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");
  254. f.attachShader(p,I("fragment",C+M));f.attachShader(p,I("vertex",G+D));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={};m.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(w in m.uniforms)p.push(w);
  255. w=m.program;M=0;for(D=p.length;M<D;M++){C=p[M];w.uniforms[C]=f.getUniformLocation(w,C)}p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<this.maxMorphTargets;w++)p.push("morphTarget"+w);for(E in m.attributes)p.push(E);E=m.program;w=p;p=0;for(M=w.length;p<M;p++){D=w[p];E.attributes[D]=f.getAttribLocation(E,D)}E=m.program.attributes;f.enableVertexAttribArray(E.position);E.color>=0&&f.enableVertexAttribArray(E.color);E.normal>=0&&f.enableVertexAttribArray(E.normal);
  256. E.tangent>=0&&f.enableVertexAttribArray(E.tangent);if(m.skinning&&E.skinVertexA>=0&&E.skinVertexB>=0&&E.skinIndex>=0&&E.skinWeight>=0){f.enableVertexAttribArray(E.skinVertexA);f.enableVertexAttribArray(E.skinVertexB);f.enableVertexAttribArray(E.skinIndex);f.enableVertexAttribArray(E.skinWeight)}if(m.morphTargets){m.numSupportedMorphTargets=0;if(E.morphTarget0>=0){f.enableVertexAttribArray(E.morphTarget0);m.numSupportedMorphTargets++}if(E.morphTarget1>=0){f.enableVertexAttribArray(E.morphTarget1);
  257. m.numSupportedMorphTargets++}if(E.morphTarget2>=0){f.enableVertexAttribArray(E.morphTarget2);m.numSupportedMorphTargets++}if(E.morphTarget3>=0){f.enableVertexAttribArray(E.morphTarget3);m.numSupportedMorphTargets++}if(E.morphTarget4>=0){f.enableVertexAttribArray(E.morphTarget4);m.numSupportedMorphTargets++}if(E.morphTarget5>=0){f.enableVertexAttribArray(E.morphTarget5);m.numSupportedMorphTargets++}if(E.morphTarget6>=0){f.enableVertexAttribArray(E.morphTarget6);m.numSupportedMorphTargets++}if(E.morphTarget7>=
  258. 0){f.enableVertexAttribArray(E.morphTarget7);m.numSupportedMorphTargets++}n.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(w=0;w<this.maxMorphTargets;w++)n.__webGLMorphTargetInfluences[w]=0}};this.render=function(m,D,p,n){var w,E,C,G,S,P,M,ca,va=m.lights,ha=m.fog;D.matrixAutoUpdate&&D.updateMatrix();m.update(undefined,!1,D);D.matrixWorldInverse.flattenToArray(da);D.projectionMatrix.flattenToArray(ea);pa.multiply(D.projectionMatrix,D.matrixWorldInverse);k(pa);this.initWebGLObjects(m);
  259. z(p);(this.autoClear||n)&&this.clear();S=m.__webglObjects.length;for(n=0;n<S;n++){w=m.__webglObjects[n];M=w.object;if(M.visible)if(!(M instanceof THREE.Mesh)||o(M)){M.matrixWorld.flattenToArray(M._objectMatrixArray);A(M,D);y(w);w.render=!0;if(this.sortObjects){sa.copy(M.position);pa.multiplyVector3(sa);w.z=sa.z}}else w.render=!1;else w.render=!1}this.sortObjects&&m.__webglObjects.sort(q);P=m.__webglObjectsImmediate.length;for(n=0;n<P;n++){w=m.__webglObjectsImmediate[n];M=w.object;if(M.visible){M.matrixAutoUpdate&&
  260. M.matrixWorld.flattenToArray(M._objectMatrixArray);A(M,D);x(w)}}F(THREE.NormalBlending);for(n=0;n<S;n++){w=m.__webglObjects[n];if(w.render){M=w.object;ca=w.buffer;C=w.opaque;h(M);for(w=0;w<C.count;w++){G=C.list[w];j(G.depthTest);e(D,va,ha,G,ca,M)}}}for(n=0;n<P;n++){w=m.__webglObjectsImmediate[n];M=w.object;if(M.visible){C=w.opaque;h(M);for(w=0;w<C.count;w++){G=C.list[w];j(G.depthTest);E=d(D,va,ha,G,M);M.render(function(wa){g(wa,E)})}}}for(n=0;n<S;n++){w=m.__webglObjects[n];if(w.render){M=w.object;
  261. ca=w.buffer;C=w.transparent;h(M);for(w=0;w<C.count;w++){G=C.list[w];F(G.blending);j(G.depthTest);e(D,va,ha,G,ca,M)}}}for(n=0;n<P;n++){w=m.__webglObjectsImmediate[n];M=w.object;if(M.visible){C=w.transparent;h(M);for(w=0;w<C.count;w++){G=C.list[w];F(G.blending);j(G.depthTest);E=d(D,va,ha,G,M);M.render(function(wa){g(wa,E)})}}}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,
  262. null)}};this.initWebGLObjects=function(m){if(!m.__webglObjects){m.__webglObjects=[];m.__webglObjectsImmediate=[]}for(;m.__objectsAdded.length;){var D=m.__objectsAdded[0],p=m,n=void 0,w=void 0,E=void 0;if(D._modelViewMatrix==undefined){D._modelViewMatrix=new THREE.Matrix4;D._normalMatrixArray=new Float32Array(9);D._modelViewMatrixArray=new Float32Array(16);D._objectMatrixArray=new Float32Array(16);D.matrixWorld.flattenToArray(D._objectMatrixArray)}if(D instanceof THREE.Mesh){w=D.geometry;w.geometryGroups==
  263. undefined&&H(w);for(n in w.geometryGroups){E=w.geometryGroups[n];if(!E.__webGLVertexBuffer){var C=E;C.__webGLVertexBuffer=f.createBuffer();C.__webGLNormalBuffer=f.createBuffer();C.__webGLTangentBuffer=f.createBuffer();C.__webGLColorBuffer=f.createBuffer();C.__webGLUVBuffer=f.createBuffer();C.__webGLUV2Buffer=f.createBuffer();C.__webGLSkinVertexABuffer=f.createBuffer();C.__webGLSkinVertexBBuffer=f.createBuffer();C.__webGLSkinIndicesBuffer=f.createBuffer();C.__webGLSkinWeightsBuffer=f.createBuffer();
  264. C.__webGLFaceBuffer=f.createBuffer();C.__webGLLineBuffer=f.createBuffer();if(C.numMorphTargets){var G=void 0,S=void 0;C.__webGLMorphTargetsBuffers=[];G=0;for(S=C.numMorphTargets;G<S;G++)C.__webGLMorphTargetsBuffers.push(f.createBuffer())}C=E;var P=D,M=void 0,ca=void 0,va=S=G=0;M=void 0;ca=void 0;var ha=void 0;ca=void 0;var wa=P.geometry;ha=wa.faces;var ia=C.faces;M=0;for(ca=ia.length;M<ca;M++){fi=ia[M];face=ha[fi];if(face instanceof THREE.Face3){G+=3;S+=1;va+=3}else if(face instanceof THREE.Face4){G+=
  265. 4;S+=2;va+=4}}M=C;ca=P;ha=void 0;ia=void 0;var Ja=void 0,Ra=void 0;Ja=void 0;var ra=[];ha=0;for(ia=ca.materials.length;ha<ia;ha++){Ja=ca.materials[ha];if(Ja instanceof THREE.MeshFaceMaterial){Ja=0;for(l=M.materials.length;Ja<l;Ja++)(Ra=M.materials[Ja])&&ra.push(Ra)}else(Ra=Ja)&&ra.push(Ra)}ca=ra;a:{M=void 0;ha=void 0;ia=ca.length;for(M=0;M<ia;M++){ha=ca[M];if(ha.map||ha.lightMap){M=!0;break a}}M=!1}a:{ha=ca;ia=void 0;ra=void 0;Ja=ha.length;for(ia=0;ia<Ja;ia++){ra=ha[ia];if(!(ra instanceof THREE.MeshBasicMaterial||
  266. ra instanceof THREE.MeshDepthMaterial)){ha=ra&&ra.shading!=undefined&&ra.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}ha=!1}a:{ia=void 0;ra=void 0;Ja=ca.length;for(ia=0;ia<Ja;ia++){ra=ca[ia];if(ra.vertexColors){ca=ra.vertexColors;break a}}ca=!1}C.__vertexArray=new Float32Array(G*3);if(ha)C.__normalArray=new Float32Array(G*3);if(wa.hasTangents)C.__tangentArray=new Float32Array(G*4);if(ca)C.__colorArray=new Float32Array(G*3);if(M){if(wa.faceUvs.length>0||wa.faceVertexUvs.length>
  267. 0)C.__uvArray=new Float32Array(G*2);if(wa.faceUvs.length>1||wa.faceVertexUvs.length>1)C.__uv2Array=new Float32Array(G*2)}if(P.geometry.skinWeights.length&&P.geometry.skinIndices.length){C.__skinVertexAArray=new Float32Array(G*4);C.__skinVertexBArray=new Float32Array(G*4);C.__skinIndexArray=new Float32Array(G*4);C.__skinWeightArray=new Float32Array(G*4)}C.__faceArray=new Uint16Array(S*3);C.__lineArray=new Uint16Array(va*2);if(C.numMorphTargets){P=void 0;wa=void 0;C.__morphTargetsArrays=[];P=0;for(wa=
  268. C.numMorphTargets;P<wa;P++)C.__morphTargetsArrays.push(new Float32Array(G*3))}C.__needsSmoothNormals=ha==THREE.SmoothShading;C.__uvType=M;C.__vertexColorType=ca;C.__normalType=ha;C.__webGLFaceCount=S*3;C.__webGLLineCount=va*2;w.__dirtyVertices=!0;w.__dirtyMorphTargets=!0;w.__dirtyElements=!0;w.__dirtyUvs=!0;w.__dirtyNormals=!0;w.__dirtyTangents=!0;w.__dirtyColors=!0}J(p.__webglObjects,E,D)}}else if(D instanceof THREE.Ribbon){w=D.geometry;if(!w.__webGLVertexBuffer){n=w;n.__webGLVertexBuffer=f.createBuffer();
  269. n.__webGLColorBuffer=f.createBuffer();n=w;E=n.vertices.length;n.__vertexArray=new Float32Array(E*3);n.__colorArray=new Float32Array(E*3);n.__webGLVertexCount=E;w.__dirtyVertices=!0;w.__dirtyColors=!0}J(p.__webglObjects,w,D)}else if(D instanceof THREE.Line){w=D.geometry;if(!w.__webGLVertexBuffer){n=w;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=w;E=n.vertices.length;n.__vertexArray=new Float32Array(E*3);n.__colorArray=new Float32Array(E*3);n.__webGLLineCount=E;w.__dirtyVertices=
  270. !0;w.__dirtyColors=!0}J(p.__webglObjects,w,D)}else if(D instanceof THREE.ParticleSystem){w=D.geometry;if(!w.__webGLVertexBuffer){n=w;n.__webGLVertexBuffer=f.createBuffer();n.__webGLColorBuffer=f.createBuffer();n=w;E=n.vertices.length;n.__vertexArray=new Float32Array(E*3);n.__colorArray=new Float32Array(E*3);n.__sortArray=[];n.__webGLParticleCount=E;w.__dirtyVertices=!0;w.__dirtyColors=!0}J(p.__webglObjects,w,D)}else THREE.MarchingCubes!==undefined&&D instanceof THREE.MarchingCubes&&p.__webglObjectsImmediate.push({object:D,
  271. opaque:{list:[],count:0},transparent:{list:[],count:0}});m.__objectsAdded.splice(0,1)}for(;m.__objectsRemoved.length;){D=m.__objectsRemoved[0];p=m;w=void 0;n=void 0;for(w=p.__webglObjects.length-1;w>=0;w--){n=p.__webglObjects[w].object;D==n&&p.__webglObjects.splice(w,1)}m.__objectsRemoved.splice(0,1)}D=0;for(p=m.__webglObjects.length;D<p;D++){n=m.__webglObjects[D].object;E=void 0;w=void 0;C=void 0;if(n instanceof THREE.Mesh){w=n.geometry;for(E in w.geometryGroups){C=w.geometryGroups[E];if(w.__dirtyVertices||
  272. w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents){G=f.DYNAMIC_DRAW;S=void 0;va=void 0;var Ga=void 0,O=void 0;Ga=void 0;var Oa=void 0,Fa=void 0,Sa=void 0;P=void 0;wa=void 0;M=void 0;ca=void 0;ha=void 0;var U=void 0,$=void 0,aa=void 0,ma=void 0;Fa=void 0;Sa=void 0;U=void 0;O=void 0;U=void 0;$=void 0;aa=void 0;Fa=void 0;U=void 0;$=void 0;aa=void 0;ma=void 0;U=void 0;$=void 0;aa=void 0;ma=void 0;U=void 0;$=void 0;aa=void 0;ma=void 0;U=void 0;
  273. $=void 0;aa=void 0;ma=void 0;O=void 0;Oa=void 0;Ga=void 0;Ga=void 0;var Ka=void 0,Xa=void 0,Ma=void 0,Va=Ra=Ja=ra=ia=0,Qa=0,L=0,ga=0,X=0,B=0,T=0,ja=C.__vertexArray,Na=C.__uvArray,Pa=C.__uv2Array,La=C.__normalArray,Ba=C.__tangentArray,Ha=C.__colorArray,Ca=C.__skinVertexAArray,Ia=C.__skinVertexBArray,Aa=C.__skinIndexArray,Da=C.__skinWeightArray,eb=C.__morphTargetsArrays,Ya=C.__faceArray,Ua=C.__lineArray,lb=C.__needsSmoothNormals;wa=C.__vertexColorType;P=C.__uvType;M=C.__normalType;var Ta=n.geometry,
  274. fb=Ta.__dirtyVertices,gb=Ta.__dirtyElements,db=Ta.__dirtyUvs,hb=Ta.__dirtyNormals,ib=Ta.__dirtyTangents,jb=Ta.__dirtyColors,kb=Ta.__dirtyMorphTargets,Wa=Ta.vertices,mb=C.faces,pb=Ta.faces,nb=Ta.faceVertexUvs[0],ob=Ta.faceVertexUvs[1],ab=Ta.skinVerticesA,bb=Ta.skinVerticesB,cb=Ta.skinIndices,$a=Ta.skinWeights,Za=Ta.morphTargets;S=0;for(va=mb.length;S<va;S++){Ga=mb[S];O=pb[Ga];nb&&(ca=nb[Ga]);ob&&(ha=ob[Ga]);Ga=O.vertexNormals;Oa=O.normal;Fa=O.vertexColors;Sa=O.color;if(O instanceof THREE.Face3){if(fb){U=
  275. Wa[O.a].position;$=Wa[O.b].position;aa=Wa[O.c].position;ja[ra]=U.x;ja[ra+1]=U.y;ja[ra+2]=U.z;ja[ra+3]=$.x;ja[ra+4]=$.y;ja[ra+5]=$.z;ja[ra+6]=aa.x;ja[ra+7]=aa.y;ja[ra+8]=aa.z;ra+=9}if(kb){Ka=0;for(Xa=Za.length;Ka<Xa;Ka++){U=Za[Ka].vertices[O.a].position;$=Za[Ka].vertices[O.b].position;aa=Za[Ka].vertices[O.c].position;Ma=eb[Ka];Ma[T+0]=U.x;Ma[T+1]=U.y;Ma[T+2]=U.z;Ma[T+3]=$.x;Ma[T+4]=$.y;Ma[T+5]=$.z;Ma[T+6]=aa.x;Ma[T+7]=aa.y;Ma[T+8]=aa.z}T+=9}if($a.length){U=$a[O.a];$=$a[O.b];aa=$a[O.c];Da[B]=U.x;Da[B+
  276. 1]=U.y;Da[B+2]=U.z;Da[B+3]=U.w;Da[B+4]=$.x;Da[B+5]=$.y;Da[B+6]=$.z;Da[B+7]=$.w;Da[B+8]=aa.x;Da[B+9]=aa.y;Da[B+10]=aa.z;Da[B+11]=aa.w;U=cb[O.a];$=cb[O.b];aa=cb[O.c];Aa[B]=U.x;Aa[B+1]=U.y;Aa[B+2]=U.z;Aa[B+3]=U.w;Aa[B+4]=$.x;Aa[B+5]=$.y;Aa[B+6]=$.z;Aa[B+7]=$.w;Aa[B+8]=aa.x;Aa[B+9]=aa.y;Aa[B+10]=aa.z;Aa[B+11]=aa.w;U=ab[O.a];$=ab[O.b];aa=ab[O.c];Ca[B]=U.x;Ca[B+1]=U.y;Ca[B+2]=U.z;Ca[B+3]=1;Ca[B+4]=$.x;Ca[B+5]=$.y;Ca[B+6]=$.z;Ca[B+7]=1;Ca[B+8]=aa.x;Ca[B+9]=aa.y;Ca[B+10]=aa.z;Ca[B+11]=1;U=bb[O.a];$=bb[O.b];
  277. aa=bb[O.c];Ia[B]=U.x;Ia[B+1]=U.y;Ia[B+2]=U.z;Ia[B+3]=1;Ia[B+4]=$.x;Ia[B+5]=$.y;Ia[B+6]=$.z;Ia[B+7]=1;Ia[B+8]=aa.x;Ia[B+9]=aa.y;Ia[B+10]=aa.z;Ia[B+11]=1;B+=12}if(jb&&wa){if(Fa.length==3&&wa==THREE.VertexColors){U=Fa[0];$=Fa[1];aa=Fa[2]}else aa=$=U=Sa;Ha[X]=U.r;Ha[X+1]=U.g;Ha[X+2]=U.b;Ha[X+3]=$.r;Ha[X+4]=$.g;Ha[X+5]=$.b;Ha[X+6]=aa.r;Ha[X+7]=aa.g;Ha[X+8]=aa.b;X+=9}if(ib&&Ta.hasTangents){Fa=Wa[O.a].tangent;Sa=Wa[O.b].tangent;U=Wa[O.c].tangent;Ba[L]=Fa.x;Ba[L+1]=Fa.y;Ba[L+2]=Fa.z;Ba[L+3]=Fa.w;Ba[L+4]=
  278. Sa.x;Ba[L+5]=Sa.y;Ba[L+6]=Sa.z;Ba[L+7]=Sa.w;Ba[L+8]=U.x;Ba[L+9]=U.y;Ba[L+10]=U.z;Ba[L+11]=U.w;L+=12}if(hb&&M)if(Ga.length==3&&lb)for(O=0;O<3;O++){Oa=Ga[O];La[Qa]=Oa.x;La[Qa+1]=Oa.y;La[Qa+2]=Oa.z;Qa+=3}else for(O=0;O<3;O++){La[Qa]=Oa.x;La[Qa+1]=Oa.y;La[Qa+2]=Oa.z;Qa+=3}if(db&&ca!==undefined&&P)for(O=0;O<3;O++){Ga=ca[O];Na[Ja]=Ga.u;Na[Ja+1]=Ga.v;Ja+=2}if(db&&ha!==undefined&&P)for(O=0;O<3;O++){Ga=ha[O];Pa[Ra]=Ga.u;Pa[Ra+1]=Ga.v;Ra+=2}if(gb){Ya[Va]=ia;Ya[Va+1]=ia+1;Ya[Va+2]=ia+2;Va+=3;Ua[ga]=ia;Ua[ga+
  279. 1]=ia+1;Ua[ga+2]=ia;Ua[ga+3]=ia+2;Ua[ga+4]=ia+1;Ua[ga+5]=ia+2;ga+=6;ia+=3}}else if(O instanceof THREE.Face4){if(fb){U=Wa[O.a].position;$=Wa[O.b].position;aa=Wa[O.c].position;ma=Wa[O.d].position;ja[ra]=U.x;ja[ra+1]=U.y;ja[ra+2]=U.z;ja[ra+3]=$.x;ja[ra+4]=$.y;ja[ra+5]=$.z;ja[ra+6]=aa.x;ja[ra+7]=aa.y;ja[ra+8]=aa.z;ja[ra+9]=ma.x;ja[ra+10]=ma.y;ja[ra+11]=ma.z;ra+=12}if(kb){Ka=0;for(Xa=Za.length;Ka<Xa;Ka++){U=Za[Ka].vertices[O.a].position;$=Za[Ka].vertices[O.b].position;aa=Za[Ka].vertices[O.c].position;
  280. ma=Za[Ka].vertices[O.d].position;Ma=eb[Ka];Ma[T+0]=U.x;Ma[T+1]=U.y;Ma[T+2]=U.z;Ma[T+3]=$.x;Ma[T+4]=$.y;Ma[T+5]=$.z;Ma[T+6]=aa.x;Ma[T+7]=aa.y;Ma[T+8]=aa.z;Ma[T+9]=ma.x;Ma[T+10]=ma.y;Ma[T+11]=ma.z}T+=12}if($a.length){U=$a[O.a];$=$a[O.b];aa=$a[O.c];ma=$a[O.d];Da[B]=U.x;Da[B+1]=U.y;Da[B+2]=U.z;Da[B+3]=U.w;Da[B+4]=$.x;Da[B+5]=$.y;Da[B+6]=$.z;Da[B+7]=$.w;Da[B+8]=aa.x;Da[B+9]=aa.y;Da[B+10]=aa.z;Da[B+11]=aa.w;Da[B+12]=ma.x;Da[B+13]=ma.y;Da[B+14]=ma.z;Da[B+15]=ma.w;U=cb[O.a];$=cb[O.b];aa=cb[O.c];ma=cb[O.d];
  281. Aa[B]=U.x;Aa[B+1]=U.y;Aa[B+2]=U.z;Aa[B+3]=U.w;Aa[B+4]=$.x;Aa[B+5]=$.y;Aa[B+6]=$.z;Aa[B+7]=$.w;Aa[B+8]=aa.x;Aa[B+9]=aa.y;Aa[B+10]=aa.z;Aa[B+11]=aa.w;Aa[B+12]=ma.x;Aa[B+13]=ma.y;Aa[B+14]=ma.z;Aa[B+15]=ma.w;U=ab[O.a];$=ab[O.b];aa=ab[O.c];ma=ab[O.d];Ca[B]=U.x;Ca[B+1]=U.y;Ca[B+2]=U.z;Ca[B+3]=1;Ca[B+4]=$.x;Ca[B+5]=$.y;Ca[B+6]=$.z;Ca[B+7]=1;Ca[B+8]=aa.x;Ca[B+9]=aa.y;Ca[B+10]=aa.z;Ca[B+11]=1;Ca[B+12]=ma.x;Ca[B+13]=ma.y;Ca[B+14]=ma.z;Ca[B+15]=1;U=bb[O.a];$=bb[O.b];aa=bb[O.c];ma=bb[O.d];Ia[B]=U.x;Ia[B+1]=U.y;
  282. Ia[B+2]=U.z;Ia[B+3]=1;Ia[B+4]=$.x;Ia[B+5]=$.y;Ia[B+6]=$.z;Ia[B+7]=1;Ia[B+8]=aa.x;Ia[B+9]=aa.y;Ia[B+10]=aa.z;Ia[B+11]=1;Ia[B+12]=ma.x;Ia[B+13]=ma.y;Ia[B+14]=ma.z;Ia[B+15]=1;B+=16}if(jb&&wa){if(Fa.length==4&&wa==THREE.VertexColors){U=Fa[0];$=Fa[1];aa=Fa[2];Fa=Fa[3]}else Fa=aa=$=U=Sa;Ha[X]=U.r;Ha[X+1]=U.g;Ha[X+2]=U.b;Ha[X+3]=$.r;Ha[X+4]=$.g;Ha[X+5]=$.b;Ha[X+6]=aa.r;Ha[X+7]=aa.g;Ha[X+8]=aa.b;Ha[X+9]=Fa.r;Ha[X+10]=Fa.g;Ha[X+11]=Fa.b;X+=12}if(ib&&Ta.hasTangents){Fa=Wa[O.a].tangent;Sa=Wa[O.b].tangent;U=
  283. Wa[O.c].tangent;O=Wa[O.d].tangent;Ba[L]=Fa.x;Ba[L+1]=Fa.y;Ba[L+2]=Fa.z;Ba[L+3]=Fa.w;Ba[L+4]=Sa.x;Ba[L+5]=Sa.y;Ba[L+6]=Sa.z;Ba[L+7]=Sa.w;Ba[L+8]=U.x;Ba[L+9]=U.y;Ba[L+10]=U.z;Ba[L+11]=U.w;Ba[L+12]=O.x;Ba[L+13]=O.y;Ba[L+14]=O.z;Ba[L+15]=O.w;L+=16}if(hb&&M)if(Ga.length==4&&lb)for(O=0;O<4;O++){Oa=Ga[O];La[Qa]=Oa.x;La[Qa+1]=Oa.y;La[Qa+2]=Oa.z;Qa+=3}else for(O=0;O<4;O++){La[Qa]=Oa.x;La[Qa+1]=Oa.y;La[Qa+2]=Oa.z;Qa+=3}if(db&&ca!==undefined&&P)for(O=0;O<4;O++){Ga=ca[O];Na[Ja]=Ga.u;Na[Ja+1]=Ga.v;Ja+=2}if(db&&
  284. ha!==undefined&&P)for(O=0;O<4;O++){Ga=ha[O];Pa[Ra]=Ga.u;Pa[Ra+1]=Ga.v;Ra+=2}if(gb){Ya[Va]=ia;Ya[Va+1]=ia+1;Ya[Va+2]=ia+2;Ya[Va+3]=ia;Ya[Va+4]=ia+2;Ya[Va+5]=ia+3;Va+=6;Ua[ga]=ia;Ua[ga+1]=ia+1;Ua[ga+2]=ia;Ua[ga+3]=ia+3;Ua[ga+4]=ia+1;Ua[ga+5]=ia+2;Ua[ga+6]=ia+2;Ua[ga+7]=ia+3;ga+=8;ia+=4}}}if(fb){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ja,G)}if(kb){Ka=0;for(Xa=Za.length;Ka<Xa;Ka++){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLMorphTargetsBuffers[Ka]);f.bufferData(f.ARRAY_BUFFER,
  285. eb[Ka],G)}}if(jb&&X>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Ha,G)}if(hb){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,La,G)}if(ib&&Ta.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Ba,G)}if(db&&Ja>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Na,G)}if(db&&Ra>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Pa,G)}if(gb){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,
  286. C.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ya,G);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ua,G)}if(B>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,Ca,G);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,Ia,G);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,Aa,G);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,
  287. Da,G)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;E=f.DYNAMIC_DRAW;P=void 0;P=void 0;wa=void 0;C=void 0;M=n.vertices;G=n.colors;ca=M.length;S=G.length;ha=n.__vertexArray;va=n.__colorArray;ia=n.__dirtyColors;if(n.__dirtyVertices){for(P=0;P<ca;P++){wa=M[P].position;C=P*3;ha[C]=wa.x;ha[C+1]=wa.y;ha[C+2]=wa.z}f.bindBuffer(f.ARRAY_BUFFER,
  288. n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ha,E)}if(ia){for(P=0;P<S;P++){color=G[P];C=P*3;va[C]=color.r;va[C+1]=color.g;va[C+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,va,E)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Line){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;E=f.DYNAMIC_DRAW;P=void 0;P=void 0;wa=void 0;C=void 0;M=n.vertices;G=n.colors;ca=M.length;S=G.length;ha=n.__vertexArray;va=n.__colorArray;ia=n.__dirtyColors;
  289. if(n.__dirtyVertices){for(P=0;P<ca;P++){wa=M[P].position;C=P*3;ha[C]=wa.x;ha[C+1]=wa.y;ha[C+2]=wa.z}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ha,E)}if(ia){for(P=0;P<S;P++){color=G[P];C=P*3;va[C]=color.r;va[C+1]=color.g;va[C+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,n.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,va,E)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(n instanceof THREE.ParticleSystem){w=n.geometry;(w.__dirtyVertices||w.__dirtyColors||n.sortParticles)&&
  290. c(w,f.DYNAMIC_DRAW,n);w.__dirtyVertices=!1;w.__dirtyColors=!1}}};this.setFaceCulling=function(m,D){if(m){!D||D=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW);if(m=="back")f.cullFace(f.BACK);else m=="front"?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK);f.enable(f.CULL_FACE)}else f.disable(f.CULL_FACE)};this.supportsVertexTextures=function(){return f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  291. 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)}}}};
  292. 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)};
  293. 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.uvs=[];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
  294. 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};
  295. 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,j=a.faces,k=e.faces,o=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=k.length;t<x;t++){h=k[t];var q,A=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof
  296. THREE.Face4&&(q=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);b=0;for(g=A.length;b<g;b++){y=A[b];q.vertexNormals.push(y.clone())}q.materials=h.materials.slice();j.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];j=[];b=0;for(g=d.length;b<g;b++)j.push(new THREE.UV(d[b].u,d[b].v));o.push(j)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,
  297. 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 V.objects)if(!N.objects[t]){H=V.objects[t];if(z=N.geometries[H.geometry]){Z=[];for(i=0;i<H.materials.length;i++)Z[i]=N.materials[H.materials[i]];J=H.position;r=H.rotation;s=H.scale;
  298. object=new THREE.Mesh(z,Z);object.position.set(J[0],J[1],J[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=H.visible;N.scene.addObject(object);N.objects[t]=object}}}function h(xa){return function(ta){N.geometries[xa]=ta;g();fa-=1;j()}}function j(){d({total_models:W,total_textures:na,loaded_models:W-fa,loaded_textures:na-R},N);fa==0&&R==0&&b(N)}var k,o,t,x,y,q,A,H,J,F,K,z,I,Q,Z,V,f,fa,R,W,na,N;V=e.data;f=new THREE.Loader;R=fa=0;N={scene:new THREE.Scene,geometries:{},
  299. materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};e=function(){R-=1;j()};for(y in V.cameras){F=V.cameras[y];if(F.type=="perspective")I=new THREE.Camera(F.fov,F.aspect,F.near,F.far);else if(F.type=="ortho"){I=new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(F.left,F.right,F.top,F.bottom,F.near,F.far)}J=F.position;F=F.target;I.position.set(J[0],J[1],J[2]);I.target.position.set(F[0],F[1],F[2]);N.cameras[y]=I}for(x in V.lights){y=V.lights[x];if(y.type=="directional"){J=y.direction;
  300. light=new THREE.DirectionalLight;light.position.set(J[0],J[1],J[2]);light.position.normalize()}else if(y.type=="point"){J=y.position;light=new THREE.PointLight;light.position.set(J[0],J[1],J[2])}F=y.color;i=y.intensity||1;light.color.setRGB(F[0]*i,F[1]*i,F[2]*i);N.scene.addLight(light);N.lights[x]=light}for(q in V.fogs){x=V.fogs[q];if(x.type=="linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));F=x.color;Q.color.setRGB(F[0],F[1],F[2]);N.fogs[q]=Q}if(N.cameras&&
  301. V.defaults.camera)N.currentCamera=N.cameras[V.defaults.camera];if(N.fogs&&V.defaults.fog)N.scene.fog=N.fogs[V.defaults.fog];F=V.defaults.bgcolor;N.bgColor=new THREE.Color;N.bgColor.setRGB(F[0],F[1],F[2]);N.bgColorAlpha=V.defaults.bgalpha;for(k in V.geometries){q=V.geometries[k];if(q.type=="bin_mesh"||q.type=="ascii_mesh")fa+=1}W=fa;for(k in V.geometries){q=V.geometries[k];if(q.type=="cube"){z=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);
  302. N.geometries[k]=z}else if(q.type=="plane"){z=new Plane(q.width,q.height,q.segmentsWidth,q.segmentsHeight);N.geometries[k]=z}else if(q.type=="sphere"){z=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);N.geometries[k]=z}else if(q.type=="cylinder"){z=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);N.geometries[k]=z}else if(q.type=="torus"){z=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);N.geometries[k]=z}else if(q.type=="icosahedron"){z=new Icosahedron(q.subdivisions);
  303. N.geometries[k]=z}else if(q.type=="bin_mesh")f.loadBinary({model:q.url,callback:h(k)});else q.type=="ascii_mesh"&&f.loadAscii({model:q.url,callback:h(k)})}for(A in V.textures){k=V.textures[A];R+=k.url instanceof Array?k.url.length:1}na=R;for(A in V.textures){k=V.textures[A];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array)q=ImageUtils.loadTextureCube(k.url,k.mapping,e);else{q=ImageUtils.loadTexture(k.url,k.mapping,e);if(THREE[k.minFilter]!=
  304. undefined)q.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)q.magFilter=THREE[k.magFilter]}N.textures[A]=q}for(o in V.materials){A=V.materials[o];for(K in A.parameters)if(K=="envMap"||K=="map"||K=="lightMap")A.parameters[K]=N.textures[A.parameters[K]];else if(K=="shading")A.parameters[K]=A.parameters[K]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(K=="blending")A.parameters[K]=THREE[A.parameters[K]]?THREE[A.parameters[K]]:THREE.NormalBlending;else K=="combine"&&(A.parameters[K]=
  305. A.parameters[K]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);N.materials[o]=A}g();c(N)}},addMesh:function(a,c,b,d,e,g,h,j,k,o){c=new THREE.Mesh(c,o);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=j;c.rotation.z=k;a.addObject(c);return c},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,
  306. 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])}));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])}));
  307. 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,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,
  308. 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;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},
  309. 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}",
  310. 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}"},
  311. 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},
  312. 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}",
  313. 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}"},
  314. 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",
  315. 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}"},
  316. 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}"},
  317. 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}",
  318. 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}};
  319. 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.0050;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=
  320. 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=
  321. 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=
  322. !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=
  323. !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);
  324. 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()},
  325. !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;
  326. 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))};
  327. THREE.PathCamera=function(a){function c(o,t,x,y){var q={name:x,fps:0.6,length:y,hierarchy:[]},A,H=t.getControlPointsArray(),J=t.getLength(),F=H.length,K=0;A=F-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:H[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[A]={time:y,pos:H[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A<F-1;A++){K=y*J.chunks[A]/J.total;t.keys[A]={time:K,pos:H[A]}}q.hierarchy[0]=t;THREE.AnimationHandler.add(q);return new THREE.Animation(o,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(o,t){var x,
  328. y,q=new THREE.Geometry;for(x=0;x<o.points.length*t;x++){y=x/(o.points.length*t);y=o.getPoint(y);q.vertices[x]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return q}function d(o,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);o.addChild(lineObj);particleObj.scale.set(1,1,1);o.addChild(particleObj);y=new Sphere(1,
  329. 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();o.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.0050;this.lookVertical=
  330. !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;
  331. 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=
  332. 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(o,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;
  333. 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,o,t,x)};this.onMouseMove=function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
  334. this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new Cube(10,10,20),k=new Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,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=
  335. 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(o,t){return function(){t.apply(o,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;
  336. var Cube=function(a,c,b,d,e,g,h,j,k){function o(J,F,K,z,I,Q,Z,V){var f,fa,R=d||1,W=e||1,na=I/2,N=Q/2,xa=t.vertices.length;if(J=="x"&&F=="y"||J=="y"&&F=="x")f="z";else if(J=="x"&&F=="z"||J=="z"&&F=="x"){f="y";W=g||1}else if(J=="z"&&F=="y"||J=="y"&&F=="z"){f="x";R=g||1}var ta=R+1,qa=W+1;I/=R;var ua=Q/W;for(fa=0;fa<qa;fa++)for(Q=0;Q<ta;Q++){var la=new THREE.Vector3;la[J]=(Q*I-na)*K;la[F]=(fa*ua-N)*z;la[f]=Z;t.vertices.push(new THREE.Vertex(la))}for(fa=0;fa<W;fa++)for(Q=0;Q<R;Q++){t.faces.push(new THREE.Face4(Q+
  337. ta*fa+xa,Q+ta*(fa+1)+xa,Q+1+ta*(fa+1)+xa,Q+1+ta*fa+xa,null,null,V));t.faceVertexUvs[0].push([new THREE.UV(Q/R,fa/W),new THREE.UV(Q/R,(fa+1)/W),new THREE.UV((Q+1)/R,(fa+1)/W),new THREE.UV((Q+1)/R,fa/W)])}}THREE.Geometry.call(this);var t=this,x=a/2,y=c/2,q=b/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var H in k)this.sides[H]!=
  338. undefined&&(this.sides[H]=k[H]);this.sides.px&&o("z","y",1*j,-1,b,c,-x,this.materials[0]);this.sides.nx&&o("z","y",-1*j,-1,b,c,x,this.materials[1]);this.sides.py&&o("x","z",1*j,1,a,b,y,this.materials[2]);this.sides.ny&&o("x","z",1*j,-1,a,b,-y,this.materials[3]);this.sides.pz&&o("x","y",1*j,-1,a,c,q,this.materials[4]);this.sides.nz&&o("x","y",-1*j,-1,a,c,-q,this.materials[5]);(function(){for(var J=[],F=[],K=0,z=t.vertices.length;K<z;K++){for(var I=t.vertices[K],Q=!1,Z=0,V=J.length;Z<V;Z++){var f=J[Z];
  339. if(I.position.x==f.position.x&&I.position.y==f.position.y&&I.position.z==f.position.z){F[K]=Z;Q=!0;break}}if(!Q){F[K]=J.length;J.push(new THREE.Vertex(I.position.clone()))}}K=0;for(z=t.faces.length;K<z;K++){I=t.faces[K];I.a=F[I.a];I.b=F[I.b];I.c=F[I.c];I.d=F[I.d]}t.vertices=J})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  340. var Cylinder=function(a,c,b,d,e,g){function h(t,x,y){j.vertices.push(new THREE.Vertex(new THREE.Vector3(t,x,y)))}THREE.Geometry.call(this);var j=this,k=Math.PI,o=d/2;for(d=0;d<a;d++)h(Math.sin(2*k*d/a)*c,Math.cos(2*k*d/a)*c,-o);for(d=0;d<a;d++)h(Math.sin(2*k*d/a)*b,Math.cos(2*k*d/a)*b,o);for(d=0;d<a;d++)j.faces.push(new THREE.Face4(d,d+a,a+(d+1)%a,(d+1)%a));if(b>0){h(0,0,-o-(g||0));for(d=a;d<a+a/2;d++)j.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,o+(e||0));
  341. for(d=a+a/2;d<2*a;d++)j.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;
  342. var Icosahedron=function(a){function c(x,y,q){var A=Math.sqrt(x*x+y*y+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,y/A,q/A)))-1}function b(x,y,q,A){A.faces.push(new THREE.Face3(x,y,q))}function d(x,y){var q=e.vertices[x].position,A=e.vertices[y].position;return c((q.x+A.x)/2,(q.y+A.y)/2,(q.z+A.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,
  343. 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 j in g.faces){var k=d(g.faces[j].a,g.faces[j].b),o=d(g.faces[j].b,g.faces[j].c),t=d(g.faces[j].c,g.faces[j].a);b(g.faces[j].a,k,t,h);b(g.faces[j].b,o,k,h);b(g.faces[j].c,
  344. t,o,h);b(k,o,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;
  345. 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=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));d[j]=a[j].clone();e[j]=this.vertices.length-1}for(var k=(new THREE.Matrix4).setRotationZ(c),o=0;o<=this.angle+0.0010;o+=c){for(j=0;j<d.length;j++)if(o<this.angle){d[j]=k.multiplyVector3(d[j].clone());this.vertices.push(new THREE.Vertex(d[j]));g[j]=this.vertices.length-1}else g=h;o==0&&(h=e);for(j=
  346. 0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.faceVertexUvs[0].push([new THREE.UV(o/b,j/a.length),new THREE.UV(o/b,(j+1)/a.length),new THREE.UV((o-c)/b,(j+1)/a.length),new THREE.UV((o-c)/b,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
  347. 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 j=b+1,k=d+1;a/=b;var o=c/d;for(e=0;e<k;e++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*o-h),0)));for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*e,c+j*(e+1),c+1+j*(e+1),c+1+j*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()};
  348. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  349. 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 j=a*Math.cos(d*e),k=a*Math.sin(d*e),o=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=k*Math.sin(x*e);x=k*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,y)))-1);o.push(t)}c.push(o)}var q,A,H;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){o=d==g-1;h=c[b][o?0:d+1];j=c[b][o?g-1:d];k=c[b-1][o?g-1:d];o=c[b-1][o?
  350. 0:d+1];y=b/(e-1);q=(b-1)/(e-1);A=(d+1)/g;x=d/g;t=new THREE.UV(1-A,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var J=new THREE.UV(1-A,q);if(b<c.length-1){q=this.vertices[h].position.clone();A=this.vertices[j].position.clone();H=this.vertices[k].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,y,x])}if(b>1){q=this.vertices[h].position.clone();
  351. A=this.vertices[k].position.clone();H=this.vertices[o].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,k,o,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,x,J])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  352. 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=
  353. 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;
  354. var TorusKnot=function(a,c,b,d,e,g,h){function j(x,y,q,A,H,J){y=q/A*x;q=Math.cos(y);return new THREE.Vector3(H*(2+q)*0.5*Math.cos(x),H*(2+q)*Math.sin(x)*0.5,J*H*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 k=
  355. a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;e=j(k,h,this.q,this.p,this.radius,this.heightScale);k=j(k+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=k.x-e.x;b.y=k.y-e.y;b.z=k.z-e.z;d.x=k.x+e.x;d.y=k.y+e.y;d.z=k.z+e.z;g.cross(b,d);d.cross(g,b);g.normalize();d.normalize();k=this.tube*Math.cos(h);h=this.tube*Math.sin(h);e.x+=k*d.x+h*g.x;e.y+=k*d.y+h*g.y;e.z+=k*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=
  356. 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);k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var o=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,k,o]);this.faces.push(new THREE.Face3(g,d,b));this.faceVertexUvs[0].push([t,
  357. o,k])}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};
  358. 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=
  359. 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(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function d(j,k){var o=new Image;o.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));
  360. j.image.width=t;j.image.height=x;j.image.getContext("2d").drawImage(this,0,0,t,x)}else j.image=this;j.needsUpdate=!0};o.src=k}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors?THREE.VertexColors:!1};a.shading&&a.shading=="Phong"&&(e="MeshPhongMaterial");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=(a.colorDiffuse[0]*
  361. 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;
  362. THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
  363. 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.");
  364. else{var h,j,k,o,t,x,y,q,A,H,J=a.faces;q=a.vertices;var F=a.normals,K=a.colors,z=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&z++;for(h=0;h<z;h++){g.faceUvs[h]=[];g.faceVertexUvs[h]=[]}k=0;for(o=q.length;k<o;){A=new THREE.Vertex;A.position.x=q[k++];A.position.y=q[k++];A.position.z=q[k++];g.vertices.push(A)}k=0;for(o=J.length;k<o;){t=J[k++];x=t&1;h=t&2;y=t&4;j=t&8;q=t&16;A=t&32;H=t&64;t&=128;if(x){x=new THREE.Face4;x.a=J[k++];x.b=J[k++];x.c=J[k++];x.d=J[k++];nVertices=4}else{x=new THREE.Face3;x.a=
  365. J[k++];x.b=J[k++];x.c=J[k++];nVertices=3}if(h){materialIndex=J[k++];x.materials=g.materials[materialIndex]}if(y)for(h=0;h<z;h++){uvLayer=a.uvs[h];uvIndex=J[k++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];g.faceUvs[h].push(new THREE.UV(u,v))}if(j)for(h=0;h<z;h++){uvLayer=a.uvs[h];uvs=[];for(j=0;j<nVertices;j++){uvIndex=J[k++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[j]=new THREE.UV(u,v)}g.faceVertexUvs[h].push(uvs)}if(q){normalIndex=J[k++]*3;normal=new THREE.Vector3;normal.x=F[normalIndex++];
  366. normal.y=F[normalIndex++];normal.z=F[normalIndex];x.normal=normal}if(A)for(h=0;h<nVertices;h++){normalIndex=J[k++]*3;normal=new THREE.Vector3;normal.x=F[normalIndex++];normal.y=F[normalIndex++];normal.z=F[normalIndex];x.vertexNormals.push(normal)}if(H){color=new THREE.Color(J[k++]);x.color=color}if(t)for(h=0;h<nVertices;h++){colorIndex=J[k++];color=new THREE.Color(K[colorIndex]);x.vertexColors.push(color)}g.faces.push(x)}}})();(function(){var h,j,k,o;if(a.skinWeights){h=0;for(j=a.skinWeights.length;h<
  367. j;h+=2){k=a.skinWeights[h];o=a.skinWeights[h+1];g.skinWeights.push(new THREE.Vector4(k,o,0,0))}}if(a.skinIndices){h=0;for(j=a.skinIndices.length;h<j;h+=2){k=a.skinIndices[h];o=a.skinIndices[h+1];g.skinIndices.push(new THREE.Vector4(k,o,0,0))}}g.bones=a.bones;g.animation=a.animation})();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;
  368. THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
  369. 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()};
  370. c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,e,g){var h=new XMLHttpRequest,j=d+"/"+a,k=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 ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(g){k==0&&(k=h.getResponseHeader("Content-Length"));g({total:k,loaded:h.responseText.length})}}else h.readyState==2&&(k=h.getResponseHeader("Content-Length"))};h.open("GET",j,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
  371. h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,d){var e=function(g){function h(p,n){var w=t(p,n),E=t(p,n+1),C=t(p,n+2),G=t(p,n+3),S=(G<<1&255|C>>7)-127;w|=(C&127)<<16|E<<8;if(w==0&&S==-127)return 0;return(1-2*(G>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,S)}function j(p,n){var w=t(p,n),E=t(p,n+1),C=t(p,n+2);return(t(p,n+3)<<24)+(C<<16)+(E<<8)+w}function k(p,n){var w=t(p,n);return(t(p,n+1)<<8)+w}function o(p,n){var w=t(p,n);return w>127?w-256:w}function t(p,
  372. n){return p.charCodeAt(n)&255}function x(p){var n,w,E;n=j(a,p);w=j(a,p+Z);E=j(a,p+V);p=k(a,p+f);THREE.BinaryLoader.prototype.f3(F,n,w,E,p)}function y(p){var n,w,E,C,G,S;n=j(a,p);w=j(a,p+Z);E=j(a,p+V);C=k(a,p+f);G=j(a,p+fa);S=j(a,p+R);p=j(a,p+W);THREE.BinaryLoader.prototype.f3n(F,I,n,w,E,C,G,S,p)}function q(p){var n,w,E,C;n=j(a,p);w=j(a,p+na);E=j(a,p+N);C=j(a,p+xa);p=k(a,p+ta);THREE.BinaryLoader.prototype.f4(F,n,w,E,C,p)}function A(p){var n,w,E,C,G,S,P,M;n=j(a,p);w=j(a,p+na);E=j(a,p+N);C=j(a,p+xa);
  373. G=k(a,p+ta);S=j(a,p+qa);P=j(a,p+ua);M=j(a,p+la);p=j(a,p+ka);THREE.BinaryLoader.prototype.f4n(F,I,n,w,E,C,G,S,P,M,p)}function H(p){var n,w;n=j(a,p);w=j(a,p+oa);p=j(a,p+pa);THREE.BinaryLoader.prototype.uv3(F.faceVertexUvs[0],Q[n*2],Q[n*2+1],Q[w*2],Q[w*2+1],Q[p*2],Q[p*2+1])}function J(p){var n,w,E;n=j(a,p);w=j(a,p+ea);E=j(a,p+da);p=j(a,p+sa);THREE.BinaryLoader.prototype.uv4(F.faceVertexUvs[0],Q[n*2],Q[n*2+1],Q[w*2],Q[w*2+1],Q[E*2],Q[E*2+1],Q[p*2],Q[p*2+1])}var F=this,K=0,z,I=[],Q=[],Z,V,f,fa,R,W,na,
  374. N,xa,ta,qa,ua,la,ka,oa,pa,ea,da,sa,Ea,Y,ya,za,m,D;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,d,g);z={signature:a.substr(K,8),header_bytes:t(a,K+8),vertex_coordinate_bytes:t(a,K+9),normal_coordinate_bytes:t(a,K+10),uv_coordinate_bytes:t(a,K+11),vertex_index_bytes:t(a,K+12),normal_index_bytes:t(a,K+13),uv_index_bytes:t(a,K+14),material_index_bytes:t(a,K+15),nvertices:j(a,K+16),nnormals:j(a,K+16+4),nuvs:j(a,K+16+8),ntri_flat:j(a,K+16+12),ntri_smooth:j(a,K+16+16),ntri_flat_uv:j(a,
  375. K+16+20),ntri_smooth_uv:j(a,K+16+24),nquad_flat:j(a,K+16+28),nquad_smooth:j(a,K+16+32),nquad_flat_uv:j(a,K+16+36),nquad_smooth_uv:j(a,K+16+40)};K+=z.header_bytes;Z=z.vertex_index_bytes;V=z.vertex_index_bytes*2;f=z.vertex_index_bytes*3;fa=z.vertex_index_bytes*3+z.material_index_bytes;R=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes;W=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*2;na=z.vertex_index_bytes;N=z.vertex_index_bytes*2;xa=z.vertex_index_bytes*3;ta=
  376. z.vertex_index_bytes*4;qa=z.vertex_index_bytes*4+z.material_index_bytes;ua=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes;la=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*2;ka=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*3;oa=z.uv_index_bytes;pa=z.uv_index_bytes*2;ea=z.uv_index_bytes;da=z.uv_index_bytes*2;sa=z.uv_index_bytes*3;g=z.vertex_index_bytes*3+z.material_index_bytes;D=z.vertex_index_bytes*4+z.material_index_bytes;Ea=z.ntri_flat*
  377. g;Y=z.ntri_smooth*(g+z.normal_index_bytes*3);ya=z.ntri_flat_uv*(g+z.uv_index_bytes*3);za=z.ntri_smooth_uv*(g+z.normal_index_bytes*3+z.uv_index_bytes*3);m=z.nquad_flat*D;g=z.nquad_smooth*(D+z.normal_index_bytes*4);D=z.nquad_flat_uv*(D+z.uv_index_bytes*4);K+=function(p){for(var n,w,E,C=z.vertex_coordinate_bytes*3,G=p+z.nvertices*C;p<G;p+=C){n=h(a,p);w=h(a,p+z.vertex_coordinate_bytes);E=h(a,p+z.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(F,n,w,E)}return z.nvertices*C}(K);K+=function(p){for(var n,
  378. w,E,C=z.normal_coordinate_bytes*3,G=p+z.nnormals*C;p<G;p+=C){n=o(a,p);w=o(a,p+z.normal_coordinate_bytes);E=o(a,p+z.normal_coordinate_bytes*2);I.push(n/127,w/127,E/127)}return z.nnormals*C}(K);K+=function(p){for(var n,w,E=z.uv_coordinate_bytes*2,C=p+z.nuvs*E;p<C;p+=E){n=h(a,p);w=h(a,p+z.uv_coordinate_bytes);Q.push(n,w)}return z.nuvs*E}(K);Ea=K+Ea;Y=Ea+Y;ya=Y+ya;za=ya+za;m=za+m;g=m+g;D=g+D;(function(p){var n,w=z.vertex_index_bytes*3+z.material_index_bytes,E=w+z.uv_index_bytes*3,C=p+z.ntri_flat_uv*E;
  379. for(n=p;n<C;n+=E){x(n);H(n+w)}return C-p})(Y);(function(p){var n,w=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,E=w+z.uv_index_bytes*3,C=p+z.ntri_smooth_uv*E;for(n=p;n<C;n+=E){y(n);H(n+w)}return C-p})(ya);(function(p){var n,w=z.vertex_index_bytes*4+z.material_index_bytes,E=w+z.uv_index_bytes*4,C=p+z.nquad_flat_uv*E;for(n=p;n<C;n+=E){q(n);J(n+w)}return C-p})(g);(function(p){var n,w=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*4,E=w+z.uv_index_bytes*4,C=
  380. p+z.nquad_smooth_uv*E;for(n=p;n<C;n+=E){A(n);J(n+w)}return C-p})(D);(function(p){var n,w=z.vertex_index_bytes*3+z.material_index_bytes,E=p+z.ntri_flat*w;for(n=p;n<E;n+=w)x(n);return E-p})(K);(function(p){var n,w=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,E=p+z.ntri_smooth*w;for(n=p;n<E;n+=w)y(n);return E-p})(Ea);(function(p){var n,w=z.vertex_index_bytes*4+z.material_index_bytes,E=p+z.nquad_flat*w;for(n=p;n<E;n+=w)q(n);return E-p})(za);(function(p){var n,w=z.vertex_index_bytes*
  381. 4+z.material_index_bytes+z.normal_index_bytes*4,E=p+z.nquad_smooth*w;for(n=p;n<E;n+=w)A(n);return E-p})(m);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,
  382. b,d,e,g,h,j,k){g=a.materials[g];var o=c[j*3],t=c[j*3+1];j=c[j*3+2];var x=c[k*3],y=c[k*3+1];k=c[k*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(o,t,j),new THREE.Vector3(x,y,k)],g))},f4n:function(a,c,b,d,e,g,h,j,k,o,t){h=a.materials[h];var x=c[k*3],y=c[k*3+1];k=c[k*3+2];var q=c[o*3],A=c[o*3+1];o=c[o*3+2];var H=c[t*3],J=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(b,d,e,g,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(x,y,k),
  383. new THREE.Vector3(q,A,o),new THREE.Vector3(H,J,t)],h))},uv3:function(a,c,b,d,e,g,h){var j=[];j.push(new THREE.UV(c,b));j.push(new THREE.UV(d,e));j.push(new THREE.UV(g,h));a.push(j)},uv4:function(a,c,b,d,e,g,h,j,k){var o=[];o.push(new THREE.UV(c,b));o.push(new THREE.UV(d,e));o.push(new THREE.UV(g,h));o.push(new THREE.UV(j,k));a.push(o)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  384. 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=
  385. 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,j,k,o,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=j+h*this.delta;d[g+1]=k;d[g+2]=o;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,j,k,o,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=j;d[g+1]=k+h*this.delta;d[g+
  386. 2]=o;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,j,k,o,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=j;d[g+1]=k;d[g+2]=o+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]-
  387. 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,j){var k=g+1,o=g+this.yd,t=g+this.zd,x=k+this.yd,y=k+this.zd,q=g+this.yd+this.zd,A=k+this.yd+this.zd,H=0,J=this.field[g],F=this.field[k],K=this.field[o],z=this.field[x],I=this.field[t],Q=this.field[y],Z=this.field[q],V=this.field[A];J<h&&(H|=1);F<h&&(H|=2);K<h&&(H|=8);z<h&&(H|=4);I<h&&(H|=16);Q<h&&(H|=32);Z<h&&(H|=128);V<h&&(H|=64);var f=THREE.edgeTable[H];if(f==0)return 0;
  388. var fa=this.delta,R=b+fa,W=d+fa;fa=e+fa;if(f&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,J,F)}if(f&2){this.compNorm(k);this.compNorm(x);this.VIntY(k*3,this.vlist,this.nlist,3,h,R,d,e,F,z)}if(f&4){this.compNorm(o);this.compNorm(x);this.VIntX(o*3,this.vlist,this.nlist,6,h,b,W,e,K,z)}if(f&8){this.compNorm(g);this.compNorm(o);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,J,K)}if(f&16){this.compNorm(t);this.compNorm(y);this.VIntX(t*3,this.vlist,this.nlist,12,h,
  389. b,d,fa,I,Q)}if(f&32){this.compNorm(y);this.compNorm(A);this.VIntY(y*3,this.vlist,this.nlist,15,h,R,d,fa,Q,V)}if(f&64){this.compNorm(q);this.compNorm(A);this.VIntX(q*3,this.vlist,this.nlist,18,h,b,W,fa,Z,V)}if(f&128){this.compNorm(t);this.compNorm(q);this.VIntY(t*3,this.vlist,this.nlist,21,h,b,d,fa,I,Z)}if(f&256){this.compNorm(g);this.compNorm(t);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,J,I)}if(f&512){this.compNorm(k);this.compNorm(y);this.VIntZ(k*3,this.vlist,this.nlist,27,h,R,d,e,F,Q)}if(f&
  390. 1024){this.compNorm(x);this.compNorm(A);this.VIntZ(x*3,this.vlist,this.nlist,30,h,R,W,e,z,V)}if(f&2048){this.compNorm(o);this.compNorm(q);this.VIntZ(o*3,this.vlist,this.nlist,33,h,b,W,e,K,Z)}H<<=4;for(h=g=0;THREE.triTable[H+h]!=-1;){b=H+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],j);h+=3;g++}return g};this.posnormtriv=function(b,d,e,g,h,j){var k=this.count*3;this.positionArray[k]=b[e];this.positionArray[k+1]=b[e+1];this.positionArray[k+
  391. 2]=b[e+2];this.positionArray[k+3]=b[g];this.positionArray[k+4]=b[g+1];this.positionArray[k+5]=b[g+2];this.positionArray[k+6]=b[h];this.positionArray[k+7]=b[h+1];this.positionArray[k+8]=b[h+2];this.normalArray[k]=d[e];this.normalArray[k+1]=d[e+1];this.normalArray[k+2]=d[e+2];this.normalArray[k+3]=d[g];this.normalArray[k+4]=d[g+1];this.normalArray[k+5]=d[g+2];this.normalArray[k+6]=d[h];this.normalArray[k+7]=d[h+1];this.normalArray[k+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=
  392. this.maxCount-3&&j(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 j=this.size*Math.sqrt(g/h),k=e*this.size,o=d*this.size,t=b*this.size,x=Math.floor(k-j);x<1&&(x=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var y=Math.floor(o-j);y<1&&(y=1);o=Math.floor(o+j);o>this.size-1&&(o=this.size-1);var q=Math.floor(t-
  393. j);q<1&&(q=1);j=Math.floor(t+j);j>this.size-1&&(j=this.size-1);for(var A,H,J,F,K,z;x<k;x++){t=this.size2*x;H=x/this.size-e;K=H*H;for(H=y;H<o;H++){J=t+this.size*H;A=H/this.size-d;z=A*A;for(A=q;A<j;A++){F=A/this.size-b;F=g/(1.0E-6+F*F+z+K)-h;F>0&&(this.field[J+A]+=F)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,o=this.size,t=this.yd,x=this.zd,y=this.field,q=o*Math.sqrt(b/d);q>o&&(q=o);for(e=0;e<q;e++){g=e/o;g*=g;j=b/(1.0E-4+g)-d;if(j>0)for(g=0;g<o;g++){k=e+g*t;for(h=0;h<o;h++)y[x*h+k]+=j}}};this.addPlaneY=
  394. function(b,d){var e,g,h,j,k,o,t=this.size,x=this.yd,y=this.zd,q=this.field,A=t*Math.sqrt(b/d);A>t&&(A=t);for(g=0;g<A;g++){e=g/t;e*=e;j=b/(1.0E-4+e)-d;if(j>0){k=g*x;for(e=0;e<t;e++){o=k+e;for(h=0;h<t;h++)q[y*h+o]+=j}}}};this.addPlaneZ=function(b,d){var e,g,h,j,k,o;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;j=b/(1.0E-4+e)-d;if(j>0){k=zd*h;for(g=0;g<size;g++){o=k+g*yd;for(e=0;e<size;e++)field[o+e]+=j}}}};this.reset=
  395. 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,j,k,o,t,x,y=this.size-2;for(h=1;h<y;h++){x=this.size2*h;o=(h-this.halfsize)/this.halfsize;for(g=1;g<y;g++){t=x+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<y;e++){j=(e-this.halfsize)/this.halfsize;d=t+e;this.polygonize(j,k,o,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(e){var g,h,j,
  396. k,o,t,x,y;for(g=0;g<e.count;g++){o=g*3;x=o+1;y=o+2;h=e.positionArray[o];j=e.positionArray[x];k=e.positionArray[y];t=new THREE.Vector3(h,j,k);h=e.normalArray[o];j=e.normalArray[x];k=e.normalArray[y];o=new THREE.Vector3(h,j,k);o.normalize();o=new THREE.Vertex(t,o);d.vertices.push(o)}nfaces=e.count/3;for(g=0;g<nfaces;g++){o=(b+g)*3;x=o+1;y=o+2;t=d.vertices[o].normal;h=d.vertices[x].normal;j=d.vertices[y].normal;o=new THREE.Face3(o,x,y,[t,h,j]);d.faces.push(o)}b+=nfaces;e.count=0});return d};this.init(a)};
  397. THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  398. 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,
  399. 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,
  400. 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]);
  401. 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,
  402. -1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,
  403. -1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,
  404. -1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,
  405. 8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,
  406. -1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,
  407. 5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,
  408. -1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,
  409. 10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,
  410. 6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,
  411. 8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,
  412. 2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,
  413. -1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,
  414. -1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,
  415. -1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
  416. 1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,
  417. -1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,
  418. 2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,
  419. 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
  420. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
  421. 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);