提交 7d8fd5f8 编写于 作者: M Mr.doob

CanvasRenderer now renders MeshDepthMaterial properly (per vertex). Gouraud is one step closer :)

Cleaned up CanvasRenderer and SVGRenderer code a bit.
上级 05b496d8
// Three.js r28 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a: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=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(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("+~~(this.r*255)+","+~~(this.g*255)+","+~~(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.Ray=function(a,b){this.origin=a||new THREE.Vector3();this.direction=b||new THREE.Vector3()};THREE.Ray.prototype={intersectScene:function(f){var c,a,b,e=f.objects,d=[];for(c=0,a=e.length;c<a;c++){b=e[c];if(b instanceof THREE.Mesh){d=d.concat(this.intersectObject(b))}}d.sort(function(h,g){return h.distance-g.distance});return d},intersectObject:function(w){var n,j,i,t,s,q,p,v,k,x,u,r,g=w.geometry,h=g.vertices,o,e=[],m;for(n=0,j=g.faces.length;n<j;n++){i=g.faces[n];u=this.origin.clone();r=this.direction.clone();t=w.matrix.transform(h[i.a].position.clone());s=w.matrix.transform(h[i.b].position.clone());q=w.matrix.transform(h[i.c].position.clone());p=i instanceof THREE.Face4?w.matrix.transform(h[i.d].position.clone()):null;v=w.matrixRotation.transform(i.normal.clone());k=r.dot(v);if(k<0){x=v.dot(new THREE.Vector3().sub(t,u))/k;m=u.addSelf(r.multiplyScalar(x));if(i instanceof THREE.Face3){if(l(m,t,s,q)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}else{if(i instanceof THREE.Face4){if(l(m,t,s,p)||l(m,s,q,p)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}}}}return e;function l(d,G,D,B){var J=B.clone().subSelf(G),H=D.clone().subSelf(G),E=d.clone().subSelf(G),F=J.dot(J),C=J.dot(H),A=J.dot(E),z=H.dot(H),f=H.dot(E),y=1/(F*z-C*C),K=(z*A-C*f)*y,I=(F*f-C*A)*y;return(K>0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;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(m){var e,b,o,g,i,j,l,k,d,c,a,h=new THREE.Vector3(),p=new THREE.Vector3();for(o=0,g=this.vertices.length;o<g;o++){i=this.vertices[o];i.normal.set(0,0,0)}for(j=0,l=this.faces.length;j<l;j++){k=this.faces[j];if(m&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.addSelf(k.vertexNormals[e])}h.divideScalar(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);p.sub(d.position,c.position);h.crossSelf(p);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]};for(var 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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae<ad;ae+=af){ac=f(c,ae);ah=f(c,ae+x.vertex_coordinate_bytes);ag=f(c,ae+x.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,ac,ah,ag)}return x.nvertices*af}function H(ai){var ae,ac,ah,ag,af=x.normal_coordinate_bytes*3,ad=ai+x.nnormals*af;for(ae=ai;ae<ad;ae+=af){ac=i(c,ae);ah=i(c,ae+x.normal_coordinate_bytes);ag=i(c,ae+x.normal_coordinate_bytes*2);A.push(ac/127,ah/127,ag/127)}return x.nnormals*af}function G(ah){var af,ae,ad,ag=x.uv_coordinate_bytes*2,ac=ah+x.nuvs*ag;for(af=ah;af<ac;af+=ag){ae=f(c,af);ad=f(c,af+x.uv_coordinate_bytes);L.push(ae,ad)}return x.nuvs*ag}function M(af){var ae,ad,ag,ac;ae=v(c,af);ad=v(c,af+V);ag=v(c,af+T);ac=Z(c,af+O);THREE.Loader.prototype.f3(I,ae,ad,ag,ac)}function m(ah){var ag,ae,aj,ad,af,ac,ai;ag=v(c,ah);ae=v(c,ah+V);aj=v(c,ah+T);ad=Z(c,ah+O);af=v(c,ah+U);ac=v(c,ah+R);ai=v(c,ah+P);THREE.Loader.prototype.f3n(I,A,ag,ae,aj,ad,af,ac,ai)}function E(af){var ae,ad,ah,ag,ac;ae=v(c,af);ad=v(c,af+D);ah=v(c,af+C);ag=v(c,af+B);ac=Z(c,af+y);THREE.Loader.prototype.f4(I,ae,ad,ah,ag,ac)}function l(af){var al,ak,aj,ai,ac,ah,ag,ae,ad;al=v(c,af);ak=v(c,af+D);aj=v(c,af+C);ai=v(c,af+B);ac=Z(c,af+y);ah=v(c,af+r);ag=v(c,af+q);ae=v(c,af+p);ad=v(c,af+o);THREE.Loader.prototype.f4n(I,A,al,ak,aj,ai,ac,ah,ag,ae,ad)}function Y(ai){var ah,ae,ac,ag,af,ad,al,ak,aj;ah=v(c,ai);ae=v(c,ai+u);ac=v(c,ai+t);ag=L[ah*2];al=L[ah*2+1];af=L[ae*2];ak=L[ae*2+1];ad=L[ac*2];aj=L[ac*2+1];THREE.Loader.prototype.uv(I,ag,al,af,ak,ad,aj)}function X(ak){var aj,ag,ae,ad,ai,ah,af,ac,ao,an,am,al;aj=v(c,ak);ag=v(c,ak+N);ae=v(c,ak+K);ad=v(c,ak+J);ai=L[aj*2];ao=L[aj*2+1];ah=L[ag*2];an=L[ag*2+1];af=L[ae*2];am=L[ae*2+1];ac=L[ad*2];al=L[ad*2+1];THREE.Loader.prototype.uv(I,ai,ao,ah,an,af,am,ac,al)}function Q(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes,ac=af+x.ntri_flat*ae;for(ad=af;ad<ac;ad+=ae){M(ad)}return ac-af}function ab(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){M(ad);Y(ad+af)}return ac-ag}function S(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ac=af+x.ntri_smooth*ae;for(ad=af;ad<ac;ad+=ae){m(ad)}return ac-af}function n(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){m(ad);Y(ad+af)}return ac-ag}function g(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes,ac=af+x.nquad_flat*ae;for(ad=af;ad<ac;ad+=ae){E(ad)}return ac-af}function s(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){E(ad);X(ad+af)}return ac-ag}function k(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ac=af+x.nquad_smooth*ae;for(ad=af;ad<ac;ad+=ae){l(ad)}return ac-af}function z(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){l(ad);X(ad+af)}return ac-ag}};d.prototype=new THREE.Geometry();d.prototype.constructor=d;e(new d(b))},createModel:function(b,d,a){var c=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,b.materials,f);e();h();this.computeCentroids();this.computeNormals();function e(){var m,k,j,o,n;for(m=0,k=b.vertices.length;m<k;m+=3){j=b.vertices[m];o=b.vertices[m+1];n=b.vertices[m+2];THREE.Loader.prototype.v(g,j,o,n)}}function h(){function p(v,u){var t,s,w,l;t=v[u];s=v[u+1];w=v[u+2];l=v[u+3];THREE.Loader.prototype.f3(g,t,s,w,l)}function k(l,u){var z,y,x,s,w,v,t;z=l[u];y=l[u+1];x=l[u+2];s=l[u+3];w=l[u+4];v=l[u+5];t=l[u+6];THREE.Loader.prototype.f3n(g,b.normals,z,y,x,s,w,v,t)}function o(w,u){var t,s,x,v,l;t=w[u];s=w[u+1];x=w[u+2];v=w[u+3];l=w[u+4];THREE.Loader.prototype.f4(g,t,s,x,v,l)}function j(l,v){var B,A,z,y,s,x,w,u,t;B=l[v];A=l[v+1];z=l[v+2];y=l[v+3];s=l[v+4];x=l[v+5];w=l[v+6];u=l[v+7];t=l[v+8];THREE.Loader.prototype.f4n(g,b.normals,B,A,z,y,s,x,w,u,t)}function r(l,y){var x,u,s,w,v,t,B,A,z;x=l[y];u=l[y+1];s=l[y+2];w=b.uvs[x*2];B=b.uvs[x*2+1];v=b.uvs[u*2];A=b.uvs[u*2+1];t=b.uvs[s*2];z=b.uvs[s*2+1];THREE.Loader.prototype.uv(g,w,B,v,A,t,z)}function q(s,A){var z,w,v,t,y,x,u,l,E,D,C,B;z=s[A];w=s[A+1];v=s[A+2];t=s[A+3];y=b.uvs[z*2];E=b.uvs[z*2+1];x=b.uvs[w*2];D=b.uvs[w*2+1];u=b.uvs[v*2];C=b.uvs[v*2+1];l=b.uvs[t*2];B=b.uvs[t*2+1];THREE.Loader.prototype.uv(g,y,E,x,D,u,C,l,B)}var n,m;for(n=0,m=b.triangles.length;n<m;n+=4){p(b.triangles,n)}for(n=0,m=b.triangles_uv.length;n<m;n+=7){p(b.triangles_uv,n);r(b.triangles_uv,n+4)}for(n=0,m=b.triangles_n.length;n<m;n+=7){k(b.triangles_n,n)}for(n=0,m=b.triangles_n_uv.length;n<m;n+=10){k(b.triangles_n_uv,n);r(b.triangles_n_uv,n+7)}for(n=0,m=b.quads.length;n<m;n+=5){o(b.quads,n)}for(n=0,m=b.quads_uv.length;n<m;n+=9){o(b.quads_uv,n);q(b.quads_uv,n+5)}for(n=0,m=b.quads_n.length;n<m;n+=9){j(b.quads_n,n)}for(n=0,m=b.quads_n_uv.length;n<m;n+=13){j(b.quads_n_uv,n);q(b.quads_n_uv,n+9)}}};c.prototype=new THREE.Geometry();c.prototype.constructor=c;d(new c(a))},v:function(b,a,d,c){b.vertices.push(new THREE.Vertex(new THREE.Vector3(a,d,c)))},f3:function(h,e,d,i,f){var g=h.materials[f];h.faces.push(new THREE.Face3(e,d,i,null,g))},f4:function(i,f,e,k,j,g){var h=i.materials[g];i.faces.push(new THREE.Face4(f,e,k,j,null,h))},f3n:function(d,l,s,r,q,p,j,i,h){var k=d.materials[p],g=l[j*3],f=l[j*3+1],e=l[j*3+2],o=l[i*3],n=l[i*3+1],m=l[i*3+2],v=l[h*3],u=l[h*3+1],t=l[h*3+2];d.faces.push(new THREE.Face3(s,r,q,[new THREE.Vector3(g,f,e),new THREE.Vector3(o,n,m),new THREE.Vector3(v,u,t)],k))},f4n:function(e,q,y,x,w,u,v,o,n,m,k){var p=e.materials[v],j=q[o*3],h=q[o*3+1],f=q[o*3+2],t=q[n*3],s=q[n*3+1],r=q[n*3+2],B=q[m*3],A=q[m*3+1],z=q[m*3+2],l=q[k*3],i=q[k*3+1],g=q[k*3+2];e.faces.push(new THREE.Face4(y,x,w,u,[new THREE.Vector3(j,h,f),new THREE.Vector3(t,s,r),new THREE.Vector3(B,A,z),new THREE.Vector3(l,i,g)],p))},uv:function(j,e,i,c,h,b,g,a,f){var d=[];d.push(new THREE.UV(e,i));d.push(new THREE.UV(c,h));d.push(new THREE.UV(b,g));if(a&&f){d.push(new THREE.UV(a,f))}j.uvs.push(d)},init_materials:function(d,a,c){d.materials=[];for(var b=0;b<a.length;++b){d.materials[b]=[THREE.Loader.prototype.createMaterial(a[b],c)]}},createMaterial:function(a,c){function g(j){var i=Math.log(j)/Math.LN2;return Math.floor(i)==i}function f(j){var i=Math.log(j)/Math.LN2;return Math.pow(2,Math.round(i))}var d,e,h,b;if(a.map_diffuse&&c){e=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(e)});h=new Image();h.onload=function(){if(!g(this.width)||!g(this.height)){var i=f(this.width),j=f(this.height);d.map.image.width=i;d.map.image.height=j;d.map.image.getContext("2d").drawImage(this,0,0,i,j)}else{d.map.image=this}d.map.loaded=1};h.src=c+"/"+a.map_diffuse}else{if(a.col_diffuse){b=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:b,opacity:a.transparency})}else{if(a.a_dbg_color){d=new THREE.MeshLambertMaterial({color:a.a_dbg_color})}else{d=new THREE.MeshLambertMaterial({color:15658734})}}}return d}};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.materialFaceGroup={};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 c,b,e,m,k,h,j,n,d,g={};function a(f){var i=[];for(c=0,b=f.length;c<b;c++){if(f[c]==undefined){i.push("undefined")}else{i.push(f[c].toString())}}return i.join("_")}for(e=0,m=this.geometry.faces.length;e<m;e++){k=this.geometry.faces[e];h=k.material;n=a(h);if(g[n]==undefined){g[n]={hash:n,counter:0}}d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}j=k instanceof THREE.Face3?3:4;if(this.materialFaceGroup[d].vertices+j>65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e<a;e++){c=this.geometry.uvs[e];for(b=0,d=c.length;b<d;b++){if(c[b].u!=1){c[b].u=c[b].u-Math.floor(c[b].u)}if(c[b].v!=1){c[b].v=c[b].v-Math.floor(c[b].v)}}}};THREE.FlatShading=0;THREE.GouraudShading=1;THREE.PhongShading=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubstractiveBlending=2;THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.linewidth!==undefined){this.linewidth=a.linewidth}}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1000;this.opacity=1;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.near!==undefined){this.near=a.near}if(a.far!==undefined){this.far=a.far}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_size: "+this.wireframe_linewidth+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color=new THREE.Color(a.color)}if(a.map!==undefined){this.map=a.map}if(a.ambient!==undefined){this.ambient=new THREE.Color(a.ambient)}if(a.specular!==undefined){this.specular=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>specular_map: "+this.specular_map+"<br/>shininess: "+this.shininess+"<br/>alpha: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2();if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F<E;F++){L=r[F];q=L.matrix;if(L.autoUpdateMatrix){L.updateMatrix()}if(L instanceof THREE.Mesh){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I<B;I++){A=w[I];if(A instanceof THREE.Face3){y=z[A.a];x=z[A.b];t=z[A.c];if(y.__visible&&x.__visible&&t.__visible){if((L.doubleSided||(L.flipSided!=(t.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(t.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0))){c=n[p]=n[p]||new THREE.RenderableFace3();c.v1.copy(y.positionScreen);c.v2.copy(x.positionScreen);c.v3.copy(t.positionScreen);c.normalWorld.copy(A.normal);L.matrixRotation.transform(c.normalWorld);c.centroidWorld.copy(A.centroid);q.transform(c.centroidWorld);c.centroidScreen.copy(c.centroidWorld);d.transform(c.centroidScreen);c.z=c.centroidScreen.z;c.meshMaterial=L.material;c.faceMaterial=A.material;c.overdraw=L.overdraw;c.uvs=L.geometry.uvs[I];c.color=A.color;e.push(c);p++}}}else{if(A instanceof THREE.Face4){y=z[A.a];x=z[A.b];t=z[A.c];s=z[A.d];if(y.__visible&&x.__visible&&t.__visible&&s.__visible){if((L.doubleSided||(L.flipSided!=((s.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(s.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0||(x.positionScreen.x-t.positionScreen.x)*(s.positionScreen.y-t.positionScreen.y)-(x.positionScreen.y-t.positionScreen.y)*(s.positionScreen.x-t.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.copy(y.positionScreen);b.v2.copy(x.positionScreen);b.v3.copy(t.positionScreen);b.v4.copy(s.positionScreen);b.normalWorld.copy(A.normal);L.matrixRotation.transform(b.normalWorld);b.centroidWorld.copy(A.centroid);q.transform(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);d.transform(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterial=L.material;b.faceMaterial=A.material;b.overdraw=L.overdraw;b.uvs=L.geometry.uvs[I];b.color=A.color;e.push(b);f++}}}}}}else{if(L instanceof THREE.Line){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);d.transform(g);g.z/=g.w;if(g.z>0&&g.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=g.x/g.w;j.y=g.y/g.w;j.z=g.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(j.x-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(j.y-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;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 n=null,x=new THREE.Projector(),s=document.createElement("canvas"),a,F,v,h,r=s.getContext("2d"),B=1,i="#000000",L="#000000",f=1,w=new THREE.Rectangle(),I=new THREE.Rectangle(),m=new THREE.Rectangle(),D=false,A=new THREE.Color(4294967295),y=new THREE.Color(4294967295),H=new THREE.Color(4278190080),k=Math.PI*2,C,G=new THREE.Vector2(),E=new THREE.Vector3(),u=new THREE.UV(),t=new THREE.UV(),q=new THREE.UV(),p=new THREE.UV(),K=new THREE.Vector2(),J=new THREE.Vector2();this.domElement=s;this.autoClear=true;this.setSize=function(N,M){a=N;F=M;v=a/2;h=F/2;s.width=a;s.height=F;r.lineJoin="round";r.lineCap="round";w.set(-v,-h,v,h)};this.clear=function(){if(!I.isEmpty()){I.inflate(1);I.minSelf(w);r.setTransform(1,0,0,-1,v,h);r.clearRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());I.empty()}};this.render=function(ah,ae){var ag,P,R,Z,af,V,S,Y,W,T,ac,aa,O,M,X,U,ad,ab,Q,N;if(this.autoClear){this.clear()}n=x.projectScene(ah,ae);r.setTransform(1,0,0,-1,v,h);D=ah.lights.length>0;if(D){e(ah,H)}for(ag=0,P=n.length;ag<P;ag++){R=n[ag];m.empty();if(R instanceof THREE.RenderableParticle){W=R.x*v;T=R.y*h;for(Z=0,af=R.material.length;Z<af;Z++){Y=R.material[Z];Y&&o(W,T,R,Y,ah)}}else{if(R instanceof THREE.RenderableLine){W=R.v1.x*v;T=R.v1.y*h;ac=R.v2.x*v;aa=R.v2.y*h;m.addPoint(W,T);m.addPoint(ac,aa);if(!w.instersects(m)){continue}Z=0;af=R.material.length;while(Z<af){Y=R.material[Z++];Y&&z(W,T,ac,aa,R,Y,ah)}}else{if(R instanceof THREE.RenderableFace3){R.v1.x*=v;R.v1.y*=h;R.v2.x*=v;R.v2.y*=h;R.v3.x*=v;R.v3.y*=h;if(R.overdraw){b(R.v1,R.v2);b(R.v2,R.v3);b(R.v3,R.v1)}W=R.v1.x;T=R.v1.y;ac=R.v2.x;aa=R.v2.y;O=R.v3.x;M=R.v3.y;m.addPoint(W,T);m.addPoint(ac,aa);m.addPoint(O,M);if(!w.instersects(m)){continue}Z=0;af=R.meshMaterial.length;while(Z<af){Y=R.meshMaterial[Z++];if(Y instanceof THREE.MeshFaceMaterial){V=0;S=R.faceMaterial.length;while(V<S){Y=R.faceMaterial[V++];Y&&l(W,T,ac,aa,O,M,R,Y,ah)}continue}l(W,T,ac,aa,O,M,R,Y,ah)}}else{if(R instanceof THREE.RenderableFace4){R.v1.x*=v;R.v1.y*=h;R.v2.x*=v;R.v2.y*=h;R.v3.x*=v;R.v3.y*=h;R.v4.x*=v;R.v4.y*=h;K.copy(R.v2);J.copy(R.v4);if(R.overdraw){b(R.v1,R.v2);b(R.v2,R.v4);b(R.v4,R.v1)}W=R.v1.x;T=R.v1.y;ac=R.v2.x;aa=R.v2.y;X=R.v4.x;U=R.v4.y;if(R.overdraw){b(R.v3,K);b(R.v3,J)}O=R.v3.x;M=R.v3.y;ad=K.x;ab=K.y;Q=J.x;N=J.y;m.addPoint(W,T);m.addPoint(ac,aa);m.addPoint(O,M);m.addPoint(X,U);if(!w.instersects(m)){continue}Z=0;af=R.meshMaterial.length;while(Z<af){Y=R.meshMaterial[Z++];if(Y instanceof THREE.MeshFaceMaterial){V=0;S=R.faceMaterial.length;while(V<S){Y=R.faceMaterial[V++];Y&&j(W,T,ac,aa,O,M,X,U,ad,ab,Q,N,R,Y,ah)}continue}j(W,T,ac,aa,O,M,X,U,ad,ab,Q,N,R,Y,ah)}}}}}I.addRectangle(m)}r.setTransform(1,0,0,1,0,0)};function e(S,P){var O,R,N,M,Q=S.lights;P.setRGBA(0,0,0,1);for(O=0,R=Q.length;O<R;O++){N=Q[O];M=N.color;if(N instanceof THREE.AmbientLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}}}function g(T,R,P){var O,S,N,M,Q=T.lights;for(O=0,S=Q.length;O<S;O++){N=Q[O];M=N.color;if(N instanceof THREE.DirectionalLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}else{if(N instanceof THREE.PointLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}}}}function d(T,R,P){var O,S,N,M,Q;lights=T.lights;for(O=0,S=lights.length;O<S;O++){N=lights[O];M=N.color;if(N instanceof THREE.DirectionalLight){Q=R.normalWorld.dot(N.position)*N.intensity;if(Q>0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}else{if(N instanceof THREE.PointLight){E.sub(N.position,R.centroidWorld);E.normalize();Q=R.normalWorld.dot(E)*N.intensity;if(Q>0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}}}}function o(O,N,R,U,T){var M,Z,X,W,S,Q,V,Y,P;if(B!=U.opacity){r.globalAlpha=B=U.opacity}if(U instanceof THREE.ParticleBasicMaterial){V=U.bitmap;Y=V.width/2;P=V.height/2;X=R.scale.x*v;W=R.scale.y*h;M=X*Y;Z=W*P;S=U.offset.x*X;Q=U.offset.y*W;m.set(O+S-M,N+Q-Z,O+S+M,N+Q+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(X,-W);r.translate(-Y+U.offset.x,-P-U.offset.y);r.drawImage(V,0,0);r.restore()}else{if(U instanceof THREE.ParticleCircleMaterial){if(D){y.copyRGB(H);g(T,R,y);A.copyRGBA(U.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=U.color.__styleString}M=R.scale.x*v;Z=R.scale.y*h;m.set(O-M,N-Z,O+M,N+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(M,Z);r.beginPath();r.arc(0,0,1,0,k,true);r.closePath();r.fillStyle=A.__styleString;r.fill();r.restore()}}}function z(M,S,O,N,P,Q,R){if(B!=Q.opacity){r.globalAlpha=B=Q.opacity}if(Q instanceof THREE.LineBasicMaterial){r.beginPath();r.moveTo(M,S);r.lineTo(O,N);r.closePath();A.__styleString=Q.color.__styleString;if(f!=Q.linewidth){r.lineWidth=f=Q.linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(Q.linewidth*2)}}function l(O,N,M,X,U,T,Q,S,R){var V,W,P;if(B!=S.opacity){r.globalAlpha=B=S.opacity}if(S.map){V=S.map.image;W=V.width-1;P=V.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);u.u*=W;u.v*=P;t.u*=W;t.v*=P;q.u*=W;q.v*=P;c(V,O,N,M,X,U,T,u.u,u.v,t.u,t.v,q.u,q.v);return}r.beginPath();r.moveTo(O,N);r.lineTo(M,X);r.lineTo(U,T);r.lineTo(O,N);r.closePath();if(S instanceof THREE.MeshBasicMaterial){A.__styleString=S.color.__styleString}else{if(S instanceof THREE.MeshDepthMaterial){C=1-(S.__2near/(S.__farPlusNear-Q.z*S.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(S instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(R,Q,y);A.copyRGBA(S.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=S.color.__styleString}}}}if(S.wireframe){if(f!=S.wireframe_linewidth){r.lineWidth=f=S.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(S.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function j(S,R,aa,Y,N,M,U,T,ab,Z,P,O,Q,W,ac){var ad,V,X;if(B!=W.opacity){r.globalAlpha=B=W.opacity}if(W.map){ad=W.map.image;V=ad.width-1;X=ad.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);p.copy(Q.uvs[3]);u.u*=V;u.v*=X;t.u*=V;t.v*=X;q.u*=V;q.v*=X;p.u*=V;p.v*=X;c(ad,S,R,aa,Y,U,T,u.u,u.v,t.u,t.v,p.u,p.v);c(ad,ab,Z,N,M,P,O,t.u,t.v,q.u,q.v,p.u,p.v);return}r.beginPath();r.moveTo(S,R);r.lineTo(aa,Y);r.lineTo(N,M);r.lineTo(U,T);r.lineTo(S,R);r.closePath();if(W instanceof THREE.MeshBasicMaterial){A.__styleString=W.color.__styleString}else{if(W instanceof THREE.MeshDepthMaterial){C=1-(W.__2near/(W.__farPlusNear-Q.z*W.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(W instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(ac,Q,y);A.copyRGBA(W.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=W.color.__styleString}}}}if(W.wireframe){if(f!=W.wireframe_linewidth){r.lineWidth=f=W.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(W.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function c(af,Z,R,X,Q,V,O,W,P,U,N,T,M){r.beginPath();r.moveTo(Z,R);r.lineTo(X,Q);r.lineTo(V,O);r.lineTo(Z,R);r.closePath();X-=Z;Q-=R;V-=Z;O-=R;U-=W;N-=P;T-=W;M-=P;var S=1/(U*M-T*N),ae=(M*X-N*V)*S,ad=(M*Q-N*O)*S,ac=(U*V-T*X)*S,ab=(U*O-T*Q)*S,aa=Z-ae*W-ac*P,Y=R-ad*W-ab*P;r.save();r.transform(ae,ad,ac,ab,aa,Y);r.clip();r.drawImage(af,0,0);r.restore()}function b(N,M){G.sub(M,N);G.unit();G.multiplyScalar(0.75);M.addSelf(G);N.subSelf(G)}};THREE.SVGRenderer=function(){var y=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,A=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),x,g=new THREE.Vector3(),d=[],l=[],C,n,f,B=1;this.domElement=t;this.autoClear=true;this.setQuality=function(D){switch(D){case"high":B=1;break;case"low":B=0;break}};this.setSize=function(E,D){b=E;o=D;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);A.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(U,R){var T,F,O,S,K,H,G,N,L,I,Q,P,E,D,M,J;if(this.autoClear){this.clear()}y=r.projectScene(U,R);n=0;f=0;i=U.lights.length>0;if(i){z(U,c)}for(T=0,F=y.length;T<F;T++){G=y[T];w.empty();if(G instanceof THREE.RenderableParticle){L=G.x*p;I=G.y*-s;for(O=0,S=G.material.length;O<S;O++){N=G.material[O];N&&j(L,I,G,N,U)}}else{if(G instanceof THREE.RenderableFace3){L=G.v1.x*p;I=G.v1.y*-s;Q=G.v2.x*p;P=G.v2.y*-s;E=G.v3.x*p;D=G.v3.y*-s;w.addPoint(L,I);w.addPoint(Q,P);w.addPoint(E,D);if(!A.instersects(w)){continue}O=0;S=G.meshMaterial.length;while(O<S){N=G.meshMaterial[O++];if(N instanceof THREE.MeshFaceMaterial){K=0;H=G.faceMaterial.length;while(K<H){N=G.faceMaterial[K++];N&&h(L,I,Q,P,E,D,G,N,U)}continue}N&&h(L,I,Q,P,E,D,G,N,U)}}else{if(G instanceof THREE.RenderableFace4){L=G.v1.x*p;I=G.v1.y*-s;Q=G.v2.x*p;P=G.v2.y*-s;E=G.v3.x*p;D=G.v3.y*-s;M=G.v4.x*p;J=G.v4.y*-s;w.addPoint(L,I);w.addPoint(Q,P);w.addPoint(E,D);w.addPoint(M,J);if(!A.instersects(w)){continue}O=0;S=G.meshMaterial.length;while(O<S){N=G.meshMaterial[O++];if(N instanceof THREE.MeshFaceMaterial){K=0;H=G.faceMaterial.length;while(K<H){N=G.faceMaterial[K++];N&&e(L,I,Q,P,E,D,M,J,G,N,U)}continue}N&&e(L,I,Q,P,E,D,M,J,G,N,U)}}}}}};function z(H,F){var E,G,D;F.setRGBA(0,0,0,1);for(E=0,G=H.lights.length;E<G;E++){D=H.lights[E];if(D instanceof THREE.AmbientLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}}}function q(I,G,F){var E,H,D;for(E=0,H=I.lights.length;E<H;E++){D=I.lights[E];if(D instanceof THREE.DirectionalLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}else{if(D instanceof THREE.PointLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}}}}function a(J,H,F){var E,I,D,G;for(E=0,I=J.lights.length;E<I;E++){D=J.lights[E];if(D instanceof THREE.DirectionalLight){G=H.normalWorld.dot(D.position)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}else{if(D instanceof THREE.PointLight){g.sub(D.position,H.centroidWorld);g.normalize();G=H.normalWorld.dot(g)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}}}}function j(D,H,E,F,G){C=u(f++);C.setAttribute("cx",D);C.setAttribute("cy",H);C.setAttribute("r",E.scale.x*p);if(F instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(G,E,v);k.copyRGBA(F.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=F.color}C.setAttribute("style","fill: "+k.__styleString)}t.appendChild(C)}function h(F,E,D,L,K,J,G,I,H){C=m(n++);C.setAttribute("d","M "+F+" "+E+" L "+D+" "+L+" L "+K+","+J+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshDepthMaterial){x=1-(I.__2near/(I.__farPlusNear-G.z*I.__farMinusNear));k.setRGBA(x,x,x,1)}else{if(I instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(H,G,v);k.copyRGBA(I.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}}if(I.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}t.appendChild(C)}function e(H,F,D,N,M,L,G,E,I,K,J){C=m(n++);C.setAttribute("d","M "+H+" "+F+" L "+D+" "+N+" L "+M+","+L+" L "+G+","+E+"z");if(K instanceof THREE.MeshBasicMaterial){k.__styleString=K.color.__styleString}else{if(K instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(J,I,v);k.copyRGBA(K.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=K.color.__styleString}}}if(K.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+K.opacity)}t.appendChild(C)}function m(D){if(d[D]==null){d[D]=document.createElementNS("http://www.w3.org/2000/svg","path");if(B==0){d[D].setAttribute("shape-rendering","crispEdges")}return d[D]}return d[D]}function u(D){if(l[D]==null){l[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B==0){l[D].setAttribute("shape-rendering","crispEdges")}return l[D]}return l[D]}};THREE.WebGLRenderer=function(l){var o=document.createElement("canvas"),e,h,q=new THREE.Matrix4(),n,a=0,b=1,f=2,d=3,g=m(l,5);this.domElement=o;this.autoClear=true;k();j(g.directional,g.point);function m(v,w){if(v){var s,u,r,t=pointLights=maxDirLights=maxPointLights=0;for(s=0,u=v.lights.length;s<u;s++){r=v.lights[s];if(r instanceof THREE.DirectionalLight){t++}if(r instanceof THREE.PointLight){pointLights++}}if((pointLights+t)<=w){maxDirLights=t;maxPointLights=pointLights}else{maxDirLights=Math.ceil(w*t/(pointLights+t));maxPointLights=w-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:w-1}}this.setSize=function(s,r){o.width=s;o.height=r;e.viewport(0,0,o.width,o.height)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.setupLights=function(y){var v,C,w,t,z,D,u=[],A=[],B=[],s=[],x=[];e.uniform1i(h.enableLighting,y.lights.length);for(v=0,C=y.lights.length;v<C;v++){w=y.lights[v];if(w instanceof THREE.AmbientLight){u.push(w)}else{if(w instanceof THREE.DirectionalLight){B.push(w)}else{if(w instanceof THREE.PointLight){A.push(w)}}}}t=z=D=0;for(v=0,C=u.length;v<C;v++){t+=u[v].color.r;z+=u[v].color.g;D+=u[v].color.b}e.uniform3f(h.ambientLightColor,t,z,D);s=[];x=[];for(v=0,C=B.length;v<C;v++){w=B[v];s.push(w.color.r*w.intensity);s.push(w.color.g*w.intensity);s.push(w.color.b*w.intensity);x.push(w.position.x);x.push(w.position.y);x.push(w.position.z)}if(B.length){e.uniform1i(h.directionalLightNumber,B.length);e.uniform3fv(h.directionalLightDirection,x);e.uniform3fv(h.directionalLightColor,s)}s=[];x=[];for(v=0,C=A.length;v<C;v++){w=A[v];s.push(w.color.r*w.intensity);s.push(w.color.g*w.intensity);s.push(w.color.b*w.intensity);x.push(w.position.x);x.push(w.position.y);x.push(w.position.z)}if(A.length){e.uniform1i(h.pointLightNumber,A.length);e.uniform3fv(h.pointLightPosition,x);e.uniform3fv(h.pointLightColor,s)}};this.createBuffers=function(K,I){var G,y,A,x,F,J,w,u,t,s,r,v=K.materialFaceGroup[I],C=[],E=[],B=[],H=[],D=[],z=0;for(G=0,y=v.faces.length;G<y;G++){A=v.faces[G];x=K.geometry.faces[A];F=x.vertexNormals;J=x.normal;w=K.geometry.uvs[A];if(x instanceof THREE.Face3){u=K.geometry.vertices[x.a].position;t=K.geometry.vertices[x.b].position;s=K.geometry.vertices[x.c].position;B.push(u.x,u.y,u.z);B.push(t.x,t.y,t.z);B.push(s.x,s.y,s.z);if(F.length==3){H.push(F[0].x,F[0].y,F[0].z);H.push(F[1].x,F[1].y,F[1].z);H.push(F[2].x,F[2].y,F[2].z)}else{H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z)}if(w){D.push(w[0].u,w[0].v);D.push(w[1].u,w[1].v);D.push(w[2].u,w[2].v)}C.push(z,z+1,z+2);E.push(z,z+1);E.push(z,z+2);E.push(z+1,z+2);z+=3}else{if(x instanceof THREE.Face4){u=K.geometry.vertices[x.a].position;t=K.geometry.vertices[x.b].position;s=K.geometry.vertices[x.c].position;r=K.geometry.vertices[x.d].position;B.push(u.x,u.y,u.z);B.push(t.x,t.y,t.z);B.push(s.x,s.y,s.z);B.push(r.x,r.y,r.z);if(F.length==4){H.push(F[0].x,F[0].y,F[0].z);H.push(F[1].x,F[1].y,F[1].z);H.push(F[2].x,F[2].y,F[2].z);H.push(F[3].x,F[3].y,F[3].z)}else{H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z)}if(w){D.push(w[0].u,w[0].v);D.push(w[1].u,w[1].v);D.push(w[2].u,w[2].v);D.push(w[3].u,w[3].v)}C.push(z,z+1,z+2);C.push(z,z+2,z+3);E.push(z,z+1);E.push(z,z+2);E.push(z,z+3);E.push(z+1,z+2);E.push(z+2,z+3);z+=4}}}if(!B.length){return}v.__webGLVertexBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(B),e.STATIC_DRAW);v.__webGLNormalBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(H),e.STATIC_DRAW);v.__webGLUVBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(D),e.STATIC_DRAW);v.__webGLFaceBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),e.STATIC_DRAW);v.__webGLLineBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),e.STATIC_DRAW);v.__webGLFaceCount=C.length;v.__webGLLineCount=E.length};this.renderBuffer=function(w,A){var v,t,u,s,r,z,y,B,x;if(w instanceof THREE.MeshPhongMaterial||w instanceof THREE.MeshLambertMaterial||w instanceof THREE.MeshBasicMaterial){v=w.color;t=w.opacity;u=w.wireframe;s=w.wireframe_linewidth;r=w.blending;x=w.map;e.uniform4f(h.mColor,v.r*t,v.g*t,v.b*t,t)}if(w instanceof THREE.MeshDepthMaterial){t=w.opacity;u=w.wireframe;s=w.wireframe_linewidth;e.uniform1f(h.m2Near,w.__2near);e.uniform1f(h.mFarPlusNear,w.__farPlusNear);e.uniform1f(h.mFarMinusNear,w.__farMinusNear);e.uniform1i(h.material,d)}else{if(w instanceof THREE.MeshPhongMaterial){z=w.ambient;y=w.specular;B=w.shininess;e.uniform4f(h.mAmbient,z.r,z.g,z.b,t);e.uniform4f(h.mSpecular,y.r,y.g,y.b,t);e.uniform1f(h.mShininess,B);e.uniform1i(h.material,f)}else{if(w instanceof THREE.MeshLambertMaterial){e.uniform1i(h.material,b)}else{if(w instanceof THREE.MeshBasicMaterial){e.uniform1i(h.material,a)}}}}if(x){if(!w.__webGLTexture&&w.map.loaded){w.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,w.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,w.map.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,w.__webGLTexture);e.uniform1i(h.tMap,0);e.uniform1i(h.enableMap,1)}else{e.uniform1i(h.enableMap,0)}e.bindBuffer(e.ARRAY_BUFFER,A.__webGLVertexBuffer);e.vertexAttribPointer(h.position,3,e.FLOAT,false,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLNormalBuffer);e.vertexAttribPointer(h.normal,3,e.FLOAT,false,0,0);if(x){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUVBuffer);e.enableVertexAttribArray(h.uv);e.vertexAttribPointer(h.uv,2,e.FLOAT,false,0,0)}else{e.disableVertexAttribArray(h.uv)}if(!u){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,A.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else{e.lineWidth(s);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);e.drawElements(e.LINES,A.__webGLLineCount,e.UNSIGNED_SHORT,0)}};this.renderMesh=function(t,w){var v,s,r,u,z,x,y,A;for(z in t.materialFaceGroup){A=t.materialFaceGroup[z];if(!A.__webGLVertexBuffer){this.createBuffers(t,z)}for(r=0,u=t.material.length;r<u;r++){y=t.material[r];if(y instanceof THREE.MeshFaceMaterial){for(v=0,s=A.material.length;v<s;v++){x=A.material[v];this.renderBuffer(x,A)}}else{x=y;this.renderBuffer(x,A)}}}};this.setupMatrices=function(r,s){r.autoUpdateMatrix&&r.updateMatrix();q.multiply(s.matrix,r.matrix);h.viewMatrixArray=new Float32Array(s.matrix.flatten());h.modelViewMatrixArray=new Float32Array(q.flatten());h.projectionMatrixArray=new Float32Array(s.projectionMatrix.flatten());n=THREE.Matrix4.makeInvert3x3(q).transpose();h.normalMatrixArray=new Float32Array(n.m);e.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);e.uniformMatrix4fv(h.modelViewMatrix,false,h.modelViewMatrixArray);e.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);e.uniformMatrix3fv(h.normalMatrix,false,h.normalMatrixArray);e.uniformMatrix4fv(h.objMatrix,false,new Float32Array(r.matrix.flatten()))};this.render=function(u,t){var v,s,r;if(this.autoClear){this.clear()}t.autoUpdateMatrix&&t.updateMatrix();e.uniform3f(h.cameraPosition,t.position.x,t.position.y,t.position.z);this.setupLights(u);for(v=0,s=u.objects.length;v<s;v++){r=u.objects[v];this.setupMatrices(r,t);if(r instanceof THREE.Mesh){this.renderMesh(r,t)}else{if(r instanceof THREE.Line){}else{if(r instanceof THREE.Particle){}}}}};this.setFaceCulling=function(s,r){if(s){if(!r||r=="ccw"){e.frontFace(e.CCW)}else{e.frontFace(e.CW)}if(s=="back"){e.cullFace(e.BACK)}else{if(s=="front"){e.cullFace(e.FRONT)}else{e.cullFace(e.FRONT_AND_BACK)}}e.enable(e.CULL_FACE)}else{e.disable(e.CULL_FACE)}};function k(){try{e=o.getContext("experimental-webgl",{antialias:true})}catch(r){}if(!e){alert("WebGL not supported");throw"cannot create webgl context"}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(0,0,0,0)}function p(r,s){var t=["#ifdef GL_ES","precision highp float;","#endif",r?"#define MAX_DIR_LIGHTS "+r:"",s?"#define MAX_POINT_LIGHTS "+s:"","uniform int material;","uniform bool enableMap;","uniform sampler2D tMap;","uniform vec4 mColor;","uniform vec4 mAmbient;","uniform vec4 mSpecular;","uniform float mShininess;","uniform float m2Near;","uniform float mFarPlusNear;","uniform float mFarMinusNear;","uniform int pointLightNumber;","uniform int directionalLightNumber;",r?"uniform mat4 viewMatrix;":"",r?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",s?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main() {","vec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );","if ( enableMap ) {","mapColor = texture2D( tMap, vUv );","}","if ( material == 3 ) { ","float w = 0.5;","gl_FragColor = vec4( w, w, w, 1.0 );","} else if ( material == 2 ) { ","vec3 normal = normalize( vNormal );","vec3 viewPosition = normalize( vViewPosition );",s?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",s?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",s?"for( int i = 0; i < pointLightNumber; i++ ) {":"",s?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",s?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",s?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",s?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",s?"float pointSpecularWeight = 0.0;":"",s?"if ( pointDotNormalHalf >= 0.0 )":"",s?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",s?"pointDiffuse += mColor * pointDiffuseWeight;":"",s?"pointSpecular += mSpecular * pointSpecularWeight;":"",s?"}":"",r?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"vec3 dirVector = normalize( lDirection.xyz );":"",r?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",r?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",r?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",r?"float dirSpecularWeight = 0.0;":"",r?"if ( dirDotNormalHalf >= 0.0 )":"",r?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",r?"dirDiffuse += mColor * dirDiffuseWeight;":"",r?"dirSpecular += mSpecular * dirSpecularWeight;":"",r?"}":"","vec4 totalLight = mAmbient;",r?"totalLight += dirDiffuse + dirSpecular;":"",s?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( mapColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * mapColor.rgb * vLightWeighting, mColor.a * mapColor.a );","} else {","gl_FragColor = mColor * mapColor;","}","}"];return t.join("\n")}function i(r,s){var t=[r?"#define MAX_DIR_LIGHTS "+r:"",s?"#define MAX_POINT_LIGHTS "+s:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",r?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",r?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",s?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",s?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",s?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","varying vec3 vFragPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",r?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",r?"}":"",s?"for( int i = 0; i < pointLightNumber; i++ ) {":"",s?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",s?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",s?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",s?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",s?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return t.join("\n")}function j(r,s){h=e.createProgram();e.attachShader(h,c("fragment",p(r,s)));e.attachShader(h,c("vertex",i(r,s)));e.linkProgram(h);if(!e.getProgramParameter(h,e.LINK_STATUS)){alert("Could not initialise shaders")}e.useProgram(h);h.viewMatrix=e.getUniformLocation(h,"viewMatrix");h.modelViewMatrix=e.getUniformLocation(h,"modelViewMatrix");h.projectionMatrix=e.getUniformLocation(h,"projectionMatrix");h.normalMatrix=e.getUniformLocation(h,"normalMatrix");h.objMatrix=e.getUniformLocation(h,"objMatrix");h.cameraPosition=e.getUniformLocation(h,"cameraPosition");h.enableLighting=e.getUniformLocation(h,"enableLighting");h.ambientLightColor=e.getUniformLocation(h,"ambientLightColor");if(r){h.directionalLightNumber=e.getUniformLocation(h,"directionalLightNumber");h.directionalLightColor=e.getUniformLocation(h,"directionalLightColor");h.directionalLightDirection=e.getUniformLocation(h,"directionalLightDirection")}if(s){h.pointLightNumber=e.getUniformLocation(h,"pointLightNumber");h.pointLightColor=e.getUniformLocation(h,"pointLightColor");h.pointLightPosition=e.getUniformLocation(h,"pointLightPosition")}h.material=e.getUniformLocation(h,"material");h.mColor=e.getUniformLocation(h,"mColor");h.mAmbient=e.getUniformLocation(h,"mAmbient");h.mSpecular=e.getUniformLocation(h,"mSpecular");h.mShininess=e.getUniformLocation(h,"mShininess");h.enableMap=e.getUniformLocation(h,"enableMap");e.uniform1i(h.enableMap,0);h.tMap=e.getUniformLocation(h,"tMap");e.uniform1i(h.tMap,0);h.m2Near=e.getUniformLocation(h,"m2Near");h.mFarPlusNear=e.getUniformLocation(h,"mFarPlusNear");h.mFarMinusNear=e.getUniformLocation(h,"mFarMinusNear");h.position=e.getAttribLocation(h,"position");e.enableVertexAttribArray(h.position);h.normal=e.getAttribLocation(h,"normal");e.enableVertexAttribArray(h.normal);h.uv=e.getAttribLocation(h,"uv");e.enableVertexAttribArray(h.uv);h.viewMatrixArray=new Float32Array(16);h.modelViewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function c(s,r){var t;if(s=="fragment"){t=e.createShader(e.FRAGMENT_SHADER)}else{if(s=="vertex"){t=e.createShader(e.VERTEX_SHADER)}}e.shaderSource(t,r);e.compileShader(t);if(!e.getShaderParameter(t,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(t));return null}return t}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null};
\ No newline at end of file
// Three.js r28 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a: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=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(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("+~~(this.r*255)+","+~~(this.g*255)+","+~~(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.Ray=function(a,b){this.origin=a||new THREE.Vector3();this.direction=b||new THREE.Vector3()};THREE.Ray.prototype={intersectScene:function(f){var c,a,b,e=f.objects,d=[];for(c=0,a=e.length;c<a;c++){b=e[c];if(b instanceof THREE.Mesh){d=d.concat(this.intersectObject(b))}}d.sort(function(h,g){return h.distance-g.distance});return d},intersectObject:function(w){var n,j,i,t,s,q,p,v,k,x,u,r,g=w.geometry,h=g.vertices,o,e=[],m;for(n=0,j=g.faces.length;n<j;n++){i=g.faces[n];u=this.origin.clone();r=this.direction.clone();t=w.matrix.transform(h[i.a].position.clone());s=w.matrix.transform(h[i.b].position.clone());q=w.matrix.transform(h[i.c].position.clone());p=i instanceof THREE.Face4?w.matrix.transform(h[i.d].position.clone()):null;v=w.matrixRotation.transform(i.normal.clone());k=r.dot(v);if(k<0){x=v.dot(new THREE.Vector3().sub(t,u))/k;m=u.addSelf(r.multiplyScalar(x));if(i instanceof THREE.Face3){if(l(m,t,s,q)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}else{if(i instanceof THREE.Face4){if(l(m,t,s,p)||l(m,s,q,p)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}}}}return e;function l(d,G,D,B){var J=B.clone().subSelf(G),H=D.clone().subSelf(G),E=d.clone().subSelf(G),F=J.dot(J),C=J.dot(H),A=J.dot(E),z=H.dot(H),f=H.dot(E),y=1/(F*z-C*C),K=(z*A-C*f)*y,I=(F*f-C*A)*y;return(K>0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;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(m){var e,b,o,g,i,j,l,k,d,c,a,h=new THREE.Vector3(),p=new THREE.Vector3();for(o=0,g=this.vertices.length;o<g;o++){i=this.vertices[o];i.normal.set(0,0,0)}for(j=0,l=this.faces.length;j<l;j++){k=this.faces[j];if(m&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.addSelf(k.vertexNormals[e])}h.divideScalar(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);p.sub(d.position,c.position);h.crossSelf(p);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]};for(var 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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae<ad;ae+=af){ac=f(c,ae);ah=f(c,ae+x.vertex_coordinate_bytes);ag=f(c,ae+x.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,ac,ah,ag)}return x.nvertices*af}function H(ai){var ae,ac,ah,ag,af=x.normal_coordinate_bytes*3,ad=ai+x.nnormals*af;for(ae=ai;ae<ad;ae+=af){ac=i(c,ae);ah=i(c,ae+x.normal_coordinate_bytes);ag=i(c,ae+x.normal_coordinate_bytes*2);A.push(ac/127,ah/127,ag/127)}return x.nnormals*af}function G(ah){var af,ae,ad,ag=x.uv_coordinate_bytes*2,ac=ah+x.nuvs*ag;for(af=ah;af<ac;af+=ag){ae=f(c,af);ad=f(c,af+x.uv_coordinate_bytes);L.push(ae,ad)}return x.nuvs*ag}function M(af){var ae,ad,ag,ac;ae=v(c,af);ad=v(c,af+V);ag=v(c,af+T);ac=Z(c,af+O);THREE.Loader.prototype.f3(I,ae,ad,ag,ac)}function m(ah){var ag,ae,aj,ad,af,ac,ai;ag=v(c,ah);ae=v(c,ah+V);aj=v(c,ah+T);ad=Z(c,ah+O);af=v(c,ah+U);ac=v(c,ah+R);ai=v(c,ah+P);THREE.Loader.prototype.f3n(I,A,ag,ae,aj,ad,af,ac,ai)}function E(af){var ae,ad,ah,ag,ac;ae=v(c,af);ad=v(c,af+D);ah=v(c,af+C);ag=v(c,af+B);ac=Z(c,af+y);THREE.Loader.prototype.f4(I,ae,ad,ah,ag,ac)}function l(af){var al,ak,aj,ai,ac,ah,ag,ae,ad;al=v(c,af);ak=v(c,af+D);aj=v(c,af+C);ai=v(c,af+B);ac=Z(c,af+y);ah=v(c,af+r);ag=v(c,af+q);ae=v(c,af+p);ad=v(c,af+o);THREE.Loader.prototype.f4n(I,A,al,ak,aj,ai,ac,ah,ag,ae,ad)}function Y(ai){var ah,ae,ac,ag,af,ad,al,ak,aj;ah=v(c,ai);ae=v(c,ai+u);ac=v(c,ai+t);ag=L[ah*2];al=L[ah*2+1];af=L[ae*2];ak=L[ae*2+1];ad=L[ac*2];aj=L[ac*2+1];THREE.Loader.prototype.uv(I,ag,al,af,ak,ad,aj)}function X(ak){var aj,ag,ae,ad,ai,ah,af,ac,ao,an,am,al;aj=v(c,ak);ag=v(c,ak+N);ae=v(c,ak+K);ad=v(c,ak+J);ai=L[aj*2];ao=L[aj*2+1];ah=L[ag*2];an=L[ag*2+1];af=L[ae*2];am=L[ae*2+1];ac=L[ad*2];al=L[ad*2+1];THREE.Loader.prototype.uv(I,ai,ao,ah,an,af,am,ac,al)}function Q(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes,ac=af+x.ntri_flat*ae;for(ad=af;ad<ac;ad+=ae){M(ad)}return ac-af}function ab(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){M(ad);Y(ad+af)}return ac-ag}function S(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ac=af+x.ntri_smooth*ae;for(ad=af;ad<ac;ad+=ae){m(ad)}return ac-af}function n(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){m(ad);Y(ad+af)}return ac-ag}function g(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes,ac=af+x.nquad_flat*ae;for(ad=af;ad<ac;ad+=ae){E(ad)}return ac-af}function s(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){E(ad);X(ad+af)}return ac-ag}function k(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ac=af+x.nquad_smooth*ae;for(ad=af;ad<ac;ad+=ae){l(ad)}return ac-af}function z(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){l(ad);X(ad+af)}return ac-ag}};d.prototype=new THREE.Geometry();d.prototype.constructor=d;e(new d(b))},createModel:function(b,d,a){var c=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,b.materials,f);e();h();this.computeCentroids();this.computeNormals();function e(){var m,k,j,o,n;for(m=0,k=b.vertices.length;m<k;m+=3){j=b.vertices[m];o=b.vertices[m+1];n=b.vertices[m+2];THREE.Loader.prototype.v(g,j,o,n)}}function h(){function p(v,u){var t,s,w,l;t=v[u];s=v[u+1];w=v[u+2];l=v[u+3];THREE.Loader.prototype.f3(g,t,s,w,l)}function k(l,u){var z,y,x,s,w,v,t;z=l[u];y=l[u+1];x=l[u+2];s=l[u+3];w=l[u+4];v=l[u+5];t=l[u+6];THREE.Loader.prototype.f3n(g,b.normals,z,y,x,s,w,v,t)}function o(w,u){var t,s,x,v,l;t=w[u];s=w[u+1];x=w[u+2];v=w[u+3];l=w[u+4];THREE.Loader.prototype.f4(g,t,s,x,v,l)}function j(l,v){var B,A,z,y,s,x,w,u,t;B=l[v];A=l[v+1];z=l[v+2];y=l[v+3];s=l[v+4];x=l[v+5];w=l[v+6];u=l[v+7];t=l[v+8];THREE.Loader.prototype.f4n(g,b.normals,B,A,z,y,s,x,w,u,t)}function r(l,y){var x,u,s,w,v,t,B,A,z;x=l[y];u=l[y+1];s=l[y+2];w=b.uvs[x*2];B=b.uvs[x*2+1];v=b.uvs[u*2];A=b.uvs[u*2+1];t=b.uvs[s*2];z=b.uvs[s*2+1];THREE.Loader.prototype.uv(g,w,B,v,A,t,z)}function q(s,A){var z,w,v,t,y,x,u,l,E,D,C,B;z=s[A];w=s[A+1];v=s[A+2];t=s[A+3];y=b.uvs[z*2];E=b.uvs[z*2+1];x=b.uvs[w*2];D=b.uvs[w*2+1];u=b.uvs[v*2];C=b.uvs[v*2+1];l=b.uvs[t*2];B=b.uvs[t*2+1];THREE.Loader.prototype.uv(g,y,E,x,D,u,C,l,B)}var n,m;for(n=0,m=b.triangles.length;n<m;n+=4){p(b.triangles,n)}for(n=0,m=b.triangles_uv.length;n<m;n+=7){p(b.triangles_uv,n);r(b.triangles_uv,n+4)}for(n=0,m=b.triangles_n.length;n<m;n+=7){k(b.triangles_n,n)}for(n=0,m=b.triangles_n_uv.length;n<m;n+=10){k(b.triangles_n_uv,n);r(b.triangles_n_uv,n+7)}for(n=0,m=b.quads.length;n<m;n+=5){o(b.quads,n)}for(n=0,m=b.quads_uv.length;n<m;n+=9){o(b.quads_uv,n);q(b.quads_uv,n+5)}for(n=0,m=b.quads_n.length;n<m;n+=9){j(b.quads_n,n)}for(n=0,m=b.quads_n_uv.length;n<m;n+=13){j(b.quads_n_uv,n);q(b.quads_n_uv,n+9)}}};c.prototype=new THREE.Geometry();c.prototype.constructor=c;d(new c(a))},v:function(b,a,d,c){b.vertices.push(new THREE.Vertex(new THREE.Vector3(a,d,c)))},f3:function(h,e,d,i,f){var g=h.materials[f];h.faces.push(new THREE.Face3(e,d,i,null,g))},f4:function(i,f,e,k,j,g){var h=i.materials[g];i.faces.push(new THREE.Face4(f,e,k,j,null,h))},f3n:function(d,l,s,r,q,p,j,i,h){var k=d.materials[p],g=l[j*3],f=l[j*3+1],e=l[j*3+2],o=l[i*3],n=l[i*3+1],m=l[i*3+2],v=l[h*3],u=l[h*3+1],t=l[h*3+2];d.faces.push(new THREE.Face3(s,r,q,[new THREE.Vector3(g,f,e),new THREE.Vector3(o,n,m),new THREE.Vector3(v,u,t)],k))},f4n:function(e,q,y,x,w,u,v,o,n,m,k){var p=e.materials[v],j=q[o*3],h=q[o*3+1],f=q[o*3+2],t=q[n*3],s=q[n*3+1],r=q[n*3+2],B=q[m*3],A=q[m*3+1],z=q[m*3+2],l=q[k*3],i=q[k*3+1],g=q[k*3+2];e.faces.push(new THREE.Face4(y,x,w,u,[new THREE.Vector3(j,h,f),new THREE.Vector3(t,s,r),new THREE.Vector3(B,A,z),new THREE.Vector3(l,i,g)],p))},uv:function(j,e,i,c,h,b,g,a,f){var d=[];d.push(new THREE.UV(e,i));d.push(new THREE.UV(c,h));d.push(new THREE.UV(b,g));if(a&&f){d.push(new THREE.UV(a,f))}j.uvs.push(d)},init_materials:function(d,a,c){d.materials=[];for(var b=0;b<a.length;++b){d.materials[b]=[THREE.Loader.prototype.createMaterial(a[b],c)]}},createMaterial:function(a,c){function g(j){var i=Math.log(j)/Math.LN2;return Math.floor(i)==i}function f(j){var i=Math.log(j)/Math.LN2;return Math.pow(2,Math.round(i))}var d,e,h,b;if(a.map_diffuse&&c){e=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(e)});h=new Image();h.onload=function(){if(!g(this.width)||!g(this.height)){var i=f(this.width),j=f(this.height);d.map.image.width=i;d.map.image.height=j;d.map.image.getContext("2d").drawImage(this,0,0,i,j)}else{d.map.image=this}d.map.loaded=1};h.src=c+"/"+a.map_diffuse}else{if(a.col_diffuse){b=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:b,opacity:a.transparency})}else{if(a.a_dbg_color){d=new THREE.MeshLambertMaterial({color:a.a_dbg_color})}else{d=new THREE.MeshLambertMaterial({color:15658734})}}}return d}};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.materialFaceGroup={};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 c,b,e,m,k,h,j,n,d,g={};function a(f){var i=[];for(c=0,b=f.length;c<b;c++){if(f[c]==undefined){i.push("undefined")}else{i.push(f[c].toString())}}return i.join("_")}for(e=0,m=this.geometry.faces.length;e<m;e++){k=this.geometry.faces[e];h=k.material;n=a(h);if(g[n]==undefined){g[n]={hash:n,counter:0}}d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}j=k instanceof THREE.Face3?3:4;if(this.materialFaceGroup[d].vertices+j>65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e<a;e++){c=this.geometry.uvs[e];for(b=0,d=c.length;b<d;b++){if(c[b].u!=1){c[b].u=c[b].u-Math.floor(c[b].u)}if(c[b].v!=1){c[b].v=c[b].v-Math.floor(c[b].v)}}}};THREE.FlatShading=0;THREE.GouraudShading=1;THREE.PhongShading=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubstractiveBlending=2;THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.linewidth!==undefined){this.linewidth=a.linewidth}}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1000;this.opacity=1;if(a){if(a.near!==undefined){this.near=a.near}if(a.far!==undefined){this.far=a.far}if(a.opacity!==undefined){this.opacity=a.opacity}}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_size: "+this.wireframe_linewidth+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color=new THREE.Color(a.color)}if(a.map!==undefined){this.map=a.map}if(a.ambient!==undefined){this.ambient=new THREE.Color(a.ambient)}if(a.specular!==undefined){this.specular=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>specular_map: "+this.specular_map+"<br/>shininess: "+this.shininess+"<br/>alpha: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2();if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F<E;F++){L=r[F];q=L.matrix;if(L.autoUpdateMatrix){L.updateMatrix()}if(L instanceof THREE.Mesh){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I<B;I++){A=w[I];if(A instanceof THREE.Face3){y=z[A.a];x=z[A.b];t=z[A.c];if(y.__visible&&x.__visible&&t.__visible){if((L.doubleSided||(L.flipSided!=(t.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(t.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0))){c=n[p]=n[p]||new THREE.RenderableFace3();c.v1.positionScreen.copy(y.positionScreen);c.v2.positionScreen.copy(x.positionScreen);c.v3.positionScreen.copy(t.positionScreen);c.normalWorld.copy(A.normal);L.matrixRotation.transform(c.normalWorld);c.centroidWorld.copy(A.centroid);q.transform(c.centroidWorld);c.centroidScreen.copy(c.centroidWorld);d.transform(c.centroidScreen);c.z=c.centroidScreen.z;c.meshMaterial=L.material;c.faceMaterial=A.material;c.overdraw=L.overdraw;c.uvs=L.geometry.uvs[I];c.color=A.color;e.push(c);p++}}}else{if(A instanceof THREE.Face4){y=z[A.a];x=z[A.b];t=z[A.c];s=z[A.d];if(y.__visible&&x.__visible&&t.__visible&&s.__visible){if((L.doubleSided||(L.flipSided!=((s.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(s.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0||(x.positionScreen.x-t.positionScreen.x)*(s.positionScreen.y-t.positionScreen.y)-(x.positionScreen.y-t.positionScreen.y)*(s.positionScreen.x-t.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.positionScreen.copy(y.positionScreen);b.v2.positionScreen.copy(x.positionScreen);b.v3.positionScreen.copy(t.positionScreen);b.v4.positionScreen.copy(s.positionScreen);b.normalWorld.copy(A.normal);L.matrixRotation.transform(b.normalWorld);b.centroidWorld.copy(A.centroid);q.transform(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);d.transform(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterial=L.material;b.faceMaterial=A.material;b.overdraw=L.overdraw;b.uvs=L.geometry.uvs[I];b.color=A.color;e.push(b);f++}}}}}}else{if(L instanceof THREE.Line){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1;if(H.__visible&&D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.positionScreen.copy(H.positionScreen);k.v2.positionScreen.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);d.transform(g);g.z/=g.w;if(g.z>0&&g.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=g.x/g.w;j.y=g.y/g.w;j.z=g.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(j.x-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(j.y-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;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 o=null,y=new THREE.Projector(),t=document.createElement("canvas"),a,I,w,i,s=t.getContext("2d"),E=1,j="#000000",R="#000000",g=1,Q,P,O,N,M=new THREE.Vertex(),L=new THREE.Vertex(),x=new THREE.Rectangle(),K=new THREE.Rectangle(),n=new THREE.Rectangle(),G=false,D=new THREE.Color(4294967295),z=new THREE.Color(4294967295),J=new THREE.Color(4278190080),l=Math.PI*2,F,H=new THREE.Vector3(),v=new THREE.UV(),u=new THREE.UV(),r=new THREE.UV(),q=new THREE.UV(),B=document.createElement("canvas"),A=B.getContext("2d"),e=A.createLinearGradient(0,0,255,0);B.width=255;B.height=4;e.addColorStop(0,"white");e.addColorStop(1,"black");A.fillStyle=e;A.fillRect(0,0,255,4);this.domElement=t;this.autoClear=true;this.setSize=function(T,S){a=T;I=S;w=a/2;i=I/2;t.width=a;t.height=I;s.lineJoin="round";s.lineCap="round";x.set(-w,-i,w,i)};this.clear=function(){if(!K.isEmpty()){K.inflate(1);K.minSelf(x);s.setTransform(1,0,0,-1,w,i);s.clearRect(K.getX(),K.getY(),K.getWidth(),K.getHeight());K.empty()}};this.render=function(W,aa){var Z,S,V,T,U,ab,X,Y;if(this.autoClear){this.clear()}o=y.projectScene(W,aa);s.setTransform(1,0,0,-1,w,i);G=W.lights.length>0;if(G){f(W,J)}for(Z=0,S=o.length;Z<S;Z++){V=o[Z];n.empty();if(V instanceof THREE.RenderableParticle){Q=V;Q.x*=w;Q.y*=i;for(T=0,U=V.material.length;T<U;T++){Y=V.material[T];Y&&p(Q,V,Y,W)}}else{if(V instanceof THREE.RenderableLine){Q=V.v1;P=V.v2;Q.positionScreen.x*=w;Q.positionScreen.y*=i;P.positionScreen.x*=w;P.positionScreen.y*=i;n.addPoint(Q.positionScreen.x,Q.positionScreen.y);n.addPoint(P.positionScreen.x,P.positionScreen.y);if(!x.instersects(n)){continue}T=0;U=V.material.length;while(T<U){Y=V.material[T++];Y&&C(Q,P,V,Y,W)}}else{if(V instanceof THREE.RenderableFace3){Q=V.v1;P=V.v2;O=V.v3;Q.positionScreen.x*=w;Q.positionScreen.y*=i;P.positionScreen.x*=w;P.positionScreen.y*=i;O.positionScreen.x*=w;O.positionScreen.y*=i;if(V.overdraw){b(Q.positionScreen,P.positionScreen);b(P.positionScreen,O.positionScreen);b(O.positionScreen,Q.positionScreen)}n.addPoint(Q.positionScreen.x,Q.positionScreen.y);n.addPoint(P.positionScreen.x,P.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);if(!x.instersects(n)){continue}T=0;U=V.meshMaterial.length;while(T<U){Y=V.meshMaterial[T++];if(Y instanceof THREE.MeshFaceMaterial){ab=0;X=V.faceMaterial.length;while(ab<X){Y=V.faceMaterial[ab++];Y&&m(Q,P,O,V,Y,W)}continue}Y&&m(Q,P,O,V,Y,W)}}else{if(V instanceof THREE.RenderableFace4){Q=V.v1;P=V.v2;O=V.v3;N=V.v4;Q.positionScreen.x*=w;Q.positionScreen.y*=i;P.positionScreen.x*=w;P.positionScreen.y*=i;O.positionScreen.x*=w;O.positionScreen.y*=i;N.positionScreen.x*=w;N.positionScreen.y*=i;M.positionScreen.copy(P.positionScreen);L.positionScreen.copy(N.positionScreen);if(V.overdraw){b(Q.positionScreen,P.positionScreen);b(P.positionScreen,N.positionScreen);b(N.positionScreen,Q.positionScreen)}if(V.overdraw){b(O.positionScreen,M.positionScreen);b(O.positionScreen,L.positionScreen)}n.addPoint(Q.positionScreen.x,Q.positionScreen.y);n.addPoint(P.positionScreen.x,P.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);n.addPoint(N.positionScreen.x,N.positionScreen.y);if(!x.instersects(n)){continue}T=0;U=V.meshMaterial.length;while(T<U){Y=V.meshMaterial[T++];if(Y instanceof THREE.MeshFaceMaterial){ab=0;X=V.faceMaterial.length;while(ab<X){Y=V.faceMaterial[ab++];Y&&k(Q,P,O,N,M,L,V,Y,W)}continue}Y&&k(Q,P,O,N,M,L,V,Y,W)}}}}}K.addRectangle(n)}s.setTransform(1,0,0,1,0,0)};function f(Y,V){var U,X,T,S,W=Y.lights;V.setRGBA(0,0,0,1);for(U=0,X=W.length;U<X;U++){T=W[U];S=T.color;if(T instanceof THREE.AmbientLight){V.r+=S.r;V.g+=S.g;V.b+=S.b}}}function h(Z,X,V){var U,Y,T,S,W=Z.lights;for(U=0,Y=W.length;U<Y;U++){T=W[U];S=T.color;if(T instanceof THREE.DirectionalLight){V.r+=S.r;V.g+=S.g;V.b+=S.b}else{if(T instanceof THREE.PointLight){V.r+=S.r;V.g+=S.g;V.b+=S.b}}}}function d(Z,X,V){var U,Y,T,S,W;lights=Z.lights;for(U=0,Y=lights.length;U<Y;U++){T=lights[U];S=T.color;if(T instanceof THREE.DirectionalLight){W=X.normalWorld.dot(T.position)*T.intensity;if(W>0){V.r+=S.r*W;V.g+=S.g*W;V.b+=S.b*W}}else{if(T instanceof THREE.PointLight){H.sub(T.position,X.centroidWorld);H.normalize();W=X.normalWorld.dot(H)*T.intensity;if(W>0){V.r+=S.r*W;V.g+=S.g*W;V.b+=S.b*W}}}}}function p(aa,V,Y,X){var S,ae,ac,ab,W,U,Z,ad,T;if(E!=Y.opacity){s.globalAlpha=E=Y.opacity}if(Y instanceof THREE.ParticleBasicMaterial){Z=Y.bitmap;ad=Z.width/2;T=Z.height/2;ac=V.scale.x*w;ab=V.scale.y*i;S=ac*ad;ae=ab*T;W=Y.offset.x*ac;U=Y.offset.y*ab;n.set(aa.x+W-S,aa.y+U-ae,aa.x+W+S,aa.y+U+ae);if(!x.instersects(n)){return}s.save();s.translate(aa.x,aa.y);s.rotate(-V.rotation);s.scale(ac,-ab);s.translate(-ad+Y.offset.x,-T-Y.offset.y);s.drawImage(Z,0,0);s.restore()}else{if(Y instanceof THREE.ParticleCircleMaterial){if(G){z.copyRGB(J);h(X,V,z);D.copyRGBA(Y.color);D.multiplySelfRGB(z);D.updateStyleString()}else{D.__styleString=Y.color.__styleString}S=V.scale.x*w;ae=V.scale.y*i;n.set(aa.x-S,aa.y-ae,aa.x+S,aa.y+ae);if(!x.instersects(n)){return}s.save();s.translate(aa.x,aa.y);s.rotate(-V.rotation);s.scale(S,ae);s.beginPath();s.arc(0,0,1,0,l,true);s.closePath();s.fillStyle=D.__styleString;s.fill();s.restore()}}}function C(W,V,S,T,U){if(E!=T.opacity){s.globalAlpha=E=T.opacity}if(T instanceof THREE.LineBasicMaterial){s.beginPath();s.moveTo(W.positionScreen.x,W.positionScreen.y);s.lineTo(V.positionScreen.x,V.positionScreen.y);s.closePath();D.__styleString=T.color.__styleString;if(g!=T.linewidth){s.lineWidth=g=T.linewidth}if(j!=D.__styleString){s.strokeStyle=j=D.__styleString}s.stroke();n.inflate(T.linewidth*2)}}function m(Z,X,W,T,V,U){var Y,aa,S;if(E!=V.opacity){s.globalAlpha=E=V.opacity}if(V.map){Y=V.map.image;aa=Y.width-1;S=Y.height-1;v.u=T.uvs[0].u*aa;v.v=T.uvs[0].v*S;u.u=T.uvs[1].u*aa;u.v=T.uvs[1].v*S;r.u=T.uvs[2].u*aa;r.v=T.uvs[2].v*S;c(Y,Z.positionScreen.x,Z.positionScreen.y,X.positionScreen.x,X.positionScreen.y,W.positionScreen.x,W.positionScreen.y,v.u,v.v,u.u,u.v,r.u,r.v);return}if(V instanceof THREE.MeshDepthMaterial){Y=B;aa=Y.width-1;S=Y.height-1;F=V.__2near/(V.__farPlusNear-Z.positionScreen.z*V.__farMinusNear);v.u=F*aa;v.v=0;F=V.__2near/(V.__farPlusNear-X.positionScreen.z*V.__farMinusNear);u.u=F*aa;u.v=1;F=V.__2near/(V.__farPlusNear-W.positionScreen.z*V.__farMinusNear);r.u=F*aa;r.v=2;c(Y,Z.positionScreen.x,Z.positionScreen.y,X.positionScreen.x,X.positionScreen.y,W.positionScreen.x,W.positionScreen.y,v.u,v.v,u.u,u.v,r.u,r.v);return}s.beginPath();s.moveTo(Z.positionScreen.x,Z.positionScreen.y);s.lineTo(X.positionScreen.x,X.positionScreen.y);s.lineTo(W.positionScreen.x,W.positionScreen.y);s.lineTo(Z.positionScreen.x,Z.positionScreen.y);s.closePath();if(V instanceof THREE.MeshBasicMaterial){D.__styleString=V.color.__styleString}else{if(V instanceof THREE.MeshDepthMaterial){}else{if(V instanceof THREE.MeshLambertMaterial){if(G){z.copyRGB(J);d(U,T,z);D.copyRGBA(V.color);D.multiplySelfRGB(z);D.updateStyleString()}else{D.__styleString=V.color.__styleString}}}}if(V.wireframe){if(g!=V.wireframe_linewidth){s.lineWidth=g=V.wireframe_linewidth}if(j!=D.__styleString){s.strokeStyle=j=D.__styleString}s.stroke();n.inflate(V.wireframe_linewidth*2)}else{if(R!=D.__styleString){s.fillStyle=R=D.__styleString}s.fill()}}function k(ac,ab,Z,Y,X,V,T,W,U){var aa,ad,S;if(E!=W.opacity){s.globalAlpha=E=W.opacity}if(W.map){aa=W.map.image;ad=aa.width-1;S=aa.height-1;v.copy(T.uvs[0]);u.copy(T.uvs[1]);r.copy(T.uvs[2]);q.copy(T.uvs[3]);v.u*=ad;v.v*=S;u.u*=ad;u.v*=S;r.u*=ad;r.v*=S;q.u*=ad;q.v*=S;c(aa,ac.positionScreen.x,ac.positionScreen.y,ab.positionScreen.x,ab.positionScreen.y,Y.positionScreen.x,Y.positionScreen.y,v.u,v.v,u.u,u.v,q.u,q.v);c(aa,X.positionScreen.x,X.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,V.positionScreen.x,V.positionScreen.y,u.u,u.v,r.u,r.v,q.u,q.v);return}if(W instanceof THREE.MeshDepthMaterial){aa=B;ad=aa.width-1;S=aa.height-1;F=W.__2near/(W.__farPlusNear-ac.positionScreen.z*W.__farMinusNear);v.u=F*ad;v.v=0;F=W.__2near/(W.__farPlusNear-ab.positionScreen.z*W.__farMinusNear);u.u=F*ad;u.v=1;F=W.__2near/(W.__farPlusNear-Z.positionScreen.z*W.__farMinusNear);r.u=F*ad;r.v=2;F=W.__2near/(W.__farPlusNear-Y.positionScreen.z*W.__farMinusNear);q.u=F*ad;q.v=3;c(aa,ac.positionScreen.x,ac.positionScreen.y,ab.positionScreen.x,ab.positionScreen.y,Y.positionScreen.x,Y.positionScreen.y,v.u,v.v,u.u,u.v,q.u,q.v);c(aa,X.positionScreen.x,X.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,V.positionScreen.x,V.positionScreen.y,u.u,u.v,r.u,r.v,q.u,q.v);return}s.beginPath();s.moveTo(ac.positionScreen.x,ac.positionScreen.y);s.lineTo(ab.positionScreen.x,ab.positionScreen.y);s.lineTo(Z.positionScreen.x,Z.positionScreen.y);s.lineTo(Y.positionScreen.x,Y.positionScreen.y);s.lineTo(ac.positionScreen.x,ac.positionScreen.y);s.closePath();if(W instanceof THREE.MeshBasicMaterial){D.__styleString=W.color.__styleString}else{if(W instanceof THREE.MeshDepthMaterial){F=1-(W.__2near/(W.__farPlusNear-T.z*W.__farMinusNear));D.setRGBA(F,F,F,1)}else{if(W instanceof THREE.MeshLambertMaterial){if(G){z.copyRGB(J);d(U,T,z);D.copyRGBA(W.color);D.multiplySelfRGB(z);D.updateStyleString()}else{D.__styleString=W.color.__styleString}}}}if(W.wireframe){if(g!=W.wireframe_linewidth){s.lineWidth=g=W.wireframe_linewidth}if(j!=D.__styleString){s.strokeStyle=j=D.__styleString}s.stroke();n.inflate(W.wireframe_linewidth*2)}else{if(R!=D.__styleString){s.fillStyle=R=D.__styleString}s.fill()}}function c(al,af,X,ad,W,ab,U,ac,V,aa,T,Z,S){s.beginPath();s.moveTo(af,X);s.lineTo(ad,W);s.lineTo(ab,U);s.closePath();ad-=af;W-=X;ab-=af;U-=X;aa-=ac;T-=V;Z-=ac;S-=V;var Y=1/(aa*S-Z*T),ak=(S*ad-T*ab)*Y,aj=(S*W-T*U)*Y,ai=(aa*ab-Z*ad)*Y,ah=(aa*U-Z*W)*Y,ag=af-ak*ac-ai*V,ae=X-aj*ac-ah*V;s.save();s.transform(ak,aj,ai,ah,ag,ae);s.clip();s.drawImage(al,0,0);s.restore()}function b(W,U){var S=U.x-W.x,V=U.y-W.y,T=1/Math.sqrt(S*S+V*V);S*=T;V*=T;U.x+=S;U.y+=V;W.x-=S;W.y-=V}};THREE.SVGRenderer=function(){var C=null,r=new THREE.Projector(),x=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,w,v,u,t,s,E=new THREE.Rectangle(),A=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),z=new THREE.Color(4294967295),c=new THREE.Color(4294967295),B,g=new THREE.Vector3(),d=[],l=[],G,n,f,F=1;this.domElement=x;this.autoClear=true;this.setQuality=function(H){switch(H){case"high":F=1;break;case"low":F=0;break}};this.setSize=function(I,H){b=I;o=H;p=b/2;w=o/2;x.setAttribute("viewBox",(-p)+" "+(-w)+" "+b+" "+o);x.setAttribute("width",b);x.setAttribute("height",o);E.set(-p,-w,p,w)};this.clear=function(){while(x.childNodes.length>0){x.removeChild(x.childNodes[0])}};this.render=function(L,P){var O,H,I,J,Q,M,K,N;if(this.autoClear){this.clear()}C=r.projectScene(L,P);n=0;f=0;i=L.lights.length>0;if(i){D(L,c)}for(O=0,H=C.length;O<H;O++){K=C[O];A.empty();if(K instanceof THREE.RenderableParticle){v=K;v.x*=p;v.y*=-w;for(I=0,J=K.material.length;I<J;I++){N=K.material[I];N&&j(v,K,N,L)}}else{if(K instanceof THREE.RenderableFace3){v=K.v1;u=K.v2;t=K.v3;v.positionScreen.x*=p;v.positionScreen.y*=-w;u.positionScreen.x*=p;u.positionScreen.y*=-w;t.positionScreen.x*=p;t.positionScreen.y*=-w;A.addPoint(v.positionScreen.x,v.positionScreen.y);A.addPoint(u.positionScreen.x,u.positionScreen.y);A.addPoint(t.positionScreen.x,t.positionScreen.y);if(!E.instersects(A)){continue}I=0;J=K.meshMaterial.length;while(I<J){N=K.meshMaterial[I++];if(N instanceof THREE.MeshFaceMaterial){Q=0;M=K.faceMaterial.length;while(Q<M){N=K.faceMaterial[Q++];N&&h(v,u,t,K,N,L)}continue}N&&h(v,u,t,K,N,L)}}else{if(K instanceof THREE.RenderableFace4){v=K.v1;u=K.v2;t=K.v3;s=K.v4;v.positionScreen.x*=p;v.positionScreen.y*=-w;u.positionScreen.x*=p;u.positionScreen.y*=-w;t.positionScreen.x*=p;t.positionScreen.y*=-w;s.positionScreen.x*=p;s.positionScreen.y*=-w;A.addPoint(v.positionScreen.x,v.positionScreen.y);A.addPoint(u.positionScreen.x,u.positionScreen.y);A.addPoint(t.positionScreen.x,t.positionScreen.y);A.addPoint(s.positionScreen.x,s.positionScreen.y);if(!E.instersects(A)){continue}I=0;J=K.meshMaterial.length;while(I<J){N=K.meshMaterial[I++];if(N instanceof THREE.MeshFaceMaterial){Q=0;M=K.faceMaterial.length;while(Q<M){N=K.faceMaterial[Q++];N&&e(v,u,t,s,K,N,L)}continue}N&&e(v,u,t,s,K,N,L)}}}}}};function D(L,J){var I,K,H;J.setRGBA(0,0,0,1);for(I=0,K=L.lights.length;I<K;I++){H=L.lights[I];if(H instanceof THREE.AmbientLight){J.r+=H.color.r;J.g+=H.color.g;J.b+=H.color.b}}}function q(M,K,J){var I,L,H;for(I=0,L=M.lights.length;I<L;I++){H=M.lights[I];if(H instanceof THREE.DirectionalLight){J.r+=H.color.r;J.g+=H.color.g;J.b+=H.color.b}else{if(H instanceof THREE.PointLight){J.r+=H.color.r;J.g+=H.color.g;J.b+=H.color.b}}}}function a(N,L,J){var I,M,H,K;for(I=0,M=N.lights.length;I<M;I++){H=N.lights[I];if(H instanceof THREE.DirectionalLight){K=L.normalWorld.dot(H.position)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}else{if(H instanceof THREE.PointLight){g.sub(H.position,L.centroidWorld);g.normalize();K=L.normalWorld.dot(g)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}}}}function j(K,H,I,J){G=y(f++);G.setAttribute("cx",K.x);G.setAttribute("cy",K.y);G.setAttribute("r",H.scale.x*p);if(I instanceof THREE.ParticleCircleMaterial){if(i){z.copyRGB(c);q(J,H,z);k.copyRGBA(I.color);k.multiplySelfRGB(z);k.updateStyleString()}else{k=I.color}G.setAttribute("style","fill: "+k.__styleString)}x.appendChild(G)}function h(M,L,K,H,I,J){G=m(n++);G.setAttribute("d","M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshDepthMaterial){B=1-(I.__2near/(I.__farPlusNear-H.z*I.__farMinusNear));k.setRGBA(B,B,B,1)}else{if(I instanceof THREE.MeshLambertMaterial){if(i){z.copyRGB(c);a(J,H,z);k.copyRGBA(I.color);k.multiplySelfRGB(z);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}}if(I.wireframe){G.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{G.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}x.appendChild(G)}function e(N,M,L,J,H,I,K){G=m(n++);G.setAttribute("d","M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+L.positionScreen.x+","+L.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshLambertMaterial){if(i){z.copyRGB(c);a(K,H,z);k.copyRGBA(I.color);k.multiplySelfRGB(z);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}if(I.wireframe){G.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{G.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}x.appendChild(G)}function m(H){if(d[H]==null){d[H]=document.createElementNS("http://www.w3.org/2000/svg","path");if(F==0){d[H].setAttribute("shape-rendering","crispEdges")}return d[H]}return d[H]}function y(H){if(l[H]==null){l[H]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(F==0){l[H].setAttribute("shape-rendering","crispEdges")}return l[H]}return l[H]}};THREE.WebGLRenderer=function(l){var o=document.createElement("canvas"),e,h,q=new THREE.Matrix4(),n,a=0,b=1,f=2,d=3,g=m(l,5);this.domElement=o;this.autoClear=true;k();j(g.directional,g.point);function m(v,w){if(v){var s,u,r,t=pointLights=maxDirLights=maxPointLights=0;for(s=0,u=v.lights.length;s<u;s++){r=v.lights[s];if(r instanceof THREE.DirectionalLight){t++}if(r instanceof THREE.PointLight){pointLights++}}if((pointLights+t)<=w){maxDirLights=t;maxPointLights=pointLights}else{maxDirLights=Math.ceil(w*t/(pointLights+t));maxPointLights=w-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:w-1}}this.setSize=function(s,r){o.width=s;o.height=r;e.viewport(0,0,o.width,o.height)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.setupLights=function(y){var v,C,w,t,z,D,u=[],A=[],B=[],s=[],x=[];e.uniform1i(h.enableLighting,y.lights.length);for(v=0,C=y.lights.length;v<C;v++){w=y.lights[v];if(w instanceof THREE.AmbientLight){u.push(w)}else{if(w instanceof THREE.DirectionalLight){B.push(w)}else{if(w instanceof THREE.PointLight){A.push(w)}}}}t=z=D=0;for(v=0,C=u.length;v<C;v++){t+=u[v].color.r;z+=u[v].color.g;D+=u[v].color.b}e.uniform3f(h.ambientLightColor,t,z,D);s=[];x=[];for(v=0,C=B.length;v<C;v++){w=B[v];s.push(w.color.r*w.intensity);s.push(w.color.g*w.intensity);s.push(w.color.b*w.intensity);x.push(w.position.x);x.push(w.position.y);x.push(w.position.z)}if(B.length){e.uniform1i(h.directionalLightNumber,B.length);e.uniform3fv(h.directionalLightDirection,x);e.uniform3fv(h.directionalLightColor,s)}s=[];x=[];for(v=0,C=A.length;v<C;v++){w=A[v];s.push(w.color.r*w.intensity);s.push(w.color.g*w.intensity);s.push(w.color.b*w.intensity);x.push(w.position.x);x.push(w.position.y);x.push(w.position.z)}if(A.length){e.uniform1i(h.pointLightNumber,A.length);e.uniform3fv(h.pointLightPosition,x);e.uniform3fv(h.pointLightColor,s)}};this.createBuffers=function(K,I){var G,y,A,x,F,J,w,u,t,s,r,v=K.materialFaceGroup[I],C=[],E=[],B=[],H=[],D=[],z=0;for(G=0,y=v.faces.length;G<y;G++){A=v.faces[G];x=K.geometry.faces[A];F=x.vertexNormals;J=x.normal;w=K.geometry.uvs[A];if(x instanceof THREE.Face3){u=K.geometry.vertices[x.a].position;t=K.geometry.vertices[x.b].position;s=K.geometry.vertices[x.c].position;B.push(u.x,u.y,u.z);B.push(t.x,t.y,t.z);B.push(s.x,s.y,s.z);if(F.length==3){H.push(F[0].x,F[0].y,F[0].z);H.push(F[1].x,F[1].y,F[1].z);H.push(F[2].x,F[2].y,F[2].z)}else{H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z)}if(w){D.push(w[0].u,w[0].v);D.push(w[1].u,w[1].v);D.push(w[2].u,w[2].v)}C.push(z,z+1,z+2);E.push(z,z+1);E.push(z,z+2);E.push(z+1,z+2);z+=3}else{if(x instanceof THREE.Face4){u=K.geometry.vertices[x.a].position;t=K.geometry.vertices[x.b].position;s=K.geometry.vertices[x.c].position;r=K.geometry.vertices[x.d].position;B.push(u.x,u.y,u.z);B.push(t.x,t.y,t.z);B.push(s.x,s.y,s.z);B.push(r.x,r.y,r.z);if(F.length==4){H.push(F[0].x,F[0].y,F[0].z);H.push(F[1].x,F[1].y,F[1].z);H.push(F[2].x,F[2].y,F[2].z);H.push(F[3].x,F[3].y,F[3].z)}else{H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z);H.push(J.x,J.y,J.z)}if(w){D.push(w[0].u,w[0].v);D.push(w[1].u,w[1].v);D.push(w[2].u,w[2].v);D.push(w[3].u,w[3].v)}C.push(z,z+1,z+2);C.push(z,z+2,z+3);E.push(z,z+1);E.push(z,z+2);E.push(z,z+3);E.push(z+1,z+2);E.push(z+2,z+3);z+=4}}}if(!B.length){return}v.__webGLVertexBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(B),e.STATIC_DRAW);v.__webGLNormalBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(H),e.STATIC_DRAW);v.__webGLUVBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(D),e.STATIC_DRAW);v.__webGLFaceBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),e.STATIC_DRAW);v.__webGLLineBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),e.STATIC_DRAW);v.__webGLFaceCount=C.length;v.__webGLLineCount=E.length};this.renderBuffer=function(w,A){var v,t,u,s,r,z,y,B,x;if(w instanceof THREE.MeshPhongMaterial||w instanceof THREE.MeshLambertMaterial||w instanceof THREE.MeshBasicMaterial){v=w.color;t=w.opacity;u=w.wireframe;s=w.wireframe_linewidth;r=w.blending;x=w.map;e.uniform4f(h.mColor,v.r*t,v.g*t,v.b*t,t)}if(w instanceof THREE.MeshDepthMaterial){t=w.opacity;u=w.wireframe;s=w.wireframe_linewidth;e.uniform1f(h.m2Near,w.__2near);e.uniform1f(h.mFarPlusNear,w.__farPlusNear);e.uniform1f(h.mFarMinusNear,w.__farMinusNear);e.uniform1i(h.material,d)}else{if(w instanceof THREE.MeshPhongMaterial){z=w.ambient;y=w.specular;B=w.shininess;e.uniform4f(h.mAmbient,z.r,z.g,z.b,t);e.uniform4f(h.mSpecular,y.r,y.g,y.b,t);e.uniform1f(h.mShininess,B);e.uniform1i(h.material,f)}else{if(w instanceof THREE.MeshLambertMaterial){e.uniform1i(h.material,b)}else{if(w instanceof THREE.MeshBasicMaterial){e.uniform1i(h.material,a)}}}}if(x){if(!w.__webGLTexture&&w.map.loaded){w.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,w.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,w.map.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,w.__webGLTexture);e.uniform1i(h.tMap,0);e.uniform1i(h.enableMap,1)}else{e.uniform1i(h.enableMap,0)}e.bindBuffer(e.ARRAY_BUFFER,A.__webGLVertexBuffer);e.vertexAttribPointer(h.position,3,e.FLOAT,false,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLNormalBuffer);e.vertexAttribPointer(h.normal,3,e.FLOAT,false,0,0);if(x){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUVBuffer);e.enableVertexAttribArray(h.uv);e.vertexAttribPointer(h.uv,2,e.FLOAT,false,0,0)}else{e.disableVertexAttribArray(h.uv)}if(!u){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,A.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else{e.lineWidth(s);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);e.drawElements(e.LINES,A.__webGLLineCount,e.UNSIGNED_SHORT,0)}};this.renderMesh=function(t,w){var v,s,r,u,z,x,y,A;for(z in t.materialFaceGroup){A=t.materialFaceGroup[z];if(!A.__webGLVertexBuffer){this.createBuffers(t,z)}for(r=0,u=t.material.length;r<u;r++){y=t.material[r];if(y instanceof THREE.MeshFaceMaterial){for(v=0,s=A.material.length;v<s;v++){x=A.material[v];this.renderBuffer(x,A)}}else{x=y;this.renderBuffer(x,A)}}}};this.setupMatrices=function(r,s){r.autoUpdateMatrix&&r.updateMatrix();q.multiply(s.matrix,r.matrix);h.viewMatrixArray=new Float32Array(s.matrix.flatten());h.modelViewMatrixArray=new Float32Array(q.flatten());h.projectionMatrixArray=new Float32Array(s.projectionMatrix.flatten());n=THREE.Matrix4.makeInvert3x3(q).transpose();h.normalMatrixArray=new Float32Array(n.m);e.uniformMatrix4fv(h.viewMatrix,false,h.viewMatrixArray);e.uniformMatrix4fv(h.modelViewMatrix,false,h.modelViewMatrixArray);e.uniformMatrix4fv(h.projectionMatrix,false,h.projectionMatrixArray);e.uniformMatrix3fv(h.normalMatrix,false,h.normalMatrixArray);e.uniformMatrix4fv(h.objMatrix,false,new Float32Array(r.matrix.flatten()))};this.render=function(u,t){var v,s,r;if(this.autoClear){this.clear()}t.autoUpdateMatrix&&t.updateMatrix();e.uniform3f(h.cameraPosition,t.position.x,t.position.y,t.position.z);this.setupLights(u);for(v=0,s=u.objects.length;v<s;v++){r=u.objects[v];this.setupMatrices(r,t);if(r instanceof THREE.Mesh){this.renderMesh(r,t)}else{if(r instanceof THREE.Line){}else{if(r instanceof THREE.Particle){}}}}};this.setFaceCulling=function(s,r){if(s){if(!r||r=="ccw"){e.frontFace(e.CCW)}else{e.frontFace(e.CW)}if(s=="back"){e.cullFace(e.BACK)}else{if(s=="front"){e.cullFace(e.FRONT)}else{e.cullFace(e.FRONT_AND_BACK)}}e.enable(e.CULL_FACE)}else{e.disable(e.CULL_FACE)}};function k(){try{e=o.getContext("experimental-webgl",{antialias:true})}catch(r){}if(!e){alert("WebGL not supported");throw"cannot create webgl context"}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(0,0,0,0)}function p(r,s){var t=["#ifdef GL_ES","precision highp float;","#endif",r?"#define MAX_DIR_LIGHTS "+r:"",s?"#define MAX_POINT_LIGHTS "+s:"","uniform int material;","uniform bool enableMap;","uniform sampler2D tMap;","uniform vec4 mColor;","uniform vec4 mAmbient;","uniform vec4 mSpecular;","uniform float mShininess;","uniform float m2Near;","uniform float mFarPlusNear;","uniform float mFarMinusNear;","uniform int pointLightNumber;","uniform int directionalLightNumber;",r?"uniform mat4 viewMatrix;":"",r?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",s?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main() {","vec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );","if ( enableMap ) {","mapColor = texture2D( tMap, vUv );","}","if ( material == 3 ) { ","float w = 0.5;","gl_FragColor = vec4( w, w, w, 1.0 );","} else if ( material == 2 ) { ","vec3 normal = normalize( vNormal );","vec3 viewPosition = normalize( vViewPosition );",s?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",s?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",s?"for( int i = 0; i < pointLightNumber; i++ ) {":"",s?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",s?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",s?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",s?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",s?"float pointSpecularWeight = 0.0;":"",s?"if ( pointDotNormalHalf >= 0.0 )":"",s?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",s?"pointDiffuse += mColor * pointDiffuseWeight;":"",s?"pointSpecular += mSpecular * pointSpecularWeight;":"",s?"}":"",r?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"vec3 dirVector = normalize( lDirection.xyz );":"",r?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",r?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",r?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",r?"float dirSpecularWeight = 0.0;":"",r?"if ( dirDotNormalHalf >= 0.0 )":"",r?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",r?"dirDiffuse += mColor * dirDiffuseWeight;":"",r?"dirSpecular += mSpecular * dirSpecularWeight;":"",r?"}":"","vec4 totalLight = mAmbient;",r?"totalLight += dirDiffuse + dirSpecular;":"",s?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( mapColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * mapColor.rgb * vLightWeighting, mColor.a * mapColor.a );","} else {","gl_FragColor = mColor * mapColor;","}","}"];return t.join("\n")}function i(r,s){var t=[r?"#define MAX_DIR_LIGHTS "+r:"",s?"#define MAX_POINT_LIGHTS "+s:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",r?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",r?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",s?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",s?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",s?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","varying vec3 vFragPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",r?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",r?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",r?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",r?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",r?"}":"",s?"for( int i = 0; i < pointLightNumber; i++ ) {":"",s?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",s?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",s?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",s?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",s?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return t.join("\n")}function j(r,s){h=e.createProgram();e.attachShader(h,c("fragment",p(r,s)));e.attachShader(h,c("vertex",i(r,s)));e.linkProgram(h);if(!e.getProgramParameter(h,e.LINK_STATUS)){alert("Could not initialise shaders")}e.useProgram(h);h.viewMatrix=e.getUniformLocation(h,"viewMatrix");h.modelViewMatrix=e.getUniformLocation(h,"modelViewMatrix");h.projectionMatrix=e.getUniformLocation(h,"projectionMatrix");h.normalMatrix=e.getUniformLocation(h,"normalMatrix");h.objMatrix=e.getUniformLocation(h,"objMatrix");h.cameraPosition=e.getUniformLocation(h,"cameraPosition");h.enableLighting=e.getUniformLocation(h,"enableLighting");h.ambientLightColor=e.getUniformLocation(h,"ambientLightColor");if(r){h.directionalLightNumber=e.getUniformLocation(h,"directionalLightNumber");h.directionalLightColor=e.getUniformLocation(h,"directionalLightColor");h.directionalLightDirection=e.getUniformLocation(h,"directionalLightDirection")}if(s){h.pointLightNumber=e.getUniformLocation(h,"pointLightNumber");h.pointLightColor=e.getUniformLocation(h,"pointLightColor");h.pointLightPosition=e.getUniformLocation(h,"pointLightPosition")}h.material=e.getUniformLocation(h,"material");h.mColor=e.getUniformLocation(h,"mColor");h.mAmbient=e.getUniformLocation(h,"mAmbient");h.mSpecular=e.getUniformLocation(h,"mSpecular");h.mShininess=e.getUniformLocation(h,"mShininess");h.enableMap=e.getUniformLocation(h,"enableMap");e.uniform1i(h.enableMap,0);h.tMap=e.getUniformLocation(h,"tMap");e.uniform1i(h.tMap,0);h.m2Near=e.getUniformLocation(h,"m2Near");h.mFarPlusNear=e.getUniformLocation(h,"mFarPlusNear");h.mFarMinusNear=e.getUniformLocation(h,"mFarMinusNear");h.position=e.getAttribLocation(h,"position");e.enableVertexAttribArray(h.position);h.normal=e.getAttribLocation(h,"normal");e.enableVertexAttribArray(h.normal);h.uv=e.getAttribLocation(h,"uv");e.enableVertexAttribArray(h.uv);h.viewMatrixArray=new Float32Array(16);h.modelViewMatrixArray=new Float32Array(16);h.projectionMatrixArray=new Float32Array(16)}function c(s,r){var t;if(s=="fragment"){t=e.createShader(e.FRAGMENT_SHADER)}else{if(s=="vertex"){t=e.createShader(e.VERTEX_SHADER)}}e.shaderSource(t,r);e.compileShader(t);if(!e.getShaderParameter(t,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(t));return null}return t}};THREE.RenderableFace3=function(){this.v1=new THREE.Vertex();this.v2=new THREE.Vertex();this.v3=new THREE.Vertex();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vertex();this.v2=new THREE.Vertex();this.v3=new THREE.Vertex();this.v4=new THREE.Vertex();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vertex();this.v2=new THREE.Vertex();this.z=null;this.color=null;this.material=null};
\ No newline at end of file
// ThreeDebug.js r28 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a: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=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(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("+~~(this.r*255)+","+~~(this.g*255)+","+~~(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.Ray=function(a,b){this.origin=a||new THREE.Vector3();this.direction=b||new THREE.Vector3()};THREE.Ray.prototype={intersectScene:function(f){var c,a,b,e=f.objects,d=[];for(c=0,a=e.length;c<a;c++){b=e[c];if(b instanceof THREE.Mesh){d=d.concat(this.intersectObject(b))}}d.sort(function(h,g){return h.distance-g.distance});return d},intersectObject:function(w){var n,j,i,t,s,q,p,v,k,x,u,r,g=w.geometry,h=g.vertices,o,e=[],m;for(n=0,j=g.faces.length;n<j;n++){i=g.faces[n];u=this.origin.clone();r=this.direction.clone();t=w.matrix.transform(h[i.a].position.clone());s=w.matrix.transform(h[i.b].position.clone());q=w.matrix.transform(h[i.c].position.clone());p=i instanceof THREE.Face4?w.matrix.transform(h[i.d].position.clone()):null;v=w.matrixRotation.transform(i.normal.clone());k=r.dot(v);if(k<0){x=v.dot(new THREE.Vector3().sub(t,u))/k;m=u.addSelf(r.multiplyScalar(x));if(i instanceof THREE.Face3){if(l(m,t,s,q)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}else{if(i instanceof THREE.Face4){if(l(m,t,s,p)||l(m,s,q,p)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}}}}return e;function l(d,G,D,B){var J=B.clone().subSelf(G),H=D.clone().subSelf(G),E=d.clone().subSelf(G),F=J.dot(J),C=J.dot(H),A=J.dot(E),z=H.dot(H),f=H.dot(E),y=1/(F*z-C*C),K=(z*A-C*f)*y,I=(F*f-C*A)*y;return(K>0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;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(m){var e,b,o,g,i,j,l,k,d,c,a,h=new THREE.Vector3(),p=new THREE.Vector3();for(o=0,g=this.vertices.length;o<g;o++){i=this.vertices[o];i.normal.set(0,0,0)}for(j=0,l=this.faces.length;j<l;j++){k=this.faces[j];if(m&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.addSelf(k.vertexNormals[e])}h.divideScalar(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);p.sub(d.position,c.position);h.crossSelf(p);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]};for(var 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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae<ad;ae+=af){ac=f(c,ae);ah=f(c,ae+x.vertex_coordinate_bytes);ag=f(c,ae+x.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,ac,ah,ag)}return x.nvertices*af}function H(ai){var ae,ac,ah,ag,af=x.normal_coordinate_bytes*3,ad=ai+x.nnormals*af;for(ae=ai;ae<ad;ae+=af){ac=i(c,ae);ah=i(c,ae+x.normal_coordinate_bytes);ag=i(c,ae+x.normal_coordinate_bytes*2);A.push(ac/127,ah/127,ag/127)}return x.nnormals*af}function G(ah){var af,ae,ad,ag=x.uv_coordinate_bytes*2,ac=ah+x.nuvs*ag;for(af=ah;af<ac;af+=ag){ae=f(c,af);ad=f(c,af+x.uv_coordinate_bytes);L.push(ae,ad)}return x.nuvs*ag}function M(af){var ae,ad,ag,ac;ae=v(c,af);ad=v(c,af+V);ag=v(c,af+T);ac=Z(c,af+O);THREE.Loader.prototype.f3(I,ae,ad,ag,ac)}function m(ah){var ag,ae,aj,ad,af,ac,ai;ag=v(c,ah);ae=v(c,ah+V);aj=v(c,ah+T);ad=Z(c,ah+O);af=v(c,ah+U);ac=v(c,ah+R);ai=v(c,ah+P);THREE.Loader.prototype.f3n(I,A,ag,ae,aj,ad,af,ac,ai)}function E(af){var ae,ad,ah,ag,ac;ae=v(c,af);ad=v(c,af+D);ah=v(c,af+C);ag=v(c,af+B);ac=Z(c,af+y);THREE.Loader.prototype.f4(I,ae,ad,ah,ag,ac)}function l(af){var al,ak,aj,ai,ac,ah,ag,ae,ad;al=v(c,af);ak=v(c,af+D);aj=v(c,af+C);ai=v(c,af+B);ac=Z(c,af+y);ah=v(c,af+r);ag=v(c,af+q);ae=v(c,af+p);ad=v(c,af+o);THREE.Loader.prototype.f4n(I,A,al,ak,aj,ai,ac,ah,ag,ae,ad)}function Y(ai){var ah,ae,ac,ag,af,ad,al,ak,aj;ah=v(c,ai);ae=v(c,ai+u);ac=v(c,ai+t);ag=L[ah*2];al=L[ah*2+1];af=L[ae*2];ak=L[ae*2+1];ad=L[ac*2];aj=L[ac*2+1];THREE.Loader.prototype.uv(I,ag,al,af,ak,ad,aj)}function X(ak){var aj,ag,ae,ad,ai,ah,af,ac,ao,an,am,al;aj=v(c,ak);ag=v(c,ak+N);ae=v(c,ak+K);ad=v(c,ak+J);ai=L[aj*2];ao=L[aj*2+1];ah=L[ag*2];an=L[ag*2+1];af=L[ae*2];am=L[ae*2+1];ac=L[ad*2];al=L[ad*2+1];THREE.Loader.prototype.uv(I,ai,ao,ah,an,af,am,ac,al)}function Q(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes,ac=af+x.ntri_flat*ae;for(ad=af;ad<ac;ad+=ae){M(ad)}return ac-af}function ab(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){M(ad);Y(ad+af)}return ac-ag}function S(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ac=af+x.ntri_smooth*ae;for(ad=af;ad<ac;ad+=ae){m(ad)}return ac-af}function n(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){m(ad);Y(ad+af)}return ac-ag}function g(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes,ac=af+x.nquad_flat*ae;for(ad=af;ad<ac;ad+=ae){E(ad)}return ac-af}function s(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){E(ad);X(ad+af)}return ac-ag}function k(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ac=af+x.nquad_smooth*ae;for(ad=af;ad<ac;ad+=ae){l(ad)}return ac-af}function z(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){l(ad);X(ad+af)}return ac-ag}};d.prototype=new THREE.Geometry();d.prototype.constructor=d;e(new d(b))},createModel:function(b,d,a){var c=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,b.materials,f);e();h();this.computeCentroids();this.computeNormals();function e(){var m,k,j,o,n;for(m=0,k=b.vertices.length;m<k;m+=3){j=b.vertices[m];o=b.vertices[m+1];n=b.vertices[m+2];THREE.Loader.prototype.v(g,j,o,n)}}function h(){function p(v,u){var t,s,w,l;t=v[u];s=v[u+1];w=v[u+2];l=v[u+3];THREE.Loader.prototype.f3(g,t,s,w,l)}function k(l,u){var z,y,x,s,w,v,t;z=l[u];y=l[u+1];x=l[u+2];s=l[u+3];w=l[u+4];v=l[u+5];t=l[u+6];THREE.Loader.prototype.f3n(g,b.normals,z,y,x,s,w,v,t)}function o(w,u){var t,s,x,v,l;t=w[u];s=w[u+1];x=w[u+2];v=w[u+3];l=w[u+4];THREE.Loader.prototype.f4(g,t,s,x,v,l)}function j(l,v){var B,A,z,y,s,x,w,u,t;B=l[v];A=l[v+1];z=l[v+2];y=l[v+3];s=l[v+4];x=l[v+5];w=l[v+6];u=l[v+7];t=l[v+8];THREE.Loader.prototype.f4n(g,b.normals,B,A,z,y,s,x,w,u,t)}function r(l,y){var x,u,s,w,v,t,B,A,z;x=l[y];u=l[y+1];s=l[y+2];w=b.uvs[x*2];B=b.uvs[x*2+1];v=b.uvs[u*2];A=b.uvs[u*2+1];t=b.uvs[s*2];z=b.uvs[s*2+1];THREE.Loader.prototype.uv(g,w,B,v,A,t,z)}function q(s,A){var z,w,v,t,y,x,u,l,E,D,C,B;z=s[A];w=s[A+1];v=s[A+2];t=s[A+3];y=b.uvs[z*2];E=b.uvs[z*2+1];x=b.uvs[w*2];D=b.uvs[w*2+1];u=b.uvs[v*2];C=b.uvs[v*2+1];l=b.uvs[t*2];B=b.uvs[t*2+1];THREE.Loader.prototype.uv(g,y,E,x,D,u,C,l,B)}var n,m;for(n=0,m=b.triangles.length;n<m;n+=4){p(b.triangles,n)}for(n=0,m=b.triangles_uv.length;n<m;n+=7){p(b.triangles_uv,n);r(b.triangles_uv,n+4)}for(n=0,m=b.triangles_n.length;n<m;n+=7){k(b.triangles_n,n)}for(n=0,m=b.triangles_n_uv.length;n<m;n+=10){k(b.triangles_n_uv,n);r(b.triangles_n_uv,n+7)}for(n=0,m=b.quads.length;n<m;n+=5){o(b.quads,n)}for(n=0,m=b.quads_uv.length;n<m;n+=9){o(b.quads_uv,n);q(b.quads_uv,n+5)}for(n=0,m=b.quads_n.length;n<m;n+=9){j(b.quads_n,n)}for(n=0,m=b.quads_n_uv.length;n<m;n+=13){j(b.quads_n_uv,n);q(b.quads_n_uv,n+9)}}};c.prototype=new THREE.Geometry();c.prototype.constructor=c;d(new c(a))},v:function(b,a,d,c){b.vertices.push(new THREE.Vertex(new THREE.Vector3(a,d,c)))},f3:function(h,e,d,i,f){var g=h.materials[f];h.faces.push(new THREE.Face3(e,d,i,null,g))},f4:function(i,f,e,k,j,g){var h=i.materials[g];i.faces.push(new THREE.Face4(f,e,k,j,null,h))},f3n:function(d,l,s,r,q,p,j,i,h){var k=d.materials[p],g=l[j*3],f=l[j*3+1],e=l[j*3+2],o=l[i*3],n=l[i*3+1],m=l[i*3+2],v=l[h*3],u=l[h*3+1],t=l[h*3+2];d.faces.push(new THREE.Face3(s,r,q,[new THREE.Vector3(g,f,e),new THREE.Vector3(o,n,m),new THREE.Vector3(v,u,t)],k))},f4n:function(e,q,y,x,w,u,v,o,n,m,k){var p=e.materials[v],j=q[o*3],h=q[o*3+1],f=q[o*3+2],t=q[n*3],s=q[n*3+1],r=q[n*3+2],B=q[m*3],A=q[m*3+1],z=q[m*3+2],l=q[k*3],i=q[k*3+1],g=q[k*3+2];e.faces.push(new THREE.Face4(y,x,w,u,[new THREE.Vector3(j,h,f),new THREE.Vector3(t,s,r),new THREE.Vector3(B,A,z),new THREE.Vector3(l,i,g)],p))},uv:function(j,e,i,c,h,b,g,a,f){var d=[];d.push(new THREE.UV(e,i));d.push(new THREE.UV(c,h));d.push(new THREE.UV(b,g));if(a&&f){d.push(new THREE.UV(a,f))}j.uvs.push(d)},init_materials:function(d,a,c){d.materials=[];for(var b=0;b<a.length;++b){d.materials[b]=[THREE.Loader.prototype.createMaterial(a[b],c)]}},createMaterial:function(a,c){function g(j){var i=Math.log(j)/Math.LN2;return Math.floor(i)==i}function f(j){var i=Math.log(j)/Math.LN2;return Math.pow(2,Math.round(i))}var d,e,h,b;if(a.map_diffuse&&c){e=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(e)});h=new Image();h.onload=function(){if(!g(this.width)||!g(this.height)){var i=f(this.width),j=f(this.height);d.map.image.width=i;d.map.image.height=j;d.map.image.getContext("2d").drawImage(this,0,0,i,j)}else{d.map.image=this}d.map.loaded=1};h.src=c+"/"+a.map_diffuse}else{if(a.col_diffuse){b=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:b,opacity:a.transparency})}else{if(a.a_dbg_color){d=new THREE.MeshLambertMaterial({color:a.a_dbg_color})}else{d=new THREE.MeshLambertMaterial({color:15658734})}}}return d}};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.materialFaceGroup={};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 c,b,e,m,k,h,j,n,d,g={};function a(f){var i=[];for(c=0,b=f.length;c<b;c++){if(f[c]==undefined){i.push("undefined")}else{i.push(f[c].toString())}}return i.join("_")}for(e=0,m=this.geometry.faces.length;e<m;e++){k=this.geometry.faces[e];h=k.material;n=a(h);if(g[n]==undefined){g[n]={hash:n,counter:0}}d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}j=k instanceof THREE.Face3?3:4;if(this.materialFaceGroup[d].vertices+j>65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e<a;e++){c=this.geometry.uvs[e];for(b=0,d=c.length;b<d;b++){if(c[b].u!=1){c[b].u=c[b].u-Math.floor(c[b].u)}if(c[b].v!=1){c[b].v=c[b].v-Math.floor(c[b].v)}}}};THREE.FlatShading=0;THREE.GouraudShading=1;THREE.PhongShading=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubstractiveBlending=2;THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.linewidth!==undefined){this.linewidth=a.linewidth}}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1000;this.opacity=1;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.near!==undefined){this.near=a.near}if(a.far!==undefined){this.far=a.far}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_size: "+this.wireframe_linewidth+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color=new THREE.Color(a.color)}if(a.map!==undefined){this.map=a.map}if(a.ambient!==undefined){this.ambient=new THREE.Color(a.ambient)}if(a.specular!==undefined){this.specular=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>specular_map: "+this.specular_map+"<br/>shininess: "+this.shininess+"<br/>alpha: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2();if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F<E;F++){L=r[F];q=L.matrix;if(L.autoUpdateMatrix){L.updateMatrix()}if(L instanceof THREE.Mesh){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I<B;I++){A=w[I];if(A instanceof THREE.Face3){y=z[A.a];x=z[A.b];t=z[A.c];if(y.__visible&&x.__visible&&t.__visible){if((L.doubleSided||(L.flipSided!=(t.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(t.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0))){c=n[p]=n[p]||new THREE.RenderableFace3();c.v1.copy(y.positionScreen);c.v2.copy(x.positionScreen);c.v3.copy(t.positionScreen);c.normalWorld.copy(A.normal);L.matrixRotation.transform(c.normalWorld);c.centroidWorld.copy(A.centroid);q.transform(c.centroidWorld);c.centroidScreen.copy(c.centroidWorld);d.transform(c.centroidScreen);c.z=c.centroidScreen.z;c.meshMaterial=L.material;c.faceMaterial=A.material;c.overdraw=L.overdraw;c.uvs=L.geometry.uvs[I];c.color=A.color;e.push(c);p++}}}else{if(A instanceof THREE.Face4){y=z[A.a];x=z[A.b];t=z[A.c];s=z[A.d];if(y.__visible&&x.__visible&&t.__visible&&s.__visible){if((L.doubleSided||(L.flipSided!=((s.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(s.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0||(x.positionScreen.x-t.positionScreen.x)*(s.positionScreen.y-t.positionScreen.y)-(x.positionScreen.y-t.positionScreen.y)*(s.positionScreen.x-t.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.copy(y.positionScreen);b.v2.copy(x.positionScreen);b.v3.copy(t.positionScreen);b.v4.copy(s.positionScreen);b.normalWorld.copy(A.normal);L.matrixRotation.transform(b.normalWorld);b.centroidWorld.copy(A.centroid);q.transform(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);d.transform(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterial=L.material;b.faceMaterial=A.material;b.overdraw=L.overdraw;b.uvs=L.geometry.uvs[I];b.color=A.color;e.push(b);f++}}}}}}else{if(L instanceof THREE.Line){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1;if(D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.copy(H.positionScreen);k.v2.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);d.transform(g);g.z/=g.w;if(g.z>0&&g.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=g.x/g.w;j.y=g.y/g.w;j.z=g.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(j.x-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(j.y-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;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 n=null,x=new THREE.Projector(),s=document.createElement("canvas"),a,F,v,h,r=s.getContext("2d"),B=1,i="#000000",L="#000000",f=1,w=new THREE.Rectangle(),I=new THREE.Rectangle(),m=new THREE.Rectangle(),D=false,A=new THREE.Color(4294967295),y=new THREE.Color(4294967295),H=new THREE.Color(4278190080),k=Math.PI*2,C,G=new THREE.Vector2(),E=new THREE.Vector3(),u=new THREE.UV(),t=new THREE.UV(),q=new THREE.UV(),p=new THREE.UV(),K=new THREE.Vector2(),J=new THREE.Vector2();this.domElement=s;this.autoClear=true;this.setSize=function(N,M){a=N;F=M;v=a/2;h=F/2;s.width=a;s.height=F;r.lineJoin="round";r.lineCap="round";w.set(-v,-h,v,h)};this.clear=function(){if(!I.isEmpty()){I.inflate(1);I.minSelf(w);r.setTransform(1,0,0,-1,v,h);r.clearRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());I.empty()}};this.render=function(ah,ae){var ag,P,R,Z,af,V,S,Y,W,T,ac,aa,O,M,X,U,ad,ab,Q,N;if(this.autoClear){this.clear()}n=x.projectScene(ah,ae);r.setTransform(1,0,0,-1,v,h);r.fillStyle="rgba(0, 255, 255, 0.5)";r.fillRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());D=ah.lights.length>0;if(D){e(ah,H)}for(ag=0,P=n.length;ag<P;ag++){R=n[ag];m.empty();if(R instanceof THREE.RenderableParticle){W=R.x*v;T=R.y*h;for(Z=0,af=R.material.length;Z<af;Z++){Y=R.material[Z];Y&&o(W,T,R,Y,ah)}}else{if(R instanceof THREE.RenderableLine){W=R.v1.x*v;T=R.v1.y*h;ac=R.v2.x*v;aa=R.v2.y*h;m.addPoint(W,T);m.addPoint(ac,aa);if(!w.instersects(m)){continue}Z=0;af=R.material.length;while(Z<af){Y=R.material[Z++];Y&&z(W,T,ac,aa,R,Y,ah)}}else{if(R instanceof THREE.RenderableFace3){R.v1.x*=v;R.v1.y*=h;R.v2.x*=v;R.v2.y*=h;R.v3.x*=v;R.v3.y*=h;if(R.overdraw){b(R.v1,R.v2);b(R.v2,R.v3);b(R.v3,R.v1)}W=R.v1.x;T=R.v1.y;ac=R.v2.x;aa=R.v2.y;O=R.v3.x;M=R.v3.y;m.addPoint(W,T);m.addPoint(ac,aa);m.addPoint(O,M);if(!w.instersects(m)){continue}Z=0;af=R.meshMaterial.length;while(Z<af){Y=R.meshMaterial[Z++];if(Y instanceof THREE.MeshFaceMaterial){V=0;S=R.faceMaterial.length;while(V<S){Y=R.faceMaterial[V++];Y&&l(W,T,ac,aa,O,M,R,Y,ah)}continue}l(W,T,ac,aa,O,M,R,Y,ah)}}else{if(R instanceof THREE.RenderableFace4){R.v1.x*=v;R.v1.y*=h;R.v2.x*=v;R.v2.y*=h;R.v3.x*=v;R.v3.y*=h;R.v4.x*=v;R.v4.y*=h;K.copy(R.v2);J.copy(R.v4);if(R.overdraw){b(R.v1,R.v2);b(R.v2,R.v4);b(R.v4,R.v1)}W=R.v1.x;T=R.v1.y;ac=R.v2.x;aa=R.v2.y;X=R.v4.x;U=R.v4.y;if(R.overdraw){b(R.v3,K);b(R.v3,J)}O=R.v3.x;M=R.v3.y;ad=K.x;ab=K.y;Q=J.x;N=J.y;m.addPoint(W,T);m.addPoint(ac,aa);m.addPoint(O,M);m.addPoint(X,U);if(!w.instersects(m)){continue}Z=0;af=R.meshMaterial.length;while(Z<af){Y=R.meshMaterial[Z++];if(Y instanceof THREE.MeshFaceMaterial){V=0;S=R.faceMaterial.length;while(V<S){Y=R.faceMaterial[V++];Y&&j(W,T,ac,aa,O,M,X,U,ad,ab,Q,N,R,Y,ah)}continue}j(W,T,ac,aa,O,M,X,U,ad,ab,Q,N,R,Y,ah)}}}}}I.addRectangle(m)}r.lineWidth=1;r.strokeStyle="rgba( 255, 0, 0, 0.5 )";r.strokeRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());r.setTransform(1,0,0,1,0,0)};function e(S,P){var O,R,N,M,Q=S.lights;P.setRGBA(0,0,0,1);for(O=0,R=Q.length;O<R;O++){N=Q[O];M=N.color;if(N instanceof THREE.AmbientLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}}}function g(T,R,P){var O,S,N,M,Q=T.lights;for(O=0,S=Q.length;O<S;O++){N=Q[O];M=N.color;if(N instanceof THREE.DirectionalLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}else{if(N instanceof THREE.PointLight){P.r+=M.r;P.g+=M.g;P.b+=M.b}}}}function d(T,R,P){var O,S,N,M,Q;lights=T.lights;for(O=0,S=lights.length;O<S;O++){N=lights[O];M=N.color;if(N instanceof THREE.DirectionalLight){Q=R.normalWorld.dot(N.position)*N.intensity;if(Q>0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}else{if(N instanceof THREE.PointLight){E.sub(N.position,R.centroidWorld);E.normalize();Q=R.normalWorld.dot(E)*N.intensity;if(Q>0){P.r+=M.r*Q;P.g+=M.g*Q;P.b+=M.b*Q}}}}}function o(O,N,R,U,T){var M,Z,X,W,S,Q,V,Y,P;if(B!=U.opacity){r.globalAlpha=B=U.opacity}if(U instanceof THREE.ParticleBasicMaterial){V=U.bitmap;Y=V.width/2;P=V.height/2;X=R.scale.x*v;W=R.scale.y*h;M=X*Y;Z=W*P;S=U.offset.x*X;Q=U.offset.y*W;m.set(O+S-M,N+Q-Z,O+S+M,N+Q+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(X,-W);r.translate(-Y+U.offset.x,-P-U.offset.y);r.drawImage(V,0,0);r.restore();r.beginPath();r.moveTo(O-10,N);r.lineTo(O+10,N);r.moveTo(O,N-10);r.lineTo(O,N+10);r.closePath();r.strokeStyle="rgb(255,255,0)";r.stroke()}else{if(U instanceof THREE.ParticleCircleMaterial){if(D){y.copyRGB(H);g(T,R,y);A.copyRGBA(U.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=U.color.__styleString}M=R.scale.x*v;Z=R.scale.y*h;m.set(O-M,N-Z,O+M,N+Z);if(!w.instersects(m)){return}r.save();r.translate(O,N);r.rotate(-R.rotation);r.scale(M,Z);r.beginPath();r.arc(0,0,1,0,k,true);r.closePath();r.fillStyle=A.__styleString;r.fill();r.restore()}}}function z(M,S,O,N,P,Q,R){if(B!=Q.opacity){r.globalAlpha=B=Q.opacity}if(Q instanceof THREE.LineBasicMaterial){r.beginPath();r.moveTo(M,S);r.lineTo(O,N);r.closePath();A.__styleString=Q.color.__styleString;if(f!=Q.linewidth){r.lineWidth=f=Q.linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(Q.linewidth*2)}}function l(O,N,M,X,U,T,Q,S,R){var V,W,P;if(B!=S.opacity){r.globalAlpha=B=S.opacity}if(S.map){V=S.map.image;W=V.width-1;P=V.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);u.u*=W;u.v*=P;t.u*=W;t.v*=P;q.u*=W;q.v*=P;c(V,O,N,M,X,U,T,u.u,u.v,t.u,t.v,q.u,q.v);return}r.beginPath();r.moveTo(O,N);r.lineTo(M,X);r.lineTo(U,T);r.lineTo(O,N);r.closePath();if(S instanceof THREE.MeshBasicMaterial){A.__styleString=S.color.__styleString}else{if(S instanceof THREE.MeshDepthMaterial){C=1-(S.__2near/(S.__farPlusNear-Q.z*S.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(S instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(R,Q,y);A.copyRGBA(S.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=S.color.__styleString}}}}if(S.wireframe){if(f!=S.wireframe_linewidth){r.lineWidth=f=S.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(S.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function j(S,R,aa,Y,N,M,U,T,ab,Z,P,O,Q,W,ac){var ad,V,X;if(B!=W.opacity){r.globalAlpha=B=W.opacity}if(W.map){ad=W.map.image;V=ad.width-1;X=ad.height-1;u.copy(Q.uvs[0]);t.copy(Q.uvs[1]);q.copy(Q.uvs[2]);p.copy(Q.uvs[3]);u.u*=V;u.v*=X;t.u*=V;t.v*=X;q.u*=V;q.v*=X;p.u*=V;p.v*=X;c(ad,S,R,aa,Y,U,T,u.u,u.v,t.u,t.v,p.u,p.v);c(ad,ab,Z,N,M,P,O,t.u,t.v,q.u,q.v,p.u,p.v);return}r.beginPath();r.moveTo(S,R);r.lineTo(aa,Y);r.lineTo(N,M);r.lineTo(U,T);r.lineTo(S,R);r.closePath();if(W instanceof THREE.MeshBasicMaterial){A.__styleString=W.color.__styleString}else{if(W instanceof THREE.MeshDepthMaterial){C=1-(W.__2near/(W.__farPlusNear-Q.z*W.__farMinusNear));A.setRGBA(C,C,C,1)}else{if(W instanceof THREE.MeshLambertMaterial){if(D){y.copyRGB(H);d(ac,Q,y);A.copyRGBA(W.color);A.multiplySelfRGB(y);A.updateStyleString()}else{A.__styleString=W.color.__styleString}}}}if(W.wireframe){if(f!=W.wireframe_linewidth){r.lineWidth=f=W.wireframe_linewidth}if(i!=A.__styleString){r.strokeStyle=i=A.__styleString}r.stroke();m.inflate(W.wireframe_linewidth*2)}else{if(L!=A.__styleString){r.fillStyle=L=A.__styleString}r.fill()}}function c(af,Z,R,X,Q,V,O,W,P,U,N,T,M){r.beginPath();r.moveTo(Z,R);r.lineTo(X,Q);r.lineTo(V,O);r.lineTo(Z,R);r.closePath();X-=Z;Q-=R;V-=Z;O-=R;U-=W;N-=P;T-=W;M-=P;var S=1/(U*M-T*N),ae=(M*X-N*V)*S,ad=(M*Q-N*O)*S,ac=(U*V-T*X)*S,ab=(U*O-T*Q)*S,aa=Z-ae*W-ac*P,Y=R-ad*W-ab*P;r.save();r.transform(ae,ad,ac,ab,aa,Y);r.clip();r.drawImage(af,0,0);r.restore()}function b(N,M){G.sub(M,N);G.unit();G.multiplyScalar(0.75);M.addSelf(G);N.subSelf(G)}};THREE.SVGRenderer=function(){var y=null,r=new THREE.Projector(),t=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,s,A=new THREE.Rectangle(),w=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),v=new THREE.Color(4294967295),c=new THREE.Color(4294967295),x,g=new THREE.Vector3(),d=[],l=[],C,n,f,B=1;this.domElement=t;this.autoClear=true;this.setQuality=function(D){switch(D){case"high":B=1;break;case"low":B=0;break}};this.setSize=function(E,D){b=E;o=D;p=b/2;s=o/2;t.setAttribute("viewBox",(-p)+" "+(-s)+" "+b+" "+o);t.setAttribute("width",b);t.setAttribute("height",o);A.set(-p,-s,p,s)};this.clear=function(){while(t.childNodes.length>0){t.removeChild(t.childNodes[0])}};this.render=function(U,R){var T,F,O,S,K,H,G,N,L,I,Q,P,E,D,M,J;if(this.autoClear){this.clear()}y=r.projectScene(U,R);n=0;f=0;i=U.lights.length>0;if(i){z(U,c)}for(T=0,F=y.length;T<F;T++){G=y[T];w.empty();if(G instanceof THREE.RenderableParticle){L=G.x*p;I=G.y*-s;for(O=0,S=G.material.length;O<S;O++){N=G.material[O];N&&j(L,I,G,N,U)}}else{if(G instanceof THREE.RenderableFace3){L=G.v1.x*p;I=G.v1.y*-s;Q=G.v2.x*p;P=G.v2.y*-s;E=G.v3.x*p;D=G.v3.y*-s;w.addPoint(L,I);w.addPoint(Q,P);w.addPoint(E,D);if(!A.instersects(w)){continue}O=0;S=G.meshMaterial.length;while(O<S){N=G.meshMaterial[O++];if(N instanceof THREE.MeshFaceMaterial){K=0;H=G.faceMaterial.length;while(K<H){N=G.faceMaterial[K++];N&&h(L,I,Q,P,E,D,G,N,U)}continue}N&&h(L,I,Q,P,E,D,G,N,U)}}else{if(G instanceof THREE.RenderableFace4){L=G.v1.x*p;I=G.v1.y*-s;Q=G.v2.x*p;P=G.v2.y*-s;E=G.v3.x*p;D=G.v3.y*-s;M=G.v4.x*p;J=G.v4.y*-s;w.addPoint(L,I);w.addPoint(Q,P);w.addPoint(E,D);w.addPoint(M,J);if(!A.instersects(w)){continue}O=0;S=G.meshMaterial.length;while(O<S){N=G.meshMaterial[O++];if(N instanceof THREE.MeshFaceMaterial){K=0;H=G.faceMaterial.length;while(K<H){N=G.faceMaterial[K++];N&&e(L,I,Q,P,E,D,M,J,G,N,U)}continue}N&&e(L,I,Q,P,E,D,M,J,G,N,U)}}}}}};function z(H,F){var E,G,D;F.setRGBA(0,0,0,1);for(E=0,G=H.lights.length;E<G;E++){D=H.lights[E];if(D instanceof THREE.AmbientLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}}}function q(I,G,F){var E,H,D;for(E=0,H=I.lights.length;E<H;E++){D=I.lights[E];if(D instanceof THREE.DirectionalLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}else{if(D instanceof THREE.PointLight){F.r+=D.color.r;F.g+=D.color.g;F.b+=D.color.b}}}}function a(J,H,F){var E,I,D,G;for(E=0,I=J.lights.length;E<I;E++){D=J.lights[E];if(D instanceof THREE.DirectionalLight){G=H.normalWorld.dot(D.position)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}else{if(D instanceof THREE.PointLight){g.sub(D.position,H.centroidWorld);g.normalize();G=H.normalWorld.dot(g)*D.intensity;if(G>0){F.r+=D.color.r*G;F.g+=D.color.g*G;F.b+=D.color.b*G}}}}}function j(D,H,E,F,G){C=u(f++);C.setAttribute("cx",D);C.setAttribute("cy",H);C.setAttribute("r",E.scale.x*p);if(F instanceof THREE.ParticleCircleMaterial){if(i){v.copyRGB(c);q(G,E,v);k.copyRGBA(F.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k=F.color}C.setAttribute("style","fill: "+k.__styleString)}t.appendChild(C)}function h(F,E,D,L,K,J,G,I,H){C=m(n++);C.setAttribute("d","M "+F+" "+E+" L "+D+" "+L+" L "+K+","+J+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshDepthMaterial){x=1-(I.__2near/(I.__farPlusNear-G.z*I.__farMinusNear));k.setRGBA(x,x,x,1)}else{if(I instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(H,G,v);k.copyRGBA(I.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}}if(I.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}t.appendChild(C)}function e(H,F,D,N,M,L,G,E,I,K,J){C=m(n++);C.setAttribute("d","M "+H+" "+F+" L "+D+" "+N+" L "+M+","+L+" L "+G+","+E+"z");if(K instanceof THREE.MeshBasicMaterial){k.__styleString=K.color.__styleString}else{if(K instanceof THREE.MeshLambertMaterial){if(i){v.copyRGB(c);a(J,I,v);k.copyRGBA(K.color);k.multiplySelfRGB(v);k.updateStyleString()}else{k.__styleString=K.color.__styleString}}}if(K.wireframe){C.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{C.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+K.opacity)}t.appendChild(C)}function m(D){if(d[D]==null){d[D]=document.createElementNS("http://www.w3.org/2000/svg","path");if(B==0){d[D].setAttribute("shape-rendering","crispEdges")}return d[D]}return d[D]}function u(D){if(l[D]==null){l[D]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(B==0){l[D].setAttribute("shape-rendering","crispEdges")}return l[D]}return l[D]}};THREE.WebGLRenderer=function(q){var f=document.createElement("canvas"),e,n,j=new THREE.Matrix4(),c,l=0,s=1,o=2,i=3,k=b(q,5);this.domElement=f;this.autoClear=true;a();g(k.directional,k.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u<w;u++){t=x.lights[u];if(t instanceof THREE.DirectionalLight){v++}if(t instanceof THREE.PointLight){pointLights++}}if((pointLights+v)<=y){maxDirLights=v;maxPointLights=pointLights}else{maxDirLights=Math.ceil(y*v/(pointLights+v));maxPointLights=y-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:y-1}}this.setSize=function(u,t){f.width=u;f.height=t;e.viewport(0,0,f.width,f.height)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.setupLights=function(z){var w,D,x,u,A,E,v=[],B=[],C=[],t=[],y=[];e.uniform1i(n.enableLighting,z.lights.length);for(w=0,D=z.lights.length;w<D;w++){x=z.lights[w];if(x instanceof THREE.AmbientLight){v.push(x)}else{if(x instanceof THREE.DirectionalLight){C.push(x)}else{if(x instanceof THREE.PointLight){B.push(x)}}}}u=A=E=0;for(w=0,D=v.length;w<D;w++){u+=v[w].color.r;A+=v[w].color.g;E+=v[w].color.b}e.uniform3f(n.ambientLightColor,u,A,E);t=[];y=[];for(w=0,D=C.length;w<D;w++){x=C[w];t.push(x.color.r*x.intensity);t.push(x.color.g*x.intensity);t.push(x.color.b*x.intensity);y.push(x.position.x);y.push(x.position.y);y.push(x.position.z)}if(C.length){e.uniform1i(n.directionalLightNumber,C.length);e.uniform3fv(n.directionalLightDirection,y);e.uniform3fv(n.directionalLightColor,t)}t=[];y=[];for(w=0,D=B.length;w<D;w++){x=B[w];t.push(x.color.r*x.intensity);t.push(x.color.g*x.intensity);t.push(x.color.b*x.intensity);y.push(x.position.x);y.push(x.position.y);y.push(x.position.z)}if(B.length){e.uniform1i(n.pointLightNumber,B.length);e.uniform3fv(n.pointLightPosition,y);e.uniform3fv(n.pointLightColor,t)}};this.createBuffers=function(M,K){var I,A,C,z,H,L,y,w,v,u,t,x=M.materialFaceGroup[K],E=[],G=[],D=[],J=[],F=[],B=0;for(I=0,A=x.faces.length;I<A;I++){C=x.faces[I];z=M.geometry.faces[C];H=z.vertexNormals;L=z.normal;y=M.geometry.uvs[C];if(z instanceof THREE.Face3){w=M.geometry.vertices[z.a].position;v=M.geometry.vertices[z.b].position;u=M.geometry.vertices[z.c].position;D.push(w.x,w.y,w.z);D.push(v.x,v.y,v.z);D.push(u.x,u.y,u.z);if(H.length==3){J.push(H[0].x,H[0].y,H[0].z);J.push(H[1].x,H[1].y,H[1].z);J.push(H[2].x,H[2].y,H[2].z)}else{J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z)}if(y){F.push(y[0].u,y[0].v);F.push(y[1].u,y[1].v);F.push(y[2].u,y[2].v)}E.push(B,B+1,B+2);G.push(B,B+1);G.push(B,B+2);G.push(B+1,B+2);B+=3}else{if(z instanceof THREE.Face4){w=M.geometry.vertices[z.a].position;v=M.geometry.vertices[z.b].position;u=M.geometry.vertices[z.c].position;t=M.geometry.vertices[z.d].position;D.push(w.x,w.y,w.z);D.push(v.x,v.y,v.z);D.push(u.x,u.y,u.z);D.push(t.x,t.y,t.z);if(H.length==4){J.push(H[0].x,H[0].y,H[0].z);J.push(H[1].x,H[1].y,H[1].z);J.push(H[2].x,H[2].y,H[2].z);J.push(H[3].x,H[3].y,H[3].z)}else{J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z)}if(y){F.push(y[0].u,y[0].v);F.push(y[1].u,y[1].v);F.push(y[2].u,y[2].v);F.push(y[3].u,y[3].v)}E.push(B,B+1,B+2);E.push(B,B+2,B+3);G.push(B,B+1);G.push(B,B+2);G.push(B,B+3);G.push(B+1,B+2);G.push(B+2,B+3);B+=4}}}if(!D.length){return}x.__webGLVertexBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,x.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(D),e.STATIC_DRAW);x.__webGLNormalBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,x.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(J),e.STATIC_DRAW);x.__webGLUVBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,x.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(F),e.STATIC_DRAW);x.__webGLFaceBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),e.STATIC_DRAW);x.__webGLLineBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),e.STATIC_DRAW);x.__webGLFaceCount=E.length;x.__webGLLineCount=G.length};this.renderBuffer=function(y,C){var x,v,w,u,t,B,A,D,z;if(y instanceof THREE.MeshPhongMaterial||y instanceof THREE.MeshLambertMaterial||y instanceof THREE.MeshBasicMaterial){x=y.color;v=y.opacity;w=y.wireframe;u=y.wireframe_linewidth;t=y.blending;z=y.map;e.uniform4f(n.mColor,x.r*v,x.g*v,x.b*v,v)}if(y instanceof THREE.MeshDepthMaterial){v=y.opacity;w=y.wireframe;u=y.wireframe_linewidth;e.uniform1f(n.m2Near,y.__2near);e.uniform1f(n.mFarPlusNear,y.__farPlusNear);e.uniform1f(n.mFarMinusNear,y.__farMinusNear);e.uniform1i(n.material,i)}else{if(y instanceof THREE.MeshPhongMaterial){B=y.ambient;A=y.specular;D=y.shininess;e.uniform4f(n.mAmbient,B.r,B.g,B.b,v);e.uniform4f(n.mSpecular,A.r,A.g,A.b,v);e.uniform1f(n.mShininess,D);e.uniform1i(n.material,o)}else{if(y instanceof THREE.MeshLambertMaterial){e.uniform1i(n.material,s)}else{if(y instanceof THREE.MeshBasicMaterial){e.uniform1i(n.material,l)}}}}if(z){if(!y.__webGLTexture&&y.map.loaded){y.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,y.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,y.map.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,y.__webGLTexture);e.uniform1i(n.tMap,0);e.uniform1i(n.enableMap,1)}else{e.uniform1i(n.enableMap,0)}e.bindBuffer(e.ARRAY_BUFFER,C.__webGLVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,false,0,0);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,false,0,0);if(z){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUVBuffer);e.enableVertexAttribArray(n.uv);e.vertexAttribPointer(n.uv,2,e.FLOAT,false,0,0)}else{e.disableVertexAttribArray(n.uv)}if(!w){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,C.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else{e.lineWidth(u);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);e.drawElements(e.LINES,C.__webGLLineCount,e.UNSIGNED_SHORT,0)}};this.renderMesh=function(v,y){var x,u,t,w,B,z,A,C;for(B in v.materialFaceGroup){C=v.materialFaceGroup[B];if(!C.__webGLVertexBuffer){this.createBuffers(v,B)}for(t=0,w=v.material.length;t<w;t++){A=v.material[t];if(A instanceof THREE.MeshFaceMaterial){for(x=0,u=C.material.length;x<u;x++){z=C.material[x];this.renderBuffer(z,C)}}else{z=A;this.renderBuffer(z,C)}}}};this.setupMatrices=function(t,u){t.autoUpdateMatrix&&t.updateMatrix();j.multiply(u.matrix,t.matrix);n.viewMatrixArray=new Float32Array(u.matrix.flatten());n.modelViewMatrixArray=new Float32Array(j.flatten());n.projectionMatrixArray=new Float32Array(u.projectionMatrix.flatten());c=THREE.Matrix4.makeInvert3x3(j).transpose();n.normalMatrixArray=new Float32Array(c.m);e.uniformMatrix4fv(n.viewMatrix,false,n.viewMatrixArray);e.uniformMatrix4fv(n.modelViewMatrix,false,n.modelViewMatrixArray);e.uniformMatrix4fv(n.projectionMatrix,false,n.projectionMatrixArray);e.uniformMatrix3fv(n.normalMatrix,false,n.normalMatrixArray);e.uniformMatrix4fv(n.objMatrix,false,new Float32Array(t.matrix.flatten()))};this.render=function(w,v){var x,u,t;if(this.autoClear){this.clear()}v.autoUpdateMatrix&&v.updateMatrix();e.uniform3f(n.cameraPosition,v.position.x,v.position.y,v.position.z);this.setupLights(w);for(x=0,u=w.objects.length;x<u;x++){t=w.objects[x];this.setupMatrices(t,v);if(t instanceof THREE.Mesh){this.renderMesh(t,v)}else{if(t instanceof THREE.Line){}else{if(t instanceof THREE.Particle){}}}}};this.setFaceCulling=function(u,t){if(u){if(!t||t=="ccw"){e.frontFace(e.CCW)}else{e.frontFace(e.CW)}if(u=="back"){e.cullFace(e.BACK)}else{if(u=="front"){e.cullFace(e.FRONT)}else{e.cullFace(e.FRONT_AND_BACK)}}e.enable(e.CULL_FACE)}else{e.disable(e.CULL_FACE)}};function a(){try{e=f.getContext("experimental-webgl",{antialias:true})}catch(t){}if(!e){alert("WebGL not supported");throw"cannot create webgl context"}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(0,0,0,0)}function p(t,u){var v=["#ifdef GL_ES","precision highp float;","#endif",t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","uniform int material;","uniform bool enableMap;","uniform sampler2D tMap;","uniform vec4 mColor;","uniform vec4 mAmbient;","uniform vec4 mSpecular;","uniform float mShininess;","uniform float m2Near;","uniform float mFarPlusNear;","uniform float mFarMinusNear;","uniform int pointLightNumber;","uniform int directionalLightNumber;",t?"uniform mat4 viewMatrix;":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main() {","vec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );","if ( enableMap ) {","mapColor = texture2D( tMap, vUv );","}","if ( material == 3 ) { ","float w = 0.5;","gl_FragColor = vec4( w, w, w, 1.0 );","} else if ( material == 2 ) { ","vec3 normal = normalize( vNormal );","vec3 viewPosition = normalize( vViewPosition );",u?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",u?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",u?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",u?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",u?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",u?"float pointSpecularWeight = 0.0;":"",u?"if ( pointDotNormalHalf >= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mColor * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mColor * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( mapColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * mapColor.rgb * vLightWeighting, mColor.a * mapColor.a );","} else {","gl_FragColor = mColor * mapColor;","}","}"];return v.join("\n")}function h(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","varying vec3 vFragPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function g(t,u){n=e.createProgram();e.attachShader(n,r("fragment",p(t,u)));e.attachShader(n,r("vertex",h(t,u)));e.linkProgram(n);if(!e.getProgramParameter(n,e.LINK_STATUS)){alert("Could not initialise shaders")}e.useProgram(n);n.viewMatrix=e.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=e.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=e.getUniformLocation(n,"projectionMatrix");n.normalMatrix=e.getUniformLocation(n,"normalMatrix");n.objMatrix=e.getUniformLocation(n,"objMatrix");n.cameraPosition=e.getUniformLocation(n,"cameraPosition");n.enableLighting=e.getUniformLocation(n,"enableLighting");n.ambientLightColor=e.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=e.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=e.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=e.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=e.getUniformLocation(n,"pointLightNumber");n.pointLightColor=e.getUniformLocation(n,"pointLightColor");n.pointLightPosition=e.getUniformLocation(n,"pointLightPosition")}n.material=e.getUniformLocation(n,"material");n.mColor=e.getUniformLocation(n,"mColor");n.mAmbient=e.getUniformLocation(n,"mAmbient");n.mSpecular=e.getUniformLocation(n,"mSpecular");n.mShininess=e.getUniformLocation(n,"mShininess");n.enableMap=e.getUniformLocation(n,"enableMap");e.uniform1i(n.enableMap,0);n.tMap=e.getUniformLocation(n,"tMap");e.uniform1i(n.tMap,0);n.m2Near=e.getUniformLocation(n,"m2Near");n.mFarPlusNear=e.getUniformLocation(n,"mFarPlusNear");n.mFarMinusNear=e.getUniformLocation(n,"mFarMinusNear");n.position=e.getAttribLocation(n,"position");e.enableVertexAttribArray(n.position);n.normal=e.getAttribLocation(n,"normal");e.enableVertexAttribArray(n.normal);n.uv=e.getAttribLocation(n,"uv");e.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=e.createShader(e.FRAGMENT_SHADER)}else{if(u=="vertex"){v=e.createShader(e.VERTEX_SHADER)}}e.shaderSource(v,t);e.compileShader(v);if(!e.getShaderParameter(v,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(v));return null}return v}function d(){var t={MAX_VARYING_VECTORS:e.getParameter(e.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:e.getParameter(e.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.v3=new THREE.Vector2();this.v4=new THREE.Vector2();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vector2();this.v2=new THREE.Vector2();this.z=null;this.color=null;this.material=null};
\ No newline at end of file
// ThreeDebug.js r28 - http://github.com/mrdoob/three.js
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};THREE.Color.prototype={setRGBA:function(f,e,c,d){this.r=f;this.g=e;this.b=c;this.a=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=(~~a).toString(16).length<8?255<<24^a: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=~~(this.a*255)<<24^~~(this.r*255)<<16^~~(this.g*255)<<8^~~(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("+~~(this.r*255)+","+~~(this.g*255)+","+~~(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.Ray=function(a,b){this.origin=a||new THREE.Vector3();this.direction=b||new THREE.Vector3()};THREE.Ray.prototype={intersectScene:function(f){var c,a,b,e=f.objects,d=[];for(c=0,a=e.length;c<a;c++){b=e[c];if(b instanceof THREE.Mesh){d=d.concat(this.intersectObject(b))}}d.sort(function(h,g){return h.distance-g.distance});return d},intersectObject:function(w){var n,j,i,t,s,q,p,v,k,x,u,r,g=w.geometry,h=g.vertices,o,e=[],m;for(n=0,j=g.faces.length;n<j;n++){i=g.faces[n];u=this.origin.clone();r=this.direction.clone();t=w.matrix.transform(h[i.a].position.clone());s=w.matrix.transform(h[i.b].position.clone());q=w.matrix.transform(h[i.c].position.clone());p=i instanceof THREE.Face4?w.matrix.transform(h[i.d].position.clone()):null;v=w.matrixRotation.transform(i.normal.clone());k=r.dot(v);if(k<0){x=v.dot(new THREE.Vector3().sub(t,u))/k;m=u.addSelf(r.multiplyScalar(x));if(i instanceof THREE.Face3){if(l(m,t,s,q)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}else{if(i instanceof THREE.Face4){if(l(m,t,s,p)||l(m,s,q,p)){o={distance:this.origin.distanceTo(m),point:m,face:i,object:w};e.push(o)}}}}}return e;function l(d,G,D,B){var J=B.clone().subSelf(G),H=D.clone().subSelf(G),E=d.clone().subSelf(G),F=J.dot(J),C=J.dot(H),A=J.dot(E),z=H.dot(H),f=H.dot(E),y=1/(F*z-C*C),K=(z*A-C*f)*y,I=(F*f-C*A)*y;return(K>0)&&(I>0)&&(K+I<1)}}};THREE.Rectangle=function(){var e,g,h,d,a,c,f=true;function b(){a=h-e;c=d-g}this.getX=function(){return e};this.getY=function(){return g};this.getWidth=function(){return a};this.getHeight=function(){return c};this.getLeft=function(){return e};this.getTop=function(){return g};this.getRight=function(){return h};this.getBottom=function(){return d};this.set=function(l,k,j,i){f=false;e=l;g=k;h=j;d=i;b()};this.addPoint=function(i,j){if(f){f=false;e=i;g=j;h=i;d=j}else{e=Math.min(e,i);g=Math.min(g,j);h=Math.max(h,i);d=Math.max(d,j)}b()};this.addRectangle=function(i){if(f){f=false;e=i.getLeft();g=i.getTop();h=i.getRight();d=i.getBottom()}else{e=Math.min(e,i.getLeft());g=Math.min(g,i.getTop());h=Math.max(h,i.getRight());d=Math.max(d,i.getBottom())}b()};this.inflate=function(i){e-=i;g-=i;h+=i;d+=i;b()};this.minSelf=function(i){e=Math.max(e,i.getLeft());g=Math.max(g,i.getTop());h=Math.min(h,i.getRight());d=Math.min(d,i.getBottom());b()};this.instersects=function(i){return Math.min(h,i.getRight())-Math.max(e,i.getLeft())>=0&&Math.min(d,i.getBottom())-Math.max(g,i.getTop())>=0};this.empty=function(){f=true;e=0;g=0;h=0;d=0;b()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+e+", right: "+h+", top: "+g+", bottom: "+d+", width: "+a+", height: "+c+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};THREE.Matrix4=function(){this._x=new THREE.Vector3();this._y=new THREE.Vector3();this._z=new THREE.Vector3()};THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n12=0;this.n13=0;this.n14=0;this.n21=0;this.n22=1;this.n23=0;this.n24=0;this.n31=0;this.n32=0;this.n33=1;this.n34=0;this.n41=0;this.n42=0;this.n43=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(d,c,b){var a=this._x,f=this._y,e=this._z;e.sub(d,c);e.normalize();a.cross(b,e);a.normalize();f.cross(e,a);f.normalize();this.n11=a.x;this.n12=a.y;this.n13=a.z;this.n14=-a.dot(d);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(d);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(d);this.n41=0;this.n42=0;this.n43=0;this.n44=1},transform:function(a){var d=a.x,c=a.y,b=a.z,e=a.w?a.w:1;a.x=this.n11*d+this.n12*c+this.n13*b+this.n14*e;a.y=this.n21*d+this.n22*c+this.n23*b+this.n24*e;a.z=this.n31*d+this.n32*c+this.n33*b+this.n34*e;e=this.n41*d+this.n42*c+this.n43*b+this.n44*e;if(a.w){a.w=e}else{a.x=a.x/e;a.y=a.y/e;a.z=a.z/e}return a},crossVector:function(b){var c=new THREE.Vector4();c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=(b.w)?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(d,c){this.n11=d.n11*c.n11+d.n12*c.n21+d.n13*c.n31+d.n14*c.n41;this.n12=d.n11*c.n12+d.n12*c.n22+d.n13*c.n32+d.n14*c.n42;this.n13=d.n11*c.n13+d.n12*c.n23+d.n13*c.n33+d.n14*c.n43;this.n14=d.n11*c.n14+d.n12*c.n24+d.n13*c.n34+d.n14*c.n44;this.n21=d.n21*c.n11+d.n22*c.n21+d.n23*c.n31+d.n24*c.n41;this.n22=d.n21*c.n12+d.n22*c.n22+d.n23*c.n32+d.n24*c.n42;this.n23=d.n21*c.n13+d.n22*c.n23+d.n23*c.n33+d.n24*c.n43;this.n24=d.n21*c.n14+d.n22*c.n24+d.n23*c.n34+d.n24*c.n44;this.n31=d.n31*c.n11+d.n32*c.n21+d.n33*c.n31+d.n34*c.n41;this.n32=d.n31*c.n12+d.n32*c.n22+d.n33*c.n32+d.n34*c.n42;this.n33=d.n31*c.n13+d.n32*c.n23+d.n33*c.n33+d.n34*c.n43;this.n34=d.n31*c.n14+d.n32*c.n24+d.n33*c.n34+d.n34*c.n44;this.n41=d.n41*c.n11+d.n42*c.n21+d.n43*c.n31+d.n44*c.n41;this.n42=d.n41*c.n12+d.n42*c.n22+d.n43*c.n32+d.n44*c.n42;this.n43=d.n41*c.n13+d.n42*c.n23+d.n43*c.n33+d.n44*c.n43;this.n44=d.n41*c.n14+d.n42*c.n24+d.n43*c.n34+d.n44*c.n44},multiplySelf:function(c){var o=this.n11,n=this.n12,k=this.n13,i=this.n14,f=this.n21,e=this.n22,d=this.n23,b=this.n24,a=this.n31,r=this.n32,q=this.n33,p=this.n34,l=this.n41,j=this.n42,h=this.n43,g=this.n44;this.n11=o*c.n11+n*c.n21+k*c.n31+i*c.n41;this.n12=o*c.n12+n*c.n22+k*c.n32+i*c.n42;this.n13=o*c.n13+n*c.n23+k*c.n33+i*c.n43;this.n14=o*c.n14+n*c.n24+k*c.n34+i*c.n44;this.n21=f*c.n11+e*c.n21+d*c.n31+b*c.n41;this.n22=f*c.n12+e*c.n22+d*c.n32+b*c.n42;this.n23=f*c.n13+e*c.n23+d*c.n33+b*c.n43;this.n24=f*c.n14+e*c.n24+d*c.n34+b*c.n44;this.n31=a*c.n11+r*c.n21+q*c.n31+p*c.n41;this.n32=a*c.n12+r*c.n22+q*c.n32+p*c.n42;this.n33=a*c.n13+r*c.n23+q*c.n33+p*c.n43;this.n34=a*c.n14+r*c.n24+q*c.n34+p*c.n44;this.n41=l*c.n11+j*c.n21+h*c.n31+g*c.n41;this.n42=l*c.n12+j*c.n22+h*c.n32+g*c.n42;this.n43=l*c.n13+j*c.n23+h*c.n33+g*c.n43;this.n44=l*c.n14+j*c.n24+h*c.n34+g*c.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return(this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44)},transpose:function(){function a(d,e,c){var b=d[e];d[e]=d[c];d[c]=b}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4();a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n14=b;a.n24=d;a.n34=c;return a};THREE.Matrix4.scaleMatrix=function(b,d,c){var a=new THREE.Matrix4();a.n11=b;a.n22=d;a.n33=c;return a};THREE.Matrix4.rotationXMatrix=function(b){var a=new THREE.Matrix4();a.n22=a.n33=Math.cos(b);a.n32=Math.sin(b);a.n23=-a.n32;return a};THREE.Matrix4.rotationYMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n33=Math.cos(b);a.n13=Math.sin(b);a.n31=-a.n13;return a};THREE.Matrix4.rotationZMatrix=function(b){var a=new THREE.Matrix4();a.n11=a.n22=Math.cos(b);a.n21=Math.sin(b);a.n12=-a.n21;return a};THREE.Matrix4.rotationAxisAngleMatrix=function(b,d){var a=new THREE.Matrix4(),f=Math.cos(d),j=Math.sin(d),i=1-f,h=b.x,g=b.y,e=b.z;a.n11=i*h*h+f;a.n12=i*h*g-j*e;a.n13=i*h*e+j*g;a.n21=i*h*g+j*e;a.n22=i*g*g+f;a.n23=i*g*e-j*h;a.n31=i*h*e-j*g;a.n32=i*g*e+j*h;a.n33=i*e*e+f;return a};THREE.Matrix4.makeInvert=function(b){var a=new THREE.Matrix4();a.n11=b.n23*b.n34*b.n42-b.n24*b.n33*b.n42+b.n24*b.n32*b.n43-b.n22*b.n34*b.n43-b.n23*b.n32*b.n44+b.n22*b.n33*b.n44;a.n12=b.n14*b.n33*b.n42-b.n13*b.n34*b.n42-b.n14*b.n32*b.n43+b.n12*b.n34*b.n43+b.n13*b.n32*b.n44-b.n12*b.n33*b.n44;a.n13=b.n13*b.n24*b.n42-b.n14*b.n23*b.n42+b.n14*b.n22*b.n43-b.n12*b.n24*b.n43-b.n13*b.n22*b.n44+b.n12*b.n23*b.n44;a.n14=b.n14*b.n23*b.n32-b.n13*b.n24*b.n32-b.n14*b.n22*b.n33+b.n12*b.n24*b.n33+b.n13*b.n22*b.n34-b.n12*b.n23*b.n34;a.n21=b.n24*b.n33*b.n41-b.n23*b.n34*b.n41-b.n24*b.n31*b.n43+b.n21*b.n34*b.n43+b.n23*b.n31*b.n44-b.n21*b.n33*b.n44;a.n22=b.n13*b.n34*b.n41-b.n14*b.n33*b.n41+b.n14*b.n31*b.n43-b.n11*b.n34*b.n43-b.n13*b.n31*b.n44+b.n11*b.n33*b.n44;a.n23=b.n14*b.n23*b.n41-b.n13*b.n24*b.n41-b.n14*b.n21*b.n43+b.n11*b.n24*b.n43+b.n13*b.n21*b.n44-b.n11*b.n23*b.n44;a.n24=b.n13*b.n24*b.n31-b.n14*b.n23*b.n31+b.n14*b.n21*b.n33-b.n11*b.n24*b.n33-b.n13*b.n21*b.n34+b.n11*b.n23*b.n34;a.n31=b.n22*b.n34*b.n41-b.n24*b.n32*b.n41+b.n24*b.n31*b.n42-b.n21*b.n34*b.n42-b.n22*b.n31*b.n44+b.n21*b.n32*b.n44;a.n32=b.n14*b.n32*b.n41-b.n12*b.n34*b.n41-b.n14*b.n31*b.n42+b.n11*b.n34*b.n42+b.n12*b.n31*b.n44-b.n11*b.n32*b.n44;a.n33=b.n13*b.n24*b.n41-b.n14*b.n22*b.n41+b.n14*b.n21*b.n42-b.n11*b.n24*b.n42-b.n12*b.n21*b.n44+b.n11*b.n22*b.n44;a.n34=b.n14*b.n22*b.n31-b.n12*b.n24*b.n31-b.n14*b.n21*b.n32+b.n11*b.n24*b.n32+b.n12*b.n21*b.n34-b.n11*b.n22*b.n34;a.n41=b.n23*b.n32*b.n41-b.n22*b.n33*b.n41-b.n23*b.n31*b.n42+b.n21*b.n33*b.n42+b.n22*b.n31*b.n43-b.n21*b.n32*b.n43;a.n42=b.n12*b.n33*b.n41-b.n13*b.n32*b.n41+b.n13*b.n31*b.n42-b.n11*b.n33*b.n42-b.n12*b.n31*b.n43+b.n11*b.n32*b.n43;a.n43=b.n13*b.n22*b.n41-b.n12*b.n23*b.n41-b.n13*b.n21*b.n42+b.n11*b.n23*b.n42+b.n12*b.n21*b.n43-b.n11*b.n22*b.n43;a.n44=b.n12*b.n23*b.n31-b.n13*b.n22*b.n31+b.n13*b.n21*b.n32-b.n11*b.n23*b.n32-b.n12*b.n21*b.n33+b.n11*b.n22*b.n33;a.multiplyScalar(1/b.determinant());return a};THREE.Matrix4.makeInvert3x3=function(o){var e=o.flatten(),l=new THREE.Matrix3(),n=e[10]*e[5]-e[6]*e[9],i=-e[10]*e[1]+e[2]*e[9],d=e[6]*e[1]-e[2]*e[5],k=-e[10]*e[4]+e[6]*e[8],g=e[10]*e[0]-e[2]*e[8],c=-e[6]*e[0]+e[2]*e[4],j=e[9]*e[4]-e[5]*e[8],f=-e[9]*e[0]+e[1]*e[8],a=e[5]*e[0]-e[1]*e[4],h=e[0]*(n)+e[1]*(k)+e[2]*(j),b;if(h==0){throw"matrix not invertible"}b=1/h;l.m[0]=b*n;l.m[1]=b*i;l.m[2]=b*d;l.m[3]=b*k;l.m[4]=b*g;l.m[5]=b*c;l.m[6]=b*j;l.m[7]=b*f;l.m[8]=b*a;return l};THREE.Matrix4.makeFrustum=function(f,r,e,o,i,h){var g,q,n,p,l,k,j;g=new THREE.Matrix4();q=2*i/(r-f);n=2*i/(o-e);p=(r+f)/(r-f);l=(o+e)/(o-e);k=-(h+i)/(h-i);j=-2*h*i/(h-i);g.n11=q;g.n12=0;g.n13=p;g.n14=0;g.n21=0;g.n22=n;g.n23=l;g.n24=0;g.n31=0;g.n32=0;g.n33=k;g.n34=j;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(e,c,g,b){var a,f,h,d;a=g*Math.tan(e*Math.PI/360);f=-a;h=f*c;d=a*c;return THREE.Matrix4.makeFrustum(h,d,f,a,g,b)};THREE.Matrix4.makeOrtho=function(c,o,k,a,g,f){var d,l,j,i,n,e,b;d=new THREE.Matrix4();n=o-c;e=k-a;b=f-g;l=(o+c)/n;j=(k+a)/e;i=(f+g)/b;d.n11=2/n;d.n12=0;d.n13=0;d.n14=-l;d.n21=0;d.n22=2/e;d.n23=0;d.n24=-j;d.n31=0;d.n32=0;d.n33=-2/b;d.n34=-i;d.n41=0;d.n42=0;d.n43=0;d.n44=1;return d};THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3();this.positionWorld=new THREE.Vector3();this.positionScreen=new THREE.Vector3();this.normal=b||new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.normalScreen=new THREE.Vector3();this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};THREE.Face3=function(e,d,h,g,f){this.a=e;this.b=d;this.c=h;this.centroid=new THREE.Vector3();this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3();this.vertexNormals=g instanceof Array?g:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};THREE.Face4=function(f,e,j,i,h,g){this.a=f;this.b=e;this.c=j;this.d=i;this.centroid=new THREE.Vector3();this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3();this.vertexNormals=h instanceof Array?h:[];this.material=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(b,a){this.u=b||0;this.v=a||0};THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[]};THREE.Geometry.prototype={computeCentroids:function(){var c,b,a;for(c=0,b=this.faces.length;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(m){var e,b,o,g,i,j,l,k,d,c,a,h=new THREE.Vector3(),p=new THREE.Vector3();for(o=0,g=this.vertices.length;o<g;o++){i=this.vertices[o];i.normal.set(0,0,0)}for(j=0,l=this.faces.length;j<l;j++){k=this.faces[j];if(m&&k.vertexNormals.length){h.set(0,0,0);for(e=0,b=k.normal.length;e<b;e++){h.addSelf(k.vertexNormals[e])}h.divideScalar(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);p.sub(d.position,c.position);h.crossSelf(p);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]};for(var 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.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4();this.projectionMatrix=THREE.Matrix4.makePerspective(c,b,d,a);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Loader=function(){};THREE.Loader.prototype={loadAsciiOld:function(a,c){var b=document.createElement("script");b.type="text/javascript";b.onload=c;b.src=a;document.getElementsByTagName("head")[0].appendChild(b)},loadAscii:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,e,b)};d.postMessage(c)},loadBinary:function(a,e,b){var c=(new Date).getTime(),d=new Worker(a);d.onmessage=function(h){var g=h.data.materials,f=h.data.buffers;THREE.Loader.prototype.loadAjaxBuffers(f,g,e,b)};d.onerror=function(f){alert("worker.onerror: "+f.message+"\n"+f.data);f.preventDefault()};d.postMessage(c)},loadAjaxBuffers:function(b,a,f,d){var e=new XMLHttpRequest(),c=d+"/"+b;e.onreadystatechange=function(){if(e.readyState==4){if(e.status==200||e.status==0){THREE.Loader.prototype.createBinModel(e.responseText,f,d,a)}else{alert("Couldn't load ["+c+"] ["+e.status+"]")}}};e.open("GET",c,true);e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(c,e,b,a){var d=function(aa){var I=this,h=0,x,A=[],L=[],V,T,O,U,R,P,D,C,B,y,r,q,p,o,u,t,N,K,J;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,a,aa);x=W(c,h);h+=x.header_bytes;V=x.vertex_index_bytes,T=x.vertex_index_bytes*2,O=x.vertex_index_bytes*3,U=x.vertex_index_bytes*3+x.material_index_bytes,R=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes,P=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2,D=x.vertex_index_bytes,C=x.vertex_index_bytes*2,B=x.vertex_index_bytes*3,y=x.vertex_index_bytes*4,r=x.vertex_index_bytes*4+x.material_index_bytes,q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes,p=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2,o=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3,u=x.uv_index_bytes,t=x.uv_index_bytes*2,N=x.uv_index_bytes,K=x.uv_index_bytes*2,J=x.uv_index_bytes*3;h+=w(h);h+=H(h);h+=G(h);h+=Q(h);h+=S(h);h+=ab(h);h+=n(h);h+=g(h);h+=k(h);h+=s(h);h+=z(h);this.computeCentroids();this.computeNormals();function W(ad,ae){var ac={signature:F(ad,ae,8),header_bytes:j(ad,ae+8),vertex_coordinate_bytes:j(ad,ae+9),normal_coordinate_bytes:j(ad,ae+10),uv_coordinate_bytes:j(ad,ae+11),vertex_index_bytes:j(ad,ae+12),normal_index_bytes:j(ad,ae+13),uv_index_bytes:j(ad,ae+14),material_index_bytes:j(ad,ae+15),nvertices:v(ad,ae+16),nnormals:v(ad,ae+16+4*1),nuvs:v(ad,ae+16+4*2),ntri_flat:v(ad,ae+16+4*3),ntri_smooth:v(ad,ae+16+4*4),ntri_flat_uv:v(ad,ae+16+4*5),ntri_smooth_uv:v(ad,ae+16+4*6),nquad_flat:v(ad,ae+16+4*7),nquad_smooth:v(ad,ae+16+4*8),nquad_flat_uv:v(ad,ae+16+4*9),nquad_smooth_uv:v(ad,ae+16+4*10)};return ac}function F(ad,ae,ac){return ad.substr(ae,ac)}function f(af,ae){var ag=j(af,ae),ai=j(af,ae+1),aj=j(af,ae+2),ak=j(af,ae+3),ad=1-(2*(ak>>7)),ah=(((ak<<1)&255)|(aj>>7))-127,ac=((aj&127)<<16)|(ai<<8)|ag;if(ac==0&&ah==-127){return 0}return ad*(1+ac*Math.pow(2,-23))*Math.pow(2,ah)}function v(ag,ah){var af=j(ag,ah),ae=j(ag,ah+1),ad=j(ag,ah+2),ac=j(ag,ah+3);return(ac<<24)+(ad<<16)+(ae<<8)+af}function Z(ae,af){var ad=j(ae,af),ac=j(ae,af+1);return(ac<<8)+ad}function i(ad,ae){var ac=j(ad,ae);return ac>127?ac-256:ac}function j(ac,ad){return ac.charCodeAt(ad)&255}function w(ai){var ae,ac,ah,ag,af=x.vertex_coordinate_bytes*3,ad=ai+x.nvertices*af;for(ae=ai;ae<ad;ae+=af){ac=f(c,ae);ah=f(c,ae+x.vertex_coordinate_bytes);ag=f(c,ae+x.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,ac,ah,ag)}return x.nvertices*af}function H(ai){var ae,ac,ah,ag,af=x.normal_coordinate_bytes*3,ad=ai+x.nnormals*af;for(ae=ai;ae<ad;ae+=af){ac=i(c,ae);ah=i(c,ae+x.normal_coordinate_bytes);ag=i(c,ae+x.normal_coordinate_bytes*2);A.push(ac/127,ah/127,ag/127)}return x.nnormals*af}function G(ah){var af,ae,ad,ag=x.uv_coordinate_bytes*2,ac=ah+x.nuvs*ag;for(af=ah;af<ac;af+=ag){ae=f(c,af);ad=f(c,af+x.uv_coordinate_bytes);L.push(ae,ad)}return x.nuvs*ag}function M(af){var ae,ad,ag,ac;ae=v(c,af);ad=v(c,af+V);ag=v(c,af+T);ac=Z(c,af+O);THREE.Loader.prototype.f3(I,ae,ad,ag,ac)}function m(ah){var ag,ae,aj,ad,af,ac,ai;ag=v(c,ah);ae=v(c,ah+V);aj=v(c,ah+T);ad=Z(c,ah+O);af=v(c,ah+U);ac=v(c,ah+R);ai=v(c,ah+P);THREE.Loader.prototype.f3n(I,A,ag,ae,aj,ad,af,ac,ai)}function E(af){var ae,ad,ah,ag,ac;ae=v(c,af);ad=v(c,af+D);ah=v(c,af+C);ag=v(c,af+B);ac=Z(c,af+y);THREE.Loader.prototype.f4(I,ae,ad,ah,ag,ac)}function l(af){var al,ak,aj,ai,ac,ah,ag,ae,ad;al=v(c,af);ak=v(c,af+D);aj=v(c,af+C);ai=v(c,af+B);ac=Z(c,af+y);ah=v(c,af+r);ag=v(c,af+q);ae=v(c,af+p);ad=v(c,af+o);THREE.Loader.prototype.f4n(I,A,al,ak,aj,ai,ac,ah,ag,ae,ad)}function Y(ai){var ah,ae,ac,ag,af,ad,al,ak,aj;ah=v(c,ai);ae=v(c,ai+u);ac=v(c,ai+t);ag=L[ah*2];al=L[ah*2+1];af=L[ae*2];ak=L[ae*2+1];ad=L[ac*2];aj=L[ac*2+1];THREE.Loader.prototype.uv(I,ag,al,af,ak,ad,aj)}function X(ak){var aj,ag,ae,ad,ai,ah,af,ac,ao,an,am,al;aj=v(c,ak);ag=v(c,ak+N);ae=v(c,ak+K);ad=v(c,ak+J);ai=L[aj*2];ao=L[aj*2+1];ah=L[ag*2];an=L[ag*2+1];af=L[ae*2];am=L[ae*2+1];ac=L[ad*2];al=L[ad*2+1];THREE.Loader.prototype.uv(I,ai,ao,ah,an,af,am,ac,al)}function Q(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes,ac=af+x.ntri_flat*ae;for(ad=af;ad<ac;ad+=ae){M(ad)}return ac-af}function ab(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){M(ad);Y(ad+af)}return ac-ag}function S(af){var ad,ae=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ac=af+x.ntri_smooth*ae;for(ad=af;ad<ac;ad+=ae){m(ad)}return ac-af}function n(ag){var ad,af=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,ae=af+x.uv_index_bytes*3,ac=ag+x.ntri_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){m(ad);Y(ad+af)}return ac-ag}function g(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes,ac=af+x.nquad_flat*ae;for(ad=af;ad<ac;ad+=ae){E(ad)}return ac-af}function s(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_flat_uv*ae;for(ad=ag;ad<ac;ad+=ae){E(ad);X(ad+af)}return ac-ag}function k(af){var ad,ae=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ac=af+x.nquad_smooth*ae;for(ad=af;ad<ac;ad+=ae){l(ad)}return ac-af}function z(ag){var ad,af=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,ae=af+x.uv_index_bytes*4,ac=ag+x.nquad_smooth_uv*ae;for(ad=ag;ad<ac;ad+=ae){l(ad);X(ad+af)}return ac-ag}};d.prototype=new THREE.Geometry();d.prototype.constructor=d;e(new d(b))},createModel:function(b,d,a){var c=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,b.materials,f);e();h();this.computeCentroids();this.computeNormals();function e(){var m,k,j,o,n;for(m=0,k=b.vertices.length;m<k;m+=3){j=b.vertices[m];o=b.vertices[m+1];n=b.vertices[m+2];THREE.Loader.prototype.v(g,j,o,n)}}function h(){function p(v,u){var t,s,w,l;t=v[u];s=v[u+1];w=v[u+2];l=v[u+3];THREE.Loader.prototype.f3(g,t,s,w,l)}function k(l,u){var z,y,x,s,w,v,t;z=l[u];y=l[u+1];x=l[u+2];s=l[u+3];w=l[u+4];v=l[u+5];t=l[u+6];THREE.Loader.prototype.f3n(g,b.normals,z,y,x,s,w,v,t)}function o(w,u){var t,s,x,v,l;t=w[u];s=w[u+1];x=w[u+2];v=w[u+3];l=w[u+4];THREE.Loader.prototype.f4(g,t,s,x,v,l)}function j(l,v){var B,A,z,y,s,x,w,u,t;B=l[v];A=l[v+1];z=l[v+2];y=l[v+3];s=l[v+4];x=l[v+5];w=l[v+6];u=l[v+7];t=l[v+8];THREE.Loader.prototype.f4n(g,b.normals,B,A,z,y,s,x,w,u,t)}function r(l,y){var x,u,s,w,v,t,B,A,z;x=l[y];u=l[y+1];s=l[y+2];w=b.uvs[x*2];B=b.uvs[x*2+1];v=b.uvs[u*2];A=b.uvs[u*2+1];t=b.uvs[s*2];z=b.uvs[s*2+1];THREE.Loader.prototype.uv(g,w,B,v,A,t,z)}function q(s,A){var z,w,v,t,y,x,u,l,E,D,C,B;z=s[A];w=s[A+1];v=s[A+2];t=s[A+3];y=b.uvs[z*2];E=b.uvs[z*2+1];x=b.uvs[w*2];D=b.uvs[w*2+1];u=b.uvs[v*2];C=b.uvs[v*2+1];l=b.uvs[t*2];B=b.uvs[t*2+1];THREE.Loader.prototype.uv(g,y,E,x,D,u,C,l,B)}var n,m;for(n=0,m=b.triangles.length;n<m;n+=4){p(b.triangles,n)}for(n=0,m=b.triangles_uv.length;n<m;n+=7){p(b.triangles_uv,n);r(b.triangles_uv,n+4)}for(n=0,m=b.triangles_n.length;n<m;n+=7){k(b.triangles_n,n)}for(n=0,m=b.triangles_n_uv.length;n<m;n+=10){k(b.triangles_n_uv,n);r(b.triangles_n_uv,n+7)}for(n=0,m=b.quads.length;n<m;n+=5){o(b.quads,n)}for(n=0,m=b.quads_uv.length;n<m;n+=9){o(b.quads_uv,n);q(b.quads_uv,n+5)}for(n=0,m=b.quads_n.length;n<m;n+=9){j(b.quads_n,n)}for(n=0,m=b.quads_n_uv.length;n<m;n+=13){j(b.quads_n_uv,n);q(b.quads_n_uv,n+9)}}};c.prototype=new THREE.Geometry();c.prototype.constructor=c;d(new c(a))},v:function(b,a,d,c){b.vertices.push(new THREE.Vertex(new THREE.Vector3(a,d,c)))},f3:function(h,e,d,i,f){var g=h.materials[f];h.faces.push(new THREE.Face3(e,d,i,null,g))},f4:function(i,f,e,k,j,g){var h=i.materials[g];i.faces.push(new THREE.Face4(f,e,k,j,null,h))},f3n:function(d,l,s,r,q,p,j,i,h){var k=d.materials[p],g=l[j*3],f=l[j*3+1],e=l[j*3+2],o=l[i*3],n=l[i*3+1],m=l[i*3+2],v=l[h*3],u=l[h*3+1],t=l[h*3+2];d.faces.push(new THREE.Face3(s,r,q,[new THREE.Vector3(g,f,e),new THREE.Vector3(o,n,m),new THREE.Vector3(v,u,t)],k))},f4n:function(e,q,y,x,w,u,v,o,n,m,k){var p=e.materials[v],j=q[o*3],h=q[o*3+1],f=q[o*3+2],t=q[n*3],s=q[n*3+1],r=q[n*3+2],B=q[m*3],A=q[m*3+1],z=q[m*3+2],l=q[k*3],i=q[k*3+1],g=q[k*3+2];e.faces.push(new THREE.Face4(y,x,w,u,[new THREE.Vector3(j,h,f),new THREE.Vector3(t,s,r),new THREE.Vector3(B,A,z),new THREE.Vector3(l,i,g)],p))},uv:function(j,e,i,c,h,b,g,a,f){var d=[];d.push(new THREE.UV(e,i));d.push(new THREE.UV(c,h));d.push(new THREE.UV(b,g));if(a&&f){d.push(new THREE.UV(a,f))}j.uvs.push(d)},init_materials:function(d,a,c){d.materials=[];for(var b=0;b<a.length;++b){d.materials[b]=[THREE.Loader.prototype.createMaterial(a[b],c)]}},createMaterial:function(a,c){function g(j){var i=Math.log(j)/Math.LN2;return Math.floor(i)==i}function f(j){var i=Math.log(j)/Math.LN2;return Math.pow(2,Math.round(i))}var d,e,h,b;if(a.map_diffuse&&c){e=document.createElement("canvas");d=new THREE.MeshLambertMaterial({map:new THREE.Texture(e)});h=new Image();h.onload=function(){if(!g(this.width)||!g(this.height)){var i=f(this.width),j=f(this.height);d.map.image.width=i;d.map.image.height=j;d.map.image.getContext("2d").drawImage(this,0,0,i,j)}else{d.map.image=this}d.map.loaded=1};h.src=c+"/"+a.map_diffuse}else{if(a.col_diffuse){b=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;d=new THREE.MeshLambertMaterial({color:b,opacity:a.transparency})}else{if(a.a_dbg_color){d=new THREE.MeshLambertMaterial({color:a.a_dbg_color})}else{d=new THREE.MeshLambertMaterial({color:15658734})}}}return d}};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.materialFaceGroup={};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 c,b,e,m,k,h,j,n,d,g={};function a(f){var i=[];for(c=0,b=f.length;c<b;c++){if(f[c]==undefined){i.push("undefined")}else{i.push(f[c].toString())}}return i.join("_")}for(e=0,m=this.geometry.faces.length;e<m;e++){k=this.geometry.faces[e];h=k.material;n=a(h);if(g[n]==undefined){g[n]={hash:n,counter:0}}d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}j=k instanceof THREE.Face3?3:4;if(this.materialFaceGroup[d].vertices+j>65535){g[n].counter+=1;d=g[n].hash+"_"+g[n].counter;if(this.materialFaceGroup[d]==undefined){this.materialFaceGroup[d]={faces:[],material:h,vertices:0}}}this.materialFaceGroup[d].faces.push(e);this.materialFaceGroup[d].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var e,a,b,d,c;for(e=0,a=this.geometry.uvs.length;e<a;e++){c=this.geometry.uvs[e];for(b=0,d=c.length;b<d;b++){if(c[b].u!=1){c[b].u=c[b].u-Math.floor(c[b].u)}if(c[b].v!=1){c[b].v=c[b].v-Math.floor(c[b].v)}}}};THREE.FlatShading=0;THREE.GouraudShading=1;THREE.PhongShading=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubstractiveBlending=2;THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.linewidth!==undefined){this.linewidth=a.linewidth}}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>)"}};THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1000;this.opacity=1;if(a){if(a.near!==undefined){this.near=a.near}if(a.far!==undefined){this.far=a.far}if(a.opacity!==undefined){this.opacity=a.opacity}}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_size: "+this.wireframe_linewidth+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.map=null;this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.specular_map=null;this.shininess=30;this.opacity=1;this.shading=THREE.GouraudShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;if(a){if(a.color!==undefined){this.color=new THREE.Color(a.color)}if(a.map!==undefined){this.map=a.map}if(a.ambient!==undefined){this.ambient=new THREE.Color(a.ambient)}if(a.specular!==undefined){this.specular=new THREE.Color(a.specular)}if(a.specular_map!==undefined){this.specular_map=a.specular_map}if(a.shininess!==undefined){this.shininess=a.shininess}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.shading!==undefined){this.shading=a.shading}if(a.blending!==undefined){this.blending=a.blending}if(a.wireframe!==undefined){this.wireframe=a.wireframe}if(a.wireframe_linewidth!==undefined){this.wireframe_linewidth=a.wireframe_linewidth}}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>specular_map: "+this.specular_map+"<br/>shininess: "+this.shininess+"<br/>alpha: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2();if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.map!==undefined){this.map=a.map}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){if(a.color!==undefined){this.color.setHex(a.color)}if(a.opacity!==undefined){this.opacity=a.opacity}if(a.blending!==undefined){this.blending=a.blending}}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(b,a){this.image=b;this.mapping=a?a:THREE.UVMapping;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};THREE.UVMapping=0;THREE.ReflectionMap=1;THREE.CubeMap=2;THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){var b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1)}};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){var b=this.lights.indexOf(a);if(b!==-1){this.lights.splice(b,1)}};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};THREE.Projector=function(){var e=null,c,p,n=[],b,f,l=[],k,m,i=[],j,h,a=[],g=new THREE.Vector4(),d=new THREE.Matrix4(),o=new THREE.Matrix4();this.projectScene=function(J,G){var F,E,D,K,I,B,r,L,q,z,H,u,C,w,A,y,x,t,s;e=[];p=0,f=0,m=0,h=0;if(G.autoUpdateMatrix){G.updateMatrix()}d.multiply(G.projectionMatrix,G.matrix);r=J.objects;for(F=0,E=r.length;F<E;F++){L=r[F];q=L.matrix;if(L.autoUpdateMatrix){L.updateMatrix()}if(L instanceof THREE.Mesh){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1}w=L.geometry.faces;for(I=0,B=w.length;I<B;I++){A=w[I];if(A instanceof THREE.Face3){y=z[A.a];x=z[A.b];t=z[A.c];if(y.__visible&&x.__visible&&t.__visible){if((L.doubleSided||(L.flipSided!=(t.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(t.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0))){c=n[p]=n[p]||new THREE.RenderableFace3();c.v1.positionScreen.copy(y.positionScreen);c.v2.positionScreen.copy(x.positionScreen);c.v3.positionScreen.copy(t.positionScreen);c.normalWorld.copy(A.normal);L.matrixRotation.transform(c.normalWorld);c.centroidWorld.copy(A.centroid);q.transform(c.centroidWorld);c.centroidScreen.copy(c.centroidWorld);d.transform(c.centroidScreen);c.z=c.centroidScreen.z;c.meshMaterial=L.material;c.faceMaterial=A.material;c.overdraw=L.overdraw;c.uvs=L.geometry.uvs[I];c.color=A.color;e.push(c);p++}}}else{if(A instanceof THREE.Face4){y=z[A.a];x=z[A.b];t=z[A.c];s=z[A.d];if(y.__visible&&x.__visible&&t.__visible&&s.__visible){if((L.doubleSided||(L.flipSided!=((s.positionScreen.x-y.positionScreen.x)*(x.positionScreen.y-y.positionScreen.y)-(s.positionScreen.y-y.positionScreen.y)*(x.positionScreen.x-y.positionScreen.x)<0||(x.positionScreen.x-t.positionScreen.x)*(s.positionScreen.y-t.positionScreen.y)-(x.positionScreen.y-t.positionScreen.y)*(s.positionScreen.x-t.positionScreen.x)<0)))){b=l[f]=l[f]||new THREE.RenderableFace4();b.v1.positionScreen.copy(y.positionScreen);b.v2.positionScreen.copy(x.positionScreen);b.v3.positionScreen.copy(t.positionScreen);b.v4.positionScreen.copy(s.positionScreen);b.normalWorld.copy(A.normal);L.matrixRotation.transform(b.normalWorld);b.centroidWorld.copy(A.centroid);q.transform(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);d.transform(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterial=L.material;b.faceMaterial=A.material;b.overdraw=L.overdraw;b.uvs=L.geometry.uvs[I];b.color=A.color;e.push(b);f++}}}}}}else{if(L instanceof THREE.Line){o.multiply(d,q);z=L.geometry.vertices;for(D=0,K=z.length;D<K;D++){H=z[D];u=H.positionScreen;u.copy(H.position);o.transform(u);H.__visible=u.z>0&&u.z<1;if(H.__visible&&D>0){C=L.geometry.vertices[D-1];if(H.__visible&&C.__visible){k=i[m]=i[m]||new THREE.RenderableLine();k.v1.positionScreen.copy(H.positionScreen);k.v2.positionScreen.copy(C.positionScreen);k.z=Math.max(H.positionScreen.z,C.positionScreen.z);k.material=L.material;e.push(k);m++}}}}else{if(L instanceof THREE.Particle){g.set(L.position.x,L.position.y,L.position.z,1);d.transform(g);g.z/=g.w;if(g.z>0&&g.z<1){j=a[h]=a[h]||new THREE.RenderableParticle();j.x=g.x/g.w;j.y=g.y/g.w;j.z=g.z;j.rotation=L.rotation.z;j.scale.x=L.scale.x*Math.abs(j.x-(g.x+G.projectionMatrix.n11)/(g.w+G.projectionMatrix.n14));j.scale.y=L.scale.y*Math.abs(j.y-(g.y+G.projectionMatrix.n22)/(g.w+G.projectionMatrix.n24));j.material=L.material;e.push(j);h++}}}}}e.sort(function(M,v){return v.z-M.z});return e};this.unprojectVector=function(q,s){var r=new THREE.Matrix4();r.multiply(THREE.Matrix4.makeInvert(s.matrix),THREE.Matrix4.makeInvert(s.projectionMatrix));r.transform(q);return q}};THREE.DOMRenderer=function(){THREE.Renderer.call(this);var e=null,g=new THREE.Projector(),b=document.createElement("div"),a,c,f,d;this.domElement=b;this.setSize=function(i,h){a=i;c=h;f=a/2;d=c/2};this.render=function(p,r){var q,h,i,n,o,s,l,k,j;e=g.projectScene(p,r);for(q=0,h=e.length;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 o=null,y=new THREE.Projector(),t=document.createElement("canvas"),a,I,w,i,s=t.getContext("2d"),E=1,j="#000000",R="#000000",g=1,Q,P,O,N,M=new THREE.Vertex(),L=new THREE.Vertex(),x=new THREE.Rectangle(),K=new THREE.Rectangle(),n=new THREE.Rectangle(),G=false,D=new THREE.Color(4294967295),z=new THREE.Color(4294967295),J=new THREE.Color(4278190080),l=Math.PI*2,F,H=new THREE.Vector3(),v=new THREE.UV(),u=new THREE.UV(),r=new THREE.UV(),q=new THREE.UV(),B=document.createElement("canvas"),A=B.getContext("2d"),e=A.createLinearGradient(0,0,255,0);B.width=255;B.height=4;e.addColorStop(0,"white");e.addColorStop(1,"black");A.fillStyle=e;A.fillRect(0,0,255,4);this.domElement=t;this.autoClear=true;this.setSize=function(T,S){a=T;I=S;w=a/2;i=I/2;t.width=a;t.height=I;s.lineJoin="round";s.lineCap="round";x.set(-w,-i,w,i)};this.clear=function(){if(!K.isEmpty()){K.inflate(1);K.minSelf(x);s.setTransform(1,0,0,-1,w,i);s.clearRect(K.getX(),K.getY(),K.getWidth(),K.getHeight());K.empty()}};this.render=function(W,aa){var Z,S,V,T,U,ab,X,Y;if(this.autoClear){this.clear()}o=y.projectScene(W,aa);s.setTransform(1,0,0,-1,w,i);s.fillStyle="rgba(0, 255, 255, 0.5)";s.fillRect(x.getX(),x.getY(),x.getWidth(),x.getHeight());G=W.lights.length>0;if(G){f(W,J)}for(Z=0,S=o.length;Z<S;Z++){V=o[Z];n.empty();if(V instanceof THREE.RenderableParticle){Q=V;Q.x*=w;Q.y*=i;for(T=0,U=V.material.length;T<U;T++){Y=V.material[T];Y&&p(Q,V,Y,W)}}else{if(V instanceof THREE.RenderableLine){Q=V.v1;P=V.v2;Q.positionScreen.x*=w;Q.positionScreen.y*=i;P.positionScreen.x*=w;P.positionScreen.y*=i;n.addPoint(Q.positionScreen.x,Q.positionScreen.y);n.addPoint(P.positionScreen.x,P.positionScreen.y);if(!x.instersects(n)){continue}T=0;U=V.material.length;while(T<U){Y=V.material[T++];Y&&C(Q,P,V,Y,W)}}else{if(V instanceof THREE.RenderableFace3){Q=V.v1;P=V.v2;O=V.v3;Q.positionScreen.x*=w;Q.positionScreen.y*=i;P.positionScreen.x*=w;P.positionScreen.y*=i;O.positionScreen.x*=w;O.positionScreen.y*=i;if(V.overdraw){b(Q.positionScreen,P.positionScreen);b(P.positionScreen,O.positionScreen);b(O.positionScreen,Q.positionScreen)}n.addPoint(Q.positionScreen.x,Q.positionScreen.y);n.addPoint(P.positionScreen.x,P.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);if(!x.instersects(n)){continue}T=0;U=V.meshMaterial.length;while(T<U){Y=V.meshMaterial[T++];if(Y instanceof THREE.MeshFaceMaterial){ab=0;X=V.faceMaterial.length;while(ab<X){Y=V.faceMaterial[ab++];Y&&m(Q,P,O,V,Y,W)}continue}Y&&m(Q,P,O,V,Y,W)}}else{if(V instanceof THREE.RenderableFace4){Q=V.v1;P=V.v2;O=V.v3;N=V.v4;Q.positionScreen.x*=w;Q.positionScreen.y*=i;P.positionScreen.x*=w;P.positionScreen.y*=i;O.positionScreen.x*=w;O.positionScreen.y*=i;N.positionScreen.x*=w;N.positionScreen.y*=i;M.positionScreen.copy(P.positionScreen);L.positionScreen.copy(N.positionScreen);if(V.overdraw){b(Q.positionScreen,P.positionScreen);b(P.positionScreen,N.positionScreen);b(N.positionScreen,Q.positionScreen)}if(V.overdraw){b(O.positionScreen,M.positionScreen);b(O.positionScreen,L.positionScreen)}n.addPoint(Q.positionScreen.x,Q.positionScreen.y);n.addPoint(P.positionScreen.x,P.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);n.addPoint(N.positionScreen.x,N.positionScreen.y);if(!x.instersects(n)){continue}T=0;U=V.meshMaterial.length;while(T<U){Y=V.meshMaterial[T++];if(Y instanceof THREE.MeshFaceMaterial){ab=0;X=V.faceMaterial.length;while(ab<X){Y=V.faceMaterial[ab++];Y&&k(Q,P,O,N,M,L,V,Y,W)}continue}Y&&k(Q,P,O,N,M,L,V,Y,W)}}}}}K.addRectangle(n)}s.lineWidth=1;s.strokeStyle="rgba( 255, 0, 0, 0.5 )";s.strokeRect(K.getX(),K.getY(),K.getWidth(),K.getHeight());s.setTransform(1,0,0,1,0,0)};function f(Y,V){var U,X,T,S,W=Y.lights;V.setRGBA(0,0,0,1);for(U=0,X=W.length;U<X;U++){T=W[U];S=T.color;if(T instanceof THREE.AmbientLight){V.r+=S.r;V.g+=S.g;V.b+=S.b}}}function h(Z,X,V){var U,Y,T,S,W=Z.lights;for(U=0,Y=W.length;U<Y;U++){T=W[U];S=T.color;if(T instanceof THREE.DirectionalLight){V.r+=S.r;V.g+=S.g;V.b+=S.b}else{if(T instanceof THREE.PointLight){V.r+=S.r;V.g+=S.g;V.b+=S.b}}}}function d(Z,X,V){var U,Y,T,S,W;lights=Z.lights;for(U=0,Y=lights.length;U<Y;U++){T=lights[U];S=T.color;if(T instanceof THREE.DirectionalLight){W=X.normalWorld.dot(T.position)*T.intensity;if(W>0){V.r+=S.r*W;V.g+=S.g*W;V.b+=S.b*W}}else{if(T instanceof THREE.PointLight){H.sub(T.position,X.centroidWorld);H.normalize();W=X.normalWorld.dot(H)*T.intensity;if(W>0){V.r+=S.r*W;V.g+=S.g*W;V.b+=S.b*W}}}}}function p(aa,V,Y,X){var S,ae,ac,ab,W,U,Z,ad,T;if(E!=Y.opacity){s.globalAlpha=E=Y.opacity}if(Y instanceof THREE.ParticleBasicMaterial){Z=Y.bitmap;ad=Z.width/2;T=Z.height/2;ac=V.scale.x*w;ab=V.scale.y*i;S=ac*ad;ae=ab*T;W=Y.offset.x*ac;U=Y.offset.y*ab;n.set(aa.x+W-S,aa.y+U-ae,aa.x+W+S,aa.y+U+ae);if(!x.instersects(n)){return}s.save();s.translate(aa.x,aa.y);s.rotate(-V.rotation);s.scale(ac,-ab);s.translate(-ad+Y.offset.x,-T-Y.offset.y);s.drawImage(Z,0,0);s.restore();s.beginPath();s.moveTo(v1x-10,v1y);s.lineTo(v1x+10,v1y);s.moveTo(v1x,v1y-10);s.lineTo(v1x,v1y+10);s.closePath();s.strokeStyle="rgb(255,255,0)";s.stroke()}else{if(Y instanceof THREE.ParticleCircleMaterial){if(G){z.copyRGB(J);h(X,V,z);D.copyRGBA(Y.color);D.multiplySelfRGB(z);D.updateStyleString()}else{D.__styleString=Y.color.__styleString}S=V.scale.x*w;ae=V.scale.y*i;n.set(aa.x-S,aa.y-ae,aa.x+S,aa.y+ae);if(!x.instersects(n)){return}s.save();s.translate(aa.x,aa.y);s.rotate(-V.rotation);s.scale(S,ae);s.beginPath();s.arc(0,0,1,0,l,true);s.closePath();s.fillStyle=D.__styleString;s.fill();s.restore()}}}function C(W,V,S,T,U){if(E!=T.opacity){s.globalAlpha=E=T.opacity}if(T instanceof THREE.LineBasicMaterial){s.beginPath();s.moveTo(W.positionScreen.x,W.positionScreen.y);s.lineTo(V.positionScreen.x,V.positionScreen.y);s.closePath();D.__styleString=T.color.__styleString;if(g!=T.linewidth){s.lineWidth=g=T.linewidth}if(j!=D.__styleString){s.strokeStyle=j=D.__styleString}s.stroke();n.inflate(T.linewidth*2)}}function m(Z,X,W,T,V,U){var Y,aa,S;if(E!=V.opacity){s.globalAlpha=E=V.opacity}if(V.map){Y=V.map.image;aa=Y.width-1;S=Y.height-1;v.u=T.uvs[0].u*aa;v.v=T.uvs[0].v*S;u.u=T.uvs[1].u*aa;u.v=T.uvs[1].v*S;r.u=T.uvs[2].u*aa;r.v=T.uvs[2].v*S;c(Y,Z.positionScreen.x,Z.positionScreen.y,X.positionScreen.x,X.positionScreen.y,W.positionScreen.x,W.positionScreen.y,v.u,v.v,u.u,u.v,r.u,r.v);return}if(V instanceof THREE.MeshDepthMaterial){Y=B;aa=Y.width-1;S=Y.height-1;F=V.__2near/(V.__farPlusNear-Z.positionScreen.z*V.__farMinusNear);v.u=F*aa;v.v=0;F=V.__2near/(V.__farPlusNear-X.positionScreen.z*V.__farMinusNear);u.u=F*aa;u.v=1;F=V.__2near/(V.__farPlusNear-W.positionScreen.z*V.__farMinusNear);r.u=F*aa;r.v=2;c(Y,Z.positionScreen.x,Z.positionScreen.y,X.positionScreen.x,X.positionScreen.y,W.positionScreen.x,W.positionScreen.y,v.u,v.v,u.u,u.v,r.u,r.v);return}s.beginPath();s.moveTo(Z.positionScreen.x,Z.positionScreen.y);s.lineTo(X.positionScreen.x,X.positionScreen.y);s.lineTo(W.positionScreen.x,W.positionScreen.y);s.lineTo(Z.positionScreen.x,Z.positionScreen.y);s.closePath();if(V instanceof THREE.MeshBasicMaterial){D.__styleString=V.color.__styleString}else{if(V instanceof THREE.MeshDepthMaterial){}else{if(V instanceof THREE.MeshLambertMaterial){if(G){z.copyRGB(J);d(U,T,z);D.copyRGBA(V.color);D.multiplySelfRGB(z);D.updateStyleString()}else{D.__styleString=V.color.__styleString}}}}if(V.wireframe){if(g!=V.wireframe_linewidth){s.lineWidth=g=V.wireframe_linewidth}if(j!=D.__styleString){s.strokeStyle=j=D.__styleString}s.stroke();n.inflate(V.wireframe_linewidth*2)}else{if(R!=D.__styleString){s.fillStyle=R=D.__styleString}s.fill()}}function k(ac,ab,Z,Y,X,V,T,W,U){var aa,ad,S;if(E!=W.opacity){s.globalAlpha=E=W.opacity}if(W.map){aa=W.map.image;ad=aa.width-1;S=aa.height-1;v.copy(T.uvs[0]);u.copy(T.uvs[1]);r.copy(T.uvs[2]);q.copy(T.uvs[3]);v.u*=ad;v.v*=S;u.u*=ad;u.v*=S;r.u*=ad;r.v*=S;q.u*=ad;q.v*=S;c(aa,ac.positionScreen.x,ac.positionScreen.y,ab.positionScreen.x,ab.positionScreen.y,Y.positionScreen.x,Y.positionScreen.y,v.u,v.v,u.u,u.v,q.u,q.v);c(aa,X.positionScreen.x,X.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,V.positionScreen.x,V.positionScreen.y,u.u,u.v,r.u,r.v,q.u,q.v);return}if(W instanceof THREE.MeshDepthMaterial){aa=B;ad=aa.width-1;S=aa.height-1;F=W.__2near/(W.__farPlusNear-ac.positionScreen.z*W.__farMinusNear);v.u=F*ad;v.v=0;F=W.__2near/(W.__farPlusNear-ab.positionScreen.z*W.__farMinusNear);u.u=F*ad;u.v=1;F=W.__2near/(W.__farPlusNear-Z.positionScreen.z*W.__farMinusNear);r.u=F*ad;r.v=2;F=W.__2near/(W.__farPlusNear-Y.positionScreen.z*W.__farMinusNear);q.u=F*ad;q.v=3;c(aa,ac.positionScreen.x,ac.positionScreen.y,ab.positionScreen.x,ab.positionScreen.y,Y.positionScreen.x,Y.positionScreen.y,v.u,v.v,u.u,u.v,q.u,q.v);c(aa,X.positionScreen.x,X.positionScreen.y,Z.positionScreen.x,Z.positionScreen.y,V.positionScreen.x,V.positionScreen.y,u.u,u.v,r.u,r.v,q.u,q.v);return}s.beginPath();s.moveTo(ac.positionScreen.x,ac.positionScreen.y);s.lineTo(ab.positionScreen.x,ab.positionScreen.y);s.lineTo(Z.positionScreen.x,Z.positionScreen.y);s.lineTo(Y.positionScreen.x,Y.positionScreen.y);s.lineTo(ac.positionScreen.x,ac.positionScreen.y);s.closePath();if(W instanceof THREE.MeshBasicMaterial){D.__styleString=W.color.__styleString}else{if(W instanceof THREE.MeshDepthMaterial){F=1-(W.__2near/(W.__farPlusNear-T.z*W.__farMinusNear));D.setRGBA(F,F,F,1)}else{if(W instanceof THREE.MeshLambertMaterial){if(G){z.copyRGB(J);d(U,T,z);D.copyRGBA(W.color);D.multiplySelfRGB(z);D.updateStyleString()}else{D.__styleString=W.color.__styleString}}}}if(W.wireframe){if(g!=W.wireframe_linewidth){s.lineWidth=g=W.wireframe_linewidth}if(j!=D.__styleString){s.strokeStyle=j=D.__styleString}s.stroke();n.inflate(W.wireframe_linewidth*2)}else{if(R!=D.__styleString){s.fillStyle=R=D.__styleString}s.fill()}}function c(al,af,X,ad,W,ab,U,ac,V,aa,T,Z,S){s.beginPath();s.moveTo(af,X);s.lineTo(ad,W);s.lineTo(ab,U);s.closePath();ad-=af;W-=X;ab-=af;U-=X;aa-=ac;T-=V;Z-=ac;S-=V;var Y=1/(aa*S-Z*T),ak=(S*ad-T*ab)*Y,aj=(S*W-T*U)*Y,ai=(aa*ab-Z*ad)*Y,ah=(aa*U-Z*W)*Y,ag=af-ak*ac-ai*V,ae=X-aj*ac-ah*V;s.save();s.transform(ak,aj,ai,ah,ag,ae);s.clip();s.drawImage(al,0,0);s.restore()}function b(W,U){var S=U.x-W.x,V=U.y-W.y,T=1/Math.sqrt(S*S+V*V);S*=T;V*=T;U.x+=S;U.y+=V;W.x-=S;W.y-=V}};THREE.SVGRenderer=function(){var C=null,r=new THREE.Projector(),x=document.createElementNS("http://www.w3.org/2000/svg","svg"),b,o,p,w,v,u,t,s,E=new THREE.Rectangle(),A=new THREE.Rectangle(),i=false,k=new THREE.Color(4294967295),z=new THREE.Color(4294967295),c=new THREE.Color(4294967295),B,g=new THREE.Vector3(),d=[],l=[],G,n,f,F=1;this.domElement=x;this.autoClear=true;this.setQuality=function(H){switch(H){case"high":F=1;break;case"low":F=0;break}};this.setSize=function(I,H){b=I;o=H;p=b/2;w=o/2;x.setAttribute("viewBox",(-p)+" "+(-w)+" "+b+" "+o);x.setAttribute("width",b);x.setAttribute("height",o);E.set(-p,-w,p,w)};this.clear=function(){while(x.childNodes.length>0){x.removeChild(x.childNodes[0])}};this.render=function(L,P){var O,H,I,J,Q,M,K,N;if(this.autoClear){this.clear()}C=r.projectScene(L,P);n=0;f=0;i=L.lights.length>0;if(i){D(L,c)}for(O=0,H=C.length;O<H;O++){K=C[O];A.empty();if(K instanceof THREE.RenderableParticle){v=K;v.x*=p;v.y*=-w;for(I=0,J=K.material.length;I<J;I++){N=K.material[I];N&&j(v,K,N,L)}}else{if(K instanceof THREE.RenderableFace3){v=K.v1;u=K.v2;t=K.v3;v.positionScreen.x*=p;v.positionScreen.y*=-w;u.positionScreen.x*=p;u.positionScreen.y*=-w;t.positionScreen.x*=p;t.positionScreen.y*=-w;A.addPoint(v.positionScreen.x,v.positionScreen.y);A.addPoint(u.positionScreen.x,u.positionScreen.y);A.addPoint(t.positionScreen.x,t.positionScreen.y);if(!E.instersects(A)){continue}I=0;J=K.meshMaterial.length;while(I<J){N=K.meshMaterial[I++];if(N instanceof THREE.MeshFaceMaterial){Q=0;M=K.faceMaterial.length;while(Q<M){N=K.faceMaterial[Q++];N&&h(v,u,t,K,N,L)}continue}N&&h(v,u,t,K,N,L)}}else{if(K instanceof THREE.RenderableFace4){v=K.v1;u=K.v2;t=K.v3;s=K.v4;v.positionScreen.x*=p;v.positionScreen.y*=-w;u.positionScreen.x*=p;u.positionScreen.y*=-w;t.positionScreen.x*=p;t.positionScreen.y*=-w;s.positionScreen.x*=p;s.positionScreen.y*=-w;A.addPoint(v.positionScreen.x,v.positionScreen.y);A.addPoint(u.positionScreen.x,u.positionScreen.y);A.addPoint(t.positionScreen.x,t.positionScreen.y);A.addPoint(s.positionScreen.x,s.positionScreen.y);if(!E.instersects(A)){continue}I=0;J=K.meshMaterial.length;while(I<J){N=K.meshMaterial[I++];if(N instanceof THREE.MeshFaceMaterial){Q=0;M=K.faceMaterial.length;while(Q<M){N=K.faceMaterial[Q++];N&&e(v,u,t,s,K,N,L)}continue}N&&e(v,u,t,s,K,N,L)}}}}}};function D(L,J){var I,K,H;J.setRGBA(0,0,0,1);for(I=0,K=L.lights.length;I<K;I++){H=L.lights[I];if(H instanceof THREE.AmbientLight){J.r+=H.color.r;J.g+=H.color.g;J.b+=H.color.b}}}function q(M,K,J){var I,L,H;for(I=0,L=M.lights.length;I<L;I++){H=M.lights[I];if(H instanceof THREE.DirectionalLight){J.r+=H.color.r;J.g+=H.color.g;J.b+=H.color.b}else{if(H instanceof THREE.PointLight){J.r+=H.color.r;J.g+=H.color.g;J.b+=H.color.b}}}}function a(N,L,J){var I,M,H,K;for(I=0,M=N.lights.length;I<M;I++){H=N.lights[I];if(H instanceof THREE.DirectionalLight){K=L.normalWorld.dot(H.position)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}else{if(H instanceof THREE.PointLight){g.sub(H.position,L.centroidWorld);g.normalize();K=L.normalWorld.dot(g)*H.intensity;if(K>0){J.r+=H.color.r*K;J.g+=H.color.g*K;J.b+=H.color.b*K}}}}}function j(K,H,I,J){G=y(f++);G.setAttribute("cx",K.x);G.setAttribute("cy",K.y);G.setAttribute("r",H.scale.x*p);if(I instanceof THREE.ParticleCircleMaterial){if(i){z.copyRGB(c);q(J,H,z);k.copyRGBA(I.color);k.multiplySelfRGB(z);k.updateStyleString()}else{k=I.color}G.setAttribute("style","fill: "+k.__styleString)}x.appendChild(G)}function h(M,L,K,H,I,J){G=m(n++);G.setAttribute("d","M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshDepthMaterial){B=1-(I.__2near/(I.__farPlusNear-H.z*I.__farMinusNear));k.setRGBA(B,B,B,1)}else{if(I instanceof THREE.MeshLambertMaterial){if(i){z.copyRGB(c);a(J,H,z);k.copyRGBA(I.color);k.multiplySelfRGB(z);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}}if(I.wireframe){G.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{G.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}x.appendChild(G)}function e(N,M,L,J,H,I,K){G=m(n++);G.setAttribute("d","M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+M.positionScreen.x+" "+M.positionScreen.y+" L "+L.positionScreen.x+","+L.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial){k.__styleString=I.color.__styleString}else{if(I instanceof THREE.MeshLambertMaterial){if(i){z.copyRGB(c);a(K,H,z);k.copyRGBA(I.color);k.multiplySelfRGB(z);k.updateStyleString()}else{k.__styleString=I.color.__styleString}}}if(I.wireframe){G.setAttribute("style","fill: none; stroke: "+k.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: round; stroke-linejoin: round")}else{G.setAttribute("style","fill: "+k.__styleString+"; fill-opacity: "+I.opacity)}x.appendChild(G)}function m(H){if(d[H]==null){d[H]=document.createElementNS("http://www.w3.org/2000/svg","path");if(F==0){d[H].setAttribute("shape-rendering","crispEdges")}return d[H]}return d[H]}function y(H){if(l[H]==null){l[H]=document.createElementNS("http://www.w3.org/2000/svg","circle");if(F==0){l[H].setAttribute("shape-rendering","crispEdges")}return l[H]}return l[H]}};THREE.WebGLRenderer=function(q){var f=document.createElement("canvas"),e,n,j=new THREE.Matrix4(),c,l=0,s=1,o=2,i=3,k=b(q,5);this.domElement=f;this.autoClear=true;a();g(k.directional,k.point);function b(x,y){if(x){var u,w,t,v=pointLights=maxDirLights=maxPointLights=0;for(u=0,w=x.lights.length;u<w;u++){t=x.lights[u];if(t instanceof THREE.DirectionalLight){v++}if(t instanceof THREE.PointLight){pointLights++}}if((pointLights+v)<=y){maxDirLights=v;maxPointLights=pointLights}else{maxDirLights=Math.ceil(y*v/(pointLights+v));maxPointLights=y-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:y-1}}this.setSize=function(u,t){f.width=u;f.height=t;e.viewport(0,0,f.width,f.height)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.setupLights=function(z){var w,D,x,u,A,E,v=[],B=[],C=[],t=[],y=[];e.uniform1i(n.enableLighting,z.lights.length);for(w=0,D=z.lights.length;w<D;w++){x=z.lights[w];if(x instanceof THREE.AmbientLight){v.push(x)}else{if(x instanceof THREE.DirectionalLight){C.push(x)}else{if(x instanceof THREE.PointLight){B.push(x)}}}}u=A=E=0;for(w=0,D=v.length;w<D;w++){u+=v[w].color.r;A+=v[w].color.g;E+=v[w].color.b}e.uniform3f(n.ambientLightColor,u,A,E);t=[];y=[];for(w=0,D=C.length;w<D;w++){x=C[w];t.push(x.color.r*x.intensity);t.push(x.color.g*x.intensity);t.push(x.color.b*x.intensity);y.push(x.position.x);y.push(x.position.y);y.push(x.position.z)}if(C.length){e.uniform1i(n.directionalLightNumber,C.length);e.uniform3fv(n.directionalLightDirection,y);e.uniform3fv(n.directionalLightColor,t)}t=[];y=[];for(w=0,D=B.length;w<D;w++){x=B[w];t.push(x.color.r*x.intensity);t.push(x.color.g*x.intensity);t.push(x.color.b*x.intensity);y.push(x.position.x);y.push(x.position.y);y.push(x.position.z)}if(B.length){e.uniform1i(n.pointLightNumber,B.length);e.uniform3fv(n.pointLightPosition,y);e.uniform3fv(n.pointLightColor,t)}};this.createBuffers=function(M,K){var I,A,C,z,H,L,y,w,v,u,t,x=M.materialFaceGroup[K],E=[],G=[],D=[],J=[],F=[],B=0;for(I=0,A=x.faces.length;I<A;I++){C=x.faces[I];z=M.geometry.faces[C];H=z.vertexNormals;L=z.normal;y=M.geometry.uvs[C];if(z instanceof THREE.Face3){w=M.geometry.vertices[z.a].position;v=M.geometry.vertices[z.b].position;u=M.geometry.vertices[z.c].position;D.push(w.x,w.y,w.z);D.push(v.x,v.y,v.z);D.push(u.x,u.y,u.z);if(H.length==3){J.push(H[0].x,H[0].y,H[0].z);J.push(H[1].x,H[1].y,H[1].z);J.push(H[2].x,H[2].y,H[2].z)}else{J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z)}if(y){F.push(y[0].u,y[0].v);F.push(y[1].u,y[1].v);F.push(y[2].u,y[2].v)}E.push(B,B+1,B+2);G.push(B,B+1);G.push(B,B+2);G.push(B+1,B+2);B+=3}else{if(z instanceof THREE.Face4){w=M.geometry.vertices[z.a].position;v=M.geometry.vertices[z.b].position;u=M.geometry.vertices[z.c].position;t=M.geometry.vertices[z.d].position;D.push(w.x,w.y,w.z);D.push(v.x,v.y,v.z);D.push(u.x,u.y,u.z);D.push(t.x,t.y,t.z);if(H.length==4){J.push(H[0].x,H[0].y,H[0].z);J.push(H[1].x,H[1].y,H[1].z);J.push(H[2].x,H[2].y,H[2].z);J.push(H[3].x,H[3].y,H[3].z)}else{J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z);J.push(L.x,L.y,L.z)}if(y){F.push(y[0].u,y[0].v);F.push(y[1].u,y[1].v);F.push(y[2].u,y[2].v);F.push(y[3].u,y[3].v)}E.push(B,B+1,B+2);E.push(B,B+2,B+3);G.push(B,B+1);G.push(B,B+2);G.push(B,B+3);G.push(B+1,B+2);G.push(B+2,B+3);B+=4}}}if(!D.length){return}x.__webGLVertexBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,x.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(D),e.STATIC_DRAW);x.__webGLNormalBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,x.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(J),e.STATIC_DRAW);x.__webGLUVBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,x.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(F),e.STATIC_DRAW);x.__webGLFaceBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),e.STATIC_DRAW);x.__webGLLineBuffer=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),e.STATIC_DRAW);x.__webGLFaceCount=E.length;x.__webGLLineCount=G.length};this.renderBuffer=function(y,C){var x,v,w,u,t,B,A,D,z;if(y instanceof THREE.MeshPhongMaterial||y instanceof THREE.MeshLambertMaterial||y instanceof THREE.MeshBasicMaterial){x=y.color;v=y.opacity;w=y.wireframe;u=y.wireframe_linewidth;t=y.blending;z=y.map;e.uniform4f(n.mColor,x.r*v,x.g*v,x.b*v,v)}if(y instanceof THREE.MeshDepthMaterial){v=y.opacity;w=y.wireframe;u=y.wireframe_linewidth;e.uniform1f(n.m2Near,y.__2near);e.uniform1f(n.mFarPlusNear,y.__farPlusNear);e.uniform1f(n.mFarMinusNear,y.__farMinusNear);e.uniform1i(n.material,i)}else{if(y instanceof THREE.MeshPhongMaterial){B=y.ambient;A=y.specular;D=y.shininess;e.uniform4f(n.mAmbient,B.r,B.g,B.b,v);e.uniform4f(n.mSpecular,A.r,A.g,A.b,v);e.uniform1f(n.mShininess,D);e.uniform1i(n.material,o)}else{if(y instanceof THREE.MeshLambertMaterial){e.uniform1i(n.material,s)}else{if(y instanceof THREE.MeshBasicMaterial){e.uniform1i(n.material,l)}}}}if(z){if(!y.__webGLTexture&&y.map.loaded){y.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,y.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,y.map.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,y.__webGLTexture);e.uniform1i(n.tMap,0);e.uniform1i(n.enableMap,1)}else{e.uniform1i(n.enableMap,0)}e.bindBuffer(e.ARRAY_BUFFER,C.__webGLVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,false,0,0);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,false,0,0);if(z){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUVBuffer);e.enableVertexAttribArray(n.uv);e.vertexAttribPointer(n.uv,2,e.FLOAT,false,0,0)}else{e.disableVertexAttribArray(n.uv)}if(!w){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,C.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else{e.lineWidth(u);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);e.drawElements(e.LINES,C.__webGLLineCount,e.UNSIGNED_SHORT,0)}};this.renderMesh=function(v,y){var x,u,t,w,B,z,A,C;for(B in v.materialFaceGroup){C=v.materialFaceGroup[B];if(!C.__webGLVertexBuffer){this.createBuffers(v,B)}for(t=0,w=v.material.length;t<w;t++){A=v.material[t];if(A instanceof THREE.MeshFaceMaterial){for(x=0,u=C.material.length;x<u;x++){z=C.material[x];this.renderBuffer(z,C)}}else{z=A;this.renderBuffer(z,C)}}}};this.setupMatrices=function(t,u){t.autoUpdateMatrix&&t.updateMatrix();j.multiply(u.matrix,t.matrix);n.viewMatrixArray=new Float32Array(u.matrix.flatten());n.modelViewMatrixArray=new Float32Array(j.flatten());n.projectionMatrixArray=new Float32Array(u.projectionMatrix.flatten());c=THREE.Matrix4.makeInvert3x3(j).transpose();n.normalMatrixArray=new Float32Array(c.m);e.uniformMatrix4fv(n.viewMatrix,false,n.viewMatrixArray);e.uniformMatrix4fv(n.modelViewMatrix,false,n.modelViewMatrixArray);e.uniformMatrix4fv(n.projectionMatrix,false,n.projectionMatrixArray);e.uniformMatrix3fv(n.normalMatrix,false,n.normalMatrixArray);e.uniformMatrix4fv(n.objMatrix,false,new Float32Array(t.matrix.flatten()))};this.render=function(w,v){var x,u,t;if(this.autoClear){this.clear()}v.autoUpdateMatrix&&v.updateMatrix();e.uniform3f(n.cameraPosition,v.position.x,v.position.y,v.position.z);this.setupLights(w);for(x=0,u=w.objects.length;x<u;x++){t=w.objects[x];this.setupMatrices(t,v);if(t instanceof THREE.Mesh){this.renderMesh(t,v)}else{if(t instanceof THREE.Line){}else{if(t instanceof THREE.Particle){}}}}};this.setFaceCulling=function(u,t){if(u){if(!t||t=="ccw"){e.frontFace(e.CCW)}else{e.frontFace(e.CW)}if(u=="back"){e.cullFace(e.BACK)}else{if(u=="front"){e.cullFace(e.FRONT)}else{e.cullFace(e.FRONT_AND_BACK)}}e.enable(e.CULL_FACE)}else{e.disable(e.CULL_FACE)}};function a(){try{e=f.getContext("experimental-webgl",{antialias:true})}catch(t){}if(!e){alert("WebGL not supported");throw"cannot create webgl context"}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(0,0,0,0)}function p(t,u){var v=["#ifdef GL_ES","precision highp float;","#endif",t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","uniform int material;","uniform bool enableMap;","uniform sampler2D tMap;","uniform vec4 mColor;","uniform vec4 mAmbient;","uniform vec4 mSpecular;","uniform float mShininess;","uniform float m2Near;","uniform float mFarPlusNear;","uniform float mFarMinusNear;","uniform int pointLightNumber;","uniform int directionalLightNumber;",t?"uniform mat4 viewMatrix;":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","void main() {","vec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );","if ( enableMap ) {","mapColor = texture2D( tMap, vUv );","}","if ( material == 3 ) { ","float w = 0.5;","gl_FragColor = vec4( w, w, w, 1.0 );","} else if ( material == 2 ) { ","vec3 normal = normalize( vNormal );","vec3 viewPosition = normalize( vViewPosition );",u?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",u?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",u?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",u?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",u?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",u?"float pointSpecularWeight = 0.0;":"",u?"if ( pointDotNormalHalf >= 0.0 )":"",u?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",u?"pointDiffuse += mColor * pointDiffuseWeight;":"",u?"pointSpecular += mSpecular * pointSpecularWeight;":"",u?"}":"",t?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"vec3 dirVector = normalize( lDirection.xyz );":"",t?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":"",t?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",t?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",t?"float dirSpecularWeight = 0.0;":"",t?"if ( dirDotNormalHalf >= 0.0 )":"",t?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",t?"dirDiffuse += mColor * dirDiffuseWeight;":"",t?"dirSpecular += mSpecular * dirSpecularWeight;":"",t?"}":"","vec4 totalLight = mAmbient;",t?"totalLight += dirDiffuse + dirSpecular;":"",u?"totalLight += pointDiffuse + pointSpecular;":"","gl_FragColor = vec4( mapColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );","} else if ( material == 1 ) {","gl_FragColor = vec4( mColor.rgb * mapColor.rgb * vLightWeighting, mColor.a * mapColor.a );","} else {","gl_FragColor = mColor * mapColor;","}","}"];return v.join("\n")}function h(t,u){var v=[t?"#define MAX_DIR_LIGHTS "+t:"",u?"#define MAX_POINT_LIGHTS "+u:"","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","uniform vec3 cameraPosition;","uniform bool enableLighting;","uniform int pointLightNumber;","uniform int directionalLightNumber;","uniform vec3 ambientLightColor;",t?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",t?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",u?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",u?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 objMatrix;","uniform mat4 viewMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat3 normalMatrix;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vLightWeighting;",u?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;","varying vec3 vFragPosition;","void main(void) {","vec4 mPosition = objMatrix * vec4( position, 1.0 );","vViewPosition = cameraPosition - mPosition.xyz;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec3 transformedNormal = normalize( normalMatrix * normal );","if ( !enableLighting ) {","vLightWeighting = vec3( 1.0, 1.0, 1.0 );","} else {","vLightWeighting = ambientLightColor;",t?"for( int i = 0; i < directionalLightNumber; i++ ) {":"",t?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",t?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",t?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",t?"}":"",u?"for( int i = 0; i < pointLightNumber; i++ ) {":"",u?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",u?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":"",u?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",u?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",u?"}":"","}","vNormal = transformedNormal;","vUv = uv;","gl_Position = projectionMatrix * mvPosition;","}"];return v.join("\n")}function g(t,u){n=e.createProgram();e.attachShader(n,r("fragment",p(t,u)));e.attachShader(n,r("vertex",h(t,u)));e.linkProgram(n);if(!e.getProgramParameter(n,e.LINK_STATUS)){alert("Could not initialise shaders")}e.useProgram(n);n.viewMatrix=e.getUniformLocation(n,"viewMatrix");n.modelViewMatrix=e.getUniformLocation(n,"modelViewMatrix");n.projectionMatrix=e.getUniformLocation(n,"projectionMatrix");n.normalMatrix=e.getUniformLocation(n,"normalMatrix");n.objMatrix=e.getUniformLocation(n,"objMatrix");n.cameraPosition=e.getUniformLocation(n,"cameraPosition");n.enableLighting=e.getUniformLocation(n,"enableLighting");n.ambientLightColor=e.getUniformLocation(n,"ambientLightColor");if(t){n.directionalLightNumber=e.getUniformLocation(n,"directionalLightNumber");n.directionalLightColor=e.getUniformLocation(n,"directionalLightColor");n.directionalLightDirection=e.getUniformLocation(n,"directionalLightDirection")}if(u){n.pointLightNumber=e.getUniformLocation(n,"pointLightNumber");n.pointLightColor=e.getUniformLocation(n,"pointLightColor");n.pointLightPosition=e.getUniformLocation(n,"pointLightPosition")}n.material=e.getUniformLocation(n,"material");n.mColor=e.getUniformLocation(n,"mColor");n.mAmbient=e.getUniformLocation(n,"mAmbient");n.mSpecular=e.getUniformLocation(n,"mSpecular");n.mShininess=e.getUniformLocation(n,"mShininess");n.enableMap=e.getUniformLocation(n,"enableMap");e.uniform1i(n.enableMap,0);n.tMap=e.getUniformLocation(n,"tMap");e.uniform1i(n.tMap,0);n.m2Near=e.getUniformLocation(n,"m2Near");n.mFarPlusNear=e.getUniformLocation(n,"mFarPlusNear");n.mFarMinusNear=e.getUniformLocation(n,"mFarMinusNear");n.position=e.getAttribLocation(n,"position");e.enableVertexAttribArray(n.position);n.normal=e.getAttribLocation(n,"normal");e.enableVertexAttribArray(n.normal);n.uv=e.getAttribLocation(n,"uv");e.enableVertexAttribArray(n.uv);n.viewMatrixArray=new Float32Array(16);n.modelViewMatrixArray=new Float32Array(16);n.projectionMatrixArray=new Float32Array(16)}function r(u,t){var v;if(u=="fragment"){v=e.createShader(e.FRAGMENT_SHADER)}else{if(u=="vertex"){v=e.createShader(e.VERTEX_SHADER)}}e.shaderSource(v,t);e.compileShader(v);if(!e.getShaderParameter(v,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(v));return null}return v}function d(){var t={MAX_VARYING_VECTORS:e.getParameter(e.MAX_VARYING_VECTORS),MAX_VERTEX_ATTRIBS:e.getParameter(e.MAX_VERTEX_ATTRIBS),MAX_TEXTURE_IMAGE_UNITS:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),MAX_VERTEX_TEXTURE_IMAGE_UNITS:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),MAX_COMBINED_TEXTURE_IMAGE_UNITS:e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),MAX_VERTEX_UNIFORM_VECTORS:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),MAX_FRAGMENT_UNIFORM_VECTORS:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)};return t}function m(u){var t,v="";for(t in u){v+=t+": "+u[t]+"\n"}return v}};THREE.RenderableFace3=function(){this.v1=new THREE.Vertex();this.v2=new THREE.Vertex();this.v3=new THREE.Vertex();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableFace4=function(){this.v1=new THREE.Vertex();this.v2=new THREE.Vertex();this.v3=new THREE.Vertex();this.v4=new THREE.Vertex();this.centroidWorld=new THREE.Vector3();this.centroidScreen=new THREE.Vector3();this.normalWorld=new THREE.Vector3();this.z=null;this.color=null;this.material=null};THREE.RenderableParticle=function(){this.x=null;this.y=null;this.z=null;this.rotation=null;this.scale=new THREE.Vector2();this.color=null;this.material=null};THREE.RenderableLine=function(){this.v1=new THREE.Vertex();this.v2=new THREE.Vertex();this.z=null;this.color=null;this.material=null};
\ No newline at end of file
......@@ -23,15 +23,9 @@
<script type="text/javascript">
var SCREEN_WIDTH = window.innerWidth;
var SCREEN_HEIGHT = window.innerHeight;
var container, stats;
var container;
var stats;
var camera;
var scene;
var renderer;
var camera, scene, renderer;
var cube, plane;
......@@ -69,7 +63,7 @@
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.Camera( 45, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 2000 );
camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.x = 1000;
camera.position.y = 1000;
camera.position.z = 1000;
......@@ -79,7 +73,7 @@
// Plane
var material = new THREE.MeshDepthMaterial( { near: 1, far: 2000, wireframe: true } );
var material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } );
plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material );
plane.rotation.x = - 90 * ( Math.PI / 180 );
......@@ -88,7 +82,7 @@
// Spheres
geometry = new Sphere( 100, 16, 8 );
geometry = new Sphere( 100, 8, 4 );
//material = new THREE.MeshLambertMaterial( { color: 0xffffff } );
material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } );
......@@ -98,16 +92,19 @@
cube.overdraw = true;
cube.position.x = ( i % 5 ) * 200 - 400;
cube.position.z = Math.floor( i / 5 ) * 200 - 400;
cube.position.z = Math.floor( i / 5 ) * 200 - 350;
/*
cube.position.x = Math.random() * 1000 - 500;
cube.position.y = Math.random() * 1000 - 500;
cube.position.z = Math.random() * 1000 - 500;
*/
cube.rotation.x = Math.random() * 200 - 100;
cube.rotation.y = Math.random() * 200 - 100;
cube.rotation.z = Math.random() * 200 - 100;
/*
cube.scale.x = cube.scale.y = cube.scale.z = Math.random() + 0.5;
*/
......@@ -132,7 +129,7 @@
renderer = new THREE.CanvasRenderer();
//renderer = new THREE.WebGLRenderer();
renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
......@@ -200,20 +197,20 @@
function loop() {
if ( moveForward ) camera.position.z -= 5; // camera.moveZ( 5 );
if ( moveBackwards ) camera.position.z += 5; // camera.moveZ( - 5 );
if ( moveForward ) camera.position.z -= 10; // camera.moveZ( 10 );
if ( moveBackwards ) camera.position.z += 10; // camera.moveZ( - 10 );
if ( moveUp ) camera.position.y += 5; // camera.moveZ( 5 );
if ( moveDown ) camera.position.y -= 5; // camera.moveZ( - 5 );
if ( moveUp ) camera.position.y += 10; // camera.moveZ( 10 );
if ( moveDown ) camera.position.y -= 10; // camera.moveZ( - 10 );
if ( moveLeft ) camera.position.x -= 5; // camera.moveX( - 5 );
if ( moveRight ) camera.position.x += 5; // camera.moveX( 5 );
if ( moveLeft ) camera.position.x -= 10; // camera.moveX( - 10 );
if ( moveRight ) camera.position.x += 10; // camera.moveX( 10 );
if ( pitchUp ) camera.rotation.x += 0.01; // camera.rotateX( 1 );
if ( pitchDown ) camera.rotation.x -= 0.01; // camera.rotateX( - 1 );
if ( yawLeft ) camera.target.position.x -= 5; // camera.rotation.y += 0.01; // camera.rotateY( 1 );
if ( yawRight ) camera.target.position.x += 5; // camera.rotation.y -= 0.01; // camera.rotateY( - 1 );
if ( yawLeft ) camera.target.position.x -= 10; // camera.rotation.y += 0.01; // camera.rotateY( 1 );
if ( yawRight ) camera.target.position.x += 10; // camera.rotation.y -= 0.01; // camera.rotateY( - 1 );
if ( rollLeft ) camera.rotation.z += 0.01; // camera.rotateZ( 1 );
if ( rollRight ) camera.rotation.z -= 0.01; // camera.rotateZ( - 1 );
......@@ -240,11 +237,9 @@
var object = scene.objects[i];
/*
object.rotation.x += 0.01;
object.rotation.y += 0.005;
object.position.y = Math.sin( object.rotation.x ) * 200;
*/
debugContext.rect( object.position.x * 0.1 - 5, object.position.z * 0.1 - 5, 10, 10 );
......
......@@ -4,8 +4,7 @@
* parameters = {
* near: <float>,
* far: <float>,
* wireframe: <boolean>,
* wireframe_linewidth: <float>
* opacity: <float>
* }
*/
......@@ -14,16 +13,12 @@ THREE.MeshDepthMaterial = function ( parameters ) {
this.near = 1;
this.far = 1000;
this.opacity = 1;
this.wireframe = false;
this.wireframe_linewidth = 1;
if ( parameters ) {
if ( parameters.near !== undefined ) this.near = parameters.near;
if ( parameters.far !== undefined ) this.far = parameters.far;
if ( parameters.opacity !== undefined ) this.opacity = parameters.opacity;
if ( parameters.wireframe !== undefined ) this.wireframe = parameters.wireframe;
if ( parameters.wireframe_linewidth !== undefined ) this.wireframe_linewidth = parameters.wireframe_linewidth;
}
......
......@@ -16,6 +16,9 @@ THREE.CanvasRenderer = function () {
_contextFillStyle = '#000000',
_contextLineWidth = 1,
_v1, _v2, _v3, _v4,
_v5 = new THREE.Vertex(), _v6 = new THREE.Vertex(), // Needed for latter splitting tris to quads
_clipRect = new THREE.Rectangle(),
_clearRect = new THREE.Rectangle(),
_bboxRect = new THREE.Rectangle(),
......@@ -25,12 +28,22 @@ THREE.CanvasRenderer = function () {
_light = new THREE.Color( 0xffffffff ),
_ambientLight = new THREE.Color( 0xff000000 ),
_pi2 = Math.PI * 2,
_w, // z-buffer to w-buffer
_vector2 = new THREE.Vector2(), // Needed for expand
_pi2 = Math.PI * 2, _w, // z-buffer to w-buffer
_vector3 = new THREE.Vector3(), // Needed for PointLight
_uv1 = new THREE.UV(), _uv2 = new THREE.UV(), _uv3 = new THREE.UV(), _uv4 = new THREE.UV(),
v5 = new THREE.Vector2(), v6 = new THREE.Vector2(); // Needed for latter splitting tris to quads
_depthMap = document.createElement( 'canvas' ),
_depthMapContext = _depthMap.getContext( '2d' ),
_depthMapGradient = _depthMapContext.createLinearGradient( 0, 0, 255, 0);
_depthMap.width = 255;
_depthMap.height = 4;
_depthMapGradient.addColorStop( 0, "white" );
_depthMapGradient.addColorStop( 1, "black" );
_depthMapContext.fillStyle = _depthMapGradient;
_depthMapContext.fillRect( 0, 0, 255, 4 );
this.domElement = _canvas;
this.autoClear = true;
......@@ -69,8 +82,7 @@ THREE.CanvasRenderer = function () {
this.render = function ( scene, camera ) {
var e, el, element, m, ml, fm, fml, material,
v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v5x, v5y, v6x, v6y;
var e, el, element, m, ml, fm, fml, material;
if ( this.autoClear ) {
......@@ -103,22 +115,25 @@ THREE.CanvasRenderer = function () {
if ( element instanceof THREE.RenderableParticle ) {
v1x = element.x * _canvasWidthHalf; v1y = element.y * _canvasHeightHalf;
_v1 = element;
_v1.x *= _canvasWidthHalf; _v1.y *= _canvasHeightHalf;
for ( m = 0, ml = element.material.length; m < ml; m++ ) {
material = element.material[ m ];
material && renderParticle( v1x, v1y, element, material, scene );
material && renderParticle( _v1, element, material, scene );
}
} else if ( element instanceof THREE.RenderableLine ) {
v1x = element.v1.x * _canvasWidthHalf; v1y = element.v1.y * _canvasHeightHalf;
v2x = element.v2.x * _canvasWidthHalf; v2y = element.v2.y * _canvasHeightHalf;
_v1 = element.v1; _v2 = element.v2;
_v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf;
_v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
_bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
if ( !_clipRect.instersects( _bboxRect ) ) {
......@@ -131,31 +146,29 @@ THREE.CanvasRenderer = function () {
while ( m < ml ) {
material = element.material[ m ++ ];
material && renderLine( v1x, v1y, v2x, v2y, element, material, scene );
material && renderLine( _v1, _v2, element, material, scene );
}
} else if ( element instanceof THREE.RenderableFace3 ) {
element.v1.x *= _canvasWidthHalf; element.v1.y *= _canvasHeightHalf;
element.v2.x *= _canvasWidthHalf; element.v2.y *= _canvasHeightHalf;
element.v3.x *= _canvasWidthHalf; element.v3.y *= _canvasHeightHalf;
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;
_v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf;
_v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
_v3.positionScreen.x *= _canvasWidthHalf; _v3.positionScreen.y *= _canvasHeightHalf;
if ( element.overdraw ) {
expand( element.v1, element.v2 );
expand( element.v2, element.v3 );
expand( element.v3, element.v1 );
expand( _v1.positionScreen, _v2.positionScreen );
expand( _v2.positionScreen, _v3.positionScreen );
expand( _v3.positionScreen, _v1.positionScreen );
}
v1x = element.v1.x; v1y = element.v1.y;
v2x = element.v2.x; v2y = element.v2.y;
v3x = element.v3.x; v3y = element.v3.y;
_bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
if ( !_clipRect.instersects( _bboxRect ) ) {
......@@ -176,7 +189,7 @@ THREE.CanvasRenderer = function () {
while ( fm < fml ) {
material = element.faceMaterial[ fm ++ ];
material && renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
material && renderFace3( _v1, _v2, _v3, element, material, scene );
}
......@@ -184,46 +197,41 @@ THREE.CanvasRenderer = function () {
}
renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
material && renderFace3( _v1, _v2, _v3, element, material, scene );
}
} else if ( element instanceof THREE.RenderableFace4 ) {
element.v1.x *= _canvasWidthHalf; element.v1.y *= _canvasHeightHalf;
element.v2.x *= _canvasWidthHalf; element.v2.y *= _canvasHeightHalf;
element.v3.x *= _canvasWidthHalf; element.v3.y *= _canvasHeightHalf;
element.v4.x *= _canvasWidthHalf; element.v4.y *= _canvasHeightHalf;
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3; _v4 = element.v4;
_v1.positionScreen.x *= _canvasWidthHalf; _v1.positionScreen.y *= _canvasHeightHalf;
_v2.positionScreen.x *= _canvasWidthHalf; _v2.positionScreen.y *= _canvasHeightHalf;
_v3.positionScreen.x *= _canvasWidthHalf; _v3.positionScreen.y *= _canvasHeightHalf;
_v4.positionScreen.x *= _canvasWidthHalf; _v4.positionScreen.y *= _canvasHeightHalf;
v5.copy( element.v2 ); v6.copy( element.v4 );
_v5.positionScreen.copy( _v2.positionScreen );
_v6.positionScreen.copy( _v4.positionScreen );
if ( element.overdraw ) {
expand( element.v1, element.v2 );
expand( element.v2, element.v4 );
expand( element.v4, element.v1 );
expand( _v1.positionScreen, _v2.positionScreen );
expand( _v2.positionScreen, _v4.positionScreen );
expand( _v4.positionScreen, _v1.positionScreen );
}
v1x = element.v1.x; v1y = element.v1.y;
v2x = element.v2.x; v2y = element.v2.y;
v4x = element.v4.x; v4y = element.v4.y;
if ( element.overdraw ) {
expand( element.v3, v5 );
expand( element.v3, v6 );
expand( _v3.positionScreen, _v5.positionScreen );
expand( _v3.positionScreen, _v6.positionScreen );
}
v3x = element.v3.x; v3y = element.v3.y;
v5x = v5.x; v5y = v5.y;
v6x = v6.x; v6y = v6.y;
_bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
_bboxRect.addPoint( v4x, v4y );
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
_bboxRect.addPoint( _v4.positionScreen.x, _v4.positionScreen.y );
if ( !_clipRect.instersects( _bboxRect ) ) {
......@@ -244,7 +252,7 @@ THREE.CanvasRenderer = function () {
while ( fm < fml ) {
material = element.faceMaterial[ fm ++ ];
material && renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v5x, v5y, v6x, v6y, element, material, scene );
material && renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
}
......@@ -252,7 +260,7 @@ THREE.CanvasRenderer = function () {
}
renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v5x, v5y, v6x, v6y, element, material, scene );
material && renderFace4( _v1, _v2, _v3, _v4, _v5, _v6, element, material, scene );
}
......@@ -376,7 +384,7 @@ THREE.CanvasRenderer = function () {
}
function renderParticle ( v1x, v1y, element, material, scene ) {
function renderParticle ( v1, element, material, scene ) {
var width, height, scaleX, scaleY, offsetX, offsetY,
bitmap, bitmapWidth, bitmapHeight;
......@@ -404,7 +412,7 @@ THREE.CanvasRenderer = function () {
// TODO: Rotations break this...
_bboxRect.set( v1x + offsetX - width, v1y + offsetY - height, v1x + offsetX + width, v1y + offsetY + height );
_bboxRect.set( v1.x + offsetX - width, v1.y + offsetY - height, v1.x + offsetX + width, v1.y + offsetY + height );
if ( !_clipRect.instersects( _bboxRect ) ) {
......@@ -413,7 +421,7 @@ THREE.CanvasRenderer = function () {
}
_context.save();
_context.translate( v1x, v1y );
_context.translate( v1.x, v1.y );
_context.rotate( - element.rotation );
_context.scale( scaleX, - scaleY );
_context.translate( - bitmapWidth + material.offset.x, - bitmapHeight - material.offset.y );
......@@ -453,7 +461,7 @@ THREE.CanvasRenderer = function () {
width = element.scale.x * _canvasWidthHalf;
height = element.scale.y * _canvasHeightHalf;
_bboxRect.set( v1x - width, v1y - height, v1x + width, v1y + height );
_bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height );
if ( !_clipRect.instersects( _bboxRect ) ) {
......@@ -462,7 +470,7 @@ THREE.CanvasRenderer = function () {
}
_context.save();
_context.translate( v1x, v1y );
_context.translate( v1.x, v1.y );
_context.rotate( - element.rotation );
_context.scale( width, height );
......@@ -479,7 +487,7 @@ THREE.CanvasRenderer = function () {
}
function renderLine( v1x, v1y, v2x, v2y, element, material, scene ) {
function renderLine( v1, v2, element, material, scene ) {
if ( _contextGlobalAlpha != material.opacity ) {
......@@ -490,8 +498,8 @@ THREE.CanvasRenderer = function () {
if ( material instanceof THREE.LineBasicMaterial ) {
_context.beginPath();
_context.moveTo( v1x, v1y );
_context.lineTo( v2x, v2y );
_context.moveTo( v1.positionScreen.x, v1.positionScreen.y );
_context.lineTo( v2.positionScreen.x, v2.positionScreen.y );
_context.closePath();
_color.__styleString = material.color.__styleString;
......@@ -516,7 +524,7 @@ THREE.CanvasRenderer = function () {
}
function renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene ) {
function renderFace3( v1, v2, v3, element, material, scene ) {
var bitmap, bitmapWidth, bitmapHeight;
......@@ -532,25 +540,42 @@ THREE.CanvasRenderer = function () {
bitmapWidth = bitmap.width - 1;
bitmapHeight = bitmap.height - 1;
_uv1.copy( element.uvs[ 0 ] );
_uv2.copy( element.uvs[ 1 ] );
_uv3.copy( element.uvs[ 2 ] );
_uv1.u = element.uvs[ 0 ].u * bitmapWidth; _uv1.v = element.uvs[ 0 ].v * bitmapHeight;
_uv2.u = element.uvs[ 1 ].u * bitmapWidth; _uv2.v = element.uvs[ 1 ].v * bitmapHeight;
_uv3.u = element.uvs[ 2 ].u * bitmapWidth; _uv3.v = element.uvs[ 2 ].v * bitmapHeight;
_uv1.u *= bitmapWidth; _uv1.v *= bitmapHeight;
_uv2.u *= bitmapWidth; _uv2.v *= bitmapHeight;
_uv3.u *= bitmapWidth; _uv3.v *= bitmapHeight;
drawTexturedTriangle( bitmap, v1.positionScreen.x, v1.positionScreen.y, v2.positionScreen.x, v2.positionScreen.y, v3.positionScreen.x, v3.positionScreen.y, _uv1.u, _uv1.v, _uv2.u, _uv2.v, _uv3.u, _uv3.v );
return;
}
if ( material instanceof THREE.MeshDepthMaterial ) {
drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v3x, v3y, _uv1.u, _uv1.v, _uv2.u, _uv2.v, _uv3.u, _uv3.v );
bitmap = _depthMap;
bitmapWidth = bitmap.width - 1;
bitmapHeight = bitmap.height - 1;
_w = material.__2near / (material.__farPlusNear - v1.positionScreen.z * material.__farMinusNear );
_uv1.u = _w * bitmapWidth; _uv1.v = 0;
_w = material.__2near / (material.__farPlusNear - v2.positionScreen.z * material.__farMinusNear );
_uv2.u = _w * bitmapWidth; _uv2.v = 1;
_w = material.__2near / (material.__farPlusNear - v3.positionScreen.z * material.__farMinusNear );
_uv3.u = _w * bitmapWidth; _uv3.v = 2;
drawTexturedTriangle( bitmap, v1.positionScreen.x, v1.positionScreen.y, v2.positionScreen.x, v2.positionScreen.y, v3.positionScreen.x, v3.positionScreen.y, _uv1.u, _uv1.v, _uv2.u, _uv2.v, _uv3.u, _uv3.v );
return;
}
_context.beginPath();
_context.moveTo( v1x, v1y );
_context.lineTo( v2x, v2y );
_context.lineTo( v3x, v3y );
_context.lineTo( v1x, v1y );
_context.moveTo( v1.positionScreen.x, v1.positionScreen.y );
_context.lineTo( v2.positionScreen.x, v2.positionScreen.y );
_context.lineTo( v3.positionScreen.x, v3.positionScreen.y );
_context.lineTo( v1.positionScreen.x, v1.positionScreen.y );
_context.closePath();
if ( material instanceof THREE.MeshBasicMaterial ) {
......@@ -559,8 +584,10 @@ THREE.CanvasRenderer = function () {
} else if ( material instanceof THREE.MeshDepthMaterial ) {
/*
_w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear ) );
_color.setRGBA( _w, _w, _w, 1 );
*/
} else if ( material instanceof THREE.MeshLambertMaterial ) {
......@@ -613,7 +640,7 @@ THREE.CanvasRenderer = function () {
}
function renderFace4 ( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v5x, v5y, v6x, v6y, element, material, scene ) {
function renderFace4( v1, v2, v3, v4, v5, v6, element, material, scene ) {
var bitmap, bitmapWidth, bitmapHeight;
......@@ -639,19 +666,44 @@ THREE.CanvasRenderer = function () {
_uv3.u *= bitmapWidth; _uv3.v *= bitmapHeight;
_uv4.u *= bitmapWidth; _uv4.v *= bitmapHeight;
drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v4x, v4y, _uv1.u, _uv1.v, _uv2.u, _uv2.v, _uv4.u, _uv4.v );
drawTexturedTriangle( bitmap, v5x, v5y, v3x, v3y, v6x, v6y, _uv2.u, _uv2.v, _uv3.u, _uv3.v, _uv4.u, _uv4.v );
drawTexturedTriangle( bitmap, v1.positionScreen.x, v1.positionScreen.y, v2.positionScreen.x, v2.positionScreen.y, v4.positionScreen.x, v4.positionScreen.y, _uv1.u, _uv1.v, _uv2.u, _uv2.v, _uv4.u, _uv4.v );
drawTexturedTriangle( bitmap, v5.positionScreen.x, v5.positionScreen.y, v3.positionScreen.x, v3.positionScreen.y, v6.positionScreen.x, v6.positionScreen.y, _uv2.u, _uv2.v, _uv3.u, _uv3.v, _uv4.u, _uv4.v );
return;
}
if ( material instanceof THREE.MeshDepthMaterial ) {
bitmap = _depthMap;
bitmapWidth = bitmap.width - 1;
bitmapHeight = bitmap.height - 1;
_w = material.__2near / (material.__farPlusNear - v1.positionScreen.z * material.__farMinusNear );
_uv1.u = _w * bitmapWidth; _uv1.v = 0;
_w = material.__2near / (material.__farPlusNear - v2.positionScreen.z * material.__farMinusNear );
_uv2.u = _w * bitmapWidth; _uv2.v = 1;
_w = material.__2near / (material.__farPlusNear - v3.positionScreen.z * material.__farMinusNear );
_uv3.u = _w * bitmapWidth; _uv3.v = 2;
_w = material.__2near / (material.__farPlusNear - v4.positionScreen.z * material.__farMinusNear );
_uv4.u = _w * bitmapWidth; _uv4.v = 3;
drawTexturedTriangle( bitmap, v1.positionScreen.x, v1.positionScreen.y, v2.positionScreen.x, v2.positionScreen.y, v4.positionScreen.x, v4.positionScreen.y, _uv1.u, _uv1.v, _uv2.u, _uv2.v, _uv4.u, _uv4.v );
drawTexturedTriangle( bitmap, v5.positionScreen.x, v5.positionScreen.y, v3.positionScreen.x, v3.positionScreen.y, v6.positionScreen.x, v6.positionScreen.y, _uv2.u, _uv2.v, _uv3.u, _uv3.v, _uv4.u, _uv4.v );
return;
}
_context.beginPath();
_context.moveTo( v1x, v1y );
_context.lineTo( v2x, v2y );
_context.lineTo( v3x, v3y );
_context.lineTo( v4x, v4y );
_context.lineTo( v1x, v1y );
_context.moveTo( v1.positionScreen.x, v1.positionScreen.y );
_context.lineTo( v2.positionScreen.x, v2.positionScreen.y );
_context.lineTo( v3.positionScreen.x, v3.positionScreen.y );
_context.lineTo( v4.positionScreen.x, v4.positionScreen.y );
_context.lineTo( v1.positionScreen.x, v1.positionScreen.y );
_context.closePath();
if ( material instanceof THREE.MeshBasicMaterial ) {
......@@ -724,15 +776,11 @@ THREE.CanvasRenderer = function () {
_context.lineTo( x2, y2 );
_context.closePath();
x1 -= x0;
y1 -= y0;
x2 -= x0;
y2 -= y0;
x1 -= x0; y1 -= y0;
x2 -= x0; y2 -= y0;
u1 -= u0;
v1 -= v0;
u2 -= u0;
v2 -= v0;
u1 -= u0; v1 -= v0;
u2 -= u0; v2 -= v0;
var det = 1 / ( u1 * v2 - u2 * v1 ),
......@@ -753,14 +801,15 @@ THREE.CanvasRenderer = function () {
// Hide anti-alias gaps
function expand( a, b ) {
function expand( v1, v2 ) {
var x = v2.x - v1.x, y = v2.y - v1.y,
unit = 1 / Math.sqrt( x * x + y * y );
_vector2.sub( b, a );
_vector2.unit();
_vector2.multiplyScalar( 0.75 );
x *= unit; y *= unit;
b.addSelf( _vector2 );
a.subSelf( _vector2 );
v2.x += x; v2.y += y;
v1.x -= x; v1.y -= y;
}
......
......@@ -84,9 +84,9 @@ THREE.Projector = function() {
( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ) ) ) {
_face3 = _face3Pool[ _face3Count ] = _face3Pool[ _face3Count ] || new THREE.RenderableFace3();
_face3.v1.copy( v1.positionScreen );
_face3.v2.copy( v2.positionScreen );
_face3.v3.copy( v3.positionScreen );
_face3.v1.positionScreen.copy( v1.positionScreen );
_face3.v2.positionScreen.copy( v2.positionScreen );
_face3.v3.positionScreen.copy( v3.positionScreen );
_face3.normalWorld.copy( face.normal );
object.matrixRotation.transform( _face3.normalWorld );
......@@ -126,10 +126,10 @@ THREE.Projector = function() {
( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0 ) ) ) ) {
_face4 = _face4Pool[ _face4Count ] = _face4Pool[ _face4Count ] || new THREE.RenderableFace4();
_face4.v1.copy( v1.positionScreen );
_face4.v2.copy( v2.positionScreen );
_face4.v3.copy( v3.positionScreen );
_face4.v4.copy( v4.positionScreen );
_face4.v1.positionScreen.copy( v1.positionScreen );
_face4.v2.positionScreen.copy( v2.positionScreen );
_face4.v3.positionScreen.copy( v3.positionScreen );
_face4.v4.positionScreen.copy( v4.positionScreen );
_face4.normalWorld.copy( face.normal );
object.matrixRotation.transform( _face4.normalWorld );
......@@ -176,15 +176,15 @@ THREE.Projector = function() {
vertex.__visible = vertexPositionScreen.z > 0 && vertexPositionScreen.z < 1;
if ( v > 0 ) {
if ( vertex.__visible && v > 0 ) {
vertex2 = object.geometry.vertices[ v - 1 ];
if ( vertex.__visible && vertex2.__visible ) {
_line = _linePool[ _lineCount ] = _linePool[ _lineCount ] || new THREE.RenderableLine();
_line.v1.copy( vertex.positionScreen );
_line.v2.copy( vertex2.positionScreen );
_line.v1.positionScreen.copy( vertex.positionScreen );
_line.v2.positionScreen.copy( vertex2.positionScreen );
// TODO: Use centroids here too.
_line.z = Math.max( vertex.positionScreen.z, vertex2.positionScreen.z );
......
......@@ -8,6 +8,9 @@ THREE.SVGRenderer = function () {
_projector = new THREE.Projector(),
_svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
_svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf,
_v1, _v2, _v3, _v4,
_clipRect = new THREE.Rectangle(),
_bboxRect = new THREE.Rectangle(),
......@@ -37,7 +40,7 @@ THREE.SVGRenderer = function () {
};
this.setSize = function ( width, height ) {
this.setSize = function( width, height ) {
_svgWidth = width; _svgHeight = height;
_svgWidthHalf = _svgWidth / 2; _svgHeightHalf = _svgHeight / 2;
......@@ -60,10 +63,9 @@ THREE.SVGRenderer = function () {
};
this.render = function ( scene, camera ) {
this.render = function( scene, camera ) {
var e, el, m, ml, fm, fml, element, material,
v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y;
var e, el, m, ml, fm, fml, element, material;
if ( this.autoClear ) {
......@@ -91,28 +93,31 @@ THREE.SVGRenderer = function () {
if ( element instanceof THREE.RenderableParticle ) {
v1x = element.x * _svgWidthHalf; v1y = element.y * -_svgHeightHalf;
_v1 = element;
_v1.x *= _svgWidthHalf; _v1.y *= -_svgHeightHalf;
for ( m = 0, ml = element.material.length; m < ml; m++ ) {
material = element.material[ m ];
material && renderParticle( v1x, v1y, element, material, scene );
material && renderParticle( _v1, element, material, scene );
}
}/* else if ( element instanceof THREE.RenderableLine ) {
TODO: It's actually quite easy...
}*/ else if ( element instanceof THREE.RenderableFace3 ) {
v1x = element.v1.x * _svgWidthHalf; v1y = element.v1.y * -_svgHeightHalf;
v2x = element.v2.x * _svgWidthHalf; v2y = element.v2.y * -_svgHeightHalf;
v3x = element.v3.x * _svgWidthHalf; v3y = element.v3.y * -_svgHeightHalf;
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;
_bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;
_v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= - _svgHeightHalf;
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
if ( !_clipRect.instersects( _bboxRect ) ) {
......@@ -133,7 +138,7 @@ THREE.SVGRenderer = function () {
while ( fm < fml ) {
material = element.faceMaterial[ fm ++ ];
material && renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
material && renderFace3( _v1, _v2, _v3, element, material, scene );
}
......@@ -141,21 +146,23 @@ THREE.SVGRenderer = function () {
}
material && renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
material && renderFace3( _v1, _v2, _v3, element, material, scene );
}
} else if ( element instanceof THREE.RenderableFace4 ) {
v1x = element.v1.x * _svgWidthHalf; v1y = element.v1.y * -_svgHeightHalf;
v2x = element.v2.x * _svgWidthHalf; v2y = element.v2.y * -_svgHeightHalf;
v3x = element.v3.x * _svgWidthHalf; v3y = element.v3.y * -_svgHeightHalf;
v4x = element.v4.x * _svgWidthHalf; v4y = element.v4.y * -_svgHeightHalf;
_v1 = element.v1; _v2 = element.v2; _v3 = element.v3; _v4 = element.v4;
_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= -_svgHeightHalf;
_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= -_svgHeightHalf;
_v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= -_svgHeightHalf;
_v4.positionScreen.x *= _svgWidthHalf; _v4.positionScreen.y *= -_svgHeightHalf;
_bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
_bboxRect.addPoint( v4x, v4y );
_bboxRect.addPoint( _v1.positionScreen.x, _v1.positionScreen.y );
_bboxRect.addPoint( _v2.positionScreen.x, _v2.positionScreen.y );
_bboxRect.addPoint( _v3.positionScreen.x, _v3.positionScreen.y );
_bboxRect.addPoint( _v4.positionScreen.x, _v4.positionScreen.y );
if ( !_clipRect.instersects( _bboxRect) ) {
......@@ -176,7 +183,7 @@ THREE.SVGRenderer = function () {
while ( fm < fml ) {
material = element.faceMaterial[ fm ++ ];
material && renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
material && renderFace4( _v1, _v2, _v3, _v4, element, material, scene );
}
......@@ -184,7 +191,7 @@ THREE.SVGRenderer = function () {
}
material && renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
material && renderFace4( _v1, _v2, _v3, _v4, element, material, scene );
}
......@@ -283,11 +290,11 @@ THREE.SVGRenderer = function () {
}
function renderParticle ( v1x, v1y, element, material, scene ) {
function renderParticle( v1, element, material, scene ) {
_svgNode = getCircleNode( _circleCount++ );
_svgNode.setAttribute( 'cx', v1x );
_svgNode.setAttribute( 'cy', v1y );
_svgNode.setAttribute( 'cx', v1.x );
_svgNode.setAttribute( 'cy', v1.y );
_svgNode.setAttribute( 'r', element.scale.x * _svgWidthHalf );
if ( material instanceof THREE.ParticleCircleMaterial ) {
......@@ -323,10 +330,10 @@ THREE.SVGRenderer = function () {
}
*/
function renderFace3 ( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene ) {
function renderFace3( v1, v2, v3, element, material, scene ) {
_svgNode = getPathNode( _pathCount ++ );
_svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + 'z' );
_svgNode.setAttribute( 'd', 'M ' + v1.positionScreen.x + ' ' + v1.positionScreen.y + ' L ' + v2.positionScreen.x + ' ' + v2.positionScreen.y + ' L ' + v3.positionScreen.x + ',' + v3.positionScreen.y + 'z' );
if ( material instanceof THREE.MeshBasicMaterial ) {
......@@ -370,10 +377,10 @@ THREE.SVGRenderer = function () {
}
function renderFace4 ( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene ) {
function renderFace4( v1, v2, v3, v4, element, material, scene ) {
_svgNode = getPathNode( _pathCount ++ );
_svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + ' L ' + v4x + ',' + v4y + 'z' );
_svgNode.setAttribute( 'd', 'M ' + v1.positionScreen.x + ' ' + v1.positionScreen.y + ' L ' + v2.positionScreen.x + ' ' + v2.positionScreen.y + ' L ' + v3.positionScreen.x + ',' + v3.positionScreen.y + ' L ' + v4.positionScreen.x + ',' + v4.positionScreen.y + 'z' );
if ( material instanceof THREE.MeshBasicMaterial ) {
......@@ -412,7 +419,7 @@ THREE.SVGRenderer = function () {
}
function getPathNode ( id ) {
function getPathNode( id ) {
if ( _svgPathPool[ id ] == null ) {
......@@ -432,7 +439,7 @@ THREE.SVGRenderer = function () {
}
function getCircleNode ( id ) {
function getCircleNode( id ) {
if ( _svgCirclePool[id] == null ) {
......
......@@ -4,9 +4,9 @@
THREE.RenderableFace3 = function () {
this.v1 = new THREE.Vector2();
this.v2 = new THREE.Vector2();
this.v3 = new THREE.Vector2();
this.v1 = new THREE.Vertex();
this.v2 = new THREE.Vertex();
this.v3 = new THREE.Vertex();
this.centroidWorld = new THREE.Vector3();
this.centroidScreen = new THREE.Vector3();
......
......@@ -4,10 +4,10 @@
THREE.RenderableFace4 = function () {
this.v1 = new THREE.Vector2();
this.v2 = new THREE.Vector2();
this.v3 = new THREE.Vector2();
this.v4 = new THREE.Vector2();
this.v1 = new THREE.Vertex();
this.v2 = new THREE.Vertex();
this.v3 = new THREE.Vertex();
this.v4 = new THREE.Vertex();
this.centroidWorld = new THREE.Vector3();
this.centroidScreen = new THREE.Vector3();
......
......@@ -4,8 +4,8 @@
THREE.RenderableLine = function () {
this.v1 = new THREE.Vector2();
this.v2 = new THREE.Vector2();
this.v1 = new THREE.Vertex();
this.v2 = new THREE.Vertex();
this.z = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册