diff --git a/README.md b/README.md index 28b0519f8555dc5c88520a590379e03ad92afc6f..156af69d0b2652a9daefdfc937e7d1a631f542c3 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,6 @@ For creating a customised version of the library, including the source files in * Added `PointLight` * `CanvasRenderer` and `SVGRenderer` basic lighting support (ColorStroke/ColorFill only) * `Renderer` > `Projector`. `CanvasRenderer`, `SVGRenderer` and `DOMRenderer` do not extend anymore -* Interactivity base code (hdi folder). To be refactored... ([mindlapse](http://github.com/mindlapse)) * Added `computeCentroids` method to `Geometry` diff --git a/build/Three.js b/build/Three.js index 57dc03cbc8fecde865e6066e6dbfdc12bb166aa2..1f5659909986eac593cfb7d47c74e101fbea80b0 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,2 +1,2 @@ // Three.js r28 - 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)0)&&(H>0)&&(J+H<1)}}};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.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.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.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=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],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};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=k-a;b=f-g;l=(o+c)/n;j=(k+a)/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 instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={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 instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={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;c0){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]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsync:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadWorker:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},createModel:function(b,d,a){var c=function(f){var r=this;THREE.Geometry.call(this);s();m();o();i();this.computeCentroids();this.computeNormals();function m(){var u,t,v;for(u=0,t=b.vertices.length;u65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshPhongMaterial=function(d,a,e,c,b){this.ambient=new THREE.Color((b>=0?(b*255)<<24:4278190080)|d);this.diffuse=new THREE.Color((b>=0?(b*255)<<24:4278190080)|a);this.specular=new THREE.Color((b>=0?(b*255)<<24:4278190080)|e);this.shininess=c;this.opacity=b;this.toString=function(){return"THREE.MeshPhongMaterial (
ambient: "+this.ambient+",
diffuse: "+this.diffuse+",
specular: "+this.specular+",
shininess: "+this.shininess+",
opacity: "+this.opacity+")"}};THREE.MeshBitmapMaterial=function(a,b){this.bitmap=a;this.mode=b||THREE.MeshBitmapMaterialMode.UVMAPPING;this.id=THREE.MeshBitmapMaterialCounter.value++;this.toString=function(){return"THREE.MeshBitmapMaterial ( bitmap: "+this.bitmap+", mode: "+this.mode+", id: "+this.id+" )"}};THREE.MeshBitmapMaterialCounter={value:0};THREE.MeshBitmapMaterialMode={UVMAPPING:0};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.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};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;c0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&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};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};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;q0;if(l){B(ac,f)}for(ab=0,K=A.length;ab0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}else{if(H instanceof THREE.PointLight){h.sub(H.position,L.centroidWorld);h.normalize();K=L.normalWorld.dot(h)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}}}}function m(J,I,M,P,O){var H,U,S,R,N,L,Q,T,K;if(P instanceof THREE.ParticleCircleMaterial){if(l){x.copyRGB(f);u(O,M,x);o.copyRGBA(P.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=P.color}H=M.scale.x*k;U=M.scale.y*p;z.set(J-H,I-U,J+H,I+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(H,U);t.beginPath();t.arc(0,0,1,0,y,true);t.closePath();t.fillStyle=o.__styleString;t.fill();t.restore()}else{if(P instanceof THREE.ParticleBitmapMaterial){Q=P.bitmap;T=Q.width/2;K=Q.height/2;S=M.scale.x*k;R=M.scale.y*p;H=S*T;U=R*K;N=P.offset.x*S;L=P.offset.y*R;z.set(J+N-H,I+L-U,J+N+H,I+L+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(S,-R);t.translate(-T+P.offset.x,-K-P.offset.y);t.drawImage(Q,0,0);t.restore()}}}function e(H,N,J,I,K,L,M){if(L instanceof THREE.LineColorMaterial){if(l){x.copyRGB(f);u(M,K,x);o.copyRGBA(L.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=L.color}t.lineWidth=L.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}}function i(J,I,H,S,P,O,L,N,M){var Q,R,K;if(N instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(N instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.lineWidth=N.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(N instanceof THREE.MeshBitmapMaterial){Q=N.bitmap;R=Q.width-1;K=Q.height-1;G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);G.u*=R;G.v*=K;F.u*=R;F.v*=K;E.u*=R;E.v*=K;w(Q,J,I,H,S,P,O,G.u,G.v,F.u,F.v,E.u,E.v)}}}}function g(N,M,V,T,I,H,P,O,W,U,K,J,L,R,X){var Y,Q,S;if(R instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(R instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.lineWidth=R.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(R instanceof THREE.MeshBitmapMaterial){Y=R.bitmap;Q=Y.width-1;S=Y.height-1;G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);C.copy(L.uvs[3]);G.u*=Q;G.v*=S;F.u*=Q;F.v*=S;E.u*=Q;E.v*=S;C.u*=Q;C.v*=S;w(Y,N,M,V,T,P,O,G.u,G.v,F.u,F.v,C.u,C.v);w(Y,W,U,I,H,K,J,F.u,F.v,E.u,E.v,C.u,C.v)}}}}function w(aa,P,O,V,U,J,H,T,S,X,W,L,K){var I,Z,Y,N,M,R,Q;t.beginPath();t.moveTo(P,O);t.lineTo(V,U);t.lineTo(J,H);t.lineTo(P,O);t.closePath();t.save();t.clip();I=T*(K-W)-X*K+L*W+(X-L)*S;Z=-(S*(J-V)-W*J+K*V+(W-K)*P)/I;Y=(W*H+S*(U-H)-K*U+(K-W)*O)/I;N=(T*(J-V)-X*J+L*V+(X-L)*P)/I;M=-(X*H+T*(U-H)-L*U+(L-X)*O)/I;R=(T*(K*V-W*J)+S*(X*J-L*V)+(L*W-X*K)*P)/I;Q=(T*(K*U-W*H)+S*(X*H-L*U)+(L*W-X*K)*O)/I;t.transform(Z,Y,N,M,R,Q);t.drawImage(aa,0,0);t.restore()}function c(I,H){j.sub(H,I);j.unit();j.multiplyScalar(0.75);H.addSelf(j);I.subSelf(j)}};THREE.SVGRenderer=function(){var x=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,z=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),g=new THREE.Vector3(),d=[],l=[],B,n,f,A=1;this.domElement=t;this.autoClear=true;this.setQuality=function(C){switch(C){case"high":A=1;break;case"low":A=0;break}};this.setSize=function(D,C){b=D;o=C;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);z.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(T,Q){var S,E,N,R,J,G,F,M,K,H,P,O,D,C,L,I;if(this.autoClear){this.clear()}x=r.projectScene(T,Q);n=0;f=0;i=T.lights.length>0;if(i){y(T,c)}for(S=0,E=x.length;S0){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 j(C,G,D,E,F){B=u(f++);B.setAttribute("cx",C);B.setAttribute("cy",G);B.setAttribute("r",D.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(F,D,v);k.copyRGBA(E.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=E.color}B.setAttribute("style","fill: "+k.__styleString)}t.appendChild(B)}function h(E,D,C,K,J,I,F,H,G){B=m(n++);B.setAttribute("d","M "+E+" "+D+" L "+C+" "+K+" L "+J+","+I+"z");if(H instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(H instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+H.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function e(G,E,C,M,L,K,F,D,H,J,I){B=m(n++);B.setAttribute("d","M "+G+" "+E+" L "+C+" "+M+" L "+L+","+K+" L "+F+","+D+"z");if(J instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(J instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+J.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function m(C){if(d[C]==null){d[C]=document.createElementNS("http://www.w3.org/2000/svg","path");if(A==0){d[C].setAttribute("shape-rendering","crispEdges")}return d[C]}return d[C]}function u(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A==0){l[C].setAttribute("shape-rendering","crispEdges")}return l[C]}return l[C]}};THREE.WebGLRenderer=function(q){var h=document.createElement("canvas"),f,n,k=new THREE.Matrix4(),d,g=0,c=1,s=2,o=3,l=b(q,5);this.domElement=h;this.autoClear=true;a();i(l.directional,l.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return v.join("\n")}function j(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function i(t,u){n=f.createProgram();f.attachShader(n,r("fragment",p(t,u)));f.attachShader(n,r("vertex",j(t,u)));f.linkProgram(n);if(!f.getProgramParameter(n,f.LINK_STATUS)){alert("Could not initialise shaders")}f.useProgram(n);n.viewMatrix=f.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=f.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=f.getUniformLocation(n,"projectionMatrix");n.normalMatrix=f.getUniformLocation(n,"normalMatrix");n.objMatrix=f.getUniformLocation(n,"objMatrix");n.cameraPosition=f.getUniformLocation(n,"cameraPosition");n.enableLighting=f.getUniformLocation(n,"enableLighting");n.ambientLightColor=f.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=f.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=f.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=f.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=f.getUniformLocation(n,"pointLightNumber");n.pointLightColor=f.getUniformLocation(n,"pointLightColor");n.pointLightPosition=f.getUniformLocation(n,"pointLightPosition")}n.material=f.getUniformLocation(n,"material");n.mColor=f.getUniformLocation(n,"mColor");n.mAmbient=f.getUniformLocation(n,"mAmbient");n.mDiffuse=f.getUniformLocation(n,"mDiffuse");n.mSpecular=f.getUniformLocation(n,"mSpecular");n.mShininess=f.getUniformLocation(n,"mShininess");n.tDiffuse=f.getUniformLocation(n,"tDiffuse");f.uniform1i(n.tDiffuse,0);n.position=f.getAttribLocation(n,"position");f.enableVertexAttribArray(n.position);n.normal=f.getAttribLocation(n,"normal");f.enableVertexAttribArray(n.normal);n.uv=f.getAttribLocation(n,"uv");f.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=f.createShader(f.FRAGMENT_SHADER)}else{if(u=="vertex"){v=f.createShader(f.VERTEX_SHADER)}}f.shaderSource(v,t);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function e(){var t={MAX_VARYING_VECTORS:f.getParameter(f.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:f.getParameter(f.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:f.getParameter(f.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:f.getParameter(f.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=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.centroidScreen=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}; \ No newline at end of file +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)0)&&(I>0)&&(K+I<1)}}};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.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.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.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=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],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};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=k-a;b=f-g;l=(o+c)/n;j=(k+a)/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 instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={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 instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={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;c0){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]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsync:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadWorker:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},createModel:function(b,d,a){var c=function(f){var r=this;THREE.Geometry.call(this);s();m();o();i();this.computeCentroids();this.computeNormals();function m(){var u,t,v;for(u=0,t=b.vertices.length;u65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshPhongMaterial=function(d,a,e,c,b){this.ambient=new THREE.Color((b>=0?(b*255)<<24:4278190080)|d);this.diffuse=new THREE.Color((b>=0?(b*255)<<24:4278190080)|a);this.specular=new THREE.Color((b>=0?(b*255)<<24:4278190080)|e);this.shininess=c;this.opacity=b;this.toString=function(){return"THREE.MeshPhongMaterial (
ambient: "+this.ambient+",
diffuse: "+this.diffuse+",
specular: "+this.specular+",
shininess: "+this.shininess+",
opacity: "+this.opacity+")"}};THREE.MeshBitmapMaterial=function(a,b){this.bitmap=a;this.mode=b||THREE.MeshBitmapMaterialMode.UVMAPPING;this.id=THREE.MeshBitmapMaterialCounter.value++;this.toString=function(){return"THREE.MeshBitmapMaterial ( bitmap: "+this.bitmap+", mode: "+this.mode+", id: "+this.id+" )"}};THREE.MeshBitmapMaterialCounter={value:0};THREE.MeshBitmapMaterialMode={UVMAPPING:0};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.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};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;c0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&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};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};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;q0;if(l){B(ac,f)}for(ab=0,K=A.length;ab0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}else{if(H instanceof THREE.PointLight){h.sub(H.position,L.centroidWorld);h.normalize();K=L.normalWorld.dot(h)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}}}}function m(J,I,M,P,O){var H,U,S,R,N,L,Q,T,K;if(P instanceof THREE.ParticleCircleMaterial){if(l){x.copyRGB(f);u(O,M,x);o.copyRGBA(P.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=P.color}H=M.scale.x*k;U=M.scale.y*p;z.set(J-H,I-U,J+H,I+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(H,U);t.beginPath();t.arc(0,0,1,0,y,true);t.closePath();t.fillStyle=o.__styleString;t.fill();t.restore()}else{if(P instanceof THREE.ParticleBitmapMaterial){Q=P.bitmap;T=Q.width/2;K=Q.height/2;S=M.scale.x*k;R=M.scale.y*p;H=S*T;U=R*K;N=P.offset.x*S;L=P.offset.y*R;z.set(J+N-H,I+L-U,J+N+H,I+L+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(S,-R);t.translate(-T+P.offset.x,-K-P.offset.y);t.drawImage(Q,0,0);t.restore()}}}function e(H,N,J,I,K,L,M){if(L instanceof THREE.LineColorMaterial){if(l){x.copyRGB(f);u(M,K,x);o.copyRGBA(L.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=L.color}t.lineWidth=L.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}}function i(J,I,H,S,P,O,L,N,M){var Q,R,K;if(N instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(N instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.lineWidth=N.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(N instanceof THREE.MeshBitmapMaterial){Q=N.bitmap;R=Q.width-1;K=Q.height-1;G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);G.u*=R;G.v*=K;F.u*=R;F.v*=K;E.u*=R;E.v*=K;w(Q,J,I,H,S,P,O,G.u,G.v,F.u,F.v,E.u,E.v)}}}}function g(N,M,V,T,I,H,P,O,W,U,K,J,L,R,X){var Y,Q,S;if(R instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(R instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.lineWidth=R.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(R instanceof THREE.MeshBitmapMaterial){Y=R.bitmap;Q=Y.width-1;S=Y.height-1;G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);C.copy(L.uvs[3]);G.u*=Q;G.v*=S;F.u*=Q;F.v*=S;E.u*=Q;E.v*=S;C.u*=Q;C.v*=S;w(Y,N,M,V,T,P,O,G.u,G.v,F.u,F.v,C.u,C.v);w(Y,W,U,I,H,K,J,F.u,F.v,E.u,E.v,C.u,C.v)}}}}function w(aa,P,O,V,U,J,H,T,S,X,W,L,K){var I,Z,Y,N,M,R,Q;t.beginPath();t.moveTo(P,O);t.lineTo(V,U);t.lineTo(J,H);t.lineTo(P,O);t.closePath();t.save();t.clip();I=T*(K-W)-X*K+L*W+(X-L)*S;Z=-(S*(J-V)-W*J+K*V+(W-K)*P)/I;Y=(W*H+S*(U-H)-K*U+(K-W)*O)/I;N=(T*(J-V)-X*J+L*V+(X-L)*P)/I;M=-(X*H+T*(U-H)-L*U+(L-X)*O)/I;R=(T*(K*V-W*J)+S*(X*J-L*V)+(L*W-X*K)*P)/I;Q=(T*(K*U-W*H)+S*(X*H-L*U)+(L*W-X*K)*O)/I;t.transform(Z,Y,N,M,R,Q);t.drawImage(aa,0,0);t.restore()}function c(I,H){j.sub(H,I);j.unit();j.multiplyScalar(0.75);H.addSelf(j);I.subSelf(j)}};THREE.SVGRenderer=function(){var x=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,z=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),g=new THREE.Vector3(),d=[],l=[],B,n,f,A=1;this.domElement=t;this.autoClear=true;this.setQuality=function(C){switch(C){case"high":A=1;break;case"low":A=0;break}};this.setSize=function(D,C){b=D;o=C;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);z.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(T,Q){var S,E,N,R,J,G,F,M,K,H,P,O,D,C,L,I;if(this.autoClear){this.clear()}x=r.projectScene(T,Q);n=0;f=0;i=T.lights.length>0;if(i){y(T,c)}for(S=0,E=x.length;S0){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 j(C,G,D,E,F){B=u(f++);B.setAttribute("cx",C);B.setAttribute("cy",G);B.setAttribute("r",D.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(F,D,v);k.copyRGBA(E.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=E.color}B.setAttribute("style","fill: "+k.__styleString)}t.appendChild(B)}function h(E,D,C,K,J,I,F,H,G){B=m(n++);B.setAttribute("d","M "+E+" "+D+" L "+C+" "+K+" L "+J+","+I+"z");if(H instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(H instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+H.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function e(G,E,C,M,L,K,F,D,H,J,I){B=m(n++);B.setAttribute("d","M "+G+" "+E+" L "+C+" "+M+" L "+L+","+K+" L "+F+","+D+"z");if(J instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(J instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+J.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function m(C){if(d[C]==null){d[C]=document.createElementNS("http://www.w3.org/2000/svg","path");if(A==0){d[C].setAttribute("shape-rendering","crispEdges")}return d[C]}return d[C]}function u(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A==0){l[C].setAttribute("shape-rendering","crispEdges")}return l[C]}return l[C]}};THREE.WebGLRenderer=function(q){var h=document.createElement("canvas"),f,n,k=new THREE.Matrix4(),d,g=0,c=1,s=2,o=3,l=b(q,5);this.domElement=h;this.autoClear=true;a();i(l.directional,l.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return v.join("\n")}function j(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function i(t,u){n=f.createProgram();f.attachShader(n,r("fragment",p(t,u)));f.attachShader(n,r("vertex",j(t,u)));f.linkProgram(n);if(!f.getProgramParameter(n,f.LINK_STATUS)){alert("Could not initialise shaders")}f.useProgram(n);n.viewMatrix=f.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=f.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=f.getUniformLocation(n,"projectionMatrix");n.normalMatrix=f.getUniformLocation(n,"normalMatrix");n.objMatrix=f.getUniformLocation(n,"objMatrix");n.cameraPosition=f.getUniformLocation(n,"cameraPosition");n.enableLighting=f.getUniformLocation(n,"enableLighting");n.ambientLightColor=f.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=f.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=f.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=f.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=f.getUniformLocation(n,"pointLightNumber");n.pointLightColor=f.getUniformLocation(n,"pointLightColor");n.pointLightPosition=f.getUniformLocation(n,"pointLightPosition")}n.material=f.getUniformLocation(n,"material");n.mColor=f.getUniformLocation(n,"mColor");n.mAmbient=f.getUniformLocation(n,"mAmbient");n.mDiffuse=f.getUniformLocation(n,"mDiffuse");n.mSpecular=f.getUniformLocation(n,"mSpecular");n.mShininess=f.getUniformLocation(n,"mShininess");n.tDiffuse=f.getUniformLocation(n,"tDiffuse");f.uniform1i(n.tDiffuse,0);n.position=f.getAttribLocation(n,"position");f.enableVertexAttribArray(n.position);n.normal=f.getAttribLocation(n,"normal");f.enableVertexAttribArray(n.normal);n.uv=f.getAttribLocation(n,"uv");f.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=f.createShader(f.FRAGMENT_SHADER)}else{if(u=="vertex"){v=f.createShader(f.VERTEX_SHADER)}}f.shaderSource(v,t);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function e(){var t={MAX_VARYING_VECTORS:f.getParameter(f.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:f.getParameter(f.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:f.getParameter(f.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:f.getParameter(f.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=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.centroidScreen=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}; \ No newline at end of file diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index 1c60e5994cfb64dac4b130491d979579b4b7c167..c8bac8a22f75fa3b1e4bc6456c31348a953880be 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,2 +1,2 @@ // ThreeDebug.js r28 - 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)0)&&(H>0)&&(J+H<1)}}};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.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.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.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=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],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};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=k-a;b=f-g;l=(o+c)/n;j=(k+a)/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 instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={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 instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={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;c0){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]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsync:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadWorker:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},createModel:function(b,d,a){var c=function(f){var r=this;THREE.Geometry.call(this);s();m();o();i();this.computeCentroids();this.computeNormals();function m(){var u,t,v;for(u=0,t=b.vertices.length;u65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshPhongMaterial=function(d,a,e,c,b){this.ambient=new THREE.Color((b>=0?(b*255)<<24:4278190080)|d);this.diffuse=new THREE.Color((b>=0?(b*255)<<24:4278190080)|a);this.specular=new THREE.Color((b>=0?(b*255)<<24:4278190080)|e);this.shininess=c;this.opacity=b;this.toString=function(){return"THREE.MeshPhongMaterial (
ambient: "+this.ambient+",
diffuse: "+this.diffuse+",
specular: "+this.specular+",
shininess: "+this.shininess+",
opacity: "+this.opacity+")"}};THREE.MeshBitmapMaterial=function(a,b){this.bitmap=a;this.mode=b||THREE.MeshBitmapMaterialMode.UVMAPPING;this.id=THREE.MeshBitmapMaterialCounter.value++;this.toString=function(){return"THREE.MeshBitmapMaterial ( bitmap: "+this.bitmap+", mode: "+this.mode+", id: "+this.id+" )"}};THREE.MeshBitmapMaterialCounter={value:0};THREE.MeshBitmapMaterialMode={UVMAPPING:0};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.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};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;c0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&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};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};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;q0;if(l){B(ac,f)}for(ab=0,K=A.length;ab0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}else{if(H instanceof THREE.PointLight){h.sub(H.position,L.centroidWorld);h.normalize();K=L.normalWorld.dot(h)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}}}}function m(J,I,M,P,O){var H,U,S,R,N,L,Q,T,K;if(P instanceof THREE.ParticleCircleMaterial){if(l){x.copyRGB(f);u(O,M,x);o.copyRGBA(P.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=P.color}H=M.scale.x*k;U=M.scale.y*p;z.set(J-H,I-U,J+H,I+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(H,U);t.beginPath();t.arc(0,0,1,0,y,true);t.closePath();t.fillStyle=o.__styleString;t.fill();t.restore()}else{if(P instanceof THREE.ParticleBitmapMaterial){Q=P.bitmap;T=Q.width/2;K=Q.height/2;S=M.scale.x*k;R=M.scale.y*p;H=S*T;U=R*K;N=P.offset.x*S;L=P.offset.y*R;z.set(J+N-H,I+L-U,J+N+H,I+L+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(S,-R);t.translate(-T+P.offset.x,-K-P.offset.y);t.drawImage(Q,0,0);t.restore();t.beginPath();t.moveTo(J-10,I);t.lineTo(J+10,I);t.moveTo(J,I-10);t.lineTo(J,I+10);t.closePath();t.strokeStyle="rgb(255,255,0)";t.stroke()}}}function e(H,N,J,I,K,L,M){if(L instanceof THREE.LineColorMaterial){if(l){x.copyRGB(f);u(M,K,x);o.copyRGBA(L.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=L.color}t.lineWidth=L.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}}function i(J,I,H,S,P,O,L,N,M){var Q,R,K;if(N instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(N instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.lineWidth=N.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(N instanceof THREE.MeshBitmapMaterial){Q=N.bitmap;R=Q.width-1;K=Q.height-1;if(!L.uvs[0]||!L.uvs[1]||!L.uvs[2]){t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.fillStyle="rgb(0, 255, 0)";t.fill();return}G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);G.u*=R;G.v*=K;F.u*=R;F.v*=K;E.u*=R;E.v*=K;w(Q,J,I,H,S,P,O,G.u,G.v,F.u,F.v,E.u,E.v)}}}}function g(N,M,V,T,I,H,P,O,W,U,K,J,L,R,X){var Y,Q,S;if(R instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(R instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.lineWidth=R.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(R instanceof THREE.MeshBitmapMaterial){Y=R.bitmap;Q=Y.width-1;S=Y.height-1;if(!L.uvs[0]||!L.uvs[1]||!L.uvs[2]||!L.uvs[3]||!L.uvs[4]){t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.fillStyle="rgb(255, 0, 255)";t.fill();return}G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);C.copy(L.uvs[3]);G.u*=Q;G.v*=S;F.u*=Q;F.v*=S;E.u*=Q;E.v*=S;C.u*=Q;C.v*=S;w(Y,N,M,V,T,P,O,G.u,G.v,F.u,F.v,C.u,C.v);w(Y,W,U,I,H,K,J,F.u,F.v,E.u,E.v,C.u,C.v)}}}}function w(aa,P,O,V,U,J,H,T,S,X,W,L,K){var I,Z,Y,N,M,R,Q;t.beginPath();t.moveTo(P,O);t.lineTo(V,U);t.lineTo(J,H);t.lineTo(P,O);t.closePath();t.save();t.clip();I=T*(K-W)-X*K+L*W+(X-L)*S;Z=-(S*(J-V)-W*J+K*V+(W-K)*P)/I;Y=(W*H+S*(U-H)-K*U+(K-W)*O)/I;N=(T*(J-V)-X*J+L*V+(X-L)*P)/I;M=-(X*H+T*(U-H)-L*U+(L-X)*O)/I;R=(T*(K*V-W*J)+S*(X*J-L*V)+(L*W-X*K)*P)/I;Q=(T*(K*U-W*H)+S*(X*H-L*U)+(L*W-X*K)*O)/I;t.transform(Z,Y,N,M,R,Q);t.drawImage(aa,0,0);t.restore()}function c(I,H){j.sub(H,I);j.unit();j.multiplyScalar(0.75);H.addSelf(j);I.subSelf(j)}};THREE.SVGRenderer=function(){var x=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,z=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),g=new THREE.Vector3(),d=[],l=[],B,n,f,A=1;this.domElement=t;this.autoClear=true;this.setQuality=function(C){switch(C){case"high":A=1;break;case"low":A=0;break}};this.setSize=function(D,C){b=D;o=C;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);z.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(T,Q){var S,E,N,R,J,G,F,M,K,H,P,O,D,C,L,I;if(this.autoClear){this.clear()}x=r.projectScene(T,Q);n=0;f=0;i=T.lights.length>0;if(i){y(T,c)}for(S=0,E=x.length;S0){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 j(C,G,D,E,F){B=u(f++);B.setAttribute("cx",C);B.setAttribute("cy",G);B.setAttribute("r",D.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(F,D,v);k.copyRGBA(E.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=E.color}B.setAttribute("style","fill: "+k.__styleString)}t.appendChild(B)}function h(E,D,C,K,J,I,F,H,G){B=m(n++);B.setAttribute("d","M "+E+" "+D+" L "+C+" "+K+" L "+J+","+I+"z");if(H instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(H instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+H.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function e(G,E,C,M,L,K,F,D,H,J,I){B=m(n++);B.setAttribute("d","M "+G+" "+E+" L "+C+" "+M+" L "+L+","+K+" L "+F+","+D+"z");if(J instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(J instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+J.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function m(C){if(d[C]==null){d[C]=document.createElementNS("http://www.w3.org/2000/svg","path");if(A==0){d[C].setAttribute("shape-rendering","crispEdges")}return d[C]}return d[C]}function u(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A==0){l[C].setAttribute("shape-rendering","crispEdges")}return l[C]}return l[C]}};THREE.WebGLRenderer=function(q){var h=document.createElement("canvas"),f,n,k=new THREE.Matrix4(),d,g=0,c=1,s=2,o=3,l=b(q,5);this.domElement=h;this.autoClear=true;a();i(l.directional,l.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return v.join("\n")}function j(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function i(t,u){n=f.createProgram();f.attachShader(n,r("fragment",p(t,u)));f.attachShader(n,r("vertex",j(t,u)));f.linkProgram(n);if(!f.getProgramParameter(n,f.LINK_STATUS)){alert("Could not initialise shaders")}f.useProgram(n);n.viewMatrix=f.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=f.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=f.getUniformLocation(n,"projectionMatrix");n.normalMatrix=f.getUniformLocation(n,"normalMatrix");n.objMatrix=f.getUniformLocation(n,"objMatrix");n.cameraPosition=f.getUniformLocation(n,"cameraPosition");n.enableLighting=f.getUniformLocation(n,"enableLighting");n.ambientLightColor=f.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=f.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=f.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=f.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=f.getUniformLocation(n,"pointLightNumber");n.pointLightColor=f.getUniformLocation(n,"pointLightColor");n.pointLightPosition=f.getUniformLocation(n,"pointLightPosition")}n.material=f.getUniformLocation(n,"material");n.mColor=f.getUniformLocation(n,"mColor");n.mAmbient=f.getUniformLocation(n,"mAmbient");n.mDiffuse=f.getUniformLocation(n,"mDiffuse");n.mSpecular=f.getUniformLocation(n,"mSpecular");n.mShininess=f.getUniformLocation(n,"mShininess");n.tDiffuse=f.getUniformLocation(n,"tDiffuse");f.uniform1i(n.tDiffuse,0);n.position=f.getAttribLocation(n,"position");f.enableVertexAttribArray(n.position);n.normal=f.getAttribLocation(n,"normal");f.enableVertexAttribArray(n.normal);n.uv=f.getAttribLocation(n,"uv");f.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=f.createShader(f.FRAGMENT_SHADER)}else{if(u=="vertex"){v=f.createShader(f.VERTEX_SHADER)}}f.shaderSource(v,t);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function e(){var t={MAX_VARYING_VECTORS:f.getParameter(f.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:f.getParameter(f.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:f.getParameter(f.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:f.getParameter(f.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=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.centroidScreen=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}; \ No newline at end of file +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)0)&&(I>0)&&(K+I<1)}}};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.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.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.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=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],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};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=k-a;b=f-g;l=(o+c)/n;j=(k+a)/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 instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={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 instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={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;c0){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]};for(var a=1,b=this.vertices.length;athis.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.ythis.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.zthis.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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);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.Loader=function(){};THREE.Loader.prototype={loadAsync:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadWorker:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},createModel:function(b,d,a){var c=function(f){var r=this;THREE.Geometry.call(this);s();m();o();i();this.computeCentroids();this.computeNormals();function m(){var u,t,v;for(u=0,t=b.vertices.length;u65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshPhongMaterial=function(d,a,e,c,b){this.ambient=new THREE.Color((b>=0?(b*255)<<24:4278190080)|d);this.diffuse=new THREE.Color((b>=0?(b*255)<<24:4278190080)|a);this.specular=new THREE.Color((b>=0?(b*255)<<24:4278190080)|e);this.shininess=c;this.opacity=b;this.toString=function(){return"THREE.MeshPhongMaterial (
ambient: "+this.ambient+",
diffuse: "+this.diffuse+",
specular: "+this.specular+",
shininess: "+this.shininess+",
opacity: "+this.opacity+")"}};THREE.MeshBitmapMaterial=function(a,b){this.bitmap=a;this.mode=b||THREE.MeshBitmapMaterialMode.UVMAPPING;this.id=THREE.MeshBitmapMaterialCounter.value++;this.toString=function(){return"THREE.MeshBitmapMaterial ( bitmap: "+this.bitmap+", mode: "+this.mode+", id: "+this.id+" )"}};THREE.MeshBitmapMaterialCounter={value:0};THREE.MeshBitmapMaterialMode={UVMAPPING:0};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.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};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;c0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I0&&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};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};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;q0;if(l){B(ac,f)}for(ab=0,K=A.length;ab0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}else{if(H instanceof THREE.PointLight){h.sub(H.position,L.centroidWorld);h.normalize();K=L.normalWorld.dot(h)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}}}}function m(J,I,M,P,O){var H,U,S,R,N,L,Q,T,K;if(P instanceof THREE.ParticleCircleMaterial){if(l){x.copyRGB(f);u(O,M,x);o.copyRGBA(P.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=P.color}H=M.scale.x*k;U=M.scale.y*p;z.set(J-H,I-U,J+H,I+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(H,U);t.beginPath();t.arc(0,0,1,0,y,true);t.closePath();t.fillStyle=o.__styleString;t.fill();t.restore()}else{if(P instanceof THREE.ParticleBitmapMaterial){Q=P.bitmap;T=Q.width/2;K=Q.height/2;S=M.scale.x*k;R=M.scale.y*p;H=S*T;U=R*K;N=P.offset.x*S;L=P.offset.y*R;z.set(J+N-H,I+L-U,J+N+H,I+L+U);if(!D.instersects(z)){return}t.save();t.translate(J,I);t.rotate(-M.rotation);t.scale(S,-R);t.translate(-T+P.offset.x,-K-P.offset.y);t.drawImage(Q,0,0);t.restore();t.beginPath();t.moveTo(J-10,I);t.lineTo(J+10,I);t.moveTo(J,I-10);t.lineTo(J,I+10);t.closePath();t.strokeStyle="rgb(255,255,0)";t.stroke()}}}function e(H,N,J,I,K,L,M){if(L instanceof THREE.LineColorMaterial){if(l){x.copyRGB(f);u(M,K,x);o.copyRGBA(L.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=L.color}t.lineWidth=L.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}}function i(J,I,H,S,P,O,L,N,M){var Q,R,K;if(N instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(N instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(M,L,x);o.copyRGBA(N.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=N.color}t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.lineWidth=N.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(N instanceof THREE.MeshBitmapMaterial){Q=N.bitmap;R=Q.width-1;K=Q.height-1;if(!L.uvs[0]||!L.uvs[1]||!L.uvs[2]){t.beginPath();t.moveTo(J,I);t.lineTo(H,S);t.lineTo(P,O);t.lineTo(J,I);t.closePath();t.fillStyle="rgb(0, 255, 0)";t.fill();return}G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);G.u*=R;G.v*=K;F.u*=R;F.v*=K;E.u*=R;E.v*=K;w(Q,J,I,H,S,P,O,G.u,G.v,F.u,F.v,E.u,E.v)}}}}function g(N,M,V,T,I,H,P,O,W,U,K,J,L,R,X){var Y,Q,S;if(R instanceof THREE.MeshColorFillMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.fillStyle=o.__styleString;t.fill()}else{if(R instanceof THREE.MeshColorStrokeMaterial){if(l){x.copyRGB(f);a(X,L,x);o.copyRGBA(R.color);o.multiplySelfRGB(x);o.updateStyleString()}else{o=R.color}t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.lineWidth=R.lineWidth;t.lineJoin="round";t.lineCap="round";t.strokeStyle=o.__styleString;t.stroke();z.inflate(t.lineWidth)}else{if(R instanceof THREE.MeshBitmapMaterial){Y=R.bitmap;Q=Y.width-1;S=Y.height-1;if(!L.uvs[0]||!L.uvs[1]||!L.uvs[2]||!L.uvs[3]||!L.uvs[4]){t.beginPath();t.moveTo(N,M);t.lineTo(V,T);t.lineTo(I,H);t.lineTo(P,O);t.lineTo(N,M);t.closePath();t.fillStyle="rgb(255, 0, 255)";t.fill();return}G.copy(L.uvs[0]);F.copy(L.uvs[1]);E.copy(L.uvs[2]);C.copy(L.uvs[3]);G.u*=Q;G.v*=S;F.u*=Q;F.v*=S;E.u*=Q;E.v*=S;C.u*=Q;C.v*=S;w(Y,N,M,V,T,P,O,G.u,G.v,F.u,F.v,C.u,C.v);w(Y,W,U,I,H,K,J,F.u,F.v,E.u,E.v,C.u,C.v)}}}}function w(aa,P,O,V,U,J,H,T,S,X,W,L,K){var I,Z,Y,N,M,R,Q;t.beginPath();t.moveTo(P,O);t.lineTo(V,U);t.lineTo(J,H);t.lineTo(P,O);t.closePath();t.save();t.clip();I=T*(K-W)-X*K+L*W+(X-L)*S;Z=-(S*(J-V)-W*J+K*V+(W-K)*P)/I;Y=(W*H+S*(U-H)-K*U+(K-W)*O)/I;N=(T*(J-V)-X*J+L*V+(X-L)*P)/I;M=-(X*H+T*(U-H)-L*U+(L-X)*O)/I;R=(T*(K*V-W*J)+S*(X*J-L*V)+(L*W-X*K)*P)/I;Q=(T*(K*U-W*H)+S*(X*H-L*U)+(L*W-X*K)*O)/I;t.transform(Z,Y,N,M,R,Q);t.drawImage(aa,0,0);t.restore()}function c(I,H){j.sub(H,I);j.unit();j.multiplyScalar(0.75);H.addSelf(j);I.subSelf(j)}};THREE.SVGRenderer=function(){var x=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,z=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),g=new THREE.Vector3(),d=[],l=[],B,n,f,A=1;this.domElement=t;this.autoClear=true;this.setQuality=function(C){switch(C){case"high":A=1;break;case"low":A=0;break}};this.setSize=function(D,C){b=D;o=C;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);z.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(T,Q){var S,E,N,R,J,G,F,M,K,H,P,O,D,C,L,I;if(this.autoClear){this.clear()}x=r.projectScene(T,Q);n=0;f=0;i=T.lights.length>0;if(i){y(T,c)}for(S=0,E=x.length;S0){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 j(C,G,D,E,F){B=u(f++);B.setAttribute("cx",C);B.setAttribute("cy",G);B.setAttribute("r",D.scale.x*p);if(E instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(F,D,v);k.copyRGBA(E.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=E.color}B.setAttribute("style","fill: "+k.__styleString)}t.appendChild(B)}function h(E,D,C,K,J,I,F,H,G){B=m(n++);B.setAttribute("d","M "+E+" "+D+" L "+C+" "+K+" L "+J+","+I+"z");if(H instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(H instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(G,F,v);k.copyRGBA(H.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=H.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+H.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function e(G,E,C,M,L,K,F,D,H,J,I){B=m(n++);B.setAttribute("d","M "+G+" "+E+" L "+C+" "+M+" L "+L+","+K+" L "+F+","+D+"z");if(J instanceof THREE.MeshColorFillMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: "+k.__styleString)}else{if(J instanceof THREE.MeshColorStrokeMaterial){if(i){v.copyRGB(c);a(I,H,v);k.copyRGBA(J.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=J.color}B.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+J.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}t.appendChild(B)}function m(C){if(d[C]==null){d[C]=document.createElementNS("http://www.w3.org/2000/svg","path");if(A==0){d[C].setAttribute("shape-rendering","crispEdges")}return d[C]}return d[C]}function u(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A==0){l[C].setAttribute("shape-rendering","crispEdges")}return l[C]}return l[C]}};THREE.WebGLRenderer=function(q){var h=document.createElement("canvas"),f,n,k=new THREE.Matrix4(),d,g=0,c=1,s=2,o=3,l=b(q,5);this.domElement=h;this.autoClear=true;a();i(l.directional,l.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mDiffuse * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mDiffuse * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( totalLight.xyz * vLightWeighting, 1.0 );","} else if ( material == 2 ) {","vec4 texelColor = texture2D( tDiffuse, vUv );","gl_FragColor = vec4( texelColor.rgb * vLightWeighting, texelColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","} else {","gl_FragColor = vec4( mColor.rgb * vLightWeighting, mColor.a );","}","}"];return v.join("\n")}function j(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function i(t,u){n=f.createProgram();f.attachShader(n,r("fragment",p(t,u)));f.attachShader(n,r("vertex",j(t,u)));f.linkProgram(n);if(!f.getProgramParameter(n,f.LINK_STATUS)){alert("Could not initialise shaders")}f.useProgram(n);n.viewMatrix=f.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=f.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=f.getUniformLocation(n,"projectionMatrix");n.normalMatrix=f.getUniformLocation(n,"normalMatrix");n.objMatrix=f.getUniformLocation(n,"objMatrix");n.cameraPosition=f.getUniformLocation(n,"cameraPosition");n.enableLighting=f.getUniformLocation(n,"enableLighting");n.ambientLightColor=f.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=f.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=f.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=f.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=f.getUniformLocation(n,"pointLightNumber");n.pointLightColor=f.getUniformLocation(n,"pointLightColor");n.pointLightPosition=f.getUniformLocation(n,"pointLightPosition")}n.material=f.getUniformLocation(n,"material");n.mColor=f.getUniformLocation(n,"mColor");n.mAmbient=f.getUniformLocation(n,"mAmbient");n.mDiffuse=f.getUniformLocation(n,"mDiffuse");n.mSpecular=f.getUniformLocation(n,"mSpecular");n.mShininess=f.getUniformLocation(n,"mShininess");n.tDiffuse=f.getUniformLocation(n,"tDiffuse");f.uniform1i(n.tDiffuse,0);n.position=f.getAttribLocation(n,"position");f.enableVertexAttribArray(n.position);n.normal=f.getAttribLocation(n,"normal");f.enableVertexAttribArray(n.normal);n.uv=f.getAttribLocation(n,"uv");f.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=f.createShader(f.FRAGMENT_SHADER)}else{if(u=="vertex"){v=f.createShader(f.VERTEX_SHADER)}}f.shaderSource(v,t);f.compileShader(v);if(!f.getShaderParameter(v,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(v));return null}return v}function e(){var t={MAX_VARYING_VECTORS:f.getParameter(f.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:f.getParameter(f.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:f.getParameter(f.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:f.getParameter(f.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:f.getParameter(f.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=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.centroidScreen=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}; \ No newline at end of file diff --git a/examples/camera_orthographic.html b/examples/camera_orthographic.html index 4f99f0d54231a24d6f3926170fd5f5adbe64cd8a..88f9c03f5a0d89d67baea66f9e9195014ffaa3c2 100644 --- a/examples/camera_orthographic.html +++ b/examples/camera_orthographic.html @@ -32,8 +32,16 @@ function init() { - container = document.createElement('div'); - document.body.appendChild(container); + container = document.createElement( 'div' ); + document.body.appendChild( container ); + + var info = document.createElement( 'div' ); + info.style.position = 'absolute'; + info.style.top = '10px'; + info.style.width = '100%'; + info.style.textAlign = 'center'; + info.innerHTML = 'three.js - orthographic view'; + container.appendChild( info ); camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 10000 ); camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -2000, 1000 ); diff --git a/examples/geometry_cube.html b/examples/geometry_cube.html index 1b0e7c8028d12e4c346cf437723d2a31006b57fa..4ae5dd4456fa4411569d641aebaa0330fdb1d9ab 100644 --- a/examples/geometry_cube.html +++ b/examples/geometry_cube.html @@ -50,16 +50,16 @@ function init() { - container = document.createElement('div'); - document.body.appendChild(container); + container = document.createElement( 'div' ); + document.body.appendChild( container ); - var info = document.createElement('div'); + var info = document.createElement( 'div' ); info.style.position = 'absolute'; info.style.top = '10px'; info.style.width = '100%'; info.style.textAlign = 'center'; info.innerHTML = 'Drag to spin the cube'; - container.appendChild(info); + container.appendChild( info ); camera = new THREE.Camera( 70, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 ); camera.position.y = 150; diff --git a/examples/interactive_cubes.html b/examples/interactive_cubes.html new file mode 100644 index 0000000000000000000000000000000000000000..22cb1e1ab939bba4e33b344805fe6a4c644518d1 --- /dev/null +++ b/examples/interactive_cubes.html @@ -0,0 +1,139 @@ + + + + three.js - interactive - cubes + + + + + + + + + + + + + + + + diff --git a/examples/interactive_spheres.html b/examples/interactive_spheres.html deleted file mode 100644 index ccb2bca0bb46686c4c781ea480e4df02acf10b5f..0000000000000000000000000000000000000000 --- a/examples/interactive_spheres.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - three.js - interactive - spheres - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/core/Ray.js b/src/core/Ray.js index 3f4e68c232ce8d4c3cc4c645c0e4a74b3c6fe45a..18442c7bb3e4a8d93aed11f6e3ace42584f6d17b 100644 --- a/src/core/Ray.js +++ b/src/core/Ray.js @@ -37,10 +37,11 @@ THREE.Ray.prototype = { intersectObject: function ( object ) { - var f, fl, face, a, b, c, d, dot, s, + var f, fl, face, a, b, c, d, normal, + dot, scalar, origin, direction, geometry = object.geometry, - matrix = object.matrix, + vertices = geometry.vertices, intersect, intersects = [], intersectPoint; @@ -48,21 +49,21 @@ THREE.Ray.prototype = { face = geometry.faces[ f ]; - // if ( !face.selectable ) continue; - - a = matrix.transform( geometry.vertices[ face.a ].position.clone() ); - b = matrix.transform( geometry.vertices[ face.b ].position.clone() ); - c = matrix.transform( geometry.vertices[ face.c ].position.clone() ); - d = face instanceof THREE.Face4 ? matrix.transform( geometry.vertices[ face.d ].position.clone() ) : null; - origin = this.origin.clone(); direction = this.direction.clone(); - dot = face.normal.dot( direction ); + + a = object.matrix.transform( vertices[ face.a ].position.clone() ); + b = object.matrix.transform( vertices[ face.b ].position.clone() ); + c = object.matrix.transform( vertices[ face.c ].position.clone() ); + d = face instanceof THREE.Face4 ? object.matrix.transform( vertices[ face.d ].position.clone() ) : null; + + normal = object.matrixRotation.transform( face.normal.clone() ); + dot = direction.dot( normal ); if ( dot < 0 ) { // Math.abs( dot ) > 0.0001 - s = face.normal.dot( new THREE.Vector3().sub( a, origin ) ) / dot; - intersectPoint = origin.addSelf( direction.multiplyScalar( s ) ); + scalar = normal.dot( new THREE.Vector3().sub( a, origin ) ) / dot; + intersectPoint = origin.addSelf( direction.multiplyScalar( scalar ) ); if ( face instanceof THREE.Face3 ) { @@ -101,13 +102,13 @@ THREE.Ray.prototype = { } } - + } - + return intersects; - + // http://www.blackpawn.com/texts/pointinpoly/default.html - + function pointInFace3( p, a, b, c ) { var v0 = c.clone().subSelf( a ), v1 = b.clone().subSelf( a ), v2 = p.clone().subSelf( a ),