12 |
- // ThreeDebug.js r18 - http://github.com/mrdoob/three.js
- var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=Math.floor(this.a*255)<<24|Math.floor(this.r*255)<<16|Math.floor(this.g*255)<<8|Math.floor(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};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(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.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*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,c,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.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(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.x;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},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){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+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},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)<a)&&(Math.abs(this.y)<a)&&(Math.abs(this.z)<a)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,d,c,b){this.x=a||0;this.y=d||0;this.z=c||0;this.w=b||1};THREE.Vector4.prototype={set:function(a,d,c,b){this.x=a;this.y=d;this.z=c;this.w=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;this.w=b.w+a.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(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;this.w=b.w-a.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},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+")"}};THREE.Rectangle=function(){var f,h,d,g,a,c,e=true;function b(){a=d-f;c=g-h}this.getX=function(){return f};this.getY=function(){return h};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getX1=function(){return f};this.getY1=function(){return h};this.getX2=function(){return d};this.getY2=function(){return g};this.set=function(j,l,i,k){e=false;f=j;h=l;d=i;g=k;b()};this.addPoint=function(i,j){if(e){e=false;f=i;h=j;d=i;g=j}else{f=Math.min(f,i);h=Math.min(h,j);d=Math.max(d,i);g=Math.max(g,j)}b()};this.addRectangle=function(i){if(e){e=false;f=i.getX1();h=i.getY1();d=i.getX2();g=i.getY2()}else{f=Math.min(f,i.getX1());h=Math.min(h,i.getY1());d=Math.max(d,i.getX2());g=Math.max(g,i.getY2())}b()};this.inflate=function(i){f-=i;h-=i;d+=i;g+=i;b()};this.minSelf=function(i){f=Math.max(f,i.getX1());h=Math.max(h,i.getY1());d=Math.min(d,i.getX2());g=Math.min(g,i.getY2());b()};this.instersects=function(i){return Math.min(d,i.getX2())-Math.max(f,i.getX1())>=0&&Math.min(g,i.getY2())-Math.max(h,i.getY1())>=0};this.empty=function(){e=true;f=0;h=0;d=0;g=0;b()};this.isEmpty=function(){return e};this.toString=function(){return"THREE.Rectangle (x1: "+f+", y1: "+g+", x2: "+d+", y1: "+h+", width: "+a+", height: "+c+")"}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=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},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}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=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},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(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=a-k;b=f-g;l=(o+c)/n;j=(a+k)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g||new THREE.Vector3();this.color=f||new THREE.Color(4278190080)};THREE.Face3.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).divideScalar(3)},toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h||new THREE.Vector3();this.color=g||new THREE.Color(4278190080)};THREE.Face4.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).addSelf(this.d).divideScalar(4)},toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};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.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;c<b;c++){a=this.faces[c];a.centroid.set(0,0,0);if(a instanceof THREE.Face3){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.divideScalar(3)}else{if(a instanceof THREE.Face4){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.addSelf(this.vertices[a.d].position);a.centroid.divideScalar(4)}}}},computeNormals:function(){var k,d,g,h,j,i,c,b,a,e=new THREE.Vector3(),l=new THREE.Vector3();for(k=0,d=this.vertices.length;k<d;k++){g=this.vertices[k];g.normal.set(0,0,0)}for(h=0,j=this.faces.length;h<j;h++){i=this.faces[h];c=this.vertices[i.a];b=this.vertices[i.b];a=this.vertices[i.c];e.sub(a.position,b.position);l.sub(c.position,b.position);e.crossSelf(l);if(!e.isZero()){e.normalize()}i.normal.copy(e)}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){this.fov=c;this.aspect=b;this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(255<<24|a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light();THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,0,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.PointLight;THREE.Object3D=function(a){this.position=new THREE.Vector3();this.rotation=new THREE.Vector3();this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4();this.matrixTranslation=new THREE.Matrix4();this.matrixRotation=new THREE.Matrix4();this.matrixScale=new THREE.Matrix4();this.screen=new THREE.Vector3();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D();THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a]};THREE.Line.prototype=new THREE.Object3D();THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a];this.flipSided=false;this.doubleSided=false;this.overdraw=false};THREE.Mesh.prototype=new THREE.Object3D();THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.LineColorMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshBitmapUVMappingMaterial=function(a){this.bitmap=a;this.toString=function(){return"THREE.MeshBitmapUVMappingMaterial ( bitmap: "+this.bitmap+" )"}};THREE.MeshColorFillMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.MeshColorFillMaterial ( color: "+this.color+" )"}};THREE.MeshColorStrokeMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c);this.toString=function(){return"THREE.MeshColorStrokeMaterial ( lineWidth: "+this.lineWidth+", color: "+this.color+" )"}};THREE.MeshFaceColorFillMaterial=function(){this.toString=function(){return"THREE.MeshFaceColorFillMaterial ( )"}};THREE.MeshFaceColorStrokeMaterial=function(a){this.lineWidth=a||1;this.toString=function(){return"THREE.MeshFaceColorStrokeMaterial ( lineWidth: "+this.lineWidth+" )"}};THREE.ParticleBitmapMaterial=function(a){this.bitmap=a;this.offset=new THREE.Vector2();this.toString=function(){return"THREE.ParticleBitmapMaterial ( bitmap: "+this.bitmap+" )"}};THREE.ParticleCircleMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.ParticleCircleMaterial ( color: "+this.color+" )"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(b){for(var c=0,a=this.objects.length;c<a;c++){if(b==this.objects[c]){this.objects.splice(c,1);return}}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(b){for(var c=0,a=this.lights.length;c<a;c++){if(b==this.lights[c]){this.lights.splice(c,1);return}}};this.add=function(a){this.addObject(a)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F<E;F++){L=r[F];q=L.matrix;if(L.autoUpdateMatrix){L.updateMatrix()}if(L instanceof THREE.Mesh){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I<B;I++){A=w[I];if(A instanceof THREE.Face3){y=z[A.a];x=z[A.b];t=z[A.c];if(y.__visible&&x.__visible&&t.__visible){if((L.doubleSided||(L.flipSided!=(t.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(t.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0))){c=n[p]=n[p]||new THREE.RenderableFace3();c.v1.copy(y.positionScreen);c.v2.copy(x.positionScreen);c.v3.copy(t.positionScreen);c.centroidWorld.copy(A.centroid);L.matrix.transform(c.centroidWorld);c.normalWorld.copy(A.normal);L.matrixRotation.transform(c.normalWorld);c.z=Math.max(y.positionScreen.z,Math.max(x.positionScreen.z,t.positionScreen.z));c.material=L.material;c.overdraw=L.overdraw;c.uvs=L.geometry.uvs[I];c.color=A.color;e.push(c);p++}}}else{if(A instanceof THREE.Face4){y=z[A.a];x=z[A.b];t=z[A.c];s=z[A.d];if(y.__visible&&x.__visible&&t.__visible&&s.__visible){if((L.doubleSided||(L.flipSided!=((s.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(s.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0||(x.positionScreen.x-t.positionScreen.x)*(s.positionScreen.y-t.positionScreen.y)-(x.positionScreen.y-t.positionScreen.y)*(s.positionScreen.x-t.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.copy(y.positionScreen);b.v2.copy(x.positionScreen);b.v3.copy(t.positionScreen);b.v4.copy(s.positionScreen);b.centroidWorld.copy(A.centroid);L.matrix.transform(b.centroidWorld);b.normalWorld.copy(A.normal);L.matrixRotation.transform(b.normalWorld);b.z=Math.max(y.positionScreen.z,Math.max(x.positionScreen.z,Math.max(t.positionScreen.z,s.positionScreen.z)));b.material=L.material;b.overdraw=L.overdraw;b.uvs=L.geometry.uvs[I];b.color=A.color;e.push(b);f++}}}}}}else{if(L instanceof THREE.Line){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);G.matrix.transform(g);G.projectionMatrix.transform(g);L.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(L.screen.z>0&&L.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=L.screen.x;j.y=L.screen.y;j.z=L.screen.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(g.x/g.w-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(g.y/g.w-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;j.color=L.color;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q<h;q++){o=e[q];if(o instanceof THREE.RenderableParticle){k=o.x*f+f;j=o.y*d+d;for(i=0,n=o.material.length;i<n;i++){s=o.material[i];if(s instanceof THREE.ParticleDOMMaterial){l=s.domElement;l.style.left=k+"px";l.style.top=j+"px"}}}}}};THREE.CanvasRenderer=function(){var w=null,q=new THREE.Projector(),n=document.createElement("canvas"),o=n.getContext("2d"),j,B,m,e,A=new THREE.Rectangle(),l=new THREE.Rectangle(),u=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),s=new THREE.Color(4294967295),f=new THREE.Color(4294967295),h=new THREE.Vector2(),g=new THREE.Vector3(),d=new THREE.Vector2(),b=new THREE.Vector2(),z=new THREE.UV(),y=new THREE.UV(),v=new THREE.UV(),t=new THREE.UV();this.domElement=n;this.autoClear=true;this.setSize=function(D,C){j=D;B=C;m=j/2;e=B/2;n.width=j;n.height=B;A.set(-m,-e,m,e)};this.clear=function(){if(!l.isEmpty()){l.inflate(1);l.minSelf(A);o.setTransform(1,0,0,-1,m,e);o.clearRect(l.getX(),l.getY(),l.getWidth(),l.getHeight());l.empty()}};this.render=function(ac,X){var ab,F,H,R,Y,N,P=Math.PI*2,J,I,V,T,E,C,L,K,W,U,G,D,Q,O,ae,ad,aa,Z,af,M,S;if(this.autoClear){this.clear()}w=q.projectScene(ac,X);o.setTransform(1,0,0,-1,m,e);o.fillStyle="rgba(0, 255, 255, 0.5)";o.fillRect(A.getX(),A.getY(),A.getWidth(),A.getHeight());i=ac.lights.length>0;if(i){x(ac,f)}for(ab=0,F=w.length;ab<F;ab++){H=w[ab];u.empty();if(H instanceof THREE.RenderableParticle){J=H.x*m;I=H.y*e;for(R=0,Y=H.material.length;R<Y;R++){N=H.material[R];if(N instanceof THREE.ParticleCircleMaterial){if(i){s.copyRGB(f);p(ac,H,s);k.copyRGBA(N.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=N.color}Q=H.scale.x*m;O=H.scale.y*e;u.set(J-Q,I-O,J+Q,I+O);if(!A.instersects(u)){continue}o.save();o.translate(J,I);o.rotate(-H.rotation);o.scale(Q,O);o.beginPath();o.arc(0,0,1,0,P,true);o.closePath();o.fillStyle=k.__styleString;o.fill();o.restore()}else{if(N instanceof THREE.ParticleBitmapMaterial){af=N.bitmap;M=af.width/2;S=af.height/2;ae=H.scale.x*m;ad=H.scale.y*e;Q=ae*M;O=ad*S;aa=N.offset.x*ae;Z=N.offset.y*ad;u.set(J+aa-Q,I+Z-O,J+aa+Q,I+Z+O);if(!A.instersects(u)){continue}o.save();o.translate(J,I);o.rotate(-H.rotation);o.scale(ae,-ad);o.translate(-M+N.offset.x,-S-N.offset.y);o.drawImage(af,0,0);o.restore();o.beginPath();o.moveTo(J-10,I);o.lineTo(J+10,I);o.moveTo(J,I-10);o.lineTo(J,I+10);o.closePath();o.strokeStyle="rgb(255,255,0)";o.stroke()}}}}else{if(H instanceof THREE.RenderableLine){J=H.v1.x*m;I=H.v1.y*e;V=H.v2.x*m;T=H.v2.y*e;u.addPoint(J,I);u.addPoint(V,T);if(!A.instersects(u)){continue}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.closePath();for(R=0,Y=H.material.length;R<Y;R++){N=H.material[R];if(N instanceof THREE.LineColorMaterial){if(i){s.copyRGB(f);p(ac,H,s);k.copyRGBA(N.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=N.color}o.lineWidth=N.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=k.__styleString;o.stroke();u.inflate(o.lineWidth)}}}else{if(H instanceof THREE.RenderableFace3){H.v1.x*=m;H.v1.y*=e;H.v2.x*=m;H.v2.y*=e;H.v3.x*=m;H.v3.y*=e;if(H.overdraw){c(H.v1,H.v2);c(H.v2,H.v3);c(H.v3,H.v1)}J=H.v1.x;I=H.v1.y;V=H.v2.x;T=H.v2.y;E=H.v3.x;C=H.v3.y;u.addPoint(J,I);u.addPoint(V,T);u.addPoint(E,C);if(!A.instersects(u)){continue}for(R=0,Y=H.material.length;R<Y;R++){N=H.material[R];if(N instanceof THREE.MeshColorFillMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(N.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=N.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(J,I);o.closePath();o.fillStyle=k.__styleString;o.fill()}else{if(N instanceof THREE.MeshColorStrokeMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(N.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=N.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(J,I);o.closePath();o.lineWidth=N.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=k.__styleString;o.stroke();u.inflate(o.lineWidth)}else{if(N instanceof THREE.MeshFaceColorFillMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(H.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=H.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(J,I);o.closePath();o.fillStyle=k.__styleString;o.fill()}else{if(N instanceof THREE.MeshFaceColorStrokeMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(H.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=H.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(J,I);o.closePath();o.lineWidth=N.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=k.__styleString;o.stroke();u.inflate(o.lineWidth)}else{if(N instanceof THREE.MeshBitmapUVMappingMaterial){af=N.bitmap;M=af.width-1;S=af.height-1;if(!H.uvs[0]||!H.uvs[1]||!H.uvs[2]){o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(J,I);o.closePath();o.fillStyle="rgb(0, 255, 0)";o.fill();continue}z.copy(H.uvs[0]);y.copy(H.uvs[1]);v.copy(H.uvs[2]);z.u*=M;z.v*=S;y.u*=M;y.v*=S;v.u*=M;v.v*=S;r(af,J,I,V,T,E,C,z.u,z.v,y.u,y.v,v.u,v.v)}}}}}}}else{if(H instanceof THREE.RenderableFace4){H.v1.x*=m;H.v1.y*=e;H.v2.x*=m;H.v2.y*=e;H.v3.x*=m;H.v3.y*=e;H.v4.x*=m;H.v4.y*=e;d.copy(H.v2);b.copy(H.v4);if(H.overdraw){c(H.v1,H.v2);c(H.v2,H.v4);c(H.v4,H.v1)}J=H.v1.x;I=H.v1.y;V=H.v2.x;T=H.v2.y;L=H.v4.x;K=H.v4.y;if(H.overdraw){c(H.v3,d);c(H.v3,b)}E=H.v3.x;C=H.v3.y;W=d.x;U=d.y;G=b.x;D=b.y;u.addPoint(J,I);u.addPoint(V,T);u.addPoint(E,C);u.addPoint(L,K);if(!A.instersects(u)){continue}for(R=0,Y=H.material.length;R<Y;R++){N=H.material[R];if(N instanceof THREE.MeshColorFillMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(N.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=N.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(L,K);o.lineTo(J,I);o.closePath();o.fillStyle=k.__styleString;o.fill()}else{if(N instanceof THREE.MeshColorStrokeMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(N.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=N.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(L,K);o.lineTo(J,I);o.closePath();o.lineWidth=N.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=k.__styleString;o.stroke();u.inflate(o.lineWidth)}else{if(N instanceof THREE.MeshFaceColorFillMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(H.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=H.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(L,K);o.lineTo(J,I);o.closePath();o.fillStyle=k.__styleString;o.fill()}else{if(N instanceof THREE.MeshFaceColorStrokeMaterial){if(i){s.copyRGB(f);a(ac,H,s);k.copyRGBA(H.color);k.multiplySelfRGB(s);k.updateStyleString()}else{k=H.color}o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(L,K);o.lineTo(J,I);o.closePath();o.lineWidth=N.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=k.__styleString;o.stroke();u.inflate(o.lineWidth)}else{if(N instanceof THREE.MeshBitmapUVMappingMaterial){af=N.bitmap;M=af.width-1;S=af.height-1;if(!H.uvs[0]||!H.uvs[1]||!H.uvs[2]||!H.uvs[3]){o.beginPath();o.moveTo(J,I);o.lineTo(V,T);o.lineTo(E,C);o.lineTo(L,K);o.lineTo(J,I);o.closePath();o.fillStyle="rgb(255, 0, 255)";o.fill();continue}z.copy(H.uvs[0]);y.copy(H.uvs[1]);v.copy(H.uvs[2]);t.copy(H.uvs[3]);z.u*=M;z.v*=S;y.u*=M;y.v*=S;v.u*=M;v.v*=S;t.u*=M;t.v*=S;r(af,J,I,V,T,L,K,z.u,z.v,y.u,y.v,t.u,t.v);r(af,W,U,E,C,G,D,y.u,y.v,v.u,v.v,t.u,t.v)}}}}}}}}}}l.addRectangle(u)}o.lineWidth=1;o.strokeStyle="rgba( 255, 0, 0, 0.5 )";o.strokeRect(l.getX(),l.getY(),l.getWidth(),l.getHeight());o.setTransform(1,0,0,1,0,0)};function x(G,E){var D,F,C;E.setRGBA(1,1,1,1);for(D=0,F=G.lights.length;D<F;D++){C=G.lights[D];if(C instanceof THREE.AmbientLight){E.r*=C.color.r;E.g*=C.color.g;E.b*=C.color.b}}}function p(H,F,E){var D,G,C;for(D=0,G=H.lights.length;D<G;D++){C=H.lights[D];if(C instanceof THREE.DirectionalLight){E.r+=C.color.r;E.g+=C.color.g;E.b+=C.color.b}else{if(C instanceof THREE.PointLight){E.r+=C.color.r;E.g+=C.color.g;E.b+=C.color.b}}}}function a(I,G,E){var D,H,C,F;for(D=0,H=I.lights.length;D<H;D++){C=I.lights[D];if(C instanceof THREE.DirectionalLight){F=G.normalWorld.dot(C.position)*C.intensity;if(F>0){E.r+=C.color.r*F;E.g+=C.color.g*F;E.b+=C.color.b*F}}else{if(C instanceof THREE.PointLight){g.sub(C.position,G.centroidWorld);g.normalize();F=G.normalWorld.dot(g)*C.intensity;if(F>0){E.r+=C.color.r*F;E.g+=C.color.g*F;E.b+=C.color.b*F}}}}}function r(V,K,J,Q,P,E,C,S,R,G,F,O,N){var D,U,T,I,H,M,L;o.beginPath();o.moveTo(K,J);o.lineTo(Q,P);o.lineTo(E,C);o.lineTo(K,J);o.closePath();o.save();o.clip();D=S*(N-F)-G*N+O*F+(G-O)*R;U=-(R*(E-Q)-F*E+N*Q+(F-N)*K)/D;T=(F*C+R*(P-C)-N*P+(N-F)*J)/D;I=(S*(E-Q)-G*E+O*Q+(G-O)*K)/D;H=-(G*C+S*(P-C)-O*P+(O-G)*J)/D;M=(S*(N*Q-F*E)+R*(G*E-O*Q)+(O*F-G*N)*K)/D;L=(S*(N*P-F*C)+R*(G*C-O*P)+(O*F-G*N)*J)/D;o.transform(U,T,I,H,M,L);o.drawImage(V,0,0);o.restore()}function c(D,C){h.sub(C,D);h.unit();h.multiplyScalar(0.75);C.addSelf(h);D.subSelf(h)}};THREE.SVGRenderer=function(){var q=null,l=new THREE.Projector(),m=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,u,k,b,s=new THREE.Rectangle(),p=new THREE.Rectangle(),f=false,h=new THREE.Color(4294967295),o=new THREE.Color(4294967295),c=new THREE.Color(4294967295),e=new THREE.Vector3(),d=[],i=[],t=1;this.domElement=m;this.autoClear=true;this.setQuality=function(v){switch(v){case"high":t=1;break;case"low":t=0;break}};this.setSize=function(w,v){g=w;u=v;k=g/2;b=u/2;m.setAttribute("viewBox",(-k)+" "+(-b)+" "+g+" "+u);m.setAttribute("width",g);m.setAttribute("height",u);s.set(-k,-b,k,b)};this.clear=function(){while(m.childNodes.length>0){m.removeChild(m.childNodes[0])}};this.render=function(O,L){var N,x,I,M,y,E,H=0,z=0,F,C,A,K,J,w,v,D,B,G;if(this.autoClear){this.clear()}q=l.projectScene(O,L);f=O.lights.length>0;if(f){r(O,c)}for(N=0,x=q.length;N<x;N++){y=q[N];for(I=0,M=y.material.length;I<M;I++){E=y.material[I];p.empty();if(y instanceof THREE.RenderableParticle){C=y.x*k;A=y.y*-b;G=y.size*k;p.set(C-G,A-G,C+G,A+G);if(!s.instersects(p)){continue}F=n(z++);F.setAttribute("cx",C);F.setAttribute("cy",A);F.setAttribute("r",G)}else{if(y instanceof THREE.RenderableFace3){C=y.v1.x*k;A=y.v1.y*-b;K=y.v2.x*k;J=y.v2.y*-b;w=y.v3.x*k;v=y.v3.y*-b;p.addPoint(C,A);p.addPoint(K,J);p.addPoint(w,v);if(!s.instersects(p)){continue}F=j(H++);F.setAttribute("d","M "+C+" "+A+" L "+K+" "+J+" L "+w+","+v+"z")}else{if(y instanceof THREE.RenderableFace4){C=y.v1.x*k;A=y.v1.y*-b;K=y.v2.x*k;J=y.v2.y*-b;w=y.v3.x*k;v=y.v3.y*-b;D=y.v4.x*k;B=y.v4.y*-b;p.addPoint(C,A);p.addPoint(K,J);p.addPoint(w,v);p.addPoint(D,B);if(!s.instersects(p)){continue}F=j(H++);F.setAttribute("d","M "+C+" "+A+" L "+K+" "+J+" L "+w+","+v+" L "+D+","+B+"z")}}}if(E instanceof THREE.MeshColorFillMaterial){if(f){o.copyRGB(c);a(O,y,o);h.copyRGBA(E.color);h.multiplySelfRGB(o);h.updateStyleString()}else{h=E.color}F.setAttribute("style","fill: "+h.__styleString)}else{if(E instanceof THREE.MeshFaceColorFillMaterial){if(f){o.copyRGB(c);a(O,y,o);h.copyRGBA(y.color);h.multiplySelfRGB(o);h.updateStyleString()}else{h=y.color}F.setAttribute("style","fill: "+h.__styleString)}else{if(E instanceof THREE.MeshColorStrokeMaterial){if(f){o.copyRGB(c);a(O,y,o);h.copyRGBA(E.color);h.multiplySelfRGB(o);h.updateStyleString()}else{h=E.color}F.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+E.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}else{if(E instanceof THREE.MeshFaceColorStrokeMaterial){if(f){o.copyRGB(c);a(O,y,o);h.copyRGBA(y.color);h.multiplySelfRGB(o);h.updateStyleString()}else{h=y.color}F.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+E.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}}}m.appendChild(F)}}};function r(z,x){var w,y,v;x.setRGBA(1,1,1,1);for(w=0,y=z.lights.length;w<y;w++){v=z.lights[w];if(v instanceof THREE.AmbientLight){x.r*=v.color.r;x.g*=v.color.g;x.b*=v.color.b}}}function a(B,z,x){var w,A,v,y;for(w=0,A=B.lights.length;w<A;w++){v=B.lights[w];if(v instanceof THREE.DirectionalLight){y=z.normalWorld.dot(v.position)*v.intensity;if(y>0){x.r+=v.color.r*y;x.g+=v.color.g*y;x.b+=v.color.b*y}}else{if(v instanceof THREE.PointLight){e.sub(v.position,z.centroidWorld);e.normalize();y=z.normalWorld.dot(e)*v.intensity;if(y>0){x.r+=v.color.r*y;x.g+=v.color.g*y;x.b+=v.color.b*y}}}}}function j(v){if(d[v]==null){d[v]=document.createElementNS("http://www.w3.org/2000/svg","path");if(t==0){d[v].setAttribute("shape-rendering","crispEdges")}return d[v]}return d[v]}function n(v){if(i[v]==null){i[v]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(t==0){i[v].setAttribute("shape-rendering","crispEdges")}return i[v]}return i[v]}};THREE.WebGLRenderer=function(){var e=document.createElement("canvas"),a,h,d=new THREE.Matrix4(),g;this.domElement=e;this.autoClear=true;f();c();this.setSize=function(j,i){e.width=j;e.height=i;a.viewport(0,0,e.width,e.height)};this.clear=function(){a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)};this.render=function(K,G){var t,L,N,z,M,C,s,q,y,A,r,J,w,B,x,I,u,D,H,F,p,n,k,j,E,v;if(this.autoClear){this.clear()}a.uniform1i(h.enableLighting,K.lights.length);for(E=0,v=K.lights.length;E<v;E++){q=K.lights[E];if(q instanceof THREE.AmbientLight){C=q.color;a.uniform3f(h.ambientColor,C.r,C.g,C.b)}else{if(q instanceof THREE.DirectionalLight){C=q.color;s=q.position;a.uniform3f(h.lightingDirection,s.x,s.y,s.z);a.uniform3f(h.directionalColor,C.r,C.g,C.b)}}}for(B=0,x=K.objects.length;B<x;B++){N=K.objects[B];if(N instanceof THREE.Mesh){if(!N.__webGLVertexBuffer){y=[];A=[];r=[];J=[];w=0;for(I=0,u=N.geometry.faces.length;I<u;I++){t=N.geometry.faces[I];L=t.color;M=t.normal;if(t instanceof THREE.Face3){p=N.geometry.vertices[t.a].position;n=N.geometry.vertices[t.b].position;k=N.geometry.vertices[t.c].position;y.push(p.x,p.y,p.z);y.push(n.x,n.y,n.z);y.push(k.x,k.y,k.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);A.push(w,w+1,w+2);w+=3}else{if(t instanceof THREE.Face4){p=N.geometry.vertices[t.a].position;n=N.geometry.vertices[t.b].position;k=N.geometry.vertices[t.c].position;j=N.geometry.vertices[t.d].position;y.push(p.x,p.y,p.z);y.push(n.x,n.y,n.z);y.push(k.x,k.y,k.z);y.push(j.x,j.y,j.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);A.push(w,w+1,w+2);A.push(w,w+2,w+3);w+=4}}}if(!y.length){continue}N.__webGLVertexBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLVertexBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(y),a.STATIC_DRAW);N.__webGLNormalBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLNormalBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(J),a.STATIC_DRAW);N.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(r),a.STATIC_DRAW);N.__webGLFaceBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),a.STATIC_DRAW);N.__webGLFaceCount=A.length}d.multiply(G.matrix,N.matrix);h.viewMatrixArray=new Float32Array(d.flatten());h.projectionMatrixArray=new Float32Array(G.projectionMatrix.flatten());g=THREE.Matrix4.makeInvert(d).transpose();h.normalMatrixArray=new Float32Array(g.flatten());a.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);a.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);a.uniformMatrix4fv(h.normalMatrix,false,h.normalMatrixArray);a.bindBuffer(a.ARRAY_BUFFER,N.__webGLVertexBuffer);a.vertexAttribPointer(h.position,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,N.__webGLNormalBuffer);a.vertexAttribPointer(h.normal,3,a.FLOAT,false,0,0);for(D=0,H=N.material.length;D<H;D++){z=N.material[D];if(z instanceof THREE.MeshColorFillMaterial){if(!z.__webGLColorBuffer){r=[];for(F=0;F<N.__webGLFaceCount;F++){r.push(z.color.r,z.color.g,z.color.b,z.color.a)}z.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,z.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(r),a.STATIC_DRAW)}a.bindBuffer(a.ARRAY_BUFFER,z.__webGLColorBuffer);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0)}else{if(z instanceof THREE.MeshFaceColorFillMaterial){a.bindBuffer(a.ARRAY_BUFFER,N.__webGLColorBuffer);a.enableVertexAttribArray(h.color);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0)}}}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);a.drawElements(a.TRIANGLES,N.__webGLFaceCount,a.UNSIGNED_SHORT,0)}}};function f(){try{a=e.getContext("experimental-webgl")}catch(i){}if(!a){alert("WebGL not supported");throw"cannot create webgl context"}a.clearColor(0,0,0,1);a.clearDepth(1);a.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.enable(a.BLEND);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA);a.clearColor(0,0,0,0)}function c(){h=a.createProgram();a.attachShader(h,b("fragment",["#ifdef GL_ES","precision highp float;","#endif","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(){","gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);","}"].join("\n")));a.attachShader(h,b("vertex",["attribute vec3 position;","attribute vec3 normal;","attribute vec4 color;","uniform bool enableLighting;","uniform vec3 ambientColor;","uniform vec3 directionalColor;","uniform vec3 lightingDirection;","uniform mat4 viewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 normalMatrix;","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(void) {","if(!enableLighting) {","lightWeighting = vec3(1.0, 1.0, 1.0);","} else {","vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);","float directionalLightWeighting = max(dot(transformedNormal.xyz, lightingDirection), 0.0);","lightWeighting = ambientColor + directionalColor * directionalLightWeighting;","}","vcolor = color;","gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );","}"].join("\n")));a.linkProgram(h);if(!a.getProgramParameter(h,a.LINK_STATUS)){alert("Could not initialise shaders")}a.useProgram(h);h.viewMatrix=a.getUniformLocation(h,"viewMatrix");h.projectionMatrix=a.getUniformLocation(h,"projectionMatrix");h.normalMatrix=a.getUniformLocation(h,"normalMatrix");h.enableLighting=a.getUniformLocation(h,"enableLighting");h.ambientColor=a.getUniformLocation(h,"ambientColor");h.directionalColor=a.getUniformLocation(h,"directionalColor");h.lightingDirection=a.getUniformLocation(h,"lightingDirection");h.color=a.getAttribLocation(h,"color");a.enableVertexAttribArray(h.color);h.position=a.getAttribLocation(h,"position");a.enableVertexAttribArray(h.position);h.normal=a.getAttribLocation(h,"normal");a.enableVertexAttribArray(h.normal);h.viewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function b(j,i){var k;if(j=="fragment"){k=a.createShader(a.FRAGMENT_SHADER)}else{if(j=="vertex"){k=a.createShader(a.VERTEX_SHADER)}}a.shaderSource(k,i);a.compileShader(k);if(!a.getShaderParameter(k,a.COMPILE_STATUS)){alert(a.getShaderInfoLog(k));return null}return k}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null};
|