ThreeWebGL.js 118 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. // ThreeWebGL.js r36 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
  3. THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,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,f,h,i,p,n;if(d==0)e=f=h=0;else{i=Math.floor(a*6);p=a*6-i;a=d*(1-b);n=d*(1-b*p);b=d*(1-b*(1-p));switch(i){case 1:e=n;f=d;h=a;break;case 2:e=a;f=d;h=b;break;case 3:e=a;f=n;h=d;break;case 4:e=b;f=a;h=d;break;case 5:e=d;f=a;h=n;break;case 6:case 0:e=d;f=b;h=a}}this.r=e;this.g=f;this.b=h;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,f=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(d)))}f.sort(function(h,i){return h.distance-i.distance});return f},intersectObject:function(a){function b(J,y,ja,V){V=V.clone().subSelf(y);ja=ja.clone().subSelf(y);var ka=J.clone().subSelf(y);J=V.dot(V);y=V.dot(ja);V=V.dot(ka);var ia=ja.dot(ja);ja=ja.dot(ka);ka=1/(J*ia-y*y);ia=(ia*V-y*ja)*ka;J=(J*ja-y*V)*ka;return ia>0&&J>0&&ia+J<1}var d,
  16. e,f,h,i,p,n,w,A,B,C,z=a.geometry,M=z.vertices,K=[];d=0;for(e=z.faces.length;d<e;d++){f=z.faces[d];B=this.origin.clone();C=this.direction.clone();n=a.matrixWorld;h=n.multiplyVector3(M[f.a].position.clone());i=n.multiplyVector3(M[f.b].position.clone());p=n.multiplyVector3(M[f.c].position.clone());n=f instanceof THREE.Face4?n.multiplyVector3(M[f.d].position.clone()):null;w=a.matrixRotationWorld.multiplyVector3(f.normal.clone());A=C.dot(w);if(A<0){w=w.dot((new THREE.Vector3).sub(h,B))/A;B=B.addSelf(C.multiplyScalar(w));
  17. if(f instanceof THREE.Face3){if(b(B,h,i,p)){f={distance:this.origin.distanceTo(B),point:B,face:f,object:a};K.push(f)}}else if(f instanceof THREE.Face4&&(b(B,h,i,n)||b(B,i,p,n))){f={distance:this.origin.distanceTo(B),point:B,face:f,object:a};K.push(f)}}}return K}};
  18. THREE.Rectangle=function(){function a(){h=e-b;i=f-d}var b,d,e,f,h,i,p=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(n,w,A,B){p=!1;b=n;d=w;e=A;f=B;a()};this.addPoint=function(n,w){if(p){p=!1;b=n;d=w;e=n;f=w}else{b=b<n?b:n;d=d<w?d:w;e=e>n?e:n;f=f>w?f:w}a()};
  19. this.add3Points=function(n,w,A,B,C,z){if(p){p=!1;b=n<A?n<C?n:C:A<C?A:C;d=w<B?w<z?w:z:B<z?B:z;e=n>A?n>C?n:C:A>C?A:C;f=w>B?w>z?w:z:B>z?B:z}else{b=n<A?n<C?n<b?n:b:C<b?C:b:A<C?A<b?A:b:C<b?C:b;d=w<B?w<z?w<d?w:d:z<d?z:d:B<z?B<d?B:d:z<d?z:d;e=n>A?n>C?n>e?n:e:C>e?C:e:A>C?A>e?A:e:C>e?C:e;f=w>B?w>z?w>f?w:f:z>f?z:f:B>z?B>f?B:f:z>f?z:f}a()};this.addRectangle=function(n){if(p){p=!1;b=n.getLeft();d=n.getTop();e=n.getRight();f=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();d=d<n.getTop()?d:n.getTop();e=e>n.getRight()?
  20. e:n.getRight();f=f>n.getBottom()?f:n.getBottom()}a()};this.inflate=function(n){b-=n;d-=n;e+=n;f+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();d=d>n.getTop()?d:n.getTop();e=e<n.getRight()?e:n.getRight();f=f<n.getBottom()?f:n.getBottom();a()};this.instersects=function(n){return Math.min(e,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(f,n.getBottom())-Math.max(d,n.getTop())>=0};this.empty=function(){p=!0;f=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,f,h,i,p,n,w,A,B,C,z,M,K){this.set(a||1,b||0,d||0,e||0,f||0,h||1,i||0,p||0,n||0,w||0,A||1,B||0,C||0,z||0,M||0,K||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
  23. THREE.Matrix4.prototype={set:function(a,b,d,e,f,h,i,p,n,w,A,B,C,z,M,K){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=h;this.n23=i;this.n24=p;this.n31=n;this.n32=w;this.n33=A;this.n34=B;this.n41=C;this.n42=z;this.n43=M;this.n44=K;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. f=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;e.cross(d,h).normalize();if(e.length()===0){h.x+=1.0E-4;e.cross(d,h).normalize()}f.cross(h,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=h.x;this.n21=e.y;this.n22=f.y;this.n23=h.y;this.n31=e.z;this.n32=f.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=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)*f;a.y=(this.n21*b+this.n22*d+this.n23*
  25. e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;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,f=a.n13,h=a.n14,i=a.n21,p=a.n22,n=a.n23,w=a.n24,A=a.n31,B=a.n32,C=a.n33,z=a.n34,M=a.n41,K=a.n42,J=a.n43,y=a.n44,ja=b.n11,V=b.n12,ka=b.n13,ia=b.n14,la=b.n21,Q=b.n22,
  27. c=b.n23,ma=b.n24,Z=b.n31,oa=b.n32,$=b.n33,U=b.n34;this.n11=d*ja+e*la+f*Z;this.n12=d*V+e*Q+f*oa;this.n13=d*ka+e*c+f*$;this.n14=d*ia+e*ma+f*U+h;this.n21=i*ja+p*la+n*Z;this.n22=i*V+p*Q+n*oa;this.n23=i*ka+p*c+n*$;this.n24=i*ia+p*ma+n*U+w;this.n31=A*ja+B*la+C*Z;this.n32=A*V+B*Q+C*oa;this.n33=A*ka+B*c+C*$;this.n34=A*ia+B*ma+C*U+z;this.n41=M*ja+K*la+J*Z;this.n42=M*V+K*Q+J*oa;this.n43=M*ka+K*c+J*$;this.n44=M*ia+K*ma+J*U+y;return this},multiplyToArray:function(a,b,d){this.multiply(a,b);d[0]=this.n11;d[1]=
  28. 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,f=this.n21,h=this.n22,i=this.n23,p=this.n24,n=this.n31,w=this.n32,A=this.n33,B=this.n34,C=this.n41,z=this.n42,M=this.n43,K=this.n44;return e*i*w*C-d*p*w*C-e*h*A*C+b*p*A*C+d*h*B*C-b*i*B*C-e*i*n*z+d*p*n*z+e*f*A*z-a*p*A*z-d*f*B*z+a*i*B*z+e*h*n*M-b*p*n*M-e*f*w*M+a*p*w*M+b*f*B*M-a*h*B*M-d*h*n*K+b*i*n*K+d*f*w*K-a*i*w*K-b*f*A*K+a*h*A*K},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),f=
  34. 1-d,h=a.x,i=a.y,p=a.z,n=f*h,w=f*i;this.set(n*h+d,n*i-e*p,n*p+e*i,0,n*i+e*p,w*i+d,w*p-e*h,0,n*p-e*i,w*p+e*h,f*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 f=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);var i=a*d,p=b*d;this.n11=f*h;this.n12=-f*e;this.n13=d;this.n21=p*h+a*e;this.n22=-p*e+a*h;this.n23=-b*f;this.n31=-i*h+b*e;this.n32=i*e+b*h;this.n33=
  35. a*f;return this},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,e=a.z,f=a.w,h=b+b,i=d+d,p=e+e;a=b*h;var n=b*i;b*=p;var w=d*i;d*=p;e*=p;h*=f;i*=f;f*=p;this.n11=1-(w+e);this.n12=n-f;this.n13=b+i;this.n21=n+f;this.n22=1-(a+e);this.n23=d-h;this.n31=b-i;this.n32=d+h;this.n33=1-(a+w);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,f=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*f;this.n23=a.n23*f;this.n33=a.n33*f}};
  37. THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,i=a.n21,p=a.n22,n=a.n23,w=a.n24,A=a.n31,B=a.n32,C=a.n33,z=a.n34,M=a.n41,K=a.n42,J=a.n43,y=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=n*z*K-w*C*K+w*B*J-p*z*J-n*B*y+p*C*y;b.n12=h*C*K-f*z*K-h*B*J+e*z*J+f*B*y-e*C*y;b.n13=f*w*K-h*n*K+h*p*J-e*w*J-f*p*y+e*n*y;b.n14=h*n*B-f*w*B-h*p*C+e*w*C+f*p*z-e*n*z;b.n21=w*C*M-n*z*M-w*A*J+i*z*J+n*A*y-i*C*y;b.n22=f*z*M-h*C*M+h*A*J-d*z*J-f*A*y+d*C*y;b.n23=h*n*M-f*w*M-h*i*J+d*w*J+f*i*y-d*n*y;
  38. b.n24=f*w*A-h*n*A+h*i*C-d*w*C-f*i*z+d*n*z;b.n31=p*z*M-w*B*M+w*A*K-i*z*K-p*A*y+i*B*y;b.n32=h*B*M-e*z*M-h*A*K+d*z*K+e*A*y-d*B*y;b.n33=f*w*M-h*p*M+h*i*K-d*w*K-e*i*y+d*p*y;b.n34=h*p*A-e*w*A-h*i*B+d*w*B+e*i*z-d*p*z;b.n41=n*B*M-p*C*M-n*A*K+i*C*K+p*A*J-i*B*J;b.n42=e*C*M-f*B*M+f*A*K-d*C*K-e*A*J+d*B*J;b.n43=f*p*M-e*n*M-f*i*K+d*n*K+e*i*J-d*p*J;b.n44=e*n*A-f*p*A+f*i*B-d*n*B-e*i*C+d*p*C;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,f=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,w=a.n23*a.n12-a.n22*a.n13,A=-a.n23*a.n11+a.n21*a.n13,B=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*i+a.n31*w;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*f;d[2]=a*h;d[3]=a*i;d[4]=a*p;d[5]=a*n;d[6]=a*w;d[7]=a*A;d[8]=a*B;return b};
  40. THREE.Matrix4.makeFrustum=function(a,b,d,e,f,h){var i;i=new THREE.Matrix4;i.n11=2*f/(b-a);i.n12=0;i.n13=(b+a)/(b-a);i.n14=0;i.n21=0;i.n22=2*f/(e-d);i.n23=(e+d)/(e-d);i.n24=0;i.n31=0;i.n32=0;i.n33=-(h+f)/(h-f);i.n34=-2*h*f/(h-f);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)};
  41. THREE.Matrix4.makeOrtho=function(a,b,d,e,f,h){var i,p,n,w;i=new THREE.Matrix4;p=b-a;n=d-e;w=h-f;i.n11=2/p;i.n12=0;i.n13=0;i.n14=-((b+a)/p);i.n21=0;i.n22=2/n;i.n23=0;i.n24=-((d+e)/n);i.n31=0;i.n32=0;i.n33=-2/w;i.n34=-((h+f)/w);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};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))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,d){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){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,f=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-f);f=Math.sin(-f);var h=Math.cos(d);d=Math.sin(d);var i=a*b,p=e*f;this.w=i*h-p*d;this.x=i*d+p*h;this.y=e*b*h+a*f*d;this.z=a*f*h-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,f=this.w,h=a.x,i=a.y,p=a.z;a=a.w;this.x=b*a+f*h+d*p-e*i;this.y=d*a+f*i+e*h-b*p;this.z=e*a+f*p+b*i-d*h;this.w=f*a-b*h-d*i-e*p;return this},
  50. multiplyVector3:function(a,b){b||(b=a);var d=a.x,e=a.y,f=a.z,h=this.x,i=this.y,p=this.z,n=this.w,w=n*d+i*f-p*e,A=n*e+p*d-h*f,B=n*f+h*e-i*d;d=-h*d-i*e-p*f;b.x=w*n+d*-h+A*-p-B*-i;b.y=A*n+d*-i+B*-h-w*-p;b.z=B*n+d*-p+w*-i-A*-h;return b}};
  51. THREE.Quaternion.slerp=function(a,b,d,e){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var h=Math.acos(f),i=Math.sqrt(1-f*f);if(Math.abs(i)<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}f=Math.sin((1-e)*h)/i;e=Math.sin(e*h)/i;d.w=a.w*f+b.w*e;d.x=a.x*f+b.x*e;d.y=a.y*f+b.y*e;d.z=a.z*f+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,f,h){this.a=a;this.b=b;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
  54. THREE.Face4=function(a,b,d,e,f,h,i){this.a=a;this.b=b;this.c=d;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};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}};
  55. THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[];this.faceVertexUvs=[];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
  56. 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);
  57. d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,h,i,p=new THREE.Vector3,n=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){h=this.vertices[e];h.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];if(a&&h.vertexNormals.length){p.set(0,0,0);b=0;for(d=h.vertexNormals.length;b<d;b++)p.addSelf(h.vertexNormals[b]);p.divideScalar(3)}else{b=this.vertices[h.a];d=this.vertices[h.b];i=this.vertices[h.c];p.sub(i.position,
  58. d.position);n.sub(b.position,d.position);p.crossSelf(n)}p.isZero()||p.normalize();h.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,
  59. 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<
  60. 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(U,R,Da,N,na,ya,S){h=U.vertices[R].position;i=U.vertices[Da].position;p=U.vertices[N].position;n=f[na];w=f[ya];A=f[S];B=i.x-h.x;C=p.x-h.x;z=i.y-h.y;M=p.y-
  61. h.y;K=i.z-h.z;J=p.z-h.z;y=w.u-n.u;ja=A.u-n.u;V=w.v-n.v;ka=A.v-n.v;ia=1/(y*ka-ja*V);c.set((ka*B-V*C)*ia,(ka*z-V*M)*ia,(ka*K-V*J)*ia);ma.set((y*C-ja*B)*ia,(y*M-ja*z)*ia,(y*J-ja*K)*ia);la[R].addSelf(c);la[Da].addSelf(c);la[N].addSelf(c);Q[R].addSelf(ma);Q[Da].addSelf(ma);Q[N].addSelf(ma)}var b,d,e,f,h,i,p,n,w,A,B,C,z,M,K,J,y,ja,V,ka,ia,la=[],Q=[],c=new THREE.Vector3,ma=new THREE.Vector3,Z=new THREE.Vector3,oa=new THREE.Vector3,$=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){la[b]=new THREE.Vector3;
  62. Q[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];f=this.faceVertexUvs[b][0];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]);
  63. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){$.copy(this.vertices[b].normal);e=la[b];Z.copy(e);Z.subSelf($.multiplyScalar($.dot(e))).normalize();oa.cross(this.vertices[b].normal,e);e=oa.dot(Q[b]);e=e<0?-1:1;this.vertices[b].tangent.set(Z.x,Z.y,Z.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],
  64. 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>
  65. 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;
  66. THREE.AnimationHandler=function(){var a=[],b={},d={};d.update=function(f){for(var h=0;h<a.length;h++)a[h].update(f)};d.addToUpdate=function(f){a.indexOf(f)===-1&&a.push(f)};d.removeFromUpdate=function(f){f=a.indexOf(f);f!==-1&&a.splice(f,1)};d.add=function(f){b[f.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+f.name+" already exists in library. Overwriting.");b[f.name]=f;if(f.initialized!==!0){for(var h=0;h<f.hierarchy.length;h++){for(var i=0;i<f.hierarchy[h].keys.length;i++){if(f.hierarchy[h].keys[i].time<
  67. 0)f.hierarchy[h].keys[i].time=0;if(f.hierarchy[h].keys[i].rot!==undefined&&!(f.hierarchy[h].keys[i].rot instanceof THREE.Quaternion)){var p=f.hierarchy[h].keys[i].rot;f.hierarchy[h].keys[i].rot=new THREE.Quaternion(p[0],p[1],p[2],p[3])}}if(f.hierarchy[h].keys[0].morphTargets!==undefined){p={};for(i=0;i<f.hierarchy[h].keys.length;i++)for(var n=0;n<f.hierarchy[h].keys[i].morphTargets.length;n++){var w=f.hierarchy[h].keys[i].morphTargets[n];p[w]=-1}f.hierarchy[h].usedMorphTargets=p;for(i=0;i<f.hierarchy[h].keys.length;i++){var A=
  68. {};for(w in p){for(n=0;n<f.hierarchy[h].keys[i].morphTargets.length;n++)if(f.hierarchy[h].keys[i].morphTargets[n]===w){A[w]=f.hierarchy[h].keys[i].morphTargetsInfluences[n];break}n===f.hierarchy[h].keys[i].morphTargets.length&&(A[w]=0)}f.hierarchy[h].keys[i].morphTargetsInfluences=A}}for(i=1;i<f.hierarchy[h].keys.length;i++)if(f.hierarchy[h].keys[i].time===f.hierarchy[h].keys[i-1].time){f.hierarchy[h].keys.splice(i,1);i--}for(i=1;i<f.hierarchy[h].keys.length;i++)f.hierarchy[h].keys[i].index=i}i=parseInt(f.length*
  69. f.fps,10);f.JIT={};f.JIT.hierarchy=[];for(h=0;h<f.hierarchy.length;h++)f.JIT.hierarchy.push(Array(i));f.initialized=!0}};d.get=function(f){if(typeof f==="string")if(b[f])return b[f];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+f);return null}};d.parse=function(f){var h=[];if(f instanceof THREE.SkinnedMesh)for(var i=0;i<f.bones.length;i++)h.push(f.bones[i]);else e(f,h);return h};var e=function(f,h){h.push(f);for(var i=0;i<f.children.length;i++)e(f.children[i],h)};d.LINEAR=
  70. 0;d.CATMULLROM=1;d.CATMULLROM_FORWARD=2;return d}();THREE.Animation=function(a,b,d,e){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=d!==undefined?d:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
  71. THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=b!==undefined?b:0;var d,e=this.hierarchy.length,f;for(d=0;d<e;d++){f=this.hierarchy[d];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=!0;f.matrixAutoUpdate=!0;if(f.animationCache===undefined){f.animationCache={};f.animationCache.prevKey={pos:0,rot:0,scl:0};f.animationCache.nextKey={pos:0,rot:0,scl:0};f.animationCache.originalMatrix=
  72. f instanceof THREE.Bone?f.skinMatrix:f.matrix}var h=f.animationCache.prevKey;f=f.animationCache.nextKey;h.pos=this.data.hierarchy[d].keys[0];h.rot=this.data.hierarchy[d].keys[0];h.scl=this.data.hierarchy[d].keys[0];f.pos=this.getNextKeyWith("pos",d,1);f.rot=this.getNextKeyWith("rot",d,1);f.scl=this.getNextKeyWith("scl",d,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
  73. THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
  74. THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
  75. THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],d,e,f,h,i,p,n,w,A=this.data.JIT.hierarchy,B,C;this.currentTime+=a*this.timeScale;C=this.currentTime;B=this.currentTime%=this.data.length;w=parseInt(Math.min(B*this.data.fps,this.data.length*this.data.fps),10);for(var z=0,M=this.hierarchy.length;z<M;z++){a=this.hierarchy[z];n=a.animationCache;if(this.JITCompile&&A[z][w]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=A[z][w];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
  76. !1}else{a.matrix=A[z][w];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var K=0;K<3;K++){d=b[K];i=n.prevKey[d];p=n.nextKey[d];if(p.time<=C){if(B<C)if(this.loop){i=this.data.hierarchy[z].keys[0];for(p=this.getNextKeyWith(d,z,1);p.time<B;){i=p;p=this.getNextKeyWith(d,z,p.index+1)}}else{this.stop();return}else{do{i=p;p=this.getNextKeyWith(d,z,p.index+1)}while(p.time<
  77. B)}n.prevKey[d]=i;n.nextKey[d]=p}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(B-i.time)/(p.time-i.time);f=i[d];h=p[d];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+z);e=e<0?0:1}if(d==="pos"){d=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){d.x=f[0]+(h[0]-f[0])*e;d.y=f[1]+(h[1]-f[1])*e;d.z=f[2]+(h[2]-f[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
  78. this.getPrevKeyWith("pos",z,i.index-1).pos;this.points[1]=f;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",z,p.index+1).pos;e=e*0.33+0.33;f=this.interpolateCatmullRom(this.points,e);d.x=f[0];d.y=f[1];d.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(d);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(d===
  79. "rot")THREE.Quaternion.slerp(f,h,a.quaternion,e);else if(d==="scl"){d=a.scale;d.x=f[0]+(h[0]-f[0])*e;d.y=f[1]+(h[1]-f[1])*e;d.z=f[2]+(h[2]-f[2])*e}}}}if(this.JITCompile&&A[0][w]===undefined){this.hierarchy[0].update(undefined,!0);for(z=0;z<this.hierarchy.length;z++)A[z][w]=this.hierarchy[z]instanceof THREE.Bone?this.hierarchy[z].skinMatrix.clone():this.hierarchy[z].matrix.clone()}}};
  80. THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var d=[],e=[],f,h,i,p,n,w;f=(a.length-1)*b;h=Math.floor(f);f-=h;d[0]=h==0?h:h-1;d[1]=h;d[2]=h>a.length-2?h:h+1;d[3]=h>a.length-3?h:h+2;h=a[d[0]];p=a[d[1]];n=a[d[2]];w=a[d[3]];d=f*f;i=f*d;e[0]=this.interpolate(h[0],p[0],n[0],w[0],f,d,i);e[1]=this.interpolate(h[1],p[1],n[1],w[1],f,d,i);e[2]=this.interpolate(h[2],p[2],n[2],w[2],f,d,i);return e};
  81. THREE.Animation.prototype.interpolate=function(a,b,d,e,f,h,i){a=(d-a)*0.5;e=(e-b)*0.5;return(2*(b-d)+a+e)*i+(-3*(b-d)-2*a-e)*h+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,d){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=d<e.length-1?d:e.length-1;else d%=e.length;for(;d<e.length;d++)if(e[d][a]!==undefined)return e[d];return this.data.hierarchy[b].keys[0]};
  82. THREE.Animation.prototype.getPrevKeyWith=function(a,b,d){var e=this.data.hierarchy[b].keys;for(d=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d>0?d:0:d>=0?d:d+e.length;d>=0;d--)if(e[d][a]!==undefined)return e[d];return this.data.hierarchy[b].keys[e.length-1]};
  83. THREE.Camera=function(a,b,d,e,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=d||0.1;this.far=e||2E3;this.target=f||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;
  84. 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)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
  85. 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=
  86. !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)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
  87. 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;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;
  88. THREE.FlatShading=0;THREE.SmoothShading=1;THREE.MaterialColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};
  89. THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
  90. 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=
  91. 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}};
  92. THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;
  93. if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;
  94. if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;
  95. if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  96. THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=
  97. !1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.envMap!==undefined)this.envMap=a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;
  98. if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;
  99. if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  100. 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=
  101. this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.lightMap!==undefined)this.lightMap=a.lightMap;if(a.map!==undefined)this.map=a.map;if(a.envMap!==undefined)this.envMap=
  102. a.envMap;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refractionRatio!==undefined)this.refractionRatio=a.refractionRatio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;
  103. if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  104. 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!==
  105. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
  106. 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!==
  107. undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
  108. THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=!1;this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==
  109. undefined)this.vertexShader=a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;
  110. if(a.wireframeLinejoin!==undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.lights!==undefined)this.lights=a.lights;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
  111. 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=
  112. 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}};
  113. THREE.Texture=function(a,b,d,e,f,h){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=f!==undefined?f:THREE.LinearFilter;this.minFilter=h!==undefined?h: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)}};
  114. 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;
  115. THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
  116. 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};
  117. var Uniforms={clone:function(a){var b,d,e,f={};for(b in a){f[b]={};for(d in a[b]){e=a[b][d];f[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return f},merge:function(a){var b,d,e,f={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)f[d]=e[d]}return f}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
  118. 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;
  119. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  120. 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;if(this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var d=0;d<this.geometry.morphTargets.length;d++){this.morphTargetInfluences.push(0);
  121. this.morphTargetDictionary[this.geometry.morphTargets[d].name]=d}}}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==undefined)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
  122. THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  123. THREE.Bone.prototype.update=function(a,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,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<f;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<f;e++)this.children[e].update(this.skinMatrix,
  124. 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;
  125. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,f,h,i,p;if(this.geometry.bones!==undefined){for(d=0;d<this.geometry.bones.length;d++){f=this.geometry.bones[d];h=f.pos;i=f.rotq;p=f.scl;e=this.addBone();e.name=f.name;e.position.set(h[0],h[1],h[2]);e.quaternion.set(i[0],i[1],i[2],i[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++){f=this.geometry.bones[d];
  126. e=this.bones[d];f.parent===-1?this.addChild(e):this.bones[f.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;
  127. 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,f=this.children.length;for(e=0;e<f;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,
  128. b*16)}};THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  129. THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,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 f=this.geometry.skinIndices[a].x,h=this.geometry.skinIndices[a].y;
  130. e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesA.push(b[f].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(b[h].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}}}};
  131. 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;
  132. 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 f;d=this.sources.length;for(a=0;a<d;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)f=
  133. "audio/mpeg";else if(b.indexOf(".ogg")!==-1)f="audio/ogg";else b.indexOf(".wav")!==-1&&(f="audio/wav");if(this.domElement.canPlayType(f)){f=document.createElement("source");f.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(f);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
  134. THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
  135. THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
  136. THREE.Sound.prototype.update=function(a,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;
  137. 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)};
  138. 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=
  139. !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;
  140. THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
  141. THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var 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])};
  142. THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,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};
  143. THREE.Projector=function(){function a(Q,c){return c.z-Q.z}function b(Q,c){var ma=0,Z=1,oa=Q.z+Q.w,$=c.z+c.w,U=-Q.z+Q.w,R=-c.z+c.w;if(oa>=0&&$>=0&&U>=0&&R>=0)return!0;else if(oa<0&&$<0||U<0&&R<0)return!1;else{if(oa<0)ma=Math.max(ma,oa/(oa-$));else $<0&&(Z=Math.min(Z,oa/(oa-$)));if(U<0)ma=Math.max(ma,U/(U-R));else R<0&&(Z=Math.min(Z,U/(U-R)));if(Z<ma)return!1;else{Q.lerpSelf(c,ma);c.lerpSelf(Q,1-Z);return!0}}}var d,e,f=[],h,i,p,n=[],w,A,B=[],C,z,M=[],K=new THREE.Vector4,J=new THREE.Vector4,y=new THREE.Matrix4,
  144. ja=new THREE.Matrix4,V=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ka=new THREE.Vector4,ia=new THREE.Vector4,la;this.projectObjects=function(Q,c,ma){c=[];var Z,oa,$;e=0;oa=Q.objects;Q=0;for(Z=oa.length;Q<Z;Q++){$=oa[Q];var U;if(!(U=!$.visible))if(U=$ instanceof THREE.Mesh){a:{U=void 0;for(var R=$.matrixWorld,Da=-$.geometry.boundingSphere.radius*Math.max($.scale.x,Math.max($.scale.y,$.scale.z)),N=0;N<6;N++){U=V[N].x*R.n14+V[N].y*R.n24+
  145. V[N].z*R.n34+V[N].w;if(U<=Da){U=!1;break a}}U=!0}U=!U}if(!U){d=f[e]=f[e]||new THREE.RenderableObject;K.copy($.position);y.multiplyVector3(K);d.object=$;d.z=K.z;c.push(d);e++}}ma&&c.sort(a);return c};this.projectScene=function(Q,c,ma){var Z=[],oa=c.near,$=c.far,U,R,Da,N,na,ya,S,za,Ka,Pa,Oa,Ha,xa,Y,ua,Ba;p=A=z=0;c.matrixAutoUpdate&&c.updateMatrix();Q.update(undefined,!1,c);y.multiply(c.projectionMatrix,c.matrixWorldInverse);V[0].set(y.n41-y.n11,y.n42-y.n12,y.n43-y.n13,y.n44-y.n14);V[1].set(y.n41+y.n11,
  146. y.n42+y.n12,y.n43+y.n13,y.n44+y.n14);V[2].set(y.n41+y.n21,y.n42+y.n22,y.n43+y.n23,y.n44+y.n24);V[3].set(y.n41-y.n21,y.n42-y.n22,y.n43-y.n23,y.n44-y.n24);V[4].set(y.n41-y.n31,y.n42-y.n32,y.n43-y.n33,y.n44-y.n34);V[5].set(y.n41+y.n31,y.n42+y.n32,y.n43+y.n33,y.n44+y.n34);for(U=0;U<6;U++){ya=V[U];ya.divideScalar(Math.sqrt(ya.x*ya.x+ya.y*ya.y+ya.z*ya.z))}ya=this.projectObjects(Q,c,!0);Q=0;for(U=ya.length;Q<U;Q++){S=ya[Q].object;if(S.visible){za=S.matrixWorld;Oa=S.matrixRotationWorld;Ka=S.materials;Pa=
  147. S.overdraw;if(S instanceof THREE.Mesh){Ha=S.geometry;xa=Ha.vertices;R=0;for(Da=xa.length;R<Da;R++){Y=xa[R];Y.positionWorld.copy(Y.position);za.multiplyVector3(Y.positionWorld);N=Y.positionScreen;N.copy(Y.positionWorld);y.multiplyVector4(N);N.x/=N.w;N.y/=N.w;Y.__visible=N.z>oa&&N.z<$}Ha=Ha.faces;R=0;for(Da=Ha.length;R<Da;R++){Y=Ha[R];if(Y instanceof THREE.Face3){N=xa[Y.a];na=xa[Y.b];ua=xa[Y.c];if(N.__visible&&na.__visible&&ua.__visible&&(S.doubleSided||S.flipSided!=(ua.positionScreen.x-N.positionScreen.x)*
  148. (na.positionScreen.y-N.positionScreen.y)-(ua.positionScreen.y-N.positionScreen.y)*(na.positionScreen.x-N.positionScreen.x)<0)){h=n[p]=n[p]||new THREE.RenderableFace3;h.v1.positionWorld.copy(N.positionWorld);h.v2.positionWorld.copy(na.positionWorld);h.v3.positionWorld.copy(ua.positionWorld);h.v1.positionScreen.copy(N.positionScreen);h.v2.positionScreen.copy(na.positionScreen);h.v3.positionScreen.copy(ua.positionScreen);h.normalWorld.copy(Y.normal);Oa.multiplyVector3(h.normalWorld);h.centroidWorld.copy(Y.centroid);
  149. za.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);y.multiplyVector3(h.centroidScreen);ua=Y.vertexNormals;la=h.vertexNormalsWorld;N=0;for(na=ua.length;N<na;N++){Ba=la[N]=la[N]||new THREE.Vector3;Ba.copy(ua[N]);Oa.multiplyVector3(Ba)}h.z=h.centroidScreen.z;h.meshMaterials=Ka;h.faceMaterials=Y.materials;h.overdraw=Pa;if(S.geometry.uvs[R]){h.uvs[0]=S.geometry.uvs[R][0];h.uvs[1]=S.geometry.uvs[R][1];h.uvs[2]=S.geometry.uvs[R][2]}Z.push(h);p++}}else if(Y instanceof THREE.Face4){N=
  150. xa[Y.a];na=xa[Y.b];ua=xa[Y.c];Ba=xa[Y.d];if(N.__visible&&na.__visible&&ua.__visible&&Ba.__visible&&(S.doubleSided||S.flipSided!=((Ba.positionScreen.x-N.positionScreen.x)*(na.positionScreen.y-N.positionScreen.y)-(Ba.positionScreen.y-N.positionScreen.y)*(na.positionScreen.x-N.positionScreen.x)<0||(na.positionScreen.x-ua.positionScreen.x)*(Ba.positionScreen.y-ua.positionScreen.y)-(na.positionScreen.y-ua.positionScreen.y)*(Ba.positionScreen.x-ua.positionScreen.x)<0))){h=n[p]=n[p]||new THREE.RenderableFace3;
  151. h.v1.positionWorld.copy(N.positionWorld);h.v2.positionWorld.copy(na.positionWorld);h.v3.positionWorld.copy(Ba.positionWorld);h.v1.positionScreen.copy(N.positionScreen);h.v2.positionScreen.copy(na.positionScreen);h.v3.positionScreen.copy(Ba.positionScreen);h.normalWorld.copy(Y.normal);Oa.multiplyVector3(h.normalWorld);h.centroidWorld.copy(Y.centroid);za.multiplyVector3(h.centroidWorld);h.centroidScreen.copy(h.centroidWorld);y.multiplyVector3(h.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=
  152. Ka;h.faceMaterials=Y.materials;h.overdraw=Pa;if(S.geometry.uvs[R]){h.uvs[0]=S.geometry.uvs[R][0];h.uvs[1]=S.geometry.uvs[R][1];h.uvs[2]=S.geometry.uvs[R][3]}Z.push(h);p++;i=n[p]=n[p]||new THREE.RenderableFace3;i.v1.positionWorld.copy(na.positionWorld);i.v2.positionWorld.copy(ua.positionWorld);i.v3.positionWorld.copy(Ba.positionWorld);i.v1.positionScreen.copy(na.positionScreen);i.v2.positionScreen.copy(ua.positionScreen);i.v3.positionScreen.copy(Ba.positionScreen);i.normalWorld.copy(h.normalWorld);
  153. i.centroidWorld.copy(h.centroidWorld);i.centroidScreen.copy(h.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=Ka;i.faceMaterials=Y.materials;i.overdraw=Pa;if(S.geometry.uvs[R]){i.uvs[0]=S.geometry.uvs[R][1];i.uvs[1]=S.geometry.uvs[R][2];i.uvs[2]=S.geometry.uvs[R][3]}Z.push(i);p++}}}}else if(S instanceof THREE.Line){ja.multiply(y,za);xa=S.geometry.vertices;Y=xa[0];Y.positionScreen.copy(Y.position);ja.multiplyVector4(Y.positionScreen);R=1;for(Da=xa.length;R<Da;R++){N=xa[R];N.positionScreen.copy(N.position);
  154. ja.multiplyVector4(N.positionScreen);na=xa[R-1];ka.copy(N.positionScreen);ia.copy(na.positionScreen);if(b(ka,ia)){ka.multiplyScalar(1/ka.w);ia.multiplyScalar(1/ia.w);w=B[A]=B[A]||new THREE.RenderableLine;w.v1.positionScreen.copy(ka);w.v2.positionScreen.copy(ia);w.z=Math.max(ka.z,ia.z);w.materials=S.materials;Z.push(w);A++}}}else if(S instanceof THREE.Particle){J.set(S.position.x,S.position.y,S.position.z,1);y.multiplyVector4(J);J.z/=J.w;if(J.z>0&&J.z<1){C=M[z]=M[z]||new THREE.RenderableParticle;C.x=
  155. J.x/J.w;C.y=J.y/J.w;C.z=J.z;C.rotation=S.rotation.z;C.scale.x=S.scale.x*Math.abs(C.x-(J.x+c.projectionMatrix.n11)/(J.w+c.projectionMatrix.n14));C.scale.y=S.scale.y*Math.abs(C.y-(J.y+c.projectionMatrix.n22)/(J.w+c.projectionMatrix.n24));C.materials=S.materials;Z.push(C);z++}}}}ma&&Z.sort(a);return Z};this.unprojectVector=function(Q,c){var ma=c.matrixWorld.clone();ma.multiplySelf(THREE.Matrix4.makeInvert(c.projectionMatrix));ma.multiplyVector3(Q);return Q}};
  156. 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,f=d.length;for(e=0;e<f;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)}}}};
  157. 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",
  158. 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",
  159. 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",
  160. 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",
  161. 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",
  162. 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}",
  163. 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;",
  164. color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif",
  165. morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
  166. default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};
  167. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",
  168. value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",
  169. value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  170. 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",
  171. 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,
  172. 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,
  173. THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),
  174. fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,
  175. THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  176. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",
  177. THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),
  178. vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
  179. THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
  180. THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
  181. THREE.WebGLRenderer=function(a){function b(g,m,o){var j,k,s,q=g.vertices,r=q.length,E=g.colors,u=E.length,v=g.__vertexArray,L=g.__colorArray,W=g.__sortArray,H=g.__dirtyVertices,I=g.__dirtyColors;if(o.sortParticles){Ka.multiplySelf(o.matrixWorld);for(j=0;j<r;j++){k=q[j].position;Ha.copy(k);Ka.multiplyVector3(Ha);W[j]=[Ha.z,j]}W.sort(function(O,T){return T[0]-O[0]});for(j=0;j<r;j++){k=q[W[j][1]].position;s=j*3;v[s]=k.x;v[s+1]=k.y;v[s+2]=k.z}for(j=0;j<u;j++){s=j*3;color=E[W[j][1]];L[s]=color.r;L[s+1]=
  182. color.g;L[s+2]=color.b}}else{if(H)for(j=0;j<r;j++){k=q[j].position;s=j*3;v[s]=k.x;v[s+1]=k.y;v[s+2]=k.z}if(I)for(j=0;j<u;j++){color=E[j];s=j*3;L[s]=color.r;L[s+1]=color.g;L[s+2]=color.b}}if(H||o.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,v,m)}if(I||o.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,L,m)}}function d(g,m){g.fragmentShader=m.fragmentShader;g.vertexShader=m.vertexShader;g.uniforms=Uniforms.clone(m.uniforms)}
  183. function e(g,m,o,j,k){j.program||oa.initMaterial(j,m,o,k);var s=j.program,q=s.uniforms,r=j.uniforms;if(s!=ma){c.useProgram(s);ma=s}c.uniformMatrix4fv(q.projectionMatrix,!1,Pa);if(o&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){r.fogColor.value.setHex(o.color.hex);if(o instanceof THREE.Fog){r.fogNear.value=o.near;r.fogFar.value=o.far}else if(o instanceof
  184. THREE.FogExp2)r.fogDensity.value=o.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j.lights){var E,u,v=0,L=0,W=0,H,I,O,T=xa,X=T.directional.colors,P=T.directional.positions,Ca=T.point.colors,x=T.point.positions,Aa=0,ta=0;o=u=u=0;for(E=m.length;o<E;o++){u=m[o];H=u.color;I=u.position;O=u.intensity;if(u instanceof THREE.AmbientLight){v+=H.r;L+=H.g;W+=H.b}else if(u instanceof THREE.DirectionalLight){u=Aa*3;X[u]=H.r*O;X[u+1]=H.g*O;X[u+2]=H.b*O;P[u]=I.x;P[u+1]=I.y;
  185. P[u+2]=I.z;Aa+=1}else if(u instanceof THREE.PointLight){u=ta*3;Ca[u]=H.r*O;Ca[u+1]=H.g*O;Ca[u+2]=H.b*O;x[u]=I.x;x[u+1]=I.y;x[u+2]=I.z;ta+=1}}for(o=Aa*3;o<X.length;o++)X[o]=0;for(o=ta*3;o<Ca.length;o++)Ca[o]=0;T.point.length=ta;T.directional.length=Aa;T.ambient[0]=v;T.ambient[1]=L;T.ambient[2]=W;m=xa;r.enableLighting.value=m.directional.length+m.point.length;r.ambientLightColor.value=m.ambient;r.directionalLightColor.value=m.directional.colors;r.directionalLightDirection.value=m.directional.positions;
  186. r.pointLightColor.value=m.point.colors;r.pointLightPosition.value=m.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.map.texture=j.map;r.lightMap.texture=j.lightMap;r.envMap.texture=j.envMap;r.reflectivity.value=j.reflectivity;r.refractionRatio.value=j.refractionRatio;r.combine.value=j.combine;r.useRefract.value=
  187. j.envMap&&j.envMap.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){r.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){r.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);r.opacity.value=j.opacity;r.size.value=j.size;r.scale.value=Q.height/2;r.map.texture=j.map}else if(j instanceof THREE.MeshPhongMaterial){r.ambient.value.setRGB(j.ambient.r,
  188. j.ambient.g,j.ambient.b);r.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);r.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){r.mNear.value=g.near;r.mFar.value=g.far;r.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)r.opacity.value=j.opacity;for(var aa in r)if(v=s.uniforms[aa]){o=r[aa];E=o.type;m=o.value;if(E=="i")c.uniform1i(v,m);else if(E=="f")c.uniform1f(v,m);else if(E=="fv1")c.uniform1fv(v,m);else if(E=="fv")c.uniform3fv(v,m);else if(E==
  189. "v2")c.uniform2f(v,m.x,m.y);else if(E=="v3")c.uniform3f(v,m.x,m.y,m.z);else if(E=="c")c.uniform3f(v,m.r,m.g,m.b);else if(E=="t"){c.uniform1i(v,m);if(o=o.texture)if(o.image instanceof Array&&o.image.length==6){if(o.image.length==6){if(o.needsUpdate){if(o.__wasSetOnce){c.bindTexture(c.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube);for(E=0;E<6;++E)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+E,0,0,0,c.RGBA,c.UNSIGNED_BYTE,o.image[E])}else{o.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,
  190. o.image.__webGLTextureCube);for(E=0;E<6;++E)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+E,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,o.image[E]);o.__wasSetOnce=!0}ja(c.TEXTURE_CUBE_MAP,o,o.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);o.needsUpdate=!1}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP,o.image.__webGLTextureCube)}}else{if(o.needsUpdate){if(o.__wasSetOnce){c.bindTexture(c.TEXTURE_2D,o.__webGLTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,o.image)}else{o.__webGLTexture=
  191. c.createTexture();c.bindTexture(c.TEXTURE_2D,o.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,o.image);o.__wasSetOnce=!0}ja(c.TEXTURE_2D,o,o.image);c.bindTexture(c.TEXTURE_2D,null);o.needsUpdate=!1}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,o.__webGLTexture)}}}c.uniformMatrix4fv(q.modelViewMatrix,!1,k._modelViewMatrixArray);c.uniformMatrix3fv(q.normalMatrix,!1,k._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||
  192. j.envMap)&&c.uniform3f(q.cameraPosition,g.position.x,g.position.y,g.position.z);(j instanceof THREE.MeshShaderMaterial||j.envMap||j.skinning)&&c.uniformMatrix4fv(q.objectMatrix,!1,k._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&c.uniformMatrix4fv(q.viewMatrix,!1,Oa);if(j.skinning){c.uniformMatrix4fv(q.cameraInverseMatrix,!1,Oa);c.uniformMatrix4fv(q.boneGlobalMatrices,!1,k.boneMatrices)}return s}
  193. function f(g,m,o,j,k,s){if(j.opacity!=0){g=e(g,m,o,j,s).attributes;if(j.morphTargets){m=j.program.attributes;s.morphTargetBase!==-1?c.bindBuffer(c.ARRAY_BUFFER,k.__webGLMorphTargetsBuffers[s.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,k.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,!1,0,0);if(s.morphTargetForcedOrder.length){o=0;for(var q=s.morphTargetForcedOrder,r=s.morphTargetInfluences;o<j.numSupportedMorphTargets&&o<q.length;){c.bindBuffer(c.ARRAY_BUFFER,k.__webGLMorphTargetsBuffers[q[o]]);
  194. c.vertexAttribPointer(m["morphTarget"+o],3,c.FLOAT,!1,0,0);s.__webGLMorphTargetInfluences[o]=r[q[o]];o++}}else{q=[];var E=-1,u=0;r=s.morphTargetInfluences;var v,L=r.length;o=0;for(s.morphTargetBase!==-1&&(q[s.morphTargetBase]=!0);o<j.numSupportedMorphTargets;){for(v=0;v<L;v++)if(!q[v]&&r[v]>E){u=v;E=r[u]}c.bindBuffer(c.ARRAY_BUFFER,k.__webGLMorphTargetsBuffers[u]);c.vertexAttribPointer(m["morphTarget"+o],3,c.FLOAT,!1,0,0);s.__webGLMorphTargetInfluences[o]=E;q[u]=1;E=-1;o++}}c.uniform1fv(j.program.uniforms.morphTargetInfluences,
  195. s.__webGLMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,k.__webGLVertexBuffer);c.vertexAttribPointer(g.position,3,c.FLOAT,!1,0,0)}if(g.color>=0){c.bindBuffer(c.ARRAY_BUFFER,k.__webGLColorBuffer);c.vertexAttribPointer(g.color,3,c.FLOAT,!1,0,0)}if(g.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,k.__webGLNormalBuffer);c.vertexAttribPointer(g.normal,3,c.FLOAT,!1,0,0)}if(g.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,k.__webGLTangentBuffer);c.vertexAttribPointer(g.tangent,4,c.FLOAT,!1,0,0)}if(g.uv>=0)if(k.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,
  196. k.__webGLUVBuffer);c.vertexAttribPointer(g.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(g.uv)}else c.disableVertexAttribArray(g.uv);if(g.uv2>=0)if(k.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,k.__webGLUV2Buffer);c.vertexAttribPointer(g.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(g.uv2)}else c.disableVertexAttribArray(g.uv2);if(j.skinning&&g.skinVertexA>=0&&g.skinVertexB>=0&&g.skinIndex>=0&&g.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,k.__webGLSkinVertexABuffer);c.vertexAttribPointer(g.skinVertexA,
  197. 4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,k.__webGLSkinVertexBBuffer);c.vertexAttribPointer(g.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,k.__webGLSkinIndicesBuffer);c.vertexAttribPointer(g.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,k.__webGLSkinWeightsBuffer);c.vertexAttribPointer(g.skinWeight,4,c.FLOAT,!1,0,0)}if(s instanceof THREE.Mesh)if(j.wireframe){c.lineWidth(j.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);c.drawElements(c.LINES,
  198. k.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,k.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(s instanceof THREE.Line){s=s.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(j.linewidth);c.drawArrays(s,0,k.__webGLLineCount)}else if(s instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,k.__webGLParticleCount);else s instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,k.__webGLVertexCount)}}function h(g,m){if(!g.__webGLVertexBuffer)g.__webGLVertexBuffer=
  199. c.createBuffer();if(!g.__webGLNormalBuffer)g.__webGLNormalBuffer=c.createBuffer();if(g.hasPos){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,g.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(m.attributes.position);c.vertexAttribPointer(m.attributes.position,3,c.FLOAT,!1,0,0)}if(g.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,g.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,g.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(m.attributes.normal);c.vertexAttribPointer(m.attributes.normal,
  200. 3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,g.count);g.count=0}function i(g){if($!=g.doubleSided){g.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);$=g.doubleSided}if(U!=g.flipSided){g.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);U=g.flipSided}}function p(g){if(Da!=g){g?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);Da=g}}function n(g){za[0].set(g.n41-g.n11,g.n42-g.n12,g.n43-g.n13,g.n44-g.n14);za[1].set(g.n41+g.n11,g.n42+g.n12,g.n43+g.n13,g.n44+g.n14);za[2].set(g.n41+g.n21,g.n42+g.n22,
  201. g.n43+g.n23,g.n44+g.n24);za[3].set(g.n41-g.n21,g.n42-g.n22,g.n43-g.n23,g.n44-g.n24);za[4].set(g.n41-g.n31,g.n42-g.n32,g.n43-g.n33,g.n44-g.n34);za[5].set(g.n41+g.n31,g.n42+g.n32,g.n43+g.n33,g.n44+g.n34);var m;for(g=0;g<6;g++){m=za[g];m.divideScalar(Math.sqrt(m.x*m.x+m.y*m.y+m.z*m.z))}}function w(g){for(var m=g.matrixWorld,o=-g.geometry.boundingSphere.radius*Math.max(g.scale.x,Math.max(g.scale.y,g.scale.z)),j=0;j<6;j++){g=za[j].x*m.n14+za[j].y*m.n24+za[j].z*m.n34+za[j].w;if(g<=o)return!1}return!0}function A(g,
  202. m){g.list[g.count]=m;g.count+=1}function B(g){var m,o,j=g.object,k=g.opaque,s=g.transparent;s.count=0;g=k.count=0;for(m=j.materials.length;g<m;g++){o=j.materials[g];o.opacity&&o.opacity<1||o.blending!=THREE.NormalBlending?A(s,o):A(k,o)}}function C(g){var m,o,j,k,s=g.object,q=g.buffer,r=g.opaque,E=g.transparent;E.count=0;g=r.count=0;for(j=s.materials.length;g<j;g++){m=s.materials[g];if(m instanceof THREE.MeshFaceMaterial){m=0;for(o=q.materials.length;m<o;m++)(k=q.materials[m])&&(k.opacity&&k.opacity<
  203. 1||k.blending!=THREE.NormalBlending?A(E,k):A(r,k))}else{k=m;k.opacity&&k.opacity<1||k.blending!=THREE.NormalBlending?A(E,k):A(r,k)}}}function z(g,m){return m.z-g.z}function M(g,m){g._modelViewMatrix.multiplyToArray(m.matrixWorldInverse,g.matrixWorld,g._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(g._modelViewMatrix).transposeIntoArray(g._normalMatrixArray)}function K(g){function m(W){var H=[];o=0;for(j=W.length;o<j;o++)W[o]==undefined?H.push("undefined"):H.push(W[o].id);return H.join("_")}var o,
  204. j,k,s,q,r,E,u,v={},L=g.morphTargets!==undefined?g.morphTargets.length:0;g.geometryGroups={};k=0;for(s=g.faces.length;k<s;k++){q=g.faces[k];r=q.materials;E=m(r);v[E]==undefined&&(v[E]={hash:E,counter:0});u=v[E].hash+"_"+v[E].counter;g.geometryGroups[u]==undefined&&(g.geometryGroups[u]={faces:[],materials:r,vertices:0,numMorphTargets:L});q=q instanceof THREE.Face3?3:4;if(g.geometryGroups[u].vertices+q>65535){v[E].counter+=1;u=v[E].hash+"_"+v[E].counter;g.geometryGroups[u]==undefined&&(g.geometryGroups[u]=
  205. {faces:[],materials:r,vertices:0,numMorphTargets:L})}g.geometryGroups[u].faces.push(k);g.geometryGroups[u].vertices+=q}}function J(g,m,o){g.push({buffer:m,object:o,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function y(g){if(g!=R){switch(g){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,c.ONE_MINUS_SRC_ALPHA);
  206. 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)}R=g}}function ja(g,m,o){if((o.width&o.width-1)==0&&(o.height&o.height-1)==0){c.texParameteri(g,c.TEXTURE_WRAP_S,la(m.wrapS));c.texParameteri(g,c.TEXTURE_WRAP_T,la(m.wrapT));c.texParameteri(g,c.TEXTURE_MAG_FILTER,la(m.magFilter));c.texParameteri(g,c.TEXTURE_MIN_FILTER,la(m.minFilter));c.generateMipmap(g)}else{c.texParameteri(g,
  207. c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(g,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(g,c.TEXTURE_MAG_FILTER,ia(m.magFilter));c.texParameteri(g,c.TEXTURE_MIN_FILTER,ia(m.minFilter))}}function V(g){if(g&&!g.__webGLFramebuffer){g.__webGLFramebuffer=c.createFramebuffer();g.__webGLRenderbuffer=c.createRenderbuffer();g.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,g.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,g.width,g.height);c.bindTexture(c.TEXTURE_2D,
  208. g.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,la(g.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,la(g.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,la(g.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,la(g.minFilter));c.texImage2D(c.TEXTURE_2D,0,la(g.format),g.width,g.height,0,la(g.format),la(g.type),null);c.bindFramebuffer(c.FRAMEBUFFER,g.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,g.__webGLTexture,
  209. 0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,g.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var m,o;if(g){m=g.__webGLFramebuffer;o=g.width;g=g.height}else{m=null;o=ya;g=S}if(m!=Z){c.bindFramebuffer(c.FRAMEBUFFER,m);c.viewport(N,na,o,g);Z=m}}function ka(g,m){var o;if(g=="fragment")o=c.createShader(c.FRAGMENT_SHADER);else g=="vertex"&&(o=c.createShader(c.VERTEX_SHADER));c.shaderSource(o,
  210. m);c.compileShader(o);if(!c.getShaderParameter(o,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(o));return null}return o}function ia(g){switch(g){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 la(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;
  211. case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;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;
  212. case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;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 Q=document.createElement("canvas"),c,ma=null,Z=null,oa=this,$=null,U=null,R=null,Da=null,N=0,na=0,ya=0,S=
  213. 0,za=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ka=new THREE.Matrix4,Pa=new Float32Array(16),Oa=new Float32Array(16),Ha=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Y=!0,ua=new THREE.Color(0),Ba=0;if(a){if(a.antialias!==undefined)Y=a.antialias;a.clearColor!==undefined&&ua.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ba=a.clearAlpha}this.maxMorphTargets=
  214. 8;this.domElement=Q;this.autoClear=!0;this.sortObjects=!0;(function(g,m,o){try{if(!(c=Q.getContext("experimental-webgl",{antialias:g})))throw"Error creating WebGL context.";}catch(j){console.error(j)}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(m.r,m.g,m.b,o);_cullEnabled=!0})(Y,ua,Ba);this.context=c;this.setSize=function(g,m){Q.width=
  215. g;Q.height=m;this.setViewport(0,0,Q.width,Q.height)};this.setViewport=function(g,m,o,j){N=g;na=m;ya=o;S=j;c.viewport(N,na,ya,S)};this.setScissor=function(g,m,o,j){c.scissor(g,m,o,j)};this.enableScissorTest=function(g){g?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(g){c.depthMask(g)};this.setClearColorHex=function(g,m){var o=new THREE.Color(g);c.clearColor(o.r,o.g,o.b,m)};this.setClearColor=function(g,m){c.clearColor(g.r,g.g,g.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|
  216. c.DEPTH_BUFFER_BIT)};this.initMaterial=function(g,m,o,j){var k,s,q;if(g instanceof THREE.MeshDepthMaterial)d(g,THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)d(g,THREE.ShaderLib.normal);else if(g instanceof THREE.MeshBasicMaterial)d(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)d(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)d(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)d(g,THREE.ShaderLib.basic);else g instanceof
  217. THREE.ParticleBasicMaterial&&d(g,THREE.ShaderLib.particle_basic);var r,E,u,v;q=u=v=0;for(r=m.length;q<r;q++){E=m[q];E instanceof THREE.DirectionalLight&&u++;E instanceof THREE.PointLight&&v++}if(v+u<=4)m=u;else{m=Math.ceil(4*u/(v+u));v=4-m}q={directional:m,point:v};r=50;if(j!==undefined&&j instanceof THREE.SkinnedMesh)r=j.bones.length;v=g.fragmentShader;m=g.vertexShader;r={fog:o,map:g.map,envMap:g.envMap,lightMap:g.lightMap,vertexColors:g.vertexColors,sizeAttenuation:g.sizeAttenuation,skinning:g.skinning,
  218. morphTargets:g.morphTargets,maxDirLights:q.directional,maxPointLights:q.point,maxBones:r};o=c.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,r.fog?"#define USE_FOG":"",r.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.lightMap?"#define USE_LIGHTMAP":"",r.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
  219. r=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+r.maxDirLights,"#define MAX_POINT_LIGHTS "+r.maxPointLights,"#define MAX_BONES "+r.maxBones,r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.lightMap?"#define USE_LIGHTMAP":"",r.vertexColors?"#define USE_COLOR":"",r.skinning?"#define USE_SKINNING":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
  220. c.attachShader(o,ka("fragment",q+v));c.attachShader(o,ka("vertex",r+m));c.linkProgram(o);c.getProgramParameter(o,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(o,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");o.uniforms={};o.attributes={};g.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(k in g.uniforms)o.push(k);
  221. k=g.program;v=0;for(m=o.length;v<m;v++){q=o[v];k.uniforms[q]=c.getUniformLocation(k,q)}o=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(k=0;k<this.maxMorphTargets;k++)o.push("morphTarget"+k);for(s in g.attributes)o.push(s);s=g.program;k=o;o=0;for(v=k.length;o<v;o++){m=k[o];s.attributes[m]=c.getAttribLocation(s,m)}s=g.program.attributes;c.enableVertexAttribArray(s.position);s.color>=0&&c.enableVertexAttribArray(s.color);s.normal>=0&&c.enableVertexAttribArray(s.normal);
  222. s.tangent>=0&&c.enableVertexAttribArray(s.tangent);if(g.skinning&&s.skinVertexA>=0&&s.skinVertexB>=0&&s.skinIndex>=0&&s.skinWeight>=0){c.enableVertexAttribArray(s.skinVertexA);c.enableVertexAttribArray(s.skinVertexB);c.enableVertexAttribArray(s.skinIndex);c.enableVertexAttribArray(s.skinWeight)}if(g.morphTargets){g.numSupportedMorphTargets=0;if(s.morphTarget0>=0){c.enableVertexAttribArray(s.morphTarget0);g.numSupportedMorphTargets++}if(s.morphTarget1>=0){c.enableVertexAttribArray(s.morphTarget1);
  223. g.numSupportedMorphTargets++}if(s.morphTarget2>=0){c.enableVertexAttribArray(s.morphTarget2);g.numSupportedMorphTargets++}if(s.morphTarget3>=0){c.enableVertexAttribArray(s.morphTarget3);g.numSupportedMorphTargets++}if(s.morphTarget4>=0){c.enableVertexAttribArray(s.morphTarget4);g.numSupportedMorphTargets++}if(s.morphTarget5>=0){c.enableVertexAttribArray(s.morphTarget5);g.numSupportedMorphTargets++}if(s.morphTarget6>=0){c.enableVertexAttribArray(s.morphTarget6);g.numSupportedMorphTargets++}if(s.morphTarget7>=
  224. 0){c.enableVertexAttribArray(s.morphTarget7);g.numSupportedMorphTargets++}j.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(k=0;k<this.maxMorphTargets;k++)j.__webGLMorphTargetInfluences[k]=0}};this.render=function(g,m,o,j){var k,s,q,r,E,u,v,L,W=g.lights,H=g.fog;m.matrixAutoUpdate&&m.updateMatrix();g.update(undefined,!1,m);m.matrixWorldInverse.flattenToArray(Oa);m.projectionMatrix.flattenToArray(Pa);Ka.multiply(m.projectionMatrix,m.matrixWorldInverse);n(Ka);this.initWebGLObjects(g);
  225. V(o);(this.autoClear||j)&&this.clear();E=g.__webglObjects.length;for(j=0;j<E;j++){k=g.__webglObjects[j];v=k.object;if(v.visible)if(!(v instanceof THREE.Mesh)||w(v)){v.matrixWorld.flattenToArray(v._objectMatrixArray);M(v,m);C(k);k.render=!0;if(this.sortObjects){Ha.copy(v.position);Ka.multiplyVector3(Ha);k.z=Ha.z}}else k.render=!1;else k.render=!1}this.sortObjects&&g.__webglObjects.sort(z);u=g.__webglObjectsImmediate.length;for(j=0;j<u;j++){k=g.__webglObjectsImmediate[j];v=k.object;if(v.visible){v.matrixAutoUpdate&&
  226. v.matrixWorld.flattenToArray(v._objectMatrixArray);M(v,m);B(k)}}y(THREE.NormalBlending);for(j=0;j<E;j++){k=g.__webglObjects[j];if(k.render){v=k.object;L=k.buffer;q=k.opaque;i(v);for(k=0;k<q.count;k++){r=q.list[k];p(r.depthTest);f(m,W,H,r,L,v)}}}for(j=0;j<u;j++){k=g.__webglObjectsImmediate[j];v=k.object;if(v.visible){q=k.opaque;i(v);for(k=0;k<q.count;k++){r=q.list[k];p(r.depthTest);s=e(m,W,H,r,v);v.render(function(I){h(I,s)})}}}for(j=0;j<E;j++){k=g.__webglObjects[j];if(k.render){v=k.object;L=k.buffer;
  227. q=k.transparent;i(v);for(k=0;k<q.count;k++){r=q.list[k];y(r.blending);p(r.depthTest);f(m,W,H,r,L,v)}}}for(j=0;j<u;j++){k=g.__webglObjectsImmediate[j];v=k.object;if(v.visible){q=k.transparent;i(v);for(k=0;k<q.count;k++){r=q.list[k];y(r.blending);p(r.depthTest);s=e(m,W,H,r,v);v.render(function(I){h(I,s)})}}}if(o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,o.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=
  228. function(g){if(!g.__webglObjects){g.__webglObjects=[];g.__webglObjectsImmediate=[]}for(;g.__objectsAdded.length;){var m=g.__objectsAdded[0],o=g,j=void 0,k=void 0,s=void 0;if(m._modelViewMatrix==undefined){m._modelViewMatrix=new THREE.Matrix4;m._normalMatrixArray=new Float32Array(9);m._modelViewMatrixArray=new Float32Array(16);m._objectMatrixArray=new Float32Array(16);m.matrixWorld.flattenToArray(m._objectMatrixArray)}if(m instanceof THREE.Mesh){k=m.geometry;k.geometryGroups==undefined&&K(k);for(j in k.geometryGroups){s=
  229. k.geometryGroups[j];if(!s.__webGLVertexBuffer){var q=s;q.__webGLVertexBuffer=c.createBuffer();q.__webGLNormalBuffer=c.createBuffer();q.__webGLTangentBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q.__webGLUVBuffer=c.createBuffer();q.__webGLUV2Buffer=c.createBuffer();q.__webGLSkinVertexABuffer=c.createBuffer();q.__webGLSkinVertexBBuffer=c.createBuffer();q.__webGLSkinIndicesBuffer=c.createBuffer();q.__webGLSkinWeightsBuffer=c.createBuffer();q.__webGLFaceBuffer=c.createBuffer();q.__webGLLineBuffer=
  230. c.createBuffer();if(q.numMorphTargets){var r=void 0,E=void 0;q.__webGLMorphTargetsBuffers=[];r=0;for(E=q.numMorphTargets;r<E;r++)q.__webGLMorphTargetsBuffers.push(c.createBuffer())}q=s;var u=m,v=void 0,L=void 0,W=E=r=0;v=void 0;var H=void 0;L=void 0;L=void 0;var I=u.geometry;H=I.faces;var O=q.faces;v=0;for(L=O.length;v<L;v++){fi=O[v];face=H[fi];if(face instanceof THREE.Face3){r+=3;E+=1;W+=3}else if(face instanceof THREE.Face4){r+=4;E+=2;W+=4}}v=q;L=u;H=void 0;O=void 0;var T=void 0,X=void 0;T=void 0;
  231. var P=[];H=0;for(O=L.materials.length;H<O;H++){T=L.materials[H];if(T instanceof THREE.MeshFaceMaterial){T=0;for(l=v.materials.length;T<l;T++)(X=v.materials[T])&&P.push(X)}else(X=T)&&P.push(X)}L=P;a:{v=void 0;H=void 0;O=L.length;for(v=0;v<O;v++){H=L[v];if(H.map||H.lightMap){v=!0;break a}}v=!1}a:{H=void 0;O=void 0;P=L.length;for(H=0;H<P;H++){O=L[H];if(O.vertexColors){H=O.vertexColors;break a}}H=!1}a:{O=void 0;P=void 0;T=L.length;for(O=0;O<T;O++){P=L[O];if(!(P instanceof THREE.MeshBasicMaterial||P instanceof
  232. THREE.MeshDepthMaterial)){L=P&&P.shading!=undefined&&P.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}L=!1}q.__vertexArray=new Float32Array(r*3);if(L)q.__normalArray=new Float32Array(r*3);if(I.hasTangents)q.__tangentArray=new Float32Array(r*4);if(H)q.__colorArray=new Float32Array(r*3);if(v){if(I.faceUvs.length>0||I.faceVertexUvs.length>0)q.__uvArray=new Float32Array(r*2);if(I.faceUvs.length>1||I.faceVertexUvs.length>1)q.__uv2Array=new Float32Array(r*2)}if(u.geometry.skinWeights.length&&
  233. u.geometry.skinIndices.length){q.__skinVertexAArray=new Float32Array(r*4);q.__skinVertexBArray=new Float32Array(r*4);q.__skinIndexArray=new Float32Array(r*4);q.__skinWeightArray=new Float32Array(r*4)}q.__faceArray=new Uint16Array(E*3);q.__lineArray=new Uint16Array(W*2);if(q.numMorphTargets){u=void 0;I=void 0;q.__morphTargetsArrays=[];u=0;for(I=q.numMorphTargets;u<I;u++)q.__morphTargetsArrays.push(new Float32Array(r*3))}q.__needsSmoothNormals=L==THREE.SmoothShading;q.__uvType=v;q.__vertexColorType=
  234. H;q.__normalType=L;q.__webGLFaceCount=E*3;q.__webGLLineCount=W*2;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=!0;k.__dirtyNormals=!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}J(o.__webglObjects,s,m)}}else if(m instanceof THREE.Ribbon){k=m.geometry;if(!k.__webGLVertexBuffer){j=k;j.__webGLVertexBuffer=c.createBuffer();j.__webGLColorBuffer=c.createBuffer();j=k;s=j.vertices.length;j.__vertexArray=new Float32Array(s*3);j.__colorArray=new Float32Array(s*3);j.__webGLVertexCount=
  235. s;k.__dirtyVertices=!0;k.__dirtyColors=!0}J(o.__webglObjects,k,m)}else if(m instanceof THREE.Line){k=m.geometry;if(!k.__webGLVertexBuffer){j=k;j.__webGLVertexBuffer=c.createBuffer();j.__webGLColorBuffer=c.createBuffer();j=k;s=j.vertices.length;j.__vertexArray=new Float32Array(s*3);j.__colorArray=new Float32Array(s*3);j.__webGLLineCount=s;k.__dirtyVertices=!0;k.__dirtyColors=!0}J(o.__webglObjects,k,m)}else if(m instanceof THREE.ParticleSystem){k=m.geometry;if(!k.__webGLVertexBuffer){j=k;j.__webGLVertexBuffer=
  236. c.createBuffer();j.__webGLColorBuffer=c.createBuffer();j=k;s=j.vertices.length;j.__vertexArray=new Float32Array(s*3);j.__colorArray=new Float32Array(s*3);j.__sortArray=[];j.__webGLParticleCount=s;k.__dirtyVertices=!0;k.__dirtyColors=!0}J(o.__webglObjects,k,m)}else THREE.MarchingCubes!==undefined&&m instanceof THREE.MarchingCubes&&o.__webglObjectsImmediate.push({object:m,opaque:{list:[],count:0},transparent:{list:[],count:0}});g.__objectsAdded.splice(0,1)}for(;g.__objectsRemoved.length;){m=g.__objectsRemoved[0];
  237. o=g;k=void 0;j=void 0;for(k=o.__webglObjects.length-1;k>=0;k--){j=o.__webglObjects[k].object;m==j&&o.__webglObjects.splice(k,1)}g.__objectsRemoved.splice(0,1)}m=0;for(o=g.__webglObjects.length;m<o;m++){j=g.__webglObjects[m].object;s=void 0;k=void 0;q=void 0;if(j instanceof THREE.Mesh){k=j.geometry;for(s in k.geometryGroups){q=k.geometryGroups[s];if(k.__dirtyVertices||k.__dirtyMorphTargets||k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents){r=c.DYNAMIC_DRAW;E=void 0;
  238. W=void 0;var Ca=void 0,x=void 0,Aa=void 0,ta=void 0,aa=void 0,Fa=void 0,Ja=void 0;Ca=void 0;var D=void 0,F=void 0,G=void 0,ca=void 0;aa=void 0;Fa=void 0;D=void 0;x=void 0;D=void 0;F=void 0;G=void 0;aa=void 0;D=void 0;F=void 0;G=void 0;ca=void 0;D=void 0;F=void 0;G=void 0;ca=void 0;D=void 0;F=void 0;G=void 0;ca=void 0;D=void 0;F=void 0;G=void 0;ca=void 0;x=void 0;ta=void 0;Aa=void 0;Ja=void 0;var va=void 0,Ta=void 0,pa=void 0,t=X=T=P=O=H=L=v=I=u=0,qa=0,ra=q.__vertexArray,Va=q.__uvArray,Wa=q.__uv2Array,
  239. Ia=q.__normalArray,da=q.__tangentArray,sa=q.__colorArray,ea=q.__skinVertexAArray,fa=q.__skinVertexBArray,ga=q.__skinIndexArray,ha=q.__skinWeightArray,Ya=q.__morphTargetsArrays,La=q.__faceArray,Ea=q.__lineArray,eb=q.__needsSmoothNormals,Xa=q.__vertexColorType,wa=j.geometry,Za=wa.__dirtyVertices,$a=wa.__dirtyElements,Ua=wa.__dirtyUvs,ab=wa.__dirtyNormals,bb=wa.__dirtyTangents,cb=wa.__dirtyColors,db=wa.__dirtyMorphTargets,Ga=wa.vertices,fb=q.faces,gb=wa.faces,hb=wa.faceVertexUvs[0],ib=wa.faceVertexUvs[1],
  240. jb=wa.colors,Qa=wa.skinVerticesA,Ra=wa.skinVerticesB,Sa=wa.skinIndices,Na=wa.skinWeights,Ma=wa.morphTargets;E=0;for(W=fb.length;E<W;E++){Ca=fb[E];x=gb[Ca];Ja=hb[Ca];Ca=ib[Ca];Aa=x.vertexNormals;ta=x.normal;aa=x.vertexColors;Fa=x.color;if(x instanceof THREE.Face3){if(Za){D=Ga[x.a].position;F=Ga[x.b].position;G=Ga[x.c].position;ra[I]=D.x;ra[I+1]=D.y;ra[I+2]=D.z;ra[I+3]=F.x;ra[I+4]=F.y;ra[I+5]=F.z;ra[I+6]=G.x;ra[I+7]=G.y;ra[I+8]=G.z;I+=9}if(db){va=0;for(Ta=Ma.length;va<Ta;va++){D=Ma[va].vertices[x.a].position;
  241. F=Ma[va].vertices[x.b].position;G=Ma[va].vertices[x.c].position;pa=Ya[va];pa[qa+0]=D.x;pa[qa+1]=D.y;pa[qa+2]=D.z;pa[qa+3]=F.x;pa[qa+4]=F.y;pa[qa+5]=F.z;pa[qa+6]=G.x;pa[qa+7]=G.y;pa[qa+8]=G.z}qa+=9}if(Na.length){D=Na[x.a];F=Na[x.b];G=Na[x.c];ha[t]=D.x;ha[t+1]=D.y;ha[t+2]=D.z;ha[t+3]=D.w;ha[t+4]=F.x;ha[t+5]=F.y;ha[t+6]=F.z;ha[t+7]=F.w;ha[t+8]=G.x;ha[t+9]=G.y;ha[t+10]=G.z;ha[t+11]=G.w;D=Sa[x.a];F=Sa[x.b];G=Sa[x.c];ga[t]=D.x;ga[t+1]=D.y;ga[t+2]=D.z;ga[t+3]=D.w;ga[t+4]=F.x;ga[t+5]=F.y;ga[t+6]=F.z;ga[t+
  242. 7]=F.w;ga[t+8]=G.x;ga[t+9]=G.y;ga[t+10]=G.z;ga[t+11]=G.w;D=Qa[x.a];F=Qa[x.b];G=Qa[x.c];ea[t]=D.x;ea[t+1]=D.y;ea[t+2]=D.z;ea[t+3]=1;ea[t+4]=F.x;ea[t+5]=F.y;ea[t+6]=F.z;ea[t+7]=1;ea[t+8]=G.x;ea[t+9]=G.y;ea[t+10]=G.z;ea[t+11]=1;D=Ra[x.a];F=Ra[x.b];G=Ra[x.c];fa[t]=D.x;fa[t+1]=D.y;fa[t+2]=D.z;fa[t+3]=1;fa[t+4]=F.x;fa[t+5]=F.y;fa[t+6]=F.z;fa[t+7]=1;fa[t+8]=G.x;fa[t+9]=G.y;fa[t+10]=G.z;fa[t+11]=1;t+=12}if(cb&&Xa){if(aa.length==3&&Xa==THREE.VertexColors){D=aa[0];F=aa[1];G=aa[2]}else G=F=D=Fa;sa[X]=D.r;sa[X+
  243. 1]=D.g;sa[X+2]=D.b;sa[X+3]=F.r;sa[X+4]=F.g;sa[X+5]=F.b;sa[X+6]=G.r;sa[X+7]=G.g;sa[X+8]=G.b;X+=9}if(bb&&wa.hasTangents){aa=Ga[x.a].tangent;Fa=Ga[x.b].tangent;D=Ga[x.c].tangent;da[P]=aa.x;da[P+1]=aa.y;da[P+2]=aa.z;da[P+3]=aa.w;da[P+4]=Fa.x;da[P+5]=Fa.y;da[P+6]=Fa.z;da[P+7]=Fa.w;da[P+8]=D.x;da[P+9]=D.y;da[P+10]=D.z;da[P+11]=D.w;P+=12}if(ab)if(Aa.length==3&&eb)for(x=0;x<3;x++){ta=Aa[x];Ia[O]=ta.x;Ia[O+1]=ta.y;Ia[O+2]=ta.z;O+=3}else for(x=0;x<3;x++){Ia[O]=ta.x;Ia[O+1]=ta.y;Ia[O+2]=ta.z;O+=3}if(Ua&&Ja)for(x=
  244. 0;x<3;x++){Aa=Ja[x];Va[v]=Aa.u;Va[v+1]=Aa.v;v+=2}if(Ua&&Ca)for(x=0;x<3;x++){Ja=Ca[x];Wa[L]=Ja.u;Wa[L+1]=Ja.v;L+=2}if($a){La[H]=u;La[H+1]=u+1;La[H+2]=u+2;H+=3;Ea[T]=u;Ea[T+1]=u+1;Ea[T+2]=u;Ea[T+3]=u+2;Ea[T+4]=u+1;Ea[T+5]=u+2;T+=6;u+=3}}else if(x instanceof THREE.Face4){if(Za){D=Ga[x.a].position;F=Ga[x.b].position;G=Ga[x.c].position;ca=Ga[x.d].position;ra[I]=D.x;ra[I+1]=D.y;ra[I+2]=D.z;ra[I+3]=F.x;ra[I+4]=F.y;ra[I+5]=F.z;ra[I+6]=G.x;ra[I+7]=G.y;ra[I+8]=G.z;ra[I+9]=ca.x;ra[I+10]=ca.y;ra[I+11]=ca.z;I+=
  245. 12}if(db){va=0;for(Ta=Ma.length;va<Ta;va++){D=Ma[va].vertices[x.a].position;F=Ma[va].vertices[x.b].position;G=Ma[va].vertices[x.c].position;ca=Ma[va].vertices[x.d].position;pa=Ya[va];pa[qa+0]=D.x;pa[qa+1]=D.y;pa[qa+2]=D.z;pa[qa+3]=F.x;pa[qa+4]=F.y;pa[qa+5]=F.z;pa[qa+6]=G.x;pa[qa+7]=G.y;pa[qa+8]=G.z;pa[qa+9]=ca.x;pa[qa+10]=ca.y;pa[qa+11]=ca.z}qa+=12}if(Na.length){D=Na[x.a];F=Na[x.b];G=Na[x.c];ca=Na[x.d];ha[t]=D.x;ha[t+1]=D.y;ha[t+2]=D.z;ha[t+3]=D.w;ha[t+4]=F.x;ha[t+5]=F.y;ha[t+6]=F.z;ha[t+7]=F.w;ha[t+
  246. 8]=G.x;ha[t+9]=G.y;ha[t+10]=G.z;ha[t+11]=G.w;ha[t+12]=ca.x;ha[t+13]=ca.y;ha[t+14]=ca.z;ha[t+15]=ca.w;D=Sa[x.a];F=Sa[x.b];G=Sa[x.c];ca=Sa[x.d];ga[t]=D.x;ga[t+1]=D.y;ga[t+2]=D.z;ga[t+3]=D.w;ga[t+4]=F.x;ga[t+5]=F.y;ga[t+6]=F.z;ga[t+7]=F.w;ga[t+8]=G.x;ga[t+9]=G.y;ga[t+10]=G.z;ga[t+11]=G.w;ga[t+12]=ca.x;ga[t+13]=ca.y;ga[t+14]=ca.z;ga[t+15]=ca.w;D=Qa[x.a];F=Qa[x.b];G=Qa[x.c];ca=Qa[x.d];ea[t]=D.x;ea[t+1]=D.y;ea[t+2]=D.z;ea[t+3]=1;ea[t+4]=F.x;ea[t+5]=F.y;ea[t+6]=F.z;ea[t+7]=1;ea[t+8]=G.x;ea[t+9]=G.y;ea[t+
  247. 10]=G.z;ea[t+11]=1;ea[t+12]=ca.x;ea[t+13]=ca.y;ea[t+14]=ca.z;ea[t+15]=1;D=Ra[x.a];F=Ra[x.b];G=Ra[x.c];ca=Ra[x.d];fa[t]=D.x;fa[t+1]=D.y;fa[t+2]=D.z;fa[t+3]=1;fa[t+4]=F.x;fa[t+5]=F.y;fa[t+6]=F.z;fa[t+7]=1;fa[t+8]=G.x;fa[t+9]=G.y;fa[t+10]=G.z;fa[t+11]=1;fa[t+12]=ca.x;fa[t+13]=ca.y;fa[t+14]=ca.z;fa[t+15]=1;t+=16}if(cb&&Xa){if(aa.length==4&&Xa==THREE.VertexColors){D=aa[0];F=aa[1];G=aa[2];aa=aa[3]}else aa=G=F=D=Fa;sa[X]=D.r;sa[X+1]=D.g;sa[X+2]=D.b;sa[X+3]=F.r;sa[X+4]=F.g;sa[X+5]=F.b;sa[X+6]=G.r;sa[X+7]=
  248. G.g;sa[X+8]=G.b;sa[X+9]=aa.r;sa[X+10]=aa.g;sa[X+11]=aa.b;X+=12}if(bb&&wa.hasTangents){aa=Ga[x.a].tangent;Fa=Ga[x.b].tangent;D=Ga[x.c].tangent;x=Ga[x.d].tangent;da[P]=aa.x;da[P+1]=aa.y;da[P+2]=aa.z;da[P+3]=aa.w;da[P+4]=Fa.x;da[P+5]=Fa.y;da[P+6]=Fa.z;da[P+7]=Fa.w;da[P+8]=D.x;da[P+9]=D.y;da[P+10]=D.z;da[P+11]=D.w;da[P+12]=x.x;da[P+13]=x.y;da[P+14]=x.z;da[P+15]=x.w;P+=16}if(ab)if(Aa.length==4&&eb)for(x=0;x<4;x++){ta=Aa[x];Ia[O]=ta.x;Ia[O+1]=ta.y;Ia[O+2]=ta.z;O+=3}else for(x=0;x<4;x++){Ia[O]=ta.x;Ia[O+
  249. 1]=ta.y;Ia[O+2]=ta.z;O+=3}if(Ua&&Ja)for(x=0;x<4;x++){Aa=Ja[x];Va[v]=Aa.u;Va[v+1]=Aa.v;v+=2}if(Ua&&Ca)for(x=0;x<4;x++){Ja=Ca[x];Wa[L]=Ja.u;Wa[L+1]=Ja.v;L+=2}if($a){La[H]=u;La[H+1]=u+1;La[H+2]=u+2;La[H+3]=u;La[H+4]=u+2;La[H+5]=u+3;H+=6;Ea[T]=u;Ea[T+1]=u+1;Ea[T+2]=u;Ea[T+3]=u+3;Ea[T+4]=u+1;Ea[T+5]=u+2;Ea[T+6]=u+2;Ea[T+7]=u+3;T+=8;u+=4}}}if(Za){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,ra,r)}if(db){va=0;for(Ta=Ma.length;va<Ta;va++){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLMorphTargetsBuffers[va]);
  250. c.bufferData(c.ARRAY_BUFFER,Ya[va],r)}}if(cb&&jb.length){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,sa,r)}if(ab){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Ia,r)}if(bb&&wa.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,da,r)}if(Ua&&v>0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Va,r)}if(Ua&&L>0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,
  251. Wa,r)}if($a){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,La,r);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Ea,r)}if(t>0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ea,r);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,fa,r);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ga,r);c.bindBuffer(c.ARRAY_BUFFER,
  252. q.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,ha,r)}}}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyTangents=!1;k.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){k=j.geometry;if(k.__dirtyVertices||k.__dirtyColors){j=k;s=c.DYNAMIC_DRAW;u=void 0;u=void 0;I=void 0;q=void 0;v=j.vertices;r=j.colors;L=v.length;E=r.length;H=j.__vertexArray;W=j.__colorArray;O=j.__dirtyColors;if(j.__dirtyVertices){for(u=0;u<L;u++){I=v[u].position;
  253. q=u*3;H[q]=I.x;H[q+1]=I.y;H[q+2]=I.z}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,H,s)}if(O){for(u=0;u<E;u++){color=r[u];q=u*3;W[q]=color.r;W[q+1]=color.g;W[q+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,W,s)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(j instanceof THREE.Line){k=j.geometry;if(k.__dirtyVertices||k.__dirtyColors){j=k;s=c.DYNAMIC_DRAW;u=void 0;u=void 0;I=void 0;q=void 0;v=j.vertices;r=j.colors;L=v.length;
  254. E=r.length;H=j.__vertexArray;W=j.__colorArray;O=j.__dirtyColors;if(j.__dirtyVertices){for(u=0;u<L;u++){I=v[u].position;q=u*3;H[q]=I.x;H[q+1]=I.y;H[q+2]=I.z}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,H,s)}if(O){for(u=0;u<E;u++){color=r[u];q=u*3;W[q]=color.r;W[q+1]=color.g;W[q+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,W,s)}}k.__dirtyVertices=!1;k.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){k=j.geometry;
  255. (k.__dirtyVertices||k.__dirtyColors||j.sortParticles)&&b(k,c.DYNAMIC_DRAW,j);k.__dirtyVertices=!1;k.__dirtyColors=!1}}};this.setFaceCulling=function(g,m){if(g){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="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}};