Three.js 127 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. // Three.js r32 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=!0;this.setHex(a)};
  3. THREE.Color.prototype={setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,g,i,l,n,k;if(c==0)e=g=i=0;else{l=Math.floor(a*6);n=a*6-l;a=c*(1-b);k=c*(1-b*n);b=c*(1-b*(1-n));switch(l){case 1:e=k;g=c;i=a;break;case 2:e=a;g=c;i=b;break;case 3:e=a;g=k;i=c;break;case 4:e=b;g=a;i=c;break;case 5:e=c;g=a;i=k;break;case 6:case 0:e=c;g=b;i=a}}this.r=e;this.g=g;this.b=i;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
  4. setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
  5. this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
  6. THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
  7. this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
  8. THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
  9. cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,e=this.z;this.x=c*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
  10. a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+
  11. this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+
  12. this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1};
  13. THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
  14. return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){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)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
  15. THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
  16. THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(i,l){return i.distance-l.distance});return g},intersectObject:function(a){function b(G,r,Z,D){D=D.clone().subSelf(r);Z=Z.clone().subSelf(r);var K=G.clone().subSelf(r);G=D.dot(D);r=D.dot(Z);D=D.dot(K);var d=Z.dot(Z);Z=Z.dot(K);K=1/(G*d-r*r);d=(d*D-r*Z)*K;G=(G*Z-r*D)*K;return d>0&&G>0&&d+G<1}var c,e,g,i,l,n,k,o,s,w,
  17. t,x=a.geometry,F=x.vertices,H=[];c=0;for(e=x.faces.length;c<e;c++){g=x.faces[c];w=this.origin.clone();t=this.direction.clone();k=a.globalMatrix;k.extractRotationMatrix(a.rotationMatrix);i=k.multiplyVector3(F[g.a].position.clone());l=k.multiplyVector3(F[g.b].position.clone());n=k.multiplyVector3(F[g.c].position.clone());k=g instanceof THREE.Face4?k.multiplyVector3(F[g.d].position.clone()):null;o=a.rotationMatrix.multiplyVector3(g.normal.clone());s=t.dot(o);if(s<0){o=o.dot((new THREE.Vector3).sub(i,
  18. w))/s;w=w.addSelf(t.multiplyScalar(o));if(g instanceof THREE.Face3){if(b(w,i,l,n)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(b(w,i,l,k)||b(w,l,n,k))){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}}return H}};
  19. THREE.Rectangle=function(){function a(){i=e-b;l=g-c}var b,c,e,g,i,l,n=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return i};this.getHeight=function(){return l};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,o,s,w){n=!1;b=k;c=o;e=s;g=w;a()};this.addPoint=function(k,o){if(n){n=!1;b=k;c=o;e=k;g=o}else{b=b<k?b:k;c=c<o?c:o;e=e>k?e:k;g=g>o?g:o}a()};
  20. this.add3Points=function(k,o,s,w,t,x){if(n){n=!1;b=k<s?k<t?k:t:s<t?s:t;c=o<w?o<x?o:x:w<x?w:x;e=k>s?k>t?k:t:s>t?s:t;g=o>w?o>x?o:x:w>x?w:x}else{b=k<s?k<t?k<b?k:b:t<b?t:b:s<t?s<b?s:b:t<b?t:b;c=o<w?o<x?o<c?o:c:x<c?x:c:w<x?w<c?w:c:x<c?x:c;e=k>s?k>t?k>e?k:e:t>e?t:e:s>t?s>e?s:e:t>e?t:e;g=o>w?o>x?o>g?o:g:x>g?x:g:w>x?w>g?w:g:x>g?x:g}a()};this.addRectangle=function(k){if(n){n=!1;b=k.getLeft();c=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();c=c<k.getTop()?c:k.getTop();e=e>k.getRight()?
  21. e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){n=!0;g=e=c=b=0;a()};this.isEmpty=function(){return n};this.toString=function(){return"THREE.Rectangle ( left: "+
  22. b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+i+", height: "+l+" )"}};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}};
  23. THREE.Matrix4=function(a,b,c,e,g,i,l,n,k,o,s,w,t,x,F,H){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=i||1;this.n23=l||0;this.n24=n||0;this.n31=k||0;this.n32=o||0;this.n33=s||1;this.n34=w||0;this.n41=t||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
  24. THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,c,e,g,i,l,n,k,o,s,w,t,x,F,H){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=i;this.n23=l;this.n24=n;this.n31=k;this.n32=o;this.n33=s;this.n34=w;this.n41=t;this.n42=x;this.n43=F;this.n44=H;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
  25. a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,i=THREE.Matrix4.__tmpVec3;i.sub(a,b).normalize();e.cross(c,i).normalize();g.cross(i,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
  26. this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
  27. a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;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*
  28. a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,l=a.n21,n=a.n22,k=a.n23,o=a.n24,s=a.n31,w=a.n32,t=a.n33,x=a.n34,F=a.n41,H=a.n42,G=a.n43,r=a.n44,Z=b.n11,D=b.n12,K=b.n13,d=b.n14,ga=b.n21,T=b.n22,N=b.n23,ba=b.n24,R=b.n31,aa=b.n32,V=b.n33,B=b.n34,I=b.n41,ka=b.n42,P=b.n43,ja=b.n44;this.n11=c*Z+e*ga+g*R+i*I;this.n12=c*D+e*T+g*aa+i*ka;this.n13=c*K+e*N+g*V+i*P;this.n14=c*d+e*ba+g*B+i*ja;this.n21=l*Z+n*ga+k*R+o*I;this.n22=l*D+n*T+k*aa+o*ka;
  29. this.n23=l*K+n*N+k*V+o*P;this.n24=l*d+n*ba+k*B+o*ja;this.n31=s*Z+w*ga+t*R+x*I;this.n32=s*D+w*T+t*aa+x*ka;this.n33=s*K+w*N+t*V+x*P;this.n34=s*d+w*ba+t*B+x*ja;this.n41=F*Z+H*ga+G*R+r*I;this.n42=F*D+H*T+G*aa+r*ka;this.n43=F*K+H*N+G*V+r*P;this.n44=F*d+H*ba+G*B+r*ja;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,i=a.n13,l=a.n14,n=a.n21,k=a.n22,o=a.n23,s=a.n24,w=a.n31,t=a.n32,x=a.n33,F=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var Z=b.n11,D=b.n12,K=b.n13,d=b.n14,ga=b.n21,T=b.n22,N=b.n23,ba=
  30. b.n24,R=b.n31,aa=b.n32,V=b.n33,B=b.n34,I=b.n41,ka=b.n42,P=b.n43;b=b.n44;this.n11=e*Z+g*ga+i*R+l*I;this.n12=e*D+g*T+i*aa+l*ka;this.n13=e*K+g*N+i*V+l*P;this.n14=e*d+g*ba+i*B+l*b;this.n21=n*Z+k*ga+o*R+s*I;this.n22=n*D+k*T+o*aa+s*ka;this.n23=n*K+k*N+o*V+s*P;this.n24=n*d+k*ba+o*B+s*b;this.n31=w*Z+t*ga+x*R+F*I;this.n32=w*D+t*T+x*aa+F*ka;this.n33=w*K+t*N+x*V+F*P;this.n34=w*d+t*ba+x*B+F*b;this.n41=H*Z+G*ga+r*R+a*I;this.n42=H*D+G*T+r*aa+a*ka;this.n43=H*K+G*N+r*V+a*P;this.n44=H*d+G*ba+r*B+a*b;c[0]=this.n11;
  31. c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,i=this.n21,l=this.n22,n=this.n23,k=this.n24,o=this.n31,s=this.n32,w=this.n33,t=this.n34,x=this.n41,F=this.n42,H=this.n43,G=this.n44,r=a.n11,Z=a.n21,D=a.n31,K=a.n41,d=a.n12,ga=a.n22,T=a.n32,N=a.n42,ba=
  32. a.n13,R=a.n23,aa=a.n33,V=a.n43,B=a.n14,I=a.n24,ka=a.n34;a=a.n44;this.n11=b*r+c*Z+e*D+g*K;this.n12=b*d+c*ga+e*T+g*N;this.n13=b*ba+c*R+e*aa+g*V;this.n14=b*B+c*I+e*ka+g*a;this.n21=i*r+l*Z+n*D+k*K;this.n22=i*d+l*ga+n*T+k*N;this.n23=i*ba+l*R+n*aa+k*V;this.n24=i*B+l*I+n*ka+k*a;this.n31=o*r+s*Z+w*D+t*K;this.n32=o*d+s*ga+w*T+t*N;this.n33=o*ba+s*R+w*aa+t*V;this.n34=o*B+s*I+w*ka+t*a;this.n41=x*r+F*Z+H*D+G*K;this.n42=x*d+F*ga+H*T+G*N;this.n43=x*ba+F*R+H*aa+G*V;this.n44=x*B+F*I+H*ka+G*a;return this},multiplyScalar:function(a){this.n11*=
  33. a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,i=this.n22,l=this.n23,n=this.n24,k=this.n31,o=this.n32,s=this.n33,w=this.n34,t=this.n41,x=this.n42,F=this.n43,H=this.n44;return e*l*o*t-c*n*o*t-e*i*s*t+b*n*s*t+c*i*w*t-b*l*w*t-e*l*k*x+c*n*k*x+e*g*s*x-a*n*s*x-c*g*w*x+a*l*w*x+
  34. e*i*k*F-b*n*k*F-e*g*o*F+a*n*o*F+b*g*w*F-a*i*w*F-c*i*k*H+b*l*k*H+c*g*o*H-a*l*o*H-b*g*s*H+a*i*s*H},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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;
  35. a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=
  36. 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,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);
  37. return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),g=1-c,i=a.x,l=a.y,n=a.z,k=g*
  38. i,o=g*l;this.set(k*i+c,k*l-e*n,k*n+e*l,0,k*l+e*n,o*l+c,o*n-e*i,0,k*n-e*l,o*n+e*i,g*n*n+c,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,c=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(-e);e=Math.sin(-e);var i=Math.cos(b);b=Math.sin(b);var l=a*e,n=c*e;this.n11=a*g;this.n12=c*b-l*i;this.n13=l*b+c*i;this.n21=e;this.n22=g*i;this.n23=-g*b;this.n31=-c*g;this.n32=n*i+a*b;this.n33=-n*b+a*i},setRotationFromQuaternion:function(a){var b=
  39. a.x,c=a.y,e=a.z,g=a.w,i=b+b,l=c+c,n=e+e;a=b*i;var k=b*l;b*=n;var o=c*l;c*=n;e*=n;i*=g;l*=g;g*=n;this.n11=1-(o+e);this.n12=k-g;this.n13=b+l;this.n21=k+g;this.n22=1-(a+e);this.n23=c-i;this.n31=b-l;this.n32=c+i;this.n33=1-(a+o)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=b;this.n13*=b;this.n21*=c;this.n22*=c;this.n23*=c;this.n31*=a;this.n32*=a;this.n33*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;
  40. a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};
  41. THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
  42. THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,l=a.n21,n=a.n22,k=a.n23,o=a.n24,s=a.n31,w=a.n32,t=a.n33,x=a.n34,F=a.n41,H=a.n42,G=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*x*H-o*t*H+o*w*G-n*x*G-k*w*r+n*t*r;b.n12=i*t*H-g*x*H-i*w*G+e*x*G+g*w*r-e*t*r;b.n13=g*o*H-i*k*H+i*n*G-e*o*G-g*n*r+e*k*r;b.n14=i*k*w-g*o*w-i*n*t+e*o*t+g*n*x-e*k*x;b.n21=o*t*F-k*x*F-o*s*G+l*x*G+k*s*r-l*t*r;b.n22=g*x*F-i*t*F+i*s*G-c*x*G-g*s*r+c*t*r;b.n23=i*k*F-g*o*F-i*l*G+c*o*G+g*l*r-c*k*r;
  43. b.n24=g*o*s-i*k*s+i*l*t-c*o*t-g*l*x+c*k*x;b.n31=n*x*F-o*w*F+o*s*H-l*x*H-n*s*r+l*w*r;b.n32=i*w*F-e*x*F-i*s*H+c*x*H+e*s*r-c*w*r;b.n33=g*o*F-i*n*F+i*l*H-c*o*H-e*l*r+c*n*r;b.n34=i*n*s-e*o*s-i*l*w+c*o*w+e*l*x-c*n*x;b.n41=k*w*F-n*t*F-k*s*H+l*t*H+n*s*G-l*w*G;b.n42=e*t*F-g*w*F+g*s*H-c*t*H-e*s*G+c*w*G;b.n43=g*n*F-e*k*F-g*l*H+c*k*H+e*l*G-c*n*G;b.n44=e*k*s-g*n*s+g*l*w-c*k*w-e*l*t+c*n*t;b.multiplyScalar(1/a.determinant());return b};
  44. THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,i=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,n=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,o=a.n23*a.n12-a.n22*a.n13,s=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*o;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*i;c[3]=a*l;c[4]=a*n;c[5]=a*k;c[6]=a*o;c[7]=a*s;c[8]=a*w;return b};
  45. THREE.Matrix4.makeFrustum=function(a,b,c,e,g,i){var l;l=new THREE.Matrix4;l.n11=2*g/(b-a);l.n12=0;l.n13=(b+a)/(b-a);l.n14=0;l.n21=0;l.n22=2*g/(e-c);l.n23=(e+c)/(e-c);l.n24=0;l.n31=0;l.n32=0;l.n33=-(i+g)/(i-g);l.n34=-2*i*g/(i-g);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)};
  46. THREE.Matrix4.makeOrtho=function(a,b,c,e,g,i){var l,n,k,o;l=new THREE.Matrix4;n=b-a;k=c-e;o=i-g;l.n11=2/n;l.n12=0;l.n13=0;l.n14=-((b+a)/n);l.n21=0;l.n22=2/k;l.n23=0;l.n24=-((c+e)/k);l.n31=0;l.n32=0;l.n33=-2/o;l.n34=-((i+g)/o);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  47. THREE.Quaternion=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e!==undefined?e:1;this.api={isDirty:!1,that:this,get x(){return this.that.x},get y(){return this.that.y},get z(){return this.that.z},get w(){return this.that.w},set x(g){this.that.x=g;this.isDirty=!0},set y(g){this.that.y=g;this.isDirty=!0},set z(g){this.that.z=g;this.isDirty=!0},set w(g){this.that.w=g;this.isDirty=!0}};this.api.__proto__=THREE.Quaternion.prototype;return this.api};
  48. THREE.Quaternion.prototype.set=function(a,b,c,e){var g=this.that;g.x=a;g.y=b;g.z=c;g.w=e;this.isDirty=!0;return this};THREE.Quaternion.prototype.setFromEuler=function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var i=Math.cos(c);c=Math.sin(c);var l=a*b,n=e*g,k=this.that;k.w=l*i-n*c;k.x=l*c+n*i;k.y=e*b*i+a*g*c;k.z=a*g*i-e*b*c;this.isDirty=!0;return this};
  49. THREE.Quaternion.prototype.calculateW=function(){var a=this.that,b=a.x,c=a.y,e=a.z;a.w=-Math.sqrt(Math.abs(1-b*b-c*c-e*e));this.isDirty=!0;return this};THREE.Quaternion.prototype.inverse=function(){var a=this.that;a.x*=-1;a.y*=-1;a.z*=-1;this.isDirty=!0;return this};THREE.Quaternion.prototype.length=function(){var a=this.that;return Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z+a.w*a.w)};
  50. THREE.Quaternion.prototype.normalize=function(){var a=this.that,b=a.x,c=a.y,e=a.z,g=a.w,i=Math.sqrt(b*b+c*c+e*e+g*g);if(i==0){a.x=0;a.y=0;a.z=0;a.w=0;this.isDirty=!0;return this}i=1/i;a.x=b*i;a.y=c*i;a.z=e*i;a.w=g*i;this.isDirty=!0;return this};
  51. THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.that;qax=b.x;qay=b.y;qaz=b.z;qaw=b.w;qbx=a.x;qby=a.y;qbz=a.z;qbw=a.w;b.x=qax*qbw+qaw*qbx+qay*qbz-qaz*qby;b.y=qay*qbw+qaw*qby+qaz*qbx-qax*qbz;b.z=qaz*qbw+qaw*qbz+qax*qby-qay*qbx;b.w=qaw*qbw-qax*qbx-qay*qby-qaz*qbz;this.isDirty=!0;return this};
  52. THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=this.that,e=a.x,g=a.y,i=a.z,l=c.x,n=c.y,k=c.z;c=c.w;var o=c*e+n*i-k*g,s=c*g+k*e-l*i,w=c*i+l*g-n*e;e=-l*e-n*g-k*i;b.x=o*c+e*-l+s*-k-w*-n;b.y=s*c+e*-n+w*-l-o*-k;b.z=w*c+e*-k+o*-n-s*-l;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
  53. THREE.Quaternion.slerp=function(a,b,c,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var i=Math.acos(g),l=Math.sqrt(1-g*g);if(Math.abs(l)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}g=Math.sin((1-e)*i)/l;e=Math.sin(e*i)/l;c.w=a.w*g+b.w*e;c.x=a.x*g+b.x*e;c.y=a.y*g+b.y*e;c.z=a.z*g+b.z*e;return c};
  54. 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};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
  55. THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  56. THREE.Face4=function(a,b,c,e,g,i){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
  57. THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
  58. THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
  59. c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,g,i,l,n=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){i=this.vertices[e];i.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];if(a&&i.vertexNormals.length){n.set(0,0,0);b=0;for(c=i.normal.length;b<c;b++)n.addSelf(i.vertexNormals[b]);n.divideScalar(3)}else{b=this.vertices[i.a];c=this.vertices[i.b];l=this.vertices[i.c];n.sub(l.position,
  60. c.position);k.sub(b.position,c.position);n.crossSelf(k)}n.isZero()||n.normalize();i.normal.copy(n)}},computeVertexNormals:function(){var a,b,c,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++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
  61. 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++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
  62. b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(B,I,ka,P,ja,ca,Q){i=B.vertices[I].position;l=B.vertices[ka].position;n=B.vertices[P].position;k=g[ja];o=g[ca];s=g[Q];w=l.x-i.x;t=n.x-i.x;x=l.y-i.y;F=n.y-
  63. i.y;H=l.z-i.z;G=n.z-i.z;r=o.u-k.u;Z=s.u-k.u;D=o.v-k.v;K=s.v-k.v;d=1/(r*K-Z*D);N.set((K*w-D*t)*d,(K*x-D*F)*d,(K*H-D*G)*d);ba.set((r*t-Z*w)*d,(r*F-Z*x)*d,(r*G-Z*H)*d);ga[I].addSelf(N);ga[ka].addSelf(N);ga[P].addSelf(N);T[I].addSelf(ba);T[ka].addSelf(ba);T[P].addSelf(ba)}var b,c,e,g,i,l,n,k,o,s,w,t,x,F,H,G,r,Z,D,K,d,ga=[],T=[],N=new THREE.Vector3,ba=new THREE.Vector3,R=new THREE.Vector3,aa=new THREE.Vector3,V=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ga[b]=new THREE.Vector3;T[b]=new THREE.Vector3}b=
  64. 0;for(c=this.faces.length;b<c;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
  65. this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){V.copy(this.vertices[b].normal);e=ga[b];R.copy(e);R.subSelf(V.multiplyScalar(V.dot(e))).normalize();aa.cross(this.vertices[b].normal,e);e=aa.dot(T[b]);e=e<0?-1:1;this.vertices[b].tangent.set(R.x,R.y,R.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],
  66. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;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>
  67. 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,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(s){var w=[];b=0;for(c=s.length;b<c;b++)s[b]==undefined?w.push("undefined"):w.push(s[b].id);return w.join("_")}var b,c,e,g,i,l,n,k,o={};e=0;for(g=this.faces.length;e<g;e++){i=this.faces[e];
  68. l=i.materials;n=a(l);o[n]==undefined&&(o[n]={hash:n,counter:0});k=o[n].hash+"_"+o[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0});i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+i>65535){o[n].counter+=1;k=o[n].hash+"_"+o[n].counter;this.geometryChunks[k]==undefined&&(this.geometryChunks[k]={faces:[],materials:l,vertices:0})}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
  69. this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
  70. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.visible=!0;this.autoUpdateMatrix=!0;this.matrixNeedsToUpdate=!0;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=1;this.rotationMatrix=
  71. new THREE.Matrix4};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.globalMatrix,b,c)}};
  72. THREE.Object3D.prototype.updateMatrix=function(){this.localMatrix.setPosition(this.position);if(this.useQuaternion){if(this.quaternion.isDirty){this.localMatrix.setRotationFromQuaternion(this.quaternion);this.quaternion.isDirty=!1}}else this.localMatrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.localMatrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0};
  73. THREE.Object3D.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a)}};THREE.Object3D.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1){this.children.splice(b,1);a.parent=undefined}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=!1};THREE.Particle.prototype=new THREE.Object3D;
  74. 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,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
  75. THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
  76. THREE.Mesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)}};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;
  77. THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
  78. THREE.Bone.prototype.update=function(a,b,c){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.skinMatrix.multiply(a,this.localMatrix):this.skinMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;if(this.hasNoneBoneChildren){this.globalMatrix.multiply(this.skin.globalMatrix,this.skinMatrix);for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.globalMatrix,!0,c)}}else for(e=
  79. 0;e<g;e++)this.children[e].update(this.skinMatrix,b,c)};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;
  80. THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,e,g,i,l,n;if(this.geometry.bones!==undefined){for(c=0;c<this.geometry.bones.length;c++){g=this.geometry.bones[c];i=g.pos;l=g.rotq;n=g.scl;e=this.addBone();e.name=g.name;e.position.set(i[0],i[1],i[2]);e.quaternion.set(l[0],l[1],l[2],l[3]);n!==undefined?e.scale.set(n[0],n[1],n[2]):e.scale.set(1,1,1)}for(c=0;c<this.bones.length;c++){g=this.geometry.bones[c];e=this.bones[c];
  81. g.parent===-1?this.addChild(e):this.bones[g.parent].addChild(e)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
  82. THREE.SkinnedMesh.prototype.update=function(a,b,c){if(this.visible){this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,c):a.update(this.globalMatrix,b,c)}}};
  83. THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
  84. THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,c*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){c=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,i=this.geometry.skinIndices[a].y;
  85. e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[i].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){c=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=c;this.geometry.skinWeights[a].y+=c}}}};
  86. THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var e=0;e<a.length;e++)a[e].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var e=0;e<c.hierarchy.length;e++)for(var g=0;g<c.hierarchy[e].keys.length;g++){if(c.hierarchy[e].keys[g].time<0)c.hierarchy[e].keys[g].time=0;c.hierarchy[e].keys[g].index=g;if(c.hierarchy[e].keys[g].rot!==undefined&&!(c.hierarchy[e].keys[g].rot instanceof
  87. THREE.Quaternion)){var i=c.hierarchy[e].keys[g].rot;c.hierarchy[e].keys[g].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}g=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(e=0;e<c.hierarchy.length;e++)c.JIT.hierarchy.push(Array(g));c.initialized=!0}};return b}();
  88. THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
  89. THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.0010;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].autoUpdateMatrix=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
  90. this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
  91. THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,e,g,i,l,n=this.data.JIT.hierarchy,k=(new Date).getTime()*0.0010-this.startTime+this.offset,o=k;if(k>this.data.length){for(;k>this.data.length;)k-=this.data.length;this.startTime=(new Date).getTime()*0.0010-k;k=(new Date).getTime()*0.0010-this.startTime}l=Math.min(parseInt(k*this.data.fps),parseInt(this.data.length*this.data.fps));for(var s=0,w=this.hierarchy.length;s<w;s++){i=this.hierarchy[s];if(n[s][l]!==
  92. undefined){i.skinMatrix=n[s][l];i.autoUpdateMatrix=!1;i.matrixNeedsToUpdate=!1;i.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,s*16)}else for(var t=0;t<3;t++){c=a[t];e=i.prevKey[c];g=i.nextKey[c];if(g.time<o){if(k<o)if(this.loop){e=this.data.hierarchy[s].keys[0];g=this.getNextKeyWith(c,s,1)}else{this.stop();return}else{do{e=g;g=this.getNextKeyWith(c,s,g.index+1)}while(g.time<k)}i.prevKey[c]=e;i.nextKey[c]=g}i.autoUpdateMatrix=!0;i.matrixNeedsToUpdate=!0;b=(k-e.time)/(g.time-e.time);e=e[c];
  93. g=g[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(e,g,i.quaternion,b)}else{c=c==="pos"?i.position:i.scale;c.x=e[0]+(g[0]-e[0])*b;c.y=e[1]+(g[1]-e[1])*b;c.z=e[2]+(g[2]-e[2])*b}}}if(n[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(s=0;s<this.hierarchy.length;s++)n[s][l]=this.hierarchy[s].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
  94. THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var e=this.data.hierarchy[b].keys;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
  95. THREE.Camera=function(a,b,c,e,g,i){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=e||2E3;this.screenCenterY=this.screenCenterX=0;this.target=i||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
  96. this.target.position.addSelf(this.tmpVec)};this.translateZ=function(l){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(l);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
  97. THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.FOV,this.aspect,this.zNear,this.zFar)};
  98. THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.autoUpdateMatrix&&(b|=this.updateMatrix());if(b||this.matrixNeedsToUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsToUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
  99. this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
  100. THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,e=a.globalMatrix.n34,g=this.inverseMatrix,i=a.boundRadius*a.boundRadiusScale,l=g.n31*b+g.n32*c+g.n33*e+g.n34;if(l-i>-this.zNear)return!1;if(l+i<-this.zFar)return!1;l-=i;var n=this.projectionMatrix,k=1/(n.n43*l),o=k*this.screenCenterX,s=(g.n11*b+g.n12*c+g.n13*e+g.n14)*n.n11*o;i=n.n11*i*o;if(s+i<-this.screenCenterX)return!1;if(s-i>this.screenCenterX)return!1;b=(g.n21*b+g.n22*c+g.n23*e+g.n24)*n.n22*k*this.screenCenterY;
  101. if(b+i<-this.screenCenterY)return!1;if(b-i>this.screenCenterY)return!1;a.screenPosition.set(s,b,l,i);return!0};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;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
  102. 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;THREE.FlatShading=0;THREE.SmoothShading=1;
  103. THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.MaterialCounter={value:0};
  104. THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
  105. a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
  106. THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
  107. THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){a.color!==
  108. undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==
  109. undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  110. THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+
  111. "<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  112. THREE.MeshLambertMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){a.color!==
  113. undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==
  114. undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  115. THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>light_map: "+this.light_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+
  116. "<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/> )"}};
  117. 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.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=
  118. this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.light_map!==undefined)this.light_map=a.light_map;if(a.map!==undefined)this.map=a.map;if(a.env_map!==undefined)this.env_map=a.env_map;
  119. if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;
  120. if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  121. THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>depth_test: "+
  122. this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  123. THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
  124. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};
  125. THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
  126. undefined)this.wireframe_linewidth=a.wireframe_linewidth}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial (<br/>id: "+this.id+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
  127. THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depth_test=!0;this.wireframe=!1;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";this.vertex_colors=!1;this.skinning=!1;if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=
  128. a.vertex_shader;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.depth_test!==undefined)this.depth_test=a.depth_test;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
  129. undefined)this.wireframe_linejoin=a.wireframe_linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors;if(a.skinning!==undefined)this.skinning=a.skinning}};
  130. THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  131. THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.offset=new THREE.Vector2;this.vertex_colors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==
  132. undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>map: "+this.map+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>depth_test: "+this.depth_test+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
  133. 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}};
  134. THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
  135. THREE.Texture=function(a,b,c,e,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i:THREE.LinearMipMapLinearFilter};
  136. THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;
  137. 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;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
  138. THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrap_s=c.wrap_s!==undefined?c.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=c.wrap_t!==undefined?c.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=c.mag_filter!==undefined?c.mag_filter:THREE.LinearFilter;this.min_filter=c.min_filter!==undefined?c.min_filter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
  139. var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b]){e=a[b][c];g[b][c]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,c,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(c in e)g[c]=e[c]}return g}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
  140. THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];this.fog=null};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};
  141. THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
  142. 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.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;
  143. THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
  144. THREE.Projector=function(){function a(T,N){return N.z-T.z}function b(T,N){var ba=0,R=1,aa=T.z+T.w,V=N.z+N.w,B=-T.z+T.w,I=-N.z+N.w;if(aa>=0&&V>=0&&B>=0&&I>=0)return!0;else if(aa<0&&V<0||B<0&&I<0)return!1;else{if(aa<0)ba=Math.max(ba,aa/(aa-V));else V<0&&(R=Math.min(R,aa/(aa-V)));if(B<0)ba=Math.max(ba,B/(B-I));else I<0&&(R=Math.min(R,B/(B-I)));if(R<ba)return!1;else{T.lerpSelf(N,ba);N.lerpSelf(T,1-R);return!0}}}var c,e,g=[],i,l,n,k=[],o,s,w=[],t,x,F=[],H=new THREE.Vector4,G=new THREE.Vector4,r=new THREE.Matrix4,
  145. Z=new THREE.Matrix4,D=[],K=new THREE.Vector4,d=new THREE.Vector4,ga;this.projectObjects=function(T,N,ba){N=[];var R,aa,V;e=0;aa=T.objects;T=0;for(R=aa.length;T<R;T++){V=aa[T];var B;if(!(B=!V.visible))if(B=V instanceof THREE.Mesh){a:{B=void 0;for(var I=V.globalMatrix,ka=-V.geometry.boundingSphere.radius*Math.max(V.scale.x,Math.max(V.scale.y,V.scale.z)),P=0;P<6;P++){B=D[P].x*I.n14+D[P].y*I.n24+D[P].z*I.n34+D[P].w;if(B<=ka){B=!1;break a}}B=!0}B=!B}if(!B){c=g[e]=g[e]||new THREE.RenderableObject;H.copy(V.position);
  146. r.multiplyVector3(H);c.object=V;c.z=H.z;N.push(c);e++}}ba&&N.sort(a);return N};this.projectScene=function(T,N,ba){var R=[],aa=N.near,V=N.far,B,I,ka,P,ja,ca,Q,ra,wa,f,m,p,j,h,q,v;n=s=x=0;N.autoUpdateMatrix&&N.update();r.multiply(N.projectionMatrix,N.globalMatrix);D[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);D[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);D[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);D[3]=new THREE.Vector4(r.n41-
  147. r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);D[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-r.n33,r.n44-r.n34);D[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);B=0;for(ca=D.length;B<ca;B++){Q=D[B];Q.divideScalar(Math.sqrt(Q.x*Q.x+Q.y*Q.y+Q.z*Q.z))}T.update(undefined,!1,N);ca=this.projectObjects(T,N,!0);T=0;for(B=ca.length;T<B;T++){Q=ca[T].object;if(Q.visible){Q.autoUpdateMatrix&&Q.updateMatrix();ra=Q.globalMatrix;ra.extractRotationMatrix(Q.rotationMatrix);m=Q.rotationMatrix;
  148. wa=Q.materials;f=Q.overdraw;if(Q instanceof THREE.Mesh){p=Q.geometry;j=p.vertices;I=0;for(ka=j.length;I<ka;I++){h=j[I];h.positionWorld.copy(h.position);ra.multiplyVector3(h.positionWorld);P=h.positionScreen;P.copy(h.positionWorld);r.multiplyVector4(P);P.x/=P.w;P.y/=P.w;h.__visible=P.z>aa&&P.z<V}p=p.faces;I=0;for(ka=p.length;I<ka;I++){h=p[I];if(h instanceof THREE.Face3){P=j[h.a];ja=j[h.b];q=j[h.c];if(P.__visible&&ja.__visible&&q.__visible&&(Q.doubleSided||Q.flipSided!=(q.positionScreen.x-P.positionScreen.x)*
  149. (ja.positionScreen.y-P.positionScreen.y)-(q.positionScreen.y-P.positionScreen.y)*(ja.positionScreen.x-P.positionScreen.x)<0)){i=k[n]=k[n]||new THREE.RenderableFace3;i.v1.positionWorld.copy(P.positionWorld);i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(q.positionWorld);i.v1.positionScreen.copy(P.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(q.positionScreen);i.normalWorld.copy(h.normal);m.multiplyVector3(i.normalWorld);i.centroidWorld.copy(h.centroid);
  150. ra.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);q=h.vertexNormals;ga=i.vertexNormalsWorld;P=0;for(ja=q.length;P<ja;P++){v=ga[P]=ga[P]||new THREE.Vector3;v.copy(q[P]);m.multiplyVector3(v)}i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;if(Q.geometry.uvs[I]){i.uvs[0]=Q.geometry.uvs[I][0];i.uvs[1]=Q.geometry.uvs[I][1];i.uvs[2]=Q.geometry.uvs[I][2]}R.push(i);n++}}else if(h instanceof THREE.Face4){P=j[h.a];
  151. ja=j[h.b];q=j[h.c];v=j[h.d];if(P.__visible&&ja.__visible&&q.__visible&&v.__visible&&(Q.doubleSided||Q.flipSided!=((v.positionScreen.x-P.positionScreen.x)*(ja.positionScreen.y-P.positionScreen.y)-(v.positionScreen.y-P.positionScreen.y)*(ja.positionScreen.x-P.positionScreen.x)<0||(ja.positionScreen.x-q.positionScreen.x)*(v.positionScreen.y-q.positionScreen.y)-(ja.positionScreen.y-q.positionScreen.y)*(v.positionScreen.x-q.positionScreen.x)<0))){i=k[n]=k[n]||new THREE.RenderableFace3;i.v1.positionWorld.copy(P.positionWorld);
  152. i.v2.positionWorld.copy(ja.positionWorld);i.v3.positionWorld.copy(v.positionWorld);i.v1.positionScreen.copy(P.positionScreen);i.v2.positionScreen.copy(ja.positionScreen);i.v3.positionScreen.copy(v.positionScreen);i.normalWorld.copy(h.normal);m.multiplyVector3(i.normalWorld);i.centroidWorld.copy(h.centroid);ra.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=wa;i.faceMaterials=h.materials;i.overdraw=f;
  153. if(Q.geometry.uvs[I]){i.uvs[0]=Q.geometry.uvs[I][0];i.uvs[1]=Q.geometry.uvs[I][1];i.uvs[2]=Q.geometry.uvs[I][3]}R.push(i);n++;l=k[n]=k[n]||new THREE.RenderableFace3;l.v1.positionWorld.copy(ja.positionWorld);l.v2.positionWorld.copy(q.positionWorld);l.v3.positionWorld.copy(v.positionWorld);l.v1.positionScreen.copy(ja.positionScreen);l.v2.positionScreen.copy(q.positionScreen);l.v3.positionScreen.copy(v.positionScreen);l.normalWorld.copy(i.normalWorld);l.centroidWorld.copy(i.centroidWorld);l.centroidScreen.copy(i.centroidScreen);
  154. l.z=l.centroidScreen.z;l.meshMaterials=wa;l.faceMaterials=h.materials;l.overdraw=f;if(Q.geometry.uvs[I]){l.uvs[0]=Q.geometry.uvs[I][1];l.uvs[1]=Q.geometry.uvs[I][2];l.uvs[2]=Q.geometry.uvs[I][3]}R.push(l);n++}}}}else if(Q instanceof THREE.Line){Z.multiply(r,ra);j=Q.geometry.vertices;h=j[0];h.positionScreen.copy(h.position);Z.multiplyVector4(h.positionScreen);I=1;for(ka=j.length;I<ka;I++){P=j[I];P.positionScreen.copy(P.position);Z.multiplyVector4(P.positionScreen);ja=j[I-1];K.copy(P.positionScreen);
  155. d.copy(ja.positionScreen);if(b(K,d)){K.multiplyScalar(1/K.w);d.multiplyScalar(1/d.w);o=w[s]=w[s]||new THREE.RenderableLine;o.v1.positionScreen.copy(K);o.v2.positionScreen.copy(d);o.z=Math.max(K.z,d.z);o.materials=Q.materials;R.push(o);s++}}}else if(Q instanceof THREE.Particle){G.set(Q.position.x,Q.position.y,Q.position.z,1);r.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){t=F[x]=F[x]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=Q.rotation.z;t.scale.x=Q.scale.x*Math.abs(t.x-
  156. (G.x+N.projectionMatrix.n11)/(G.w+N.projectionMatrix.n14));t.scale.y=Q.scale.y*Math.abs(t.y-(G.y+N.projectionMatrix.n22)/(G.w+N.projectionMatrix.n24));t.materials=Q.materials;R.push(t);x++}}}}ba&&R.sort(a);return R};this.unprojectVector=function(T,N){var ba=THREE.Matrix4.makeInvert(N.globalMatrix);ba.multiplySelf(THREE.Matrix4.makeInvert(N.projectionMatrix));ba.multiplyVector3(T);return T}};
  157. THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,i;this.domElement=document.createElement("div");this.setSize=function(l,n){c=l;e=n;g=c/2;i=e/2};this.render=function(l,n){var k,o,s,w,t,x,F,H;a=b.projectScene(l,n);k=0;for(o=a.length;k<o;k++){t=a[k];if(t instanceof THREE.RenderableParticle){F=t.x*g+g;H=t.y*i+i;s=0;for(w=t.material.length;s<w;s++){x=t.material[s];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=F+"px";x.style.top=H+"px"}}}}}};
  158. THREE.CanvasRenderer=function(){function a(na){if(t!=na)o.globalAlpha=t=na}function b(na){if(x!=na){switch(na){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}x=na}}var c=null,e=new THREE.Projector,g=document.createElement("canvas"),i,l,n,k,o=g.getContext("2d"),s=new THREE.Color(0),w=0,t=1,x=0,F=null,H=null,G=1,r,Z,D,K,d,ga,T,N,ba,R=new THREE.Color,
  159. aa=new THREE.Color,V=new THREE.Color,B=new THREE.Color,I=new THREE.Color,ka,P,ja,ca,Q,ra,wa,f,m,p=new THREE.Rectangle,j=new THREE.Rectangle,h=new THREE.Rectangle,q=!1,v=new THREE.Color,C=new THREE.Color,W=new THREE.Color,L=new THREE.Color,S=Math.PI*2,E=new THREE.Vector3,da,ea,va,la,ha,ia,fa=16;da=document.createElement("canvas");da.width=da.height=2;ea=da.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);va=ea.getImageData(0,0,2,2);la=va.data;ha=document.createElement("canvas");ha.width=
  160. ha.height=fa;ia=ha.getContext("2d");ia.translate(-fa/2,-fa/2);ia.scale(fa,fa);fa--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(na,y){i=na;l=y;n=i/2;k=l/2;g.width=i;g.height=l;p.set(-n,-k,n,k);t=1;x=0;H=F=null;G=1};this.setClearColor=function(na,y){s=na;w=y;j.set(-n,-k,n,k);o.setTransform(1,0,0,-1,n,k);this.clear()};this.setClearColorHex=function(na,y){s.setHex(na);w=y;j.set(-n,-k,n,k);o.setTransform(1,0,0,-1,n,k);this.clear()};this.clear=function(){o.setTransform(1,
  161. 0,0,-1,n,k);if(!j.isEmpty()){j.inflate(1);j.minSelf(p);if(s.hex==0&&w==0)o.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());else{b(THREE.NormalBlending);a(1);o.fillStyle="rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+w+")";o.fillRect(j.getX(),j.getY(),j.getWidth(),j.getHeight())}j.empty()}};this.render=function(na,y){function Fa(z){var X,Y,A,U=z.lights;C.setRGB(0,0,0);W.setRGB(0,0,0);L.setRGB(0,0,0);z=0;for(X=U.length;z<X;z++){Y=U[z];A=Y.color;if(Y instanceof
  162. THREE.AmbientLight){C.r+=A.r;C.g+=A.g;C.b+=A.b}else if(Y instanceof THREE.DirectionalLight){W.r+=A.r;W.g+=A.g;W.b+=A.b}else if(Y instanceof THREE.PointLight){L.r+=A.r;L.g+=A.g;L.b+=A.b}}}function za(z,X,Y,A){var U,ma,xa,Da,Ea=z.lights;z=0;for(U=Ea.length;z<U;z++){ma=Ea[z];xa=ma.color;Da=ma.intensity;if(ma instanceof THREE.DirectionalLight){ma=Y.dot(ma.position)*Da;if(ma>0){A.r+=xa.r*ma;A.g+=xa.g*ma;A.b+=xa.b*ma}}else if(ma instanceof THREE.PointLight){E.sub(ma.position,X);E.normalize();ma=Y.dot(E)*
  163. Da;if(ma>0){A.r+=xa.r*ma;A.g+=xa.g*ma;A.b+=xa.b*ma}}}}function Ga(z,X,Y){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);var A,U,ma,xa,Da,Ea;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map&&Y.map.image.loaded){xa=Y.map.image;Da=xa.width>>1;Ea=xa.height>>1;U=X.scale.x*n;ma=X.scale.y*k;Y=U*Da;A=ma*Ea;h.set(z.x-Y,z.y-A,z.x+Y,z.y+A);if(p.instersects(h)){o.save();o.translate(z.x,z.y);o.rotate(-X.rotation);o.scale(U,-ma);o.translate(-Da,-Ea);o.drawImage(xa,0,0);o.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(q){v.r=
  164. C.r+W.r+L.r;v.g=C.g+W.g+L.g;v.b=C.b+W.b+L.b;R.r=Y.color.r*v.r;R.g=Y.color.g*v.g;R.b=Y.color.b*v.b;R.updateStyleString()}else R.__styleString=Y.color.__styleString;Y=X.scale.x*n;A=X.scale.y*k;h.set(z.x-Y,z.y-A,z.x+Y,z.y+A);if(p.instersects(h)){U=R.__styleString;if(H!=U)o.fillStyle=H=U;o.save();o.translate(z.x,z.y);o.rotate(-X.rotation);o.scale(Y,A);o.beginPath();o.arc(0,0,1,0,S,!0);o.closePath();o.fill();o.restore()}}}}function O(z,X,Y,A){if(A.opacity!=0){a(A.opacity);b(A.blending);o.beginPath();o.moveTo(z.positionScreen.x,
  165. z.positionScreen.y);o.lineTo(X.positionScreen.x,X.positionScreen.y);o.closePath();if(A instanceof THREE.LineBasicMaterial){R.__styleString=A.color.__styleString;z=A.linewidth;if(G!=z)o.lineWidth=G=z;z=R.__styleString;if(F!=z)o.strokeStyle=F=z;o.stroke();h.inflate(A.linewidth*2)}}}function M(z,X,Y,A,U,ma){if(U.opacity!=0){a(U.opacity);b(U.blending);K=z.positionScreen.x;d=z.positionScreen.y;ga=X.positionScreen.x;T=X.positionScreen.y;N=Y.positionScreen.x;ba=Y.positionScreen.y;o.beginPath();o.moveTo(K,
  166. d);o.lineTo(ga,T);o.lineTo(N,ba);o.lineTo(K,d);o.closePath();if(U instanceof THREE.MeshBasicMaterial)if(U.map)U.map.image.loaded&&U.map.mapping instanceof THREE.UVMapping&&Ca(K,d,ga,T,N,ba,U.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);else if(U.env_map){if(U.env_map.image.loaded&&U.env_map.mapping instanceof THREE.SphericalReflectionMapping){z=y.globalMatrix;E.copy(A.vertexNormalsWorld[0]);ca=(E.x*z.n11+E.y*z.n12+E.z*z.n13)*0.5+0.5;Q=-(E.x*z.n21+E.y*z.n22+E.z*z.n23)*
  167. 0.5+0.5;E.copy(A.vertexNormalsWorld[1]);ra=(E.x*z.n11+E.y*z.n12+E.z*z.n13)*0.5+0.5;wa=-(E.x*z.n21+E.y*z.n22+E.z*z.n23)*0.5+0.5;E.copy(A.vertexNormalsWorld[2]);f=(E.x*z.n11+E.y*z.n12+E.z*z.n13)*0.5+0.5;m=-(E.x*z.n21+E.y*z.n22+E.z*z.n23)*0.5+0.5;Ca(K,d,ga,T,N,ba,U.env_map.image,ca,Q,ra,wa,f,m)}}else U.wireframe?J(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString);else if(U instanceof THREE.MeshLambertMaterial){if(U.map&&!U.wireframe){U.map.mapping instanceof THREE.UVMapping&&Ca(K,
  168. d,ga,T,N,ba,U.map.image,A.uvs[0].u,A.uvs[0].v,A.uvs[1].u,A.uvs[1].v,A.uvs[2].u,A.uvs[2].v);b(THREE.SubtractiveBlending)}if(q)if(!U.wireframe&&U.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){aa.r=V.r=B.r=C.r;aa.g=V.g=B.g=C.g;aa.b=V.b=B.b=C.b;za(ma,A.v1.positionWorld,A.vertexNormalsWorld[0],aa);za(ma,A.v2.positionWorld,A.vertexNormalsWorld[1],V);za(ma,A.v3.positionWorld,A.vertexNormalsWorld[2],B);I.r=(V.r+B.r)*0.5;I.g=(V.g+B.g)*0.5;I.b=(V.b+B.b)*0.5;ja=Aa(aa,V,B,I);Ca(K,d,ga,T,N,ba,
  169. ja,0,0,1,0,0,1)}else{v.r=C.r;v.g=C.g;v.b=C.b;za(ma,A.centroidWorld,A.normalWorld,v);R.r=U.color.r*v.r;R.g=U.color.g*v.g;R.b=U.color.b*v.b;R.updateStyleString();U.wireframe?J(R.__styleString,U.wireframe_linewidth):oa(R.__styleString)}else U.wireframe?J(U.color.__styleString,U.wireframe_linewidth):oa(U.color.__styleString)}else if(U instanceof THREE.MeshDepthMaterial){ka=y.near;P=y.far;aa.r=aa.g=aa.b=1-u(z.positionScreen.z,ka,P);V.r=V.g=V.b=1-u(X.positionScreen.z,ka,P);B.r=B.g=B.b=1-u(Y.positionScreen.z,
  170. ka,P);I.r=(V.r+B.r)*0.5;I.g=(V.g+B.g)*0.5;I.b=(V.b+B.b)*0.5;ja=Aa(aa,V,B,I);Ca(K,d,ga,T,N,ba,ja,0,0,1,0,0,1)}else if(U instanceof THREE.MeshNormalMaterial){R.r=Ba(A.normalWorld.x);R.g=Ba(A.normalWorld.y);R.b=Ba(A.normalWorld.z);R.updateStyleString();U.wireframe?J(R.__styleString,U.wireframe_linewidth):oa(R.__styleString)}}}function J(z,X){if(F!=z)o.strokeStyle=F=z;if(G!=X)o.lineWidth=G=X;o.stroke();h.inflate(X*2)}function oa(z){if(H!=z)o.fillStyle=H=z;o.fill()}function Ca(z,X,Y,A,U,ma,xa,Da,Ea,Ia,
  171. ya,Ja,Qa){var Ka,La;Ka=xa.width-1;La=xa.height-1;Da*=Ka;Ea*=La;Ia*=Ka;ya*=La;Ja*=Ka;Qa*=La;Y-=z;A-=X;U-=z;ma-=X;Ia-=Da;ya-=Ea;Ja-=Da;Qa-=Ea;Ka=Ia*Qa-Ja*ya;if(Ka!=0){La=1/Ka;Ka=(Qa*Y-ya*U)*La;ya=(Qa*A-ya*ma)*La;Y=(Ia*U-Ja*Y)*La;A=(Ia*ma-Ja*A)*La;z=z-Ka*Da-Y*Ea;X=X-ya*Da-A*Ea;o.save();o.transform(Ka,ya,Y,A,z,X);o.clip();o.drawImage(xa,0,0);o.restore()}}function Aa(z,X,Y,A){var U=~~(z.r*255),ma=~~(z.g*255);z=~~(z.b*255);var xa=~~(X.r*255),Da=~~(X.g*255);X=~~(X.b*255);var Ea=~~(Y.r*255),Ia=~~(Y.g*255);
  172. Y=~~(Y.b*255);var ya=~~(A.r*255),Ja=~~(A.g*255);A=~~(A.b*255);la[0]=U<0?0:U>255?255:U;la[1]=ma<0?0:ma>255?255:ma;la[2]=z<0?0:z>255?255:z;la[4]=xa<0?0:xa>255?255:xa;la[5]=Da<0?0:Da>255?255:Da;la[6]=X<0?0:X>255?255:X;la[8]=Ea<0?0:Ea>255?255:Ea;la[9]=Ia<0?0:Ia>255?255:Ia;la[10]=Y<0?0:Y>255?255:Y;la[12]=ya<0?0:ya>255?255:ya;la[13]=Ja<0?0:Ja>255?255:Ja;la[14]=A<0?0:A>255?255:A;ea.putImageData(va,0,0);ia.drawImage(da,0,0);return ha}function u(z,X,Y){z=(z-X)/(Y-X);return z*z*(3-2*z)}function Ba(z){z=(z+
  173. 1)*0.5;return z<0?0:z>1?1:z}function Oa(z,X){var Y=X.x-z.x,A=X.y-z.y,U=1/Math.sqrt(Y*Y+A*A);Y*=U;A*=U;X.x+=Y;X.y+=A;z.x-=Y;z.y-=A}var Ma,Ha,$,sa,pa,ta,ua,qa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,n,k);c=e.projectScene(na,y,this.sortElements);(q=na.lights.length>0)&&Fa(na);Ma=0;for(Ha=c.length;Ma<Ha;Ma++){$=c[Ma];h.empty();if($ instanceof THREE.RenderableParticle){r=$;r.x*=n;r.y*=k;sa=0;for(pa=$.materials.length;sa<pa;sa++)Ga(r,$,$.materials[sa],na)}else if($ instanceof THREE.RenderableLine){r=
  174. $.v1;Z=$.v2;r.positionScreen.x*=n;r.positionScreen.y*=k;Z.positionScreen.x*=n;Z.positionScreen.y*=k;h.addPoint(r.positionScreen.x,r.positionScreen.y);h.addPoint(Z.positionScreen.x,Z.positionScreen.y);if(p.instersects(h)){sa=0;for(pa=$.materials.length;sa<pa;)O(r,Z,$,$.materials[sa++],na)}}else if($ instanceof THREE.RenderableFace3){r=$.v1;Z=$.v2;D=$.v3;r.positionScreen.x*=n;r.positionScreen.y*=k;Z.positionScreen.x*=n;Z.positionScreen.y*=k;D.positionScreen.x*=n;D.positionScreen.y*=k;if($.overdraw){Oa(r.positionScreen,
  175. Z.positionScreen);Oa(Z.positionScreen,D.positionScreen);Oa(D.positionScreen,r.positionScreen)}h.add3Points(r.positionScreen.x,r.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,D.positionScreen.x,D.positionScreen.y);if(p.instersects(h)){sa=0;for(pa=$.meshMaterials.length;sa<pa;){qa=$.meshMaterials[sa++];if(qa instanceof THREE.MeshFaceMaterial){ta=0;for(ua=$.faceMaterials.length;ta<ua;)(qa=$.faceMaterials[ta++])&&M(r,Z,D,$,qa,na)}else M(r,Z,D,$,qa,na)}}}j.addRectangle(h)}o.setTransform(1,0,0,
  176. 1,0,0)}};
  177. THREE.SVGRenderer=function(){function a(ca,Q,ra){var wa,f,m,p;wa=0;for(f=ca.lights.length;wa<f;wa++){m=ca.lights[wa];if(m instanceof THREE.DirectionalLight){p=Q.normalWorld.dot(m.position)*m.intensity;if(p>0){ra.r+=m.color.r*p;ra.g+=m.color.g*p;ra.b+=m.color.b*p}}else if(m instanceof THREE.PointLight){ba.sub(m.position,Q.centroidWorld);ba.normalize();p=Q.normalWorld.dot(ba)*m.intensity;if(p>0){ra.r+=m.color.r*p;ra.g+=m.color.g*p;ra.b+=m.color.b*p}}}}function b(ca,Q,ra,wa,f,m){B=e(I++);B.setAttribute("d","M "+
  178. ca.positionScreen.x+" "+ca.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)D.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(Z){K.r=d.r;K.g=d.g;K.b=d.b;a(m,wa,K);D.r=f.color.r*K.r;D.g=f.color.g*K.g;D.b=f.color.b*K.b;D.updateStyleString()}else D.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshDepthMaterial){N=1-f.__2near/(f.__farPlusNear-
  179. wa.z*f.__farMinusNear);D.setRGB(N,N,N)}else f instanceof THREE.MeshNormalMaterial&&D.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));f.wireframe?B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):B.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+f.opacity);n.appendChild(B)}function c(ca,Q,ra,wa,
  180. f,m,p){B=e(I++);B.setAttribute("d","M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(m instanceof THREE.MeshBasicMaterial)D.__styleString=m.color.__styleString;else if(m instanceof THREE.MeshLambertMaterial)if(Z){K.r=d.r;K.g=d.g;K.b=d.b;a(p,f,K);D.r=m.color.r*K.r;D.g=m.color.g*K.g;D.b=m.color.b*K.b;D.updateStyleString()}else D.__styleString=m.color.__styleString;
  181. else if(m instanceof THREE.MeshDepthMaterial){N=1-m.__2near/(m.__farPlusNear-f.z*m.__farMinusNear);D.setRGB(N,N,N)}else m instanceof THREE.MeshNormalMaterial&&D.setRGB(g(f.normalWorld.x),g(f.normalWorld.y),g(f.normalWorld.z));m.wireframe?B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+m.wireframe_linewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframe_linecap+"; stroke-linejoin: "+m.wireframe_linejoin):B.setAttribute("style","fill: "+D.__styleString+
  182. "; fill-opacity: "+m.opacity);n.appendChild(B)}function e(ca){if(R[ca]==null){R[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");ja==0&&R[ca].setAttribute("shape-rendering","crispEdges")}return R[ca]}function g(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var i=null,l=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,o,s,w,t,x,F,H,G=new THREE.Rectangle,r=new THREE.Rectangle,Z=!1,D=new THREE.Color(16777215),K=new THREE.Color(16777215),
  183. d=new THREE.Color(0),ga=new THREE.Color(0),T=new THREE.Color(0),N,ba=new THREE.Vector3,R=[],aa=[],V=[],B,I,ka,P,ja=1;this.domElement=n;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ca){switch(ca){case "high":ja=1;break;case "low":ja=0}};this.setSize=function(ca,Q){k=ca;o=Q;s=k/2;w=o/2;n.setAttribute("viewBox",-s+" "+-w+" "+k+" "+o);n.setAttribute("width",k);n.setAttribute("height",o);G.set(-s,-w,s,w)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};
  184. this.render=function(ca,Q){var ra,wa,f,m,p,j,h,q;this.autoClear&&this.clear();i=l.projectScene(ca,Q,this.sortElements);P=ka=I=0;if(Z=ca.lights.length>0){h=ca.lights;d.setRGB(0,0,0);ga.setRGB(0,0,0);T.setRGB(0,0,0);ra=0;for(wa=h.length;ra<wa;ra++){f=h[ra];m=f.color;if(f instanceof THREE.AmbientLight){d.r+=m.r;d.g+=m.g;d.b+=m.b}else if(f instanceof THREE.DirectionalLight){ga.r+=m.r;ga.g+=m.g;ga.b+=m.b}else if(f instanceof THREE.PointLight){T.r+=m.r;T.g+=m.g;T.b+=m.b}}}ra=0;for(wa=i.length;ra<wa;ra++){h=
  185. i[ra];r.empty();if(h instanceof THREE.RenderableParticle){t=h;t.x*=s;t.y*=-w;f=0;for(m=h.materials.length;f<m;f++)if(q=h.materials[f]){p=t;j=h;var v=ka++;if(aa[v]==null){aa[v]=document.createElementNS("http://www.w3.org/2000/svg","circle");ja==0&&aa[v].setAttribute("shape-rendering","crispEdges")}B=aa[v];B.setAttribute("cx",p.x);B.setAttribute("cy",p.y);B.setAttribute("r",j.scale.x*s);if(q instanceof THREE.ParticleCircleMaterial){if(Z){K.r=d.r+ga.r+T.r;K.g=d.g+ga.g+T.g;K.b=d.b+ga.b+T.b;D.r=q.color.r*
  186. K.r;D.g=q.color.g*K.g;D.b=q.color.b*K.b;D.updateStyleString()}else D=q.color;B.setAttribute("style","fill: "+D.__styleString)}n.appendChild(B)}}else if(h instanceof THREE.RenderableLine){t=h.v1;x=h.v2;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(r)){f=0;for(m=h.materials.length;f<m;)if(q=h.materials[f++]){p=t;j=x;v=P++;if(V[v]==null){V[v]=
  187. document.createElementNS("http://www.w3.org/2000/svg","line");ja==0&&V[v].setAttribute("shape-rendering","crispEdges")}B=V[v];B.setAttribute("x1",p.positionScreen.x);B.setAttribute("y1",p.positionScreen.y);B.setAttribute("x2",j.positionScreen.x);B.setAttribute("y2",j.positionScreen.y);if(q instanceof THREE.LineBasicMaterial){D.__styleString=q.color.__styleString;B.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+q.linewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+
  188. q.linecap+"; stroke-linejoin: "+q.linejoin);n.appendChild(B)}}}}else if(h instanceof THREE.RenderableFace3){t=h.v1;x=h.v2;F=h.v3;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(G.instersects(r)){f=0;for(m=h.meshMaterials.length;f<m;){q=h.meshMaterials[f++];if(q instanceof
  189. THREE.MeshFaceMaterial){p=0;for(j=h.faceMaterials.length;p<j;)(q=h.faceMaterials[p++])&&b(t,x,F,h,q,ca)}else q&&b(t,x,F,h,q,ca)}}}else if(h instanceof THREE.RenderableFace4){t=h.v1;x=h.v2;F=h.v3;H=h.v4;t.positionScreen.x*=s;t.positionScreen.y*=-w;x.positionScreen.x*=s;x.positionScreen.y*=-w;F.positionScreen.x*=s;F.positionScreen.y*=-w;H.positionScreen.x*=s;H.positionScreen.y*=-w;r.addPoint(t.positionScreen.x,t.positionScreen.y);r.addPoint(x.positionScreen.x,x.positionScreen.y);r.addPoint(F.positionScreen.x,
  190. F.positionScreen.y);r.addPoint(H.positionScreen.x,H.positionScreen.y);if(G.instersects(r)){f=0;for(m=h.meshMaterials.length;f<m;){q=h.meshMaterials[f++];if(q instanceof THREE.MeshFaceMaterial){p=0;for(j=h.faceMaterials.length;p<j;)(q=h.faceMaterials[p++])&&c(t,x,F,H,h,q,ca)}else q&&c(t,x,F,H,h,q,ca)}}}}}};
  191. THREE.WebGLRenderer=function(a){function b(f,m,p){var j,h,q,v=f.vertices,C=v.length,W=f.colors,L=W.length,S=f.__vertexArray,E=f.__colorArray,da=f.__sortArray,ea=f.__dirtyVertices,va=f.__dirtyColors;if(p.sortParticles){I.multiplySelf(p.globalMatrix);for(j=0;j<C;j++){h=v[j].position;ca.copy(h);I.multiplyVector3(ca);da[j]=[ca.z,j]}da.sort(function(la,ha){return ha[0]-la[0]});for(j=0;j<C;j++){h=v[da[j][1]].position;q=j*3;S[q]=h.x;S[q+1]=h.y;S[q+2]=h.z}for(j=0;j<L;j++){q=j*3;color=W[da[j][1]];E[q]=color.r;
  192. E[q+1]=color.g;E[q+2]=color.b}}else{if(ea)for(j=0;j<C;j++){h=v[j].position;q=j*3;S[q]=h.x;S[q+1]=h.y;S[q+2]=h.z}if(va)for(j=0;j<L;j++){color=W[j];q=j*3;E[q]=color.r;E[q+1]=color.g;E[q+2]=color.b}}if(ea||p.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,S,m)}if(va||p.sortParticles){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,E,m)}}function c(f,m){f.fragment_shader=m.fragment_shader;f.vertex_shader=m.vertex_shader;f.uniforms=
  193. Uniforms.clone(m.uniforms)}function e(f,m,p,j,h){j.program||N.initMaterial(j,m,p);var q=j.program,v=q.uniforms,C=j.uniforms;if(q!=ga){d.useProgram(q);ga=q;d.uniformMatrix4fv(v.projectionMatrix,!1,ka)}if(p&&(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial||j instanceof THREE.LineBasicMaterial||j instanceof THREE.ParticleBasicMaterial)){C.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){C.fogNear.value=p.near;C.fogFar.value=
  194. p.far}else if(p instanceof THREE.FogExp2)C.fogDensity.value=p.density}if(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial){var W,L,S=0,E=0,da=0,ea,va,la,ha=N.lights,ia=ha.directional.colors,fa=ha.directional.positions,na=ha.point.colors,y=ha.point.positions,Fa=0,za=0;p=L=L=0;for(W=m.length;p<W;p++){L=m[p];ea=L.color;va=L.position;la=L.intensity;if(L instanceof THREE.AmbientLight){S+=ea.r;E+=ea.g;da+=ea.b}else if(L instanceof THREE.DirectionalLight){L=Fa*3;ia[L]=ea.r*la;
  195. ia[L+1]=ea.g*la;ia[L+2]=ea.b*la;fa[L]=va.x;fa[L+1]=va.y;fa[L+2]=va.z;Fa+=1}else if(L instanceof THREE.PointLight){L=za*3;na[L]=ea.r*la;na[L+1]=ea.g*la;na[L+2]=ea.b*la;y[L]=va.x;y[L+1]=va.y;y[L+2]=va.z;za+=1}}for(p=Fa*3;p<ia.length;p++)ia[p]=0;for(p=za*3;p<na.length;p++)na[p]=0;ha.point.length=za;ha.directional.length=Fa;ha.ambient[0]=S;ha.ambient[1]=E;ha.ambient[2]=da;m=N.lights;C.enableLighting.value=m.directional.length+m.point.length;C.ambientLightColor.value=m.ambient;C.directionalLightColor.value=
  196. m.directional.colors;C.directionalLightDirection.value=m.directional.positions;C.pointLightColor.value=m.point.colors;C.pointLightPosition.value=m.point.positions}if(j instanceof THREE.MeshBasicMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshPhongMaterial){C.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity;C.map.texture=j.map;C.light_map.texture=j.light_map;C.env_map.texture=j.env_map;C.reflectivity.value=j.reflectivity;
  197. C.refraction_ratio.value=j.refraction_ratio;C.combine.value=j.combine;C.useRefract.value=j.env_map&&j.env_map.mapping instanceof THREE.CubeRefractionMapping}if(j instanceof THREE.LineBasicMaterial){C.diffuse.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity}else if(j instanceof THREE.ParticleBasicMaterial){C.psColor.value.setRGB(j.color.r*j.opacity,j.color.g*j.opacity,j.color.b*j.opacity);C.opacity.value=j.opacity;C.size.value=j.size;C.map.texture=
  198. j.map}else if(j instanceof THREE.MeshPhongMaterial){C.ambient.value.setRGB(j.ambient.r,j.ambient.g,j.ambient.b);C.specular.value.setRGB(j.specular.r,j.specular.g,j.specular.b);C.shininess.value=j.shininess}else if(j instanceof THREE.MeshDepthMaterial){C.mNear.value=f.near;C.mFar.value=f.far;C.opacity.value=j.opacity}else if(j instanceof THREE.MeshNormalMaterial)C.opacity.value=j.opacity;for(var Ga in C)if(S=q.uniforms[Ga]){p=C[Ga];W=p.type;m=p.value;if(W=="i")d.uniform1i(S,m);else if(W=="f")d.uniform1f(S,
  199. m);else if(W=="fv1")d.uniform1fv(S,m);else if(W=="fv")d.uniform3fv(S,m);else if(W=="v2")d.uniform2f(S,m.x,m.y);else if(W=="v3")d.uniform3f(S,m.x,m.y,m.z);else if(W=="c")d.uniform3f(S,m.r,m.g,m.b);else if(W=="t"){d.uniform1i(S,m);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(!p.image.__webGLTextureCube&&!p.image.__cubeMapInitialized&&p.image.loadCount==6){p.image.__webGLTextureCube=d.createTexture();d.bindTexture(d.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);
  200. d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR);d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.LINEAR_MIPMAP_LINEAR);for(W=0;W<6;++W)d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,p.image[W]);d.generateMipmap(d.TEXTURE_CUBE_MAP);d.bindTexture(d.TEXTURE_CUBE_MAP,null);p.image.__cubeMapInitialized=!0}d.activeTexture(d.TEXTURE0+
  201. m);d.bindTexture(d.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(!p.__webGLTexture&&p.image.loaded){p.__webGLTexture=d.createTexture();d.bindTexture(d.TEXTURE_2D,p.__webGLTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,p.image);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,D(p.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,D(p.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,D(p.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,D(p.min_filter));
  202. d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}d.activeTexture(d.TEXTURE0+m);d.bindTexture(d.TEXTURE_2D,p.__webGLTexture)}}}d.uniformMatrix4fv(v.modelViewMatrix,!1,h._modelViewMatrixArray);d.uniformMatrix3fv(v.normalMatrix,!1,h._normalMatrixArray);(j instanceof THREE.MeshShaderMaterial||j instanceof THREE.MeshPhongMaterial||j.env_map)&&d.uniform3f(v.cameraPosition,f.position.x,f.position.y,f.position.z);(j instanceof THREE.MeshShaderMaterial||j.env_map||j.skinning)&&d.uniformMatrix4fv(v.objectMatrix,
  203. !1,h._objectMatrixArray);(j instanceof THREE.MeshPhongMaterial||j instanceof THREE.MeshLambertMaterial||j instanceof THREE.MeshShaderMaterial||j.skinning)&&d.uniformMatrix4fv(v.viewMatrix,!1,ja);if(j.skinning){d.uniformMatrix4fv(v.cameraInverseMatrix,!1,P);d.uniformMatrix4fv(v.uBoneGlobalMatrices,!1,h.boneMatrices)}return q}function g(f,m,p,j,h,q){f=e(f,m,p,j,q).attributes;d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.vertexAttribPointer(f.position,3,d.FLOAT,!1,0,0);if(f.color>=0){d.bindBuffer(d.ARRAY_BUFFER,
  204. h.__webGLColorBuffer);d.vertexAttribPointer(f.color,3,d.FLOAT,!1,0,0)}if(f.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.vertexAttribPointer(f.normal,3,d.FLOAT,!1,0,0)}if(f.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.vertexAttribPointer(f.tangent,4,d.FLOAT,!1,0,0)}if(f.uv>=0)if(h.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.vertexAttribPointer(f.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv)}else d.disableVertexAttribArray(f.uv);if(f.uv2>=
  205. 0)if(h.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUV2Buffer);d.vertexAttribPointer(f.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(f.uv2)}else d.disableVertexAttribArray(f.uv2);if(j.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);d.vertexAttribPointer(f.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);d.vertexAttribPointer(f.skinVertexB,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,
  206. h.__webGLSkinIndicesBuffer);d.vertexAttribPointer(f.skinIndex,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);d.vertexAttribPointer(f.skinWeight,4,d.FLOAT,!1,0,0)}if(q instanceof THREE.Mesh)if(j.wireframe){d.lineWidth(j.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.drawElements(d.LINES,h.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,h.__webGLFaceCount,d.UNSIGNED_SHORT,
  207. 0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(j.linewidth);d.drawArrays(q,0,h.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,h.__webGLParticleCount)}function i(f,m){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=d.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=d.createBuffer();if(f.hasPos){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,f.positionArray,d.DYNAMIC_DRAW);
  208. d.enableVertexAttribArray(m.attributes.position);d.vertexAttribPointer(m.attributes.position,3,d.FLOAT,!1,0,0)}if(f.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,f.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,f.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(m.attributes.normal);d.vertexAttribPointer(m.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,f.count);f.count=0}function l(f){if(ba!=f.doubleSided){f.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);ba=f.doubleSided}if(R!=
  209. f.flipSided){f.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);R=f.flipSided}}function n(f){if(V!=f){f?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);V=f}}function k(f){B[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);B[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);B[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);B[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);B[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);B[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,
  210. f.n44+f.n34);var m;for(f=0;f<5;f++){m=B[f];m.divideScalar(Math.sqrt(m.x*m.x+m.y*m.y+m.z*m.z))}}function o(f){for(var m=f.globalMatrix,p=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),j=0;j<6;j++){f=B[j].x*m.n14+B[j].y*m.n24+B[j].z*m.n34+B[j].w;if(f<=p)return!1}return!0}function s(f,m){f.list[f.count]=m;f.count+=1}function w(f){var m,p,j=f.object,h=f.opaque,q=f.transparent;q.count=0;f=h.count=0;for(m=j.materials.length;f<m;f++){p=j.materials[f];p.opacity&&p.opacity<
  211. 1||p.blending!=THREE.NormalBlending?s(q,p):s(h,p)}}function t(f){var m,p,j,h,q=f.object,v=f.buffer,C=f.opaque,W=f.transparent;W.count=0;f=C.count=0;for(j=q.materials.length;f<j;f++){m=q.materials[f];if(m instanceof THREE.MeshFaceMaterial){m=0;for(p=v.materials.length;m<p;m++)(h=v.materials[m])&&(h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(C,h))}else{h=m;h.opacity&&h.opacity<1||h.blending!=THREE.NormalBlending?s(W,h):s(C,h)}}}function x(f,m){return m.z-f.z}function F(f,m,p,j,
  212. h){if(m[p]==undefined){f.push({buffer:j,object:h,opaque:{list:[],count:0},transparent:{list:[],count:0}});m[p]=1}}function H(f,m){f._modelViewMatrix.multiplyToArray(m.globalMatrix,f.globalMatrix,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function G(f){if(f!=aa){switch(f){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE);break;case THREE.SubtractiveBlending:d.blendFunc(d.DST_COLOR,d.ZERO);break;case THREE.BillboardBlending:d.blendEquation(d.FUNC_ADD);
  213. d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);break;default:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA)}aa=f}}function r(f,m){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=d.createFramebuffer();f.__webGLRenderbuffer=d.createRenderbuffer();f.__webGLTexture=d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,f.__webGLRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,f.width,f.height);d.bindTexture(d.TEXTURE_2D,f.__webGLTexture);d.texParameteri(d.TEXTURE_2D,
  214. d.TEXTURE_WRAP_S,D(f.wrap_s));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,D(f.wrap_t));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,D(f.mag_filter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,D(f.min_filter));d.texImage2D(d.TEXTURE_2D,0,D(f.format),f.width,f.height,0,D(f.format),D(f.type),null);d.bindFramebuffer(d.FRAMEBUFFER,f.__webGLFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,f.__webGLTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,
  215. d.RENDERBUFFER,f.__webGLRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var p,j,h;if(f){p=f.__webGLFramebuffer;j=f.width;h=f.height}else{p=null;j=K.width;h=K.height}if(p!=T){d.bindFramebuffer(d.FRAMEBUFFER,p);d.viewport(0,0,j,h);m&&d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT);T=p}}function Z(f,m){var p;if(f=="fragment")p=d.createShader(d.FRAGMENT_SHADER);else f=="vertex"&&(p=d.createShader(d.VERTEX_SHADER));d.shaderSource(p,
  216. m);d.compileShader(p);if(!d.getShaderParameter(p,d.COMPILE_STATUS)){alert(d.getShaderInfoLog(p));return null}return p}function D(f){switch(f){case THREE.RepeatWrapping:return d.REPEAT;case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;
  217. case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE;case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;
  218. case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var K=document.createElement("canvas"),d,ga=null,T=null,N=this,ba=null,R=null,aa=null,V=null,B=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Matrix4,ka=new Float32Array(16),P=new Float32Array(16),ja=new Float32Array(16),ca=new THREE.Vector4,Q=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)Q=a.antialias;
  219. a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=K;this.autoClear=!0;this.sortObjects=!1;(function(f,m,p){try{d=K.getContext("experimental-webgl",{antialias:f})}catch(j){console.log(j)}if(!d){alert("WebGL not supported");throw"cannot create webgl context";}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendFunc(d.ONE,d.ONE_MINUS_SRC_ALPHA);
  220. d.clearColor(m.r,m.g,m.b,p);_cullEnabled=!0})(Q,ra,wa);this.context=d;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,m){K.width=f;K.height=m;d.viewport(0,0,K.width,K.height)};this.setClearColorHex=function(f,m){var p=new THREE.Color(f);d.clearColor(p.r,p.g,p.b,m)};this.setClearColor=function(f,m){d.clearColor(f.r,f.g,f.b,m)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT)};this.initMaterial=
  221. function(f,m,p){var j,h;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&
  222. c(f,THREE.ShaderLib.particle_basic);var q,v,C,W;h=C=W=0;for(q=m.length;h<q;h++){v=m[h];v instanceof THREE.DirectionalLight&&C++;v instanceof THREE.PointLight&&W++}if(W+C<=4)m=C;else{m=Math.ceil(4*C/(W+C));W=4-m}h={directional:m,point:W};W=f.fragment_shader;m=f.vertex_shader;q={fog:p,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,skinning:f.skinning,maxDirLights:h.directional,maxPointLights:h.point};p=d.createProgram();h=["#ifdef GL_ES\nprecision highp float;\n#endif",
  223. "#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+
  224. q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"",q.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
  225. d.attachShader(p,Z("fragment",h+W));d.attachShader(p,Z("vertex",q+m));d.linkProgram(p);d.getProgramParameter(p,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(p,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");p.uniforms={};p.attributes={};f.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","uBoneGlobalMatrices"];for(j in f.uniforms)p.push(j);j=f.program;W=0;for(m=p.length;W<
  226. m;W++){h=p[W];j.uniforms[h]=d.getUniformLocation(j,h)}j=f.program;p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];W=0;for(m=p.length;W<m;W++){h=p[W];j.attributes[h]=d.getAttribLocation(j,h)}j=f.program.attributes;d.enableVertexAttribArray(j.position);j.color>=0&&d.enableVertexAttribArray(j.color);j.normal>=0&&d.enableVertexAttribArray(j.normal);j.tangent>=0&&d.enableVertexAttribArray(j.tangent);if(f.skinning&&j.skinVertexA>=0&&j.skinVertexB>=
  227. 0&&j.skinIndex>=0&&j.skinWeight>=0){d.enableVertexAttribArray(j.skinVertexA);d.enableVertexAttribArray(j.skinVertexB);d.enableVertexAttribArray(j.skinIndex);d.enableVertexAttribArray(j.skinWeight)}};this.render=function(f,m,p,j){var h,q,v,C,W,L,S,E,da=f.lights,ea=f.fog;m.autoUpdateMatrix&&m.update();m.globalMatrix.flattenToArray(ja);m.projectionMatrix.flattenToArray(ka);m.inverseMatrix.flattenToArray(P);I.multiply(m.projectionMatrix,m.globalMatrix);k(I);THREE.AnimationHandler&&THREE.AnimationHandler.update();
  228. f.update(undefined,!1,m);this.initWebGLObjects(f,m);r(p,j!==undefined?j:!0);this.autoClear&&this.clear();W=f.__webGLObjects.length;for(j=0;j<W;j++){h=f.__webGLObjects[j];S=h.object;if(S.visible)if(!(S instanceof THREE.Mesh)||o(S)){S.globalMatrix.flattenToArray(S._objectMatrixArray);H(S,m);t(h);h.render=!0;if(this.sortObjects){ca.copy(S.position);I.multiplyVector3(ca);h.z=ca.z}}else h.render=!1;else h.render=!1}this.sortObjects&&f.__webGLObjects.sort(x);L=f.__webGLObjectsImmediate.length;for(j=0;j<
  229. L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){S.autoUpdateMatrix&&S.globalMatrix.flattenToArray(S._objectMatrixArray);H(S,m);w(h)}}G(THREE.NormalBlending);for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){S=h.object;E=h.buffer;v=h.opaque;l(S);for(h=0;h<v.count;h++){C=v.list[h];n(C.depth_test);g(m,da,ea,C,E,S)}}}for(j=0;j<L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){v=h.opaque;l(S);for(h=0;h<v.count;h++){C=v.list[h];n(C.depth_test);q=e(m,da,ea,C,S);S.render(function(va){i(va,
  230. q)})}}}for(j=0;j<W;j++){h=f.__webGLObjects[j];if(h.render){S=h.object;E=h.buffer;v=h.transparent;l(S);for(h=0;h<v.count;h++){C=v.list[h];G(C.blending);n(C.depth_test);g(m,da,ea,C,E,S)}}}for(j=0;j<L;j++){h=f.__webGLObjectsImmediate[j];S=h.object;if(S.visible){v=h.transparent;l(S);for(h=0;h<v.count;h++){C=v.list[h];G(C.blending);n(C.depth_test);q=e(m,da,ea,C,S);S.render(function(va){i(va,q)})}}}if(p&&p.min_filter!==THREE.NearestFilter&&p.min_filter!==THREE.LinearFilter){d.bindTexture(d.TEXTURE_2D,p.__webGLTexture);
  231. d.generateMipmap(d.TEXTURE_2D);d.bindTexture(d.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){var m,p,j;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}m=0;for(p=f.objects.length;m<p;m++){j=f.objects[m];var h=f,q=void 0,v=void 0,C=void 0,W=void 0;v=j.geometry;if(h.__webGLObjectsMap[j.id]==undefined){h.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);
  232. j._objectMatrixArray=new Float32Array(16);j.globalMatrix.flattenToArray(j._objectMatrixArray)}W=h.__webGLObjectsMap[j.id];objlist=h.__webGLObjects;if(j instanceof THREE.Mesh){for(q in v.geometryChunks){C=v.geometryChunks[q];if(!C.__webGLVertexBuffer){h=C;h.__webGLVertexBuffer=d.createBuffer();h.__webGLNormalBuffer=d.createBuffer();h.__webGLTangentBuffer=d.createBuffer();h.__webGLColorBuffer=d.createBuffer();h.__webGLUVBuffer=d.createBuffer();h.__webGLUV2Buffer=d.createBuffer();h.__webGLSkinVertexABuffer=
  233. d.createBuffer();h.__webGLSkinVertexBBuffer=d.createBuffer();h.__webGLSkinIndicesBuffer=d.createBuffer();h.__webGLSkinWeightsBuffer=d.createBuffer();h.__webGLFaceBuffer=d.createBuffer();h.__webGLLineBuffer=d.createBuffer();h=C;var L=j,S=void 0,E=void 0,da=0,ea=0,va=0,la=L.geometry.faces,ha=h.faces;S=0;for(E=ha.length;S<E;S++){fi=ha[S];face=la[fi];if(face instanceof THREE.Face3){da+=3;ea+=1;va+=3}else if(face instanceof THREE.Face4){da+=4;ea+=2;va+=4}}h.__vertexArray=new Float32Array(da*3);h.__normalArray=
  234. new Float32Array(da*3);h.__tangentArray=new Float32Array(da*4);h.__colorArray=new Float32Array(da*3);h.__uvArray=new Float32Array(da*2);h.__uv2Array=new Float32Array(da*2);h.__skinVertexAArray=new Float32Array(da*4);h.__skinVertexBArray=new Float32Array(da*4);h.__skinIndexArray=new Float32Array(da*4);h.__skinWeightArray=new Float32Array(da*4);h.__faceArray=new Uint16Array(ea*3);h.__lineArray=new Uint16Array(va*2);E=S=h;da=void 0;la=void 0;var ia=void 0,fa=void 0;ia=void 0;ha=!1;da=0;for(la=L.materials.length;da<
  235. la;da++){ia=L.materials[da];if(ia instanceof THREE.MeshFaceMaterial){ia=0;for(fa=E.materials.length;ia<fa;ia++)if(E.materials[ia]&&E.materials[ia].shading!=undefined&&E.materials[ia].shading==THREE.SmoothShading){ha=!0;break}}else if(ia&&ia.shading!=undefined&&ia.shading==THREE.SmoothShading){ha=!0;break}if(ha)break}S.__needsSmoothNormals=ha;h.__webGLFaceCount=ea*3;h.__webGLLineCount=va*2;v.__dirtyVertices=!0;v.__dirtyElements=!0;v.__dirtyUvs=!0;v.__dirtyNormals=!0;v.__dirtyTangents=!0;v.__dirtyColors=
  236. !0}if(v.__dirtyVertices||v.__dirtyElements||v.__dirtyUvs||v.__dirtyNormals||v.__dirtyColors||v.__dirtyTangents){h=C;ea=d.DYNAMIC_DRAW;va=void 0;S=void 0;var na=void 0,y=void 0,Fa=void 0,za=void 0,Ga=void 0;na=void 0;var O=void 0,M=void 0,J=void 0,oa=void 0;O=void 0;M=void 0;J=void 0;y=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;O=void 0;M=void 0;J=void 0;oa=void 0;y=void 0;za=void 0;Fa=void 0;
  237. Ga=void 0;var Ca=fa=ia=ha=la=da=L=E=0,Aa=0,u=0,Ba=h.__vertexArray,Oa=h.__uvArray,Ma=h.__uv2Array,Ha=h.__normalArray,$=h.__tangentArray,sa=h.__colorArray,pa=h.__skinVertexAArray,ta=h.__skinVertexBArray,ua=h.__skinIndexArray,qa=h.__skinWeightArray,z=h.__faceArray,X=h.__lineArray,Y=h.__needsSmoothNormals,A=j.geometry,U=A.__dirtyVertices,ma=A.__dirtyElements,xa=A.__dirtyUvs,Da=A.__dirtyNormals,Ea=A.__dirtyTangents,Ia=A.__dirtyColors,ya=A.vertices,Ja=h.faces,Qa=A.faces,Ka=A.uvs,La=A.uvs2,Na=A.colors,Ra=
  238. A.skinVerticesA,Sa=A.skinVerticesB,Ta=A.skinIndices,Pa=A.skinWeights;va=0;for(S=Ja.length;va<S;va++){na=Ja[va];y=Qa[na];Ga=Ka[na];na=La[na];Fa=y.vertexNormals;za=y.normal;if(y instanceof THREE.Face3){if(U){O=ya[y.a].position;M=ya[y.b].position;J=ya[y.c].position;Ba[L]=O.x;Ba[L+1]=O.y;Ba[L+2]=O.z;Ba[L+3]=M.x;Ba[L+4]=M.y;Ba[L+5]=M.z;Ba[L+6]=J.x;Ba[L+7]=J.y;Ba[L+8]=J.z;L+=9}if(Pa.length){O=Pa[y.a];M=Pa[y.b];J=Pa[y.c];qa[u]=O.x;qa[u+1]=O.y;qa[u+2]=O.z;qa[u+3]=O.w;qa[u+4]=M.x;qa[u+5]=M.y;qa[u+6]=M.z;qa[u+
  239. 7]=M.w;qa[u+8]=J.x;qa[u+9]=J.y;qa[u+10]=J.z;qa[u+11]=J.w;O=Ta[y.a];M=Ta[y.b];J=Ta[y.c];ua[u]=O.x;ua[u+1]=O.y;ua[u+2]=O.z;ua[u+3]=O.w;ua[u+4]=M.x;ua[u+5]=M.y;ua[u+6]=M.z;ua[u+7]=M.w;ua[u+8]=J.x;ua[u+9]=J.y;ua[u+10]=J.z;ua[u+11]=J.w;O=Ra[y.a];M=Ra[y.b];J=Ra[y.c];pa[u]=O.x;pa[u+1]=O.y;pa[u+2]=O.z;pa[u+3]=1;pa[u+4]=M.x;pa[u+5]=M.y;pa[u+6]=M.z;pa[u+7]=1;pa[u+8]=J.x;pa[u+9]=J.y;pa[u+10]=J.z;pa[u+11]=1;O=Sa[y.a];M=Sa[y.b];J=Sa[y.c];ta[u]=O.x;ta[u+1]=O.y;ta[u+2]=O.z;ta[u+3]=1;ta[u+4]=M.x;ta[u+5]=M.y;ta[u+
  240. 6]=M.z;ta[u+7]=1;ta[u+8]=J.x;ta[u+9]=J.y;ta[u+10]=J.z;ta[u+11]=1;u+=12}if(Ia&&Na.length){O=Na[y.a];M=Na[y.b];J=Na[y.c];sa[Aa]=O.r;sa[Aa+1]=O.g;sa[Aa+2]=O.b;sa[Aa+3]=M.r;sa[Aa+4]=M.g;sa[Aa+5]=M.b;sa[Aa+6]=J.r;sa[Aa+7]=J.g;sa[Aa+8]=J.b;Aa+=9}if(Ea&&A.hasTangents){O=ya[y.a].tangent;M=ya[y.b].tangent;J=ya[y.c].tangent;$[fa]=O.x;$[fa+1]=O.y;$[fa+2]=O.z;$[fa+3]=O.w;$[fa+4]=M.x;$[fa+5]=M.y;$[fa+6]=M.z;$[fa+7]=M.w;$[fa+8]=J.x;$[fa+9]=J.y;$[fa+10]=J.z;$[fa+11]=J.w;fa+=12}if(Da)if(Fa.length==3&&Y)for(y=0;y<
  241. 3;y++){za=Fa[y];Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}else for(y=0;y<3;y++){Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}if(xa&&Ga)for(y=0;y<3;y++){Fa=Ga[y];Oa[da]=Fa.u;Oa[da+1]=Fa.v;da+=2}if(xa&&na)for(y=0;y<3;y++){Ga=na[y];Ma[la]=Ga.u;Ma[la+1]=Ga.v;la+=2}if(ma){z[ha]=E;z[ha+1]=E+1;z[ha+2]=E+2;ha+=3;X[Ca]=E;X[Ca+1]=E+1;X[Ca+2]=E;X[Ca+3]=E+2;X[Ca+4]=E+1;X[Ca+5]=E+2;Ca+=6;E+=3}}else if(y instanceof THREE.Face4){if(U){O=ya[y.a].position;M=ya[y.b].position;J=ya[y.c].position;oa=ya[y.d].position;
  242. Ba[L]=O.x;Ba[L+1]=O.y;Ba[L+2]=O.z;Ba[L+3]=M.x;Ba[L+4]=M.y;Ba[L+5]=M.z;Ba[L+6]=J.x;Ba[L+7]=J.y;Ba[L+8]=J.z;Ba[L+9]=oa.x;Ba[L+10]=oa.y;Ba[L+11]=oa.z;L+=12}if(Pa.length){O=Pa[y.a];M=Pa[y.b];J=Pa[y.c];oa=Pa[y.d];qa[u]=O.x;qa[u+1]=O.y;qa[u+2]=O.z;qa[u+3]=O.w;qa[u+4]=M.x;qa[u+5]=M.y;qa[u+6]=M.z;qa[u+7]=M.w;qa[u+8]=J.x;qa[u+9]=J.y;qa[u+10]=J.z;qa[u+11]=J.w;qa[u+12]=oa.x;qa[u+13]=oa.y;qa[u+14]=oa.z;qa[u+15]=oa.w;O=Ta[y.a];M=Ta[y.b];J=Ta[y.c];oa=Ta[y.d];ua[u]=O.x;ua[u+1]=O.y;ua[u+2]=O.z;ua[u+3]=O.w;ua[u+4]=
  243. M.x;ua[u+5]=M.y;ua[u+6]=M.z;ua[u+7]=M.w;ua[u+8]=J.x;ua[u+9]=J.y;ua[u+10]=J.z;ua[u+11]=J.w;ua[u+12]=oa.x;ua[u+13]=oa.y;ua[u+14]=oa.z;ua[u+15]=oa.w;O=Ra[y.a];M=Ra[y.b];J=Ra[y.c];oa=Ra[y.d];pa[u]=O.x;pa[u+1]=O.y;pa[u+2]=O.z;pa[u+3]=1;pa[u+4]=M.x;pa[u+5]=M.y;pa[u+6]=M.z;pa[u+7]=1;pa[u+8]=J.x;pa[u+9]=J.y;pa[u+10]=J.z;pa[u+11]=1;pa[u+12]=oa.x;pa[u+13]=oa.y;pa[u+14]=oa.z;pa[u+15]=1;O=Sa[y.a];M=Sa[y.b];J=Sa[y.c];oa=Sa[y.d];ta[u]=O.x;ta[u+1]=O.y;ta[u+2]=O.z;ta[u+3]=1;ta[u+4]=M.x;ta[u+5]=M.y;ta[u+6]=M.z;ta[u+
  244. 7]=1;ta[u+8]=J.x;ta[u+9]=J.y;ta[u+10]=J.z;ta[u+11]=1;ta[u+12]=oa.x;ta[u+13]=oa.y;ta[u+14]=oa.z;ta[u+15]=1;u+=16}if(Ia&&Na.length){O=Na[y.a];M=Na[y.b];J=Na[y.c];oa=Na[y.d];sa[Aa]=O.r;sa[Aa+1]=O.g;sa[Aa+2]=O.b;sa[Aa+3]=M.r;sa[Aa+4]=M.g;sa[Aa+5]=M.b;sa[Aa+6]=J.r;sa[Aa+7]=J.g;sa[Aa+8]=J.b;sa[Aa+9]=oa.r;sa[Aa+10]=oa.g;sa[Aa+11]=oa.b;Aa+=12}if(Ea&&A.hasTangents){O=ya[y.a].tangent;M=ya[y.b].tangent;J=ya[y.c].tangent;y=ya[y.d].tangent;$[fa]=O.x;$[fa+1]=O.y;$[fa+2]=O.z;$[fa+3]=O.w;$[fa+4]=M.x;$[fa+5]=M.y;
  245. $[fa+6]=M.z;$[fa+7]=M.w;$[fa+8]=J.x;$[fa+9]=J.y;$[fa+10]=J.z;$[fa+11]=J.w;$[fa+12]=y.x;$[fa+13]=y.y;$[fa+14]=y.z;$[fa+15]=y.w;fa+=16}if(Da)if(Fa.length==4&&Y)for(y=0;y<4;y++){za=Fa[y];Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}else for(y=0;y<4;y++){Ha[ia]=za.x;Ha[ia+1]=za.y;Ha[ia+2]=za.z;ia+=3}if(xa&&Ga)for(y=0;y<4;y++){Fa=Ga[y];Oa[da]=Fa.u;Oa[da+1]=Fa.v;da+=2}if(xa&&na)for(y=0;y<4;y++){Ga=na[y];Ma[la]=Ga.u;Ma[la+1]=Ga.v;la+=2}if(ma){z[ha]=E;z[ha+1]=E+1;z[ha+2]=E+2;z[ha+3]=E;z[ha+4]=E+2;z[ha+5]=
  246. E+3;ha+=6;X[Ca]=E;X[Ca+1]=E+1;X[Ca+2]=E;X[Ca+3]=E+3;X[Ca+4]=E+1;X[Ca+5]=E+2;X[Ca+6]=E+2;X[Ca+7]=E+3;Ca+=8;E+=4}}}if(U){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,Ba,ea)}if(Ia&&Na.length){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,sa,ea)}if(Da){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ha,ea)}if(Ea&&A.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLTangentBuffer);d.bufferData(d.ARRAY_BUFFER,
  247. $,ea)}if(xa&&da>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Oa,ea)}if(xa&&la>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ma,ea)}if(ma){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,z,ea);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,h.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,X,ea)}if(u>0){d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,pa,ea);
  248. d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,ta,ea);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,ua,ea);d.bindBuffer(d.ARRAY_BUFFER,h.__webGLSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER,qa,ea)}}F(objlist,W,q,C,j)}v.__dirtyVertices=!1;v.__dirtyElements=!1;v.__dirtyUvs=!1;v.__dirtyNormals=!1;v.__dirtyTangents=!1;v.__dirtyColors=!1}else if(j instanceof THREE.Line){if(!v.__webGLVertexBuffer){q=v;q.__webGLVertexBuffer=d.createBuffer();
  249. q.__webGLColorBuffer=d.createBuffer();q=v;C=q.vertices.length;q.__vertexArray=new Float32Array(C*3);q.__colorArray=new Float32Array(C*3);q.__webGLLineCount=C;v.__dirtyVertices=!0;v.__dirtyColors=!0}if(v.__dirtyVertices||v.__dirtyColors){q=v;C=d.DYNAMIC_DRAW;E=void 0;E=void 0;L=void 0;h=void 0;da=q.vertices;ea=q.colors;la=da.length;va=ea.length;ha=q.__vertexArray;S=q.__colorArray;ia=q.__dirtyColors;if(q.__dirtyVertices){for(E=0;E<la;E++){L=da[E].position;h=E*3;ha[h]=L.x;ha[h+1]=L.y;ha[h+2]=L.z}d.bindBuffer(d.ARRAY_BUFFER,
  250. q.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,ha,C)}if(ia){for(E=0;E<va;E++){color=ea[E];h=E*3;S[h]=color.r;S[h+1]=color.g;S[h+2]=color.b}d.bindBuffer(d.ARRAY_BUFFER,q.__webGLColorBuffer);d.bufferData(d.ARRAY_BUFFER,S,C)}}F(objlist,W,0,v,j);v.__dirtyVertices=!1;v.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){if(!v.__webGLVertexBuffer){q=v;q.__webGLVertexBuffer=d.createBuffer();q.__webGLColorBuffer=d.createBuffer();q=v;C=q.vertices.length;q.__vertexArray=new Float32Array(C*3);q.__colorArray=
  251. new Float32Array(C*3);q.__sortArray=[];q.__webGLParticleCount=C;v.__dirtyVertices=!0;v.__dirtyColors=!0}(v.__dirtyVertices||v.__dirtyColors||j.sortParticles)&&b(v,d.DYNAMIC_DRAW,j,camera);F(objlist,W,0,v,j);v.__dirtyVertices=!1;v.__dirtyColors=!1}else if(j instanceof THREE.MarchingCubes){v=W;if(v[0]==undefined){h.__webGLObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});v[0]=1}}}};this.removeObject=function(f,m){var p,j;for(p=f.__webGLObjects.length-1;p>=0;p--){j=
  252. f.__webGLObjects[p].object;m==j&&f.__webGLObjects.splice(p,1)}};this.setFaceCulling=function(f,m){if(f){!m||m=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(f=="back")d.cullFace(d.BACK);else f=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
  253. THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
  254. envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, 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 refraction_ratio;\nuniform bool useRefract;\n#endif",
  255. 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 ), refraction_ratio );\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",
  256. 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 light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
  257. lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, 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",
  258. 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}",
  259. 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;",
  260. 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 uBoneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( uBoneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( uBoneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
  261. THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
  262. value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
  263. THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragment_shader:"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}",vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
  264. value:1}},fragment_shader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertex_shader:"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,fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,
  265. THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:[THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.color_pars_vertex,
  266. THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,
  267. THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["varying vec3 vLightWeighting;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,
  268. THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,
  269. THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_pars_fragment,THREE.Snippets.lightmap_pars_fragment,THREE.Snippets.envmap_pars_fragment,THREE.Snippets.fog_pars_fragment,
  270. THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.Snippets.lights_fragment,THREE.Snippets.map_fragment,THREE.Snippets.lightmap_fragment,THREE.Snippets.color_fragment,THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.lightmap_pars_vertex,THREE.Snippets.envmap_pars_vertex,
  271. THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
  272. THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",
  273. THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};
  274. THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
  275. THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};