Browse Source

WebGLRenderer optimisation: flattening camera matrices just once per render, it was doing it once per object before.
WebGLRenderer2: Trying to re-create WebGLRenderer from scratch... Creating a program per material instead of just one for everything. Seems to be 3x faster by now...

Mr.doob 14 years ago
parent
commit
b84bca3bb0

+ 178 - 178
build/Three.js

@@ -1,178 +1,178 @@
-// Three.js r31 - http://github.com/mrdoob/three.js
-var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
-THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
-","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", 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(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
-THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;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){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+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(){var a=
-Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},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,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
-THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
-return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(n,o){return n.distance-o.distance});return h},intersectObject:function(a){function b(O,J,K,v){v=v.clone().subSelf(J);K=K.clone().subSelf(J);var g=O.clone().subSelf(J);O=v.dot(v);J=v.dot(K);v=v.dot(g);var k=K.dot(K);K=K.dot(g);g=1/(O*k-J*J);k=(k*v-J*K)*g;O=(O*K-J*v)*g;return k>0&&O>0&&k+O<1}var d,e,h,n,o,l,m,c,A,x,
-r,q=a.geometry,E=q.vertices,M=[];d=0;for(e=q.faces.length;d<e;d++){h=q.faces[d];x=this.origin.clone();r=this.direction.clone();n=a.matrix.multiplyVector3(E[h.a].position.clone());o=a.matrix.multiplyVector3(E[h.b].position.clone());l=a.matrix.multiplyVector3(E[h.c].position.clone());m=h instanceof THREE.Face4?a.matrix.multiplyVector3(E[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());A=r.dot(c);if(A<0){c=c.dot((new THREE.Vector3).sub(n,x))/A;x=x.addSelf(r.multiplyScalar(c));
-if(h instanceof THREE.Face3){if(b(x,n,o,l)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};M.push(h)}}else if(h instanceof THREE.Face4)if(b(x,n,o,m)||b(x,o,l,m)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};M.push(h)}}}return M}};
-THREE.Rectangle=function(){function a(){n=e-b;o=h-d}var b,d,e,h,n,o,l=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return n};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(m,c,A,x){l=false;b=m;d=c;e=A;h=x;a()};this.addPoint=function(m,c){if(l){l=false;b=m;d=c;e=m;h=c}else{b=b<m?b:m;d=d<c?d:c;e=e>m?e:m;h=h>c?
-h:c}a()};this.add3Points=function(m,c,A,x,r,q){if(l){l=false;b=m<A?m<r?m:r:A<r?A:r;d=c<x?c<q?c:q:x<q?x:q;e=m>A?m>r?m:r:A>r?A:r;h=c>x?c>q?c:q:x>q?x:q}else{b=m<A?m<r?m<b?m:b:r<b?r:b:A<r?A<b?A:b:r<b?r:b;d=c<x?c<q?c<d?c:d:q<d?q:d:x<q?x<d?x:d:q<d?q:d;e=m>A?m>r?m>e?m:e:r>e?r:e:A>r?A>e?A:e:r>e?r:e;h=c>x?c>q?c>h?c:h:q>h?q:h:x>q?x>h?x:h:q>h?q:h}a()};this.addRectangle=function(m){if(l){l=false;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=b<m.getLeft()?b:m.getLeft();d=d<m.getTop()?d:m.getTop();
-e=e>m.getRight()?e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e<m.getRight()?e:m.getRight();h=h<m.getBottom()?h:m.getBottom();a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){l=true;h=e=d=b=0;a()};this.isEmpty=function(){return l};this.toString=
-function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+n+", height: "+o+" )"}};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(a,b,d,e,h,n,o,l,m,c,A,x,r,q,E,M){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=n||1;this.n23=o||0;this.n24=l||0;this.n31=m||0;this.n32=c||0;this.n33=A||1;this.n34=x||0;this.n41=r||0;this.n42=q||0;this.n43=E||0;this.n44=M||1};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,h,n,o,l,m,c,A,x,r,q,E,M){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=n;this.n23=o;this.n24=l;this.n31=m;this.n32=c;this.n33=A;this.n34=x;this.n41=r;this.n42=q;this.n43=E;this.n44=M;return this},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;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();h.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x;
-this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
-h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,n=a.n14,o=a.n21,l=a.n22,m=a.n23,c=a.n24,A=a.n31,x=a.n32,
-r=a.n33,q=a.n34,E=a.n41,M=a.n42,O=a.n43,J=a.n44,K=b.n11,v=b.n12,g=b.n13,k=b.n14,f=b.n21,p=b.n22,j=b.n23,i=b.n24,u=b.n31,s=b.n32,G=b.n33,y=b.n34,H=b.n41,Q=b.n42,z=b.n43,P=b.n44;this.n11=d*K+e*f+h*u+n*H;this.n12=d*v+e*p+h*s+n*Q;this.n13=d*g+e*j+h*G+n*z;this.n14=d*k+e*i+h*y+n*P;this.n21=o*K+l*f+m*u+c*H;this.n22=o*v+l*p+m*s+c*Q;this.n23=o*g+l*j+m*G+c*z;this.n24=o*k+l*i+m*y+c*P;this.n31=A*K+x*f+r*u+q*H;this.n32=A*v+x*p+r*s+q*Q;this.n33=A*g+x*j+r*G+q*z;this.n34=A*k+x*i+r*y+q*P;this.n41=E*K+M*f+O*u+J*H;
-this.n42=E*v+M*p+O*s+J*Q;this.n43=E*g+M*j+O*G+J*z;this.n44=E*k+M*i+O*y+J*P;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,n=this.n21,o=this.n22,l=this.n23,m=this.n24,c=this.n31,A=this.n32,x=this.n33,r=this.n34,q=this.n41,E=this.n42,M=this.n43,O=this.n44,J=a.n11,K=a.n21,v=a.n31,g=a.n41,k=a.n12,f=a.n22,p=a.n32,j=a.n42,i=a.n13,u=a.n23,s=a.n33,G=a.n43,y=a.n14,H=a.n24,Q=a.n34;a=a.n44;this.n11=b*J+d*K+e*v+h*g;this.n12=b*k+d*f+e*p+h*j;this.n13=b*i+d*u+e*s+h*G;this.n14=
-b*y+d*H+e*Q+h*a;this.n21=n*J+o*K+l*v+m*g;this.n22=n*k+o*f+l*p+m*j;this.n23=n*i+o*u+l*s+m*G;this.n24=n*y+o*H+l*Q+m*a;this.n31=c*J+A*K+x*v+r*g;this.n32=c*k+A*f+x*p+r*j;this.n33=c*i+A*u+x*s+r*G;this.n34=c*y+A*H+x*Q+r*a;this.n41=q*J+E*K+M*v+O*g;this.n42=q*k+E*f+M*p+O*j;this.n43=q*i+E*u+M*s+O*G;this.n44=q*y+E*H+M*Q+O*a;return this},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;return this},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(b,d,e){var h=b[d];b[d]=b[e];
-b[e]=h}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(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};
-THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),n=1-e,o=a.x,l=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*l-h*m;d.n13=n*o*m+h*l;d.n21=n*o*l+h*m;d.n22=n*l*l+e;d.n23=n*l*m-h*o;d.n31=n*o*m-h*l;d.n32=n*l*m+h*o;d.n33=n*m*m+e;return d};
-THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
-a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
-a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
-a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],A=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*l;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*A;return a};
-THREE.Matrix4.makeFrustum=function(a,b,d,e,h,n){var o,l,m;o=new THREE.Matrix4;l=2*h/(b-a);m=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+h)/(n-h);h=-2*n*h/(n-h);o.n11=l;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=h;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,b,d,e,h,n){var o,l,m,c;o=new THREE.Matrix4;l=b-a;m=d-e;c=n-h;a=(b+a)/l;d=(d+e)/m;h=(n+h)/c;o.n11=2/l;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-h;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
-THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
-THREE.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,b,d,e,h,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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=[];this.geometryChunks={};this.hasTangents=false};
-THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,h,n,o,l=new THREE.Vector3,m=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){n=this.vertices[e];n.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];if(a&&n.vertexNormals.length){l.set(0,0,0);b=0;for(d=n.normal.length;b<d;b++)l.addSelf(n.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[n.a];d=this.vertices[n.b];o=this.vertices[n.c];l.sub(o.position,
-d.position);m.sub(b.position,d.position);l.crossSelf(m)}l.isZero()||l.normalize();n.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeTangents:function(){function a(y,H,Q,z){n=y.vertices[H].position;o=y.vertices[Q].position;
-l=y.vertices[z].position;m=h[0];c=h[1];A=h[2];x=o.x-n.x;r=l.x-n.x;q=o.y-n.y;E=l.y-n.y;M=o.z-n.z;O=l.z-n.z;J=c.u-m.u;K=A.u-m.u;v=c.v-m.v;g=A.v-m.v;k=1/(J*g-K*v);i.set((g*x-v*r)*k,(g*q-v*E)*k,(g*M-v*O)*k);u.set((J*r-K*x)*k,(J*E-K*q)*k,(J*O-K*M)*k);p[H].addSelf(i);p[Q].addSelf(i);p[z].addSelf(i);j[H].addSelf(u);j[Q].addSelf(u);j[z].addSelf(u)}var b,d,e,h,n,o,l,m,c,A,x,r,q,E,M,O,J,K,v,g,k,f,p=[],j=[],i=new THREE.Vector3,u=new THREE.Vector3,s=new THREE.Vector3,G=new THREE.Vector3;f=new THREE.Vector3;b=
-0;for(d=this.vertices.length;b<d;b++){p[b]=new THREE.Vector3;j[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];h=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
-this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){f.copy(this.vertices[b].normal);e=p[b];s.copy(e);s.subSelf(f.multiplyScalar(f.dot(e))).normalize();G.cross(this.vertices[b].normal,e);test=G.dot(j[b]);e=test<0?-1:1;this.vertices[b].tangent.set(s.x,s.y,s.z,e)}this.hasTangents=true},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}}},sortFacesByMaterial:function(){function a(A){var x=[];b=0;for(d=A.length;b<d;b++)A[b]==undefined?x.push("undefined"):x.push(A[b].toString());return x.join("_")}var b,d,e,h,n,o,l,m,c={};e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];o=n.material;l=a(o);if(c[l]==undefined)c[l]={hash:l,counter:0};m=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,
-vertices:0};n=n instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+n>65535){c[l].counter+=1;m=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
-this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(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(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
-this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
-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(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
-THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
-THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,h;a=0;for(b=this.geometry.uvs.length;a<b;a++){h=this.geometry.uvs[a];d=0;for(e=h.length;d<e;d++){if(h[d].u!=1)h[d].u-=Math.floor(h[d].u);if(h[d].v!=1)h[d].v-=Math.floor(h[d].v)}}};THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
-THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){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;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
-this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
-THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
-this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
-THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
-this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
-THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
-"round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
-a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
-a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
-this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
-THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;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.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
-THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
-THREE.MeshCubeMaterial=function(a){this.id=THREE.MeshCubeMaterial.value++;this.env_map=null;this.blending=THREE.NormalBlending;if(a)if(a.env_map!==undefined)this.env_map=a.env_map;this.toString=function(){return"THREE.MeshCubeMaterial( id: "+this.id+"<br/>env_map: "+this.env_map+" )"}};THREE.MeshCubeMaterialCounter={value:0};
-THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
-undefined)this.uniforms=a.uniforms;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
-"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
-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){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){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(a,b,d,e,h,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
-this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
-THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
-THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
-THREE.Projector=function(){function a(K,v){var g=0,k=1,f=K.z+K.w,p=v.z+v.w,j=-K.z+K.w,i=-v.z+v.w;if(f>=0&&p>=0&&j>=0&&i>=0)return true;else if(f<0&&p<0||j<0&&i<0)return false;else{if(f<0)g=Math.max(g,f/(f-p));else if(p<0)k=Math.min(k,f/(f-p));if(j<0)g=Math.max(g,j/(j-i));else if(i<0)k=Math.min(k,j/(j-i));if(k<g)return false;else{K.lerpSelf(v,g);v.lerpSelf(K,1-k);return true}}}var b=null,d,e,h,n=[],o,l,m=[],c,A,x=[],r=new THREE.Vector4,q=new THREE.Matrix4,E=new THREE.Matrix4,M=new THREE.Vector4,O=
-new THREE.Vector4,J;this.projectScene=function(K,v){var g,k,f,p,j,i,u,s,G,y,H,Q,z,P,D,R,S;b=[];h=l=A=0;v.autoUpdateMatrix&&v.updateMatrix();q.multiply(v.projectionMatrix,v.matrix);u=K.objects;g=0;for(k=u.length;g<k;g++){s=u[g];s.autoUpdateMatrix&&s.updateMatrix();G=s.matrix;y=s.rotationMatrix;H=s.material;Q=s.overdraw;if(s instanceof THREE.Mesh){z=s.geometry.vertices;f=0;for(p=z.length;f<p;f++){P=z[f];P.positionWorld.copy(P.position);G.multiplyVector3(P.positionWorld);D=P.positionScreen;D.copy(P.positionWorld);
-q.multiplyVector4(D);D.multiplyScalar(1/D.w);P.__visible=D.z>0&&D.z<1}P=s.geometry.faces;f=0;for(p=P.length;f<p;f++){D=P[f];if(D instanceof THREE.Face3){j=z[D.a];i=z[D.b];R=z[D.c];if(j.__visible&&i.__visible&&R.__visible)if(s.doubleSided||s.flipSided!=(R.positionScreen.x-j.positionScreen.x)*(i.positionScreen.y-j.positionScreen.y)-(R.positionScreen.y-j.positionScreen.y)*(i.positionScreen.x-j.positionScreen.x)<0){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(j.positionWorld);d.v2.positionWorld.copy(i.positionWorld);
-d.v3.positionWorld.copy(R.positionWorld);d.v1.positionScreen.copy(j.positionScreen);d.v2.positionScreen.copy(i.positionScreen);d.v3.positionScreen.copy(R.positionScreen);d.normalWorld.copy(D.normal);y.multiplyVector3(d.normalWorld);d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);q.multiplyVector3(d.centroidScreen);R=D.vertexNormals;J=d.vertexNormalsWorld;j=0;for(i=R.length;j<i;j++){S=J[j]=J[j]||new THREE.Vector3;S.copy(R[j]);y.multiplyVector3(S)}d.z=
-d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(s.geometry.uvs[f]){d.uvs[0]=s.geometry.uvs[f][0];d.uvs[1]=s.geometry.uvs[f][1];d.uvs[2]=s.geometry.uvs[f][2]}b.push(d);h++}}else if(D instanceof THREE.Face4){j=z[D.a];i=z[D.b];R=z[D.c];S=z[D.d];if(j.__visible&&i.__visible&&R.__visible&&S.__visible)if(s.doubleSided||s.flipSided!=((S.positionScreen.x-j.positionScreen.x)*(i.positionScreen.y-j.positionScreen.y)-(S.positionScreen.y-j.positionScreen.y)*(i.positionScreen.x-j.positionScreen.x)<
-0||(i.positionScreen.x-R.positionScreen.x)*(S.positionScreen.y-R.positionScreen.y)-(i.positionScreen.y-R.positionScreen.y)*(S.positionScreen.x-R.positionScreen.x)<0)){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(j.positionWorld);d.v2.positionWorld.copy(i.positionWorld);d.v3.positionWorld.copy(S.positionWorld);d.v1.positionScreen.copy(j.positionScreen);d.v2.positionScreen.copy(i.positionScreen);d.v3.positionScreen.copy(S.positionScreen);d.normalWorld.copy(D.normal);y.multiplyVector3(d.normalWorld);
-d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);q.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(s.geometry.uvs[f]){d.uvs[0]=s.geometry.uvs[f][0];d.uvs[1]=s.geometry.uvs[f][1];d.uvs[2]=s.geometry.uvs[f][3]}b.push(d);h++;e=n[h]=n[h]||new THREE.RenderableFace3;e.v1.positionWorld.copy(i.positionWorld);e.v2.positionWorld.copy(R.positionWorld);e.v3.positionWorld.copy(S.positionWorld);
-e.v1.positionScreen.copy(i.positionScreen);e.v2.positionScreen.copy(R.positionScreen);e.v3.positionScreen.copy(S.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=H;e.faceMaterial=D.material;e.overdraw=Q;if(s.geometry.uvs[f]){e.uvs[0]=s.geometry.uvs[f][1];e.uvs[1]=s.geometry.uvs[f][2];e.uvs[2]=s.geometry.uvs[f][3]}b.push(e);h++}}}}else if(s instanceof THREE.Line){E.multiply(q,G);z=s.geometry.vertices;
-P=z[0];P.positionScreen.copy(P.position);E.multiplyVector4(P.positionScreen);f=1;for(p=z.length;f<p;f++){j=z[f];j.positionScreen.copy(j.position);E.multiplyVector4(j.positionScreen);i=z[f-1];M.copy(j.positionScreen);O.copy(i.positionScreen);if(a(M,O)){M.multiplyScalar(1/M.w);O.multiplyScalar(1/O.w);o=m[l]=m[l]||new THREE.RenderableLine;o.v1.positionScreen.copy(M);o.v2.positionScreen.copy(O);o.z=Math.max(M.z,O.z);o.material=s.material;b.push(o);l++}}}else if(s instanceof THREE.Particle){r.set(s.position.x,
-s.position.y,s.position.z,1);q.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=x[A]=x[A]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(r.x+v.projectionMatrix.n11)/(r.w+v.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(r.y+v.projectionMatrix.n22)/(r.w+v.projectionMatrix.n24));c.material=s.material;b.push(c);A++}}}b.sort(function(I,B){return B.z-I.z});return b};this.unprojectVector=function(K,v){var g=new THREE.Matrix4;
-g.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));g.multiplyVector3(K);return K}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,n;this.domElement=document.createElement("div");this.setSize=function(o,l){d=o;e=l;h=d/2;n=e/2};this.render=function(o,l){var m,c,A,x,r,q,E,M;a=b.projectScene(o,l);m=0;for(c=a.length;m<c;m++){r=a[m];if(r instanceof THREE.RenderableParticle){E=r.x*h+h;M=r.y*n+n;A=0;for(x=r.material.length;A<x;A++){q=r.material[A];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=E+"px";q.style.top=M+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,h,n,o,l=d.getContext("2d"),m=1,c=0,A=null,x=null,r=1,q,E,M,O,J,K,v,g,k,f=new THREE.Color,p=new THREE.Color,j=new THREE.Color,i=new THREE.Color,u=new THREE.Color,s,G,y,H,Q,z,P,D,R,S,I=new THREE.Rectangle,B=new THREE.Rectangle,C=new THREE.Rectangle,W=false,Y=new THREE.Color,N=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,X=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
-na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=d;this.autoClear=true;this.setSize=function(ga,ua){e=ga;h=ua;n=e/2;o=h/2;d.width=e;d.height=h;I.set(-n,-o,n,o)};this.clear=function(){if(!B.isEmpty()){B.inflate(1);B.minSelf(I);l.clearRect(B.getX(),B.getY(),B.getWidth(),B.getHeight());
-B.empty()}};this.render=function(ga,ua){function Ka(t){var T,L,w,F=t.lights;N.setRGB(0,0,0);U.setRGB(0,0,0);aa.setRGB(0,0,0);t=0;for(T=F.length;t<T;t++){L=F[t];w=L.color;if(L instanceof THREE.AmbientLight){N.r+=w.r;N.g+=w.g;N.b+=w.b}else if(L instanceof THREE.DirectionalLight){U.r+=w.r;U.g+=w.g;U.b+=w.b}else if(L instanceof THREE.PointLight){aa.r+=w.r;aa.g+=w.g;aa.b+=w.b}}}function va(t,T,L,w){var F,V,$,ba,ca=t.lights;t=0;for(F=ca.length;t<F;t++){V=ca[t];$=V.color;ba=V.intensity;if(V instanceof THREE.DirectionalLight){V=
-L.dot(V.position)*ba;if(V>0){w.r+=$.r*V;w.g+=$.g*V;w.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,T);X.normalize();V=L.dot(X)*ba;if(V>0){w.r+=$.r*V;w.g+=$.g*V;w.b+=$.b*V}}}}function La(t,T,L){if(L.opacity!=0){Ba(L.opacity);wa(L.blending);var w,F,V,$,ba,ca;if(L instanceof THREE.ParticleBasicMaterial){if(L.map){$=L.map;ba=$.width>>1;ca=$.height>>1;F=T.scale.x*n;V=T.scale.y*o;L=F*ba;w=V*ca;C.set(t.x-L,t.y-w,t.x+L,t.y+w);if(I.instersects(C)){l.save();l.translate(t.x,t.y);l.rotate(-T.rotation);
-l.scale(F,-V);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}else if(L instanceof THREE.ParticleCircleMaterial){if(W){Y.r=N.r+U.r+aa.r;Y.g=N.g+U.g+aa.g;Y.b=N.b+U.b+aa.b;f.r=L.color.r*Y.r;f.g=L.color.g*Y.g;f.b=L.color.b*Y.b;f.updateStyleString()}else f.__styleString=L.color.__styleString;L=T.scale.x*n;w=T.scale.y*o;C.set(t.x-L,t.y-w,t.x+L,t.y+w);if(I.instersects(C)){F=f.__styleString;if(x!=F)l.fillStyle=x=F;l.save();l.translate(t.x,t.y);l.rotate(-T.rotation);l.scale(L,w);l.beginPath();l.arc(0,
-0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(t,T,L,w){if(w.opacity!=0){Ba(w.opacity);wa(w.blending);l.beginPath();l.moveTo(t.positionScreen.x,t.positionScreen.y);l.lineTo(T.positionScreen.x,T.positionScreen.y);l.closePath();if(w instanceof THREE.LineBasicMaterial){f.__styleString=w.color.__styleString;t=w.linewidth;if(r!=t)l.lineWidth=r=t;t=f.__styleString;if(A!=t)l.strokeStyle=A=t;l.stroke();C.inflate(w.linewidth*2)}}}function Fa(t,T,L,w,F,V){if(F.opacity!=0){Ba(F.opacity);wa(F.blending);
-O=t.positionScreen.x;J=t.positionScreen.y;K=T.positionScreen.x;v=T.positionScreen.y;g=L.positionScreen.x;k=L.positionScreen.y;l.beginPath();l.moveTo(O,J);l.lineTo(K,v);l.lineTo(g,k);l.lineTo(O,J);l.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(O,J,K,v,g,k,F.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){t=
-ua.matrix;X.copy(w.vertexNormalsWorld[0]);Q=(X.x*t.n11+X.y*t.n12+X.z*t.n13)*0.5+0.5;z=-(X.x*t.n21+X.y*t.n22+X.z*t.n23)*0.5+0.5;X.copy(w.vertexNormalsWorld[1]);P=(X.x*t.n11+X.y*t.n12+X.z*t.n13)*0.5+0.5;D=-(X.x*t.n21+X.y*t.n22+X.z*t.n23)*0.5+0.5;X.copy(w.vertexNormalsWorld[2]);R=(X.x*t.n11+X.y*t.n12+X.z*t.n13)*0.5+0.5;S=-(X.x*t.n21+X.y*t.n22+X.z*t.n23)*0.5+0.5;qa(O,J,K,v,g,k,F.env_map.image,Q,z,P,D,R,S)}}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString);else if(F instanceof
-THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(O,J,K,v,g,k,F.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);wa(THREE.SubtractiveBlending)}if(W)if(!F.wireframe&&F.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==3){p.r=j.r=i.r=N.r;p.g=j.g=i.g=N.g;p.b=j.b=i.b=N.b;va(V,w.v1.positionWorld,w.vertexNormalsWorld[0],p);va(V,w.v2.positionWorld,w.vertexNormalsWorld[1],j);va(V,w.v3.positionWorld,w.vertexNormalsWorld[2],
-i);u.r=(j.r+i.r)*0.5;u.g=(j.g+i.g)*0.5;u.b=(j.b+i.b)*0.5;H=Ga(p,j,i,u);qa(O,J,K,v,g,k,H,0,0,1,0,0,1)}else{Y.r=N.r;Y.g=N.g;Y.b=N.b;va(V,w.centroidWorld,w.normalWorld,Y);f.r=F.color.r*Y.r;f.g=F.color.g*Y.g;f.b=F.color.b*Y.b;f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){s=F.__2near;G=F.__farPlusNear;y=F.__farMinusNear;
-p.r=p.g=p.b=1-s/(G-t.positionScreen.z*y);j.r=j.g=j.b=1-s/(G-T.positionScreen.z*y);i.r=i.g=i.b=1-s/(G-L.positionScreen.z*y);u.r=(j.r+i.r)*0.5;u.g=(j.g+i.g)*0.5;u.b=(j.b+i.b)*0.5;H=Ga(p,j,i,u);qa(O,J,K,v,g,k,H,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){f.r=Ca(w.normalWorld.x);f.g=Ca(w.normalWorld.y);f.b=Ca(w.normalWorld.z);f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}}}function xa(t,T){if(A!=t)l.strokeStyle=A=t;if(r!=T)l.lineWidth=
-r=T;l.stroke();C.inflate(T*2)}function ya(t){if(x!=t)l.fillStyle=x=t;l.fill()}function qa(t,T,L,w,F,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;L-=t;w-=T;F-=t;V-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*L-ea*F)*ja;ea=(ra*w-ea*V)*ja;L=(ha*F-ia*L)*ja;w=(ha*V-ia*w)*ja;t=t-ka*ba-L*ca;T=T-ea*ba-w*ca;l.save();l.transform(ka,ea,L,w,t,T);l.clip();l.drawImage($,0,0);l.restore()}function Ba(t){if(m!=t)l.globalAlpha=m=t}function wa(t){if(c!=
-t){switch(t){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=t}}function Ga(t,T,L,w){var F=~~(t.r*255),V=~~(t.g*255);t=~~(t.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*255);var ca=~~(L.r*255),ha=~~(L.g*255);L=~~(L.b*255);var ea=~~(w.r*255),ia=~~(w.g*255);w=~~(w.b*255);da[0]=F<0?0:F>255?255:F;da[1]=V<0?0:V>255?255:V;da[2]=t<0?0:t>
-255?255:t;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=L<0?0:L>255?255:L;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=w<0?0:w>255?255:w;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Da(t,T){var L=T.x-t.x,w=T.y-t.y,F=1/Math.sqrt(L*L+w*w);L*=F;w*=F;T.x+=L;T.y+=w;t.x-=L;t.y-=w}var za,Ha,Z,fa,ma,Ea,Ia,sa;l.setTransform(1,0,0,-1,
-n,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua);(W=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];C.empty();if(Z instanceof THREE.RenderableParticle){q=Z;q.x*=n;q.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(q,Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){q=Z.v1;E=Z.v2;q.positionScreen.x*=n;q.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;C.addPoint(q.positionScreen.x,q.positionScreen.y);C.addPoint(E.positionScreen.x,E.positionScreen.y);
-if(I.instersects(C)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(q,E,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){q=Z.v1;E=Z.v2;M=Z.v3;q.positionScreen.x*=n;q.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;M.positionScreen.x*=n;M.positionScreen.y*=o;if(Z.overdraw){Da(q.positionScreen,E.positionScreen);Da(E.positionScreen,M.positionScreen);Da(M.positionScreen,q.positionScreen)}C.add3Points(q.positionScreen.x,q.positionScreen.y,E.positionScreen.x,E.positionScreen.y,
-M.positionScreen.x,M.positionScreen.y);if(I.instersects(C)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(q,E,M,Z,sa,ga)}else Fa(q,E,M,Z,sa,ga)}}}B.addRectangle(C)}l.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(D,R,S){var I,B,C,W;I=0;for(B=D.lights.length;I<B;I++){C=D.lights[I];if(C instanceof THREE.DirectionalLight){W=R.normalWorld.dot(C.position)*C.intensity;if(W>0){S.r+=C.color.r*W;S.g+=C.color.g*W;S.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){i.sub(C.position,R.centroidWorld);i.normalize();W=R.normalWorld.dot(i)*C.intensity;if(W>0){S.r+=C.color.r*W;S.g+=C.color.g*W;S.b+=C.color.b*W}}}}function b(D,R,S,I,B,C){y=e(H++);y.setAttribute("d","M "+D.positionScreen.x+
-" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(K){g.r=k.r;g.g=k.g;g.b=k.b;a(C,I,g);v.r=B.color.r*g.r;v.g=B.color.g*g.g;v.b=B.color.b*g.b;v.updateStyleString()}else v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=1-B.__2near/(B.__farPlusNear-I.z*B.__farMinusNear);
-v.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&v.setRGB(h(I.normalWorld.x),h(I.normalWorld.y),h(I.normalWorld.z));B.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+B.opacity);l.appendChild(y)}function d(D,R,S,I,B,C,W){y=e(H++);y.setAttribute("d",
-"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)v.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(K){g.r=k.r;g.g=k.g;g.b=k.b;a(W,B,g);v.r=C.color.r*g.r;v.g=C.color.g*g.g;v.b=C.color.b*g.b;v.updateStyleString()}else v.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){j=
-1-C.__2near/(C.__farPlusNear-B.z*C.__farMinusNear);v.setRGB(j,j,j)}else C instanceof THREE.MeshNormalMaterial&&v.setRGB(h(B.normalWorld.x),h(B.normalWorld.y),h(B.normalWorld.z));C.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+C.opacity);l.appendChild(y)}
-function e(D){if(u[D]==null){u[D]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&u[D].setAttribute("shape-rendering","crispEdges");return u[D]}return u[D]}function h(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var n=null,o=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,A,x,r,q,E,M,O=new THREE.Rectangle,J=new THREE.Rectangle,K=false,v=new THREE.Color(16777215),g=new THREE.Color(16777215),k=new THREE.Color(0),f=new THREE.Color(0),
-p=new THREE.Color(0),j,i=new THREE.Vector3,u=[],s=[],G=[],y,H,Q,z,P=1;this.domElement=l;this.autoClear=true;this.setQuality=function(D){switch(D){case "high":P=1;break;case "low":P=0}};this.setSize=function(D,R){m=D;c=R;A=m/2;x=c/2;l.setAttribute("viewBox",-A+" "+-x+" "+m+" "+c);l.setAttribute("width",m);l.setAttribute("height",c);O.set(-A,-x,A,x)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(D,R){var S,I,B,C,W,Y,N,U;this.autoClear&&this.clear();
-n=o.projectScene(D,R);z=Q=H=0;if(K=D.lights.length>0){N=D.lights;k.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);S=0;for(I=N.length;S<I;S++){B=N[S];C=B.color;if(B instanceof THREE.AmbientLight){k.r+=C.r;k.g+=C.g;k.b+=C.b}else if(B instanceof THREE.DirectionalLight){f.r+=C.r;f.g+=C.g;f.b+=C.b}else if(B instanceof THREE.PointLight){p.r+=C.r;p.g+=C.g;p.b+=C.b}}}S=0;for(I=n.length;S<I;S++){N=n[S];J.empty();if(N instanceof THREE.RenderableParticle){r=N;r.x*=A;r.y*=-x;B=0;for(C=N.material.length;B<C;B++)if(U=
-N.material[B]){W=r;Y=N;U=U;var aa=Q++;if(s[aa]==null){s[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");P==0&&s[aa].setAttribute("shape-rendering","crispEdges")}y=s[aa];y.setAttribute("cx",W.x);y.setAttribute("cy",W.y);y.setAttribute("r",Y.scale.x*A);if(U instanceof THREE.ParticleCircleMaterial){if(K){g.r=k.r+f.r+p.r;g.g=k.g+f.g+p.g;g.b=k.b+f.b+p.b;v.r=U.color.r*g.r;v.g=U.color.g*g.g;v.b=U.color.b*g.b;v.updateStyleString()}else v=U.color;y.setAttribute("style","fill: "+v.__styleString)}l.appendChild(y)}}else if(N instanceof
-THREE.RenderableLine){r=N.v1;q=N.v2;r.positionScreen.x*=A;r.positionScreen.y*=-x;q.positionScreen.x*=A;q.positionScreen.y*=-x;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(q.positionScreen.x,q.positionScreen.y);if(O.instersects(J)){B=0;for(C=N.material.length;B<C;)if(U=N.material[B++]){W=r;Y=q;U=U;aa=z++;if(G[aa]==null){G[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");P==0&&G[aa].setAttribute("shape-rendering","crispEdges")}y=G[aa];y.setAttribute("x1",W.positionScreen.x);
-y.setAttribute("y1",W.positionScreen.y);y.setAttribute("x2",Y.positionScreen.x);y.setAttribute("y2",Y.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){v.__styleString=U.color.__styleString;y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);l.appendChild(y)}}}}else if(N instanceof THREE.RenderableFace3){r=N.v1;q=N.v2;E=N.v3;r.positionScreen.x*=A;r.positionScreen.y*=
--x;q.positionScreen.x*=A;q.positionScreen.y*=-x;E.positionScreen.x*=A;E.positionScreen.y*=-x;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(q.positionScreen.x,q.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);if(O.instersects(J)){B=0;for(C=N.meshMaterial.length;B<C;){U=N.meshMaterial[B++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&b(r,q,E,N,U,D)}else U&&b(r,q,E,N,U,D)}}}else if(N instanceof THREE.RenderableFace4){r=
-N.v1;q=N.v2;E=N.v3;M=N.v4;r.positionScreen.x*=A;r.positionScreen.y*=-x;q.positionScreen.x*=A;q.positionScreen.y*=-x;E.positionScreen.x*=A;E.positionScreen.y*=-x;M.positionScreen.x*=A;M.positionScreen.y*=-x;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(q.positionScreen.x,q.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);J.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(J)){B=0;for(C=N.meshMaterial.length;B<C;){U=N.meshMaterial[B++];if(U instanceof
-THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&d(r,q,E,M,N,U,D)}else U&&d(r,q,E,M,N,U,D)}}}}}};
-THREE.WebGLRenderer=function(a){function b(g,k){var f=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
-g));c.attachShader(f,o("vertex",p+k));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function d(g,k){if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
-c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_CUBE_MAP,
-g.image.__webGLTextureCube)}}function e(g,k){if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,g.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,l(g.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,l(g.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,l(g.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,l(g.min_filter));c.generateMipmap(c.TEXTURE_2D);
-c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_2D,g.__webGLTexture)}function h(g,k){var f,p,j;f=0;for(p=k.length;f<p;f++){j=k[f];g.uniforms[j]=c.getUniformLocation(g,j)}}function n(g,k){var f,p,j;f=0;for(p=k.length;f<p;f++){j=k[f];g.attributes[j]=c.getAttribLocation(g,j);g.attributes[j]>=0&&c.enableVertexAttribArray(g.attributes[j])}}function o(g,k){var f;if(g=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")f=c.createShader(c.VERTEX_SHADER);
-c.shaderSource(f,k);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function l(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
-case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var m=document.createElement("canvas"),c,A,x,r=new THREE.Matrix4,q,E=new Float32Array(16),M=new Float32Array(16),O=new Float32Array(16),J=new Float32Array(9),K=new Float32Array(16);a=function(g,k){if(g){var f,p,j,i=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=g.lights.length;f<p;f++){j=g.lights[f];j instanceof THREE.DirectionalLight&&i++;j instanceof
-THREE.PointLight&&pointLights++}if(pointLights+i<=k){maxDirLights=i;maxPointLights=pointLights}else{maxDirLights=Math.ceil(k*i/(pointLights+i));maxPointLights=k-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:k-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(v){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
-c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);A=x=function(g,k){var f=[g?"#define MAX_DIR_LIGHTS "+g:"",k?"#define MAX_POINT_LIGHTS "+k:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",g?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
-"",k?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",k?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",k?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
-g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",g?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",g?"}":"",k?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",k?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",k?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
-"",k?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",k?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",k?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
-p=[g?"#define MAX_DIR_LIGHTS "+g:"",k?"#define MAX_POINT_LIGHTS "+k:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
-g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",k?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
-k?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",k?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",k?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",k?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",k?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",k?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",k?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",k?"float pointSpecularWeight = 0.0;":"",k?"if ( pointDotNormalHalf >= 0.0 )":
-"",k?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",k?"pointDiffuse  += mColor * pointDiffuseWeight;":"",k?"pointSpecular += mSpecular * pointSpecularWeight;":"",k?"}":"",g?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"vec3 dirVector = normalize( lDirection.xyz );":"",g?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
-"",g?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",g?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",g?"float dirSpecularWeight = 0.0;":"",g?"if ( dirDotNormalHalf >= 0.0 )":"",g?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",g?"dirDiffuse  += mColor * dirDiffuseWeight;":"",g?"dirSpecular += mSpecular * dirSpecularWeight;":"",g?"}":"","vec4 totalLight = mAmbient;",g?"totalLight += dirDiffuse + dirSpecular;":"",k?"totalLight += pointDiffuse + pointSpecular;":
-"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
-f=b(p,f);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);g&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&h(f,["pointLightNumber","pointLightColor",
-"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);n(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(g,k){m.width=g;m.height=k;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(g,k){var f,p,j,i,u,s=[],
-G=[],y=[];i=[];u=[];c.uniform1i(g.uniforms.enableLighting,k.length);f=0;for(p=k.length;f<p;f++){j=k[f];if(j instanceof THREE.AmbientLight)s.push(j);else if(j instanceof THREE.DirectionalLight)y.push(j);else j instanceof THREE.PointLight&&G.push(j)}f=j=i=u=0;for(p=s.length;f<p;f++){j+=s[f].color.r;i+=s[f].color.g;u+=s[f].color.b}c.uniform3f(g.uniforms.ambientLightColor,j,i,u);i=[];u=[];f=0;for(p=y.length;f<p;f++){j=y[f];i.push(j.color.r*j.intensity);i.push(j.color.g*j.intensity);i.push(j.color.b*j.intensity);
-u.push(j.position.x);u.push(j.position.y);u.push(j.position.z)}if(y.length){c.uniform1i(g.uniforms.directionalLightNumber,y.length);c.uniform3fv(g.uniforms.directionalLightDirection,u);c.uniform3fv(g.uniforms.directionalLightColor,i)}i=[];u=[];f=0;for(p=G.length;f<p;f++){j=G[f];i.push(j.color.r*j.intensity);i.push(j.color.g*j.intensity);i.push(j.color.b*j.intensity);u.push(j.position.x);u.push(j.position.y);u.push(j.position.z)}if(G.length){c.uniform1i(g.uniforms.pointLightNumber,G.length);c.uniform3fv(g.uniforms.pointLightPosition,
-u);c.uniform3fv(g.uniforms.pointLightColor,i)}};this.createBuffers=function(g,k){var f,p,j,i,u,s,G,y,H,Q=[],z=[],P=[],D=[],R=[],S=[],I=0,B=g.geometry.geometryChunks[k],C;j=false;f=0;for(p=g.material.length;f<p;f++){meshMaterial=g.material[f];if(meshMaterial instanceof THREE.MeshFaceMaterial){u=0;for(C=B.material.length;u<C;u++)if(B.material[u]&&B.material[u].shading!=undefined&&B.material[u].shading==THREE.SmoothShading){j=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
-THREE.SmoothShading){j=true;break}if(j)break}C=j;f=0;for(p=B.faces.length;f<p;f++){j=B.faces[f];i=g.geometry.faces[j];u=i.vertexNormals;faceNormal=i.normal;j=g.geometry.uvs[j];if(i instanceof THREE.Face3){s=g.geometry.vertices[i.a].position;G=g.geometry.vertices[i.b].position;y=g.geometry.vertices[i.c].position;P.push(s.x,s.y,s.z);P.push(G.x,G.y,G.z);P.push(y.x,y.y,y.z);if(g.geometry.hasTangents){s=g.geometry.vertices[i.a].tangent;G=g.geometry.vertices[i.b].tangent;y=g.geometry.vertices[i.c].tangent;
-R.push(s.x,s.y,s.z,s.w);R.push(G.x,G.y,G.z,G.w);R.push(y.x,y.y,y.z,y.w)}if(u.length==3&&C)for(i=0;i<3;i++)D.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<3;i++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(i=0;i<3;i++)S.push(j[i].u,j[i].v);Q.push(I,I+1,I+2);z.push(I,I+1);z.push(I,I+2);z.push(I+1,I+2);I+=3}else if(i instanceof THREE.Face4){s=g.geometry.vertices[i.a].position;G=g.geometry.vertices[i.b].position;y=g.geometry.vertices[i.c].position;H=g.geometry.vertices[i.d].position;P.push(s.x,
-s.y,s.z);P.push(G.x,G.y,G.z);P.push(y.x,y.y,y.z);P.push(H.x,H.y,H.z);if(g.geometry.hasTangents){s=g.geometry.vertices[i.a].tangent;G=g.geometry.vertices[i.b].tangent;y=g.geometry.vertices[i.c].tangent;i=g.geometry.vertices[i.d].tangent;R.push(s.x,s.y,s.z,s.w);R.push(G.x,G.y,G.z,G.w);R.push(y.x,y.y,y.z,y.w);R.push(i.x,i.y,i.z,i.w)}if(u.length==4&&C)for(i=0;i<4;i++)D.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<4;i++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(i=0;i<4;i++)S.push(j[i].u,j[i].v);
-Q.push(I,I+1,I+2);Q.push(I,I+2,I+3);z.push(I,I+1);z.push(I,I+2);z.push(I,I+3);z.push(I+1,I+2);z.push(I+2,I+3);I+=4}}if(P.length){B.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,B.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);B.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,B.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);if(g.geometry.hasTangents){B.__webGLTangentBuffer=c.createBuffer();
-c.bindBuffer(c.ARRAY_BUFFER,B.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}if(S.length>0){B.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,B.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW)}B.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,B.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);B.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-B.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(z),c.STATIC_DRAW);B.__webGLFaceCount=Q.length;B.__webGLLineCount=z.length}};this.renderBuffer=function(g,k,f,p){var j,i,u,s,G,y,H,Q,z;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(z in f.uniforms)H.push(z);h(f.program,H);n(f.program,["position","normal","uv","tangent"])}z=
-f.program}else z=x;if(z!=A){c.useProgram(z);A=z}z==x&&this.setupLights(z,k);this.loadCamera(z,g);this.loadMatrices(z);if(f instanceof THREE.MeshShaderMaterial){u=f.wireframe;s=f.wireframe_linewidth;g=z;k=f.uniforms;var P;for(j in k){Q=k[j].type;H=k[j].value;P=g.uniforms[j];if(Q=="i")c.uniform1i(P,H);else if(Q=="f")c.uniform1f(P,H);else if(Q=="v3")c.uniform3f(P,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(P,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(P,H);if(Q=k[j].texture)Q.image instanceof Array&&Q.image.length==
-6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;i=f.opacity;u=f.wireframe;s=f.wireframe_linewidth;G=f.map;y=f.env_map;k=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(z.uniforms.mColor,j.r*i,j.g*i,j.b*i,i);c.uniform1i(z.uniforms.mixEnvMap,k);c.uniform1f(z.uniforms.mReflectivity,g);c.uniform1i(z.uniforms.useRefract,
-Q);c.uniform1f(z.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(z.uniforms.mOpacity,i);c.uniform1i(z.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;u=f.wireframe;s=f.wireframe_linewidth;c.uniform1f(z.uniforms.mOpacity,i);c.uniform1f(z.uniforms.m2Near,f.__2near);c.uniform1f(z.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(z.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(z.uniforms.material,3)}else if(f instanceof
-THREE.MeshPhongMaterial){j=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(z.uniforms.mAmbient,j.r,j.g,j.b,i);c.uniform4f(z.uniforms.mSpecular,g.r,g.g,g.b,i);c.uniform1f(z.uniforms.mShininess,f);c.uniform1i(z.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(z.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(z.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(z.uniforms.material,5);y=f.env_map}if(G){e(G,0);c.uniform1i(z.uniforms.tMap,
-0);c.uniform1i(z.uniforms.enableMap,1)}else c.uniform1i(z.uniforms.enableMap,0);if(y){d(y,1);c.uniform1i(z.uniforms.tCube,1);c.uniform1i(z.uniforms.enableCubeMap,1)}else c.uniform1i(z.uniforms.enableCubeMap,0);i=z.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
-c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(u){c.lineWidth(s);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
-0)}};this.renderPass=function(g,k,f,p,j,i){var u,s,G,y,H;G=0;for(y=f.material.length;G<y;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(s=p.material.length;u<s;u++)if((H=p.material[u])&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,k,H,p)}}else if((H=u)&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,k,H,p)}}};this.render=function(g,k){var f,p,j,i,u=g.lights;this.initWebGLObjects(g);this.autoClear&&this.clear();
-k.autoUpdateMatrix&&k.updateMatrix();f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,k);this.renderPass(k,u,i,j,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,k);this.renderPass(k,u,i,j,THREE.AdditiveBlending,false);this.renderPass(k,u,i,j,THREE.SubtractiveBlending,false);this.renderPass(k,u,i,j,THREE.AdditiveBlending,true);
-this.renderPass(k,u,i,j,THREE.SubtractiveBlending,true);this.renderPass(k,u,i,j,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(g){var k,f,p,j,i,u;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}k=0;for(f=g.objects.length;k<f;k++){p=g.objects[k];if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};u=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(i in p.geometry.geometryChunks){j=p.geometry.geometryChunks[i];j.__webGLVertexBuffer||this.createBuffers(p,
-i);if(u[i]==undefined){j={buffer:j,object:p};g.__webGLObjects.push(j);u[i]=1}}}};this.removeObject=function(g,k){var f,p;for(f=g.__webGLObjects.length-1;f>=0;f--){p=g.__webGLObjects[f].object;k==p&&g.__webGLObjects.splice(f,1)}};this.setupMatrices=function(g,k){g.autoUpdateMatrix&&g.updateMatrix();r.multiply(k.matrix,g.matrix);E.set(k.matrix.flatten());M.set(r.flatten());O.set(k.projectionMatrix.flatten());q=THREE.Matrix4.makeInvert3x3(r).transpose();J.set(q.m);K.set(g.matrix.flatten())};this.loadMatrices=
-function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,E);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,O);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,k){c.uniform3f(g.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);
-break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,k){if(g){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.RenderableFace3=function(){this.z=null;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.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
-THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
+// Three.js r31 - http://github.com/mrdoob/three.js
+var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
+THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
+","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", 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(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
+THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
+cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;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){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+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(){var a=
+Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},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,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
+THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
+return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(n,o){return n.distance-o.distance});return h},intersectObject:function(a){function b(P,J,K,v){v=v.clone().subSelf(J);K=K.clone().subSelf(J);var g=P.clone().subSelf(J);P=v.dot(v);J=v.dot(K);v=v.dot(g);var k=K.dot(K);K=K.dot(g);g=1/(P*k-J*J);k=(k*v-J*K)*g;P=(P*K-J*v)*g;return k>0&&P>0&&k+P<1}var d,e,h,n,o,l,m,c,z,x,
+q,r=a.geometry,E=r.vertices,L=[];d=0;for(e=r.faces.length;d<e;d++){h=r.faces[d];x=this.origin.clone();q=this.direction.clone();n=a.matrix.multiplyVector3(E[h.a].position.clone());o=a.matrix.multiplyVector3(E[h.b].position.clone());l=a.matrix.multiplyVector3(E[h.c].position.clone());m=h instanceof THREE.Face4?a.matrix.multiplyVector3(E[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());z=q.dot(c);if(z<0){c=c.dot((new THREE.Vector3).sub(n,x))/z;x=x.addSelf(q.multiplyScalar(c));
+if(h instanceof THREE.Face3){if(b(x,n,o,l)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};L.push(h)}}else if(h instanceof THREE.Face4)if(b(x,n,o,m)||b(x,o,l,m)){h={distance:this.origin.distanceTo(x),point:x,face:h,object:a};L.push(h)}}}return L}};
+THREE.Rectangle=function(){function a(){n=e-b;o=h-d}var b,d,e,h,n,o,l=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return n};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(m,c,z,x){l=false;b=m;d=c;e=z;h=x;a()};this.addPoint=function(m,c){if(l){l=false;b=m;d=c;e=m;h=c}else{b=b<m?b:m;d=d<c?d:c;e=e>m?e:m;h=h>c?
+h:c}a()};this.add3Points=function(m,c,z,x,q,r){if(l){l=false;b=m<z?m<q?m:q:z<q?z:q;d=c<x?c<r?c:r:x<r?x:r;e=m>z?m>q?m:q:z>q?z:q;h=c>x?c>r?c:r:x>r?x:r}else{b=m<z?m<q?m<b?m:b:q<b?q:b:z<q?z<b?z:b:q<b?q:b;d=c<x?c<r?c<d?c:d:r<d?r:d:x<r?x<d?x:d:r<d?r:d;e=m>z?m>q?m>e?m:e:q>e?q:e:z>q?z>e?z:e:q>e?q:e;h=c>x?c>r?c>h?c:h:r>h?r:h:x>r?x>h?x:h:r>h?r:h}a()};this.addRectangle=function(m){if(l){l=false;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=b<m.getLeft()?b:m.getLeft();d=d<m.getTop()?d:m.getTop();
+e=e>m.getRight()?e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e<m.getRight()?e:m.getRight();h=h<m.getBottom()?h:m.getBottom();a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){l=true;h=e=d=b=0;a()};this.isEmpty=function(){return l};this.toString=
+function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+n+", height: "+o+" )"}};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(a,b,d,e,h,n,o,l,m,c,z,x,q,r,E,L){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=n||1;this.n23=o||0;this.n24=l||0;this.n31=m||0;this.n32=c||0;this.n33=z||1;this.n34=x||0;this.n41=q||0;this.n42=r||0;this.n43=E||0;this.n44=L||1};
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,h,n,o,l,m,c,z,x,q,r,E,L){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=n;this.n23=o;this.n24=l;this.n31=m;this.n32=c;this.n33=z;this.n34=x;this.n41=q;this.n42=r;this.n43=E;this.n44=L;return this},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;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();h.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x;
+this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
+h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,n=a.n14,o=a.n21,l=a.n22,m=a.n23,c=a.n24,z=a.n31,x=a.n32,
+q=a.n33,r=a.n34,E=a.n41,L=a.n42,P=a.n43,J=a.n44,K=b.n11,v=b.n12,g=b.n13,k=b.n14,f=b.n21,p=b.n22,i=b.n23,j=b.n24,u=b.n31,s=b.n32,G=b.n33,y=b.n34,H=b.n41,Q=b.n42,C=b.n43,O=b.n44;this.n11=d*K+e*f+h*u+n*H;this.n12=d*v+e*p+h*s+n*Q;this.n13=d*g+e*i+h*G+n*C;this.n14=d*k+e*j+h*y+n*O;this.n21=o*K+l*f+m*u+c*H;this.n22=o*v+l*p+m*s+c*Q;this.n23=o*g+l*i+m*G+c*C;this.n24=o*k+l*j+m*y+c*O;this.n31=z*K+x*f+q*u+r*H;this.n32=z*v+x*p+q*s+r*Q;this.n33=z*g+x*i+q*G+r*C;this.n34=z*k+x*j+q*y+r*O;this.n41=E*K+L*f+P*u+J*H;
+this.n42=E*v+L*p+P*s+J*Q;this.n43=E*g+L*i+P*G+J*C;this.n44=E*k+L*j+P*y+J*O;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,n=this.n21,o=this.n22,l=this.n23,m=this.n24,c=this.n31,z=this.n32,x=this.n33,q=this.n34,r=this.n41,E=this.n42,L=this.n43,P=this.n44,J=a.n11,K=a.n21,v=a.n31,g=a.n41,k=a.n12,f=a.n22,p=a.n32,i=a.n42,j=a.n13,u=a.n23,s=a.n33,G=a.n43,y=a.n14,H=a.n24,Q=a.n34;a=a.n44;this.n11=b*J+d*K+e*v+h*g;this.n12=b*k+d*f+e*p+h*i;this.n13=b*j+d*u+e*s+h*G;this.n14=
+b*y+d*H+e*Q+h*a;this.n21=n*J+o*K+l*v+m*g;this.n22=n*k+o*f+l*p+m*i;this.n23=n*j+o*u+l*s+m*G;this.n24=n*y+o*H+l*Q+m*a;this.n31=c*J+z*K+x*v+q*g;this.n32=c*k+z*f+x*p+q*i;this.n33=c*j+z*u+x*s+q*G;this.n34=c*y+z*H+x*Q+q*a;this.n41=r*J+E*K+L*v+P*g;this.n42=r*k+E*f+L*p+P*i;this.n43=r*j+E*u+L*s+P*G;this.n44=r*y+E*H+L*Q+P*a;return this},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;return this},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(b,d,e){var h=b[d];b[d]=b[e];
+b[e]=h}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(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};
+THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),n=1-e,o=a.x,l=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*l-h*m;d.n13=n*o*m+h*l;d.n21=n*o*l+h*m;d.n22=n*l*l+e;d.n23=n*l*m-h*o;d.n31=n*o*m-h*l;d.n32=n*l*m+h*o;d.n33=n*m*m+e;return d};
+THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
+a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
+a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
+a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*l;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*z;return a};
+THREE.Matrix4.makeFrustum=function(a,b,d,e,h,n){var o,l,m;o=new THREE.Matrix4;l=2*h/(b-a);m=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+h)/(n-h);h=-2*n*h/(n-h);o.n11=l;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=h;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)};
+THREE.Matrix4.makeOrtho=function(a,b,d,e,h,n){var o,l,m,c;o=new THREE.Matrix4;l=b-a;m=d-e;c=n-h;a=(b+a)/l;d=(d+e)/m;h=(n+h)/c;o.n11=2/l;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-h;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
+THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
+THREE.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,b,d,e,h,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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=[];this.geometryChunks={};this.hasTangents=false};
+THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,h,n,o,l=new THREE.Vector3,m=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){n=this.vertices[e];n.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];if(a&&n.vertexNormals.length){l.set(0,0,0);b=0;for(d=n.normal.length;b<d;b++)l.addSelf(n.vertexNormals[b]);l.divideScalar(3)}else{b=this.vertices[n.a];d=this.vertices[n.b];o=this.vertices[n.c];l.sub(o.position,
+d.position);m.sub(b.position,d.position);l.crossSelf(m)}l.isZero()||l.normalize();n.normal.copy(l)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeTangents:function(){function a(y,H,Q,C){n=y.vertices[H].position;o=y.vertices[Q].position;
+l=y.vertices[C].position;m=h[0];c=h[1];z=h[2];x=o.x-n.x;q=l.x-n.x;r=o.y-n.y;E=l.y-n.y;L=o.z-n.z;P=l.z-n.z;J=c.u-m.u;K=z.u-m.u;v=c.v-m.v;g=z.v-m.v;k=1/(J*g-K*v);j.set((g*x-v*q)*k,(g*r-v*E)*k,(g*L-v*P)*k);u.set((J*q-K*x)*k,(J*E-K*r)*k,(J*P-K*L)*k);p[H].addSelf(j);p[Q].addSelf(j);p[C].addSelf(j);i[H].addSelf(u);i[Q].addSelf(u);i[C].addSelf(u)}var b,d,e,h,n,o,l,m,c,z,x,q,r,E,L,P,J,K,v,g,k,f,p=[],i=[],j=new THREE.Vector3,u=new THREE.Vector3,s=new THREE.Vector3,G=new THREE.Vector3;f=new THREE.Vector3;b=
+0;for(d=this.vertices.length;b<d;b++){p[b]=new THREE.Vector3;i[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];h=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
+this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){f.copy(this.vertices[b].normal);e=p[b];s.copy(e);s.subSelf(f.multiplyScalar(f.dot(e))).normalize();G.cross(this.vertices[b].normal,e);test=G.dot(i[b]);e=test<0?-1:1;this.vertices[b].tangent.set(s.x,s.y,s.z,e)}this.hasTangents=true},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}}},sortFacesByMaterial:function(){function a(z){var x=[];b=0;for(d=z.length;b<d;b++)z[b]==undefined?x.push("undefined"):x.push(z[b].toString());return x.join("_")}var b,d,e,h,n,o,l,m,c={};e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];o=n.material;l=a(o);if(c[l]==undefined)c[l]={hash:l,counter:0};m=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,
+vertices:0};n=n instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+n>65535){c[l].counter+=1;m=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
+THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
+this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(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(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
+THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
+this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
+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(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
+THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
+THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,h;a=0;for(b=this.geometry.uvs.length;a<b;a++){h=this.geometry.uvs[a];d=0;for(e=h.length;d<e;d++){if(h[d].u!=1)h[d].u-=Math.floor(h[d].u);if(h[d].v!=1)h[d].v-=Math.floor(h[d].v)}}};THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
+THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){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;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
+THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
+THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
+THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
+"round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
+a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
+a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
+THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;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.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
+THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
+THREE.MeshCubeMaterial=function(a){this.id=THREE.MeshCubeMaterial.value++;this.env_map=null;this.blending=THREE.NormalBlending;if(a)if(a.env_map!==undefined)this.env_map=a.env_map;this.toString=function(){return"THREE.MeshCubeMaterial( id: "+this.id+"<br/>env_map: "+this.env_map+" )"}};THREE.MeshCubeMaterialCounter={value:0};
+THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
+undefined)this.uniforms=a.uniforms;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
+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){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){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(a,b,d,e,h,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
+THREE.Projector=function(){function a(K,v){var g=0,k=1,f=K.z+K.w,p=v.z+v.w,i=-K.z+K.w,j=-v.z+v.w;if(f>=0&&p>=0&&i>=0&&j>=0)return true;else if(f<0&&p<0||i<0&&j<0)return false;else{if(f<0)g=Math.max(g,f/(f-p));else if(p<0)k=Math.min(k,f/(f-p));if(i<0)g=Math.max(g,i/(i-j));else if(j<0)k=Math.min(k,i/(i-j));if(k<g)return false;else{K.lerpSelf(v,g);v.lerpSelf(K,1-k);return true}}}var b=null,d,e,h,n=[],o,l,m=[],c,z,x=[],q=new THREE.Vector4,r=new THREE.Matrix4,E=new THREE.Matrix4,L=new THREE.Vector4,P=
+new THREE.Vector4,J;this.projectScene=function(K,v){var g,k,f,p,i,j,u,s,G,y,H,Q,C,O,D,R,S;b=[];h=l=z=0;v.autoUpdateMatrix&&v.updateMatrix();r.multiply(v.projectionMatrix,v.matrix);u=K.objects;g=0;for(k=u.length;g<k;g++){s=u[g];s.autoUpdateMatrix&&s.updateMatrix();G=s.matrix;y=s.rotationMatrix;H=s.material;Q=s.overdraw;if(s instanceof THREE.Mesh){C=s.geometry;O=C.vertices;f=0;for(p=O.length;f<p;f++){D=O[f];D.positionWorld.copy(D.position);G.multiplyVector3(D.positionWorld);i=D.positionScreen;i.copy(D.positionWorld);
+r.multiplyVector4(i);i.multiplyScalar(1/i.w);D.__visible=i.z>0&&i.z<1}C=C.faces;f=0;for(p=C.length;f<p;f++){D=C[f];if(D instanceof THREE.Face3){i=O[D.a];j=O[D.b];R=O[D.c];if(i.__visible&&j.__visible&&R.__visible)if(s.doubleSided||s.flipSided!=(R.positionScreen.x-i.positionScreen.x)*(j.positionScreen.y-i.positionScreen.y)-(R.positionScreen.y-i.positionScreen.y)*(j.positionScreen.x-i.positionScreen.x)<0){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(i.positionWorld);d.v2.positionWorld.copy(j.positionWorld);
+d.v3.positionWorld.copy(R.positionWorld);d.v1.positionScreen.copy(i.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(R.positionScreen);d.normalWorld.copy(D.normal);y.multiplyVector3(d.normalWorld);d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);r.multiplyVector3(d.centroidScreen);R=D.vertexNormals;J=d.vertexNormalsWorld;i=0;for(j=R.length;i<j;i++){S=J[i]=J[i]||new THREE.Vector3;S.copy(R[i]);y.multiplyVector3(S)}d.z=
+d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(s.geometry.uvs[f]){d.uvs[0]=s.geometry.uvs[f][0];d.uvs[1]=s.geometry.uvs[f][1];d.uvs[2]=s.geometry.uvs[f][2]}b.push(d);h++}}else if(D instanceof THREE.Face4){i=O[D.a];j=O[D.b];R=O[D.c];S=O[D.d];if(i.__visible&&j.__visible&&R.__visible&&S.__visible)if(s.doubleSided||s.flipSided!=((S.positionScreen.x-i.positionScreen.x)*(j.positionScreen.y-i.positionScreen.y)-(S.positionScreen.y-i.positionScreen.y)*(j.positionScreen.x-i.positionScreen.x)<
+0||(j.positionScreen.x-R.positionScreen.x)*(S.positionScreen.y-R.positionScreen.y)-(j.positionScreen.y-R.positionScreen.y)*(S.positionScreen.x-R.positionScreen.x)<0)){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(i.positionWorld);d.v2.positionWorld.copy(j.positionWorld);d.v3.positionWorld.copy(S.positionWorld);d.v1.positionScreen.copy(i.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(S.positionScreen);d.normalWorld.copy(D.normal);y.multiplyVector3(d.normalWorld);
+d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);r.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(s.geometry.uvs[f]){d.uvs[0]=s.geometry.uvs[f][0];d.uvs[1]=s.geometry.uvs[f][1];d.uvs[2]=s.geometry.uvs[f][3]}b.push(d);h++;e=n[h]=n[h]||new THREE.RenderableFace3;e.v1.positionWorld.copy(j.positionWorld);e.v2.positionWorld.copy(R.positionWorld);e.v3.positionWorld.copy(S.positionWorld);
+e.v1.positionScreen.copy(j.positionScreen);e.v2.positionScreen.copy(R.positionScreen);e.v3.positionScreen.copy(S.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=H;e.faceMaterial=D.material;e.overdraw=Q;if(s.geometry.uvs[f]){e.uvs[0]=s.geometry.uvs[f][1];e.uvs[1]=s.geometry.uvs[f][2];e.uvs[2]=s.geometry.uvs[f][3]}b.push(e);h++}}}}else if(s instanceof THREE.Line){E.multiply(r,G);O=s.geometry.vertices;
+D=O[0];D.positionScreen.copy(D.position);E.multiplyVector4(D.positionScreen);f=1;for(p=O.length;f<p;f++){i=O[f];i.positionScreen.copy(i.position);E.multiplyVector4(i.positionScreen);j=O[f-1];L.copy(i.positionScreen);P.copy(j.positionScreen);if(a(L,P)){L.multiplyScalar(1/L.w);P.multiplyScalar(1/P.w);o=m[l]=m[l]||new THREE.RenderableLine;o.v1.positionScreen.copy(L);o.v2.positionScreen.copy(P);o.z=Math.max(L.z,P.z);o.material=s.material;b.push(o);l++}}}else if(s instanceof THREE.Particle){q.set(s.position.x,
+s.position.y,s.position.z,1);r.multiplyVector4(q);q.z/=q.w;if(q.z>0&&q.z<1){c=x[z]=x[z]||new THREE.RenderableParticle;c.x=q.x/q.w;c.y=q.y/q.w;c.z=q.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(q.x+v.projectionMatrix.n11)/(q.w+v.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(q.y+v.projectionMatrix.n22)/(q.w+v.projectionMatrix.n24));c.material=s.material;b.push(c);z++}}}b.sort(function(I,A){return A.z-I.z});return b};this.unprojectVector=function(K,v){var g=new THREE.Matrix4;
+g.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));g.multiplyVector3(K);return K}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,n;this.domElement=document.createElement("div");this.setSize=function(o,l){d=o;e=l;h=d/2;n=e/2};this.render=function(o,l){var m,c,z,x,q,r,E,L;a=b.projectScene(o,l);m=0;for(c=a.length;m<c;m++){q=a[m];if(q instanceof THREE.RenderableParticle){E=q.x*h+h;L=q.y*n+n;z=0;for(x=q.material.length;z<x;z++){r=q.material[z];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=E+"px";r.style.top=L+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,h,n,o,l=d.getContext("2d"),m=1,c=0,z=null,x=null,q=1,r,E,L,P,J,K,v,g,k,f=new THREE.Color,p=new THREE.Color,i=new THREE.Color,j=new THREE.Color,u=new THREE.Color,s,G,y,H,Q,C,O,D,R,S,I=new THREE.Rectangle,A=new THREE.Rectangle,B=new THREE.Rectangle,W=false,Y=new THREE.Color,N=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,X=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
+na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=d;this.autoClear=true;this.setSize=function(ga,ua){e=ga;h=ua;n=e/2;o=h/2;d.width=e;d.height=h;I.set(-n,-o,n,o)};this.clear=function(){if(!A.isEmpty()){A.inflate(1);A.minSelf(I);l.clearRect(A.getX(),A.getY(),A.getWidth(),A.getHeight());
+A.empty()}};this.render=function(ga,ua){function Ka(t){var T,M,w,F=t.lights;N.setRGB(0,0,0);U.setRGB(0,0,0);aa.setRGB(0,0,0);t=0;for(T=F.length;t<T;t++){M=F[t];w=M.color;if(M instanceof THREE.AmbientLight){N.r+=w.r;N.g+=w.g;N.b+=w.b}else if(M instanceof THREE.DirectionalLight){U.r+=w.r;U.g+=w.g;U.b+=w.b}else if(M instanceof THREE.PointLight){aa.r+=w.r;aa.g+=w.g;aa.b+=w.b}}}function va(t,T,M,w){var F,V,$,ba,ca=t.lights;t=0;for(F=ca.length;t<F;t++){V=ca[t];$=V.color;ba=V.intensity;if(V instanceof THREE.DirectionalLight){V=
+M.dot(V.position)*ba;if(V>0){w.r+=$.r*V;w.g+=$.g*V;w.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,T);X.normalize();V=M.dot(X)*ba;if(V>0){w.r+=$.r*V;w.g+=$.g*V;w.b+=$.b*V}}}}function La(t,T,M){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);var w,F,V,$,ba,ca;if(M instanceof THREE.ParticleBasicMaterial){if(M.map){$=M.map;ba=$.width>>1;ca=$.height>>1;F=T.scale.x*n;V=T.scale.y*o;M=F*ba;w=V*ca;B.set(t.x-M,t.y-w,t.x+M,t.y+w);if(I.instersects(B)){l.save();l.translate(t.x,t.y);l.rotate(-T.rotation);
+l.scale(F,-V);l.translate(-ba,-ca);l.drawImage($,0,0);l.restore()}}}else if(M instanceof THREE.ParticleCircleMaterial){if(W){Y.r=N.r+U.r+aa.r;Y.g=N.g+U.g+aa.g;Y.b=N.b+U.b+aa.b;f.r=M.color.r*Y.r;f.g=M.color.g*Y.g;f.b=M.color.b*Y.b;f.updateStyleString()}else f.__styleString=M.color.__styleString;M=T.scale.x*n;w=T.scale.y*o;B.set(t.x-M,t.y-w,t.x+M,t.y+w);if(I.instersects(B)){F=f.__styleString;if(x!=F)l.fillStyle=x=F;l.save();l.translate(t.x,t.y);l.rotate(-T.rotation);l.scale(M,w);l.beginPath();l.arc(0,
+0,1,0,Ja,true);l.closePath();l.fill();l.restore()}}}}function Ma(t,T,M,w){if(w.opacity!=0){Ba(w.opacity);wa(w.blending);l.beginPath();l.moveTo(t.positionScreen.x,t.positionScreen.y);l.lineTo(T.positionScreen.x,T.positionScreen.y);l.closePath();if(w instanceof THREE.LineBasicMaterial){f.__styleString=w.color.__styleString;t=w.linewidth;if(q!=t)l.lineWidth=q=t;t=f.__styleString;if(z!=t)l.strokeStyle=z=t;l.stroke();B.inflate(w.linewidth*2)}}}function Fa(t,T,M,w,F,V){if(F.opacity!=0){Ba(F.opacity);wa(F.blending);
+P=t.positionScreen.x;J=t.positionScreen.y;K=T.positionScreen.x;v=T.positionScreen.y;g=M.positionScreen.x;k=M.positionScreen.y;l.beginPath();l.moveTo(P,J);l.lineTo(K,v);l.lineTo(g,k);l.lineTo(P,J);l.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(P,J,K,v,g,k,F.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){t=
+ua.matrix;X.copy(w.vertexNormalsWorld[0]);Q=(X.x*t.n11+X.y*t.n12+X.z*t.n13)*0.5+0.5;C=-(X.x*t.n21+X.y*t.n22+X.z*t.n23)*0.5+0.5;X.copy(w.vertexNormalsWorld[1]);O=(X.x*t.n11+X.y*t.n12+X.z*t.n13)*0.5+0.5;D=-(X.x*t.n21+X.y*t.n22+X.z*t.n23)*0.5+0.5;X.copy(w.vertexNormalsWorld[2]);R=(X.x*t.n11+X.y*t.n12+X.z*t.n13)*0.5+0.5;S=-(X.x*t.n21+X.y*t.n22+X.z*t.n23)*0.5+0.5;qa(P,J,K,v,g,k,F.env_map.image,Q,C,O,D,R,S)}}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString);else if(F instanceof
+THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(P,J,K,v,g,k,F.map.image,w.uvs[0].u,w.uvs[0].v,w.uvs[1].u,w.uvs[1].v,w.uvs[2].u,w.uvs[2].v);wa(THREE.SubtractiveBlending)}if(W)if(!F.wireframe&&F.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==3){p.r=i.r=j.r=N.r;p.g=i.g=j.g=N.g;p.b=i.b=j.b=N.b;va(V,w.v1.positionWorld,w.vertexNormalsWorld[0],p);va(V,w.v2.positionWorld,w.vertexNormalsWorld[1],i);va(V,w.v3.positionWorld,w.vertexNormalsWorld[2],
+j);u.r=(i.r+j.r)*0.5;u.g=(i.g+j.g)*0.5;u.b=(i.b+j.b)*0.5;H=Ga(p,i,j,u);qa(P,J,K,v,g,k,H,0,0,1,0,0,1)}else{Y.r=N.r;Y.g=N.g;Y.b=N.b;va(V,w.centroidWorld,w.normalWorld,Y);f.r=F.color.r*Y.r;f.g=F.color.g*Y.g;f.b=F.color.b*Y.b;f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){s=F.__2near;G=F.__farPlusNear;y=F.__farMinusNear;
+p.r=p.g=p.b=1-s/(G-t.positionScreen.z*y);i.r=i.g=i.b=1-s/(G-T.positionScreen.z*y);j.r=j.g=j.b=1-s/(G-M.positionScreen.z*y);u.r=(i.r+j.r)*0.5;u.g=(i.g+j.g)*0.5;u.b=(i.b+j.b)*0.5;H=Ga(p,i,j,u);qa(P,J,K,v,g,k,H,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){f.r=Ca(w.normalWorld.x);f.g=Ca(w.normalWorld.y);f.b=Ca(w.normalWorld.z);f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}}}function xa(t,T){if(z!=t)l.strokeStyle=z=t;if(q!=T)l.lineWidth=
+q=T;l.stroke();B.inflate(T*2)}function ya(t){if(x!=t)l.fillStyle=x=t;l.fill()}function qa(t,T,M,w,F,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;M-=t;w-=T;F-=t;V-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*M-ea*F)*ja;ea=(ra*w-ea*V)*ja;M=(ha*F-ia*M)*ja;w=(ha*V-ia*w)*ja;t=t-ka*ba-M*ca;T=T-ea*ba-w*ca;l.save();l.transform(ka,ea,M,w,t,T);l.clip();l.drawImage($,0,0);l.restore()}function Ba(t){if(m!=t)l.globalAlpha=m=t}function wa(t){if(c!=
+t){switch(t){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=t}}function Ga(t,T,M,w){var F=~~(t.r*255),V=~~(t.g*255);t=~~(t.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*255);var ca=~~(M.r*255),ha=~~(M.g*255);M=~~(M.b*255);var ea=~~(w.r*255),ia=~~(w.g*255);w=~~(w.b*255);da[0]=F<0?0:F>255?255:F;da[1]=V<0?0:V>255?255:V;da[2]=t<0?0:t>
+255?255:t;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=M<0?0:M>255?255:M;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=w<0?0:w>255?255:w;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Da(t,T){var M=T.x-t.x,w=T.y-t.y,F=1/Math.sqrt(M*M+w*w);M*=F;w*=F;T.x+=M;T.y+=w;t.x-=M;t.y-=w}var za,Ha,Z,fa,ma,Ea,Ia,sa;l.setTransform(1,0,0,-1,
+n,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua);(W=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];B.empty();if(Z instanceof THREE.RenderableParticle){r=Z;r.x*=n;r.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(r,Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){r=Z.v1;E=Z.v2;r.positionScreen.x*=n;r.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;B.addPoint(r.positionScreen.x,r.positionScreen.y);B.addPoint(E.positionScreen.x,E.positionScreen.y);
+if(I.instersects(B)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(r,E,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){r=Z.v1;E=Z.v2;L=Z.v3;r.positionScreen.x*=n;r.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;L.positionScreen.x*=n;L.positionScreen.y*=o;if(Z.overdraw){Da(r.positionScreen,E.positionScreen);Da(E.positionScreen,L.positionScreen);Da(L.positionScreen,r.positionScreen)}B.add3Points(r.positionScreen.x,r.positionScreen.y,E.positionScreen.x,E.positionScreen.y,
+L.positionScreen.x,L.positionScreen.y);if(I.instersects(B)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(r,E,L,Z,sa,ga)}else Fa(r,E,L,Z,sa,ga)}}}A.addRectangle(B)}l.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(D,R,S){var I,A,B,W;I=0;for(A=D.lights.length;I<A;I++){B=D.lights[I];if(B instanceof THREE.DirectionalLight){W=R.normalWorld.dot(B.position)*B.intensity;if(W>0){S.r+=B.color.r*W;S.g+=B.color.g*W;S.b+=B.color.b*W}}else if(B instanceof THREE.PointLight){j.sub(B.position,R.centroidWorld);j.normalize();W=R.normalWorld.dot(j)*B.intensity;if(W>0){S.r+=B.color.r*W;S.g+=B.color.g*W;S.b+=B.color.b*W}}}}function b(D,R,S,I,A,B){y=e(H++);y.setAttribute("d","M "+D.positionScreen.x+
+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)v.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(K){g.r=k.r;g.g=k.g;g.b=k.b;a(B,I,g);v.r=A.color.r*g.r;v.g=A.color.g*g.g;v.b=A.color.b*g.b;v.updateStyleString()}else v.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){i=1-A.__2near/(A.__farPlusNear-I.z*A.__farMinusNear);
+v.setRGB(i,i,i)}else A instanceof THREE.MeshNormalMaterial&&v.setRGB(h(I.normalWorld.x),h(I.normalWorld.y),h(I.normalWorld.z));A.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+A.opacity);l.appendChild(y)}function d(D,R,S,I,A,B,W){y=e(H++);y.setAttribute("d",
+"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(K){g.r=k.r;g.g=k.g;g.b=k.b;a(W,A,g);v.r=B.color.r*g.r;v.g=B.color.g*g.g;v.b=B.color.b*g.b;v.updateStyleString()}else v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){i=
+1-B.__2near/(B.__farPlusNear-A.z*B.__farMinusNear);v.setRGB(i,i,i)}else B instanceof THREE.MeshNormalMaterial&&v.setRGB(h(A.normalWorld.x),h(A.normalWorld.y),h(A.normalWorld.z));B.wireframe?y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):y.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+B.opacity);l.appendChild(y)}
+function e(D){if(u[D]==null){u[D]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&u[D].setAttribute("shape-rendering","crispEdges");return u[D]}return u[D]}function h(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var n=null,o=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,z,x,q,r,E,L,P=new THREE.Rectangle,J=new THREE.Rectangle,K=false,v=new THREE.Color(16777215),g=new THREE.Color(16777215),k=new THREE.Color(0),f=new THREE.Color(0),
+p=new THREE.Color(0),i,j=new THREE.Vector3,u=[],s=[],G=[],y,H,Q,C,O=1;this.domElement=l;this.autoClear=true;this.setQuality=function(D){switch(D){case "high":O=1;break;case "low":O=0}};this.setSize=function(D,R){m=D;c=R;z=m/2;x=c/2;l.setAttribute("viewBox",-z+" "+-x+" "+m+" "+c);l.setAttribute("width",m);l.setAttribute("height",c);P.set(-z,-x,z,x)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(D,R){var S,I,A,B,W,Y,N,U;this.autoClear&&this.clear();
+n=o.projectScene(D,R);C=Q=H=0;if(K=D.lights.length>0){N=D.lights;k.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);S=0;for(I=N.length;S<I;S++){A=N[S];B=A.color;if(A instanceof THREE.AmbientLight){k.r+=B.r;k.g+=B.g;k.b+=B.b}else if(A instanceof THREE.DirectionalLight){f.r+=B.r;f.g+=B.g;f.b+=B.b}else if(A instanceof THREE.PointLight){p.r+=B.r;p.g+=B.g;p.b+=B.b}}}S=0;for(I=n.length;S<I;S++){N=n[S];J.empty();if(N instanceof THREE.RenderableParticle){q=N;q.x*=z;q.y*=-x;A=0;for(B=N.material.length;A<B;A++)if(U=
+N.material[A]){W=q;Y=N;U=U;var aa=Q++;if(s[aa]==null){s[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&s[aa].setAttribute("shape-rendering","crispEdges")}y=s[aa];y.setAttribute("cx",W.x);y.setAttribute("cy",W.y);y.setAttribute("r",Y.scale.x*z);if(U instanceof THREE.ParticleCircleMaterial){if(K){g.r=k.r+f.r+p.r;g.g=k.g+f.g+p.g;g.b=k.b+f.b+p.b;v.r=U.color.r*g.r;v.g=U.color.g*g.g;v.b=U.color.b*g.b;v.updateStyleString()}else v=U.color;y.setAttribute("style","fill: "+v.__styleString)}l.appendChild(y)}}else if(N instanceof
+THREE.RenderableLine){q=N.v1;r=N.v2;q.positionScreen.x*=z;q.positionScreen.y*=-x;r.positionScreen.x*=z;r.positionScreen.y*=-x;J.addPoint(q.positionScreen.x,q.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);if(P.instersects(J)){A=0;for(B=N.material.length;A<B;)if(U=N.material[A++]){W=q;Y=r;U=U;aa=C++;if(G[aa]==null){G[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");O==0&&G[aa].setAttribute("shape-rendering","crispEdges")}y=G[aa];y.setAttribute("x1",W.positionScreen.x);
+y.setAttribute("y1",W.positionScreen.y);y.setAttribute("x2",Y.positionScreen.x);y.setAttribute("y2",Y.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){v.__styleString=U.color.__styleString;y.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);l.appendChild(y)}}}}else if(N instanceof THREE.RenderableFace3){q=N.v1;r=N.v2;E=N.v3;q.positionScreen.x*=z;q.positionScreen.y*=
+-x;r.positionScreen.x*=z;r.positionScreen.y*=-x;E.positionScreen.x*=z;E.positionScreen.y*=-x;J.addPoint(q.positionScreen.x,q.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);if(P.instersects(J)){A=0;for(B=N.meshMaterial.length;A<B;){U=N.meshMaterial[A++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&b(q,r,E,N,U,D)}else U&&b(q,r,E,N,U,D)}}}else if(N instanceof THREE.RenderableFace4){q=
+N.v1;r=N.v2;E=N.v3;L=N.v4;q.positionScreen.x*=z;q.positionScreen.y*=-x;r.positionScreen.x*=z;r.positionScreen.y*=-x;E.positionScreen.x*=z;E.positionScreen.y*=-x;L.positionScreen.x*=z;L.positionScreen.y*=-x;J.addPoint(q.positionScreen.x,q.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);J.addPoint(L.positionScreen.x,L.positionScreen.y);if(P.instersects(J)){A=0;for(B=N.meshMaterial.length;A<B;){U=N.meshMaterial[A++];if(U instanceof
+THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&d(q,r,E,L,N,U,D)}else U&&d(q,r,E,L,N,U,D)}}}}}};
+THREE.WebGLRenderer=function(a){function b(g,k){var f=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
+g));c.attachShader(f,o("vertex",p+k));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function d(g,k){if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
+c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_CUBE_MAP,
+g.image.__webGLTextureCube)}}function e(g,k){if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,g.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,l(g.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,l(g.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,l(g.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,l(g.min_filter));c.generateMipmap(c.TEXTURE_2D);
+c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_2D,g.__webGLTexture)}function h(g,k){var f,p,i;f=0;for(p=k.length;f<p;f++){i=k[f];g.uniforms[i]=c.getUniformLocation(g,i)}}function n(g,k){var f,p,i;f=0;for(p=k.length;f<p;f++){i=k[f];g.attributes[i]=c.getAttribLocation(g,i);g.attributes[i]>=0&&c.enableVertexAttribArray(g.attributes[i])}}function o(g,k){var f;if(g=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")f=c.createShader(c.VERTEX_SHADER);
+c.shaderSource(f,k);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function l(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
+case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var m=document.createElement("canvas"),c,z,x,q=new THREE.Matrix4,r,E=new Float32Array(16),L=new Float32Array(16),P=new Float32Array(16),J=new Float32Array(9),K=new Float32Array(16);a=function(g,k){if(g){var f,p,i,j=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=g.lights.length;f<p;f++){i=g.lights[f];i instanceof THREE.DirectionalLight&&j++;i instanceof
+THREE.PointLight&&pointLights++}if(pointLights+j<=k){maxDirLights=j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(k*j/(pointLights+j));maxPointLights=k-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:k-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(v){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
+c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);z=x=function(g,k){var f=[g?"#define MAX_DIR_LIGHTS "+g:"",k?"#define MAX_POINT_LIGHTS "+k:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",g?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
+"",k?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",k?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",k?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
+g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",g?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",g?"}":"",k?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",k?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",k?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
+"",k?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",k?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",k?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
+p=[g?"#define MAX_DIR_LIGHTS "+g:"",k?"#define MAX_POINT_LIGHTS "+k:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
+g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",k?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
+k?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",k?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",k?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",k?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",k?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",k?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",k?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",k?"float pointSpecularWeight = 0.0;":"",k?"if ( pointDotNormalHalf >= 0.0 )":
+"",k?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",k?"pointDiffuse  += mColor * pointDiffuseWeight;":"",k?"pointSpecular += mSpecular * pointSpecularWeight;":"",k?"}":"",g?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"vec3 dirVector = normalize( lDirection.xyz );":"",g?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
+"",g?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",g?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",g?"float dirSpecularWeight = 0.0;":"",g?"if ( dirDotNormalHalf >= 0.0 )":"",g?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",g?"dirDiffuse  += mColor * dirDiffuseWeight;":"",g?"dirSpecular += mSpecular * dirSpecularWeight;":"",g?"}":"","vec4 totalLight = mAmbient;",g?"totalLight += dirDiffuse + dirSpecular;":"",k?"totalLight += pointDiffuse + pointSpecular;":
+"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
+f=b(p,f);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);g&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&h(f,["pointLightNumber","pointLightColor",
+"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);n(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(g,k){m.width=g;m.height=k;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(g,k){var f,p,i,j,u,s=[],
+G=[],y=[];j=[];u=[];c.uniform1i(g.uniforms.enableLighting,k.length);f=0;for(p=k.length;f<p;f++){i=k[f];if(i instanceof THREE.AmbientLight)s.push(i);else if(i instanceof THREE.DirectionalLight)y.push(i);else i instanceof THREE.PointLight&&G.push(i)}f=i=j=u=0;for(p=s.length;f<p;f++){i+=s[f].color.r;j+=s[f].color.g;u+=s[f].color.b}c.uniform3f(g.uniforms.ambientLightColor,i,j,u);j=[];u=[];f=0;for(p=y.length;f<p;f++){i=y[f];j.push(i.color.r*i.intensity);j.push(i.color.g*i.intensity);j.push(i.color.b*i.intensity);
+u.push(i.position.x);u.push(i.position.y);u.push(i.position.z)}if(y.length){c.uniform1i(g.uniforms.directionalLightNumber,y.length);c.uniform3fv(g.uniforms.directionalLightDirection,u);c.uniform3fv(g.uniforms.directionalLightColor,j)}j=[];u=[];f=0;for(p=G.length;f<p;f++){i=G[f];j.push(i.color.r*i.intensity);j.push(i.color.g*i.intensity);j.push(i.color.b*i.intensity);u.push(i.position.x);u.push(i.position.y);u.push(i.position.z)}if(G.length){c.uniform1i(g.uniforms.pointLightNumber,G.length);c.uniform3fv(g.uniforms.pointLightPosition,
+u);c.uniform3fv(g.uniforms.pointLightColor,j)}};this.createBuffers=function(g,k){var f,p,i,j,u,s,G,y,H,Q=[],C=[],O=[],D=[],R=[],S=[],I=0,A=g.geometry.geometryChunks[k],B;i=false;f=0;for(p=g.material.length;f<p;f++){meshMaterial=g.material[f];if(meshMaterial instanceof THREE.MeshFaceMaterial){u=0;for(B=A.material.length;u<B;u++)if(A.material[u]&&A.material[u].shading!=undefined&&A.material[u].shading==THREE.SmoothShading){i=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
+THREE.SmoothShading){i=true;break}if(i)break}B=i;f=0;for(p=A.faces.length;f<p;f++){i=A.faces[f];j=g.geometry.faces[i];u=j.vertexNormals;faceNormal=j.normal;i=g.geometry.uvs[i];if(j instanceof THREE.Face3){s=g.geometry.vertices[j.a].position;G=g.geometry.vertices[j.b].position;y=g.geometry.vertices[j.c].position;O.push(s.x,s.y,s.z);O.push(G.x,G.y,G.z);O.push(y.x,y.y,y.z);if(g.geometry.hasTangents){s=g.geometry.vertices[j.a].tangent;G=g.geometry.vertices[j.b].tangent;y=g.geometry.vertices[j.c].tangent;
+R.push(s.x,s.y,s.z,s.w);R.push(G.x,G.y,G.z,G.w);R.push(y.x,y.y,y.z,y.w)}if(u.length==3&&B)for(j=0;j<3;j++)D.push(u[j].x,u[j].y,u[j].z);else for(j=0;j<3;j++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(i)for(j=0;j<3;j++)S.push(i[j].u,i[j].v);Q.push(I,I+1,I+2);C.push(I,I+1);C.push(I,I+2);C.push(I+1,I+2);I+=3}else if(j instanceof THREE.Face4){s=g.geometry.vertices[j.a].position;G=g.geometry.vertices[j.b].position;y=g.geometry.vertices[j.c].position;H=g.geometry.vertices[j.d].position;O.push(s.x,
+s.y,s.z);O.push(G.x,G.y,G.z);O.push(y.x,y.y,y.z);O.push(H.x,H.y,H.z);if(g.geometry.hasTangents){s=g.geometry.vertices[j.a].tangent;G=g.geometry.vertices[j.b].tangent;y=g.geometry.vertices[j.c].tangent;j=g.geometry.vertices[j.d].tangent;R.push(s.x,s.y,s.z,s.w);R.push(G.x,G.y,G.z,G.w);R.push(y.x,y.y,y.z,y.w);R.push(j.x,j.y,j.z,j.w)}if(u.length==4&&B)for(j=0;j<4;j++)D.push(u[j].x,u[j].y,u[j].z);else for(j=0;j<4;j++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(i)for(j=0;j<4;j++)S.push(i[j].u,i[j].v);
+Q.push(I,I+1,I+2);Q.push(I,I+2,I+3);C.push(I,I+1);C.push(I,I+2);C.push(I,I+3);C.push(I+1,I+2);C.push(I+2,I+3);I+=4}}if(O.length){A.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(O),c.STATIC_DRAW);A.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);if(g.geometry.hasTangents){A.__webGLTangentBuffer=c.createBuffer();
+c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}if(S.length>0){A.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW)}A.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);A.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+A.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),c.STATIC_DRAW);A.__webGLFaceCount=Q.length;A.__webGLLineCount=C.length}};this.renderBuffer=function(g,k,f,p){var i,j,u,s,G,y,H,Q,C;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(C in f.uniforms)H.push(C);h(f.program,H);n(f.program,["position","normal","uv","tangent"])}C=
+f.program}else C=x;if(C!=z){c.useProgram(C);z=C}C==x&&this.setupLights(C,k);this.loadCamera(C,g);this.loadMatrices(C);if(f instanceof THREE.MeshShaderMaterial){u=f.wireframe;L.set(q.flatten());s=f.wireframe_linewidth;g=C;k=f.uniforms;var O;for(i in k){Q=k[i].type;H=k[i].value;O=g.uniforms[i];if(Q=="i")c.uniform1i(O,H);else if(Q=="f")c.uniform1f(O,H);else if(Q=="v3")c.uniform3f(O,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(O,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(O,H);if(Q=k[i].texture)Q.image instanceof
+Array&&Q.image.length==6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){i=f.color;j=f.opacity;u=f.wireframe;s=f.wireframe_linewidth;G=f.map;y=f.env_map;k=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(C.uniforms.mColor,i.r*j,i.g*j,i.b*j,j);c.uniform1i(C.uniforms.mixEnvMap,k);c.uniform1f(C.uniforms.mReflectivity,
+g);c.uniform1i(C.uniforms.useRefract,Q);c.uniform1f(C.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){j=f.opacity;c.uniform1f(C.uniforms.mOpacity,j);c.uniform1i(C.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){j=f.opacity;u=f.wireframe;s=f.wireframe_linewidth;c.uniform1f(C.uniforms.mOpacity,j);c.uniform1f(C.uniforms.m2Near,f.__2near);c.uniform1f(C.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(C.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(C.uniforms.material,
+3)}else if(f instanceof THREE.MeshPhongMaterial){i=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(C.uniforms.mAmbient,i.r,i.g,i.b,j);c.uniform4f(C.uniforms.mSpecular,g.r,g.g,g.b,j);c.uniform1f(C.uniforms.mShininess,f);c.uniform1i(C.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(C.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(C.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(C.uniforms.material,5);y=f.env_map}if(G){e(G,
+0);c.uniform1i(C.uniforms.tMap,0);c.uniform1i(C.uniforms.enableMap,1)}else c.uniform1i(C.uniforms.enableMap,0);if(y){d(y,1);c.uniform1i(C.uniforms.tCube,1);c.uniform1i(C.uniforms.enableCubeMap,1)}else c.uniform1i(C.uniforms.enableCubeMap,0);j=C.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);if(j.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0)}if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,
+p.__webGLTangentBuffer);c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(u){c.lineWidth(s);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,
+p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(g,k,f,p,i,j){var u,s,G,y,H;G=0;for(y=f.material.length;G<y;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(s=p.material.length;u<s;u++)if((H=p.material[u])&&H.blending==i&&H.opacity<1==j){this.setBlending(H.blending);this.renderBuffer(g,k,H,p)}}else if((H=u)&&H.blending==i&&H.opacity<1==j){this.setBlending(H.blending);this.renderBuffer(g,k,H,p)}}};this.render=function(g,k){var f,p,i,j,u=g.lights;this.initWebGLObjects(g);
+this.autoClear&&this.clear();k.autoUpdateMatrix&&k.updateMatrix();E.set(k.matrix.flatten());P.set(k.projectionMatrix.flatten());f=0;for(p=g.__webGLObjects.length;f<p;f++){i=g.__webGLObjects[f];j=i.object;i=i.buffer;if(j.visible){this.setupMatrices(j,k);this.renderPass(k,u,j,i,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){i=g.__webGLObjects[f];j=i.object;i=i.buffer;if(j.visible){this.setupMatrices(j,k);this.renderPass(k,u,j,i,THREE.AdditiveBlending,false);this.renderPass(k,
+u,j,i,THREE.SubtractiveBlending,false);this.renderPass(k,u,j,i,THREE.AdditiveBlending,true);this.renderPass(k,u,j,i,THREE.SubtractiveBlending,true);this.renderPass(k,u,j,i,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(g){var k,f,p,i,j,u;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}k=0;for(f=g.objects.length;k<f;k++){p=g.objects[k];if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};u=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(j in p.geometry.geometryChunks){i=
+p.geometry.geometryChunks[j];i.__webGLVertexBuffer||this.createBuffers(p,j);if(u[j]==undefined){i={buffer:i,object:p};g.__webGLObjects.push(i);u[j]=1}}}};this.removeObject=function(g,k){var f,p;for(f=g.__webGLObjects.length-1;f>=0;f--){p=g.__webGLObjects[f].object;k==p&&g.__webGLObjects.splice(f,1)}};this.setupMatrices=function(g,k){g.autoUpdateMatrix&&g.updateMatrix();q.multiply(k.matrix,g.matrix);L.set(q.flatten());r=THREE.Matrix4.makeInvert3x3(q).transpose();J.set(r.m);K.set(g.matrix.flatten())};
+this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,E);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,L);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,P);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,k){c.uniform3f(g.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,
+c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,k){if(g){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.RenderableFace3=function(){this.z=null;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.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
+THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};

+ 179 - 179
build/ThreeDebug.js

@@ -1,179 +1,179 @@
-// ThreeDebug.js r31 - http://github.com/mrdoob/three.js
-var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
-THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
-","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", 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(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
-THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;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){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+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(){var a=
-Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},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,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
-THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
-return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(n,o){return n.distance-o.distance});return h},intersectObject:function(a){function b(O,J,K,w){w=w.clone().subSelf(J);K=K.clone().subSelf(J);var g=O.clone().subSelf(J);O=w.dot(w);J=w.dot(K);w=w.dot(g);var l=K.dot(K);K=K.dot(g);g=1/(O*l-J*J);l=(l*w-J*K)*g;O=(O*K-J*w)*g;return l>0&&O>0&&l+O<1}var d,e,h,n,o,k,m,c,B,y,
-s,r=a.geometry,E=r.vertices,M=[];d=0;for(e=r.faces.length;d<e;d++){h=r.faces[d];y=this.origin.clone();s=this.direction.clone();n=a.matrix.multiplyVector3(E[h.a].position.clone());o=a.matrix.multiplyVector3(E[h.b].position.clone());k=a.matrix.multiplyVector3(E[h.c].position.clone());m=h instanceof THREE.Face4?a.matrix.multiplyVector3(E[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());B=s.dot(c);if(B<0){c=c.dot((new THREE.Vector3).sub(n,y))/B;y=y.addSelf(s.multiplyScalar(c));
-if(h instanceof THREE.Face3){if(b(y,n,o,k)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};M.push(h)}}else if(h instanceof THREE.Face4)if(b(y,n,o,m)||b(y,o,k,m)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};M.push(h)}}}return M}};
-THREE.Rectangle=function(){function a(){n=e-b;o=h-d}var b,d,e,h,n,o,k=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return n};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(m,c,B,y){k=false;b=m;d=c;e=B;h=y;a()};this.addPoint=function(m,c){if(k){k=false;b=m;d=c;e=m;h=c}else{b=b<m?b:m;d=d<c?d:c;e=e>m?e:m;h=h>c?
-h:c}a()};this.add3Points=function(m,c,B,y,s,r){if(k){k=false;b=m<B?m<s?m:s:B<s?B:s;d=c<y?c<r?c:r:y<r?y:r;e=m>B?m>s?m:s:B>s?B:s;h=c>y?c>r?c:r:y>r?y:r}else{b=m<B?m<s?m<b?m:b:s<b?s:b:B<s?B<b?B:b:s<b?s:b;d=c<y?c<r?c<d?c:d:r<d?r:d:y<r?y<d?y:d:r<d?r:d;e=m>B?m>s?m>e?m:e:s>e?s:e:B>s?B>e?B:e:s>e?s:e;h=c>y?c>r?c>h?c:h:r>h?r:h:y>r?y>h?y:h:r>h?r:h}a()};this.addRectangle=function(m){if(k){k=false;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=b<m.getLeft()?b:m.getLeft();d=d<m.getTop()?d:m.getTop();
-e=e>m.getRight()?e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e<m.getRight()?e:m.getRight();h=h<m.getBottom()?h:m.getBottom();a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){k=true;h=e=d=b=0;a()};this.isEmpty=function(){return k};this.toString=
-function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+n+", height: "+o+" )"}};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(a,b,d,e,h,n,o,k,m,c,B,y,s,r,E,M){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=n||1;this.n23=o||0;this.n24=k||0;this.n31=m||0;this.n32=c||0;this.n33=B||1;this.n34=y||0;this.n41=s||0;this.n42=r||0;this.n43=E||0;this.n44=M||1};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,h,n,o,k,m,c,B,y,s,r,E,M){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=n;this.n23=o;this.n24=k;this.n31=m;this.n32=c;this.n33=B;this.n34=y;this.n41=s;this.n42=r;this.n43=E;this.n44=M;return this},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;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();h.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x;
-this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
-h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,n=a.n14,o=a.n21,k=a.n22,m=a.n23,c=a.n24,B=a.n31,y=a.n32,
-s=a.n33,r=a.n34,E=a.n41,M=a.n42,O=a.n43,J=a.n44,K=b.n11,w=b.n12,g=b.n13,l=b.n14,f=b.n21,p=b.n22,j=b.n23,i=b.n24,u=b.n31,t=b.n32,G=b.n33,z=b.n34,H=b.n41,Q=b.n42,A=b.n43,P=b.n44;this.n11=d*K+e*f+h*u+n*H;this.n12=d*w+e*p+h*t+n*Q;this.n13=d*g+e*j+h*G+n*A;this.n14=d*l+e*i+h*z+n*P;this.n21=o*K+k*f+m*u+c*H;this.n22=o*w+k*p+m*t+c*Q;this.n23=o*g+k*j+m*G+c*A;this.n24=o*l+k*i+m*z+c*P;this.n31=B*K+y*f+s*u+r*H;this.n32=B*w+y*p+s*t+r*Q;this.n33=B*g+y*j+s*G+r*A;this.n34=B*l+y*i+s*z+r*P;this.n41=E*K+M*f+O*u+J*H;
-this.n42=E*w+M*p+O*t+J*Q;this.n43=E*g+M*j+O*G+J*A;this.n44=E*l+M*i+O*z+J*P;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,n=this.n21,o=this.n22,k=this.n23,m=this.n24,c=this.n31,B=this.n32,y=this.n33,s=this.n34,r=this.n41,E=this.n42,M=this.n43,O=this.n44,J=a.n11,K=a.n21,w=a.n31,g=a.n41,l=a.n12,f=a.n22,p=a.n32,j=a.n42,i=a.n13,u=a.n23,t=a.n33,G=a.n43,z=a.n14,H=a.n24,Q=a.n34;a=a.n44;this.n11=b*J+d*K+e*w+h*g;this.n12=b*l+d*f+e*p+h*j;this.n13=b*i+d*u+e*t+h*G;this.n14=
-b*z+d*H+e*Q+h*a;this.n21=n*J+o*K+k*w+m*g;this.n22=n*l+o*f+k*p+m*j;this.n23=n*i+o*u+k*t+m*G;this.n24=n*z+o*H+k*Q+m*a;this.n31=c*J+B*K+y*w+s*g;this.n32=c*l+B*f+y*p+s*j;this.n33=c*i+B*u+y*t+s*G;this.n34=c*z+B*H+y*Q+s*a;this.n41=r*J+E*K+M*w+O*g;this.n42=r*l+E*f+M*p+O*j;this.n43=r*i+E*u+M*t+O*G;this.n44=r*z+E*H+M*Q+O*a;return this},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;return this},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(b,d,e){var h=b[d];b[d]=b[e];
-b[e]=h}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(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};
-THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),n=1-e,o=a.x,k=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*k-h*m;d.n13=n*o*m+h*k;d.n21=n*o*k+h*m;d.n22=n*k*k+e;d.n23=n*k*m-h*o;d.n31=n*o*m-h*k;d.n32=n*k*m+h*o;d.n33=n*m*m+e;return d};
-THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
-a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
-a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
-a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*k;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*B;return a};
-THREE.Matrix4.makeFrustum=function(a,b,d,e,h,n){var o,k,m;o=new THREE.Matrix4;k=2*h/(b-a);m=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+h)/(n-h);h=-2*n*h/(n-h);o.n11=k;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=h;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,b,d,e,h,n){var o,k,m,c;o=new THREE.Matrix4;k=b-a;m=d-e;c=n-h;a=(b+a)/k;d=(d+e)/m;h=(n+h)/c;o.n11=2/k;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-h;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
-THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
-THREE.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,b,d,e,h,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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=[];this.geometryChunks={};this.hasTangents=false};
-THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,h,n,o,k=new THREE.Vector3,m=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){n=this.vertices[e];n.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];if(a&&n.vertexNormals.length){k.set(0,0,0);b=0;for(d=n.normal.length;b<d;b++)k.addSelf(n.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[n.a];d=this.vertices[n.b];o=this.vertices[n.c];k.sub(o.position,
-d.position);m.sub(b.position,d.position);k.crossSelf(m)}k.isZero()||k.normalize();n.normal.copy(k)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeTangents:function(){function a(z,H,Q,A){n=z.vertices[H].position;o=z.vertices[Q].position;
-k=z.vertices[A].position;m=h[0];c=h[1];B=h[2];y=o.x-n.x;s=k.x-n.x;r=o.y-n.y;E=k.y-n.y;M=o.z-n.z;O=k.z-n.z;J=c.u-m.u;K=B.u-m.u;w=c.v-m.v;g=B.v-m.v;l=1/(J*g-K*w);i.set((g*y-w*s)*l,(g*r-w*E)*l,(g*M-w*O)*l);u.set((J*s-K*y)*l,(J*E-K*r)*l,(J*O-K*M)*l);p[H].addSelf(i);p[Q].addSelf(i);p[A].addSelf(i);j[H].addSelf(u);j[Q].addSelf(u);j[A].addSelf(u)}var b,d,e,h,n,o,k,m,c,B,y,s,r,E,M,O,J,K,w,g,l,f,p=[],j=[],i=new THREE.Vector3,u=new THREE.Vector3,t=new THREE.Vector3,G=new THREE.Vector3;f=new THREE.Vector3;b=
-0;for(d=this.vertices.length;b<d;b++){p[b]=new THREE.Vector3;j[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];h=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
-this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){f.copy(this.vertices[b].normal);e=p[b];t.copy(e);t.subSelf(f.multiplyScalar(f.dot(e))).normalize();G.cross(this.vertices[b].normal,e);test=G.dot(j[b]);e=test<0?-1:1;this.vertices[b].tangent.set(t.x,t.y,t.z,e)}this.hasTangents=true},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}}},sortFacesByMaterial:function(){function a(B){var y=[];b=0;for(d=B.length;b<d;b++)B[b]==undefined?y.push("undefined"):y.push(B[b].toString());return y.join("_")}var b,d,e,h,n,o,k,m,c={};e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];o=n.material;k=a(o);if(c[k]==undefined)c[k]={hash:k,counter:0};m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,
-vertices:0};n=n instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+n>65535){c[k].counter+=1;m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
-this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(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(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
-this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
-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(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
-THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
-THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,h;a=0;for(b=this.geometry.uvs.length;a<b;a++){h=this.geometry.uvs[a];d=0;for(e=h.length;d<e;d++){if(h[d].u!=1)h[d].u-=Math.floor(h[d].u);if(h[d].v!=1)h[d].v-=Math.floor(h[d].v)}}};THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
-THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){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;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
-this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
-THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
-this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
-THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
-this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
-THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
-"round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
-a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
-a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
-this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
-THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;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.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
-THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
-THREE.MeshCubeMaterial=function(a){this.id=THREE.MeshCubeMaterial.value++;this.env_map=null;this.blending=THREE.NormalBlending;if(a)if(a.env_map!==undefined)this.env_map=a.env_map;this.toString=function(){return"THREE.MeshCubeMaterial( id: "+this.id+"<br/>env_map: "+this.env_map+" )"}};THREE.MeshCubeMaterialCounter={value:0};
-THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
-undefined)this.uniforms=a.uniforms;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
-"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
-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){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){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(a,b,d,e,h,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
-this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
-THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
-THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
-THREE.Projector=function(){function a(K,w){var g=0,l=1,f=K.z+K.w,p=w.z+w.w,j=-K.z+K.w,i=-w.z+w.w;if(f>=0&&p>=0&&j>=0&&i>=0)return true;else if(f<0&&p<0||j<0&&i<0)return false;else{if(f<0)g=Math.max(g,f/(f-p));else if(p<0)l=Math.min(l,f/(f-p));if(j<0)g=Math.max(g,j/(j-i));else if(i<0)l=Math.min(l,j/(j-i));if(l<g)return false;else{K.lerpSelf(w,g);w.lerpSelf(K,1-l);return true}}}var b=null,d,e,h,n=[],o,k,m=[],c,B,y=[],s=new THREE.Vector4,r=new THREE.Matrix4,E=new THREE.Matrix4,M=new THREE.Vector4,O=
-new THREE.Vector4,J;this.projectScene=function(K,w){var g,l,f,p,j,i,u,t,G,z,H,Q,A,P,D,R,S;b=[];h=k=B=0;w.autoUpdateMatrix&&w.updateMatrix();r.multiply(w.projectionMatrix,w.matrix);u=K.objects;g=0;for(l=u.length;g<l;g++){t=u[g];t.autoUpdateMatrix&&t.updateMatrix();G=t.matrix;z=t.rotationMatrix;H=t.material;Q=t.overdraw;if(t instanceof THREE.Mesh){A=t.geometry.vertices;f=0;for(p=A.length;f<p;f++){P=A[f];P.positionWorld.copy(P.position);G.multiplyVector3(P.positionWorld);D=P.positionScreen;D.copy(P.positionWorld);
-r.multiplyVector4(D);D.multiplyScalar(1/D.w);P.__visible=D.z>0&&D.z<1}P=t.geometry.faces;f=0;for(p=P.length;f<p;f++){D=P[f];if(D instanceof THREE.Face3){j=A[D.a];i=A[D.b];R=A[D.c];if(j.__visible&&i.__visible&&R.__visible)if(t.doubleSided||t.flipSided!=(R.positionScreen.x-j.positionScreen.x)*(i.positionScreen.y-j.positionScreen.y)-(R.positionScreen.y-j.positionScreen.y)*(i.positionScreen.x-j.positionScreen.x)<0){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(j.positionWorld);d.v2.positionWorld.copy(i.positionWorld);
-d.v3.positionWorld.copy(R.positionWorld);d.v1.positionScreen.copy(j.positionScreen);d.v2.positionScreen.copy(i.positionScreen);d.v3.positionScreen.copy(R.positionScreen);d.normalWorld.copy(D.normal);z.multiplyVector3(d.normalWorld);d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);r.multiplyVector3(d.centroidScreen);R=D.vertexNormals;J=d.vertexNormalsWorld;j=0;for(i=R.length;j<i;j++){S=J[j]=J[j]||new THREE.Vector3;S.copy(R[j]);z.multiplyVector3(S)}d.z=
-d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(t.geometry.uvs[f]){d.uvs[0]=t.geometry.uvs[f][0];d.uvs[1]=t.geometry.uvs[f][1];d.uvs[2]=t.geometry.uvs[f][2]}b.push(d);h++}}else if(D instanceof THREE.Face4){j=A[D.a];i=A[D.b];R=A[D.c];S=A[D.d];if(j.__visible&&i.__visible&&R.__visible&&S.__visible)if(t.doubleSided||t.flipSided!=((S.positionScreen.x-j.positionScreen.x)*(i.positionScreen.y-j.positionScreen.y)-(S.positionScreen.y-j.positionScreen.y)*(i.positionScreen.x-j.positionScreen.x)<
-0||(i.positionScreen.x-R.positionScreen.x)*(S.positionScreen.y-R.positionScreen.y)-(i.positionScreen.y-R.positionScreen.y)*(S.positionScreen.x-R.positionScreen.x)<0)){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(j.positionWorld);d.v2.positionWorld.copy(i.positionWorld);d.v3.positionWorld.copy(S.positionWorld);d.v1.positionScreen.copy(j.positionScreen);d.v2.positionScreen.copy(i.positionScreen);d.v3.positionScreen.copy(S.positionScreen);d.normalWorld.copy(D.normal);z.multiplyVector3(d.normalWorld);
-d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);r.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(t.geometry.uvs[f]){d.uvs[0]=t.geometry.uvs[f][0];d.uvs[1]=t.geometry.uvs[f][1];d.uvs[2]=t.geometry.uvs[f][3]}b.push(d);h++;e=n[h]=n[h]||new THREE.RenderableFace3;e.v1.positionWorld.copy(i.positionWorld);e.v2.positionWorld.copy(R.positionWorld);e.v3.positionWorld.copy(S.positionWorld);
-e.v1.positionScreen.copy(i.positionScreen);e.v2.positionScreen.copy(R.positionScreen);e.v3.positionScreen.copy(S.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=H;e.faceMaterial=D.material;e.overdraw=Q;if(t.geometry.uvs[f]){e.uvs[0]=t.geometry.uvs[f][1];e.uvs[1]=t.geometry.uvs[f][2];e.uvs[2]=t.geometry.uvs[f][3]}b.push(e);h++}}}}else if(t instanceof THREE.Line){E.multiply(r,G);A=t.geometry.vertices;
-P=A[0];P.positionScreen.copy(P.position);E.multiplyVector4(P.positionScreen);f=1;for(p=A.length;f<p;f++){j=A[f];j.positionScreen.copy(j.position);E.multiplyVector4(j.positionScreen);i=A[f-1];M.copy(j.positionScreen);O.copy(i.positionScreen);if(a(M,O)){M.multiplyScalar(1/M.w);O.multiplyScalar(1/O.w);o=m[k]=m[k]||new THREE.RenderableLine;o.v1.positionScreen.copy(M);o.v2.positionScreen.copy(O);o.z=Math.max(M.z,O.z);o.material=t.material;b.push(o);k++}}}else if(t instanceof THREE.Particle){s.set(t.position.x,
-t.position.y,t.position.z,1);r.multiplyVector4(s);s.z/=s.w;if(s.z>0&&s.z<1){c=y[B]=y[B]||new THREE.RenderableParticle;c.x=s.x/s.w;c.y=s.y/s.w;c.z=s.z;c.rotation=t.rotation.z;c.scale.x=t.scale.x*Math.abs(c.x-(s.x+w.projectionMatrix.n11)/(s.w+w.projectionMatrix.n14));c.scale.y=t.scale.y*Math.abs(c.y-(s.y+w.projectionMatrix.n22)/(s.w+w.projectionMatrix.n24));c.material=t.material;b.push(c);B++}}}b.sort(function(I,v){return v.z-I.z});return b};this.unprojectVector=function(K,w){var g=new THREE.Matrix4;
-g.multiply(THREE.Matrix4.makeInvert(w.matrix),THREE.Matrix4.makeInvert(w.projectionMatrix));g.multiplyVector3(K);return K}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,n;this.domElement=document.createElement("div");this.setSize=function(o,k){d=o;e=k;h=d/2;n=e/2};this.render=function(o,k){var m,c,B,y,s,r,E,M;a=b.projectScene(o,k);m=0;for(c=a.length;m<c;m++){s=a[m];if(s instanceof THREE.RenderableParticle){E=s.x*h+h;M=s.y*n+n;B=0;for(y=s.material.length;B<y;B++){r=s.material[B];if(r instanceof THREE.ParticleDOMMaterial){r=r.domElement;r.style.left=E+"px";r.style.top=M+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,h,n,o,k=d.getContext("2d"),m=1,c=0,B=null,y=null,s=1,r,E,M,O,J,K,w,g,l,f=new THREE.Color,p=new THREE.Color,j=new THREE.Color,i=new THREE.Color,u=new THREE.Color,t,G,z,H,Q,A,P,D,R,S,I=new THREE.Rectangle,v=new THREE.Rectangle,C=new THREE.Rectangle,W=false,Y=new THREE.Color,N=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,X=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
-na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=d;this.autoClear=true;this.setSize=function(ga,ua){e=ga;h=ua;n=e/2;o=h/2;d.width=e;d.height=h;I.set(-n,-o,n,o)};this.clear=function(){if(!v.isEmpty()){v.inflate(1);v.minSelf(I);k.clearRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());
-v.empty()}};this.render=function(ga,ua){function Ka(q){var T,L,x,F=q.lights;N.setRGB(0,0,0);U.setRGB(0,0,0);aa.setRGB(0,0,0);q=0;for(T=F.length;q<T;q++){L=F[q];x=L.color;if(L instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(L instanceof THREE.DirectionalLight){U.r+=x.r;U.g+=x.g;U.b+=x.b}else if(L instanceof THREE.PointLight){aa.r+=x.r;aa.g+=x.g;aa.b+=x.b}}}function va(q,T,L,x){var F,V,$,ba,ca=q.lights;q=0;for(F=ca.length;q<F;q++){V=ca[q];$=V.color;ba=V.intensity;if(V instanceof THREE.DirectionalLight){V=
-L.dot(V.position)*ba;if(V>0){x.r+=$.r*V;x.g+=$.g*V;x.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,T);X.normalize();V=L.dot(X)*ba;if(V>0){x.r+=$.r*V;x.g+=$.g*V;x.b+=$.b*V}}}}function La(q,T,L){if(L.opacity!=0){Ba(L.opacity);wa(L.blending);var x,F,V,$,ba,ca;if(L instanceof THREE.ParticleBasicMaterial){if(L.map){$=L.map;ba=$.width>>1;ca=$.height>>1;F=T.scale.x*n;V=T.scale.y*o;L=F*ba;x=V*ca;C.set(q.x-L,q.y-x,q.x+L,q.y+x);if(!I.instersects(C))return;k.save();k.translate(q.x,q.y);k.rotate(-T.rotation);
-k.scale(F,-V);k.translate(-ba,-ca);k.drawImage($,0,0);k.restore()}k.beginPath();k.moveTo(q.x-10,q.y);k.lineTo(q.x+10,q.y);k.moveTo(q.x,q.y-10);k.lineTo(q.x,q.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(L instanceof THREE.ParticleCircleMaterial){if(W){Y.r=N.r+U.r+aa.r;Y.g=N.g+U.g+aa.g;Y.b=N.b+U.b+aa.b;f.r=L.color.r*Y.r;f.g=L.color.g*Y.g;f.b=L.color.b*Y.b;f.updateStyleString()}else f.__styleString=L.color.__styleString;L=T.scale.x*n;x=T.scale.y*o;C.set(q.x-L,q.y-x,q.x+L,q.y+
-x);if(I.instersects(C)){F=f.__styleString;if(y!=F)k.fillStyle=y=F;k.save();k.translate(q.x,q.y);k.rotate(-T.rotation);k.scale(L,x);k.beginPath();k.arc(0,0,1,0,Ja,true);k.closePath();k.fill();k.restore()}}}}function Ma(q,T,L,x){if(x.opacity!=0){Ba(x.opacity);wa(x.blending);k.beginPath();k.moveTo(q.positionScreen.x,q.positionScreen.y);k.lineTo(T.positionScreen.x,T.positionScreen.y);k.closePath();if(x instanceof THREE.LineBasicMaterial){f.__styleString=x.color.__styleString;q=x.linewidth;if(s!=q)k.lineWidth=
-s=q;q=f.__styleString;if(B!=q)k.strokeStyle=B=q;k.stroke();C.inflate(x.linewidth*2)}}}function Fa(q,T,L,x,F,V){if(F.opacity!=0){Ba(F.opacity);wa(F.blending);O=q.positionScreen.x;J=q.positionScreen.y;K=T.positionScreen.x;w=T.positionScreen.y;g=L.positionScreen.x;l=L.positionScreen.y;k.beginPath();k.moveTo(O,J);k.lineTo(K,w);k.lineTo(g,l);k.lineTo(O,J);k.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(O,J,K,w,g,l,F.map.image,
-x.uvs[0].u,x.uvs[0].v,x.uvs[1].u,x.uvs[1].v,x.uvs[2].u,x.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){q=ua.matrix;X.copy(x.vertexNormalsWorld[0]);Q=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;A=-(X.x*q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;X.copy(x.vertexNormalsWorld[1]);P=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;D=-(X.x*q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;X.copy(x.vertexNormalsWorld[2]);R=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;S=-(X.x*
-q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;qa(O,J,K,w,g,l,F.env_map.image,Q,A,P,D,R,S)}}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString);else if(F instanceof THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(O,J,K,w,g,l,F.map.image,x.uvs[0].u,x.uvs[0].v,x.uvs[1].u,x.uvs[1].v,x.uvs[2].u,x.uvs[2].v);wa(THREE.SubtractiveBlending)}if(W)if(!F.wireframe&&F.shading==THREE.SmoothShading&&x.vertexNormalsWorld.length==3){p.r=j.r=
-i.r=N.r;p.g=j.g=i.g=N.g;p.b=j.b=i.b=N.b;va(V,x.v1.positionWorld,x.vertexNormalsWorld[0],p);va(V,x.v2.positionWorld,x.vertexNormalsWorld[1],j);va(V,x.v3.positionWorld,x.vertexNormalsWorld[2],i);u.r=(j.r+i.r)*0.5;u.g=(j.g+i.g)*0.5;u.b=(j.b+i.b)*0.5;H=Ga(p,j,i,u);qa(O,J,K,w,g,l,H,0,0,1,0,0,1)}else{Y.r=N.r;Y.g=N.g;Y.b=N.b;va(V,x.centroidWorld,x.normalWorld,Y);f.r=F.color.r*Y.r;f.g=F.color.g*Y.g;f.b=F.color.b*Y.b;f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}else F.wireframe?
-xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){t=F.__2near;G=F.__farPlusNear;z=F.__farMinusNear;p.r=p.g=p.b=1-t/(G-q.positionScreen.z*z);j.r=j.g=j.b=1-t/(G-T.positionScreen.z*z);i.r=i.g=i.b=1-t/(G-L.positionScreen.z*z);u.r=(j.r+i.r)*0.5;u.g=(j.g+i.g)*0.5;u.b=(j.b+i.b)*0.5;H=Ga(p,j,i,u);qa(O,J,K,w,g,l,H,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){f.r=Ca(x.normalWorld.x);f.g=Ca(x.normalWorld.y);f.b=Ca(x.normalWorld.z);
-f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}}}function xa(q,T){if(B!=q)k.strokeStyle=B=q;if(s!=T)k.lineWidth=s=T;k.stroke();C.inflate(T*2)}function ya(q){if(y!=q)k.fillStyle=y=q;k.fill()}function qa(q,T,L,x,F,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;L-=q;x-=T;F-=q;V-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*L-ea*F)*ja;ea=(ra*x-ea*V)*ja;L=(ha*F-ia*L)*ja;x=(ha*V-ia*x)*ja;q=
-q-ka*ba-L*ca;T=T-ea*ba-x*ca;k.save();k.transform(ka,ea,L,x,q,T);k.clip();k.drawImage($,0,0);k.restore()}function Ba(q){if(m!=q)k.globalAlpha=m=q}function wa(q){if(c!=q){switch(q){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=q}}function Ga(q,T,L,x){var F=~~(q.r*255),V=~~(q.g*255);q=~~(q.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*
-255);var ca=~~(L.r*255),ha=~~(L.g*255);L=~~(L.b*255);var ea=~~(x.r*255),ia=~~(x.g*255);x=~~(x.b*255);da[0]=F<0?0:F>255?255:F;da[1]=V<0?0:V>255?255:V;da[2]=q<0?0:q>255?255:q;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=L<0?0:L>255?255:L;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=x<0?0:x>255?255:x;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(q){q=(q+1)*0.5;return q<0?
-0:q>1?1:q}function Da(q,T){var L=T.x-q.x,x=T.y-q.y,F=1/Math.sqrt(L*L+x*x);L*=F;x*=F;T.x+=L;T.y+=x;q.x-=L;q.y-=x}var za,Ha,Z,fa,ma,Ea,Ia,sa;k.setTransform(1,0,0,-1,n,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());(W=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];C.empty();if(Z instanceof THREE.RenderableParticle){r=Z;r.x*=n;r.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(r,
-Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){r=Z.v1;E=Z.v2;r.positionScreen.x*=n;r.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;C.addPoint(r.positionScreen.x,r.positionScreen.y);C.addPoint(E.positionScreen.x,E.positionScreen.y);if(I.instersects(C)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(r,E,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){r=Z.v1;E=Z.v2;M=Z.v3;r.positionScreen.x*=n;r.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=
-o;M.positionScreen.x*=n;M.positionScreen.y*=o;if(Z.overdraw){Da(r.positionScreen,E.positionScreen);Da(E.positionScreen,M.positionScreen);Da(M.positionScreen,r.positionScreen)}C.add3Points(r.positionScreen.x,r.positionScreen.y,E.positionScreen.x,E.positionScreen.y,M.positionScreen.x,M.positionScreen.y);if(I.instersects(C)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(r,
-E,M,Z,sa,ga)}else Fa(r,E,M,Z,sa,ga)}}}v.addRectangle(C)}k.lineWidth=1;k.strokeStyle="rgba( 255, 0, 0, 0.5 )";k.strokeRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());k.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(D,R,S){var I,v,C,W;I=0;for(v=D.lights.length;I<v;I++){C=D.lights[I];if(C instanceof THREE.DirectionalLight){W=R.normalWorld.dot(C.position)*C.intensity;if(W>0){S.r+=C.color.r*W;S.g+=C.color.g*W;S.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){i.sub(C.position,R.centroidWorld);i.normalize();W=R.normalWorld.dot(i)*C.intensity;if(W>0){S.r+=C.color.r*W;S.g+=C.color.g*W;S.b+=C.color.b*W}}}}function b(D,R,S,I,v,C){z=e(H++);z.setAttribute("d","M "+D.positionScreen.x+
-" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(v instanceof THREE.MeshBasicMaterial)w.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshLambertMaterial)if(K){g.r=l.r;g.g=l.g;g.b=l.b;a(C,I,g);w.r=v.color.r*g.r;w.g=v.color.g*g.g;w.b=v.color.b*g.b;w.updateStyleString()}else w.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshDepthMaterial){j=1-v.__2near/(v.__farPlusNear-I.z*v.__farMinusNear);
-w.setRGB(j,j,j)}else v instanceof THREE.MeshNormalMaterial&&w.setRGB(h(I.normalWorld.x),h(I.normalWorld.y),h(I.normalWorld.z));v.wireframe?z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+v.wireframe_linewidth+"; stroke-opacity: "+v.opacity+"; stroke-linecap: "+v.wireframe_linecap+"; stroke-linejoin: "+v.wireframe_linejoin):z.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+v.opacity);k.appendChild(z)}function d(D,R,S,I,v,C,W){z=e(H++);z.setAttribute("d",
-"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)w.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(K){g.r=l.r;g.g=l.g;g.b=l.b;a(W,v,g);w.r=C.color.r*g.r;w.g=C.color.g*g.g;w.b=C.color.b*g.b;w.updateStyleString()}else w.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){j=
-1-C.__2near/(C.__farPlusNear-v.z*C.__farMinusNear);w.setRGB(j,j,j)}else C instanceof THREE.MeshNormalMaterial&&w.setRGB(h(v.normalWorld.x),h(v.normalWorld.y),h(v.normalWorld.z));C.wireframe?z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):z.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+C.opacity);k.appendChild(z)}
-function e(D){if(u[D]==null){u[D]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&u[D].setAttribute("shape-rendering","crispEdges");return u[D]}return u[D]}function h(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var n=null,o=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,B,y,s,r,E,M,O=new THREE.Rectangle,J=new THREE.Rectangle,K=false,w=new THREE.Color(16777215),g=new THREE.Color(16777215),l=new THREE.Color(0),f=new THREE.Color(0),
-p=new THREE.Color(0),j,i=new THREE.Vector3,u=[],t=[],G=[],z,H,Q,A,P=1;this.domElement=k;this.autoClear=true;this.setQuality=function(D){switch(D){case "high":P=1;break;case "low":P=0}};this.setSize=function(D,R){m=D;c=R;B=m/2;y=c/2;k.setAttribute("viewBox",-B+" "+-y+" "+m+" "+c);k.setAttribute("width",m);k.setAttribute("height",c);O.set(-B,-y,B,y)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(D,R){var S,I,v,C,W,Y,N,U;this.autoClear&&this.clear();
-n=o.projectScene(D,R);A=Q=H=0;if(K=D.lights.length>0){N=D.lights;l.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);S=0;for(I=N.length;S<I;S++){v=N[S];C=v.color;if(v instanceof THREE.AmbientLight){l.r+=C.r;l.g+=C.g;l.b+=C.b}else if(v instanceof THREE.DirectionalLight){f.r+=C.r;f.g+=C.g;f.b+=C.b}else if(v instanceof THREE.PointLight){p.r+=C.r;p.g+=C.g;p.b+=C.b}}}S=0;for(I=n.length;S<I;S++){N=n[S];J.empty();if(N instanceof THREE.RenderableParticle){s=N;s.x*=B;s.y*=-y;v=0;for(C=N.material.length;v<C;v++)if(U=
-N.material[v]){W=s;Y=N;U=U;var aa=Q++;if(t[aa]==null){t[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");P==0&&t[aa].setAttribute("shape-rendering","crispEdges")}z=t[aa];z.setAttribute("cx",W.x);z.setAttribute("cy",W.y);z.setAttribute("r",Y.scale.x*B);if(U instanceof THREE.ParticleCircleMaterial){if(K){g.r=l.r+f.r+p.r;g.g=l.g+f.g+p.g;g.b=l.b+f.b+p.b;w.r=U.color.r*g.r;w.g=U.color.g*g.g;w.b=U.color.b*g.b;w.updateStyleString()}else w=U.color;z.setAttribute("style","fill: "+w.__styleString)}k.appendChild(z)}}else if(N instanceof
-THREE.RenderableLine){s=N.v1;r=N.v2;s.positionScreen.x*=B;s.positionScreen.y*=-y;r.positionScreen.x*=B;r.positionScreen.y*=-y;J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);if(O.instersects(J)){v=0;for(C=N.material.length;v<C;)if(U=N.material[v++]){W=s;Y=r;U=U;aa=A++;if(G[aa]==null){G[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");P==0&&G[aa].setAttribute("shape-rendering","crispEdges")}z=G[aa];z.setAttribute("x1",W.positionScreen.x);
-z.setAttribute("y1",W.positionScreen.y);z.setAttribute("x2",Y.positionScreen.x);z.setAttribute("y2",Y.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){w.__styleString=U.color.__styleString;z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);k.appendChild(z)}}}}else if(N instanceof THREE.RenderableFace3){s=N.v1;r=N.v2;E=N.v3;s.positionScreen.x*=B;s.positionScreen.y*=
--y;r.positionScreen.x*=B;r.positionScreen.y*=-y;E.positionScreen.x*=B;E.positionScreen.y*=-y;J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);if(O.instersects(J)){v=0;for(C=N.meshMaterial.length;v<C;){U=N.meshMaterial[v++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&b(s,r,E,N,U,D)}else U&&b(s,r,E,N,U,D)}}}else if(N instanceof THREE.RenderableFace4){s=
-N.v1;r=N.v2;E=N.v3;M=N.v4;s.positionScreen.x*=B;s.positionScreen.y*=-y;r.positionScreen.x*=B;r.positionScreen.y*=-y;E.positionScreen.x*=B;E.positionScreen.y*=-y;M.positionScreen.x*=B;M.positionScreen.y*=-y;J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);J.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(J)){v=0;for(C=N.meshMaterial.length;v<C;){U=N.meshMaterial[v++];if(U instanceof
-THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&d(s,r,E,M,N,U,D)}else U&&d(s,r,E,M,N,U,D)}}}}}};
-THREE.WebGLRenderer=function(a){function b(g,l){var f=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
-g));c.attachShader(f,o("vertex",p+l));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function d(g,l){if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
-c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP,
-g.image.__webGLTextureCube)}}function e(g,l){if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,g.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(g.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(g.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(g.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,k(g.min_filter));c.generateMipmap(c.TEXTURE_2D);
-c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,g.__webGLTexture)}function h(g,l){var f,p,j;f=0;for(p=l.length;f<p;f++){j=l[f];g.uniforms[j]=c.getUniformLocation(g,j)}}function n(g,l){var f,p,j;f=0;for(p=l.length;f<p;f++){j=l[f];g.attributes[j]=c.getAttribLocation(g,j);g.attributes[j]>=0&&c.enableVertexAttribArray(g.attributes[j])}}function o(g,l){var f;if(g=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")f=c.createShader(c.VERTEX_SHADER);
-c.shaderSource(f,l);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function k(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
-case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var m=document.createElement("canvas"),c,B,y,s=new THREE.Matrix4,r,E=new Float32Array(16),M=new Float32Array(16),O=new Float32Array(16),J=new Float32Array(9),K=new Float32Array(16);a=function(g,l){if(g){var f,p,j,i=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=g.lights.length;f<p;f++){j=g.lights[f];j instanceof THREE.DirectionalLight&&i++;j instanceof
-THREE.PointLight&&pointLights++}if(pointLights+i<=l){maxDirLights=i;maxPointLights=pointLights}else{maxDirLights=Math.ceil(l*i/(pointLights+i));maxPointLights=l-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:l-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(w){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
-c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);B=y=function(g,l){var f=[g?"#define MAX_DIR_LIGHTS "+g:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",g?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
-"",l?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",l?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
-g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",g?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",g?"}":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",l?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
-"",l?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",l?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",l?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
-p=[g?"#define MAX_DIR_LIGHTS "+g:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
-g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
-l?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",l?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",l?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",l?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",l?"float pointSpecularWeight = 0.0;":"",l?"if ( pointDotNormalHalf >= 0.0 )":
-"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse  += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",g?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"vec3 dirVector = normalize( lDirection.xyz );":"",g?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
-"",g?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",g?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",g?"float dirSpecularWeight = 0.0;":"",g?"if ( dirDotNormalHalf >= 0.0 )":"",g?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",g?"dirDiffuse  += mColor * dirDiffuseWeight;":"",g?"dirSpecular += mSpecular * dirSpecularWeight;":"",g?"}":"","vec4 totalLight = mAmbient;",g?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;":
-"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
-f=b(p,f);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);g&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&h(f,["pointLightNumber","pointLightColor",
-"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);n(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(g,l){m.width=g;m.height=l;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(g,l){var f,p,j,i,u,t=[],
-G=[],z=[];i=[];u=[];c.uniform1i(g.uniforms.enableLighting,l.length);f=0;for(p=l.length;f<p;f++){j=l[f];if(j instanceof THREE.AmbientLight)t.push(j);else if(j instanceof THREE.DirectionalLight)z.push(j);else j instanceof THREE.PointLight&&G.push(j)}f=j=i=u=0;for(p=t.length;f<p;f++){j+=t[f].color.r;i+=t[f].color.g;u+=t[f].color.b}c.uniform3f(g.uniforms.ambientLightColor,j,i,u);i=[];u=[];f=0;for(p=z.length;f<p;f++){j=z[f];i.push(j.color.r*j.intensity);i.push(j.color.g*j.intensity);i.push(j.color.b*j.intensity);
-u.push(j.position.x);u.push(j.position.y);u.push(j.position.z)}if(z.length){c.uniform1i(g.uniforms.directionalLightNumber,z.length);c.uniform3fv(g.uniforms.directionalLightDirection,u);c.uniform3fv(g.uniforms.directionalLightColor,i)}i=[];u=[];f=0;for(p=G.length;f<p;f++){j=G[f];i.push(j.color.r*j.intensity);i.push(j.color.g*j.intensity);i.push(j.color.b*j.intensity);u.push(j.position.x);u.push(j.position.y);u.push(j.position.z)}if(G.length){c.uniform1i(g.uniforms.pointLightNumber,G.length);c.uniform3fv(g.uniforms.pointLightPosition,
-u);c.uniform3fv(g.uniforms.pointLightColor,i)}};this.createBuffers=function(g,l){var f,p,j,i,u,t,G,z,H,Q=[],A=[],P=[],D=[],R=[],S=[],I=0,v=g.geometry.geometryChunks[l],C;j=false;f=0;for(p=g.material.length;f<p;f++){meshMaterial=g.material[f];if(meshMaterial instanceof THREE.MeshFaceMaterial){u=0;for(C=v.material.length;u<C;u++)if(v.material[u]&&v.material[u].shading!=undefined&&v.material[u].shading==THREE.SmoothShading){j=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
-THREE.SmoothShading){j=true;break}if(j)break}C=j;f=0;for(p=v.faces.length;f<p;f++){j=v.faces[f];i=g.geometry.faces[j];u=i.vertexNormals;faceNormal=i.normal;j=g.geometry.uvs[j];if(i instanceof THREE.Face3){t=g.geometry.vertices[i.a].position;G=g.geometry.vertices[i.b].position;z=g.geometry.vertices[i.c].position;P.push(t.x,t.y,t.z);P.push(G.x,G.y,G.z);P.push(z.x,z.y,z.z);if(g.geometry.hasTangents){t=g.geometry.vertices[i.a].tangent;G=g.geometry.vertices[i.b].tangent;z=g.geometry.vertices[i.c].tangent;
-R.push(t.x,t.y,t.z,t.w);R.push(G.x,G.y,G.z,G.w);R.push(z.x,z.y,z.z,z.w)}if(u.length==3&&C)for(i=0;i<3;i++)D.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<3;i++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(i=0;i<3;i++)S.push(j[i].u,j[i].v);Q.push(I,I+1,I+2);A.push(I,I+1);A.push(I,I+2);A.push(I+1,I+2);I+=3}else if(i instanceof THREE.Face4){t=g.geometry.vertices[i.a].position;G=g.geometry.vertices[i.b].position;z=g.geometry.vertices[i.c].position;H=g.geometry.vertices[i.d].position;P.push(t.x,
-t.y,t.z);P.push(G.x,G.y,G.z);P.push(z.x,z.y,z.z);P.push(H.x,H.y,H.z);if(g.geometry.hasTangents){t=g.geometry.vertices[i.a].tangent;G=g.geometry.vertices[i.b].tangent;z=g.geometry.vertices[i.c].tangent;i=g.geometry.vertices[i.d].tangent;R.push(t.x,t.y,t.z,t.w);R.push(G.x,G.y,G.z,G.w);R.push(z.x,z.y,z.z,z.w);R.push(i.x,i.y,i.z,i.w)}if(u.length==4&&C)for(i=0;i<4;i++)D.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<4;i++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(j)for(i=0;i<4;i++)S.push(j[i].u,j[i].v);
-Q.push(I,I+1,I+2);Q.push(I,I+2,I+3);A.push(I,I+1);A.push(I,I+2);A.push(I,I+3);A.push(I+1,I+2);A.push(I+2,I+3);I+=4}}if(P.length){v.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);v.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);if(g.geometry.hasTangents){v.__webGLTangentBuffer=c.createBuffer();
-c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}if(S.length>0){v.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW)}v.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);v.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-v.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),c.STATIC_DRAW);v.__webGLFaceCount=Q.length;v.__webGLLineCount=A.length}};this.renderBuffer=function(g,l,f,p){var j,i,u,t,G,z,H,Q,A;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(A in f.uniforms)H.push(A);h(f.program,H);n(f.program,["position","normal","uv","tangent"])}A=
-f.program}else A=y;if(A!=B){c.useProgram(A);B=A}A==y&&this.setupLights(A,l);this.loadCamera(A,g);this.loadMatrices(A);if(f instanceof THREE.MeshShaderMaterial){u=f.wireframe;t=f.wireframe_linewidth;g=A;l=f.uniforms;var P;for(j in l){Q=l[j].type;H=l[j].value;P=g.uniforms[j];if(Q=="i")c.uniform1i(P,H);else if(Q=="f")c.uniform1f(P,H);else if(Q=="v3")c.uniform3f(P,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(P,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(P,H);if(Q=l[j].texture)Q.image instanceof Array&&Q.image.length==
-6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;i=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;G=f.map;z=f.env_map;l=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(A.uniforms.mColor,j.r*i,j.g*i,j.b*i,i);c.uniform1i(A.uniforms.mixEnvMap,l);c.uniform1f(A.uniforms.mReflectivity,g);c.uniform1i(A.uniforms.useRefract,
-Q);c.uniform1f(A.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(A.uniforms.mOpacity,i);c.uniform1i(A.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;c.uniform1f(A.uniforms.mOpacity,i);c.uniform1f(A.uniforms.m2Near,f.__2near);c.uniform1f(A.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(A.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(A.uniforms.material,3)}else if(f instanceof
-THREE.MeshPhongMaterial){j=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(A.uniforms.mAmbient,j.r,j.g,j.b,i);c.uniform4f(A.uniforms.mSpecular,g.r,g.g,g.b,i);c.uniform1f(A.uniforms.mShininess,f);c.uniform1i(A.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(A.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(A.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(A.uniforms.material,5);z=f.env_map}if(G){e(G,0);c.uniform1i(A.uniforms.tMap,
-0);c.uniform1i(A.uniforms.enableMap,1)}else c.uniform1i(A.uniforms.enableMap,0);if(z){d(z,1);c.uniform1i(A.uniforms.tCube,1);c.uniform1i(A.uniforms.enableCubeMap,1)}else c.uniform1i(A.uniforms.enableCubeMap,0);i=A.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
-c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(u){c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
-0)}};this.renderPass=function(g,l,f,p,j,i){var u,t,G,z,H;G=0;for(z=f.material.length;G<z;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(t=p.material.length;u<t;u++)if((H=p.material[u])&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}else if((H=u)&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}};this.render=function(g,l){var f,p,j,i,u=g.lights;this.initWebGLObjects(g);this.autoClear&&this.clear();
-l.autoUpdateMatrix&&l.updateMatrix();f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,l);this.renderPass(l,u,i,j,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,l);this.renderPass(l,u,i,j,THREE.AdditiveBlending,false);this.renderPass(l,u,i,j,THREE.SubtractiveBlending,false);this.renderPass(l,u,i,j,THREE.AdditiveBlending,true);
-this.renderPass(l,u,i,j,THREE.SubtractiveBlending,true);this.renderPass(l,u,i,j,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(g){var l,f,p,j,i,u;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}l=0;for(f=g.objects.length;l<f;l++){p=g.objects[l];if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};u=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(i in p.geometry.geometryChunks){j=p.geometry.geometryChunks[i];j.__webGLVertexBuffer||this.createBuffers(p,
-i);if(u[i]==undefined){j={buffer:j,object:p};g.__webGLObjects.push(j);u[i]=1}}}};this.removeObject=function(g,l){var f,p;for(f=g.__webGLObjects.length-1;f>=0;f--){p=g.__webGLObjects[f].object;l==p&&g.__webGLObjects.splice(f,1)}};this.setupMatrices=function(g,l){g.autoUpdateMatrix&&g.updateMatrix();s.multiply(l.matrix,g.matrix);E.set(l.matrix.flatten());M.set(s.flatten());O.set(l.projectionMatrix.flatten());r=THREE.Matrix4.makeInvert3x3(s).transpose();J.set(r.m);K.set(g.matrix.flatten())};this.loadMatrices=
-function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,E);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,M);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,O);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,l){c.uniform3f(g.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);
-break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,l){if(g){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.RenderableFace3=function(){this.z=null;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.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
-THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
+// ThreeDebug.js r31 - http://github.com/mrdoob/three.js
+var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
+THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
+","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", 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(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.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,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
+THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
+cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;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){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+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(){var a=
+Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},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,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
+THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.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(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
+return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(n,o){return n.distance-o.distance});return h},intersectObject:function(a){function b(P,J,K,w){w=w.clone().subSelf(J);K=K.clone().subSelf(J);var g=P.clone().subSelf(J);P=w.dot(w);J=w.dot(K);w=w.dot(g);var l=K.dot(K);K=K.dot(g);g=1/(P*l-J*J);l=(l*w-J*K)*g;P=(P*K-J*w)*g;return l>0&&P>0&&l+P<1}var d,e,h,n,o,k,m,c,A,y,
+r,s=a.geometry,E=s.vertices,L=[];d=0;for(e=s.faces.length;d<e;d++){h=s.faces[d];y=this.origin.clone();r=this.direction.clone();n=a.matrix.multiplyVector3(E[h.a].position.clone());o=a.matrix.multiplyVector3(E[h.b].position.clone());k=a.matrix.multiplyVector3(E[h.c].position.clone());m=h instanceof THREE.Face4?a.matrix.multiplyVector3(E[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());A=r.dot(c);if(A<0){c=c.dot((new THREE.Vector3).sub(n,y))/A;y=y.addSelf(r.multiplyScalar(c));
+if(h instanceof THREE.Face3){if(b(y,n,o,k)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};L.push(h)}}else if(h instanceof THREE.Face4)if(b(y,n,o,m)||b(y,o,k,m)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};L.push(h)}}}return L}};
+THREE.Rectangle=function(){function a(){n=e-b;o=h-d}var b,d,e,h,n,o,k=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return n};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(m,c,A,y){k=false;b=m;d=c;e=A;h=y;a()};this.addPoint=function(m,c){if(k){k=false;b=m;d=c;e=m;h=c}else{b=b<m?b:m;d=d<c?d:c;e=e>m?e:m;h=h>c?
+h:c}a()};this.add3Points=function(m,c,A,y,r,s){if(k){k=false;b=m<A?m<r?m:r:A<r?A:r;d=c<y?c<s?c:s:y<s?y:s;e=m>A?m>r?m:r:A>r?A:r;h=c>y?c>s?c:s:y>s?y:s}else{b=m<A?m<r?m<b?m:b:r<b?r:b:A<r?A<b?A:b:r<b?r:b;d=c<y?c<s?c<d?c:d:s<d?s:d:y<s?y<d?y:d:s<d?s:d;e=m>A?m>r?m>e?m:e:r>e?r:e:A>r?A>e?A:e:r>e?r:e;h=c>y?c>s?c>h?c:h:s>h?s:h:y>s?y>h?y:h:s>h?s:h}a()};this.addRectangle=function(m){if(k){k=false;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=b<m.getLeft()?b:m.getLeft();d=d<m.getTop()?d:m.getTop();
+e=e>m.getRight()?e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e<m.getRight()?e:m.getRight();h=h<m.getBottom()?h:m.getBottom();a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){k=true;h=e=d=b=0;a()};this.isEmpty=function(){return k};this.toString=
+function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+h+", width: "+n+", height: "+o+" )"}};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(a,b,d,e,h,n,o,k,m,c,A,y,r,s,E,L){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=h||0;this.n22=n||1;this.n23=o||0;this.n24=k||0;this.n31=m||0;this.n32=c||0;this.n33=A||1;this.n34=y||0;this.n41=r||0;this.n42=s||0;this.n43=E||0;this.n44=L||1};
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,h,n,o,k,m,c,A,y,r,s,E,L){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=n;this.n23=o;this.n24=k;this.n31=m;this.n32=c;this.n33=A;this.n34=y;this.n41=r;this.n42=s;this.n43=E;this.n44=L;return this},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;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();e.cross(d,n).normalize();h.cross(n,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x;
+this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
+h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,n=a.n14,o=a.n21,k=a.n22,m=a.n23,c=a.n24,A=a.n31,y=a.n32,
+r=a.n33,s=a.n34,E=a.n41,L=a.n42,P=a.n43,J=a.n44,K=b.n11,w=b.n12,g=b.n13,l=b.n14,f=b.n21,p=b.n22,i=b.n23,j=b.n24,u=b.n31,t=b.n32,G=b.n33,z=b.n34,H=b.n41,Q=b.n42,C=b.n43,O=b.n44;this.n11=d*K+e*f+h*u+n*H;this.n12=d*w+e*p+h*t+n*Q;this.n13=d*g+e*i+h*G+n*C;this.n14=d*l+e*j+h*z+n*O;this.n21=o*K+k*f+m*u+c*H;this.n22=o*w+k*p+m*t+c*Q;this.n23=o*g+k*i+m*G+c*C;this.n24=o*l+k*j+m*z+c*O;this.n31=A*K+y*f+r*u+s*H;this.n32=A*w+y*p+r*t+s*Q;this.n33=A*g+y*i+r*G+s*C;this.n34=A*l+y*j+r*z+s*O;this.n41=E*K+L*f+P*u+J*H;
+this.n42=E*w+L*p+P*t+J*Q;this.n43=E*g+L*i+P*G+J*C;this.n44=E*l+L*j+P*z+J*O;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,n=this.n21,o=this.n22,k=this.n23,m=this.n24,c=this.n31,A=this.n32,y=this.n33,r=this.n34,s=this.n41,E=this.n42,L=this.n43,P=this.n44,J=a.n11,K=a.n21,w=a.n31,g=a.n41,l=a.n12,f=a.n22,p=a.n32,i=a.n42,j=a.n13,u=a.n23,t=a.n33,G=a.n43,z=a.n14,H=a.n24,Q=a.n34;a=a.n44;this.n11=b*J+d*K+e*w+h*g;this.n12=b*l+d*f+e*p+h*i;this.n13=b*j+d*u+e*t+h*G;this.n14=
+b*z+d*H+e*Q+h*a;this.n21=n*J+o*K+k*w+m*g;this.n22=n*l+o*f+k*p+m*i;this.n23=n*j+o*u+k*t+m*G;this.n24=n*z+o*H+k*Q+m*a;this.n31=c*J+A*K+y*w+r*g;this.n32=c*l+A*f+y*p+r*i;this.n33=c*j+A*u+y*t+r*G;this.n34=c*z+A*H+y*Q+r*a;this.n41=s*J+E*K+L*w+P*g;this.n42=s*l+E*f+L*p+P*i;this.n43=s*j+E*u+L*t+P*G;this.n44=s*z+E*H+L*Q+P*a;return this},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;return this},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(b,d,e){var h=b[d];b[d]=b[e];
+b[e]=h}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(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};
+THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),h=Math.sin(b),n=1-e,o=a.x,k=a.y,m=a.z;d.n11=n*o*o+e;d.n12=n*o*k-h*m;d.n13=n*o*m+h*k;d.n21=n*o*k+h*m;d.n22=n*k*k+e;d.n23=n*k*m-h*o;d.n31=n*o*m-h*k;d.n32=n*k*m+h*o;d.n33=n*m*m+e;return d};
+THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
+a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
+a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
+a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],A=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*o;a.m[5]=b*k;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*A;return a};
+THREE.Matrix4.makeFrustum=function(a,b,d,e,h,n){var o,k,m;o=new THREE.Matrix4;k=2*h/(b-a);m=2*h/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(n+h)/(n-h);h=-2*n*h/(n-h);o.n11=k;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=m;o.n23=d;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=h;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)};
+THREE.Matrix4.makeOrtho=function(a,b,d,e,h,n){var o,k,m,c;o=new THREE.Matrix4;k=b-a;m=d-e;c=n-h;a=(b+a)/k;d=(d+e)/m;h=(n+h)/c;o.n11=2/k;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/m;o.n23=0;o.n24=-d;o.n31=0;o.n32=0;o.n33=-2/c;o.n34=-h;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
+THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
+THREE.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,b,d,e,h,n){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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=[];this.geometryChunks={};this.hasTangents=false};
+THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,h,n,o,k=new THREE.Vector3,m=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){n=this.vertices[e];n.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];if(a&&n.vertexNormals.length){k.set(0,0,0);b=0;for(d=n.normal.length;b<d;b++)k.addSelf(n.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[n.a];d=this.vertices[n.b];o=this.vertices[n.c];k.sub(o.position,
+d.position);m.sub(b.position,d.position);k.crossSelf(m)}k.isZero()||k.normalize();n.normal.copy(k)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeTangents:function(){function a(z,H,Q,C){n=z.vertices[H].position;o=z.vertices[Q].position;
+k=z.vertices[C].position;m=h[0];c=h[1];A=h[2];y=o.x-n.x;r=k.x-n.x;s=o.y-n.y;E=k.y-n.y;L=o.z-n.z;P=k.z-n.z;J=c.u-m.u;K=A.u-m.u;w=c.v-m.v;g=A.v-m.v;l=1/(J*g-K*w);j.set((g*y-w*r)*l,(g*s-w*E)*l,(g*L-w*P)*l);u.set((J*r-K*y)*l,(J*E-K*s)*l,(J*P-K*L)*l);p[H].addSelf(j);p[Q].addSelf(j);p[C].addSelf(j);i[H].addSelf(u);i[Q].addSelf(u);i[C].addSelf(u)}var b,d,e,h,n,o,k,m,c,A,y,r,s,E,L,P,J,K,w,g,l,f,p=[],i=[],j=new THREE.Vector3,u=new THREE.Vector3,t=new THREE.Vector3,G=new THREE.Vector3;f=new THREE.Vector3;b=
+0;for(d=this.vertices.length;b<d;b++){p[b]=new THREE.Vector3;i[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];h=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
+this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){f.copy(this.vertices[b].normal);e=p[b];t.copy(e);t.subSelf(f.multiplyScalar(f.dot(e))).normalize();G.cross(this.vertices[b].normal,e);test=G.dot(i[b]);e=test<0?-1:1;this.vertices[b].tangent.set(t.x,t.y,t.z,e)}this.hasTangents=true},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}}},sortFacesByMaterial:function(){function a(A){var y=[];b=0;for(d=A.length;b<d;b++)A[b]==undefined?y.push("undefined"):y.push(A[b].toString());return y.join("_")}var b,d,e,h,n,o,k,m,c={};e=0;for(h=this.faces.length;e<h;e++){n=this.faces[e];o=n.material;k=a(o);if(c[k]==undefined)c[k]={hash:k,counter:0};m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,
+vertices:0};n=n instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+n>65535){c[k].counter+=1;m=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:o,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
+THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
+this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(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(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
+THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
+this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
+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(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
+THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
+THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,h;a=0;for(b=this.geometry.uvs.length;a<b;a++){h=this.geometry.uvs[a];d=0;for(e=h.length;d<e;d++){if(h[d].u!=1)h[d].u-=Math.floor(h[d].u);if(h[d].v!=1)h[d].v-=Math.floor(h[d].v)}}};THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
+THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){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;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
+THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
+THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
+THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(15658734);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
+"round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
+a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
+a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
+THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.blending=THREE.NormalBlending;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.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};
+THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
+THREE.MeshCubeMaterial=function(a){this.id=THREE.MeshCubeMaterial.value++;this.env_map=null;this.blending=THREE.NormalBlending;if(a)if(a.env_map!==undefined)this.env_map=a.env_map;this.toString=function(){return"THREE.MeshCubeMaterial( id: "+this.id+"<br/>env_map: "+this.env_map+" )"}};THREE.MeshCubeMaterialCounter={value:0};
+THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
+undefined)this.uniforms=a.uniforms;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;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
+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){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){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(a,b,d,e,h,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
+this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
+THREE.Projector=function(){function a(K,w){var g=0,l=1,f=K.z+K.w,p=w.z+w.w,i=-K.z+K.w,j=-w.z+w.w;if(f>=0&&p>=0&&i>=0&&j>=0)return true;else if(f<0&&p<0||i<0&&j<0)return false;else{if(f<0)g=Math.max(g,f/(f-p));else if(p<0)l=Math.min(l,f/(f-p));if(i<0)g=Math.max(g,i/(i-j));else if(j<0)l=Math.min(l,i/(i-j));if(l<g)return false;else{K.lerpSelf(w,g);w.lerpSelf(K,1-l);return true}}}var b=null,d,e,h,n=[],o,k,m=[],c,A,y=[],r=new THREE.Vector4,s=new THREE.Matrix4,E=new THREE.Matrix4,L=new THREE.Vector4,P=
+new THREE.Vector4,J;this.projectScene=function(K,w){var g,l,f,p,i,j,u,t,G,z,H,Q,C,O,D,R,S;b=[];h=k=A=0;w.autoUpdateMatrix&&w.updateMatrix();s.multiply(w.projectionMatrix,w.matrix);u=K.objects;g=0;for(l=u.length;g<l;g++){t=u[g];t.autoUpdateMatrix&&t.updateMatrix();G=t.matrix;z=t.rotationMatrix;H=t.material;Q=t.overdraw;if(t instanceof THREE.Mesh){C=t.geometry;O=C.vertices;f=0;for(p=O.length;f<p;f++){D=O[f];D.positionWorld.copy(D.position);G.multiplyVector3(D.positionWorld);i=D.positionScreen;i.copy(D.positionWorld);
+s.multiplyVector4(i);i.multiplyScalar(1/i.w);D.__visible=i.z>0&&i.z<1}C=C.faces;f=0;for(p=C.length;f<p;f++){D=C[f];if(D instanceof THREE.Face3){i=O[D.a];j=O[D.b];R=O[D.c];if(i.__visible&&j.__visible&&R.__visible)if(t.doubleSided||t.flipSided!=(R.positionScreen.x-i.positionScreen.x)*(j.positionScreen.y-i.positionScreen.y)-(R.positionScreen.y-i.positionScreen.y)*(j.positionScreen.x-i.positionScreen.x)<0){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(i.positionWorld);d.v2.positionWorld.copy(j.positionWorld);
+d.v3.positionWorld.copy(R.positionWorld);d.v1.positionScreen.copy(i.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(R.positionScreen);d.normalWorld.copy(D.normal);z.multiplyVector3(d.normalWorld);d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);s.multiplyVector3(d.centroidScreen);R=D.vertexNormals;J=d.vertexNormalsWorld;i=0;for(j=R.length;i<j;i++){S=J[i]=J[i]||new THREE.Vector3;S.copy(R[i]);z.multiplyVector3(S)}d.z=
+d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(t.geometry.uvs[f]){d.uvs[0]=t.geometry.uvs[f][0];d.uvs[1]=t.geometry.uvs[f][1];d.uvs[2]=t.geometry.uvs[f][2]}b.push(d);h++}}else if(D instanceof THREE.Face4){i=O[D.a];j=O[D.b];R=O[D.c];S=O[D.d];if(i.__visible&&j.__visible&&R.__visible&&S.__visible)if(t.doubleSided||t.flipSided!=((S.positionScreen.x-i.positionScreen.x)*(j.positionScreen.y-i.positionScreen.y)-(S.positionScreen.y-i.positionScreen.y)*(j.positionScreen.x-i.positionScreen.x)<
+0||(j.positionScreen.x-R.positionScreen.x)*(S.positionScreen.y-R.positionScreen.y)-(j.positionScreen.y-R.positionScreen.y)*(S.positionScreen.x-R.positionScreen.x)<0)){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(i.positionWorld);d.v2.positionWorld.copy(j.positionWorld);d.v3.positionWorld.copy(S.positionWorld);d.v1.positionScreen.copy(i.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(S.positionScreen);d.normalWorld.copy(D.normal);z.multiplyVector3(d.normalWorld);
+d.centroidWorld.copy(D.centroid);G.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);s.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=H;d.faceMaterial=D.material;d.overdraw=Q;if(t.geometry.uvs[f]){d.uvs[0]=t.geometry.uvs[f][0];d.uvs[1]=t.geometry.uvs[f][1];d.uvs[2]=t.geometry.uvs[f][3]}b.push(d);h++;e=n[h]=n[h]||new THREE.RenderableFace3;e.v1.positionWorld.copy(j.positionWorld);e.v2.positionWorld.copy(R.positionWorld);e.v3.positionWorld.copy(S.positionWorld);
+e.v1.positionScreen.copy(j.positionScreen);e.v2.positionScreen.copy(R.positionScreen);e.v3.positionScreen.copy(S.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=H;e.faceMaterial=D.material;e.overdraw=Q;if(t.geometry.uvs[f]){e.uvs[0]=t.geometry.uvs[f][1];e.uvs[1]=t.geometry.uvs[f][2];e.uvs[2]=t.geometry.uvs[f][3]}b.push(e);h++}}}}else if(t instanceof THREE.Line){E.multiply(s,G);O=t.geometry.vertices;
+D=O[0];D.positionScreen.copy(D.position);E.multiplyVector4(D.positionScreen);f=1;for(p=O.length;f<p;f++){i=O[f];i.positionScreen.copy(i.position);E.multiplyVector4(i.positionScreen);j=O[f-1];L.copy(i.positionScreen);P.copy(j.positionScreen);if(a(L,P)){L.multiplyScalar(1/L.w);P.multiplyScalar(1/P.w);o=m[k]=m[k]||new THREE.RenderableLine;o.v1.positionScreen.copy(L);o.v2.positionScreen.copy(P);o.z=Math.max(L.z,P.z);o.material=t.material;b.push(o);k++}}}else if(t instanceof THREE.Particle){r.set(t.position.x,
+t.position.y,t.position.z,1);s.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=y[A]=y[A]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=t.rotation.z;c.scale.x=t.scale.x*Math.abs(c.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14));c.scale.y=t.scale.y*Math.abs(c.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));c.material=t.material;b.push(c);A++}}}b.sort(function(I,v){return v.z-I.z});return b};this.unprojectVector=function(K,w){var g=new THREE.Matrix4;
+g.multiply(THREE.Matrix4.makeInvert(w.matrix),THREE.Matrix4.makeInvert(w.projectionMatrix));g.multiplyVector3(K);return K}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,h,n;this.domElement=document.createElement("div");this.setSize=function(o,k){d=o;e=k;h=d/2;n=e/2};this.render=function(o,k){var m,c,A,y,r,s,E,L;a=b.projectScene(o,k);m=0;for(c=a.length;m<c;m++){r=a[m];if(r instanceof THREE.RenderableParticle){E=r.x*h+h;L=r.y*n+n;A=0;for(y=r.material.length;A<y;A++){s=r.material[A];if(s instanceof THREE.ParticleDOMMaterial){s=s.domElement;s.style.left=E+"px";s.style.top=L+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,h,n,o,k=d.getContext("2d"),m=1,c=0,A=null,y=null,r=1,s,E,L,P,J,K,w,g,l,f=new THREE.Color,p=new THREE.Color,i=new THREE.Color,j=new THREE.Color,u=new THREE.Color,t,G,z,H,Q,C,O,D,R,S,I=new THREE.Rectangle,v=new THREE.Rectangle,B=new THREE.Rectangle,W=false,Y=new THREE.Color,N=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,X=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
+na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=d;this.autoClear=true;this.setSize=function(ga,ua){e=ga;h=ua;n=e/2;o=h/2;d.width=e;d.height=h;I.set(-n,-o,n,o)};this.clear=function(){if(!v.isEmpty()){v.inflate(1);v.minSelf(I);k.clearRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());
+v.empty()}};this.render=function(ga,ua){function Ka(q){var T,M,x,F=q.lights;N.setRGB(0,0,0);U.setRGB(0,0,0);aa.setRGB(0,0,0);q=0;for(T=F.length;q<T;q++){M=F[q];x=M.color;if(M instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(M instanceof THREE.DirectionalLight){U.r+=x.r;U.g+=x.g;U.b+=x.b}else if(M instanceof THREE.PointLight){aa.r+=x.r;aa.g+=x.g;aa.b+=x.b}}}function va(q,T,M,x){var F,V,$,ba,ca=q.lights;q=0;for(F=ca.length;q<F;q++){V=ca[q];$=V.color;ba=V.intensity;if(V instanceof THREE.DirectionalLight){V=
+M.dot(V.position)*ba;if(V>0){x.r+=$.r*V;x.g+=$.g*V;x.b+=$.b*V}}else if(V instanceof THREE.PointLight){X.sub(V.position,T);X.normalize();V=M.dot(X)*ba;if(V>0){x.r+=$.r*V;x.g+=$.g*V;x.b+=$.b*V}}}}function La(q,T,M){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);var x,F,V,$,ba,ca;if(M instanceof THREE.ParticleBasicMaterial){if(M.map){$=M.map;ba=$.width>>1;ca=$.height>>1;F=T.scale.x*n;V=T.scale.y*o;M=F*ba;x=V*ca;B.set(q.x-M,q.y-x,q.x+M,q.y+x);if(!I.instersects(B))return;k.save();k.translate(q.x,q.y);k.rotate(-T.rotation);
+k.scale(F,-V);k.translate(-ba,-ca);k.drawImage($,0,0);k.restore()}k.beginPath();k.moveTo(q.x-10,q.y);k.lineTo(q.x+10,q.y);k.moveTo(q.x,q.y-10);k.lineTo(q.x,q.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(M instanceof THREE.ParticleCircleMaterial){if(W){Y.r=N.r+U.r+aa.r;Y.g=N.g+U.g+aa.g;Y.b=N.b+U.b+aa.b;f.r=M.color.r*Y.r;f.g=M.color.g*Y.g;f.b=M.color.b*Y.b;f.updateStyleString()}else f.__styleString=M.color.__styleString;M=T.scale.x*n;x=T.scale.y*o;B.set(q.x-M,q.y-x,q.x+M,q.y+
+x);if(I.instersects(B)){F=f.__styleString;if(y!=F)k.fillStyle=y=F;k.save();k.translate(q.x,q.y);k.rotate(-T.rotation);k.scale(M,x);k.beginPath();k.arc(0,0,1,0,Ja,true);k.closePath();k.fill();k.restore()}}}}function Ma(q,T,M,x){if(x.opacity!=0){Ba(x.opacity);wa(x.blending);k.beginPath();k.moveTo(q.positionScreen.x,q.positionScreen.y);k.lineTo(T.positionScreen.x,T.positionScreen.y);k.closePath();if(x instanceof THREE.LineBasicMaterial){f.__styleString=x.color.__styleString;q=x.linewidth;if(r!=q)k.lineWidth=
+r=q;q=f.__styleString;if(A!=q)k.strokeStyle=A=q;k.stroke();B.inflate(x.linewidth*2)}}}function Fa(q,T,M,x,F,V){if(F.opacity!=0){Ba(F.opacity);wa(F.blending);P=q.positionScreen.x;J=q.positionScreen.y;K=T.positionScreen.x;w=T.positionScreen.y;g=M.positionScreen.x;l=M.positionScreen.y;k.beginPath();k.moveTo(P,J);k.lineTo(K,w);k.lineTo(g,l);k.lineTo(P,J);k.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(P,J,K,w,g,l,F.map.image,
+x.uvs[0].u,x.uvs[0].v,x.uvs[1].u,x.uvs[1].v,x.uvs[2].u,x.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){q=ua.matrix;X.copy(x.vertexNormalsWorld[0]);Q=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;C=-(X.x*q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;X.copy(x.vertexNormalsWorld[1]);O=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;D=-(X.x*q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;X.copy(x.vertexNormalsWorld[2]);R=(X.x*q.n11+X.y*q.n12+X.z*q.n13)*0.5+0.5;S=-(X.x*
+q.n21+X.y*q.n22+X.z*q.n23)*0.5+0.5;qa(P,J,K,w,g,l,F.env_map.image,Q,C,O,D,R,S)}}else F.wireframe?xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString);else if(F instanceof THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(P,J,K,w,g,l,F.map.image,x.uvs[0].u,x.uvs[0].v,x.uvs[1].u,x.uvs[1].v,x.uvs[2].u,x.uvs[2].v);wa(THREE.SubtractiveBlending)}if(W)if(!F.wireframe&&F.shading==THREE.SmoothShading&&x.vertexNormalsWorld.length==3){p.r=i.r=
+j.r=N.r;p.g=i.g=j.g=N.g;p.b=i.b=j.b=N.b;va(V,x.v1.positionWorld,x.vertexNormalsWorld[0],p);va(V,x.v2.positionWorld,x.vertexNormalsWorld[1],i);va(V,x.v3.positionWorld,x.vertexNormalsWorld[2],j);u.r=(i.r+j.r)*0.5;u.g=(i.g+j.g)*0.5;u.b=(i.b+j.b)*0.5;H=Ga(p,i,j,u);qa(P,J,K,w,g,l,H,0,0,1,0,0,1)}else{Y.r=N.r;Y.g=N.g;Y.b=N.b;va(V,x.centroidWorld,x.normalWorld,Y);f.r=F.color.r*Y.r;f.g=F.color.g*Y.g;f.b=F.color.b*Y.b;f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}else F.wireframe?
+xa(F.color.__styleString,F.wireframe_linewidth):ya(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){t=F.__2near;G=F.__farPlusNear;z=F.__farMinusNear;p.r=p.g=p.b=1-t/(G-q.positionScreen.z*z);i.r=i.g=i.b=1-t/(G-T.positionScreen.z*z);j.r=j.g=j.b=1-t/(G-M.positionScreen.z*z);u.r=(i.r+j.r)*0.5;u.g=(i.g+j.g)*0.5;u.b=(i.b+j.b)*0.5;H=Ga(p,i,j,u);qa(P,J,K,w,g,l,H,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){f.r=Ca(x.normalWorld.x);f.g=Ca(x.normalWorld.y);f.b=Ca(x.normalWorld.z);
+f.updateStyleString();F.wireframe?xa(f.__styleString,F.wireframe_linewidth):ya(f.__styleString)}}}function xa(q,T){if(A!=q)k.strokeStyle=A=q;if(r!=T)k.lineWidth=r=T;k.stroke();B.inflate(T*2)}function ya(q){if(y!=q)k.fillStyle=y=q;k.fill()}function qa(q,T,M,x,F,V,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;M-=q;x-=T;F-=q;V-=T;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*M-ea*F)*ja;ea=(ra*x-ea*V)*ja;M=(ha*F-ia*M)*ja;x=(ha*V-ia*x)*ja;q=
+q-ka*ba-M*ca;T=T-ea*ba-x*ca;k.save();k.transform(ka,ea,M,x,q,T);k.clip();k.drawImage($,0,0);k.restore()}function Ba(q){if(m!=q)k.globalAlpha=m=q}function wa(q){if(c!=q){switch(q){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=q}}function Ga(q,T,M,x){var F=~~(q.r*255),V=~~(q.g*255);q=~~(q.b*255);var $=~~(T.r*255),ba=~~(T.g*255);T=~~(T.b*
+255);var ca=~~(M.r*255),ha=~~(M.g*255);M=~~(M.b*255);var ea=~~(x.r*255),ia=~~(x.g*255);x=~~(x.b*255);da[0]=F<0?0:F>255?255:F;da[1]=V<0?0:V>255?255:V;da[2]=q<0?0:q>255?255:q;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=M<0?0:M>255?255:M;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=x<0?0:x>255?255:x;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(q){q=(q+1)*0.5;return q<0?
+0:q>1?1:q}function Da(q,T){var M=T.x-q.x,x=T.y-q.y,F=1/Math.sqrt(M*M+x*x);M*=F;x*=F;T.x+=M;T.y+=x;q.x-=M;q.y-=x}var za,Ha,Z,fa,ma,Ea,Ia,sa;k.setTransform(1,0,0,-1,n,o);this.autoClear&&this.clear();a=b.projectScene(ga,ua);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());(W=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];B.empty();if(Z instanceof THREE.RenderableParticle){s=Z;s.x*=n;s.y*=o;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(s,
+Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){s=Z.v1;E=Z.v2;s.positionScreen.x*=n;s.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=o;B.addPoint(s.positionScreen.x,s.positionScreen.y);B.addPoint(E.positionScreen.x,E.positionScreen.y);if(I.instersects(B)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(s,E,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){s=Z.v1;E=Z.v2;L=Z.v3;s.positionScreen.x*=n;s.positionScreen.y*=o;E.positionScreen.x*=n;E.positionScreen.y*=
+o;L.positionScreen.x*=n;L.positionScreen.y*=o;if(Z.overdraw){Da(s.positionScreen,E.positionScreen);Da(E.positionScreen,L.positionScreen);Da(L.positionScreen,s.positionScreen)}B.add3Points(s.positionScreen.x,s.positionScreen.y,E.positionScreen.x,E.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(I.instersects(B)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(s,
+E,L,Z,sa,ga)}else Fa(s,E,L,Z,sa,ga)}}}v.addRectangle(B)}k.lineWidth=1;k.strokeStyle="rgba( 255, 0, 0, 0.5 )";k.strokeRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());k.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(D,R,S){var I,v,B,W;I=0;for(v=D.lights.length;I<v;I++){B=D.lights[I];if(B instanceof THREE.DirectionalLight){W=R.normalWorld.dot(B.position)*B.intensity;if(W>0){S.r+=B.color.r*W;S.g+=B.color.g*W;S.b+=B.color.b*W}}else if(B instanceof THREE.PointLight){j.sub(B.position,R.centroidWorld);j.normalize();W=R.normalWorld.dot(j)*B.intensity;if(W>0){S.r+=B.color.r*W;S.g+=B.color.g*W;S.b+=B.color.b*W}}}}function b(D,R,S,I,v,B){z=e(H++);z.setAttribute("d","M "+D.positionScreen.x+
+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(v instanceof THREE.MeshBasicMaterial)w.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshLambertMaterial)if(K){g.r=l.r;g.g=l.g;g.b=l.b;a(B,I,g);w.r=v.color.r*g.r;w.g=v.color.g*g.g;w.b=v.color.b*g.b;w.updateStyleString()}else w.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshDepthMaterial){i=1-v.__2near/(v.__farPlusNear-I.z*v.__farMinusNear);
+w.setRGB(i,i,i)}else v instanceof THREE.MeshNormalMaterial&&w.setRGB(h(I.normalWorld.x),h(I.normalWorld.y),h(I.normalWorld.z));v.wireframe?z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+v.wireframe_linewidth+"; stroke-opacity: "+v.opacity+"; stroke-linecap: "+v.wireframe_linecap+"; stroke-linejoin: "+v.wireframe_linejoin):z.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+v.opacity);k.appendChild(z)}function d(D,R,S,I,v,B,W){z=e(H++);z.setAttribute("d",
+"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)w.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(K){g.r=l.r;g.g=l.g;g.b=l.b;a(W,v,g);w.r=B.color.r*g.r;w.g=B.color.g*g.g;w.b=B.color.b*g.b;w.updateStyleString()}else w.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){i=
+1-B.__2near/(B.__farPlusNear-v.z*B.__farMinusNear);w.setRGB(i,i,i)}else B instanceof THREE.MeshNormalMaterial&&w.setRGB(h(v.normalWorld.x),h(v.normalWorld.y),h(v.normalWorld.z));B.wireframe?z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):z.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+B.opacity);k.appendChild(z)}
+function e(D){if(u[D]==null){u[D]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&u[D].setAttribute("shape-rendering","crispEdges");return u[D]}return u[D]}function h(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var n=null,o=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,A,y,r,s,E,L,P=new THREE.Rectangle,J=new THREE.Rectangle,K=false,w=new THREE.Color(16777215),g=new THREE.Color(16777215),l=new THREE.Color(0),f=new THREE.Color(0),
+p=new THREE.Color(0),i,j=new THREE.Vector3,u=[],t=[],G=[],z,H,Q,C,O=1;this.domElement=k;this.autoClear=true;this.setQuality=function(D){switch(D){case "high":O=1;break;case "low":O=0}};this.setSize=function(D,R){m=D;c=R;A=m/2;y=c/2;k.setAttribute("viewBox",-A+" "+-y+" "+m+" "+c);k.setAttribute("width",m);k.setAttribute("height",c);P.set(-A,-y,A,y)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(D,R){var S,I,v,B,W,Y,N,U;this.autoClear&&this.clear();
+n=o.projectScene(D,R);C=Q=H=0;if(K=D.lights.length>0){N=D.lights;l.setRGB(0,0,0);f.setRGB(0,0,0);p.setRGB(0,0,0);S=0;for(I=N.length;S<I;S++){v=N[S];B=v.color;if(v instanceof THREE.AmbientLight){l.r+=B.r;l.g+=B.g;l.b+=B.b}else if(v instanceof THREE.DirectionalLight){f.r+=B.r;f.g+=B.g;f.b+=B.b}else if(v instanceof THREE.PointLight){p.r+=B.r;p.g+=B.g;p.b+=B.b}}}S=0;for(I=n.length;S<I;S++){N=n[S];J.empty();if(N instanceof THREE.RenderableParticle){r=N;r.x*=A;r.y*=-y;v=0;for(B=N.material.length;v<B;v++)if(U=
+N.material[v]){W=r;Y=N;U=U;var aa=Q++;if(t[aa]==null){t[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");O==0&&t[aa].setAttribute("shape-rendering","crispEdges")}z=t[aa];z.setAttribute("cx",W.x);z.setAttribute("cy",W.y);z.setAttribute("r",Y.scale.x*A);if(U instanceof THREE.ParticleCircleMaterial){if(K){g.r=l.r+f.r+p.r;g.g=l.g+f.g+p.g;g.b=l.b+f.b+p.b;w.r=U.color.r*g.r;w.g=U.color.g*g.g;w.b=U.color.b*g.b;w.updateStyleString()}else w=U.color;z.setAttribute("style","fill: "+w.__styleString)}k.appendChild(z)}}else if(N instanceof
+THREE.RenderableLine){r=N.v1;s=N.v2;r.positionScreen.x*=A;r.positionScreen.y*=-y;s.positionScreen.x*=A;s.positionScreen.y*=-y;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(s.positionScreen.x,s.positionScreen.y);if(P.instersects(J)){v=0;for(B=N.material.length;v<B;)if(U=N.material[v++]){W=r;Y=s;U=U;aa=C++;if(G[aa]==null){G[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");O==0&&G[aa].setAttribute("shape-rendering","crispEdges")}z=G[aa];z.setAttribute("x1",W.positionScreen.x);
+z.setAttribute("y1",W.positionScreen.y);z.setAttribute("x2",Y.positionScreen.x);z.setAttribute("y2",Y.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){w.__styleString=U.color.__styleString;z.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);k.appendChild(z)}}}}else if(N instanceof THREE.RenderableFace3){r=N.v1;s=N.v2;E=N.v3;r.positionScreen.x*=A;r.positionScreen.y*=
+-y;s.positionScreen.x*=A;s.positionScreen.y*=-y;E.positionScreen.x*=A;E.positionScreen.y*=-y;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);if(P.instersects(J)){v=0;for(B=N.meshMaterial.length;v<B;){U=N.meshMaterial[v++];if(U instanceof THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&b(r,s,E,N,U,D)}else U&&b(r,s,E,N,U,D)}}}else if(N instanceof THREE.RenderableFace4){r=
+N.v1;s=N.v2;E=N.v3;L=N.v4;r.positionScreen.x*=A;r.positionScreen.y*=-y;s.positionScreen.x*=A;s.positionScreen.y*=-y;E.positionScreen.x*=A;E.positionScreen.y*=-y;L.positionScreen.x*=A;L.positionScreen.y*=-y;J.addPoint(r.positionScreen.x,r.positionScreen.y);J.addPoint(s.positionScreen.x,s.positionScreen.y);J.addPoint(E.positionScreen.x,E.positionScreen.y);J.addPoint(L.positionScreen.x,L.positionScreen.y);if(P.instersects(J)){v=0;for(B=N.meshMaterial.length;v<B;){U=N.meshMaterial[v++];if(U instanceof
+THREE.MeshFaceMaterial){W=0;for(Y=N.faceMaterial.length;W<Y;)(U=N.faceMaterial[W++])&&d(r,s,E,L,N,U,D)}else U&&d(r,s,E,L,N,U,D)}}}}}};
+THREE.WebGLRenderer=function(a){function b(g,l){var f=c.createProgram(),p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(f,o("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+
+g));c.attachShader(f,o("vertex",p+l));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function d(g,l){if(g.image.length==6){if(!g.image.__webGLTextureCube&&!g.image.__cubeMapInitialized&&g.image.loadCount==6){g.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,g.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
+c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);g.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP,
+g.image.__webGLTextureCube)}}function e(g,l){if(!g.__webGLTexture&&g.image.loaded){g.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,g.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,g.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(g.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(g.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(g.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,k(g.min_filter));c.generateMipmap(c.TEXTURE_2D);
+c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,g.__webGLTexture)}function h(g,l){var f,p,i;f=0;for(p=l.length;f<p;f++){i=l[f];g.uniforms[i]=c.getUniformLocation(g,i)}}function n(g,l){var f,p,i;f=0;for(p=l.length;f<p;f++){i=l[f];g.attributes[i]=c.getAttribLocation(g,i);g.attributes[i]>=0&&c.enableVertexAttribArray(g.attributes[i])}}function o(g,l){var f;if(g=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(g=="vertex")f=c.createShader(c.VERTEX_SHADER);
+c.shaderSource(f,l);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function k(g){switch(g){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
+case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var m=document.createElement("canvas"),c,A,y,r=new THREE.Matrix4,s,E=new Float32Array(16),L=new Float32Array(16),P=new Float32Array(16),J=new Float32Array(9),K=new Float32Array(16);a=function(g,l){if(g){var f,p,i,j=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=g.lights.length;f<p;f++){i=g.lights[f];i instanceof THREE.DirectionalLight&&j++;i instanceof
+THREE.PointLight&&pointLights++}if(pointLights+j<=l){maxDirLights=j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(l*j/(pointLights+j));maxPointLights=l-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:l-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(w){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
+c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);A=y=function(g,l){var f=[g?"#define MAX_DIR_LIGHTS "+g:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",g?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
+"",l?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",l?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
+g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",g?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",g?"}":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",l?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
+"",l?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",l?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",l?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
+p=[g?"#define MAX_DIR_LIGHTS "+g:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
+g?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
+l?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",l?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",l?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",l?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",l?"float pointSpecularWeight = 0.0;":"",l?"if ( pointDotNormalHalf >= 0.0 )":
+"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse  += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",g?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",g?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",g?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",g?"vec3 dirVector = normalize( lDirection.xyz );":"",g?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
+"",g?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",g?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",g?"float dirSpecularWeight = 0.0;":"",g?"if ( dirDotNormalHalf >= 0.0 )":"",g?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",g?"dirDiffuse  += mColor * dirDiffuseWeight;":"",g?"dirSpecular += mSpecular * dirSpecularWeight;":"",g?"}":"","vec4 totalLight = mAmbient;",g?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;":
+"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
+f=b(p,f);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);g&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&h(f,["pointLightNumber","pointLightColor",
+"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);n(f,["position","normal","uv"]);return f}(a.directional,a.point);this.setSize=function(g,l){m.width=g;m.height=l;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(g,l){var f,p,i,j,u,t=[],
+G=[],z=[];j=[];u=[];c.uniform1i(g.uniforms.enableLighting,l.length);f=0;for(p=l.length;f<p;f++){i=l[f];if(i instanceof THREE.AmbientLight)t.push(i);else if(i instanceof THREE.DirectionalLight)z.push(i);else i instanceof THREE.PointLight&&G.push(i)}f=i=j=u=0;for(p=t.length;f<p;f++){i+=t[f].color.r;j+=t[f].color.g;u+=t[f].color.b}c.uniform3f(g.uniforms.ambientLightColor,i,j,u);j=[];u=[];f=0;for(p=z.length;f<p;f++){i=z[f];j.push(i.color.r*i.intensity);j.push(i.color.g*i.intensity);j.push(i.color.b*i.intensity);
+u.push(i.position.x);u.push(i.position.y);u.push(i.position.z)}if(z.length){c.uniform1i(g.uniforms.directionalLightNumber,z.length);c.uniform3fv(g.uniforms.directionalLightDirection,u);c.uniform3fv(g.uniforms.directionalLightColor,j)}j=[];u=[];f=0;for(p=G.length;f<p;f++){i=G[f];j.push(i.color.r*i.intensity);j.push(i.color.g*i.intensity);j.push(i.color.b*i.intensity);u.push(i.position.x);u.push(i.position.y);u.push(i.position.z)}if(G.length){c.uniform1i(g.uniforms.pointLightNumber,G.length);c.uniform3fv(g.uniforms.pointLightPosition,
+u);c.uniform3fv(g.uniforms.pointLightColor,j)}};this.createBuffers=function(g,l){var f,p,i,j,u,t,G,z,H,Q=[],C=[],O=[],D=[],R=[],S=[],I=0,v=g.geometry.geometryChunks[l],B;i=false;f=0;for(p=g.material.length;f<p;f++){meshMaterial=g.material[f];if(meshMaterial instanceof THREE.MeshFaceMaterial){u=0;for(B=v.material.length;u<B;u++)if(v.material[u]&&v.material[u].shading!=undefined&&v.material[u].shading==THREE.SmoothShading){i=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
+THREE.SmoothShading){i=true;break}if(i)break}B=i;f=0;for(p=v.faces.length;f<p;f++){i=v.faces[f];j=g.geometry.faces[i];u=j.vertexNormals;faceNormal=j.normal;i=g.geometry.uvs[i];if(j instanceof THREE.Face3){t=g.geometry.vertices[j.a].position;G=g.geometry.vertices[j.b].position;z=g.geometry.vertices[j.c].position;O.push(t.x,t.y,t.z);O.push(G.x,G.y,G.z);O.push(z.x,z.y,z.z);if(g.geometry.hasTangents){t=g.geometry.vertices[j.a].tangent;G=g.geometry.vertices[j.b].tangent;z=g.geometry.vertices[j.c].tangent;
+R.push(t.x,t.y,t.z,t.w);R.push(G.x,G.y,G.z,G.w);R.push(z.x,z.y,z.z,z.w)}if(u.length==3&&B)for(j=0;j<3;j++)D.push(u[j].x,u[j].y,u[j].z);else for(j=0;j<3;j++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(i)for(j=0;j<3;j++)S.push(i[j].u,i[j].v);Q.push(I,I+1,I+2);C.push(I,I+1);C.push(I,I+2);C.push(I+1,I+2);I+=3}else if(j instanceof THREE.Face4){t=g.geometry.vertices[j.a].position;G=g.geometry.vertices[j.b].position;z=g.geometry.vertices[j.c].position;H=g.geometry.vertices[j.d].position;O.push(t.x,
+t.y,t.z);O.push(G.x,G.y,G.z);O.push(z.x,z.y,z.z);O.push(H.x,H.y,H.z);if(g.geometry.hasTangents){t=g.geometry.vertices[j.a].tangent;G=g.geometry.vertices[j.b].tangent;z=g.geometry.vertices[j.c].tangent;j=g.geometry.vertices[j.d].tangent;R.push(t.x,t.y,t.z,t.w);R.push(G.x,G.y,G.z,G.w);R.push(z.x,z.y,z.z,z.w);R.push(j.x,j.y,j.z,j.w)}if(u.length==4&&B)for(j=0;j<4;j++)D.push(u[j].x,u[j].y,u[j].z);else for(j=0;j<4;j++)D.push(faceNormal.x,faceNormal.y,faceNormal.z);if(i)for(j=0;j<4;j++)S.push(i[j].u,i[j].v);
+Q.push(I,I+1,I+2);Q.push(I,I+2,I+3);C.push(I,I+1);C.push(I,I+2);C.push(I,I+3);C.push(I+1,I+2);C.push(I+2,I+3);I+=4}}if(O.length){v.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(O),c.STATIC_DRAW);v.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);if(g.geometry.hasTangents){v.__webGLTangentBuffer=c.createBuffer();
+c.bindBuffer(c.ARRAY_BUFFER,v.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}if(S.length>0){v.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW)}v.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);v.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+v.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(C),c.STATIC_DRAW);v.__webGLFaceCount=Q.length;v.__webGLLineCount=C.length}};this.renderBuffer=function(g,l,f,p){var i,j,u,t,G,z,H,Q,C;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(C in f.uniforms)H.push(C);h(f.program,H);n(f.program,["position","normal","uv","tangent"])}C=
+f.program}else C=y;if(C!=A){c.useProgram(C);A=C}C==y&&this.setupLights(C,l);this.loadCamera(C,g);this.loadMatrices(C);if(f instanceof THREE.MeshShaderMaterial){u=f.wireframe;L.set(r.flatten());t=f.wireframe_linewidth;g=C;l=f.uniforms;var O;for(i in l){Q=l[i].type;H=l[i].value;O=g.uniforms[i];if(Q=="i")c.uniform1i(O,H);else if(Q=="f")c.uniform1f(O,H);else if(Q=="v3")c.uniform3f(O,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(O,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(O,H);if(Q=l[i].texture)Q.image instanceof
+Array&&Q.image.length==6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){i=f.color;j=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;G=f.map;z=f.env_map;l=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(C.uniforms.mColor,i.r*j,i.g*j,i.b*j,j);c.uniform1i(C.uniforms.mixEnvMap,l);c.uniform1f(C.uniforms.mReflectivity,
+g);c.uniform1i(C.uniforms.useRefract,Q);c.uniform1f(C.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){j=f.opacity;c.uniform1f(C.uniforms.mOpacity,j);c.uniform1i(C.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){j=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;c.uniform1f(C.uniforms.mOpacity,j);c.uniform1f(C.uniforms.m2Near,f.__2near);c.uniform1f(C.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(C.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(C.uniforms.material,
+3)}else if(f instanceof THREE.MeshPhongMaterial){i=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(C.uniforms.mAmbient,i.r,i.g,i.b,j);c.uniform4f(C.uniforms.mSpecular,g.r,g.g,g.b,j);c.uniform1f(C.uniforms.mShininess,f);c.uniform1i(C.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(C.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(C.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(C.uniforms.material,5);z=f.env_map}if(G){e(G,
+0);c.uniform1i(C.uniforms.tMap,0);c.uniform1i(C.uniforms.enableMap,1)}else c.uniform1i(C.uniforms.enableMap,0);if(z){d(z,1);c.uniform1i(C.uniforms.tCube,1);c.uniform1i(C.uniforms.enableCubeMap,1)}else c.uniform1i(C.uniforms.enableCubeMap,0);j=C.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);if(j.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0)}if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,
+p.__webGLTangentBuffer);c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(u){c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,
+p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(g,l,f,p,i,j){var u,t,G,z,H;G=0;for(z=f.material.length;G<z;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(t=p.material.length;u<t;u++)if((H=p.material[u])&&H.blending==i&&H.opacity<1==j){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}else if((H=u)&&H.blending==i&&H.opacity<1==j){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}};this.render=function(g,l){var f,p,i,j,u=g.lights;this.initWebGLObjects(g);
+this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();E.set(l.matrix.flatten());P.set(l.projectionMatrix.flatten());f=0;for(p=g.__webGLObjects.length;f<p;f++){i=g.__webGLObjects[f];j=i.object;i=i.buffer;if(j.visible){this.setupMatrices(j,l);this.renderPass(l,u,j,i,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){i=g.__webGLObjects[f];j=i.object;i=i.buffer;if(j.visible){this.setupMatrices(j,l);this.renderPass(l,u,j,i,THREE.AdditiveBlending,false);this.renderPass(l,
+u,j,i,THREE.SubtractiveBlending,false);this.renderPass(l,u,j,i,THREE.AdditiveBlending,true);this.renderPass(l,u,j,i,THREE.SubtractiveBlending,true);this.renderPass(l,u,j,i,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(g){var l,f,p,i,j,u;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={}}l=0;for(f=g.objects.length;l<f;l++){p=g.objects[l];if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};u=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(j in p.geometry.geometryChunks){i=
+p.geometry.geometryChunks[j];i.__webGLVertexBuffer||this.createBuffers(p,j);if(u[j]==undefined){i={buffer:i,object:p};g.__webGLObjects.push(i);u[j]=1}}}};this.removeObject=function(g,l){var f,p;for(f=g.__webGLObjects.length-1;f>=0;f--){p=g.__webGLObjects[f].object;l==p&&g.__webGLObjects.splice(f,1)}};this.setupMatrices=function(g,l){g.autoUpdateMatrix&&g.updateMatrix();r.multiply(l.matrix,g.matrix);L.set(r.flatten());s=THREE.Matrix4.makeInvert3x3(r).transpose();J.set(s.m);K.set(g.matrix.flatten())};
+this.loadMatrices=function(g){c.uniformMatrix4fv(g.uniforms.viewMatrix,false,E);c.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,L);c.uniformMatrix4fv(g.uniforms.projectionMatrix,false,P);c.uniformMatrix3fv(g.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(g.uniforms.objectMatrix,false,K)};this.loadCamera=function(g,l){c.uniform3f(g.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,
+c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,l){if(g){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(g=="back")c.cullFace(c.BACK);else g=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.RenderableFace3=function(){this.z=null;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.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
+THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};

File diff suppressed because it is too large
+ 0 - 186
build/ThreeExtras.js


+ 1 - 1
examples/materials_normalmap.html

@@ -174,7 +174,7 @@
 				
 				
 				uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
 				uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
 				uniforms[ "uSpecularColor" ].value.setHex( specular );
 				uniforms[ "uSpecularColor" ].value.setHex( specular );
-				uniforms[ "uAmbientColor" ].value.setHex( ambient );
+				uniforms[ "uAmbientLightColor" ].value.setHex( ambient );
 				
 				
 				uniforms[ "uShininess" ].value = shininess;
 				uniforms[ "uShininess" ].value = shininess;
 
 

+ 1 - 0
examples/uqbiquity_test.html

@@ -67,6 +67,7 @@
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderer2.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>

+ 205 - 0
examples/webglrenderer2_sandbox.html

@@ -0,0 +1,205 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js - webgl</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				background:#fff;
+				padding:0;
+				margin:0;
+				font-weight: bold;
+				overflow:hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				color: #ffffff;
+				padding: 5px;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+				z-index:1000; 
+			}
+
+			a {
+				color: #ffffff;
+			}
+			#log { position:absolute; top:50px; text-align:left; display:block; z-index:100 }
+		</style>
+	</head>
+
+	<body>
+		<pre id="log"></pre>
+
+		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl cube Fresnel shader demo.</div>
+
+		<!-- 
+		<script type="text/javascript" src="../build/Three.js"></script>
+		-->
+
+		<script type="text/javascript" src="../src/Three.js"></script>
+		<script type="text/javascript" src="../src/core/Color.js"></script>
+		<script type="text/javascript" src="../src/core/Vector2.js"></script>
+		<script type="text/javascript" src="../src/core/Vector3.js"></script>
+		<script type="text/javascript" src="../src/core/Vector4.js"></script>
+		<script type="text/javascript" src="../src/core/Ray.js"></script>
+		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
+		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
+		<script type="text/javascript" src="../src/core/Matrix4.js"></script>
+		<script type="text/javascript" src="../src/core/Vertex.js"></script>
+		<script type="text/javascript" src="../src/core/Face3.js"></script>
+		<script type="text/javascript" src="../src/core/Face4.js"></script>
+		<script type="text/javascript" src="../src/core/UV.js"></script>
+		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
+		<script type="text/javascript" src="../src/lights/Light.js"></script>
+		<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
+		<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
+		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
+		<script type="text/javascript" src="../src/objects/Object3D.js"></script>
+		<script type="text/javascript" src="../src/objects/Particle.js"></script>
+		<script type="text/javascript" src="../src/objects/Line.js"></script>
+		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
+		<script type="text/javascript" src="../src/materials/Material.js"></script>
+		<script type="text/javascript" src="../src/materials/LineBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshLambertMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshDepthMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshCubeMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/Texture.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/CubeReflectionMapping.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/CubeRefractionMapping.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/LatitudeReflectionMapping.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/LatitudeRefractionMapping.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/SphericalReflectionMapping.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/SphericalRefractionMapping.js"></script>
+		<script type="text/javascript" src="../src/materials/mappings/UVMapping.js"></script>
+		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
+		<script type="text/javascript" src="../src/renderers/Projector.js"></script>
+		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderer2.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
+
+		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
+		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
+
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script type="text/javascript">
+
+			var statsEnabled = true;
+
+			var container, stats;
+
+			var camera, scene, webglRenderer;
+
+			var mesh, zmesh, lightMesh, geometry;
+
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			init();
+			// loop();
+			setInterval( loop, 1000 / 60 );
+
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
+				camera.position.z = 3200;
+
+				scene = new THREE.Scene();
+
+				var geometry = new Sphere( 100, 32, 16 );
+
+				var uniforms = ShaderUtils.lib[ 'basic' ].uniforms;
+				var vertex_shader = ShaderUtils.lib[ 'basic' ].vertex_shader;
+				var fragment_shader = ShaderUtils.lib[ 'basic' ].fragment_shader;
+
+				/*
+				var material = new THREE.MeshShaderMaterial( {
+							uniforms: uniforms,
+							vertex_shader: vertex_shader,
+							fragment_shader: fragment_shader
+						} );
+				*/
+
+				var material = new THREE.MeshBasicMaterial( { color: 0x0000ff, opacity: 0.5 } );
+
+				for ( var i = 0; i < 1000; i ++ ) {
+
+					var mesh = new THREE.Mesh( geometry, material );
+					mesh.position.x = Math.random() * 10000 - 5000;
+					mesh.position.y = Math.random() * 10000 - 5000;
+					mesh.position.z = Math.random() * 10000 - 5000;
+					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 4 + 1;
+					scene.addObject( mesh );
+
+				}
+
+				webglRenderer = new THREE.WebGLRenderer2();
+				webglRenderer.setSize( window.innerWidth, window.innerHeight );
+				container.appendChild( webglRenderer.domElement );
+
+				if ( statsEnabled ) {
+
+					stats = new Stats();
+					stats.domElement.style.position = 'absolute';
+					stats.domElement.style.top = '0px';
+					stats.domElement.style.zIndex = 100;
+					container.appendChild( stats.domElement );
+
+				}
+
+			}
+
+			function onDocumentMouseMove(event) {
+
+				mouseX = ( event.clientX - windowHalfX ) * 10;
+				mouseY = ( event.clientY - windowHalfY ) * 10;
+
+			}
+
+			function loop() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
+				camera.position.y += ( - mouseY - camera.position.y ) * .05;
+
+				webglRenderer.render( scene, camera );
+
+				if ( statsEnabled ) stats.update();
+
+			}
+
+			function log( text ) {
+
+				var e = document.getElementById("log");
+				e.innerHTML = text + "<br/>" + e.innerHTML;
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 4 - 4
src/extras/ShaderUtils.js

@@ -260,7 +260,7 @@ var ShaderUtils = {
 			].join("\n")
 			].join("\n")
 
 
 		},
 		},
-
+		/*
 		'hatching' : {
 		'hatching' : {
 
 
 			uniforms: {
 			uniforms: {
@@ -347,8 +347,8 @@ var ShaderUtils = {
 			].join("\n")
 			].join("\n")
 
 
 		},
 		},
-
-		'new': {
+		*/
+		'basic': {
 
 
 			uniforms: {},
 			uniforms: {},
 
 
@@ -366,7 +366,7 @@ var ShaderUtils = {
 
 
 				"void main() {",
 				"void main() {",
 
 
-					"gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
+					"gl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);",
 
 
 				"}"
 				"}"
 
 

+ 1 - 1
src/materials/MeshShaderMaterial.js

@@ -24,7 +24,7 @@ THREE.MeshShaderMaterial = function ( parameters ) {
 	this.opacity = 1;
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
-		
+
 	this.wireframe = false;
 	this.wireframe = false;
 	this.wireframe_linewidth = 1;
 	this.wireframe_linewidth = 1;
 	this.wireframe_linecap = 'round';
 	this.wireframe_linecap = 'round';

+ 5 - 3
src/renderers/Projector.js

@@ -24,7 +24,7 @@ THREE.Projector = function() {
 
 
 		var o, ol, v, vl, f, fl, n, nl, objects, object,
 		var o, ol, v, vl, f, fl, n, nl, objects, object,
 		objectMatrix, objectRotationMatrix, objectMaterial, objectOverdraw,
 		objectMatrix, objectRotationMatrix, objectMaterial, objectOverdraw,
-		vertices, vertex, vertexPositionScreen,
+		geometry, vertices, vertex, vertexPositionScreen,
 		faces, face, faceVertexNormals, normal, v1, v2, v3, v4;
 		faces, face, faceVertexNormals, normal, v1, v2, v3, v4;
 
 
 		_renderList = [];
 		_renderList = [];
@@ -48,9 +48,11 @@ THREE.Projector = function() {
 
 
 			if ( object instanceof THREE.Mesh ) {
 			if ( object instanceof THREE.Mesh ) {
 
 
+				geometry = object.geometry;
+
 				// vertices
 				// vertices
 
 
-				vertices = object.geometry.vertices;
+				vertices = geometry.vertices;
 
 
 				for ( v = 0, vl = vertices.length; v < vl; v++ ) {
 				for ( v = 0, vl = vertices.length; v < vl; v++ ) {
 
 
@@ -74,7 +76,7 @@ THREE.Projector = function() {
 
 
 				// faces
 				// faces
 
 
-				faces = object.geometry.faces;
+				faces = geometry.faces;
 
 
 				for ( f = 0, fl = faces.length; f < fl; f ++ ) {
 				for ( f = 0, fl = faces.length; f < fl; f ++ ) {
 
 

+ 4 - 4
src/renderers/WebGLRenderer.js

@@ -412,7 +412,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 
 		if ( material instanceof THREE.MeshShaderMaterial ) {
 		if ( material instanceof THREE.MeshShaderMaterial ) {
 
 
-			mWireframe = material.wireframe;
+			mWireframe = material.wireframe;		_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
 			mLineWidth = material.wireframe_linewidth;
 			mLineWidth = material.wireframe_linewidth;
 			
 			
 			mBlending = material.blending;
 			mBlending = material.blending;
@@ -646,6 +646,9 @@ THREE.WebGLRenderer = function ( scene ) {
 
 
 		camera.autoUpdateMatrix && camera.updateMatrix();
 		camera.autoUpdateMatrix && camera.updateMatrix();
 
 
+		_viewMatrixArray.set( camera.matrix.flatten() );
+		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
+
 		// opaque pass
 		// opaque pass
 
 
 		for ( o = 0, ol = scene.__webGLObjects.length; o < ol; o++ ) {
 		for ( o = 0, ol = scene.__webGLObjects.length; o < ol; o++ ) {
@@ -782,10 +785,7 @@ THREE.WebGLRenderer = function ( scene ) {
 		object.autoUpdateMatrix && object.updateMatrix();
 		object.autoUpdateMatrix && object.updateMatrix();
 
 
 		_modelViewMatrix.multiply( camera.matrix, object.matrix );
 		_modelViewMatrix.multiply( camera.matrix, object.matrix );
-
-		_viewMatrixArray.set( camera.matrix.flatten() );
 		_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
 		_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
-		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 
 
 		_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();
 		_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();
 		_normalMatrixArray.set( _normalMatrix.m );
 		_normalMatrixArray.set( _normalMatrix.m );

+ 392 - 0
src/renderers/WebGLRenderer2.js

@@ -0,0 +1,392 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.WebGLRenderer2 = function ( scene ) {
+
+	var _canvas = document.createElement( 'canvas' ),
+	_gl, _currentProgram,
+	_modelViewMatrix = new THREE.Matrix4(),
+	_viewMatrixArray = new Float32Array( 16 ),
+	_modelViewMatrixArray = new Float32Array( 16 ),
+	_projectionMatrixArray = new Float32Array( 16 ),
+	_normalMatrixArray = new Float32Array( 9 ),
+	_objectMatrixArray = new Float32Array( 16 );
+
+	try {
+
+		_gl = _canvas.getContext( 'experimental-webgl', { antialias: true } );
+
+	} catch(e) { }
+
+	if ( !_gl ) {
+
+		alert("WebGL not supported");
+		throw "cannot create webgl context";
+
+	}
+
+	_gl.clearColor( 0, 0, 0, 1 );
+	_gl.clearDepth( 1 );
+
+	_gl.enable( _gl.DEPTH_TEST );
+	_gl.depthFunc( _gl.LEQUAL );
+
+	_gl.frontFace( _gl.CCW );
+	_gl.cullFace( _gl.BACK );
+	_gl.enable( _gl.CULL_FACE );
+
+	_gl.enable( _gl.BLEND );
+	_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
+	_gl.clearColor( 0, 0, 0, 0 );
+
+	this.domElement = _canvas;
+	this.autoClear = true;
+
+	this.setSize = function ( width, height ) {
+
+		_canvas.width = width;
+		_canvas.height = height;
+		_gl.viewport( 0, 0, _canvas.width, _canvas.height );
+
+	};
+
+	this.clear = function () {
+
+		_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT );
+
+	};
+
+	this.render = function( scene, camera ) {
+
+		var o, ol;
+
+		this.autoClear && this.clear();
+
+		camera.autoUpdateMatrix && camera.updateMatrix();
+
+		_viewMatrixArray.set( camera.matrix.flatten() );
+		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
+
+		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
+
+			object = scene.objects[ o ];
+
+			if ( object.visible ) {
+
+				renderObject( object );
+
+			}
+
+		}
+
+		function renderObject( object ) {
+
+			var geometry, material, m, nl,
+			program, attributes;
+
+			object.autoUpdateMatrix && object.updateMatrix();
+
+			_objectMatrixArray.set( object.matrix.flatten() );
+
+			_modelViewMatrix.multiply( camera.matrix, object.matrix );
+			_modelViewMatrixArray.set( _modelViewMatrix.flatten() );
+
+			if ( object instanceof THREE.Mesh ) {
+
+				geometry = object.geometry;
+
+				if ( geometry.__webglBuffers == undefined ) {
+
+					if ( buildBuffers( geometry ) == false ) return;
+
+				}
+
+				for ( m = 0, ml = object.material.length; m < ml; m ++ ) {
+
+					material = object.material[ m ];
+
+					if ( material.__webglProgram == undefined ) {
+
+						if ( createProgram( material ) == false ) continue;
+
+					}
+
+					program = material.__webglProgram;
+					attributes = program.attributes;
+
+					if( program != _currentProgram ) {
+
+						_gl.useProgram( program );
+						_currentProgram = program;
+
+					}
+
+					if ( material instanceof THREE.MeshBasicMaterial ) {
+
+						_gl.uniform4f( program.uniforms.mColor,  material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity, material.opacity );
+
+					}
+
+
+					_gl.uniform3f( program.uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
+
+					_gl.uniformMatrix4fv( program.uniforms.viewMatrix, false, _viewMatrixArray );
+					_gl.uniformMatrix4fv( program.uniforms.projectionMatrix, false, _projectionMatrixArray );
+					_gl.uniformMatrix4fv( program.uniforms.objectMatrix, false, _objectMatrixArray );
+					_gl.uniformMatrix4fv( program.uniforms.modelViewMatrix, false, _modelViewMatrixArray );
+
+					_gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglBuffers.vertexBuffer );
+					_gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
+
+					if ( ! material.wireframe ) {
+
+						_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometry.__webglBuffers.faceBuffer );
+						_gl.drawElements( _gl.TRIANGLES, geometry.__webglBuffers.faceCount, _gl.UNSIGNED_SHORT, 0 );
+
+					} else {
+
+						_gl.lineWidth( material.wireframe_linewidth );
+						_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometry.__webglBuffers.lineBuffer );
+						_gl.drawElements( _gl.LINES, geometry.__webglBuffers.lineCount, _gl.UNSIGNED_SHORT, 0 );
+
+					}
+
+				}
+
+			}
+
+		}
+
+		function buildBuffers( geometry ) {
+
+			var f, fl, face, v1, v2, v3, verticesIndex = 0,
+			verticesArray = [], facesArray = [], linesArray = [],
+			buffers = {};
+
+			for ( f = 0, fl = geometry.faces.length; f < fl; f++ ) {
+
+				face = geometry.faces[ f ];
+
+				if ( face instanceof THREE.Face3 ) {
+
+					v1 = geometry.vertices[ face.a ].position;
+					v2 = geometry.vertices[ face.b ].position;
+					v3 = geometry.vertices[ face.c ].position;
+
+					verticesArray.push( v1.x, v1.y, v1.z );
+					verticesArray.push( v2.x, v2.y, v2.z );
+					verticesArray.push( v3.x, v3.y, v3.z );
+
+					facesArray.push( verticesIndex, verticesIndex + 1, verticesIndex + 2 );
+
+					// TODO: don't add lines that already exist (faces sharing edge)
+
+					linesArray.push( verticesIndex, verticesIndex + 1 );
+					linesArray.push( verticesIndex, verticesIndex + 2 );
+					linesArray.push( verticesIndex + 1, verticesIndex + 2 );
+
+					verticesIndex += 3;
+
+				} else if ( face instanceof THREE.Face4 ) {
+
+					v1 = geometry.vertices[ face.a ].position;
+					v2 = geometry.vertices[ face.b ].position;
+					v3 = geometry.vertices[ face.c ].position;
+					v4 = geometry.vertices[ face.d ].position;
+
+					verticesArray.push( v1.x, v1.y, v1.z );
+					verticesArray.push( v2.x, v2.y, v2.z );
+					verticesArray.push( v3.x, v3.y, v3.z );
+					verticesArray.push( v4.x, v4.y, v4.z );
+
+					facesArray.push( verticesIndex, verticesIndex + 1, verticesIndex + 2 );
+					facesArray.push( verticesIndex, verticesIndex + 2, verticesIndex + 3 );
+
+					// TODO: don't add lines that already exist (faces sharing edge)
+
+					linesArray.push( verticesIndex, verticesIndex + 1 );
+					linesArray.push( verticesIndex, verticesIndex + 2 );
+					linesArray.push( verticesIndex, verticesIndex + 3 );
+					linesArray.push( verticesIndex + 1, verticesIndex + 2 );
+					linesArray.push( verticesIndex + 2, verticesIndex + 3 );
+
+					verticesIndex += 4;
+
+				}
+
+			}
+
+			if ( !verticesArray.length ) return false;
+
+			buffers.vertexBuffer = _gl.createBuffer();
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.vertexBuffer );
+			_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( verticesArray ), _gl.STATIC_DRAW );
+
+			buffers.faceBuffer = _gl.createBuffer();
+			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffers.faceBuffer );
+			_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( facesArray ), _gl.STATIC_DRAW );
+
+			buffers.lineBuffer = _gl.createBuffer();
+			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffers.lineBuffer );
+			_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( linesArray ), _gl.STATIC_DRAW );
+
+			buffers.faceCount = facesArray.length;
+			buffers.lineCount = linesArray.length;
+
+			geometry.__webglBuffers = buffers;
+
+			return true;
+
+		}
+
+		function createProgram( material ) {
+
+			var vs = '', fs = '',
+			identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
+
+			if ( material instanceof THREE.MeshBasicMaterial ) {
+
+				vs += 'void main() {\n';
+				vs += 'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n';
+				vs += '}'
+
+				fs += 'uniform vec4 mColor;\n';
+				fs += 'void main() {\n';
+				fs += 'gl_FragColor = mColor;\n';
+				fs += '}';
+
+				identifiers.push( 'mColor' );
+
+			} else if ( material instanceof THREE.MeshShaderMaterial ) {
+
+				vs = material.vertex_shader;
+				fs = material.fragment_shader;
+
+				for( uniform in material.uniforms ) {
+
+					identifiers.push( uniform );
+
+				}
+
+			} else {
+
+				return false;
+
+			}
+
+			material.__webglProgram = compileProgram( vs, fs );
+
+			cacheUniformLocations( material.__webglProgram, identifiers );
+			cacheAttributeLocations( material.__webglProgram, [ "position", "normal", "uv", "tangent" ] );
+
+			return true;
+
+		}
+
+		function compileProgram( vertex_shader, fragment_shader ) {
+
+			var program = _gl.createProgram(), shader
+
+			prefix_vertex = [
+				//maxVertexTextures() > 0 ? "#define VERTEX_TEXTURES" : "",
+
+				"uniform mat4 objectMatrix;",
+				"uniform mat4 modelViewMatrix;",
+				"uniform mat4 projectionMatrix;",
+				//"uniform mat4 viewMatrix;",
+				"uniform mat3 normalMatrix;",
+				"uniform vec3 cameraPosition;",
+				"attribute vec3 position;",
+				//"attribute vec3 normal;",
+				//"attribute vec2 uv;",
+				""
+			].join("\n"),
+
+			prefix_fragment = [
+				"#ifdef GL_ES",
+					"precision highp float;",
+				"#endif",
+				//"uniform mat4 viewMatrix;",
+				""
+			].join("\n");
+
+			// Vertex shader
+
+			shader = _gl.createShader( _gl.VERTEX_SHADER );
+			_gl.shaderSource( shader, prefix_vertex + vertex_shader );
+			_gl.compileShader( shader );
+			_gl.attachShader( program, shader );
+
+			if ( !_gl.getShaderParameter( shader, _gl.COMPILE_STATUS ) ) {
+
+				alert( _gl.getShaderInfoLog( shader ) );
+				return null;
+
+			}
+
+			// Fragment Shader
+
+			shader = _gl.createShader( _gl.FRAGMENT_SHADER );
+			_gl.shaderSource( shader, prefix_fragment + fragment_shader );
+			_gl.compileShader( shader );
+			_gl.attachShader( program, shader );
+
+			if ( !_gl.getShaderParameter( shader, _gl.COMPILE_STATUS ) ) {
+
+				alert( _gl.getShaderInfoLog( shader ) );
+				return null;
+
+			}
+
+			_gl.linkProgram( program );
+
+			if ( !_gl.getProgramParameter( program, _gl.LINK_STATUS ) ) {
+
+				alert( "Could not initialise shaders\n VALIDATE_STATUS: " + _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ) + ", gl error [" + _gl.getError() + "]" );
+
+			}
+
+			program.uniforms = {};
+			program.attributes = {};
+
+			return program;
+
+		}
+
+		function cacheUniformLocations( program, identifiers ) {
+
+			var i, l, id;
+
+			for( i = 0, l = identifiers.length; i < l; i++ ) {
+
+				id = identifiers[ i ];
+				program.uniforms[ id ] = _gl.getUniformLocation( program, id );
+
+			}
+
+		}
+
+		function cacheAttributeLocations( program, identifiers ) {
+
+			var i, l, id;
+
+			for( i = 0, l = identifiers.length; i < l; i++ ) {
+
+				id = identifiers[ i ];
+				program.attributes[ id ] = _gl.getAttribLocation( program, id );
+
+				if ( program.attributes[ id ] >= 0 ) {
+
+					_gl.enableVertexAttribArray( program.attributes[ id ] );
+
+				}
+
+			}
+
+		}
+
+
+	};
+
+};

Some files were not shown because too many files changed in this diff