Ver código fonte

Changed a bit clear color API.

Renamed: setClearColor( hex, opacity ) => setClearColorHex( hex, opacity )

New: setClearColor( color, opacity )

In this way it's a bit cheaper to animate clear color.

Hope I didn't break examples - I searched for "setClearColor" and changed it in one place where it was used.
alteredq 14 anos atrás
pai
commit
b3ea0d5fcd

+ 128 - 128
build/Three.js

@@ -1,66 +1,66 @@
 // Three.js r32 - 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,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,h,b,q,r,l;if(d==0)f=h=b=0;else{q=Math.floor(a*6);r=a*6-q;a=d*(1-c);l=d*(1-c*r);c=d*(1-c*(1-r));switch(q){case 1:f=l;h=d;b=a;break;case 2:f=a;h=d;b=c;break;case 3:f=a;h=l;b=d;break;case 4:f=c;h=a;b=d;break;case 5:f=d;h=a;b=l;break;case 6:case 0:f=d;h=c;b=a}}this.r=f;this.g=h;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var g,h,b,r,q,l;if(d==0)g=h=b=0;else{r=Math.floor(a*6);q=a*6-r;a=d*(1-c);l=d*(1-c*q);c=d*(1-c*(1-q));switch(r){case 1:g=l;h=d;b=a;break;case 2:g=a;h=d;b=c;break;case 3:g=a;h=l;b=d;break;case 4:g=c;h=a;b=d;break;case 5:g=d;h=a;b=l;break;case 6:case 0:g=d;h=c;b=a}}this.r=g;this.g=h;this.b=b;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
 a.z;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 c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+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,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
-THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
+THREE.Vector4=function(a,c,d,g){this.x=a||0;this.y=c||0;this.z=d||0;this.w=g||1};
+THREE.Vector4.prototype={set:function(a,c,d,g){this.x=a;this.y=c;this.z=d;this.w=g;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,h=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(M,s,T,G){G=G.clone().subSelf(s);T=T.clone().subSelf(s);var g=M.clone().subSelf(s);M=G.dot(G);s=G.dot(T);G=G.dot(g);var m=T.dot(T);T=T.dot(g);g=1/(M*m-s*s);m=(m*G-s*T)*g;M=(M*T-s*G)*g;return m>0&&M>0&&m+M<1}var d,f,h,b,q,r,l,p,z,y,
-u,x=a.geometry,H=x.vertices,K=[];d=0;for(f=x.faces.length;d<f;d++){h=x.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(H[h.a].position.clone());q=a.matrix.multiplyVector3(H[h.b].position.clone());r=a.matrix.multiplyVector3(H[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(H[h.d].position.clone()):null;p=a.rotationMatrix.multiplyVector3(h.normal.clone());z=u.dot(p);if(z<0){p=p.dot((new THREE.Vector3).sub(b,y))/z;y=y.addSelf(u.multiplyScalar(p));
-if(h instanceof THREE.Face3){if(c(y,b,q,r)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(y,b,q,l)||c(y,q,r,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}}return K}};
-THREE.Rectangle=function(){function a(){b=f-c;q=h-d}var c,d,f,h,b,q,r=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(l,p,z,y){r=false;c=l;d=p;f=z;h=y;a()};this.addPoint=function(l,p){if(r){r=false;c=l;d=p;f=l;h=p}else{c=c<l?c:l;d=d<p?d:p;f=f>l?f:l;h=h>p?
-h:p}a()};this.add3Points=function(l,p,z,y,u,x){if(r){r=false;c=l<z?l<u?l:u:z<u?z:u;d=p<y?p<x?p:x:y<x?y:x;f=l>z?l>u?l:u:z>u?z:u;h=p>y?p>x?p:x:y>x?y:x}else{c=l<z?l<u?l<c?l:c:u<c?u:c:z<u?z<c?z:c:u<c?u:c;d=p<y?p<x?p<d?p:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>u?l>f?l:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f;h=p>y?p>x?p>h?p:h:x>h?x:h:y>x?y>h?y:h:x>h?x:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();f=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
-f=f>l.getRight()?f:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=f=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+h+", width: "+b+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,f,h,b,q,r,l,p,z,y,u,x,H,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=h||0;this.n22=b||1;this.n23=q||0;this.n24=r||0;this.n31=l||0;this.n32=p||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-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,c,d,f,h,b,q,r,l,p,z,y,u,x,H,K){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=p;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=H;this.n44=K;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,c,d){var f=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();f.cross(d,b).normalize();h.cross(b,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
-this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,h=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
-f+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,p=a.n24,z=a.n31,
-y=a.n32,u=a.n33,x=a.n34,H=a.n41,K=a.n42,M=a.n43,s=a.n44,T=c.n11,G=c.n12,g=c.n13,m=c.n14,i=c.n21,e=c.n22,j=c.n23,k=c.n24,o=c.n31,w=c.n32,n=c.n33,t=c.n34,v=c.n41,D=c.n42,E=c.n43,I=c.n44;this.n11=d*T+f*i+h*o+b*v;this.n12=d*G+f*e+h*w+b*D;this.n13=d*g+f*j+h*n+b*E;this.n14=d*m+f*k+h*t+b*I;this.n21=q*T+r*i+l*o+p*v;this.n22=q*G+r*e+l*w+p*D;this.n23=q*g+r*j+l*n+p*E;this.n24=q*m+r*k+l*t+p*I;this.n31=z*T+y*i+u*o+x*v;this.n32=z*G+y*e+u*w+x*D;this.n33=z*g+y*j+u*n+x*E;this.n34=z*m+y*k+u*t+x*I;this.n41=H*T+K*i+
-M*o+s*v;this.n42=H*G+K*e+M*w+s*D;this.n43=H*g+K*j+M*n+s*E;this.n44=H*m+K*k+M*t+s*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,p=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,H=this.n42,K=this.n43,M=this.n44,s=a.n11,T=a.n21,G=a.n31,g=a.n41,m=a.n12,i=a.n22,e=a.n32,j=a.n42,k=a.n13,o=a.n23,w=a.n33,n=a.n43,t=a.n14,v=a.n24,D=a.n34;a=a.n44;this.n11=c*s+d*T+f*G+h*g;this.n12=c*m+d*i+f*e+h*j;this.n13=c*k+d*o+f*w+h*
-n;this.n14=c*t+d*v+f*D+h*a;this.n21=b*s+q*T+r*G+l*g;this.n22=b*m+q*i+r*e+l*j;this.n23=b*k+q*o+r*w+l*n;this.n24=b*t+q*v+r*D+l*a;this.n31=p*s+z*T+y*G+u*g;this.n32=p*m+z*i+y*e+u*j;this.n33=p*k+z*o+y*w+u*n;this.n34=p*t+z*v+y*D+u*a;this.n41=x*s+H*T+K*G+M*g;this.n42=x*m+H*i+K*e+M*j;this.n43=x*k+H*o+K*w+M*n;this.n44=x*t+H*v+K*D+M*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(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,p=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,H=this.n43,K=this.n44;return f*q*p*u-d*r*p*u-f*b*z*u+c*r*z*u+d*b*y*u-c*q*y*u-f*q*l*x+d*r*l*x+f*h*z*x-a*r*z*x-d*h*y*x+a*q*y*x+f*b*l*H-c*r*l*H-f*h*p*H+a*r*p*H+c*h*y*H-a*b*y*H-d*b*l*K+c*q*l*K+d*h*p*K-a*q*p*K-c*h*z*K+a*b*z*K},transpose:function(){function a(c,d,
-f){var h=c[d];c[d]=c[f];c[f]=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(){var a=this.flat;a[0]=this.n11;
+THREE.Ray.prototype={intersectScene:function(a){var c,d,g=a.objects,h=[];a=0;for(c=g.length;a<c;a++){d=g[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,r){return b.distance-r.distance});return h},intersectObject:function(a){function c(M,s,T,G){G=G.clone().subSelf(s);T=T.clone().subSelf(s);var f=M.clone().subSelf(s);M=G.dot(G);s=G.dot(T);G=G.dot(f);var m=T.dot(T);T=T.dot(f);f=1/(M*m-s*s);m=(m*G-s*T)*f;M=(M*T-s*G)*f;return m>0&&M>0&&m+M<1}var d,g,h,b,r,q,l,p,z,y,
+u,x=a.geometry,H=x.vertices,K=[];d=0;for(g=x.faces.length;d<g;d++){h=x.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(H[h.a].position.clone());r=a.matrix.multiplyVector3(H[h.b].position.clone());q=a.matrix.multiplyVector3(H[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(H[h.d].position.clone()):null;p=a.rotationMatrix.multiplyVector3(h.normal.clone());z=u.dot(p);if(z<0){p=p.dot((new THREE.Vector3).sub(b,y))/z;y=y.addSelf(u.multiplyScalar(p));
+if(h instanceof THREE.Face3){if(c(y,b,r,q)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(y,b,r,l)||c(y,r,q,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}}return K}};
+THREE.Rectangle=function(){function a(){b=g-c;r=h-d}var c,d,g,h,b,r,q=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return r};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return g};this.getBottom=function(){return h};this.set=function(l,p,z,y){q=false;c=l;d=p;g=z;h=y;a()};this.addPoint=function(l,p){if(q){q=false;c=l;d=p;g=l;h=p}else{c=c<l?c:l;d=d<p?d:p;g=g>l?g:l;h=h>p?
+h:p}a()};this.add3Points=function(l,p,z,y,u,x){if(q){q=false;c=l<z?l<u?l:u:z<u?z:u;d=p<y?p<x?p:x:y<x?y:x;g=l>z?l>u?l:u:z>u?z:u;h=p>y?p>x?p:x:y>x?y:x}else{c=l<z?l<u?l<c?l:c:u<c?u:c:z<u?z<c?z:c:u<c?u:c;d=p<y?p<x?p<d?p:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;g=l>z?l>u?l>g?l:g:u>g?u:g:z>u?z>g?z:g:u>g?u:g;h=p>y?p>x?p>h?p:h:x>h?x:h:y>x?y>h?y:h:x>h?x:h}a()};this.addRectangle=function(l){if(q){q=false;c=l.getLeft();d=l.getTop();g=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
+g=g>l.getRight()?g:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;g+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();g=g<l.getRight()?g:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(g,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){q=true;h=g=d=c=0;a()};this.isEmpty=function(){return q};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+g+", top: "+d+", bottom: "+h+", width: "+b+", height: "+r+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
+THREE.Matrix4=function(a,c,d,g,h,b,r,q,l,p,z,y,u,x,H,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=g||0;this.n21=h||0;this.n22=b||1;this.n23=r||0;this.n24=q||0;this.n31=l||0;this.n32=p||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+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,c,d,g,h,b,r,q,l,p,z,y,u,x,H,K){this.n11=a;this.n12=c;this.n13=d;this.n14=g;this.n21=h;this.n22=b;this.n23=r;this.n24=q;this.n31=l;this.n32=p;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=H;this.n44=K;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,c,d){var g=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();g.cross(d,b).normalize();h.cross(b,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
+this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,g=a.z,h=1/(this.n41*c+this.n42*d+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*g+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*g+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*g+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,g=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*g+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
+g+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*g+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*g+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,g=a.n12,h=a.n13,b=a.n14,r=a.n21,q=a.n22,l=a.n23,p=a.n24,z=a.n31,
+y=a.n32,u=a.n33,x=a.n34,H=a.n41,K=a.n42,M=a.n43,s=a.n44,T=c.n11,G=c.n12,f=c.n13,m=c.n14,i=c.n21,e=c.n22,j=c.n23,k=c.n24,o=c.n31,w=c.n32,n=c.n33,t=c.n34,v=c.n41,D=c.n42,E=c.n43,I=c.n44;this.n11=d*T+g*i+h*o+b*v;this.n12=d*G+g*e+h*w+b*D;this.n13=d*f+g*j+h*n+b*E;this.n14=d*m+g*k+h*t+b*I;this.n21=r*T+q*i+l*o+p*v;this.n22=r*G+q*e+l*w+p*D;this.n23=r*f+q*j+l*n+p*E;this.n24=r*m+q*k+l*t+p*I;this.n31=z*T+y*i+u*o+x*v;this.n32=z*G+y*e+u*w+x*D;this.n33=z*f+y*j+u*n+x*E;this.n34=z*m+y*k+u*t+x*I;this.n41=H*T+K*i+
+M*o+s*v;this.n42=H*G+K*e+M*w+s*D;this.n43=H*f+K*j+M*n+s*E;this.n44=H*m+K*k+M*t+s*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,g=this.n13,h=this.n14,b=this.n21,r=this.n22,q=this.n23,l=this.n24,p=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,H=this.n42,K=this.n43,M=this.n44,s=a.n11,T=a.n21,G=a.n31,f=a.n41,m=a.n12,i=a.n22,e=a.n32,j=a.n42,k=a.n13,o=a.n23,w=a.n33,n=a.n43,t=a.n14,v=a.n24,D=a.n34;a=a.n44;this.n11=c*s+d*T+g*G+h*f;this.n12=c*m+d*i+g*e+h*j;this.n13=c*k+d*o+g*w+h*
+n;this.n14=c*t+d*v+g*D+h*a;this.n21=b*s+r*T+q*G+l*f;this.n22=b*m+r*i+q*e+l*j;this.n23=b*k+r*o+q*w+l*n;this.n24=b*t+r*v+q*D+l*a;this.n31=p*s+z*T+y*G+u*f;this.n32=p*m+z*i+y*e+u*j;this.n33=p*k+z*o+y*w+u*n;this.n34=p*t+z*v+y*D+u*a;this.n41=x*s+H*T+K*G+M*f;this.n42=x*m+H*i+K*e+M*j;this.n43=x*k+H*o+K*w+M*n;this.n44=x*t+H*v+K*D+M*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(){var a=this.n11,c=this.n12,d=this.n13,g=this.n14,h=this.n21,b=this.n22,r=this.n23,q=this.n24,l=this.n31,p=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,H=this.n43,K=this.n44;return g*r*p*u-d*q*p*u-g*b*z*u+c*q*z*u+d*b*y*u-c*r*y*u-g*r*l*x+d*q*l*x+g*h*z*x-a*q*z*x-d*h*y*x+a*r*y*x+g*b*l*H-c*q*l*H-g*h*p*H+a*q*p*H+c*h*y*H-a*b*y*H-d*b*l*K+c*r*l*K+d*h*p*K-a*r*p*K-c*h*z*K+a*b*z*K},transpose:function(){function a(c,d,
+g){var h=c[d];c[d]=c[g];c[g]=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(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,p=h*q;this.set(l*b+d,l*q-f*r,l*r+f*q,0,l*q+f*r,p*q+d,p*r-f*b,0,l*r-f*q,p*r+f*b,h*r*r+d,0,0,0,0,1);return this},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,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
+Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),g=Math.sin(c),h=1-d,b=a.x,r=a.y,q=a.z,l=h*b,p=h*r;this.set(l*b+d,l*r-g*q,l*q+g*r,0,l*r+g*q,p*r+d,p*q-g*b,0,l*q-g*r,p*q+g*b,h*q*q+d,0,0,0,0,1);return this},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,c,d){var g=new THREE.Matrix4;g.setTranslation(a,c,d);return g};THREE.Matrix4.scaleMatrix=function(a,c,d){var g=new THREE.Matrix4;g.setScale(a,c,d);return g};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,p=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,H=a.n42,K=a.n43,M=a.n44,s=new THREE.Matrix4;s.n11=r*u*H-l*y*H+l*z*K-q*u*K-r*z*M+q*y*M;s.n12=h*y*H-f*u*H-h*z*K+d*u*K+f*z*M-d*y*M;s.n13=f*l*H-h*r*H+h*q*K-d*l*K-f*q*M+d*r*M;s.n14=h*r*z-f*l*z-h*q*y+d*l*y+f*q*u-d*r*u;s.n21=l*y*x-r*u*x-l*p*K+b*u*K+r*p*M-b*y*M;s.n22=f*u*x-h*y*x+h*p*K-c*u*K-f*p*M+c*y*M;s.n23=h*r*x-f*l*x-h*b*K+c*l*K+f*b*M-c*r*M;s.n24=f*l*p-h*r*p+
-h*b*y-c*l*y-f*b*u+c*r*u;s.n31=q*u*x-l*z*x+l*p*H-b*u*H-q*p*M+b*z*M;s.n32=h*z*x-d*u*x-h*p*H+c*u*H+d*p*M-c*z*M;s.n33=f*l*x-h*q*x+h*b*H-c*l*H-d*b*M+c*q*M;s.n34=h*q*p-d*l*p-h*b*z+c*l*z+d*b*u-c*q*u;s.n41=r*z*x-q*y*x-r*p*H+b*y*H+q*p*K-b*z*K;s.n42=d*y*x-f*z*x+f*p*H-c*y*H-d*p*K+c*z*K;s.n43=f*q*x-d*r*x-f*b*H+c*r*H+d*b*K-c*q*K;s.n44=d*r*p-f*q*p+f*b*z-c*r*z-d*b*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,f=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],q=-c[10]*c[4]+c[6]*c[8],r=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],p=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*q+c[2]*p;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*f;d[1]=c*h;d[2]=c*b;d[3]=c*q;d[4]=c*r;d[5]=c*l;d[6]=c*p;d[7]=c*z;d[8]=c*y;return a};
-THREE.Matrix4.makeFrustum=function(a,c,d,f,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(b+h)/(b-h);h=-2*b*h/(b-h);q.n11=r;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,f)};
-THREE.Matrix4.makeOrtho=function(a,c,d,f,h,b){var q,r,l,p;q=new THREE.Matrix4;r=c-a;l=d-f;p=b-h;a=(c+a)/r;d=(d+f)/l;h=(b+h)/p;q.n11=2/r;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/p;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,g=a.n13,h=a.n14,b=a.n21,r=a.n22,q=a.n23,l=a.n24,p=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,H=a.n42,K=a.n43,M=a.n44,s=new THREE.Matrix4;s.n11=q*u*H-l*y*H+l*z*K-r*u*K-q*z*M+r*y*M;s.n12=h*y*H-g*u*H-h*z*K+d*u*K+g*z*M-d*y*M;s.n13=g*l*H-h*q*H+h*r*K-d*l*K-g*r*M+d*q*M;s.n14=h*q*z-g*l*z-h*r*y+d*l*y+g*r*u-d*q*u;s.n21=l*y*x-q*u*x-l*p*K+b*u*K+q*p*M-b*y*M;s.n22=g*u*x-h*y*x+h*p*K-c*u*K-g*p*M+c*y*M;s.n23=h*q*x-g*l*x-h*b*K+c*l*K+g*b*M-c*q*M;s.n24=g*l*p-h*q*p+
+h*b*y-c*l*y-g*b*u+c*q*u;s.n31=r*u*x-l*z*x+l*p*H-b*u*H-r*p*M+b*z*M;s.n32=h*z*x-d*u*x-h*p*H+c*u*H+d*p*M-c*z*M;s.n33=g*l*x-h*r*x+h*b*H-c*l*H-d*b*M+c*r*M;s.n34=h*r*p-d*l*p-h*b*z+c*l*z+d*b*u-c*r*u;s.n41=q*z*x-r*y*x-q*p*H+b*y*H+r*p*K-b*z*K;s.n42=d*y*x-g*z*x+g*p*H-c*y*H-d*p*K+c*z*K;s.n43=g*r*x-d*q*x-g*b*H+c*q*H+d*b*K-c*r*K;s.n44=d*q*p-g*r*p+g*b*z-c*q*z-d*b*y+c*r*y;s.multiplyScalar(1/a.determinant());return s};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,g=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],r=-c[10]*c[4]+c[6]*c[8],q=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],p=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*g+c[1]*r+c[2]*p;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*g;d[1]=c*h;d[2]=c*b;d[3]=c*r;d[4]=c*q;d[5]=c*l;d[6]=c*p;d[7]=c*z;d[8]=c*y;return a};
+THREE.Matrix4.makeFrustum=function(a,c,d,g,h,b){var r,q,l;r=new THREE.Matrix4;q=2*h/(c-a);l=2*h/(g-d);a=(c+a)/(c-a);d=(g+d)/(g-d);g=-(b+h)/(b-h);h=-2*b*h/(b-h);r.n11=q;r.n12=0;r.n13=a;r.n14=0;r.n21=0;r.n22=l;r.n23=d;r.n24=0;r.n31=0;r.n32=0;r.n33=g;r.n34=h;r.n41=0;r.n42=0;r.n43=-1;r.n44=0;return r};THREE.Matrix4.makePerspective=function(a,c,d,g){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,g)};
+THREE.Matrix4.makeOrtho=function(a,c,d,g,h,b){var r,q,l,p;r=new THREE.Matrix4;q=c-a;l=d-g;p=b-h;a=(c+a)/q;d=(d+g)/l;h=(b+h)/p;r.n11=2/q;r.n12=0;r.n13=0;r.n14=-a;r.n21=0;r.n22=2/l;r.n23=0;r.n24=-d;r.n31=0;r.n32=0;r.n33=-2/p;r.n34=-h;r.n41=0;r.n42=0;r.n43=0;r.n44=1;return r};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,d,f,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,c,d,f,h,b){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
+THREE.Face3=function(a,c,d,g,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,c,d,g,h,b){this.a=a;this.b=c;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;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 c,d,f,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){b=this.vertices[f];b.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];if(a&&b.vertexNormals.length){r.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)r.addSelf(b.vertexNormals[c]);r.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];q=this.vertices[b.c];r.sub(q.position,
-d.position);l.sub(c.position,d.position);r.crossSelf(l)}r.isZero()||r.normalize();b.normal.copy(r)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(t,v,D,E,I,L,N){b=t.vertices[v].position;q=t.vertices[D].position;r=t.vertices[E].position;l=h[I];p=h[L];z=h[N];y=q.x-b.x;u=r.x-b.x;x=q.y-b.y;H=r.y-b.y;
-K=q.z-b.z;M=r.z-b.z;s=p.u-l.u;T=z.u-l.u;G=p.v-l.v;g=z.v-l.v;m=1/(s*g-T*G);j.set((g*y-G*u)*m,(g*x-G*H)*m,(g*K-G*M)*m);k.set((s*u-T*y)*m,(s*H-T*x)*m,(s*M-T*K)*m);i[v].addSelf(j);i[D].addSelf(j);i[E].addSelf(j);e[v].addSelf(k);e[D].addSelf(k);e[E].addSelf(k)}var c,d,f,h,b,q,r,l,p,z,y,u,x,H,K,M,s,T,G,g,m,i=[],e=[],j=new THREE.Vector3,k=new THREE.Vector3,o=new THREE.Vector3,w=new THREE.Vector3,n=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;e[c]=new THREE.Vector3}c=0;
-for(d=this.faces.length;c<d;c++){f=this.faces[c];h=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
-this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){n.copy(this.vertices[c].normal);f=i[c];o.copy(f);o.subSelf(n.multiplyScalar(n.dot(f))).normalize();w.cross(this.vertices[c].normal,f);f=w.dot(e[c]);f=f<0?-1:1;this.vertices[c].tangent.set(o.x,o.y,o.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,g,h,b,r,q=new THREE.Vector3,l=new THREE.Vector3;g=0;for(h=this.vertices.length;g<h;g++){b=this.vertices[g];b.normal.set(0,0,0)}g=0;for(h=this.faces.length;g<h;g++){b=this.faces[g];if(a&&b.vertexNormals.length){q.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)q.addSelf(b.vertexNormals[c]);q.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];r=this.vertices[b.c];q.sub(r.position,
+d.position);l.sub(c.position,d.position);q.crossSelf(l)}q.isZero()||q.normalize();b.normal.copy(q)}},computeVertexNormals:function(){var a,c,d,g;if(this.__tmpVertices==undefined){g=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)g[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{g=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)g[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){g[d.a].addSelf(d.normal);g[d.b].addSelf(d.normal);g[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){g[d.a].addSelf(d.normal);g[d.b].addSelf(d.normal);g[d.c].addSelf(d.normal);g[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)g[a].normalize();a=0;for(c=this.faces.length;a<
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(g[d.a]);d.vertexNormals[1].copy(g[d.b]);d.vertexNormals[2].copy(g[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(g[d.a]);d.vertexNormals[1].copy(g[d.b]);d.vertexNormals[2].copy(g[d.c]);d.vertexNormals[3].copy(g[d.d])}}},computeTangents:function(){function a(t,v,D,E,I,L,N){b=t.vertices[v].position;r=t.vertices[D].position;q=t.vertices[E].position;l=h[I];p=h[L];z=h[N];y=r.x-b.x;u=q.x-b.x;x=r.y-b.y;H=q.y-b.y;
+K=r.z-b.z;M=q.z-b.z;s=p.u-l.u;T=z.u-l.u;G=p.v-l.v;f=z.v-l.v;m=1/(s*f-T*G);j.set((f*y-G*u)*m,(f*x-G*H)*m,(f*K-G*M)*m);k.set((s*u-T*y)*m,(s*H-T*x)*m,(s*M-T*K)*m);i[v].addSelf(j);i[D].addSelf(j);i[E].addSelf(j);e[v].addSelf(k);e[D].addSelf(k);e[E].addSelf(k)}var c,d,g,h,b,r,q,l,p,z,y,u,x,H,K,M,s,T,G,f,m,i=[],e=[],j=new THREE.Vector3,k=new THREE.Vector3,o=new THREE.Vector3,w=new THREE.Vector3,n=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;e[c]=new THREE.Vector3}c=0;
+for(d=this.faces.length;c<d;c++){g=this.faces[c];h=this.uvs[c];if(g instanceof THREE.Face3){a(this,g.a,g.b,g.c,0,1,2);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2])}else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2]);
+this.vertices[g.d].normal.copy(g.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){n.copy(this.vertices[c].normal);g=i[c];o.copy(g);o.subSelf(n.multiplyScalar(n.dot(g))).normalize();w.cross(this.vertices[c].normal,g);g=w.dot(e[c]);g=g<0?-1:1;this.vertices[c].tangent.set(o.x,o.y,o.z,g)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,h,b,q,r,l,p={};f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];
-q=b.materials;r=a(q);if(p[r]==undefined)p[r]={hash:r,counter:0};l=p[r].hash+"_"+p[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){p[r].counter+=1;l=p[r].hash+"_"+p[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,g,h,b,r,q,l,p={};g=0;for(h=this.faces.length;g<h;g++){b=this.faces[g];
+r=b.materials;q=a(r);if(p[q]==undefined)p[q]={hash:q,counter:0};l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:r,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){p[q].counter+=1;l=p[q].hash+"_"+p[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:r,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+THREE.Camera=function(a,c,d,g){this.fov=a;this.aspect=c;this.near=d;this.far=g;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
 THREE.Camera.prototype={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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
 THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
-THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
+THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,g=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){g.setRotY(c.y);this.rotationMatrix.multiplySelf(g)}if(c.z!=0){g.setRotZ(c.z);this.rotationMatrix.multiplySelf(g)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){g.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(g)}}};THREE.Object3DCounter={value:0};
 THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
 THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
@@ -90,110 +90,110 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
 THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.size=this.opacity=1;this.vertex_colors=false;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.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
 THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
 THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={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};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,g,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},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.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
 THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var c,d,f,h={};for(c in a){h[c]={};for(d in a[c]){f=a[c][d];h[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var c,d,f,h={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)h[d]=f[d]}return h}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+var Uniforms={clone:function(a){var c,d,g,h={};for(c in a){h[c]={};for(d in a[c]){g=a[c][d];h[c][d]=g instanceof THREE.Color||g instanceof THREE.Vector3||g instanceof THREE.Texture?g.clone():g}}return h},merge:function(a){var c,d,g,h={};for(c=0;c<a.length;c++){g=this.clone(a[c]);for(d in g)h[d]=g[d]}return h}};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.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(e,j){return j.z-e.z}function c(e,j){var k=0,o=1,w=e.z+e.w,n=j.z+j.w,t=-e.z+e.w,v=-j.z+j.w;if(w>=0&&n>=0&&t>=0&&v>=0)return true;else if(w<0&&n<0||t<0&&v<0)return false;else{if(w<0)k=Math.max(k,w/(w-n));else if(n<0)o=Math.min(o,w/(w-n));if(t<0)k=Math.max(k,t/(t-v));else if(v<0)o=Math.min(o,t/(t-v));if(o<k)return false;else{e.lerpSelf(j,k);j.lerpSelf(e,1-o);return true}}}var d,f,h=[],b,q,r,l=[],p,z,y=[],u,x,H=[],K=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
-T=new THREE.Matrix4,G=[],g=new THREE.Vector4,m=new THREE.Vector4,i;this.projectObjects=function(e,j,k){var o=[],w,n;f=0;s.multiply(j.projectionMatrix,j.matrix);G[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);G[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);G[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);G[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);G[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
+THREE.Projector=function(){function a(e,j){return j.z-e.z}function c(e,j){var k=0,o=1,w=e.z+e.w,n=j.z+j.w,t=-e.z+e.w,v=-j.z+j.w;if(w>=0&&n>=0&&t>=0&&v>=0)return true;else if(w<0&&n<0||t<0&&v<0)return false;else{if(w<0)k=Math.max(k,w/(w-n));else if(n<0)o=Math.min(o,w/(w-n));if(t<0)k=Math.max(k,t/(t-v));else if(v<0)o=Math.min(o,t/(t-v));if(o<k)return false;else{e.lerpSelf(j,k);j.lerpSelf(e,1-o);return true}}}var d,g,h=[],b,r,q,l=[],p,z,y=[],u,x,H=[],K=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
+T=new THREE.Matrix4,G=[],f=new THREE.Vector4,m=new THREE.Vector4,i;this.projectObjects=function(e,j,k){var o=[],w,n;g=0;s.multiply(j.projectionMatrix,j.matrix);G[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);G[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);G[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);G[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);G[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
 s.n33,s.n44-s.n34);G[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);j=0;for(w=G.length;j<w;j++){n=G[j];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}w=e.objects;e=0;for(j=w.length;e<j;e++){n=w[e];var t;if(!(t=!n.visible)){if(t=n instanceof THREE.Mesh){a:{t=void 0;for(var v=n.position,D=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),E=0;E<6;E++){t=G[E].x*v.x+G[E].y*v.y+G[E].z*v.z+G[E].w;if(t<=D){t=false;break a}}t=true}t=!t}t=t}if(!t){d=
-h[f]=h[f]||new THREE.RenderableObject;K.copy(n.position);s.multiplyVector3(K);d.object=n;d.z=K.z;o.push(d);f++}}k&&o.sort(a);return o};this.projectScene=function(e,j,k){var o=[],w=j.near,n=j.far,t,v,D,E,I,L,N,V,W,J,B,R,O,C,Q,U;r=z=x=0;j.autoUpdateMatrix&&j.updateMatrix();s.multiply(j.projectionMatrix,j.matrix);L=this.projectObjects(e,j,true);e=0;for(t=L.length;e<t;e++){N=L[e].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
+h[g]=h[g]||new THREE.RenderableObject;K.copy(n.position);s.multiplyVector3(K);d.object=n;d.z=K.z;o.push(d);g++}}k&&o.sort(a);return o};this.projectScene=function(e,j,k){var o=[],w=j.near,n=j.far,t,v,D,E,I,L,N,V,W,J,B,R,O,C,Q,U;q=z=x=0;j.autoUpdateMatrix&&j.updateMatrix();s.multiply(j.projectionMatrix,j.matrix);L=this.projectObjects(e,j,true);e=0;for(t=L.length;e<t;e++){N=L[e].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
 THREE.Mesh){R=N.geometry;O=R.vertices;v=0;for(D=O.length;v<D;v++){C=O[v];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);E=C.positionScreen;E.copy(C.positionWorld);s.multiplyVector4(E);E.x/=E.w;E.y/=E.w;C.__visible=E.z>w&&E.z<n}R=R.faces;v=0;for(D=R.length;v<D;v++){C=R[v];if(C instanceof THREE.Face3){E=O[C.a];I=O[C.b];Q=O[C.c];if(E.__visible&&I.__visible&&Q.__visible)if(N.doubleSided||N.flipSided!=(Q.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-
-(Q.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(Q.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(Q.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
-b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);Q=C.vertexNormals;i=b.vertexNormalsWorld;E=0;for(I=Q.length;E<I;E++){U=i[E]=i[E]||new THREE.Vector3;U.copy(Q[E]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][2]}o.push(b);r++}}else if(C instanceof THREE.Face4){E=O[C.a];I=O[C.b];Q=O[C.c];U=O[C.d];if(E.__visible&&
-I.__visible&&Q.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(U.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0||(I.positionScreen.x-Q.positionScreen.x)*(U.positionScreen.y-Q.positionScreen.y)-(I.positionScreen.y-Q.positionScreen.y)*(U.positionScreen.x-Q.positionScreen.x)<0)){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
+(Q.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0){b=l[q]=l[q]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(Q.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(Q.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
+b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);Q=C.vertexNormals;i=b.vertexNormalsWorld;E=0;for(I=Q.length;E<I;E++){U=i[E]=i[E]||new THREE.Vector3;U.copy(Q[E]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][2]}o.push(b);q++}}else if(C instanceof THREE.Face4){E=O[C.a];I=O[C.b];Q=O[C.c];U=O[C.d];if(E.__visible&&
+I.__visible&&Q.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(U.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0||(I.positionScreen.x-Q.positionScreen.x)*(U.positionScreen.y-Q.positionScreen.y)-(I.positionScreen.y-Q.positionScreen.y)*(U.positionScreen.x-Q.positionScreen.x)<0)){b=l[q]=l[q]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
 b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];
-b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][3]}o.push(b);r++;q=l[r]=l[r]||new THREE.RenderableFace3;q.v1.positionWorld.copy(I.positionWorld);q.v2.positionWorld.copy(Q.positionWorld);q.v3.positionWorld.copy(U.positionWorld);q.v1.positionScreen.copy(I.positionScreen);q.v2.positionScreen.copy(Q.positionScreen);q.v3.positionScreen.copy(U.positionScreen);q.normalWorld.copy(b.normalWorld);q.centroidWorld.copy(b.centroidWorld);q.centroidScreen.copy(b.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
-J;q.faceMaterials=C.materials;q.overdraw=B;if(N.geometry.uvs[v]){q.uvs[0]=N.geometry.uvs[v][1];q.uvs[1]=N.geometry.uvs[v][2];q.uvs[2]=N.geometry.uvs[v][3]}o.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(s,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);v=1;for(D=O.length;v<D;v++){E=O[v];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);I=O[v-1];g.copy(E.positionScreen);m.copy(I.positionScreen);if(c(g,m)){g.multiplyScalar(1/
-g.w);m.multiplyScalar(1/m.w);p=y[z]=y[z]||new THREE.RenderableLine;p.v1.positionScreen.copy(g);p.v2.positionScreen.copy(m);p.z=Math.max(g.z,m.z);p.materials=N.materials;o.push(p);z++}}}else if(N instanceof THREE.Particle){M.set(N.position.x,N.position.y,N.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=M.x/M.w;u.y=M.y/M.w;u.z=M.z;u.rotation=N.rotation.z;u.scale.x=N.scale.x*Math.abs(u.x-(M.x+j.projectionMatrix.n11)/(M.w+j.projectionMatrix.n14));
+b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][3]}o.push(b);q++;r=l[q]=l[q]||new THREE.RenderableFace3;r.v1.positionWorld.copy(I.positionWorld);r.v2.positionWorld.copy(Q.positionWorld);r.v3.positionWorld.copy(U.positionWorld);r.v1.positionScreen.copy(I.positionScreen);r.v2.positionScreen.copy(Q.positionScreen);r.v3.positionScreen.copy(U.positionScreen);r.normalWorld.copy(b.normalWorld);r.centroidWorld.copy(b.centroidWorld);r.centroidScreen.copy(b.centroidScreen);r.z=r.centroidScreen.z;r.meshMaterials=
+J;r.faceMaterials=C.materials;r.overdraw=B;if(N.geometry.uvs[v]){r.uvs[0]=N.geometry.uvs[v][1];r.uvs[1]=N.geometry.uvs[v][2];r.uvs[2]=N.geometry.uvs[v][3]}o.push(r);q++}}}}else if(N instanceof THREE.Line){T.multiply(s,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);v=1;for(D=O.length;v<D;v++){E=O[v];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);I=O[v-1];f.copy(E.positionScreen);m.copy(I.positionScreen);if(c(f,m)){f.multiplyScalar(1/
+f.w);m.multiplyScalar(1/m.w);p=y[z]=y[z]||new THREE.RenderableLine;p.v1.positionScreen.copy(f);p.v2.positionScreen.copy(m);p.z=Math.max(f.z,m.z);p.materials=N.materials;o.push(p);z++}}}else if(N instanceof THREE.Particle){M.set(N.position.x,N.position.y,N.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=M.x/M.w;u.y=M.y/M.w;u.z=M.z;u.rotation=N.rotation.z;u.scale.x=N.scale.x*Math.abs(u.x-(M.x+j.projectionMatrix.n11)/(M.w+j.projectionMatrix.n14));
 u.scale.y=N.scale.y*Math.abs(u.y-(M.y+j.projectionMatrix.n22)/(M.w+j.projectionMatrix.n24));u.materials=N.materials;o.push(u);x++}}}}k&&o.sort(a);return o};this.unprojectVector=function(e,j){var k=THREE.Matrix4.makeInvert(j.matrix);k.multiplySelf(THREE.Matrix4.makeInvert(j.projectionMatrix));k.multiplyVector3(e);return e}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;f=r;h=d/2;b=f/2};this.render=function(q,r){var l,p,z,y,u,x,H,K;a=c.projectScene(q,r);l=0;for(p=a.length;l<p;l++){u=a[l];if(u instanceof THREE.RenderableParticle){H=u.x*h+h;K=u.y*b+b;z=0;for(y=u.material.length;z<y;z++){x=u.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=K+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ca){if(u!=ca)p.globalAlpha=u=ca}function c(ca){if(x!=ca){switch(ca){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}x=ca}}var d=null,f=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,p=h.getContext("2d"),z=new THREE.Color(0),y=0,u=1,x=0,H=null,K=null,M=1,s,T,G,g,m,i,e,j,k,o=new THREE.Color,
-w=new THREE.Color,n=new THREE.Color,t=new THREE.Color,v=new THREE.Color,D,E,I,L,N,V,W,J,B,R=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,Q=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,ka,ga,pa,ea,qa=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);ka=oa.getImageData(0,0,2,2);ga=ka.data;pa=document.createElement("canvas");pa.width=
-pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,la){b=ca;q=la;r=b/2;l=q/2;h.width=b;h.height=q;R.set(-r,-l,r,l);u=1;x=0;K=H=null;M=1};this.setClearColor=function(ca,la){z.setHex(ca);y=la;O.set(-r,-l,r,l);p.setTransform(1,0,0,-1,r,l);this.clear()};this.clear=function(){p.setTransform(1,0,0,-1,r,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(R);if(z.hex==0&&y==0)p.clearRect(O.getX(),
-O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);p.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";p.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,F,P=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=P.length;A<X;A++){S=P[A];F=S.color;if(S instanceof THREE.AmbientLight){Y.r+=F.r;Y.g+=F.g;Y.b+=F.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
-F.r;fa.g+=F.g;fa.b+=F.b}else if(S instanceof THREE.PointLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}}}function Aa(A,X,S,F){var P,$,da,ha,ia=A.lights;A=0;for(P=ia.length;A<P;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
-var F,P,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;P=X.scale.x*r;$=X.scale.y*l;S=P*ha;F=$*ia;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(R.instersects(C)){p.save();p.translate(A.x,A.y);p.rotate(-X.rotation);p.scale(P,-$);p.translate(-ha,-ia);p.drawImage(da,0,0);p.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(Q){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;o.r=S.color.r*U.r;o.g=S.color.g*U.g;
-o.b=S.color.b*U.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;S=X.scale.x*r;F=X.scale.y*l;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(R.instersects(C)){P=o.__styleString;if(K!=P)p.fillStyle=K=P;p.save();p.translate(A.x,A.y);p.rotate(-X.rotation);p.scale(S,F);p.beginPath();p.arc(0,0,1,0,za,true);p.closePath();p.fill();p.restore()}}}}function Oa(A,X,S,F){if(F.opacity!=0){a(F.opacity);c(F.blending);p.beginPath();p.moveTo(A.positionScreen.x,A.positionScreen.y);p.lineTo(X.positionScreen.x,X.positionScreen.y);
-p.closePath();if(F instanceof THREE.LineBasicMaterial){o.__styleString=F.color.__styleString;A=F.linewidth;if(M!=A)p.lineWidth=M=A;A=o.__styleString;if(H!=A)p.strokeStyle=H=A;p.stroke();C.inflate(F.linewidth*2)}}}function Ja(A,X,S,F,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);g=A.positionScreen.x;m=A.positionScreen.y;i=X.positionScreen.x;e=X.positionScreen.y;j=S.positionScreen.x;k=S.positionScreen.y;p.beginPath();p.moveTo(g,m);p.lineTo(i,e);p.lineTo(j,k);p.lineTo(g,m);p.closePath();if(P instanceof
-THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&wa(g,m,i,e,j,k,P.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=la.matrix;Z.copy(F.vertexNormalsWorld[0]);L=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;
-W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(g,m,i,e,j,k,P.env_map.image,L,N,V,W,J,B)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&wa(g,m,i,e,j,k,P.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);
-c(THREE.SubtractiveBlending)}if(Q)if(!P.wireframe&&P.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){w.r=n.r=t.r=Y.r;w.g=n.g=t.g=Y.g;w.b=n.b=t.b=Y.b;Aa($,F.v1.positionWorld,F.vertexNormalsWorld[0],w);Aa($,F.v2.positionWorld,F.vertexNormalsWorld[1],n);Aa($,F.v3.positionWorld,F.vertexNormalsWorld[2],t);v.r=(n.r+t.r)*0.5;v.g=(n.g+t.g)*0.5;v.b=(n.b+t.b)*0.5;I=Ka(w,n,t,v);wa(g,m,i,e,j,k,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,F.centroidWorld,F.normalWorld,U);o.r=P.color.r*U.r;o.g=
-P.color.g*U.g;o.b=P.color.b*U.b;o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){D=la.near;E=la.far;w.r=w.g=w.b=1-Fa(A.positionScreen.z,D,E);n.r=n.g=n.b=1-Fa(X.positionScreen.z,D,E);t.r=t.g=t.b=1-Fa(S.positionScreen.z,D,E);v.r=(n.r+t.r)*0.5;v.g=(n.g+t.g)*0.5;v.b=(n.b+t.b)*0.5;I=Ka(w,n,t,v);wa(g,m,i,e,j,k,I,0,0,1,0,0,
-1)}else if(P instanceof THREE.MeshNormalMaterial){o.r=Ga(F.normalWorld.x);o.g=Ga(F.normalWorld.y);o.b=Ga(F.normalWorld.z);o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}}}function Ba(A,X){if(H!=A)p.strokeStyle=H=A;if(M!=X)p.lineWidth=M=X;p.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)p.fillStyle=K=A;p.fill()}function wa(A,X,S,F,P,$,da,ha,ia,ra,ja,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ja*=ta;sa*=ua;xa*=ta;S-=A;F-=X;P-=
-A;$-=X;ra-=ha;ja-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ja);ua=(xa*S-ja*P)*ta;ja=(xa*F-ja*$)*ta;S=(ra*P-sa*S)*ta;F=(ra*$-sa*F)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-F*ia;p.save();p.transform(ua,ja,S,F,A,X);p.clip();p.drawImage(da,0,0);p.restore()}function Ka(A,X,S,F){var P=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),ra=~~(S.g*255);S=~~(S.b*255);var ja=~~(F.r*255),sa=~~(F.g*255);F=~~(F.b*255);ga[0]=P<0?0:P>255?255:P;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:
-A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ja<0?0:ja>255?255:ja;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=F<0?0:F>255?255:F;oa.putImageData(ka,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,F=X.y-A.y,P=1/Math.sqrt(S*S+F*F);S*=P;F*=P;X.x+=S;X.y+=F;A.x-=S;A.y-=
-F}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():p.setTransform(1,0,0,-1,r,l);d=f.projectScene(ca,la,this.sortElements);(Q=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){s=ba;s.x*=r;s.y*=l;ma=0;for(va=ba.materials.length;ma<va;ma++)Na(s,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){s=ba.v1;T=ba.v2;s.positionScreen.x*=r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(s.positionScreen.x,
-s.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(s,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){s=ba.v1;T=ba.v2;G=ba.v3;s.positionScreen.x*=r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;G.positionScreen.x*=r;G.positionScreen.y*=l;if(ba.overdraw){Ha(s.positionScreen,T.positionScreen);Ha(T.positionScreen,G.positionScreen);Ha(G.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,
-s.positionScreen.y,T.positionScreen.x,T.positionScreen.y,G.positionScreen.x,G.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(s,T,G,ba,ya,ca)}else Ja(s,T,G,ba,ya,ca)}}}O.addRectangle(C)}p.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(L,N,V){var W,J,B,R;W=0;for(J=L.lights.length;W<J;W++){B=L.lights[W];if(B instanceof THREE.DirectionalLight){R=N.normalWorld.dot(B.position)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}else if(B instanceof THREE.PointLight){k.sub(B.position,N.centroidWorld);k.normalize();R=N.normalWorld.dot(k)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}}}function c(L,N,V,W,J,B){t=f(v++);t.setAttribute("d","M "+L.positionScreen.x+
-" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){g.r=m.r;g.g=m.g;g.b=m.b;a(B,W,g);G.r=J.color.r*g.r;G.g=J.color.g*g.g;G.b=J.color.b*g.b;G.updateStyleString()}else G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){j=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
-G.setRGB(j,j,j)}else J instanceof THREE.MeshNormalMaterial&&G.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(t)}function d(L,N,V,W,J,B,R){t=f(v++);t.setAttribute("d",
-"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){g.r=m.r;g.g=m.g;g.b=m.b;a(R,J,g);G.r=B.color.r*g.r;G.g=B.color.g*g.g;G.b=B.color.b*g.b;G.updateStyleString()}else G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=
-1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);G.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&G.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(t)}
-function f(L){if(o[L]==null){o[L]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&o[L].setAttribute("shape-rendering","crispEdges");return o[L]}return o[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,p,z,y,u,x,H,K,M=new THREE.Rectangle,s=new THREE.Rectangle,T=false,G=new THREE.Color(16777215),g=new THREE.Color(16777215),m=new THREE.Color(0),i=new THREE.Color(0),
-e=new THREE.Color(0),j,k=new THREE.Vector3,o=[],w=[],n=[],t,v,D,E,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":I=1;break;case "low":I=0}};this.setSize=function(L,N){l=L;p=N;z=l/2;y=p/2;r.setAttribute("viewBox",-z+" "+-y+" "+l+" "+p);r.setAttribute("width",l);r.setAttribute("height",p);M.set(-z,-y,z,y)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(L,N){var V,W,
-J,B,R,O,C,Q;this.autoClear&&this.clear();b=q.projectScene(L,N,this.sortElements);E=D=v=0;if(T=L.lights.length>0){C=L.lights;m.setRGB(0,0,0);i.setRGB(0,0,0);e.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){m.r+=B.r;m.g+=B.g;m.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){e.r+=B.r;e.g+=B.g;e.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];s.empty();if(C instanceof THREE.RenderableParticle){u=
-C;u.x*=z;u.y*=-y;J=0;for(B=C.materials.length;J<B;J++)if(Q=C.materials[J]){R=u;O=C;Q=Q;var U=D++;if(w[U]==null){w[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&w[U].setAttribute("shape-rendering","crispEdges")}t=w[U];t.setAttribute("cx",R.x);t.setAttribute("cy",R.y);t.setAttribute("r",O.scale.x*z);if(Q instanceof THREE.ParticleCircleMaterial){if(T){g.r=m.r+i.r+e.r;g.g=m.g+i.g+e.g;g.b=m.b+i.b+e.b;G.r=Q.color.r*g.r;G.g=Q.color.g*g.g;G.b=Q.color.b*g.b;G.updateStyleString()}else G=
-Q.color;t.setAttribute("style","fill: "+G.__styleString)}r.appendChild(t)}}else if(C instanceof THREE.RenderableLine){u=C.v1;x=C.v2;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.materials.length;J<B;)if(Q=C.materials[J++]){R=u;O=x;Q=Q;U=E++;if(n[U]==null){n[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
-0&&n[U].setAttribute("shape-rendering","crispEdges")}t=n[U];t.setAttribute("x1",R.positionScreen.x);t.setAttribute("y1",R.positionScreen.y);t.setAttribute("x2",O.positionScreen.x);t.setAttribute("y2",O.positionScreen.y);if(Q instanceof THREE.LineBasicMaterial){G.__styleString=Q.color.__styleString;t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+Q.linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.linecap+"; stroke-linejoin: "+Q.linejoin);r.appendChild(t)}}}}else if(C instanceof
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,g,h,b;this.domElement=document.createElement("div");this.setSize=function(r,q){d=r;g=q;h=d/2;b=g/2};this.render=function(r,q){var l,p,z,y,u,x,H,K;a=c.projectScene(r,q);l=0;for(p=a.length;l<p;l++){u=a[l];if(u instanceof THREE.RenderableParticle){H=u.x*h+h;K=u.y*b+b;z=0;for(y=u.material.length;z<y;z++){x=u.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=K+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ca){if(u!=ca)p.globalAlpha=u=ca}function c(ca){if(x!=ca){switch(ca){case THREE.NormalBlending:p.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:p.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:p.globalCompositeOperation="darker"}x=ca}}var d=null,g=new THREE.Projector,h=document.createElement("canvas"),b,r,q,l,p=h.getContext("2d"),z=new THREE.Color(0),y=0,u=1,x=0,H=null,K=null,M=1,s,T,G,f,m,i,e,j,k,o=new THREE.Color,
+w=new THREE.Color,n=new THREE.Color,t=new THREE.Color,v=new THREE.Color,D,E,I,L,N,V,W,J,B,R=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,Q=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,la,ga,pa,ea,qa=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);la=oa.getImageData(0,0,2,2);ga=la.data;pa=document.createElement("canvas");pa.width=
+pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,ja){b=ca;r=ja;q=b/2;l=r/2;h.width=b;h.height=r;R.set(-q,-l,q,l);u=1;x=0;K=H=null;M=1};this.setClearColor=function(ca,ja){z=ca;y=ja;O.set(-q,-l,q,l);p.setTransform(1,0,0,-1,q,l);this.clear()};this.setClearColorHex=function(ca,ja){z.setHex(ca);y=ja;O.set(-q,-l,q,l);p.setTransform(1,0,0,-1,q,l);this.clear()};this.clear=function(){p.setTransform(1,
+0,0,-1,q,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(R);if(z.hex==0&&y==0)p.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);p.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";p.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,ja){function Ea(A){var X,S,F,P=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=P.length;A<X;A++){S=P[A];F=S.color;if(S instanceof
+THREE.AmbientLight){Y.r+=F.r;Y.g+=F.g;Y.b+=F.b}else if(S instanceof THREE.DirectionalLight){fa.r+=F.r;fa.g+=F.g;fa.b+=F.b}else if(S instanceof THREE.PointLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}}}function Aa(A,X,S,F){var P,$,da,ha,ia=A.lights;A=0;for(P=ia.length;A<P;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>
+0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);var F,P,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;P=X.scale.x*q;$=X.scale.y*l;S=P*ha;F=$*ia;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(R.instersects(C)){p.save();p.translate(A.x,A.y);p.rotate(-X.rotation);p.scale(P,-$);p.translate(-ha,-ia);p.drawImage(da,0,0);p.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(Q){U.r=
+Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;o.r=S.color.r*U.r;o.g=S.color.g*U.g;o.b=S.color.b*U.b;o.updateStyleString()}else o.__styleString=S.color.__styleString;S=X.scale.x*q;F=X.scale.y*l;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(R.instersects(C)){P=o.__styleString;if(K!=P)p.fillStyle=K=P;p.save();p.translate(A.x,A.y);p.rotate(-X.rotation);p.scale(S,F);p.beginPath();p.arc(0,0,1,0,za,true);p.closePath();p.fill();p.restore()}}}}function Oa(A,X,S,F){if(F.opacity!=0){a(F.opacity);c(F.blending);p.beginPath();
+p.moveTo(A.positionScreen.x,A.positionScreen.y);p.lineTo(X.positionScreen.x,X.positionScreen.y);p.closePath();if(F instanceof THREE.LineBasicMaterial){o.__styleString=F.color.__styleString;A=F.linewidth;if(M!=A)p.lineWidth=M=A;A=o.__styleString;if(H!=A)p.strokeStyle=H=A;p.stroke();C.inflate(F.linewidth*2)}}}function Ja(A,X,S,F,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);f=A.positionScreen.x;m=A.positionScreen.y;i=X.positionScreen.x;e=X.positionScreen.y;j=S.positionScreen.x;k=S.positionScreen.y;
+p.beginPath();p.moveTo(f,m);p.lineTo(i,e);p.lineTo(j,k);p.lineTo(f,m);p.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&wa(f,m,i,e,j,k,P.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ja.matrix;Z.copy(F.vertexNormalsWorld[0]);L=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*
+A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(f,m,i,e,j,k,P.env_map.image,L,N,V,W,J,B)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&
+wa(f,m,i,e,j,k,P.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);c(THREE.SubtractiveBlending)}if(Q)if(!P.wireframe&&P.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){w.r=n.r=t.r=Y.r;w.g=n.g=t.g=Y.g;w.b=n.b=t.b=Y.b;Aa($,F.v1.positionWorld,F.vertexNormalsWorld[0],w);Aa($,F.v2.positionWorld,F.vertexNormalsWorld[1],n);Aa($,F.v3.positionWorld,F.vertexNormalsWorld[2],t);v.r=(n.r+t.r)*0.5;v.g=(n.g+t.g)*0.5;v.b=(n.b+t.b)*0.5;I=Ka(w,n,t,v);wa(f,m,i,e,j,k,I,0,0,1,
+0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,F.centroidWorld,F.normalWorld,U);o.r=P.color.r*U.r;o.g=P.color.g*U.g;o.b=P.color.b*U.b;o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){D=ja.near;E=ja.far;w.r=w.g=w.b=1-Fa(A.positionScreen.z,D,E);n.r=n.g=n.b=1-Fa(X.positionScreen.z,D,E);t.r=t.g=t.b=1-Fa(S.positionScreen.z,D,E);
+v.r=(n.r+t.r)*0.5;v.g=(n.g+t.g)*0.5;v.b=(n.b+t.b)*0.5;I=Ka(w,n,t,v);wa(f,m,i,e,j,k,I,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){o.r=Ga(F.normalWorld.x);o.g=Ga(F.normalWorld.y);o.b=Ga(F.normalWorld.z);o.updateStyleString();P.wireframe?Ba(o.__styleString,P.wireframe_linewidth):Ca(o.__styleString)}}}function Ba(A,X){if(H!=A)p.strokeStyle=H=A;if(M!=X)p.lineWidth=M=X;p.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)p.fillStyle=K=A;p.fill()}function wa(A,X,S,F,P,$,da,ha,ia,ra,ka,sa,xa){var ua,
+ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ka*=ta;sa*=ua;xa*=ta;S-=A;F-=X;P-=A;$-=X;ra-=ha;ka-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ka);ua=(xa*S-ka*P)*ta;ka=(xa*F-ka*$)*ta;S=(ra*P-sa*S)*ta;F=(ra*$-sa*F)*ta;A=A-ua*ha-S*ia;X=X-ka*ha-F*ia;p.save();p.transform(ua,ka,S,F,A,X);p.clip();p.drawImage(da,0,0);p.restore()}function Ka(A,X,S,F){var P=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),ra=~~(S.g*255);S=~~(S.b*255);var ka=~~(F.r*255),sa=
+~~(F.g*255);F=~~(F.b*255);ga[0]=P<0?0:P>255?255:P;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ka<0?0:ka>255?255:ka;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=F<0?0:F>255?255:F;oa.putImageData(la,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,
+X){var S=X.x-A.x,F=X.y-A.y,P=1/Math.sqrt(S*S+F*F);S*=P;F*=P;X.x+=S;X.y+=F;A.x-=S;A.y-=F}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():p.setTransform(1,0,0,-1,q,l);d=g.projectScene(ca,ja,this.sortElements);(Q=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){s=ba;s.x*=q;s.y*=l;ma=0;for(va=ba.materials.length;ma<va;ma++)Na(s,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){s=ba.v1;T=ba.v2;s.positionScreen.x*=
+q;s.positionScreen.y*=l;T.positionScreen.x*=q;T.positionScreen.y*=l;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(s,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){s=ba.v1;T=ba.v2;G=ba.v3;s.positionScreen.x*=q;s.positionScreen.y*=l;T.positionScreen.x*=q;T.positionScreen.y*=l;G.positionScreen.x*=q;G.positionScreen.y*=l;if(ba.overdraw){Ha(s.positionScreen,T.positionScreen);
+Ha(T.positionScreen,G.positionScreen);Ha(G.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,T.positionScreen.x,T.positionScreen.y,G.positionScreen.x,G.positionScreen.y);if(R.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(s,T,G,ba,ya,ca)}else Ja(s,T,G,ba,ya,ca)}}}O.addRectangle(C)}p.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(L,N,V){var W,J,B,R;W=0;for(J=L.lights.length;W<J;W++){B=L.lights[W];if(B instanceof THREE.DirectionalLight){R=N.normalWorld.dot(B.position)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}else if(B instanceof THREE.PointLight){k.sub(B.position,N.centroidWorld);k.normalize();R=N.normalWorld.dot(k)*B.intensity;if(R>0){V.r+=B.color.r*R;V.g+=B.color.g*R;V.b+=B.color.b*R}}}}function c(L,N,V,W,J,B){t=g(v++);t.setAttribute("d","M "+L.positionScreen.x+
+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){f.r=m.r;f.g=m.g;f.b=m.b;a(B,W,f);G.r=J.color.r*f.r;G.g=J.color.g*f.g;G.b=J.color.b*f.b;G.updateStyleString()}else G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){j=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
+G.setRGB(j,j,j)}else J instanceof THREE.MeshNormalMaterial&&G.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+J.opacity);q.appendChild(t)}function d(L,N,V,W,J,B,R){t=g(v++);t.setAttribute("d",
+"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){f.r=m.r;f.g=m.g;f.b=m.b;a(R,J,f);G.r=B.color.r*f.r;G.g=B.color.g*f.g;G.b=B.color.b*f.b;G.updateStyleString()}else G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=
+1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);G.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&G.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+B.opacity);q.appendChild(t)}
+function g(L){if(o[L]==null){o[L]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&o[L].setAttribute("shape-rendering","crispEdges");return o[L]}return o[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var b=null,r=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,p,z,y,u,x,H,K,M=new THREE.Rectangle,s=new THREE.Rectangle,T=false,G=new THREE.Color(16777215),f=new THREE.Color(16777215),m=new THREE.Color(0),i=new THREE.Color(0),
+e=new THREE.Color(0),j,k=new THREE.Vector3,o=[],w=[],n=[],t,v,D,E,I=1;this.domElement=q;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":I=1;break;case "low":I=0}};this.setSize=function(L,N){l=L;p=N;z=l/2;y=p/2;q.setAttribute("viewBox",-z+" "+-y+" "+l+" "+p);q.setAttribute("width",l);q.setAttribute("height",p);M.set(-z,-y,z,y)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(L,N){var V,W,
+J,B,R,O,C,Q;this.autoClear&&this.clear();b=r.projectScene(L,N,this.sortElements);E=D=v=0;if(T=L.lights.length>0){C=L.lights;m.setRGB(0,0,0);i.setRGB(0,0,0);e.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){m.r+=B.r;m.g+=B.g;m.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){e.r+=B.r;e.g+=B.g;e.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];s.empty();if(C instanceof THREE.RenderableParticle){u=
+C;u.x*=z;u.y*=-y;J=0;for(B=C.materials.length;J<B;J++)if(Q=C.materials[J]){R=u;O=C;Q=Q;var U=D++;if(w[U]==null){w[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&w[U].setAttribute("shape-rendering","crispEdges")}t=w[U];t.setAttribute("cx",R.x);t.setAttribute("cy",R.y);t.setAttribute("r",O.scale.x*z);if(Q instanceof THREE.ParticleCircleMaterial){if(T){f.r=m.r+i.r+e.r;f.g=m.g+i.g+e.g;f.b=m.b+i.b+e.b;G.r=Q.color.r*f.r;G.g=Q.color.g*f.g;G.b=Q.color.b*f.b;G.updateStyleString()}else G=
+Q.color;t.setAttribute("style","fill: "+G.__styleString)}q.appendChild(t)}}else if(C instanceof THREE.RenderableLine){u=C.v1;x=C.v2;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.materials.length;J<B;)if(Q=C.materials[J++]){R=u;O=x;Q=Q;U=E++;if(n[U]==null){n[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
+0&&n[U].setAttribute("shape-rendering","crispEdges")}t=n[U];t.setAttribute("x1",R.positionScreen.x);t.setAttribute("y1",R.positionScreen.y);t.setAttribute("x2",O.positionScreen.x);t.setAttribute("y2",O.positionScreen.y);if(Q instanceof THREE.LineBasicMaterial){G.__styleString=Q.color.__styleString;t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+Q.linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.linecap+"; stroke-linejoin: "+Q.linejoin);q.appendChild(t)}}}}else if(C instanceof
 THREE.RenderableFace3){u=C.v1;x=C.v2;H=C.v3;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.meshMaterials.length;J<B;){Q=C.meshMaterials[J++];if(Q instanceof THREE.MeshFaceMaterial){R=0;for(O=C.faceMaterials.length;R<O;)(Q=C.faceMaterials[R++])&&
 c(u,x,H,C,Q,L)}else Q&&c(u,x,H,C,Q,L)}}}else if(C instanceof THREE.RenderableFace4){u=C.v1;x=C.v2;H=C.v3;K=C.v4;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;K.positionScreen.x*=z;K.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);if(M.instersects(s)){J=
 0;for(B=C.meshMaterials.length;J<B;){Q=C.meshMaterials[J++];if(Q instanceof THREE.MeshFaceMaterial){R=0;for(O=C.faceMaterials.length;R<O;)(Q=C.faceMaterials[R++])&&d(u,x,H,K,C,Q,L)}else Q&&d(u,x,H,K,C,Q,L)}}}}}};
-THREE.WebGLRenderer=function(a){function c(g,m){g.fragment_shader=m.fragment_shader;g.vertex_shader=m.vertex_shader;g.uniforms=Uniforms.clone(m.uniforms)}function d(g,m){var i;if(g=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,m);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function f(g){switch(g){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
+THREE.WebGLRenderer=function(a){function c(f,m){f.fragment_shader=m.fragment_shader;f.vertex_shader=m.vertex_shader;f.uniforms=Uniforms.clone(m.uniforms)}function d(f,m){var i;if(f=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,m);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function g(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,q=null,r=null,l=new THREE.Matrix4,p,z=new Float32Array(16),y=new Float32Array(16),
-u=new Float32Array(16),x=new Float32Array(9),H=new Float32Array(16),K=new THREE.Matrix4,M=new THREE.Vector4,s=true,T=new THREE.Color(0),G=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)G=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(g,m,i){try{b=h.getContext("experimental-webgl",{antialias:g})}catch(e){console.log(e)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
-0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(m.r,m.g,m.b,i)})(s,T,G);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,m){h.width=g;h.height=m;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(g,m){var i=new THREE.Color(g);b.clearColor(i.r,
-i.g,i.b,m)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(g,m){var i,e,j,k=0,o=0,w=0,n,t,v,D=this.lights,E=D.directional.colors,I=D.directional.positions,L=D.point.colors,N=D.point.positions,V=0,W=0;i=0;for(e=m.length;i<e;i++){j=m[i];n=j.color;t=j.position;v=j.intensity;if(j instanceof THREE.AmbientLight){k+=n.r;o+=n.g;w+=n.b}else if(j instanceof THREE.DirectionalLight){E[V*3]=n.r*v;E[V*3+1]=n.g*v;E[V*3+2]=n.b*v;I[V*3]=t.x;I[V*3+1]=t.y;I[V*3+2]=t.z;
-V+=1}else if(j instanceof THREE.PointLight){L[W*3]=n.r*v;L[W*3+1]=n.g*v;L[W*3+2]=n.b*v;N[W*3]=t.x;N[W*3+1]=t.y;N[W*3+2]=t.z;W+=1}}D.point.length=W;D.directional.length=V;D.ambient[0]=k;D.ambient[1]=o;D.ambient[2]=w};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLParticleBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=
-function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLNormalBuffer=b.createBuffer();g.__webGLTangentBuffer=b.createBuffer();g.__webGLUVBuffer=b.createBuffer();g.__webGLUV2Buffer=b.createBuffer();g.__webGLFaceBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(g){var m=g.vertices.length;g.__vertexArray=new Float32Array(m*3);g.__lineArray=new Uint16Array(m);g.__webGLLineCount=m};this.initParticleBuffers=function(g){var m=g.vertices.length;g.__vertexArray=
-new Float32Array(m*3);g.__colorArray=new Float32Array(m*3);g.__particleArray=new Uint16Array(m);g.__sortArray=[];g.__webGLParticleCount=m};this.initMeshBuffers=function(g,m){var i,e,j=0,k=0,o=0,w=m.geometry.faces,n=g.faces;i=0;for(e=n.length;i<e;i++){fi=n[i];face=w[fi];if(face instanceof THREE.Face3){j+=3;k+=1;o+=3}else if(face instanceof THREE.Face4){j+=4;k+=2;o+=4}}g.__vertexArray=new Float32Array(j*3);g.__normalArray=new Float32Array(j*3);g.__tangentArray=new Float32Array(j*4);g.__uvArray=new Float32Array(j*
-2);g.__uv2Array=new Float32Array(j*2);g.__faceArray=new Uint16Array(k*3);g.__lineArray=new Uint16Array(o*2);j=false;i=0;for(e=m.materials.length;i<e;i++){w=m.materials[i];if(w instanceof THREE.MeshFaceMaterial){w=0;for(n=g.materials.length;w<n;w++)if(g.materials[w]&&g.materials[w].shading!=undefined&&g.materials[w].shading==THREE.SmoothShading){j=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){j=true;break}if(j)break}g.__needsSmoothNormals=j;g.__webGLFaceCount=k*3;g.__webGLLineCount=
-o*2};this.setMeshBuffers=function(g,m,i){var e,j,k,o,w,n,t,v,D,E,I=0,L=0,N=0,V=0,W=0,J=0,B=0,R=0,O=g.__vertexArray,C=g.__uvArray,Q=g.__uv2Array,U=g.__normalArray,Y=g.__tangentArray,fa=g.__faceArray,aa=g.__lineArray,za=g.__needsSmoothNormals,Z=m.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=g.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;m=0;for(e=qa.length;m<e;m++){j=qa[m];k=ca[j];n=la[j];j=Ea[j];o=k.vertexNormals;w=k.normal;if(k instanceof
-THREE.Face3){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;L+=9}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;B+=12}if(ga)if(o.length==3&&za)for(k=0;k<3;k++){w=o[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<3;k++){U[J]=
-w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&n)for(k=0;k<3;k++){o=n[k];C[N]=o.u;C[N+1]=o.v;N+=2}if(ka&&j)for(k=0;k<3;k++){n=j[k];Q[V]=n.u;Q[V+1]=n.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+2;aa[R+4]=I+1;aa[R+5]=I+2;R+=6;I+=3}}else if(k instanceof THREE.Face4){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;E=ea[k.d].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;O[L+9]=E.x;O[L+10]=
-E.y;O[L+11]=E.z;L+=12}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;k=ea[k.d].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;Y[B+12]=k.x;Y[B+13]=k.y;Y[B+14]=k.z;Y[B+15]=k.w;B+=16}if(ga)if(o.length==4&&za)for(k=0;k<4;k++){w=o[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<4;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&n)for(k=0;k<4;k++){o=n[k];C[N]=o.u;C[N+1]=o.v;N+=
-2}if(ka&&j)for(k=0;k<4;k++){n=j[k];Q[V]=n.u;Q[V+1]=n.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+3;aa[R+4]=I+1;aa[R+5]=I+2;aa[R+6]=I+2;aa[R+7]=I+3;R+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
-Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Q,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(g,m){var i,e,j,k=g.vertices,o=k.length,w=g.__vertexArray,n=g.__lineArray,t=
-g.__dirtyElements;if(g.__dirtyVertices){for(i=0;i<o;i++){e=k[i].position;j=i*3;w[j]=e.x;w[j+1]=e.y;w[j+2]=e.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,m)}if(t){for(i=0;i<o;i++)n[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,n,m)}};this.setParticleBuffers=function(g,m,i,e){var j,k,o;k=g.vertices;var w=k.length,n=g.colors,t=n.length,v=g.__vertexArray,D=g.__particleArray,E=g.__colorArray,I=g.__sortArray,L=g.__dirtyVertices,
-N=g.__dirtyElements,V=g.__dirtyColors;if(i.sortParticles){K.multiply(e.projectionMatrix,e.matrix);K.multiplySelf(i.matrix);for(j=0;j<w;j++){o=k[j].position;M.copy(o);K.multiplyVector3(M);I[j]=[M.z,j]}I.sort(function(W,J){return J[0]-W[0]});for(j=0;j<w;j++){o=k[I[j][1]].position;e=j*3;v[e]=o.x;v[e+1]=o.y;v[e+2]=o.z}for(k=0;k<t;k++){e=k*3;color=n[I[k][1]];E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}else{if(L)for(j=0;j<w;j++){o=k[j].position;e=j*3;v[e]=o.x;v[e+1]=o.y;v[e+2]=o.z}if(V)for(k=0;k<t;k++){color=
-n[k];e=k*3;E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}if(N){for(j=0;j<w;j++)D[j]=j;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,m)}if(L||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,m)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,m)}};this.initMaterial=function(g,m,i){if(!g.program){var e,j;if(g instanceof THREE.MeshDepthMaterial)c(g,
-THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)c(g,THREE.ShaderLib.normal);else if(g instanceof THREE.MeshBasicMaterial)c(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)c(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)c(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)c(g,THREE.ShaderLib.basic);else g instanceof THREE.ParticleBasicMaterial&&c(g,THREE.ShaderLib.particle_basic);var k,o,w,n;j=w=n=0;for(k=m.length;j<
-k;j++){o=m[j];o instanceof THREE.DirectionalLight&&w++;o instanceof THREE.PointLight&&n++}if(n+w<=4){m=w;n=n}else{m=Math.ceil(4*w/(n+w));n=4-m}j={directional:m,point:n};n=g.fragment_shader;m=g.vertex_shader;k={fog:i,map:g.map,env_map:g.env_map,light_map:g.light_map,vertex_colors:g.vertex_colors,maxDirLights:j.directional,maxPointLights:j.point};i=b.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,
-k.fog?"#define USE_FOG":"",k.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":
-"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",j+n));b.attachShader(i,d("vertex",k+m));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||
-alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};g.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(e in g.uniforms)i.push(e);e=g.program;n=0;for(m=i.length;n<m;n++){j=i[n];e.uniforms[j]=b.getUniformLocation(e,j)}g=g.program;e=["position","normal","uv","uv2","tangent","color"];i=0;for(n=e.length;i<n;i++){m=e[i];g.attributes[m]=
-b.getAttribLocation(g,m)}}};this.setProgram=function(g,m,i,e){this.initMaterial(e,m,i);var j=e.program;if(j!=q){b.useProgram(j);q=j}this.loadCamera(j,g);this.loadMatrices(j);if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial){this.setupLights(j,m);m=this.lights;e.uniforms.enableLighting.value=m.directional.length+m.point.length;e.uniforms.ambientLightColor.value=m.ambient;e.uniforms.directionalLightColor.value=m.directional.colors;e.uniforms.directionalLightDirection.value=
-m.directional.positions;e.uniforms.pointLightColor.value=m.point.colors;e.uniforms.pointLightPosition.value=m.point.positions}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.light_map.texture=e.light_map;e.uniforms.env_map.texture=e.env_map;e.uniforms.reflectivity.value=
-e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.LineBasicMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,
-e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.ParticleBasicMaterial){e.uniforms.psColor.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.size.value=e.size;e.uniforms.map.texture=
-e.map;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.MeshPhongMaterial){e.uniforms.ambient.value.setRGB(e.ambient.r,e.ambient.g,e.ambient.b);e.uniforms.specular.value.setRGB(e.specular.r,e.specular.g,e.specular.b);e.uniforms.shininess.value=e.shininess}if(e instanceof THREE.MeshDepthMaterial){e.uniforms.mNear.value=
-g.near;e.uniforms.mFar.value=g.far}g=e.uniforms;var k,o;for(k in g)if(o=j.uniforms[k]){e=g[k];m=e.type;i=e.value;if(m=="i")b.uniform1i(o,i);else if(m=="f")b.uniform1f(o,i);else if(m=="fv1")b.uniform1fv(o,i);else if(m=="fv")b.uniform3fv(o,i);else if(m=="v2")b.uniform2f(o,i.x,i.y);else if(m=="v3")b.uniform3f(o,i.x,i.y,i.z);else if(m=="c")b.uniform3f(o,i.r,i.g,i.b);else if(m=="t"){b.uniform1i(o,i);if(e=e.texture)if(e.image instanceof Array&&e.image.length==6){e=e;i=i;if(e.image.length==6){if(!e.image.__webGLTextureCube&&
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,r=null,q=null,l=new THREE.Matrix4,p,z=new Float32Array(16),y=new Float32Array(16),
+u=new Float32Array(16),x=new Float32Array(9),H=new Float32Array(16),K=new THREE.Matrix4,M=new THREE.Vector4,s=true,T=new THREE.Color(0),G=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)G=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(f,m,i){try{b=h.getContext("experimental-webgl",{antialias:f})}catch(e){console.log(e)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(m.r,m.g,m.b,i)})(s,T,G);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,m){h.width=f;h.height=m;b.viewport(0,0,h.width,h.height)};this.setClearColorHex=function(f,m){var i=new THREE.Color(f);b.clearColor(i.r,
+i.g,i.b,m)};this.setClearColor=function(f,m){b.clearColor(f.r,f.g,f.b,m)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,m){var i,e,j,k=0,o=0,w=0,n,t,v,D=this.lights,E=D.directional.colors,I=D.directional.positions,L=D.point.colors,N=D.point.positions,V=0,W=0;i=0;for(e=m.length;i<e;i++){j=m[i];n=j.color;t=j.position;v=j.intensity;if(j instanceof THREE.AmbientLight){k+=n.r;o+=n.g;w+=n.b}else if(j instanceof THREE.DirectionalLight){E[V*3]=n.r*v;E[V*
+3+1]=n.g*v;E[V*3+2]=n.b*v;I[V*3]=t.x;I[V*3+1]=t.y;I[V*3+2]=t.z;V+=1}else if(j instanceof THREE.PointLight){L[W*3]=n.r*v;L[W*3+1]=n.g*v;L[W*3+2]=n.b*v;N[W*3]=t.x;N[W*3+1]=t.y;N[W*3+2]=t.z;W+=1}}D.point.length=W;D.directional.length=V;D.ambient[0]=k;D.ambient[1]=o;D.ambient[2]=w};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLParticleBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();
+f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=b.createBuffer();f.__webGLUV2Buffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var m=f.vertices.length;f.__vertexArray=new Float32Array(m*3);f.__lineArray=new Uint16Array(m);f.__webGLLineCount=m};this.initParticleBuffers=
+function(f){var m=f.vertices.length;f.__vertexArray=new Float32Array(m*3);f.__colorArray=new Float32Array(m*3);f.__particleArray=new Uint16Array(m);f.__sortArray=[];f.__webGLParticleCount=m};this.initMeshBuffers=function(f,m){var i,e,j=0,k=0,o=0,w=m.geometry.faces,n=f.faces;i=0;for(e=n.length;i<e;i++){fi=n[i];face=w[fi];if(face instanceof THREE.Face3){j+=3;k+=1;o+=3}else if(face instanceof THREE.Face4){j+=4;k+=2;o+=4}}f.__vertexArray=new Float32Array(j*3);f.__normalArray=new Float32Array(j*3);f.__tangentArray=
+new Float32Array(j*4);f.__uvArray=new Float32Array(j*2);f.__uv2Array=new Float32Array(j*2);f.__faceArray=new Uint16Array(k*3);f.__lineArray=new Uint16Array(o*2);j=false;i=0;for(e=m.materials.length;i<e;i++){w=m.materials[i];if(w instanceof THREE.MeshFaceMaterial){w=0;for(n=f.materials.length;w<n;w++)if(f.materials[w]&&f.materials[w].shading!=undefined&&f.materials[w].shading==THREE.SmoothShading){j=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){j=true;break}if(j)break}f.__needsSmoothNormals=
+j;f.__webGLFaceCount=k*3;f.__webGLLineCount=o*2};this.setMeshBuffers=function(f,m,i){var e,j,k,o,w,n,t,v,D,E,I=0,L=0,N=0,V=0,W=0,J=0,B=0,R=0,O=f.__vertexArray,C=f.__uvArray,Q=f.__uv2Array,U=f.__normalArray,Y=f.__tangentArray,fa=f.__faceArray,aa=f.__lineArray,za=f.__needsSmoothNormals,Z=m.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,la=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=f.faces,ca=Z.faces,ja=Z.uvs,Ea=Z.uvs2;m=0;for(e=qa.length;m<e;m++){j=qa[m];k=ca[j];n=ja[j];
+j=Ea[j];o=k.vertexNormals;w=k.normal;if(k instanceof THREE.Face3){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;L+=9}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;B+=12}if(ga)if(o.length==3&&za)for(k=0;k<3;k++){w=o[k];U[J]=w.x;
+U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<3;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(la&&n)for(k=0;k<3;k++){o=n[k];C[N]=o.u;C[N+1]=o.v;N+=2}if(la&&j)for(k=0;k<3;k++){n=j[k];Q[V]=n.u;Q[V+1]=n.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+2;aa[R+4]=I+1;aa[R+5]=I+2;R+=6;I+=3}}else if(k instanceof THREE.Face4){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;E=ea[k.d].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;
+O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;O[L+9]=E.x;O[L+10]=E.y;O[L+11]=E.z;L+=12}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;k=ea[k.d].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;Y[B+12]=k.x;Y[B+13]=k.y;Y[B+14]=k.z;Y[B+15]=k.w;B+=16}if(ga)if(o.length==4&&za)for(k=0;k<4;k++){w=o[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<4;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(la&&
+n)for(k=0;k<4;k++){o=n[k];C[N]=o.u;C[N+1]=o.v;N+=2}if(la&&j)for(k=0;k<4;k++){n=j[k];Q[V]=n.u;Q[V+1]=n.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[R]=I;aa[R+1]=I+1;aa[R+2]=I;aa[R+3]=I+3;aa[R+4]=I+1;aa[R+5]=I+2;aa[R+6]=I+2;aa[R+7]=I+3;R+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,
+f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Y,i)}if(la&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(la&&V>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Q,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(f,m){var i,e,j,k=f.vertices,
+o=k.length,w=f.__vertexArray,n=f.__lineArray,t=f.__dirtyElements;if(f.__dirtyVertices){for(i=0;i<o;i++){e=k[i].position;j=i*3;w[j]=e.x;w[j+1]=e.y;w[j+2]=e.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,m)}if(t){for(i=0;i<o;i++)n[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,n,m)}};this.setParticleBuffers=function(f,m,i,e){var j,k,o;k=f.vertices;var w=k.length,n=f.colors,t=n.length,v=f.__vertexArray,D=f.__particleArray,
+E=f.__colorArray,I=f.__sortArray,L=f.__dirtyVertices,N=f.__dirtyElements,V=f.__dirtyColors;if(i.sortParticles){K.multiply(e.projectionMatrix,e.matrix);K.multiplySelf(i.matrix);for(j=0;j<w;j++){o=k[j].position;M.copy(o);K.multiplyVector3(M);I[j]=[M.z,j]}I.sort(function(W,J){return J[0]-W[0]});for(j=0;j<w;j++){o=k[I[j][1]].position;e=j*3;v[e]=o.x;v[e+1]=o.y;v[e+2]=o.z}for(k=0;k<t;k++){e=k*3;color=n[I[k][1]];E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}else{if(L)for(j=0;j<w;j++){o=k[j].position;e=j*3;
+v[e]=o.x;v[e+1]=o.y;v[e+2]=o.z}if(V)for(k=0;k<t;k++){color=n[k];e=k*3;E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}if(N){for(j=0;j<w;j++)D[j]=j;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,m)}if(L||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,m)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,m)}};this.initMaterial=function(f,m,i){if(!f.program){var e,
+j;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);
+var k,o,w,n;j=w=n=0;for(k=m.length;j<k;j++){o=m[j];o instanceof THREE.DirectionalLight&&w++;o instanceof THREE.PointLight&&n++}if(n+w<=4){m=w;n=n}else{m=Math.ceil(4*w/(n+w));n=4-m}j={directional:m,point:n};n=f.fragment_shader;m=f.vertex_shader;k={fog:i,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:j.directional,maxPointLights:j.point};i=b.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+
+k.maxPointLights,k.fog?"#define USE_FOG":"",k.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,k.map?"#define USE_MAP":"",
+k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",j+n));b.attachShader(i,d("vertex",k+m));b.linkProgram(i);
+b.getProgramParameter(i,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};f.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(e in f.uniforms)i.push(e);e=f.program;n=0;for(m=i.length;n<m;n++){j=i[n];e.uniforms[j]=b.getUniformLocation(e,j)}f=f.program;e=["position","normal","uv","uv2","tangent","color"];i=0;
+for(n=e.length;i<n;i++){m=e[i];f.attributes[m]=b.getAttribLocation(f,m)}}};this.setProgram=function(f,m,i,e){this.initMaterial(e,m,i);var j=e.program;if(j!=r){b.useProgram(j);r=j}this.loadCamera(j,f);this.loadMatrices(j);if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial){this.setupLights(j,m);m=this.lights;e.uniforms.enableLighting.value=m.directional.length+m.point.length;e.uniforms.ambientLightColor.value=m.ambient;e.uniforms.directionalLightColor.value=m.directional.colors;
+e.uniforms.directionalLightDirection.value=m.directional.positions;e.uniforms.pointLightColor.value=m.point.colors;e.uniforms.pointLightPosition.value=m.point.positions}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.light_map.texture=e.light_map;e.uniforms.env_map.texture=
+e.env_map;e.uniforms.reflectivity.value=e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.LineBasicMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*
+e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.ParticleBasicMaterial){e.uniforms.psColor.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.size.value=e.size;
+e.uniforms.map.texture=e.map;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.MeshPhongMaterial){e.uniforms.ambient.value.setRGB(e.ambient.r,e.ambient.g,e.ambient.b);e.uniforms.specular.value.setRGB(e.specular.r,e.specular.g,e.specular.b);e.uniforms.shininess.value=e.shininess}if(e instanceof THREE.MeshDepthMaterial){e.uniforms.mNear.value=
+f.near;e.uniforms.mFar.value=f.far}f=e.uniforms;var k,o;for(k in f)if(o=j.uniforms[k]){e=f[k];m=e.type;i=e.value;if(m=="i")b.uniform1i(o,i);else if(m=="f")b.uniform1f(o,i);else if(m=="fv1")b.uniform1fv(o,i);else if(m=="fv")b.uniform3fv(o,i);else if(m=="v2")b.uniform2f(o,i.x,i.y);else if(m=="v3")b.uniform3f(o,i.x,i.y,i.z);else if(m=="c")b.uniform3f(o,i.r,i.g,i.b);else if(m=="t"){b.uniform1i(o,i);if(e=e.texture)if(e.image instanceof Array&&e.image.length==6){e=e;i=i;if(e.image.length==6){if(!e.image.__webGLTextureCube&&
 !e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(m=0;m<6;++m)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
-m,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image[m]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}else{e=e;i=i;if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(e.wrap_s));
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(e.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture)}}}return j};this.renderBuffer=function(g,m,i,e,j,k){g=this.setProgram(g,m,i,e,k).attributes;b.bindBuffer(b.ARRAY_BUFFER,j.__webGLVertexBuffer);b.vertexAttribPointer(g.position,
-3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.position);if(g.color>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.vertexAttribPointer(g.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.color)}if(g.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.vertexAttribPointer(g.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.normal)}if(g.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer);b.vertexAttribPointer(g.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.tangent)}if(g.uv>=
-0)if(j.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.vertexAttribPointer(g.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv)}else b.disableVertexAttribArray(g.uv);if(g.uv2>=0)if(j.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.vertexAttribPointer(g.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv2)}else b.disableVertexAttribArray(g.uv2);if(e.wireframe||e instanceof THREE.LineBasicMaterial){g=e.wireframe_linewidth!==undefined?e.wireframe_linewidth:
-e.linewidth!==undefined?e.linewidth:1;e=e instanceof THREE.LineBasicMaterial&&k.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.drawElements(e,j.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(e instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLParticleBuffer);b.drawElements(b.POINTS,j.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
-j.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,m,i,e,j,k,o){var w,n,t,v,D;t=0;for(v=e.materials.length;t<v;t++){w=e.materials[t];if(w instanceof THREE.MeshFaceMaterial){w=0;for(n=j.materials.length;w<n;w++)if((D=j.materials[w])&&D.blending==k&&D.opacity<1==o){this.setBlending(D.blending);this.renderBuffer(g,m,i,D,j,e)}}else if((D=w)&&D.blending==k&&D.opacity<1==o){this.setBlending(D.blending);this.renderBuffer(g,m,i,D,j,e)}}};this.renderPassImmediate=function(g,m,i,e,j,k){var o,
-w,n,t;o=0;for(w=e.materials.length;o<w;o++)if((n=e.materials[o])&&n.blending==j&&n.opacity<1==k){this.setBlending(n.blending);t=this.setProgram(g,m,i,n,e);e.render(function(v){var D=t;if(!v.__webGLVertexBuffer)v.__webGLVertexBuffer=b.createBuffer();if(!v.__webGLNormalBuffer)v.__webGLNormalBuffer=b.createBuffer();if(v.hasPos){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.position);b.vertexAttribPointer(D.attributes.position,
-3,b.FLOAT,false,0,0)}if(v.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,v.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.normal);b.vertexAttribPointer(D.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,v.count);v.count=0})}};this.render=function(g,m,i,e){var j,k,o,w=g.lights,n=g.fog;m.autoUpdateMatrix&&m.updateMatrix();z.set(m.matrix.flatten());u.set(m.projectionMatrix.flatten());this.initWebGLObjects(g,m);e=e!==undefined?
-e:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
-f(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(i.format),i.width,i.height,0,f(i.format),f(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
-null)}if(i){j=i.__webGLFramebuffer;o=i.width;k=i.height}else{j=null;o=h.width;k=h.height}if(j!=r){b.bindFramebuffer(b.FRAMEBUFFER,j);b.viewport(0,0,o,k);e&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=j}this.autoClear&&this.clear();j=g.__webGLObjects.length;for(e=0;e<j;e++){k=g.__webGLObjects[e];o=k.object;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();if(o.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);o.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(e=0;e<j;e++){k=g.__webGLObjects[e];
-o=k.object;k=k.buffer;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();this.setupMatrices(o,m);this.renderPass(m,w,n,o,k,THREE.NormalBlending,false)}}for(e=0;e<g.__webGLObjectsImmediate.length;e++){k=g.__webGLObjectsImmediate[e];o=k.object;if(o.visible){this.setupMatrices(o,m);this.renderPassImmediate(m,w,n,o,THREE.NormalBlending,false)}}for(e=0;e<j;e++){k=g.__webGLObjects[e];o=k.object;k=k.buffer;if(o.visible){this.setupMatrices(o,m);this.renderPass(m,w,n,o,k,THREE.AdditiveBlending,false);this.renderPass(m,
-w,n,o,k,THREE.SubtractiveBlending,false);this.renderPass(m,w,n,o,k,THREE.AdditiveBlending,true);this.renderPass(m,w,n,o,k,THREE.SubtractiveBlending,true);this.renderPass(m,w,n,o,k,THREE.NormalBlending,true);this.renderPass(m,w,n,o,k,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(g,m){function i(D,
-E,I,L){if(D[E]==undefined){g.__webGLObjects.push({buffer:I,object:L});D[E]=1}}function e(D,E,I){if(D[E]==undefined){g.__webGLObjectsImmediate.push({object:I});D[E]=1}}var j,k,o,w,n,t,v;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={};g.__webGLObjectsImmediate=[]}j=0;for(k=g.objects.length;j<k;j++){o=g.objects[j];n=o.geometry;if(g.__webGLObjectsMap[o.id]==undefined)g.__webGLObjectsMap[o.id]={};v=g.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh){for(w in n.geometryChunks){t=n.geometryChunks[w];
+m,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image[m]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}else{e=e;i=i;if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,g(e.wrap_s));
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,g(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,g(e.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture)}}}return j};this.renderBuffer=function(f,m,i,e,j,k){f=this.setProgram(f,m,i,e,k).attributes;b.bindBuffer(b.ARRAY_BUFFER,j.__webGLVertexBuffer);b.vertexAttribPointer(f.position,
+3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.position);if(f.color>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.vertexAttribPointer(f.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.color)}if(f.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.vertexAttribPointer(f.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.normal)}if(f.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer);b.vertexAttribPointer(f.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.tangent)}if(f.uv>=
+0)if(j.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.vertexAttribPointer(f.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv)}else b.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(j.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.vertexAttribPointer(f.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv2)}else b.disableVertexAttribArray(f.uv2);if(e.wireframe||e instanceof THREE.LineBasicMaterial){f=e.wireframe_linewidth!==undefined?e.wireframe_linewidth:
+e.linewidth!==undefined?e.linewidth:1;e=e instanceof THREE.LineBasicMaterial&&k.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.drawElements(e,j.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(e instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLParticleBuffer);b.drawElements(b.POINTS,j.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
+j.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,m,i,e,j,k,o){var w,n,t,v,D;t=0;for(v=e.materials.length;t<v;t++){w=e.materials[t];if(w instanceof THREE.MeshFaceMaterial){w=0;for(n=j.materials.length;w<n;w++)if((D=j.materials[w])&&D.blending==k&&D.opacity<1==o){this.setBlending(D.blending);this.renderBuffer(f,m,i,D,j,e)}}else if((D=w)&&D.blending==k&&D.opacity<1==o){this.setBlending(D.blending);this.renderBuffer(f,m,i,D,j,e)}}};this.renderPassImmediate=function(f,m,i,e,j,k){var o,
+w,n,t;o=0;for(w=e.materials.length;o<w;o++)if((n=e.materials[o])&&n.blending==j&&n.opacity<1==k){this.setBlending(n.blending);t=this.setProgram(f,m,i,n,e);e.render(function(v){var D=t;if(!v.__webGLVertexBuffer)v.__webGLVertexBuffer=b.createBuffer();if(!v.__webGLNormalBuffer)v.__webGLNormalBuffer=b.createBuffer();if(v.hasPos){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.position);b.vertexAttribPointer(D.attributes.position,
+3,b.FLOAT,false,0,0)}if(v.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,v.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.normal);b.vertexAttribPointer(D.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,v.count);v.count=0})}};this.render=function(f,m,i,e){var j,k,o,w=f.lights,n=f.fog;m.autoUpdateMatrix&&m.updateMatrix();z.set(m.matrix.flatten());u.set(m.projectionMatrix.flatten());this.initWebGLObjects(f,m);e=e!==undefined?
+e:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,g(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
+g(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,g(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,g(i.format),i.width,i.height,0,g(i.format),g(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
+null)}if(i){j=i.__webGLFramebuffer;o=i.width;k=i.height}else{j=null;o=h.width;k=h.height}if(j!=q){b.bindFramebuffer(b.FRAMEBUFFER,j);b.viewport(0,0,o,k);e&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);q=j}this.autoClear&&this.clear();j=f.__webGLObjects.length;for(e=0;e<j;e++){k=f.__webGLObjects[e];o=k.object;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();if(o.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);o.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(e=0;e<j;e++){k=f.__webGLObjects[e];
+o=k.object;k=k.buffer;if(o.visible){o.autoUpdateMatrix&&o.updateMatrix();this.setupMatrices(o,m);this.renderPass(m,w,n,o,k,THREE.NormalBlending,false)}}for(e=0;e<f.__webGLObjectsImmediate.length;e++){k=f.__webGLObjectsImmediate[e];o=k.object;if(o.visible){this.setupMatrices(o,m);this.renderPassImmediate(m,w,n,o,THREE.NormalBlending,false)}}for(e=0;e<j;e++){k=f.__webGLObjects[e];o=k.object;k=k.buffer;if(o.visible){this.setupMatrices(o,m);this.renderPass(m,w,n,o,k,THREE.AdditiveBlending,false);this.renderPass(m,
+w,n,o,k,THREE.SubtractiveBlending,false);this.renderPass(m,w,n,o,k,THREE.AdditiveBlending,true);this.renderPass(m,w,n,o,k,THREE.SubtractiveBlending,true);this.renderPass(m,w,n,o,k,THREE.NormalBlending,true);this.renderPass(m,w,n,o,k,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(f,m){function i(D,
+E,I,L){if(D[E]==undefined){f.__webGLObjects.push({buffer:I,object:L});D[E]=1}}function e(D,E,I){if(D[E]==undefined){f.__webGLObjectsImmediate.push({object:I});D[E]=1}}var j,k,o,w,n,t,v;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}j=0;for(k=f.objects.length;j<k;j++){o=f.objects[j];n=o.geometry;if(f.__webGLObjectsMap[o.id]==undefined)f.__webGLObjectsMap[o.id]={};v=f.__webGLObjectsMap[o.id];if(o instanceof THREE.Mesh){for(w in n.geometryChunks){t=n.geometryChunks[w];
 if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,o);n.__dirtyVertices=true;n.__dirtyElements=true;n.__dirtyUvs=true;n.__dirtyNormals=true;n.__dirtyTangents=true}if(n.__dirtyVertices||n.__dirtyElements||n.__dirtyUvs)this.setMeshBuffers(t,o,b.DYNAMIC_DRAW);i(v,w,t,o)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false}else if(o instanceof THREE.Line){if(!n.__webGLVertexBuffer){this.createLineBuffers(n);this.initLineBuffers(n);
 n.__dirtyVertices=true;n.__dirtyElements=true}n.__dirtyVertices&&this.setLineBuffers(n,b.DYNAMIC_DRAW);i(v,0,n,o);n.__dirtyVertices=false;n.__dirtyElements=false}else if(o instanceof THREE.ParticleSystem){if(!n.__webGLVertexBuffer){this.createParticleBuffers(n);this.initParticleBuffers(n);n.__dirtyVertices=true;n.__dirtyColors=true;n.__dirtyElements=true}if(n.__dirtyVertices||n.__dirtyColors||o.sortParticles)this.setParticleBuffers(n,b.DYNAMIC_DRAW,o,m);i(v,0,n,o);n.__dirtyVertices=false;n.__dirtyColors=
-false;n.__dirtyElements=false}else o instanceof THREE.MarchingCubes&&e(v,0,o)}};this.removeObject=function(g,m){var i,e;for(i=g.__webGLObjects.length-1;i>=0;i--){e=g.__webGLObjects[i].object;m==e&&g.__webGLObjects.splice(i,1)}};this.setupMatrices=function(g,m){l.multiply(m.matrix,g.matrix);y.set(l.flatten());p=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(p.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,
-false,y);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,m){b.uniform3f(g.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
-b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,m){if(g){!m||m=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK);else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+false;n.__dirtyElements=false}else o instanceof THREE.MarchingCubes&&e(v,0,o)}};this.removeObject=function(f,m){var i,e;for(i=f.__webGLObjects.length-1;i>=0;i--){e=f.__webGLObjects[i].object;m==e&&f.__webGLObjects.splice(i,1)}};this.setupMatrices=function(f,m){l.multiply(m.matrix,f.matrix);y.set(l.flatten());p=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(p.m);H.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,
+false,y);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,H)};this.loadCamera=function(f,m){b.uniform3f(f.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
+b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,m){if(f){!m||m=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
 envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",

+ 129 - 129
build/ThreeDebug.js

@@ -1,66 +1,66 @@
 // ThreeDebug.js r32 - 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,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,h,b,q,r,l;if(d==0)f=h=b=0;else{q=Math.floor(a*6);r=a*6-q;a=d*(1-c);l=d*(1-c*r);c=d*(1-c*(1-r));switch(q){case 1:f=l;h=d;b=a;break;case 2:f=a;h=d;b=c;break;case 3:f=a;h=l;b=d;break;case 4:f=c;h=a;b=d;break;case 5:f=d;h=a;b=l;break;case 6:case 0:f=d;h=c;b=a}}this.r=f;this.g=h;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var g,h,b,r,q,l;if(d==0)g=h=b=0;else{r=Math.floor(a*6);q=a*6-r;a=d*(1-c);l=d*(1-c*q);c=d*(1-c*(1-q));switch(r){case 1:g=l;h=d;b=a;break;case 2:g=a;h=d;b=c;break;case 3:g=a;h=l;b=d;break;case 4:g=c;h=a;b=d;break;case 5:g=d;h=a;b=l;break;case 6:case 0:g=d;h=c;b=a}}this.r=g;this.g=h;this.b=b;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
+cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
 a.z;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 c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+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,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
-THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
+THREE.Vector4=function(a,c,d,g){this.x=a||0;this.y=c||0;this.z=d||0;this.w=g||1};
+THREE.Vector4.prototype={set:function(a,c,d,g){this.x=a;this.y=c;this.z=d;this.w=g;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,h=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,q){return b.distance-q.distance});return h},intersectObject:function(a){function c(M,s,T,G){G=G.clone().subSelf(s);T=T.clone().subSelf(s);var g=M.clone().subSelf(s);M=G.dot(G);s=G.dot(T);G=G.dot(g);var n=T.dot(T);T=T.dot(g);g=1/(M*n-s*s);n=(n*G-s*T)*g;M=(M*T-s*G)*g;return n>0&&M>0&&n+M<1}var d,f,h,b,q,r,l,m,z,y,
-u,x=a.geometry,H=x.vertices,K=[];d=0;for(f=x.faces.length;d<f;d++){h=x.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(H[h.a].position.clone());q=a.matrix.multiplyVector3(H[h.b].position.clone());r=a.matrix.multiplyVector3(H[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(H[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());z=u.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(b,y))/z;y=y.addSelf(u.multiplyScalar(m));
-if(h instanceof THREE.Face3){if(c(y,b,q,r)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(y,b,q,l)||c(y,q,r,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}}return K}};
-THREE.Rectangle=function(){function a(){b=f-c;q=h-d}var c,d,f,h,b,q,r=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return q};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(l,m,z,y){r=false;c=l;d=m;f=z;h=y;a()};this.addPoint=function(l,m){if(r){r=false;c=l;d=m;f=l;h=m}else{c=c<l?c:l;d=d<m?d:m;f=f>l?f:l;h=h>m?
-h:m}a()};this.add3Points=function(l,m,z,y,u,x){if(r){r=false;c=l<z?l<u?l:u:z<u?z:u;d=m<y?m<x?m:x:y<x?y:x;f=l>z?l>u?l:u:z>u?z:u;h=m>y?m>x?m:x:y>x?y:x}else{c=l<z?l<u?l<c?l:c:u<c?u:c:z<u?z<c?z:c:u<c?u:c;d=m<y?m<x?m<d?m:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;f=l>z?l>u?l>f?l:f:u>f?u:f:z>u?z>f?z:f:u>f?u:f;h=m>y?m>x?m>h?m:h:x>h?x:h:y>x?y>h?y:h:x>h?x:h}a()};this.addRectangle=function(l){if(r){r=false;c=l.getLeft();d=l.getTop();f=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
-f=f>l.getRight()?f:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f<l.getRight()?f:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(f,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=f=d=c=0;a()};this.isEmpty=function(){return r};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+h+", width: "+b+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,f,h,b,q,r,l,m,z,y,u,x,H,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=h||0;this.n22=b||1;this.n23=q||0;this.n24=r||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-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,c,d,f,h,b,q,r,l,m,z,y,u,x,H,K){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=h;this.n22=b;this.n23=q;this.n24=r;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=H;this.n44=K;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,c,d){var f=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();f.cross(d,b).normalize();h.cross(b,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
-this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,h=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
-f+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,h=a.n13,b=a.n14,q=a.n21,r=a.n22,l=a.n23,m=a.n24,z=a.n31,
-y=a.n32,u=a.n33,x=a.n34,H=a.n41,K=a.n42,M=a.n43,s=a.n44,T=c.n11,G=c.n12,g=c.n13,n=c.n14,i=c.n21,e=c.n22,j=c.n23,k=c.n24,p=c.n31,w=c.n32,o=c.n33,t=c.n34,v=c.n41,D=c.n42,E=c.n43,I=c.n44;this.n11=d*T+f*i+h*p+b*v;this.n12=d*G+f*e+h*w+b*D;this.n13=d*g+f*j+h*o+b*E;this.n14=d*n+f*k+h*t+b*I;this.n21=q*T+r*i+l*p+m*v;this.n22=q*G+r*e+l*w+m*D;this.n23=q*g+r*j+l*o+m*E;this.n24=q*n+r*k+l*t+m*I;this.n31=z*T+y*i+u*p+x*v;this.n32=z*G+y*e+u*w+x*D;this.n33=z*g+y*j+u*o+x*E;this.n34=z*n+y*k+u*t+x*I;this.n41=H*T+K*i+
-M*p+s*v;this.n42=H*G+K*e+M*w+s*D;this.n43=H*g+K*j+M*o+s*E;this.n44=H*n+K*k+M*t+s*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,h=this.n14,b=this.n21,q=this.n22,r=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,H=this.n42,K=this.n43,M=this.n44,s=a.n11,T=a.n21,G=a.n31,g=a.n41,n=a.n12,i=a.n22,e=a.n32,j=a.n42,k=a.n13,p=a.n23,w=a.n33,o=a.n43,t=a.n14,v=a.n24,D=a.n34;a=a.n44;this.n11=c*s+d*T+f*G+h*g;this.n12=c*n+d*i+f*e+h*j;this.n13=c*k+d*p+f*w+h*
-o;this.n14=c*t+d*v+f*D+h*a;this.n21=b*s+q*T+r*G+l*g;this.n22=b*n+q*i+r*e+l*j;this.n23=b*k+q*p+r*w+l*o;this.n24=b*t+q*v+r*D+l*a;this.n31=m*s+z*T+y*G+u*g;this.n32=m*n+z*i+y*e+u*j;this.n33=m*k+z*p+y*w+u*o;this.n34=m*t+z*v+y*D+u*a;this.n41=x*s+H*T+K*G+M*g;this.n42=x*n+H*i+K*e+M*j;this.n43=x*k+H*p+K*w+M*o;this.n44=x*t+H*v+K*D+M*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(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,h=this.n21,b=this.n22,q=this.n23,r=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,H=this.n43,K=this.n44;return f*q*m*u-d*r*m*u-f*b*z*u+c*r*z*u+d*b*y*u-c*q*y*u-f*q*l*x+d*r*l*x+f*h*z*x-a*r*z*x-d*h*y*x+a*q*y*x+f*b*l*H-c*r*l*H-f*h*m*H+a*r*m*H+c*h*y*H-a*b*y*H-d*b*l*K+c*q*l*K+d*h*m*K-a*q*m*K-c*h*z*K+a*b*z*K},transpose:function(){function a(c,d,
-f){var h=c[d];c[d]=c[f];c[f]=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(){var a=this.flat;a[0]=this.n11;
+THREE.Ray.prototype={intersectScene:function(a){var c,d,g=a.objects,h=[];a=0;for(c=g.length;a<c;a++){d=g[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(b,r){return b.distance-r.distance});return h},intersectObject:function(a){function c(M,s,T,G){G=G.clone().subSelf(s);T=T.clone().subSelf(s);var f=M.clone().subSelf(s);M=G.dot(G);s=G.dot(T);G=G.dot(f);var n=T.dot(T);T=T.dot(f);f=1/(M*n-s*s);n=(n*G-s*T)*f;M=(M*T-s*G)*f;return n>0&&M>0&&n+M<1}var d,g,h,b,r,q,l,m,z,y,
+u,x=a.geometry,H=x.vertices,K=[];d=0;for(g=x.faces.length;d<g;d++){h=x.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(H[h.a].position.clone());r=a.matrix.multiplyVector3(H[h.b].position.clone());q=a.matrix.multiplyVector3(H[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.multiplyVector3(H[h.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(h.normal.clone());z=u.dot(m);if(z<0){m=m.dot((new THREE.Vector3).sub(b,y))/z;y=y.addSelf(u.multiplyScalar(m));
+if(h instanceof THREE.Face3){if(c(y,b,r,q)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}else if(h instanceof THREE.Face4)if(c(y,b,r,l)||c(y,r,q,l)){h={distance:this.origin.distanceTo(y),point:y,face:h,object:a};K.push(h)}}}return K}};
+THREE.Rectangle=function(){function a(){b=g-c;r=h-d}var c,d,g,h,b,r,q=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return r};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return g};this.getBottom=function(){return h};this.set=function(l,m,z,y){q=false;c=l;d=m;g=z;h=y;a()};this.addPoint=function(l,m){if(q){q=false;c=l;d=m;g=l;h=m}else{c=c<l?c:l;d=d<m?d:m;g=g>l?g:l;h=h>m?
+h:m}a()};this.add3Points=function(l,m,z,y,u,x){if(q){q=false;c=l<z?l<u?l:u:z<u?z:u;d=m<y?m<x?m:x:y<x?y:x;g=l>z?l>u?l:u:z>u?z:u;h=m>y?m>x?m:x:y>x?y:x}else{c=l<z?l<u?l<c?l:c:u<c?u:c:z<u?z<c?z:c:u<c?u:c;d=m<y?m<x?m<d?m:d:x<d?x:d:y<x?y<d?y:d:x<d?x:d;g=l>z?l>u?l>g?l:g:u>g?u:g:z>u?z>g?z:g:u>g?u:g;h=m>y?m>x?m>h?m:h:x>h?x:h:y>x?y>h?y:h:x>h?x:h}a()};this.addRectangle=function(l){if(q){q=false;c=l.getLeft();d=l.getTop();g=l.getRight();h=l.getBottom()}else{c=c<l.getLeft()?c:l.getLeft();d=d<l.getTop()?d:l.getTop();
+g=g>l.getRight()?g:l.getRight();h=h>l.getBottom()?h:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;g+=l;h+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();g=g<l.getRight()?g:l.getRight();h=h<l.getBottom()?h:l.getBottom();a()};this.instersects=function(l){return Math.min(g,l.getRight())-Math.max(c,l.getLeft())>=0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){q=true;h=g=d=c=0;a()};this.isEmpty=function(){return q};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+g+", top: "+d+", bottom: "+h+", width: "+b+", height: "+r+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
+THREE.Matrix4=function(a,c,d,g,h,b,r,q,l,m,z,y,u,x,H,K){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=g||0;this.n21=h||0;this.n22=b||1;this.n23=r||0;this.n24=q||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=H||0;this.n44=K||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+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,c,d,g,h,b,r,q,l,m,z,y,u,x,H,K){this.n11=a;this.n12=c;this.n13=d;this.n14=g;this.n21=h;this.n22=b;this.n23=r;this.n24=q;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=H;this.n44=K;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,c,d){var g=THREE.Matrix4.__tmpVec1,h=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();g.cross(d,b).normalize();h.cross(b,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);
+this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,g=a.z,h=1/(this.n41*c+this.n42*d+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*g+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*g+this.n24)*h;a.z=(this.n31*c+this.n32*d+this.n33*g+this.n34)*h;return a},multiplyVector4:function(a){var c=a.x,d=a.y,g=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*g+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*
+g+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*g+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*g+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,g=a.n12,h=a.n13,b=a.n14,r=a.n21,q=a.n22,l=a.n23,m=a.n24,z=a.n31,
+y=a.n32,u=a.n33,x=a.n34,H=a.n41,K=a.n42,M=a.n43,s=a.n44,T=c.n11,G=c.n12,f=c.n13,n=c.n14,i=c.n21,e=c.n22,j=c.n23,k=c.n24,p=c.n31,w=c.n32,o=c.n33,t=c.n34,v=c.n41,D=c.n42,E=c.n43,I=c.n44;this.n11=d*T+g*i+h*p+b*v;this.n12=d*G+g*e+h*w+b*D;this.n13=d*f+g*j+h*o+b*E;this.n14=d*n+g*k+h*t+b*I;this.n21=r*T+q*i+l*p+m*v;this.n22=r*G+q*e+l*w+m*D;this.n23=r*f+q*j+l*o+m*E;this.n24=r*n+q*k+l*t+m*I;this.n31=z*T+y*i+u*p+x*v;this.n32=z*G+y*e+u*w+x*D;this.n33=z*f+y*j+u*o+x*E;this.n34=z*n+y*k+u*t+x*I;this.n41=H*T+K*i+
+M*p+s*v;this.n42=H*G+K*e+M*w+s*D;this.n43=H*f+K*j+M*o+s*E;this.n44=H*n+K*k+M*t+s*I;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,g=this.n13,h=this.n14,b=this.n21,r=this.n22,q=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,H=this.n42,K=this.n43,M=this.n44,s=a.n11,T=a.n21,G=a.n31,f=a.n41,n=a.n12,i=a.n22,e=a.n32,j=a.n42,k=a.n13,p=a.n23,w=a.n33,o=a.n43,t=a.n14,v=a.n24,D=a.n34;a=a.n44;this.n11=c*s+d*T+g*G+h*f;this.n12=c*n+d*i+g*e+h*j;this.n13=c*k+d*p+g*w+h*
+o;this.n14=c*t+d*v+g*D+h*a;this.n21=b*s+r*T+q*G+l*f;this.n22=b*n+r*i+q*e+l*j;this.n23=b*k+r*p+q*w+l*o;this.n24=b*t+r*v+q*D+l*a;this.n31=m*s+z*T+y*G+u*f;this.n32=m*n+z*i+y*e+u*j;this.n33=m*k+z*p+y*w+u*o;this.n34=m*t+z*v+y*D+u*a;this.n41=x*s+H*T+K*G+M*f;this.n42=x*n+H*i+K*e+M*j;this.n43=x*k+H*p+K*w+M*o;this.n44=x*t+H*v+K*D+M*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(){var a=this.n11,c=this.n12,d=this.n13,g=this.n14,h=this.n21,b=this.n22,r=this.n23,q=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,H=this.n43,K=this.n44;return g*r*m*u-d*q*m*u-g*b*z*u+c*q*z*u+d*b*y*u-c*r*y*u-g*r*l*x+d*q*l*x+g*h*z*x-a*q*z*x-d*h*y*x+a*r*y*x+g*b*l*H-c*q*l*H-g*h*m*H+a*q*m*H+c*h*y*H-a*b*y*H-d*b*l*K+c*r*l*K+d*h*m*K-a*r*m*K-c*h*z*K+a*b*z*K},transpose:function(){function a(c,d,
+g){var h=c[d];c[d]=c[g];c[g]=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(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),h=1-d,b=a.x,q=a.y,r=a.z,l=h*b,m=h*q;this.set(l*b+d,l*q-f*r,l*r+f*q,0,l*q+f*r,m*q+d,m*r-f*b,0,l*r-f*q,m*r+f*b,h*r*r+d,0,0,0,0,1);return this},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,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
+Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),g=Math.sin(c),h=1-d,b=a.x,r=a.y,q=a.z,l=h*b,m=h*r;this.set(l*b+d,l*r-g*q,l*q+g*r,0,l*r+g*q,m*r+d,m*q-g*b,0,l*q-g*r,m*q+g*b,h*q*q+d,0,0,0,0,1);return this},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,c,d){var g=new THREE.Matrix4;g.setTranslation(a,c,d);return g};THREE.Matrix4.scaleMatrix=function(a,c,d){var g=new THREE.Matrix4;g.setScale(a,c,d);return g};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,h=a.n14,b=a.n21,q=a.n22,r=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,H=a.n42,K=a.n43,M=a.n44,s=new THREE.Matrix4;s.n11=r*u*H-l*y*H+l*z*K-q*u*K-r*z*M+q*y*M;s.n12=h*y*H-f*u*H-h*z*K+d*u*K+f*z*M-d*y*M;s.n13=f*l*H-h*r*H+h*q*K-d*l*K-f*q*M+d*r*M;s.n14=h*r*z-f*l*z-h*q*y+d*l*y+f*q*u-d*r*u;s.n21=l*y*x-r*u*x-l*m*K+b*u*K+r*m*M-b*y*M;s.n22=f*u*x-h*y*x+h*m*K-c*u*K-f*m*M+c*y*M;s.n23=h*r*x-f*l*x-h*b*K+c*l*K+f*b*M-c*r*M;s.n24=f*l*m-h*r*m+
-h*b*y-c*l*y-f*b*u+c*r*u;s.n31=q*u*x-l*z*x+l*m*H-b*u*H-q*m*M+b*z*M;s.n32=h*z*x-d*u*x-h*m*H+c*u*H+d*m*M-c*z*M;s.n33=f*l*x-h*q*x+h*b*H-c*l*H-d*b*M+c*q*M;s.n34=h*q*m-d*l*m-h*b*z+c*l*z+d*b*u-c*q*u;s.n41=r*z*x-q*y*x-r*m*H+b*y*H+q*m*K-b*z*K;s.n42=d*y*x-f*z*x+f*m*H-c*y*H-d*m*K+c*z*K;s.n43=f*q*x-d*r*x-f*b*H+c*r*H+d*b*K-c*q*K;s.n44=d*r*m-f*q*m+f*b*z-c*r*z-d*b*y+c*q*y;s.multiplyScalar(1/a.determinant());return s};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,f=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],q=-c[10]*c[4]+c[6]*c[8],r=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*f+c[1]*q+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*f;d[1]=c*h;d[2]=c*b;d[3]=c*q;d[4]=c*r;d[5]=c*l;d[6]=c*m;d[7]=c*z;d[8]=c*y;return a};
-THREE.Matrix4.makeFrustum=function(a,c,d,f,h,b){var q,r,l;q=new THREE.Matrix4;r=2*h/(c-a);l=2*h/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(b+h)/(b-h);h=-2*b*h/(b-h);q.n11=r;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=h;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,f)};
-THREE.Matrix4.makeOrtho=function(a,c,d,f,h,b){var q,r,l,m;q=new THREE.Matrix4;r=c-a;l=d-f;m=b-h;a=(c+a)/r;d=(d+f)/l;h=(b+h)/m;q.n11=2/r;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-h;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,g=a.n13,h=a.n14,b=a.n21,r=a.n22,q=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,H=a.n42,K=a.n43,M=a.n44,s=new THREE.Matrix4;s.n11=q*u*H-l*y*H+l*z*K-r*u*K-q*z*M+r*y*M;s.n12=h*y*H-g*u*H-h*z*K+d*u*K+g*z*M-d*y*M;s.n13=g*l*H-h*q*H+h*r*K-d*l*K-g*r*M+d*q*M;s.n14=h*q*z-g*l*z-h*r*y+d*l*y+g*r*u-d*q*u;s.n21=l*y*x-q*u*x-l*m*K+b*u*K+q*m*M-b*y*M;s.n22=g*u*x-h*y*x+h*m*K-c*u*K-g*m*M+c*y*M;s.n23=h*q*x-g*l*x-h*b*K+c*l*K+g*b*M-c*q*M;s.n24=g*l*m-h*q*m+
+h*b*y-c*l*y-g*b*u+c*q*u;s.n31=r*u*x-l*z*x+l*m*H-b*u*H-r*m*M+b*z*M;s.n32=h*z*x-d*u*x-h*m*H+c*u*H+d*m*M-c*z*M;s.n33=g*l*x-h*r*x+h*b*H-c*l*H-d*b*M+c*r*M;s.n34=h*r*m-d*l*m-h*b*z+c*l*z+d*b*u-c*r*u;s.n41=q*z*x-r*y*x-q*m*H+b*y*H+r*m*K-b*z*K;s.n42=d*y*x-g*z*x+g*m*H-c*y*H-d*m*K+c*z*K;s.n43=g*r*x-d*q*x-g*b*H+c*q*H+d*b*K-c*r*K;s.n44=d*q*m-g*r*m+g*b*z-c*q*z-d*b*y+c*r*y;s.multiplyScalar(1/a.determinant());return s};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,g=c[10]*c[5]-c[6]*c[9],h=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],r=-c[10]*c[4]+c[6]*c[8],q=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*g+c[1]*r+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*g;d[1]=c*h;d[2]=c*b;d[3]=c*r;d[4]=c*q;d[5]=c*l;d[6]=c*m;d[7]=c*z;d[8]=c*y;return a};
+THREE.Matrix4.makeFrustum=function(a,c,d,g,h,b){var r,q,l;r=new THREE.Matrix4;q=2*h/(c-a);l=2*h/(g-d);a=(c+a)/(c-a);d=(g+d)/(g-d);g=-(b+h)/(b-h);h=-2*b*h/(b-h);r.n11=q;r.n12=0;r.n13=a;r.n14=0;r.n21=0;r.n22=l;r.n23=d;r.n24=0;r.n31=0;r.n32=0;r.n33=g;r.n34=h;r.n41=0;r.n42=0;r.n43=-1;r.n44=0;return r};THREE.Matrix4.makePerspective=function(a,c,d,g){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,g)};
+THREE.Matrix4.makeOrtho=function(a,c,d,g,h,b){var r,q,l,m;r=new THREE.Matrix4;q=c-a;l=d-g;m=b-h;a=(c+a)/q;d=(d+g)/l;h=(b+h)/m;r.n11=2/q;r.n12=0;r.n13=0;r.n14=-a;r.n21=0;r.n22=2/l;r.n23=0;r.n24=-d;r.n31=0;r.n32=0;r.n33=-2/m;r.n34=-h;r.n41=0;r.n42=0;r.n43=0;r.n44=1;return r};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,d,f,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,c,d,f,h,b){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
+THREE.Face3=function(a,c,d,g,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,c,d,g,h,b){this.a=a;this.b=c;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;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 c,d,f,h,b,q,r=new THREE.Vector3,l=new THREE.Vector3;f=0;for(h=this.vertices.length;f<h;f++){b=this.vertices[f];b.normal.set(0,0,0)}f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];if(a&&b.vertexNormals.length){r.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)r.addSelf(b.vertexNormals[c]);r.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];q=this.vertices[b.c];r.sub(q.position,
-d.position);l.sub(c.position,d.position);r.crossSelf(l)}r.isZero()||r.normalize();b.normal.copy(r)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(t,v,D,E,I,L,N){b=t.vertices[v].position;q=t.vertices[D].position;r=t.vertices[E].position;l=h[I];m=h[L];z=h[N];y=q.x-b.x;u=r.x-b.x;x=q.y-b.y;H=r.y-b.y;
-K=q.z-b.z;M=r.z-b.z;s=m.u-l.u;T=z.u-l.u;G=m.v-l.v;g=z.v-l.v;n=1/(s*g-T*G);j.set((g*y-G*u)*n,(g*x-G*H)*n,(g*K-G*M)*n);k.set((s*u-T*y)*n,(s*H-T*x)*n,(s*M-T*K)*n);i[v].addSelf(j);i[D].addSelf(j);i[E].addSelf(j);e[v].addSelf(k);e[D].addSelf(k);e[E].addSelf(k)}var c,d,f,h,b,q,r,l,m,z,y,u,x,H,K,M,s,T,G,g,n,i=[],e=[],j=new THREE.Vector3,k=new THREE.Vector3,p=new THREE.Vector3,w=new THREE.Vector3,o=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;e[c]=new THREE.Vector3}c=0;
-for(d=this.faces.length;c<d;c++){f=this.faces[c];h=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
-this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){o.copy(this.vertices[c].normal);f=i[c];p.copy(f);p.subSelf(o.multiplyScalar(o.dot(f))).normalize();w.cross(this.vertices[c].normal,f);f=w.dot(e[c]);f=f<0?-1:1;this.vertices[c].tangent.set(p.x,p.y,p.z,f)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,g,h,b,r,q=new THREE.Vector3,l=new THREE.Vector3;g=0;for(h=this.vertices.length;g<h;g++){b=this.vertices[g];b.normal.set(0,0,0)}g=0;for(h=this.faces.length;g<h;g++){b=this.faces[g];if(a&&b.vertexNormals.length){q.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)q.addSelf(b.vertexNormals[c]);q.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];r=this.vertices[b.c];q.sub(r.position,
+d.position);l.sub(c.position,d.position);q.crossSelf(l)}q.isZero()||q.normalize();b.normal.copy(q)}},computeVertexNormals:function(){var a,c,d,g;if(this.__tmpVertices==undefined){g=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)g[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{g=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)g[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){g[d.a].addSelf(d.normal);g[d.b].addSelf(d.normal);g[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){g[d.a].addSelf(d.normal);g[d.b].addSelf(d.normal);g[d.c].addSelf(d.normal);g[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)g[a].normalize();a=0;for(c=this.faces.length;a<
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(g[d.a]);d.vertexNormals[1].copy(g[d.b]);d.vertexNormals[2].copy(g[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(g[d.a]);d.vertexNormals[1].copy(g[d.b]);d.vertexNormals[2].copy(g[d.c]);d.vertexNormals[3].copy(g[d.d])}}},computeTangents:function(){function a(t,v,D,E,I,L,N){b=t.vertices[v].position;r=t.vertices[D].position;q=t.vertices[E].position;l=h[I];m=h[L];z=h[N];y=r.x-b.x;u=q.x-b.x;x=r.y-b.y;H=q.y-b.y;
+K=r.z-b.z;M=q.z-b.z;s=m.u-l.u;T=z.u-l.u;G=m.v-l.v;f=z.v-l.v;n=1/(s*f-T*G);j.set((f*y-G*u)*n,(f*x-G*H)*n,(f*K-G*M)*n);k.set((s*u-T*y)*n,(s*H-T*x)*n,(s*M-T*K)*n);i[v].addSelf(j);i[D].addSelf(j);i[E].addSelf(j);e[v].addSelf(k);e[D].addSelf(k);e[E].addSelf(k)}var c,d,g,h,b,r,q,l,m,z,y,u,x,H,K,M,s,T,G,f,n,i=[],e=[],j=new THREE.Vector3,k=new THREE.Vector3,p=new THREE.Vector3,w=new THREE.Vector3,o=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){i[c]=new THREE.Vector3;e[c]=new THREE.Vector3}c=0;
+for(d=this.faces.length;c<d;c++){g=this.faces[c];h=this.uvs[c];if(g instanceof THREE.Face3){a(this,g.a,g.b,g.c,0,1,2);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2])}else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3);this.vertices[g.a].normal.copy(g.vertexNormals[0]);this.vertices[g.b].normal.copy(g.vertexNormals[1]);this.vertices[g.c].normal.copy(g.vertexNormals[2]);
+this.vertices[g.d].normal.copy(g.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){o.copy(this.vertices[c].normal);g=i[c];p.copy(g);p.subSelf(o.multiplyScalar(o.dot(g))).normalize();w.cross(this.vertices[c].normal,g);g=w.dot(e[c]);g=g<0?-1:1;this.vertices[c].tangent.set(p.x,p.y,p.z,g)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,f,h,b,q,r,l,m={};f=0;for(h=this.faces.length;f<h;f++){b=this.faces[f];
-q=b.materials;r=a(q);if(m[r]==undefined)m[r]={hash:r,counter:0};l=m[r].hash+"_"+m[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){m[r].counter+=1;l=m[r].hash+"_"+m[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(z){var y=[];c=0;for(d=z.length;c<d;c++)z[c]==undefined?y.push("undefined"):y.push(z[c].toString());return y.join("_")}var c,d,g,h,b,r,q,l,m={};g=0;for(h=this.faces.length;g<h;g++){b=this.faces[g];
+r=b.materials;q=a(r);if(m[q]==undefined)m[q]={hash:q,counter:0};l=m[q].hash+"_"+m[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:r,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+b>65535){m[q].counter+=1;l=m[q].hash+"_"+m[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:r,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+THREE.Camera=function(a,c,d,g){this.fov=a;this.aspect=c;this.near=d;this.far=g;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(h);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
 THREE.Camera.prototype={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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;
 THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.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.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
-THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){f.setRotY(c.y);this.rotationMatrix.multiplySelf(f)}if(c.z!=0){f.setRotZ(c.z);this.rotationMatrix.multiplySelf(f)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){f.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(f)}}};THREE.Object3DCounter={value:0};
+THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,g=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){g.setRotY(c.y);this.rotationMatrix.multiplySelf(g)}if(c.z!=0){g.setRotZ(c.z);this.rotationMatrix.multiplySelf(g)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){g.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(g)}}};THREE.Object3DCounter={value:0};
 THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
 THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};
 THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;
@@ -90,111 +90,111 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM
 THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.size=this.opacity=1;this.vertex_colors=false;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.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};
 THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>size: "+this.size+"<br/>blending: "+this.blending+"<br/>vertex_colors: "+this.vertex_colors+"<br/>)"}};
 THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={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};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,g,h,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter};
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},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.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
 THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var c,d,f,h={};for(c in a){h[c]={};for(d in a[c]){f=a[c][d];h[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return h},merge:function(a){var c,d,f,h={};for(c=0;c<a.length;c++){f=this.clone(a[c]);for(d in f)h[d]=f[d]}return h}};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
+var Uniforms={clone:function(a){var c,d,g,h={};for(c in a){h[c]={};for(d in a[c]){g=a[c][d];h[c][d]=g instanceof THREE.Color||g instanceof THREE.Vector3||g instanceof THREE.Texture?g.clone():g}}return h},merge:function(a){var c,d,g,h={};for(c=0;c<a.length;c++){g=this.clone(a[c]);for(d in g)h[d]=g[d]}return h}};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.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(e,j){return j.z-e.z}function c(e,j){var k=0,p=1,w=e.z+e.w,o=j.z+j.w,t=-e.z+e.w,v=-j.z+j.w;if(w>=0&&o>=0&&t>=0&&v>=0)return true;else if(w<0&&o<0||t<0&&v<0)return false;else{if(w<0)k=Math.max(k,w/(w-o));else if(o<0)p=Math.min(p,w/(w-o));if(t<0)k=Math.max(k,t/(t-v));else if(v<0)p=Math.min(p,t/(t-v));if(p<k)return false;else{e.lerpSelf(j,k);j.lerpSelf(e,1-p);return true}}}var d,f,h=[],b,q,r,l=[],m,z,y=[],u,x,H=[],K=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
-T=new THREE.Matrix4,G=[],g=new THREE.Vector4,n=new THREE.Vector4,i;this.projectObjects=function(e,j,k){var p=[],w,o;f=0;s.multiply(j.projectionMatrix,j.matrix);G[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);G[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);G[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);G[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);G[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
+THREE.Projector=function(){function a(e,j){return j.z-e.z}function c(e,j){var k=0,p=1,w=e.z+e.w,o=j.z+j.w,t=-e.z+e.w,v=-j.z+j.w;if(w>=0&&o>=0&&t>=0&&v>=0)return true;else if(w<0&&o<0||t<0&&v<0)return false;else{if(w<0)k=Math.max(k,w/(w-o));else if(o<0)p=Math.min(p,w/(w-o));if(t<0)k=Math.max(k,t/(t-v));else if(v<0)p=Math.min(p,t/(t-v));if(p<k)return false;else{e.lerpSelf(j,k);j.lerpSelf(e,1-p);return true}}}var d,g,h=[],b,r,q,l=[],m,z,y=[],u,x,H=[],K=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
+T=new THREE.Matrix4,G=[],f=new THREE.Vector4,n=new THREE.Vector4,i;this.projectObjects=function(e,j,k){var p=[],w,o;g=0;s.multiply(j.projectionMatrix,j.matrix);G[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);G[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);G[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);G[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);G[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
 s.n33,s.n44-s.n34);G[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);j=0;for(w=G.length;j<w;j++){o=G[j];o.divideScalar(Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z))}w=e.objects;e=0;for(j=w.length;e<j;e++){o=w[e];var t;if(!(t=!o.visible)){if(t=o instanceof THREE.Mesh){a:{t=void 0;for(var v=o.position,D=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),E=0;E<6;E++){t=G[E].x*v.x+G[E].y*v.y+G[E].z*v.z+G[E].w;if(t<=D){t=false;break a}}t=true}t=!t}t=t}if(!t){d=
-h[f]=h[f]||new THREE.RenderableObject;K.copy(o.position);s.multiplyVector3(K);d.object=o;d.z=K.z;p.push(d);f++}}k&&p.sort(a);return p};this.projectScene=function(e,j,k){var p=[],w=j.near,o=j.far,t,v,D,E,I,L,N,V,W,J,B,P,O,C,R,U;r=z=x=0;j.autoUpdateMatrix&&j.updateMatrix();s.multiply(j.projectionMatrix,j.matrix);L=this.projectObjects(e,j,true);e=0;for(t=L.length;e<t;e++){N=L[e].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
+h[g]=h[g]||new THREE.RenderableObject;K.copy(o.position);s.multiplyVector3(K);d.object=o;d.z=K.z;p.push(d);g++}}k&&p.sort(a);return p};this.projectScene=function(e,j,k){var p=[],w=j.near,o=j.far,t,v,D,E,I,L,N,V,W,J,B,P,O,C,R,U;q=z=x=0;j.autoUpdateMatrix&&j.updateMatrix();s.multiply(j.projectionMatrix,j.matrix);L=this.projectObjects(e,j,true);e=0;for(t=L.length;e<t;e++){N=L[e].object;if(N.visible){N.autoUpdateMatrix&&N.updateMatrix();V=N.matrix;W=N.rotationMatrix;J=N.materials;B=N.overdraw;if(N instanceof
 THREE.Mesh){P=N.geometry;O=P.vertices;v=0;for(D=O.length;v<D;v++){C=O[v];C.positionWorld.copy(C.position);V.multiplyVector3(C.positionWorld);E=C.positionScreen;E.copy(C.positionWorld);s.multiplyVector4(E);E.x/=E.w;E.y/=E.w;C.__visible=E.z>w&&E.z<o}P=P.faces;v=0;for(D=P.length;v<D;v++){C=P[v];if(C instanceof THREE.Face3){E=O[C.a];I=O[C.b];R=O[C.c];if(E.__visible&&I.__visible&&R.__visible)if(N.doubleSided||N.flipSided!=(R.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-
-(R.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(R.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(R.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
-b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);R=C.vertexNormals;i=b.vertexNormalsWorld;E=0;for(I=R.length;E<I;E++){U=i[E]=i[E]||new THREE.Vector3;U.copy(R[E]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][2]}p.push(b);r++}}else if(C instanceof THREE.Face4){E=O[C.a];I=O[C.b];R=O[C.c];U=O[C.d];if(E.__visible&&
-I.__visible&&R.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(U.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0||(I.positionScreen.x-R.positionScreen.x)*(U.positionScreen.y-R.positionScreen.y)-(I.positionScreen.y-R.positionScreen.y)*(U.positionScreen.x-R.positionScreen.x)<0)){b=l[r]=l[r]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
+(R.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0){b=l[q]=l[q]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);b.v3.positionWorld.copy(R.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(R.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);
+b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);R=C.vertexNormals;i=b.vertexNormalsWorld;E=0;for(I=R.length;E<I;E++){U=i[E]=i[E]||new THREE.Vector3;U.copy(R[E]);W.multiplyVector3(U)}b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][2]}p.push(b);q++}}else if(C instanceof THREE.Face4){E=O[C.a];I=O[C.b];R=O[C.c];U=O[C.d];if(E.__visible&&
+I.__visible&&R.__visible&&U.__visible)if(N.doubleSided||N.flipSided!=((U.positionScreen.x-E.positionScreen.x)*(I.positionScreen.y-E.positionScreen.y)-(U.positionScreen.y-E.positionScreen.y)*(I.positionScreen.x-E.positionScreen.x)<0||(I.positionScreen.x-R.positionScreen.x)*(U.positionScreen.y-R.positionScreen.y)-(I.positionScreen.y-R.positionScreen.y)*(U.positionScreen.x-R.positionScreen.x)<0)){b=l[q]=l[q]||new THREE.RenderableFace3;b.v1.positionWorld.copy(E.positionWorld);b.v2.positionWorld.copy(I.positionWorld);
 b.v3.positionWorld.copy(U.positionWorld);b.v1.positionScreen.copy(E.positionScreen);b.v2.positionScreen.copy(I.positionScreen);b.v3.positionScreen.copy(U.positionScreen);b.normalWorld.copy(C.normal);W.multiplyVector3(b.normalWorld);b.centroidWorld.copy(C.centroid);V.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);s.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=J;b.faceMaterials=C.materials;b.overdraw=B;if(N.geometry.uvs[v]){b.uvs[0]=N.geometry.uvs[v][0];
-b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][3]}p.push(b);r++;q=l[r]=l[r]||new THREE.RenderableFace3;q.v1.positionWorld.copy(I.positionWorld);q.v2.positionWorld.copy(R.positionWorld);q.v3.positionWorld.copy(U.positionWorld);q.v1.positionScreen.copy(I.positionScreen);q.v2.positionScreen.copy(R.positionScreen);q.v3.positionScreen.copy(U.positionScreen);q.normalWorld.copy(b.normalWorld);q.centroidWorld.copy(b.centroidWorld);q.centroidScreen.copy(b.centroidScreen);q.z=q.centroidScreen.z;q.meshMaterials=
-J;q.faceMaterials=C.materials;q.overdraw=B;if(N.geometry.uvs[v]){q.uvs[0]=N.geometry.uvs[v][1];q.uvs[1]=N.geometry.uvs[v][2];q.uvs[2]=N.geometry.uvs[v][3]}p.push(q);r++}}}}else if(N instanceof THREE.Line){T.multiply(s,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);v=1;for(D=O.length;v<D;v++){E=O[v];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);I=O[v-1];g.copy(E.positionScreen);n.copy(I.positionScreen);if(c(g,n)){g.multiplyScalar(1/
-g.w);n.multiplyScalar(1/n.w);m=y[z]=y[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(g);m.v2.positionScreen.copy(n);m.z=Math.max(g.z,n.z);m.materials=N.materials;p.push(m);z++}}}else if(N instanceof THREE.Particle){M.set(N.position.x,N.position.y,N.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=M.x/M.w;u.y=M.y/M.w;u.z=M.z;u.rotation=N.rotation.z;u.scale.x=N.scale.x*Math.abs(u.x-(M.x+j.projectionMatrix.n11)/(M.w+j.projectionMatrix.n14));
+b.uvs[1]=N.geometry.uvs[v][1];b.uvs[2]=N.geometry.uvs[v][3]}p.push(b);q++;r=l[q]=l[q]||new THREE.RenderableFace3;r.v1.positionWorld.copy(I.positionWorld);r.v2.positionWorld.copy(R.positionWorld);r.v3.positionWorld.copy(U.positionWorld);r.v1.positionScreen.copy(I.positionScreen);r.v2.positionScreen.copy(R.positionScreen);r.v3.positionScreen.copy(U.positionScreen);r.normalWorld.copy(b.normalWorld);r.centroidWorld.copy(b.centroidWorld);r.centroidScreen.copy(b.centroidScreen);r.z=r.centroidScreen.z;r.meshMaterials=
+J;r.faceMaterials=C.materials;r.overdraw=B;if(N.geometry.uvs[v]){r.uvs[0]=N.geometry.uvs[v][1];r.uvs[1]=N.geometry.uvs[v][2];r.uvs[2]=N.geometry.uvs[v][3]}p.push(r);q++}}}}else if(N instanceof THREE.Line){T.multiply(s,V);O=N.geometry.vertices;C=O[0];C.positionScreen.copy(C.position);T.multiplyVector4(C.positionScreen);v=1;for(D=O.length;v<D;v++){E=O[v];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);I=O[v-1];f.copy(E.positionScreen);n.copy(I.positionScreen);if(c(f,n)){f.multiplyScalar(1/
+f.w);n.multiplyScalar(1/n.w);m=y[z]=y[z]||new THREE.RenderableLine;m.v1.positionScreen.copy(f);m.v2.positionScreen.copy(n);m.z=Math.max(f.z,n.z);m.materials=N.materials;p.push(m);z++}}}else if(N instanceof THREE.Particle){M.set(N.position.x,N.position.y,N.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){u=H[x]=H[x]||new THREE.RenderableParticle;u.x=M.x/M.w;u.y=M.y/M.w;u.z=M.z;u.rotation=N.rotation.z;u.scale.x=N.scale.x*Math.abs(u.x-(M.x+j.projectionMatrix.n11)/(M.w+j.projectionMatrix.n14));
 u.scale.y=N.scale.y*Math.abs(u.y-(M.y+j.projectionMatrix.n22)/(M.w+j.projectionMatrix.n24));u.materials=N.materials;p.push(u);x++}}}}k&&p.sort(a);return p};this.unprojectVector=function(e,j){var k=THREE.Matrix4.makeInvert(j.matrix);k.multiplySelf(THREE.Matrix4.makeInvert(j.projectionMatrix));k.multiplyVector3(e);return e}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,h,b;this.domElement=document.createElement("div");this.setSize=function(q,r){d=q;f=r;h=d/2;b=f/2};this.render=function(q,r){var l,m,z,y,u,x,H,K;a=c.projectScene(q,r);l=0;for(m=a.length;l<m;l++){u=a[l];if(u instanceof THREE.RenderableParticle){H=u.x*h+h;K=u.y*b+b;z=0;for(y=u.material.length;z<y;z++){x=u.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=K+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ca){if(u!=ca)m.globalAlpha=u=ca}function c(ca){if(x!=ca){switch(ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=ca}}var d=null,f=new THREE.Projector,h=document.createElement("canvas"),b,q,r,l,m=h.getContext("2d"),z=new THREE.Color(0),y=0,u=1,x=0,H=null,K=null,M=1,s,T,G,g,n,i,e,j,k,p=new THREE.Color,
-w=new THREE.Color,o=new THREE.Color,t=new THREE.Color,v=new THREE.Color,D,E,I,L,N,V,W,J,B,P=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,R=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,ka,ga,pa,ea,qa=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);ka=oa.getImageData(0,0,2,2);ga=ka.data;pa=document.createElement("canvas");pa.width=
-pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,la){b=ca;q=la;r=b/2;l=q/2;h.width=b;h.height=q;P.set(-r,-l,r,l);u=1;x=0;K=H=null;M=1};this.setClearColor=function(ca,la){z.setHex(ca);y=la;O.set(-r,-l,r,l);m.setTransform(1,0,0,-1,r,l);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,r,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(P);if(z.hex==0&&y==0)m.clearRect(O.getX(),
-O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";m.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,la){function Ea(A){var X,S,F,Q=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=Q.length;A<X;A++){S=Q[A];F=S.color;if(S instanceof THREE.AmbientLight){Y.r+=F.r;Y.g+=F.g;Y.b+=F.b}else if(S instanceof THREE.DirectionalLight){fa.r+=
-F.r;fa.g+=F.g;fa.b+=F.b}else if(S instanceof THREE.PointLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}}}function Aa(A,X,S,F){var Q,$,da,ha,ia=A.lights;A=0;for(Q=ia.length;A<Q;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);
-var F,Q,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;Q=X.scale.x*r;$=X.scale.y*l;S=Q*ha;F=$*ia;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(!P.instersects(C))return;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(Q,-$);m.translate(-ha,-ia);m.drawImage(da,0,0);m.restore()}m.beginPath();m.moveTo(A.x-10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";
-m.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(R){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;p.r=S.color.r*U.r;p.g=S.color.g*U.g;p.b=S.color.b*U.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;S=X.scale.x*r;F=X.scale.y*l;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(P.instersects(C)){Q=p.__styleString;if(K!=Q)m.fillStyle=K=Q;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(S,F);m.beginPath();m.arc(0,0,1,0,za,true);m.closePath();m.fill();m.restore()}}}}
-function Oa(A,X,S,F){if(F.opacity!=0){a(F.opacity);c(F.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(F instanceof THREE.LineBasicMaterial){p.__styleString=F.color.__styleString;A=F.linewidth;if(M!=A)m.lineWidth=M=A;A=p.__styleString;if(H!=A)m.strokeStyle=H=A;m.stroke();C.inflate(F.linewidth*2)}}}function Ja(A,X,S,F,Q,$){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);g=A.positionScreen.x;n=A.positionScreen.y;i=
-X.positionScreen.x;e=X.positionScreen.y;j=S.positionScreen.x;k=S.positionScreen.y;m.beginPath();m.moveTo(g,n);m.lineTo(i,e);m.lineTo(j,k);m.lineTo(g,n);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&wa(g,n,i,e,j,k,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=la.matrix;Z.copy(F.vertexNormalsWorld[0]);
-L=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(g,n,i,e,j,k,Q.env_map.image,L,N,V,W,J,B)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&
-!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&wa(g,n,i,e,j,k,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);c(THREE.SubtractiveBlending)}if(R)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){w.r=o.r=t.r=Y.r;w.g=o.g=t.g=Y.g;w.b=o.b=t.b=Y.b;Aa($,F.v1.positionWorld,F.vertexNormalsWorld[0],w);Aa($,F.v2.positionWorld,F.vertexNormalsWorld[1],o);Aa($,F.v3.positionWorld,F.vertexNormalsWorld[2],t);v.r=(o.r+t.r)*0.5;v.g=(o.g+t.g)*0.5;
-v.b=(o.b+t.b)*0.5;I=Ka(w,o,t,v);wa(g,n,i,e,j,k,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,F.centroidWorld,F.normalWorld,U);p.r=Q.color.r*U.r;p.g=Q.color.g*U.g;p.b=Q.color.b*U.b;p.updateStyleString();Q.wireframe?Ba(p.__styleString,Q.wireframe_linewidth):Ca(p.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){D=la.near;E=la.far;w.r=w.g=w.b=1-Fa(A.positionScreen.z,D,E);o.r=o.g=o.b=1-Fa(X.positionScreen.z,
-D,E);t.r=t.g=t.b=1-Fa(S.positionScreen.z,D,E);v.r=(o.r+t.r)*0.5;v.g=(o.g+t.g)*0.5;v.b=(o.b+t.b)*0.5;I=Ka(w,o,t,v);wa(g,n,i,e,j,k,I,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){p.r=Ga(F.normalWorld.x);p.g=Ga(F.normalWorld.y);p.b=Ga(F.normalWorld.z);p.updateStyleString();Q.wireframe?Ba(p.__styleString,Q.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(A,X){if(H!=A)m.strokeStyle=H=A;if(M!=X)m.lineWidth=M=X;m.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)m.fillStyle=K=A;m.fill()}
-function wa(A,X,S,F,Q,$,da,ha,ia,ra,ja,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ja*=ta;sa*=ua;xa*=ta;S-=A;F-=X;Q-=A;$-=X;ra-=ha;ja-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ja);ua=(xa*S-ja*Q)*ta;ja=(xa*F-ja*$)*ta;S=(ra*Q-sa*S)*ta;F=(ra*$-sa*F)*ta;A=A-ua*ha-S*ia;X=X-ja*ha-F*ia;m.save();m.transform(ua,ja,S,F,A,X);m.clip();m.drawImage(da,0,0);m.restore()}function Ka(A,X,S,F){var Q=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),
-ra=~~(S.g*255);S=~~(S.b*255);var ja=~~(F.r*255),sa=~~(F.g*255);F=~~(F.b*255);ga[0]=Q<0?0:Q>255?255:Q;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ja<0?0:ja>255?255:ja;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=F<0?0:F>255?255:F;oa.putImageData(ka,0,0);ea.drawImage(na,0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=
-(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,F=X.y-A.y,Q=1/Math.sqrt(S*S+F*F);S*=Q;F*=Q;X.x+=S;X.y+=F;A.x-=S;A.y-=F}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():m.setTransform(1,0,0,-1,r,l);d=f.projectScene(ca,la,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());(R=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){s=ba;s.x*=r;s.y*=l;
-ma=0;for(va=ba.materials.length;ma<va;ma++)Na(s,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){s=ba.v1;T=ba.v2;s.positionScreen.x*=r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(s,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof THREE.RenderableFace3){s=ba.v1;T=ba.v2;G=ba.v3;s.positionScreen.x*=
-r;s.positionScreen.y*=l;T.positionScreen.x*=r;T.positionScreen.y*=l;G.positionScreen.x*=r;G.positionScreen.y*=l;if(ba.overdraw){Ha(s.positionScreen,T.positionScreen);Ha(T.positionScreen,G.positionScreen);Ha(G.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,T.positionScreen.x,T.positionScreen.y,G.positionScreen.x,G.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=
-0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(s,T,G,ba,ya,ca)}else Ja(s,T,G,ba,ya,ca)}}}O.addRectangle(C)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(L,N,V){var W,J,B,P;W=0;for(J=L.lights.length;W<J;W++){B=L.lights[W];if(B instanceof THREE.DirectionalLight){P=N.normalWorld.dot(B.position)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}else if(B instanceof THREE.PointLight){k.sub(B.position,N.centroidWorld);k.normalize();P=N.normalWorld.dot(k)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}}}function c(L,N,V,W,J,B){t=f(v++);t.setAttribute("d","M "+L.positionScreen.x+
-" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){g.r=n.r;g.g=n.g;g.b=n.b;a(B,W,g);G.r=J.color.r*g.r;G.g=J.color.g*g.g;G.b=J.color.b*g.b;G.updateStyleString()}else G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){j=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
-G.setRGB(j,j,j)}else J instanceof THREE.MeshNormalMaterial&&G.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+J.opacity);r.appendChild(t)}function d(L,N,V,W,J,B,P){t=f(v++);t.setAttribute("d",
-"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){g.r=n.r;g.g=n.g;g.b=n.b;a(P,J,g);G.r=B.color.r*g.r;G.g=B.color.g*g.g;G.b=B.color.b*g.b;G.updateStyleString()}else G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=
-1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);G.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&G.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+B.opacity);r.appendChild(t)}
-function f(L){if(p[L]==null){p[L]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&p[L].setAttribute("shape-rendering","crispEdges");return p[L]}return p[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var b=null,q=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,u,x,H,K,M=new THREE.Rectangle,s=new THREE.Rectangle,T=false,G=new THREE.Color(16777215),g=new THREE.Color(16777215),n=new THREE.Color(0),i=new THREE.Color(0),
-e=new THREE.Color(0),j,k=new THREE.Vector3,p=[],w=[],o=[],t,v,D,E,I=1;this.domElement=r;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":I=1;break;case "low":I=0}};this.setSize=function(L,N){l=L;m=N;z=l/2;y=m/2;r.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);r.setAttribute("width",l);r.setAttribute("height",m);M.set(-z,-y,z,y)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(L,N){var V,W,
-J,B,P,O,C,R;this.autoClear&&this.clear();b=q.projectScene(L,N,this.sortElements);E=D=v=0;if(T=L.lights.length>0){C=L.lights;n.setRGB(0,0,0);i.setRGB(0,0,0);e.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){n.r+=B.r;n.g+=B.g;n.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){e.r+=B.r;e.g+=B.g;e.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];s.empty();if(C instanceof THREE.RenderableParticle){u=
-C;u.x*=z;u.y*=-y;J=0;for(B=C.materials.length;J<B;J++)if(R=C.materials[J]){P=u;O=C;R=R;var U=D++;if(w[U]==null){w[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&w[U].setAttribute("shape-rendering","crispEdges")}t=w[U];t.setAttribute("cx",P.x);t.setAttribute("cy",P.y);t.setAttribute("r",O.scale.x*z);if(R instanceof THREE.ParticleCircleMaterial){if(T){g.r=n.r+i.r+e.r;g.g=n.g+i.g+e.g;g.b=n.b+i.b+e.b;G.r=R.color.r*g.r;G.g=R.color.g*g.g;G.b=R.color.b*g.b;G.updateStyleString()}else G=
-R.color;t.setAttribute("style","fill: "+G.__styleString)}r.appendChild(t)}}else if(C instanceof THREE.RenderableLine){u=C.v1;x=C.v2;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.materials.length;J<B;)if(R=C.materials[J++]){P=u;O=x;R=R;U=E++;if(o[U]==null){o[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
-0&&o[U].setAttribute("shape-rendering","crispEdges")}t=o[U];t.setAttribute("x1",P.positionScreen.x);t.setAttribute("y1",P.positionScreen.y);t.setAttribute("x2",O.positionScreen.x);t.setAttribute("y2",O.positionScreen.y);if(R instanceof THREE.LineBasicMaterial){G.__styleString=R.color.__styleString;t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+R.linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.linecap+"; stroke-linejoin: "+R.linejoin);r.appendChild(t)}}}}else if(C instanceof
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,g,h,b;this.domElement=document.createElement("div");this.setSize=function(r,q){d=r;g=q;h=d/2;b=g/2};this.render=function(r,q){var l,m,z,y,u,x,H,K;a=c.projectScene(r,q);l=0;for(m=a.length;l<m;l++){u=a[l];if(u instanceof THREE.RenderableParticle){H=u.x*h+h;K=u.y*b+b;z=0;for(y=u.material.length;z<y;z++){x=u.material[z];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=H+"px";x.style.top=K+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ca){if(u!=ca)m.globalAlpha=u=ca}function c(ca){if(x!=ca){switch(ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}x=ca}}var d=null,g=new THREE.Projector,h=document.createElement("canvas"),b,r,q,l,m=h.getContext("2d"),z=new THREE.Color(0),y=0,u=1,x=0,H=null,K=null,M=1,s,T,G,f,n,i,e,j,k,p=new THREE.Color,
+w=new THREE.Color,o=new THREE.Color,t=new THREE.Color,v=new THREE.Color,D,E,I,L,N,V,W,J,B,P=new THREE.Rectangle,O=new THREE.Rectangle,C=new THREE.Rectangle,R=false,U=new THREE.Color,Y=new THREE.Color,fa=new THREE.Color,aa=new THREE.Color,za=Math.PI*2,Z=new THREE.Vector3,na,oa,la,ga,pa,ea,qa=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);la=oa.getImageData(0,0,2,2);ga=la.data;pa=document.createElement("canvas");pa.width=
+pa.height=qa;ea=pa.getContext("2d");ea.translate(-qa/2,-qa/2);ea.scale(qa,qa);qa--;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ca,ja){b=ca;r=ja;q=b/2;l=r/2;h.width=b;h.height=r;P.set(-q,-l,q,l);u=1;x=0;K=H=null;M=1};this.setClearColor=function(ca,ja){z=ca;y=ja;O.set(-q,-l,q,l);m.setTransform(1,0,0,-1,q,l);this.clear()};this.setClearColorHex=function(ca,ja){z.setHex(ca);y=ja;O.set(-q,-l,q,l);m.setTransform(1,0,0,-1,q,l);this.clear()};this.clear=function(){m.setTransform(1,
+0,0,-1,q,l);if(!O.isEmpty()){O.inflate(1);O.minSelf(P);if(z.hex==0&&y==0)m.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+y+")";m.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(ca,ja){function Ea(A){var X,S,F,Q=A.lights;Y.setRGB(0,0,0);fa.setRGB(0,0,0);aa.setRGB(0,0,0);A=0;for(X=Q.length;A<X;A++){S=Q[A];F=S.color;if(S instanceof
+THREE.AmbientLight){Y.r+=F.r;Y.g+=F.g;Y.b+=F.b}else if(S instanceof THREE.DirectionalLight){fa.r+=F.r;fa.g+=F.g;fa.b+=F.b}else if(S instanceof THREE.PointLight){aa.r+=F.r;aa.g+=F.g;aa.b+=F.b}}}function Aa(A,X,S,F){var Q,$,da,ha,ia=A.lights;A=0;for(Q=ia.length;A<Q;A++){$=ia[A];da=$.color;ha=$.intensity;if($ instanceof THREE.DirectionalLight){$=S.dot($.position)*ha;if($>0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}else if($ instanceof THREE.PointLight){Z.sub($.position,X);Z.normalize();$=S.dot(Z)*ha;if($>
+0){F.r+=da.r*$;F.g+=da.g*$;F.b+=da.b*$}}}}function Na(A,X,S){if(S.opacity!=0){a(S.opacity);c(S.blending);var F,Q,$,da,ha,ia;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){da=S.map.image;ha=da.width>>1;ia=da.height>>1;Q=X.scale.x*q;$=X.scale.y*l;S=Q*ha;F=$*ia;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(!P.instersects(C))return;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(Q,-$);m.translate(-ha,-ia);m.drawImage(da,0,0);m.restore()}m.beginPath();m.moveTo(A.x-10,A.y);m.lineTo(A.x+
+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(R){U.r=Y.r+fa.r+aa.r;U.g=Y.g+fa.g+aa.g;U.b=Y.b+fa.b+aa.b;p.r=S.color.r*U.r;p.g=S.color.g*U.g;p.b=S.color.b*U.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;S=X.scale.x*q;F=X.scale.y*l;C.set(A.x-S,A.y-F,A.x+S,A.y+F);if(P.instersects(C)){Q=p.__styleString;if(K!=Q)m.fillStyle=K=Q;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);
+m.scale(S,F);m.beginPath();m.arc(0,0,1,0,za,true);m.closePath();m.fill();m.restore()}}}}function Oa(A,X,S,F){if(F.opacity!=0){a(F.opacity);c(F.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(F instanceof THREE.LineBasicMaterial){p.__styleString=F.color.__styleString;A=F.linewidth;if(M!=A)m.lineWidth=M=A;A=p.__styleString;if(H!=A)m.strokeStyle=H=A;m.stroke();C.inflate(F.linewidth*2)}}}function Ja(A,X,S,F,Q,$){if(Q.opacity!=
+0){a(Q.opacity);c(Q.blending);f=A.positionScreen.x;n=A.positionScreen.y;i=X.positionScreen.x;e=X.positionScreen.y;j=S.positionScreen.x;k=S.positionScreen.y;m.beginPath();m.moveTo(f,n);m.lineTo(i,e);m.lineTo(j,k);m.lineTo(f,n);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&wa(f,n,i,e,j,k,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof
+THREE.SphericalReflectionMapping){A=ja.matrix;Z.copy(F.vertexNormalsWorld[0]);L=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;N=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[1]);V=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;W=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;Z.copy(F.vertexNormalsWorld[2]);J=(Z.x*A.n11+Z.y*A.n12+Z.z*A.n13)*0.5+0.5;B=-(Z.x*A.n21+Z.y*A.n22+Z.z*A.n23)*0.5+0.5;wa(f,n,i,e,j,k,Q.env_map.image,L,N,V,W,J,B)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):
+Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&wa(f,n,i,e,j,k,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);c(THREE.SubtractiveBlending)}if(R)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){w.r=o.r=t.r=Y.r;w.g=o.g=t.g=Y.g;w.b=o.b=t.b=Y.b;Aa($,F.v1.positionWorld,F.vertexNormalsWorld[0],w);Aa($,F.v2.positionWorld,F.vertexNormalsWorld[1],o);Aa($,
+F.v3.positionWorld,F.vertexNormalsWorld[2],t);v.r=(o.r+t.r)*0.5;v.g=(o.g+t.g)*0.5;v.b=(o.b+t.b)*0.5;I=Ka(w,o,t,v);wa(f,n,i,e,j,k,I,0,0,1,0,0,1)}else{U.r=Y.r;U.g=Y.g;U.b=Y.b;Aa($,F.centroidWorld,F.normalWorld,U);p.r=Q.color.r*U.r;p.g=Q.color.g*U.g;p.b=Q.color.b*U.b;p.updateStyleString();Q.wireframe?Ba(p.__styleString,Q.wireframe_linewidth):Ca(p.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){D=ja.near;
+E=ja.far;w.r=w.g=w.b=1-Fa(A.positionScreen.z,D,E);o.r=o.g=o.b=1-Fa(X.positionScreen.z,D,E);t.r=t.g=t.b=1-Fa(S.positionScreen.z,D,E);v.r=(o.r+t.r)*0.5;v.g=(o.g+t.g)*0.5;v.b=(o.b+t.b)*0.5;I=Ka(w,o,t,v);wa(f,n,i,e,j,k,I,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){p.r=Ga(F.normalWorld.x);p.g=Ga(F.normalWorld.y);p.b=Ga(F.normalWorld.z);p.updateStyleString();Q.wireframe?Ba(p.__styleString,Q.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(A,X){if(H!=A)m.strokeStyle=H=A;if(M!=X)m.lineWidth=
+M=X;m.stroke();C.inflate(X*2)}function Ca(A){if(K!=A)m.fillStyle=K=A;m.fill()}function wa(A,X,S,F,Q,$,da,ha,ia,ra,ka,sa,xa){var ua,ta;ua=da.width-1;ta=da.height-1;ha*=ua;ia*=ta;ra*=ua;ka*=ta;sa*=ua;xa*=ta;S-=A;F-=X;Q-=A;$-=X;ra-=ha;ka-=ia;sa-=ha;xa-=ia;ta=1/(ra*xa-sa*ka);ua=(xa*S-ka*Q)*ta;ka=(xa*F-ka*$)*ta;S=(ra*Q-sa*S)*ta;F=(ra*$-sa*F)*ta;A=A-ua*ha-S*ia;X=X-ka*ha-F*ia;m.save();m.transform(ua,ka,S,F,A,X);m.clip();m.drawImage(da,0,0);m.restore()}function Ka(A,X,S,F){var Q=~~(A.r*255),$=~~(A.g*255);
+A=~~(A.b*255);var da=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(S.r*255),ra=~~(S.g*255);S=~~(S.b*255);var ka=~~(F.r*255),sa=~~(F.g*255);F=~~(F.b*255);ga[0]=Q<0?0:Q>255?255:Q;ga[1]=$<0?0:$>255?255:$;ga[2]=A<0?0:A>255?255:A;ga[4]=da<0?0:da>255?255:da;ga[5]=ha<0?0:ha>255?255:ha;ga[6]=X<0?0:X>255?255:X;ga[8]=ia<0?0:ia>255?255:ia;ga[9]=ra<0?0:ra>255?255:ra;ga[10]=S<0?0:S>255?255:S;ga[12]=ka<0?0:ka>255?255:ka;ga[13]=sa<0?0:sa>255?255:sa;ga[14]=F<0?0:F>255?255:F;oa.putImageData(la,0,0);ea.drawImage(na,
+0,0);return pa}function Fa(A,X,S){A=(A-X)/(S-X);return A*A*(3-2*A)}function Ga(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,X){var S=X.x-A.x,F=X.y-A.y,Q=1/Math.sqrt(S*S+F*F);S*=Q;F*=Q;X.x+=S;X.y+=F;A.x-=S;A.y-=F}var Da,La,ba,ma,va,Ia,Ma,ya;this.autoClear?this.clear():m.setTransform(1,0,0,-1,q,l);d=g.projectScene(ca,ja,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(P.getX(),P.getY(),P.getWidth(),P.getHeight());(R=ca.lights.length>0)&&Ea(ca);Da=0;for(La=d.length;Da<La;Da++){ba=
+d[Da];C.empty();if(ba instanceof THREE.RenderableParticle){s=ba;s.x*=q;s.y*=l;ma=0;for(va=ba.materials.length;ma<va;ma++)Na(s,ba,ba.materials[ma],ca)}else if(ba instanceof THREE.RenderableLine){s=ba.v1;T=ba.v2;s.positionScreen.x*=q;s.positionScreen.y*=l;T.positionScreen.x*=q;T.positionScreen.y*=l;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(T.positionScreen.x,T.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.materials.length;ma<va;)Oa(s,T,ba,ba.materials[ma++],ca)}}else if(ba instanceof
+THREE.RenderableFace3){s=ba.v1;T=ba.v2;G=ba.v3;s.positionScreen.x*=q;s.positionScreen.y*=l;T.positionScreen.x*=q;T.positionScreen.y*=l;G.positionScreen.x*=q;G.positionScreen.y*=l;if(ba.overdraw){Ha(s.positionScreen,T.positionScreen);Ha(T.positionScreen,G.positionScreen);Ha(G.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,T.positionScreen.x,T.positionScreen.y,G.positionScreen.x,G.positionScreen.y);if(P.instersects(C)){ma=0;for(va=ba.meshMaterials.length;ma<va;){ya=
+ba.meshMaterials[ma++];if(ya instanceof THREE.MeshFaceMaterial){Ia=0;for(Ma=ba.faceMaterials.length;Ia<Ma;)(ya=ba.faceMaterials[Ia++])&&Ja(s,T,G,ba,ya,ca)}else Ja(s,T,G,ba,ya,ca)}}}O.addRectangle(C)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(L,N,V){var W,J,B,P;W=0;for(J=L.lights.length;W<J;W++){B=L.lights[W];if(B instanceof THREE.DirectionalLight){P=N.normalWorld.dot(B.position)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}else if(B instanceof THREE.PointLight){k.sub(B.position,N.centroidWorld);k.normalize();P=N.normalWorld.dot(k)*B.intensity;if(P>0){V.r+=B.color.r*P;V.g+=B.color.g*P;V.b+=B.color.b*P}}}}function c(L,N,V,W,J,B){t=g(v++);t.setAttribute("d","M "+L.positionScreen.x+
+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(T){f.r=n.r;f.g=n.g;f.b=n.b;a(B,W,f);G.r=J.color.r*f.r;G.g=J.color.g*f.g;G.b=J.color.b*f.b;G.updateStyleString()}else G.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){j=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear);
+G.setRGB(j,j,j)}else J instanceof THREE.MeshNormalMaterial&&G.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));J.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+J.opacity);q.appendChild(t)}function d(L,N,V,W,J,B,P){t=g(v++);t.setAttribute("d",
+"M "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){f.r=n.r;f.g=n.g;f.b=n.b;a(P,J,f);G.r=B.color.r*f.r;G.g=B.color.g*f.g;G.b=B.color.b*f.b;G.updateStyleString()}else G.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){j=
+1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);G.setRGB(j,j,j)}else B instanceof THREE.MeshNormalMaterial&&G.setRGB(h(J.normalWorld.x),h(J.normalWorld.y),h(J.normalWorld.z));B.wireframe?t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):t.setAttribute("style","fill: "+G.__styleString+"; fill-opacity: "+B.opacity);q.appendChild(t)}
+function g(L){if(p[L]==null){p[L]=document.createElementNS("http://www.w3.org/2000/svg","path");I==0&&p[L].setAttribute("shape-rendering","crispEdges");return p[L]}return p[L]}function h(L){return L<0?Math.min((1+L)*0.5,0.5):0.5+Math.min(L*0.5,0.5)}var b=null,r=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,u,x,H,K,M=new THREE.Rectangle,s=new THREE.Rectangle,T=false,G=new THREE.Color(16777215),f=new THREE.Color(16777215),n=new THREE.Color(0),i=new THREE.Color(0),
+e=new THREE.Color(0),j,k=new THREE.Vector3,p=[],w=[],o=[],t,v,D,E,I=1;this.domElement=q;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(L){switch(L){case "high":I=1;break;case "low":I=0}};this.setSize=function(L,N){l=L;m=N;z=l/2;y=m/2;q.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);q.setAttribute("width",l);q.setAttribute("height",m);M.set(-z,-y,z,y)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(L,N){var V,W,
+J,B,P,O,C,R;this.autoClear&&this.clear();b=r.projectScene(L,N,this.sortElements);E=D=v=0;if(T=L.lights.length>0){C=L.lights;n.setRGB(0,0,0);i.setRGB(0,0,0);e.setRGB(0,0,0);V=0;for(W=C.length;V<W;V++){J=C[V];B=J.color;if(J instanceof THREE.AmbientLight){n.r+=B.r;n.g+=B.g;n.b+=B.b}else if(J instanceof THREE.DirectionalLight){i.r+=B.r;i.g+=B.g;i.b+=B.b}else if(J instanceof THREE.PointLight){e.r+=B.r;e.g+=B.g;e.b+=B.b}}}V=0;for(W=b.length;V<W;V++){C=b[V];s.empty();if(C instanceof THREE.RenderableParticle){u=
+C;u.x*=z;u.y*=-y;J=0;for(B=C.materials.length;J<B;J++)if(R=C.materials[J]){P=u;O=C;R=R;var U=D++;if(w[U]==null){w[U]=document.createElementNS("http://www.w3.org/2000/svg","circle");I==0&&w[U].setAttribute("shape-rendering","crispEdges")}t=w[U];t.setAttribute("cx",P.x);t.setAttribute("cy",P.y);t.setAttribute("r",O.scale.x*z);if(R instanceof THREE.ParticleCircleMaterial){if(T){f.r=n.r+i.r+e.r;f.g=n.g+i.g+e.g;f.b=n.b+i.b+e.b;G.r=R.color.r*f.r;G.g=R.color.g*f.g;G.b=R.color.b*f.b;G.updateStyleString()}else G=
+R.color;t.setAttribute("style","fill: "+G.__styleString)}q.appendChild(t)}}else if(C instanceof THREE.RenderableLine){u=C.v1;x=C.v2;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.materials.length;J<B;)if(R=C.materials[J++]){P=u;O=x;R=R;U=E++;if(o[U]==null){o[U]=document.createElementNS("http://www.w3.org/2000/svg","line");I==
+0&&o[U].setAttribute("shape-rendering","crispEdges")}t=o[U];t.setAttribute("x1",P.positionScreen.x);t.setAttribute("y1",P.positionScreen.y);t.setAttribute("x2",O.positionScreen.x);t.setAttribute("y2",O.positionScreen.y);if(R instanceof THREE.LineBasicMaterial){G.__styleString=R.color.__styleString;t.setAttribute("style","fill: none; stroke: "+G.__styleString+"; stroke-width: "+R.linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.linecap+"; stroke-linejoin: "+R.linejoin);q.appendChild(t)}}}}else if(C instanceof
 THREE.RenderableFace3){u=C.v1;x=C.v2;H=C.v3;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(s)){J=0;for(B=C.meshMaterials.length;J<B;){R=C.meshMaterials[J++];if(R instanceof THREE.MeshFaceMaterial){P=0;for(O=C.faceMaterials.length;P<O;)(R=C.faceMaterials[P++])&&
 c(u,x,H,C,R,L)}else R&&c(u,x,H,C,R,L)}}}else if(C instanceof THREE.RenderableFace4){u=C.v1;x=C.v2;H=C.v3;K=C.v4;u.positionScreen.x*=z;u.positionScreen.y*=-y;x.positionScreen.x*=z;x.positionScreen.y*=-y;H.positionScreen.x*=z;H.positionScreen.y*=-y;K.positionScreen.x*=z;K.positionScreen.y*=-y;s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(H.positionScreen.x,H.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);if(M.instersects(s)){J=
 0;for(B=C.meshMaterials.length;J<B;){R=C.meshMaterials[J++];if(R instanceof THREE.MeshFaceMaterial){P=0;for(O=C.faceMaterials.length;P<O;)(R=C.faceMaterials[P++])&&d(u,x,H,K,C,R,L)}else R&&d(u,x,H,K,C,R,L)}}}}}};
-THREE.WebGLRenderer=function(a){function c(g,n){g.fragment_shader=n.fragment_shader;g.vertex_shader=n.vertex_shader;g.uniforms=Uniforms.clone(n.uniforms)}function d(g,n){var i;if(g=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(g=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,n);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function f(g){switch(g){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
+THREE.WebGLRenderer=function(a){function c(f,n){f.fragment_shader=n.fragment_shader;f.vertex_shader=n.vertex_shader;f.uniforms=Uniforms.clone(n.uniforms)}function d(f,n){var i;if(f=="fragment")i=b.createShader(b.FRAGMENT_SHADER);else if(f=="vertex")i=b.createShader(b.VERTEX_SHADER);b.shaderSource(i,n);b.compileShader(i);if(!b.getShaderParameter(i,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(i));return null}return i}function g(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,q=null,r=null,l=new THREE.Matrix4,m,z=new Float32Array(16),y=new Float32Array(16),
-u=new Float32Array(16),x=new Float32Array(9),H=new Float32Array(16),K=new THREE.Matrix4,M=new THREE.Vector4,s=true,T=new THREE.Color(0),G=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)G=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(g,n,i){try{b=h.getContext("experimental-webgl",{antialias:g})}catch(e){console.log(e)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
-0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(n.r,n.g,n.b,i)})(s,T,G);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(g,n){h.width=g;h.height=n;b.viewport(0,0,h.width,h.height)};this.setClearColor=function(g,n){var i=new THREE.Color(g);b.clearColor(i.r,
-i.g,i.b,n)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(g,n){var i,e,j,k=0,p=0,w=0,o,t,v,D=this.lights,E=D.directional.colors,I=D.directional.positions,L=D.point.colors,N=D.point.positions,V=0,W=0;i=0;for(e=n.length;i<e;i++){j=n[i];o=j.color;t=j.position;v=j.intensity;if(j instanceof THREE.AmbientLight){k+=o.r;p+=o.g;w+=o.b}else if(j instanceof THREE.DirectionalLight){E[V*3]=o.r*v;E[V*3+1]=o.g*v;E[V*3+2]=o.b*v;I[V*3]=t.x;I[V*3+1]=t.y;I[V*3+2]=t.z;
-V+=1}else if(j instanceof THREE.PointLight){L[W*3]=o.r*v;L[W*3+1]=o.g*v;L[W*3+2]=o.b*v;N[W*3]=t.x;N[W*3+1]=t.y;N[W*3+2]=t.z;W+=1}}D.point.length=W;D.directional.length=V;D.ambient[0]=k;D.ambient[1]=p;D.ambient[2]=w};this.createParticleBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLParticleBuffer=b.createBuffer();g.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=
-function(g){g.__webGLVertexBuffer=b.createBuffer();g.__webGLNormalBuffer=b.createBuffer();g.__webGLTangentBuffer=b.createBuffer();g.__webGLUVBuffer=b.createBuffer();g.__webGLUV2Buffer=b.createBuffer();g.__webGLFaceBuffer=b.createBuffer();g.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(g){var n=g.vertices.length;g.__vertexArray=new Float32Array(n*3);g.__lineArray=new Uint16Array(n);g.__webGLLineCount=n};this.initParticleBuffers=function(g){var n=g.vertices.length;g.__vertexArray=
-new Float32Array(n*3);g.__colorArray=new Float32Array(n*3);g.__particleArray=new Uint16Array(n);g.__sortArray=[];g.__webGLParticleCount=n};this.initMeshBuffers=function(g,n){var i,e,j=0,k=0,p=0,w=n.geometry.faces,o=g.faces;i=0;for(e=o.length;i<e;i++){fi=o[i];face=w[fi];if(face instanceof THREE.Face3){j+=3;k+=1;p+=3}else if(face instanceof THREE.Face4){j+=4;k+=2;p+=4}}g.__vertexArray=new Float32Array(j*3);g.__normalArray=new Float32Array(j*3);g.__tangentArray=new Float32Array(j*4);g.__uvArray=new Float32Array(j*
-2);g.__uv2Array=new Float32Array(j*2);g.__faceArray=new Uint16Array(k*3);g.__lineArray=new Uint16Array(p*2);j=false;i=0;for(e=n.materials.length;i<e;i++){w=n.materials[i];if(w instanceof THREE.MeshFaceMaterial){w=0;for(o=g.materials.length;w<o;w++)if(g.materials[w]&&g.materials[w].shading!=undefined&&g.materials[w].shading==THREE.SmoothShading){j=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){j=true;break}if(j)break}g.__needsSmoothNormals=j;g.__webGLFaceCount=k*3;g.__webGLLineCount=
-p*2};this.setMeshBuffers=function(g,n,i){var e,j,k,p,w,o,t,v,D,E,I=0,L=0,N=0,V=0,W=0,J=0,B=0,P=0,O=g.__vertexArray,C=g.__uvArray,R=g.__uv2Array,U=g.__normalArray,Y=g.__tangentArray,fa=g.__faceArray,aa=g.__lineArray,za=g.__needsSmoothNormals,Z=n.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,ka=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=g.faces,ca=Z.faces,la=Z.uvs,Ea=Z.uvs2;n=0;for(e=qa.length;n<e;n++){j=qa[n];k=ca[j];o=la[j];j=Ea[j];p=k.vertexNormals;w=k.normal;if(k instanceof
-THREE.Face3){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;L+=9}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;B+=12}if(ga)if(p.length==3&&za)for(k=0;k<3;k++){w=p[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<3;k++){U[J]=
-w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&o)for(k=0;k<3;k++){p=o[k];C[N]=p.u;C[N+1]=p.v;N+=2}if(ka&&j)for(k=0;k<3;k++){o=j[k];R[V]=o.u;R[V+1]=o.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+2;aa[P+4]=I+1;aa[P+5]=I+2;P+=6;I+=3}}else if(k instanceof THREE.Face4){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;E=ea[k.d].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;O[L+9]=E.x;O[L+10]=
-E.y;O[L+11]=E.z;L+=12}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;k=ea[k.d].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;Y[B+12]=k.x;Y[B+13]=k.y;Y[B+14]=k.z;Y[B+15]=k.w;B+=16}if(ga)if(p.length==4&&za)for(k=0;k<4;k++){w=p[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<4;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(ka&&o)for(k=0;k<4;k++){p=o[k];C[N]=p.u;C[N+1]=p.v;N+=
-2}if(ka&&j)for(k=0;k<4;k++){o=j[k];R[V]=o.u;R[V+1]=o.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+3;aa[P+4]=I+1;aa[P+5]=I+2;aa[P+6]=I+2;aa[P+7]=I+3;P+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,
-Y,i)}if(ka&&N>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(ka&&V>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,R,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(g,n){var i,e,j,k=g.vertices,p=k.length,w=g.__vertexArray,o=g.__lineArray,t=
-g.__dirtyElements;if(g.__dirtyVertices){for(i=0;i<p;i++){e=k[i].position;j=i*3;w[j]=e.x;w[j+1]=e.y;w[j+2]=e.z}b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,n)}if(t){for(i=0;i<p;i++)o[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,o,n)}};this.setParticleBuffers=function(g,n,i,e){var j,k,p;k=g.vertices;var w=k.length,o=g.colors,t=o.length,v=g.__vertexArray,D=g.__particleArray,E=g.__colorArray,I=g.__sortArray,L=g.__dirtyVertices,
-N=g.__dirtyElements,V=g.__dirtyColors;if(i.sortParticles){K.multiply(e.projectionMatrix,e.matrix);K.multiplySelf(i.matrix);for(j=0;j<w;j++){p=k[j].position;M.copy(p);K.multiplyVector3(M);I[j]=[M.z,j]}I.sort(function(W,J){return J[0]-W[0]});for(j=0;j<w;j++){p=k[I[j][1]].position;e=j*3;v[e]=p.x;v[e+1]=p.y;v[e+2]=p.z}for(k=0;k<t;k++){e=k*3;color=o[I[k][1]];E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}else{if(L)for(j=0;j<w;j++){p=k[j].position;e=j*3;v[e]=p.x;v[e+1]=p.y;v[e+2]=p.z}if(V)for(k=0;k<t;k++){color=
-o[k];e=k*3;E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}if(N){for(j=0;j<w;j++)D[j]=j;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,n)}if(L||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,n)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,n)}};this.initMaterial=function(g,n,i){if(!g.program){var e,j;if(g instanceof THREE.MeshDepthMaterial)c(g,
-THREE.ShaderLib.depth);else if(g instanceof THREE.MeshNormalMaterial)c(g,THREE.ShaderLib.normal);else if(g instanceof THREE.MeshBasicMaterial)c(g,THREE.ShaderLib.basic);else if(g instanceof THREE.MeshLambertMaterial)c(g,THREE.ShaderLib.lambert);else if(g instanceof THREE.MeshPhongMaterial)c(g,THREE.ShaderLib.phong);else if(g instanceof THREE.LineBasicMaterial)c(g,THREE.ShaderLib.basic);else g instanceof THREE.ParticleBasicMaterial&&c(g,THREE.ShaderLib.particle_basic);var k,p,w,o;j=w=o=0;for(k=n.length;j<
-k;j++){p=n[j];p instanceof THREE.DirectionalLight&&w++;p instanceof THREE.PointLight&&o++}if(o+w<=4){n=w;o=o}else{n=Math.ceil(4*w/(o+w));o=4-n}j={directional:n,point:o};o=g.fragment_shader;n=g.vertex_shader;k={fog:i,map:g.map,env_map:g.env_map,light_map:g.light_map,vertex_colors:g.vertex_colors,maxDirLights:j.directional,maxPointLights:j.point};i=b.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,
-k.fog?"#define USE_FOG":"",k.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":
-"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",j+o));b.attachShader(i,d("vertex",k+n));b.linkProgram(i);b.getProgramParameter(i,b.LINK_STATUS)||
-alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};g.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(e in g.uniforms)i.push(e);e=g.program;o=0;for(n=i.length;o<n;o++){j=i[o];e.uniforms[j]=b.getUniformLocation(e,j)}g=g.program;e=["position","normal","uv","uv2","tangent","color"];i=0;for(o=e.length;i<o;i++){n=e[i];g.attributes[n]=
-b.getAttribLocation(g,n)}}};this.setProgram=function(g,n,i,e){this.initMaterial(e,n,i);var j=e.program;if(j!=q){b.useProgram(j);q=j}this.loadCamera(j,g);this.loadMatrices(j);if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial){this.setupLights(j,n);n=this.lights;e.uniforms.enableLighting.value=n.directional.length+n.point.length;e.uniforms.ambientLightColor.value=n.ambient;e.uniforms.directionalLightColor.value=n.directional.colors;e.uniforms.directionalLightDirection.value=
-n.directional.positions;e.uniforms.pointLightColor.value=n.point.colors;e.uniforms.pointLightPosition.value=n.point.positions}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.light_map.texture=e.light_map;e.uniforms.env_map.texture=e.env_map;e.uniforms.reflectivity.value=
-e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.LineBasicMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,
-e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.ParticleBasicMaterial){e.uniforms.psColor.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.size.value=e.size;e.uniforms.map.texture=
-e.map;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.MeshPhongMaterial){e.uniforms.ambient.value.setRGB(e.ambient.r,e.ambient.g,e.ambient.b);e.uniforms.specular.value.setRGB(e.specular.r,e.specular.g,e.specular.b);e.uniforms.shininess.value=e.shininess}if(e instanceof THREE.MeshDepthMaterial){e.uniforms.mNear.value=
-g.near;e.uniforms.mFar.value=g.far}g=e.uniforms;var k,p;for(k in g)if(p=j.uniforms[k]){e=g[k];n=e.type;i=e.value;if(n=="i")b.uniform1i(p,i);else if(n=="f")b.uniform1f(p,i);else if(n=="fv1")b.uniform1fv(p,i);else if(n=="fv")b.uniform3fv(p,i);else if(n=="v2")b.uniform2f(p,i.x,i.y);else if(n=="v3")b.uniform3f(p,i.x,i.y,i.z);else if(n=="c")b.uniform3f(p,i.r,i.g,i.b);else if(n=="t"){b.uniform1i(p,i);if(e=e.texture)if(e.image instanceof Array&&e.image.length==6){e=e;i=i;if(e.image.length==6){if(!e.image.__webGLTextureCube&&
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var h=document.createElement("canvas"),b,r=null,q=null,l=new THREE.Matrix4,m,z=new Float32Array(16),y=new Float32Array(16),
+u=new Float32Array(16),x=new Float32Array(9),H=new Float32Array(16),K=new THREE.Matrix4,M=new THREE.Vector4,s=true,T=new THREE.Color(0),G=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)G=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(f,n,i){try{b=h.getContext("experimental-webgl",{antialias:f})}catch(e){console.log(e)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(n.r,n.g,n.b,i)})(s,T,G);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,n){h.width=f;h.height=n;b.viewport(0,0,h.width,h.height)};this.setClearColorHex=function(f,n){var i=new THREE.Color(f);b.clearColor(i.r,
+i.g,i.b,n)};this.setClearColor=function(f,n){b.clearColor(f.r,f.g,f.b,n)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,n){var i,e,j,k=0,p=0,w=0,o,t,v,D=this.lights,E=D.directional.colors,I=D.directional.positions,L=D.point.colors,N=D.point.positions,V=0,W=0;i=0;for(e=n.length;i<e;i++){j=n[i];o=j.color;t=j.position;v=j.intensity;if(j instanceof THREE.AmbientLight){k+=o.r;p+=o.g;w+=o.b}else if(j instanceof THREE.DirectionalLight){E[V*3]=o.r*v;E[V*
+3+1]=o.g*v;E[V*3+2]=o.b*v;I[V*3]=t.x;I[V*3+1]=t.y;I[V*3+2]=t.z;V+=1}else if(j instanceof THREE.PointLight){L[W*3]=o.r*v;L[W*3+1]=o.g*v;L[W*3+2]=o.b*v;N[W*3]=t.x;N[W*3+1]=t.y;N[W*3+2]=t.z;W+=1}}D.point.length=W;D.directional.length=V;D.ambient[0]=k;D.ambient[1]=p;D.ambient[2]=w};this.createParticleBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLParticleBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();
+f.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(f){f.__webGLVertexBuffer=b.createBuffer();f.__webGLNormalBuffer=b.createBuffer();f.__webGLTangentBuffer=b.createBuffer();f.__webGLUVBuffer=b.createBuffer();f.__webGLUV2Buffer=b.createBuffer();f.__webGLFaceBuffer=b.createBuffer();f.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(f){var n=f.vertices.length;f.__vertexArray=new Float32Array(n*3);f.__lineArray=new Uint16Array(n);f.__webGLLineCount=n};this.initParticleBuffers=
+function(f){var n=f.vertices.length;f.__vertexArray=new Float32Array(n*3);f.__colorArray=new Float32Array(n*3);f.__particleArray=new Uint16Array(n);f.__sortArray=[];f.__webGLParticleCount=n};this.initMeshBuffers=function(f,n){var i,e,j=0,k=0,p=0,w=n.geometry.faces,o=f.faces;i=0;for(e=o.length;i<e;i++){fi=o[i];face=w[fi];if(face instanceof THREE.Face3){j+=3;k+=1;p+=3}else if(face instanceof THREE.Face4){j+=4;k+=2;p+=4}}f.__vertexArray=new Float32Array(j*3);f.__normalArray=new Float32Array(j*3);f.__tangentArray=
+new Float32Array(j*4);f.__uvArray=new Float32Array(j*2);f.__uv2Array=new Float32Array(j*2);f.__faceArray=new Uint16Array(k*3);f.__lineArray=new Uint16Array(p*2);j=false;i=0;for(e=n.materials.length;i<e;i++){w=n.materials[i];if(w instanceof THREE.MeshFaceMaterial){w=0;for(o=f.materials.length;w<o;w++)if(f.materials[w]&&f.materials[w].shading!=undefined&&f.materials[w].shading==THREE.SmoothShading){j=true;break}}else if(w&&w.shading!=undefined&&w.shading==THREE.SmoothShading){j=true;break}if(j)break}f.__needsSmoothNormals=
+j;f.__webGLFaceCount=k*3;f.__webGLLineCount=p*2};this.setMeshBuffers=function(f,n,i){var e,j,k,p,w,o,t,v,D,E,I=0,L=0,N=0,V=0,W=0,J=0,B=0,P=0,O=f.__vertexArray,C=f.__uvArray,R=f.__uv2Array,U=f.__normalArray,Y=f.__tangentArray,fa=f.__faceArray,aa=f.__lineArray,za=f.__needsSmoothNormals,Z=n.geometry,na=Z.__dirtyVertices,oa=Z.__dirtyElements,la=Z.__dirtyUvs,ga=Z.__dirtyNormals,pa=Z.__dirtyTangents,ea=Z.vertices,qa=f.faces,ca=Z.faces,ja=Z.uvs,Ea=Z.uvs2;n=0;for(e=qa.length;n<e;n++){j=qa[n];k=ca[j];o=ja[j];
+j=Ea[j];p=k.vertexNormals;w=k.normal;if(k instanceof THREE.Face3){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;L+=9}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;B+=12}if(ga)if(p.length==3&&za)for(k=0;k<3;k++){w=p[k];U[J]=w.x;
+U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<3;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(la&&o)for(k=0;k<3;k++){p=o[k];C[N]=p.u;C[N+1]=p.v;N+=2}if(la&&j)for(k=0;k<3;k++){o=j[k];R[V]=o.u;R[V+1]=o.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;W+=3;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+2;aa[P+4]=I+1;aa[P+5]=I+2;P+=6;I+=3}}else if(k instanceof THREE.Face4){if(na){t=ea[k.a].position;v=ea[k.b].position;D=ea[k.c].position;E=ea[k.d].position;O[L]=t.x;O[L+1]=t.y;O[L+2]=t.z;O[L+3]=v.x;O[L+4]=v.y;O[L+5]=v.z;
+O[L+6]=D.x;O[L+7]=D.y;O[L+8]=D.z;O[L+9]=E.x;O[L+10]=E.y;O[L+11]=E.z;L+=12}if(pa&&Z.hasTangents){t=ea[k.a].tangent;v=ea[k.b].tangent;D=ea[k.c].tangent;k=ea[k.d].tangent;Y[B]=t.x;Y[B+1]=t.y;Y[B+2]=t.z;Y[B+3]=t.w;Y[B+4]=v.x;Y[B+5]=v.y;Y[B+6]=v.z;Y[B+7]=v.w;Y[B+8]=D.x;Y[B+9]=D.y;Y[B+10]=D.z;Y[B+11]=D.w;Y[B+12]=k.x;Y[B+13]=k.y;Y[B+14]=k.z;Y[B+15]=k.w;B+=16}if(ga)if(p.length==4&&za)for(k=0;k<4;k++){w=p[k];U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}else for(k=0;k<4;k++){U[J]=w.x;U[J+1]=w.y;U[J+2]=w.z;J+=3}if(la&&
+o)for(k=0;k<4;k++){p=o[k];C[N]=p.u;C[N+1]=p.v;N+=2}if(la&&j)for(k=0;k<4;k++){o=j[k];R[V]=o.u;R[V+1]=o.v;V+=2}if(oa){fa[W]=I;fa[W+1]=I+1;fa[W+2]=I+2;fa[W+3]=I;fa[W+4]=I+2;fa[W+5]=I+3;W+=6;aa[P]=I;aa[P+1]=I+1;aa[P+2]=I;aa[P+3]=I+3;aa[P+4]=I+1;aa[P+5]=I+2;aa[P+6]=I+2;aa[P+7]=I+3;P+=8;I+=4}}}if(na){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,O,i)}if(ga){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,U,i)}if(pa&&Z.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,
+f.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,Y,i)}if(la&&N>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,C,i)}if(la&&V>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,R,i)}if(oa){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,i);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,aa,i)}};this.setLineBuffers=function(f,n){var i,e,j,k=f.vertices,
+p=k.length,w=f.__vertexArray,o=f.__lineArray,t=f.__dirtyElements;if(f.__dirtyVertices){for(i=0;i<p;i++){e=k[i].position;j=i*3;w[j]=e.x;w[j+1]=e.y;w[j+2]=e.z}b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,w,n)}if(t){for(i=0;i<p;i++)o[i]=i;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,o,n)}};this.setParticleBuffers=function(f,n,i,e){var j,k,p;k=f.vertices;var w=k.length,o=f.colors,t=o.length,v=f.__vertexArray,D=f.__particleArray,
+E=f.__colorArray,I=f.__sortArray,L=f.__dirtyVertices,N=f.__dirtyElements,V=f.__dirtyColors;if(i.sortParticles){K.multiply(e.projectionMatrix,e.matrix);K.multiplySelf(i.matrix);for(j=0;j<w;j++){p=k[j].position;M.copy(p);K.multiplyVector3(M);I[j]=[M.z,j]}I.sort(function(W,J){return J[0]-W[0]});for(j=0;j<w;j++){p=k[I[j][1]].position;e=j*3;v[e]=p.x;v[e+1]=p.y;v[e+2]=p.z}for(k=0;k<t;k++){e=k*3;color=o[I[k][1]];E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}else{if(L)for(j=0;j<w;j++){p=k[j].position;e=j*3;
+v[e]=p.x;v[e+1]=p.y;v[e+2]=p.z}if(V)for(k=0;k<t;k++){color=o[k];e=k*3;E[e]=color.r;E[e+1]=color.g;E[e+2]=color.b}}if(N){for(j=0;j<w;j++)D[j]=j;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,D,n)}if(L||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v,n)}if(V||i.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,E,n)}};this.initMaterial=function(f,n,i){if(!f.program){var e,
+j;if(f instanceof THREE.MeshDepthMaterial)c(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)c(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)c(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)c(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)c(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)c(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&c(f,THREE.ShaderLib.particle_basic);
+var k,p,w,o;j=w=o=0;for(k=n.length;j<k;j++){p=n[j];p instanceof THREE.DirectionalLight&&w++;p instanceof THREE.PointLight&&o++}if(o+w<=4){n=w;o=o}else{n=Math.ceil(4*w/(o+w));o=4-n}j={directional:n,point:o};o=f.fragment_shader;n=f.vertex_shader;k={fog:i,map:f.map,env_map:f.env_map,light_map:f.light_map,vertex_colors:f.vertex_colors,maxDirLights:j.directional,maxPointLights:j.point};i=b.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+
+k.maxPointLights,k.fog?"#define USE_FOG":"",k.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",k.map?"#define USE_MAP":"",k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");k=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+k.maxDirLights,"#define MAX_POINT_LIGHTS "+k.maxPointLights,k.map?"#define USE_MAP":"",
+k.env_map?"#define USE_ENVMAP":"",k.light_map?"#define USE_LIGHTMAP":"",k.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(i,d("fragment",j+o));b.attachShader(i,d("vertex",k+n));b.linkProgram(i);
+b.getProgramParameter(i,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(i,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");i.uniforms={};i.attributes={};f.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(e in f.uniforms)i.push(e);e=f.program;o=0;for(n=i.length;o<n;o++){j=i[o];e.uniforms[j]=b.getUniformLocation(e,j)}f=f.program;e=["position","normal","uv","uv2","tangent","color"];i=0;
+for(o=e.length;i<o;i++){n=e[i];f.attributes[n]=b.getAttribLocation(f,n)}}};this.setProgram=function(f,n,i,e){this.initMaterial(e,n,i);var j=e.program;if(j!=r){b.useProgram(j);r=j}this.loadCamera(j,f);this.loadMatrices(j);if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial){this.setupLights(j,n);n=this.lights;e.uniforms.enableLighting.value=n.directional.length+n.point.length;e.uniforms.ambientLightColor.value=n.ambient;e.uniforms.directionalLightColor.value=n.directional.colors;
+e.uniforms.directionalLightDirection.value=n.directional.positions;e.uniforms.pointLightColor.value=n.point.colors;e.uniforms.pointLightPosition.value=n.point.positions}if(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.map.texture=e.map;e.uniforms.light_map.texture=e.light_map;e.uniforms.env_map.texture=
+e.env_map;e.uniforms.reflectivity.value=e.reflectivity;e.uniforms.refraction_ratio.value=e.refraction_ratio;e.uniforms.combine.value=e.combine;e.uniforms.useRefract.value=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.LineBasicMaterial){e.uniforms.diffuse.value.setRGB(e.color.r*
+e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.ParticleBasicMaterial){e.uniforms.psColor.value.setRGB(e.color.r*e.opacity,e.color.g*e.opacity,e.color.b*e.opacity);e.uniforms.opacity.value=e.opacity;e.uniforms.size.value=e.size;
+e.uniforms.map.texture=e.map;if(i){e.uniforms.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){e.uniforms.fogNear.value=i.near;e.uniforms.fogFar.value=i.far}else if(i instanceof THREE.FogExp2)e.uniforms.fogDensity.value=i.density}}if(e instanceof THREE.MeshPhongMaterial){e.uniforms.ambient.value.setRGB(e.ambient.r,e.ambient.g,e.ambient.b);e.uniforms.specular.value.setRGB(e.specular.r,e.specular.g,e.specular.b);e.uniforms.shininess.value=e.shininess}if(e instanceof THREE.MeshDepthMaterial){e.uniforms.mNear.value=
+f.near;e.uniforms.mFar.value=f.far}f=e.uniforms;var k,p;for(k in f)if(p=j.uniforms[k]){e=f[k];n=e.type;i=e.value;if(n=="i")b.uniform1i(p,i);else if(n=="f")b.uniform1f(p,i);else if(n=="fv1")b.uniform1fv(p,i);else if(n=="fv")b.uniform3fv(p,i);else if(n=="v2")b.uniform2f(p,i.x,i.y);else if(n=="v3")b.uniform3f(p,i.x,i.y,i.z);else if(n=="c")b.uniform3f(p,i.r,i.g,i.b);else if(n=="t"){b.uniform1i(p,i);if(e=e.texture)if(e.image instanceof Array&&e.image.length==6){e=e;i=i;if(e.image.length==6){if(!e.image.__webGLTextureCube&&
 !e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(n=0;n<6;++n)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
-n,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image[n]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}else{e=e;i=i;if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(e.wrap_s));
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(e.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture)}}}return j};this.renderBuffer=function(g,n,i,e,j,k){g=this.setProgram(g,n,i,e,k).attributes;b.bindBuffer(b.ARRAY_BUFFER,j.__webGLVertexBuffer);b.vertexAttribPointer(g.position,
-3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.position);if(g.color>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.vertexAttribPointer(g.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.color)}if(g.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.vertexAttribPointer(g.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.normal)}if(g.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer);b.vertexAttribPointer(g.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.tangent)}if(g.uv>=
-0)if(j.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.vertexAttribPointer(g.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv)}else b.disableVertexAttribArray(g.uv);if(g.uv2>=0)if(j.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.vertexAttribPointer(g.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(g.uv2)}else b.disableVertexAttribArray(g.uv2);if(e.wireframe||e instanceof THREE.LineBasicMaterial){g=e.wireframe_linewidth!==undefined?e.wireframe_linewidth:
-e.linewidth!==undefined?e.linewidth:1;e=e instanceof THREE.LineBasicMaterial&&k.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.drawElements(e,j.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(e instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLParticleBuffer);b.drawElements(b.POINTS,j.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
-j.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,n,i,e,j,k,p){var w,o,t,v,D;t=0;for(v=e.materials.length;t<v;t++){w=e.materials[t];if(w instanceof THREE.MeshFaceMaterial){w=0;for(o=j.materials.length;w<o;w++)if((D=j.materials[w])&&D.blending==k&&D.opacity<1==p){this.setBlending(D.blending);this.renderBuffer(g,n,i,D,j,e)}}else if((D=w)&&D.blending==k&&D.opacity<1==p){this.setBlending(D.blending);this.renderBuffer(g,n,i,D,j,e)}}};this.renderPassImmediate=function(g,n,i,e,j,k){var p,
-w,o,t;p=0;for(w=e.materials.length;p<w;p++)if((o=e.materials[p])&&o.blending==j&&o.opacity<1==k){this.setBlending(o.blending);t=this.setProgram(g,n,i,o,e);e.render(function(v){var D=t;if(!v.__webGLVertexBuffer)v.__webGLVertexBuffer=b.createBuffer();if(!v.__webGLNormalBuffer)v.__webGLNormalBuffer=b.createBuffer();if(v.hasPos){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.position);b.vertexAttribPointer(D.attributes.position,
-3,b.FLOAT,false,0,0)}if(v.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,v.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.normal);b.vertexAttribPointer(D.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,v.count);v.count=0})}};this.render=function(g,n,i,e){var j,k,p,w=g.lights,o=g.fog;n.autoUpdateMatrix&&n.updateMatrix();z.set(n.matrix.flatten());u.set(n.projectionMatrix.flatten());this.initWebGLObjects(g,n);e=e!==undefined?
-e:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
-f(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(i.format),i.width,i.height,0,f(i.format),f(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
-null)}if(i){j=i.__webGLFramebuffer;p=i.width;k=i.height}else{j=null;p=h.width;k=h.height}if(j!=r){b.bindFramebuffer(b.FRAMEBUFFER,j);b.viewport(0,0,p,k);e&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);r=j}this.autoClear&&this.clear();j=g.__webGLObjects.length;for(e=0;e<j;e++){k=g.__webGLObjects[e];p=k.object;if(p.visible){p.autoUpdateMatrix&&p.updateMatrix();if(p.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);p.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(e=0;e<j;e++){k=g.__webGLObjects[e];
-p=k.object;k=k.buffer;if(p.visible){p.autoUpdateMatrix&&p.updateMatrix();this.setupMatrices(p,n);this.renderPass(n,w,o,p,k,THREE.NormalBlending,false)}}for(e=0;e<g.__webGLObjectsImmediate.length;e++){k=g.__webGLObjectsImmediate[e];p=k.object;if(p.visible){this.setupMatrices(p,n);this.renderPassImmediate(n,w,o,p,THREE.NormalBlending,false)}}for(e=0;e<j;e++){k=g.__webGLObjects[e];p=k.object;k=k.buffer;if(p.visible){this.setupMatrices(p,n);this.renderPass(n,w,o,p,k,THREE.AdditiveBlending,false);this.renderPass(n,
-w,o,p,k,THREE.SubtractiveBlending,false);this.renderPass(n,w,o,p,k,THREE.AdditiveBlending,true);this.renderPass(n,w,o,p,k,THREE.SubtractiveBlending,true);this.renderPass(n,w,o,p,k,THREE.NormalBlending,true);this.renderPass(n,w,o,p,k,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(g,n){function i(D,
-E,I,L){if(D[E]==undefined){g.__webGLObjects.push({buffer:I,object:L});D[E]=1}}function e(D,E,I){if(D[E]==undefined){g.__webGLObjectsImmediate.push({object:I});D[E]=1}}var j,k,p,w,o,t,v;if(!g.__webGLObjects){g.__webGLObjects=[];g.__webGLObjectsMap={};g.__webGLObjectsImmediate=[]}j=0;for(k=g.objects.length;j<k;j++){p=g.objects[j];o=p.geometry;if(g.__webGLObjectsMap[p.id]==undefined)g.__webGLObjectsMap[p.id]={};v=g.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh){for(w in o.geometryChunks){t=o.geometryChunks[w];
+n,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image[n]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}else{e=e;i=i;if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,g(e.wrap_s));
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,g(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,g(e.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+i);b.bindTexture(b.TEXTURE_2D,e.__webGLTexture)}}}return j};this.renderBuffer=function(f,n,i,e,j,k){f=this.setProgram(f,n,i,e,k).attributes;b.bindBuffer(b.ARRAY_BUFFER,j.__webGLVertexBuffer);b.vertexAttribPointer(f.position,
+3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.position);if(f.color>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLColorBuffer);b.vertexAttribPointer(f.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.color)}if(f.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLNormalBuffer);b.vertexAttribPointer(f.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.normal)}if(f.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLTangentBuffer);b.vertexAttribPointer(f.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.tangent)}if(f.uv>=
+0)if(j.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUVBuffer);b.vertexAttribPointer(f.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv)}else b.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(j.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,j.__webGLUV2Buffer);b.vertexAttribPointer(f.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(f.uv2)}else b.disableVertexAttribArray(f.uv2);if(e.wireframe||e instanceof THREE.LineBasicMaterial){f=e.wireframe_linewidth!==undefined?e.wireframe_linewidth:
+e.linewidth!==undefined?e.linewidth:1;e=e instanceof THREE.LineBasicMaterial&&k.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);b.drawElements(e,j.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(e instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLParticleBuffer);b.drawElements(b.POINTS,j.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
+j.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,n,i,e,j,k,p){var w,o,t,v,D;t=0;for(v=e.materials.length;t<v;t++){w=e.materials[t];if(w instanceof THREE.MeshFaceMaterial){w=0;for(o=j.materials.length;w<o;w++)if((D=j.materials[w])&&D.blending==k&&D.opacity<1==p){this.setBlending(D.blending);this.renderBuffer(f,n,i,D,j,e)}}else if((D=w)&&D.blending==k&&D.opacity<1==p){this.setBlending(D.blending);this.renderBuffer(f,n,i,D,j,e)}}};this.renderPassImmediate=function(f,n,i,e,j,k){var p,
+w,o,t;p=0;for(w=e.materials.length;p<w;p++)if((o=e.materials[p])&&o.blending==j&&o.opacity<1==k){this.setBlending(o.blending);t=this.setProgram(f,n,i,o,e);e.render(function(v){var D=t;if(!v.__webGLVertexBuffer)v.__webGLVertexBuffer=b.createBuffer();if(!v.__webGLNormalBuffer)v.__webGLNormalBuffer=b.createBuffer();if(v.hasPos){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,v.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.position);b.vertexAttribPointer(D.attributes.position,
+3,b.FLOAT,false,0,0)}if(v.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,v.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(D.attributes.normal);b.vertexAttribPointer(D.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,v.count);v.count=0})}};this.render=function(f,n,i,e){var j,k,p,w=f.lights,o=f.fog;n.autoUpdateMatrix&&n.updateMatrix();z.set(n.matrix.flatten());u.set(n.projectionMatrix.flatten());this.initWebGLObjects(f,n);e=e!==undefined?
+e:true;if(i&&!i.__webGLFramebuffer){i.__webGLFramebuffer=b.createFramebuffer();i.__webGLRenderbuffer=b.createRenderbuffer();i.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,i.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,i.width,i.height);b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,g(i.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g(i.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
+g(i.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,g(i.min_filter));b.texImage2D(b.TEXTURE_2D,0,g(i.format),i.width,i.height,0,g(i.format),g(i.type),null);b.bindFramebuffer(b.FRAMEBUFFER,i.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,i.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,i.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
+null)}if(i){j=i.__webGLFramebuffer;p=i.width;k=i.height}else{j=null;p=h.width;k=h.height}if(j!=q){b.bindFramebuffer(b.FRAMEBUFFER,j);b.viewport(0,0,p,k);e&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);q=j}this.autoClear&&this.clear();j=f.__webGLObjects.length;for(e=0;e<j;e++){k=f.__webGLObjects[e];p=k.object;if(p.visible){p.autoUpdateMatrix&&p.updateMatrix();if(p.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);p.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(e=0;e<j;e++){k=f.__webGLObjects[e];
+p=k.object;k=k.buffer;if(p.visible){p.autoUpdateMatrix&&p.updateMatrix();this.setupMatrices(p,n);this.renderPass(n,w,o,p,k,THREE.NormalBlending,false)}}for(e=0;e<f.__webGLObjectsImmediate.length;e++){k=f.__webGLObjectsImmediate[e];p=k.object;if(p.visible){this.setupMatrices(p,n);this.renderPassImmediate(n,w,o,p,THREE.NormalBlending,false)}}for(e=0;e<j;e++){k=f.__webGLObjects[e];p=k.object;k=k.buffer;if(p.visible){this.setupMatrices(p,n);this.renderPass(n,w,o,p,k,THREE.AdditiveBlending,false);this.renderPass(n,
+w,o,p,k,THREE.SubtractiveBlending,false);this.renderPass(n,w,o,p,k,THREE.AdditiveBlending,true);this.renderPass(n,w,o,p,k,THREE.SubtractiveBlending,true);this.renderPass(n,w,o,p,k,THREE.NormalBlending,true);this.renderPass(n,w,o,p,k,THREE.BillboardBlending,false)}}if(i&&i.min_filter!==THREE.NearestFilter&&i.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,i.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(f,n){function i(D,
+E,I,L){if(D[E]==undefined){f.__webGLObjects.push({buffer:I,object:L});D[E]=1}}function e(D,E,I){if(D[E]==undefined){f.__webGLObjectsImmediate.push({object:I});D[E]=1}}var j,k,p,w,o,t,v;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}j=0;for(k=f.objects.length;j<k;j++){p=f.objects[j];o=p.geometry;if(f.__webGLObjectsMap[p.id]==undefined)f.__webGLObjectsMap[p.id]={};v=f.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh){for(w in o.geometryChunks){t=o.geometryChunks[w];
 if(!t.__webGLVertexBuffer){this.createMeshBuffers(t);this.initMeshBuffers(t,p);o.__dirtyVertices=true;o.__dirtyElements=true;o.__dirtyUvs=true;o.__dirtyNormals=true;o.__dirtyTangents=true}if(o.__dirtyVertices||o.__dirtyElements||o.__dirtyUvs)this.setMeshBuffers(t,p,b.DYNAMIC_DRAW);i(v,w,t,p)}o.__dirtyVertices=false;o.__dirtyElements=false;o.__dirtyUvs=false;o.__dirtyNormals=false;o.__dirtyTangents=false}else if(p instanceof THREE.Line){if(!o.__webGLVertexBuffer){this.createLineBuffers(o);this.initLineBuffers(o);
 o.__dirtyVertices=true;o.__dirtyElements=true}o.__dirtyVertices&&this.setLineBuffers(o,b.DYNAMIC_DRAW);i(v,0,o,p);o.__dirtyVertices=false;o.__dirtyElements=false}else if(p instanceof THREE.ParticleSystem){if(!o.__webGLVertexBuffer){this.createParticleBuffers(o);this.initParticleBuffers(o);o.__dirtyVertices=true;o.__dirtyColors=true;o.__dirtyElements=true}if(o.__dirtyVertices||o.__dirtyColors||p.sortParticles)this.setParticleBuffers(o,b.DYNAMIC_DRAW,p,n);i(v,0,o,p);o.__dirtyVertices=false;o.__dirtyColors=
-false;o.__dirtyElements=false}else p instanceof THREE.MarchingCubes&&e(v,0,p)}};this.removeObject=function(g,n){var i,e;for(i=g.__webGLObjects.length-1;i>=0;i--){e=g.__webGLObjects[i].object;n==e&&g.__webGLObjects.splice(i,1)}};this.setupMatrices=function(g,n){l.multiply(n.matrix,g.matrix);y.set(l.flatten());m=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(m.m);H.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,
-false,y);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,H)};this.loadCamera=function(g,n){b.uniform3f(g.uniforms.cameraPosition,n.position.x,n.position.y,n.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
-b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,n){if(g){!n||n=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK);else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+false;o.__dirtyElements=false}else p instanceof THREE.MarchingCubes&&e(v,0,p)}};this.removeObject=function(f,n){var i,e;for(i=f.__webGLObjects.length-1;i>=0;i--){e=f.__webGLObjects[i].object;n==e&&f.__webGLObjects.splice(i,1)}};this.setupMatrices=function(f,n){l.multiply(n.matrix,f.matrix);y.set(l.flatten());m=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(m.m);H.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,
+false,y);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,H)};this.loadCamera=function(f,n){b.uniform3f(f.uniforms.cameraPosition,n.position.x,n.position.y,n.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
+b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,n){if(f){!n||n=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
 envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",

+ 125 - 125
build/ThreeExtras.js

@@ -1,6 +1,6 @@
 // ThreeExtras.js r32 - 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,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,f,b,g,j,h;if(d==0)e=f=b=0;else{g=Math.floor(a*6);j=a*6-g;a=d*(1-c);h=d*(1-c*j);c=d*(1-c*(1-j));switch(g){case 1:e=h;f=d;b=a;break;case 2:e=a;f=d;b=c;break;case 3:e=a;f=h;b=d;break;case 4:e=c;f=a;b=d;break;case 5:e=d;f=a;b=h;break;case 6:case 0:e=d;f=c;b=a}}this.r=e;this.g=f;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},
+THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,f,b,h,j,g;if(d==0)e=f=b=0;else{h=Math.floor(a*6);j=a*6-h;a=d*(1-c);g=d*(1-c*j);c=d*(1-c*(1-j));switch(h){case 1:e=g;f=d;b=a;break;case 2:e=a;f=d;b=c;break;case 3:e=a;f=g;b=d;break;case 4:e=c;f=a;b=d;break;case 5:e=d;f=a;b=g;break;case 6:case 0:e=d;f=c;b=a}}this.r=e;this.g=f;this.b=b;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)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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*
@@ -13,47 +13,47 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,g){return b.distance-g.distance});return f},intersectObject:function(a){function c(G,w,H,p){p=p.clone().subSelf(w);H=H.clone().subSelf(w);var l=G.clone().subSelf(w);G=p.dot(p);w=p.dot(H);p=p.dot(l);var v=H.dot(H);H=H.dot(l);l=1/(G*v-w*w);v=(v*p-w*H)*l;G=(G*H-w*p)*l;return v>0&&G>0&&v+G<1}var d,e,f,b,g,j,h,m,n,y,
-u,o=a.geometry,A=o.vertices,C=[];d=0;for(e=o.faces.length;d<e;d++){f=o.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(A[f.a].position.clone());g=a.matrix.multiplyVector3(A[f.b].position.clone());j=a.matrix.multiplyVector3(A[f.c].position.clone());h=f instanceof THREE.Face4?a.matrix.multiplyVector3(A[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());n=u.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(b,y))/n;y=y.addSelf(u.multiplyScalar(m));
-if(f instanceof THREE.Face3){if(c(y,b,g,j)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};C.push(f)}}else if(f instanceof THREE.Face4)if(c(y,b,g,h)||c(y,g,j,h)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};C.push(f)}}}return C}};
-THREE.Rectangle=function(){function a(){b=e-c;g=f-d}var c,d,e,f,b,g,j=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return g};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(h,m,n,y){j=false;c=h;d=m;e=n;f=y;a()};this.addPoint=function(h,m){if(j){j=false;c=h;d=m;e=h;f=m}else{c=c<h?c:h;d=d<m?d:m;e=e>h?e:h;f=f>m?
-f:m}a()};this.add3Points=function(h,m,n,y,u,o){if(j){j=false;c=h<n?h<u?h:u:n<u?n:u;d=m<y?m<o?m:o:y<o?y:o;e=h>n?h>u?h:u:n>u?n:u;f=m>y?m>o?m:o:y>o?y:o}else{c=h<n?h<u?h<c?h:c:u<c?u:c:n<u?n<c?n:c:u<c?u:c;d=m<y?m<o?m<d?m:d:o<d?o:d:y<o?y<d?y:d:o<d?o:d;e=h>n?h>u?h>e?h:e:u>e?u:e:n>u?n>e?n:e:u>e?u:e;f=m>y?m>o?m>f?m:f:o>f?o:f:y>o?y>f?y:f:o>f?o:f}a()};this.addRectangle=function(h){if(j){j=false;c=h.getLeft();d=h.getTop();e=h.getRight();f=h.getBottom()}else{c=c<h.getLeft()?c:h.getLeft();d=d<h.getTop()?d:h.getTop();
-e=e>h.getRight()?e:h.getRight();f=f>h.getBottom()?f:h.getBottom()}a()};this.inflate=function(h){c-=h;d-=h;e+=h;f+=h;a()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();e=e<h.getRight()?e:h.getRight();f=f<h.getBottom()?f:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(c,h.getLeft())>=0&&Math.min(f,h.getBottom())-Math.max(d,h.getTop())>=0};this.empty=function(){j=true;f=e=d=c=0;a()};this.isEmpty=function(){return j};this.toString=
-function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+g+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,e,f,b,g,j,h,m,n,y,u,o,A,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=g||0;this.n24=j||0;this.n31=h||0;this.n32=m||0;this.n33=n||1;this.n34=y||0;this.n41=u||0;this.n42=o||0;this.n43=A||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-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,c,d,e,f,b,g,j,h,m,n,y,u,o,A,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=g;this.n24=j;this.n31=h;this.n32=m;this.n33=n;this.n34=y;this.n41=u;this.n42=o;this.n43=A;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,h){return b.distance-h.distance});return f},intersectObject:function(a){function c(G,w,H,p){p=p.clone().subSelf(w);H=H.clone().subSelf(w);var l=G.clone().subSelf(w);G=p.dot(p);w=p.dot(H);p=p.dot(l);var v=H.dot(H);H=H.dot(l);l=1/(G*v-w*w);v=(v*p-w*H)*l;G=(G*H-w*p)*l;return v>0&&G>0&&v+G<1}var d,e,f,b,h,j,g,m,n,y,
+u,o=a.geometry,A=o.vertices,C=[];d=0;for(e=o.faces.length;d<e;d++){f=o.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(A[f.a].position.clone());h=a.matrix.multiplyVector3(A[f.b].position.clone());j=a.matrix.multiplyVector3(A[f.c].position.clone());g=f instanceof THREE.Face4?a.matrix.multiplyVector3(A[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());n=u.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(b,y))/n;y=y.addSelf(u.multiplyScalar(m));
+if(f instanceof THREE.Face3){if(c(y,b,h,j)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};C.push(f)}}else if(f instanceof THREE.Face4)if(c(y,b,h,g)||c(y,h,j,g)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};C.push(f)}}}return C}};
+THREE.Rectangle=function(){function a(){b=e-c;h=f-d}var c,d,e,f,b,h,j=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,m,n,y){j=false;c=g;d=m;e=n;f=y;a()};this.addPoint=function(g,m){if(j){j=false;c=g;d=m;e=g;f=m}else{c=c<g?c:g;d=d<m?d:m;e=e>g?e:g;f=f>m?
+f:m}a()};this.add3Points=function(g,m,n,y,u,o){if(j){j=false;c=g<n?g<u?g:u:n<u?n:u;d=m<y?m<o?m:o:y<o?y:o;e=g>n?g>u?g:u:n>u?n:u;f=m>y?m>o?m:o:y>o?y:o}else{c=g<n?g<u?g<c?g:c:u<c?u:c:n<u?n<c?n:c:u<c?u:c;d=m<y?m<o?m<d?m:d:o<d?o:d:y<o?y<d?y:d:o<d?o:d;e=g>n?g>u?g>e?g:e:u>e?u:e:n>u?n>e?n:e:u>e?u:e;f=m>y?m>o?m>f?m:f:o>f?o:f:y>o?y>f?y:f:o>f?o:f}a()};this.addRectangle=function(g){if(j){j=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=c<g.getLeft()?c:g.getLeft();d=d<g.getTop()?d:g.getTop();
+e=e>g.getRight()?e:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;a()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e<g.getRight()?e:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(e,g.getRight())-Math.max(c,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(d,g.getTop())>=0};this.empty=function(){j=true;f=e=d=c=0;a()};this.isEmpty=function(){return j};this.toString=
+function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
+THREE.Matrix4=function(a,c,d,e,f,b,h,j,g,m,n,y,u,o,A,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=h||0;this.n24=j||0;this.n31=g||0;this.n32=m||0;this.n33=n||1;this.n34=y||0;this.n41=u||0;this.n42=o||0;this.n43=A||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+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,c,d,e,f,b,h,j,g,m,n,y,u,o,A,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=h;this.n24=j;this.n31=g;this.n32=m;this.n33=n;this.n34=y;this.n41=u;this.n42=o;this.n43=A;this.n44=C;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,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();f.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
 this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*
-e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,f=a.n13,b=a.n14,g=a.n21,j=a.n22,h=a.n23,m=a.n24,n=a.n31,
-y=a.n32,u=a.n33,o=a.n34,A=a.n41,C=a.n42,G=a.n43,w=a.n44,H=c.n11,p=c.n12,l=c.n13,v=c.n14,t=c.n21,k=c.n22,q=c.n23,x=c.n24,z=c.n31,F=c.n32,B=c.n33,D=c.n34,I=c.n41,N=c.n42,O=c.n43,Q=c.n44;this.n11=d*H+e*t+f*z+b*I;this.n12=d*p+e*k+f*F+b*N;this.n13=d*l+e*q+f*B+b*O;this.n14=d*v+e*x+f*D+b*Q;this.n21=g*H+j*t+h*z+m*I;this.n22=g*p+j*k+h*F+m*N;this.n23=g*l+j*q+h*B+m*O;this.n24=g*v+j*x+h*D+m*Q;this.n31=n*H+y*t+u*z+o*I;this.n32=n*p+y*k+u*F+o*N;this.n33=n*l+y*q+u*B+o*O;this.n34=n*v+y*x+u*D+o*Q;this.n41=A*H+C*t+
-G*z+w*I;this.n42=A*p+C*k+G*F+w*N;this.n43=A*l+C*q+G*B+w*O;this.n44=A*v+C*x+G*D+w*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,g=this.n22,j=this.n23,h=this.n24,m=this.n31,n=this.n32,y=this.n33,u=this.n34,o=this.n41,A=this.n42,C=this.n43,G=this.n44,w=a.n11,H=a.n21,p=a.n31,l=a.n41,v=a.n12,t=a.n22,k=a.n32,q=a.n42,x=a.n13,z=a.n23,F=a.n33,B=a.n43,D=a.n14,I=a.n24,N=a.n34;a=a.n44;this.n11=c*w+d*H+e*p+f*l;this.n12=c*v+d*t+e*k+f*q;this.n13=c*x+d*z+e*F+f*
-B;this.n14=c*D+d*I+e*N+f*a;this.n21=b*w+g*H+j*p+h*l;this.n22=b*v+g*t+j*k+h*q;this.n23=b*x+g*z+j*F+h*B;this.n24=b*D+g*I+j*N+h*a;this.n31=m*w+n*H+y*p+u*l;this.n32=m*v+n*t+y*k+u*q;this.n33=m*x+n*z+y*F+u*B;this.n34=m*D+n*I+y*N+u*a;this.n41=o*w+A*H+C*p+G*l;this.n42=o*v+A*t+C*k+G*q;this.n43=o*x+A*z+C*F+G*B;this.n44=o*D+A*I+C*N+G*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(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,g=this.n23,j=this.n24,h=this.n31,m=this.n32,n=this.n33,y=this.n34,u=this.n41,o=this.n42,A=this.n43,C=this.n44;return e*g*m*u-d*j*m*u-e*b*n*u+c*j*n*u+d*b*y*u-c*g*y*u-e*g*h*o+d*j*h*o+e*f*n*o-a*j*n*o-d*f*y*o+a*g*y*o+e*b*h*A-c*j*h*A-e*f*m*A+a*j*m*A+c*f*y*A-a*b*y*A-d*b*h*C+c*g*h*C+d*f*m*C-a*g*m*C-c*f*n*C+a*b*n*C},transpose:function(){function a(c,d,
+e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,f=a.n13,b=a.n14,h=a.n21,j=a.n22,g=a.n23,m=a.n24,n=a.n31,
+y=a.n32,u=a.n33,o=a.n34,A=a.n41,C=a.n42,G=a.n43,w=a.n44,H=c.n11,p=c.n12,l=c.n13,v=c.n14,t=c.n21,k=c.n22,q=c.n23,x=c.n24,z=c.n31,F=c.n32,B=c.n33,D=c.n34,I=c.n41,N=c.n42,O=c.n43,Q=c.n44;this.n11=d*H+e*t+f*z+b*I;this.n12=d*p+e*k+f*F+b*N;this.n13=d*l+e*q+f*B+b*O;this.n14=d*v+e*x+f*D+b*Q;this.n21=h*H+j*t+g*z+m*I;this.n22=h*p+j*k+g*F+m*N;this.n23=h*l+j*q+g*B+m*O;this.n24=h*v+j*x+g*D+m*Q;this.n31=n*H+y*t+u*z+o*I;this.n32=n*p+y*k+u*F+o*N;this.n33=n*l+y*q+u*B+o*O;this.n34=n*v+y*x+u*D+o*Q;this.n41=A*H+C*t+
+G*z+w*I;this.n42=A*p+C*k+G*F+w*N;this.n43=A*l+C*q+G*B+w*O;this.n44=A*v+C*x+G*D+w*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,h=this.n22,j=this.n23,g=this.n24,m=this.n31,n=this.n32,y=this.n33,u=this.n34,o=this.n41,A=this.n42,C=this.n43,G=this.n44,w=a.n11,H=a.n21,p=a.n31,l=a.n41,v=a.n12,t=a.n22,k=a.n32,q=a.n42,x=a.n13,z=a.n23,F=a.n33,B=a.n43,D=a.n14,I=a.n24,N=a.n34;a=a.n44;this.n11=c*w+d*H+e*p+f*l;this.n12=c*v+d*t+e*k+f*q;this.n13=c*x+d*z+e*F+f*
+B;this.n14=c*D+d*I+e*N+f*a;this.n21=b*w+h*H+j*p+g*l;this.n22=b*v+h*t+j*k+g*q;this.n23=b*x+h*z+j*F+g*B;this.n24=b*D+h*I+j*N+g*a;this.n31=m*w+n*H+y*p+u*l;this.n32=m*v+n*t+y*k+u*q;this.n33=m*x+n*z+y*F+u*B;this.n34=m*D+n*I+y*N+u*a;this.n41=o*w+A*H+C*p+G*l;this.n42=o*v+A*t+C*k+G*q;this.n43=o*x+A*z+C*F+G*B;this.n44=o*D+A*I+C*N+G*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(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,h=this.n23,j=this.n24,g=this.n31,m=this.n32,n=this.n33,y=this.n34,u=this.n41,o=this.n42,A=this.n43,C=this.n44;return e*h*m*u-d*j*m*u-e*b*n*u+c*j*n*u+d*b*y*u-c*h*y*u-e*h*g*o+d*j*g*o+e*f*n*o-a*j*n*o-d*f*y*o+a*h*y*o+e*b*g*A-c*j*g*A-e*f*m*A+a*j*m*A+c*f*y*A-a*b*y*A-d*b*g*C+c*h*g*C+d*f*m*C-a*h*m*C-c*f*n*C+a*b*n*C},transpose:function(){function a(c,d,
 e){var f=c[d];c[d]=c[e];c[e]=f}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(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
-Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,g=a.y,j=a.z,h=f*b,m=f*g;this.set(h*b+d,h*g-e*j,h*j+e*g,0,h*g+e*j,m*g+d,m*j-e*b,0,h*j-e*g,m*j+e*b,f*j*j+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
+Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,h=a.y,j=a.z,g=f*b,m=f*h;this.set(g*b+d,g*h-e*j,g*j+e*h,0,g*h+e*j,m*h+d,m*j-e*b,0,g*j-e*h,m*j+e*b,f*j*j+d,0,0,0,0,1);return this},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,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,g=a.n22,j=a.n23,h=a.n24,m=a.n31,n=a.n32,y=a.n33,u=a.n34,o=a.n41,A=a.n42,C=a.n43,G=a.n44,w=new THREE.Matrix4;w.n11=j*u*A-h*y*A+h*n*C-g*u*C-j*n*G+g*y*G;w.n12=f*y*A-e*u*A-f*n*C+d*u*C+e*n*G-d*y*G;w.n13=e*h*A-f*j*A+f*g*C-d*h*C-e*g*G+d*j*G;w.n14=f*j*n-e*h*n-f*g*y+d*h*y+e*g*u-d*j*u;w.n21=h*y*o-j*u*o-h*m*C+b*u*C+j*m*G-b*y*G;w.n22=e*u*o-f*y*o+f*m*C-c*u*C-e*m*G+c*y*G;w.n23=f*j*o-e*h*o-f*b*C+c*h*C+e*b*G-c*j*G;w.n24=e*h*m-f*j*m+
-f*b*y-c*h*y-e*b*u+c*j*u;w.n31=g*u*o-h*n*o+h*m*A-b*u*A-g*m*G+b*n*G;w.n32=f*n*o-d*u*o-f*m*A+c*u*A+d*m*G-c*n*G;w.n33=e*h*o-f*g*o+f*b*A-c*h*A-d*b*G+c*g*G;w.n34=f*g*m-d*h*m-f*b*n+c*h*n+d*b*u-c*g*u;w.n41=j*n*o-g*y*o-j*m*A+b*y*A+g*m*C-b*n*C;w.n42=d*y*o-e*n*o+e*m*A-c*y*A-d*m*C+c*n*C;w.n43=e*g*o-d*j*o-e*b*A+c*j*A+d*b*C-c*g*C;w.n44=d*j*m-e*g*m+e*b*n-c*j*n-d*b*y+c*g*y;w.multiplyScalar(1/a.determinant());return w};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],g=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],h=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],n=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*g+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*g;d[4]=c*j;d[5]=c*h;d[6]=c*m;d[7]=c*n;d[8]=c*y;return a};
-THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var g,j,h;g=new THREE.Matrix4;j=2*f/(c-a);h=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);g.n11=j;g.n12=0;g.n13=a;g.n14=0;g.n21=0;g.n22=h;g.n23=d;g.n24=0;g.n31=0;g.n32=0;g.n33=e;g.n34=f;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var g,j,h,m;g=new THREE.Matrix4;j=c-a;h=d-e;m=b-f;a=(c+a)/j;d=(d+e)/h;f=(b+f)/m;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-a;g.n21=0;g.n22=2/h;g.n23=0;g.n24=-d;g.n31=0;g.n32=0;g.n33=-2/m;g.n34=-f;g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,h=a.n22,j=a.n23,g=a.n24,m=a.n31,n=a.n32,y=a.n33,u=a.n34,o=a.n41,A=a.n42,C=a.n43,G=a.n44,w=new THREE.Matrix4;w.n11=j*u*A-g*y*A+g*n*C-h*u*C-j*n*G+h*y*G;w.n12=f*y*A-e*u*A-f*n*C+d*u*C+e*n*G-d*y*G;w.n13=e*g*A-f*j*A+f*h*C-d*g*C-e*h*G+d*j*G;w.n14=f*j*n-e*g*n-f*h*y+d*g*y+e*h*u-d*j*u;w.n21=g*y*o-j*u*o-g*m*C+b*u*C+j*m*G-b*y*G;w.n22=e*u*o-f*y*o+f*m*C-c*u*C-e*m*G+c*y*G;w.n23=f*j*o-e*g*o-f*b*C+c*g*C+e*b*G-c*j*G;w.n24=e*g*m-f*j*m+
+f*b*y-c*g*y-e*b*u+c*j*u;w.n31=h*u*o-g*n*o+g*m*A-b*u*A-h*m*G+b*n*G;w.n32=f*n*o-d*u*o-f*m*A+c*u*A+d*m*G-c*n*G;w.n33=e*g*o-f*h*o+f*b*A-c*g*A-d*b*G+c*h*G;w.n34=f*h*m-d*g*m-f*b*n+c*g*n+d*b*u-c*h*u;w.n41=j*n*o-h*y*o-j*m*A+b*y*A+h*m*C-b*n*C;w.n42=d*y*o-e*n*o+e*m*A-c*y*A-d*m*C+c*n*C;w.n43=e*h*o-d*j*o-e*b*A+c*j*A+d*b*C-c*h*C;w.n44=d*j*m-e*h*m+e*b*n-c*j*n-d*b*y+c*h*y;w.multiplyScalar(1/a.determinant());return w};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],h=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],n=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*h+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*h;d[4]=c*j;d[5]=c*g;d[6]=c*m;d[7]=c*n;d[8]=c*y;return a};
+THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var h,j,g;h=new THREE.Matrix4;j=2*f/(c-a);g=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);h.n11=j;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=g;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=f;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
+THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var h,j,g,m;h=new THREE.Matrix4;j=c-a;g=d-e;m=b-f;a=(c+a)/j;d=(d+e)/g;f=(b+f)/m;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/g;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-f;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||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,c,d,e,f){this.a=a;this.b=c;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.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,c,d,e,f,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;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 c,d,e,f,b,g,j=new THREE.Vector3,h=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){j.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)j.addSelf(b.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];g=this.vertices[b.c];j.sub(g.position,
-d.position);h.sub(c.position,d.position);j.crossSelf(h)}j.isZero()||j.normalize();b.normal.copy(j)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,f,b,h,j=new THREE.Vector3,g=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){j.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)j.addSelf(b.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];h=this.vertices[b.c];j.sub(h.position,
+d.position);g.sub(c.position,d.position);j.crossSelf(g)}j.isZero()||j.normalize();b.normal.copy(j)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,N,O,Q,T,U){b=D.vertices[I].position;g=D.vertices[N].position;j=D.vertices[O].position;h=f[Q];m=f[T];n=f[U];y=g.x-b.x;u=j.x-b.x;o=g.y-b.y;A=j.y-b.y;
-C=g.z-b.z;G=j.z-b.z;w=m.u-h.u;H=n.u-h.u;p=m.v-h.v;l=n.v-h.v;v=1/(w*l-H*p);q.set((l*y-p*u)*v,(l*o-p*A)*v,(l*C-p*G)*v);x.set((w*u-H*y)*v,(w*A-H*o)*v,(w*G-H*C)*v);t[I].addSelf(q);t[N].addSelf(q);t[O].addSelf(q);k[I].addSelf(x);k[N].addSelf(x);k[O].addSelf(x)}var c,d,e,f,b,g,j,h,m,n,y,u,o,A,C,G,w,H,p,l,v,t=[],k=[],q=new THREE.Vector3,x=new THREE.Vector3,z=new THREE.Vector3,F=new THREE.Vector3,B=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){t[c]=new THREE.Vector3;k[c]=new THREE.Vector3}c=0;
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,N,O,Q,T,U){b=D.vertices[I].position;h=D.vertices[N].position;j=D.vertices[O].position;g=f[Q];m=f[T];n=f[U];y=h.x-b.x;u=j.x-b.x;o=h.y-b.y;A=j.y-b.y;
+C=h.z-b.z;G=j.z-b.z;w=m.u-g.u;H=n.u-g.u;p=m.v-g.v;l=n.v-g.v;v=1/(w*l-H*p);q.set((l*y-p*u)*v,(l*o-p*A)*v,(l*C-p*G)*v);x.set((w*u-H*y)*v,(w*A-H*o)*v,(w*G-H*C)*v);t[I].addSelf(q);t[N].addSelf(q);t[O].addSelf(q);k[I].addSelf(x);k[N].addSelf(x);k[O].addSelf(x)}var c,d,e,f,b,h,j,g,m,n,y,u,o,A,C,G,w,H,p,l,v,t=[],k=[],q=new THREE.Vector3,x=new THREE.Vector3,z=new THREE.Vector3,F=new THREE.Vector3,B=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){t[c]=new THREE.Vector3;k[c]=new THREE.Vector3}c=0;
 for(d=this.faces.length;c<d;c++){e=this.faces[c];f=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);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,0,1,2);a(this,e.a,e.b,e.d,0,1,3);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])}}c=0;for(d=this.vertices.length;c<d;c++){B.copy(this.vertices[c].normal);e=t[c];z.copy(e);z.subSelf(B.multiplyScalar(B.dot(e))).normalize();F.cross(this.vertices[c].normal,e);e=F.dot(k[c]);e=e<0?-1:1;this.vertices[c].tangent.set(z.x,z.y,z.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={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 c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var y=[];c=0;for(d=n.length;c<d;c++)n[c]==undefined?y.push("undefined"):y.push(n[c].toString());return y.join("_")}var c,d,e,f,b,g,j,h,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
-g=b.materials;j=a(g);if(m[j]==undefined)m[j]={hash:j,counter:0};h=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:g,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[h].vertices+b>65535){m[j].counter+=1;h=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:g,vertices:0}}this.geometryChunks[h].faces.push(e);this.geometryChunks[h].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var y=[];c=0;for(d=n.length;c<d;c++)n[c]==undefined?y.push("undefined"):y.push(n[c].toString());return y.join("_")}var c,d,e,f,b,h,j,g,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
+h=b.materials;j=a(h);if(m[j]==undefined)m[j]={hash:j,counter:0};g=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:h,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+b>65535){m[j].counter+=1;g=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:h,vertices:0}}this.geometryChunks[g].faces.push(e);this.geometryChunks[g].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
@@ -98,47 +98,47 @@ var Uniforms={clone:function(a){var c,d,e,f={};for(c in a){f[c]={};for(d in a[c]
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(k,q){return q.z-k.z}function c(k,q){var x=0,z=1,F=k.z+k.w,B=q.z+q.w,D=-k.z+k.w,I=-q.z+q.w;if(F>=0&&B>=0&&D>=0&&I>=0)return true;else if(F<0&&B<0||D<0&&I<0)return false;else{if(F<0)x=Math.max(x,F/(F-B));else if(B<0)z=Math.min(z,F/(F-B));if(D<0)x=Math.max(x,D/(D-I));else if(I<0)z=Math.min(z,D/(D-I));if(z<x)return false;else{k.lerpSelf(q,x);q.lerpSelf(k,1-z);return true}}}var d,e,f=[],b,g,j,h=[],m,n,y=[],u,o,A=[],C=new THREE.Vector4,G=new THREE.Vector4,w=new THREE.Matrix4,
+THREE.Projector=function(){function a(k,q){return q.z-k.z}function c(k,q){var x=0,z=1,F=k.z+k.w,B=q.z+q.w,D=-k.z+k.w,I=-q.z+q.w;if(F>=0&&B>=0&&D>=0&&I>=0)return true;else if(F<0&&B<0||D<0&&I<0)return false;else{if(F<0)x=Math.max(x,F/(F-B));else if(B<0)z=Math.min(z,F/(F-B));if(D<0)x=Math.max(x,D/(D-I));else if(I<0)z=Math.min(z,D/(D-I));if(z<x)return false;else{k.lerpSelf(q,x);q.lerpSelf(k,1-z);return true}}}var d,e,f=[],b,h,j,g=[],m,n,y=[],u,o,A=[],C=new THREE.Vector4,G=new THREE.Vector4,w=new THREE.Matrix4,
 H=new THREE.Matrix4,p=[],l=new THREE.Vector4,v=new THREE.Vector4,t;this.projectObjects=function(k,q,x){var z=[],F,B;e=0;w.multiply(q.projectionMatrix,q.matrix);p[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);p[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);p[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);p[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);p[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
 w.n33,w.n44-w.n34);p[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);q=0;for(F=p.length;q<F;q++){B=p[q];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}F=k.objects;k=0;for(q=F.length;k<q;k++){B=F[k];var D;if(!(D=!B.visible)){if(D=B instanceof THREE.Mesh){a:{D=void 0;for(var I=B.position,N=-B.geometry.boundingSphere.radius*Math.max(B.scale.x,Math.max(B.scale.y,B.scale.z)),O=0;O<6;O++){D=p[O].x*I.x+p[O].y*I.y+p[O].z*I.z+p[O].w;if(D<=N){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
 f[e]=f[e]||new THREE.RenderableObject;C.copy(B.position);w.multiplyVector3(C);d.object=B;d.z=C.z;z.push(d);e++}}x&&z.sort(a);return z};this.projectScene=function(k,q,x){var z=[],F=q.near,B=q.far,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$;j=n=o=0;q.autoUpdateMatrix&&q.updateMatrix();w.multiply(q.projectionMatrix,q.matrix);T=this.projectObjects(k,q,true);k=0;for(D=T.length;k<D;k++){U=T[k].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ba=U.matrix;ca=U.rotationMatrix;S=U.materials;K=U.overdraw;if(U instanceof
 THREE.Mesh){Z=U.geometry;V=Z.vertices;I=0;for(N=V.length;I<N;I++){P=V[I];P.positionWorld.copy(P.position);ba.multiplyVector3(P.positionWorld);O=P.positionScreen;O.copy(P.positionWorld);w.multiplyVector4(O);O.x/=O.w;O.y/=O.w;P.__visible=O.z>F&&O.z<B}Z=Z.faces;I=0;for(N=Z.length;I<N;I++){P=Z[I];if(P instanceof THREE.Face3){O=V[P.a];Q=V[P.b];W=V[P.c];if(O.__visible&&Q.__visible&&W.__visible)if(U.doubleSided||U.flipSided!=(W.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-
-(W.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0){b=h[j]=h[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);
+(W.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0){b=g[j]=g[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);
 b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);W=P.vertexNormals;t=b.vertexNormalsWorld;O=0;for(Q=W.length;O<Q;O++){$=t[O]=t[O]||new THREE.Vector3;$.copy(W[O]);ca.multiplyVector3($)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][2]}z.push(b);j++}}else if(P instanceof THREE.Face4){O=V[P.a];Q=V[P.b];W=V[P.c];$=V[P.d];if(O.__visible&&
-Q.__visible&&W.__visible&&$.__visible)if(U.doubleSided||U.flipSided!=(($.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-($.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*($.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*($.positionScreen.x-W.positionScreen.x)<0)){b=h[j]=h[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);
+Q.__visible&&W.__visible&&$.__visible)if(U.doubleSided||U.flipSided!=(($.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-($.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*($.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*($.positionScreen.x-W.positionScreen.x)<0)){b=g[j]=g[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);
 b.v3.positionWorld.copy($.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy($.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];
-b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][3]}z.push(b);j++;g=h[j]=h[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Q.positionWorld);g.v2.positionWorld.copy(W.positionWorld);g.v3.positionWorld.copy($.positionWorld);g.v1.positionScreen.copy(Q.positionScreen);g.v2.positionScreen.copy(W.positionScreen);g.v3.positionScreen.copy($.positionScreen);g.normalWorld.copy(b.normalWorld);g.centroidWorld.copy(b.centroidWorld);g.centroidScreen.copy(b.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=
-S;g.faceMaterials=P.materials;g.overdraw=K;if(U.geometry.uvs[I]){g.uvs[0]=U.geometry.uvs[I][1];g.uvs[1]=U.geometry.uvs[I][2];g.uvs[2]=U.geometry.uvs[I][3]}z.push(g);j++}}}}else if(U instanceof THREE.Line){H.multiply(w,ba);V=U.geometry.vertices;P=V[0];P.positionScreen.copy(P.position);H.multiplyVector4(P.positionScreen);I=1;for(N=V.length;I<N;I++){O=V[I];O.positionScreen.copy(O.position);H.multiplyVector4(O.positionScreen);Q=V[I-1];l.copy(O.positionScreen);v.copy(Q.positionScreen);if(c(l,v)){l.multiplyScalar(1/
+b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][3]}z.push(b);j++;h=g[j]=g[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(W.positionWorld);h.v3.positionWorld.copy($.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(W.positionScreen);h.v3.positionScreen.copy($.positionScreen);h.normalWorld.copy(b.normalWorld);h.centroidWorld.copy(b.centroidWorld);h.centroidScreen.copy(b.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=
+S;h.faceMaterials=P.materials;h.overdraw=K;if(U.geometry.uvs[I]){h.uvs[0]=U.geometry.uvs[I][1];h.uvs[1]=U.geometry.uvs[I][2];h.uvs[2]=U.geometry.uvs[I][3]}z.push(h);j++}}}}else if(U instanceof THREE.Line){H.multiply(w,ba);V=U.geometry.vertices;P=V[0];P.positionScreen.copy(P.position);H.multiplyVector4(P.positionScreen);I=1;for(N=V.length;I<N;I++){O=V[I];O.positionScreen.copy(O.position);H.multiplyVector4(O.positionScreen);Q=V[I-1];l.copy(O.positionScreen);v.copy(Q.positionScreen);if(c(l,v)){l.multiplyScalar(1/
 l.w);v.multiplyScalar(1/v.w);m=y[n]=y[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(l);m.v2.positionScreen.copy(v);m.z=Math.max(l.z,v.z);m.materials=U.materials;z.push(m);n++}}}else if(U instanceof THREE.Particle){G.set(U.position.x,U.position.y,U.position.z,1);w.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){u=A[o]=A[o]||new THREE.RenderableParticle;u.x=G.x/G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=U.rotation.z;u.scale.x=U.scale.x*Math.abs(u.x-(G.x+q.projectionMatrix.n11)/(G.w+q.projectionMatrix.n14));
 u.scale.y=U.scale.y*Math.abs(u.y-(G.y+q.projectionMatrix.n22)/(G.w+q.projectionMatrix.n24));u.materials=U.materials;z.push(u);o++}}}}x&&z.sort(a);return z};this.unprojectVector=function(k,q){var x=THREE.Matrix4.makeInvert(q.matrix);x.multiplySelf(THREE.Matrix4.makeInvert(q.projectionMatrix));x.multiplyVector3(k);return k}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(g,j){d=g;e=j;f=d/2;b=e/2};this.render=function(g,j){var h,m,n,y,u,o,A,C;a=c.projectScene(g,j);h=0;for(m=a.length;h<m;h++){u=a[h];if(u instanceof THREE.RenderableParticle){A=u.x*f+f;C=u.y*b+b;n=0;for(y=u.material.length;n<y;n++){o=u.material[n];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=A+"px";o.style.top=C+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ma){if(u!=ma)m.globalAlpha=u=ma}function c(ma){if(o!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}o=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,g,j,h,m=f.getContext("2d"),n=new THREE.Color(0),y=0,u=1,o=0,A=null,C=null,G=1,w,H,p,l,v,t,k,q,x,z=new THREE.Color,
-F=new THREE.Color,B=new THREE.Color,D=new THREE.Color,I=new THREE.Color,N,O,Q,T,U,ba,ca,S,K,Z=new THREE.Rectangle,V=new THREE.Rectangle,P=new THREE.Rectangle,W=false,$=new THREE.Color,da=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,X,ea,ja,ia,qa,la,ua=16;X=document.createElement("canvas");X.width=X.height=2;ea=X.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);ja=ea.getImageData(0,0,2,2);ia=ja.data;qa=document.createElement("canvas");qa.width=
-qa.height=ua;la=qa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;g=sa;j=b/2;h=g/2;f.width=b;f.height=g;Z.set(-j,-h,j,h);u=1;o=0;C=A=null;G=1};this.setClearColor=function(ma,sa){n.setHex(ma);y=sa;V.set(-j,-h,j,h);m.setTransform(1,0,0,-1,j,h);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,j,h);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(n.hex==0&&y==0)m.clearRect(V.getX(),
-V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+y+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ma,sa){function Ha(M){var fa,aa,R,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];R=aa.color;if(aa instanceof THREE.AmbientLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
-R.r;ha.g+=R.g;ha.b+=R.b}else if(aa instanceof THREE.PointLight){E.r+=R.r;E.g+=R.g;E.b+=R.b}}}function Da(M,fa,aa,R){var Y,ga,na,oa,pa=M.lights;M=0;for(Y=pa.length;M<Y;M++){ga=pa[M];na=ga.color;oa=ga.intensity;if(ga instanceof THREE.DirectionalLight){ga=aa.dot(ga.position)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}else if(ga instanceof THREE.PointLight){J.sub(ga.position,fa);J.normalize();ga=aa.dot(J)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}}}function Qa(M,fa,aa){if(aa.opacity!=
-0){a(aa.opacity);c(aa.blending);var R,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*j;ga=fa.scale.y*h;aa=Y*oa;R=ga*pa;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(W){$.r=da.r+ha.r+E.r;$.g=da.g+ha.g+E.g;$.b=da.b+
-ha.b+E.b;z.r=aa.color.r*$.r;z.g=aa.color.g*$.g;z.b=aa.color.b*$.b;z.updateStyleString()}else z.__styleString=aa.color.__styleString;aa=fa.scale.x*j;R=fa.scale.y*h;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){Y=z.__styleString;if(C!=Y)m.fillStyle=C=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(M.positionScreen.x,
-M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){z.__styleString=R.color.__styleString;M=R.linewidth;if(G!=M)m.lineWidth=G=M;M=z.__styleString;if(A!=M)m.strokeStyle=A=M;m.stroke();P.inflate(R.linewidth*2)}}}function Ma(M,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;v=M.positionScreen.y;t=fa.positionScreen.x;k=fa.positionScreen.y;q=aa.positionScreen.x;x=aa.positionScreen.y;m.beginPath();m.moveTo(l,
-v);m.lineTo(t,k);m.lineTo(q,x);m.lineTo(l,v);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(l,v,t,k,q,x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(R.vertexNormalsWorld[0]);T=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;U=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;
-J.copy(R.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(l,v,t,k,q,x,Y.env_map.image,T,U,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(l,v,t,k,q,
-x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){F.r=B.r=D.r=da.r;F.g=B.g=D.g=da.g;F.b=B.b=D.b=da.b;Da(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],F);Da(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],B);Da(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],D);I.r=(B.r+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,v,t,k,q,x,Q,0,0,1,0,0,1)}else{$.r=
-da.r;$.g=da.g;$.b=da.b;Da(ga,R.centroidWorld,R.normalWorld,$);z.r=Y.color.r*$.r;z.g=Y.color.g*$.g;z.b=Y.color.b*$.b;z.updateStyleString();Y.wireframe?Ea(z.__styleString,Y.wireframe_linewidth):Fa(z.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){N=sa.near;O=sa.far;F.r=F.g=F.b=1-Ia(M.positionScreen.z,N,O);B.r=B.g=B.b=1-Ia(fa.positionScreen.z,N,O);D.r=D.g=D.b=1-Ia(aa.positionScreen.z,N,O);I.r=(B.r+
-D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,v,t,k,q,x,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){z.r=Ja(R.normalWorld.x);z.g=Ja(R.normalWorld.y);z.b=Ja(R.normalWorld.z);z.updateStyleString();Y.wireframe?Ea(z.__styleString,Y.wireframe_linewidth):Fa(z.__styleString)}}}function Ea(M,fa){if(A!=M)m.strokeStyle=A=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();P.inflate(fa*2)}function Fa(M){if(C!=M)m.fillStyle=C=M;m.fill()}function Aa(M,fa,aa,R,Y,ga,na,oa,pa,va,ra,wa,Ba){var ya,
-xa;ya=na.width-1;xa=na.height-1;oa*=ya;pa*=xa;va*=ya;ra*=xa;wa*=ya;Ba*=xa;aa-=M;R-=fa;Y-=M;ga-=fa;va-=oa;ra-=pa;wa-=oa;Ba-=pa;xa=1/(va*Ba-wa*ra);ya=(Ba*aa-ra*Y)*xa;ra=(Ba*R-ra*ga)*xa;aa=(va*Y-wa*aa)*xa;R=(va*ga-wa*R)*xa;M=M-ya*oa-aa*pa;fa=fa-ra*oa-R*pa;m.save();m.transform(ya,ra,aa,R,M,fa);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,fa,aa,R){var Y=~~(M.r*255),ga=~~(M.g*255);M=~~(M.b*255);var na=~~(fa.r*255),oa=~~(fa.g*255);fa=~~(fa.b*255);var pa=~~(aa.r*255),va=~~(aa.g*255);aa=~~(aa.b*
-255);var ra=~~(R.r*255),wa=~~(R.g*255);R=~~(R.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=ga<0?0:ga>255?255:ga;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=fa<0?0:fa>255?255:fa;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=va<0?0:va>255?255:va;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=ra<0?0:ra>255?255:ra;ia[13]=wa<0?0:wa>255?255:wa;ia[14]=R<0?0:R>255?255:R;ea.putImageData(ja,0,0);la.drawImage(X,0,0);return qa}function Ia(M,fa,aa){M=(M-fa)/(aa-fa);return M*M*(3-2*M)}function Ja(M){M=(M+
-1)*0.5;return M<0?0:M>1?1:M}function Ka(M,fa){var aa=fa.x-M.x,R=fa.y-M.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;M.x-=aa;M.y-=R}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,h);d=e.projectScene(ma,sa,this.sortElements);(W=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];P.empty();if(ka instanceof THREE.RenderableParticle){w=ka;w.x*=j;w.y*=h;ta=0;for(za=ka.materials.length;ta<za;ta++)Qa(w,ka,ka.materials[ta],ma)}else if(ka instanceof
-THREE.RenderableLine){w=ka.v1;H=ka.v2;w.positionScreen.x*=j;w.positionScreen.y*=h;H.positionScreen.x*=j;H.positionScreen.y*=h;P.addPoint(w.positionScreen.x,w.positionScreen.y);P.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.materials.length;ta<za;)Ra(w,H,ka,ka.materials[ta++],ma)}}else if(ka instanceof THREE.RenderableFace3){w=ka.v1;H=ka.v2;p=ka.v3;w.positionScreen.x*=j;w.positionScreen.y*=h;H.positionScreen.x*=j;H.positionScreen.y*=h;p.positionScreen.x*=j;p.positionScreen.y*=
-h;if(ka.overdraw){Ka(w.positionScreen,H.positionScreen);Ka(H.positionScreen,p.positionScreen);Ka(p.positionScreen,w.positionScreen)}P.add3Points(w.positionScreen.x,w.positionScreen.y,H.positionScreen.x,H.positionScreen.y,p.positionScreen.x,p.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=ka.faceMaterials[La++])&&Ma(w,H,p,ka,Ca,ma)}else Ma(w,H,p,ka,Ca,
-ma)}}}V.addRectangle(P)}m.setTransform(1,0,0,1,0,0)}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(h,j){d=h;e=j;f=d/2;b=e/2};this.render=function(h,j){var g,m,n,y,u,o,A,C;a=c.projectScene(h,j);g=0;for(m=a.length;g<m;g++){u=a[g];if(u instanceof THREE.RenderableParticle){A=u.x*f+f;C=u.y*b+b;n=0;for(y=u.material.length;n<y;n++){o=u.material[n];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=A+"px";o.style.top=C+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(la){if(u!=la)m.globalAlpha=u=la}function c(la){if(o!=la){switch(la){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}o=la}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,h,j,g,m=f.getContext("2d"),n=new THREE.Color(0),y=0,u=1,o=0,A=null,C=null,G=1,w,H,p,l,v,t,k,q,x,z=new THREE.Color,
+F=new THREE.Color,B=new THREE.Color,D=new THREE.Color,I=new THREE.Color,N,O,Q,T,U,ba,ca,S,K,Z=new THREE.Rectangle,V=new THREE.Rectangle,P=new THREE.Rectangle,W=false,$=new THREE.Color,da=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,X,ea,ja,ia,qa,ma,ua=16;X=document.createElement("canvas");X.width=X.height=2;ea=X.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);ja=ea.getImageData(0,0,2,2);ia=ja.data;qa=document.createElement("canvas");qa.width=
+qa.height=ua;ma=qa.getContext("2d");ma.translate(-ua/2,-ua/2);ma.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(la,ra){b=la;h=ra;j=b/2;g=h/2;f.width=b;f.height=h;Z.set(-j,-g,j,g);u=1;o=0;C=A=null;G=1};this.setClearColor=function(la,ra){n=la;y=ra;V.set(-j,-g,j,g);m.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(la,ra){n.setHex(la);y=ra;V.set(-j,-g,j,g);m.setTransform(1,0,0,-1,j,g);this.clear()};this.clear=function(){m.setTransform(1,
+0,0,-1,j,g);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(n.hex==0&&y==0)m.clearRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+y+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(la,ra){function Ha(M){var fa,aa,R,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];R=aa.color;if(aa instanceof
+THREE.AmbientLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=R.r;ha.g+=R.g;ha.b+=R.b}else if(aa instanceof THREE.PointLight){E.r+=R.r;E.g+=R.g;E.b+=R.b}}}function Da(M,fa,aa,R){var Y,ga,na,oa,pa=M.lights;M=0;for(Y=pa.length;M<Y;M++){ga=pa[M];na=ga.color;oa=ga.intensity;if(ga instanceof THREE.DirectionalLight){ga=aa.dot(ga.position)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}else if(ga instanceof THREE.PointLight){J.sub(ga.position,fa);J.normalize();
+ga=aa.dot(J)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}}}function Qa(M,fa,aa){if(aa.opacity!=0){a(aa.opacity);c(aa.blending);var R,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*j;ga=fa.scale.y*g;aa=Y*oa;R=ga*pa;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof
+THREE.ParticleCircleMaterial){if(W){$.r=da.r+ha.r+E.r;$.g=da.g+ha.g+E.g;$.b=da.b+ha.b+E.b;z.r=aa.color.r*$.r;z.g=aa.color.g*$.g;z.b=aa.color.b*$.b;z.updateStyleString()}else z.__styleString=aa.color.__styleString;aa=fa.scale.x*j;R=fa.scale.y*g;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){Y=z.__styleString;if(C!=Y)m.fillStyle=C=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,
+R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(M.positionScreen.x,M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){z.__styleString=R.color.__styleString;M=R.linewidth;if(G!=M)m.lineWidth=G=M;M=z.__styleString;if(A!=M)m.strokeStyle=A=M;m.stroke();P.inflate(R.linewidth*2)}}}function Ma(M,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;v=M.positionScreen.y;t=fa.positionScreen.x;
+k=fa.positionScreen.y;q=aa.positionScreen.x;x=aa.positionScreen.y;m.beginPath();m.moveTo(l,v);m.lineTo(t,k);m.lineTo(q,x);m.lineTo(l,v);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(l,v,t,k,q,x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=ra.matrix;J.copy(R.vertexNormalsWorld[0]);
+T=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;U=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(l,v,t,k,q,x,Y.env_map.image,T,U,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&
+!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(l,v,t,k,q,x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){F.r=B.r=D.r=da.r;F.g=B.g=D.g=da.g;F.b=B.b=D.b=da.b;Da(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],F);Da(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],B);Da(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],D);I.r=(B.r+D.r)*0.5;I.g=(B.g+D.g)*
+0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,v,t,k,q,x,Q,0,0,1,0,0,1)}else{$.r=da.r;$.g=da.g;$.b=da.b;Da(ga,R.centroidWorld,R.normalWorld,$);z.r=Y.color.r*$.r;z.g=Y.color.g*$.g;z.b=Y.color.b*$.b;z.updateStyleString();Y.wireframe?Ea(z.__styleString,Y.wireframe_linewidth):Fa(z.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){N=ra.near;O=ra.far;F.r=F.g=F.b=1-Ia(M.positionScreen.z,N,O);B.r=B.g=B.b=1-Ia(fa.positionScreen.z,
+N,O);D.r=D.g=D.b=1-Ia(aa.positionScreen.z,N,O);I.r=(B.r+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,v,t,k,q,x,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){z.r=Ja(R.normalWorld.x);z.g=Ja(R.normalWorld.y);z.b=Ja(R.normalWorld.z);z.updateStyleString();Y.wireframe?Ea(z.__styleString,Y.wireframe_linewidth):Fa(z.__styleString)}}}function Ea(M,fa){if(A!=M)m.strokeStyle=A=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();P.inflate(fa*2)}function Fa(M){if(C!=M)m.fillStyle=C=M;m.fill()}
+function Aa(M,fa,aa,R,Y,ga,na,oa,pa,va,sa,wa,Ba){var ya,xa;ya=na.width-1;xa=na.height-1;oa*=ya;pa*=xa;va*=ya;sa*=xa;wa*=ya;Ba*=xa;aa-=M;R-=fa;Y-=M;ga-=fa;va-=oa;sa-=pa;wa-=oa;Ba-=pa;xa=1/(va*Ba-wa*sa);ya=(Ba*aa-sa*Y)*xa;sa=(Ba*R-sa*ga)*xa;aa=(va*Y-wa*aa)*xa;R=(va*ga-wa*R)*xa;M=M-ya*oa-aa*pa;fa=fa-sa*oa-R*pa;m.save();m.transform(ya,sa,aa,R,M,fa);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,fa,aa,R){var Y=~~(M.r*255),ga=~~(M.g*255);M=~~(M.b*255);var na=~~(fa.r*255),oa=~~(fa.g*255);fa=~~(fa.b*
+255);var pa=~~(aa.r*255),va=~~(aa.g*255);aa=~~(aa.b*255);var sa=~~(R.r*255),wa=~~(R.g*255);R=~~(R.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=ga<0?0:ga>255?255:ga;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=fa<0?0:fa>255?255:fa;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=va<0?0:va>255?255:va;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=sa<0?0:sa>255?255:sa;ia[13]=wa<0?0:wa>255?255:wa;ia[14]=R<0?0:R>255?255:R;ea.putImageData(ja,0,0);ma.drawImage(X,0,0);return qa}function Ia(M,fa,aa){M=
+(M-fa)/(aa-fa);return M*M*(3-2*M)}function Ja(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,fa){var aa=fa.x-M.x,R=fa.y-M.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;M.x-=aa;M.y-=R}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,g);d=e.projectScene(la,ra,this.sortElements);(W=la.lights.length>0)&&Ha(la);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];P.empty();if(ka instanceof THREE.RenderableParticle){w=ka;w.x*=j;w.y*=g;ta=0;for(za=ka.materials.length;ta<
+za;ta++)Qa(w,ka,ka.materials[ta],la)}else if(ka instanceof THREE.RenderableLine){w=ka.v1;H=ka.v2;w.positionScreen.x*=j;w.positionScreen.y*=g;H.positionScreen.x*=j;H.positionScreen.y*=g;P.addPoint(w.positionScreen.x,w.positionScreen.y);P.addPoint(H.positionScreen.x,H.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.materials.length;ta<za;)Ra(w,H,ka,ka.materials[ta++],la)}}else if(ka instanceof THREE.RenderableFace3){w=ka.v1;H=ka.v2;p=ka.v3;w.positionScreen.x*=j;w.positionScreen.y*=g;H.positionScreen.x*=
+j;H.positionScreen.y*=g;p.positionScreen.x*=j;p.positionScreen.y*=g;if(ka.overdraw){Ka(w.positionScreen,H.positionScreen);Ka(H.positionScreen,p.positionScreen);Ka(p.positionScreen,w.positionScreen)}P.add3Points(w.positionScreen.x,w.positionScreen.y,H.positionScreen.x,H.positionScreen.y,p.positionScreen.x,p.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=
+ka.faceMaterials[La++])&&Ma(w,H,p,ka,Ca,la)}else Ma(w,H,p,ka,Ca,la)}}}V.addRectangle(P)}m.setTransform(1,0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function a(T,U,ba){var ca,S,K,Z;ca=0;for(S=T.lights.length;ca<S;ca++){K=T.lights[ca];if(K instanceof THREE.DirectionalLight){Z=U.normalWorld.dot(K.position)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}else if(K instanceof THREE.PointLight){x.sub(K.position,U.centroidWorld);x.normalize();Z=U.normalWorld.dot(x)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}}}function c(T,U,ba,ca,S,K){D=e(I++);D.setAttribute("d",
 "M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)p.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(H){l.r=v.r;l.g=v.g;l.b=v.b;a(K,ca,l);p.r=S.color.r*l.r;p.g=S.color.g*l.g;p.b=S.color.b*l.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){q=1-S.__2near/(S.__farPlusNear-
 ca.z*S.__farMinusNear);p.setRGB(q,q,q)}else S instanceof THREE.MeshNormalMaterial&&p.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?D.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):D.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+S.opacity);j.appendChild(D)}function d(T,U,ba,ca,S,
 K,Z){D=e(I++);D.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)p.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(H){l.r=v.r;l.g=v.g;l.b=v.b;a(Z,S,l);p.r=K.color.r*l.r;p.g=K.color.g*l.g;p.b=K.color.b*l.b;p.updateStyleString()}else p.__styleString=K.color.__styleString;
 else if(K instanceof THREE.MeshDepthMaterial){q=1-K.__2near/(K.__farPlusNear-S.z*K.__farMinusNear);p.setRGB(q,q,q)}else K instanceof THREE.MeshNormalMaterial&&p.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));K.wireframe?D.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):D.setAttribute("style","fill: "+p.__styleString+
-"; fill-opacity: "+K.opacity);j.appendChild(D)}function e(T){if(z[T]==null){z[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&z[T].setAttribute("shape-rendering","crispEdges");return z[T]}return z[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,g=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,m,n,y,u,o,A,C,G=new THREE.Rectangle,w=new THREE.Rectangle,H=false,p=new THREE.Color(16777215),l=new THREE.Color(16777215),
-v=new THREE.Color(0),t=new THREE.Color(0),k=new THREE.Color(0),q,x=new THREE.Vector3,z=[],F=[],B=[],D,I,N,O,Q=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){h=T;m=U;n=h/2;y=m/2;j.setAttribute("viewBox",-n+" "+-y+" "+h+" "+m);j.setAttribute("width",h);j.setAttribute("height",m);G.set(-n,-y,n,y)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};
-this.render=function(T,U){var ba,ca,S,K,Z,V,P,W;this.autoClear&&this.clear();b=g.projectScene(T,U,this.sortElements);O=N=I=0;if(H=T.lights.length>0){P=T.lights;v.setRGB(0,0,0);t.setRGB(0,0,0);k.setRGB(0,0,0);ba=0;for(ca=P.length;ba<ca;ba++){S=P[ba];K=S.color;if(S instanceof THREE.AmbientLight){v.r+=K.r;v.g+=K.g;v.b+=K.b}else if(S instanceof THREE.DirectionalLight){t.r+=K.r;t.g+=K.g;t.b+=K.b}else if(S instanceof THREE.PointLight){k.r+=K.r;k.g+=K.g;k.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){P=b[ba];
+"; fill-opacity: "+K.opacity);j.appendChild(D)}function e(T){if(z[T]==null){z[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&z[T].setAttribute("shape-rendering","crispEdges");return z[T]}return z[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,n,y,u,o,A,C,G=new THREE.Rectangle,w=new THREE.Rectangle,H=false,p=new THREE.Color(16777215),l=new THREE.Color(16777215),
+v=new THREE.Color(0),t=new THREE.Color(0),k=new THREE.Color(0),q,x=new THREE.Vector3,z=[],F=[],B=[],D,I,N,O,Q=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){g=T;m=U;n=g/2;y=m/2;j.setAttribute("viewBox",-n+" "+-y+" "+g+" "+m);j.setAttribute("width",g);j.setAttribute("height",m);G.set(-n,-y,n,y)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};
+this.render=function(T,U){var ba,ca,S,K,Z,V,P,W;this.autoClear&&this.clear();b=h.projectScene(T,U,this.sortElements);O=N=I=0;if(H=T.lights.length>0){P=T.lights;v.setRGB(0,0,0);t.setRGB(0,0,0);k.setRGB(0,0,0);ba=0;for(ca=P.length;ba<ca;ba++){S=P[ba];K=S.color;if(S instanceof THREE.AmbientLight){v.r+=K.r;v.g+=K.g;v.b+=K.b}else if(S instanceof THREE.DirectionalLight){t.r+=K.r;t.g+=K.g;t.b+=K.b}else if(S instanceof THREE.PointLight){k.r+=K.r;k.g+=K.g;k.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){P=b[ba];
 w.empty();if(P instanceof THREE.RenderableParticle){u=P;u.x*=n;u.y*=-y;S=0;for(K=P.materials.length;S<K;S++)if(W=P.materials[S]){Z=u;V=P;W=W;var $=N++;if(F[$]==null){F[$]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&F[$].setAttribute("shape-rendering","crispEdges")}D=F[$];D.setAttribute("cx",Z.x);D.setAttribute("cy",Z.y);D.setAttribute("r",V.scale.x*n);if(W instanceof THREE.ParticleCircleMaterial){if(H){l.r=v.r+t.r+k.r;l.g=v.g+t.g+k.g;l.b=v.b+t.b+k.b;p.r=W.color.r*l.r;p.g=
 W.color.g*l.g;p.b=W.color.b*l.b;p.updateStyleString()}else p=W.color;D.setAttribute("style","fill: "+p.__styleString)}j.appendChild(D)}}else if(P instanceof THREE.RenderableLine){u=P.v1;o=P.v2;u.positionScreen.x*=n;u.positionScreen.y*=-y;o.positionScreen.x*=n;o.positionScreen.y*=-y;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.materials.length;S<K;)if(W=P.materials[S++]){Z=u;V=o;W=W;$=O++;if(B[$]==null){B[$]=document.createElementNS("http://www.w3.org/2000/svg",
 "line");Q==0&&B[$].setAttribute("shape-rendering","crispEdges")}D=B[$];D.setAttribute("x1",Z.positionScreen.x);D.setAttribute("y1",Z.positionScreen.y);D.setAttribute("x2",V.positionScreen.x);D.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){p.__styleString=W.color.__styleString;D.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);j.appendChild(D)}}}}else if(P instanceof
@@ -147,29 +147,29 @@ c(u,o,A,P,W,T)}else W&&c(u,o,A,P,W,T)}}}else if(P instanceof THREE.RenderableFac
 0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&d(u,o,A,C,P,W,T)}else W&&d(u,o,A,C,P,W,T)}}}}}};
 THREE.WebGLRenderer=function(a){function c(l,v){l.fragment_shader=v.fragment_shader;l.vertex_shader=v.vertex_shader;l.uniforms=Uniforms.clone(v.uniforms)}function d(l,v){var t;if(l=="fragment")t=b.createShader(b.FRAGMENT_SHADER);else if(l=="vertex")t=b.createShader(b.VERTEX_SHADER);b.shaderSource(t,v);b.compileShader(t);if(!b.getShaderParameter(t,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(t));return null}return t}function e(l){switch(l){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,g=null,j=null,h=new THREE.Matrix4,m,n=new Float32Array(16),y=new Float32Array(16),
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,h=null,j=null,g=new THREE.Matrix4,m,n=new Float32Array(16),y=new Float32Array(16),
 u=new Float32Array(16),o=new Float32Array(9),A=new Float32Array(16),C=new THREE.Matrix4,G=new THREE.Vector4,w=true,H=new THREE.Color(0),p=0;if(a){if(a.antialias!==undefined)w=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)p=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(l,v,t){try{b=f.getContext("experimental-webgl",{antialias:l})}catch(k){console.log(k)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
-0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(v.r,v.g,v.b,t)})(w,H,p);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,v){f.width=l;f.height=v;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(l,v){var t=new THREE.Color(l);b.clearColor(t.r,
-t.g,t.b,v)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,v){var t,k,q,x=0,z=0,F=0,B,D,I,N=this.lights,O=N.directional.colors,Q=N.directional.positions,T=N.point.colors,U=N.point.positions,ba=0,ca=0;t=0;for(k=v.length;t<k;t++){q=v[t];B=q.color;D=q.position;I=q.intensity;if(q instanceof THREE.AmbientLight){x+=B.r;z+=B.g;F+=B.b}else if(q instanceof THREE.DirectionalLight){O[ba*3]=B.r*I;O[ba*3+1]=B.g*I;O[ba*3+2]=B.b*I;Q[ba*3]=D.x;Q[ba*3+1]=D.y;Q[ba*
-3+2]=D.z;ba+=1}else if(q instanceof THREE.PointLight){T[ca*3]=B.r*I;T[ca*3+1]=B.g*I;T[ca*3+2]=B.b*I;U[ca*3]=D.x;U[ca*3+1]=D.y;U[ca*3+2]=D.z;ca+=1}}N.point.length=ca;N.directional.length=ba;N.ambient[0]=x;N.ambient[1]=z;N.ambient[2]=F};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLParticleBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};
-this.createMeshBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(l){var v=l.vertices.length;l.__vertexArray=new Float32Array(v*3);l.__lineArray=new Uint16Array(v);l.__webGLLineCount=v};this.initParticleBuffers=function(l){var v=l.vertices.length;
-l.__vertexArray=new Float32Array(v*3);l.__colorArray=new Float32Array(v*3);l.__particleArray=new Uint16Array(v);l.__sortArray=[];l.__webGLParticleCount=v};this.initMeshBuffers=function(l,v){var t,k,q=0,x=0,z=0,F=v.geometry.faces,B=l.faces;t=0;for(k=B.length;t<k;t++){fi=B[t];face=F[fi];if(face instanceof THREE.Face3){q+=3;x+=1;z+=3}else if(face instanceof THREE.Face4){q+=4;x+=2;z+=4}}l.__vertexArray=new Float32Array(q*3);l.__normalArray=new Float32Array(q*3);l.__tangentArray=new Float32Array(q*4);
-l.__uvArray=new Float32Array(q*2);l.__uv2Array=new Float32Array(q*2);l.__faceArray=new Uint16Array(x*3);l.__lineArray=new Uint16Array(z*2);q=false;t=0;for(k=v.materials.length;t<k;t++){F=v.materials[t];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=l.materials.length;F<B;F++)if(l.materials[F]&&l.materials[F].shading!=undefined&&l.materials[F].shading==THREE.SmoothShading){q=true;break}}else if(F&&F.shading!=undefined&&F.shading==THREE.SmoothShading){q=true;break}if(q)break}l.__needsSmoothNormals=
-q;l.__webGLFaceCount=x*3;l.__webGLLineCount=z*2};this.setMeshBuffers=function(l,v,t){var k,q,x,z,F,B,D,I,N,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,K=0,Z=0,V=l.__vertexArray,P=l.__uvArray,W=l.__uv2Array,$=l.__normalArray,da=l.__tangentArray,ha=l.__faceArray,E=l.__lineArray,L=l.__needsSmoothNormals,J=v.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,la=J.vertices,ua=l.faces,ma=J.faces,sa=J.uvs,Ha=J.uvs2;v=0;for(k=ua.length;v<k;v++){q=ua[v];x=ma[q];B=sa[q];
-q=Ha[q];z=x.vertexNormals;F=x.normal;if(x instanceof THREE.Face3){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;T+=9}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;K+=12}if(ia)if(z.length==3&&L)for(x=0;x<3;x++){F=z[x];
-$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<3;x++){$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<3;x++){z=B[x];P[U]=z.u;P[U+1]=z.v;U+=2}if(ja&&q)for(x=0;x<3;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ca+=3;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+2;E[Z+4]=Q+1;E[Z+5]=Q+2;Z+=6;Q+=3}}else if(x instanceof THREE.Face4){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;O=la[x.d].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;
-V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;V[T+9]=O.x;V[T+10]=O.y;V[T+11]=O.z;T+=12}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;x=la[x.d].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;da[K+12]=x.x;da[K+13]=x.y;da[K+14]=x.z;da[K+15]=x.w;K+=16}if(ia)if(z.length==4&&L)for(x=0;x<4;x++){F=z[x];$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<4;x++){$[S]=F.x;$[S+1]=
-F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<4;x++){z=B[x];P[U]=z.u;P[U+1]=z.v;U+=2}if(ja&&q)for(x=0;x<4;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ha[ca+3]=Q;ha[ca+4]=Q+2;ha[ca+5]=Q+3;ca+=6;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+3;E[Z+4]=Q+1;E[Z+5]=Q+2;E[Z+6]=Q+2;E[Z+7]=Q+3;Z+=8;Q+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,t)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,$,t)}if(qa&&
-J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,da,t)}if(ja&&U>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,P,t)}if(ja&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,W,t)}if(ea){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,t)}};this.setLineBuffers=
-function(l,v){var t,k,q,x=l.vertices,z=x.length,F=l.__vertexArray,B=l.__lineArray,D=l.__dirtyElements;if(l.__dirtyVertices){for(t=0;t<z;t++){k=x[t].position;q=t*3;F[q]=k.x;F[q+1]=k.y;F[q+2]=k.z}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,v)}if(D){for(t=0;t<z;t++)B[t]=t;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,B,v)}};this.setParticleBuffers=function(l,v,t,k){var q,x,z;x=l.vertices;var F=x.length,B=l.colors,D=B.length,
-I=l.__vertexArray,N=l.__particleArray,O=l.__colorArray,Q=l.__sortArray,T=l.__dirtyVertices,U=l.__dirtyElements,ba=l.__dirtyColors;if(t.sortParticles){C.multiply(k.projectionMatrix,k.matrix);C.multiplySelf(t.matrix);for(q=0;q<F;q++){z=x[q].position;G.copy(z);C.multiplyVector3(G);Q[q]=[G.z,q]}Q.sort(function(ca,S){return S[0]-ca[0]});for(q=0;q<F;q++){z=x[Q[q][1]].position;k=q*3;I[k]=z.x;I[k+1]=z.y;I[k+2]=z.z}for(x=0;x<D;x++){k=x*3;color=B[Q[x][1]];O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}else{if(T)for(q=
-0;q<F;q++){z=x[q].position;k=q*3;I[k]=z.x;I[k+1]=z.y;I[k+2]=z.z}if(ba)for(x=0;x<D;x++){color=B[x];k=x*3;O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}if(U){for(q=0;q<F;q++)N[q]=q;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,v)}if(T||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I,v)}if(ba||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,O,v)}};this.initMaterial=
-function(l,v,t){if(!l.program){var k,q;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&
-c(l,THREE.ShaderLib.particle_basic);var x,z,F,B;q=F=B=0;for(x=v.length;q<x;q++){z=v[q];z instanceof THREE.DirectionalLight&&F++;z instanceof THREE.PointLight&&B++}if(B+F<=4){v=F;B=B}else{v=Math.ceil(4*F/(B+F));B=4-v}q={directional:v,point:B};B=l.fragment_shader;v=l.vertex_shader;x={fog:t,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:q.directional,maxPointLights:q.point};t=b.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
-x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");x=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(v.r,v.g,v.b,t)})(w,H,p);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,v){f.width=l;f.height=v;b.viewport(0,0,f.width,f.height)};this.setClearColorHex=function(l,v){var t=new THREE.Color(l);b.clearColor(t.r,
+t.g,t.b,v)};this.setClearColor=function(l,v){b.clearColor(l.r,l.g,l.b,v)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,v){var t,k,q,x=0,z=0,F=0,B,D,I,N=this.lights,O=N.directional.colors,Q=N.directional.positions,T=N.point.colors,U=N.point.positions,ba=0,ca=0;t=0;for(k=v.length;t<k;t++){q=v[t];B=q.color;D=q.position;I=q.intensity;if(q instanceof THREE.AmbientLight){x+=B.r;z+=B.g;F+=B.b}else if(q instanceof THREE.DirectionalLight){O[ba*3]=B.r*I;
+O[ba*3+1]=B.g*I;O[ba*3+2]=B.b*I;Q[ba*3]=D.x;Q[ba*3+1]=D.y;Q[ba*3+2]=D.z;ba+=1}else if(q instanceof THREE.PointLight){T[ca*3]=B.r*I;T[ca*3+1]=B.g*I;T[ca*3+2]=B.b*I;U[ca*3]=D.x;U[ca*3+1]=D.y;U[ca*3+2]=D.z;ca+=1}}N.point.length=ca;N.directional.length=ba;N.ambient[0]=x;N.ambient[1]=z;N.ambient[2]=F};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLParticleBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=
+b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.createMeshBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(l){var v=l.vertices.length;l.__vertexArray=new Float32Array(v*3);l.__lineArray=new Uint16Array(v);l.__webGLLineCount=
+v};this.initParticleBuffers=function(l){var v=l.vertices.length;l.__vertexArray=new Float32Array(v*3);l.__colorArray=new Float32Array(v*3);l.__particleArray=new Uint16Array(v);l.__sortArray=[];l.__webGLParticleCount=v};this.initMeshBuffers=function(l,v){var t,k,q=0,x=0,z=0,F=v.geometry.faces,B=l.faces;t=0;for(k=B.length;t<k;t++){fi=B[t];face=F[fi];if(face instanceof THREE.Face3){q+=3;x+=1;z+=3}else if(face instanceof THREE.Face4){q+=4;x+=2;z+=4}}l.__vertexArray=new Float32Array(q*3);l.__normalArray=
+new Float32Array(q*3);l.__tangentArray=new Float32Array(q*4);l.__uvArray=new Float32Array(q*2);l.__uv2Array=new Float32Array(q*2);l.__faceArray=new Uint16Array(x*3);l.__lineArray=new Uint16Array(z*2);q=false;t=0;for(k=v.materials.length;t<k;t++){F=v.materials[t];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=l.materials.length;F<B;F++)if(l.materials[F]&&l.materials[F].shading!=undefined&&l.materials[F].shading==THREE.SmoothShading){q=true;break}}else if(F&&F.shading!=undefined&&F.shading==THREE.SmoothShading){q=
+true;break}if(q)break}l.__needsSmoothNormals=q;l.__webGLFaceCount=x*3;l.__webGLLineCount=z*2};this.setMeshBuffers=function(l,v,t){var k,q,x,z,F,B,D,I,N,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,K=0,Z=0,V=l.__vertexArray,P=l.__uvArray,W=l.__uv2Array,$=l.__normalArray,da=l.__tangentArray,ha=l.__faceArray,E=l.__lineArray,L=l.__needsSmoothNormals,J=v.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,ma=J.vertices,ua=l.faces,la=J.faces,ra=J.uvs,Ha=J.uvs2;v=0;
+for(k=ua.length;v<k;v++){q=ua[v];x=la[q];B=ra[q];q=Ha[q];z=x.vertexNormals;F=x.normal;if(x instanceof THREE.Face3){if(X){D=ma[x.a].position;I=ma[x.b].position;N=ma[x.c].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;T+=9}if(qa&&J.hasTangents){D=ma[x.a].tangent;I=ma[x.b].tangent;N=ma[x.c].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;K+=
+12}if(ia)if(z.length==3&&L)for(x=0;x<3;x++){F=z[x];$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<3;x++){$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<3;x++){z=B[x];P[U]=z.u;P[U+1]=z.v;U+=2}if(ja&&q)for(x=0;x<3;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ca+=3;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+2;E[Z+4]=Q+1;E[Z+5]=Q+2;Z+=6;Q+=3}}else if(x instanceof THREE.Face4){if(X){D=ma[x.a].position;I=ma[x.b].position;N=ma[x.c].position;O=ma[x.d].position;V[T]=
+D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;V[T+9]=O.x;V[T+10]=O.y;V[T+11]=O.z;T+=12}if(qa&&J.hasTangents){D=ma[x.a].tangent;I=ma[x.b].tangent;N=ma[x.c].tangent;x=ma[x.d].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;da[K+12]=x.x;da[K+13]=x.y;da[K+14]=x.z;da[K+15]=x.w;K+=16}if(ia)if(z.length==4&&L)for(x=0;x<4;x++){F=z[x];$[S]=F.x;$[S+1]=F.y;$[S+
+2]=F.z;S+=3}else for(x=0;x<4;x++){$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<4;x++){z=B[x];P[U]=z.u;P[U+1]=z.v;U+=2}if(ja&&q)for(x=0;x<4;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ha[ca+3]=Q;ha[ca+4]=Q+2;ha[ca+5]=Q+3;ca+=6;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+3;E[Z+4]=Q+1;E[Z+5]=Q+2;E[Z+6]=Q+2;E[Z+7]=Q+3;Z+=8;Q+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,t)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);
+b.bufferData(b.ARRAY_BUFFER,$,t)}if(qa&&J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,da,t)}if(ja&&U>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,P,t)}if(ja&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,W,t)}if(ea){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,
+E,t)}};this.setLineBuffers=function(l,v){var t,k,q,x=l.vertices,z=x.length,F=l.__vertexArray,B=l.__lineArray,D=l.__dirtyElements;if(l.__dirtyVertices){for(t=0;t<z;t++){k=x[t].position;q=t*3;F[q]=k.x;F[q+1]=k.y;F[q+2]=k.z}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,v)}if(D){for(t=0;t<z;t++)B[t]=t;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,B,v)}};this.setParticleBuffers=function(l,v,t,k){var q,x,z;x=l.vertices;var F=
+x.length,B=l.colors,D=B.length,I=l.__vertexArray,N=l.__particleArray,O=l.__colorArray,Q=l.__sortArray,T=l.__dirtyVertices,U=l.__dirtyElements,ba=l.__dirtyColors;if(t.sortParticles){C.multiply(k.projectionMatrix,k.matrix);C.multiplySelf(t.matrix);for(q=0;q<F;q++){z=x[q].position;G.copy(z);C.multiplyVector3(G);Q[q]=[G.z,q]}Q.sort(function(ca,S){return S[0]-ca[0]});for(q=0;q<F;q++){z=x[Q[q][1]].position;k=q*3;I[k]=z.x;I[k+1]=z.y;I[k+2]=z.z}for(x=0;x<D;x++){k=x*3;color=B[Q[x][1]];O[k]=color.r;O[k+1]=
+color.g;O[k+2]=color.b}}else{if(T)for(q=0;q<F;q++){z=x[q].position;k=q*3;I[k]=z.x;I[k+1]=z.y;I[k+2]=z.z}if(ba)for(x=0;x<D;x++){color=B[x];k=x*3;O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}if(U){for(q=0;q<F;q++)N[q]=q;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,v)}if(T||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I,v)}if(ba||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,
+O,v)}};this.initMaterial=function(l,v,t){if(!l.program){var k,q;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof
+THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var x,z,F,B;q=F=B=0;for(x=v.length;q<x;q++){z=v[q];z instanceof THREE.DirectionalLight&&F++;z instanceof THREE.PointLight&&B++}if(B+F<=4){v=F;B=B}else{v=Math.ceil(4*F/(B+F));B=4-v}q={directional:v,point:B};B=l.fragment_shader;v=l.vertex_shader;x={fog:t,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:q.directional,maxPointLights:q.point};t=b.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif",
+"#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");x=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+
 x.maxPointLights,x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(t,d("fragment",q+B));b.attachShader(t,
 d("vertex",x+v));b.linkProgram(t);b.getProgramParameter(t,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(t,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");t.uniforms={};t.attributes={};l.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(k in l.uniforms)t.push(k);k=l.program;B=0;for(v=t.length;B<v;B++){q=t[B];k.uniforms[q]=b.getUniformLocation(k,q)}l=l.program;k=["position","normal",
-"uv","uv2","tangent","color"];t=0;for(B=k.length;t<B;t++){v=k[t];l.attributes[v]=b.getAttribLocation(l,v)}}};this.setProgram=function(l,v,t,k){this.initMaterial(k,v,t);var q=k.program;if(q!=g){b.useProgram(q);g=q}this.loadCamera(q,l);this.loadMatrices(q);if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial){this.setupLights(q,v);v=this.lights;k.uniforms.enableLighting.value=v.directional.length+v.point.length;k.uniforms.ambientLightColor.value=v.ambient;k.uniforms.directionalLightColor.value=
+"uv","uv2","tangent","color"];t=0;for(B=k.length;t<B;t++){v=k[t];l.attributes[v]=b.getAttribLocation(l,v)}}};this.setProgram=function(l,v,t,k){this.initMaterial(k,v,t);var q=k.program;if(q!=h){b.useProgram(q);h=q}this.loadCamera(q,l);this.loadMatrices(q);if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial){this.setupLights(q,v);v=this.lights;k.uniforms.enableLighting.value=v.directional.length+v.point.length;k.uniforms.ambientLightColor.value=v.ambient;k.uniforms.directionalLightColor.value=
 v.directional.colors;k.uniforms.directionalLightDirection.value=v.directional.positions;k.uniforms.pointLightColor.value=v.point.colors;k.uniforms.pointLightPosition.value=v.point.positions}if(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial){k.uniforms.diffuse.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.map.texture=k.map;k.uniforms.light_map.texture=k.light_map;
 k.uniforms.env_map.texture=k.env_map;k.uniforms.reflectivity.value=k.reflectivity;k.uniforms.refraction_ratio.value=k.refraction_ratio;k.uniforms.combine.value=k.combine;k.uniforms.useRefract.value=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;if(t){k.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){k.uniforms.fogNear.value=t.near;k.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)k.uniforms.fogDensity.value=t.density}}if(k instanceof THREE.LineBasicMaterial){k.uniforms.diffuse.value.setRGB(k.color.r*
 k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;if(t){k.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){k.uniforms.fogNear.value=t.near;k.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)k.uniforms.fogDensity.value=t.density}}if(k instanceof THREE.ParticleBasicMaterial){k.uniforms.psColor.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.size.value=k.size;
@@ -192,7 +192,7 @@ F,B,z,x,THREE.SubtractiveBlending,false);this.renderPass(v,F,B,z,x,THREE.Additiv
 O,Q,T){if(N[O]==undefined){l.__webGLObjects.push({buffer:Q,object:T});N[O]=1}}function k(N,O,Q){if(N[O]==undefined){l.__webGLObjectsImmediate.push({object:Q});N[O]=1}}var q,x,z,F,B,D,I;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}q=0;for(x=l.objects.length;q<x;q++){z=l.objects[q];B=z.geometry;if(l.__webGLObjectsMap[z.id]==undefined)l.__webGLObjectsMap[z.id]={};I=l.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(F in B.geometryChunks){D=B.geometryChunks[F];
 if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,z);B.__dirtyVertices=true;B.__dirtyElements=true;B.__dirtyUvs=true;B.__dirtyNormals=true;B.__dirtyTangents=true}if(B.__dirtyVertices||B.__dirtyElements||B.__dirtyUvs)this.setMeshBuffers(D,z,b.DYNAMIC_DRAW);t(I,F,D,z)}B.__dirtyVertices=false;B.__dirtyElements=false;B.__dirtyUvs=false;B.__dirtyNormals=false;B.__dirtyTangents=false}else if(z instanceof THREE.Line){if(!B.__webGLVertexBuffer){this.createLineBuffers(B);this.initLineBuffers(B);
 B.__dirtyVertices=true;B.__dirtyElements=true}B.__dirtyVertices&&this.setLineBuffers(B,b.DYNAMIC_DRAW);t(I,0,B,z);B.__dirtyVertices=false;B.__dirtyElements=false}else if(z instanceof THREE.ParticleSystem){if(!B.__webGLVertexBuffer){this.createParticleBuffers(B);this.initParticleBuffers(B);B.__dirtyVertices=true;B.__dirtyColors=true;B.__dirtyElements=true}if(B.__dirtyVertices||B.__dirtyColors||z.sortParticles)this.setParticleBuffers(B,b.DYNAMIC_DRAW,z,v);t(I,0,B,z);B.__dirtyVertices=false;B.__dirtyColors=
-false;B.__dirtyElements=false}else z instanceof THREE.MarchingCubes&&k(I,0,z)}};this.removeObject=function(l,v){var t,k;for(t=l.__webGLObjects.length-1;t>=0;t--){k=l.__webGLObjects[t].object;v==k&&l.__webGLObjects.splice(t,1)}};this.setupMatrices=function(l,v){h.multiply(v.matrix,l.matrix);y.set(h.flatten());m=THREE.Matrix4.makeInvert3x3(h).transpose();o.set(m.m);A.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,false,n);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,
+false;B.__dirtyElements=false}else z instanceof THREE.MarchingCubes&&k(I,0,z)}};this.removeObject=function(l,v){var t,k;for(t=l.__webGLObjects.length-1;t>=0;t--){k=l.__webGLObjects[t].object;v==k&&l.__webGLObjects.splice(t,1)}};this.setupMatrices=function(l,v){g.multiply(v.matrix,l.matrix);y.set(g.flatten());m=THREE.Matrix4.makeInvert3x3(g).transpose();o.set(m.m);A.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,false,n);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,
 false,y);b.uniformMatrix4fv(l.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(l.uniforms.normalMatrix,false,o);b.uniformMatrix4fv(l.uniforms.objectMatrix,false,A)};this.loadCamera=function(l,v){b.uniform3f(l.uniforms.cameraPosition,v.position.x,v.position.y,v.position.z)};this.setBlending=function(l){switch(l){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
 b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(l,v){if(l){!v||v=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(l=="back")b.cullFace(b.BACK);else l=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
@@ -217,17 +217,17 @@ THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].
 "gl_FragColor = mColor * mapColor * vertexColor;",THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};
 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.faceMaterials=this.meshMaterials=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.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
-var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,g=f.vertices,j=a.faces,h=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var n=0,y=g.length;n<y;n++){var u=new THREE.Vertex(g[n].position.clone());d&&c.matrix.multiplyVector3(u.position);b.push(u)}n=0;for(y=h.length;n<y;n++){g=h[n];var o,A=g.vertexNormals;if(g instanceof THREE.Face3)o=new THREE.Face3(g.a+e,g.b+e,g.c+e);else if(g instanceof THREE.Face4)o=new THREE.Face4(g.a+
-e,g.b+e,g.c+e,g.d+e);o.centroid.copy(g.centroid);o.normal.copy(g.normal);d=0;for(b=A.length;d<b;d++){u=A[d];o.vertexNormals.push(u.clone())}o.materials=g.materials.slice();j.push(o)}n=0;for(y=f.length;n<y;n++){e=f[n];j=[];d=0;for(b=e.length;d<b;d++)j.push(new THREE.UV(e[d].u,e[d].v));m.push(j)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
+var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,h=f.vertices,j=a.faces,g=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var n=0,y=h.length;n<y;n++){var u=new THREE.Vertex(h[n].position.clone());d&&c.matrix.multiplyVector3(u.position);b.push(u)}n=0;for(y=g.length;n<y;n++){h=g[n];var o,A=h.vertexNormals;if(h instanceof THREE.Face3)o=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)o=new THREE.Face4(h.a+
+e,h.b+e,h.c+e,h.d+e);o.centroid.copy(h.centroid);o.normal.copy(h.normal);d=0;for(b=A.length;d<b;d++){u=A[d];o.vertexNormals.push(u.clone())}o.materials=h.materials.slice();j.push(o)}n=0;for(y=f.length;n<y;n++){e=f[n];j=[];d=0;for(b=e.length;d<b;d++)j.push(new THREE.UV(e[d].u,e[d].v));m.push(j)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
 a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(n in k.objects)if(!D.objects[n]){C=k.objects[n];if(p=D.geometries[C.geometry]){t=[];for(i=0;i<C.materials.length;i++)t[i]=D.materials[C.materials[i]];G=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(p,t);object.position.set(G[0],G[1],G[2]);
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;D.scene.addObject(object);D.objects[n]=object}}}function g(I){return function(N){D.geometries[I]=N;b();x-=1;j()}}function j(){e({total_models:F,total_textures:B,loaded_models:F-x,loaded_textures:B-z},D);x==0&&z==0&&d(D)}var h,m,n,y,u,o,A,C,G,w,H,p,l,v,t,k,q,x,z,F,B,D;k=f.data;q=new THREE.Loader;z=x=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;D.scene.addObject(object);D.objects[n]=object}}}function h(I){return function(N){D.geometries[I]=N;b();x-=1;j()}}function j(){e({total_models:F,total_textures:B,loaded_models:F-x,loaded_textures:B-z},D);x==0&&z==0&&d(D)}var g,m,n,y,u,o,A,C,G,w,H,p,l,v,t,k,q,x,z,F,B,D;k=f.data;q=new THREE.Loader;z=x=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
 f=function(){z-=1;j()};for(u in k.cameras){w=k.cameras[u];if(w.type=="perspective")l=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}G=w.position;w=w.target;l.position.set(G[0],G[1],G[2]);l.target.position.set(w[0],w[1],w[2]);D.cameras[u]=l}for(y in k.lights){u=k.lights[y];if(u.type=="directional"){G=u.direction;light=new THREE.DirectionalLight;light.position.set(G[0],G[1],
 G[2]);light.position.normalize()}else if(u.type=="point"){G=u.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}w=u.color;i=u.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);D.scene.addLight(light);D.lights[y]=light}for(o in k.fogs){y=k.fogs[o];if(y.type=="linear")v=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")v=new THREE.FogExp2(0,y.density);w=y.color;v.color.setRGB(w[0],w[1],w[2]);D.fogs[o]=v}if(D.cameras&&k.defaults.camera)D.currentCamera=D.cameras[k.defaults.camera];
-if(D.fogs&&k.defaults.fog)D.scene.fog=D.fogs[k.defaults.fog];w=k.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(w[0],w[1],w[2]);D.bgColorAlpha=k.defaults.bgalpha;for(h in k.geometries){o=k.geometries[h];if(o.type=="bin_mesh"||o.type=="ascii_mesh")x+=1}F=x;for(h in k.geometries){o=k.geometries[h];if(o.type=="cube"){p=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);D.geometries[h]=p}else if(o.type=="plane"){p=new Plane(o.width,o.height,o.segments_width,
-o.segments_height);D.geometries[h]=p}else if(o.type=="sphere"){p=new Sphere(o.radius,o.segments_width,o.segments_height);D.geometries[h]=p}else if(o.type=="cylinder"){p=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);D.geometries[h]=p}else if(o.type=="torus"){p=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);D.geometries[h]=p}else if(o.type=="icosahedron"){p=new Icosahedron(o.subdivisions);D.geometries[h]=p}else if(o.type=="bin_mesh")q.loadBinary({model:o.url,callback:g(h)});
-else o.type=="ascii_mesh"&&q.loadAscii({model:o.url,callback:g(h)})}for(A in k.textures){h=k.textures[A];z+=h.url instanceof Array?h.url.length:1}B=z;for(A in k.textures){h=k.textures[A];if(h.mapping!=undefined&&THREE[h.mapping]!=undefined)h.mapping=new THREE[h.mapping];if(h.url instanceof Array){o=ImageUtils.loadArray(h.url,f);o=new THREE.Texture(o,h.mapping)}else{o=ImageUtils.loadTexture(h.url,h.mapping,f);if(THREE[h.min_filter]!=undefined)o.min_filter=THREE[h.min_filter];if(THREE[h.mag_filter]!=
-undefined)o.mag_filter=THREE[h.mag_filter]}D.textures[A]=o}for(m in k.materials){A=k.materials[m];for(H in A.parameters)if(H=="env_map"||H=="map"||H=="light_map")A.parameters[H]=D.textures[A.parameters[H]];else if(H=="shading")A.parameters[H]=A.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")A.parameters[H]=THREE[A.parameters[H]]?THREE[A.parameters[H]]:THREE.NormalBlending;else if(H=="combine")A.parameters[H]=A.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
-A=new THREE[A.type](A.parameters);D.materials[m]=A}b();c(D)}},addMesh:function(a,c,d,e,f,b,g,j,h,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=g;c.rotation.y=j;c.rotation.z=h;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
+if(D.fogs&&k.defaults.fog)D.scene.fog=D.fogs[k.defaults.fog];w=k.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(w[0],w[1],w[2]);D.bgColorAlpha=k.defaults.bgalpha;for(g in k.geometries){o=k.geometries[g];if(o.type=="bin_mesh"||o.type=="ascii_mesh")x+=1}F=x;for(g in k.geometries){o=k.geometries[g];if(o.type=="cube"){p=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);D.geometries[g]=p}else if(o.type=="plane"){p=new Plane(o.width,o.height,o.segments_width,
+o.segments_height);D.geometries[g]=p}else if(o.type=="sphere"){p=new Sphere(o.radius,o.segments_width,o.segments_height);D.geometries[g]=p}else if(o.type=="cylinder"){p=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);D.geometries[g]=p}else if(o.type=="torus"){p=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);D.geometries[g]=p}else if(o.type=="icosahedron"){p=new Icosahedron(o.subdivisions);D.geometries[g]=p}else if(o.type=="bin_mesh")q.loadBinary({model:o.url,callback:h(g)});
+else o.type=="ascii_mesh"&&q.loadAscii({model:o.url,callback:h(g)})}for(A in k.textures){g=k.textures[A];z+=g.url instanceof Array?g.url.length:1}B=z;for(A in k.textures){g=k.textures[A];if(g.mapping!=undefined&&THREE[g.mapping]!=undefined)g.mapping=new THREE[g.mapping];if(g.url instanceof Array){o=ImageUtils.loadArray(g.url,f);o=new THREE.Texture(o,g.mapping)}else{o=ImageUtils.loadTexture(g.url,g.mapping,f);if(THREE[g.min_filter]!=undefined)o.min_filter=THREE[g.min_filter];if(THREE[g.mag_filter]!=
+undefined)o.mag_filter=THREE[g.mag_filter]}D.textures[A]=o}for(m in k.materials){A=k.materials[m];for(H in A.parameters)if(H=="env_map"||H=="map"||H=="light_map")A.parameters[H]=D.textures[A.parameters[H]];else if(H=="shading")A.parameters[H]=A.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")A.parameters[H]=THREE[A.parameters[H]]?THREE[A.parameters[H]]:THREE.NormalBlending;else if(H=="combine")A.parameters[H]=A.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
+A=new THREE[A.type](A.parameters);D.materials[m]=A}b();c(D)}},addMesh:function(a,c,d,e,f,b,h,j,g,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=h;c.rotation.y=j;c.rotation.z=g;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
 c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
 c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var f=Math.PI/2,b=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
 SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
@@ -239,38 +239,38 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin(vUv.y * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,g,j){function h(C,G,w,H,p,l,v,t){var k,q,x=e||1,z=f||1,F=x+1,B=z+1,D=p/2,I=l/2;p=p/x;var N=l/z,O=m.vertices.length;if(C=="x"&&G=="y"||C=="y"&&G=="x")k="z";else if(C=="x"&&G=="z"||C=="z"&&G=="x")k="y";else if(C==
-"z"&&G=="y"||C=="y"&&G=="z")k="x";for(q=0;q<B;q++)for(l=0;l<F;l++){var Q=new THREE.Vector3;Q[C]=(l*p-D)*w;Q[G]=(q*N-I)*H;Q[k]=v;m.vertices.push(new THREE.Vertex(Q))}for(q=0;q<z;q++)for(l=0;l<x;l++){m.faces.push(new THREE.Face4(l+F*q+O,l+F*(q+1)+O,l+1+F*(q+1)+O,l+1+F*q+O,null,t));m.uvs.push([new THREE.UV(l/x,q/z),new THREE.UV(l/x,(q+1)/z),new THREE.UV((l+1)/x,(q+1)/z),new THREE.UV((l+1)/x,q/z)])}}THREE.Geometry.call(this);var m=this,n=a/2,y=c/2,u=d/2;g=g?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
-b;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(j!=undefined)for(var A in j)if(this.sides[A]!=undefined)this.sides[A]=j[A];this.sides.px&&h("z","y",1*g,-1,d,c,-n,this.materials[0]);this.sides.nx&&h("z","y",-1*g,-1,d,c,n,this.materials[1]);this.sides.py&&h("x","z",1*g,1,a,d,y,this.materials[2]);this.sides.ny&&h("x","z",1*g,-1,a,d,-y,this.materials[3]);this.sides.pz&&h("x","y",1*g,-1,a,c,u,this.materials[4]);
-this.sides.nz&&h("x","y",-1*g,-1,a,c,-u,this.materials[5]);(function(){for(var C=[],G=[],w=0,H=m.vertices.length;w<H;w++){for(var p=m.vertices[w],l=false,v=0,t=C.length;v<t;v++){var k=C[v];if(p.position.x==k.position.x&&p.position.y==k.position.y&&p.position.z==k.position.z){G[w]=v;l=true;break}}if(!l){G[w]=C.length;C.push(new THREE.Vertex(p.position.clone()))}}w=0;for(H=m.faces.length;w<H;w++){p=m.faces[w];p.a=G[p.a];p.b=G[p.b];p.c=G[p.c];p.d=G[p.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,h,j){function g(C,G,w,H,p,l,v,t){var k,q,x=e||1,z=f||1,F=x+1,B=z+1,D=p/2,I=l/2;p=p/x;var N=l/z,O=m.vertices.length;if(C=="x"&&G=="y"||C=="y"&&G=="x")k="z";else if(C=="x"&&G=="z"||C=="z"&&G=="x")k="y";else if(C==
+"z"&&G=="y"||C=="y"&&G=="z")k="x";for(q=0;q<B;q++)for(l=0;l<F;l++){var Q=new THREE.Vector3;Q[C]=(l*p-D)*w;Q[G]=(q*N-I)*H;Q[k]=v;m.vertices.push(new THREE.Vertex(Q))}for(q=0;q<z;q++)for(l=0;l<x;l++){m.faces.push(new THREE.Face4(l+F*q+O,l+F*(q+1)+O,l+1+F*(q+1)+O,l+1+F*q+O,null,t));m.uvs.push([new THREE.UV(l/x,q/z),new THREE.UV(l/x,(q+1)/z),new THREE.UV((l+1)/x,(q+1)/z),new THREE.UV((l+1)/x,q/z)])}}THREE.Geometry.call(this);var m=this,n=a/2,y=c/2,u=d/2;h=h?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
+b;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(j!=undefined)for(var A in j)if(this.sides[A]!=undefined)this.sides[A]=j[A];this.sides.px&&g("z","y",1*h,-1,d,c,-n,this.materials[0]);this.sides.nx&&g("z","y",-1*h,-1,d,c,n,this.materials[1]);this.sides.py&&g("x","z",1*h,1,a,d,y,this.materials[2]);this.sides.ny&&g("x","z",1*h,-1,a,d,-y,this.materials[3]);this.sides.pz&&g("x","y",1*h,-1,a,c,u,this.materials[4]);
+this.sides.nz&&g("x","y",-1*h,-1,a,c,-u,this.materials[5]);(function(){for(var C=[],G=[],w=0,H=m.vertices.length;w<H;w++){for(var p=m.vertices[w],l=false,v=0,t=C.length;v<t;v++){var k=C[v];if(p.position.x==k.position.x&&p.position.y==k.position.y&&p.position.z==k.position.z){G[w]=v;l=true;break}}if(!l){G[w]=C.length;C.push(new THREE.Vertex(p.position.clone()))}}w=0;for(H=m.faces.length;w<H;w++){p=m.faces[w];p.a=G[p.a];p.b=G[p.b];p.c=G[p.c];p.d=G[p.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();
 this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,c,d,e,f){function b(m,n,y){g.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,y)))}THREE.Geometry.call(this);var g=this,j=Math.PI,h;for(h=0;h<a;h++)b(Math.sin(2*j*h/a)*c,Math.cos(2*j*h/a)*c,0);for(h=0;h<a;h++)b(Math.sin(2*j*h/a)*d,Math.cos(2*j*h/a)*d,e);for(h=0;h<a;h++)g.faces.push(new THREE.Face4(h,h+a,a+(h+1)%a,(h+1)%a));if(d!=0){b(0,0,-f);for(h=a;h<a+a/2;h++)g.faces.push(new THREE.Face4(2*a,(2*h-2*a)%a,(2*h-2*a+1)%a,(2*h-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(h=a+a/2;h<
-2*a;h++)g.faces.push(new THREE.Face4((2*h-2*a+2)%a+a,(2*h-2*a+1)%a+a,(2*h-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
-var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,b=a/2,g=c/2;d=d||1;e=e||1;var j=d+1,h=e+1;a=a/d;var m=c/e;for(f=0;f<h;f++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-g),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+j*f,c+j*(f+1),c+1+j*(f+1),c+1+j*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
+var Cylinder=function(a,c,d,e,f){function b(m,n,y){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,y)))}THREE.Geometry.call(this);var h=this,j=Math.PI,g;for(g=0;g<a;g++)b(Math.sin(2*j*g/a)*c,Math.cos(2*j*g/a)*c,0);for(g=0;g<a;g++)b(Math.sin(2*j*g/a)*d,Math.cos(2*j*g/a)*d,e);for(g=0;g<a;g++)h.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){b(0,0,-f);for(g=a;g<a+a/2;g++)h.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(g=a+a/2;g<
+2*a;g++)h.faces.push(new THREE.Face4((2*g-2*a+2)%a+a,(2*g-2*a+1)%a+a,(2*g-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
+var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,b=a/2,h=c/2;d=d||1;e=e||1;var j=d+1,g=e+1;a=a/d;var m=c/e;for(f=0;f<g;f++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-h),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+j*f,c+j*(f+1),c+1+j*(f+1),c+1+j*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),g=Math.max(2,d||6);c=[];for(d=0;d<g+1;d++){e=d/g;var j=a*Math.cos(e*f),h=a*Math.sin(e*f),m=[],n=0;for(e=0;e<b;e++){var y=2*e/b,u=h*Math.sin(y*f);y=h*Math.cos(y*f);(d==0||d==g)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,u)))-1);m.push(n)}c.push(m)}var o,A,C;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;g=c[d][m?0:e+1];j=c[d][m?b-1:e];h=c[d-1][m?b-1:e];m=c[d-1][m?
-0:e+1];u=d/(f-1);o=(d-1)/(f-1);A=(e+1)/b;y=e/b;n=new THREE.UV(1-A,u);u=new THREE.UV(1-y,u);y=new THREE.UV(1-y,o);var G=new THREE.UV(1-A,o);if(d<c.length-1){o=this.vertices[g].position.clone();A=this.vertices[j].position.clone();C=this.vertices[h].position.clone();o.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(g,j,h,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,u,y])}if(d>1){o=this.vertices[g].position.clone();
-A=this.vertices[h].position.clone();C=this.vertices[m].position.clone();o.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(g,h,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,y,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),h=Math.max(2,d||6);c=[];for(d=0;d<h+1;d++){e=d/h;var j=a*Math.cos(e*f),g=a*Math.sin(e*f),m=[],n=0;for(e=0;e<b;e++){var y=2*e/b,u=g*Math.sin(y*f);y=g*Math.cos(y*f);(d==0||d==h)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,u)))-1);m.push(n)}c.push(m)}var o,A,C;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;h=c[d][m?0:e+1];j=c[d][m?b-1:e];g=c[d-1][m?b-1:e];m=c[d-1][m?
+0:e+1];u=d/(f-1);o=(d-1)/(f-1);A=(e+1)/b;y=e/b;n=new THREE.UV(1-A,u);u=new THREE.UV(1-y,u);y=new THREE.UV(1-y,o);var G=new THREE.UV(1-A,o);if(d<c.length-1){o=this.vertices[h].position.clone();A=this.vertices[j].position.clone();C=this.vertices[g].position.clone();o.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(h,j,g,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,u,y])}if(d>1){o=this.vertices[h].position.clone();
+A=this.vertices[g].position.clone();C=this.vertices[m].position.clone();o.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(h,g,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,y,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
-1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,g));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var Icosahedron=function(a){function c(y,u,o){var A=Math.sqrt(y*y+u*u+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(y/A,u/A,o/A)))-1}function d(y,u,o,A){A.faces.push(new THREE.Face3(y,u,o))}function e(y,u){var o=f.vertices[y].position,A=f.vertices[u].position;return c((o.x+A.x)/2,(o.y+A.y)/2,(o.z+A.z)/2)}var f=this,b=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
-1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var j in b.faces){var h=e(b.faces[j].a,b.faces[j].b),m=e(b.faces[j].b,b.faces[j].c),n=e(b.faces[j].c,b.faces[j].a);d(b.faces[j].a,h,n,g);d(b.faces[j].b,m,h,g);d(b.faces[j].c,
-n,m,g);d(h,m,n,g)}b.faces=g.faces}f.faces=b.faces;delete b;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],b=[],g=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));f[j]=this.vertices.length-1;e[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var h=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(j=0;j<e.length;j++)if(m<d){e[j]=h.multiplyVector3(e[j].clone());this.vertices.push(new THREE.Vertex(e[j]));b[j]=this.vertices.length-1}else b=g;if(m==0)g=f;for(j=0;j<f.length-1;j++){this.faces.push(new THREE.Face4(b[j],
+1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
+var Icosahedron=function(a){function c(y,u,o){var A=Math.sqrt(y*y+u*u+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(y/A,u/A,o/A)))-1}function d(y,u,o,A){A.faces.push(new THREE.Face3(y,u,o))}function e(y,u){var o=f.vertices[y].position,A=f.vertices[u].position;return c((o.x+A.x)/2,(o.y+A.y)/2,(o.z+A.z)/2)}var f=this,b=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
+1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in b.faces){var g=e(b.faces[j].a,b.faces[j].b),m=e(b.faces[j].b,b.faces[j].c),n=e(b.faces[j].c,b.faces[j].a);d(b.faces[j].a,g,n,h);d(b.faces[j].b,m,g,h);d(b.faces[j].c,
+n,m,h);d(g,m,n,h)}b.faces=h.faces}f.faces=b.faces;delete b;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],b=[],h=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));f[j]=this.vertices.length-1;e[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var g=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(j=0;j<e.length;j++)if(m<d){e[j]=g.multiplyVector3(e[j].clone());this.vertices.push(new THREE.Vertex(e[j]));b[j]=this.vertices.length-1}else b=h;if(m==0)h=f;for(j=0;j<f.length-1;j++){this.faces.push(new THREE.Face4(b[j],
 b[j+1],f[j+1],f[j]));this.uvs.push([new THREE.UV(m/d,j/a.length),new THREE.UV(m/d,(j+1)/a.length),new THREE.UV((m-c)/d,(j+1)/a.length),new THREE.UV((m-c)/d,j/a.length)])}f=b;b=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(d){this.isolation=80;this.size=d;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=true;this.maxCount=4096;this.count=
-0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,f){return d+(e-d)*f};this.VIntX=function(d,e,f,b,g,j,h,m,n,y){g=(g-n)/(y-n);n=this.normal_cache;e[b]=j+g*this.delta;e[b+1]=h;e[b+2]=m;f[b]=this.lerp(n[d],n[d+3],g);f[b+1]=this.lerp(n[d+1],n[d+4],g);f[b+2]=this.lerp(n[d+2],n[d+5],g)};this.VIntY=function(d,e,f,b,g,j,h,m,n,y){g=(g-n)/(y-n);n=this.normal_cache;e[b]=j;e[b+1]=h+g*this.delta;e[b+
-2]=m;e=d+this.yd*3;f[b]=this.lerp(n[d],n[e],g);f[b+1]=this.lerp(n[d+1],n[e+1],g);f[b+2]=this.lerp(n[d+2],n[e+2],g)};this.VIntZ=function(d,e,f,b,g,j,h,m,n,y){g=(g-n)/(y-n);n=this.normal_cache;e[b]=j;e[b+1]=h;e[b+2]=m+g*this.delta;e=d+this.zd*3;f[b]=this.lerp(n[d],n[e],g);f[b+1]=this.lerp(n[d+1],n[e+1],g);f[b+2]=this.lerp(n[d+2],n[e+2],g)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
-this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,f,b,g,j){var h=b+1,m=b+this.yd,n=b+this.zd,y=h+this.yd,u=h+this.zd,o=b+this.yd+this.zd,A=h+this.yd+this.zd,C=0,G=this.field[b],w=this.field[h],H=this.field[m],p=this.field[y],l=this.field[n],v=this.field[u],t=this.field[o],k=this.field[A];if(G<g)C|=1;if(w<g)C|=2;if(H<g)C|=8;if(p<g)C|=4;if(l<g)C|=16;if(v<g)C|=32;if(t<g)C|=128;if(k<g)C|=64;var q=THREE.edgeTable[C];if(q==0)return 0;
-var x=this.delta,z=d+x,F=e+x;x=f+x;if(q&1){this.compNorm(b);this.compNorm(h);this.VIntX(b*3,this.vlist,this.nlist,0,g,d,e,f,G,w)}if(q&2){this.compNorm(h);this.compNorm(y);this.VIntY(h*3,this.vlist,this.nlist,3,g,z,e,f,w,p)}if(q&4){this.compNorm(m);this.compNorm(y);this.VIntX(m*3,this.vlist,this.nlist,6,g,d,F,f,H,p)}if(q&8){this.compNorm(b);this.compNorm(m);this.VIntY(b*3,this.vlist,this.nlist,9,g,d,e,f,G,H)}if(q&16){this.compNorm(n);this.compNorm(u);this.VIntX(n*3,this.vlist,this.nlist,12,g,d,e,x,
-l,v)}if(q&32){this.compNorm(u);this.compNorm(A);this.VIntY(u*3,this.vlist,this.nlist,15,g,z,e,x,v,k)}if(q&64){this.compNorm(o);this.compNorm(A);this.VIntX(o*3,this.vlist,this.nlist,18,g,d,F,x,t,k)}if(q&128){this.compNorm(n);this.compNorm(o);this.VIntY(n*3,this.vlist,this.nlist,21,g,d,e,x,l,t)}if(q&256){this.compNorm(b);this.compNorm(n);this.VIntZ(b*3,this.vlist,this.nlist,24,g,d,e,f,G,l)}if(q&512){this.compNorm(h);this.compNorm(u);this.VIntZ(h*3,this.vlist,this.nlist,27,g,z,e,f,w,v)}if(q&1024){this.compNorm(y);
-this.compNorm(A);this.VIntZ(y*3,this.vlist,this.nlist,30,g,z,F,f,p,k)}if(q&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,g,d,F,f,H,t)}C<<=4;for(g=b=0;THREE.triTable[C+g]!=-1;){d=C+g;e=d+1;f=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[f],j);g+=3;b++}return b};this.posnormtriv=function(d,e,f,b,g,j){var h=this.count*3;this.positionArray[h]=d[f];this.positionArray[h+1]=d[f+1];this.positionArray[h+2]=d[f+2];this.positionArray[h+
-3]=d[b];this.positionArray[h+4]=d[b+1];this.positionArray[h+5]=d[b+2];this.positionArray[h+6]=d[g];this.positionArray[h+7]=d[g+1];this.positionArray[h+8]=d[g+2];this.normalArray[h]=e[f];this.normalArray[h+1]=e[f+1];this.normalArray[h+2]=e[f+2];this.normalArray[h+3]=e[b];this.normalArray[h+4]=e[b+1];this.normalArray[h+5]=e[b+2];this.normalArray[h+6]=e[g];this.normalArray[h+7]=e[g+1];this.normalArray[h+8]=e[g+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
-function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,f,b,g){var j=this.size*Math.sqrt(b/g),h=f*this.size,m=e*this.size,n=d*this.size,y=Math.floor(h-j);if(y<1)y=1;h=Math.floor(h+j);if(h>this.size-1)h=this.size-1;var u=Math.floor(m-j);if(u<1)u=1;m=Math.floor(m+j);if(m>this.size-1)m=this.size-1;var o=Math.floor(n-j);if(o<1)o=1;j=Math.floor(n+j);
-if(j>this.size-1)j=this.size-1;var A,C,G,w,H,p;for(y=y;y<h;y++){n=this.size*this.size*y;C=y/this.size-f;H=C*C;for(C=u;C<m;C++){G=n+this.size*C;A=C/this.size-e;p=A*A;for(A=o;A<j;A++){w=A/this.size-d;w=b/(1.0E-6+w*w+p+H)-g;if(w>0)this.field[G+A]+=w}}}};this.addPlaneX=function(d,e){var f,b,g,j,h,m=this.size,n=this.yd,y=this.zd,u=this.field,o=m*Math.sqrt(d/e);if(o>m)o=m;for(f=0;f<o;f++){b=f/m;b=b*b;j=d/(1.0E-4+b)-e;if(j>0)for(b=0;b<m;b++){h=f+b*n;for(g=0;g<m;g++)u[y*g+h]+=j}}};this.addPlaneY=function(d,
-e){var f,b,g,j,h,m,n=this.size,y=this.yd,u=this.zd,o=this.field,A=n*Math.sqrt(d/e);if(A>n)A=n;for(b=0;b<A;b++){f=b/n;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){h=b*y;for(f=0;f<n;f++){m=h+f;for(g=0;g<n;g++)o[u*g+m]+=j}}}};this.addPlaneZ=function(d,e){var f,b,g,j,h,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(g=0;g<dist;g++){f=g/size;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){h=zd*g;for(b=0;b<size;b++){m=h+b*yd;for(f=0;f<size;f++)field[m+f]+=j}}}};this.reset=function(){var d;
-for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,f,b,g,j,h,m,n,y,u=this.size-2;for(g=1;g<u;g++){y=this.size2*g;m=(g-this.halfsize)/this.halfsize;for(b=1;b<u;b++){n=y+this.size*b;h=(b-this.halfsize)/this.halfsize;for(f=1;f<u;f++){j=(f-this.halfsize)/this.halfsize;e=n+f;this.polygonize(j,h,m,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(f){var b,g,j,h,m,n,y,u;for(b=
-0;b<f.count;b++){m=b*3;y=m+1;u=m+2;g=f.positionArray[m];j=f.positionArray[y];h=f.positionArray[u];n=new THREE.Vector3(g,j,h);g=f.normalArray[m];j=f.normalArray[y];h=f.normalArray[u];m=new THREE.Vector3(g,j,h);m.normalize();m=new THREE.Vertex(n,m);e.vertices.push(m)}nfaces=f.count/3;for(b=0;b<nfaces;b++){m=(d+b)*3;y=m+1;u=m+2;n=e.vertices[m].normal;g=e.vertices[y].normal;j=e.vertices[u].normal;m=new THREE.Face3(m,y,u,[n,g,j]);e.faces.push(m)}d+=nfaces;f.count=0});e.sortFacesByMaterial();return e};
+0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,f){return d+(e-d)*f};this.VIntX=function(d,e,f,b,h,j,g,m,n,y){h=(h-n)/(y-n);n=this.normal_cache;e[b]=j+h*this.delta;e[b+1]=g;e[b+2]=m;f[b]=this.lerp(n[d],n[d+3],h);f[b+1]=this.lerp(n[d+1],n[d+4],h);f[b+2]=this.lerp(n[d+2],n[d+5],h)};this.VIntY=function(d,e,f,b,h,j,g,m,n,y){h=(h-n)/(y-n);n=this.normal_cache;e[b]=j;e[b+1]=g+h*this.delta;e[b+
+2]=m;e=d+this.yd*3;f[b]=this.lerp(n[d],n[e],h);f[b+1]=this.lerp(n[d+1],n[e+1],h);f[b+2]=this.lerp(n[d+2],n[e+2],h)};this.VIntZ=function(d,e,f,b,h,j,g,m,n,y){h=(h-n)/(y-n);n=this.normal_cache;e[b]=j;e[b+1]=g;e[b+2]=m+h*this.delta;e=d+this.zd*3;f[b]=this.lerp(n[d],n[e],h);f[b+1]=this.lerp(n[d+1],n[e+1],h);f[b+2]=this.lerp(n[d+2],n[e+2],h)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
+this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,f,b,h,j){var g=b+1,m=b+this.yd,n=b+this.zd,y=g+this.yd,u=g+this.zd,o=b+this.yd+this.zd,A=g+this.yd+this.zd,C=0,G=this.field[b],w=this.field[g],H=this.field[m],p=this.field[y],l=this.field[n],v=this.field[u],t=this.field[o],k=this.field[A];if(G<h)C|=1;if(w<h)C|=2;if(H<h)C|=8;if(p<h)C|=4;if(l<h)C|=16;if(v<h)C|=32;if(t<h)C|=128;if(k<h)C|=64;var q=THREE.edgeTable[C];if(q==0)return 0;
+var x=this.delta,z=d+x,F=e+x;x=f+x;if(q&1){this.compNorm(b);this.compNorm(g);this.VIntX(b*3,this.vlist,this.nlist,0,h,d,e,f,G,w)}if(q&2){this.compNorm(g);this.compNorm(y);this.VIntY(g*3,this.vlist,this.nlist,3,h,z,e,f,w,p)}if(q&4){this.compNorm(m);this.compNorm(y);this.VIntX(m*3,this.vlist,this.nlist,6,h,d,F,f,H,p)}if(q&8){this.compNorm(b);this.compNorm(m);this.VIntY(b*3,this.vlist,this.nlist,9,h,d,e,f,G,H)}if(q&16){this.compNorm(n);this.compNorm(u);this.VIntX(n*3,this.vlist,this.nlist,12,h,d,e,x,
+l,v)}if(q&32){this.compNorm(u);this.compNorm(A);this.VIntY(u*3,this.vlist,this.nlist,15,h,z,e,x,v,k)}if(q&64){this.compNorm(o);this.compNorm(A);this.VIntX(o*3,this.vlist,this.nlist,18,h,d,F,x,t,k)}if(q&128){this.compNorm(n);this.compNorm(o);this.VIntY(n*3,this.vlist,this.nlist,21,h,d,e,x,l,t)}if(q&256){this.compNorm(b);this.compNorm(n);this.VIntZ(b*3,this.vlist,this.nlist,24,h,d,e,f,G,l)}if(q&512){this.compNorm(g);this.compNorm(u);this.VIntZ(g*3,this.vlist,this.nlist,27,h,z,e,f,w,v)}if(q&1024){this.compNorm(y);
+this.compNorm(A);this.VIntZ(y*3,this.vlist,this.nlist,30,h,z,F,f,p,k)}if(q&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,h,d,F,f,H,t)}C<<=4;for(h=b=0;THREE.triTable[C+h]!=-1;){d=C+h;e=d+1;f=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[f],j);h+=3;b++}return b};this.posnormtriv=function(d,e,f,b,h,j){var g=this.count*3;this.positionArray[g]=d[f];this.positionArray[g+1]=d[f+1];this.positionArray[g+2]=d[f+2];this.positionArray[g+
+3]=d[b];this.positionArray[g+4]=d[b+1];this.positionArray[g+5]=d[b+2];this.positionArray[g+6]=d[h];this.positionArray[g+7]=d[h+1];this.positionArray[g+8]=d[h+2];this.normalArray[g]=e[f];this.normalArray[g+1]=e[f+1];this.normalArray[g+2]=e[f+2];this.normalArray[g+3]=e[b];this.normalArray[g+4]=e[b+1];this.normalArray[g+5]=e[b+2];this.normalArray[g+6]=e[h];this.normalArray[g+7]=e[h+1];this.normalArray[g+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
+function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,f,b,h){var j=this.size*Math.sqrt(b/h),g=f*this.size,m=e*this.size,n=d*this.size,y=Math.floor(g-j);if(y<1)y=1;g=Math.floor(g+j);if(g>this.size-1)g=this.size-1;var u=Math.floor(m-j);if(u<1)u=1;m=Math.floor(m+j);if(m>this.size-1)m=this.size-1;var o=Math.floor(n-j);if(o<1)o=1;j=Math.floor(n+j);
+if(j>this.size-1)j=this.size-1;var A,C,G,w,H,p;for(y=y;y<g;y++){n=this.size*this.size*y;C=y/this.size-f;H=C*C;for(C=u;C<m;C++){G=n+this.size*C;A=C/this.size-e;p=A*A;for(A=o;A<j;A++){w=A/this.size-d;w=b/(1.0E-6+w*w+p+H)-h;if(w>0)this.field[G+A]+=w}}}};this.addPlaneX=function(d,e){var f,b,h,j,g,m=this.size,n=this.yd,y=this.zd,u=this.field,o=m*Math.sqrt(d/e);if(o>m)o=m;for(f=0;f<o;f++){b=f/m;b=b*b;j=d/(1.0E-4+b)-e;if(j>0)for(b=0;b<m;b++){g=f+b*n;for(h=0;h<m;h++)u[y*h+g]+=j}}};this.addPlaneY=function(d,
+e){var f,b,h,j,g,m,n=this.size,y=this.yd,u=this.zd,o=this.field,A=n*Math.sqrt(d/e);if(A>n)A=n;for(b=0;b<A;b++){f=b/n;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){g=b*y;for(f=0;f<n;f++){m=g+f;for(h=0;h<n;h++)o[u*h+m]+=j}}}};this.addPlaneZ=function(d,e){var f,b,h,j,g,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(h=0;h<dist;h++){f=h/size;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){g=zd*h;for(b=0;b<size;b++){m=g+b*yd;for(f=0;f<size;f++)field[m+f]+=j}}}};this.reset=function(){var d;
+for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,f,b,h,j,g,m,n,y,u=this.size-2;for(h=1;h<u;h++){y=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(b=1;b<u;b++){n=y+this.size*b;g=(b-this.halfsize)/this.halfsize;for(f=1;f<u;f++){j=(f-this.halfsize)/this.halfsize;e=n+f;this.polygonize(j,g,m,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(f){var b,h,j,g,m,n,y,u;for(b=
+0;b<f.count;b++){m=b*3;y=m+1;u=m+2;h=f.positionArray[m];j=f.positionArray[y];g=f.positionArray[u];n=new THREE.Vector3(h,j,g);h=f.normalArray[m];j=f.normalArray[y];g=f.normalArray[u];m=new THREE.Vector3(h,j,g);m.normalize();m=new THREE.Vertex(n,m);e.vertices.push(m)}nfaces=f.count/3;for(b=0;b<nfaces;b++){m=(d+b)*3;y=m+1;u=m+2;n=e.vertices[m].normal;h=e.vertices[y].normal;j=e.vertices[u].normal;m=new THREE.Face3(m,y,u,[n,h,j]);e.faces.push(m)}d+=nfaces;f.count=0});e.sortFacesByMaterial();return e};
 this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
@@ -298,25 +298,25 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
 THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
 c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
-THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(g){THREE.Loader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,d,f,e,b)};c.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var g=new XMLHttpRequest,j=e+"/"+a,h=0;
-g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.Loader.prototype.createBinModel(g.responseText,d,f,c):alert("Couldn't load ["+j+"] ["+g.status+"]");else if(g.readyState==3){if(b){if(h==0)h=g.getResponseHeader("Content-Length");b({total:h,loaded:g.responseText.length})}}else if(g.readyState==2)h=g.getResponseHeader("Content-Length")};g.open("GET",j,true);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)},
-createBinModel:function(a,c,d,e){var f=function(b){function g(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2),ja=n(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function j(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2);return(n(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function h(E,L){var J=n(E,L);return(n(E,L+1)<<8)+J}function m(E,L){var J=n(E,L);return J>127?J-256:J}function n(E,L){return E.charCodeAt(L)&255}function y(E){var L,
-J,X;L=j(a,E);J=j(a,E+t);X=j(a,E+k);E=h(a,E+q);THREE.Loader.prototype.f3(w,L,J,X,E)}function u(E){var L,J,X,ea,ja,ia;L=j(a,E);J=j(a,E+t);X=j(a,E+k);ea=h(a,E+q);ja=j(a,E+x);ia=j(a,E+z);E=j(a,E+F);THREE.Loader.prototype.f3n(w,l,L,J,X,ea,ja,ia,E)}function o(E){var L,J,X,ea;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);E=h(a,E+N);THREE.Loader.prototype.f4(w,L,J,X,ea,E)}function A(E){var L,J,X,ea,ja,ia,qa,la;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);ja=h(a,E+N);ia=j(a,E+O);qa=j(a,E+Q);la=j(a,E+T);E=j(a,E+
-U);THREE.Loader.prototype.f4n(w,l,L,J,X,ea,ja,ia,qa,la,E)}function C(E){var L,J;L=j(a,E);J=j(a,E+ba);E=j(a,E+ca);THREE.Loader.prototype.uv3(w.uvs,v[L*2],v[L*2+1],v[J*2],v[J*2+1],v[E*2],v[E*2+1])}function G(E){var L,J,X;L=j(a,E);J=j(a,E+S);X=j(a,E+K);E=j(a,E+Z);THREE.Loader.prototype.uv4(w.uvs,v[L*2],v[L*2+1],v[J*2],v[J*2+1],v[X*2],v[X*2+1],v[E*2],v[E*2+1])}var w=this,H=0,p,l=[],v=[],t,k,q,x,z,F,B,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
+THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,f,e,b)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var h=new XMLHttpRequest,j=e+"/"+a,g=0;
+h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,f,c):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(b){if(g==0)g=h.getResponseHeader("Content-Length");b({total:g,loaded:h.responseText.length})}}else if(h.readyState==2)g=h.getResponseHeader("Content-Length")};h.open("GET",j,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
+createBinModel:function(a,c,d,e){var f=function(b){function h(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2),ja=n(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function j(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2);return(n(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function g(E,L){var J=n(E,L);return(n(E,L+1)<<8)+J}function m(E,L){var J=n(E,L);return J>127?J-256:J}function n(E,L){return E.charCodeAt(L)&255}function y(E){var L,
+J,X;L=j(a,E);J=j(a,E+t);X=j(a,E+k);E=g(a,E+q);THREE.Loader.prototype.f3(w,L,J,X,E)}function u(E){var L,J,X,ea,ja,ia;L=j(a,E);J=j(a,E+t);X=j(a,E+k);ea=g(a,E+q);ja=j(a,E+x);ia=j(a,E+z);E=j(a,E+F);THREE.Loader.prototype.f3n(w,l,L,J,X,ea,ja,ia,E)}function o(E){var L,J,X,ea;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);E=g(a,E+N);THREE.Loader.prototype.f4(w,L,J,X,ea,E)}function A(E){var L,J,X,ea,ja,ia,qa,ma;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);ja=g(a,E+N);ia=j(a,E+O);qa=j(a,E+Q);ma=j(a,E+T);E=j(a,E+
+U);THREE.Loader.prototype.f4n(w,l,L,J,X,ea,ja,ia,qa,ma,E)}function C(E){var L,J;L=j(a,E);J=j(a,E+ba);E=j(a,E+ca);THREE.Loader.prototype.uv3(w.uvs,v[L*2],v[L*2+1],v[J*2],v[J*2+1],v[E*2],v[E*2+1])}function G(E){var L,J,X;L=j(a,E);J=j(a,E+S);X=j(a,E+K);E=j(a,E+Z);THREE.Loader.prototype.uv4(w.uvs,v[L*2],v[L*2+1],v[J*2],v[J*2+1],v[X*2],v[X*2+1],v[E*2],v[E*2+1])}var w=this,H=0,p,l=[],v=[],t,k,q,x,z,F,B,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
 e,b);p={signature:a.substr(H,8),header_bytes:n(a,H+8),vertex_coordinate_bytes:n(a,H+9),normal_coordinate_bytes:n(a,H+10),uv_coordinate_bytes:n(a,H+11),vertex_index_bytes:n(a,H+12),normal_index_bytes:n(a,H+13),uv_index_bytes:n(a,H+14),material_index_bytes:n(a,H+15),nvertices:j(a,H+16),nnormals:j(a,H+16+4),nuvs:j(a,H+16+8),ntri_flat:j(a,H+16+12),ntri_smooth:j(a,H+16+16),ntri_flat_uv:j(a,H+16+20),ntri_smooth_uv:j(a,H+16+24),nquad_flat:j(a,H+16+28),nquad_smooth:j(a,H+16+32),nquad_flat_uv:j(a,H+16+36),
 nquad_smooth_uv:j(a,H+16+40)};H+=p.header_bytes;t=p.vertex_index_bytes;k=p.vertex_index_bytes*2;q=p.vertex_index_bytes*3;x=p.vertex_index_bytes*3+p.material_index_bytes;z=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;F=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;B=p.vertex_index_bytes;D=p.vertex_index_bytes*2;I=p.vertex_index_bytes*3;N=p.vertex_index_bytes*4;O=p.vertex_index_bytes*4+p.material_index_bytes;Q=p.vertex_index_bytes*4+p.material_index_bytes+
 p.normal_index_bytes;T=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*2;U=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;ba=p.uv_index_bytes;ca=p.uv_index_bytes*2;S=p.uv_index_bytes;K=p.uv_index_bytes*2;Z=p.uv_index_bytes*3;b=p.vertex_index_bytes*3+p.material_index_bytes;ha=p.vertex_index_bytes*4+p.material_index_bytes;V=p.ntri_flat*b;P=p.ntri_smooth*(b+p.normal_index_bytes*3);W=p.ntri_flat_uv*(b+p.uv_index_bytes*3);$=p.ntri_smooth_uv*(b+p.normal_index_bytes*
-3+p.uv_index_bytes*3);da=p.nquad_flat*ha;b=p.nquad_smooth*(ha+p.normal_index_bytes*4);ha=p.nquad_flat_uv*(ha+p.uv_index_bytes*4);H+=function(E){var L,J,X,ea=p.vertex_coordinate_bytes*3,ja=E+p.nvertices*ea;for(E=E;E<ja;E+=ea){L=g(a,E);J=g(a,E+p.vertex_coordinate_bytes);X=g(a,E+p.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,L,J,X)}return p.nvertices*ea}(H);H+=function(E){var L,J,X,ea=p.normal_coordinate_bytes*3,ja=E+p.nnormals*ea;for(E=E;E<ja;E+=ea){L=m(a,E);J=m(a,E+p.normal_coordinate_bytes);
-X=m(a,E+p.normal_coordinate_bytes*2);l.push(L/127,J/127,X/127)}return p.nnormals*ea}(H);H+=function(E){var L,J,X=p.uv_coordinate_bytes*2,ea=E+p.nuvs*X;for(E=E;E<ea;E+=X){L=g(a,E);J=g(a,E+p.uv_coordinate_bytes);v.push(L,J)}return p.nuvs*X}(H);H=H;V=H+V;P=V+P;W=P+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,X=J+p.uv_index_bytes*3,ea=E+p.ntri_flat_uv*X;for(L=E;L<ea;L+=X){y(L);C(L+J)}return ea-E})(P);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+
+3+p.uv_index_bytes*3);da=p.nquad_flat*ha;b=p.nquad_smooth*(ha+p.normal_index_bytes*4);ha=p.nquad_flat_uv*(ha+p.uv_index_bytes*4);H+=function(E){var L,J,X,ea=p.vertex_coordinate_bytes*3,ja=E+p.nvertices*ea;for(E=E;E<ja;E+=ea){L=h(a,E);J=h(a,E+p.vertex_coordinate_bytes);X=h(a,E+p.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,L,J,X)}return p.nvertices*ea}(H);H+=function(E){var L,J,X,ea=p.normal_coordinate_bytes*3,ja=E+p.nnormals*ea;for(E=E;E<ja;E+=ea){L=m(a,E);J=m(a,E+p.normal_coordinate_bytes);
+X=m(a,E+p.normal_coordinate_bytes*2);l.push(L/127,J/127,X/127)}return p.nnormals*ea}(H);H+=function(E){var L,J,X=p.uv_coordinate_bytes*2,ea=E+p.nuvs*X;for(E=E;E<ea;E+=X){L=h(a,E);J=h(a,E+p.uv_coordinate_bytes);v.push(L,J)}return p.nuvs*X}(H);H=H;V=H+V;P=V+P;W=P+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,X=J+p.uv_index_bytes*3,ea=E+p.ntri_flat_uv*X;for(L=E;L<ea;L+=X){y(L);C(L+J)}return ea-E})(P);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+
 p.normal_index_bytes*3,X=J+p.uv_index_bytes*3,ea=E+p.ntri_smooth_uv*X;for(L=E;L<ea;L+=X){u(L);C(L+J)}return ea-E})(W);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,X=J+p.uv_index_bytes*4,ea=E+p.nquad_flat_uv*X;for(L=E;L<ea;L+=X){o(L);G(L+J)}return ea-E})(b);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,X=J+p.uv_index_bytes*4,ea=E+p.nquad_smooth_uv*X;for(L=E;L<ea;L+=X){A(L);G(L+J)}return ea-E})(ha);(function(E){var L,J=p.vertex_index_bytes*
 3+p.material_index_bytes,X=E+p.ntri_flat*J;for(L=E;L<X;L+=J)y(L);return X-E})(H);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,X=E+p.ntri_smooth*J;for(L=E;L<X;L+=J)u(L);return X-E})(V);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,X=E+p.nquad_flat*J;for(L=E;L<X;L+=J)o(L);return X-E})($);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,X=E+p.nquad_smooth*J;for(L=E;L<X;L+=J)A(L);return X-E})(da);
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var g,j,h,m,n;g=0;for(j=a.vertices.length;g<j;g+=3){h=a.vertices[g];m=a.vertices[g+1];n=a.vertices[g+2];THREE.Loader.prototype.v(b,h,m,n)}})();(function(){function g(A,C){THREE.Loader.prototype.f3(b,A[C],
-A[C+1],A[C+2],A[C+3])}function j(A,C){THREE.Loader.prototype.f3n(b,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6])}function h(A,C){THREE.Loader.prototype.f4(b,A[C],A[C+1],A[C+2],A[C+3],A[C+4])}function m(A,C){THREE.Loader.prototype.f4n(b,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6],A[C+7],A[C+8])}function n(A,C){var G,w,H,p,l,v,t,k,q;G=A[C];w=A[C+1];H=A[C+2];p=a.uvs[G*2];t=a.uvs[G*2+1];l=a.uvs[w*2];k=a.uvs[w*2+1];v=a.uvs[H*2];q=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,p,
+this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var h,j,g,m,n;h=0;for(j=a.vertices.length;h<j;h+=3){g=a.vertices[h];m=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(b,g,m,n)}})();(function(){function h(A,C){THREE.Loader.prototype.f3(b,A[C],
+A[C+1],A[C+2],A[C+3])}function j(A,C){THREE.Loader.prototype.f3n(b,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6])}function g(A,C){THREE.Loader.prototype.f4(b,A[C],A[C+1],A[C+2],A[C+3],A[C+4])}function m(A,C){THREE.Loader.prototype.f4n(b,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6],A[C+7],A[C+8])}function n(A,C){var G,w,H,p,l,v,t,k,q;G=A[C];w=A[C+1];H=A[C+2];p=a.uvs[G*2];t=a.uvs[G*2+1];l=a.uvs[w*2];k=a.uvs[w*2+1];v=a.uvs[H*2];q=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,p,
 t,l,k,v,q);if(a.uvs2){p=a.uvs2[G*2];t=a.uvs2[G*2+1];l=a.uvs2[w*2];k=a.uvs2[w*2+1];v=a.uvs2[H*2];q=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(b.uvs2,p,1-t,l,1-k,v,1-q)}}function y(A,C){var G,w,H,p,l,v,t,k,q,x,z,F;G=A[C];w=A[C+1];H=A[C+2];p=A[C+3];l=a.uvs[G*2];q=a.uvs[G*2+1];v=a.uvs[w*2];x=a.uvs[w*2+1];t=a.uvs[H*2];z=a.uvs[H*2+1];k=a.uvs[p*2];F=a.uvs[p*2+1];THREE.Loader.prototype.uv4(b.uvs,l,q,v,x,t,z,k,F);if(a.uvs2){l=a.uvs2[G*2];q=a.uvs2[G*2+1];v=a.uvs2[w*2];x=a.uvs2[w*2+1];t=a.uvs2[H*2];z=a.uvs2[H*
-2+1];k=a.uvs2[p*2];F=a.uvs2[p*2+1];THREE.Loader.prototype.uv4(b.uvs2,l,1-q,v,1-x,t,1-z,k,1-F)}}var u,o;u=0;for(o=a.triangles_uv.length;u<o;u+=7){g(a.triangles_uv,u);n(a.triangles_uv,u+4)}u=0;for(o=a.triangles_n_uv.length;u<o;u+=10){j(a.triangles_n_uv,u);n(a.triangles_n_uv,u+7)}u=0;for(o=a.quads_uv.length;u<o;u+=9){h(a.quads_uv,u);y(a.quads_uv,u+5)}u=0;for(o=a.quads_n_uv.length;u<o;u+=13){m(a.quads_n_uv,u);y(a.quads_n_uv,u+9)}u=0;for(o=a.triangles.length;u<o;u+=4)g(a.triangles,u);u=0;for(o=a.triangles_n.length;u<
-o;u+=7)j(a.triangles_n,u);u=0;for(o=a.quads.length;u<o;u+=5)h(a.quads,u);u=0;for(o=a.quads_n.length;u<o;u+=9)m(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
-a.materials[b]))},f3n:function(a,c,d,e,f,b,g,j,h){b=a.materials[b];var m=c[j*3],n=c[j*3+1];j=c[j*3+2];var y=c[h*3],u=c[h*3+1];h=c[h*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(m,n,j),new THREE.Vector3(y,u,h)],b))},f4n:function(a,c,d,e,f,b,g,j,h,m,n){g=a.materials[g];var y=c[h*3],u=c[h*3+1];h=c[h*3+2];var o=c[m*3],A=c[m*3+1];m=c[m*3+2];var C=c[n*3],G=c[n*3+1];n=c[n*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[j*3],c[j*3+1],
-c[j*3+2]),new THREE.Vector3(y,u,h),new THREE.Vector3(o,A,m),new THREE.Vector3(C,G,n)],g))},uv3:function(a,c,d,e,f,b,g){var j=[];j.push(new THREE.UV(c,d));j.push(new THREE.UV(e,f));j.push(new THREE.UV(b,g));a.push(j)},uv4:function(a,c,d,e,f,b,g,j,h){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,g));m.push(new THREE.UV(j,h));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
-d)]},createMaterial:function(a,c){function d(g){g=Math.log(g)/Math.LN2;return Math.floor(g)==g}function e(g,j){var h=new Image;h.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));g.image.width=m;g.image.height=n;g.image.getContext("2d").drawImage(this,0,0,m,n)}else g.image=this;g.image.loaded=1};h.src=j}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
+2+1];k=a.uvs2[p*2];F=a.uvs2[p*2+1];THREE.Loader.prototype.uv4(b.uvs2,l,1-q,v,1-x,t,1-z,k,1-F)}}var u,o;u=0;for(o=a.triangles_uv.length;u<o;u+=7){h(a.triangles_uv,u);n(a.triangles_uv,u+4)}u=0;for(o=a.triangles_n_uv.length;u<o;u+=10){j(a.triangles_n_uv,u);n(a.triangles_n_uv,u+7)}u=0;for(o=a.quads_uv.length;u<o;u+=9){g(a.quads_uv,u);y(a.quads_uv,u+5)}u=0;for(o=a.quads_n_uv.length;u<o;u+=13){m(a.quads_n_uv,u);y(a.quads_n_uv,u+9)}u=0;for(o=a.triangles.length;u<o;u+=4)h(a.triangles,u);u=0;for(o=a.triangles_n.length;u<
+o;u+=7)j(a.triangles_n,u);u=0;for(o=a.quads.length;u<o;u+=5)g(a.quads,u);u=0;for(o=a.quads_n.length;u<o;u+=9)m(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
+a.materials[b]))},f3n:function(a,c,d,e,f,b,h,j,g){b=a.materials[b];var m=c[j*3],n=c[j*3+1];j=c[j*3+2];var y=c[g*3],u=c[g*3+1];g=c[g*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,n,j),new THREE.Vector3(y,u,g)],b))},f4n:function(a,c,d,e,f,b,h,j,g,m,n){h=a.materials[h];var y=c[g*3],u=c[g*3+1];g=c[g*3+2];var o=c[m*3],A=c[m*3+1];m=c[m*3+2];var C=c[n*3],G=c[n*3+1];n=c[n*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[j*3],c[j*3+1],
+c[j*3+2]),new THREE.Vector3(y,u,g),new THREE.Vector3(o,A,m),new THREE.Vector3(C,G,n)],h))},uv3:function(a,c,d,e,f,b,h){var j=[];j.push(new THREE.UV(c,d));j.push(new THREE.UV(e,f));j.push(new THREE.UV(b,h));a.push(j)},uv4:function(a,c,d,e,f,b,h,j,g){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,h));m.push(new THREE.UV(j,g));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
+d)]},createMaterial:function(a,c){function d(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function e(h,j){var g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));h.image.width=m;h.image.height=n;h.image.getContext("2d").drawImage(this,0,0,m,n)}else h.image=this;h.image.loaded=1};g.src=j}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
 e(f.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){b=document.createElement("canvas");f.light_map=new THREE.Texture(b);e(f.light_map,c+"/"+a.map_lightmap)}return f},extractUrlbase:function(a){a=a.split("/");a.pop();
 return a.join("/")}};

+ 2 - 2
examples/scene_test.html

@@ -260,7 +260,7 @@
 					camera.aspect = window.innerWidth / window.innerHeight;
 					camera.updateProjectionMatrix();
 					
-					renderer.setClearColor( result.bgColor.hex, result.bgAlpha );
+					renderer.setClearColor( result.bgColor, result.bgAlpha );
 					
 					*/
 
@@ -322,7 +322,7 @@
 				camera.aspect = window.innerWidth / window.innerHeight;
 				camera.updateProjectionMatrix();
 				
-				renderer.setClearColor( loaded.bgColor.hex, loaded.bgAlpha );
+				renderer.setClearColor( loaded.bgColor, loaded.bgAlpha );
 				
 			}
 			

+ 1 - 0
examples/uqbiquity_test.html

@@ -80,6 +80,7 @@
 		<script type="text/javascript" src="../src/extras/primitives/Cube.js"></script>
 		<script type="text/javascript" src="../src/extras/primitives/Plane.js"></script>
 		<script type="text/javascript" src="../src/extras/primitives/Cylinder.js"></script>
+		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 

+ 13 - 1
src/renderers/CanvasRenderer.js

@@ -95,7 +95,19 @@ THREE.CanvasRenderer = function () {
 
 	};
 
-	this.setClearColor = function( hex, opacity ) {
+	this.setClearColor = function( color, opacity ) {
+
+		_clearColor = color;
+		_clearOpacity = opacity;
+
+		_clearRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
+		_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
+
+		this.clear();
+
+	};
+
+	this.setClearColorHex = function( hex, opacity ) {
 
 		_clearColor.setHex( hex );
 		_clearOpacity = opacity;

+ 7 - 1
src/renderers/WebGLRenderer.js

@@ -74,13 +74,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	this.setClearColor = function( hex, alpha ) {
+	this.setClearColorHex = function( hex, alpha ) {
 
 		var color = new THREE.Color( hex );
 		_gl.clearColor( color.r, color.g, color.b, alpha );
 
 	};
 
+	this.setClearColor = function( color, alpha ) {
+
+		_gl.clearColor( color.r, color.g, color.b, alpha );
+
+	};
+
 	this.clear = function () {
 
 		_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT );

+ 11 - 2
src/renderers/WebGLRenderer2.js

@@ -67,9 +67,18 @@ THREE.WebGLRenderer2 = function ( antialias ) {
 
 	};
 
-	this.setClearColor = function( hex, opacity ) {
+	this.setClearColor = function( color, opacity ) {
 
-		_clearColor = hex.setHex( hex );
+		_clearColor = color;
+		_clearOpacity = opacity;
+
+		_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );
+
+	};
+
+	this.setClearColorHex = function( hex, opacity ) {
+
+		_clearColor.setHex( hex );
 		_clearOpacity = opacity;
 
 		_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );