Three.js 184 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. // Three.js r35 - 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(E,v,F,w){w=w.clone().subSelf(v);F=F.clone().subSelf(v);var N=E.clone().subSelf(v);E=w.dot(w);v=w.dot(F);w=w.dot(N);var L=F.dot(F);F=F.dot(N);N=1/(E*L-v*v);L=(L*w-v*F)*N;E=(E*F-v*w)*N;return L>0&&E>0&&L+E<1}var b,d,e,g,h,j,k,n,q,x,
  16. u,t=a.geometry,y=t.vertices,A=[];b=0;for(d=t.faces.length;b<d;b++){e=t.faces[b];x=this.origin.clone();u=this.direction.clone();k=a.matrixWorld;g=k.multiplyVector3(y[e.a].position.clone());h=k.multiplyVector3(y[e.b].position.clone());j=k.multiplyVector3(y[e.c].position.clone());k=e instanceof THREE.Face4?k.multiplyVector3(y[e.d].position.clone()):null;n=a.matrixRotationWorld.multiplyVector3(e.normal.clone());q=u.dot(n);if(q<0){n=n.dot((new THREE.Vector3).sub(g,x))/q;x=x.addSelf(u.multiplyScalar(n));
  17. if(e instanceof THREE.Face3){if(c(x,g,h,j)){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};A.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};A.push(e)}}}return A}};
  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,n,q,x){j=!1;c=k;b=n;d=q;e=x;a()};this.addPoint=function(k,n){if(j){j=!1;c=k;b=n;d=k;e=n}else{c=c<k?c:k;b=b<n?b:n;d=d>k?d:k;e=e>n?e:n}a()};
  19. this.add3Points=function(k,n,q,x,u,t){if(j){j=!1;c=k<q?k<u?k:u:q<u?q:u;b=n<x?n<t?n:t:x<t?x:t;d=k>q?k>u?k:u:q>u?q:u;e=n>x?n>t?n:t:x>t?x:t}else{c=k<q?k<u?k<c?k:c:u<c?u:c:q<u?q<c?q:c:u<c?u:c;b=n<x?n<t?n<b?n:b:t<b?t:b:x<t?x<b?x:b:t<b?t:b;d=k>q?k>u?k>d?k:d:u>d?u:d:q>u?q>d?q:d:u>d?u:d;e=n>x?n>t?n>e?n:e:t>e?t:e:x>t?x>e?x:e:t>e?t: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,n,q,x,u,t,y,A){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,n||0,q||1,x||0,u||0,t||0,y||0,A||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,n,q,x,u,t,y,A){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=n;this.n33=q;this.n34=x;this.n41=u;this.n42=t;this.n43=y;this.n44=A;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();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*d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},
  25. 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();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+
  26. 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,n=a.n24,q=a.n31,x=a.n32,u=a.n33,t=a.n34,y=a.n41,A=a.n42,E=a.n43,v=a.n44,F=c.n11,w=c.n12,N=c.n13,L=c.n14,Z=c.n21,M=c.n22,f=c.n23,V=c.n24,T=c.n31,ca=c.n32,ea=c.n33,I=c.n34;this.n11=b*F+d*Z+e*T;this.n12=
  27. b*w+d*M+e*ca;this.n13=b*N+d*f+e*ea;this.n14=b*L+d*V+e*I+g;this.n21=h*F+j*Z+k*T;this.n22=h*w+j*M+k*ca;this.n23=h*N+j*f+k*ea;this.n24=h*L+j*V+k*I+n;this.n31=q*F+x*Z+u*T;this.n32=q*w+x*M+u*ca;this.n33=q*N+x*f+u*ea;this.n34=q*L+x*V+u*I+t;this.n41=y*F+A*Z+E*T;this.n42=y*w+A*M+E*ca;this.n43=y*N+A*f+E*ea;this.n44=y*L+A*V+E*I+v;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=
  28. 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=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=
  29. this.n22,h=this.n23,j=this.n24,k=this.n31,n=this.n32,q=this.n33,x=this.n34,u=this.n41,t=this.n42,y=this.n43,A=this.n44;return d*h*n*u-b*j*n*u-d*g*q*u+c*j*q*u+b*g*x*u-c*h*x*u-d*h*k*t+b*j*k*t+d*e*q*t-a*j*q*t-b*e*x*t+a*h*x*t+d*g*k*y-c*j*k*y-d*e*n*y+a*j*n*y+c*e*x*y-a*g*x*y-b*g*k*A+c*h*k*A+b*e*n*A-a*h*n*A-c*e*q*A+a*g*q*A},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=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=
  30. 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;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=
  31. 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]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;
  32. 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,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},
  33. 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,n=e*h;this.set(k*g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,n*h+b,n*j-d*g,0,k*j-d*h,
  34. n*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=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=
  35. b+b,j=d+d;a=c*g;var k=c*h;c*=j;var n=b*h;b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(n+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+n);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=a.n34},extractRotation:function(a,
  36. 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,n=a.n24,q=a.n31,x=a.n32,u=a.n33,t=a.n34,y=a.n41,A=a.n42,E=a.n43,v=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*t*A-n*u*A+n*x*E-j*t*E-k*x*v+j*u*v;c.n12=g*u*A-e*t*A-g*x*E+d*t*E+e*x*v-d*u*v;c.n13=e*n*A-g*k*A+g*j*E-d*n*E-e*j*v+d*k*v;c.n14=g*k*x-e*n*x-g*j*u+d*n*u+e*j*t-d*k*t;c.n21=n*u*y-k*t*y-n*q*E+h*t*E+k*q*v-h*u*v;c.n22=e*t*y-g*u*y+g*q*E-b*t*E-e*q*v+b*u*v;c.n23=g*k*y-e*n*y-g*h*E+b*n*E+e*h*v-b*k*v;
  38. c.n24=e*n*q-g*k*q+g*h*u-b*n*u-e*h*t+b*k*t;c.n31=j*t*y-n*x*y+n*q*A-h*t*A-j*q*v+h*x*v;c.n32=g*x*y-d*t*y-g*q*A+b*t*A+d*q*v-b*x*v;c.n33=e*n*y-g*j*y+g*h*A-b*n*A-d*h*v+b*j*v;c.n34=g*j*q-d*n*q-g*h*x+b*n*x+d*h*t-b*j*t;c.n41=k*x*y-j*u*y-k*q*A+h*u*A+j*q*E-h*x*E;c.n42=d*u*y-e*x*y+e*q*A-b*u*A-d*q*E+b*x*E;c.n43=e*j*y-d*k*y-e*h*A+b*k*A+d*h*E-b*j*E;c.n44=d*k*q-e*j*q+e*h*x-b*k*x-d*h*u+b*j*u;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,n=a.n23*a.n12-a.n22*a.n13,q=-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*n;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*n;b[7]=a*q;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,n;h=new THREE.Matrix4;j=c-a;k=b-d;n=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/n;h.n34=-((g+e)/n);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))}return!0},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.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,n=k*b+h*e-j*d,q=k*d+j*b-g*e,x=k*e+g*d-h*b;b=-g*b-h*d-j*e;c.x=n*k+b*-g+q*-j-x*-h;c.y=q*k+b*-h+x*-g-n*-j;c.z=x*k+b*-j+n*-h-q*-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};
  52. THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
  53. THREE.Face3=function(a,c,b,d,e){this.a=a;this.b=c;this.c=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};
  54. 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}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];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.vertices.length;d<e;d++){g=this.vertices[d];g.normal.set(0,0,0)}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,
  57. b.position);k.sub(c.position,b.position);j.crossSelf(k)}j.isZero()||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,
  58. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)d[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];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<
  59. c;a++){b=this.faces[a];if(b instanceof THREE.Face3){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}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(I,ba,wa,da,ua,ha,fa){g=I.vertices[ba].position;h=I.vertices[wa].position;j=I.vertices[da].position;k=e[ua];n=e[ha];q=e[fa];x=h.x-g.x;u=j.x-g.x;t=h.y-g.y;
  60. y=j.y-g.y;A=h.z-g.z;E=j.z-g.z;v=n.u-k.u;F=q.u-k.u;w=n.v-k.v;N=q.v-k.v;L=1/(v*N-F*w);f.set((N*x-w*u)*L,(N*t-w*y)*L,(N*A-w*E)*L);V.set((v*u-F*x)*L,(v*y-F*t)*L,(v*E-F*A)*L);Z[ba].addSelf(f);Z[wa].addSelf(f);Z[da].addSelf(f);M[ba].addSelf(V);M[wa].addSelf(V);M[da].addSelf(V)}var c,b,d,e,g,h,j,k,n,q,x,u,t,y,A,E,v,F,w,N,L,Z=[],M=[],f=new THREE.Vector3,V=new THREE.Vector3,T=new THREE.Vector3,ca=new THREE.Vector3,ea=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){Z[c]=new THREE.Vector3;M[c]=new THREE.Vector3}c=
  61. 0;for(b=this.faces.length;c<b;c++){d=this.faces[c];e=this.uvs[c];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]);
  62. this.vertices[d.d].normal.copy(d.vertexNormals[3])}}c=0;for(b=this.vertices.length;c<b;c++){ea.copy(this.vertices[c].normal);d=Z[c];T.copy(d);T.subSelf(ea.multiplyScalar(ea.dot(d))).normalize();ca.cross(this.vertices[c].normal,d);d=ca.dot(M[c]);d=d<0?-1:1;this.vertices[c].tangent.set(T.x,T.y,T.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],
  63. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
  64. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
  65. THREE.Spline=function(){function a(u,t,y,A,E,v,F){u=(y-u)*0.5;A=(A-t)*0.5;return(2*(t-y)+u+A)*F+(-3*(t-y)-2*u-A)*v+u*E+t}var c=[],b={x:0,y:0,z:0},d,e,g,h,j,k,n,q,x;this.get2DPoint=function(u,t){d=(u.length-1)*t;e=Math.floor(d);g=d-e;c[0]=e==0?e:e-1;c[1]=e;c[2]=e>u.length-2?e:e+1;c[3]=e>u.length-3?e:e+2;k=u[c[0]];n=u[c[1]];q=u[c[2]];x=u[c[3]];h=g*g;j=g*h;b.x=a(k.x,n.x,q.x,x.x,g,h,j);b.y=a(k.y,n.y,q.y,x.y,g,h,j);b.z=a(k.z,n.z,q.z,x.z,g,h,j);return b}};
  66. 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){e.length=parseInt(e.length*1E3,10);e.fps*=0.0010;for(var g=0;g<e.hierarchy.length;g++)for(var h=
  67. 0;h<e.hierarchy[g].keys.length;h++){if(e.hierarchy[g].keys[h].time<0)e.hierarchy[g].keys[h].time=0;e.hierarchy[g].keys[h].time=parseInt(e.hierarchy[g].keys[h].time*1E3,10);e.hierarchy[g].keys[h].index=h;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])}}h=parseInt(e.length*e.fps*0.0010,10);e.JIT={};e.JIT.hierarchy=[];for(g=0;g<e.hierarchy.length;g++)e.JIT.hierarchy.push(Array(h));
  68. 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=0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=2;return b}();
  69. 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.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=b!==undefined?b:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==undefined?d:!0};
  70. 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;for(var b=0;b<this.hierarchy.length;b++){this.hierarchy[b].useQuaternion=!0;this.hierarchy[b].matrixAutoUpdate=!0;if(this.hierarchy[b].animationCache===undefined){this.hierarchy[b].animationCache={};this.hierarchy[b].animationCache.prevKey={pos:0,rot:0,scl:0};this.hierarchy[b].animationCache.nextKey={pos:0,rot:0,scl:0};this.hierarchy[b].animationCache.originalMatrix=
  71. this.hierarchy[b]instanceof THREE.Bone?this.hierarchy[b].skinMatrix:this.hierarchy[b].matrix}var d=this.hierarchy[b].animationCache.prevKey,e=this.hierarchy[b].animationCache.nextKey;d.pos=this.data.hierarchy[b].keys[0];d.rot=this.data.hierarchy[b].keys[0];d.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)};
  72. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  73. THREE.Animation.prototype.stop=function(){this.isPlaying=!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}};
  74. THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,j,k,n,q=this.data.JIT.hierarchy,x,u;this.currentTime+=a;u=this.currentTime;x=this.currentTime%=this.data.length;n=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var t=0,y=this.hierarchy.length;t<y;t++){a=this.hierarchy[t];k=a.animationCache;if(q[t][n]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=q[t][n];a.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,t*16);
  75. a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!1}else{a.matrix=q[t][n];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var A=0;A<3;A++){b=c[A];h=k.prevKey[b];j=k.nextKey[b];if(j.time<u){if(x<u)if(this.loop){h=this.data.hierarchy[t].keys[0];j=this.getNextKeyWith(b,t,1)}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(b,t,j.index+1)}while(j.time<x)}k.prevKey[b]=
  76. 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);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;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{var E=[];E[0]=this.getPrevKeyWith(b,t,h.index-1)[b];E[1]=e;E[2]=g;E[3]=this.getNextKeyWith(b,t,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(E,
  77. d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}else if(b==="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&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;t<this.hierarchy.length;t++)q[t][n]=this.hierarchy[t]instanceof THREE.Bone?this.hierarchy[t].skinMatrix.clone():this.hierarchy[t].matrix.clone()}}};
  78. THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],d=[],e,g,h,j,k,n;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]];n=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],n[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],n[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],n[2],e,b,h);return d};
  79. 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;for(b%=d.length;b<d.length;b++)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[0]};
  80. THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b=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]};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()};
  81. THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;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)};
  82. 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=
  83. !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)};
  84. 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.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=a.noFly;if(a.lookVertical!==
  85. undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;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.phy=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=
  86. !1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};
  87. 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=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?
  88. 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);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lat=Math.max(-85,Math.min(85,this.lat));
  89. this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,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()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),
  90. !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;
  91. 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))};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;
  92. 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;
  93. THREE.FlatShading=0;THREE.SmoothShading=1;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(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  94. 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=
  95. 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}};
  96. 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;if(a){a.color!==undefined&&
  97. 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;if(a.blending!==undefined)this.blending=
  98. 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}};
  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;if(a){a.color!==undefined&&
  100. 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;if(a.blending!==undefined)this.blending=
  101. 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. 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=
  103. this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!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=a.envMap;if(a.combine!==
  104. 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;if(a.wireframeLinecap!==
  105. 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}};
  106. 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!==
  107. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
  108. 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!==
  109. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
  110. 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.vertexColors=!1;this.skinning=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==undefined)this.vertexShader=
  111. 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;if(a.wireframeLinejoin!==
  112. undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  113. 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.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.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
  114. undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;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}};
  115. THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};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};
  116. THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
  117. THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
  118. 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};
  119. 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;
  120. 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;
  121. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;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}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
  122. 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;
  123. 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,
  124. 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;
  125. 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]);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];d=this.bones[b];
  126. 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;
  127. 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)}}};
  128. THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  129. 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;
  130. 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}}}};
  131. 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;
  132. 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=
  133. "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;
  134. 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()};
  135. 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};
  136. 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;
  137. 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)};
  138. 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=
  139. !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;
  140. 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])};
  141. 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])};
  142. 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||2.5E-4};
  143. THREE.Projector=function(){function a(M,f){return f.z-M.z}function c(M,f){var V=0,T=1,ca=M.z+M.w,ea=f.z+f.w,I=-M.z+M.w,ba=-f.z+f.w;if(ca>=0&&ea>=0&&I>=0&&ba>=0)return!0;else if(ca<0&&ea<0||I<0&&ba<0)return!1;else{if(ca<0)V=Math.max(V,ca/(ca-ea));else ea<0&&(T=Math.min(T,ca/(ca-ea)));if(I<0)V=Math.max(V,I/(I-ba));else ba<0&&(T=Math.min(T,I/(I-ba)));if(T<V)return!1;else{M.lerpSelf(f,V);f.lerpSelf(M,1-T);return!0}}}var b,d,e=[],g,h,j,k=[],n,q,x=[],u,t,y=[],A=new THREE.Vector4,E=new THREE.Vector4,v=new THREE.Matrix4,
  144. F=new THREE.Matrix4,w=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Vector4,L=new THREE.Vector4,Z;this.projectObjects=function(M,f,V){f=[];var T,ca,ea;d=0;ca=M.objects;M=0;for(T=ca.length;M<T;M++){ea=ca[M];var I;if(!(I=!ea.visible))if(I=ea instanceof THREE.Mesh){a:{I=void 0;for(var ba=ea.matrixWorld,wa=-ea.geometry.boundingSphere.radius*Math.max(ea.scale.x,Math.max(ea.scale.y,ea.scale.z)),da=0;da<6;da++){I=w[da].x*ba.n14+
  145. w[da].y*ba.n24+w[da].z*ba.n34+w[da].w;if(I<=wa){I=!1;break a}}I=!0}I=!I}if(!I){b=e[d]=e[d]||new THREE.RenderableObject;A.copy(ea.position);v.multiplyVector3(A);b.object=ea;b.z=A.z;f.push(b);d++}}V&&f.sort(a);return f};this.projectScene=function(M,f,V){var T=[],ca=f.near,ea=f.far,I,ba,wa,da,ua,ha,fa,sa,xa,ga,aa,la,ma,R,ia,pa;j=q=t=0;f.matrixAutoUpdate&&f.update();v.multiply(f.projectionMatrix,f.matrixWorldInverse);w[0].set(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);w[1].set(v.n41+v.n11,v.n42+
  146. v.n12,v.n43+v.n13,v.n44+v.n14);w[2].set(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);w[3].set(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);w[4].set(v.n41-v.n31,v.n42-v.n32,v.n43-v.n33,v.n44-v.n34);w[5].set(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);for(I=0;I<6;I++){ha=w[I];ha.divideScalar(Math.sqrt(ha.x*ha.x+ha.y*ha.y+ha.z*ha.z))}M.update(undefined,!1,f);ha=this.projectObjects(M,f,!0);M=0;for(I=ha.length;M<I;M++){fa=ha[M].object;if(fa.visible){sa=fa.matrixWorld;aa=fa.matrixRotationWorld;
  147. xa=fa.materials;ga=fa.overdraw;if(fa instanceof THREE.Mesh){la=fa.geometry;ma=la.vertices;ba=0;for(wa=ma.length;ba<wa;ba++){R=ma[ba];R.positionWorld.copy(R.position);sa.multiplyVector3(R.positionWorld);da=R.positionScreen;da.copy(R.positionWorld);v.multiplyVector4(da);da.x/=da.w;da.y/=da.w;R.__visible=da.z>ca&&da.z<ea}la=la.faces;ba=0;for(wa=la.length;ba<wa;ba++){R=la[ba];if(R instanceof THREE.Face3){da=ma[R.a];ua=ma[R.b];ia=ma[R.c];if(da.__visible&&ua.__visible&&ia.__visible&&(fa.doubleSided||fa.flipSided!=
  148. (ia.positionScreen.x-da.positionScreen.x)*(ua.positionScreen.y-da.positionScreen.y)-(ia.positionScreen.y-da.positionScreen.y)*(ua.positionScreen.x-da.positionScreen.x)<0)){g=k[j]=k[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(da.positionWorld);g.v2.positionWorld.copy(ua.positionWorld);g.v3.positionWorld.copy(ia.positionWorld);g.v1.positionScreen.copy(da.positionScreen);g.v2.positionScreen.copy(ua.positionScreen);g.v3.positionScreen.copy(ia.positionScreen);g.normalWorld.copy(R.normal);aa.multiplyVector3(g.normalWorld);
  149. g.centroidWorld.copy(R.centroid);sa.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);ia=R.vertexNormals;Z=g.vertexNormalsWorld;da=0;for(ua=ia.length;da<ua;da++){pa=Z[da]=Z[da]||new THREE.Vector3;pa.copy(ia[da]);aa.multiplyVector3(pa)}g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=R.materials;g.overdraw=ga;if(fa.geometry.uvs[ba]){g.uvs[0]=fa.geometry.uvs[ba][0];g.uvs[1]=fa.geometry.uvs[ba][1];g.uvs[2]=fa.geometry.uvs[ba][2]}T.push(g);
  150. j++}}else if(R instanceof THREE.Face4){da=ma[R.a];ua=ma[R.b];ia=ma[R.c];pa=ma[R.d];if(da.__visible&&ua.__visible&&ia.__visible&&pa.__visible&&(fa.doubleSided||fa.flipSided!=((pa.positionScreen.x-da.positionScreen.x)*(ua.positionScreen.y-da.positionScreen.y)-(pa.positionScreen.y-da.positionScreen.y)*(ua.positionScreen.x-da.positionScreen.x)<0||(ua.positionScreen.x-ia.positionScreen.x)*(pa.positionScreen.y-ia.positionScreen.y)-(ua.positionScreen.y-ia.positionScreen.y)*(pa.positionScreen.x-ia.positionScreen.x)<
  151. 0))){g=k[j]=k[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(da.positionWorld);g.v2.positionWorld.copy(ua.positionWorld);g.v3.positionWorld.copy(pa.positionWorld);g.v1.positionScreen.copy(da.positionScreen);g.v2.positionScreen.copy(ua.positionScreen);g.v3.positionScreen.copy(pa.positionScreen);g.normalWorld.copy(R.normal);aa.multiplyVector3(g.normalWorld);g.centroidWorld.copy(R.centroid);sa.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);
  152. g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=R.materials;g.overdraw=ga;if(fa.geometry.uvs[ba]){g.uvs[0]=fa.geometry.uvs[ba][0];g.uvs[1]=fa.geometry.uvs[ba][1];g.uvs[2]=fa.geometry.uvs[ba][3]}T.push(g);j++;h=k[j]=k[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ua.positionWorld);h.v2.positionWorld.copy(ia.positionWorld);h.v3.positionWorld.copy(pa.positionWorld);h.v1.positionScreen.copy(ua.positionScreen);h.v2.positionScreen.copy(ia.positionScreen);h.v3.positionScreen.copy(pa.positionScreen);
  153. h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=xa;h.faceMaterials=R.materials;h.overdraw=ga;if(fa.geometry.uvs[ba]){h.uvs[0]=fa.geometry.uvs[ba][1];h.uvs[1]=fa.geometry.uvs[ba][2];h.uvs[2]=fa.geometry.uvs[ba][3]}T.push(h);j++}}}}else if(fa instanceof THREE.Line){F.multiply(v,sa);ma=fa.geometry.vertices;R=ma[0];R.positionScreen.copy(R.position);F.multiplyVector4(R.positionScreen);ba=1;for(wa=ma.length;ba<
  154. wa;ba++){da=ma[ba];da.positionScreen.copy(da.position);F.multiplyVector4(da.positionScreen);ua=ma[ba-1];N.copy(da.positionScreen);L.copy(ua.positionScreen);if(c(N,L)){N.multiplyScalar(1/N.w);L.multiplyScalar(1/L.w);n=x[q]=x[q]||new THREE.RenderableLine;n.v1.positionScreen.copy(N);n.v2.positionScreen.copy(L);n.z=Math.max(N.z,L.z);n.materials=fa.materials;T.push(n);q++}}}else if(fa instanceof THREE.Particle){E.set(fa.position.x,fa.position.y,fa.position.z,1);v.multiplyVector4(E);E.z/=E.w;if(E.z>0&&
  155. E.z<1){u=y[t]=y[t]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=fa.rotation.z;u.scale.x=fa.scale.x*Math.abs(u.x-(E.x+f.projectionMatrix.n11)/(E.w+f.projectionMatrix.n14));u.scale.y=fa.scale.y*Math.abs(u.y-(E.y+f.projectionMatrix.n22)/(E.w+f.projectionMatrix.n24));u.materials=fa.materials;T.push(u);t++}}}}V&&T.sort(a);return T};this.unprojectVector=function(M,f){var V=f.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(f.projectionMatrix));V.multiplyVector3(M);
  156. return M}};
  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,n,q,x,u,t,y,A;a=c.projectScene(h,j);k=0;for(n=a.length;k<n;k++){u=a[k];if(u instanceof THREE.RenderableParticle){y=u.x*e+e;A=u.y*g+g;q=0;for(x=u.material.length;q<x;q++){t=u.material[q];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=y+"px";t.style.top=A+"px"}}}}}};
  158. THREE.CanvasRenderer=function(){function a(ja){if(u!=ja)n.globalAlpha=u=ja}function c(ja){if(t!=ja){switch(ja){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}t=ja}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,j,k,n=e.getContext("2d"),q=new THREE.Color(0),x=0,u=1,t=0,y=null,A=null,E=1,v,F,w,N,L,Z,M,f,V,T=new THREE.Color,
  159. ca=new THREE.Color,ea=new THREE.Color,I=new THREE.Color,ba=new THREE.Color,wa,da,ua,ha,fa,sa,xa,ga,aa,la=new THREE.Rectangle,ma=new THREE.Rectangle,R=new THREE.Rectangle,ia=!1,pa=new THREE.Color,l=new THREE.Color,z=new THREE.Color,p=new THREE.Color,m=Math.PI*2,o=new THREE.Vector3,B,C,G,Q,H,O,ka=16;B=document.createElement("canvas");B.width=B.height=2;C=B.getContext("2d");C.fillStyle="rgba(0,0,0,1)";C.fillRect(0,0,2,2);G=C.getImageData(0,0,2,2);Q=G.data;H=document.createElement("canvas");H.width=H.height=
  160. ka;O=H.getContext("2d");O.translate(-ka/2,-ka/2);O.scale(ka,ka);ka--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ja,qa){g=ja;h=qa;j=g/2;k=h/2;e.width=g;e.height=h;la.set(-j,-k,j,k);u=1;t=0;A=y=null;E=1};this.setClearColor=function(ja,qa){q=ja;x=qa};this.setClearColorHex=function(ja,qa){q.setHex(ja);x=qa};this.clear=function(){n.setTransform(1,0,0,-1,j,k);if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(la);if(q.hex==0&&x==0)n.clearRect(ma.getX(),ma.getY(),
  161. ma.getWidth(),ma.getHeight());else{c(THREE.NormalBlending);a(1);n.fillStyle="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+x+")";n.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight())}ma.empty()}};this.render=function(ja,qa){function ra(J){var Y,U,K,S=J.lights;l.setRGB(0,0,0);z.setRGB(0,0,0);p.setRGB(0,0,0);J=0;for(Y=S.length;J<Y;J++){U=S[J];K=U.color;if(U instanceof THREE.AmbientLight){l.r+=K.r;l.g+=K.g;l.b+=K.b}else if(U instanceof THREE.DirectionalLight){z.r+=
  162. K.r;z.g+=K.g;z.b+=K.b}else if(U instanceof THREE.PointLight){p.r+=K.r;p.g+=K.g;p.b+=K.b}}}function na(J,Y,U,K){var S,ta,va,Ha,ya=J.lights;J=0;for(S=ya.length;J<S;J++){ta=ya[J];va=ta.color;Ha=ta.intensity;if(ta instanceof THREE.DirectionalLight){ta=U.dot(ta.position)*Ha;if(ta>0){K.r+=va.r*ta;K.g+=va.g*ta;K.b+=va.b*ta}}else if(ta instanceof THREE.PointLight){o.sub(ta.position,Y);o.normalize();ta=U.dot(o)*Ha;if(ta>0){K.r+=va.r*ta;K.g+=va.g*ta;K.b+=va.b*ta}}}}function oa(J,Y,U){if(U.opacity!=0){a(U.opacity);
  163. c(U.blending);var K,S,ta,va,Ha,ya;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){va=U.map.image;Ha=va.width>>1;ya=va.height>>1;S=Y.scale.x*j;ta=Y.scale.y*k;U=S*Ha;K=ta*ya;R.set(J.x-U,J.y-K,J.x+U,J.y+K);if(la.instersects(R)){n.save();n.translate(J.x,J.y);n.rotate(-Y.rotation);n.scale(S,-ta);n.translate(-Ha,-ya);n.drawImage(va,0,0);n.restore()}}}else if(U instanceof THREE.ParticleCircleMaterial){if(ia){pa.r=l.r+z.r+p.r;pa.g=l.g+z.g+p.g;pa.b=l.b+z.b+p.b;T.r=U.color.r*pa.r;T.g=U.color.g*pa.g;
  164. T.b=U.color.b*pa.b;T.updateStyleString()}else T.__styleString=U.color.__styleString;U=Y.scale.x*j;K=Y.scale.y*k;R.set(J.x-U,J.y-K,J.x+U,J.y+K);if(la.instersects(R)){S=T.__styleString;if(A!=S)n.fillStyle=A=S;n.save();n.translate(J.x,J.y);n.rotate(-Y.rotation);n.scale(U,K);n.beginPath();n.arc(0,0,1,0,m,!0);n.closePath();n.fill();n.restore()}}}}function Ia(J,Y,U,K){if(K.opacity!=0){a(K.opacity);c(K.blending);n.beginPath();n.moveTo(J.positionScreen.x,J.positionScreen.y);n.lineTo(Y.positionScreen.x,Y.positionScreen.y);
  165. n.closePath();if(K instanceof THREE.LineBasicMaterial){T.__styleString=K.color.__styleString;J=K.linewidth;if(E!=J)n.lineWidth=E=J;J=T.__styleString;if(y!=J)n.strokeStyle=y=J;n.stroke();R.inflate(K.linewidth*2)}}}function P(J,Y,U,K,S,ta){if(S.opacity!=0){a(S.opacity);c(S.blending);N=J.positionScreen.x;L=J.positionScreen.y;Z=Y.positionScreen.x;M=Y.positionScreen.y;f=U.positionScreen.x;V=U.positionScreen.y;n.beginPath();n.moveTo(N,L);n.lineTo(Z,M);n.lineTo(f,V);n.lineTo(N,L);n.closePath();if(S instanceof
  166. THREE.MeshBasicMaterial)if(S.map)S.map.mapping instanceof THREE.UVMapping&&Ea(N,L,Z,M,f,V,S.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(S.envMap){if(S.envMap.mapping instanceof THREE.SphericalReflectionMapping){J=qa.matrixWorldInverse;o.copy(K.vertexNormalsWorld[0]);ha=(o.x*J.n11+o.y*J.n12+o.z*J.n13)*0.5+0.5;fa=-(o.x*J.n21+o.y*J.n22+o.z*J.n23)*0.5+0.5;o.copy(K.vertexNormalsWorld[1]);sa=(o.x*J.n11+o.y*J.n12+o.z*J.n13)*0.5+0.5;xa=-(o.x*J.n21+o.y*J.n22+o.z*J.n23)*
  167. 0.5+0.5;o.copy(K.vertexNormalsWorld[2]);ga=(o.x*J.n11+o.y*J.n12+o.z*J.n13)*0.5+0.5;aa=-(o.x*J.n21+o.y*J.n22+o.z*J.n23)*0.5+0.5;Ea(N,L,Z,M,f,V,S.envMap.image,ha,fa,sa,xa,ga,aa)}}else S.wireframe?Fa(S.color.__styleString,S.wireframeLinewidth):Da(S.color.__styleString);else if(S instanceof THREE.MeshLambertMaterial){if(S.map&&!S.wireframe){S.map.mapping instanceof THREE.UVMapping&&Ea(N,L,Z,M,f,V,S.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);c(THREE.SubtractiveBlending)}if(ia)if(!S.wireframe&&
  168. S.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){ca.r=ea.r=I.r=l.r;ca.g=ea.g=I.g=l.g;ca.b=ea.b=I.b=l.b;na(ta,K.v1.positionWorld,K.vertexNormalsWorld[0],ca);na(ta,K.v2.positionWorld,K.vertexNormalsWorld[1],ea);na(ta,K.v3.positionWorld,K.vertexNormalsWorld[2],I);ba.r=(ea.r+I.r)*0.5;ba.g=(ea.g+I.g)*0.5;ba.b=(ea.b+I.b)*0.5;ua=W(ca,ea,I,ba);Ea(N,L,Z,M,f,V,ua,0,0,1,0,0,1)}else{pa.r=l.r;pa.g=l.g;pa.b=l.b;na(ta,K.centroidWorld,K.normalWorld,pa);T.r=S.color.r*pa.r;T.g=S.color.g*pa.g;T.b=S.color.b*
  169. pa.b;T.updateStyleString();S.wireframe?Fa(T.__styleString,S.wireframeLinewidth):Da(T.__styleString)}else S.wireframe?Fa(S.color.__styleString,S.wireframeLinewidth):Da(S.color.__styleString)}else if(S instanceof THREE.MeshDepthMaterial){wa=qa.near;da=qa.far;ca.r=ca.g=ca.b=1-X(J.positionScreen.z,wa,da);ea.r=ea.g=ea.b=1-X(Y.positionScreen.z,wa,da);I.r=I.g=I.b=1-X(U.positionScreen.z,wa,da);ba.r=(ea.r+I.r)*0.5;ba.g=(ea.g+I.g)*0.5;ba.b=(ea.b+I.b)*0.5;ua=W(ca,ea,I,ba);Ea(N,L,Z,M,f,V,ua,0,0,1,0,0,1)}else if(S instanceof
  170. THREE.MeshNormalMaterial){T.r=$(K.normalWorld.x);T.g=$(K.normalWorld.y);T.b=$(K.normalWorld.z);T.updateStyleString();S.wireframe?Fa(T.__styleString,S.wireframeLinewidth):Da(T.__styleString)}}}function Fa(J,Y){if(y!=J)n.strokeStyle=y=J;if(E!=Y)n.lineWidth=E=Y;n.stroke();R.inflate(Y*2)}function Da(J){if(A!=J)n.fillStyle=A=J;n.fill()}function Ea(J,Y,U,K,S,ta,va,Ha,ya,Oa,Ja,Ka,Sa){var Ma,Pa;Ma=va.width-1;Pa=va.height-1;Ha*=Ma;ya*=Pa;Oa*=Ma;Ja*=Pa;Ka*=Ma;Sa*=Pa;U-=J;K-=Y;S-=J;ta-=Y;Oa-=Ha;Ja-=ya;Ka-=Ha;
  171. Sa-=ya;Ma=Oa*Sa-Ka*Ja;if(Ma!=0){Pa=1/Ma;Ma=(Sa*U-Ja*S)*Pa;Ja=(Sa*K-Ja*ta)*Pa;U=(Oa*S-Ka*U)*Pa;K=(Oa*ta-Ka*K)*Pa;J=J-Ma*Ha-U*ya;Y=Y-Ja*Ha-K*ya;n.save();n.transform(Ma,Ja,U,K,J,Y);n.clip();n.drawImage(va,0,0);n.restore()}}function W(J,Y,U,K){var S=~~(J.r*255),ta=~~(J.g*255);J=~~(J.b*255);var va=~~(Y.r*255),Ha=~~(Y.g*255);Y=~~(Y.b*255);var ya=~~(U.r*255),Oa=~~(U.g*255);U=~~(U.b*255);var Ja=~~(K.r*255),Ka=~~(K.g*255);K=~~(K.b*255);Q[0]=S<0?0:S>255?255:S;Q[1]=ta<0?0:ta>255?255:ta;Q[2]=J<0?0:J>255?255:
  172. J;Q[4]=va<0?0:va>255?255:va;Q[5]=Ha<0?0:Ha>255?255:Ha;Q[6]=Y<0?0:Y>255?255:Y;Q[8]=ya<0?0:ya>255?255:ya;Q[9]=Oa<0?0:Oa>255?255:Oa;Q[10]=U<0?0:U>255?255:U;Q[12]=Ja<0?0:Ja>255?255:Ja;Q[13]=Ka<0?0:Ka>255?255:Ka;Q[14]=K<0?0:K>255?255:K;C.putImageData(G,0,0);O.drawImage(B,0,0);return H}function X(J,Y,U){J=(J-Y)/(U-Y);return J*J*(3-2*J)}function $(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function za(J,Y){var U=Y.x-J.x,K=Y.y-J.y,S=1/Math.sqrt(U*U+K*K);U*=S;K*=S;Y.x+=U;Y.y+=K;J.x-=U;J.y-=K}var Ga,Ca,D,Ba,Qa,Ta,
  173. La,Aa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,j,k);b=d.projectScene(ja,qa,this.sortElements);(ia=ja.lights.length>0)&&ra(ja);Ga=0;for(Ca=b.length;Ga<Ca;Ga++){D=b[Ga];R.empty();if(D instanceof THREE.RenderableParticle){v=D;v.x*=j;v.y*=k;Ba=0;for(Qa=D.materials.length;Ba<Qa;Ba++)oa(v,D,D.materials[Ba],ja)}else if(D instanceof THREE.RenderableLine){v=D.v1;F=D.v2;v.positionScreen.x*=j;v.positionScreen.y*=k;F.positionScreen.x*=j;F.positionScreen.y*=k;R.addPoint(v.positionScreen.x,v.positionScreen.y);
  174. R.addPoint(F.positionScreen.x,F.positionScreen.y);if(la.instersects(R)){Ba=0;for(Qa=D.materials.length;Ba<Qa;)Ia(v,F,D,D.materials[Ba++],ja)}}else if(D instanceof THREE.RenderableFace3){v=D.v1;F=D.v2;w=D.v3;v.positionScreen.x*=j;v.positionScreen.y*=k;F.positionScreen.x*=j;F.positionScreen.y*=k;w.positionScreen.x*=j;w.positionScreen.y*=k;if(D.overdraw){za(v.positionScreen,F.positionScreen);za(F.positionScreen,w.positionScreen);za(w.positionScreen,v.positionScreen)}R.add3Points(v.positionScreen.x,v.positionScreen.y,
  175. F.positionScreen.x,F.positionScreen.y,w.positionScreen.x,w.positionScreen.y);if(la.instersects(R)){Ba=0;for(Qa=D.meshMaterials.length;Ba<Qa;){Aa=D.meshMaterials[Ba++];if(Aa instanceof THREE.MeshFaceMaterial){Ta=0;for(La=D.faceMaterials.length;Ta<La;)(Aa=D.faceMaterials[Ta++])&&P(v,F,w,D,Aa,ja)}else P(v,F,w,D,Aa,ja)}}}ma.addRectangle(R)}n.setTransform(1,0,0,1,0,0)}};
  176. THREE.SVGRenderer=function(){function a(ha,fa,sa){var xa,ga,aa,la;xa=0;for(ga=ha.lights.length;xa<ga;xa++){aa=ha.lights[xa];if(aa instanceof THREE.DirectionalLight){la=fa.normalWorld.dot(aa.position)*aa.intensity;if(la>0){sa.r+=aa.color.r*la;sa.g+=aa.color.g*la;sa.b+=aa.color.b*la}}else if(aa instanceof THREE.PointLight){V.sub(aa.position,fa.centroidWorld);V.normalize();la=fa.normalWorld.dot(V)*aa.intensity;if(la>0){sa.r+=aa.color.r*la;sa.g+=aa.color.g*la;sa.b+=aa.color.b*la}}}}function c(ha,fa,sa,
  177. xa,ga,aa){I=d(ba++);I.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)w.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(aa,xa,N);w.r=ga.color.r*N.r;w.g=ga.color.g*N.g;w.b=ga.color.b*N.b;w.updateStyleString()}else w.__styleString=ga.color.__styleString;else if(ga instanceof
  178. THREE.MeshDepthMaterial){f=1-ga.__2near/(ga.__farPlusNear-xa.z*ga.__farMinusNear);w.setRGB(f,f,f)}else ga instanceof THREE.MeshNormalMaterial&&w.setRGB(e(xa.normalWorld.x),e(xa.normalWorld.y),e(xa.normalWorld.z));ga.wireframe?I.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):I.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+
  179. ga.opacity);j.appendChild(I)}function b(ha,fa,sa,xa,ga,aa,la){I=d(ba++);I.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)w.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(la,ga,N);w.r=aa.color.r*N.r;w.g=aa.color.g*N.g;
  180. w.b=aa.color.b*N.b;w.updateStyleString()}else w.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){f=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);w.setRGB(f,f,f)}else aa instanceof THREE.MeshNormalMaterial&&w.setRGB(e(ga.normalWorld.x),e(ga.normalWorld.y),e(ga.normalWorld.z));aa.wireframe?I.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+
  181. "; stroke-linejoin: "+aa.wireframeLinejoin):I.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+aa.opacity);j.appendChild(I)}function d(ha){if(T[ha]==null){T[ha]=document.createElementNS("http://www.w3.org/2000/svg","path");ua==0&&T[ha].setAttribute("shape-rendering","crispEdges")}return T[ha]}function e(ha){return ha<0?Math.min((1+ha)*0.5,0.5):0.5+Math.min(ha*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,q,x,u,t,y,A,E=
  182. new THREE.Rectangle,v=new THREE.Rectangle,F=!1,w=new THREE.Color(16777215),N=new THREE.Color(16777215),L=new THREE.Color(0),Z=new THREE.Color(0),M=new THREE.Color(0),f,V=new THREE.Vector3,T=[],ca=[],ea=[],I,ba,wa,da,ua=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ha){switch(ha){case "high":ua=1;break;case "low":ua=0}};this.setSize=function(ha,fa){k=ha;n=fa;q=k/2;x=n/2;j.setAttribute("viewBox",-q+" "+-x+" "+k+" "+n);j.setAttribute("width",
  183. k);j.setAttribute("height",n);E.set(-q,-x,q,x)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(ha,fa){var sa,xa,ga,aa,la,ma,R,ia;this.autoClear&&this.clear();g=h.projectScene(ha,fa,this.sortElements);da=wa=ba=0;if(F=ha.lights.length>0){R=ha.lights;L.setRGB(0,0,0);Z.setRGB(0,0,0);M.setRGB(0,0,0);sa=0;for(xa=R.length;sa<xa;sa++){ga=R[sa];aa=ga.color;if(ga instanceof THREE.AmbientLight){L.r+=aa.r;L.g+=aa.g;L.b+=aa.b}else if(ga instanceof THREE.DirectionalLight){Z.r+=
  184. aa.r;Z.g+=aa.g;Z.b+=aa.b}else if(ga instanceof THREE.PointLight){M.r+=aa.r;M.g+=aa.g;M.b+=aa.b}}}sa=0;for(xa=g.length;sa<xa;sa++){R=g[sa];v.empty();if(R instanceof THREE.RenderableParticle){u=R;u.x*=q;u.y*=-x;ga=0;for(aa=R.materials.length;ga<aa;ga++)if(ia=R.materials[ga]){la=u;ma=R;var pa=wa++;if(ca[pa]==null){ca[pa]=document.createElementNS("http://www.w3.org/2000/svg","circle");ua==0&&ca[pa].setAttribute("shape-rendering","crispEdges")}I=ca[pa];I.setAttribute("cx",la.x);I.setAttribute("cy",la.y);
  185. I.setAttribute("r",ma.scale.x*q);if(ia instanceof THREE.ParticleCircleMaterial){if(F){N.r=L.r+Z.r+M.r;N.g=L.g+Z.g+M.g;N.b=L.b+Z.b+M.b;w.r=ia.color.r*N.r;w.g=ia.color.g*N.g;w.b=ia.color.b*N.b;w.updateStyleString()}else w=ia.color;I.setAttribute("style","fill: "+w.__styleString)}j.appendChild(I)}}else if(R instanceof THREE.RenderableLine){u=R.v1;t=R.v2;u.positionScreen.x*=q;u.positionScreen.y*=-x;t.positionScreen.x*=q;t.positionScreen.y*=-x;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,
  186. t.positionScreen.y);if(E.instersects(v)){ga=0;for(aa=R.materials.length;ga<aa;)if(ia=R.materials[ga++]){la=u;ma=t;pa=da++;if(ea[pa]==null){ea[pa]=document.createElementNS("http://www.w3.org/2000/svg","line");ua==0&&ea[pa].setAttribute("shape-rendering","crispEdges")}I=ea[pa];I.setAttribute("x1",la.positionScreen.x);I.setAttribute("y1",la.positionScreen.y);I.setAttribute("x2",ma.positionScreen.x);I.setAttribute("y2",ma.positionScreen.y);if(ia instanceof THREE.LineBasicMaterial){w.__styleString=ia.color.__styleString;
  187. I.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+ia.linewidth+"; stroke-opacity: "+ia.opacity+"; stroke-linecap: "+ia.linecap+"; stroke-linejoin: "+ia.linejoin);j.appendChild(I)}}}}else if(R instanceof THREE.RenderableFace3){u=R.v1;t=R.v2;y=R.v3;u.positionScreen.x*=q;u.positionScreen.y*=-x;t.positionScreen.x*=q;t.positionScreen.y*=-x;y.positionScreen.x*=q;y.positionScreen.y*=-x;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);
  188. v.addPoint(y.positionScreen.x,y.positionScreen.y);if(E.instersects(v)){ga=0;for(aa=R.meshMaterials.length;ga<aa;){ia=R.meshMaterials[ga++];if(ia instanceof THREE.MeshFaceMaterial){la=0;for(ma=R.faceMaterials.length;la<ma;)(ia=R.faceMaterials[la++])&&c(u,t,y,R,ia,ha)}else ia&&c(u,t,y,R,ia,ha)}}}else if(R instanceof THREE.RenderableFace4){u=R.v1;t=R.v2;y=R.v3;A=R.v4;u.positionScreen.x*=q;u.positionScreen.y*=-x;t.positionScreen.x*=q;t.positionScreen.y*=-x;y.positionScreen.x*=q;y.positionScreen.y*=-x;
  189. A.positionScreen.x*=q;A.positionScreen.y*=-x;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(y.positionScreen.x,y.positionScreen.y);v.addPoint(A.positionScreen.x,A.positionScreen.y);if(E.instersects(v)){ga=0;for(aa=R.meshMaterials.length;ga<aa;){ia=R.meshMaterials[ga++];if(ia instanceof THREE.MeshFaceMaterial){la=0;for(ma=R.faceMaterials.length;la<ma;)(ia=R.faceMaterials[la++])&&b(u,t,y,A,R,ia,ha)}else ia&&b(u,t,y,A,R,ia,ha)}}}}}};
  190. THREE.WebGLRenderer=function(a){function c(l,z,p){var m,o,B,C=l.vertices,G=C.length,Q=l.colors,H=Q.length,O=l.__vertexArray,ka=l.__colorArray,ja=l.__sortArray,qa=l.__dirtyVertices,ra=l.__dirtyColors;if(p.sortParticles){xa.multiplySelf(p.matrixWorld);for(m=0;m<G;m++){o=C[m].position;la.copy(o);xa.multiplyVector3(la);ja[m]=[la.z,m]}ja.sort(function(na,oa){return oa[0]-na[0]});for(m=0;m<G;m++){o=C[ja[m][1]].position;B=m*3;O[B]=o.x;O[B+1]=o.y;O[B+2]=o.z}for(m=0;m<H;m++){B=m*3;color=Q[ja[m][1]];ka[B]=
  191. color.r;ka[B+1]=color.g;ka[B+2]=color.b}}else{if(qa)for(m=0;m<G;m++){o=C[m].position;B=m*3;O[B]=o.x;O[B+1]=o.y;O[B+2]=o.z}if(ra)for(m=0;m<H;m++){color=Q[m];B=m*3;ka[B]=color.r;ka[B+1]=color.g;ka[B+2]=color.b}}if(qa||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,O,z)}if(ra||p.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,ka,z)}}function b(l,z){l.fragmentShader=z.fragmentShader;l.vertexShader=z.vertexShader;
  192. l.uniforms=Uniforms.clone(z.uniforms)}function d(l,z,p,m,o){m.program||ca.initMaterial(m,z,p,o);var B=m.program,C=B.uniforms,G=m.uniforms;if(B!=V){f.useProgram(B);V=B;f.uniformMatrix4fv(C.projectionMatrix,!1,ga)}if(p&&(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial||m instanceof THREE.LineBasicMaterial||m instanceof THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){G.fogNear.value=p.near;
  193. G.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)G.fogDensity.value=p.density}if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){var Q,H,O=0,ka=0,ja=0,qa,ra,na,oa=ma,Ia=oa.directional.colors,P=oa.directional.positions,Fa=oa.point.colors,Da=oa.point.positions,Ea=0,W=0;p=H=H=0;for(Q=z.length;p<Q;p++){H=z[p];qa=H.color;ra=H.position;na=H.intensity;if(H instanceof THREE.AmbientLight){O+=qa.r;ka+=qa.g;ja+=qa.b}else if(H instanceof THREE.DirectionalLight){H=Ea*3;Ia[H]=
  194. qa.r*na;Ia[H+1]=qa.g*na;Ia[H+2]=qa.b*na;P[H]=ra.x;P[H+1]=ra.y;P[H+2]=ra.z;Ea+=1}else if(H instanceof THREE.PointLight){H=W*3;Fa[H]=qa.r*na;Fa[H+1]=qa.g*na;Fa[H+2]=qa.b*na;Da[H]=ra.x;Da[H+1]=ra.y;Da[H+2]=ra.z;W+=1}}for(p=Ea*3;p<Ia.length;p++)Ia[p]=0;for(p=W*3;p<Fa.length;p++)Fa[p]=0;oa.point.length=W;oa.directional.length=Ea;oa.ambient[0]=O;oa.ambient[1]=ka;oa.ambient[2]=ja;z=ma;G.enableLighting.value=z.directional.length+z.point.length;G.ambientLightColor.value=z.ambient;G.directionalLightColor.value=
  195. z.directional.colors;G.directionalLightDirection.value=z.directional.positions;G.pointLightColor.value=z.point.colors;G.pointLightPosition.value=z.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);G.opacity.value=m.opacity;G.map.texture=m.map;G.lightMap.texture=m.lightMap;G.envMap.texture=m.envMap;G.reflectivity.value=m.reflectivity;
  196. G.refractionRatio.value=m.refractionRatio;G.combine.value=m.combine;G.useRefract.value=m.envMap&&m.envMap.mapping instanceof THREE.CubeRefractionMapping}if(m instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);G.opacity.value=m.opacity}else if(m instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);G.opacity.value=m.opacity;G.size.value=m.size;G.map.texture=m.map}else if(m instanceof
  197. THREE.MeshPhongMaterial){G.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);G.specular.value.setRGB(m.specular.r,m.specular.g,m.specular.b);G.shininess.value=m.shininess}else if(m instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=m.opacity}else if(m instanceof THREE.MeshNormalMaterial)G.opacity.value=m.opacity;for(var X in G)if(O=B.uniforms[X]){p=G[X];Q=p.type;z=p.value;if(Q=="i")f.uniform1i(O,z);else if(Q=="f")f.uniform1f(O,z);else if(Q=="fv1")f.uniform1fv(O,
  198. z);else if(Q=="fv")f.uniform3fv(O,z);else if(Q=="v2")f.uniform2f(O,z.x,z.y);else if(Q=="v3")f.uniform3f(O,z.x,z.y,z.z);else if(Q=="c")f.uniform3f(O,z.r,z.g,z.b);else if(Q=="t"){f.uniform1i(O,z);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(Q=0;Q<6;++Q)f.texSubImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,0,0,f.RGBA,f.UNSIGNED_BYTE,p.image[Q])}else{p.image.__webGLTextureCube=
  199. f.createTexture();f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(Q=0;Q<6;++Q)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+Q,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,p.image[Q]);p.__wasSetOnce=!0}F(f.TEXTURE_CUBE_MAP,p,p.image[0]);f.bindTexture(f.TEXTURE_CUBE_MAP,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+z);f.bindTexture(f.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(p.needsUpdate){if(p.__wasSetOnce){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.texSubImage2D(f.TEXTURE_2D,
  200. 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}F(f.TEXTURE_2D,p,p.image);f.bindTexture(f.TEXTURE_2D,null);p.needsUpdate=!1}f.activeTexture(f.TEXTURE0+z);f.bindTexture(f.TEXTURE_2D,p.__webGLTexture)}}}f.uniformMatrix4fv(C.modelViewMatrix,!1,o._modelViewMatrixArray);f.uniformMatrix3fv(C.normalMatrix,!1,o._normalMatrixArray);(m instanceof THREE.MeshShaderMaterial||
  201. m instanceof THREE.MeshPhongMaterial||m.envMap)&&f.uniform3f(C.cameraPosition,l.position.x,l.position.y,l.position.z);(m instanceof THREE.MeshShaderMaterial||m.envMap||m.skinning)&&f.uniformMatrix4fv(C.objectMatrix,!1,o._objectMatrixArray);(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshShaderMaterial||m.skinning)&&f.uniformMatrix4fv(C.viewMatrix,!1,aa);if(m.skinning){f.uniformMatrix4fv(C.cameraInverseMatrix,!1,aa);f.uniformMatrix4fv(C.boneGlobalMatrices,
  202. !1,o.boneMatrices)}return B}function e(l,z,p,m,o,B){l=d(l,z,p,m,B).attributes;f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.vertexAttribPointer(l.position,3,f.FLOAT,!1,0,0);if(l.color>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.vertexAttribPointer(l.color,3,f.FLOAT,!1,0,0)}if(l.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLNormalBuffer);f.vertexAttribPointer(l.normal,3,f.FLOAT,!1,0,0)}if(l.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLTangentBuffer);f.vertexAttribPointer(l.tangent,
  203. 4,f.FLOAT,!1,0,0)}if(l.uv>=0)if(o.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUVBuffer);f.vertexAttribPointer(l.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv)}else f.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(o.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUV2Buffer);f.vertexAttribPointer(l.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv2)}else f.disableVertexAttribArray(l.uv2);if(m.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,
  204. o.__webGLSkinVertexABuffer);f.vertexAttribPointer(l.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);f.vertexAttribPointer(l.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);f.vertexAttribPointer(l.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);f.vertexAttribPointer(l.skinWeight,4,f.FLOAT,!1,0,0)}if(B instanceof THREE.Mesh)if(m.wireframe){f.lineWidth(m.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,
  205. o.__webGLLineBuffer);f.drawElements(f.LINES,o.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,o.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(B instanceof THREE.Line){B=B.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(m.linewidth);f.drawArrays(B,0,o.__webGLLineCount)}else if(B instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,o.__webGLParticleCount);else B instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,
  206. 0,o.__webGLVertexCount)}function g(l,z){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=f.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=f.createBuffer();if(l.hasPos){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,l.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(z.attributes.position);f.vertexAttribPointer(z.attributes.position,3,f.FLOAT,!1,0,0)}if(l.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,l.normalArray,
  207. f.DYNAMIC_DRAW);f.enableVertexAttribArray(z.attributes.normal);f.vertexAttribPointer(z.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,l.count);l.count=0}function h(l){if(ea!=l.doubleSided){l.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);ea=l.doubleSided}if(I!=l.flipSided){l.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);I=l.flipSided}}function j(l){if(wa!=l){l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);wa=l}}function k(l){sa[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,
  208. l.n44-l.n14);sa[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);sa[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);sa[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);sa[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);sa[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var z;for(l=0;l<6;l++){z=sa[l];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}}function n(l){for(var z=l.matrixWorld,p=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,
  209. l.scale.z)),m=0;m<6;m++){l=sa[m].x*z.n14+sa[m].y*z.n24+sa[m].z*z.n34+sa[m].w;if(l<=p)return!1}return!0}function q(l,z){l.list[l.count]=z;l.count+=1}function x(l){var z,p,m=l.object,o=l.opaque,B=l.transparent;B.count=0;l=o.count=0;for(z=m.materials.length;l<z;l++){p=m.materials[l];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?q(B,p):q(o,p)}}function u(l){var z,p,m,o,B=l.object,C=l.buffer,G=l.opaque,Q=l.transparent;Q.count=0;l=G.count=0;for(m=B.materials.length;l<m;l++){z=B.materials[l];
  210. if(z instanceof THREE.MeshFaceMaterial){z=0;for(p=C.materials.length;z<p;z++)(o=C.materials[z])&&(o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?q(Q,o):q(G,o))}else{o=z;o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?q(Q,o):q(G,o)}}}function t(l,z){return z.z-l.z}function y(l,z){l._modelViewMatrix.multiplyToArray(z.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function A(l){function z(ka){var ja=
  211. [];p=0;for(m=ka.length;p<m;p++)ka[p]==undefined?ja.push("undefined"):ja.push(ka[p].id);return ja.join("_")}var p,m,o,B,C,G,Q,H,O={};l.geometryGroups={};o=0;for(B=l.faces.length;o<B;o++){C=l.faces[o];G=C.materials;Q=z(G);O[Q]==undefined&&(O[Q]={hash:Q,counter:0});H=O[Q].hash+"_"+O[Q].counter;l.geometryGroups[H]==undefined&&(l.geometryGroups[H]={faces:[],materials:G,vertices:0});C=C instanceof THREE.Face3?3:4;if(l.geometryGroups[H].vertices+C>65535){O[Q].counter+=1;H=O[Q].hash+"_"+O[Q].counter;l.geometryGroups[H]==
  212. undefined&&(l.geometryGroups[H]={faces:[],materials:G,vertices:0})}l.geometryGroups[H].faces.push(o);l.geometryGroups[H].vertices+=C}}function E(l,z,p){l.push({buffer:z,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function v(l){if(l!=ba){switch(l){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,
  213. 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)}ba=l}}function F(l,z,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(l,f.TEXTURE_WRAP_S,Z(z.wrapS));f.texParameteri(l,f.TEXTURE_WRAP_T,Z(z.wrapT));f.texParameteri(l,f.TEXTURE_MAG_FILTER,Z(z.magFilter));f.texParameteri(l,f.TEXTURE_MIN_FILTER,Z(z.minFilter));f.generateMipmap(l)}else{f.texParameteri(l,
  214. f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(l,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(l,f.TEXTURE_MAG_FILTER,L(z.magFilter));f.texParameteri(l,f.TEXTURE_MIN_FILTER,L(z.minFilter))}}function w(l){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=f.createFramebuffer();l.__webGLRenderbuffer=f.createRenderbuffer();l.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,l.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,l.width,l.height);f.bindTexture(f.TEXTURE_2D,
  215. l.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,Z(l.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,Z(l.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,Z(l.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,Z(l.minFilter));f.texImage2D(f.TEXTURE_2D,0,Z(l.format),l.width,l.height,0,Z(l.format),Z(l.type),null);f.bindFramebuffer(f.FRAMEBUFFER,l.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,
  216. f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var z,p;if(l){z=l.__webGLFramebuffer;p=l.width;l=l.height}else{z=null;p=ha;l=fa}if(z!=T){f.bindFramebuffer(f.FRAMEBUFFER,z);f.viewport(da,ua,p,l);T=z}}function N(l,z){var p;if(l=="fragment")p=f.createShader(f.FRAGMENT_SHADER);else l=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,z);f.compileShader(p);if(!f.getShaderParameter(p,
  217. f.COMPILE_STATUS)){alert(f.getShaderInfoLog(p));return null}return p}function L(l){switch(l){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}function Z(l){switch(l){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;
  218. 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;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;
  219. 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}var M=document.createElement("canvas"),f,V=null,T=null,ca=this,ea=null,I=null,ba=null,wa=null,da=0,ua=0,ha=0,fa=0,sa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
  220. new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Matrix4,ga=new Float32Array(16),aa=new Float32Array(16),la=new THREE.Vector4,ma={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},R=!0,ia=new THREE.Color(0),pa=0;if(a){if(a.antialias!==undefined)R=a.antialias;a.clearColor!==undefined&&ia.setHex(a.clearColor);if(a.clearAlpha!==undefined)pa=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(l,z,p){try{if(!(f=
  221. M.getContext("experimental-webgl",{antialias:l})))throw"Error creating WebGL context.";}catch(m){console.error(m)}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);f.clearColor(z.r,z.g,z.b,p);_cullEnabled=!0})(R,ia,pa);this.context=f;this.setSize=function(l,z){M.width=l;M.height=z;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(l,
  222. z,p,m){da=l;ua=z;ha=p;fa=m;f.viewport(da,ua,ha,fa)};this.setScissor=function(l,z,p,m){f.scissor(l,z,p,m)};this.enableScissorTest=function(l){l?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(l){f.depthMask(l)};this.setClearColorHex=function(l,z){var p=new THREE.Color(l);f.clearColor(p.r,p.g,p.b,z)};this.setClearColor=function(l,z){f.clearColor(l.r,l.g,l.b,z)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,
  223. z,p,m){var o;if(l instanceof THREE.MeshDepthMaterial)b(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)b(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)b(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)b(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)b(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)b(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&b(l,THREE.ShaderLib.particle_basic);
  224. var B,C,G,Q,H;B=Q=H=0;for(C=z.length;B<C;B++){G=z[B];G instanceof THREE.DirectionalLight&&Q++;G instanceof THREE.PointLight&&H++}if(H+Q<=4)z=Q;else{z=Math.ceil(4*Q/(H+Q));H=4-z}z={directional:z,point:H};B=50;if(m!==undefined&&m instanceof THREE.SkinnedMesh)B=m.bones.length;m=l.fragmentShader;H=l.vertexShader;B={fog:p,map:l.map,envMap:l.envMap,lightMap:l.lightMap,vertexColors:l.vertexColors,skinning:l.skinning,maxDirLights:z.directional,maxPointLights:z.point,maxBones:B};p=f.createProgram();z=["#ifdef GL_ES\nprecision highp float;\n#endif",
  225. "#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+B.maxPointLights,B.fog?"#define USE_FOG":"",B.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",B.map?"#define USE_MAP":"",B.envMap?"#define USE_ENVMAP":"",B.lightMap?"#define USE_LIGHTMAP":"",B.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");B=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+B.maxDirLights,"#define MAX_POINT_LIGHTS "+
  226. B.maxPointLights,"#define MAX_BONES "+B.maxBones,B.map?"#define USE_MAP":"",B.envMap?"#define USE_ENVMAP":"",B.lightMap?"#define USE_LIGHTMAP":"",B.vertexColors?"#define USE_COLOR":"",B.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
  227. f.attachShader(p,N("fragment",z+m));f.attachShader(p,N("vertex",B+H));f.linkProgram(p);f.getProgramParameter(p,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};l.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(o in l.uniforms)p.push(o);o=l.program;m=0;for(H=p.length;m<
  228. H;m++){z=p[m];o.uniforms[z]=f.getUniformLocation(o,z)}o=l.program;p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];m=0;for(H=p.length;m<H;m++){z=p[m];o.attributes[z]=f.getAttribLocation(o,z)}o=l.program.attributes;f.enableVertexAttribArray(o.position);o.color>=0&&f.enableVertexAttribArray(o.color);o.normal>=0&&f.enableVertexAttribArray(o.normal);o.tangent>=0&&f.enableVertexAttribArray(o.tangent);if(l.skinning&&o.skinVertexA>=0&&o.skinVertexB>=
  229. 0&&o.skinIndex>=0&&o.skinWeight>=0){f.enableVertexAttribArray(o.skinVertexA);f.enableVertexAttribArray(o.skinVertexB);f.enableVertexAttribArray(o.skinIndex);f.enableVertexAttribArray(o.skinWeight)}};this.render=function(l,z,p,m){var o,B,C,G,Q,H,O,ka,ja=l.lights,qa=l.fog;z.matrixAutoUpdate&&z.update();z.matrixWorldInverse.flattenToArray(aa);z.projectionMatrix.flattenToArray(ga);xa.multiply(z.projectionMatrix,z.matrixWorldInverse);k(xa);l.update(undefined,!1,z);this.initWebGLObjects(l);w(p);(this.autoClear||
  230. m)&&this.clear();Q=l.__webglObjects.length;for(m=0;m<Q;m++){o=l.__webglObjects[m];O=o.object;if(O.visible)if(!(O instanceof THREE.Mesh)||n(O)){O.matrixWorld.flattenToArray(O._objectMatrixArray);y(O,z);u(o);o.render=!0;if(this.sortObjects){la.copy(O.position);xa.multiplyVector3(la);o.z=la.z}}else o.render=!1;else o.render=!1}this.sortObjects&&l.__webglObjects.sort(t);H=l.__webglObjectsImmediate.length;for(m=0;m<H;m++){o=l.__webglObjectsImmediate[m];O=o.object;if(O.visible){O.matrixAutoUpdate&&O.matrixWorld.flattenToArray(O._objectMatrixArray);
  231. y(O,z);x(o)}}v(THREE.NormalBlending);for(m=0;m<Q;m++){o=l.__webglObjects[m];if(o.render){O=o.object;ka=o.buffer;C=o.opaque;h(O);for(o=0;o<C.count;o++){G=C.list[o];j(G.depthTest);e(z,ja,qa,G,ka,O)}}}for(m=0;m<H;m++){o=l.__webglObjectsImmediate[m];O=o.object;if(O.visible){C=o.opaque;h(O);for(o=0;o<C.count;o++){G=C.list[o];j(G.depthTest);B=d(z,ja,qa,G,O);O.render(function(ra){g(ra,B)})}}}for(m=0;m<Q;m++){o=l.__webglObjects[m];if(o.render){O=o.object;ka=o.buffer;C=o.transparent;h(O);for(o=0;o<C.count;o++){G=
  232. C.list[o];v(G.blending);j(G.depthTest);e(z,ja,qa,G,ka,O)}}}for(m=0;m<H;m++){o=l.__webglObjectsImmediate[m];O=o.object;if(O.visible){C=o.transparent;h(O);for(o=0;o<C.count;o++){G=C.list[o];v(G.blending);j(G.depthTest);B=d(z,ja,qa,G,O);O.render(function(ra){g(ra,B)})}}}if(p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}};this.initWebGLObjects=function(l){if(!l.__webglObjects){l.__webglObjects=
  233. [];l.__webglObjectsImmediate=[]}for(;l.__objectsAdded.length;){var z=l.__objectsAdded[0],p=l,m=void 0,o=void 0,B=void 0;if(z._modelViewMatrix==undefined){z._modelViewMatrix=new THREE.Matrix4;z._normalMatrixArray=new Float32Array(9);z._modelViewMatrixArray=new Float32Array(16);z._objectMatrixArray=new Float32Array(16);z.matrixWorld.flattenToArray(z._objectMatrixArray)}if(z instanceof THREE.Mesh){o=z.geometry;o.geometryGroups==undefined&&A(o);for(m in o.geometryGroups){B=o.geometryGroups[m];if(!B.__webGLVertexBuffer){var C=
  234. B;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();C.__webGLFaceBuffer=f.createBuffer();C.__webGLLineBuffer=f.createBuffer();C=B;var G=z,Q=void 0,H=
  235. void 0,O=0,ka=0,ja=0,qa=G.geometry.faces,ra=C.faces;Q=0;for(H=ra.length;Q<H;Q++){fi=ra[Q];face=qa[fi];if(face instanceof THREE.Face3){O+=3;ka+=1;ja+=3}else if(face instanceof THREE.Face4){O+=4;ka+=2;ja+=4}}C.__vertexArray=new Float32Array(O*3);C.__normalArray=new Float32Array(O*3);C.__tangentArray=new Float32Array(O*4);C.__colorArray=new Float32Array(O*3);C.__uvArray=new Float32Array(O*2);C.__uv2Array=new Float32Array(O*2);C.__skinVertexAArray=new Float32Array(O*4);C.__skinVertexBArray=new Float32Array(O*
  236. 4);C.__skinIndexArray=new Float32Array(O*4);C.__skinWeightArray=new Float32Array(O*4);C.__faceArray=new Uint16Array(ka*3);C.__lineArray=new Uint16Array(ja*2);H=Q=C;O=void 0;qa=void 0;var na=void 0,oa=void 0;na=void 0;ra=!1;O=0;for(qa=G.materials.length;O<qa;O++){na=G.materials[O];if(na instanceof THREE.MeshFaceMaterial){na=0;for(oa=H.materials.length;na<oa;na++)if(H.materials[na]&&H.materials[na].shading!=undefined&&H.materials[na].shading==THREE.SmoothShading){ra=!0;break}}else if(na&&na.shading!=
  237. undefined&&na.shading==THREE.SmoothShading){ra=!0;break}if(ra)break}Q.__needsSmoothNormals=ra;C.__webGLFaceCount=ka*3;C.__webGLLineCount=ja*2;o.__dirtyVertices=!0;o.__dirtyElements=!0;o.__dirtyUvs=!0;o.__dirtyNormals=!0;o.__dirtyTangents=!0;o.__dirtyColors=!0}E(p.__webglObjects,B,z)}}else if(z instanceof THREE.Ribbon){o=z.geometry;if(!o.__webGLVertexBuffer){m=o;m.__webGLVertexBuffer=f.createBuffer();m.__webGLColorBuffer=f.createBuffer();m=o;B=m.vertices.length;m.__vertexArray=new Float32Array(B*3);
  238. m.__colorArray=new Float32Array(B*3);m.__webGLVertexCount=B;o.__dirtyVertices=!0;o.__dirtyColors=!0}E(p.__webglObjects,o,z)}else if(z instanceof THREE.Line){o=z.geometry;if(!o.__webGLVertexBuffer){m=o;m.__webGLVertexBuffer=f.createBuffer();m.__webGLColorBuffer=f.createBuffer();m=o;B=m.vertices.length;m.__vertexArray=new Float32Array(B*3);m.__colorArray=new Float32Array(B*3);m.__webGLLineCount=B;o.__dirtyVertices=!0;o.__dirtyColors=!0}E(p.__webglObjects,o,z)}else if(z instanceof THREE.ParticleSystem){o=
  239. z.geometry;if(!o.__webGLVertexBuffer){m=o;m.__webGLVertexBuffer=f.createBuffer();m.__webGLColorBuffer=f.createBuffer();m=o;B=m.vertices.length;m.__vertexArray=new Float32Array(B*3);m.__colorArray=new Float32Array(B*3);m.__sortArray=[];m.__webGLParticleCount=B;o.__dirtyVertices=!0;o.__dirtyColors=!0}E(p.__webglObjects,o,z)}else THREE.MarchingCubes!==undefined&&z instanceof THREE.MarchingCubes&&p.__webglObjectsImmediate.push({object:z,opaque:{list:[],count:0},transparent:{list:[],count:0}});l.__objectsAdded.splice(0,
  240. 1)}for(;l.__objectsRemoved.length;){z=l.__objectsRemoved[0];p=l;o=void 0;m=void 0;for(o=p.__webglObjects.length-1;o>=0;o--){m=p.__webglObjects[o].object;z==m&&p.__webglObjects.splice(o,1)}l.__objectsRemoved.splice(0,1)}z=0;for(p=l.__webglObjects.length;z<p;z++){m=l.__webglObjects[z].object;B=void 0;o=void 0;C=void 0;if(m instanceof THREE.Mesh){o=m.geometry;for(B in o.geometryGroups){C=o.geometryGroups[B];if(o.__dirtyVertices||o.__dirtyElements||o.__dirtyUvs||o.__dirtyNormals||o.__dirtyColors||o.__dirtyTangents){ka=
  241. f.DYNAMIC_DRAW;ja=void 0;Q=void 0;var Ia=void 0,P=void 0,Fa=void 0,Da=void 0,Ea=void 0;Ia=void 0;var W=void 0,X=void 0,$=void 0,za=void 0;W=void 0;X=void 0;$=void 0;P=void 0;W=void 0;X=void 0;$=void 0;za=void 0;W=void 0;X=void 0;$=void 0;za=void 0;W=void 0;X=void 0;$=void 0;za=void 0;W=void 0;X=void 0;$=void 0;za=void 0;W=void 0;X=void 0;$=void 0;za=void 0;P=void 0;Da=void 0;Fa=void 0;Ea=void 0;var Ga=oa=na=ra=qa=O=G=H=0,Ca=0,D=0,Ba=C.__vertexArray,Qa=C.__uvArray,Ta=C.__uv2Array,La=C.__normalArray,
  242. Aa=C.__tangentArray,J=C.__colorArray,Y=C.__skinVertexAArray,U=C.__skinVertexBArray,K=C.__skinIndexArray,S=C.__skinWeightArray,ta=C.__faceArray,va=C.__lineArray,Ha=C.__needsSmoothNormals,ya=m.geometry,Oa=ya.__dirtyVertices,Ja=ya.__dirtyElements,Ka=ya.__dirtyUvs,Sa=ya.__dirtyNormals,Ma=ya.__dirtyTangents,Pa=ya.__dirtyColors,Na=ya.vertices,Ya=C.faces,Za=ya.faces,$a=ya.uvs,ab=ya.uvs2,Ra=ya.colors,Va=ya.skinVerticesA,Wa=ya.skinVerticesB,Xa=ya.skinIndices,Ua=ya.skinWeights;ja=0;for(Q=Ya.length;ja<Q;ja++){Ia=
  243. Ya[ja];P=Za[Ia];Ea=$a[Ia];Ia=ab[Ia];Fa=P.vertexNormals;Da=P.normal;if(P instanceof THREE.Face3){if(Oa){W=Na[P.a].position;X=Na[P.b].position;$=Na[P.c].position;Ba[G]=W.x;Ba[G+1]=W.y;Ba[G+2]=W.z;Ba[G+3]=X.x;Ba[G+4]=X.y;Ba[G+5]=X.z;Ba[G+6]=$.x;Ba[G+7]=$.y;Ba[G+8]=$.z;G+=9}if(Ua.length){W=Ua[P.a];X=Ua[P.b];$=Ua[P.c];S[D]=W.x;S[D+1]=W.y;S[D+2]=W.z;S[D+3]=W.w;S[D+4]=X.x;S[D+5]=X.y;S[D+6]=X.z;S[D+7]=X.w;S[D+8]=$.x;S[D+9]=$.y;S[D+10]=$.z;S[D+11]=$.w;W=Xa[P.a];X=Xa[P.b];$=Xa[P.c];K[D]=W.x;K[D+1]=W.y;K[D+
  244. 2]=W.z;K[D+3]=W.w;K[D+4]=X.x;K[D+5]=X.y;K[D+6]=X.z;K[D+7]=X.w;K[D+8]=$.x;K[D+9]=$.y;K[D+10]=$.z;K[D+11]=$.w;W=Va[P.a];X=Va[P.b];$=Va[P.c];Y[D]=W.x;Y[D+1]=W.y;Y[D+2]=W.z;Y[D+3]=1;Y[D+4]=X.x;Y[D+5]=X.y;Y[D+6]=X.z;Y[D+7]=1;Y[D+8]=$.x;Y[D+9]=$.y;Y[D+10]=$.z;Y[D+11]=1;W=Wa[P.a];X=Wa[P.b];$=Wa[P.c];U[D]=W.x;U[D+1]=W.y;U[D+2]=W.z;U[D+3]=1;U[D+4]=X.x;U[D+5]=X.y;U[D+6]=X.z;U[D+7]=1;U[D+8]=$.x;U[D+9]=$.y;U[D+10]=$.z;U[D+11]=1;D+=12}if(Pa&&Ra.length){W=Ra[P.a];X=Ra[P.b];$=Ra[P.c];J[Ca]=W.r;J[Ca+1]=W.g;J[Ca+
  245. 2]=W.b;J[Ca+3]=X.r;J[Ca+4]=X.g;J[Ca+5]=X.b;J[Ca+6]=$.r;J[Ca+7]=$.g;J[Ca+8]=$.b;Ca+=9}if(Ma&&ya.hasTangents){W=Na[P.a].tangent;X=Na[P.b].tangent;$=Na[P.c].tangent;Aa[oa]=W.x;Aa[oa+1]=W.y;Aa[oa+2]=W.z;Aa[oa+3]=W.w;Aa[oa+4]=X.x;Aa[oa+5]=X.y;Aa[oa+6]=X.z;Aa[oa+7]=X.w;Aa[oa+8]=$.x;Aa[oa+9]=$.y;Aa[oa+10]=$.z;Aa[oa+11]=$.w;oa+=12}if(Sa)if(Fa.length==3&&Ha)for(P=0;P<3;P++){Da=Fa[P];La[na]=Da.x;La[na+1]=Da.y;La[na+2]=Da.z;na+=3}else for(P=0;P<3;P++){La[na]=Da.x;La[na+1]=Da.y;La[na+2]=Da.z;na+=3}if(Ka&&Ea)for(P=
  246. 0;P<3;P++){Fa=Ea[P];Qa[O]=Fa.u;Qa[O+1]=Fa.v;O+=2}if(Ka&&Ia)for(P=0;P<3;P++){Ea=Ia[P];Ta[qa]=Ea.u;Ta[qa+1]=Ea.v;qa+=2}if(Ja){ta[ra]=H;ta[ra+1]=H+1;ta[ra+2]=H+2;ra+=3;va[Ga]=H;va[Ga+1]=H+1;va[Ga+2]=H;va[Ga+3]=H+2;va[Ga+4]=H+1;va[Ga+5]=H+2;Ga+=6;H+=3}}else if(P instanceof THREE.Face4){if(Oa){W=Na[P.a].position;X=Na[P.b].position;$=Na[P.c].position;za=Na[P.d].position;Ba[G]=W.x;Ba[G+1]=W.y;Ba[G+2]=W.z;Ba[G+3]=X.x;Ba[G+4]=X.y;Ba[G+5]=X.z;Ba[G+6]=$.x;Ba[G+7]=$.y;Ba[G+8]=$.z;Ba[G+9]=za.x;Ba[G+10]=za.y;Ba[G+
  247. 11]=za.z;G+=12}if(Ua.length){W=Ua[P.a];X=Ua[P.b];$=Ua[P.c];za=Ua[P.d];S[D]=W.x;S[D+1]=W.y;S[D+2]=W.z;S[D+3]=W.w;S[D+4]=X.x;S[D+5]=X.y;S[D+6]=X.z;S[D+7]=X.w;S[D+8]=$.x;S[D+9]=$.y;S[D+10]=$.z;S[D+11]=$.w;S[D+12]=za.x;S[D+13]=za.y;S[D+14]=za.z;S[D+15]=za.w;W=Xa[P.a];X=Xa[P.b];$=Xa[P.c];za=Xa[P.d];K[D]=W.x;K[D+1]=W.y;K[D+2]=W.z;K[D+3]=W.w;K[D+4]=X.x;K[D+5]=X.y;K[D+6]=X.z;K[D+7]=X.w;K[D+8]=$.x;K[D+9]=$.y;K[D+10]=$.z;K[D+11]=$.w;K[D+12]=za.x;K[D+13]=za.y;K[D+14]=za.z;K[D+15]=za.w;W=Va[P.a];X=Va[P.b];$=
  248. Va[P.c];za=Va[P.d];Y[D]=W.x;Y[D+1]=W.y;Y[D+2]=W.z;Y[D+3]=1;Y[D+4]=X.x;Y[D+5]=X.y;Y[D+6]=X.z;Y[D+7]=1;Y[D+8]=$.x;Y[D+9]=$.y;Y[D+10]=$.z;Y[D+11]=1;Y[D+12]=za.x;Y[D+13]=za.y;Y[D+14]=za.z;Y[D+15]=1;W=Wa[P.a];X=Wa[P.b];$=Wa[P.c];za=Wa[P.d];U[D]=W.x;U[D+1]=W.y;U[D+2]=W.z;U[D+3]=1;U[D+4]=X.x;U[D+5]=X.y;U[D+6]=X.z;U[D+7]=1;U[D+8]=$.x;U[D+9]=$.y;U[D+10]=$.z;U[D+11]=1;U[D+12]=za.x;U[D+13]=za.y;U[D+14]=za.z;U[D+15]=1;D+=16}if(Pa&&Ra.length){W=Ra[P.a];X=Ra[P.b];$=Ra[P.c];za=Ra[P.d];J[Ca]=W.r;J[Ca+1]=W.g;J[Ca+
  249. 2]=W.b;J[Ca+3]=X.r;J[Ca+4]=X.g;J[Ca+5]=X.b;J[Ca+6]=$.r;J[Ca+7]=$.g;J[Ca+8]=$.b;J[Ca+9]=za.r;J[Ca+10]=za.g;J[Ca+11]=za.b;Ca+=12}if(Ma&&ya.hasTangents){W=Na[P.a].tangent;X=Na[P.b].tangent;$=Na[P.c].tangent;P=Na[P.d].tangent;Aa[oa]=W.x;Aa[oa+1]=W.y;Aa[oa+2]=W.z;Aa[oa+3]=W.w;Aa[oa+4]=X.x;Aa[oa+5]=X.y;Aa[oa+6]=X.z;Aa[oa+7]=X.w;Aa[oa+8]=$.x;Aa[oa+9]=$.y;Aa[oa+10]=$.z;Aa[oa+11]=$.w;Aa[oa+12]=P.x;Aa[oa+13]=P.y;Aa[oa+14]=P.z;Aa[oa+15]=P.w;oa+=16}if(Sa)if(Fa.length==4&&Ha)for(P=0;P<4;P++){Da=Fa[P];La[na]=Da.x;
  250. La[na+1]=Da.y;La[na+2]=Da.z;na+=3}else for(P=0;P<4;P++){La[na]=Da.x;La[na+1]=Da.y;La[na+2]=Da.z;na+=3}if(Ka&&Ea)for(P=0;P<4;P++){Fa=Ea[P];Qa[O]=Fa.u;Qa[O+1]=Fa.v;O+=2}if(Ka&&Ia)for(P=0;P<4;P++){Ea=Ia[P];Ta[qa]=Ea.u;Ta[qa+1]=Ea.v;qa+=2}if(Ja){ta[ra]=H;ta[ra+1]=H+1;ta[ra+2]=H+2;ta[ra+3]=H;ta[ra+4]=H+2;ta[ra+5]=H+3;ra+=6;va[Ga]=H;va[Ga+1]=H+1;va[Ga+2]=H;va[Ga+3]=H+3;va[Ga+4]=H+1;va[Ga+5]=H+2;va[Ga+6]=H+2;va[Ga+7]=H+3;Ga+=8;H+=4}}}if(Oa){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,
  251. Ba,ka)}if(Pa&&Ra.length){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,J,ka)}if(Sa){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,La,ka)}if(Ma&&ya.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Aa,ka)}if(Ka&&O>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,ka)}if(Ka&&qa>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Ta,ka)}if(Ja){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,
  252. C.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,ta,ka);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,va,ka)}if(D>0){f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,Y,ka);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,U,ka);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,K,ka);f.bindBuffer(f.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,
  253. S,ka)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(m instanceof THREE.Ribbon){o=m.geometry;if(o.__dirtyVertices||o.__dirtyColors){m=o;B=f.DYNAMIC_DRAW;H=void 0;H=void 0;G=void 0;C=void 0;O=m.vertices;ka=m.colors;qa=O.length;ja=ka.length;ra=m.__vertexArray;Q=m.__colorArray;na=m.__dirtyColors;if(m.__dirtyVertices){for(H=0;H<qa;H++){G=O[H].position;C=H*3;ra[C]=G.x;ra[C+1]=G.y;ra[C+2]=G.z}f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);
  254. f.bufferData(f.ARRAY_BUFFER,ra,B)}if(na){for(H=0;H<ja;H++){color=ka[H];C=H*3;Q[C]=color.r;Q[C+1]=color.g;Q[C+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,m.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Q,B)}}o.__dirtyVertices=!1;o.__dirtyColors=!1}else if(m instanceof THREE.Line){o=m.geometry;if(o.__dirtyVertices||o.__dirtyColors){m=o;B=f.DYNAMIC_DRAW;H=void 0;H=void 0;G=void 0;C=void 0;O=m.vertices;ka=m.colors;qa=O.length;ja=ka.length;ra=m.__vertexArray;Q=m.__colorArray;na=m.__dirtyColors;if(m.__dirtyVertices){for(H=
  255. 0;H<qa;H++){G=O[H].position;C=H*3;ra[C]=G.x;ra[C+1]=G.y;ra[C+2]=G.z}f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ra,B)}if(na){for(H=0;H<ja;H++){color=ka[H];C=H*3;Q[C]=color.r;Q[C+1]=color.g;Q[C+2]=color.b}f.bindBuffer(f.ARRAY_BUFFER,m.__webGLColorBuffer);f.bufferData(f.ARRAY_BUFFER,Q,B)}}o.__dirtyVertices=!1;o.__dirtyColors=!1}else if(m instanceof THREE.ParticleSystem){o=m.geometry;(o.__dirtyVertices||o.__dirtyColors||m.sortParticles)&&c(o,f.DYNAMIC_DRAW,m);o.__dirtyVertices=
  256. !1;o.__dirtyColors=!1}}};this.setFaceCulling=function(l,z){if(l){!z||z=="ccw"?f.frontFace(f.CCW):f.frontFace(f.CW);if(l=="back")f.cullFace(f.BACK);else l=="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}};
  257. THREE.Snippets={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",
  258. 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",
  259. 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",
  260. 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",
  261. 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",
  262. 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}",
  263. 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;",
  264. 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#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
  265. 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)}},lights:{enableLighting:{type:"i",
  266. 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},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  267. 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",
  268. 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.Snippets.color_pars_fragment,
  269. THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex,
  270. THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,
  271. THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,
  272. THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,
  273. 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;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,
  274. THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,
  275. THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.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;",
  276. THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;",
  277. THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};
  278. 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)}}}};
  279. THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};
  280. 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.Vertex;this.v2=new THREE.Vertex;this.materials=null};
  281. 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,n=a.uvs;e=e.uvs;b&&c.matrixAutoUpdate&&c.updateMatrix();for(var q=0,x=h.length;q<x;q++){var u=new THREE.Vertex(h[q].position.clone());b&&c.matrix.multiplyVector3(u.position);g.push(u)}q=0;for(x=k.length;q<x;q++){h=k[q];var t,y=h.vertexNormals;if(h instanceof THREE.Face3)t=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(t=new THREE.Face4(h.a+
  282. d,h.b+d,h.c+d,h.d+d));t.centroid.copy(h.centroid);t.normal.copy(h.normal);b=0;for(g=y.length;b<g;b++){u=y[b];t.vertexNormals.push(u.clone())}t.materials=h.materials.slice();j.push(t)}q=0;for(x=e.length;q<x;q++){d=e[q];j=[];b=0;for(g=d.length;b<g;b++)j.push(new THREE.UV(d[b].u,d[b].v));n.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,c,b){var d,e=[],g=new THREE.Texture(e,
  283. 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(q in M.objects)if(!I.objects[q]){A=M.objects[q];if(w=I.geometries[A.geometry]){Z=[];for(i=0;i<A.materials.length;i++)Z[i]=I.materials[A.materials[i]];E=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(w,Z);object.position.set(E[0],
  284. E[1],E[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;I.scene.addObject(object);I.objects[q]=object}}}function h(ba){return function(wa){I.geometries[ba]=wa;g();V-=1;j()}}function j(){d({total_models:ca,total_textures:ea,loaded_models:ca-V,loaded_textures:ea-T},I);V==0&&T==0&&b(I)}var k,n,q,x,u,t,y,A,E,v,F,w,N,L,Z,M,f,V,T,ca,ea,I;M=e.data;f=new THREE.Loader;T=V=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},
  285. lights:{},fogs:{}};e=function(){T-=1;j()};for(u in M.cameras){v=M.cameras[u];if(v.type=="perspective")N=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){N=new THREE.Camera;N.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}E=v.position;v=v.target;N.position.set(E[0],E[1],E[2]);N.target.position.set(v[0],v[1],v[2]);I.cameras[u]=N}for(x in M.lights){u=M.lights[x];if(u.type=="directional"){E=u.direction;light=new THREE.DirectionalLight;light.position.set(E[0],
  286. E[1],E[2]);light.position.normalize()}else if(u.type=="point"){E=u.position;light=new THREE.PointLight;light.position.set(E[0],E[1],E[2])}v=u.color;i=u.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);I.scene.addLight(light);I.lights[x]=light}for(t in M.fogs){x=M.fogs[t];if(x.type=="linear")L=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(L=new THREE.FogExp2(0,x.density));v=x.color;L.color.setRGB(v[0],v[1],v[2]);I.fogs[t]=L}if(I.cameras&&M.defaults.camera)I.currentCamera=I.cameras[M.defaults.camera];
  287. if(I.fogs&&M.defaults.fog)I.scene.fog=I.fogs[M.defaults.fog];v=M.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(v[0],v[1],v[2]);I.bgColorAlpha=M.defaults.bgalpha;for(k in M.geometries){t=M.geometries[k];if(t.type=="bin_mesh"||t.type=="ascii_mesh")V+=1}ca=V;for(k in M.geometries){t=M.geometries[k];if(t.type=="cube"){w=new Cube(t.width,t.height,t.depth,t.segmentsWidth,t.segmentsHeight,t.segmentsDepth,null,t.flipped,t.sides);I.geometries[k]=w}else if(t.type=="plane"){w=new Plane(t.width,
  288. t.height,t.segmentsWidth,t.segmentsHeight);I.geometries[k]=w}else if(t.type=="sphere"){w=new Sphere(t.radius,t.segmentsWidth,t.segmentsHeight);I.geometries[k]=w}else if(t.type=="cylinder"){w=new Cylinder(t.numSegs,t.topRad,t.botRad,t.height,t.topOffset,t.botOffset);I.geometries[k]=w}else if(t.type=="torus"){w=new Torus(t.radius,t.tube,t.segmentsR,t.segmentsT);I.geometries[k]=w}else if(t.type=="icosahedron"){w=new Icosahedron(t.subdivisions);I.geometries[k]=w}else if(t.type=="bin_mesh")f.loadBinary({model:t.url,
  289. callback:h(k)});else t.type=="ascii_mesh"&&f.loadAscii({model:t.url,callback:h(k)})}for(y in M.textures){k=M.textures[y];T+=k.url instanceof Array?k.url.length:1}ea=T;for(y in M.textures){k=M.textures[y];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array)t=ImageUtils.loadTextureCube(k.url,k.mapping,e);else{t=ImageUtils.loadTexture(k.url,k.mapping,e);if(THREE[k.minFilter]!=undefined)t.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)t.magFilter=
  290. THREE[k.magFilter]}I.textures[y]=t}for(n in M.materials){y=M.materials[n];for(F in y.parameters)if(F=="envMap"||F=="map"||F=="lightMap")y.parameters[F]=I.textures[y.parameters[F]];else if(F=="shading")y.parameters[F]=y.parameters[F]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(F=="blending")y.parameters[F]=THREE[y.parameters[F]]?THREE[y.parameters[F]]:THREE.NormalBlending;else F=="combine"&&(y.parameters[F]=y.parameters[F]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);y=new THREE[y.type](y.parameters);
  291. I.materials[n]=y}g();c(I)}},addMesh:function(a,c,b,d,e,g,h,j,k,n){c=new THREE.Mesh(c,n);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,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);
  292. 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])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);
  293. 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,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
  294. SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
  295. 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}"},
  296. 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},
  297. 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}",
  298. 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}"},
  299. 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",
  300. 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}"},
  301. 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}"},
  302. 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}",
  303. 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}},Cube=function(a,c,b,d,e,g,h,j,k){function n(E,v,F,w,N,L,Z,M){var f,V,T=d||1,ca=e||1,ea=N/2,I=L/2,ba=q.vertices.length;if(E=="x"&&v=="y"||E=="y"&&v=="x")f="z";else if(E=="x"&&v=="z"||E=="z"&&v=="x"){f="y";ca=g||1}else if(E=="z"&&
  304. v=="y"||E=="y"&&v=="z"){f="x";T=g||1}var wa=T+1,da=ca+1;N/=T;var ua=L/ca;for(V=0;V<da;V++)for(L=0;L<wa;L++){var ha=new THREE.Vector3;ha[E]=(L*N-ea)*F;ha[v]=(V*ua-I)*w;ha[f]=Z;q.vertices.push(new THREE.Vertex(ha))}for(V=0;V<ca;V++)for(L=0;L<T;L++){q.faces.push(new THREE.Face4(L+wa*V+ba,L+wa*(V+1)+ba,L+1+wa*(V+1)+ba,L+1+wa*V+ba,null,M));q.uvs.push([new THREE.UV(L/T,V/ca),new THREE.UV(L/T,(V+1)/ca),new THREE.UV((L+1)/T,(V+1)/ca),new THREE.UV((L+1)/T,V/ca)])}}THREE.Geometry.call(this);var q=this,x=a/
  305. 2,u=c/2,t=b/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var y=0;y<6;y++)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 A in k)this.sides[A]!=undefined&&(this.sides[A]=k[A]);this.sides.px&&n("z","y",1*j,-1,b,c,-x,this.materials[0]);this.sides.nx&&n("z","y",-1*j,-1,b,c,x,this.materials[1]);this.sides.py&&n("x","z",1*j,1,a,b,u,this.materials[2]);this.sides.ny&&n("x","z",1*j,-1,
  306. a,b,-u,this.materials[3]);this.sides.pz&&n("x","y",1*j,-1,a,c,t,this.materials[4]);this.sides.nz&&n("x","y",-1*j,-1,a,c,-t,this.materials[5]);(function(){for(var E=[],v=[],F=0,w=q.vertices.length;F<w;F++){for(var N=q.vertices[F],L=!1,Z=0,M=E.length;Z<M;Z++){var f=E[Z];if(N.position.x==f.position.x&&N.position.y==f.position.y&&N.position.z==f.position.z){v[F]=Z;L=!0;break}}if(!L){v[F]=E.length;E.push(new THREE.Vertex(N.position.clone()))}}F=0;for(w=q.faces.length;F<w;F++){N=q.faces[F];N.a=v[N.a];N.b=
  307. v[N.b];N.c=v[N.c];N.d=v[N.d]}q.vertices=E})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  308. var Cylinder=function(a,c,b,d,e){function g(n,q,x){h.vertices.push(new THREE.Vertex(new THREE.Vector3(n,q,x)))}THREE.Geometry.call(this);var h=this,j=Math.PI,k;for(k=0;k<a;k++)g(Math.sin(2*j*k/a)*c,Math.cos(2*j*k/a)*c,0);for(k=0;k<a;k++)g(Math.sin(2*j*k/a)*b,Math.cos(2*j*k/a)*b,d);for(k=0;k<a;k++)h.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(b!=0){g(0,0,-e);for(k=a;k<a+a/2;k++)h.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(c!=0){g(0,0,d+e);for(k=a+a/2;k<
  309. 2*a;k++)h.faces.push(new THREE.Face4((2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  310. 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 n=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*n-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.uvs.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()};
  311. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  312. 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),n=[],q=0;for(d=0;d<g;d++){var x=2*d/g,u=k*Math.sin(x*e);x=k*Math.cos(x*e);(b==0||b==h)&&d>0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,u)))-1);n.push(q)}c.push(n)}var t,y,A;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){n=d==g-1;h=c[b][n?0:d+1];j=c[b][n?g-1:d];k=c[b-1][n?g-1:d];n=c[b-1][n?
  313. 0:d+1];u=b/(e-1);t=(b-1)/(e-1);y=(d+1)/g;x=d/g;q=new THREE.UV(1-y,u);u=new THREE.UV(1-x,u);x=new THREE.UV(1-x,t);var E=new THREE.UV(1-y,t);if(b<c.length-1){t=this.vertices[h].position.clone();y=this.vertices[j].position.clone();A=this.vertices[k].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,u,x])}if(b>1){t=this.vertices[h].position.clone();
  314. y=this.vertices[k].position.clone();A=this.vertices[n].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,n,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,x,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  315. 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=
  316. 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.uvs.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;
  317. var Icosahedron=function(a){function c(x,u,t){var y=Math.sqrt(x*x+u*u+t*t);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/y,u/y,t/y)))-1}function b(x,u,t,y){y.faces.push(new THREE.Face3(x,u,t))}function d(x,u){var t=e.vertices[x].position,y=e.vertices[u].position;return c((t.x+y.x)/2,(t.y+y.y)/2,(t.z+y.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,
  318. 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),n=d(g.faces[j].b,g.faces[j].c),q=d(g.faces[j].c,g.faces[j].a);b(g.faces[j].a,k,q,h);b(g.faces[j].b,n,k,h);b(g.faces[j].c,
  319. q,n,h);b(k,n,q,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;
  320. function LathedObject(a,c,b){THREE.Geometry.call(this);this.nsteps=c||12;this.latheAngle=b||2*Math.PI;c=this.latheAngle/this.nsteps;for(var d=[],e=[],g=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));e[j]=this.vertices.length-1;d[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var k=THREE.Matrix4.rotationZMatrix(this.stepSize),n=0;n<=this.latheAngle+0.0010;n+=this.stepSize){for(j=0;j<d.length;j++)if(n<b){d[j]=k.multiplyVector3(d[j].clone());this.vertices.push(new THREE.Vertex(d[j]));
  321. g[j]=this.vertices.length-1}else g=h;n==0&&(h=e);for(j=0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.uvs.push([new THREE.UV(n/b,j/a.length),new THREE.UV(n/b,(j+1)/a.length),new THREE.UV((n-c)/b,(j+1)/a.length),new THREE.UV((n-c)/b,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
  322. if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  323. 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=
  324. 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,n,q,x){h=(h-q)/(x-q);q=this.normal_cache;d[g]=j+h*this.delta;d[g+1]=k;d[g+2]=n;e[g]=this.lerp(q[b],q[b+3],h);e[g+1]=this.lerp(q[b+1],q[b+4],h);e[g+2]=this.lerp(q[b+2],q[b+5],h)};this.VIntY=function(b,d,e,g,h,j,k,n,q,x){h=(h-q)/(x-q);q=this.normal_cache;d[g]=j;d[g+1]=k+h*this.delta;d[g+
  325. 2]=n;d=b+this.yd*3;e[g]=this.lerp(q[b],q[d],h);e[g+1]=this.lerp(q[b+1],q[d+1],h);e[g+2]=this.lerp(q[b+2],q[d+2],h)};this.VIntZ=function(b,d,e,g,h,j,k,n,q,x){h=(h-q)/(x-q);q=this.normal_cache;d[g]=j;d[g+1]=k;d[g+2]=n+h*this.delta;d=b+this.zd*3;e[g]=this.lerp(q[b],q[d],h);e[g+1]=this.lerp(q[b+1],q[d+1],h);e[g+2]=this.lerp(q[b+2],q[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]-
  326. 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,n=g+this.yd,q=g+this.zd,x=k+this.yd,u=k+this.zd,t=g+this.yd+this.zd,y=k+this.yd+this.zd,A=0,E=this.field[g],v=this.field[k],F=this.field[n],w=this.field[x],N=this.field[q],L=this.field[u],Z=this.field[t],M=this.field[y];E<h&&(A|=1);v<h&&(A|=2);F<h&&(A|=8);w<h&&(A|=4);N<h&&(A|=16);L<h&&(A|=32);Z<h&&(A|=128);M<h&&(A|=64);var f=THREE.edgeTable[A];if(f==0)return 0;
  327. var V=this.delta,T=b+V,ca=d+V;V=e+V;if(f&1){this.compNorm(g);this.compNorm(k);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,E,v)}if(f&2){this.compNorm(k);this.compNorm(x);this.VIntY(k*3,this.vlist,this.nlist,3,h,T,d,e,v,w)}if(f&4){this.compNorm(n);this.compNorm(x);this.VIntX(n*3,this.vlist,this.nlist,6,h,b,ca,e,F,w)}if(f&8){this.compNorm(g);this.compNorm(n);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,E,F)}if(f&16){this.compNorm(q);this.compNorm(u);this.VIntX(q*3,this.vlist,this.nlist,12,h,b,d,
  328. V,N,L)}if(f&32){this.compNorm(u);this.compNorm(y);this.VIntY(u*3,this.vlist,this.nlist,15,h,T,d,V,L,M)}if(f&64){this.compNorm(t);this.compNorm(y);this.VIntX(t*3,this.vlist,this.nlist,18,h,b,ca,V,Z,M)}if(f&128){this.compNorm(q);this.compNorm(t);this.VIntY(q*3,this.vlist,this.nlist,21,h,b,d,V,N,Z)}if(f&256){this.compNorm(g);this.compNorm(q);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,E,N)}if(f&512){this.compNorm(k);this.compNorm(u);this.VIntZ(k*3,this.vlist,this.nlist,27,h,T,d,e,v,L)}if(f&1024){this.compNorm(x);
  329. this.compNorm(y);this.VIntZ(x*3,this.vlist,this.nlist,30,h,T,ca,e,w,M)}if(f&2048){this.compNorm(n);this.compNorm(t);this.VIntZ(n*3,this.vlist,this.nlist,33,h,b,ca,e,F,Z)}A<<=4;for(h=g=0;THREE.triTable[A+h]!=-1;){b=A+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+2]=b[e+2];this.positionArray[k+
  330. 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>=this.maxCount-3&&j(this)};this.begin=
  331. 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,n=d*this.size,q=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 u=Math.floor(n-j);u<1&&(u=1);n=Math.floor(n+j);n>this.size-1&&(n=this.size-1);var t=Math.floor(q-j);t<1&&(t=1);j=Math.floor(q+j);
  332. j>this.size-1&&(j=this.size-1);for(var y,A,E,v,F,w;x<k;x++){q=this.size2*x;A=x/this.size-e;F=A*A;for(A=u;A<n;A++){E=q+this.size*A;y=A/this.size-d;w=y*y;for(y=t;y<j;y++){v=y/this.size-b;v=g/(1.0E-6+v*v+w+F)-h;v>0&&(this.field[E+y]+=v)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,n=this.size,q=this.yd,x=this.zd,u=this.field,t=n*Math.sqrt(b/d);t>n&&(t=n);for(e=0;e<t;e++){g=e/n;g*=g;j=b/(1.0E-4+g)-d;if(j>0)for(g=0;g<n;g++){k=e+g*q;for(h=0;h<n;h++)u[x*h+k]+=j}}};this.addPlaneY=function(b,d){var e,g,
  333. h,j,k,n,q=this.size,x=this.yd,u=this.zd,t=this.field,y=q*Math.sqrt(b/d);y>q&&(y=q);for(g=0;g<y;g++){e=g/q;e*=e;j=b/(1.0E-4+e)-d;if(j>0){k=g*x;for(e=0;e<q;e++){n=k+e;for(h=0;h<q;h++)t[u*h+n]+=j}}}};this.addPlaneZ=function(b,d){var e,g,h,j,k,n;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++){n=k+g*yd;for(e=0;e<size;e++)field[n+e]+=j}}}};this.reset=function(){var b;
  334. 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,n,q,x,u=this.size-2;for(h=1;h<u;h++){x=this.size2*h;n=(h-this.halfsize)/this.halfsize;for(g=1;g<u;g++){q=x+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<u;e++){j=(e-this.halfsize)/this.halfsize;d=q+e;this.polygonize(j,k,n,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,k,n,q,x,u;for(g=
  335. 0;g<e.count;g++){n=g*3;x=n+1;u=n+2;h=e.positionArray[n];j=e.positionArray[x];k=e.positionArray[u];q=new THREE.Vector3(h,j,k);h=e.normalArray[n];j=e.normalArray[x];k=e.normalArray[u];n=new THREE.Vector3(h,j,k);n.normalize();n=new THREE.Vertex(q,n);d.vertices.push(n)}nfaces=e.count/3;for(g=0;g<nfaces;g++){n=(b+g)*3;x=n+1;u=n+2;q=d.vertices[n].normal;h=d.vertices[x].normal;j=d.vertices[u].normal;n=new THREE.Face3(n,x,u,[q,h,j]);d.faces.push(n)}b+=nfaces;e.count=0});return d};this.init(a)};
  336. THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  337. 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,
  338. 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,
  339. 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]);
  340. 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,
  341. -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,
  342. -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,
  343. -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,
  344. 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,
  345. -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,
  346. 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,
  347. -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,
  348. 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,
  349. 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,
  350. 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,
  351. 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,
  352. -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,
  353. -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,
  354. -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,
  355. 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,
  356. -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,
  357. 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,
  358. 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,
  359. -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,
  360. 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
  361. 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=
  362. c},loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii: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.Loader.prototype.createModel(e.data,b,d)};c.postMessage(a)},loadBinary:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:
  363. 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.Loader.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()};c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,e,g){var h=new XMLHttpRequest,j=d+"/"+a,k=0;
  364. h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.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");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
  365. createBinModel:function(a,c,b,d){var e=function(g){function h(p,m){var o=q(p,m),B=q(p,m+1),C=q(p,m+2),G=q(p,m+3),Q=(G<<1&255|C>>7)-127;o|=(C&127)<<16|B<<8;if(o==0&&Q==-127)return 0;return(1-2*(G>>7))*(1+o*Math.pow(2,-23))*Math.pow(2,Q)}function j(p,m){var o=q(p,m),B=q(p,m+1),C=q(p,m+2);return(q(p,m+3)<<24)+(C<<16)+(B<<8)+o}function k(p,m){var o=q(p,m);return(q(p,m+1)<<8)+o}function n(p,m){var o=q(p,m);return o>127?o-256:o}function q(p,m){return p.charCodeAt(m)&255}function x(p){var m,o,B;m=j(a,p);
  366. o=j(a,p+Z);B=j(a,p+M);p=k(a,p+f);THREE.Loader.prototype.f3(v,m,o,B,p)}function u(p){var m,o,B,C,G,Q;m=j(a,p);o=j(a,p+Z);B=j(a,p+M);C=k(a,p+f);G=j(a,p+V);Q=j(a,p+T);p=j(a,p+ca);THREE.Loader.prototype.f3n(v,N,m,o,B,C,G,Q,p)}function t(p){var m,o,B,C;m=j(a,p);o=j(a,p+ea);B=j(a,p+I);C=j(a,p+ba);p=k(a,p+wa);THREE.Loader.prototype.f4(v,m,o,B,C,p)}function y(p){var m,o,B,C,G,Q,H,O;m=j(a,p);o=j(a,p+ea);B=j(a,p+I);C=j(a,p+ba);G=k(a,p+wa);Q=j(a,p+da);H=j(a,p+ua);O=j(a,p+ha);p=j(a,p+fa);THREE.Loader.prototype.f4n(v,
  367. N,m,o,B,C,G,Q,H,O,p)}function A(p){var m,o;m=j(a,p);o=j(a,p+sa);p=j(a,p+xa);THREE.Loader.prototype.uv3(v.uvs,L[m*2],L[m*2+1],L[o*2],L[o*2+1],L[p*2],L[p*2+1])}function E(p){var m,o,B;m=j(a,p);o=j(a,p+ga);B=j(a,p+aa);p=j(a,p+la);THREE.Loader.prototype.uv4(v.uvs,L[m*2],L[m*2+1],L[o*2],L[o*2+1],L[B*2],L[B*2+1],L[p*2],L[p*2+1])}var v=this,F=0,w,N=[],L=[],Z,M,f,V,T,ca,ea,I,ba,wa,da,ua,ha,fa,sa,xa,ga,aa,la,ma,R,ia,pa,l,z;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);w={signature:a.substr(F,
  368. 8),header_bytes:q(a,F+8),vertex_coordinate_bytes:q(a,F+9),normal_coordinate_bytes:q(a,F+10),uv_coordinate_bytes:q(a,F+11),vertex_index_bytes:q(a,F+12),normal_index_bytes:q(a,F+13),uv_index_bytes:q(a,F+14),material_index_bytes:q(a,F+15),nvertices:j(a,F+16),nnormals:j(a,F+16+4),nuvs:j(a,F+16+8),ntri_flat:j(a,F+16+12),ntri_smooth:j(a,F+16+16),ntri_flat_uv:j(a,F+16+20),ntri_smooth_uv:j(a,F+16+24),nquad_flat:j(a,F+16+28),nquad_smooth:j(a,F+16+32),nquad_flat_uv:j(a,F+16+36),nquad_smooth_uv:j(a,F+16+40)};
  369. F+=w.header_bytes;Z=w.vertex_index_bytes;M=w.vertex_index_bytes*2;f=w.vertex_index_bytes*3;V=w.vertex_index_bytes*3+w.material_index_bytes;T=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;ca=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;ea=w.vertex_index_bytes;I=w.vertex_index_bytes*2;ba=w.vertex_index_bytes*3;wa=w.vertex_index_bytes*4;da=w.vertex_index_bytes*4+w.material_index_bytes;ua=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;ha=
  370. w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;fa=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;sa=w.uv_index_bytes;xa=w.uv_index_bytes*2;ga=w.uv_index_bytes;aa=w.uv_index_bytes*2;la=w.uv_index_bytes*3;g=w.vertex_index_bytes*3+w.material_index_bytes;z=w.vertex_index_bytes*4+w.material_index_bytes;ma=w.ntri_flat*g;R=w.ntri_smooth*(g+w.normal_index_bytes*3);ia=w.ntri_flat_uv*(g+w.uv_index_bytes*3);pa=w.ntri_smooth_uv*(g+w.normal_index_bytes*3+w.uv_index_bytes*
  371. 3);l=w.nquad_flat*z;g=w.nquad_smooth*(z+w.normal_index_bytes*4);z=w.nquad_flat_uv*(z+w.uv_index_bytes*4);F+=function(p){for(var m,o,B,C=w.vertex_coordinate_bytes*3,G=p+w.nvertices*C;p<G;p+=C){m=h(a,p);o=h(a,p+w.vertex_coordinate_bytes);B=h(a,p+w.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,m,o,B)}return w.nvertices*C}(F);F+=function(p){for(var m,o,B,C=w.normal_coordinate_bytes*3,G=p+w.nnormals*C;p<G;p+=C){m=n(a,p);o=n(a,p+w.normal_coordinate_bytes);B=n(a,p+w.normal_coordinate_bytes*2);N.push(m/
  372. 127,o/127,B/127)}return w.nnormals*C}(F);F+=function(p){for(var m,o,B=w.uv_coordinate_bytes*2,C=p+w.nuvs*B;p<C;p+=B){m=h(a,p);o=h(a,p+w.uv_coordinate_bytes);L.push(m,o)}return w.nuvs*B}(F);ma=F+ma;R=ma+R;ia=R+ia;pa=ia+pa;l=pa+l;g=l+g;z=g+z;(function(p){var m,o=w.vertex_index_bytes*3+w.material_index_bytes,B=o+w.uv_index_bytes*3,C=p+w.ntri_flat_uv*B;for(m=p;m<C;m+=B){x(m);A(m+o)}return C-p})(R);(function(p){var m,o=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*3,B=o+w.uv_index_bytes*
  373. 3,C=p+w.ntri_smooth_uv*B;for(m=p;m<C;m+=B){u(m);A(m+o)}return C-p})(ia);(function(p){var m,o=w.vertex_index_bytes*4+w.material_index_bytes,B=o+w.uv_index_bytes*4,C=p+w.nquad_flat_uv*B;for(m=p;m<C;m+=B){t(m);E(m+o)}return C-p})(g);(function(p){var m,o=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*4,B=o+w.uv_index_bytes*4,C=p+w.nquad_smooth_uv*B;for(m=p;m<C;m+=B){y(m);E(m+o)}return C-p})(z);(function(p){var m,o=w.vertex_index_bytes*3+w.material_index_bytes,B=p+w.ntri_flat*o;for(m=
  374. p;m<B;m+=o)x(m);return B-p})(F);(function(p){var m,o=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*3,B=p+w.ntri_smooth*o;for(m=p;m<B;m+=o)u(m);return B-p})(ma);(function(p){var m,o=w.vertex_index_bytes*4+w.material_index_bytes,B=p+w.nquad_flat*o;for(m=p;m<B;m+=o)t(m);return B-p})(pa);(function(p){var m,o=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*4,B=p+w.nquad_smooth*o;for(m=p;m<B;m+=o)y(m);return B-p})(l);this.computeCentroids();this.computeFaceNormals()};
  375. e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(b))},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(){var h,j,k,n,q;h=0;for(j=a.vertices.length;h<j;h+=3){k=a.vertices[h];n=a.vertices[h+1];q=a.vertices[h+2];THREE.Loader.prototype.v(g,k,n,q)}if(a.colors){h=0;for(j=a.colors.length;h<j;h+=3){k=a.colors[h];n=a.colors[h+1];q=a.colors[h+2];THREE.Loader.prototype.vc(g,k,n,q)}}})();(function(){function h(y,
  376. A){THREE.Loader.prototype.f3(g,y[A],y[A+1],y[A+2],y[A+3])}function j(y,A){THREE.Loader.prototype.f3n(g,a.normals,y[A],y[A+1],y[A+2],y[A+3],y[A+4],y[A+5],y[A+6])}function k(y,A){THREE.Loader.prototype.f4(g,y[A],y[A+1],y[A+2],y[A+3],y[A+4])}function n(y,A){THREE.Loader.prototype.f4n(g,a.normals,y[A],y[A+1],y[A+2],y[A+3],y[A+4],y[A+5],y[A+6],y[A+7],y[A+8])}function q(y,A){var E,v,F,w,N,L,Z,M,f;E=y[A];v=y[A+1];F=y[A+2];w=a.uvs[E*2];Z=a.uvs[E*2+1];N=a.uvs[v*2];M=a.uvs[v*2+1];L=a.uvs[F*2];f=a.uvs[F*2+1];
  377. THREE.Loader.prototype.uv3(g.uvs,w,Z,N,M,L,f);if(a.uvs2&&a.uvs2.length){w=a.uvs2[E*2];Z=a.uvs2[E*2+1];N=a.uvs2[v*2];M=a.uvs2[v*2+1];L=a.uvs2[F*2];f=a.uvs2[F*2+1];THREE.Loader.prototype.uv3(g.uvs2,w,1-Z,N,1-M,L,1-f)}}function x(y,A){var E,v,F,w,N,L,Z,M,f,V,T,ca;E=y[A];v=y[A+1];F=y[A+2];w=y[A+3];N=a.uvs[E*2];f=a.uvs[E*2+1];L=a.uvs[v*2];V=a.uvs[v*2+1];Z=a.uvs[F*2];T=a.uvs[F*2+1];M=a.uvs[w*2];ca=a.uvs[w*2+1];THREE.Loader.prototype.uv4(g.uvs,N,f,L,V,Z,T,M,ca);if(a.uvs2){N=a.uvs2[E*2];f=a.uvs2[E*2+1];L=
  378. a.uvs2[v*2];V=a.uvs2[v*2+1];Z=a.uvs2[F*2];T=a.uvs2[F*2+1];M=a.uvs2[w*2];ca=a.uvs2[w*2+1];THREE.Loader.prototype.uv4(g.uvs2,N,1-f,L,1-V,Z,1-T,M,1-ca)}}var u,t;u=0;for(t=a.trianglesUvs.length;u<t;u+=7){h(a.trianglesUvs,u);q(a.trianglesUvs,u+4)}u=0;for(t=a.trianglesNormalsUvs.length;u<t;u+=10){j(a.trianglesNormalsUvs,u);q(a.trianglesNormalsUvs,u+7)}u=0;for(t=a.quadsUvs.length;u<t;u+=9){k(a.quadsUvs,u);x(a.quadsUvs,u+5)}u=0;for(t=a.quadsNormalsUvs.length;u<t;u+=13){n(a.quadsNormalsUvs,u);x(a.quadsNormalsUvs,
  379. u+9)}u=0;for(t=a.triangles.length;u<t;u+=4)h(a.triangles,u);u=0;for(t=a.trianglesNormals.length;u<t;u+=7)j(a.trianglesNormals,u);u=0;for(t=a.quads.length;u<t;u+=5)k(a.quads,u);u=0;for(t=a.quadsNormals.length;u<t;u+=9)n(a.quadsNormals,u)})();(function(){var h,j,k,n;if(a.skinWeights){h=0;for(j=a.skinWeights.length;h<j;h+=2){k=a.skinWeights[h];n=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,k,n,0,0)}}if(a.skinIndices){h=0;for(j=a.skinIndices.length;h<j;h+=2){k=a.skinIndices[h];n=a.skinIndices[h+1];
  380. THREE.Loader.prototype.si(g,k,n,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(b))},bones:function(a,c){a.bones=c},animation:function(a,c){a.animation=c},si:function(a,c,b,d,e){a.skinIndices.push(new THREE.Vector4(c,b,d,e))},sw:function(a,c,b,d,e){a.skinWeights.push(new THREE.Vector4(c,b,d,e))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,
  381. b,d)))},vc:function(a,c,b,d){var e=new THREE.Color(16777215);e.setRGB(c,b,d);a.colors.push(e)},f3:function(a,c,b,d,e){a.faces.push(new THREE.Face3(c,b,d,null,a.materials[e]))},f4:function(a,c,b,d,e,g){a.faces.push(new THREE.Face4(c,b,d,e,null,a.materials[g]))},f3n:function(a,c,b,d,e,g,h,j,k){g=a.materials[g];var n=c[j*3],q=c[j*3+1];j=c[j*3+2];var x=c[k*3],u=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(n,q,j),new THREE.Vector3(x,
  382. u,k)],g))},f4n:function(a,c,b,d,e,g,h,j,k,n,q){h=a.materials[h];var x=c[k*3],u=c[k*3+1];k=c[k*3+2];var t=c[n*3],y=c[n*3+1];n=c[n*3+2];var A=c[q*3],E=c[q*3+1];q=c[q*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,u,k),new THREE.Vector3(t,y,n),new THREE.Vector3(A,E,q)],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 n=[];n.push(new THREE.UV(c,
  383. b));n.push(new THREE.UV(d,e));n.push(new THREE.UV(g,h));n.push(new THREE.UV(j,k));a.push(n)},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 n=new Image;n.onload=function(){if(!b(this.width)||!b(this.height)){var q=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/
  384. Math.LN2));j.image.width=q;j.image.height=x;j.image.getContext("2d").drawImage(this,0,0,q,x)}else j.image=this;j.needsUpdate=!0};n.src=k}var e,g,h;e="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(e="MeshPhongMaterial");if(a.mapDiffuse&&c){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*
  385. 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);d(g.lightMap,c+"/"+a.mapLightmap)}return new THREE[e](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};