ThreeWebGL.js 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // ThreeWebGL.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,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,l,m,p,o;if(d==0)e=g=l=0;else{m=Math.floor(a*6);p=a*6-m;a=d*(1-b);o=d*(1-b*p);b=d*(1-b*(1-p));switch(m){case 1:e=o;g=d;l=a;break;case 2:e=a;g=d;l=b;break;case 3:e=a;g=o;l=d;break;case 4:e=b;g=a;l=d;break;case 5:e=d;g=a;l=o;break;case 6:case 0:e=d;g=b;l=a}}this.r=e;this.g=g;this.b=l;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,b){this.set(a||0,b||0)};
  6. THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;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,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.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,b,d){this.set(a||0,b||0,d||0)};
  8. THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.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,b){this.set(a.x-b.x,a.y-b.y,a.z-b.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. b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.set(d*a.z-e*a.y,e*a.x-b*a.z,b*a.y-d*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.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 b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+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 b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}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,b,d,e){this.set(a||0,b||0,d||0,e||1)};
  13. THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.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,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.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,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
  15. THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(l,m){return l.distance-m.distance});return g},intersectObject:function(a){function b(I,J,P,S){S=S.clone().subSelf(J);P=P.clone().subSelf(J);var Z=I.clone().subSelf(J);I=S.dot(S);J=S.dot(P);S=S.dot(Z);var da=P.dot(P);P=P.dot(Z);Z=1/(I*da-J*J);da=(da*S-J*P)*Z;I=(I*P-J*S)*Z;return da>0&&I>0&&da+I<1}var d,e,g,l,m,p,o,
  16. q,u,x,A,B=a.geometry,G=B.vertices,H=[];d=0;for(e=B.faces.length;d<e;d++){g=B.faces[d];x=this.origin.clone();A=this.direction.clone();o=a.matrixWorld;l=o.multiplyVector3(G[g.a].position.clone());m=o.multiplyVector3(G[g.b].position.clone());p=o.multiplyVector3(G[g.c].position.clone());o=g instanceof THREE.Face4?o.multiplyVector3(G[g.d].position.clone()):null;q=a.matrixRotationWorld.multiplyVector3(g.normal.clone());u=A.dot(q);if(u<0){q=q.dot((new THREE.Vector3).sub(l,x))/u;x=x.addSelf(A.multiplyScalar(q));
  17. if(g instanceof THREE.Face3){if(b(x,l,m,p)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(b(x,l,m,o)||b(x,m,p,o))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}}return H}};
  18. THREE.Rectangle=function(){function a(){l=e-b;m=g-d}var b,d,e,g,l,m,p=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return l};this.getHeight=function(){return m};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(o,q,u,x){p=!1;b=o;d=q;e=u;g=x;a()};this.addPoint=function(o,q){if(p){p=!1;b=o;d=q;e=o;g=q}else{b=b<o?b:o;d=d<q?d:q;e=e>o?e:o;g=g>q?g:q}a()};
  19. this.add3Points=function(o,q,u,x,A,B){if(p){p=!1;b=o<u?o<A?o:A:u<A?u:A;d=q<x?q<B?q:B:x<B?x:B;e=o>u?o>A?o:A:u>A?u:A;g=q>x?q>B?q:B:x>B?x:B}else{b=o<u?o<A?o<b?o:b:A<b?A:b:u<A?u<b?u:b:A<b?A:b;d=q<x?q<B?q<d?q:d:B<d?B:d:x<B?x<d?x:d:B<d?B:d;e=o>u?o>A?o>e?o:e:A>e?A:e:u>A?u>e?u:e:A>e?A:e;g=q>x?q>B?q>g?q:g:B>g?B:g:x>B?x>g?x:g:B>g?B:g}a()};this.addRectangle=function(o){if(p){p=!1;b=o.getLeft();d=o.getTop();e=o.getRight();g=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();d=d<o.getTop()?d:o.getTop();e=e>o.getRight()?
  20. e:o.getRight();g=g>o.getBottom()?g:o.getBottom()}a()};this.inflate=function(o){b-=o;d-=o;e+=o;g+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();d=d>o.getTop()?d:o.getTop();e=e<o.getRight()?e:o.getRight();g=g<o.getBottom()?g:o.getBottom();a()};this.instersects=function(o){return Math.min(e,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(g,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){p=!0;g=e=d=b=0;a()};this.isEmpty=function(){return p}};
  21. THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
  22. THREE.Matrix4=function(a,b,d,e,g,l,m,p,o,q,u,x,A,B,G,H){this.set(a||1,b||0,d||0,e||0,g||0,l||1,m||0,p||0,o||0,q||0,u||1,x||0,A||0,B||0,G||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  23. THREE.Matrix4.prototype={set:function(a,b,d,e,g,l,m,p,o,q,u,x,A,B,G,H){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=l;this.n23=m;this.n24=p;this.n31=o;this.n32=q;this.n33=u;this.n34=x;this.n41=A;this.n42=B;this.n43=G;this.n44=H;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__v1,
  24. g=THREE.Matrix4.__v2,l=THREE.Matrix4.__v3;l.sub(a,b).normalize();if(l.length()===0)l.z=1;e.cross(d,l).normalize();if(e.length()===0){l.x+=1.0E-4;e.cross(d,l).normalize()}g.cross(l,e).normalize();this.n11=e.x;this.n12=g.x;this.n13=l.x;this.n21=e.y;this.n22=g.y;this.n23=l.y;this.n31=e.z;this.n32=g.z;this.n33=l.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*
  25. e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},rotateAxis:function(a){var b=a.x,d=a.y,e=a.z;a.x=b*this.n11+d*this.n12+e*this.n13;a.y=b*this.n21+d*this.n22+e*this.n23;a.z=b*this.n31+d*this.n32+e*this.n33;a.normalize();
  26. return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,l=a.n14,m=a.n21,p=a.n22,o=a.n23,q=a.n24,u=a.n31,x=a.n32,A=a.n33,B=a.n34,G=a.n41,H=a.n42,I=a.n43,J=a.n44,P=b.n11,S=b.n12,Z=b.n13,da=b.n14,$=b.n21,fa=b.n22,
  27. c=b.n23,pa=b.n24,na=b.n31,va=b.n32,qa=b.n33,ra=b.n34;this.n11=d*P+e*$+g*na;this.n12=d*S+e*fa+g*va;this.n13=d*Z+e*c+g*qa;this.n14=d*da+e*pa+g*ra+l;this.n21=m*P+p*$+o*na;this.n22=m*S+p*fa+o*va;this.n23=m*Z+p*c+o*qa;this.n24=m*da+p*pa+o*ra+q;this.n31=u*P+x*$+A*na;this.n32=u*S+x*fa+A*va;this.n33=u*Z+x*c+A*qa;this.n34=u*da+x*pa+A*ra+B;this.n41=G*P+H*$+I*na;this.n42=G*S+H*fa+I*va;this.n43=G*Z+H*c+I*qa;this.n44=G*da+H*pa+I*ra+J;return this},multiplyToArray:function(a,b,d){this.multiply(a,b);d[0]=this.n11;
  28. d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[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*=
  29. a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,l=this.n22,m=this.n23,p=this.n24,o=this.n31,q=this.n32,u=this.n33,x=this.n34,A=this.n41,B=this.n42,G=this.n43,H=this.n44;return e*m*q*A-d*p*q*A-e*l*u*A+b*p*u*A+d*l*x*A-b*m*x*A-e*m*o*B+d*p*o*B+e*g*u*B-a*p*u*B-d*g*x*B+a*m*x*B+e*l*o*G-b*p*o*G-e*g*q*G+a*p*q*G+b*g*x*G-a*l*x*G-d*l*o*H+b*m*o*H+d*g*q*H-a*m*q*H-b*g*u*H+a*l*u*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=
  30. this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=
  31. this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;
  32. a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,
  33. 0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),g=
  34. 1-d,l=a.x,m=a.y,p=a.z,o=g*l,q=g*m;this.set(o*l+d,o*m-e*p,o*p+e*m,0,o*m+e*p,q*m+d,q*p-e*l,0,o*p-e*m,q*p+e*l,g*p*p+d,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 b=a.x,d=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var l=Math.cos(e);e=Math.sin(e);var m=a*d,p=b*d;this.n11=g*l;this.n12=-g*e;this.n13=d;this.n21=p*l+a*e;this.n22=-p*e+a*l;this.n23=-b*g;this.n31=-m*l+b*e;this.n32=m*e+b*l;this.n33=
  35. a*g;return this},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,e=a.z,g=a.w,l=b+b,m=d+d,p=e+e;a=b*l;var o=b*m;b*=p;var q=d*m;d*=p;e*=p;l*=g;m*=g;g*=p;this.n11=1-(q+e);this.n12=o-g;this.n13=b+m;this.n21=o+g;this.n22=1-(a+e);this.n23=d-l;this.n31=b-m;this.n32=d+l;this.n33=1-(a+q);return this},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;this.n42*=d;this.n43*=a;return this},extractPosition:function(a){this.n14=
  36. a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var d=1/b.x,e=1/b.y,g=1/b.z;this.n11=a.n11*d;this.n21=a.n21*d;this.n31=a.n31*d;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*g;this.n23=a.n23*g;this.n33=a.n33*g}};
  37. THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,g=a.n13,l=a.n14,m=a.n21,p=a.n22,o=a.n23,q=a.n24,u=a.n31,x=a.n32,A=a.n33,B=a.n34,G=a.n41,H=a.n42,I=a.n43,J=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=o*B*H-q*A*H+q*x*I-p*B*I-o*x*J+p*A*J;b.n12=l*A*H-g*B*H-l*x*I+e*B*I+g*x*J-e*A*J;b.n13=g*q*H-l*o*H+l*p*I-e*q*I-g*p*J+e*o*J;b.n14=l*o*x-g*q*x-l*p*A+e*q*A+g*p*B-e*o*B;b.n21=q*A*G-o*B*G-q*u*I+m*B*I+o*u*J-m*A*J;b.n22=g*B*G-l*A*G+l*u*I-d*B*I-g*u*J+d*A*J;b.n23=l*o*G-g*q*G-l*m*I+d*q*I+g*m*J-d*o*J;
  38. b.n24=g*q*u-l*o*u+l*m*A-d*q*A-g*m*B+d*o*B;b.n31=p*B*G-q*x*G+q*u*H-m*B*H-p*u*J+m*x*J;b.n32=l*x*G-e*B*G-l*u*H+d*B*H+e*u*J-d*x*J;b.n33=g*q*G-l*p*G+l*m*H-d*q*H-e*m*J+d*p*J;b.n34=l*p*u-e*q*u-l*m*x+d*q*x+e*m*B-d*p*B;b.n41=o*x*G-p*A*G-o*u*H+m*A*H+p*u*I-m*x*I;b.n42=e*A*G-g*x*G+g*u*H-d*A*H-e*u*I+d*x*I;b.n43=g*p*G-e*o*G-g*m*H+d*o*H+e*m*I-d*p*I;b.n44=e*o*u-g*p*u+g*m*x-d*o*x-e*m*A+d*p*A;b.multiplyScalar(1/a.determinant());return b};
  39. THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,l=a.n32*a.n21-a.n31*a.n22,m=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,o=-a.n32*a.n11+a.n31*a.n12,q=a.n23*a.n12-a.n22*a.n13,u=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*m+a.n31*q;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*l;d[3]=a*m;d[4]=a*p;d[5]=a*o;d[6]=a*q;d[7]=a*u;d[8]=a*x;return b};
  40. THREE.Matrix4.makeFrustum=function(a,b,d,e,g,l){var m;m=new THREE.Matrix4;m.n11=2*g/(b-a);m.n12=0;m.n13=(b+a)/(b-a);m.n14=0;m.n21=0;m.n22=2*g/(e-d);m.n23=(e+d)/(e-d);m.n24=0;m.n31=0;m.n32=0;m.n33=-(l+g)/(l-g);m.n34=-2*l*g/(l-g);m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
  41. THREE.Matrix4.makeOrtho=function(a,b,d,e,g,l){var m,p,o,q;m=new THREE.Matrix4;p=b-a;o=d-e;q=l-g;m.n11=2/p;m.n12=0;m.n13=0;m.n14=-((b+a)/p);m.n21=0;m.n22=2/o;m.n23=0;m.n24=-((d+e)/o);m.n31=0;m.n32=0;m.n33=-2/q;m.n34=-((l+g)/q);m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m};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,b){this.matrix.rotateAxis(b);this.position.addSelf(b.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 b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,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,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var e=this.children.length;a<e;a++)this.children[a].update(this.matrixWorld,
  47. b,d)}}};THREE.Quaternion=function(a,b,d,e){this.set(a||0,b||0,d||0,e!==undefined?e:1)};
  48. THREE.Quaternion.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,d=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var l=Math.cos(d);d=Math.sin(d);var m=a*b,p=e*g;this.w=m*l-p*d;this.x=m*d+p*l;this.y=e*b*l+a*g*d;this.z=a*g*l-e*b*d;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 b=this.x,d=this.y,e=this.z,g=this.w,l=a.x,m=a.y,p=a.z;a=a.w;this.x=b*a+g*l+d*p-e*m;this.y=d*a+g*m+e*l-b*p;this.z=e*a+g*p+b*m-d*l;this.w=g*a-b*l-d*m-e*p;return this},
  50. multiplyVector3:function(a,b){b||(b=a);var d=a.x,e=a.y,g=a.z,l=this.x,m=this.y,p=this.z,o=this.w,q=o*d+m*g-p*e,u=o*e+p*d-l*g,x=o*g+l*e-m*d;d=-l*d-m*e-p*g;b.x=q*o+d*-l+u*-p-x*-m;b.y=u*o+d*-m+x*-l-q*-p;b.z=x*o+d*-p+q*-m-u*-l;return b}};
  51. THREE.Quaternion.slerp=function(a,b,d,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var l=Math.acos(g),m=Math.sqrt(1-g*g);if(Math.abs(m)<0.0010){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}g=Math.sin((1-e)*l)/m;e=Math.sin(e*l)/m;d.w=a.w*g+b.w*e;d.x=a.x*g+b.x*e;d.y=a.y*g+b.y*e;d.z=a.z*g+b.z*e;return d};
  52. THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||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,b,d,e,g){this.a=a;this.b=b;this.c=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]};THREE.Face4=function(a,b,d,e,g,l){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=l instanceof Array?l:[l]};
  54. THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;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,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
  56. d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,l,m,p=new THREE.Vector3,o=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){l=this.vertices[e];l.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){l=this.faces[e];if(a&&l.vertexNormals.length){p.set(0,0,0);b=0;for(d=l.vertexNormals.length;b<d;b++)p.addSelf(l.vertexNormals[b]);p.divideScalar(3)}else{b=this.vertices[l.a];d=this.vertices[l.b];m=this.vertices[l.c];p.sub(m.position,
  57. d.position);o.sub(b.position,d.position);p.crossSelf(o)}p.isZero()||p.normalize();l.normal.copy(p)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
  58. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
  59. b;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(ra,Ba,Ca,xa,Fa,Ga,Ha){l=ra.vertices[Ba].position;m=ra.vertices[Ca].position;p=ra.vertices[xa].position;o=g[Fa];q=g[Ga];u=g[Ha];x=m.x-l.x;A=p.x-l.x;B=m.y-
  60. l.y;G=p.y-l.y;H=m.z-l.z;I=p.z-l.z;J=q.u-o.u;P=u.u-o.u;S=q.v-o.v;Z=u.v-o.v;da=1/(J*Z-P*S);c.set((Z*x-S*A)*da,(Z*B-S*G)*da,(Z*H-S*I)*da);pa.set((J*A-P*x)*da,(J*G-P*B)*da,(J*I-P*H)*da);$[Ba].addSelf(c);$[Ca].addSelf(c);$[xa].addSelf(c);fa[Ba].addSelf(pa);fa[Ca].addSelf(pa);fa[xa].addSelf(pa)}var b,d,e,g,l,m,p,o,q,u,x,A,B,G,H,I,J,P,S,Z,da,$=[],fa=[],c=new THREE.Vector3,pa=new THREE.Vector3,na=new THREE.Vector3,va=new THREE.Vector3,qa=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){$[b]=new THREE.Vector3;
  61. fa[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
  62. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){qa.copy(this.vertices[b].normal);e=$[b];na.copy(e);na.subSelf(qa.multiplyScalar(qa.dot(e))).normalize();va.cross(this.vertices[b].normal,e);e=va.dot(fa[b]);e=e<0?-1:1;this.vertices[b].tangent.set(na.x,na.y,na.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
  63. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;b<d;b++){a=this.vertices[b];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,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
  65. THREE.Camera=function(a,b,d,e,g){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=d||0.1;this.far=e||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
  66. THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
  67. THREE.Camera.prototype.update=function(a,b,d){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);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
  68. !1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,d)};
  69. THREE.QuakeCamera=function(a){function b(d,e){return function(){e.apply(d,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
  70. a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
  71. this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(d){d.preventDefault();d.stopPropagation();if(!this.dragToLook)switch(d.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(d){d.preventDefault();d.stopPropagation();if(!this.dragToLook)switch(d.button){case 0:this.moveForward=
  72. !1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(d){this.mouseX=d.clientX-this.windowHalfX;this.mouseY=d.clientY-this.windowHalfY};this.onKeyDown=function(d){switch(d.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(d){switch(d.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
  73. !1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);
  74. var d=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(d=0);this.lon+=this.mouseX*d;this.lookVertical&&(this.lat-=this.mouseY*d);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;d=this.target.position;var e=this.position;d.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);d.y=e.y+100*Math.cos(this.phi);d.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(d){d.preventDefault()},
  75. !1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
  76. THREE.QuakeCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};
  77. THREE.PathCamera=function(a){function b(q,u){var x=q[0]-u[0],A=q[1]-u[1],B=q[2]-u[2];return Math.sqrt(x*x+A*A+B*B)}function d(q,u,x,A){var B={name:x,fps:0.6,length:A,hierarchy:[]},G,H;G=u.length;var I,J,P=[];H=new THREE.Spline;var S=0;for(I=0;I<u.length;I++){J=u[I];P[I]={x:J[0],y:J[1],z:J[2]}}var Z=[u[0][0],u[0][1],u[0][2]];for(I=1;I<P.length*100;I++){J=I/(P.length*100);position=H.getPoint(P,J);S+=b([position.x,position.y,position.z],Z);Z=[position.x,position.y,position.z]}I=S;P=0;S=G-1;H={parent:-1,
  78. keys:[]};H.keys[0]={time:0,pos:u[0],rot:[0,0,0,1],scl:[1,1,1]};H.keys[S]={time:A,pos:u[S],rot:[0,0,0,1],scl:[1,1,1]};console.log("path totalLength: ",I);for(G=1;G<S;G++){P+=A*b(u[G],u[G-1])/I;H.keys[G]={time:P,pos:u[G]}}B.hierarchy[0]=H;THREE.AnimationHandler.add(B);return new THREE.Animation(q,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(q,u){var x,A,B=new THREE.Geometry,G=new THREE.Spline,H=[];for(x=0;x<u.length;x++){A=u[x];H[x]={x:A[0],y:A[1],z:A[2]}}for(x=0;x<H.length*10;x++){A=
  79. x/(H.length*10);A=G.getPoint(H,A);B.vertices[x]=new THREE.Vertex(new THREE.Vector3(A.x,A.y,A.z))}x=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(B,x);lineObj.scale.set(1,1,1);q.addChild(lineObj);x=new Sphere(1,16,8);G=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<u.length;i++){B=new THREE.Mesh(x,G);B.position.set(u[i][0],u[i][1],u[i][2]);B.updateMatrix();q.addChild(B)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.duration=1E4;this.waypoints=
  80. [];this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=!0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
  81. if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
  82. this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,l=Math.PI/180;this.updateManual=function(){var q,u;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*l;this.theta=this.lon*l;q=this.phi%g;this.phi=q>=0?q:q+g;q=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange;
  83. this.phi=(this.phi-q[0])*(u[1]-u[0])/(q[1]-q[0])+u[0];q=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-q[0])*(u[1]-u[0])/(q[1]-q[0])+u[0];q=this.target.position;u=this.position;q.x=u.x+100*Math.sin(this.phi)*Math.cos(this.theta);q.y=u.y+100*Math.cos(this.phi);q.z=u.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.onMouseMove=function(q){this.mouseX=q.clientX-this.windowHalfX;this.mouseY=q.clientY-this.windowHalfY};if(this.createDebugDummy){a=
  84. new THREE.MeshLambertMaterial({color:30719});var m=new THREE.MeshLambertMaterial({color:65280}),p=new Cube(10,10,20),o=new Cube(2,2,10);this.animationParent=new THREE.Mesh(p,a);a=new THREE.Mesh(o,m);a.position.set(0,10,0);this.animation=d(this.animationParent,this.waypoints,"cameraPath01",this.duration);this.animationParent.addChild(this);this.animationParent.addChild(a)}else{this.animation=d(this.animationParent,this.waypoints,"cameraPath01",this.duration);this.animationParent.addChild(this)}this.createDebugPath&&
  85. e(this.debugPath,this.waypoints);this.domElement.addEventListener("mousemove",function(q,u){return function(){u.apply(q,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.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;
  86. THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
  87. THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;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(){};
  88. THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  89. 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=
  90. 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}};
  91. 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&&
  92. 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=
  93. 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}};
  94. 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&&
  95. 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=
  96. 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}};
  97. 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=
  98. 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!==
  99. 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!==
  100. 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}};
  101. 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!==
  102. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
  103. 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!==
  104. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
  105. 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=
  106. 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!==
  107. undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  108. THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=
  109. a.sizeAttenuation;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};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}};
  110. THREE.Texture=function(a,b,d,e,g,l){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==undefined?e:THREE.ClampToEdgeWrapping;this.magFilter=g!==undefined?g:THREE.LinearFilter;this.minFilter=l!==undefined?l:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
  111. THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;
  112. THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
  113. THREE.RenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrapS=d.wrapS!==undefined?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==undefined?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==undefined?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==undefined?d.minFilter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
  114. var Uniforms={clone:function(a){var b,d,e,g={};for(b in a){g[b]={};for(d in a[b]){e=a[b][d];g[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,d,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)g[d]=e[d]}return g}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
  115. THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
  116. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];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;
  117. 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;
  118. THREE.Bone.prototype.update=function(a,b,d){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,d):a.update(this.matrixWorld,!0,d)}}else for(e=0;e<g;e++)this.children[e].update(this.skinMatrix,
  119. b,d)};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;
  120. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,g,l,m,p;if(this.geometry.bones!==undefined){for(d=0;d<this.geometry.bones.length;d++){g=this.geometry.bones[d];l=g.pos;m=g.rotq;p=g.scl;e=this.addBone();e.name=g.name;e.position.set(l[0],l[1],l[2]);e.quaternion.set(m[0],m[1],m[2],m[3]);e.useQuaternion=!0;p!==undefined?e.scale.set(p[0],p[1],p[2]):e.scale.set(1,1,1)}for(d=0;d<this.bones.length;d++){g=this.geometry.bones[d];
  121. e=this.bones[d];g.parent===-1?this.addChild(e):this.bones[g.parent].addChild(e)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  122. THREE.SkinnedMesh.prototype.update=function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,d):a.update(this.matrixWorld,b,d)}d=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(b=0;b<d;b++)ba[b].skinMatrix.flattenToArrayOffset(bm,
  123. b*16)}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  124. THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],d=0;d<this.bones.length;d++){a=this.bones[d];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,d*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){d=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,l=this.geometry.skinIndices[a].y;
  125. e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(b[l].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){d=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=d;this.geometry.skinWeights[a].y+=d}}}};
  126. THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
  127. THREE.Sound=function(a,b,d,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,d!==undefined?d:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var g;d=this.sources.length;for(a=0;a<d;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)g=
  128. "audio/mpeg";else if(b.indexOf(".ogg")!==-1)g="audio/ogg";else b.indexOf(".wav")!==-1&&(g="audio/wav");if(this.domElement.canPlayType(g)){g=document.createElement("source");g.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(g);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;
  129. 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()};
  130. 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};
  131. THREE.Sound.prototype.update=function(a,b,d){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.matrixWorld,b,d)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
  132. THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(a,b){b===undefined&&(b=0);b=Math.abs(b);for(var d=0;d<this.LODs.length;d++)if(b<this.LODs[d].visibleAtDistance)break;this.LODs.splice(d,0,{visibleAtDistance:b,object3D:a});this.addChild(a)};
  133. THREE.LOD.prototype.update=function(a,b,d){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}if(this.LODs.length>1){a=d.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 e=1;e<this.LODs.length;e++)if(a>=this.LODs[e].visibleAtDistance){this.LODs[e-1].object3D.visible=
  134. !1;this.LODs[e].object3D.visible=!0}else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,d)};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;
  135. 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 b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
  136. 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 b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
  137. 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,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==undefined?b:2.5E-4};
  138. 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,b,d){d&&a.update(undefined,!1,b);d=a.sounds;var e,g=d.length;for(e=0;e<g;e++){a=d[e];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
  139. THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
  140. 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",
  141. 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",
  142. 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",
  143. 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",
  144. 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}",
  145. 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;",
  146. 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"};
  147. 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",
  148. value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  149. 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",
  150. value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
  151. THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
  152. THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
  153. THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",
  154. THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,
  155. THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
  156. THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
  157. THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
  158. THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
  159. THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
  160. THREE.WebGLRenderer=function(a){function b(f,k,n){var h,j,w,r=f.vertices,v=r.length,D=f.colors,t=D.length,z=f.__vertexArray,M=f.__colorArray,R=f.__sortArray,O=f.__dirtyVertices,L=f.__dirtyColors;if(n.sortParticles){Ia.multiplySelf(n.matrixWorld);for(h=0;h<v;h++){j=r[h].position;Da.copy(j);Ia.multiplyVector3(Da);R[h]=[Da.z,h]}R.sort(function(N,K){return K[0]-N[0]});for(h=0;h<v;h++){j=r[R[h][1]].position;w=h*3;z[w]=j.x;z[w+1]=j.y;z[w+2]=j.z}for(h=0;h<t;h++){w=h*3;color=D[R[h][1]];M[w]=color.r;M[w+1]=
  161. color.g;M[w+2]=color.b}}else{if(O)for(h=0;h<v;h++){j=r[h].position;w=h*3;z[w]=j.x;z[w+1]=j.y;z[w+2]=j.z}if(L)for(h=0;h<t;h++){color=D[h];w=h*3;M[w]=color.r;M[w+1]=color.g;M[w+2]=color.b}}if(O||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,z,k)}if(L||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,M,k)}}function d(f,k){f.fragmentShader=k.fragmentShader;f.vertexShader=k.vertexShader;f.uniforms=Uniforms.clone(k.uniforms)}
  162. function e(f,k,n,h,j){h.program||va.initMaterial(h,k,n,j);var w=h.program,r=w.uniforms,v=h.uniforms;if(w!=pa){c.useProgram(w);pa=w}c.uniformMatrix4fv(r.projectionMatrix,!1,Ra);if(n&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){v.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){v.fogNear.value=n.near;v.fogFar.value=n.far}else if(n instanceof
  163. THREE.FogExp2)v.fogDensity.value=n.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){var D,t,z=0,M=0,R=0,O,L,N,K=Sa,ja=K.directional.colors,y=K.directional.positions,ga=K.point.colors,ea=K.point.positions,ia=0,C=0;n=t=t=0;for(D=k.length;n<D;n++){t=k[n];O=t.color;L=t.position;N=t.intensity;if(t instanceof THREE.AmbientLight){z+=O.r;M+=O.g;R+=O.b}else if(t instanceof THREE.DirectionalLight){t=ia*3;ja[t]=O.r*N;ja[t+1]=O.g*N;ja[t+2]=O.b*N;y[t]=L.x;y[t+1]=L.y;y[t+
  164. 2]=L.z;ia+=1}else if(t instanceof THREE.PointLight){t=C*3;ga[t]=O.r*N;ga[t+1]=O.g*N;ga[t+2]=O.b*N;ea[t]=L.x;ea[t+1]=L.y;ea[t+2]=L.z;C+=1}}for(n=ia*3;n<ja.length;n++)ja[n]=0;for(n=C*3;n<ga.length;n++)ga[n]=0;K.point.length=C;K.directional.length=ia;K.ambient[0]=z;K.ambient[1]=M;K.ambient[2]=R;k=Sa;v.enableLighting.value=k.directional.length+k.point.length;v.ambientLightColor.value=k.ambient;v.directionalLightColor.value=k.directional.colors;v.directionalLightDirection.value=k.directional.positions;
  165. v.pointLightColor.value=k.point.colors;v.pointLightPosition.value=k.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){v.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);v.opacity.value=h.opacity;v.map.texture=h.map;v.lightMap.texture=h.lightMap;v.envMap.texture=h.envMap;v.reflectivity.value=h.reflectivity;v.refractionRatio.value=h.refractionRatio;v.combine.value=h.combine;v.useRefract.value=
  166. h.envMap&&h.envMap.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){v.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);v.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){v.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);v.opacity.value=h.opacity;v.size.value=h.size;v.scale.value=fa.height/2;v.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){v.ambient.value.setRGB(h.ambient.r,
  167. h.ambient.g,h.ambient.b);v.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);v.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){v.mNear.value=f.near;v.mFar.value=f.far;v.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)v.opacity.value=h.opacity;for(var E in v)if(z=w.uniforms[E]){n=v[E];D=n.type;k=n.value;if(D=="i")c.uniform1i(z,k);else if(D=="f")c.uniform1f(z,k);else if(D=="fv1")c.uniform1fv(z,k);else if(D=="fv")c.uniform3fv(z,k);else if(D==
  168. "v2")c.uniform2f(z,k.x,k.y);else if(D=="v3")c.uniform3f(z,k.x,k.y,k.z);else if(D=="c")c.uniform3f(z,k.r,k.g,k.b);else if(D=="t"){c.uniform1i(z,k);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){if(n.image.length==6){if(n.needsUpdate){if(n.__wasSetOnce){c.bindTexture(c.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube);for(D=0;D<6;++D)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,n.image[D])}else{n.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,
  169. n.image.__webGLTextureCube);for(D=0;D<6;++D)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,n.image[D]);n.__wasSetOnce=!0}P(c.TEXTURE_CUBE_MAP,n,n.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);n.needsUpdate=!1}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{if(n.needsUpdate){if(n.__wasSetOnce){c.bindTexture(c.TEXTURE_2D,n.__webGLTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,n.image)}else{n.__webGLTexture=
  170. c.createTexture();c.bindTexture(c.TEXTURE_2D,n.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,n.image);n.__wasSetOnce=!0}P(c.TEXTURE_2D,n,n.image);c.bindTexture(c.TEXTURE_2D,null);n.needsUpdate=!1}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_2D,n.__webGLTexture)}}}c.uniformMatrix4fv(r.modelViewMatrix,!1,j._modelViewMatrixArray);c.uniformMatrix3fv(r.normalMatrix,!1,j._normalMatrixArray);(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||
  171. h.envMap)&&c.uniform3f(r.cameraPosition,f.position.x,f.position.y,f.position.z);(h instanceof THREE.MeshShaderMaterial||h.envMap||h.skinning)&&c.uniformMatrix4fv(r.objectMatrix,!1,j._objectMatrixArray);(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial||h.skinning)&&c.uniformMatrix4fv(r.viewMatrix,!1,La);if(h.skinning){c.uniformMatrix4fv(r.cameraInverseMatrix,!1,La);c.uniformMatrix4fv(r.boneGlobalMatrices,!1,j.boneMatrices)}return w}
  172. function g(f,k,n,h,j,w){if(h.opacity!=0){f=e(f,k,n,h,w).attributes;c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,
  173. c.FLOAT,!1,0,0)}if(f.uv>=0)if(j.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(j.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(h.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,
  174. j.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(w instanceof THREE.Mesh)if(h.wireframe){c.lineWidth(h.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
  175. j.__webGLLineBuffer);c.drawElements(c.LINES,j.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,j.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(w instanceof THREE.Line){w=w.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(h.linewidth);c.drawArrays(w,0,j.__webGLLineCount)}else if(w instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,j.__webGLParticleCount);else w instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,
  176. 0,j.__webGLVertexCount)}}function l(f,k){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(k.attributes.position);c.vertexAttribPointer(k.attributes.position,3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
  177. f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(k.attributes.normal);c.vertexAttribPointer(k.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function m(f){if(qa!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);qa=f.doubleSided}if(ra!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);ra=f.flipSided}}function p(f){if(Ca!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);Ca=f}}function o(f){sa[0].set(f.n41-f.n11,f.n42-
  178. f.n12,f.n43-f.n13,f.n44-f.n14);sa[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);sa[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);sa[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);sa[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);sa[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var k;for(f=0;f<6;f++){k=sa[f];k.divideScalar(Math.sqrt(k.x*k.x+k.y*k.y+k.z*k.z))}}function q(f){for(var k=f.matrixWorld,n=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,
  179. Math.max(f.scale.y,f.scale.z)),h=0;h<6;h++){f=sa[h].x*k.n14+sa[h].y*k.n24+sa[h].z*k.n34+sa[h].w;if(f<=n)return!1}return!0}function u(f,k){f.list[f.count]=k;f.count+=1}function x(f){var k,n,h=f.object,j=f.opaque,w=f.transparent;w.count=0;f=j.count=0;for(k=h.materials.length;f<k;f++){n=h.materials[f];n.opacity&&n.opacity<1||n.blending!=THREE.NormalBlending?u(w,n):u(j,n)}}function A(f){var k,n,h,j,w=f.object,r=f.buffer,v=f.opaque,D=f.transparent;D.count=0;f=v.count=0;for(h=w.materials.length;f<h;f++){k=
  180. w.materials[f];if(k instanceof THREE.MeshFaceMaterial){k=0;for(n=r.materials.length;k<n;k++)(j=r.materials[k])&&(j.opacity&&j.opacity<1||j.blending!=THREE.NormalBlending?u(D,j):u(v,j))}else{j=k;j.opacity&&j.opacity<1||j.blending!=THREE.NormalBlending?u(D,j):u(v,j)}}}function B(f,k){return k.z-f.z}function G(f,k){f._modelViewMatrix.multiplyToArray(k.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function H(f){function k(M){var R=
  181. [];n=0;for(h=M.length;n<h;n++)M[n]==undefined?R.push("undefined"):R.push(M[n].id);return R.join("_")}var n,h,j,w,r,v,D,t,z={};f.geometryGroups={};j=0;for(w=f.faces.length;j<w;j++){r=f.faces[j];v=r.materials;D=k(v);z[D]==undefined&&(z[D]={hash:D,counter:0});t=z[D].hash+"_"+z[D].counter;f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:v,vertices:0});r=r instanceof THREE.Face3?3:4;if(f.geometryGroups[t].vertices+r>65535){z[D].counter+=1;t=z[D].hash+"_"+z[D].counter;f.geometryGroups[t]==
  182. undefined&&(f.geometryGroups[t]={faces:[],materials:v,vertices:0})}f.geometryGroups[t].faces.push(j);f.geometryGroups[t].vertices+=r}}function I(f,k,n){f.push({buffer:k,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function J(f){if(f!=Ba){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,
  183. c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}Ba=f}}function P(f,k,n){if((n.width&n.width-1)==0&&(n.height&n.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,$(k.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,$(k.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,$(k.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,$(k.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,
  184. c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,da(k.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,da(k.minFilter))}}function S(f){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,
  185. f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,$(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,$(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,$(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,$(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,$(f.format),f.width,f.height,0,$(f.format),$(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER,f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,
  186. c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var k,n;if(f){k=f.__webGLFramebuffer;n=f.width;f=f.height}else{k=null;n=Ga;f=Ha}if(k!=na){c.bindFramebuffer(c.FRAMEBUFFER,k);c.viewport(xa,Fa,n,f);na=k}}function Z(f,k){var n;if(f=="fragment")n=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(n=c.createShader(c.VERTEX_SHADER));c.shaderSource(n,k);c.compileShader(n);if(!c.getShaderParameter(n,
  187. c.COMPILE_STATUS)){alert(c.getShaderInfoLog(n));return null}return n}function da(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return c.LINEAR}}function $(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
  188. case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;
  189. case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var fa=document.createElement("canvas"),c,pa=null,na=null,va=this,qa=null,ra=null,Ba=null,Ca=null,xa=0,Fa=0,Ga=0,Ha=0,sa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
  190. new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ia=new THREE.Matrix4,Ra=new Float32Array(16),La=new Float32Array(16),Da=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ta=!0,Ua=new THREE.Color(0),Va=0;if(a){if(a.antialias!==undefined)Ta=a.antialias;a.clearColor!==undefined&&Ua.setHex(a.clearColor);if(a.clearAlpha!==undefined)Va=a.clearAlpha}this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(f,k,n){try{if(!(c=
  191. fa.getContext("experimental-webgl",{antialias:f})))throw"Error creating WebGL context.";}catch(h){console.error(h)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(k.r,k.g,k.b,n);_cullEnabled=!0})(Ta,Ua,Va);this.context=c;this.setSize=function(f,k){fa.width=f;fa.height=k;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(f,
  192. k,n,h){xa=f;Fa=k;Ga=n;Ha=h;c.viewport(xa,Fa,Ga,Ha)};this.setScissor=function(f,k,n,h){c.scissor(f,k,n,h)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){c.depthMask(f)};this.setClearColorHex=function(f,k){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,k)};this.setClearColor=function(f,k){c.clearColor(f.r,f.g,f.b,k)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,
  193. k,n,h){var j;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);
  194. var w,r,v,D,t;w=D=t=0;for(r=k.length;w<r;w++){v=k[w];v instanceof THREE.DirectionalLight&&D++;v instanceof THREE.PointLight&&t++}if(t+D<=4)k=D;else{k=Math.ceil(4*D/(t+D));t=4-k}k={directional:k,point:t};w=50;if(h!==undefined&&h instanceof THREE.SkinnedMesh)w=h.bones.length;h=f.fragmentShader;t=f.vertexShader;w={fog:n,map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,maxDirLights:k.directional,maxPointLights:k.point,maxBones:w};
  195. n=c.createProgram();k=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");w=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":
  196. "","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,"#define MAX_BONES "+w.maxBones,w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"",w.skinning?"#define USE_SKINNING":"",w.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
  197. c.attachShader(n,Z("fragment",k+h));c.attachShader(n,Z("vertex",w+t));c.linkProgram(n);c.getProgramParameter(n,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(n,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");n.uniforms={};n.attributes={};f.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(j in f.uniforms)n.push(j);j=f.program;h=0;for(t=n.length;h<
  198. t;h++){k=n[h];j.uniforms[k]=c.getUniformLocation(j,k)}j=f.program;n=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];h=0;for(t=n.length;h<t;h++){k=n[h];j.attributes[k]=c.getAttribLocation(j,k)}j=f.program.attributes;c.enableVertexAttribArray(j.position);j.color>=0&&c.enableVertexAttribArray(j.color);j.normal>=0&&c.enableVertexAttribArray(j.normal);j.tangent>=0&&c.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>=
  199. 0&&j.skinIndex>=0&&j.skinWeight>=0){c.enableVertexAttribArray(j.skinVertexA);c.enableVertexAttribArray(j.skinVertexB);c.enableVertexAttribArray(j.skinIndex);c.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,k,n,h){var j,w,r,v,D,t,z,M,R=f.lights,O=f.fog;k.matrixAutoUpdate&&k.parent===undefined&&k.update(undefined,!0);f.update(undefined,!1,k);k.matrixWorldInverse.flattenToArray(La);k.projectionMatrix.flattenToArray(Ra);Ia.multiply(k.projectionMatrix,k.matrixWorldInverse);o(Ia);this.initWebGLObjects(f);
  200. S(n);(this.autoClear||h)&&this.clear();D=f.__webglObjects.length;for(h=0;h<D;h++){j=f.__webglObjects[h];z=j.object;if(z.visible)if(!(z instanceof THREE.Mesh)||q(z)){z.matrixWorld.flattenToArray(z._objectMatrixArray);G(z,k);A(j);j.render=!0;if(this.sortObjects){Da.copy(z.position);Ia.multiplyVector3(Da);j.z=Da.z}}else j.render=!1;else j.render=!1}this.sortObjects&&f.__webglObjects.sort(B);t=f.__webglObjectsImmediate.length;for(h=0;h<t;h++){j=f.__webglObjectsImmediate[h];z=j.object;if(z.visible){z.matrixAutoUpdate&&
  201. z.matrixWorld.flattenToArray(z._objectMatrixArray);G(z,k);x(j)}}J(THREE.NormalBlending);for(h=0;h<D;h++){j=f.__webglObjects[h];if(j.render){z=j.object;M=j.buffer;r=j.opaque;m(z);for(j=0;j<r.count;j++){v=r.list[j];p(v.depthTest);g(k,R,O,v,M,z)}}}for(h=0;h<t;h++){j=f.__webglObjectsImmediate[h];z=j.object;if(z.visible){r=j.opaque;m(z);for(j=0;j<r.count;j++){v=r.list[j];p(v.depthTest);w=e(k,R,O,v,z);z.render(function(L){l(L,w)})}}}for(h=0;h<D;h++){j=f.__webglObjects[h];if(j.render){z=j.object;M=j.buffer;
  202. r=j.transparent;m(z);for(j=0;j<r.count;j++){v=r.list[j];J(v.blending);p(v.depthTest);g(k,R,O,v,M,z)}}}for(h=0;h<t;h++){j=f.__webglObjectsImmediate[h];z=j.object;if(z.visible){r=j.transparent;m(z);for(j=0;j<r.count;j++){v=r.list[j];J(v.blending);p(v.depthTest);w=e(k,R,O,v,z);z.render(function(L){l(L,w)})}}}if(n&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,n.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=
  203. function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[]}for(;f.__objectsAdded.length;){var k=f.__objectsAdded[0],n=f,h=void 0,j=void 0,w=void 0;if(k._modelViewMatrix==undefined){k._modelViewMatrix=new THREE.Matrix4;k._normalMatrixArray=new Float32Array(9);k._modelViewMatrixArray=new Float32Array(16);k._objectMatrixArray=new Float32Array(16);k.matrixWorld.flattenToArray(k._objectMatrixArray)}if(k instanceof THREE.Mesh){j=k.geometry;j.geometryGroups==undefined&&H(j);for(h in j.geometryGroups){w=
  204. j.geometryGroups[h];if(!w.__webGLVertexBuffer){var r=w;r.__webGLVertexBuffer=c.createBuffer();r.__webGLNormalBuffer=c.createBuffer();r.__webGLTangentBuffer=c.createBuffer();r.__webGLColorBuffer=c.createBuffer();r.__webGLUVBuffer=c.createBuffer();r.__webGLUV2Buffer=c.createBuffer();r.__webGLSkinVertexABuffer=c.createBuffer();r.__webGLSkinVertexBBuffer=c.createBuffer();r.__webGLSkinIndicesBuffer=c.createBuffer();r.__webGLSkinWeightsBuffer=c.createBuffer();r.__webGLFaceBuffer=c.createBuffer();r.__webGLLineBuffer=
  205. c.createBuffer();r=w;var v=k,D=void 0,t=void 0,z=0,M=0,R=0,O=v.geometry.faces,L=r.faces;D=0;for(t=L.length;D<t;D++){fi=L[D];face=O[fi];if(face instanceof THREE.Face3){z+=3;M+=1;R+=3}else if(face instanceof THREE.Face4){z+=4;M+=2;R+=4}}r.__vertexArray=new Float32Array(z*3);r.__normalArray=new Float32Array(z*3);r.__tangentArray=new Float32Array(z*4);r.__colorArray=new Float32Array(z*3);r.__uvArray=new Float32Array(z*2);r.__uv2Array=new Float32Array(z*2);r.__skinVertexAArray=new Float32Array(z*4);r.__skinVertexBArray=
  206. new Float32Array(z*4);r.__skinIndexArray=new Float32Array(z*4);r.__skinWeightArray=new Float32Array(z*4);r.__faceArray=new Uint16Array(M*3);r.__lineArray=new Uint16Array(R*2);t=D=r;z=void 0;O=void 0;var N=void 0,K=void 0;N=void 0;L=!1;z=0;for(O=v.materials.length;z<O;z++){N=v.materials[z];if(N instanceof THREE.MeshFaceMaterial){N=0;for(K=t.materials.length;N<K;N++)if(t.materials[N]&&t.materials[N].shading!=undefined&&t.materials[N].shading==THREE.SmoothShading){L=!0;break}}else if(N&&N.shading!=undefined&&
  207. N.shading==THREE.SmoothShading){L=!0;break}if(L)break}D.__needsSmoothNormals=L;r.__webGLFaceCount=M*3;r.__webGLLineCount=R*2;j.__dirtyVertices=!0;j.__dirtyElements=!0;j.__dirtyUvs=!0;j.__dirtyNormals=!0;j.__dirtyTangents=!0;j.__dirtyColors=!0}I(n.__webglObjects,w,k)}}else if(k instanceof THREE.Ribbon){j=k.geometry;if(!j.__webGLVertexBuffer){h=j;h.__webGLVertexBuffer=c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h=j;w=h.vertices.length;h.__vertexArray=new Float32Array(w*3);h.__colorArray=
  208. new Float32Array(w*3);h.__webGLVertexCount=w;j.__dirtyVertices=!0;j.__dirtyColors=!0}I(n.__webglObjects,j,k)}else if(k instanceof THREE.Line){j=k.geometry;if(!j.__webGLVertexBuffer){h=j;h.__webGLVertexBuffer=c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h=j;w=h.vertices.length;h.__vertexArray=new Float32Array(w*3);h.__colorArray=new Float32Array(w*3);h.__webGLLineCount=w;j.__dirtyVertices=!0;j.__dirtyColors=!0}I(n.__webglObjects,j,k)}else if(k instanceof THREE.ParticleSystem){j=k.geometry;
  209. if(!j.__webGLVertexBuffer){h=j;h.__webGLVertexBuffer=c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h=j;w=h.vertices.length;h.__vertexArray=new Float32Array(w*3);h.__colorArray=new Float32Array(w*3);h.__sortArray=[];h.__webGLParticleCount=w;j.__dirtyVertices=!0;j.__dirtyColors=!0}I(n.__webglObjects,j,k)}else THREE.MarchingCubes!==undefined&&k instanceof THREE.MarchingCubes&&n.__webglObjectsImmediate.push({object:k,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,
  210. 1)}for(;f.__objectsRemoved.length;){k=f.__objectsRemoved[0];n=f;j=void 0;h=void 0;for(j=n.__webglObjects.length-1;j>=0;j--){h=n.__webglObjects[j].object;k==h&&n.__webglObjects.splice(j,1)}f.__objectsRemoved.splice(0,1)}k=0;for(n=f.__webglObjects.length;k<n;k++){h=f.__webglObjects[k].object;w=void 0;j=void 0;r=void 0;if(h instanceof THREE.Mesh){j=h.geometry;for(w in j.geometryGroups){r=j.geometryGroups[w];if(j.__dirtyVertices||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents){M=
  211. c.DYNAMIC_DRAW;R=void 0;D=void 0;var ja=void 0,y=void 0,ga=void 0,ea=void 0,ia=void 0;ja=void 0;var C=void 0,E=void 0,F=void 0,Q=void 0;C=void 0;E=void 0;F=void 0;y=void 0;C=void 0;E=void 0;F=void 0;Q=void 0;C=void 0;E=void 0;F=void 0;Q=void 0;C=void 0;E=void 0;F=void 0;Q=void 0;C=void 0;E=void 0;F=void 0;Q=void 0;C=void 0;E=void 0;F=void 0;Q=void 0;y=void 0;ea=void 0;ga=void 0;ia=void 0;var ka=K=N=L=O=z=v=t=0,Y=0,s=0,aa=r.__vertexArray,Ja=r.__uvArray,Ka=r.__uv2Array,oa=r.__normalArray,T=r.__tangentArray,
  212. ca=r.__colorArray,U=r.__skinVertexAArray,V=r.__skinVertexBArray,W=r.__skinIndexArray,X=r.__skinWeightArray,ta=r.__faceArray,la=r.__lineArray,Wa=r.__needsSmoothNormals,ha=h.geometry,Ma=ha.__dirtyVertices,Na=ha.__dirtyElements,Ea=ha.__dirtyUvs,Oa=ha.__dirtyNormals,Pa=ha.__dirtyTangents,Qa=ha.__dirtyColors,ma=ha.vertices,Xa=r.faces,Ya=ha.faces,Za=ha.uvs,$a=ha.uvs2,ua=ha.colors,ya=ha.skinVerticesA,za=ha.skinVerticesB,Aa=ha.skinIndices,wa=ha.skinWeights;R=0;for(D=Xa.length;R<D;R++){ja=Xa[R];y=Ya[ja];ia=
  213. Za[ja];ja=$a[ja];ga=y.vertexNormals;ea=y.normal;if(y instanceof THREE.Face3){if(Ma){C=ma[y.a].position;E=ma[y.b].position;F=ma[y.c].position;aa[v]=C.x;aa[v+1]=C.y;aa[v+2]=C.z;aa[v+3]=E.x;aa[v+4]=E.y;aa[v+5]=E.z;aa[v+6]=F.x;aa[v+7]=F.y;aa[v+8]=F.z;v+=9}if(wa.length){C=wa[y.a];E=wa[y.b];F=wa[y.c];X[s]=C.x;X[s+1]=C.y;X[s+2]=C.z;X[s+3]=C.w;X[s+4]=E.x;X[s+5]=E.y;X[s+6]=E.z;X[s+7]=E.w;X[s+8]=F.x;X[s+9]=F.y;X[s+10]=F.z;X[s+11]=F.w;C=Aa[y.a];E=Aa[y.b];F=Aa[y.c];W[s]=C.x;W[s+1]=C.y;W[s+2]=C.z;W[s+3]=C.w;W[s+
  214. 4]=E.x;W[s+5]=E.y;W[s+6]=E.z;W[s+7]=E.w;W[s+8]=F.x;W[s+9]=F.y;W[s+10]=F.z;W[s+11]=F.w;C=ya[y.a];E=ya[y.b];F=ya[y.c];U[s]=C.x;U[s+1]=C.y;U[s+2]=C.z;U[s+3]=1;U[s+4]=E.x;U[s+5]=E.y;U[s+6]=E.z;U[s+7]=1;U[s+8]=F.x;U[s+9]=F.y;U[s+10]=F.z;U[s+11]=1;C=za[y.a];E=za[y.b];F=za[y.c];V[s]=C.x;V[s+1]=C.y;V[s+2]=C.z;V[s+3]=1;V[s+4]=E.x;V[s+5]=E.y;V[s+6]=E.z;V[s+7]=1;V[s+8]=F.x;V[s+9]=F.y;V[s+10]=F.z;V[s+11]=1;s+=12}if(Qa&&ua.length){C=ua[y.a];E=ua[y.b];F=ua[y.c];ca[Y]=C.r;ca[Y+1]=C.g;ca[Y+2]=C.b;ca[Y+3]=E.r;ca[Y+
  215. 4]=E.g;ca[Y+5]=E.b;ca[Y+6]=F.r;ca[Y+7]=F.g;ca[Y+8]=F.b;Y+=9}if(Pa&&ha.hasTangents){C=ma[y.a].tangent;E=ma[y.b].tangent;F=ma[y.c].tangent;T[K]=C.x;T[K+1]=C.y;T[K+2]=C.z;T[K+3]=C.w;T[K+4]=E.x;T[K+5]=E.y;T[K+6]=E.z;T[K+7]=E.w;T[K+8]=F.x;T[K+9]=F.y;T[K+10]=F.z;T[K+11]=F.w;K+=12}if(Oa)if(ga.length==3&&Wa)for(y=0;y<3;y++){ea=ga[y];oa[N]=ea.x;oa[N+1]=ea.y;oa[N+2]=ea.z;N+=3}else for(y=0;y<3;y++){oa[N]=ea.x;oa[N+1]=ea.y;oa[N+2]=ea.z;N+=3}if(Ea&&ia)for(y=0;y<3;y++){ga=ia[y];Ja[z]=ga.u;Ja[z+1]=ga.v;z+=2}if(Ea&&
  216. ja)for(y=0;y<3;y++){ia=ja[y];Ka[O]=ia.u;Ka[O+1]=ia.v;O+=2}if(Na){ta[L]=t;ta[L+1]=t+1;ta[L+2]=t+2;L+=3;la[ka]=t;la[ka+1]=t+1;la[ka+2]=t;la[ka+3]=t+2;la[ka+4]=t+1;la[ka+5]=t+2;ka+=6;t+=3}}else if(y instanceof THREE.Face4){if(Ma){C=ma[y.a].position;E=ma[y.b].position;F=ma[y.c].position;Q=ma[y.d].position;aa[v]=C.x;aa[v+1]=C.y;aa[v+2]=C.z;aa[v+3]=E.x;aa[v+4]=E.y;aa[v+5]=E.z;aa[v+6]=F.x;aa[v+7]=F.y;aa[v+8]=F.z;aa[v+9]=Q.x;aa[v+10]=Q.y;aa[v+11]=Q.z;v+=12}if(wa.length){C=wa[y.a];E=wa[y.b];F=wa[y.c];Q=wa[y.d];
  217. X[s]=C.x;X[s+1]=C.y;X[s+2]=C.z;X[s+3]=C.w;X[s+4]=E.x;X[s+5]=E.y;X[s+6]=E.z;X[s+7]=E.w;X[s+8]=F.x;X[s+9]=F.y;X[s+10]=F.z;X[s+11]=F.w;X[s+12]=Q.x;X[s+13]=Q.y;X[s+14]=Q.z;X[s+15]=Q.w;C=Aa[y.a];E=Aa[y.b];F=Aa[y.c];Q=Aa[y.d];W[s]=C.x;W[s+1]=C.y;W[s+2]=C.z;W[s+3]=C.w;W[s+4]=E.x;W[s+5]=E.y;W[s+6]=E.z;W[s+7]=E.w;W[s+8]=F.x;W[s+9]=F.y;W[s+10]=F.z;W[s+11]=F.w;W[s+12]=Q.x;W[s+13]=Q.y;W[s+14]=Q.z;W[s+15]=Q.w;C=ya[y.a];E=ya[y.b];F=ya[y.c];Q=ya[y.d];U[s]=C.x;U[s+1]=C.y;U[s+2]=C.z;U[s+3]=1;U[s+4]=E.x;U[s+5]=E.y;
  218. U[s+6]=E.z;U[s+7]=1;U[s+8]=F.x;U[s+9]=F.y;U[s+10]=F.z;U[s+11]=1;U[s+12]=Q.x;U[s+13]=Q.y;U[s+14]=Q.z;U[s+15]=1;C=za[y.a];E=za[y.b];F=za[y.c];Q=za[y.d];V[s]=C.x;V[s+1]=C.y;V[s+2]=C.z;V[s+3]=1;V[s+4]=E.x;V[s+5]=E.y;V[s+6]=E.z;V[s+7]=1;V[s+8]=F.x;V[s+9]=F.y;V[s+10]=F.z;V[s+11]=1;V[s+12]=Q.x;V[s+13]=Q.y;V[s+14]=Q.z;V[s+15]=1;s+=16}if(Qa&&ua.length){C=ua[y.a];E=ua[y.b];F=ua[y.c];Q=ua[y.d];ca[Y]=C.r;ca[Y+1]=C.g;ca[Y+2]=C.b;ca[Y+3]=E.r;ca[Y+4]=E.g;ca[Y+5]=E.b;ca[Y+6]=F.r;ca[Y+7]=F.g;ca[Y+8]=F.b;ca[Y+9]=Q.r;
  219. ca[Y+10]=Q.g;ca[Y+11]=Q.b;Y+=12}if(Pa&&ha.hasTangents){C=ma[y.a].tangent;E=ma[y.b].tangent;F=ma[y.c].tangent;y=ma[y.d].tangent;T[K]=C.x;T[K+1]=C.y;T[K+2]=C.z;T[K+3]=C.w;T[K+4]=E.x;T[K+5]=E.y;T[K+6]=E.z;T[K+7]=E.w;T[K+8]=F.x;T[K+9]=F.y;T[K+10]=F.z;T[K+11]=F.w;T[K+12]=y.x;T[K+13]=y.y;T[K+14]=y.z;T[K+15]=y.w;K+=16}if(Oa)if(ga.length==4&&Wa)for(y=0;y<4;y++){ea=ga[y];oa[N]=ea.x;oa[N+1]=ea.y;oa[N+2]=ea.z;N+=3}else for(y=0;y<4;y++){oa[N]=ea.x;oa[N+1]=ea.y;oa[N+2]=ea.z;N+=3}if(Ea&&ia)for(y=0;y<4;y++){ga=
  220. ia[y];Ja[z]=ga.u;Ja[z+1]=ga.v;z+=2}if(Ea&&ja)for(y=0;y<4;y++){ia=ja[y];Ka[O]=ia.u;Ka[O+1]=ia.v;O+=2}if(Na){ta[L]=t;ta[L+1]=t+1;ta[L+2]=t+2;ta[L+3]=t;ta[L+4]=t+2;ta[L+5]=t+3;L+=6;la[ka]=t;la[ka+1]=t+1;la[ka+2]=t;la[ka+3]=t+3;la[ka+4]=t+1;la[ka+5]=t+2;la[ka+6]=t+2;la[ka+7]=t+3;ka+=8;t+=4}}}if(Ma){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,aa,M)}if(Qa&&ua.length){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,ca,M)}if(Oa){c.bindBuffer(c.ARRAY_BUFFER,
  221. r.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,oa,M)}if(Pa&&ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,T,M)}if(Ea&&z>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ja,M)}if(Ea&&O>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ka,M)}if(Na){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ta,M);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);
  222. c.bufferData(c.ELEMENT_ARRAY_BUFFER,la,M)}if(s>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,U,M);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,V,M);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,W,M);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,X,M)}}}j.__dirtyVertices=!1;j.__dirtyElements=!1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=
  223. !1;j.__dirtyColors=!1}else if(h instanceof THREE.Ribbon){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;w=c.DYNAMIC_DRAW;t=void 0;t=void 0;v=void 0;r=void 0;z=h.vertices;M=h.colors;O=z.length;R=M.length;L=h.__vertexArray;D=h.__colorArray;N=h.__dirtyColors;if(h.__dirtyVertices){for(t=0;t<O;t++){v=z[t].position;r=t*3;L[r]=v.x;L[r+1]=v.y;L[r+2]=v.z}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,L,w)}if(N){for(t=0;t<R;t++){color=M[t];r=t*3;D[r]=color.r;D[r+1]=
  224. color.g;D[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,D,w)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(h instanceof THREE.Line){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;w=c.DYNAMIC_DRAW;t=void 0;t=void 0;v=void 0;r=void 0;z=h.vertices;M=h.colors;O=z.length;R=M.length;L=h.__vertexArray;D=h.__colorArray;N=h.__dirtyColors;if(h.__dirtyVertices){for(t=0;t<O;t++){v=z[t].position;r=t*3;L[r]=v.x;L[r+1]=v.y;L[r+2]=v.z}c.bindBuffer(c.ARRAY_BUFFER,
  225. h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,L,w)}if(N){for(t=0;t<R;t++){color=M[t];r=t*3;D[r]=color.r;D[r+1]=color.g;D[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,D,w)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(h instanceof THREE.ParticleSystem){j=h.geometry;(j.__dirtyVertices||j.__dirtyColors||h.sortParticles)&&b(j,c.DYNAMIC_DRAW,h);j.__dirtyVertices=!1;j.__dirtyColors=!1}}};this.setFaceCulling=function(f,k){if(f){!k||k=="ccw"?c.frontFace(c.CCW):
  226. c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};