ThreeCanvas.js 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // ThreeCanvas.js r32 - http://github.com/mrdoob/three.js
  2. var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
  3. THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,h,j,g;if(c==0)d=e=f=0;else{h=Math.floor(a*6);j=a*6-h;a=c*(1-b);g=c*(1-b*j);b=c*(1-b*(1-j));switch(h){case 1:d=g;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=g;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=g;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
  4. this.updateStyleString()}},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,d=this.z;this.x=c*a.z-d*a.y;this.y=d*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,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
  13. THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;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,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,h){return f.distance-h.distance});return e},intersectObject:function(a){function b(r,k,F,B){B=B.clone().subSelf(k);F=F.clone().subSelf(k);var J=r.clone().subSelf(k);r=B.dot(B);k=B.dot(F);B=B.dot(J);var G=F.dot(F);F=F.dot(J);J=1/(r*G-k*k);G=(G*B-k*F)*J;r=(r*F-k*B)*J;return G>0&&r>0&&G+r<1}var c,d,e,f,h,j,g,i,m,n,
  17. o,p=a.geometry,t=p.vertices,u=[];c=0;for(d=p.faces.length;c<d;c++){e=p.faces[c];n=this.origin.clone();o=this.direction.clone();g=a.globalMatrix;g.extractRotationMatrix(a.matrixRotation);f=g.multiplyVector3(t[e.a].position.clone());h=g.multiplyVector3(t[e.b].position.clone());j=g.multiplyVector3(t[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(t[e.d].position.clone()):null;i=a.matrixRotation.multiplyVector3(e.normal.clone());m=o.dot(i);if(m<0){i=i.dot((new THREE.Vector3).sub(f,
  18. n))/m;n=n.addSelf(o.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(n,f,h,j)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};u.push(e)}}else if(e instanceof THREE.Face4&&(b(n,f,h,g)||b(n,h,j,g))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};u.push(e)}}}return u}};
  19. THREE.Rectangle=function(){function a(){f=d-b;h=e-c}var b,c,d,e,f,h,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,m,n){j=!1;b=g;c=i;d=m;e=n;a()};this.addPoint=function(g,i){if(j){j=!1;b=g;c=i;d=g;e=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;e=e>i?e:i}a()};
  20. this.add3Points=function(g,i,m,n,o,p){if(j){j=!1;b=g<m?g<o?g:o:m<o?m:o;c=i<n?i<p?i:p:n<p?n:p;d=g>m?g>o?g:o:m>o?m:o;e=i>n?i>p?i:p:n>p?n:p}else{b=g<m?g<o?g<b?g:b:o<b?o:b:m<o?m<b?m:b:o<b?o:b;c=i<n?i<p?i<c?i:c:p<c?p:c:n<p?n<c?n:c:p<c?p:c;d=g>m?g>o?g>d?g:d:o>d?o:d:m>o?m>d?m:d:o>d?o:d;e=i>n?i>p?i>e?i:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e}a()};this.addRectangle=function(g){if(j){j=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
  21. d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j};this.toString=function(){return"THREE.Rectangle ( left: "+
  22. b+", right: "+d+", top: "+c+", bottom: "+e+", width: "+f+", height: "+h+" )"}};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,d,e,f,h,j,g,i,m,n,o,p,t,u){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=e||0;this.n22=f||1;this.n23=h||0;this.n24=j||0;this.n31=g||0;this.n32=i||0;this.n33=m||1;this.n34=n||0;this.n41=o||0;this.n42=p||0;this.n43=t||0;this.n44=u||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,d,e,f,h,j,g,i,m,n,o,p,t,u){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=h;this.n24=j;this.n31=g;this.n32=i;this.n33=m;this.n34=n;this.n41=o;this.n42=p;this.n43=t;this.n44=u;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 d=THREE.Matrix4.__tmpVec1,e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=e.x;this.n22=e.y;this.n23=e.z;this.n24=-e.dot(a);
  26. this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;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,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,m=a.n31,n=a.n32,o=a.n33,p=a.n34,t=a.n41,u=a.n42,r=a.n43,k=a.n44,F=b.n11,B=b.n12,J=b.n13,G=b.n14,N=b.n21,C=b.n22,z=b.n23,K=b.n24,y=b.n31,L=b.n32,D=b.n33,w=b.n34,s=b.n41,O=b.n42,v=b.n43,P=b.n44;this.n11=c*F+d*N+e*y+f*s;this.n12=c*B+d*C+e*L+f*O;this.n13=c*J+d*z+e*D+f*v;this.n14=c*G+d*K+e*w+f*P;this.n21=h*F+j*N+g*y+i*s;this.n22=h*B+j*C+g*L+i*O;this.n23=h*J+
  29. j*z+g*D+i*v;this.n24=h*G+j*K+g*w+i*P;this.n31=m*F+n*N+o*y+p*s;this.n32=m*B+n*C+o*L+p*O;this.n33=m*J+n*z+o*D+p*v;this.n34=m*G+n*K+o*w+p*P;this.n41=t*F+u*N+r*y+k*s;this.n42=t*B+u*C+r*L+k*O;this.n43=t*J+u*z+r*D+k*v;this.n44=t*G+u*K+r*w+k*P;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,j=a.n21,g=a.n22,i=a.n23,m=a.n24,n=a.n31,o=a.n32,p=a.n33,t=a.n34,u=a.n41,r=a.n42,k=a.n43;a=a.n44;var F=b.n11,B=b.n12,J=b.n13,G=b.n14,N=b.n21,C=b.n22,z=b.n23,K=b.n24,y=b.n31,L=b.n32,D=b.n33,
  30. w=b.n34,s=b.n41,O=b.n42,v=b.n43;b=b.n44;this.n11=d*F+e*N+f*y+h*s;this.n12=d*B+e*C+f*L+h*O;this.n13=d*J+e*z+f*D+h*v;this.n14=d*G+e*K+f*w+h*b;this.n21=j*F+g*N+i*y+m*s;this.n22=j*B+g*C+i*L+m*O;this.n23=j*J+g*z+i*D+m*v;this.n24=j*G+g*K+i*w+m*b;this.n31=n*F+o*N+p*y+t*s;this.n32=n*B+o*C+p*L+t*O;this.n33=n*J+o*z+p*D+t*v;this.n34=n*G+o*K+p*w+t*b;this.n41=u*F+r*N+k*y+a*s;this.n42=u*B+r*C+k*L+a*O;this.n43=u*J+r*z+k*D+a*v;this.n44=u*G+r*K+k*w+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=
  31. 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,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,g=this.n24,i=this.n31,m=this.n32,n=this.n33,o=this.n34,p=this.n41,t=this.n42,u=this.n43,r=this.n44,k=a.n11,F=a.n21,B=a.n31,J=a.n41,G=a.n12,N=a.n22,C=a.n32,z=a.n42,K=a.n13,y=a.n23,L=a.n33,D=a.n43,w=a.n14,s=a.n24,O=
  32. a.n34;a=a.n44;this.n11=b*k+c*F+d*B+e*J;this.n12=b*G+c*N+d*C+e*z;this.n13=b*K+c*y+d*L+e*D;this.n14=b*w+c*s+d*O+e*a;this.n21=f*k+h*F+j*B+g*J;this.n22=f*G+h*N+j*C+g*z;this.n23=f*K+h*y+j*L+g*D;this.n24=f*w+h*s+j*O+g*a;this.n31=i*k+m*F+n*B+o*J;this.n32=i*G+m*N+n*C+o*z;this.n33=i*K+m*y+n*L+o*D;this.n34=i*w+m*s+n*O+o*a;this.n41=p*k+t*F+u*B+r*J;this.n42=p*G+t*N+u*C+r*z;this.n43=p*K+t*y+u*L+r*D;this.n44=p*w+t*s+u*O+r*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;
  33. 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,d=this.n14,e=this.n21,f=this.n22,h=this.n23,j=this.n24,g=this.n31,i=this.n32,m=this.n33,n=this.n34,o=this.n41,p=this.n42,t=this.n43,u=this.n44;return d*h*i*o-c*j*i*o-d*f*m*o+b*j*m*o+c*f*n*o-b*h*n*o-d*h*g*p+c*j*g*p+d*e*m*p-a*j*m*p-c*e*n*p+a*h*n*p+d*f*g*t-b*j*g*t-d*e*i*t+a*j*i*t+b*e*n*
  34. t-a*f*n*t-c*f*g*u+b*h*g*u+c*e*i*u-a*h*i*u-b*e*m*u+a*f*m*u},transpose:function(){function a(b,c,d){var e=b[c];b[c]=b[d];b[d]=e}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;a.n34=this.n34;a.n41=this.n41;a.n42=
  35. 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]=this.n13;a[9]=this.n23;a[10]=this.n33;
  36. 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);return this},setScale:function(a,b,c){this.set(a,
  37. 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),d=Math.sin(b),e=1-c,f=a.x,h=a.y,j=a.z,g=e*f,i=e*h;this.set(g*f+c,g*h-d*j,g*j+d*h,0,g*h+d*j,
  38. i*h+c,i*j-d*f,0,g*j-d*h,i*j+d*f,e*j*j+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,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(b);b=Math.sin(b);var h=a*d,j=c*d;this.n11=a*e;this.n12=c*b-h*f;this.n13=h*b+c*f;this.n21=d;this.n22=e*f;this.n23=-e*b;this.n31=-c*e;this.n32=j*f+a*b;this.n33=-j*b+a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=
  39. a.w,f=b+b,h=c+c,j=d+d;a=b*f;var g=b*h;b*=j;var i=c*h;c*=j;d*=j;f*=e;h*=e;e*=j;this.n11=1-(i+d);this.n12=g-e;this.n13=b+h;this.n21=g+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-h;this.n32=c+f;this.n33=1-(a+i)},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;a.n23=this.n23;
  40. 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 d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};
  41. THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};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,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,m=a.n31,n=a.n32,o=a.n33,p=a.n34,t=a.n41,u=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*p*u-i*o*u+i*n*r-j*p*r-g*n*k+j*o*k;b.n12=f*o*u-e*p*u-f*n*r+d*p*r+e*n*k-d*o*k;b.n13=e*i*u-f*g*u+f*j*r-d*i*r-e*j*k+d*g*k;b.n14=f*g*n-e*i*n-f*j*o+d*i*o+e*j*p-d*g*p;b.n21=i*o*t-g*p*t-i*m*r+h*p*r+g*m*k-h*o*k;b.n22=e*p*t-f*o*t+f*m*r-c*p*r-e*m*k+c*o*k;b.n23=f*g*t-e*i*t-f*h*r+c*i*r+e*h*k-c*g*k;
  43. b.n24=e*i*m-f*g*m+f*h*o-c*i*o-e*h*p+c*g*p;b.n31=j*p*t-i*n*t+i*m*u-h*p*u-j*m*k+h*n*k;b.n32=f*n*t-d*p*t-f*m*u+c*p*u+d*m*k-c*n*k;b.n33=e*i*t-f*j*t+f*h*u-c*i*u-d*h*k+c*j*k;b.n34=f*j*m-d*i*m-f*h*n+c*i*n+d*h*p-c*j*p;b.n41=g*n*t-j*o*t-g*m*u+h*o*u+j*m*r-h*n*r;b.n42=d*o*t-e*n*t+e*m*u-c*o*u-d*m*r+c*n*r;b.n43=e*j*t-d*g*t-e*h*u+c*g*u+d*h*r-c*j*r;b.n44=d*g*m-e*j*m+e*h*n-c*g*n-d*h*o+c*j*o;b.multiplyScalar(1/a.determinant());return b};
  44. THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*h;c[4]=a*j;c[5]=a*g;c[6]=a*i;c[7]=a*m;c[8]=a*n;return b};
  45. THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(f+e)/(f-e);h.n34=-2*f*e/(f-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
  46. THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var h,j,g,i;h=new THREE.Matrix4;j=b-a;g=c-d;i=f-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/g;h.n23=0;h.n24=-((c+d)/g);h.n31=0;h.n32=0;h.n33=-2/i;h.n34=-((f+e)/i);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
  47. THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
  48. 1;this.visible=!0};THREE.Object3D.prototype.update=function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.globalMatrix,b,c)}};
  49. THREE.Object3D.prototype.updateMatrix=function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.localMatrix.setRotationFromQuaternion(this.quaternion):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};
  50. 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};
  51. 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+" )"}};
  52. THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
  53. THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};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};
  54. 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};
  55. 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);
  56. c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,h,j=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){j.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)j.addSelf(f.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];j.sub(h.position,
  57. c.position);g.sub(b.position,c.position);j.crossSelf(g)}j.isZero()||j.normalize();f.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[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,
  58. new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
  59. b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(w,s,O,v,P,ca,E){f=w.vertices[s].position;h=w.vertices[O].position;j=w.vertices[v].position;g=e[P];i=e[ca];m=e[E];n=h.x-f.x;o=j.x-f.x;p=h.y-f.y;t=j.y-f.y;
  60. u=h.z-f.z;r=j.z-f.z;k=i.u-g.u;F=m.u-g.u;B=i.v-g.v;J=m.v-g.v;G=1/(k*J-F*B);z.set((J*n-B*o)*G,(J*p-B*t)*G,(J*u-B*r)*G);K.set((k*o-F*n)*G,(k*t-F*p)*G,(k*r-F*u)*G);N[s].addSelf(z);N[O].addSelf(z);N[v].addSelf(z);C[s].addSelf(K);C[O].addSelf(K);C[v].addSelf(K)}var b,c,d,e,f,h,j,g,i,m,n,o,p,t,u,r,k,F,B,J,G,N=[],C=[],z=new THREE.Vector3,K=new THREE.Vector3,y=new THREE.Vector3,L=new THREE.Vector3,D=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){N[b]=new THREE.Vector3;C[b]=new THREE.Vector3}b=0;
  61. for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
  62. this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){D.copy(this.vertices[b].normal);d=N[b];y.copy(d);y.subSelf(D.multiplyScalar(D.dot(d))).normalize();L.cross(this.vertices[b].normal,d);d=L.dot(C[b]);d=d<0?-1:1;this.vertices[b].tangent.set(y.x,y.y,y.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
  63. z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var 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>
  64. this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(m){var n=[];b=0;for(c=m.length;b<c;b++)m[b]==undefined?n.push("undefined"):n.push(m[b].id);return n.join("_")}var b,c,d,e,f,h,j,g,i={};d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];
  65. h=f.materials;j=a(h);i[j]==undefined&&(i[j]={hash:j,counter:0});g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0});f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+f>65535){i[j].counter+=1;g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0})}this.geometryChunks[g].faces.push(d);this.geometryChunks[g].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
  66. this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
  67. THREE.Camera=function(a,b,c,d,e,f){THREE.Object3D.call(this);this.FOV=a||50;this.aspect=b||1;this.zNear=c||0.1;this.zFar=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=f||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(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);
  68. this.target.position.addSelf(this.tmpVec)};this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);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;
  69. THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.FOV,this.aspect,this.zNear,this.zFar)};
  70. 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.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
  71. this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
  72. THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,e=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,h=e.n31*b+e.n32*c+e.n33*d+e.n34;if(h-f>-this.zNear)return!1;if(h+f<-this.zFar)return!1;h-=f;var j=this.projectionMatrix,g=1/(j.n43*h),i=g*this.screenCenterX,m=(e.n11*b+e.n12*c+e.n13*d+e.n14)*j.n11*i;f=j.n11*f*i;if(m+f<-this.screenCenterX)return!1;if(m-f>this.screenCenterX)return!1;b=(e.n21*b+e.n22*c+e.n23*d+e.n24)*j.n22*g*this.screenCenterY;
  73. if(b+f<-this.screenCenterY)return!1;if(b-f>this.screenCenterY)return!1;a.screenPosition.set(m,b,h,f);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;
  74. 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;
  75. THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
  76. 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=
  77. 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}};
  78. 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/>)"}};
  79. 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!==
  80. 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!==
  81. 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}};
  82. 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+
  83. "<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>vertex_colors: "+this.vertex_colors+"<br/>skinning: "+this.skinning+"<br/>)"}};
  84. 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!==
  85. 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!==
  86. 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}};
  87. 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+
  88. "<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/> )"}};
  89. 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=
  90. 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;
  91. 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;
  92. 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}};
  93. 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: "+
  94. 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/>)"}};
  95. 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!==
  96. 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/>)"}};
  97. 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!==
  98. 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"}};
  99. 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!==
  100. 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/>)"}};
  101. 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}};
  102. THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
  103. THREE.Texture=function(a,b,c,d,e,f){if(a.getContext)a.loaded=!0;this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=e!==undefined?e:THREE.LinearFilter;this.min_filter=f!==undefined?f:THREE.LinearMipMapLinearFilter};
  104. 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;
  105. 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;THREE.CubeReflectionMapping=function(){};
  106. THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
  107. 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;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
  108. 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;
  109. 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)};
  110. 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)};
  111. 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;
  112. THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
  113. THREE.Projector=function(){function a(C,z){return z.z-C.z}function b(C,z){var K=0,y=1,L=C.z+C.w,D=z.z+z.w,w=-C.z+C.w,s=-z.z+z.w;if(L>=0&&D>=0&&w>=0&&s>=0)return!0;else if(L<0&&D<0||w<0&&s<0)return!1;else{if(L<0)K=Math.max(K,L/(L-D));else D<0&&(y=Math.min(y,L/(L-D)));if(w<0)K=Math.max(K,w/(w-s));else s<0&&(y=Math.min(y,w/(w-s)));if(y<K)return!1;else{C.lerpSelf(z,K);z.lerpSelf(C,1-y);return!0}}}var c,d,e=[],f,h,j,g=[],i,m,n=[],o,p,t=[],u=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,F=new THREE.Matrix4,
  114. B=[],J=new THREE.Vector4,G=new THREE.Vector4,N;this.projectObjects=function(C,z,K){z=[];var y,L,D;d=0;L=C.objects;C=0;for(y=L.length;C<y;C++){D=L[C];var w;if(!(w=!D.visible))if(w=D instanceof THREE.Mesh){a:{w=void 0;for(var s=D.globalMatrix,O=-D.geometry.boundingSphere.radius*Math.max(D.scale.x,Math.max(D.scale.y,D.scale.z)),v=0;v<6;v++){w=B[v].x*s.n14+B[v].y*s.n24+B[v].z*s.n34+B[v].w;if(w<=O){w=!1;break a}}w=!0}w=!w}if(!w){c=e[d]=e[d]||new THREE.RenderableObject;u.copy(D.position);k.multiplyVector3(u);
  115. c.object=D;c.z=u.z;z.push(c);d++}}K&&z.sort(a);return z};this.projectScene=function(C,z,K){var y=[],L=z.zNear,D=z.zFar,w,s,O,v,P,ca,E,ga,ka,la,ma,Z,Q,I,U,R;j=m=p=0;z.matrixAutoUpdate&&z.update();k.multiply(z.projectionMatrix,z.globalMatrix);B[0]=new THREE.Vector4(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);B[1]=new THREE.Vector4(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);B[2]=new THREE.Vector4(k.n41+k.n21,k.n42+k.n22,k.n43+k.n23,k.n44+k.n24);B[3]=new THREE.Vector4(k.n41-k.n21,k.n42-k.n22,
  116. k.n43-k.n23,k.n44-k.n24);B[4]=new THREE.Vector4(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);B[5]=new THREE.Vector4(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);w=0;for(ca=B.length;w<ca;w++){E=B[w];E.divideScalar(Math.sqrt(E.x*E.x+E.y*E.y+E.z*E.z))}C.update(undefined,!1,z);ca=this.projectObjects(C,z,!0);C=0;for(w=ca.length;C<w;C++){E=ca[C].object;if(E.visible){E.matrixAutoUpdate&&E.updateMatrix();ga=E.globalMatrix;ga.extractRotationMatrix(E.matrixRotation);ma=E.matrixRotation;ka=E.materials;
  117. la=E.overdraw;if(E instanceof THREE.Mesh){Z=E.geometry;Q=Z.vertices;s=0;for(O=Q.length;s<O;s++){I=Q[s];I.positionWorld.copy(I.position);ga.multiplyVector3(I.positionWorld);v=I.positionScreen;v.copy(I.positionWorld);k.multiplyVector4(v);v.x/=v.w;v.y/=v.w;I.__visible=v.z>L&&v.z<D}Z=Z.faces;s=0;for(O=Z.length;s<O;s++){I=Z[s];if(I instanceof THREE.Face3){v=Q[I.a];P=Q[I.b];U=Q[I.c];if(v.__visible&&P.__visible&&U.__visible&&(E.doubleSided||E.flipSided!=(U.positionScreen.x-v.positionScreen.x)*(P.positionScreen.y-
  118. v.positionScreen.y)-(U.positionScreen.y-v.positionScreen.y)*(P.positionScreen.x-v.positionScreen.x)<0)){f=g[j]=g[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(v.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(U.positionWorld);f.v1.positionScreen.copy(v.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(U.positionScreen);f.normalWorld.copy(I.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(I.centroid);ga.multiplyVector3(f.centroidWorld);
  119. f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);U=I.vertexNormals;N=f.vertexNormalsWorld;v=0;for(P=U.length;v<P;v++){R=N[v]=N[v]||new THREE.Vector3;R.copy(U[v]);ma.multiplyVector3(R)}f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=I.materials;f.overdraw=la;if(E.geometry.uvs[s]){f.uvs[0]=E.geometry.uvs[s][0];f.uvs[1]=E.geometry.uvs[s][1];f.uvs[2]=E.geometry.uvs[s][2]}y.push(f);j++}}else if(I instanceof THREE.Face4){v=Q[I.a];P=Q[I.b];U=Q[I.c];R=Q[I.d];if(v.__visible&&
  120. P.__visible&&U.__visible&&R.__visible&&(E.doubleSided||E.flipSided!=((R.positionScreen.x-v.positionScreen.x)*(P.positionScreen.y-v.positionScreen.y)-(R.positionScreen.y-v.positionScreen.y)*(P.positionScreen.x-v.positionScreen.x)<0||(P.positionScreen.x-U.positionScreen.x)*(R.positionScreen.y-U.positionScreen.y)-(P.positionScreen.y-U.positionScreen.y)*(R.positionScreen.x-U.positionScreen.x)<0))){f=g[j]=g[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(v.positionWorld);f.v2.positionWorld.copy(P.positionWorld);
  121. f.v3.positionWorld.copy(R.positionWorld);f.v1.positionScreen.copy(v.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(I.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(I.centroid);ga.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=I.materials;f.overdraw=la;if(E.geometry.uvs[s]){f.uvs[0]=E.geometry.uvs[s][0];
  122. f.uvs[1]=E.geometry.uvs[s][1];f.uvs[2]=E.geometry.uvs[s][3]}y.push(f);j++;h=g[j]=g[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(P.positionWorld);h.v2.positionWorld.copy(U.positionWorld);h.v3.positionWorld.copy(R.positionWorld);h.v1.positionScreen.copy(P.positionScreen);h.v2.positionScreen.copy(U.positionScreen);h.v3.positionScreen.copy(R.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=
  123. ka;h.faceMaterials=I.materials;h.overdraw=la;if(E.geometry.uvs[s]){h.uvs[0]=E.geometry.uvs[s][1];h.uvs[1]=E.geometry.uvs[s][2];h.uvs[2]=E.geometry.uvs[s][3]}y.push(h);j++}}}}else if(E instanceof THREE.Line){F.multiply(k,ga);Q=E.geometry.vertices;I=Q[0];I.positionScreen.copy(I.position);F.multiplyVector4(I.positionScreen);s=1;for(O=Q.length;s<O;s++){v=Q[s];v.positionScreen.copy(v.position);F.multiplyVector4(v.positionScreen);P=Q[s-1];J.copy(v.positionScreen);G.copy(P.positionScreen);if(b(J,G)){J.multiplyScalar(1/
  124. J.w);G.multiplyScalar(1/G.w);i=n[m]=n[m]||new THREE.RenderableLine;i.v1.positionScreen.copy(J);i.v2.positionScreen.copy(G);i.z=Math.max(J.z,G.z);i.materials=E.materials;y.push(i);m++}}}else if(E instanceof THREE.Particle){r.set(E.position.x,E.position.y,E.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){o=t[p]=t[p]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=E.rotation.z;o.scale.x=E.scale.x*Math.abs(o.x-(r.x+z.projectionMatrix.n11)/(r.w+z.projectionMatrix.n14));
  125. o.scale.y=E.scale.y*Math.abs(o.y-(r.y+z.projectionMatrix.n22)/(r.w+z.projectionMatrix.n24));o.materials=E.materials;y.push(o);p++}}}}K&&y.sort(a);return y};this.unprojectVector=function(C,z){var K=THREE.Matrix4.makeInvert(z.globalMatrix);K.multiplySelf(THREE.Matrix4.makeInvert(z.projectionMatrix));K.multiplyVector3(C);return C}};
  126. THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(p!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}p=V}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,h,j,g,i=e.getContext("2d"),m=new THREE.Color(0),n=0,o=1,p=0,t=null,u=null,r=1,k,F,B,J,G,N,C,z,K,y=new THREE.Color,
  127. L=new THREE.Color,D=new THREE.Color,w=new THREE.Color,s=new THREE.Color,O,v,P,ca,E,ga,ka,la,ma,Z=new THREE.Rectangle,Q=new THREE.Rectangle,I=new THREE.Rectangle,U=!1,R=new THREE.Color,$=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,S=new THREE.Vector3,ra,sa,Ca,aa,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);aa=Ca.data;ta=document.createElement("canvas");
  128. ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){f=V;h=da;j=f/2;g=h/2;e.width=f;e.height=h;Z.set(-j,-g,j,g);o=1;p=0;u=t=null;r=1};this.setClearColor=function(V,da){m=V;n=da;Q.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(V,da){m.setHex(V);n=da;Q.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.clear=
  129. function(){i.setTransform(1,0,0,-1,j,g);if(!Q.isEmpty()){Q.inflate(1);Q.minSelf(Z);if(m.hex==0&&n==0)i.clearRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(m.r*255)+","+Math.floor(m.g*255)+","+Math.floor(m.b*255)+","+n+")";i.fillRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight())}Q.empty()}};this.render=function(V,da){function Ma(l){var H,A,q,x=l.lights;$.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(H=x.length;l<H;l++){A=
  130. x[l];q=A.color;if(A instanceof THREE.AmbientLight){$.r+=q.r;$.g+=q.g;$.b+=q.b}else if(A instanceof THREE.DirectionalLight){na.r+=q.r;na.g+=q.g;na.b+=q.b}else if(A instanceof THREE.PointLight){oa.r+=q.r;oa.g+=q.g;oa.b+=q.b}}}function ya(l,H,A,q){var x,M,W,X,Y=l.lights;l=0;for(x=Y.length;l<x;l++){M=Y[l];W=M.color;X=M.intensity;if(M instanceof THREE.DirectionalLight){M=A.dot(M.position)*X;if(M>0){q.r+=W.r*M;q.g+=W.g*M;q.b+=W.b*M}}else if(M instanceof THREE.PointLight){S.sub(M.position,H);S.normalize();
  131. M=A.dot(S)*X;if(M>0){q.r+=W.r*M;q.g+=W.g*M;q.b+=W.b*M}}}}function Na(l,H,A){if(A.opacity!=0){a(A.opacity);b(A.blending);var q,x,M,W,X,Y;if(A instanceof THREE.ParticleBasicMaterial){if(A.map&&A.map.image.loaded){W=A.map.image;X=W.width>>1;Y=W.height>>1;x=H.scale.x*j;M=H.scale.y*g;A=x*X;q=M*Y;I.set(l.x-A,l.y-q,l.x+A,l.y+q);if(Z.instersects(I)){i.save();i.translate(l.x,l.y);i.rotate(-H.rotation);i.scale(x,-M);i.translate(-X,-Y);i.drawImage(W,0,0);i.restore()}}}else if(A instanceof THREE.ParticleCircleMaterial){if(U){R.r=
  132. $.r+na.r+oa.r;R.g=$.g+na.g+oa.g;R.b=$.b+na.b+oa.b;y.r=A.color.r*R.r;y.g=A.color.g*R.g;y.b=A.color.b*R.b;y.updateStyleString()}else y.__styleString=A.color.__styleString;A=H.scale.x*j;q=H.scale.y*g;I.set(l.x-A,l.y-q,l.x+A,l.y+q);if(Z.instersects(I)){x=y.__styleString;if(u!=x)i.fillStyle=u=x;i.save();i.translate(l.x,l.y);i.rotate(-H.rotation);i.scale(A,q);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,H,A,q){if(q.opacity!=0){a(q.opacity);b(q.blending);i.beginPath();
  133. i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(H.positionScreen.x,H.positionScreen.y);i.closePath();if(q instanceof THREE.LineBasicMaterial){y.__styleString=q.color.__styleString;l=q.linewidth;if(r!=l)i.lineWidth=r=l;l=y.__styleString;if(t!=l)i.strokeStyle=t=l;i.stroke();I.inflate(q.linewidth*2)}}}function Ha(l,H,A,q,x,M){if(x.opacity!=0){a(x.opacity);b(x.blending);J=l.positionScreen.x;G=l.positionScreen.y;N=H.positionScreen.x;C=H.positionScreen.y;z=A.positionScreen.x;K=A.positionScreen.y;
  134. i.beginPath();i.moveTo(J,G);i.lineTo(N,C);i.lineTo(z,K);i.lineTo(J,G);i.closePath();if(x instanceof THREE.MeshBasicMaterial)if(x.map)x.map.image.loaded&&x.map.mapping instanceof THREE.UVMapping&&ua(J,G,N,C,z,K,x.map.image,q.uvs[0].u,q.uvs[0].v,q.uvs[1].u,q.uvs[1].v,q.uvs[2].u,q.uvs[2].v);else if(x.env_map){if(x.env_map.image.loaded&&x.env_map.mapping instanceof THREE.SphericalReflectionMapping){l=da.globalMatrix;S.copy(q.vertexNormalsWorld[0]);ca=(S.x*l.n11+S.y*l.n12+S.z*l.n13)*0.5+0.5;E=-(S.x*l.n21+
  135. S.y*l.n22+S.z*l.n23)*0.5+0.5;S.copy(q.vertexNormalsWorld[1]);ga=(S.x*l.n11+S.y*l.n12+S.z*l.n13)*0.5+0.5;ka=-(S.x*l.n21+S.y*l.n22+S.z*l.n23)*0.5+0.5;S.copy(q.vertexNormalsWorld[2]);la=(S.x*l.n11+S.y*l.n12+S.z*l.n13)*0.5+0.5;ma=-(S.x*l.n21+S.y*l.n22+S.z*l.n23)*0.5+0.5;ua(J,G,N,C,z,K,x.env_map.image,ca,E,ga,ka,la,ma)}}else x.wireframe?za(x.color.__styleString,x.wireframe_linewidth):Aa(x.color.__styleString);else if(x instanceof THREE.MeshLambertMaterial){if(x.map&&!x.wireframe){x.map.mapping instanceof
  136. THREE.UVMapping&&ua(J,G,N,C,z,K,x.map.image,q.uvs[0].u,q.uvs[0].v,q.uvs[1].u,q.uvs[1].v,q.uvs[2].u,q.uvs[2].v);b(THREE.SubtractiveBlending)}if(U)if(!x.wireframe&&x.shading==THREE.SmoothShading&&q.vertexNormalsWorld.length==3){L.r=D.r=w.r=$.r;L.g=D.g=w.g=$.g;L.b=D.b=w.b=$.b;ya(M,q.v1.positionWorld,q.vertexNormalsWorld[0],L);ya(M,q.v2.positionWorld,q.vertexNormalsWorld[1],D);ya(M,q.v3.positionWorld,q.vertexNormalsWorld[2],w);s.r=(D.r+w.r)*0.5;s.g=(D.g+w.g)*0.5;s.b=(D.b+w.b)*0.5;P=Ia(L,D,w,s);ua(J,G,
  137. N,C,z,K,P,0,0,1,0,0,1)}else{R.r=$.r;R.g=$.g;R.b=$.b;ya(M,q.centroidWorld,q.normalWorld,R);y.r=x.color.r*R.r;y.g=x.color.g*R.g;y.b=x.color.b*R.b;y.updateStyleString();x.wireframe?za(y.__styleString,x.wireframe_linewidth):Aa(y.__styleString)}else x.wireframe?za(x.color.__styleString,x.wireframe_linewidth):Aa(x.color.__styleString)}else if(x instanceof THREE.MeshDepthMaterial){O=da.near;v=da.far;L.r=L.g=L.b=1-Da(l.positionScreen.z,O,v);D.r=D.g=D.b=1-Da(H.positionScreen.z,O,v);w.r=w.g=w.b=1-Da(A.positionScreen.z,
  138. O,v);s.r=(D.r+w.r)*0.5;s.g=(D.g+w.g)*0.5;s.b=(D.b+w.b)*0.5;P=Ia(L,D,w,s);ua(J,G,N,C,z,K,P,0,0,1,0,0,1)}else if(x instanceof THREE.MeshNormalMaterial){y.r=Ea(q.normalWorld.x);y.g=Ea(q.normalWorld.y);y.b=Ea(q.normalWorld.z);y.updateStyleString();x.wireframe?za(y.__styleString,x.wireframe_linewidth):Aa(y.__styleString)}}}function za(l,H){if(t!=l)i.strokeStyle=t=l;if(r!=H)i.lineWidth=r=H;i.stroke();I.inflate(H*2)}function Aa(l){if(u!=l)i.fillStyle=u=l;i.fill()}function ua(l,H,A,q,x,M,W,X,Y,ha,ba,ia,va){var ea,
  139. ja;ea=W.width-1;ja=W.height-1;X*=ea;Y*=ja;ha*=ea;ba*=ja;ia*=ea;va*=ja;A-=l;q-=H;x-=l;M-=H;ha-=X;ba-=Y;ia-=X;va-=Y;ea=ha*va-ia*ba;if(ea!=0){ja=1/ea;ea=(va*A-ba*x)*ja;ba=(va*q-ba*M)*ja;A=(ha*x-ia*A)*ja;q=(ha*M-ia*q)*ja;l=l-ea*X-A*Y;H=H-ba*X-q*Y;i.save();i.transform(ea,ba,A,q,l,H);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(l,H,A,q){var x=~~(l.r*255),M=~~(l.g*255);l=~~(l.b*255);var W=~~(H.r*255),X=~~(H.g*255);H=~~(H.b*255);var Y=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ba=~~(q.r*255),ia=
  140. ~~(q.g*255);q=~~(q.b*255);aa[0]=x<0?0:x>255?255:x;aa[1]=M<0?0:M>255?255:M;aa[2]=l<0?0:l>255?255:l;aa[4]=W<0?0:W>255?255:W;aa[5]=X<0?0:X>255?255:X;aa[6]=H<0?0:H>255?255:H;aa[8]=Y<0?0:Y>255?255:Y;aa[9]=ha<0?0:ha>255?255:ha;aa[10]=A<0?0:A>255?255:A;aa[12]=ba<0?0:ba>255?255:ba;aa[13]=ia<0?0:ia>255?255:ia;aa[14]=q<0?0:q>255?255:q;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,H,A){l=(l-H)/(A-H);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,H){var A=
  141. H.x-l.x,q=H.y-l.y,x=1/Math.sqrt(A*A+q*q);A*=x;q*=x;H.x+=A;H.y+=q;l.x-=A;l.y-=q}var Ba,Ja,T,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,g);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length>0)&&Ma(V);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){T=c[Ba];I.empty();if(T instanceof THREE.RenderableParticle){k=T;k.x*=j;k.y*=g;fa=0;for(qa=T.materials.length;fa<qa;fa++)Na(k,T,T.materials[fa],V)}else if(T instanceof THREE.RenderableLine){k=T.v1;F=T.v2;k.positionScreen.x*=j;k.positionScreen.y*=
  142. g;F.positionScreen.x*=j;F.positionScreen.y*=g;I.addPoint(k.positionScreen.x,k.positionScreen.y);I.addPoint(F.positionScreen.x,F.positionScreen.y);if(Z.instersects(I)){fa=0;for(qa=T.materials.length;fa<qa;)Oa(k,F,T,T.materials[fa++],V)}}else if(T instanceof THREE.RenderableFace3){k=T.v1;F=T.v2;B=T.v3;k.positionScreen.x*=j;k.positionScreen.y*=g;F.positionScreen.x*=j;F.positionScreen.y*=g;B.positionScreen.x*=j;B.positionScreen.y*=g;if(T.overdraw){Fa(k.positionScreen,F.positionScreen);Fa(F.positionScreen,
  143. B.positionScreen);Fa(B.positionScreen,k.positionScreen)}I.add3Points(k.positionScreen.x,k.positionScreen.y,F.positionScreen.x,F.positionScreen.y,B.positionScreen.x,B.positionScreen.y);if(Z.instersects(I)){fa=0;for(qa=T.meshMaterials.length;fa<qa;){wa=T.meshMaterials[fa++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=T.faceMaterials.length;Ga<Ka;)(wa=T.faceMaterials[Ga++])&&Ha(k,F,B,T,wa,V)}else Ha(k,F,B,T,wa,V)}}}Q.addRectangle(I)}i.setTransform(1,0,0,1,0,0)}};
  144. THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};
  145. THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};