ThreeDebug.js 52.0 KB
Newer Older
1 2
// ThreeDebug.js r23 - 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,m,i,k){e=false;f=j;h=m;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 p=this.n11,o=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,s=this.n32,r=this.n33,q=this.n34,n=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=p*c.n11+o*c.n21+k*c.n31+i*c.n41;this.n12=p*c.n12+o*c.n22+k*c.n32+i*c.n42;this.n13=p*c.n13+o*c.n23+k*c.n33+i*c.n43;this.n14=p*c.n14+o*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+s*c.n21+r*c.n31+q*c.n41;this.n32=a*c.n12+s*c.n22+r*c.n32+q*c.n42;this.n33=a*c.n13+s*c.n23+r*c.n33+q*c.n43;this.n34=a*c.n14+s*c.n24+r*c.n34+q*c.n44;this.n41=n*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=n*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=n*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=n*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.makeInvert3x3=function(p){var n=new THREE.Matrix3();var e=p.flatten();var o=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4];var h=e[0]*(o)+e[1]*(k)+e[2]*(j);if(h==0){throw"matrix not invertible"}var b=1/h;n.m[0]=b*o;n.m[1]=b*i;n.m[2]=b*d;n.m[3]=b*k;n.m[4]=b*g;n.m[5]=b*c;n.m[6]=b*j;n.m[7]=b*f;n.m[8]=b*a;return n};THREE.Matrix4.makeFrustum=function(f,s,e,p,i,h){var g,r,o,q,n,k,j;g=new THREE.Matrix4();r=2*i/(s-f);o=2*i/(p-e);q=(s+f)/(s-f);n=(p+e)/(p-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=r;g.n12=0;g.n13=q;g.n14=0;g.n21=0;g.n22=o;g.n23=n;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,q,k,a,g,f){var d,n,j,i,o,e,b;d=new THREE.Matrix4();o=q-c;e=a-k;b=f-g;n=(q+c)/o;j=(a+k)/e;i=(f+g)/b;d.n11=2/o;d.n12=0;d.n13=0;d.n14=-n;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.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};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,i,h,f,g){this.a=e;this.b=d;this.c=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.color=f||new THREE.Color(4278190080);this.vertexNormals=h instanceof Array?h:[];this.material=g||0};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,k,j,i,g,h){this.a=f;this.b=e;this.c=k;this.d=j;this.centroid=new THREE.Vector3();this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3();this.color=g||new THREE.Color(4278190080);this.vertexNormals=i instanceof Array?i:[];this.material=h||0};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(o){var e,b,p,g,i,j,m,k,d,c,a,h=new THREE.Vector3(),q=new THREE.Vector3();for(p=0,g=this.vertices.length;p<g;p++){i=this.vertices[p];i.normal.set(0,0,0)}for(j=0,m=this.faces.length;j<m;j++){k=this.faces[j];if(o&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.x+=k.vertexNormals[e].x;h.y+=k.vertexNormals[e].y;h.z+=k.vertexNormals[e].z}h.x/=3;h.y/=3;h.z/=3;if(!h.isZero()){h.normalize()}k.normal.copy(h)}else{d=this.vertices[k.a];c=this.vertices[k.b];a=this.vertices[k.c];h.sub(a.position,c.position);q.sub(d.position,c.position);h.crossSelf(q);if(!h.isZero()){h.normalize()}k.normal.copy(h)}}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};var a,b;for(a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0]){this.bbox.x[0]=vertex.position.x}else{if(vertex.position.x>this.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.y<this.bbox.y[0]){this.bbox.y[0]=vertex.position.y}else{if(vertex.position.y>this.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.z<this.bbox.z[0]){this.bbox.z[0]=vertex.position.z}else{if(vertex.position.z>this.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},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,c){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a];this.flipSided=false;this.doubleSided=false;this.overdraw=false;this.materialFaces={};this.sortFacesByMaterial();if(c){this.normalizeUVs()}this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D();THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.sortFacesByMaterial=function(){var d,c,b,a;for(d=0,c=this.geometry.faces.length;d<c;d++){b=this.geometry.faces[d];a=b.material;if(this.materialFaces[a]==undefined){this.materialFaces[a]={faces:[]}}this.materialFaces[a].faces.push(d)}};THREE.Mesh.prototype.normalizeUVs=function(){var c,a;for(c=0,l=this.geometry.uvs.length;c<l;c++){var b=this.geometry.uvs[c];for(a=0,jl=b.length;a<jl;a++){if(b[a].u!=1){b[a].u=b[a].u-Math.floor(b[a].u)}if(b[a].v!=1){b[a].v=b[a].v-Math.floor(b[a].v)}}}};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.loaded=0;this.decalIndex=-1;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,q,o=[],b,f,m=[],k,n,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),p=new THREE.Matrix4();this.projectScene=function(K,H){var G,F,E,L,J,C,s,M,r,A,I,w,D,x,B,z,y,u,t;e=[];q=0,f=0,n=0,h=0;if(H.autoUpdateMatrix){H.updateMatrix()}d.multiply(H.projectionMatrix,H.matrix);s=K.objects;for(G=0,F=s.length;G<F;G++){M=s[G];r=M.matrix;if(M.autoUpdateMatrix){M.updateMatrix()}if(M instanceof THREE.Mesh){p.multiply(d,r);A=M.geometry.vertices;for(E=0,L=A.length;E<L;E++){I=A[E];w=I.positionScreen;w.copy(I.position);p.transform(w);I.__visible=w.z>0&&w.z<1}x=M.geometry.faces;for(J=0,C=x.length;J<C;J++){B=x[J];if(B instanceof THREE.Face3){z=A[B.a];y=A[B.b];u=A[B.c];if(z.__visible&&y.__visible&&u.__visible){if((M.doubleSided||(M.flipSided!=(u.positionScreen.x-z.positionScreen.x)*(y.positionScreen.y-z.positionScreen.y)-(u.positionScreen.y-z.positionScreen.y)*(y.positionScreen.x-z.positionScreen.x)<0))){c=o[q]=o[q]||new THREE.RenderableFace3();c.v1.copy(z.positionScreen);c.v2.copy(y.positionScreen);c.v3.copy(u.positionScreen);c.centroidWorld.copy(B.centroid);M.matrix.transform(c.centroidWorld);c.normalWorld.copy(B.normal);M.matrixRotation.transform(c.normalWorld);c.z=Math.max(z.positionScreen.z,Math.max(y.positionScreen.z,u.positionScreen.z));c.material=M.material;c.materialIndex=B.material;c.overdraw=M.overdraw;c.uvs=M.geometry.uvs[J];c.color=B.color;e.push(c);q++}}}else{if(B instanceof THREE.Face4){z=A[B.a];y=A[B.b];u=A[B.c];t=A[B.d];if(z.__visible&&y.__visible&&u.__visible&&t.__visible){if((M.doubleSided||(M.flipSided!=((t.positionScreen.x-z.positionScreen.x)*(y.positionScreen.y-z.positionScreen.y)-(t.positionScreen.y-z.positionScreen.y)*(y.positionScreen.x-z.positionScreen.x)<0||(y.positionScreen.x-u.positionScreen.x)*(t.positionScreen.y-u.positionScreen.y)-(y.positionScreen.y-u.positionScreen.y)*(t.positionScreen.x-u.positionScreen.x)<0)))){b=m[f]=m[f]||new THREE.RenderableFace4();b.v1.copy(z.positionScreen);b.v2.copy(y.positionScreen);b.v3.copy(u.positionScreen);b.v4.copy(t.positionScreen);b.centroidWorld.copy(B.centroid);M.matrix.transform(b.centroidWorld);b.normalWorld.copy(B.normal);M.matrixRotation.transform(b.normalWorld);b.z=Math.max(z.positionScreen.z,Math.max(y.positionScreen.z,Math.max(u.positionScreen.z,t.positionScreen.z)));b.material=M.material;b.materialIndex=B.material;b.overdraw=M.overdraw;b.uvs=M.geometry.uvs[J];b.color=B.color;e.push(b);f++}}}}}}else{if(M instanceof THREE.Line){p.multiply(d,r);A=M.geometry.vertices;for(E=0,L=A.length;E<L;E++){I=A[E];w=I.positionScreen;w.copy(I.position);p.transform(w);I.__visible=w.z>0&&w.z<1;if(E>0){D=M.geometry.vertices[E-1];if(I.__visible&&D.__visible){k=i[n]=i[n]||new THREE.RenderableLine();k.v1.copy(I.positionScreen);k.v2.copy(D.positionScreen);k.z=Math.max(I.positionScreen.z,D.positionScreen.z);k.material=M.material;e.push(k);n++}}}}else{if(M instanceof THREE.Particle){g.set(M.position.x,M.position.y,M.position.z,1);H.matrix.transform(g);H.projectionMatrix.transform(g);M.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(M.screen.z>0&&M.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=M.screen.x;j.y=M.screen.y;j.z=M.screen.z;j.rotation=M.rotation.z;j.scale.x=M.scale.x*Math.abs(g.x/g.w-(g.x+H.projectionMatrix.n11)/(g.w+H.projectionMatrix.n14));j.scale.y=M.scale.y*Math.abs(g.y/g.w-(g.y+H.projectionMatrix.n22)/(g.w+H.projectionMatrix.n24));j.material=M.material;j.color=M.color;e.push(j);h++}}}}}e.sort(function(N,v){return v.z-N.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(q,s){var r,h,i,o,p,t,n,k,j;e=g.projectScene(q,s);for(r=0,h=e.length;r<h;r++){p=e[r];if(p instanceof THREE.RenderableParticle){k=p.x*f+f;j=p.y*d+d;for(i=0,o=p.material.length;i<o;i++){t=p.material[i];if(t instanceof THREE.ParticleDOMMaterial){n=t.domElement;n.style.left=k+"px";n.style.top=j+"px"}}}}}};THREE.CanvasRenderer=function(){var x=null,r=new THREE.Projector(),o=document.createElement("canvas"),p=o.getContext("2d"),j,C,n,e,B=new THREE.Rectangle(),m=new THREE.Rectangle(),v=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),t=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(),A=new THREE.UV(),z=new THREE.UV(),w=new THREE.UV(),u=new THREE.UV();this.domElement=o;this.autoClear=true;this.setSize=function(E,D){j=E;C=D;n=j/2;e=C/2;o.width=j;o.height=C;B.set(-n,-e,n,e)};this.clear=function(){if(!m.isEmpty()){m.inflate(1);m.minSelf(B);p.setTransform(1,0,0,-1,n,e);p.clearRect(m.getX(),m.getY(),m.getWidth(),m.getHeight());m.empty()}};this.isFullOverlay=function(F,D,E){return((F instanceof THREE.MeshBitmapUVMappingMaterial||F instanceof THREE.MeshFaceColorFillMaterial||F instanceof THREE.MeshColorFillMaterial)&&!(D==E.materialIndex||E.materialIndex==F.decalIndex))};this.render=function(ad,Y){var ac,G,I,S,Z,O,Q=Math.PI*2,K,J,W,U,F,D,M,L,X,V,H,E,R,P,af,ae,ab,aa,ag,N,T;if(this.autoClear){this.clear()}x=r.projectScene(ad,Y);p.setTransform(1,0,0,-1,n,e);p.fillStyle="rgba(0, 255, 255, 0.5)";p.fillRect(B.getX(),B.getY(),B.getWidth(),B.getHeight());i=ad.lights.length>0;if(i){y(ad,f)}for(ac=0,G=x.length;ac<G;ac++){I=x[ac];v.empty();if(I instanceof THREE.RenderableParticle){K=I.x*n;J=I.y*e;for(S=0,Z=I.material.length;S<Z;S++){O=I.material[S];if(O instanceof THREE.ParticleCircleMaterial){if(i){t.copyRGB(f);q(ad,I,t);k.copyRGBA(O.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=O.color}R=I.scale.x*n;P=I.scale.y*e;v.set(K-R,J-P,K+R,J+P);if(!B.instersects(v)){continue}p.save();p.translate(K,J);p.rotate(-I.rotation);p.scale(R,P);p.beginPath();p.arc(0,0,1,0,Q,true);p.closePath();p.fillStyle=k.__styleString;p.fill();p.restore()}else{if(O instanceof THREE.ParticleBitmapMaterial){ag=O.bitmap;N=ag.width/2;T=ag.height/2;af=I.scale.x*n;ae=I.scale.y*e;R=af*N;P=ae*T;ab=O.offset.x*af;aa=O.offset.y*ae;v.set(K+ab-R,J+aa-P,K+ab+R,J+aa+P);if(!B.instersects(v)){continue}p.save();p.translate(K,J);p.rotate(-I.rotation);p.scale(af,-ae);p.translate(-N+O.offset.x,-T-O.offset.y);p.drawImage(ag,0,0);p.restore();p.beginPath();p.moveTo(K-10,J);p.lineTo(K+10,J);p.moveTo(K,J-10);p.lineTo(K,J+10);p.closePath();p.strokeStyle="rgb(255,255,0)";p.stroke()}}}}else{if(I instanceof THREE.RenderableLine){K=I.v1.x*n;J=I.v1.y*e;W=I.v2.x*n;U=I.v2.y*e;v.addPoint(K,J);v.addPoint(W,U);if(!B.instersects(v)){continue}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.closePath();for(S=0,Z=I.material.length;S<Z;S++){O=I.material[S];if(O instanceof THREE.LineColorMaterial){if(i){t.copyRGB(f);q(ad,I,t);k.copyRGBA(O.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=O.color}p.lineWidth=O.lineWidth;p.lineJoin="round";p.lineCap="round";p.strokeStyle=k.__styleString;p.stroke();v.inflate(p.lineWidth)}}}else{if(I instanceof THREE.RenderableFace3){I.v1.x*=n;I.v1.y*=e;I.v2.x*=n;I.v2.y*=e;I.v3.x*=n;I.v3.y*=e;if(I.overdraw){c(I.v1,I.v2);c(I.v2,I.v3);c(I.v3,I.v1)}K=I.v1.x;J=I.v1.y;W=I.v2.x;U=I.v2.y;F=I.v3.x;D=I.v3.y;v.addPoint(K,J);v.addPoint(W,U);v.addPoint(F,D);if(!B.instersects(v)){continue}for(S=0,Z=I.material.length;S<Z;S++){O=I.material[S];if(this.isFullOverlay(O,S,I)){continue}if(O instanceof THREE.MeshColorFillMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(O.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=O.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(K,J);p.closePath();p.fillStyle=k.__styleString;p.fill()}else{if(O instanceof THREE.MeshColorStrokeMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(O.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=O.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(K,J);p.closePath();p.lineWidth=O.lineWidth;p.lineJoin="round";p.lineCap="round";p.strokeStyle=k.__styleString;p.stroke();v.inflate(p.lineWidth)}else{if(O instanceof THREE.MeshFaceColorFillMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(I.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=I.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(K,J);p.closePath();p.fillStyle=k.__styleString;p.fill()}else{if(O instanceof THREE.MeshFaceColorStrokeMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(I.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=I.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(K,J);p.closePath();p.lineWidth=O.lineWidth;p.lineJoin="round";p.lineCap="round";p.strokeStyle=k.__styleString;p.stroke();v.inflate(p.lineWidth)}else{if(O instanceof THREE.MeshBitmapUVMappingMaterial){ag=O.bitmap;N=ag.width-1;T=ag.height-1;if(!I.uvs[0]||!I.uvs[1]||!I.uvs[2]){p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(K,J);p.closePath();p.fillStyle="rgb(0, 255, 0)";p.fill();continue}A.copy(I.uvs[0]);z.copy(I.uvs[1]);w.copy(I.uvs[2]);A.u*=N;A.v*=T;z.u*=N;z.v*=T;w.u*=N;w.v*=T;s(ag,K,J,W,U,F,D,A.u,A.v,z.u,z.v,w.u,w.v)}}}}}}}else{if(I instanceof THREE.RenderableFace4){I.v1.x*=n;I.v1.y*=e;I.v2.x*=n;I.v2.y*=e;I.v3.x*=n;I.v3.y*=e;I.v4.x*=n;I.v4.y*=e;d.copy(I.v2);b.copy(I.v4);if(I.overdraw){c(I.v1,I.v2);c(I.v2,I.v4);c(I.v4,I.v1)}K=I.v1.x;J=I.v1.y;W=I.v2.x;U=I.v2.y;M=I.v4.x;L=I.v4.y;if(I.overdraw){c(I.v3,d);c(I.v3,b)}F=I.v3.x;D=I.v3.y;X=d.x;V=d.y;H=b.x;E=b.y;v.addPoint(K,J);v.addPoint(W,U);v.addPoint(F,D);v.addPoint(M,L);if(!B.instersects(v)){continue}for(S=0,Z=I.material.length;S<Z;S++){O=I.material[S];if(this.isFullOverlay(O,S,I)){continue}if(O instanceof THREE.MeshColorFillMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(O.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=O.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(M,L);p.lineTo(K,J);p.closePath();p.fillStyle=k.__styleString;p.fill()}else{if(O instanceof THREE.MeshColorStrokeMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(O.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=O.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(M,L);p.lineTo(K,J);p.closePath();p.lineWidth=O.lineWidth;p.lineJoin="round";p.lineCap="round";p.strokeStyle=k.__styleString;p.stroke();v.inflate(p.lineWidth)}else{if(O instanceof THREE.MeshFaceColorFillMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(I.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=I.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(M,L);p.lineTo(K,J);p.closePath();p.fillStyle=k.__styleString;p.fill()}else{if(O instanceof THREE.MeshFaceColorStrokeMaterial){if(i){t.copyRGB(f);a(ad,I,t);k.copyRGBA(I.color);k.multiplySelfRGB(t);k.updateStyleString()}else{k=I.color}p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(M,L);p.lineTo(K,J);p.closePath();p.lineWidth=O.lineWidth;p.lineJoin="round";p.lineCap="round";p.strokeStyle=k.__styleString;p.stroke();v.inflate(p.lineWidth)}else{if(O instanceof THREE.MeshBitmapUVMappingMaterial){ag=O.bitmap;N=ag.width-1;T=ag.height-1;if(!I.uvs[0]||!I.uvs[1]||!I.uvs[2]||!I.uvs[3]){p.beginPath();p.moveTo(K,J);p.lineTo(W,U);p.lineTo(F,D);p.lineTo(M,L);p.lineTo(K,J);p.closePath();p.fillStyle="rgb(255, 0, 255)";p.fill();continue}A.copy(I.uvs[0]);z.copy(I.uvs[1]);w.copy(I.uvs[2]);u.copy(I.uvs[3]);A.u*=N;A.v*=T;z.u*=N;z.v*=T;w.u*=N;w.v*=T;u.u*=N;u.v*=T;s(ag,K,J,W,U,M,L,A.u,A.v,z.u,z.v,u.u,u.v);s(ag,X,V,F,D,H,E,z.u,z.v,w.u,w.v,u.u,u.v)}}}}}}}}}}m.addRectangle(v)}p.lineWidth=1;p.strokeStyle="rgba( 255, 0, 0, 0.5 )";p.strokeRect(m.getX(),m.getY(),m.getWidth(),m.getHeight());p.setTransform(1,0,0,1,0,0)};function y(H,F){var E,G,D;F.setRGBA(1,1,1,1);for(E=0,G=H.lights.length;E<G;E++){D=H.lights[E];if(D instanceof THREE.AmbientLight){F.r*=D.color.r;F.g*=D.color.g;F.b*=D.color.b}}}function q(I,G,F){var E,H,D;for(E=0,H=I.lights.length;E<H;E++){D=I.lights[E];if(D instanceof THREE.DirectionalLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}else{if(D instanceof THREE.PointLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}}}}function a(J,H,F){var E,I,D,G;for(E=0,I=J.lights.length;E<I;E++){D=J.lights[E];if(D instanceof THREE.DirectionalLight){G=H.normalWorld.dot(D.position)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}else{if(D instanceof THREE.PointLight){g.sub(D.position,H.centroidWorld);g.normalize();G=H.normalWorld.dot(g)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}}}}function s(W,L,K,R,Q,F,D,T,S,H,G,P,O){var E,V,U,J,I,N,M;p.beginPath();p.moveTo(L,K);p.lineTo(R,Q);p.lineTo(F,D);p.lineTo(L,K);p.closePath();p.save();p.clip();E=T*(O-G)-H*O+P*G+(H-P)*S;V=-(S*(F-R)-G*F+O*R+(G-O)*L)/E;U=(G*D+S*(Q-D)-O*Q+(O-G)*K)/E;J=(T*(F-R)-H*F+P*R+(H-P)*L)/E;I=-(H*D+T*(Q-D)-P*Q+(P-H)*K)/E;N=(T*(O*R-G*F)+S*(H*F-P*R)+(P*G-H*O)*L)/E;M=(T*(O*Q-G*D)+S*(H*D-P*Q)+(P*G-H*O)*K)/E;p.transform(V,U,J,I,N,M);p.drawImage(W,0,0);p.restore()}function c(E,D){h.sub(D,E);h.unit();h.multiplyScalar(0.75);D.addSelf(h);E.subSelf(h)}};THREE.SVGRenderer=function(){var r=null,m=new THREE.Projector(),n=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,v,k,b,t=new THREE.Rectangle(),q=new THREE.Rectangle(),f=false,h=new THREE.Color(4294967295),p=new THREE.Color(4294967295),c=new THREE.Color(4294967295),e=new THREE.Vector3(),d=[],i=[],u=1;this.domElement=n;this.autoClear=true;this.setQuality=function(w){switch(w){case"high":u=1;break;case"low":u=0;break}};this.setSize=function(x,w){g=x;v=w;k=g/2;b=v/2;n.setAttribute("viewBox",(-k)+" "+(-b)+" "+g+" "+v);n.setAttribute("width",g);n.setAttribute("height",v);t.set(-k,-b,k,b)};this.clear=function(){while(n.childNodes.length>0){n.removeChild(n.childNodes[0])}};this.render=function(P,M){var O,y,J,N,z,F,I=0,A=0,G,D,B,L,K,x,w,E,C,H;if(this.autoClear){this.clear()}r=m.projectScene(P,M);f=P.lights.length>0;if(f){s(P,c)}for(O=0,y=r.length;O<y;O++){z=r[O];for(J=0,N=z.material.length;J<N;J++){F=z.material[J];q.empty();if(z instanceof THREE.RenderableParticle){D=z.x*k;B=z.y*-b;H=z.size*k;q.set(D-H,B-H,D+H,B+H);if(!t.instersects(q)){continue}G=o(A++);G.setAttribute("cx",D);G.setAttribute("cy",B);G.setAttribute("r",H)}else{if(z instanceof THREE.RenderableFace3){D=z.v1.x*k;B=z.v1.y*-b;L=z.v2.x*k;K=z.v2.y*-b;x=z.v3.x*k;w=z.v3.y*-b;q.addPoint(D,B);q.addPoint(L,K);q.addPoint(x,w);if(!t.instersects(q)){continue}G=j(I++);G.setAttribute("d","M "+D+" "+B+" L "+L+" "+K+" L "+x+","+w+"z")}else{if(z instanceof THREE.RenderableFace4){D=z.v1.x*k;B=z.v1.y*-b;L=z.v2.x*k;K=z.v2.y*-b;x=z.v3.x*k;w=z.v3.y*-b;E=z.v4.x*k;C=z.v4.y*-b;q.addPoint(D,B);q.addPoint(L,K);q.addPoint(x,w);q.addPoint(E,C);if(!t.instersects(q)){continue}G=j(I++);G.setAttribute("d","M "+D+" "+B+" L "+L+" "+K+" L "+x+","+w+" L "+E+","+C+"z")}}}if(F instanceof THREE.MeshColorFillMaterial){if(f){p.copyRGB(c);a(P,z,p);h.copyRGBA(F.color);h.multiplySelfRGB(p);h.updateStyleString()}else{h=F.color}G.setAttribute("style","fill: "+h.__styleString)}else{if(F instanceof THREE.MeshFaceColorFillMaterial){if(f){p.copyRGB(c);a(P,z,p);h.copyRGBA(z.color);h.multiplySelfRGB(p);h.updateStyleString()}else{h=z.color}G.setAttribute("style","fill: "+h.__styleString)}else{if(F instanceof THREE.MeshColorStrokeMaterial){if(f){p.copyRGB(c);a(P,z,p);h.copyRGBA(F.color);h.multiplySelfRGB(p);h.updateStyleString()}else{h=F.color}G.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+F.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}else{if(F instanceof THREE.MeshFaceColorStrokeMaterial){if(f){p.copyRGB(c);a(P,z,p);h.copyRGBA(z.color);h.multiplySelfRGB(p);h.updateStyleString()}else{h=z.color}G.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+F.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}}}n.appendChild(G)}}};function s(A,y){var x,z,w;y.setRGBA(1,1,1,1);for(x=0,z=A.lights.length;x<z;x++){w=A.lights[x];if(w instanceof THREE.AmbientLight){y.r*=w.color.r;y.g*=w.color.g;y.b*=w.color.b}}}function a(C,A,y){var x,B,w,z;for(x=0,B=C.lights.length;x<B;x++){w=C.lights[x];if(w instanceof THREE.DirectionalLight){z=A.normalWorld.dot(w.position)*w.intensity;if(z>0){y.r+=w.color.r*z;y.g+=w.color.g*z;y.b+=w.color.b*z}}else{if(w instanceof THREE.PointLight){e.sub(w.position,A.centroidWorld);e.normalize();z=A.normalWorld.dot(e)*w.intensity;if(z>0){y.r+=w.color.r*z;y.g+=w.color.g*z;y.b+=w.color.b*z}}}}}function j(w){if(d[w]==null){d[w]=document.createElementNS("http://www.w3.org/2000/svg","path");if(u==0){d[w].setAttribute("shape-rendering","crispEdges")}return d[w]}return d[w]}function o(w){if(i[w]==null){i[w]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(u==0){i[w].setAttribute("shape-rendering","crispEdges")}return i[w]}return i[w]}};THREE.WebGLRenderer=function(){var m=document.createElement("canvas"),c,d,e=new THREE.Matrix4(),k;this.domElement=m;this.autoClear=true;h();g();var a=0,n=1,f=2,j=3,i=4;this.setSize=function(p,o){m.width=p;m.height=o;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(u){var s,t,o,r,q,p;c.uniform1i(d.enableLighting,u.lights.length);for(s=0,t=u.lights.length;s<t;s++){p=u.lights[s];if(p instanceof THREE.AmbientLight){o=p.color;c.uniform3f(d.ambientColor,o.r,o.g,o.b)}else{if(p instanceof THREE.DirectionalLight){o=p.color;r=p.position;q=p.intensity;c.uniform3f(d.lightingDirection,r.x,r.y,r.z);c.uniform3f(d.directionalColor,o.r*q,o.g*q,o.b*q)}else{if(p instanceof THREE.PointLight){o=p.color;r=p.position;q=p.intensity;c.uniform3f(d.pointPosition,r.x,r.y,r.z);c.uniform3f(d.pointColor,o.r*q,o.g*q,o.b*q)}}}}};this.createBuffers=function(K,v){var s=K.materialFaces[v];var B=K.material[v];var C=[];var E=[];var A=[];var t=[];var H=[];var D=[];var y=0;var G,x,z,w,I,F,J,u,r,q,p,o;for(G=0,x=s.faces.length;G<x;G++){z=s.faces[G];w=K.geometry.faces[z];I=w.color;F=w.vertexNormals;J=w.normal;u=K.geometry.uvs[z];if(w instanceof THREE.Face3){r=K.geometry.vertices[w.a].position;q=K.geometry.vertices[w.b].position;p=K.geometry.vertices[w.c].position;A.push(r.x,r.y,r.z);A.push(q.x,q.y,q.z);A.push(p.x,p.y,p.z);if(F.length==3){H.push(F[0].x,F[0].y,F[0].z);H.push(F[1].x,F[1].y,F[1].z);H.push(F[2].x,F[2].y,F[2].z)}else{H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z)}t.push(I.r,I.g,I.b,I.a);t.push(I.r,I.g,I.b,I.a);t.push(I.r,I.g,I.b,I.a);if(u){D.push(u[0].u,u[0].v);D.push(u[1].u,u[1].v);D.push(u[2].u,u[2].v)}C.push(y,y+1,y+2);E.push(y,y+1);E.push(y,y+2);E.push(y+1,y+2);y+=3}else{if(w instanceof THREE.Face4){r=K.geometry.vertices[w.a].position;q=K.geometry.vertices[w.b].position;p=K.geometry.vertices[w.c].position;o=K.geometry.vertices[w.d].position;A.push(r.x,r.y,r.z);A.push(q.x,q.y,q.z);A.push(p.x,p.y,p.z);A.push(o.x,o.y,o.z);if(F.length==4){H.push(F[0].x,F[0].y,F[0].z);H.push(F[1].x,F[1].y,F[1].z);H.push(F[2].x,F[2].y,F[2].z);H.push(F[3].x,F[3].y,F[3].z)}else{H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z)}t.push(I.r,I.g,I.b,I.a);t.push(I.r,I.g,I.b,I.a);t.push(I.r,I.g,I.b,I.a);t.push(I.r,I.g,I.b,I.a);if(u){D.push(u[0].u,u[0].v);D.push(u[1].u,u[1].v);D.push(u[2].u,u[2].v);D.push(u[3].u,u[3].v)}C.push(y,y+1,y+2);C.push(y,y+2,y+3);E.push(y,y+1);E.push(y,y+2);E.push(y,y+3);E.push(y+1,y+2);E.push(y+2,y+3);y+=4}}}if(!A.length){return}s.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,s.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(A),c.STATIC_DRAW);s.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,s.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);s.__webGLColorBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,s.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(t),c.STATIC_DRAW);s.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,s.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);s.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),c.STATIC_DRAW);s.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),c.STATIC_DRAW);s.__webGLFaceCount=C.length;s.__webGLLineCount=E.length};this.renderMesh=function(p,t){var o,q,v,u,r,w,s;for(var v in p.materialFaces){r=p.materialFaces[v];u=p.material[v];if(!u){continue}if(!r.__webGLVertexBuffer){this.createBuffers(p,v)}for(o=0,q=p.material.length;o<q;o++){u=p.material[o];if((u instanceof THREE.MeshBitmapUVMappingMaterial||u instanceof THREE.MeshFaceColorFillMaterial||u instanceof THREE.MeshColorFillMaterial)&&!(o==v||v==u.decalIndex)){continue}if(u instanceof THREE.MeshColorFillMaterial){color=u.color;c.uniform4f(d.uniformColor,color.r,color.g,color.b,color.a);c.uniform1i(d.material,a)}else{if(u instanceof THREE.MeshColorStrokeMaterial){s=u.lineWidth;color=u.color;c.uniform4f(d.uniformColor,color.r,color.g,color.b,color.a);c.uniform1i(d.material,n)}else{if(u instanceof THREE.MeshFaceColorFillMaterial){c.uniform1i(d.material,f)}else{if(u instanceof THREE.MeshFaceColorStrokeMaterial){s=u.lineWidth;c.uniform1i(d.material,j)}else{if(u instanceof THREE.MeshBitmapUVMappingMaterial){if(!u.__webGLTexture&&u.loaded){u.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,u.bitmap);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.uniform1i(d.diffuse,0);c.uniform1i(d.material,i)}}}}}c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.vertexAttribPointer(d.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLNormalBuffer);c.vertexAttribPointer(d.normal,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLColorBuffer);c.vertexAttribPointer(d.color,4,c.FLOAT,false,0,0);if(u instanceof THREE.MeshBitmapUVMappingMaterial){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.enableVertexAttribArray(d.uv);c.vertexAttribPointer(d.uv,2,c.FLOAT,false,0,0)}else{c.disableVertexAttribArray(d.uv)}if(u instanceof THREE.MeshBitmapUVMappingMaterial||u instanceof THREE.MeshFaceColorFillMaterial||u instanceof THREE.MeshColorFillMaterial){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,r.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else{if(u instanceof THREE.MeshColorStrokeMaterial||u instanceof THREE.MeshFaceColorStrokeMaterial){c.lineWidth(s);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);c.drawElements(c.LINES,r.__webGLLineCount,c.UNSIGNED_SHORT,0)}}}}};this.setupMatrices=function(o,p){p.autoUpdateMatrix&&p.updateMatrix();o.autoUpdateMatrix&&o.updateMatrix();e.multiply(p.matrix,o.matrix);d.viewMatrixArray=new Float32Array(e.flatten());d.projectionMatrixArray=new Float32Array(p.projectionMatrix.flatten());k=THREE.Matrix4.makeInvert3x3(o.matrix).transpose();d.normalMatrixArray=new Float32Array(k.m);c.uniformMatrix4fv(d.viewMatrix,false,d.viewMatrixArray);c.uniformMatrix4fv(d.projectionMatrix,false,d.projectionMatrixArray);c.uniformMatrix3fv(d.normalMatrix,false,d.normalMatrixArray);c.uniformMatrix4fv(d.objMatrix,false,new Float32Array(o.matrix.flatten()))};this.render=function(s,r){var t,q,p;if(this.autoClear){this.clear()}this.setupLights(s);for(t=0,q=s.objects.length;t<q;t++){p=s.objects[t];this.setupMatrices(p,r);if(p instanceof THREE.Mesh){this.renderMesh(p,r)}else{if(p instanceof THREE.Line){}else{if(p instanceof THREE.Particle){}}}}};function h(){try{c=m.getContext("experimental-webgl",{antialias:true})}catch(o){}if(!c){alert("WebGL not supported");throw"cannot create webgl context"}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0)}function g(){d=c.createProgram();c.attachShader(d,b("fragment",["#ifdef GL_ES","precision highp float;","#endif","uniform sampler2D diffuse;","uniform vec4 uniformColor;","varying vec2 vertexUv;","varying vec4 vertexColor;","varying vec3 lightWeighting;","varying vec3 vNormal;","uniform int material;","void main(){","if(material==4) {","vec4 texelColor = texture2D(diffuse, vertexUv);","gl_FragColor = vec4(texelColor.rgb * lightWeighting, texelColor.a);","} else if(material==3) {","gl_FragColor = vec4(vertexColor.rgb * lightWeighting, vertexColor.a);","} else if(material==2) {","gl_FragColor = vec4(vertexColor.rgb * lightWeighting, vertexColor.a);","} else if(material==1) {","gl_FragColor = vec4(uniformColor.rgb * lightWeighting, uniformColor.a);","} else {","gl_FragColor = vec4(uniformColor.rgb * lightWeighting, uniformColor.a);","}","}"].join("\n")));c.attachShader(d,b("vertex",["attribute vec3 position;","attribute vec3 normal;","attribute vec4 color;","attribute vec2 uv;","uniform bool enableLighting;","uniform vec3 ambientColor;","uniform vec3 directionalColor;","uniform vec3 lightingDirection;","uniform vec3 pointColor;","uniform vec3 pointPosition;","uniform mat4 viewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 objMatrix;","uniform mat3 normalMatrix;","varying vec4 vertexColor;","varying vec2 vertexUv;","varying vec3 lightWeighting;","varying vec3 vNormal;","void main(void) {","vec4 mvPosition = viewMatrix * vec4( position, 1.0 );","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize(normalMatrix * normal);","if(!enableLighting) {","lightWeighting = vec3(1.0, 1.0, 1.0);","} else {","vec3 pointLight = normalize(pointPosition.xyz - mPosition.xyz);","float directionalLightWeighting = max(dot(transformedNormal, normalize(lightingDirection)), 0.0);","float pointLightWeighting = max(dot(transformedNormal, pointLight), 0.0);","lightWeighting = ambientColor + directionalColor * directionalLightWeighting + pointColor * pointLightWeighting;","}","vNormal = transformedNormal;","vertexColor = color;","vertexUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"].join("\n")));c.linkProgram(d);if(!c.getProgramParameter(d,c.LINK_STATUS)){alert("Could not initialise shaders")}c.useProgram(d);d.viewMatrix=c.getUniformLocation(d,"viewMatrix");d.projectionMatrix=c.getUniformLocation(d,"projectionMatrix");d.normalMatrix=c.getUniformLocation(d,"normalMatrix");d.objMatrix=c.getUniformLocation(d,"objMatrix");d.enableLighting=c.getUniformLocation(d,"enableLighting");d.ambientColor=c.getUniformLocation(d,"ambientColor");d.directionalColor=c.getUniformLocation(d,"directionalColor");d.lightingDirection=c.getUniformLocation(d,"lightingDirection");d.pointColor=c.getUniformLocation(d,"pointColor");d.pointPosition=c.getUniformLocation(d,"pointPosition");d.material=c.getUniformLocation(d,"material");d.uniformColor=c.getUniformLocation(d,"uniformColor");d.color=c.getAttribLocation(d,"color");c.enableVertexAttribArray(d.color);d.position=c.getAttribLocation(d,"position");c.enableVertexAttribArray(d.position);d.normal=c.getAttribLocation(d,"normal");c.enableVertexAttribArray(d.normal);d.uv=c.getAttribLocation(d,"uv");c.enableVertexAttribArray(d.uv);d.diffuse=c.getUniformLocation(d,"diffuse");c.uniform1i(d.diffuse,0);d.viewMatrixArray=new Float32Array(16);d.projectionMatrixArray=new Float32Array(16)}function b(p,o){var q;if(p=="fragment"){q=c.createShader(c.FRAGMENT_SHADER)}else{if(p=="vertex"){q=c.createShader(c.VERTEX_SHADER)}}c.shaderSource(q,o);c.compileShader(q);if(!c.getShaderParameter(q,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(q));return null}return q}};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};