提交 60c23544 编写于 作者: U unknown

Added OBJ -> Three.js converter.

Added OBJ converter test example.

Modified Three.js to handle converted models:

 - extended WebGL renderer to use texturing
   - broke down model into multiple VBOs according to materials
   - textures are lazy created when images get loaded
     (converter takes care of resizing images to nearest power of 2
      dimensions using 2d canvas)

 - changed material array semantics in Mesh object
    - before: multiple materials were applied to all faces (broken in WebGL, needs multitexturing shader)
    - now: there is only single material per face, but one mesh can have faces with different materials

 - added per vertex normals (to get smooth shading in WebGL)
上级 647b4a57
// Three.js r18 - http://github.com/mrdoob/three.js // Three.js r18 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=Math.floor(this.a*255)<<24|Math.floor(this.r*255)<<16|Math.floor(this.g*255)<<8|Math.floor(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)<a)&&(Math.abs(this.y)<a)&&(Math.abs(this.z)<a)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,d,c,b){this.x=a||0;this.y=d||0;this.z=c||0;this.w=b||1};THREE.Vector4.prototype={set:function(a,d,c,b){this.x=a;this.y=d;this.z=c;this.w=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;this.w=b.w+a.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;this.w=b.w-a.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Rectangle=function(){var f,h,d,g,a,c,e=true;function b(){a=d-f;c=g-h}this.getX=function(){return f};this.getY=function(){return h};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getX1=function(){return f};this.getY1=function(){return h};this.getX2=function(){return d};this.getY2=function(){return g};this.set=function(j,l,i,k){e=false;f=j;h=l;d=i;g=k;b()};this.addPoint=function(i,j){if(e){e=false;f=i;h=j;d=i;g=j}else{f=Math.min(f,i);h=Math.min(h,j);d=Math.max(d,i);g=Math.max(g,j)}b()};this.addRectangle=function(i){if(e){e=false;f=i.getX1();h=i.getY1();d=i.getX2();g=i.getY2()}else{f=Math.min(f,i.getX1());h=Math.min(h,i.getY1());d=Math.max(d,i.getX2());g=Math.max(g,i.getY2())}b()};this.inflate=function(i){f-=i;h-=i;d+=i;g+=i;b()};this.minSelf=function(i){f=Math.max(f,i.getX1());h=Math.max(h,i.getY1());d=Math.min(d,i.getX2());g=Math.min(g,i.getY2());b()};this.instersects=function(i){return Math.min(d,i.getX2())-Math.max(f,i.getX1())>=0&&Math.min(g,i.getY2())-Math.max(h,i.getY1())>=0};this.empty=function(){e=true;f=0;h=0;d=0;g=0;b()};this.isEmpty=function(){return e};this.toString=function(){return"THREE.Rectangle (x1: "+f+", y1: "+g+", x2: "+d+", y1: "+h+", width: "+a+", height: "+c+")"}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=a-k;b=f-g;l=(o+c)/n;j=(a+k)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g||new THREE.Vector3();this.color=f||new THREE.Color(4278190080)};THREE.Face3.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).divideScalar(3)},toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h||new THREE.Vector3();this.color=g||new THREE.Color(4278190080)};THREE.Face4.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).addSelf(this.d).divideScalar(4)},toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;c<b;c++){a=this.faces[c];a.centroid.set(0,0,0);if(a instanceof THREE.Face3){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.divideScalar(3)}else{if(a instanceof THREE.Face4){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.addSelf(this.vertices[a.d].position);a.centroid.divideScalar(4)}}}},computeNormals:function(){var k,d,g,h,j,i,c,b,a,e=new THREE.Vector3(),l=new THREE.Vector3();for(k=0,d=this.vertices.length;k<d;k++){g=this.vertices[k];g.normal.set(0,0,0)}for(h=0,j=this.faces.length;h<j;h++){i=this.faces[h];c=this.vertices[i.a];b=this.vertices[i.b];a=this.vertices[i.c];e.sub(a.position,b.position);l.sub(c.position,b.position);e.crossSelf(l);if(!e.isZero()){e.normalize()}i.normal.copy(e)}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){this.fov=c;this.aspect=b;this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(255<<24|a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light();THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,0,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.PointLight;THREE.Object3D=function(a){this.position=new THREE.Vector3();this.rotation=new THREE.Vector3();this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4();this.matrixTranslation=new THREE.Matrix4();this.matrixRotation=new THREE.Matrix4();this.matrixScale=new THREE.Matrix4();this.screen=new THREE.Vector3();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D();THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a]};THREE.Line.prototype=new THREE.Object3D();THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a];this.flipSided=false;this.doubleSided=false;this.overdraw=false};THREE.Mesh.prototype=new THREE.Object3D();THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.LineColorMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshBitmapUVMappingMaterial=function(a){this.bitmap=a;this.toString=function(){return"THREE.MeshBitmapUVMappingMaterial ( bitmap: "+this.bitmap+" )"}};THREE.MeshColorFillMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.MeshColorFillMaterial ( color: "+this.color+" )"}};THREE.MeshColorStrokeMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c);this.toString=function(){return"THREE.MeshColorStrokeMaterial ( lineWidth: "+this.lineWidth+", color: "+this.color+" )"}};THREE.MeshFaceColorFillMaterial=function(){this.toString=function(){return"THREE.MeshFaceColorFillMaterial ( )"}};THREE.MeshFaceColorStrokeMaterial=function(a){this.lineWidth=a||1;this.toString=function(){return"THREE.MeshFaceColorStrokeMaterial ( lineWidth: "+this.lineWidth+" )"}};THREE.ParticleBitmapMaterial=function(a){this.bitmap=a;this.offset=new THREE.Vector2();this.toString=function(){return"THREE.ParticleBitmapMaterial ( bitmap: "+this.bitmap+" )"}};THREE.ParticleCircleMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.ParticleCircleMaterial ( color: "+this.color+" )"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(b){for(var c=0,a=this.objects.length;c<a;c++){if(b==this.objects[c]){this.objects.splice(c,1);return}}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(b){for(var c=0,a=this.lights.length;c<a;c++){if(b==this.lights[c]){this.lights.splice(c,1);return}}};this.add=function(a){this.addObject(a)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,q,o=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),p=new THREE.Matrix4();this.projectScene=function(K,H){var G,F,E,L,J,C,s,M,r,A,I,w,D,x,B,z,y,u,t;e=[];q=0,f=0,m=0,h=0;if(H.autoUpdateMatrix){H.updateMatrix()}d.multiply(H.projectionMatrix,H.matrix);s=K.objects;for(G=0,F=s.length;G<F;G++){M=s[G];r=M.matrix;if(M.autoUpdateMatrix){M.updateMatrix()}if(M instanceof THREE.Mesh){p.multiply(d,r);A=M.geometry.vertices;for(E=0,L=A.length;E<L;E++){I=A[E];w=I.positionScreen;w.copy(I.position);p.transform(w);I.__visible=w.z>0&&w.z<1}x=M.geometry.faces;for(J=0,C=x.length;J<C;J++){B=x[J];if(B instanceof THREE.Face3){z=A[B.a];y=A[B.b];u=A[B.c];if(z.__visible&&y.__visible&&u.__visible){if((M.doubleSided||(M.flipSided!=(u.positionScreen.x-z.positionScreen.x)*(y.positionScreen.y-z.positionScreen.y)-(u.positionScreen.y-z.positionScreen.y)*(y.positionScreen.x-z.positionScreen.x)<0))){c=o[q]=o[q]||new THREE.RenderableFace3();c.v1.copy(z.positionScreen);c.v2.copy(y.positionScreen);c.v3.copy(u.positionScreen);c.centroidWorld.copy(B.centroid);M.matrix.transform(c.centroidWorld);c.normalWorld.copy(B.normal);M.matrixRotation.transform(c.normalWorld);c.z=Math.max(z.positionScreen.z,Math.max(y.positionScreen.z,u.positionScreen.z));c.material=M.material;c.overdraw=M.overdraw;c.uvs=M.geometry.uvs[J];c.color=B.color;e.push(c);q++}}}else{if(B instanceof THREE.Face4){z=A[B.a];y=A[B.b];u=A[B.c];t=A[B.d];if(z.__visible&&y.__visible&&u.__visible&&t.__visible){if((M.doubleSided||(M.flipSided!=((t.positionScreen.x-z.positionScreen.x)*(y.positionScreen.y-z.positionScreen.y)-(t.positionScreen.y-z.positionScreen.y)*(y.positionScreen.x-z.positionScreen.x)<0||(y.positionScreen.x-u.positionScreen.x)*(t.positionScreen.y-u.positionScreen.y)-(y.positionScreen.y-u.positionScreen.y)*(t.positionScreen.x-u.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.copy(z.positionScreen);b.v2.copy(y.positionScreen);b.v3.copy(u.positionScreen);b.v4.copy(t.positionScreen);b.centroidWorld.copy(B.centroid);M.matrix.transform(b.centroidWorld);b.normalWorld.copy(B.normal);M.matrixRotation.transform(b.normalWorld);b.z=Math.max(z.positionScreen.z,Math.max(y.positionScreen.z,Math.max(u.positionScreen.z,t.positionScreen.z)));b.material=M.material;b.overdraw=M.overdraw;b.uvs=M.geometry.uvs[J];b.color=B.color;e.push(b);f++}}}}}}else{if(M instanceof THREE.Line){p.multiply(d,r);A=M.geometry.vertices;for(E=0,L=A.length;E<L;E++){I=A[E];w=I.positionScreen;w.copy(I.position);p.transform(w);I.__visible=w.z>0&&w.z<1;if(E>0){D=M.geometry.vertices[E-1];if(I.__visible&&D.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(I.positionScreen);k.v2.copy(D.positionScreen);k.z=Math.max(I.positionScreen.z,D.positionScreen.z);k.material=M.material;e.push(k);m++}}}}else{if(M instanceof THREE.Particle){g.set(M.position.x,M.position.y,M.position.z,1);H.matrix.transform(g);H.projectionMatrix.transform(g);M.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(M.screen.z>0&&M.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=M.screen.x;j.y=M.screen.y;j.z=M.screen.z;j.rotation=M.rotation.z;j.scale.x=M.scale.x*Math.abs(g.x/g.w-(g.x+H.projectionMatrix.n11)/(g.w+H.projectionMatrix.n14));j.scale.y=M.scale.y*Math.abs(g.y/g.w-(g.y+H.projectionMatrix.n22)/(g.w+H.projectionMatrix.n24));j.material=M.material;j.color=M.color;e.push(j);h++}}}}}e.sort(n);return e};function n(s,r){return r.z-s.z}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q<h;q++){o=e[q];if(o instanceof THREE.RenderableParticle){k=o.x*f+f;j=o.y*d+d;for(i=0,n=o.material.length;i<n;i++){s=o.material[i];if(s instanceof THREE.ParticleDOMMaterial){l=s.domElement;l.style.left=k+"px";l.style.top=j+"px"}}}}}};THREE.CanvasRenderer=function(){var u=null,o=new THREE.Projector(),m=document.createElement("canvas"),n=m.getContext("2d"),h,z,k,c,y=new THREE.Rectangle(),j=new THREE.Rectangle(),s=new THREE.Rectangle(),i=new THREE.Color(4294967295),q=new THREE.Color(4294967295),e=new THREE.Color(4294967295),g=new THREE.Vector2(),f=new THREE.Vector3(),d=new THREE.Vector2(),a=new THREE.Vector2(),x=new THREE.UV(),w=new THREE.UV(),t=new THREE.UV(),r=new THREE.UV();this.domElement=m;this.autoClear=true;this.setSize=function(B,A){h=B;z=A;k=h/2;c=z/2;m.width=h;m.height=z;y.set(-k,-c,k,c)};this.clear=function(){if(!j.isEmpty()){j.inflate(1);j.minSelf(y);n.setTransform(1,0,0,-1,k,c);n.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());j.empty()}};this.render=function(aa,V){var Z,D,F,P,W,L,N=Math.PI*2,H,G,T,R,C,A,J,I,U,S,E,B,O,M,ac,ab,Y,X,ad,K,Q;if(this.autoClear){this.clear()}u=o.projectScene(aa,V);n.setTransform(1,0,0,-1,k,c);v(aa,e);for(Z=0,D=u.length;Z<D;Z++){F=u[Z];s.empty();if(F instanceof THREE.RenderableParticle){H=F.x*k;G=F.y*c;for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.ParticleCircleMaterial){q.copyRGB(e);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();O=F.scale.x*k;M=F.scale.y*c;s.set(H-O,G-M,H+O,G+M);if(!y.instersects(s)){continue}n.save();n.translate(H,G);n.rotate(-F.rotation);n.scale(O,M);n.beginPath();n.arc(0,0,1,0,N,true);n.closePath();n.fillStyle=i.__styleString;n.fill();n.restore()}else{if(L instanceof THREE.ParticleBitmapMaterial){ad=L.bitmap;K=ad.width/2;Q=ad.height/2;ac=F.scale.x*k;ab=F.scale.y*c;O=ac*K;M=ab*Q;Y=L.offset.x*ac;X=L.offset.y*ab;s.set(H+Y-O,G+X-M,H+Y+O,G+X+M);if(!y.instersects(s)){continue}n.save();n.translate(H,G);n.rotate(-F.rotation);n.scale(ac,-ab);n.translate(-K+L.offset.x,-Q-L.offset.y);n.drawImage(ad,0,0);n.restore()}}}}else{if(F instanceof THREE.RenderableLine){H=F.v1.x*k;G=F.v1.y*c;T=F.v2.x*k;R=F.v2.y*c;s.addPoint(H,G);s.addPoint(T,R);if(!y.instersects(s)){continue}n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.closePath();for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.LineColorMaterial){q.copyRGB(e);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}}}else{if(F instanceof THREE.RenderableFace3){F.v1.x*=k;F.v1.y*=c;F.v2.x*=k;F.v2.y*=c;F.v3.x*=k;F.v3.y*=c;if(F.overdraw){b(F.v1,F.v2);b(F.v2,F.v3);b(F.v3,F.v1)}H=F.v1.x;G=F.v1.y;T=F.v2.x;R=F.v2.y;C=F.v3.x;A=F.v3.y;s.addPoint(H,G);s.addPoint(T,R);s.addPoint(C,A);if(!y.instersects(s)){continue}for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.MeshColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshFaceColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshFaceColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshBitmapUVMappingMaterial){ad=L.bitmap;K=ad.width-1;Q=ad.height-1;x.copy(F.uvs[0]);w.copy(F.uvs[1]);t.copy(F.uvs[2]);x.u*=K;x.v*=Q;w.u*=K;w.v*=Q;t.u*=K;t.v*=Q;p(ad,H,G,T,R,C,A,x.u,x.v,w.u,w.v,t.u,t.v)}}}}}}}else{if(F instanceof THREE.RenderableFace4){F.v1.x*=k;F.v1.y*=c;F.v2.x*=k;F.v2.y*=c;F.v3.x*=k;F.v3.y*=c;F.v4.x*=k;F.v4.y*=c;d.copy(F.v2);a.copy(F.v4);if(F.overdraw){b(F.v1,F.v2);b(F.v2,F.v4);b(F.v4,F.v1)}H=F.v1.x;G=F.v1.y;T=F.v2.x;R=F.v2.y;J=F.v4.x;I=F.v4.y;if(F.overdraw){b(F.v3,d);b(F.v3,a)}C=F.v3.x;A=F.v3.y;U=d.x;S=d.y;E=a.x;B=a.y;s.addPoint(H,G);s.addPoint(T,R);s.addPoint(C,A);s.addPoint(J,I);if(!y.instersects(s)){continue}for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.MeshColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshFaceColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshFaceColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshBitmapUVMappingMaterial){ad=L.bitmap;K=ad.width-1;Q=ad.height-1;x.copy(F.uvs[0]);w.copy(F.uvs[1]);t.copy(F.uvs[2]);r.copy(F.uvs[3]);x.u*=K;x.v*=Q;w.u*=K;w.v*=Q;t.u*=K;t.v*=Q;r.u*=K;r.v*=Q;p(ad,H,G,T,R,J,I,x.u,x.v,w.u,w.v,r.u,r.v);p(ad,U,S,C,A,E,B,w.u,w.v,t.u,t.v,r.u,r.v)}}}}}}}}}}j.addRectangle(s)}n.setTransform(1,0,0,1,0,0)};function v(E,C){var B,D,A;C.setRGBA(1,1,1,1);for(B=0,D=E.lights.length;B<D;B++){A=E.lights[B];if(A instanceof THREE.AmbientLight){C.r*=A.color.r;C.g*=A.color.g;C.b*=A.color.b}}}function l(G,E,C){var B,F,A,D;for(B=0,F=G.lights.length;B<F;B++){A=G.lights[B];if(A instanceof THREE.DirectionalLight){D=E.normalWorld.dot(A.position)*A.intensity;if(D>0){C.r+=A.color.r*D;C.g+=A.color.g*D;C.b+=A.color.b*D}}else{if(A instanceof THREE.PointLight){f.sub(A.position,E.centroidWorld);f.normalize();D=E.normalWorld.dot(f)*A.intensity;if(D>0){C.r+=A.color.r*D;C.g+=A.color.g*D;C.b+=A.color.b*D}}}}}function p(T,I,H,O,N,C,A,Q,P,E,D,M,L){var B,S,R,G,F,K,J;n.beginPath();n.moveTo(I,H);n.lineTo(O,N);n.lineTo(C,A);n.lineTo(I,H);n.closePath();n.save();n.clip();B=Q*(L-D)-E*L+M*D+(E-M)*P;S=-(P*(C-O)-D*C+L*O+(D-L)*I)/B;R=(D*A+P*(N-A)-L*N+(L-D)*H)/B;G=(Q*(C-O)-E*C+M*O+(E-M)*I)/B;F=-(E*A+Q*(N-A)-M*N+(M-E)*H)/B;K=(Q*(L*O-D*C)+P*(E*C-M*O)+(M*D-E*L)*I)/B;J=(Q*(L*N-D*A)+P*(E*A-M*N)+(M*D-E*L)*H)/B;n.transform(S,R,G,F,K,J);n.drawImage(T,0,0);n.restore()}function b(B,A){g.sub(A,B);g.unit();g.multiplyScalar(0.75);A.addSelf(g);B.subSelf(g)}};THREE.SVGRenderer=function(){var p=null,k=new THREE.Projector(),l=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,t,i,a,r=new THREE.Rectangle(),o=new THREE.Rectangle(),f=new THREE.Color(4294967295),n=new THREE.Color(4294967295),b=new THREE.Color(4294967295),d=new THREE.Vector3(),c=[],g=[],s=1;this.domElement=l;this.autoClear=true;this.setQuality=function(u){switch(u){case"high":s=1;break;case"low":s=0;break}};this.setSize=function(v,u){e=v;t=u;i=e/2;a=t/2;l.setAttribute("viewBox",(-i)+" "+(-a)+" "+e+" "+t);l.setAttribute("width",e);l.setAttribute("height",t);r.set(-i,-a,i,a)};this.clear=function(){while(l.childNodes.length>0){l.removeChild(l.childNodes[0])}};this.render=function(N,K){var M,w,H,L,x,D,G=0,y=0,E,B,z,J,I,v,u,C,A,F;if(this.autoClear){this.clear()}p=k.projectScene(N,K);q(N,b);for(M=0,w=p.length;M<w;M++){x=p[M];for(H=0,L=x.material.length;H<L;H++){D=x.material[H];o.empty();if(x instanceof THREE.RenderableParticle){B=x.x*i;z=x.y*-a;F=x.size*i;o.set(B-F,z-F,B+F,z+F);if(!r.instersects(o)){continue}E=m(y++);E.setAttribute("cx",B);E.setAttribute("cy",z);E.setAttribute("r",F)}else{if(x instanceof THREE.RenderableFace3){B=x.v1.x*i;z=x.v1.y*-a;J=x.v2.x*i;I=x.v2.y*-a;v=x.v3.x*i;u=x.v3.y*-a;o.addPoint(B,z);o.addPoint(J,I);o.addPoint(v,u);if(!r.instersects(o)){continue}E=h(G++);E.setAttribute("d","M "+B+" "+z+" L "+J+" "+I+" L "+v+","+u+"z")}else{if(x instanceof THREE.RenderableFace4){B=x.v1.x*i;z=x.v1.y*-a;J=x.v2.x*i;I=x.v2.y*-a;v=x.v3.x*i;u=x.v3.y*-a;C=x.v4.x*i;A=x.v4.y*-a;o.addPoint(B,z);o.addPoint(J,I);o.addPoint(v,u);o.addPoint(C,A);if(!r.instersects(o)){continue}E=h(G++);E.setAttribute("d","M "+B+" "+z+" L "+J+" "+I+" L "+v+","+u+" L "+C+","+A+"z")}}}if(D instanceof THREE.MeshColorFillMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(D.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: "+f.__styleString)}else{if(D instanceof THREE.MeshFaceColorFillMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(x.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: "+f.__styleString)}else{if(D instanceof THREE.MeshColorStrokeMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(D.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+D.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}else{if(D instanceof THREE.MeshFaceColorStrokeMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(x.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+D.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}}}l.appendChild(E)}}};function q(y,w){var v,x,u;w.setRGBA(1,1,1,1);for(v=0,x=y.lights.length;v<x;v++){u=y.lights[v];if(u instanceof THREE.AmbientLight){w.r*=u.color.r;w.g*=u.color.g;w.b*=u.color.b}}}function j(A,y,w){var v,z,u,x;for(v=0,z=A.lights.length;v<z;v++){u=A.lights[v];if(u instanceof THREE.DirectionalLight){x=y.normalWorld.dot(u.position)*u.intensity;if(x>0){w.r+=u.color.r*x;w.g+=u.color.g*x;w.b+=u.color.b*x}}else{if(u instanceof THREE.PointLight){d.sub(u.position,y.centroidWorld);d.normalize();x=y.normalWorld.dot(d)*u.intensity;if(x>0){w.r+=u.color.r*x;w.g+=u.color.g*x;w.b+=u.color.b*x}}}}}function h(u){if(c[u]==null){c[u]=document.createElementNS("http://www.w3.org/2000/svg","path");if(s==0){c[u].setAttribute("shape-rendering","crispEdges")}return c[u]}return c[u]}function m(u){if(g[u]==null){g[u]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(s==0){g[u].setAttribute("shape-rendering","crispEdges")}return g[u]}return g[u]}};THREE.WebGLRenderer=function(){var e=document.createElement("canvas"),a,h,d=new THREE.Matrix4(),g;this.domElement=e;this.autoClear=true;f();c();this.setSize=function(j,i){e.width=j;e.height=i;a.viewport(0,0,e.width,e.height)};this.clear=function(){a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)};this.render=function(K,G){var t,L,N,z,M,C,s,q,y,A,r,J,w,B,x,I,u,D,H,F,p,n,k,j,E,v;if(this.autoClear){this.clear()}a.uniform1i(h.enableLighting,K.lights.length);for(E=0,v=K.lights.length;E<v;E++){q=K.lights[E];if(q instanceof THREE.AmbientLight){C=q.color;a.uniform3f(h.ambientColor,C.r,C.g,C.b)}else{if(q instanceof THREE.DirectionalLight){C=q.color;s=q.position;a.uniform3f(h.lightingDirection,s.x,s.y,s.z);a.uniform3f(h.directionalColor,C.r,C.g,C.b)}}}for(B=0,x=K.objects.length;B<x;B++){N=K.objects[B];if(N instanceof THREE.Mesh){if(!N.__webGLVertexBuffer){y=[];A=[];r=[];J=[];w=0;for(I=0,u=N.geometry.faces.length;I<u;I++){t=N.geometry.faces[I];L=t.color;M=t.normal;if(t instanceof THREE.Face3){p=N.geometry.vertices[t.a].position;n=N.geometry.vertices[t.b].position;k=N.geometry.vertices[t.c].position;y.push(p.x,p.y,p.z);y.push(n.x,n.y,n.z);y.push(k.x,k.y,k.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);A.push(w,w+1,w+2);w+=3}else{if(t instanceof THREE.Face4){p=N.geometry.vertices[t.a].position;n=N.geometry.vertices[t.b].position;k=N.geometry.vertices[t.c].position;j=N.geometry.vertices[t.d].position;y.push(p.x,p.y,p.z);y.push(n.x,n.y,n.z);y.push(k.x,k.y,k.z);y.push(j.x,j.y,j.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);A.push(w,w+1,w+2);A.push(w,w+2,w+3);w+=4}}}if(!y.length){continue}N.__webGLVertexBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLVertexBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(y),a.STATIC_DRAW);N.__webGLNormalBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLNormalBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(J),a.STATIC_DRAW);N.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(r),a.STATIC_DRAW);N.__webGLFaceBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),a.STATIC_DRAW);N.__webGLFaceCount=A.length}d.multiply(G.matrix,N.matrix);h.viewMatrixArray=new Float32Array(d.flatten());h.projectionMatrixArray=new Float32Array(G.projectionMatrix.flatten());g=THREE.Matrix4.makeInvert(d).transpose();h.normalMatrixArray=new Float32Array(g.flatten());a.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);a.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);a.uniformMatrix4fv(h.normalMatrix,false,h.normalMatrixArray);a.bindBuffer(a.ARRAY_BUFFER,N.__webGLVertexBuffer);a.vertexAttribPointer(h.position,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,N.__webGLNormalBuffer);a.vertexAttribPointer(h.normal,3,a.FLOAT,false,0,0);for(D=0,H=N.material.length;D<H;D++){z=N.material[D];if(z instanceof THREE.MeshColorFillMaterial){if(!z.__webGLColorBuffer){r=[];for(F=0;F<N.__webGLFaceCount;F++){r.push(z.color.r,z.color.g,z.color.b,z.color.a)}z.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,z.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(r),a.STATIC_DRAW)}a.bindBuffer(a.ARRAY_BUFFER,z.__webGLColorBuffer);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0)}else{if(z instanceof THREE.MeshFaceColorFillMaterial){a.bindBuffer(a.ARRAY_BUFFER,N.__webGLColorBuffer);a.enableVertexAttribArray(h.color);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0)}}}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);a.drawElements(a.TRIANGLES,N.__webGLFaceCount,a.UNSIGNED_SHORT,0)}}};function f(){try{a=e.getContext("experimental-webgl")}catch(i){}if(!a){alert("WebGL not supported");throw"cannot create webgl context"}a.clearColor(0,0,0,1);a.clearDepth(1);a.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.enable(a.BLEND);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA);a.clearColor(0,0,0,0)}function c(){h=a.createProgram();a.attachShader(h,b("fragment",["#ifdef GL_ES","precision highp float;","#endif","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(){","gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);","}"].join("\n")));a.attachShader(h,b("vertex",["attribute vec3 position;","attribute vec3 normal;","attribute vec4 color;","uniform bool enableLighting;","uniform vec3 ambientColor;","uniform vec3 directionalColor;","uniform vec3 lightingDirection;","uniform mat4 viewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 normalMatrix;","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(void) {","if(!enableLighting) {","lightWeighting = vec3(1.0, 1.0, 1.0);","} else {","vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);","float directionalLightWeighting = max(dot(transformedNormal.xyz, lightingDirection), 0.0);","lightWeighting = ambientColor + directionalColor * directionalLightWeighting;","}","vcolor = color;","gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );","}"].join("\n")));a.linkProgram(h);if(!a.getProgramParameter(h,a.LINK_STATUS)){alert("Could not initialise shaders")}a.useProgram(h);h.viewMatrix=a.getUniformLocation(h,"viewMatrix");h.projectionMatrix=a.getUniformLocation(h,"projectionMatrix");h.normalMatrix=a.getUniformLocation(h,"normalMatrix");h.enableLighting=a.getUniformLocation(h,"enableLighting");h.ambientColor=a.getUniformLocation(h,"ambientColor");h.directionalColor=a.getUniformLocation(h,"directionalColor");h.lightingDirection=a.getUniformLocation(h,"lightingDirection");h.color=a.getAttribLocation(h,"color");a.enableVertexAttribArray(h.color);h.position=a.getAttribLocation(h,"position");a.enableVertexAttribArray(h.position);h.normal=a.getAttribLocation(h,"normal");a.enableVertexAttribArray(h.normal);h.viewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function b(j,i){var k;if(j=="fragment"){k=a.createShader(a.FRAGMENT_SHADER)}else{if(j=="vertex"){k=a.createShader(a.VERTEX_SHADER)}}a.shaderSource(k,i);a.compileShader(k);if(!a.getShaderParameter(k,a.COMPILE_STATUS)){alert(a.getShaderInfoLog(k));return null}return k}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null}; var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=Math.floor(this.a*255)<<24|Math.floor(this.r*255)<<16|Math.floor(this.g*255)<<8|Math.floor(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)<a)&&(Math.abs(this.y)<a)&&(Math.abs(this.z)<a)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,d,c,b){this.x=a||0;this.y=d||0;this.z=c||0;this.w=b||1};THREE.Vector4.prototype={set:function(a,d,c,b){this.x=a;this.y=d;this.z=c;this.w=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;this.w=b.w+a.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;this.w=b.w-a.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Rectangle=function(){var f,h,d,g,a,c,e=true;function b(){a=d-f;c=g-h}this.getX=function(){return f};this.getY=function(){return h};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getX1=function(){return f};this.getY1=function(){return h};this.getX2=function(){return d};this.getY2=function(){return g};this.set=function(j,m,i,k){e=false;f=j;h=m;d=i;g=k;b()};this.addPoint=function(i,j){if(e){e=false;f=i;h=j;d=i;g=j}else{f=Math.min(f,i);h=Math.min(h,j);d=Math.max(d,i);g=Math.max(g,j)}b()};this.addRectangle=function(i){if(e){e=false;f=i.getX1();h=i.getY1();d=i.getX2();g=i.getY2()}else{f=Math.min(f,i.getX1());h=Math.min(h,i.getY1());d=Math.max(d,i.getX2());g=Math.max(g,i.getY2())}b()};this.inflate=function(i){f-=i;h-=i;d+=i;g+=i;b()};this.minSelf=function(i){f=Math.max(f,i.getX1());h=Math.max(h,i.getY1());d=Math.min(d,i.getX2());g=Math.min(g,i.getY2());b()};this.instersects=function(i){return Math.min(d,i.getX2())-Math.max(f,i.getX1())>=0&&Math.min(g,i.getY2())-Math.max(h,i.getY1())>=0};this.empty=function(){e=true;f=0;h=0;d=0;g=0;b()};this.isEmpty=function(){return e};this.toString=function(){return"THREE.Rectangle (x1: "+f+", y1: "+g+", x2: "+d+", y1: "+h+", width: "+a+", height: "+c+")"}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var p=this.n11,o=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,s=this.n32,r=this.n33,q=this.n34,n=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=p*c.n11+o*c.n21+k*c.n31+i*c.n41;this.n12=p*c.n12+o*c.n22+k*c.n32+i*c.n42;this.n13=p*c.n13+o*c.n23+k*c.n33+i*c.n43;this.n14=p*c.n14+o*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+s*c.n21+r*c.n31+q*c.n41;this.n32=a*c.n12+s*c.n22+r*c.n32+q*c.n42;this.n33=a*c.n13+s*c.n23+r*c.n33+q*c.n43;this.n34=a*c.n14+s*c.n24+r*c.n34+q*c.n44;this.n41=n*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=n*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=n*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=n*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeFrustum=function(f,s,e,p,i,h){var g,r,o,q,n,k,j;g=new THREE.Matrix4();r=2*i/(s-f);o=2*i/(p-e);q=(s+f)/(s-f);n=(p+e)/(p-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=r;g.n12=0;g.n13=q;g.n14=0;g.n21=0;g.n22=o;g.n23=n;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,q,k,a,g,f){var d,n,j,i,o,e,b;d=new THREE.Matrix4();o=q-c;e=a-k;b=f-g;n=(q+c)/o;j=(a+k)/e;i=(f+g)/b;d.n11=2/o;d.n12=0;d.n13=0;d.n14=-n;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,i,h,f,g){this.a=e;this.b=d;this.c=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.color=f||new THREE.Color(4278190080);this.vertexNormals=h instanceof Array?h:[];this.material=g||0};THREE.Face3.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).divideScalar(3)},toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,k,j,i,g,h){this.a=f;this.b=e;this.c=k;this.d=j;this.centroid=new THREE.Vector3();this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3();this.color=g||new THREE.Color(4278190080);this.vertexNormals=i instanceof Array?i:[];this.material=h||0};THREE.Face4.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).addSelf(this.d).divideScalar(4)},toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;c<b;c++){a=this.faces[c];a.centroid.set(0,0,0);if(a instanceof THREE.Face3){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.divideScalar(3)}else{if(a instanceof THREE.Face4){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.addSelf(this.vertices[a.d].position);a.centroid.divideScalar(4)}}}},computeNormals:function(o){var e,b,p,g,i,j,m,k,d,c,a,h=new THREE.Vector3(),q=new THREE.Vector3();for(p=0,g=this.vertices.length;p<g;p++){i=this.vertices[p];i.normal.set(0,0,0)}for(j=0,m=this.faces.length;j<m;j++){k=this.faces[j];if(o&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.x+=k.vertexNormals[e].x;h.y+=k.vertexNormals[e].y;h.z+=k.vertexNormals[e].z}h.x/=3;h.y/=3;h.z/=3;if(!h.isZero()){h.normalize()}k.normal.copy(h)}else{d=this.vertices[k.a];c=this.vertices[k.b];a=this.vertices[k.c];h.sub(a.position,c.position);q.sub(d.position,c.position);h.crossSelf(q);if(!h.isZero()){h.normalize()}k.normal.copy(h)}}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};var a,b;for(a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0]){this.bbox.x[0]=vertex.position.x}else{if(vertex.position.x>this.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.y<this.bbox.y[0]){this.bbox.y[0]=vertex.position.y}else{if(vertex.position.y>this.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.z<this.bbox.z[0]){this.bbox.z[0]=vertex.position.z}else{if(vertex.position.z>this.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){this.fov=c;this.aspect=b;this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(255<<24|a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light();THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,0,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.PointLight;THREE.Object3D=function(a){this.position=new THREE.Vector3();this.rotation=new THREE.Vector3();this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4();this.matrixTranslation=new THREE.Matrix4();this.matrixRotation=new THREE.Matrix4();this.matrixScale=new THREE.Matrix4();this.screen=new THREE.Vector3();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D();THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a]};THREE.Line.prototype=new THREE.Object3D();THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(b,a,c){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a];this.flipSided=false;this.doubleSided=false;this.overdraw=false;this.materialFaces={};this.sortFacesByMaterial();if(c){this.normalizeUVs()}this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D();THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.sortFacesByMaterial=function(){var d,c,b,a;for(d=0,c=this.geometry.faces.length;d<c;d++){b=this.geometry.faces[d];a=b.material;if(this.materialFaces[a]==undefined){this.materialFaces[a]={faces:[]}}this.materialFaces[a].faces.push(d)}};THREE.Mesh.prototype.normalizeUVs=function(){var c,a;for(c=0,l=this.geometry.uvs.length;c<l;c++){var b=this.geometry.uvs[c];for(a=0,jl=b.length;a<jl;a++){if(b[a].u!=1){b[a].u=b[a].u-Math.floor(b[a].u)}if(b[a].v!=1){b[a].v=b[a].v-Math.floor(b[a].v)}}}};THREE.LineColorMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshBitmapUVMappingMaterial=function(a){this.bitmap=a;this.toString=function(){return"THREE.MeshBitmapUVMappingMaterial ( bitmap: "+this.bitmap+" )"}};THREE.MeshColorFillMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.MeshColorFillMaterial ( color: "+this.color+" )"}};THREE.MeshColorStrokeMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c);this.toString=function(){return"THREE.MeshColorStrokeMaterial ( lineWidth: "+this.lineWidth+", color: "+this.color+" )"}};THREE.MeshFaceColorFillMaterial=function(){this.toString=function(){return"THREE.MeshFaceColorFillMaterial ( )"}};THREE.MeshFaceColorStrokeMaterial=function(a){this.lineWidth=a||1;this.toString=function(){return"THREE.MeshFaceColorStrokeMaterial ( lineWidth: "+this.lineWidth+" )"}};THREE.ParticleBitmapMaterial=function(a){this.bitmap=a;this.offset=new THREE.Vector2();this.toString=function(){return"THREE.ParticleBitmapMaterial ( bitmap: "+this.bitmap+" )"}};THREE.ParticleCircleMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.ParticleCircleMaterial ( color: "+this.color+" )"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(b){for(var c=0,a=this.objects.length;c<a;c++){if(b==this.objects[c]){this.objects.splice(c,1);return}}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(b){for(var c=0,a=this.lights.length;c<a;c++){if(b==this.lights[c]){this.lights.splice(c,1);return}}};this.add=function(a){this.addObject(a)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,r,p=[],b,f,m=[],k,n,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),q=new THREE.Matrix4();this.projectScene=function(L,I){var H,G,F,M,K,D,t,N,s,B,J,x,E,y,C,A,z,w,u;e=[];r=0,f=0,n=0,h=0;if(I.autoUpdateMatrix){I.updateMatrix()}d.multiply(I.projectionMatrix,I.matrix);t=L.objects;for(H=0,G=t.length;H<G;H++){N=t[H];s=N.matrix;if(N.autoUpdateMatrix){N.updateMatrix()}if(N instanceof THREE.Mesh){q.multiply(d,s);B=N.geometry.vertices;for(F=0,M=B.length;F<M;F++){J=B[F];x=J.positionScreen;x.copy(J.position);q.transform(x);J.__visible=x.z>0&&x.z<1}y=N.geometry.faces;for(K=0,D=y.length;K<D;K++){C=y[K];if(C instanceof THREE.Face3){A=B[C.a];z=B[C.b];w=B[C.c];if(A.__visible&&z.__visible&&w.__visible){if((N.doubleSided||(N.flipSided!=(w.positionScreen.x-A.positionScreen.x)*(z.positionScreen.y-A.positionScreen.y)-(w.positionScreen.y-A.positionScreen.y)*(z.positionScreen.x-A.positionScreen.x)<0))){c=p[r]=p[r]||new THREE.RenderableFace3();c.v1.copy(A.positionScreen);c.v2.copy(z.positionScreen);c.v3.copy(w.positionScreen);c.centroidWorld.copy(C.centroid);N.matrix.transform(c.centroidWorld);c.normalWorld.copy(C.normal);N.matrixRotation.transform(c.normalWorld);c.z=Math.max(A.positionScreen.z,Math.max(z.positionScreen.z,w.positionScreen.z));c.material=[N.material[C.material]];c.overdraw=N.overdraw;c.uvs=N.geometry.uvs[K];c.color=C.color;e.push(c);r++}}}else{if(C instanceof THREE.Face4){A=B[C.a];z=B[C.b];w=B[C.c];u=B[C.d];if(A.__visible&&z.__visible&&w.__visible&&u.__visible){if((N.doubleSided||(N.flipSided!=((u.positionScreen.x-A.positionScreen.x)*(z.positionScreen.y-A.positionScreen.y)-(u.positionScreen.y-A.positionScreen.y)*(z.positionScreen.x-A.positionScreen.x)<0||(z.positionScreen.x-w.positionScreen.x)*(u.positionScreen.y-w.positionScreen.y)-(z.positionScreen.y-w.positionScreen.y)*(u.positionScreen.x-w.positionScreen.x)<0)))){b=m[f]=m[f]||new THREE.RenderableFace4();b.v1.copy(A.positionScreen);b.v2.copy(z.positionScreen);b.v3.copy(w.positionScreen);b.v4.copy(u.positionScreen);b.centroidWorld.copy(C.centroid);N.matrix.transform(b.centroidWorld);b.normalWorld.copy(C.normal);N.matrixRotation.transform(b.normalWorld);b.z=Math.max(A.positionScreen.z,Math.max(z.positionScreen.z,Math.max(w.positionScreen.z,u.positionScreen.z)));b.material=[N.material[C.material]];b.overdraw=N.overdraw;b.uvs=N.geometry.uvs[K];b.color=C.color;e.push(b);f++}}}}}}else{if(N instanceof THREE.Line){q.multiply(d,s);B=N.geometry.vertices;for(F=0,M=B.length;F<M;F++){J=B[F];x=J.positionScreen;x.copy(J.position);q.transform(x);J.__visible=x.z>0&&x.z<1;if(F>0){E=N.geometry.vertices[F-1];if(J.__visible&&E.__visible){k=i[n]=i[n]||new THREE.RenderableLine();k.v1.copy(J.positionScreen);k.v2.copy(E.positionScreen);k.z=Math.max(J.positionScreen.z,E.positionScreen.z);k.material=N.material;e.push(k);n++}}}}else{if(N instanceof THREE.Particle){g.set(N.position.x,N.position.y,N.position.z,1);I.matrix.transform(g);I.projectionMatrix.transform(g);N.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(N.screen.z>0&&N.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=N.screen.x;j.y=N.screen.y;j.z=N.screen.z;j.rotation=N.rotation.z;j.scale.x=N.scale.x*Math.abs(g.x/g.w-(g.x+I.projectionMatrix.n11)/(g.w+I.projectionMatrix.n14));j.scale.y=N.scale.y*Math.abs(g.y/g.w-(g.y+I.projectionMatrix.n22)/(g.w+I.projectionMatrix.n24));j.material=N.material;j.color=N.color;e.push(j);h++}}}}}e.sort(o);return e};function o(t,s){return s.z-t.z}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(q,s){var r,h,i,o,p,t,n,k,j;e=g.projectScene(q,s);for(r=0,h=e.length;r<h;r++){p=e[r];if(p instanceof THREE.RenderableParticle){k=p.x*f+f;j=p.y*d+d;for(i=0,o=p.material.length;i<o;i++){t=p.material[i];if(t instanceof THREE.ParticleDOMMaterial){n=t.domElement;n.style.left=k+"px";n.style.top=j+"px"}}}}}};THREE.CanvasRenderer=function(){var v=null,p=new THREE.Projector(),n=document.createElement("canvas"),o=n.getContext("2d"),h,A,k,c,z=new THREE.Rectangle(),j=new THREE.Rectangle(),t=new THREE.Rectangle(),i=new THREE.Color(4294967295),r=new THREE.Color(4294967295),e=new THREE.Color(4294967295),g=new THREE.Vector2(),f=new THREE.Vector3(),d=new THREE.Vector2(),a=new THREE.Vector2(),y=new THREE.UV(),x=new THREE.UV(),u=new THREE.UV(),s=new THREE.UV();this.domElement=n;this.autoClear=true;this.setSize=function(C,B){h=C;A=B;k=h/2;c=A/2;n.width=h;n.height=A;z.set(-k,-c,k,c)};this.clear=function(){if(!j.isEmpty()){j.inflate(1);j.minSelf(z);o.setTransform(1,0,0,-1,k,c);o.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());j.empty()}};this.render=function(ab,W){var aa,E,G,Q,X,M,O=Math.PI*2,I,H,U,S,D,B,K,J,V,T,F,C,P,N,ad,ac,Z,Y,ae,L,R;if(this.autoClear){this.clear()}v=p.projectScene(ab,W);o.setTransform(1,0,0,-1,k,c);w(ab,e);for(aa=0,E=v.length;aa<E;aa++){G=v[aa];t.empty();if(G instanceof THREE.RenderableParticle){I=G.x*k;H=G.y*c;for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.ParticleCircleMaterial){r.copyRGB(e);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();P=G.scale.x*k;N=G.scale.y*c;t.set(I-P,H-N,I+P,H+N);if(!z.instersects(t)){continue}o.save();o.translate(I,H);o.rotate(-G.rotation);o.scale(P,N);o.beginPath();o.arc(0,0,1,0,O,true);o.closePath();o.fillStyle=i.__styleString;o.fill();o.restore()}else{if(M instanceof THREE.ParticleBitmapMaterial){ae=M.bitmap;L=ae.width/2;R=ae.height/2;ad=G.scale.x*k;ac=G.scale.y*c;P=ad*L;N=ac*R;Z=M.offset.x*ad;Y=M.offset.y*ac;t.set(I+Z-P,H+Y-N,I+Z+P,H+Y+N);if(!z.instersects(t)){continue}o.save();o.translate(I,H);o.rotate(-G.rotation);o.scale(ad,-ac);o.translate(-L+M.offset.x,-R-M.offset.y);o.drawImage(ae,0,0);o.restore()}}}}else{if(G instanceof THREE.RenderableLine){I=G.v1.x*k;H=G.v1.y*c;U=G.v2.x*k;S=G.v2.y*c;t.addPoint(I,H);t.addPoint(U,S);if(!z.instersects(t)){continue}o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.closePath();for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.LineColorMaterial){r.copyRGB(e);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}}}else{if(G instanceof THREE.RenderableFace3){G.v1.x*=k;G.v1.y*=c;G.v2.x*=k;G.v2.y*=c;G.v3.x*=k;G.v3.y*=c;if(G.overdraw){b(G.v1,G.v2);b(G.v2,G.v3);b(G.v3,G.v1)}I=G.v1.x;H=G.v1.y;U=G.v2.x;S=G.v2.y;D=G.v3.x;B=G.v3.y;t.addPoint(I,H);t.addPoint(U,S);t.addPoint(D,B);if(!z.instersects(t)){continue}for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.MeshColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshFaceColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshFaceColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshBitmapUVMappingMaterial){ae=M.bitmap;L=ae.width-1;R=ae.height-1;y.copy(G.uvs[0]);x.copy(G.uvs[1]);u.copy(G.uvs[2]);y.u*=L;y.v*=R;x.u*=L;x.v*=R;u.u*=L;u.v*=R;q(ae,I,H,U,S,D,B,y.u,y.v,x.u,x.v,u.u,u.v)}}}}}}}else{if(G instanceof THREE.RenderableFace4){G.v1.x*=k;G.v1.y*=c;G.v2.x*=k;G.v2.y*=c;G.v3.x*=k;G.v3.y*=c;G.v4.x*=k;G.v4.y*=c;d.copy(G.v2);a.copy(G.v4);if(G.overdraw){b(G.v1,G.v2);b(G.v2,G.v4);b(G.v4,G.v1)}I=G.v1.x;H=G.v1.y;U=G.v2.x;S=G.v2.y;K=G.v4.x;J=G.v4.y;if(G.overdraw){b(G.v3,d);b(G.v3,a)}D=G.v3.x;B=G.v3.y;V=d.x;T=d.y;F=a.x;C=a.y;t.addPoint(I,H);t.addPoint(U,S);t.addPoint(D,B);t.addPoint(K,J);if(!z.instersects(t)){continue}for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.MeshColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshFaceColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshFaceColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshBitmapUVMappingMaterial){ae=M.bitmap;L=ae.width-1;R=ae.height-1;y.copy(G.uvs[0]);x.copy(G.uvs[1]);u.copy(G.uvs[2]);s.copy(G.uvs[3]);y.u*=L;y.v*=R;x.u*=L;x.v*=R;u.u*=L;u.v*=R;s.u*=L;s.v*=R;q(ae,I,H,U,S,K,J,y.u,y.v,x.u,x.v,s.u,s.v);q(ae,V,T,D,B,F,C,x.u,x.v,u.u,u.v,s.u,s.v)}}}}}}}}}}j.addRectangle(t)}o.setTransform(1,0,0,1,0,0)};function w(F,D){var C,E,B;D.setRGBA(1,1,1,1);for(C=0,E=F.lights.length;C<E;C++){B=F.lights[C];if(B instanceof THREE.AmbientLight){D.r*=B.color.r;D.g*=B.color.g;D.b*=B.color.b}}}function m(H,F,D){var C,G,B,E;for(C=0,G=H.lights.length;C<G;C++){B=H.lights[C];if(B instanceof THREE.DirectionalLight){E=F.normalWorld.dot(B.position)*B.intensity;if(E>0){D.r+=B.color.r*E;D.g+=B.color.g*E;D.b+=B.color.b*E}}else{if(B instanceof THREE.PointLight){f.sub(B.position,F.centroidWorld);f.normalize();E=F.normalWorld.dot(f)*B.intensity;if(E>0){D.r+=B.color.r*E;D.g+=B.color.g*E;D.b+=B.color.b*E}}}}}function q(U,J,I,P,O,D,B,R,Q,F,E,N,M){var C,T,S,H,G,L,K;o.beginPath();o.moveTo(J,I);o.lineTo(P,O);o.lineTo(D,B);o.lineTo(J,I);o.closePath();o.save();o.clip();C=R*(M-E)-F*M+N*E+(F-N)*Q;T=-(Q*(D-P)-E*D+M*P+(E-M)*J)/C;S=(E*B+Q*(O-B)-M*O+(M-E)*I)/C;H=(R*(D-P)-F*D+N*P+(F-N)*J)/C;G=-(F*B+R*(O-B)-N*O+(N-F)*I)/C;L=(R*(M*P-E*D)+Q*(F*D-N*P)+(N*E-F*M)*J)/C;K=(R*(M*O-E*B)+Q*(F*B-N*O)+(N*E-F*M)*I)/C;o.transform(T,S,H,G,L,K);o.drawImage(U,0,0);o.restore()}function b(C,B){g.sub(B,C);g.unit();g.multiplyScalar(0.75);B.addSelf(g);C.subSelf(g)}};THREE.SVGRenderer=function(){var q=null,k=new THREE.Projector(),m=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,u,i,a,s=new THREE.Rectangle(),p=new THREE.Rectangle(),f=new THREE.Color(4294967295),o=new THREE.Color(4294967295),b=new THREE.Color(4294967295),d=new THREE.Vector3(),c=[],g=[],t=1;this.domElement=m;this.autoClear=true;this.setQuality=function(v){switch(v){case"high":t=1;break;case"low":t=0;break}};this.setSize=function(w,v){e=w;u=v;i=e/2;a=u/2;m.setAttribute("viewBox",(-i)+" "+(-a)+" "+e+" "+u);m.setAttribute("width",e);m.setAttribute("height",u);s.set(-i,-a,i,a)};this.clear=function(){while(m.childNodes.length>0){m.removeChild(m.childNodes[0])}};this.render=function(O,L){var N,x,I,M,y,E,H=0,z=0,F,C,A,K,J,w,v,D,B,G;if(this.autoClear){this.clear()}q=k.projectScene(O,L);r(O,b);for(N=0,x=q.length;N<x;N++){y=q[N];for(I=0,M=y.material.length;I<M;I++){E=y.material[I];p.empty();if(y instanceof THREE.RenderableParticle){C=y.x*i;A=y.y*-a;G=y.size*i;p.set(C-G,A-G,C+G,A+G);if(!s.instersects(p)){continue}F=n(z++);F.setAttribute("cx",C);F.setAttribute("cy",A);F.setAttribute("r",G)}else{if(y instanceof THREE.RenderableFace3){C=y.v1.x*i;A=y.v1.y*-a;K=y.v2.x*i;J=y.v2.y*-a;w=y.v3.x*i;v=y.v3.y*-a;p.addPoint(C,A);p.addPoint(K,J);p.addPoint(w,v);if(!s.instersects(p)){continue}F=h(H++);F.setAttribute("d","M "+C+" "+A+" L "+K+" "+J+" L "+w+","+v+"z")}else{if(y instanceof THREE.RenderableFace4){C=y.v1.x*i;A=y.v1.y*-a;K=y.v2.x*i;J=y.v2.y*-a;w=y.v3.x*i;v=y.v3.y*-a;D=y.v4.x*i;B=y.v4.y*-a;p.addPoint(C,A);p.addPoint(K,J);p.addPoint(w,v);p.addPoint(D,B);if(!s.instersects(p)){continue}F=h(H++);F.setAttribute("d","M "+C+" "+A+" L "+K+" "+J+" L "+w+","+v+" L "+D+","+B+"z")}}}if(E instanceof THREE.MeshColorFillMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(E.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: "+f.__styleString)}else{if(E instanceof THREE.MeshFaceColorFillMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(y.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: "+f.__styleString)}else{if(E instanceof THREE.MeshColorStrokeMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(E.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+E.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}else{if(E instanceof THREE.MeshFaceColorStrokeMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(y.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+E.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}}}m.appendChild(F)}}};function r(z,x){var w,y,v;x.setRGBA(1,1,1,1);for(w=0,y=z.lights.length;w<y;w++){v=z.lights[w];if(v instanceof THREE.AmbientLight){x.r*=v.color.r;x.g*=v.color.g;x.b*=v.color.b}}}function j(B,z,x){var w,A,v,y;for(w=0,A=B.lights.length;w<A;w++){v=B.lights[w];if(v instanceof THREE.DirectionalLight){y=z.normalWorld.dot(v.position)*v.intensity;if(y>0){x.r+=v.color.r*y;x.g+=v.color.g*y;x.b+=v.color.b*y}}else{if(v instanceof THREE.PointLight){d.sub(v.position,z.centroidWorld);d.normalize();y=z.normalWorld.dot(d)*v.intensity;if(y>0){x.r+=v.color.r*y;x.g+=v.color.g*y;x.b+=v.color.b*y}}}}}function h(v){if(c[v]==null){c[v]=document.createElementNS("http://www.w3.org/2000/svg","path");if(t==0){c[v].setAttribute("shape-rendering","crispEdges")}return c[v]}return c[v]}function n(v){if(g[v]==null){g[v]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(t==0){g[v].setAttribute("shape-rendering","crispEdges")}return g[v]}return g[v]}};THREE.WebGLRenderer=function(){var e=document.createElement("canvas"),a,h,d=new THREE.Matrix4(),g;this.domElement=e;this.autoClear=true;f();c();this.setSize=function(j,i){e.width=j;e.height=i;a.viewport(0,0,e.width,e.height)};this.clear=function(){a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)};this.render=function(O,K){var v,P,R,C,Q,G,u,q,B,D,s,N,y,F,A,M,w,H,L,J,p,n,k,j,I,x,t,E;if(this.autoClear){this.clear()}a.uniform1i(h.enableLighting,O.lights.length);for(I=0,x=O.lights.length;I<x;I++){q=O.lights[I];if(q instanceof THREE.AmbientLight){G=q.color;a.uniform3f(h.ambientColor,G.r,G.g,G.b)}else{if(q instanceof THREE.DirectionalLight){G=q.color;u=q.position;a.uniform3f(h.lightingDirection,u.x,u.y,u.z);a.uniform3f(h.directionalColor,G.r,G.g,G.b)}}}for(F=0,A=O.objects.length;F<A;F++){R=O.objects[F];var r,z;if(R instanceof THREE.Mesh){d.multiply(K.matrix,R.matrix);h.viewMatrixArray=new Float32Array(d.flatten());h.projectionMatrixArray=new Float32Array(K.projectionMatrix.flatten());g=THREE.Matrix4.makeInvert(d).transpose();h.normalMatrixArray=new Float32Array(g.flatten());a.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);a.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);a.uniformMatrix4fv(h.normalMatrix,false,h.normalMatrixArray);for(var H in R.materialFaces){r=R.materialFaces[H];C=R.material[H];if(!C){continue}if(!r.__webGLVertexBuffer){B=[];D=[];s=[];N=[];E=[];y=0;for(M=0,w=r.faces.length;M<w;M++){z=r.faces[M];v=R.geometry.faces[z];P=v.color;vertexNormals=v.vertexNormals;Q=v.normal;t=R.geometry.uvs[z];if(v instanceof THREE.Face3){p=R.geometry.vertices[v.a].position;n=R.geometry.vertices[v.b].position;k=R.geometry.vertices[v.c].position;B.push(p.x,p.y,p.z);B.push(n.x,n.y,n.z);B.push(k.x,k.y,k.z);if(vertexNormals.length==3){N.push(vertexNormals[0].x,vertexNormals[0].y,vertexNormals[0].z);N.push(vertexNormals[1].x,vertexNormals[1].y,vertexNormals[1].z);N.push(vertexNormals[2].x,vertexNormals[2].y,vertexNormals[2].z)}else{N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z)}s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);if(t){E.push(t[0].u,t[0].v);E.push(t[1].u,t[1].v);E.push(t[2].u,t[2].v)}D.push(y,y+1,y+2);y+=3}else{if(v instanceof THREE.Face4){p=R.geometry.vertices[v.a].position;n=R.geometry.vertices[v.b].position;k=R.geometry.vertices[v.c].position;j=R.geometry.vertices[v.d].position;B.push(p.x,p.y,p.z);B.push(n.x,n.y,n.z);B.push(k.x,k.y,k.z);B.push(j.x,j.y,j.z);if(vertexNormals.length==4){N.push(vertexNormals[0].x,vertexNormals[0].y,vertexNormals[0].z);N.push(vertexNormals[1].x,vertexNormals[1].y,vertexNormals[1].z);N.push(vertexNormals[2].x,vertexNormals[2].y,vertexNormals[2].z);N.push(vertexNormals[3].x,vertexNormals[3].y,vertexNormals[3].z)}else{N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z)}s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);if(t){E.push(t[0].u,t[0].v);E.push(t[1].u,t[1].v);E.push(t[2].u,t[2].v);E.push(t[3].u,t[3].v)}D.push(y,y+1,y+2);D.push(y,y+2,y+3);y+=4}}}if(!B.length){continue}r.__webGLVertexBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLVertexBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(B),a.STATIC_DRAW);r.__webGLNormalBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLNormalBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(N),a.STATIC_DRAW);if(C instanceof THREE.MeshFaceColorFillMaterial||C instanceof THREE.MeshBitmapUVMappingMaterial){r.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(s),a.STATIC_DRAW)}r.__webGLUVBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLUVBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(E),a.STATIC_DRAW);r.__webGLFaceBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),a.STATIC_DRAW);r.__webGLFaceCount=D.length}if(C instanceof THREE.MeshColorFillMaterial){if(!r.__webGLColorBuffer){s=[];for(J=0;J<r.__webGLFaceCount;J++){s.push(C.color.r,C.color.g,C.color.b,C.color.a)}r.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(s),a.STATIC_DRAW)}a.uniform1i(h.enableTexture,0)}else{if(C instanceof THREE.MeshFaceColorFillMaterial){a.uniform1i(h.enableTexture,0)}else{if(C instanceof THREE.MeshBitmapUVMappingMaterial){if(!C.__webGLTexture&&C.loaded){C.__webGLTexture=a.createTexture();a.bindTexture(a.TEXTURE_2D,C.__webGLTexture);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,C.bitmap);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR);a.generateMipmap(a.TEXTURE_2D);a.bindTexture(a.TEXTURE_2D,null)}a.uniform1i(h.enableTexture,1);a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,C.__webGLTexture);a.uniform1i(h.diffuse,0)}}}a.bindBuffer(a.ARRAY_BUFFER,r.__webGLVertexBuffer);a.vertexAttribPointer(h.position,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,r.__webGLNormalBuffer);a.vertexAttribPointer(h.normal,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,r.__webGLUVBuffer);if(R.geometry.uvs.length){a.enableVertexAttribArray(h.uv);a.vertexAttribPointer(h.uv,2,a.FLOAT,false,0,0)}else{a.disableVertexAttribArray(h.uv)}a.bindBuffer(a.ARRAY_BUFFER,r.__webGLColorBuffer);a.enableVertexAttribArray(h.color);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);a.drawElements(a.TRIANGLES,r.__webGLFaceCount,a.UNSIGNED_SHORT,0)}}}};function f(){try{a=e.getContext("experimental-webgl",{antialias:true})}catch(i){}if(!a){alert("WebGL not supported");throw"cannot create webgl context"}a.clearColor(0,0,0,1);a.clearDepth(1);a.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.enable(a.BLEND);a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA);a.clearColor(0,0,0,0)}function c(){h=a.createProgram();a.attachShader(h,b("fragment",["#ifdef GL_ES","precision highp float;","#endif","uniform bool enableTexture;","uniform sampler2D diffuse;","varying vec2 vuv;","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(){","if(enableTexture) {","vec4 texelColor = texture2D(diffuse, vuv);","gl_FragColor = vec4(texelColor.rgb * lightWeighting, texelColor.a);","} else {","gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);","}","}"].join("\n")));a.attachShader(h,b("vertex",["attribute vec3 position;","attribute vec3 normal;","attribute vec4 color;","attribute vec2 uv;","uniform bool enableLighting;","uniform vec3 ambientColor;","uniform vec3 directionalColor;","uniform vec3 lightingDirection;","uniform mat4 viewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 normalMatrix;","varying vec4 vcolor;","varying vec3 lightWeighting;","varying vec2 vuv;","void main(void) {","if(!enableLighting) {","lightWeighting = vec3(1.0, 1.0, 1.0);","} else {","vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);","float directionalLightWeighting = max(dot(normalize(transformedNormal.xyz), lightingDirection), 0.0);","lightWeighting = ambientColor + directionalColor * directionalLightWeighting;","}","vcolor = color;","vuv = uv;","gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );","}"].join("\n")));a.linkProgram(h);if(!a.getProgramParameter(h,a.LINK_STATUS)){alert("Could not initialise shaders")}a.useProgram(h);h.viewMatrix=a.getUniformLocation(h,"viewMatrix");h.projectionMatrix=a.getUniformLocation(h,"projectionMatrix");h.normalMatrix=a.getUniformLocation(h,"normalMatrix");h.enableLighting=a.getUniformLocation(h,"enableLighting");h.ambientColor=a.getUniformLocation(h,"ambientColor");h.directionalColor=a.getUniformLocation(h,"directionalColor");h.lightingDirection=a.getUniformLocation(h,"lightingDirection");h.enableTexture=a.getUniformLocation(h,"enableTexture");h.color=a.getAttribLocation(h,"color");a.enableVertexAttribArray(h.color);h.position=a.getAttribLocation(h,"position");a.enableVertexAttribArray(h.position);h.normal=a.getAttribLocation(h,"normal");a.enableVertexAttribArray(h.normal);h.uv=a.getAttribLocation(h,"uv");a.enableVertexAttribArray(h.uv);h.diffuse=a.getUniformLocation(h,"diffuse");a.uniform1i(h.diffuse,0);h.viewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function b(j,i){var k;if(j=="fragment"){k=a.createShader(a.FRAGMENT_SHADER)}else{if(j=="vertex"){k=a.createShader(a.VERTEX_SHADER)}}a.shaderSource(k,i);a.compileShader(k);if(!a.getShaderParameter(k,a.COMPILE_STATUS)){alert(a.getShaderInfoLog(k));return null}return k}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null};
\ No newline at end of file \ No newline at end of file
// ThreeDebug.js r18 - http://github.com/mrdoob/three.js // ThreeDebug.js r18 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=Math.floor(this.a*255)<<24|Math.floor(this.r*255)<<16|Math.floor(this.g*255)<<8|Math.floor(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)<a)&&(Math.abs(this.y)<a)&&(Math.abs(this.z)<a)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,d,c,b){this.x=a||0;this.y=d||0;this.z=c||0;this.w=b||1};THREE.Vector4.prototype={set:function(a,d,c,b){this.x=a;this.y=d;this.z=c;this.w=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;this.w=b.w+a.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;this.w=b.w-a.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Rectangle=function(){var f,h,d,g,a,c,e=true;function b(){a=d-f;c=g-h}this.getX=function(){return f};this.getY=function(){return h};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getX1=function(){return f};this.getY1=function(){return h};this.getX2=function(){return d};this.getY2=function(){return g};this.set=function(j,l,i,k){e=false;f=j;h=l;d=i;g=k;b()};this.addPoint=function(i,j){if(e){e=false;f=i;h=j;d=i;g=j}else{f=Math.min(f,i);h=Math.min(h,j);d=Math.max(d,i);g=Math.max(g,j)}b()};this.addRectangle=function(i){if(e){e=false;f=i.getX1();h=i.getY1();d=i.getX2();g=i.getY2()}else{f=Math.min(f,i.getX1());h=Math.min(h,i.getY1());d=Math.max(d,i.getX2());g=Math.max(g,i.getY2())}b()};this.inflate=function(i){f-=i;h-=i;d+=i;g+=i;b()};this.minSelf=function(i){f=Math.max(f,i.getX1());h=Math.max(h,i.getY1());d=Math.min(d,i.getX2());g=Math.min(g,i.getY2());b()};this.instersects=function(i){return Math.min(d,i.getX2())-Math.max(f,i.getX1())>=0&&Math.min(g,i.getY2())-Math.max(h,i.getY1())>=0};this.empty=function(){e=true;f=0;h=0;d=0;g=0;b()};this.isEmpty=function(){return e};this.toString=function(){return"THREE.Rectangle (x1: "+f+", y1: "+g+", x2: "+d+", y1: "+h+", width: "+a+", height: "+c+")"}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=a-k;b=f-g;l=(o+c)/n;j=(a+k)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g||new THREE.Vector3();this.color=f||new THREE.Color(4278190080)};THREE.Face3.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).divideScalar(3)},toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h||new THREE.Vector3();this.color=g||new THREE.Color(4278190080)};THREE.Face4.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).addSelf(this.d).divideScalar(4)},toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;c<b;c++){a=this.faces[c];a.centroid.set(0,0,0);if(a instanceof THREE.Face3){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.divideScalar(3)}else{if(a instanceof THREE.Face4){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.addSelf(this.vertices[a.d].position);a.centroid.divideScalar(4)}}}},computeNormals:function(){var k,d,g,h,j,i,c,b,a,e=new THREE.Vector3(),l=new THREE.Vector3();for(k=0,d=this.vertices.length;k<d;k++){g=this.vertices[k];g.normal.set(0,0,0)}for(h=0,j=this.faces.length;h<j;h++){i=this.faces[h];c=this.vertices[i.a];b=this.vertices[i.b];a=this.vertices[i.c];e.sub(a.position,b.position);l.sub(c.position,b.position);e.crossSelf(l);if(!e.isZero()){e.normalize()}i.normal.copy(e)}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){this.fov=c;this.aspect=b;this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(255<<24|a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light();THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,0,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.PointLight;THREE.Object3D=function(a){this.position=new THREE.Vector3();this.rotation=new THREE.Vector3();this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4();this.matrixTranslation=new THREE.Matrix4();this.matrixRotation=new THREE.Matrix4();this.matrixScale=new THREE.Matrix4();this.screen=new THREE.Vector3();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D();THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a]};THREE.Line.prototype=new THREE.Object3D();THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a];this.flipSided=false;this.doubleSided=false;this.overdraw=false};THREE.Mesh.prototype=new THREE.Object3D();THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.LineColorMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshBitmapUVMappingMaterial=function(a){this.bitmap=a;this.toString=function(){return"THREE.MeshBitmapUVMappingMaterial ( bitmap: "+this.bitmap+" )"}};THREE.MeshColorFillMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.MeshColorFillMaterial ( color: "+this.color+" )"}};THREE.MeshColorStrokeMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c);this.toString=function(){return"THREE.MeshColorStrokeMaterial ( lineWidth: "+this.lineWidth+", color: "+this.color+" )"}};THREE.MeshFaceColorFillMaterial=function(){this.toString=function(){return"THREE.MeshFaceColorFillMaterial ( )"}};THREE.MeshFaceColorStrokeMaterial=function(a){this.lineWidth=a||1;this.toString=function(){return"THREE.MeshFaceColorStrokeMaterial ( lineWidth: "+this.lineWidth+" )"}};THREE.ParticleBitmapMaterial=function(a){this.bitmap=a;this.offset=new THREE.Vector2();this.toString=function(){return"THREE.ParticleBitmapMaterial ( bitmap: "+this.bitmap+" )"}};THREE.ParticleCircleMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.ParticleCircleMaterial ( color: "+this.color+" )"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(b){for(var c=0,a=this.objects.length;c<a;c++){if(b==this.objects[c]){this.objects.splice(c,1);return}}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(b){for(var c=0,a=this.lights.length;c<a;c++){if(b==this.lights[c]){this.lights.splice(c,1);return}}};this.add=function(a){this.addObject(a)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,q,o=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),p=new THREE.Matrix4();this.projectScene=function(K,H){var G,F,E,L,J,C,s,M,r,A,I,w,D,x,B,z,y,u,t;e=[];q=0,f=0,m=0,h=0;if(H.autoUpdateMatrix){H.updateMatrix()}d.multiply(H.projectionMatrix,H.matrix);s=K.objects;for(G=0,F=s.length;G<F;G++){M=s[G];r=M.matrix;if(M.autoUpdateMatrix){M.updateMatrix()}if(M instanceof THREE.Mesh){p.multiply(d,r);A=M.geometry.vertices;for(E=0,L=A.length;E<L;E++){I=A[E];w=I.positionScreen;w.copy(I.position);p.transform(w);I.__visible=w.z>0&&w.z<1}x=M.geometry.faces;for(J=0,C=x.length;J<C;J++){B=x[J];if(B instanceof THREE.Face3){z=A[B.a];y=A[B.b];u=A[B.c];if(z.__visible&&y.__visible&&u.__visible){if((M.doubleSided||(M.flipSided!=(u.positionScreen.x-z.positionScreen.x)*(y.positionScreen.y-z.positionScreen.y)-(u.positionScreen.y-z.positionScreen.y)*(y.positionScreen.x-z.positionScreen.x)<0))){c=o[q]=o[q]||new THREE.RenderableFace3();c.v1.copy(z.positionScreen);c.v2.copy(y.positionScreen);c.v3.copy(u.positionScreen);c.centroidWorld.copy(B.centroid);M.matrix.transform(c.centroidWorld);c.normalWorld.copy(B.normal);M.matrixRotation.transform(c.normalWorld);c.z=Math.max(z.positionScreen.z,Math.max(y.positionScreen.z,u.positionScreen.z));c.material=M.material;c.overdraw=M.overdraw;c.uvs=M.geometry.uvs[J];c.color=B.color;e.push(c);q++}}}else{if(B instanceof THREE.Face4){z=A[B.a];y=A[B.b];u=A[B.c];t=A[B.d];if(z.__visible&&y.__visible&&u.__visible&&t.__visible){if((M.doubleSided||(M.flipSided!=((t.positionScreen.x-z.positionScreen.x)*(y.positionScreen.y-z.positionScreen.y)-(t.positionScreen.y-z.positionScreen.y)*(y.positionScreen.x-z.positionScreen.x)<0||(y.positionScreen.x-u.positionScreen.x)*(t.positionScreen.y-u.positionScreen.y)-(y.positionScreen.y-u.positionScreen.y)*(t.positionScreen.x-u.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.copy(z.positionScreen);b.v2.copy(y.positionScreen);b.v3.copy(u.positionScreen);b.v4.copy(t.positionScreen);b.centroidWorld.copy(B.centroid);M.matrix.transform(b.centroidWorld);b.normalWorld.copy(B.normal);M.matrixRotation.transform(b.normalWorld);b.z=Math.max(z.positionScreen.z,Math.max(y.positionScreen.z,Math.max(u.positionScreen.z,t.positionScreen.z)));b.material=M.material;b.overdraw=M.overdraw;b.uvs=M.geometry.uvs[J];b.color=B.color;e.push(b);f++}}}}}}else{if(M instanceof THREE.Line){p.multiply(d,r);A=M.geometry.vertices;for(E=0,L=A.length;E<L;E++){I=A[E];w=I.positionScreen;w.copy(I.position);p.transform(w);I.__visible=w.z>0&&w.z<1;if(E>0){D=M.geometry.vertices[E-1];if(I.__visible&&D.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(I.positionScreen);k.v2.copy(D.positionScreen);k.z=Math.max(I.positionScreen.z,D.positionScreen.z);k.material=M.material;e.push(k);m++}}}}else{if(M instanceof THREE.Particle){g.set(M.position.x,M.position.y,M.position.z,1);H.matrix.transform(g);H.projectionMatrix.transform(g);M.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(M.screen.z>0&&M.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=M.screen.x;j.y=M.screen.y;j.z=M.screen.z;j.rotation=M.rotation.z;j.scale.x=M.scale.x*Math.abs(g.x/g.w-(g.x+H.projectionMatrix.n11)/(g.w+H.projectionMatrix.n14));j.scale.y=M.scale.y*Math.abs(g.y/g.w-(g.y+H.projectionMatrix.n22)/(g.w+H.projectionMatrix.n24));j.material=M.material;j.color=M.color;e.push(j);h++}}}}}e.sort(n);return e};function n(s,r){return r.z-s.z}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;q<h;q++){o=e[q];if(o instanceof THREE.RenderableParticle){k=o.x*f+f;j=o.y*d+d;for(i=0,n=o.material.length;i<n;i++){s=o.material[i];if(s instanceof THREE.ParticleDOMMaterial){l=s.domElement;l.style.left=k+"px";l.style.top=j+"px"}}}}}};THREE.CanvasRenderer=function(){var u=null,o=new THREE.Projector(),m=document.createElement("canvas"),n=m.getContext("2d"),h,z,k,c,y=new THREE.Rectangle(),j=new THREE.Rectangle(),s=new THREE.Rectangle(),i=new THREE.Color(4294967295),q=new THREE.Color(4294967295),e=new THREE.Color(4294967295),g=new THREE.Vector2(),f=new THREE.Vector3(),d=new THREE.Vector2(),a=new THREE.Vector2(),x=new THREE.UV(),w=new THREE.UV(),t=new THREE.UV(),r=new THREE.UV();this.domElement=m;this.autoClear=true;this.setSize=function(B,A){h=B;z=A;k=h/2;c=z/2;m.width=h;m.height=z;y.set(-k,-c,k,c)};this.clear=function(){if(!j.isEmpty()){j.inflate(1);j.minSelf(y);n.setTransform(1,0,0,-1,k,c);n.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());j.empty()}};this.render=function(aa,V){var Z,D,F,P,W,L,N=Math.PI*2,H,G,T,R,C,A,J,I,U,S,E,B,O,M,ac,ab,Y,X,ad,K,Q;if(this.autoClear){this.clear()}u=o.projectScene(aa,V);n.setTransform(1,0,0,-1,k,c);n.fillStyle="rgba(0, 255, 255, 0.5)";n.fillRect(y.getX(),y.getY(),y.getWidth(),y.getHeight());v(aa,e);for(Z=0,D=u.length;Z<D;Z++){F=u[Z];s.empty();if(F instanceof THREE.RenderableParticle){H=F.x*k;G=F.y*c;for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.ParticleCircleMaterial){q.copyRGB(e);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();O=F.scale.x*k;M=F.scale.y*c;s.set(H-O,G-M,H+O,G+M);if(!y.instersects(s)){continue}n.save();n.translate(H,G);n.rotate(-F.rotation);n.scale(O,M);n.beginPath();n.arc(0,0,1,0,N,true);n.closePath();n.fillStyle=i.__styleString;n.fill();n.restore()}else{if(L instanceof THREE.ParticleBitmapMaterial){ad=L.bitmap;K=ad.width/2;Q=ad.height/2;ac=F.scale.x*k;ab=F.scale.y*c;O=ac*K;M=ab*Q;Y=L.offset.x*ac;X=L.offset.y*ab;s.set(H+Y-O,G+X-M,H+Y+O,G+X+M);if(!y.instersects(s)){continue}n.save();n.translate(H,G);n.rotate(-F.rotation);n.scale(ac,-ab);n.translate(-K+L.offset.x,-Q-L.offset.y);n.drawImage(ad,0,0);n.restore();n.beginPath();n.moveTo(H-10,G);n.lineTo(H+10,G);n.moveTo(H,G-10);n.lineTo(H,G+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}}}}else{if(F instanceof THREE.RenderableLine){H=F.v1.x*k;G=F.v1.y*c;T=F.v2.x*k;R=F.v2.y*c;s.addPoint(H,G);s.addPoint(T,R);if(!y.instersects(s)){continue}n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.closePath();for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.LineColorMaterial){q.copyRGB(e);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}}}else{if(F instanceof THREE.RenderableFace3){F.v1.x*=k;F.v1.y*=c;F.v2.x*=k;F.v2.y*=c;F.v3.x*=k;F.v3.y*=c;if(F.overdraw){b(F.v1,F.v2);b(F.v2,F.v3);b(F.v3,F.v1)}H=F.v1.x;G=F.v1.y;T=F.v2.x;R=F.v2.y;C=F.v3.x;A=F.v3.y;s.addPoint(H,G);s.addPoint(T,R);s.addPoint(C,A);if(!y.instersects(s)){continue}for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.MeshColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshFaceColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshFaceColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshBitmapUVMappingMaterial){ad=L.bitmap;K=ad.width-1;Q=ad.height-1;if(!F.uvs[0]||!F.uvs[1]||!F.uvs[2]){n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.fillStyle="rgb(0, 255, 0)";n.fill();continue}x.copy(F.uvs[0]);w.copy(F.uvs[1]);t.copy(F.uvs[2]);x.u*=K;x.v*=Q;w.u*=K;w.v*=Q;t.u*=K;t.v*=Q;p(ad,H,G,T,R,C,A,x.u,x.v,w.u,w.v,t.u,t.v)}}}}}}}else{if(F instanceof THREE.RenderableFace4){F.v1.x*=k;F.v1.y*=c;F.v2.x*=k;F.v2.y*=c;F.v3.x*=k;F.v3.y*=c;F.v4.x*=k;F.v4.y*=c;d.copy(F.v2);a.copy(F.v4);if(F.overdraw){b(F.v1,F.v2);b(F.v2,F.v4);b(F.v4,F.v1)}H=F.v1.x;G=F.v1.y;T=F.v2.x;R=F.v2.y;J=F.v4.x;I=F.v4.y;if(F.overdraw){b(F.v3,d);b(F.v3,a)}C=F.v3.x;A=F.v3.y;U=d.x;S=d.y;E=a.x;B=a.y;s.addPoint(H,G);s.addPoint(T,R);s.addPoint(C,A);s.addPoint(J,I);if(!y.instersects(s)){continue}for(P=0,W=F.material.length;P<W;P++){L=F.material[P];if(L instanceof THREE.MeshColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(L.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshFaceColorFillMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.fillStyle=i.__styleString;n.fill()}else{if(L instanceof THREE.MeshFaceColorStrokeMaterial){q.copyRGB(e);l(aa,F,q);i.copyRGBA(F.color);i.multiplySelfRGB(q);i.updateStyleString();n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.lineWidth=L.lineWidth;n.lineJoin="round";n.lineCap="round";n.strokeStyle=i.__styleString;n.stroke();s.inflate(n.lineWidth)}else{if(L instanceof THREE.MeshBitmapUVMappingMaterial){ad=L.bitmap;K=ad.width-1;Q=ad.height-1;if(!F.uvs[0]||!F.uvs[1]||!F.uvs[2]||!F.uvs[3]){n.beginPath();n.moveTo(H,G);n.lineTo(T,R);n.lineTo(C,A);n.lineTo(J,I);n.lineTo(H,G);n.closePath();n.fillStyle="rgb(255, 0, 255)";n.fill();continue}x.copy(F.uvs[0]);w.copy(F.uvs[1]);t.copy(F.uvs[2]);r.copy(F.uvs[3]);x.u*=K;x.v*=Q;w.u*=K;w.v*=Q;t.u*=K;t.v*=Q;r.u*=K;r.v*=Q;p(ad,H,G,T,R,J,I,x.u,x.v,w.u,w.v,r.u,r.v);p(ad,U,S,C,A,E,B,w.u,w.v,t.u,t.v,r.u,r.v)}}}}}}}}}}j.addRectangle(s)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());n.setTransform(1,0,0,1,0,0)};function v(E,C){var B,D,A;C.setRGBA(1,1,1,1);for(B=0,D=E.lights.length;B<D;B++){A=E.lights[B];if(A instanceof THREE.AmbientLight){C.r*=A.color.r;C.g*=A.color.g;C.b*=A.color.b}}}function l(G,E,C){var B,F,A,D;for(B=0,F=G.lights.length;B<F;B++){A=G.lights[B];if(A instanceof THREE.DirectionalLight){D=E.normalWorld.dot(A.position)*A.intensity;if(D>0){C.r+=A.color.r*D;C.g+=A.color.g*D;C.b+=A.color.b*D}}else{if(A instanceof THREE.PointLight){f.sub(A.position,E.centroidWorld);f.normalize();D=E.normalWorld.dot(f)*A.intensity;if(D>0){C.r+=A.color.r*D;C.g+=A.color.g*D;C.b+=A.color.b*D}}}}}function p(T,I,H,O,N,C,A,Q,P,E,D,M,L){var B,S,R,G,F,K,J;n.beginPath();n.moveTo(I,H);n.lineTo(O,N);n.lineTo(C,A);n.lineTo(I,H);n.closePath();n.save();n.clip();B=Q*(L-D)-E*L+M*D+(E-M)*P;S=-(P*(C-O)-D*C+L*O+(D-L)*I)/B;R=(D*A+P*(N-A)-L*N+(L-D)*H)/B;G=(Q*(C-O)-E*C+M*O+(E-M)*I)/B;F=-(E*A+Q*(N-A)-M*N+(M-E)*H)/B;K=(Q*(L*O-D*C)+P*(E*C-M*O)+(M*D-E*L)*I)/B;J=(Q*(L*N-D*A)+P*(E*A-M*N)+(M*D-E*L)*H)/B;n.transform(S,R,G,F,K,J);n.drawImage(T,0,0);n.restore()}function b(B,A){g.sub(A,B);g.unit();g.multiplyScalar(0.75);A.addSelf(g);B.subSelf(g)}};THREE.SVGRenderer=function(){var p=null,k=new THREE.Projector(),l=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,t,i,a,r=new THREE.Rectangle(),o=new THREE.Rectangle(),f=new THREE.Color(4294967295),n=new THREE.Color(4294967295),b=new THREE.Color(4294967295),d=new THREE.Vector3(),c=[],g=[],s=1;this.domElement=l;this.autoClear=true;this.setQuality=function(u){switch(u){case"high":s=1;break;case"low":s=0;break}};this.setSize=function(v,u){e=v;t=u;i=e/2;a=t/2;l.setAttribute("viewBox",(-i)+" "+(-a)+" "+e+" "+t);l.setAttribute("width",e);l.setAttribute("height",t);r.set(-i,-a,i,a)};this.clear=function(){while(l.childNodes.length>0){l.removeChild(l.childNodes[0])}};this.render=function(N,K){var M,w,H,L,x,D,G=0,y=0,E,B,z,J,I,v,u,C,A,F;if(this.autoClear){this.clear()}p=k.projectScene(N,K);q(N,b);for(M=0,w=p.length;M<w;M++){x=p[M];for(H=0,L=x.material.length;H<L;H++){D=x.material[H];o.empty();if(x instanceof THREE.RenderableParticle){B=x.x*i;z=x.y*-a;F=x.size*i;o.set(B-F,z-F,B+F,z+F);if(!r.instersects(o)){continue}E=m(y++);E.setAttribute("cx",B);E.setAttribute("cy",z);E.setAttribute("r",F)}else{if(x instanceof THREE.RenderableFace3){B=x.v1.x*i;z=x.v1.y*-a;J=x.v2.x*i;I=x.v2.y*-a;v=x.v3.x*i;u=x.v3.y*-a;o.addPoint(B,z);o.addPoint(J,I);o.addPoint(v,u);if(!r.instersects(o)){continue}E=h(G++);E.setAttribute("d","M "+B+" "+z+" L "+J+" "+I+" L "+v+","+u+"z")}else{if(x instanceof THREE.RenderableFace4){B=x.v1.x*i;z=x.v1.y*-a;J=x.v2.x*i;I=x.v2.y*-a;v=x.v3.x*i;u=x.v3.y*-a;C=x.v4.x*i;A=x.v4.y*-a;o.addPoint(B,z);o.addPoint(J,I);o.addPoint(v,u);o.addPoint(C,A);if(!r.instersects(o)){continue}E=h(G++);E.setAttribute("d","M "+B+" "+z+" L "+J+" "+I+" L "+v+","+u+" L "+C+","+A+"z")}}}if(D instanceof THREE.MeshColorFillMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(D.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: "+f.__styleString)}else{if(D instanceof THREE.MeshFaceColorFillMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(x.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: "+f.__styleString)}else{if(D instanceof THREE.MeshColorStrokeMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(D.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+D.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}else{if(D instanceof THREE.MeshFaceColorStrokeMaterial){n.copyRGB(b);j(N,x,n);f.copyRGBA(x.color);f.multiplySelfRGB(n);f.updateStyleString();E.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+D.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}}}l.appendChild(E)}}};function q(y,w){var v,x,u;w.setRGBA(1,1,1,1);for(v=0,x=y.lights.length;v<x;v++){u=y.lights[v];if(u instanceof THREE.AmbientLight){w.r*=u.color.r;w.g*=u.color.g;w.b*=u.color.b}}}function j(A,y,w){var v,z,u,x;for(v=0,z=A.lights.length;v<z;v++){u=A.lights[v];if(u instanceof THREE.DirectionalLight){x=y.normalWorld.dot(u.position)*u.intensity;if(x>0){w.r+=u.color.r*x;w.g+=u.color.g*x;w.b+=u.color.b*x}}else{if(u instanceof THREE.PointLight){d.sub(u.position,y.centroidWorld);d.normalize();x=y.normalWorld.dot(d)*u.intensity;if(x>0){w.r+=u.color.r*x;w.g+=u.color.g*x;w.b+=u.color.b*x}}}}}function h(u){if(c[u]==null){c[u]=document.createElementNS("http://www.w3.org/2000/svg","path");if(s==0){c[u].setAttribute("shape-rendering","crispEdges")}return c[u]}return c[u]}function m(u){if(g[u]==null){g[u]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(s==0){g[u].setAttribute("shape-rendering","crispEdges")}return g[u]}return g[u]}};THREE.WebGLRenderer=function(){var e=document.createElement("canvas"),a,h,d=new THREE.Matrix4(),g;this.domElement=e;this.autoClear=true;f();c();this.setSize=function(j,i){e.width=j;e.height=i;a.viewport(0,0,e.width,e.height)};this.clear=function(){a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)};this.render=function(K,G){var t,L,N,z,M,C,s,q,y,A,r,J,w,B,x,I,u,D,H,F,p,n,k,j,E,v;if(this.autoClear){this.clear()}a.uniform1i(h.enableLighting,K.lights.length);for(E=0,v=K.lights.length;E<v;E++){q=K.lights[E];if(q instanceof THREE.AmbientLight){C=q.color;a.uniform3f(h.ambientColor,C.r,C.g,C.b)}else{if(q instanceof THREE.DirectionalLight){C=q.color;s=q.position;a.uniform3f(h.lightingDirection,s.x,s.y,s.z);a.uniform3f(h.directionalColor,C.r,C.g,C.b)}}}for(B=0,x=K.objects.length;B<x;B++){N=K.objects[B];if(N instanceof THREE.Mesh){if(!N.__webGLVertexBuffer){y=[];A=[];r=[];J=[];w=0;for(I=0,u=N.geometry.faces.length;I<u;I++){t=N.geometry.faces[I];L=t.color;M=t.normal;if(t instanceof THREE.Face3){p=N.geometry.vertices[t.a].position;n=N.geometry.vertices[t.b].position;k=N.geometry.vertices[t.c].position;y.push(p.x,p.y,p.z);y.push(n.x,n.y,n.z);y.push(k.x,k.y,k.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);A.push(w,w+1,w+2);w+=3}else{if(t instanceof THREE.Face4){p=N.geometry.vertices[t.a].position;n=N.geometry.vertices[t.b].position;k=N.geometry.vertices[t.c].position;j=N.geometry.vertices[t.d].position;y.push(p.x,p.y,p.z);y.push(n.x,n.y,n.z);y.push(k.x,k.y,k.z);y.push(j.x,j.y,j.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);J.push(M.x,M.y,M.z);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);r.push(L.r,L.g,L.b,L.a);A.push(w,w+1,w+2);A.push(w,w+2,w+3);w+=4}}}if(!y.length){continue}N.__webGLVertexBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLVertexBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(y),a.STATIC_DRAW);N.__webGLNormalBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLNormalBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(J),a.STATIC_DRAW);N.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,N.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(r),a.STATIC_DRAW);N.__webGLFaceBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),a.STATIC_DRAW);N.__webGLFaceCount=A.length}d.multiply(G.matrix,N.matrix);h.viewMatrixArray=new Float32Array(d.flatten());h.projectionMatrixArray=new Float32Array(G.projectionMatrix.flatten());g=THREE.Matrix4.makeInvert(d).transpose();h.normalMatrixArray=new Float32Array(g.flatten());a.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);a.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);a.uniformMatrix4fv(h.normalMatrix,false,h.normalMatrixArray);a.bindBuffer(a.ARRAY_BUFFER,N.__webGLVertexBuffer);a.vertexAttribPointer(h.position,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,N.__webGLNormalBuffer);a.vertexAttribPointer(h.normal,3,a.FLOAT,false,0,0);for(D=0,H=N.material.length;D<H;D++){z=N.material[D];if(z instanceof THREE.MeshColorFillMaterial){if(!z.__webGLColorBuffer){r=[];for(F=0;F<N.__webGLFaceCount;F++){r.push(z.color.r,z.color.g,z.color.b,z.color.a)}z.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,z.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(r),a.STATIC_DRAW)}a.bindBuffer(a.ARRAY_BUFFER,z.__webGLColorBuffer);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0)}else{if(z instanceof THREE.MeshFaceColorFillMaterial){a.bindBuffer(a.ARRAY_BUFFER,N.__webGLColorBuffer);a.enableVertexAttribArray(h.color);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0)}}}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);a.drawElements(a.TRIANGLES,N.__webGLFaceCount,a.UNSIGNED_SHORT,0)}}};function f(){try{a=e.getContext("experimental-webgl")}catch(i){}if(!a){alert("WebGL not supported");throw"cannot create webgl context"}a.clearColor(0,0,0,1);a.clearDepth(1);a.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.enable(a.BLEND);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA);a.clearColor(0,0,0,0)}function c(){h=a.createProgram();a.attachShader(h,b("fragment",["#ifdef GL_ES","precision highp float;","#endif","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(){","gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);","}"].join("\n")));a.attachShader(h,b("vertex",["attribute vec3 position;","attribute vec3 normal;","attribute vec4 color;","uniform bool enableLighting;","uniform vec3 ambientColor;","uniform vec3 directionalColor;","uniform vec3 lightingDirection;","uniform mat4 viewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 normalMatrix;","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(void) {","if(!enableLighting) {","lightWeighting = vec3(1.0, 1.0, 1.0);","} else {","vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);","float directionalLightWeighting = max(dot(transformedNormal.xyz, lightingDirection), 0.0);","lightWeighting = ambientColor + directionalColor * directionalLightWeighting;","}","vcolor = color;","gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );","}"].join("\n")));a.linkProgram(h);if(!a.getProgramParameter(h,a.LINK_STATUS)){alert("Could not initialise shaders")}a.useProgram(h);h.viewMatrix=a.getUniformLocation(h,"viewMatrix");h.projectionMatrix=a.getUniformLocation(h,"projectionMatrix");h.normalMatrix=a.getUniformLocation(h,"normalMatrix");h.enableLighting=a.getUniformLocation(h,"enableLighting");h.ambientColor=a.getUniformLocation(h,"ambientColor");h.directionalColor=a.getUniformLocation(h,"directionalColor");h.lightingDirection=a.getUniformLocation(h,"lightingDirection");h.color=a.getAttribLocation(h,"color");a.enableVertexAttribArray(h.color);h.position=a.getAttribLocation(h,"position");a.enableVertexAttribArray(h.position);h.normal=a.getAttribLocation(h,"normal");a.enableVertexAttribArray(h.normal);h.viewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function b(j,i){var k;if(j=="fragment"){k=a.createShader(a.FRAGMENT_SHADER)}else{if(j=="vertex"){k=a.createShader(a.VERTEX_SHADER)}}a.shaderSource(k,i);a.compileShader(k);if(!a.getShaderParameter(k,a.COMPILE_STATUS)){alert(a.getShaderInfoLog(k));return null}return k}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null}; var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=a;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},copyRGB:function(a){this.r=a.r;this.g=a.g;this.b=a.b},copyRGBA:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a},multiplySelfRGB:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b},updateHex:function(){this.hex=Math.floor(this.a*255)<<24|Math.floor(this.r*255)<<16|Math.floor(this.g*255)<<8|Math.floor(this.b*255)},updateRGBA:function(){this.a=(this.hex>>24&255)/255;this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgba("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+","+this.a+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", a: "+this.a+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},cross:function(b,a){this.x=b.y*a.z-b.z*a.y;this.y=b.z*a.x-b.x*a.z;this.z=b.x*a.y-b.y*a.x;return this},crossSelf:function(c){var b=this.x,a=this.y,d=this.z;this.x=a*c.z-d*c.y;this.y=d*c.x-b*c.z;this.z=b*c.y-a*c.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(d){var c=this.x-d.x,b=this.y-d.y,a=this.z-d.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){if(this.length()>0){this.multiplyScalar(1/this.length())}else{this.multiplyScalar(0)}return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){var a=0.0001;return(Math.abs(this.x)<a)&&(Math.abs(this.y)<a)&&(Math.abs(this.z)<a)},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,d,c,b){this.x=a||0;this.y=d||0;this.z=c||0;this.w=b||1};THREE.Vector4.prototype={set:function(a,d,c,b){this.x=a;this.y=d;this.z=c;this.w=b;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},add:function(b,a){this.x=b.x+a.x;this.y=b.y+a.y;this.z=b.z+a.z;this.w=b.w+a.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(b,a){this.x=b.x-a.x;this.y=b.y-a.y;this.z=b.z-a.z;this.w=b.w-a.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};THREE.Rectangle=function(){var f,h,d,g,a,c,e=true;function b(){a=d-f;c=g-h}this.getX=function(){return f};this.getY=function(){return h};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getX1=function(){return f};this.getY1=function(){return h};this.getX2=function(){return d};this.getY2=function(){return g};this.set=function(j,m,i,k){e=false;f=j;h=m;d=i;g=k;b()};this.addPoint=function(i,j){if(e){e=false;f=i;h=j;d=i;g=j}else{f=Math.min(f,i);h=Math.min(h,j);d=Math.max(d,i);g=Math.max(g,j)}b()};this.addRectangle=function(i){if(e){e=false;f=i.getX1();h=i.getY1();d=i.getX2();g=i.getY2()}else{f=Math.min(f,i.getX1());h=Math.min(h,i.getY1());d=Math.max(d,i.getX2());g=Math.max(g,i.getY2())}b()};this.inflate=function(i){f-=i;h-=i;d+=i;g+=i;b()};this.minSelf=function(i){f=Math.max(f,i.getX1());h=Math.max(h,i.getY1());d=Math.min(d,i.getX2());g=Math.min(g,i.getY2());b()};this.instersects=function(i){return Math.min(d,i.getX2())-Math.max(f,i.getX1())>=0&&Math.min(g,i.getY2())-Math.max(h,i.getY1())>=0};this.empty=function(){e=true;f=0;h=0;d=0;g=0;b()};this.isEmpty=function(){return e};this.toString=function(){return"THREE.Rectangle (x1: "+f+", y1: "+g+", x2: "+d+", y1: "+h+", width: "+a+", height: "+c+")"}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var p=this.n11,o=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,s=this.n32,r=this.n33,q=this.n34,n=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=p*c.n11+o*c.n21+k*c.n31+i*c.n41;this.n12=p*c.n12+o*c.n22+k*c.n32+i*c.n42;this.n13=p*c.n13+o*c.n23+k*c.n33+i*c.n43;this.n14=p*c.n14+o*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+s*c.n21+r*c.n31+q*c.n41;this.n32=a*c.n12+s*c.n22+r*c.n32+q*c.n42;this.n33=a*c.n13+s*c.n23+r*c.n33+q*c.n43;this.n34=a*c.n14+s*c.n24+r*c.n34+q*c.n44;this.n41=n*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=n*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=n*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=n*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeFrustum=function(f,s,e,p,i,h){var g,r,o,q,n,k,j;g=new THREE.Matrix4();r=2*i/(s-f);o=2*i/(p-e);q=(s+f)/(s-f);n=(p+e)/(p-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=r;g.n12=0;g.n13=q;g.n14=0;g.n21=0;g.n22=o;g.n23=n;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,q,k,a,g,f){var d,n,j,i,o,e,b;d=new THREE.Matrix4();o=q-c;e=a-k;b=f-g;n=(q+c)/o;j=(a+k)/e;i=(f+g)/b;d.n11=2/o;d.n12=0;d.n13=0;d.n14=-n;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,i,h,f,g){this.a=e;this.b=d;this.c=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.color=f||new THREE.Color(4278190080);this.vertexNormals=h instanceof Array?h:[];this.material=g||0};THREE.Face3.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).divideScalar(3)},toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,k,j,i,g,h){this.a=f;this.b=e;this.c=k;this.d=j;this.centroid=new THREE.Vector3();this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3();this.color=g||new THREE.Color(4278190080);this.vertexNormals=i instanceof Array?i:[];this.material=h||0};THREE.Face4.prototype={getCenter:function(){return this.a.clone().addSelf(this.b).addSelf(this.c).addSelf(this.d).divideScalar(4)},toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;c<b;c++){a=this.faces[c];a.centroid.set(0,0,0);if(a instanceof THREE.Face3){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.divideScalar(3)}else{if(a instanceof THREE.Face4){a.centroid.addSelf(this.vertices[a.a].position);a.centroid.addSelf(this.vertices[a.b].position);a.centroid.addSelf(this.vertices[a.c].position);a.centroid.addSelf(this.vertices[a.d].position);a.centroid.divideScalar(4)}}}},computeNormals:function(o){var e,b,p,g,i,j,m,k,d,c,a,h=new THREE.Vector3(),q=new THREE.Vector3();for(p=0,g=this.vertices.length;p<g;p++){i=this.vertices[p];i.normal.set(0,0,0)}for(j=0,m=this.faces.length;j<m;j++){k=this.faces[j];if(o&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.x+=k.vertexNormals[e].x;h.y+=k.vertexNormals[e].y;h.z+=k.vertexNormals[e].z}h.x/=3;h.y/=3;h.z/=3;if(!h.isZero()){h.normalize()}k.normal.copy(h)}else{d=this.vertices[k.a];c=this.vertices[k.b];a=this.vertices[k.c];h.sub(a.position,c.position);q.sub(d.position,c.position);h.crossSelf(q);if(!h.isZero()){h.normalize()}k.normal.copy(h)}}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};var a,b;for(a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0]){this.bbox.x[0]=vertex.position.x}else{if(vertex.position.x>this.bbox.x[1]){this.bbox.x[1]=vertex.position.x}}if(vertex.position.y<this.bbox.y[0]){this.bbox.y[0]=vertex.position.y}else{if(vertex.position.y>this.bbox.y[1]){this.bbox.y[1]=vertex.position.y}}if(vertex.position.z<this.bbox.z[0]){this.bbox.z[0]=vertex.position.z}else{if(vertex.position.z>this.bbox.z[1]){this.bbox.z[1]=vertex.position.z}}}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};THREE.Camera=function(c,b,d,a){this.fov=c;this.aspect=b;this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(255<<24|a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light();THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,a){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,0,0);this.intensity=a||1};THREE.DirectionalLight.prototype=new THREE.Light();THREE.DirectionalLight.prototype.constructor=THREE.PointLight;THREE.Object3D=function(a){this.position=new THREE.Vector3();this.rotation=new THREE.Vector3();this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4();this.matrixTranslation=new THREE.Matrix4();this.matrixRotation=new THREE.Matrix4();this.matrixScale=new THREE.Matrix4();this.screen=new THREE.Vector3();this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.matrixRotation=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.matrixRotation.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.matrixRotation.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.matrixScale=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.matrixRotation);this.matrix.multiplySelf(this.matrixScale)}};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D();THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(b,a){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a]};THREE.Line.prototype=new THREE.Object3D();THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(b,a,c){THREE.Object3D.call(this);this.geometry=b;this.material=a instanceof Array?a:[a];this.flipSided=false;this.doubleSided=false;this.overdraw=false;this.materialFaces={};this.sortFacesByMaterial();if(c){this.normalizeUVs()}this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D();THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.sortFacesByMaterial=function(){var d,c,b,a;for(d=0,c=this.geometry.faces.length;d<c;d++){b=this.geometry.faces[d];a=b.material;if(this.materialFaces[a]==undefined){this.materialFaces[a]={faces:[]}}this.materialFaces[a].faces.push(d)}};THREE.Mesh.prototype.normalizeUVs=function(){var c,a;for(c=0,l=this.geometry.uvs.length;c<l;c++){var b=this.geometry.uvs[c];for(a=0,jl=b.length;a<jl;a++){if(b[a].u!=1){b[a].u=b[a].u-Math.floor(b[a].u)}if(b[a].v!=1){b[a].v=b[a].v-Math.floor(b[a].v)}}}};THREE.LineColorMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c)};THREE.LineColorMaterial.prototype={toString:function(){return"THREE.LineColorMaterial ( color: "+this.color+", lineWidth: "+this.lineWidth+" )"}};THREE.MeshBitmapUVMappingMaterial=function(a){this.bitmap=a;this.toString=function(){return"THREE.MeshBitmapUVMappingMaterial ( bitmap: "+this.bitmap+" )"}};THREE.MeshColorFillMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.MeshColorFillMaterial ( color: "+this.color+" )"}};THREE.MeshColorStrokeMaterial=function(c,b,a){this.lineWidth=a||1;this.color=new THREE.Color((b>=0?(b*255)<<24:4278190080)|c);this.toString=function(){return"THREE.MeshColorStrokeMaterial ( lineWidth: "+this.lineWidth+", color: "+this.color+" )"}};THREE.MeshFaceColorFillMaterial=function(){this.toString=function(){return"THREE.MeshFaceColorFillMaterial ( )"}};THREE.MeshFaceColorStrokeMaterial=function(a){this.lineWidth=a||1;this.toString=function(){return"THREE.MeshFaceColorStrokeMaterial ( lineWidth: "+this.lineWidth+" )"}};THREE.ParticleBitmapMaterial=function(a){this.bitmap=a;this.offset=new THREE.Vector2();this.toString=function(){return"THREE.ParticleBitmapMaterial ( bitmap: "+this.bitmap+" )"}};THREE.ParticleCircleMaterial=function(b,a){this.color=new THREE.Color((a>=0?(a*255)<<24:4278190080)|b);this.toString=function(){return"THREE.ParticleCircleMaterial ( color: "+this.color+" )"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(b){for(var c=0,a=this.objects.length;c<a;c++){if(b==this.objects[c]){this.objects.splice(c,1);return}}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(b){for(var c=0,a=this.lights.length;c<a;c++){if(b==this.lights[c]){this.lights.splice(c,1);return}}};this.add=function(a){this.addObject(a)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,r,p=[],b,f,m=[],k,n,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),q=new THREE.Matrix4();this.projectScene=function(L,I){var H,G,F,M,K,D,t,N,s,B,J,x,E,y,C,A,z,w,u;e=[];r=0,f=0,n=0,h=0;if(I.autoUpdateMatrix){I.updateMatrix()}d.multiply(I.projectionMatrix,I.matrix);t=L.objects;for(H=0,G=t.length;H<G;H++){N=t[H];s=N.matrix;if(N.autoUpdateMatrix){N.updateMatrix()}if(N instanceof THREE.Mesh){q.multiply(d,s);B=N.geometry.vertices;for(F=0,M=B.length;F<M;F++){J=B[F];x=J.positionScreen;x.copy(J.position);q.transform(x);J.__visible=x.z>0&&x.z<1}y=N.geometry.faces;for(K=0,D=y.length;K<D;K++){C=y[K];if(C instanceof THREE.Face3){A=B[C.a];z=B[C.b];w=B[C.c];if(A.__visible&&z.__visible&&w.__visible){if((N.doubleSided||(N.flipSided!=(w.positionScreen.x-A.positionScreen.x)*(z.positionScreen.y-A.positionScreen.y)-(w.positionScreen.y-A.positionScreen.y)*(z.positionScreen.x-A.positionScreen.x)<0))){c=p[r]=p[r]||new THREE.RenderableFace3();c.v1.copy(A.positionScreen);c.v2.copy(z.positionScreen);c.v3.copy(w.positionScreen);c.centroidWorld.copy(C.centroid);N.matrix.transform(c.centroidWorld);c.normalWorld.copy(C.normal);N.matrixRotation.transform(c.normalWorld);c.z=Math.max(A.positionScreen.z,Math.max(z.positionScreen.z,w.positionScreen.z));c.material=[N.material[C.material]];c.overdraw=N.overdraw;c.uvs=N.geometry.uvs[K];c.color=C.color;e.push(c);r++}}}else{if(C instanceof THREE.Face4){A=B[C.a];z=B[C.b];w=B[C.c];u=B[C.d];if(A.__visible&&z.__visible&&w.__visible&&u.__visible){if((N.doubleSided||(N.flipSided!=((u.positionScreen.x-A.positionScreen.x)*(z.positionScreen.y-A.positionScreen.y)-(u.positionScreen.y-A.positionScreen.y)*(z.positionScreen.x-A.positionScreen.x)<0||(z.positionScreen.x-w.positionScreen.x)*(u.positionScreen.y-w.positionScreen.y)-(z.positionScreen.y-w.positionScreen.y)*(u.positionScreen.x-w.positionScreen.x)<0)))){b=m[f]=m[f]||new THREE.RenderableFace4();b.v1.copy(A.positionScreen);b.v2.copy(z.positionScreen);b.v3.copy(w.positionScreen);b.v4.copy(u.positionScreen);b.centroidWorld.copy(C.centroid);N.matrix.transform(b.centroidWorld);b.normalWorld.copy(C.normal);N.matrixRotation.transform(b.normalWorld);b.z=Math.max(A.positionScreen.z,Math.max(z.positionScreen.z,Math.max(w.positionScreen.z,u.positionScreen.z)));b.material=[N.material[C.material]];b.overdraw=N.overdraw;b.uvs=N.geometry.uvs[K];b.color=C.color;e.push(b);f++}}}}}}else{if(N instanceof THREE.Line){q.multiply(d,s);B=N.geometry.vertices;for(F=0,M=B.length;F<M;F++){J=B[F];x=J.positionScreen;x.copy(J.position);q.transform(x);J.__visible=x.z>0&&x.z<1;if(F>0){E=N.geometry.vertices[F-1];if(J.__visible&&E.__visible){k=i[n]=i[n]||new THREE.RenderableLine();k.v1.copy(J.positionScreen);k.v2.copy(E.positionScreen);k.z=Math.max(J.positionScreen.z,E.positionScreen.z);k.material=N.material;e.push(k);n++}}}}else{if(N instanceof THREE.Particle){g.set(N.position.x,N.position.y,N.position.z,1);I.matrix.transform(g);I.projectionMatrix.transform(g);N.screen.set(g.x/g.w,g.y/g.w,g.z/g.w);if(N.screen.z>0&&N.screen.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=N.screen.x;j.y=N.screen.y;j.z=N.screen.z;j.rotation=N.rotation.z;j.scale.x=N.scale.x*Math.abs(g.x/g.w-(g.x+I.projectionMatrix.n11)/(g.w+I.projectionMatrix.n14));j.scale.y=N.scale.y*Math.abs(g.y/g.w-(g.y+I.projectionMatrix.n22)/(g.w+I.projectionMatrix.n24));j.material=N.material;j.color=N.color;e.push(j);h++}}}}}e.sort(o);return e};function o(t,s){return s.z-t.z}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(q,s){var r,h,i,o,p,t,n,k,j;e=g.projectScene(q,s);for(r=0,h=e.length;r<h;r++){p=e[r];if(p instanceof THREE.RenderableParticle){k=p.x*f+f;j=p.y*d+d;for(i=0,o=p.material.length;i<o;i++){t=p.material[i];if(t instanceof THREE.ParticleDOMMaterial){n=t.domElement;n.style.left=k+"px";n.style.top=j+"px"}}}}}};THREE.CanvasRenderer=function(){var v=null,p=new THREE.Projector(),n=document.createElement("canvas"),o=n.getContext("2d"),h,A,k,c,z=new THREE.Rectangle(),j=new THREE.Rectangle(),t=new THREE.Rectangle(),i=new THREE.Color(4294967295),r=new THREE.Color(4294967295),e=new THREE.Color(4294967295),g=new THREE.Vector2(),f=new THREE.Vector3(),d=new THREE.Vector2(),a=new THREE.Vector2(),y=new THREE.UV(),x=new THREE.UV(),u=new THREE.UV(),s=new THREE.UV();this.domElement=n;this.autoClear=true;this.setSize=function(C,B){h=C;A=B;k=h/2;c=A/2;n.width=h;n.height=A;z.set(-k,-c,k,c)};this.clear=function(){if(!j.isEmpty()){j.inflate(1);j.minSelf(z);o.setTransform(1,0,0,-1,k,c);o.clearRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());j.empty()}};this.render=function(ab,W){var aa,E,G,Q,X,M,O=Math.PI*2,I,H,U,S,D,B,K,J,V,T,F,C,P,N,ad,ac,Z,Y,ae,L,R;if(this.autoClear){this.clear()}v=p.projectScene(ab,W);o.setTransform(1,0,0,-1,k,c);o.fillStyle="rgba(0, 255, 255, 0.5)";o.fillRect(z.getX(),z.getY(),z.getWidth(),z.getHeight());w(ab,e);for(aa=0,E=v.length;aa<E;aa++){G=v[aa];t.empty();if(G instanceof THREE.RenderableParticle){I=G.x*k;H=G.y*c;for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.ParticleCircleMaterial){r.copyRGB(e);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();P=G.scale.x*k;N=G.scale.y*c;t.set(I-P,H-N,I+P,H+N);if(!z.instersects(t)){continue}o.save();o.translate(I,H);o.rotate(-G.rotation);o.scale(P,N);o.beginPath();o.arc(0,0,1,0,O,true);o.closePath();o.fillStyle=i.__styleString;o.fill();o.restore()}else{if(M instanceof THREE.ParticleBitmapMaterial){ae=M.bitmap;L=ae.width/2;R=ae.height/2;ad=G.scale.x*k;ac=G.scale.y*c;P=ad*L;N=ac*R;Z=M.offset.x*ad;Y=M.offset.y*ac;t.set(I+Z-P,H+Y-N,I+Z+P,H+Y+N);if(!z.instersects(t)){continue}o.save();o.translate(I,H);o.rotate(-G.rotation);o.scale(ad,-ac);o.translate(-L+M.offset.x,-R-M.offset.y);o.drawImage(ae,0,0);o.restore();o.beginPath();o.moveTo(I-10,H);o.lineTo(I+10,H);o.moveTo(I,H-10);o.lineTo(I,H+10);o.closePath();o.strokeStyle="rgb(255,255,0)";o.stroke()}}}}else{if(G instanceof THREE.RenderableLine){I=G.v1.x*k;H=G.v1.y*c;U=G.v2.x*k;S=G.v2.y*c;t.addPoint(I,H);t.addPoint(U,S);if(!z.instersects(t)){continue}o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.closePath();for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.LineColorMaterial){r.copyRGB(e);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}}}else{if(G instanceof THREE.RenderableFace3){G.v1.x*=k;G.v1.y*=c;G.v2.x*=k;G.v2.y*=c;G.v3.x*=k;G.v3.y*=c;if(G.overdraw){b(G.v1,G.v2);b(G.v2,G.v3);b(G.v3,G.v1)}I=G.v1.x;H=G.v1.y;U=G.v2.x;S=G.v2.y;D=G.v3.x;B=G.v3.y;t.addPoint(I,H);t.addPoint(U,S);t.addPoint(D,B);if(!z.instersects(t)){continue}for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.MeshColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshFaceColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshFaceColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshBitmapUVMappingMaterial){ae=M.bitmap;L=ae.width-1;R=ae.height-1;if(!G.uvs[0]||!G.uvs[1]||!G.uvs[2]){o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(I,H);o.closePath();o.fillStyle="rgb(0, 255, 0)";o.fill();continue}y.copy(G.uvs[0]);x.copy(G.uvs[1]);u.copy(G.uvs[2]);y.u*=L;y.v*=R;x.u*=L;x.v*=R;u.u*=L;u.v*=R;q(ae,I,H,U,S,D,B,y.u,y.v,x.u,x.v,u.u,u.v)}}}}}}}else{if(G instanceof THREE.RenderableFace4){G.v1.x*=k;G.v1.y*=c;G.v2.x*=k;G.v2.y*=c;G.v3.x*=k;G.v3.y*=c;G.v4.x*=k;G.v4.y*=c;d.copy(G.v2);a.copy(G.v4);if(G.overdraw){b(G.v1,G.v2);b(G.v2,G.v4);b(G.v4,G.v1)}I=G.v1.x;H=G.v1.y;U=G.v2.x;S=G.v2.y;K=G.v4.x;J=G.v4.y;if(G.overdraw){b(G.v3,d);b(G.v3,a)}D=G.v3.x;B=G.v3.y;V=d.x;T=d.y;F=a.x;C=a.y;t.addPoint(I,H);t.addPoint(U,S);t.addPoint(D,B);t.addPoint(K,J);if(!z.instersects(t)){continue}for(Q=0,X=G.material.length;Q<X;Q++){M=G.material[Q];if(M instanceof THREE.MeshColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(M.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshFaceColorFillMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.fillStyle=i.__styleString;o.fill()}else{if(M instanceof THREE.MeshFaceColorStrokeMaterial){r.copyRGB(e);m(ab,G,r);i.copyRGBA(G.color);i.multiplySelfRGB(r);i.updateStyleString();o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.lineWidth=M.lineWidth;o.lineJoin="round";o.lineCap="round";o.strokeStyle=i.__styleString;o.stroke();t.inflate(o.lineWidth)}else{if(M instanceof THREE.MeshBitmapUVMappingMaterial){ae=M.bitmap;L=ae.width-1;R=ae.height-1;if(!G.uvs[0]||!G.uvs[1]||!G.uvs[2]||!G.uvs[3]){o.beginPath();o.moveTo(I,H);o.lineTo(U,S);o.lineTo(D,B);o.lineTo(K,J);o.lineTo(I,H);o.closePath();o.fillStyle="rgb(255, 0, 255)";o.fill();continue}y.copy(G.uvs[0]);x.copy(G.uvs[1]);u.copy(G.uvs[2]);s.copy(G.uvs[3]);y.u*=L;y.v*=R;x.u*=L;x.v*=R;u.u*=L;u.v*=R;s.u*=L;s.v*=R;q(ae,I,H,U,S,K,J,y.u,y.v,x.u,x.v,s.u,s.v);q(ae,V,T,D,B,F,C,x.u,x.v,u.u,u.v,s.u,s.v)}}}}}}}}}}j.addRectangle(t)}o.lineWidth=1;o.strokeStyle="rgba( 255, 0, 0, 0.5 )";o.strokeRect(j.getX(),j.getY(),j.getWidth(),j.getHeight());o.setTransform(1,0,0,1,0,0)};function w(F,D){var C,E,B;D.setRGBA(1,1,1,1);for(C=0,E=F.lights.length;C<E;C++){B=F.lights[C];if(B instanceof THREE.AmbientLight){D.r*=B.color.r;D.g*=B.color.g;D.b*=B.color.b}}}function m(H,F,D){var C,G,B,E;for(C=0,G=H.lights.length;C<G;C++){B=H.lights[C];if(B instanceof THREE.DirectionalLight){E=F.normalWorld.dot(B.position)*B.intensity;if(E>0){D.r+=B.color.r*E;D.g+=B.color.g*E;D.b+=B.color.b*E}}else{if(B instanceof THREE.PointLight){f.sub(B.position,F.centroidWorld);f.normalize();E=F.normalWorld.dot(f)*B.intensity;if(E>0){D.r+=B.color.r*E;D.g+=B.color.g*E;D.b+=B.color.b*E}}}}}function q(U,J,I,P,O,D,B,R,Q,F,E,N,M){var C,T,S,H,G,L,K;o.beginPath();o.moveTo(J,I);o.lineTo(P,O);o.lineTo(D,B);o.lineTo(J,I);o.closePath();o.save();o.clip();C=R*(M-E)-F*M+N*E+(F-N)*Q;T=-(Q*(D-P)-E*D+M*P+(E-M)*J)/C;S=(E*B+Q*(O-B)-M*O+(M-E)*I)/C;H=(R*(D-P)-F*D+N*P+(F-N)*J)/C;G=-(F*B+R*(O-B)-N*O+(N-F)*I)/C;L=(R*(M*P-E*D)+Q*(F*D-N*P)+(N*E-F*M)*J)/C;K=(R*(M*O-E*B)+Q*(F*B-N*O)+(N*E-F*M)*I)/C;o.transform(T,S,H,G,L,K);o.drawImage(U,0,0);o.restore()}function b(C,B){g.sub(B,C);g.unit();g.multiplyScalar(0.75);B.addSelf(g);C.subSelf(g)}};THREE.SVGRenderer=function(){var q=null,k=new THREE.Projector(),m=document.createElementNS("http://www.w3.org/2000/svg","svg"),e,u,i,a,s=new THREE.Rectangle(),p=new THREE.Rectangle(),f=new THREE.Color(4294967295),o=new THREE.Color(4294967295),b=new THREE.Color(4294967295),d=new THREE.Vector3(),c=[],g=[],t=1;this.domElement=m;this.autoClear=true;this.setQuality=function(v){switch(v){case"high":t=1;break;case"low":t=0;break}};this.setSize=function(w,v){e=w;u=v;i=e/2;a=u/2;m.setAttribute("viewBox",(-i)+" "+(-a)+" "+e+" "+u);m.setAttribute("width",e);m.setAttribute("height",u);s.set(-i,-a,i,a)};this.clear=function(){while(m.childNodes.length>0){m.removeChild(m.childNodes[0])}};this.render=function(O,L){var N,x,I,M,y,E,H=0,z=0,F,C,A,K,J,w,v,D,B,G;if(this.autoClear){this.clear()}q=k.projectScene(O,L);r(O,b);for(N=0,x=q.length;N<x;N++){y=q[N];for(I=0,M=y.material.length;I<M;I++){E=y.material[I];p.empty();if(y instanceof THREE.RenderableParticle){C=y.x*i;A=y.y*-a;G=y.size*i;p.set(C-G,A-G,C+G,A+G);if(!s.instersects(p)){continue}F=n(z++);F.setAttribute("cx",C);F.setAttribute("cy",A);F.setAttribute("r",G)}else{if(y instanceof THREE.RenderableFace3){C=y.v1.x*i;A=y.v1.y*-a;K=y.v2.x*i;J=y.v2.y*-a;w=y.v3.x*i;v=y.v3.y*-a;p.addPoint(C,A);p.addPoint(K,J);p.addPoint(w,v);if(!s.instersects(p)){continue}F=h(H++);F.setAttribute("d","M "+C+" "+A+" L "+K+" "+J+" L "+w+","+v+"z")}else{if(y instanceof THREE.RenderableFace4){C=y.v1.x*i;A=y.v1.y*-a;K=y.v2.x*i;J=y.v2.y*-a;w=y.v3.x*i;v=y.v3.y*-a;D=y.v4.x*i;B=y.v4.y*-a;p.addPoint(C,A);p.addPoint(K,J);p.addPoint(w,v);p.addPoint(D,B);if(!s.instersects(p)){continue}F=h(H++);F.setAttribute("d","M "+C+" "+A+" L "+K+" "+J+" L "+w+","+v+" L "+D+","+B+"z")}}}if(E instanceof THREE.MeshColorFillMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(E.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: "+f.__styleString)}else{if(E instanceof THREE.MeshFaceColorFillMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(y.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: "+f.__styleString)}else{if(E instanceof THREE.MeshColorStrokeMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(E.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+E.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}else{if(E instanceof THREE.MeshFaceColorStrokeMaterial){o.copyRGB(b);j(O,y,o);f.copyRGBA(y.color);f.multiplySelfRGB(o);f.updateStyleString();F.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+E.lineWidth+"; stroke-linecap: round; stroke-linejoin: round")}}}}m.appendChild(F)}}};function r(z,x){var w,y,v;x.setRGBA(1,1,1,1);for(w=0,y=z.lights.length;w<y;w++){v=z.lights[w];if(v instanceof THREE.AmbientLight){x.r*=v.color.r;x.g*=v.color.g;x.b*=v.color.b}}}function j(B,z,x){var w,A,v,y;for(w=0,A=B.lights.length;w<A;w++){v=B.lights[w];if(v instanceof THREE.DirectionalLight){y=z.normalWorld.dot(v.position)*v.intensity;if(y>0){x.r+=v.color.r*y;x.g+=v.color.g*y;x.b+=v.color.b*y}}else{if(v instanceof THREE.PointLight){d.sub(v.position,z.centroidWorld);d.normalize();y=z.normalWorld.dot(d)*v.intensity;if(y>0){x.r+=v.color.r*y;x.g+=v.color.g*y;x.b+=v.color.b*y}}}}}function h(v){if(c[v]==null){c[v]=document.createElementNS("http://www.w3.org/2000/svg","path");if(t==0){c[v].setAttribute("shape-rendering","crispEdges")}return c[v]}return c[v]}function n(v){if(g[v]==null){g[v]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(t==0){g[v].setAttribute("shape-rendering","crispEdges")}return g[v]}return g[v]}};THREE.WebGLRenderer=function(){var e=document.createElement("canvas"),a,h,d=new THREE.Matrix4(),g;this.domElement=e;this.autoClear=true;f();c();this.setSize=function(j,i){e.width=j;e.height=i;a.viewport(0,0,e.width,e.height)};this.clear=function(){a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)};this.render=function(O,K){var v,P,R,C,Q,G,u,q,B,D,s,N,y,F,A,M,w,H,L,J,p,n,k,j,I,x,t,E;if(this.autoClear){this.clear()}a.uniform1i(h.enableLighting,O.lights.length);for(I=0,x=O.lights.length;I<x;I++){q=O.lights[I];if(q instanceof THREE.AmbientLight){G=q.color;a.uniform3f(h.ambientColor,G.r,G.g,G.b)}else{if(q instanceof THREE.DirectionalLight){G=q.color;u=q.position;a.uniform3f(h.lightingDirection,u.x,u.y,u.z);a.uniform3f(h.directionalColor,G.r,G.g,G.b)}}}for(F=0,A=O.objects.length;F<A;F++){R=O.objects[F];var r,z;if(R instanceof THREE.Mesh){d.multiply(K.matrix,R.matrix);h.viewMatrixArray=new Float32Array(d.flatten());h.projectionMatrixArray=new Float32Array(K.projectionMatrix.flatten());g=THREE.Matrix4.makeInvert(d).transpose();h.normalMatrixArray=new Float32Array(g.flatten());a.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);a.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);a.uniformMatrix4fv(h.normalMatrix,false,h.normalMatrixArray);for(var H in R.materialFaces){r=R.materialFaces[H];C=R.material[H];if(!C){continue}if(!r.__webGLVertexBuffer){B=[];D=[];s=[];N=[];E=[];y=0;for(M=0,w=r.faces.length;M<w;M++){z=r.faces[M];v=R.geometry.faces[z];P=v.color;vertexNormals=v.vertexNormals;Q=v.normal;t=R.geometry.uvs[z];if(v instanceof THREE.Face3){p=R.geometry.vertices[v.a].position;n=R.geometry.vertices[v.b].position;k=R.geometry.vertices[v.c].position;B.push(p.x,p.y,p.z);B.push(n.x,n.y,n.z);B.push(k.x,k.y,k.z);if(vertexNormals.length==3){N.push(vertexNormals[0].x,vertexNormals[0].y,vertexNormals[0].z);N.push(vertexNormals[1].x,vertexNormals[1].y,vertexNormals[1].z);N.push(vertexNormals[2].x,vertexNormals[2].y,vertexNormals[2].z)}else{N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z)}s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);if(t){E.push(t[0].u,t[0].v);E.push(t[1].u,t[1].v);E.push(t[2].u,t[2].v)}D.push(y,y+1,y+2);y+=3}else{if(v instanceof THREE.Face4){p=R.geometry.vertices[v.a].position;n=R.geometry.vertices[v.b].position;k=R.geometry.vertices[v.c].position;j=R.geometry.vertices[v.d].position;B.push(p.x,p.y,p.z);B.push(n.x,n.y,n.z);B.push(k.x,k.y,k.z);B.push(j.x,j.y,j.z);if(vertexNormals.length==4){N.push(vertexNormals[0].x,vertexNormals[0].y,vertexNormals[0].z);N.push(vertexNormals[1].x,vertexNormals[1].y,vertexNormals[1].z);N.push(vertexNormals[2].x,vertexNormals[2].y,vertexNormals[2].z);N.push(vertexNormals[3].x,vertexNormals[3].y,vertexNormals[3].z)}else{N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z);N.push(Q.x,Q.y,Q.z)}s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);s.push(P.r,P.g,P.b,P.a);if(t){E.push(t[0].u,t[0].v);E.push(t[1].u,t[1].v);E.push(t[2].u,t[2].v);E.push(t[3].u,t[3].v)}D.push(y,y+1,y+2);D.push(y,y+2,y+3);y+=4}}}if(!B.length){continue}r.__webGLVertexBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLVertexBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(B),a.STATIC_DRAW);r.__webGLNormalBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLNormalBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(N),a.STATIC_DRAW);if(C instanceof THREE.MeshFaceColorFillMaterial||C instanceof THREE.MeshBitmapUVMappingMaterial){r.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(s),a.STATIC_DRAW)}r.__webGLUVBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLUVBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(E),a.STATIC_DRAW);r.__webGLFaceBuffer=a.createBuffer();a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(D),a.STATIC_DRAW);r.__webGLFaceCount=D.length}if(C instanceof THREE.MeshColorFillMaterial){if(!r.__webGLColorBuffer){s=[];for(J=0;J<r.__webGLFaceCount;J++){s.push(C.color.r,C.color.g,C.color.b,C.color.a)}r.__webGLColorBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,r.__webGLColorBuffer);a.bufferData(a.ARRAY_BUFFER,new Float32Array(s),a.STATIC_DRAW)}a.uniform1i(h.enableTexture,0)}else{if(C instanceof THREE.MeshFaceColorFillMaterial){a.uniform1i(h.enableTexture,0)}else{if(C instanceof THREE.MeshBitmapUVMappingMaterial){if(!C.__webGLTexture&&C.loaded){C.__webGLTexture=a.createTexture();a.bindTexture(a.TEXTURE_2D,C.__webGLTexture);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,C.bitmap);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR);a.generateMipmap(a.TEXTURE_2D);a.bindTexture(a.TEXTURE_2D,null)}a.uniform1i(h.enableTexture,1);a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,C.__webGLTexture);a.uniform1i(h.diffuse,0)}}}a.bindBuffer(a.ARRAY_BUFFER,r.__webGLVertexBuffer);a.vertexAttribPointer(h.position,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,r.__webGLNormalBuffer);a.vertexAttribPointer(h.normal,3,a.FLOAT,false,0,0);a.bindBuffer(a.ARRAY_BUFFER,r.__webGLUVBuffer);if(R.geometry.uvs.length){a.enableVertexAttribArray(h.uv);a.vertexAttribPointer(h.uv,2,a.FLOAT,false,0,0)}else{a.disableVertexAttribArray(h.uv)}a.bindBuffer(a.ARRAY_BUFFER,r.__webGLColorBuffer);a.enableVertexAttribArray(h.color);a.vertexAttribPointer(h.color,4,a.FLOAT,false,0,0);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);a.drawElements(a.TRIANGLES,r.__webGLFaceCount,a.UNSIGNED_SHORT,0)}}}};function f(){try{a=e.getContext("experimental-webgl",{antialias:true})}catch(i){}if(!a){alert("WebGL not supported");throw"cannot create webgl context"}a.clearColor(0,0,0,1);a.clearDepth(1);a.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.enable(a.BLEND);a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA);a.clearColor(0,0,0,0)}function c(){h=a.createProgram();a.attachShader(h,b("fragment",["#ifdef GL_ES","precision highp float;","#endif","uniform bool enableTexture;","uniform sampler2D diffuse;","varying vec2 vuv;","varying vec4 vcolor;","varying vec3 lightWeighting;","void main(){","if(enableTexture) {","vec4 texelColor = texture2D(diffuse, vuv);","gl_FragColor = vec4(texelColor.rgb * lightWeighting, texelColor.a);","} else {","gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);","}","}"].join("\n")));a.attachShader(h,b("vertex",["attribute vec3 position;","attribute vec3 normal;","attribute vec4 color;","attribute vec2 uv;","uniform bool enableLighting;","uniform vec3 ambientColor;","uniform vec3 directionalColor;","uniform vec3 lightingDirection;","uniform mat4 viewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 normalMatrix;","varying vec4 vcolor;","varying vec3 lightWeighting;","varying vec2 vuv;","void main(void) {","if(!enableLighting) {","lightWeighting = vec3(1.0, 1.0, 1.0);","} else {","vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);","float directionalLightWeighting = max(dot(normalize(transformedNormal.xyz), lightingDirection), 0.0);","lightWeighting = ambientColor + directionalColor * directionalLightWeighting;","}","vcolor = color;","vuv = uv;","gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );","}"].join("\n")));a.linkProgram(h);if(!a.getProgramParameter(h,a.LINK_STATUS)){alert("Could not initialise shaders")}a.useProgram(h);h.viewMatrix=a.getUniformLocation(h,"viewMatrix");h.projectionMatrix=a.getUniformLocation(h,"projectionMatrix");h.normalMatrix=a.getUniformLocation(h,"normalMatrix");h.enableLighting=a.getUniformLocation(h,"enableLighting");h.ambientColor=a.getUniformLocation(h,"ambientColor");h.directionalColor=a.getUniformLocation(h,"directionalColor");h.lightingDirection=a.getUniformLocation(h,"lightingDirection");h.enableTexture=a.getUniformLocation(h,"enableTexture");h.color=a.getAttribLocation(h,"color");a.enableVertexAttribArray(h.color);h.position=a.getAttribLocation(h,"position");a.enableVertexAttribArray(h.position);h.normal=a.getAttribLocation(h,"normal");a.enableVertexAttribArray(h.normal);h.uv=a.getAttribLocation(h,"uv");a.enableVertexAttribArray(h.uv);h.diffuse=a.getUniformLocation(h,"diffuse");a.uniform1i(h.diffuse,0);h.viewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function b(j,i){var k;if(j=="fragment"){k=a.createShader(a.FRAGMENT_SHADER)}else{if(j=="vertex"){k=a.createShader(a.VERTEX_SHADER)}}a.shaderSource(k,i);a.compileShader(k);if(!a.getShaderParameter(k,a.COMPILE_STATUS)){alert(a.getShaderInfoLog(k));return null}return k}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null};
\ No newline at end of file \ No newline at end of file
...@@ -43,7 +43,7 @@ var Sphere = function ( radius, segments_width, segments_height ) { ...@@ -43,7 +43,7 @@ var Sphere = function ( radius, segments_width, segments_height ) {
} }
var iVerNum = aVtc.length; var n1, n2, n3, iVerNum = aVtc.length;
for ( j = 0; j < iVerNum; j++ ) { for ( j = 0; j < iVerNum; j++ ) {
...@@ -70,15 +70,31 @@ var Sphere = function ( radius, segments_width, segments_height ) { ...@@ -70,15 +70,31 @@ var Sphere = function ( radius, segments_width, segments_height ) {
var aP4uv = new THREE.UV( 1 - fI0, fJ1 ); var aP4uv = new THREE.UV( 1 - fI0, fJ1 );
if ( j < ( aVtc.length - 1 ) ) { if ( j < ( aVtc.length - 1 ) ) {
n1 = this.vertices[aP1].position.clone();
n2 = this.vertices[aP2].position.clone();
n3 = this.vertices[aP3].position.clone();
n1.normalize();
n2.normalize();
n3.normalize();
this.faces.push( new THREE.Face3( aP1, aP2, aP3 ) ); this.faces.push( new THREE.Face3( aP1, aP2, aP3, [new THREE.Vector3(n1.x,n1.y,n1.z), new THREE.Vector3(n2.x,n2.y,n2.z), new THREE.Vector3(n3.x,n3.y,n3.z)] ) );
//this.faces.push( new THREE.Face3( aP1, aP2, aP3 ) );
this.uvs.push( [ aP1uv, aP2uv, aP3uv ] ); this.uvs.push( [ aP1uv, aP2uv, aP3uv ] );
} }
if ( j > 1 ) { if ( j > 1 ) {
this.faces.push( new THREE.Face3( aP1, aP3, aP4 ) ); n1 = this.vertices[aP1].position.clone();
n2 = this.vertices[aP3].position.clone();
n3 = this.vertices[aP4].position.clone();
n1.normalize();
n2.normalize();
n3.normalize();
this.faces.push( new THREE.Face3( aP1, aP3, aP4, [new THREE.Vector3(n1.x,n1.y,n1.z), new THREE.Vector3(n2.x,n2.y,n2.z), new THREE.Vector3(n3.x,n3.y,n3.z)] ) );
//this.faces.push( new THREE.Face3( aP1, aP3, aP4 ) );
this.uvs.push( [ aP1uv, aP3uv, aP4uv ] ); this.uvs.push( [ aP1uv, aP3uv, aP4uv ] );
} }
......
<Files *.js>
SetOutputFilter DEFLATE
</Files>
因为 它太大了无法显示 source diff 。你可以改为 查看blob
# Material Count: 6
newmtl FrontColorNoCullingID__01_-_Default1noCulli
Ns 154.901961
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.165000 0.165000 0.165000
Ni 1.000000
d 1.000000
illum 2
map_Kd _01_-_Default1noCulling.JPG
newmtl _02_-_Default1noCulli__02_-_Default1noCulli
Ns 154.901961
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.165000 0.165000 0.165000
Ni 1.000000
d 1.000000
illum 2
map_Kd _02_-_Default1noCulling.JPG
newmtl _01_-_Default1noCulli__01_-_Default1noCulli
Ns 154.901961
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.165000 0.165000 0.165000
Ni 1.000000
d 1.000000
illum 2
map_Kd _01_-_Default1noCulling.JPG
newmtl FrontColorNoCullingID__03_-_Default1noCulli
Ns 154.901961
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.165000 0.165000 0.165000
Ni 1.000000
d 1.000000
illum 2
map_Kd _03_-_Default1noCulling.JPG
newmtl _03_-_Default1noCulli__03_-_Default1noCulli
Ns 154.901961
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.165000 0.165000 0.165000
Ni 1.000000
d 1.000000
illum 2
map_Kd _03_-_Default1noCulling.JPG
newmtl FrontColorNoCullingID__02_-_Default1noCulli
Ns 154.901961
Ka 0.000000 0.000000 0.000000
Kd 0.800000 0.800000 0.800000
Ks 0.165000 0.165000 0.165000
Ni 1.000000
d 1.000000
illum 2
map_Kd _02_-_Default1noCulling.JPG
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Model by Reallusion iClone from Google 3d Warehouse:
http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1
\ No newline at end of file
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>three.js - OBJ converter test</title>
<meta charset="utf-8">
<style type="text/css">
body {
background: #fff;
margin: 0px;
overflow: hidden;
font-family:georgia;
text-align:center;
}
h1 { }
a { color:skyblue }
canvas { pointer-events:none; z-index:10; position:relative }
#log { position:absolute; top:0 }
#d { text-align:center; margin:1em 0 -15em 0; z-index:0; position:relative; display:block }
.button { background:#000; color:#fff; padding:0.2em 0.5em; cursor:pointer }
.inactive { background:#999; color:#eee }
</style>
</head>
<body>
<div id="d">
<h1>OBJ to Three.js converter test</h1>
<span id="rcanvas" class="button inactive">2d canvas renderer</span>
<span id="rwebgl" class="button">WebGL renderer</span>
<br/>
<p>Model by <a href="http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1">Reallusion iClone</a>.
<p>Using a modified version of <a href="http://github.com/alteredq/three.js">Three.js</a> by mrdoob.
<br/>
<p>Best viewed in Chrome 7/8 or Firefox 4 using WebGL renderer.
<p>Canvas renderer is very slow on anything other than Chrome.
</div>
<div id="log"></div>
<script type="text/javascript" src="../build/Three.js"></script>
<!--
-->
<!--
<script type="text/javascript" src="../src/Three.js"></script>
<script type="text/javascript" src="../src/core/Color.js"></script>
<script type="text/javascript" src="../src/core/Vector2.js"></script>
<script type="text/javascript" src="../src/core/Vector3.js"></script>
<script type="text/javascript" src="../src/core/Vector4.js"></script>
<script type="text/javascript" src="../src/core/Rectangle.js"></script>
<script type="text/javascript" src="../src/core/Matrix4.js"></script>
<script type="text/javascript" src="../src/core/Vertex.js"></script>
<script type="text/javascript" src="../src/core/Face3.js"></script>
<script type="text/javascript" src="../src/core/Face4.js"></script>
<script type="text/javascript" src="../src/core/UV.js"></script>
<script type="text/javascript" src="../src/core/Geometry.js"></script>
<script type="text/javascript" src="../src/cameras/Camera.js"></script>
<script type="text/javascript" src="../src/lights/Light.js"></script>
<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
<script type="text/javascript" src="../src/lights/PointLight.js"></script>
<script type="text/javascript" src="../src/objects/Object3D.js"></script>
<script type="text/javascript" src="../src/objects/Mesh.js"></script>
<script type="text/javascript" src="../src/objects/Particle.js"></script>
<script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script>
<script type="text/javascript" src="../src/renderers/Projector.js"></script>
<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
-->
<!--
<script type="text/javascript" src="obj/female02/female02.js"></script>
-->
<script type="text/javascript" src="geometry/primitives/Sphere.js"></script>
<script type="text/javascript" src="geometry/primitives/Plane.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
<script type="text/javascript">
var SCREEN_WIDTH = window.innerWidth;
var SCREEN_HEIGHT = window.innerHeight;
var FLOOR = -200;
var container;
var stats;
var camera;
var scene;
var canvasRenderer, webglRenderer;
var mesh, zmesh, geometry;
var mouseX = 0;
var mouseY = 0;
var windowHalfX = window.innerWidth >> 1;
var windowHalfY = window.innerHeight >> 1;
var render_canvas = 1, render_gl = 1;
var has_gl = 0;
var bcanvas = document.getElementById("rcanvas");
var bwebgl = document.getElementById("rwebgl");
document.addEventListener('mousemove', onDocumentMouseMove, false);
init();
loop();
render_canvas = !has_gl;
bwebgl.style.display = has_gl ? "inline" : "none";
bcanvas.className = render_canvas ? "button" : "button inactive";
setInterval(loop, 1000/60);
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.Camera( 75, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 100000 );
camera.position.z = 500;
camera.updateMatrix();
scene = new THREE.Scene();
// GROUND
var x = document.createElement( "canvas" );
var xc = x.getContext("2d");
x.width = x.height = 128;
xc.fillStyle = "#fff";
xc.fillRect(0, 0, 128, 128);
xc.fillStyle = "#000";
xc.fillRect(0, 0, 64, 64);
xc.fillStyle = "#999";
xc.fillRect(32, 32, 32, 32);
xc.fillStyle = "#000";
xc.fillRect(64, 64, 64, 64);
xc.fillStyle = "#555";
xc.fillRect(96, 96, 32, 32);
var xm = new THREE.MeshBitmapUVMappingMaterial( x );
xm.loaded = 1;
geometry = new Plane( 100, 100, 15, 10 );
for(var i=0; i<geometry.uvs.length; i++) {
var uvs = geometry.uvs[i];
for ( j = 0, jl = uvs.length; j < jl; j++ ) {
uvs[j].u *= 10;
uvs[j].v *= 10;
}
}
mesh = new THREE.Mesh( geometry, xm );
mesh.position.x = 0;
mesh.position.y = FLOOR;
mesh.position.z = 0;
mesh.rotation.x = 1.57;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 10;
mesh.doubleSided = true;
mesh.updateMatrix();
scene.add(mesh);
// SPHERES
sphere = new Sphere( 100, 16, 8 );
for (var i=0; i<10; i++) {
mesh = new THREE.Mesh( sphere, new THREE.MeshColorFillMaterial( 0xffdddddd ) );
mesh.position.x = 500 * (Math.random() - 0.5);
mesh.position.y = 300 * (Math.random() - 0) + FLOOR;
mesh.position.z = 100 * (Math.random() - 1);
mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.25 * (Math.random() + 0.5);
//mesh.doubleSided = true;
mesh.overdraw = true;
mesh.updateMatrix();
scene.add(mesh);
}
// LIGHTS
var ambient = new THREE.AmbientLight( 0x221100 );
scene.addLight( ambient );
var directionalLight = new THREE.DirectionalLight( 0xffeedd );
directionalLight.position.y = -70;
directionalLight.position.z = 100;
directionalLight.position.normalize();
scene.addLight( directionalLight );
var pointLight = new THREE.PointLight( 0xff0000, 1 );
scene.addLight( pointLight );
if ( render_gl ) {
try {
webglRenderer = new THREE.WebGLRenderer();
webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
container.appendChild( webglRenderer.domElement );
has_gl = 1;
}
catch (e) {
}
}
if( render_canvas ) {
canvasRenderer = new THREE.CanvasRenderer();
canvasRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
container.appendChild( canvasRenderer.domElement );
}
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
bcanvas.addEventListener("click", toggleCanvas, false);
bwebgl.addEventListener("click", toggleWebGL, false);
function createModel() {
// MESH
geometry = new Female02( "obj/female02" );
zmesh = new THREE.Mesh( geometry, geometry.materials, 1 );
zmesh.position.z = 50;
zmesh.position.y = FLOOR;
zmesh.scale.x = zmesh.scale.y = zmesh.scale.z = 3;
//zmesh.doubleSided = true;
//zmesh.flipSided = true;
zmesh.overdraw = true;
zmesh.updateMatrix();
scene.add(zmesh);
// PLANES with all materials from the model
createMaterialsPalette( geometry.materials, 100 );
}
loadAsync( "obj/female02/female02.js", createModel);
}
function loadAsync( url, callback ) {
var el = document.createElement( 'script' );
el.type = 'text/javascript';
el.onload = callback;
el.src = url;
document.getElementsByTagName("head")[0].appendChild(el);
}
function createMaterialsPalette( materials, size ) {
for ( var i=0; i<materials.length; ++i ) {
// material
mesh = new THREE.Mesh( new Plane( size, size ), materials[i] );
mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
mesh.position.y = FLOOR + size/2;
mesh.position.z = -100;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
mesh.doubleSided = true;
mesh.updateMatrix();
scene.add(mesh);
// number
var x = document.createElement( "canvas" );
var xc = x.getContext("2d");
x.width = x.height = 128;
xc.shadowColor = "#000";
xc.shadowBlur = 7;
xc.fillStyle = "orange";
xc.font = "50pt arial bold";
xc.fillText(i, 10, 64);
var xm = new THREE.MeshBitmapUVMappingMaterial( x );
xm.loaded = 1;
mesh = new THREE.Mesh( new Plane( size, size ), xm );
mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
mesh.position.y = FLOOR + size/2;
mesh.position.z = -99;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
mesh.doubleSided = true;
mesh.updateMatrix();
scene.add(mesh);
}
}
function onDocumentMouseMove(event) {
mouseX = ( event.clientX - windowHalfX );
mouseY = ( event.clientY - windowHalfY );
}
function loop() {
camera.position.x += ( mouseX - camera.position.x ) * .05;
camera.position.y += ( - mouseY - camera.position.y ) * .05;
camera.updateMatrix();
if ( zmesh && 0 ) {
zmesh.rotation.y += 0.005;
zmesh.updateMatrix();
}
if ( render_canvas ) canvasRenderer.render( scene, camera );
if ( render_gl && has_gl ) webglRenderer.render( scene, camera );
stats.update();
}
function log(text) {
var e = document.getElementById("log");
e.innerHTML = text + "<br/>" + e.innerHTML;
}
function toggleCanvas() {
render_canvas = !render_canvas;
bcanvas.className = render_canvas ? "button" : "button inactive";
render_gl = !render_canvas;
bwebgl.className = render_gl ? "button" : "button inactive";
if( has_gl )
webglRenderer.domElement.style.display = render_gl ? "block" : "none";
canvasRenderer.domElement.style.display = render_canvas ? "block" : "none";
}
function toggleWebGL() {
render_gl = !render_gl;
bwebgl.className = render_gl ? "button" : "button inactive";
render_canvas = !render_gl;
bcanvas.className = render_canvas ? "button" : "button inactive";
if( has_gl )
webglRenderer.domElement.style.display = render_gl ? "block" : "none";
canvasRenderer.domElement.style.display = render_canvas ? "block" : "none";
}
</script>
</body>
</html>
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.Face3 = function ( a, b, c, normal, color ) { THREE.Face3 = function ( a, b, c, normal, color, material ) {
this.a = a; this.a = a;
this.b = b; this.b = b;
this.c = c; this.c = c;
this.centroid = new THREE.Vector3(); this.centroid = new THREE.Vector3();
this.normal = normal || new THREE.Vector3(); this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
this.color = color || new THREE.Color( 0xff000000 ); this.color = color || new THREE.Color( 0xff000000 );
this.vertexNormals = normal instanceof Array ? normal : [];
this.material = material || 0;
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.Face4 = function ( a, b, c, d, normal, color ) { THREE.Face4 = function ( a, b, c, d, normal, color, material ) {
this.a = a; this.a = a;
this.b = b; this.b = b;
...@@ -10,12 +10,16 @@ THREE.Face4 = function ( a, b, c, d, normal, color ) { ...@@ -10,12 +10,16 @@ THREE.Face4 = function ( a, b, c, d, normal, color ) {
this.d = d; this.d = d;
this.centroid = new THREE.Vector3(); this.centroid = new THREE.Vector3();
this.normal = normal || new THREE.Vector3(); this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
this.color = color || new THREE.Color( 0xff000000 ); this.color = color || new THREE.Color( 0xff000000 );
this.vertexNormals = normal instanceof Array ? normal : [];
this.material = material || 0;
}; };
THREE.Face4.prototype = { THREE.Face4.prototype = {
// TODO: Dupe? (Geometry/computeCentroid) // TODO: Dupe? (Geometry/computeCentroid)
......
...@@ -43,9 +43,9 @@ THREE.Geometry.prototype = { ...@@ -43,9 +43,9 @@ THREE.Geometry.prototype = {
}, },
computeNormals: function () { computeNormals: function ( useVertexNormals ) {
var v, vl, vertex, f, fl, face, vA, vB, vC, cb = new THREE.Vector3(), ab = new THREE.Vector3(); var n, nl, v, vl, vertex, f, fl, face, vA, vB, vC, cb = new THREE.Vector3(), ab = new THREE.Vector3();
for ( v = 0, vl = this.vertices.length; v < vl; v++ ) { for ( v = 0, vl = this.vertices.length; v < vl; v++ ) {
...@@ -58,25 +58,86 @@ THREE.Geometry.prototype = { ...@@ -58,25 +58,86 @@ THREE.Geometry.prototype = {
face = this.faces[ f ]; face = this.faces[ f ];
vA = this.vertices[ face.a ]; if ( useVertexNormals && face.vertexNormals.length ) {
vB = this.vertices[ face.b ];
vC = this.vertices[ face.c ]; // set face normal to average of vertex normals
cb.set( 0, 0, 0 );
cb.sub( vC.position, vB.position ); for ( n = 0, nl = face.normal.length; n < nl; n++ ) {
ab.sub( vA.position, vB.position ); cb.x += face.vertexNormals[n].x;
cb.crossSelf( ab ); cb.y += face.vertexNormals[n].y;
cb.z += face.vertexNormals[n].z;
}
if ( !cb.isZero() ) { cb.x /= 3;
cb.y /= 3;
cb.z /= 3;
cb.normalize(); if ( !cb.isZero() ) {
} cb.normalize();
}
face.normal.copy( cb );
}
else {
vA = this.vertices[ face.a ];
vB = this.vertices[ face.b ];
vC = this.vertices[ face.c ];
cb.sub( vC.position, vB.position );
ab.sub( vA.position, vB.position );
cb.crossSelf( ab );
if ( !cb.isZero() ) {
cb.normalize();
}
face.normal.copy( cb ); face.normal.copy( cb );
}
} }
}, },
computeBoundingBox: function ( ) {
if ( this.vertices.length > 0 ) {
this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
'y': [ this.vertices[ 0 ].position.y, this.vertices[ 0 ].position.y ],
'z': [ this.vertices[ 0 ].position.z, this.vertices[ 0 ].position.z ] };
var v, vl;
for ( v = 1, vl = this.vertices.length; v < vl; v++ ) {
vertex = this.vertices[ v ];
if ( vertex.position.x < this.bbox.x[ 0 ] )
this.bbox.x[ 0 ] = vertex.position.x;
else if ( vertex.position.x > this.bbox.x[ 1 ] )
this.bbox.x[ 1 ] = vertex.position.x;
if ( vertex.position.y < this.bbox.y[ 0 ] )
this.bbox.y[ 0 ] = vertex.position.y;
else if ( vertex.position.y > this.bbox.y[ 1 ] )
this.bbox.y[ 1 ] = vertex.position.y;
if ( vertex.position.z < this.bbox.z[ 0 ] )
this.bbox.z[ 0 ] = vertex.position.z;
else if ( vertex.position.z > this.bbox.z[ 1 ] )
this.bbox.z[ 1 ] = vertex.position.z;
}
}
},
toString: function () { toString: function () {
......
/** /**
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.ParticleDOMMaterial = function ( domElement ) { THREE.ParticleDOMMaterial = function ( domElement ) {
this.domElement = domElement; this.domElement = domElement;
this.toString = function () { this.toString = function () {
return 'THREE.ParticleDOMMaterial ( domElement: ' + this.domElement + ' )'; return 'THREE.ParticleDOMMaterial ( domElement: ' + this.domElement + ' )';
}; };
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.Mesh = function ( geometry, material ) { THREE.Mesh = function ( geometry, material, normUVs ) {
THREE.Object3D.call( this ); THREE.Object3D.call( this );
...@@ -14,7 +14,51 @@ THREE.Mesh = function ( geometry, material ) { ...@@ -14,7 +14,51 @@ THREE.Mesh = function ( geometry, material ) {
this.overdraw = false; this.overdraw = false;
this.materialFaces = {};
this.sortFacesByMaterial();
if( normUVs ) this.normalizeUVs();
this.geometry.computeBoundingBox();
}; };
THREE.Mesh.prototype = new THREE.Object3D(); THREE.Mesh.prototype = new THREE.Object3D();
THREE.Mesh.prototype.constructor = THREE.Mesh; THREE.Mesh.prototype.constructor = THREE.Mesh;
THREE.Mesh.prototype.sortFacesByMaterial = function () {
var f, fl, face, material;
for ( f = 0, fl = this.geometry.faces.length; f < fl; f++ ) {
face = this.geometry.faces[ f ];
material = face.material;
if ( this.materialFaces[material] == undefined )
this.materialFaces[material] = { 'faces': [] };
this.materialFaces[material].faces.push( f );
}
}
THREE.Mesh.prototype.normalizeUVs = function () {
var i,j;
for ( i = 0, l = this.geometry.uvs.length; i < l; i++ ) {
var uvs = this.geometry.uvs[i];
for ( j = 0, jl = uvs.length; j < jl; j++ ) {
// texture repeat
// (WebGL does this by default but canvas renderer needs to do it explicitly)
if( uvs[j].u != 1.0 ) uvs[j].u = uvs[j].u - Math.floor(uvs[j].u);
if( uvs[j].v != 1.0 ) uvs[j].v = uvs[j].v - Math.floor(uvs[j].v);
}
}
}
...@@ -358,7 +358,6 @@ THREE.CanvasRenderer = function () { ...@@ -358,7 +358,6 @@ THREE.CanvasRenderer = function () {
_context.moveTo( v1x, v1y ); _context.moveTo( v1x, v1y );
_context.lineTo( v2x, v2y ); _context.lineTo( v2x, v2y );
_context.lineTo( v3x, v3y ); _context.lineTo( v3x, v3y );
_context.lineTo( v4x, v4y );
_context.lineTo( v1x, v1y ); _context.lineTo( v1x, v1y );
_context.closePath(); _context.closePath();
...@@ -668,6 +667,10 @@ THREE.CanvasRenderer = function () { ...@@ -668,6 +667,10 @@ THREE.CanvasRenderer = function () {
_context.save(); _context.save();
_context.clip(); _context.clip();
// debug triangle outline
//_context.strokeStyle = "black";
//_context.stroke();
denom = uv1u * ( uv3v - uv2v ) - uv2u * uv3v + uv3u * uv2v + ( uv2u - uv3u ) * uv1v; denom = uv1u * ( uv3v - uv2v ) - uv2u * uv3v + uv3u * uv2v + ( uv2u - uv3u ) * uv1v;
......
...@@ -96,7 +96,7 @@ THREE.Projector = function() { ...@@ -96,7 +96,7 @@ THREE.Projector = function() {
_face3.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, v3.positionScreen.z ) ); _face3.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, v3.positionScreen.z ) );
_face3.material = object.material; _face3.material = [ object.material[face.material] ];
_face3.overdraw = object.overdraw; _face3.overdraw = object.overdraw;
_face3.uvs = object.geometry.uvs[ f ]; _face3.uvs = object.geometry.uvs[ f ];
_face3.color = face.color; _face3.color = face.color;
...@@ -135,7 +135,7 @@ THREE.Projector = function() { ...@@ -135,7 +135,7 @@ THREE.Projector = function() {
_face4.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, Math.max( v3.positionScreen.z, v4.positionScreen.z ) ) ); _face4.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, Math.max( v3.positionScreen.z, v4.positionScreen.z ) ) );
_face4.material = object.material; _face4.material = [ object.material[face.material] ];
_face4.overdraw = object.overdraw; _face4.overdraw = object.overdraw;
_face4.uvs = object.geometry.uvs[ f ]; _face4.uvs = object.geometry.uvs[ f ];
_face4.color = face.color; _face4.color = face.color;
......
...@@ -33,7 +33,8 @@ THREE.WebGLRenderer = function () { ...@@ -33,7 +33,8 @@ THREE.WebGLRenderer = function () {
var face, faceColor, object, material, normal, lightColor, lightPosition, light, var face, faceColor, object, material, normal, lightColor, lightPosition, light,
vertexArray, faceArray, colorArray, normalArray, vertexIndex, vertexArray, faceArray, colorArray, normalArray, vertexIndex,
o, ol, f, fl, m, ml, i, v1, v2, v3, v4, o, ol, f, fl, m, ml, i, v1, v2, v3, v4,
l, ll; l, ll,
uv, uvArray;
if ( this.autoClear ) { if ( this.autoClear ) {
...@@ -68,99 +69,9 @@ THREE.WebGLRenderer = function () { ...@@ -68,99 +69,9 @@ THREE.WebGLRenderer = function () {
object = scene.objects[ o ]; object = scene.objects[ o ];
if ( object instanceof THREE.Mesh ) { var materialFace, fi;
if ( !object.__webGLVertexBuffer ) {
vertexArray = [];
faceArray = [];
colorArray = [];
normalArray = [];
vertexIndex = 0;
for ( f = 0, fl = object.geometry.faces.length; f < fl; f++ ) {
face = object.geometry.faces[ f ];
faceColor = face.color;
normal = face.normal;
if ( face instanceof THREE.Face3 ) {
v1 = object.geometry.vertices[ face.a ].position;
v2 = object.geometry.vertices[ face.b ].position;
v3 = object.geometry.vertices[ face.c ].position;
vertexArray.push( v1.x, v1.y, v1.z );
vertexArray.push( v2.x, v2.y, v2.z );
vertexArray.push( v3.x, v3.y, v3.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
faceArray.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 );
vertexIndex += 3;
} else if ( face instanceof THREE.Face4 ) {
v1 = object.geometry.vertices[ face.a ].position;
v2 = object.geometry.vertices[ face.b ].position;
v3 = object.geometry.vertices[ face.c ].position;
v4 = object.geometry.vertices[ face.d ].position;
vertexArray.push( v1.x, v1.y, v1.z );
vertexArray.push( v2.x, v2.y, v2.z );
vertexArray.push( v3.x, v3.y, v3.z );
vertexArray.push( v4.x, v4.y, v4.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
faceArray.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 );
faceArray.push( vertexIndex, vertexIndex + 2, vertexIndex + 3 );
vertexIndex += 4;
}
}
if ( !vertexArray.length ) {
continue;
}
object.__webGLVertexBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLVertexBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertexArray ), _gl.STATIC_DRAW );
object.__webGLNormalBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLNormalBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( normalArray ), _gl.STATIC_DRAW );
object.__webGLColorBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLColorBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( colorArray ), _gl.STATIC_DRAW );
object.__webGLFaceBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, object.__webGLFaceBuffer );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faceArray ), _gl.STATIC_DRAW );
object.__webGLFaceCount = faceArray.length;
}
if ( object instanceof THREE.Mesh ) {
viewMatrix.multiply( camera.matrix, object.matrix ); viewMatrix.multiply( camera.matrix, object.matrix );
...@@ -174,51 +85,249 @@ THREE.WebGLRenderer = function () { ...@@ -174,51 +85,249 @@ THREE.WebGLRenderer = function () {
_gl.uniformMatrix4fv( _program.projectionMatrix, false, _program.projectionMatrixArray ); _gl.uniformMatrix4fv( _program.projectionMatrix, false, _program.projectionMatrixArray );
_gl.uniformMatrix4fv( _program.normalMatrix, false, _program.normalMatrixArray ); _gl.uniformMatrix4fv( _program.normalMatrix, false, _program.normalMatrixArray );
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLVertexBuffer ); // create separate VBOs per material
_gl.vertexAttribPointer( _program.position, 3, _gl.FLOAT, false, 0, 0 ); for (var m in object.materialFaces ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLNormalBuffer ); materialFace = object.materialFaces[m];
_gl.vertexAttribPointer( _program.normal, 3, _gl.FLOAT, false, 0, 0 ); material = object.material[m];
if( !material ) continue;
for ( m = 0, ml = object.material.length; m < ml; m++ ) { //log(material);
material = object.material[ m ]; if( !materialFace.__webGLVertexBuffer ) {
vertexArray = [];
faceArray = [];
colorArray = [];
normalArray = [];
uvArray = [];
vertexIndex = 0;
//log( "object.geometry.uvs: " + object.geometry.uvs.length + " " + object.geometry.uvs);
for ( f = 0, fl = materialFace.faces.length; f < fl; f++ ) {
fi = materialFace.faces[f];
face = object.geometry.faces[ fi ];
faceColor = face.color;
vertexNormals = face.vertexNormals;
normal = face.normal;
uv = object.geometry.uvs[ fi ];
if ( face instanceof THREE.Face3 ) {
v1 = object.geometry.vertices[ face.a ].position;
v2 = object.geometry.vertices[ face.b ].position;
v3 = object.geometry.vertices[ face.c ].position;
vertexArray.push( v1.x, v1.y, v1.z );
vertexArray.push( v2.x, v2.y, v2.z );
vertexArray.push( v3.x, v3.y, v3.z );
if ( vertexNormals.length == 3 ) {
normalArray.push( vertexNormals[0].x, vertexNormals[0].y, vertexNormals[0].z );
normalArray.push( vertexNormals[1].x, vertexNormals[1].y, vertexNormals[1].z );
normalArray.push( vertexNormals[2].x, vertexNormals[2].y, vertexNormals[2].z );
}
else {
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
}
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
if ( uv ) {
uvArray.push( uv[0].u, uv[0].v );
uvArray.push( uv[1].u, uv[1].v );
uvArray.push( uv[2].u, uv[2].v );
}
faceArray.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 );
vertexIndex += 3;
} else if ( face instanceof THREE.Face4 ) {
v1 = object.geometry.vertices[ face.a ].position;
v2 = object.geometry.vertices[ face.b ].position;
v3 = object.geometry.vertices[ face.c ].position;
v4 = object.geometry.vertices[ face.d ].position;
vertexArray.push( v1.x, v1.y, v1.z );
vertexArray.push( v2.x, v2.y, v2.z );
vertexArray.push( v3.x, v3.y, v3.z );
vertexArray.push( v4.x, v4.y, v4.z );
if ( vertexNormals.length == 4 ) {
normalArray.push( vertexNormals[0].x, vertexNormals[0].y, vertexNormals[0].z );
normalArray.push( vertexNormals[1].x, vertexNormals[1].y, vertexNormals[1].z );
normalArray.push( vertexNormals[2].x, vertexNormals[2].y, vertexNormals[2].z );
normalArray.push( vertexNormals[3].x, vertexNormals[3].y, vertexNormals[3].z );
}
else {
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
normalArray.push( normal.x, normal.y, normal.z );
}
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
colorArray.push( faceColor.r, faceColor.g, faceColor.b, faceColor.a );
if ( uv ) {
uvArray.push( uv[0].u, uv[0].v );
uvArray.push( uv[1].u, uv[1].v );
uvArray.push( uv[2].u, uv[2].v );
uvArray.push( uv[3].u, uv[3].v );
}
faceArray.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 );
faceArray.push( vertexIndex, vertexIndex + 2, vertexIndex + 3 );
vertexIndex += 4;
}
}
if ( !vertexArray.length ) {
continue;
}
/*
log( "vertices: " + vertexArray.length/3 );
log( "faces: " + faceArray.length/3 );
log( "normals: " + normalArray.length/3 );
log( "colors: " + colorArray.length/4 );
log( "uvs: " + uvArray.length/2 );
*/
materialFace.__webGLVertexBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLVertexBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertexArray ), _gl.STATIC_DRAW );
materialFace.__webGLNormalBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLNormalBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( normalArray ), _gl.STATIC_DRAW );
if( material instanceof THREE.MeshFaceColorFillMaterial || material instanceof THREE.MeshBitmapUVMappingMaterial ) {
materialFace.__webGLColorBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLColorBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( colorArray ), _gl.STATIC_DRAW );
}
materialFace.__webGLUVBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLUVBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( uvArray ), _gl.STATIC_DRAW );
materialFace.__webGLFaceBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, materialFace.__webGLFaceBuffer );
_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faceArray ), _gl.STATIC_DRAW );
materialFace.__webGLFaceCount = faceArray.length;
}
if ( material instanceof THREE.MeshColorFillMaterial ) { if ( material instanceof THREE.MeshColorFillMaterial ) {
if ( !material.__webGLColorBuffer ) { if ( !materialFace.__webGLColorBuffer ) {
colorArray = []; colorArray = [];
for ( i = 0; i < object.__webGLFaceCount; i ++ ) { for ( i = 0; i < materialFace.__webGLFaceCount; i ++ ) {
colorArray.push( material.color.r, material.color.g, material.color.b, material.color.a ); colorArray.push( material.color.r, material.color.g, material.color.b, material.color.a );
} }
material.__webGLColorBuffer = _gl.createBuffer(); materialFace.__webGLColorBuffer = _gl.createBuffer();
_gl.bindBuffer( _gl.ARRAY_BUFFER, material.__webGLColorBuffer ); _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLColorBuffer );
_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( colorArray ), _gl.STATIC_DRAW ); _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( colorArray ), _gl.STATIC_DRAW );
} }
_gl.uniform1i( _program.enableTexture, 0 );
} else if ( material instanceof THREE.MeshFaceColorFillMaterial ) {
_gl.uniform1i( _program.enableTexture, 0 );
} else if ( material instanceof THREE.MeshBitmapUVMappingMaterial ) {
if ( !material.__webGLTexture && material.loaded ) {
//log(material.bitmap);
material.__webGLTexture = _gl.createTexture();
_gl.bindTexture( _gl.TEXTURE_2D, material.__webGLTexture );
_gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, material.bitmap ) ;
_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, _gl.LINEAR );
//_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR_MIPMAP_NEAREST );
_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR_MIPMAP_LINEAR );
_gl.generateMipmap( _gl.TEXTURE_2D );
_gl.bindTexture( _gl.TEXTURE_2D, null );
}
_gl.uniform1i( _program.enableTexture, 1 );
_gl.activeTexture( _gl.TEXTURE0 );
_gl.bindTexture( _gl.TEXTURE_2D, material.__webGLTexture );
_gl.uniform1i( _program.diffuse, 0 );
}
// vertices
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLVertexBuffer );
_gl.vertexAttribPointer( _program.position, 3, _gl.FLOAT, false, 0, 0 );
// normals
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLNormalBuffer );
_gl.vertexAttribPointer( _program.normal, 3, _gl.FLOAT, false, 0, 0 );
// uvs
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLUVBuffer );
if ( object.geometry.uvs.length ) {
_gl.enableVertexAttribArray( _program.uv );
_gl.vertexAttribPointer( _program.uv, 2, _gl.FLOAT, false, 0, 0 );
}
else {
_gl.disableVertexAttribArray( _program.uv );
}
// colors
_gl.bindBuffer( _gl.ARRAY_BUFFER, materialFace.__webGLColorBuffer );
_gl.enableVertexAttribArray( _program.color );
_gl.vertexAttribPointer( _program.color, 4, _gl.FLOAT, false, 0, 0 );
// render faces
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, materialFace.__webGLFaceBuffer );
_gl.drawElements( _gl.TRIANGLES, materialFace.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
}
}
_gl.bindBuffer( _gl.ARRAY_BUFFER, material.__webGLColorBuffer );
_gl.vertexAttribPointer( _program.color, 4, _gl.FLOAT, false, 0, 0 );
} else if ( material instanceof THREE.MeshFaceColorFillMaterial ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLColorBuffer );
_gl.enableVertexAttribArray( _program.color );
_gl.vertexAttribPointer( _program.color, 4, _gl.FLOAT, false, 0, 0 );
}
}
_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, object.__webGLFaceBuffer );
_gl.drawElements( _gl.TRIANGLES, object.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
}
} }
}; };
...@@ -227,7 +336,7 @@ THREE.WebGLRenderer = function () { ...@@ -227,7 +336,7 @@ THREE.WebGLRenderer = function () {
try { try {
_gl = _canvas.getContext( 'experimental-webgl' ); _gl = _canvas.getContext( 'experimental-webgl', { antialias: true} );
} catch(e) { } } catch(e) { }
...@@ -245,8 +354,9 @@ THREE.WebGLRenderer = function () { ...@@ -245,8 +354,9 @@ THREE.WebGLRenderer = function () {
_gl.depthFunc( _gl.LEQUAL ); _gl.depthFunc( _gl.LEQUAL );
_gl.enable( _gl.BLEND ); _gl.enable( _gl.BLEND );
_gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA ); //_gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA );
// _gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE ); // cool! // _gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE ); // cool!
_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
_gl.clearColor( 0, 0, 0, 0 ); _gl.clearColor( 0, 0, 0, 0 );
} }
...@@ -260,13 +370,20 @@ THREE.WebGLRenderer = function () { ...@@ -260,13 +370,20 @@ THREE.WebGLRenderer = function () {
"precision highp float;", "precision highp float;",
"#endif", "#endif",
"uniform bool enableTexture;",
"uniform sampler2D diffuse;",
"varying vec2 vuv;",
"varying vec4 vcolor;", "varying vec4 vcolor;",
"varying vec3 lightWeighting;", "varying vec3 lightWeighting;",
"void main(){", "void main(){",
"if(enableTexture) {",
"gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);", "vec4 texelColor = texture2D(diffuse, vuv);",
"gl_FragColor = vec4(texelColor.rgb * lightWeighting, texelColor.a);",
"} else {",
"gl_FragColor = vec4(vcolor.rgb * lightWeighting, vcolor.a);",
"}",
"}" "}"
].join("\n") ) ); ].join("\n") ) );
...@@ -274,6 +391,7 @@ THREE.WebGLRenderer = function () { ...@@ -274,6 +391,7 @@ THREE.WebGLRenderer = function () {
"attribute vec3 position;", "attribute vec3 position;",
"attribute vec3 normal;", "attribute vec3 normal;",
"attribute vec4 color;", "attribute vec4 color;",
"attribute vec2 uv;",
"uniform bool enableLighting;", "uniform bool enableLighting;",
"uniform vec3 ambientColor;", "uniform vec3 ambientColor;",
...@@ -285,6 +403,7 @@ THREE.WebGLRenderer = function () { ...@@ -285,6 +403,7 @@ THREE.WebGLRenderer = function () {
"uniform mat4 normalMatrix;", "uniform mat4 normalMatrix;",
"varying vec4 vcolor;", "varying vec4 vcolor;",
"varying vec3 lightWeighting;", "varying vec3 lightWeighting;",
"varying vec2 vuv;",
"void main(void) {", "void main(void) {",
...@@ -292,11 +411,12 @@ THREE.WebGLRenderer = function () { ...@@ -292,11 +411,12 @@ THREE.WebGLRenderer = function () {
"lightWeighting = vec3(1.0, 1.0, 1.0);", "lightWeighting = vec3(1.0, 1.0, 1.0);",
"} else {", "} else {",
"vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);", "vec4 transformedNormal = normalMatrix * vec4(normal, 1.0);",
"float directionalLightWeighting = max(dot(transformedNormal.xyz, lightingDirection), 0.0);", "float directionalLightWeighting = max(dot(normalize(transformedNormal.xyz), lightingDirection), 0.0);",
"lightWeighting = ambientColor + directionalColor * directionalLightWeighting;", "lightWeighting = ambientColor + directionalColor * directionalLightWeighting;",
"}", "}",
"vcolor = color;", "vcolor = color;",
"vuv = uv;",
"gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );", "gl_Position = projectionMatrix * viewMatrix * vec4( position, 1.0 );",
"}"].join("\n") ) ); "}"].join("\n") ) );
...@@ -320,6 +440,8 @@ THREE.WebGLRenderer = function () { ...@@ -320,6 +440,8 @@ THREE.WebGLRenderer = function () {
_program.directionalColor = _gl.getUniformLocation(_program, 'directionalColor'); _program.directionalColor = _gl.getUniformLocation(_program, 'directionalColor');
_program.lightingDirection = _gl.getUniformLocation(_program, 'lightingDirection'); _program.lightingDirection = _gl.getUniformLocation(_program, 'lightingDirection');
_program.enableTexture = _gl.getUniformLocation(_program, 'enableTexture');
_program.color = _gl.getAttribLocation( _program, "color" ); _program.color = _gl.getAttribLocation( _program, "color" );
_gl.enableVertexAttribArray( _program.color ); _gl.enableVertexAttribArray( _program.color );
...@@ -329,6 +451,12 @@ THREE.WebGLRenderer = function () { ...@@ -329,6 +451,12 @@ THREE.WebGLRenderer = function () {
_program.normal = _gl.getAttribLocation( _program, "normal" ); _program.normal = _gl.getAttribLocation( _program, "normal" );
_gl.enableVertexAttribArray( _program.normal ); _gl.enableVertexAttribArray( _program.normal );
_program.uv = _gl.getAttribLocation( _program, "uv" );
_gl.enableVertexAttribArray( _program.uv );
_program.diffuse = _gl.getUniformLocation( _program, "diffuse");
_gl.uniform1i( _program.diffuse, 0 );
_program.viewMatrixArray = new Float32Array(16); _program.viewMatrixArray = new Float32Array(16);
_program.projectionMatrixArray = new Float32Array(16); _program.projectionMatrixArray = new Float32Array(16);
......
"""Convert Wavefront OBJ / MTL files into Three.js
-------------------------
How to use this converter
-------------------------
python convert_obj_threejs.py -i filename.obj -o filename.js [-a center|top|bottom]
Note: by default, model is centered (middle of bounding box goes to 0,0,0).
--------------------------------------------------
How to use generated JS file in your HTML document
--------------------------------------------------
<script type="text/javascript" src="Three.js"></script>
<script type="text/javascript" src="ModelName.js"></script>
...
<script type="text/javascript">
...
var normalizeUVsFlag = 1; // set to 1 if canvas render has missing materials
var geometry = new ModelName( path_to_textures );
var mesh = new THREE.Mesh( geometry, geometry.materials, normalizeUVsFlag );
...
</script>
-------------------------------------
Parsers based on formats descriptions
-------------------------------------
http://en.wikipedia.org/wiki/Obj
http://en.wikipedia.org/wiki/Material_Template_Library
-------------------
Current limitations
-------------------
- for the moment, only diffuse color and texture are used
(will need to extend shaders / renderers / materials in Three)
- models cannot have more than 65,536 vertices
(this comes from WebGL using just 16-bit indices,
could be worked around by expanding indexed
faces into full vertex definitions)
- texture coordinates can be wrong in canvas renderer
(there is crude normalization, but it doesn't
work for all cases)
- everything is using smoothing
(if you want flat shading for whole mesh,
don't export normals, then Three will
compute own normals)
----------------------------------------------
How to get proper OBJ + MTL files with Blender
----------------------------------------------
0. Remove default cube (press DEL and ENTER)
1. Import / create model
2. Select all meshes (Select -> Select All by Type -> Mesh)
3. Export to OBJ (File -> Export -> Wavefront .obj) [*]
- enable following options in exporter
Material Groups
Rotate X90
Apply Modifiers
High Quality Normals
Copy Images
Selection Only
Objects as OBJ Objects
UVs
Normals
Materials
Edges
- select empty folder
- give your exported file name with "obj" extension
- click on "Export OBJ" button
4. Your model is now all files in this folder (OBJ, MTL, number of images)
- this converter assumes all files staying in the same folder,
(OBJ / MTL files use relative paths)
- for WebGL, textures must be power of 2 sized
[*] If OBJ export fails (Blender 2.54 beta), patch your Blender installation
following instructions here:
http://www.blendernation.com/2010/09/12/blender-2-54-beta-released/
------
Author
------
AlteredQualia http://alteredqualia.com
"""
import fileinput
import operator
import random
import os.path
import getopt
import sys
# #####################################################
# Configuration
# #####################################################
ALIGN = "center" # center bottom top none
# default colors for debugging (each material gets one distinct color):
# white, red, green, blue, yellow, cyan, magenta
COLORS = [0xffeeeeee, 0xffee0000, 0xff00ee00, 0xff0000ee, 0xffeeee00, 0xff00eeee, 0xffee00ee]
# #####################################################
# Templates
# #####################################################
TEMPLATE_FILE = u"""\
// Converted from: %(fname)s
// vertices: %(nvertex)d
// faces: %(nface)d
// materials: %(nmaterial)d
//
// This file was generated by "convert_obj_treejs.py"
var %(name)s = function ( urlbase ) {
var scope = this;
THREE.Geometry.call(this);
var materials = [%(materials)s];
init_materials();
var normals = [%(normals)s];
%(vertices)s
%(uvs)s
%(faces)s
this.computeCentroids();
this.computeNormals();
function material_color( mi ) {
var m = materials[mi];
if( m.col_diffuse )
return (m.col_diffuse[0]*255 << 16) + (m.col_diffuse[1]*255 << 8) + m.col_diffuse[2]*255;
else if ( m.a_dbg_color )
return m.a_dbg_color;
else
return 0xffeeeeee;
}
function v( x, y, z ) {
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
}
function f3( a, b, c, material ) {
var color = material_color(material);
scope.faces.push( new THREE.Face3( a, b, c, null, new THREE.Color(color), material ) );
}
function f4( a, b, c, d, material ) {
var color = material_color(material);
scope.faces.push( new THREE.Face4( a, b, c, d, null, new THREE.Color(color), material ) );
}
function f3n( a, b, c, material, n1, n2, n3 ) {
var color = material_color(material);
var n1x = normals[n1][0];
var n1y = normals[n1][1];
var n1z = normals[n1][2];
var n2x = normals[n2][0];
var n2y = normals[n2][1];
var n2z = normals[n2][2];
var n3x = normals[n3][0];
var n3y = normals[n3][1];
var n3z = normals[n3][2];
scope.faces.push( new THREE.Face3( a, b, c,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )],
new THREE.Color(color), material ) );
}
function f4n( a, b, c, d, material, n1, n2, n3, n4 ) {
var color = material_color(material);
var n1x = normals[n1][0];
var n1y = normals[n1][1];
var n1z = normals[n1][2];
var n2x = normals[n2][0];
var n2y = normals[n2][1];
var n2z = normals[n2][2];
var n3x = normals[n3][0];
var n3y = normals[n3][1];
var n3z = normals[n3][2];
var n4x = normals[n4][0];
var n4y = normals[n4][1];
var n4z = normals[n4][2];
scope.faces.push( new THREE.Face4( a, b, c, d,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )],
new THREE.Color(color), material ) );
}
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
var uv = [];
uv.push( new THREE.UV( u1, v1 ) );
uv.push( new THREE.UV( u2, v2 ) );
uv.push( new THREE.UV( u3, v3 ) );
if ( u4 && v4 ) uv.push( new THREE.UV( u4, v4 ) );
scope.uvs.push( uv );
}
function init_materials() {
scope.materials = [];
for(var i=0; i<materials.length; ++i) {
scope.materials[i] = create_material( materials[i], urlbase );
}
}
function is_pow2( n ) {
var l = Math.log(n) / Math.LN2;
return Math.floor(l) == l;
}
function nearest_pow2(n) {
var l = Math.log(n) / Math.LN2;
return Math.pow( 2, Math.round(l) );
}
function create_material( m ) {
var material;
if( m.map_diffuse && urlbase ) {
var texture = document.createElement( 'canvas' );
material = new THREE.MeshBitmapUVMappingMaterial( texture );
var image = new Image();
image.onload = function () {
if ( !is_pow2(this.width) || !is_pow2(this.height) ) {
var w = nearest_pow2( this.width );
var h = nearest_pow2( this.height );
material.bitmap.width = w;
material.bitmap.height = h;
material.bitmap.getContext("2d").drawImage( this, 0, 0, w, h );
}
else {
material.bitmap = this;
}
material.loaded = 1;
};
image.src = urlbase + "/" + m.map_diffuse;
}
else if( m.col_diffuse ) {
var color = (m.col_diffuse[0]*255 << 16) + (m.col_diffuse[1]*255 << 8) + m.col_diffuse[2]*255;
material = new THREE.MeshColorFillMaterial( color, m.transparency );
}
else if( m.a_dbg_color ) {
material = new THREE.MeshColorFillMaterial( m.a_dbg_color );
}
else {
material = new THREE.MeshFaceColorFillMaterial( );
}
return material;
}
}
%(name)s.prototype = new THREE.Geometry();
%(name)s.prototype.constructor = %(name)s;
"""
TEMPLATE_VERTEX = "\tv(%f,%f,%f);"
TEMPLATE_UV3 = "\tuv(%f,%f,%f,%f,%f,%f);"
TEMPLATE_UV4 = "\tuv(%f,%f,%f,%f,%f,%f,%f,%f);"
TEMPLATE_FACE3 = "\tf3(%d,%d,%d,%d);"
TEMPLATE_FACE4 = "\tf4(%d,%d,%d,%d,%d);"
TEMPLATE_FACE3N = "\tf3n(%d,%d,%d, %d, %d,%d,%d);"
TEMPLATE_FACE4N = "\tf4n(%d,%d,%d,%d, %d, %d,%d,%d,%d);"
TEMPLATE_N = "[%f,%f,%f]"
# #####################################################
# Utils
# #####################################################
def file_exists(filename):
"""Return true if file exists and is accessible for reading.
Should be safer than just testing for existence due to links and
permissions magic on Unix filesystems.
@rtype: boolean
"""
try:
f = open(filename, 'r')
f.close()
return True
except IOError:
return False
def get_name(fname):
"""Create model name based of filename ("path/fname.js" -> "Fname").
"""
return os.path.basename(fname).split(".")[0].capitalize()
def bbox(vertices):
"""Compute bounding box of vertex array.
"""
if len(vertices)>0:
minx = maxx = vertices[0][0]
miny = maxy = vertices[0][1]
minz = maxz = vertices[0][2]
for v in vertices[1:]:
if v[0]<minx:
minx = v[0]
elif v[0]>maxx:
maxx = v[0]
if v[1]<miny:
miny = v[1]
elif v[1]>maxy:
maxy = v[1]
if v[2]<minz:
minz = v[2]
elif v[2]>maxz:
maxz = v[2]
return { 'x':[minx,maxx], 'y':[miny,maxy], 'z':[minz,maxz] }
else:
return { 'x':[0,0], 'y':[0,0], 'z':[0,0] }
def translate(vertices, t):
"""Translate array of vertices by vector t.
"""
for i in xrange(len(vertices)):
vertices[i][0] += t[0]
vertices[i][1] += t[1]
vertices[i][2] += t[2]
def center(vertices):
"""Center model (middle of bounding box).
"""
bb = bbox(vertices)
cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0
cy = bb['y'][0] + (bb['y'][1] - bb['y'][0])/2.0
cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0
translate(vertices, [-cx,-cy,-cz])
def top(vertices):
"""Align top of the model with the floor (Y-axis) and center it around X and Z.
"""
bb = bbox(vertices)
cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0
cy = bb['y'][1]
cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0
translate(vertices, [-cx,-cy,-cz])
def bottom(vertices):
"""Align bottom of the model with the floor (Y-axis) and center it around X and Z.
"""
bb = bbox(vertices)
cx = bb['x'][0] + (bb['x'][1] - bb['x'][0])/2.0
cy = bb['y'][0]
cz = bb['z'][0] + (bb['z'][1] - bb['z'][0])/2.0
translate(vertices, [-cx,cy,-cz])
def normalize(v):
"""Normalize 3d vector"""
l = math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
v[0] /= l
v[1] /= l
v[2] /= l
# #####################################################
# MTL parser
# #####################################################
def parse_mtl(fname):
"""Parse MTL file.
"""
materials = {}
for line in fileinput.input(fname):
chunks = line.split()
if len(chunks) > 0:
# Material start
# newmtl identifier
if chunks[0] == "newmtl" and len(chunks) == 2:
identifier = chunks[1]
if not identifier in materials:
materials[identifier] = {}
# Diffuse color
# Kd 1.000 1.000 1.000
if chunks[0] == "Kd" and len(chunks) == 4:
materials[identifier]["col_diffuse"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Ambient color
# Ka 1.000 1.000 1.000
if chunks[0] == "Ka" and len(chunks) == 4:
materials[identifier]["col_ambient"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Specular color
# Ks 1.000 1.000 1.000
if chunks[0] == "Ks" and len(chunks) == 4:
materials[identifier]["col_specular"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Specular coefficient
# Ns 154.000
if chunks[0] == "Ns" and len(chunks) == 2:
materials[identifier]["specular_coef"] = float(chunks[1])
# Transparency
# Tr 0.9 or d 0.9
if (chunks[0] == "Tr" or chunks[0] == "d") and len(chunks) == 2:
materials[identifier]["transparency"] = float(chunks[1])
# Optical density
# Ni 1.0
if chunks[0] == "Ni" and len(chunks) == 2:
materials[identifier]["optical_density"] = float(chunks[1])
# Diffuse texture
# map_Kd texture_diffuse.jpg
if chunks[0] == "map_Kd" and len(chunks) == 2:
materials[identifier]["map_diffuse"] = chunks[1]
# Ambient texture
# map_Ka texture_ambient.jpg
if chunks[0] == "map_Ka" and len(chunks) == 2:
materials[identifier]["map_ambient"] = chunks[1]
# Specular texture
# map_Ks texture_specular.jpg
if chunks[0] == "map_Ks" and len(chunks) == 2:
materials[identifier]["map_specular"] = chunks[1]
# Alpha texture
# map_d texture_alpha.png
if chunks[0] == "map_d" and len(chunks) == 2:
materials[identifier]["map_alpha"] = chunks[1]
# Bump texture
# map_bump texture_bump.jpg or bump texture_bump.jpg
if (chunks[0] == "map_bump" or chunks[0] == "bump") and len(chunks) == 2:
materials[identifier]["map_bump"] = chunks[1]
# Illumination
# illum 2
#
# 0. Color on and Ambient off
# 1. Color on and Ambient on
# 2. Highlight on
# 3. Reflection on and Ray trace on
# 4. Transparency: Glass on, Reflection: Ray trace on
# 5. Reflection: Fresnel on and Ray trace on
# 6. Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
# 7. Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
# 8. Reflection on and Ray trace off
# 9. Transparency: Glass on, Reflection: Ray trace off
# 10. Casts shadows onto invisible surfaces
if chunks[0] == "illum" and len(chunks) == 2:
materials[identifier]["illumination"] = int(chunks[1])
return materials
# #####################################################
# OBJ parser
# #####################################################
def parse_vertex(text):
"""Parse text chunk specifying single vertex.
Possible formats:
vertex index
vertex index / texture index
vertex index / texture index / normal index
vertex index / / normal index
"""
v = 0
t = 0
n = 0
chunks = text.split("/")
v = int(chunks[0])
if len(chunks) > 1:
if chunks[1]:
t = int(chunks[1])
if len(chunks) > 2:
if chunks[2]:
n = int(chunks[2])
return { 'v':v, 't':t, 'n':n }
def parse_obj(fname):
"""Parse OBJ file.
"""
vertices = []
normals = []
uvs = []
faces = []
materials = {}
mcounter = 0
mcurrent = 0
mtllib = ""
# current face state
group = 0
object = 0
smooth = 0
for line in fileinput.input(fname):
chunks = line.split()
if len(chunks) > 0:
# Vertices as (x,y,z) coordinates
# v 0.123 0.234 0.345
if chunks[0] == "v" and len(chunks) == 4:
x = float(chunks[1])
y = float(chunks[2])
z = float(chunks[3])
vertices.append([x,y,z])
# Normals in (x,y,z) form; normals might not be unit
# vn 0.707 0.000 0.707
if chunks[0] == "vn" and len(chunks) == 4:
x = float(chunks[1])
y = float(chunks[2])
z = float(chunks[3])
normals.append([x,y,z])
# Texture coordinates in (u,v[,w]) coordinates, w is optional
# vt 0.500 -1.352 [0.234]
if chunks[0] == "vt" and len(chunks) >= 3:
u = float(chunks[1])
v = float(chunks[2])
w = 0
if len(chunks)>3:
w = float(chunks[3])
uvs.append([u,v,w])
# Face
if chunks[0] == "f" and len(chunks) >= 4:
vertex_index = []
uv_index = []
normal_index = []
for v in chunks[1:]:
vertex = parse_vertex(v)
if vertex['v']:
vertex_index.append(vertex['v'])
if vertex['t']:
uv_index.append(vertex['t'])
if vertex['n']:
normal_index.append(vertex['n'])
faces.append({
'vertex':vertex_index,
'uv':uv_index,
'normal':normal_index,
'material':mcurrent,
'group':group,
'object':object,
'smooth':smooth,
})
# Group
if chunks[0] == "g" and len(chunks) == 2:
group = chunks[1]
# Object
if chunks[0] == "o" and len(chunks) == 2:
object = chunks[1]
# Materials definition
if chunks[0] == "mtllib" and len(chunks) == 2:
mtllib = chunks[1]
# Material
if chunks[0] == "usemtl" and len(chunks) == 2:
material = chunks[1]
if not material in materials:
mcurrent = mcounter
materials[material] = mcounter
mcounter += 1
else:
mcurrent = materials[material]
# Smooth shading
if chunks[0] == "s" and len(chunks) == 2:
smooth = chunks[1]
return faces, vertices, uvs, normals, materials, mtllib
# #####################################################
# Generator
# #####################################################
def generate_vertex(v):
return TEMPLATE_VERTEX % (v[0], v[1], v[2])
def generate_uv(f, uvs):
ui = f['uv']
if len(ui) == 3:
return TEMPLATE_UV3 % (uvs[ui[0]-1][0], 1.0 - uvs[ui[0]-1][1],
uvs[ui[1]-1][0], 1.0 - uvs[ui[1]-1][1],
uvs[ui[2]-1][0], 1.0 - uvs[ui[2]-1][1])
elif len(ui) == 4:
return TEMPLATE_UV4 % (uvs[ui[0]-1][0], 1.0 - uvs[ui[0]-1][1],
uvs[ui[1]-1][0], 1.0 - uvs[ui[1]-1][1],
uvs[ui[2]-1][0], 1.0 - uvs[ui[2]-1][1],
uvs[ui[3]-1][0], 1.0 - uvs[ui[3]-1][1])
return ""
def generate_face(f):
vi = f['vertex']
if f["normal"]:
ni = f['normal']
if len(vi) == 3:
return TEMPLATE_FACE3N % (vi[0]-1, vi[1]-1, vi[2]-1, f['material'], ni[0]-1, ni[1]-1, ni[2]-1)
elif len(vi) == 4:
return TEMPLATE_FACE4N % (vi[0]-1, vi[1]-1, vi[2]-1, vi[3]-1, f['material'], ni[0]-1, ni[1]-1, ni[2]-1, n[3]-1)
else:
if len(vi) == 3:
return TEMPLATE_FACE3 % (vi[0]-1, vi[1]-1, vi[2]-1, f['material'])
elif len(vi) == 4:
return TEMPLATE_FACE4 % (vi[0]-1, vi[1]-1, vi[2]-1, vi[3]-1, f['material'])
return ""
def generate_normal(n):
return TEMPLATE_N % (n[0], n[1], n[2])
def generate_color(i):
"""Generate hex color corresponding to integer.
Colors should have well defined ordering.
First N colors are hardcoded, then colors are random
(must seed random number generator with deterministic value
before getting colors).
"""
if i < len(COLORS):
return "0x%x" % COLORS[i]
else:
return "0x%x" % (int(0xffffff * random.random()) + 0xff000000)
def value2string(v):
if type(v)==str and v[0] != "0":
return '"%s"' % v
return str(v)
def generate_materials(mtl, materials):
"""Generate JS array of materials objects
JS material objects are basically prettified one-to-one
mappings of MTL properties in JSON format.
"""
mtl_array = []
for m in mtl:
index = materials[m]
# add debug information
# materials should be sorted according to how
# they appeared in OBJ file (for the first time)
# this index is identifier used in face definitions
mtl[m]['a_dbg_name'] = m
mtl[m]['a_dbg_index'] = index
mtl[m]['a_dbg_color'] = generate_color(index)
mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
mtl_string = "\t{\n%s\n\t}" % mtl_raw
mtl_array.append([index, mtl_string])
return ",\n\n".join([m for i,m in sorted(mtl_array)])
def generate_mtl(materials):
"""Generate dummy materials (if there is no MTL file).
"""
mtl = {}
for m in materials:
index = materials[m]
mtl[m] = {
'a_dbg_name': m,
'a_dbg_index': index,
'a_dbg_color': generate_color(index)
}
return mtl
# #####################################################
# API
# #####################################################
def convert(infile, outfile):
"""Convert infile.obj to outfile.js
Here is where everything happens. If you need to automate conversions,
just import this file as Python module and call this method.
"""
if not file_exists(infile):
print "Couldn't find [%s]" % infile
return
faces, vertices, uvs, normals, materials, mtllib = parse_obj(infile)
if ALIGN == "center":
center(vertices)
elif ALIGN == "bottom":
bottom(vertices)
elif ALIGN == "top":
top(vertices)
random.seed(42) # to get well defined color order for materials
uv_string = ""
if len(uvs)>0:
uv_string = "\n".join([generate_uv(f, uvs) for f in faces])
mtl = {}
if mtllib:
# create full pathname for MTL (included from OBJ)
path = os.path.dirname(infile)
fname = os.path.join(path, mtllib)
if file_exists(fname):
mtl = parse_mtl(fname)
else:
print "Couldn't find [%s]" % fname
if not mtl:
# if there is no specified MTL or if loading failed,
# generate default materials with debug colors
mtl = generate_mtl(materials)
text = TEMPLATE_FILE % {
"name" : get_name(outfile),
"vertices" : "\n".join([generate_vertex(v) for v in vertices]),
"faces" : "\n".join([generate_face(f) for f in faces]),
"uvs" : uv_string,
"normals" : ",".join(generate_normal(n) for n in normals),
"materials" : generate_materials(mtl, materials),
"fname" : infile,
"nvertex" : len(vertices),
"nface" : len(faces),
"nmaterial" : len(materials)
}
out = open(outfile, "w")
out.write(text)
out.close()
print "%d vertices, %d faces, %d materials" % (len(vertices), len(faces), len(materials))
# #############################################################################
# Helpers
# #############################################################################
def usage():
print "Usage: %s -i filename.obj -o filename.js [-a center|top|bottom]" % os.path.basename(sys.argv[0])
# #####################################################
# Main
# #####################################################
if __name__ == "__main__":
# get parameters from the command line
try:
opts, args = getopt.getopt(sys.argv[1:], "hi:o:a:", ["help", "input=", "output=", "align="])
except getopt.GetoptError:
usage()
sys.exit(2)
infile = outfile = ""
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
elif o in ("-i", "--input"):
infile = a
elif o in ("-o", "--output"):
outfile = a
elif o in ("-a", "--align"):
if a in ("top", "bottom", "center"):
ALIGN = a
if infile == "" or outfile == "":
usage()
sys.exit(2)
print "Converting [%s] into [%s] ..." % (infile, outfile)
convert(infile, outfile)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册