Browse Source

Added vertex colors to ASCII model loader and to Blender exporter (plus corresponding example).

Also fixed quads vertex color bug in WebGLRenderer and did small optimization of face state handling.
alteredq 14 years ago
parent
commit
a9af9481e5

+ 139 - 139
build/Three.js

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

+ 140 - 140
build/ThreeDebug.js

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

+ 172 - 171
build/ThreeExtras.js

@@ -13,32 +13,32 @@ 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;
 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+")"}};
 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=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,g=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function c(H,x,I,t){t=t.clone().subSelf(x);I=I.clone().subSelf(x);var k=H.clone().subSelf(x);H=t.dot(t);x=t.dot(I);t=t.dot(k);var w=I.dot(I);I=I.dot(k);k=1/(H*w-x*x);w=(w*t-x*I)*k;H=(H*I-x*t)*k;return w>0&&H>0&&w+H<1}var d,e,g,f,h,b,j,l,p,A,
-q,m=a.geometry,B=m.vertices,E=[];d=0;for(e=m.faces.length;d<e;d++){g=m.faces[d];A=this.origin.clone();q=this.direction.clone();f=a.matrix.multiplyVector3(B[g.a].position.clone());h=a.matrix.multiplyVector3(B[g.b].position.clone());b=a.matrix.multiplyVector3(B[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(B[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());p=q.dot(l);if(p<0){l=l.dot((new THREE.Vector3).sub(f,A))/p;A=A.addSelf(q.multiplyScalar(l));
-if(g instanceof THREE.Face3){if(c(A,f,h,b)){g={distance:this.origin.distanceTo(A),point:A,face:g,object:a};E.push(g)}}else if(g instanceof THREE.Face4)if(c(A,f,h,j)||c(A,h,b,j)){g={distance:this.origin.distanceTo(A),point:A,face:g,object:a};E.push(g)}}}return E}};
-THREE.Rectangle=function(){function a(){f=e-c;h=g-d}var c,d,e,g,f,h,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,l,p,A){b=false;c=j;d=l;e=p;g=A;a()};this.addPoint=function(j,l){if(b){b=false;c=j;d=l;e=j;g=l}else{c=c<j?c:j;d=d<l?d:l;e=e>j?e:j;g=g>l?
-g:l}a()};this.add3Points=function(j,l,p,A,q,m){if(b){b=false;c=j<p?j<q?j:q:p<q?p:q;d=l<A?l<m?l:m:A<m?A:m;e=j>p?j>q?j:q:p>q?p:q;g=l>A?l>m?l:m:A>m?A:m}else{c=j<p?j<q?j<c?j:c:q<c?q:c:p<q?p<c?p:c:q<c?q:c;d=l<A?l<m?l<d?l:d:m<d?m:d:A<m?A<d?A:d:m<d?m:d;e=j>p?j>q?j>e?j:e:q>e?q:e:p>q?p>e?p:e:q>e?q:e;g=l>A?l>m?l>g?l:g:m>g?m:g:A>m?A>g?A:g:m>g?m:g}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();e=j.getRight();g=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();d=d<j.getTop()?d:j.getTop();
+THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,g=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(f,h){return f.distance-h.distance});return g},intersectObject:function(a){function c(H,y,I,v){v=v.clone().subSelf(y);I=I.clone().subSelf(y);var L=H.clone().subSelf(y);H=v.dot(v);y=v.dot(I);v=v.dot(L);var k=I.dot(I);I=I.dot(L);L=1/(H*k-y*y);k=(k*v-y*I)*L;H=(H*I-y*v)*L;return k>0&&H>0&&k+H<1}var d,e,g,f,h,b,j,l,t,A,
+w,o=a.geometry,p=o.vertices,C=[];d=0;for(e=o.faces.length;d<e;d++){g=o.faces[d];A=this.origin.clone();w=this.direction.clone();f=a.matrix.multiplyVector3(p[g.a].position.clone());h=a.matrix.multiplyVector3(p[g.b].position.clone());b=a.matrix.multiplyVector3(p[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.multiplyVector3(p[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());t=w.dot(l);if(t<0){l=l.dot((new THREE.Vector3).sub(f,A))/t;A=A.addSelf(w.multiplyScalar(l));
+if(g instanceof THREE.Face3){if(c(A,f,h,b)){g={distance:this.origin.distanceTo(A),point:A,face:g,object:a};C.push(g)}}else if(g instanceof THREE.Face4)if(c(A,f,h,j)||c(A,h,b,j)){g={distance:this.origin.distanceTo(A),point:A,face:g,object:a};C.push(g)}}}return C}};
+THREE.Rectangle=function(){function a(){f=e-c;h=g-d}var c,d,e,g,f,h,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,l,t,A){b=false;c=j;d=l;e=t;g=A;a()};this.addPoint=function(j,l){if(b){b=false;c=j;d=l;e=j;g=l}else{c=c<j?c:j;d=d<l?d:l;e=e>j?e:j;g=g>l?
+g:l}a()};this.add3Points=function(j,l,t,A,w,o){if(b){b=false;c=j<t?j<w?j:w:t<w?t:w;d=l<A?l<o?l:o:A<o?A:o;e=j>t?j>w?j:w:t>w?t:w;g=l>A?l>o?l:o:A>o?A:o}else{c=j<t?j<w?j<c?j:c:w<c?w:c:t<w?t<c?t:c:w<c?w:c;d=l<A?l<o?l<d?l:d:o<d?o:d:A<o?A<d?A:d:o<d?o:d;e=j>t?j>w?j>e?j:e:w>e?w:e:t>w?t>e?t:e:w>e?w:e;g=l>A?l>o?l>g?l:g:o>g?o:g:A>o?A>g?A:g:o>g?o:g}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();e=j.getRight();g=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();d=d<j.getTop()?d:j.getTop();
 e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){c-=j;d-=j;e+=j;g+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
 e=e>j.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){c-=j;d-=j;e+=j;g+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=e=d=c=0;a()};this.isEmpty=function(){return b};this.toString=
 function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", 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},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
 function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+f+", 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},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
-THREE.Matrix4=function(a,c,d,e,g,f,h,b,j,l,p,A,q,m,B,E){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=b||0;this.n31=j||0;this.n32=l||0;this.n33=p||1;this.n34=A||0;this.n41=q||0;this.n42=m||0;this.n43=B||0;this.n44=E||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,g,f,h,b,j,l,p,A,q,m,B,E){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=b;this.n31=j;this.n32=l;this.n33=p;this.n34=A;this.n41=q;this.n42=m;this.n43=B;this.n44=E;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,c,d,e,g,f,h,b,j,l,t,A,w,o,p,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=b||0;this.n31=j||0;this.n32=l||0;this.n33=t||1;this.n34=A||0;this.n41=w||0;this.n42=o||0;this.n43=p||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,g,f,h,b,j,l,t,A,w,o,p,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=b;this.n31=j;this.n32=l;this.n33=t;this.n34=A;this.n41=w;this.n42=o;this.n43=p;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,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,c).normalize();e.cross(d,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
 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,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,c).normalize();e.cross(d,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
 this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.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,g=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)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
 this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.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,g=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)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*
-e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;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,g=a.n13,f=a.n14,h=a.n21,b=a.n22,j=a.n23,l=a.n24,p=a.n31,
-A=a.n32,q=a.n33,m=a.n34,B=a.n41,E=a.n42,H=a.n43,x=a.n44,I=c.n11,t=c.n12,k=c.n13,w=c.n14,u=c.n21,n=c.n22,o=c.n23,v=c.n24,D=c.n31,y=c.n32,C=c.n33,z=c.n34,F=c.n41,J=c.n42,M=c.n43,Q=c.n44;this.n11=d*I+e*u+g*D+f*F;this.n12=d*t+e*n+g*y+f*J;this.n13=d*k+e*o+g*C+f*M;this.n14=d*w+e*v+g*z+f*Q;this.n21=h*I+b*u+j*D+l*F;this.n22=h*t+b*n+j*y+l*J;this.n23=h*k+b*o+j*C+l*M;this.n24=h*w+b*v+j*z+l*Q;this.n31=p*I+A*u+q*D+m*F;this.n32=p*t+A*n+q*y+m*J;this.n33=p*k+A*o+q*C+m*M;this.n34=p*w+A*v+q*z+m*Q;this.n41=B*I+E*u+
-H*D+x*F;this.n42=B*t+E*n+H*y+x*J;this.n43=B*k+E*o+H*C+x*M;this.n44=B*w+E*v+H*z+x*Q;return this},multiplyToArray:function(a,c,d){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,b=a.n21,j=a.n22,l=a.n23,p=a.n24,A=a.n31,q=a.n32,m=a.n33,B=a.n34,E=a.n41,H=a.n42,x=a.n43;a=a.n44;var I=c.n11,t=c.n12,k=c.n13,w=c.n14,u=c.n21,n=c.n22,o=c.n23,v=c.n24,D=c.n31,y=c.n32,C=c.n33,z=c.n34,F=c.n41,J=c.n42,M=c.n43;c=c.n44;this.n11=e*I+g*u+f*D+h*F;this.n12=e*t+g*n+f*y+h*J;this.n13=e*k+g*o+f*C+h*M;this.n14=e*w+g*v+f*z+h*c;this.n21=
-b*I+j*u+l*D+p*F;this.n22=b*t+j*n+l*y+p*J;this.n23=b*k+j*o+l*C+p*M;this.n24=b*w+j*v+l*z+p*c;this.n31=A*I+q*u+m*D+B*F;this.n32=A*t+q*n+m*y+B*J;this.n33=A*k+q*o+m*C+B*M;this.n34=A*w+q*v+m*z+B*c;this.n41=E*I+H*u+x*D+a*F;this.n42=E*t+H*n+x*y+a*J;this.n43=E*k+H*o+x*C+a*M;this.n44=E*w+H*v+x*z+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;
-d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,b=this.n23,j=this.n24,l=this.n31,p=this.n32,A=this.n33,q=this.n34,m=this.n41,B=this.n42,E=this.n43,H=this.n44,x=a.n11,I=a.n21,t=a.n31,k=a.n41,w=a.n12,u=a.n22,n=a.n32,o=a.n42,v=a.n13,D=a.n23,y=a.n33,C=a.n43,z=a.n14,F=a.n24,J=a.n34;a=a.n44;this.n11=c*x+d*I+e*t+g*k;this.n12=c*w+d*u+e*n+g*o;this.n13=c*v+d*D+e*y+g*C;this.n14=c*z+d*F+e*J+g*a;this.n21=f*x+h*I+b*t+j*k;this.n22=f*w+h*
-u+b*n+j*o;this.n23=f*v+h*D+b*y+j*C;this.n24=f*z+h*F+b*J+j*a;this.n31=l*x+p*I+A*t+q*k;this.n32=l*w+p*u+A*n+q*o;this.n33=l*v+p*D+A*y+q*C;this.n34=l*z+p*F+A*J+q*a;this.n41=m*x+B*I+E*t+H*k;this.n42=m*w+B*u+E*n+H*o;this.n43=m*v+B*D+E*y+H*C;this.n44=m*z+B*F+E*J+H*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,g=this.n21,f=this.n22,h=this.n23,b=this.n24,j=this.n31,l=this.n32,p=this.n33,A=this.n34,q=this.n41,m=this.n42,B=this.n43,E=this.n44;return e*h*l*q-d*b*l*q-e*f*p*q+c*b*p*q+d*f*A*q-c*h*A*q-e*h*j*m+d*b*j*m+e*g*p*m-a*b*p*m-d*g*A*m+a*h*A*m+e*f*j*B-c*b*j*B-e*g*l*B+a*b*l*B+c*g*A*B-a*f*A*B-d*f*j*E+c*h*j*E+d*g*l*E-a*h*l*E-c*g*p*E+a*f*p*E},transpose:function(){function a(c,d,e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31",
+e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;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,g=a.n13,f=a.n14,h=a.n21,b=a.n22,j=a.n23,l=a.n24,t=a.n31,
+A=a.n32,w=a.n33,o=a.n34,p=a.n41,C=a.n42,H=a.n43,y=a.n44,I=c.n11,v=c.n12,L=c.n13,k=c.n14,B=c.n21,n=c.n22,m=c.n23,z=c.n24,q=c.n31,D=c.n32,x=c.n33,u=c.n34,F=c.n41,J=c.n42,G=c.n43,T=c.n44;this.n11=d*I+e*B+g*q+f*F;this.n12=d*v+e*n+g*D+f*J;this.n13=d*L+e*m+g*x+f*G;this.n14=d*k+e*z+g*u+f*T;this.n21=h*I+b*B+j*q+l*F;this.n22=h*v+b*n+j*D+l*J;this.n23=h*L+b*m+j*x+l*G;this.n24=h*k+b*z+j*u+l*T;this.n31=t*I+A*B+w*q+o*F;this.n32=t*v+A*n+w*D+o*J;this.n33=t*L+A*m+w*x+o*G;this.n34=t*k+A*z+w*u+o*T;this.n41=p*I+C*B+
+H*q+y*F;this.n42=p*v+C*n+H*D+y*J;this.n43=p*L+C*m+H*x+y*G;this.n44=p*k+C*z+H*u+y*T;return this},multiplyToArray:function(a,c,d){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,b=a.n21,j=a.n22,l=a.n23,t=a.n24,A=a.n31,w=a.n32,o=a.n33,p=a.n34,C=a.n41,H=a.n42,y=a.n43;a=a.n44;var I=c.n11,v=c.n12,L=c.n13,k=c.n14,B=c.n21,n=c.n22,m=c.n23,z=c.n24,q=c.n31,D=c.n32,x=c.n33,u=c.n34,F=c.n41,J=c.n42,G=c.n43;c=c.n44;this.n11=e*I+g*B+f*q+h*F;this.n12=e*v+g*n+f*D+h*J;this.n13=e*L+g*m+f*x+h*G;this.n14=e*k+g*z+f*u+h*c;this.n21=
+b*I+j*B+l*q+t*F;this.n22=b*v+j*n+l*D+t*J;this.n23=b*L+j*m+l*x+t*G;this.n24=b*k+j*z+l*u+t*c;this.n31=A*I+w*B+o*q+p*F;this.n32=A*v+w*n+o*D+p*J;this.n33=A*L+w*m+o*x+p*G;this.n34=A*k+w*z+o*u+p*c;this.n41=C*I+H*B+y*q+a*F;this.n42=C*v+H*n+y*D+a*J;this.n43=C*L+H*m+y*x+a*G;this.n44=C*k+H*z+y*u+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;
+d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,b=this.n23,j=this.n24,l=this.n31,t=this.n32,A=this.n33,w=this.n34,o=this.n41,p=this.n42,C=this.n43,H=this.n44,y=a.n11,I=a.n21,v=a.n31,L=a.n41,k=a.n12,B=a.n22,n=a.n32,m=a.n42,z=a.n13,q=a.n23,D=a.n33,x=a.n43,u=a.n14,F=a.n24,J=a.n34;a=a.n44;this.n11=c*y+d*I+e*v+g*L;this.n12=c*k+d*B+e*n+g*m;this.n13=c*z+d*q+e*D+g*x;this.n14=c*u+d*F+e*J+g*a;this.n21=f*y+h*I+b*v+j*L;this.n22=f*k+h*
+B+b*n+j*m;this.n23=f*z+h*q+b*D+j*x;this.n24=f*u+h*F+b*J+j*a;this.n31=l*y+t*I+A*v+w*L;this.n32=l*k+t*B+A*n+w*m;this.n33=l*z+t*q+A*D+w*x;this.n34=l*u+t*F+A*J+w*a;this.n41=o*y+p*I+C*v+H*L;this.n42=o*k+p*B+C*n+H*m;this.n43=o*z+p*q+C*D+H*x;this.n44=o*u+p*F+C*J+H*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,g=this.n21,f=this.n22,h=this.n23,b=this.n24,j=this.n31,l=this.n32,t=this.n33,A=this.n34,w=this.n41,o=this.n42,p=this.n43,C=this.n44;return e*h*l*w-d*b*l*w-e*f*t*w+c*b*t*w+d*f*A*w-c*h*A*w-e*h*j*o+d*b*j*o+e*g*t*o-a*b*t*o-d*g*A*o+a*h*A*o+e*f*j*p-c*b*j*p-e*g*l*p+a*b*l*p+c*g*A*p-a*f*A*p-d*f*j*C+c*h*j*C+d*g*l*C-a*h*l*C-c*g*t*C+a*f*t*C},transpose:function(){function a(c,d,e){var g=c[d];c[d]=c[e];c[e]=g}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]=
 "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},flattenToArray:function(a){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,
 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},flattenToArray:function(a){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),g=1-d,f=a.x,h=a.y,b=a.z,
 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),g=1-d,f=a.x,h=a.y,b=a.z,
 j=g*f,l=g*h;this.set(j*f+d,j*h-e*b,j*b+e*h,0,j*h+e*b,l*h+d,l*b-e*f,0,j*b-e*h,l*b+e*f,g*b*b+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};
 j=g*f,l=g*h;this.set(j*f+d,j*h-e*b,j*b+e*h,0,j*h+e*b,l*h+d,l*b-e*f,0,j*b-e*h,l*b+e*f,g*b*b+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.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,g=a.n14,f=a.n21,h=a.n22,b=a.n23,j=a.n24,l=a.n31,p=a.n32,A=a.n33,q=a.n34,m=a.n41,B=a.n42,E=a.n43,H=a.n44,x=new THREE.Matrix4;x.n11=b*q*B-j*A*B+j*p*E-h*q*E-b*p*H+h*A*H;x.n12=g*A*B-e*q*B-g*p*E+d*q*E+e*p*H-d*A*H;x.n13=e*j*B-g*b*B+g*h*E-d*j*E-e*h*H+d*b*H;x.n14=g*b*p-e*j*p-g*h*A+d*j*A+e*h*q-d*b*q;x.n21=j*A*m-b*q*m-j*l*E+f*q*E+b*l*H-f*A*H;x.n22=e*q*m-g*A*m+g*l*E-c*q*E-e*l*H+c*A*H;x.n23=g*b*m-e*j*m-g*f*E+c*j*E+e*f*H-c*b*H;x.n24=e*j*l-g*b*l+
-g*f*A-c*j*A-e*f*q+c*b*q;x.n31=h*q*m-j*p*m+j*l*B-f*q*B-h*l*H+f*p*H;x.n32=g*p*m-d*q*m-g*l*B+c*q*B+d*l*H-c*p*H;x.n33=e*j*m-g*h*m+g*f*B-c*j*B-d*f*H+c*h*H;x.n34=g*h*l-d*j*l-g*f*p+c*j*p+d*f*q-c*h*q;x.n41=b*p*m-h*A*m-b*l*B+f*A*B+h*l*E-f*p*E;x.n42=d*A*m-e*p*m+e*l*B-c*A*B-d*l*E+c*p*E;x.n43=e*h*m-d*b*m-e*f*B+c*b*B+d*f*E-c*h*E;x.n44=d*b*l-e*h*l+e*f*p-c*b*p-d*f*A+c*h*A;x.multiplyScalar(1/a.determinant());return x};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,b=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*f;d[3]=a*h;d[4]=a*b;d[5]=a*j;d[6]=a*l;d[7]=a*p;d[8]=a*A;return c};
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,b=a.n23,j=a.n24,l=a.n31,t=a.n32,A=a.n33,w=a.n34,o=a.n41,p=a.n42,C=a.n43,H=a.n44,y=new THREE.Matrix4;y.n11=b*w*p-j*A*p+j*t*C-h*w*C-b*t*H+h*A*H;y.n12=g*A*p-e*w*p-g*t*C+d*w*C+e*t*H-d*A*H;y.n13=e*j*p-g*b*p+g*h*C-d*j*C-e*h*H+d*b*H;y.n14=g*b*t-e*j*t-g*h*A+d*j*A+e*h*w-d*b*w;y.n21=j*A*o-b*w*o-j*l*C+f*w*C+b*l*H-f*A*H;y.n22=e*w*o-g*A*o+g*l*C-c*w*C-e*l*H+c*A*H;y.n23=g*b*o-e*j*o-g*f*C+c*j*C+e*f*H-c*b*H;y.n24=e*j*l-g*b*l+
+g*f*A-c*j*A-e*f*w+c*b*w;y.n31=h*w*o-j*t*o+j*l*p-f*w*p-h*l*H+f*t*H;y.n32=g*t*o-d*w*o-g*l*p+c*w*p+d*l*H-c*t*H;y.n33=e*j*o-g*h*o+g*f*p-c*j*p-d*f*H+c*h*H;y.n34=g*h*l-d*j*l-g*f*t+c*j*t+d*f*w-c*h*w;y.n41=b*t*o-h*A*o-b*l*p+f*A*p+h*l*C-f*t*C;y.n42=d*A*o-e*t*o+e*l*p-c*A*p-d*l*C+c*t*C;y.n43=e*h*o-d*b*o-e*f*p+c*b*p+d*f*C-c*h*C;y.n44=d*b*l-e*h*l+e*f*t-c*b*t-d*f*A+c*h*A;y.multiplyScalar(1/a.determinant());return y};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,b=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*f;d[3]=a*h;d[4]=a*b;d[5]=a*j;d[6]=a*l;d[7]=a*t;d[8]=a*A;return c};
 THREE.Matrix4.makeFrustum=function(a,c,d,e,g,f){var h,b,j;h=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=b;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)};
 THREE.Matrix4.makeFrustum=function(a,c,d,e,g,f){var h,b,j;h=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=b;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=d;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)};
 THREE.Matrix4.makeOrtho=function(a,c,d,e,g,f){var h,b,j,l;h=new THREE.Matrix4;b=c-a;j=d-e;l=f-g;a=(c+a)/b;d=(d+e)/j;g=(f+g)/l;h.n11=2/b;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-g;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.Matrix4.makeOrtho=function(a,c,d,e,g,f){var h,b,j,l;h=new THREE.Matrix4;b=c-a;j=d-e;l=f-g;a=(c+a)/b;d=(d+e)/j;g=(f+g)/l;h.n11=2/b;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-d;h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-g;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.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+" )"}};
@@ -49,12 +49,12 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
 d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,g,f,h,b=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){b.set(0,0,0);c=0;for(d=f.normal.length;c<d;c++)b.addSelf(f.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[f.a];d=this.vertices[f.b];h=this.vertices[f.c];b.sub(h.position,
 d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,g,f,h,b=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){f=this.vertices[e];f.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];if(a&&f.vertexNormals.length){b.set(0,0,0);c=0;for(d=f.normal.length;c<d;c++)b.addSelf(f.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[f.a];d=this.vertices[f.b];h=this.vertices[f.c];b.sub(h.position,
 d.position);j.sub(c.position,d.position);b.crossSelf(j)}b.isZero()||b.normalize();f.normal.copy(b)}},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.position);j.sub(c.position,d.position);b.crossSelf(j)}b.isZero()||b.normalize();f.normal.copy(b)}},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<
 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(z,F,J,M,Q,S,U){f=z.vertices[F].position;h=z.vertices[J].position;b=z.vertices[M].position;j=g[Q];l=g[S];p=g[U];A=h.x-f.x;q=b.x-f.x;m=h.y-f.y;B=b.y-f.y;
-E=h.z-f.z;H=b.z-f.z;x=l.u-j.u;I=p.u-j.u;t=l.v-j.v;k=p.v-j.v;w=1/(x*k-I*t);o.set((k*A-t*q)*w,(k*m-t*B)*w,(k*E-t*H)*w);v.set((x*q-I*A)*w,(x*B-I*m)*w,(x*H-I*E)*w);u[F].addSelf(o);u[J].addSelf(o);u[M].addSelf(o);n[F].addSelf(v);n[J].addSelf(v);n[M].addSelf(v)}var c,d,e,g,f,h,b,j,l,p,A,q,m,B,E,H,x,I,t,k,w,u=[],n=[],o=new THREE.Vector3,v=new THREE.Vector3,D=new THREE.Vector3,y=new THREE.Vector3,C=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){u[c]=new THREE.Vector3;n[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(u,F,J,G,T,U,O){f=u.vertices[F].position;h=u.vertices[J].position;b=u.vertices[G].position;j=g[T];l=g[U];t=g[O];A=h.x-f.x;w=b.x-f.x;o=h.y-f.y;p=b.y-f.y;
+C=h.z-f.z;H=b.z-f.z;y=l.u-j.u;I=t.u-j.u;v=l.v-j.v;L=t.v-j.v;k=1/(y*L-I*v);m.set((L*A-v*w)*k,(L*o-v*p)*k,(L*C-v*H)*k);z.set((y*w-I*A)*k,(y*p-I*o)*k,(y*H-I*C)*k);B[F].addSelf(m);B[J].addSelf(m);B[G].addSelf(m);n[F].addSelf(z);n[J].addSelf(z);n[G].addSelf(z)}var c,d,e,g,f,h,b,j,l,t,A,w,o,p,C,H,y,I,v,L,k,B=[],n=[],m=new THREE.Vector3,z=new THREE.Vector3,q=new THREE.Vector3,D=new THREE.Vector3,x=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){B[c]=new THREE.Vector3;n[c]=new THREE.Vector3}c=0;
 for(d=this.faces.length;c<d;c++){e=this.faces[c];g=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]);
 for(d=this.faces.length;c<d;c++){e=this.faces[c];g=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++){C.copy(this.vertices[c].normal);e=u[c];D.copy(e);D.subSelf(C.multiplyScalar(C.dot(e))).normalize();y.cross(this.vertices[c].normal,e);e=y.dot(n[c]);e=e<0?-1:1;this.vertices[c].tangent.set(D.x,D.y,D.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],
+this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){x.copy(this.vertices[c].normal);e=B[c];q.copy(e);q.subSelf(x.multiplyScalar(x.dot(e))).normalize();D.cross(this.vertices[c].normal,e);e=D.dot(n[c]);e=e<0?-1:1;this.vertices[c].tangent.set(q.x,q.y,q.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>
 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(p){var A=[];c=0;for(d=p.length;c<d;c++)p[c]==undefined?A.push("undefined"):A.push(p[c].toString());return A.join("_")}var c,d,e,g,f,h,b,j,l={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
+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(t){var A=[];c=0;for(d=t.length;c<d;c++)t[c]==undefined?A.push("undefined"):A.push(t[c].toString());return A.join("_")}var c,d,e,g,f,h,b,j,l={};e=0;for(g=this.faces.length;e<g;e++){f=this.faces[e];
 h=f.materials;b=a(h);if(l[b]==undefined)l[b]={hash:b,counter:0};j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){l[b].counter+=1;j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
 h=f.materials;b=a(h);if(l[b]==undefined)l[b]={hash:b,counter:0};j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0};f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+f>65535){l[b].counter+=1;j=l[b].hash+"_"+l[b].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 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(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
 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(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
@@ -104,106 +104,106 @@ var Uniforms={clone:function(a){var c,d,e,g={};for(c in a){g[c]={};for(d in a[c]
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=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.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.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(n,o){return o.z-n.z}function c(n,o){var v=0,D=1,y=n.z+n.w,C=o.z+o.w,z=-n.z+n.w,F=-o.z+o.w;if(y>=0&&C>=0&&z>=0&&F>=0)return true;else if(y<0&&C<0||z<0&&F<0)return false;else{if(y<0)v=Math.max(v,y/(y-C));else if(C<0)D=Math.min(D,y/(y-C));if(z<0)v=Math.max(v,z/(z-F));else if(F<0)D=Math.min(D,z/(z-F));if(D<v)return false;else{n.lerpSelf(o,v);o.lerpSelf(n,1-D);return true}}}var d,e,g=[],f,h,b,j=[],l,p,A=[],q,m,B=[],E=new THREE.Vector4,H=new THREE.Vector4,x=new THREE.Matrix4,
-I=new THREE.Matrix4,t=[],k=new THREE.Vector4,w=new THREE.Vector4,u;this.projectObjects=function(n,o,v){var D=[],y,C;e=0;x.multiply(o.projectionMatrix,o.matrix);t[0]=new THREE.Vector4(x.n41-x.n11,x.n42-x.n12,x.n43-x.n13,x.n44-x.n14);t[1]=new THREE.Vector4(x.n41+x.n11,x.n42+x.n12,x.n43+x.n13,x.n44+x.n14);t[2]=new THREE.Vector4(x.n41+x.n21,x.n42+x.n22,x.n43+x.n23,x.n44+x.n24);t[3]=new THREE.Vector4(x.n41-x.n21,x.n42-x.n22,x.n43-x.n23,x.n44-x.n24);t[4]=new THREE.Vector4(x.n41-x.n31,x.n42-x.n32,x.n43-
-x.n33,x.n44-x.n34);t[5]=new THREE.Vector4(x.n41+x.n31,x.n42+x.n32,x.n43+x.n33,x.n44+x.n34);o=0;for(y=t.length;o<y;o++){C=t[o];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}y=n.objects;n=0;for(o=y.length;n<o;n++){C=y[n];var z;if(!(z=!C.visible)){if(z=C instanceof THREE.Mesh){a:{z=void 0;for(var F=C.position,J=-C.geometry.boundingSphere.radius*Math.max(C.scale.x,Math.max(C.scale.y,C.scale.z)),M=0;M<6;M++){z=t[M].x*F.x+t[M].y*F.y+t[M].z*F.z+t[M].w;if(z<=J){z=false;break a}}z=true}z=!z}z=z}if(!z){d=
-g[e]=g[e]||new THREE.RenderableObject;E.copy(C.position);x.multiplyVector3(E);d.object=C;d.z=E.z;D.push(d);e++}}v&&D.sort(a);return D};this.projectScene=function(n,o,v){var D=[],y=o.near,C=o.far,z,F,J,M,Q,S,U,ca,da,T,O,Z,V,K,W,ba;b=p=m=0;o.autoUpdateMatrix&&o.updateMatrix();x.multiply(o.projectionMatrix,o.matrix);S=this.projectObjects(n,o,true);n=0;for(z=S.length;n<z;n++){U=S[n].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ca=U.matrix;da=U.rotationMatrix;T=U.materials;O=U.overdraw;if(U instanceof
-THREE.Mesh){Z=U.geometry;V=Z.vertices;F=0;for(J=V.length;F<J;F++){K=V[F];K.positionWorld.copy(K.position);ca.multiplyVector3(K.positionWorld);M=K.positionScreen;M.copy(K.positionWorld);x.multiplyVector4(M);M.x/=M.w;M.y/=M.w;K.__visible=M.z>y&&M.z<C}Z=Z.faces;F=0;for(J=Z.length;F<J;F++){K=Z[F];if(K instanceof THREE.Face3){M=V[K.a];Q=V[K.b];W=V[K.c];if(M.__visible&&Q.__visible&&W.__visible)if(U.doubleSided||U.flipSided!=(W.positionScreen.x-M.positionScreen.x)*(Q.positionScreen.y-M.positionScreen.y)-
-(W.positionScreen.y-M.positionScreen.y)*(Q.positionScreen.x-M.positionScreen.x)<0){f=j[b]=j[b]||new THREE.RenderableFace3;f.v1.positionWorld.copy(M.positionWorld);f.v2.positionWorld.copy(Q.positionWorld);f.v3.positionWorld.copy(W.positionWorld);f.v1.positionScreen.copy(M.positionScreen);f.v2.positionScreen.copy(Q.positionScreen);f.v3.positionScreen.copy(W.positionScreen);f.normalWorld.copy(K.normal);da.multiplyVector3(f.normalWorld);f.centroidWorld.copy(K.centroid);ca.multiplyVector3(f.centroidWorld);
-f.centroidScreen.copy(f.centroidWorld);x.multiplyVector3(f.centroidScreen);W=K.vertexNormals;u=f.vertexNormalsWorld;M=0;for(Q=W.length;M<Q;M++){ba=u[M]=u[M]||new THREE.Vector3;ba.copy(W[M]);da.multiplyVector3(ba)}f.z=f.centroidScreen.z;f.meshMaterials=T;f.faceMaterials=K.materials;f.overdraw=O;if(U.geometry.uvs[F]){f.uvs[0]=U.geometry.uvs[F][0];f.uvs[1]=U.geometry.uvs[F][1];f.uvs[2]=U.geometry.uvs[F][2]}D.push(f);b++}}else if(K instanceof THREE.Face4){M=V[K.a];Q=V[K.b];W=V[K.c];ba=V[K.d];if(M.__visible&&
-Q.__visible&&W.__visible&&ba.__visible)if(U.doubleSided||U.flipSided!=((ba.positionScreen.x-M.positionScreen.x)*(Q.positionScreen.y-M.positionScreen.y)-(ba.positionScreen.y-M.positionScreen.y)*(Q.positionScreen.x-M.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*(ba.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*(ba.positionScreen.x-W.positionScreen.x)<0)){f=j[b]=j[b]||new THREE.RenderableFace3;f.v1.positionWorld.copy(M.positionWorld);f.v2.positionWorld.copy(Q.positionWorld);
-f.v3.positionWorld.copy(ba.positionWorld);f.v1.positionScreen.copy(M.positionScreen);f.v2.positionScreen.copy(Q.positionScreen);f.v3.positionScreen.copy(ba.positionScreen);f.normalWorld.copy(K.normal);da.multiplyVector3(f.normalWorld);f.centroidWorld.copy(K.centroid);ca.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);x.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=T;f.faceMaterials=K.materials;f.overdraw=O;if(U.geometry.uvs[F]){f.uvs[0]=U.geometry.uvs[F][0];
-f.uvs[1]=U.geometry.uvs[F][1];f.uvs[2]=U.geometry.uvs[F][3]}D.push(f);b++;h=j[b]=j[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(Q.positionWorld);h.v2.positionWorld.copy(W.positionWorld);h.v3.positionWorld.copy(ba.positionWorld);h.v1.positionScreen.copy(Q.positionScreen);h.v2.positionScreen.copy(W.positionScreen);h.v3.positionScreen.copy(ba.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
-h.meshMaterials=T;h.faceMaterials=K.materials;h.overdraw=O;if(U.geometry.uvs[F]){h.uvs[0]=U.geometry.uvs[F][1];h.uvs[1]=U.geometry.uvs[F][2];h.uvs[2]=U.geometry.uvs[F][3]}D.push(h);b++}}}}else if(U instanceof THREE.Line){I.multiply(x,ca);V=U.geometry.vertices;K=V[0];K.positionScreen.copy(K.position);I.multiplyVector4(K.positionScreen);F=1;for(J=V.length;F<J;F++){M=V[F];M.positionScreen.copy(M.position);I.multiplyVector4(M.positionScreen);Q=V[F-1];k.copy(M.positionScreen);w.copy(Q.positionScreen);
-if(c(k,w)){k.multiplyScalar(1/k.w);w.multiplyScalar(1/w.w);l=A[p]=A[p]||new THREE.RenderableLine;l.v1.positionScreen.copy(k);l.v2.positionScreen.copy(w);l.z=Math.max(k.z,w.z);l.materials=U.materials;D.push(l);p++}}}else if(U instanceof THREE.Particle){H.set(U.position.x,U.position.y,U.position.z,1);x.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){q=B[m]=B[m]||new THREE.RenderableParticle;q.x=H.x/H.w;q.y=H.y/H.w;q.z=H.z;q.rotation=U.rotation.z;q.scale.x=U.scale.x*Math.abs(q.x-(H.x+o.projectionMatrix.n11)/
-(H.w+o.projectionMatrix.n14));q.scale.y=U.scale.y*Math.abs(q.y-(H.y+o.projectionMatrix.n22)/(H.w+o.projectionMatrix.n24));q.materials=U.materials;D.push(q);m++}}}}v&&D.sort(a);return D};this.unprojectVector=function(n,o){var v=THREE.Matrix4.makeInvert(o.matrix);v.multiplySelf(THREE.Matrix4.makeInvert(o.projectionMatrix));v.multiplyVector3(n);return n}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,b){d=h;e=b;g=d/2;f=e/2};this.render=function(h,b){var j,l,p,A,q,m,B,E;a=c.projectScene(h,b);j=0;for(l=a.length;j<l;j++){q=a[j];if(q instanceof THREE.RenderableParticle){B=q.x*g+g;E=q.y*f+f;p=0;for(A=q.material.length;p<A;p++){m=q.material[p];if(m instanceof THREE.ParticleDOMMaterial){m=m.domElement;m.style.left=B+"px";m.style.top=E+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ka){if(q!=ka)l.globalAlpha=q=ka}function c(ka){if(m!=ka){switch(ka){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}m=ka}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,b,j,l=g.getContext("2d"),p=new THREE.Color(0),A=0,q=1,m=0,B=null,E=null,H=1,x,I,t,k,w,u,n,o,v,D=new THREE.Color,
-y=new THREE.Color,C=new THREE.Color,z=new THREE.Color,F=new THREE.Color,J,M,Q,S,U,ca,da,T,O,Z=new THREE.Rectangle,V=new THREE.Rectangle,K=new THREE.Rectangle,W=false,ba=new THREE.Color,ha=new THREE.Color,ea=new THREE.Color,G=new THREE.Color,N=Math.PI*2,L=new THREE.Vector3,X,$,ma,ia,qa,ta,ua=16;X=document.createElement("canvas");X.width=X.height=2;$=X.getContext("2d");$.fillStyle="rgba(0,0,0,1)";$.fillRect(0,0,2,2);ma=$.getImageData(0,0,2,2);ia=ma.data;qa=document.createElement("canvas");qa.width=
-qa.height=ua;ta=qa.getContext("2d");ta.translate(-ua/2,-ua/2);ta.scale(ua,ua);ua--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,ja){f=ka;h=ja;b=f/2;j=h/2;g.width=f;g.height=h;Z.set(-b,-j,b,j);q=1;m=0;E=B=null;H=1};this.setClearColor=function(ka,ja){p=ka;A=ja;V.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.setClearColorHex=function(ka,ja){p.setHex(ka);A=ja;V.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.clear=function(){l.setTransform(1,
-0,0,-1,b,j);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(p.hex==0&&A==0)l.clearRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);l.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+A+")";l.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ka,ja){function Fa(P){var fa,aa,R,Y=P.lights;ha.setRGB(0,0,0);ea.setRGB(0,0,0);G.setRGB(0,0,0);P=0;for(fa=Y.length;P<fa;P++){aa=Y[P];R=aa.color;if(aa instanceof
-THREE.AmbientLight){ha.r+=R.r;ha.g+=R.g;ha.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ea.r+=R.r;ea.g+=R.g;ea.b+=R.b}else if(aa instanceof THREE.PointLight){G.r+=R.r;G.g+=R.g;G.b+=R.b}}}function Aa(P,fa,aa,R){var Y,ga,na,oa,pa=P.lights;P=0;for(Y=pa.length;P<Y;P++){ga=pa[P];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){L.sub(ga.position,fa);L.normalize();
-ga=aa.dot(L)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}}}function Ja(P,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*b;ga=fa.scale.y*j;aa=Y*oa;R=ga*pa;K.set(P.x-aa,P.y-R,P.x+aa,P.y+R);if(Z.instersects(K)){l.save();l.translate(P.x,P.y);l.rotate(-fa.rotation);l.scale(Y,-ga);l.translate(-oa,-pa);l.drawImage(na,0,0);l.restore()}}}else if(aa instanceof
-THREE.ParticleCircleMaterial){if(W){ba.r=ha.r+ea.r+G.r;ba.g=ha.g+ea.g+G.g;ba.b=ha.b+ea.b+G.b;D.r=aa.color.r*ba.r;D.g=aa.color.g*ba.g;D.b=aa.color.b*ba.b;D.updateStyleString()}else D.__styleString=aa.color.__styleString;aa=fa.scale.x*b;R=fa.scale.y*j;K.set(P.x-aa,P.y-R,P.x+aa,P.y+R);if(Z.instersects(K)){Y=D.__styleString;if(E!=Y)l.fillStyle=E=Y;l.save();l.translate(P.x,P.y);l.rotate(-fa.rotation);l.scale(aa,R);l.beginPath();l.arc(0,0,1,0,N,true);l.closePath();l.fill();l.restore()}}}}function Ka(P,
-fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);l.beginPath();l.moveTo(P.positionScreen.x,P.positionScreen.y);l.lineTo(fa.positionScreen.x,fa.positionScreen.y);l.closePath();if(R instanceof THREE.LineBasicMaterial){D.__styleString=R.color.__styleString;P=R.linewidth;if(H!=P)l.lineWidth=H=P;P=D.__styleString;if(B!=P)l.strokeStyle=B=P;l.stroke();K.inflate(R.linewidth*2)}}}function ra(P,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);k=P.positionScreen.x;w=P.positionScreen.y;u=fa.positionScreen.x;
-n=fa.positionScreen.y;o=aa.positionScreen.x;v=aa.positionScreen.y;l.beginPath();l.moveTo(k,w);l.lineTo(u,n);l.lineTo(o,v);l.lineTo(k,w);l.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Ca(k,w,u,n,o,v,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){P=ja.matrix;L.copy(R.vertexNormalsWorld[0]);
-S=(L.x*P.n11+L.y*P.n12+L.z*P.n13)*0.5+0.5;U=-(L.x*P.n21+L.y*P.n22+L.z*P.n23)*0.5+0.5;L.copy(R.vertexNormalsWorld[1]);ca=(L.x*P.n11+L.y*P.n12+L.z*P.n13)*0.5+0.5;da=-(L.x*P.n21+L.y*P.n22+L.z*P.n23)*0.5+0.5;L.copy(R.vertexNormalsWorld[2]);T=(L.x*P.n11+L.y*P.n12+L.z*P.n13)*0.5+0.5;O=-(L.x*P.n21+L.y*P.n22+L.z*P.n23)*0.5+0.5;Ca(k,w,u,n,o,v,Y.env_map.image,S,U,ca,da,T,O)}}else Y.wireframe?Ga(Y.color.__styleString,Y.wireframe_linewidth):Ha(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&
-!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Ca(k,w,u,n,o,v,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){y.r=C.r=z.r=ha.r;y.g=C.g=z.g=ha.g;y.b=C.b=z.b=ha.b;Aa(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],y);Aa(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],C);Aa(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],z);F.r=(C.r+z.r)*0.5;F.g=(C.g+z.g)*
-0.5;F.b=(C.b+z.b)*0.5;Q=Pa(y,C,z,F);Ca(k,w,u,n,o,v,Q,0,0,1,0,0,1)}else{ba.r=ha.r;ba.g=ha.g;ba.b=ha.b;Aa(ga,R.centroidWorld,R.normalWorld,ba);D.r=Y.color.r*ba.r;D.g=Y.color.g*ba.g;D.b=Y.color.b*ba.b;D.updateStyleString();Y.wireframe?Ga(D.__styleString,Y.wireframe_linewidth):Ha(D.__styleString)}else Y.wireframe?Ga(Y.color.__styleString,Y.wireframe_linewidth):Ha(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){J=ja.near;M=ja.far;y.r=y.g=y.b=1-La(P.positionScreen.z,J,M);C.r=C.g=C.b=
-1-La(fa.positionScreen.z,J,M);z.r=z.g=z.b=1-La(aa.positionScreen.z,J,M);F.r=(C.r+z.r)*0.5;F.g=(C.g+z.g)*0.5;F.b=(C.b+z.b)*0.5;Q=Pa(y,C,z,F);Ca(k,w,u,n,o,v,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){D.r=Ma(R.normalWorld.x);D.g=Ma(R.normalWorld.y);D.b=Ma(R.normalWorld.z);D.updateStyleString();Y.wireframe?Ga(D.__styleString,Y.wireframe_linewidth):Ha(D.__styleString)}}}function Ga(P,fa){if(B!=P)l.strokeStyle=B=P;if(H!=fa)l.lineWidth=H=fa;l.stroke();K.inflate(fa*2)}function Ha(P){if(E!=
-P)l.fillStyle=E=P;l.fill()}function Ca(P,fa,aa,R,Y,ga,na,oa,pa,xa,sa,ya,Da){var va,za;va=na.width-1;za=na.height-1;oa*=va;pa*=za;xa*=va;sa*=za;ya*=va;Da*=za;aa-=P;R-=fa;Y-=P;ga-=fa;xa-=oa;sa-=pa;ya-=oa;Da-=pa;va=xa*Da-ya*sa;if(va!=0){za=1/va;va=(Da*aa-sa*Y)*za;sa=(Da*R-sa*ga)*za;aa=(xa*Y-ya*aa)*za;R=(xa*ga-ya*R)*za;P=P-va*oa-aa*pa;fa=fa-sa*oa-R*pa;l.save();l.transform(va,sa,aa,R,P,fa);l.clip();l.drawImage(na,0,0);l.restore()}}function Pa(P,fa,aa,R){var Y=~~(P.r*255),ga=~~(P.g*255);P=~~(P.b*255);var na=
-~~(fa.r*255),oa=~~(fa.g*255);fa=~~(fa.b*255);var pa=~~(aa.r*255),xa=~~(aa.g*255);aa=~~(aa.b*255);var sa=~~(R.r*255),ya=~~(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]=P<0?0:P>255?255:P;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]=xa<0?0:xa>255?255:xa;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=sa<0?0:sa>255?255:sa;ia[13]=ya<0?0:ya>255?255:ya;ia[14]=R<0?0:R>255?255:R;$.putImageData(ma,0,0);ta.drawImage(X,
-0,0);return qa}function La(P,fa,aa){P=(P-fa)/(aa-fa);return P*P*(3-2*P)}function Ma(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function Na(P,fa){var aa=fa.x-P.x,R=fa.y-P.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;P.x-=aa;P.y-=R}var Ia,Qa,la,wa,Ba,Oa,Ra,Ea;this.autoClear?this.clear():l.setTransform(1,0,0,-1,b,j);d=e.projectScene(ka,ja,this.sortElements);(W=ka.lights.length>0)&&Fa(ka);Ia=0;for(Qa=d.length;Ia<Qa;Ia++){la=d[Ia];K.empty();if(la instanceof THREE.RenderableParticle){x=la;x.x*=b;x.y*=
-j;wa=0;for(Ba=la.materials.length;wa<Ba;wa++)Ja(x,la,la.materials[wa],ka)}else if(la instanceof THREE.RenderableLine){x=la.v1;I=la.v2;x.positionScreen.x*=b;x.positionScreen.y*=j;I.positionScreen.x*=b;I.positionScreen.y*=j;K.addPoint(x.positionScreen.x,x.positionScreen.y);K.addPoint(I.positionScreen.x,I.positionScreen.y);if(Z.instersects(K)){wa=0;for(Ba=la.materials.length;wa<Ba;)Ka(x,I,la,la.materials[wa++],ka)}}else if(la instanceof THREE.RenderableFace3){x=la.v1;I=la.v2;t=la.v3;x.positionScreen.x*=
-b;x.positionScreen.y*=j;I.positionScreen.x*=b;I.positionScreen.y*=j;t.positionScreen.x*=b;t.positionScreen.y*=j;if(la.overdraw){Na(x.positionScreen,I.positionScreen);Na(I.positionScreen,t.positionScreen);Na(t.positionScreen,x.positionScreen)}K.add3Points(x.positionScreen.x,x.positionScreen.y,I.positionScreen.x,I.positionScreen.y,t.positionScreen.x,t.positionScreen.y);if(Z.instersects(K)){wa=0;for(Ba=la.meshMaterials.length;wa<Ba;){Ea=la.meshMaterials[wa++];if(Ea instanceof THREE.MeshFaceMaterial){Oa=
-0;for(Ra=la.faceMaterials.length;Oa<Ra;)(Ea=la.faceMaterials[Oa++])&&ra(x,I,t,la,Ea,ka)}else ra(x,I,t,la,Ea,ka)}}}V.addRectangle(K)}l.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(S,U,ca){var da,T,O,Z;da=0;for(T=S.lights.length;da<T;da++){O=S.lights[da];if(O instanceof THREE.DirectionalLight){Z=U.normalWorld.dot(O.position)*O.intensity;if(Z>0){ca.r+=O.color.r*Z;ca.g+=O.color.g*Z;ca.b+=O.color.b*Z}}else if(O instanceof THREE.PointLight){v.sub(O.position,U.centroidWorld);v.normalize();Z=U.normalWorld.dot(v)*O.intensity;if(Z>0){ca.r+=O.color.r*Z;ca.g+=O.color.g*Z;ca.b+=O.color.b*Z}}}}function c(S,U,ca,da,T,O){z=e(F++);z.setAttribute("d",
-"M "+S.positionScreen.x+" "+S.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(T instanceof THREE.MeshBasicMaterial)t.__styleString=T.color.__styleString;else if(T instanceof THREE.MeshLambertMaterial)if(I){k.r=w.r;k.g=w.g;k.b=w.b;a(O,da,k);t.r=T.color.r*k.r;t.g=T.color.g*k.g;t.b=T.color.b*k.b;t.updateStyleString()}else t.__styleString=T.color.__styleString;else if(T instanceof THREE.MeshDepthMaterial){o=1-T.__2near/(T.__farPlusNear-
-da.z*T.__farMinusNear);t.setRGB(o,o,o)}else T instanceof THREE.MeshNormalMaterial&&t.setRGB(g(da.normalWorld.x),g(da.normalWorld.y),g(da.normalWorld.z));T.wireframe?z.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+T.wireframe_linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.wireframe_linecap+"; stroke-linejoin: "+T.wireframe_linejoin):z.setAttribute("style","fill: "+t.__styleString+"; fill-opacity: "+T.opacity);b.appendChild(z)}function d(S,U,ca,da,T,
-O,Z){z=e(F++);z.setAttribute("d","M "+S.positionScreen.x+" "+S.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+" L "+da.positionScreen.x+","+da.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)t.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(I){k.r=w.r;k.g=w.g;k.b=w.b;a(Z,T,k);t.r=O.color.r*k.r;t.g=O.color.g*k.g;t.b=O.color.b*k.b;t.updateStyleString()}else t.__styleString=O.color.__styleString;
-else if(O instanceof THREE.MeshDepthMaterial){o=1-O.__2near/(O.__farPlusNear-T.z*O.__farMinusNear);t.setRGB(o,o,o)}else O instanceof THREE.MeshNormalMaterial&&t.setRGB(g(T.normalWorld.x),g(T.normalWorld.y),g(T.normalWorld.z));O.wireframe?z.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):z.setAttribute("style","fill: "+t.__styleString+
-"; fill-opacity: "+O.opacity);b.appendChild(z)}function e(S){if(D[S]==null){D[S]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&D[S].setAttribute("shape-rendering","crispEdges");return D[S]}return D[S]}function g(S){return S<0?Math.min((1+S)*0.5,0.5):0.5+Math.min(S*0.5,0.5)}var f=null,h=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,p,A,q,m,B,E,H=new THREE.Rectangle,x=new THREE.Rectangle,I=false,t=new THREE.Color(16777215),k=new THREE.Color(16777215),
-w=new THREE.Color(0),u=new THREE.Color(0),n=new THREE.Color(0),o,v=new THREE.Vector3,D=[],y=[],C=[],z,F,J,M,Q=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(S){switch(S){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(S,U){j=S;l=U;p=j/2;A=l/2;b.setAttribute("viewBox",-p+" "+-A+" "+j+" "+l);b.setAttribute("width",j);b.setAttribute("height",l);H.set(-p,-A,p,A)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};
-this.render=function(S,U){var ca,da,T,O,Z,V,K,W;this.autoClear&&this.clear();f=h.projectScene(S,U,this.sortElements);M=J=F=0;if(I=S.lights.length>0){K=S.lights;w.setRGB(0,0,0);u.setRGB(0,0,0);n.setRGB(0,0,0);ca=0;for(da=K.length;ca<da;ca++){T=K[ca];O=T.color;if(T instanceof THREE.AmbientLight){w.r+=O.r;w.g+=O.g;w.b+=O.b}else if(T instanceof THREE.DirectionalLight){u.r+=O.r;u.g+=O.g;u.b+=O.b}else if(T instanceof THREE.PointLight){n.r+=O.r;n.g+=O.g;n.b+=O.b}}}ca=0;for(da=f.length;ca<da;ca++){K=f[ca];
-x.empty();if(K instanceof THREE.RenderableParticle){q=K;q.x*=p;q.y*=-A;T=0;for(O=K.materials.length;T<O;T++)if(W=K.materials[T]){Z=q;V=K;W=W;var ba=J++;if(y[ba]==null){y[ba]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&y[ba].setAttribute("shape-rendering","crispEdges")}z=y[ba];z.setAttribute("cx",Z.x);z.setAttribute("cy",Z.y);z.setAttribute("r",V.scale.x*p);if(W instanceof THREE.ParticleCircleMaterial){if(I){k.r=w.r+u.r+n.r;k.g=w.g+u.g+n.g;k.b=w.b+u.b+n.b;t.r=W.color.r*k.r;
-t.g=W.color.g*k.g;t.b=W.color.b*k.b;t.updateStyleString()}else t=W.color;z.setAttribute("style","fill: "+t.__styleString)}b.appendChild(z)}}else if(K instanceof THREE.RenderableLine){q=K.v1;m=K.v2;q.positionScreen.x*=p;q.positionScreen.y*=-A;m.positionScreen.x*=p;m.positionScreen.y*=-A;x.addPoint(q.positionScreen.x,q.positionScreen.y);x.addPoint(m.positionScreen.x,m.positionScreen.y);if(H.instersects(x)){T=0;for(O=K.materials.length;T<O;)if(W=K.materials[T++]){Z=q;V=m;W=W;ba=M++;if(C[ba]==null){C[ba]=
-document.createElementNS("http://www.w3.org/2000/svg","line");Q==0&&C[ba].setAttribute("shape-rendering","crispEdges")}z=C[ba];z.setAttribute("x1",Z.positionScreen.x);z.setAttribute("y1",Z.positionScreen.y);z.setAttribute("x2",V.positionScreen.x);z.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){t.__styleString=W.color.__styleString;z.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+
-W.linecap+"; stroke-linejoin: "+W.linejoin);b.appendChild(z)}}}}else if(K instanceof THREE.RenderableFace3){q=K.v1;m=K.v2;B=K.v3;q.positionScreen.x*=p;q.positionScreen.y*=-A;m.positionScreen.x*=p;m.positionScreen.y*=-A;B.positionScreen.x*=p;B.positionScreen.y*=-A;x.addPoint(q.positionScreen.x,q.positionScreen.y);x.addPoint(m.positionScreen.x,m.positionScreen.y);x.addPoint(B.positionScreen.x,B.positionScreen.y);if(H.instersects(x)){T=0;for(O=K.meshMaterials.length;T<O;){W=K.meshMaterials[T++];if(W instanceof
-THREE.MeshFaceMaterial){Z=0;for(V=K.faceMaterials.length;Z<V;)(W=K.faceMaterials[Z++])&&c(q,m,B,K,W,S)}else W&&c(q,m,B,K,W,S)}}}else if(K instanceof THREE.RenderableFace4){q=K.v1;m=K.v2;B=K.v3;E=K.v4;q.positionScreen.x*=p;q.positionScreen.y*=-A;m.positionScreen.x*=p;m.positionScreen.y*=-A;B.positionScreen.x*=p;B.positionScreen.y*=-A;E.positionScreen.x*=p;E.positionScreen.y*=-A;x.addPoint(q.positionScreen.x,q.positionScreen.y);x.addPoint(m.positionScreen.x,m.positionScreen.y);x.addPoint(B.positionScreen.x,
-B.positionScreen.y);x.addPoint(E.positionScreen.x,E.positionScreen.y);if(H.instersects(x)){T=0;for(O=K.meshMaterials.length;T<O;){W=K.meshMaterials[T++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=K.faceMaterials.length;Z<V;)(W=K.faceMaterials[Z++])&&d(q,m,B,E,K,W,S)}else W&&d(q,m,B,E,K,W,S)}}}}}};
-THREE.WebGLRenderer=function(a){function c(k,w){k.fragment_shader=w.fragment_shader;k.vertex_shader=w.vertex_shader;k.uniforms=Uniforms.clone(w.uniforms)}function d(k){if(k.doubleSided){if(p){b.disable(b.CULL_FACE);p=false}}else{if(!p){b.enable(b.CULL_FACE);p=true}k.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}function e(k){if(k!=A){switch(k){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)}A=k}}function g(k,w){var u;if(k=="fragment")u=b.createShader(b.FRAGMENT_SHADER);else if(k=="vertex")u=b.createShader(b.VERTEX_SHADER);b.shaderSource(u,w);b.compileShader(u);if(!b.getShaderParameter(u,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(u));return null}return u}function f(k){switch(k){case THREE.RepeatWrapping:return b.REPEAT;
+THREE.Projector=function(){function a(n,m){return m.z-n.z}function c(n,m){var z=0,q=1,D=n.z+n.w,x=m.z+m.w,u=-n.z+n.w,F=-m.z+m.w;if(D>=0&&x>=0&&u>=0&&F>=0)return true;else if(D<0&&x<0||u<0&&F<0)return false;else{if(D<0)z=Math.max(z,D/(D-x));else if(x<0)q=Math.min(q,D/(D-x));if(u<0)z=Math.max(z,u/(u-F));else if(F<0)q=Math.min(q,u/(u-F));if(q<z)return false;else{n.lerpSelf(m,z);m.lerpSelf(n,1-q);return true}}}var d,e,g=[],f,h,b,j=[],l,t,A=[],w,o,p=[],C=new THREE.Vector4,H=new THREE.Vector4,y=new THREE.Matrix4,
+I=new THREE.Matrix4,v=[],L=new THREE.Vector4,k=new THREE.Vector4,B;this.projectObjects=function(n,m,z){var q=[],D,x;e=0;y.multiply(m.projectionMatrix,m.matrix);v[0]=new THREE.Vector4(y.n41-y.n11,y.n42-y.n12,y.n43-y.n13,y.n44-y.n14);v[1]=new THREE.Vector4(y.n41+y.n11,y.n42+y.n12,y.n43+y.n13,y.n44+y.n14);v[2]=new THREE.Vector4(y.n41+y.n21,y.n42+y.n22,y.n43+y.n23,y.n44+y.n24);v[3]=new THREE.Vector4(y.n41-y.n21,y.n42-y.n22,y.n43-y.n23,y.n44-y.n24);v[4]=new THREE.Vector4(y.n41-y.n31,y.n42-y.n32,y.n43-
+y.n33,y.n44-y.n34);v[5]=new THREE.Vector4(y.n41+y.n31,y.n42+y.n32,y.n43+y.n33,y.n44+y.n34);m=0;for(D=v.length;m<D;m++){x=v[m];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}D=n.objects;n=0;for(m=D.length;n<m;n++){x=D[n];var u;if(!(u=!x.visible)){if(u=x instanceof THREE.Mesh){a:{u=void 0;for(var F=x.position,J=-x.geometry.boundingSphere.radius*Math.max(x.scale.x,Math.max(x.scale.y,x.scale.z)),G=0;G<6;G++){u=v[G].x*F.x+v[G].y*F.y+v[G].z*F.z+v[G].w;if(u<=J){u=false;break a}}u=true}u=!u}u=u}if(!u){d=
+g[e]=g[e]||new THREE.RenderableObject;C.copy(x.position);y.multiplyVector3(C);d.object=x;d.z=C.z;q.push(d);e++}}z&&q.sort(a);return q};this.projectScene=function(n,m,z){var q=[],D=m.near,x=m.far,u,F,J,G,T,U,O,ba,ca,W,R,X,Y,M,S,aa;b=t=o=0;m.autoUpdateMatrix&&m.updateMatrix();y.multiply(m.projectionMatrix,m.matrix);U=this.projectObjects(n,m,true);n=0;for(u=U.length;n<u;n++){O=U[n].object;if(O.visible){O.autoUpdateMatrix&&O.updateMatrix();ba=O.matrix;ca=O.rotationMatrix;W=O.materials;R=O.overdraw;if(O instanceof
+THREE.Mesh){X=O.geometry;Y=X.vertices;F=0;for(J=Y.length;F<J;F++){M=Y[F];M.positionWorld.copy(M.position);ba.multiplyVector3(M.positionWorld);G=M.positionScreen;G.copy(M.positionWorld);y.multiplyVector4(G);G.x/=G.w;G.y/=G.w;M.__visible=G.z>D&&G.z<x}X=X.faces;F=0;for(J=X.length;F<J;F++){M=X[F];if(M instanceof THREE.Face3){G=Y[M.a];T=Y[M.b];S=Y[M.c];if(G.__visible&&T.__visible&&S.__visible)if(O.doubleSided||O.flipSided!=(S.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-
+(S.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0){f=j[b]=j[b]||new THREE.RenderableFace3;f.v1.positionWorld.copy(G.positionWorld);f.v2.positionWorld.copy(T.positionWorld);f.v3.positionWorld.copy(S.positionWorld);f.v1.positionScreen.copy(G.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(S.positionScreen);f.normalWorld.copy(M.normal);ca.multiplyVector3(f.normalWorld);f.centroidWorld.copy(M.centroid);ba.multiplyVector3(f.centroidWorld);
+f.centroidScreen.copy(f.centroidWorld);y.multiplyVector3(f.centroidScreen);S=M.vertexNormals;B=f.vertexNormalsWorld;G=0;for(T=S.length;G<T;G++){aa=B[G]=B[G]||new THREE.Vector3;aa.copy(S[G]);ca.multiplyVector3(aa)}f.z=f.centroidScreen.z;f.meshMaterials=W;f.faceMaterials=M.materials;f.overdraw=R;if(O.geometry.uvs[F]){f.uvs[0]=O.geometry.uvs[F][0];f.uvs[1]=O.geometry.uvs[F][1];f.uvs[2]=O.geometry.uvs[F][2]}q.push(f);b++}}else if(M instanceof THREE.Face4){G=Y[M.a];T=Y[M.b];S=Y[M.c];aa=Y[M.d];if(G.__visible&&
+T.__visible&&S.__visible&&aa.__visible)if(O.doubleSided||O.flipSided!=((aa.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-(aa.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0||(T.positionScreen.x-S.positionScreen.x)*(aa.positionScreen.y-S.positionScreen.y)-(T.positionScreen.y-S.positionScreen.y)*(aa.positionScreen.x-S.positionScreen.x)<0)){f=j[b]=j[b]||new THREE.RenderableFace3;f.v1.positionWorld.copy(G.positionWorld);f.v2.positionWorld.copy(T.positionWorld);
+f.v3.positionWorld.copy(aa.positionWorld);f.v1.positionScreen.copy(G.positionScreen);f.v2.positionScreen.copy(T.positionScreen);f.v3.positionScreen.copy(aa.positionScreen);f.normalWorld.copy(M.normal);ca.multiplyVector3(f.normalWorld);f.centroidWorld.copy(M.centroid);ba.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);y.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=W;f.faceMaterials=M.materials;f.overdraw=R;if(O.geometry.uvs[F]){f.uvs[0]=O.geometry.uvs[F][0];
+f.uvs[1]=O.geometry.uvs[F][1];f.uvs[2]=O.geometry.uvs[F][3]}q.push(f);b++;h=j[b]=j[b]||new THREE.RenderableFace3;h.v1.positionWorld.copy(T.positionWorld);h.v2.positionWorld.copy(S.positionWorld);h.v3.positionWorld.copy(aa.positionWorld);h.v1.positionScreen.copy(T.positionScreen);h.v2.positionScreen.copy(S.positionScreen);h.v3.positionScreen.copy(aa.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;
+h.meshMaterials=W;h.faceMaterials=M.materials;h.overdraw=R;if(O.geometry.uvs[F]){h.uvs[0]=O.geometry.uvs[F][1];h.uvs[1]=O.geometry.uvs[F][2];h.uvs[2]=O.geometry.uvs[F][3]}q.push(h);b++}}}}else if(O instanceof THREE.Line){I.multiply(y,ba);Y=O.geometry.vertices;M=Y[0];M.positionScreen.copy(M.position);I.multiplyVector4(M.positionScreen);F=1;for(J=Y.length;F<J;F++){G=Y[F];G.positionScreen.copy(G.position);I.multiplyVector4(G.positionScreen);T=Y[F-1];L.copy(G.positionScreen);k.copy(T.positionScreen);
+if(c(L,k)){L.multiplyScalar(1/L.w);k.multiplyScalar(1/k.w);l=A[t]=A[t]||new THREE.RenderableLine;l.v1.positionScreen.copy(L);l.v2.positionScreen.copy(k);l.z=Math.max(L.z,k.z);l.materials=O.materials;q.push(l);t++}}}else if(O instanceof THREE.Particle){H.set(O.position.x,O.position.y,O.position.z,1);y.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){w=p[o]=p[o]||new THREE.RenderableParticle;w.x=H.x/H.w;w.y=H.y/H.w;w.z=H.z;w.rotation=O.rotation.z;w.scale.x=O.scale.x*Math.abs(w.x-(H.x+m.projectionMatrix.n11)/
+(H.w+m.projectionMatrix.n14));w.scale.y=O.scale.y*Math.abs(w.y-(H.y+m.projectionMatrix.n22)/(H.w+m.projectionMatrix.n24));w.materials=O.materials;q.push(w);o++}}}}z&&q.sort(a);return q};this.unprojectVector=function(n,m){var z=THREE.Matrix4.makeInvert(m.matrix);z.multiplySelf(THREE.Matrix4.makeInvert(m.projectionMatrix));z.multiplyVector3(n);return n}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,b){d=h;e=b;g=d/2;f=e/2};this.render=function(h,b){var j,l,t,A,w,o,p,C;a=c.projectScene(h,b);j=0;for(l=a.length;j<l;j++){w=a[j];if(w instanceof THREE.RenderableParticle){p=w.x*g+g;C=w.y*f+f;t=0;for(A=w.material.length;t<A;t++){o=w.material[t];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=p+"px";o.style.top=C+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ka){if(w!=ka)l.globalAlpha=w=ka}function c(ka){if(o!=ka){switch(ka){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}o=ka}}var d=null,e=new THREE.Projector,g=document.createElement("canvas"),f,h,b,j,l=g.getContext("2d"),t=new THREE.Color(0),A=0,w=1,o=0,p=null,C=null,H=1,y,I,v,L,k,B,n,m,z,q=new THREE.Color,
+D=new THREE.Color,x=new THREE.Color,u=new THREE.Color,F=new THREE.Color,J,G,T,U,O,ba,ca,W,R,X=new THREE.Rectangle,Y=new THREE.Rectangle,M=new THREE.Rectangle,S=false,aa=new THREE.Color,ja=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,K=Math.PI*2,N=new THREE.Vector3,V,da,ga,ia,ta,ra,va=16;V=document.createElement("canvas");V.width=V.height=2;da=V.getContext("2d");da.fillStyle="rgba(0,0,0,1)";da.fillRect(0,0,2,2);ga=da.getImageData(0,0,2,2);ia=ga.data;ta=document.createElement("canvas");ta.width=
+ta.height=va;ra=ta.getContext("2d");ra.translate(-va/2,-va/2);ra.scale(va,va);va--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ka,sa){f=ka;h=sa;b=f/2;j=h/2;g.width=f;g.height=h;X.set(-b,-j,b,j);w=1;o=0;C=p=null;H=1};this.setClearColor=function(ka,sa){t=ka;A=sa;Y.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.setClearColorHex=function(ka,sa){t.setHex(ka);A=sa;Y.set(-b,-j,b,j);l.setTransform(1,0,0,-1,b,j);this.clear()};this.clear=function(){l.setTransform(1,
+0,0,-1,b,j);if(!Y.isEmpty()){Y.inflate(1);Y.minSelf(X);if(t.hex==0&&A==0)l.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight());else{c(THREE.NormalBlending);a(1);l.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+A+")";l.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())}Y.empty()}};this.render=function(ka,sa){function oa(P){var ea,$,Q,Z=P.lights;ja.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);P=0;for(ea=Z.length;P<ea;P++){$=Z[P];Q=$.color;if($ instanceof
+THREE.AmbientLight){ja.r+=Q.r;ja.g+=Q.g;ja.b+=Q.b}else if($ instanceof THREE.DirectionalLight){ha.r+=Q.r;ha.g+=Q.g;ha.b+=Q.b}else if($ instanceof THREE.PointLight){E.r+=Q.r;E.g+=Q.g;E.b+=Q.b}}}function Ba(P,ea,$,Q){var Z,fa,ma,na,pa=P.lights;P=0;for(Z=pa.length;P<Z;P++){fa=pa[P];ma=fa.color;na=fa.intensity;if(fa instanceof THREE.DirectionalLight){fa=$.dot(fa.position)*na;if(fa>0){Q.r+=ma.r*fa;Q.g+=ma.g*fa;Q.b+=ma.b*fa}}else if(fa instanceof THREE.PointLight){N.sub(fa.position,ea);N.normalize();fa=
+$.dot(N)*na;if(fa>0){Q.r+=ma.r*fa;Q.g+=ma.g*fa;Q.b+=ma.b*fa}}}}function Ja(P,ea,$){if($.opacity!=0){a($.opacity);c($.blending);var Q,Z,fa,ma,na,pa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){ma=$.map.image;na=ma.width>>1;pa=ma.height>>1;Z=ea.scale.x*b;fa=ea.scale.y*j;$=Z*na;Q=fa*pa;M.set(P.x-$,P.y-Q,P.x+$,P.y+Q);if(X.instersects(M)){l.save();l.translate(P.x,P.y);l.rotate(-ea.rotation);l.scale(Z,-fa);l.translate(-na,-pa);l.drawImage(ma,0,0);l.restore()}}}else if($ instanceof
+THREE.ParticleCircleMaterial){if(S){aa.r=ja.r+ha.r+E.r;aa.g=ja.g+ha.g+E.g;aa.b=ja.b+ha.b+E.b;q.r=$.color.r*aa.r;q.g=$.color.g*aa.g;q.b=$.color.b*aa.b;q.updateStyleString()}else q.__styleString=$.color.__styleString;$=ea.scale.x*b;Q=ea.scale.y*j;M.set(P.x-$,P.y-Q,P.x+$,P.y+Q);if(X.instersects(M)){Z=q.__styleString;if(C!=Z)l.fillStyle=C=Z;l.save();l.translate(P.x,P.y);l.rotate(-ea.rotation);l.scale($,Q);l.beginPath();l.arc(0,0,1,0,K,true);l.closePath();l.fill();l.restore()}}}}function Ka(P,ea,$,Q){if(Q.opacity!=
+0){a(Q.opacity);c(Q.blending);l.beginPath();l.moveTo(P.positionScreen.x,P.positionScreen.y);l.lineTo(ea.positionScreen.x,ea.positionScreen.y);l.closePath();if(Q instanceof THREE.LineBasicMaterial){q.__styleString=Q.color.__styleString;P=Q.linewidth;if(H!=P)l.lineWidth=H=P;P=q.__styleString;if(p!=P)l.strokeStyle=p=P;l.stroke();M.inflate(Q.linewidth*2)}}}function Ga(P,ea,$,Q,Z,fa){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);L=P.positionScreen.x;k=P.positionScreen.y;B=ea.positionScreen.x;n=ea.positionScreen.y;
+m=$.positionScreen.x;z=$.positionScreen.y;l.beginPath();l.moveTo(L,k);l.lineTo(B,n);l.lineTo(m,z);l.lineTo(L,k);l.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Da(L,k,B,n,m,z,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=sa.matrix;N.copy(Q.vertexNormalsWorld[0]);U=(N.x*P.n11+N.y*
+P.n12+N.z*P.n13)*0.5+0.5;O=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;N.copy(Q.vertexNormalsWorld[1]);ba=(N.x*P.n11+N.y*P.n12+N.z*P.n13)*0.5+0.5;ca=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;N.copy(Q.vertexNormalsWorld[2]);W=(N.x*P.n11+N.y*P.n12+N.z*P.n13)*0.5+0.5;R=-(N.x*P.n21+N.y*P.n22+N.z*P.n23)*0.5+0.5;Da(L,k,B,n,m,z,Z.env_map.image,U,O,ba,ca,W,R)}}else Z.wireframe?qa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof
+THREE.UVMapping&&Da(L,k,B,n,m,z,Z.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);c(THREE.SubtractiveBlending)}if(S)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){D.r=x.r=u.r=ja.r;D.g=x.g=u.g=ja.g;D.b=x.b=u.b=ja.b;Ba(fa,Q.v1.positionWorld,Q.vertexNormalsWorld[0],D);Ba(fa,Q.v2.positionWorld,Q.vertexNormalsWorld[1],x);Ba(fa,Q.v3.positionWorld,Q.vertexNormalsWorld[2],u);F.r=(x.r+u.r)*0.5;F.g=(x.g+u.g)*0.5;F.b=(x.b+u.b)*0.5;T=Pa(D,x,u,F);
+Da(L,k,B,n,m,z,T,0,0,1,0,0,1)}else{aa.r=ja.r;aa.g=ja.g;aa.b=ja.b;Ba(fa,Q.centroidWorld,Q.normalWorld,aa);q.r=Z.color.r*aa.r;q.g=Z.color.g*aa.g;q.b=Z.color.b*aa.b;q.updateStyleString();Z.wireframe?qa(q.__styleString,Z.wireframe_linewidth):Ha(q.__styleString)}else Z.wireframe?qa(Z.color.__styleString,Z.wireframe_linewidth):Ha(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){J=sa.near;G=sa.far;D.r=D.g=D.b=1-La(P.positionScreen.z,J,G);x.r=x.g=x.b=1-La(ea.positionScreen.z,J,G);u.r=
+u.g=u.b=1-La($.positionScreen.z,J,G);F.r=(x.r+u.r)*0.5;F.g=(x.g+u.g)*0.5;F.b=(x.b+u.b)*0.5;T=Pa(D,x,u,F);Da(L,k,B,n,m,z,T,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){q.r=Ma(Q.normalWorld.x);q.g=Ma(Q.normalWorld.y);q.b=Ma(Q.normalWorld.z);q.updateStyleString();Z.wireframe?qa(q.__styleString,Z.wireframe_linewidth):Ha(q.__styleString)}}}function qa(P,ea){if(p!=P)l.strokeStyle=p=P;if(H!=ea)l.lineWidth=H=ea;l.stroke();M.inflate(ea*2)}function Ha(P){if(C!=P)l.fillStyle=C=P;l.fill()}function Da(P,
+ea,$,Q,Z,fa,ma,na,pa,ya,ua,za,Ea){var wa,Aa;wa=ma.width-1;Aa=ma.height-1;na*=wa;pa*=Aa;ya*=wa;ua*=Aa;za*=wa;Ea*=Aa;$-=P;Q-=ea;Z-=P;fa-=ea;ya-=na;ua-=pa;za-=na;Ea-=pa;wa=ya*Ea-za*ua;if(wa!=0){Aa=1/wa;wa=(Ea*$-ua*Z)*Aa;ua=(Ea*Q-ua*fa)*Aa;$=(ya*Z-za*$)*Aa;Q=(ya*fa-za*Q)*Aa;P=P-wa*na-$*pa;ea=ea-ua*na-Q*pa;l.save();l.transform(wa,ua,$,Q,P,ea);l.clip();l.drawImage(ma,0,0);l.restore()}}function Pa(P,ea,$,Q){var Z=~~(P.r*255),fa=~~(P.g*255);P=~~(P.b*255);var ma=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);
+var pa=~~($.r*255),ya=~~($.g*255);$=~~($.b*255);var ua=~~(Q.r*255),za=~~(Q.g*255);Q=~~(Q.b*255);ia[0]=Z<0?0:Z>255?255:Z;ia[1]=fa<0?0:fa>255?255:fa;ia[2]=P<0?0:P>255?255:P;ia[4]=ma<0?0:ma>255?255:ma;ia[5]=na<0?0:na>255?255:na;ia[6]=ea<0?0:ea>255?255:ea;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=ya<0?0:ya>255?255:ya;ia[10]=$<0?0:$>255?255:$;ia[12]=ua<0?0:ua>255?255:ua;ia[13]=za<0?0:za>255?255:za;ia[14]=Q<0?0:Q>255?255:Q;da.putImageData(ga,0,0);ra.drawImage(V,0,0);return ta}function La(P,ea,$){P=(P-ea)/($-ea);
+return P*P*(3-2*P)}function Ma(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function Na(P,ea){var $=ea.x-P.x,Q=ea.y-P.y,Z=1/Math.sqrt($*$+Q*Q);$*=Z;Q*=Z;ea.x+=$;ea.y+=Q;P.x-=$;P.y-=Q}var Ia,Qa,la,xa,Ca,Oa,Ra,Fa;this.autoClear?this.clear():l.setTransform(1,0,0,-1,b,j);d=e.projectScene(ka,sa,this.sortElements);(S=ka.lights.length>0)&&oa(ka);Ia=0;for(Qa=d.length;Ia<Qa;Ia++){la=d[Ia];M.empty();if(la instanceof THREE.RenderableParticle){y=la;y.x*=b;y.y*=j;xa=0;for(Ca=la.materials.length;xa<Ca;xa++)Ja(y,la,la.materials[xa],
+ka)}else if(la instanceof THREE.RenderableLine){y=la.v1;I=la.v2;y.positionScreen.x*=b;y.positionScreen.y*=j;I.positionScreen.x*=b;I.positionScreen.y*=j;M.addPoint(y.positionScreen.x,y.positionScreen.y);M.addPoint(I.positionScreen.x,I.positionScreen.y);if(X.instersects(M)){xa=0;for(Ca=la.materials.length;xa<Ca;)Ka(y,I,la,la.materials[xa++],ka)}}else if(la instanceof THREE.RenderableFace3){y=la.v1;I=la.v2;v=la.v3;y.positionScreen.x*=b;y.positionScreen.y*=j;I.positionScreen.x*=b;I.positionScreen.y*=
+j;v.positionScreen.x*=b;v.positionScreen.y*=j;if(la.overdraw){Na(y.positionScreen,I.positionScreen);Na(I.positionScreen,v.positionScreen);Na(v.positionScreen,y.positionScreen)}M.add3Points(y.positionScreen.x,y.positionScreen.y,I.positionScreen.x,I.positionScreen.y,v.positionScreen.x,v.positionScreen.y);if(X.instersects(M)){xa=0;for(Ca=la.meshMaterials.length;xa<Ca;){Fa=la.meshMaterials[xa++];if(Fa instanceof THREE.MeshFaceMaterial){Oa=0;for(Ra=la.faceMaterials.length;Oa<Ra;)(Fa=la.faceMaterials[Oa++])&&
+Ga(y,I,v,la,Fa,ka)}else Ga(y,I,v,la,Fa,ka)}}}Y.addRectangle(M)}l.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(U,O,ba){var ca,W,R,X;ca=0;for(W=U.lights.length;ca<W;ca++){R=U.lights[ca];if(R instanceof THREE.DirectionalLight){X=O.normalWorld.dot(R.position)*R.intensity;if(X>0){ba.r+=R.color.r*X;ba.g+=R.color.g*X;ba.b+=R.color.b*X}}else if(R instanceof THREE.PointLight){z.sub(R.position,O.centroidWorld);z.normalize();X=O.normalWorld.dot(z)*R.intensity;if(X>0){ba.r+=R.color.r*X;ba.g+=R.color.g*X;ba.b+=R.color.b*X}}}}function c(U,O,ba,ca,W,R){u=e(F++);u.setAttribute("d",
+"M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(W instanceof THREE.MeshBasicMaterial)v.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshLambertMaterial)if(I){L.r=k.r;L.g=k.g;L.b=k.b;a(R,ca,L);v.r=W.color.r*L.r;v.g=W.color.g*L.g;v.b=W.color.b*L.b;v.updateStyleString()}else v.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshDepthMaterial){m=1-W.__2near/(W.__farPlusNear-
+ca.z*W.__farMinusNear);v.setRGB(m,m,m)}else W instanceof THREE.MeshNormalMaterial&&v.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));W.wireframe?u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+W.wireframe_linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.wireframe_linecap+"; stroke-linejoin: "+W.wireframe_linejoin):u.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+W.opacity);b.appendChild(u)}function d(U,O,ba,ca,W,
+R,X){u=e(F++);u.setAttribute("d","M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)v.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(I){L.r=k.r;L.g=k.g;L.b=k.b;a(X,W,L);v.r=R.color.r*L.r;v.g=R.color.g*L.g;v.b=R.color.b*L.b;v.updateStyleString()}else v.__styleString=R.color.__styleString;
+else if(R instanceof THREE.MeshDepthMaterial){m=1-R.__2near/(R.__farPlusNear-W.z*R.__farMinusNear);v.setRGB(m,m,m)}else R instanceof THREE.MeshNormalMaterial&&v.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));R.wireframe?u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):u.setAttribute("style","fill: "+v.__styleString+
+"; fill-opacity: "+R.opacity);b.appendChild(u)}function e(U){if(q[U]==null){q[U]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&q[U].setAttribute("shape-rendering","crispEdges");return q[U]}return q[U]}function g(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var f=null,h=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,t,A,w,o,p,C,H=new THREE.Rectangle,y=new THREE.Rectangle,I=false,v=new THREE.Color(16777215),L=new THREE.Color(16777215),
+k=new THREE.Color(0),B=new THREE.Color(0),n=new THREE.Color(0),m,z=new THREE.Vector3,q=[],D=[],x=[],u,F,J,G,T=1;this.domElement=b;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":T=1;break;case "low":T=0}};this.setSize=function(U,O){j=U;l=O;t=j/2;A=l/2;b.setAttribute("viewBox",-t+" "+-A+" "+j+" "+l);b.setAttribute("width",j);b.setAttribute("height",l);H.set(-t,-A,t,A)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};
+this.render=function(U,O){var ba,ca,W,R,X,Y,M,S;this.autoClear&&this.clear();f=h.projectScene(U,O,this.sortElements);G=J=F=0;if(I=U.lights.length>0){M=U.lights;k.setRGB(0,0,0);B.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(ca=M.length;ba<ca;ba++){W=M[ba];R=W.color;if(W instanceof THREE.AmbientLight){k.r+=R.r;k.g+=R.g;k.b+=R.b}else if(W instanceof THREE.DirectionalLight){B.r+=R.r;B.g+=R.g;B.b+=R.b}else if(W instanceof THREE.PointLight){n.r+=R.r;n.g+=R.g;n.b+=R.b}}}ba=0;for(ca=f.length;ba<ca;ba++){M=f[ba];
+y.empty();if(M instanceof THREE.RenderableParticle){w=M;w.x*=t;w.y*=-A;W=0;for(R=M.materials.length;W<R;W++)if(S=M.materials[W]){X=w;Y=M;S=S;var aa=J++;if(D[aa]==null){D[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&D[aa].setAttribute("shape-rendering","crispEdges")}u=D[aa];u.setAttribute("cx",X.x);u.setAttribute("cy",X.y);u.setAttribute("r",Y.scale.x*t);if(S instanceof THREE.ParticleCircleMaterial){if(I){L.r=k.r+B.r+n.r;L.g=k.g+B.g+n.g;L.b=k.b+B.b+n.b;v.r=S.color.r*L.r;
+v.g=S.color.g*L.g;v.b=S.color.b*L.b;v.updateStyleString()}else v=S.color;u.setAttribute("style","fill: "+v.__styleString)}b.appendChild(u)}}else if(M instanceof THREE.RenderableLine){w=M.v1;o=M.v2;w.positionScreen.x*=t;w.positionScreen.y*=-A;o.positionScreen.x*=t;o.positionScreen.y*=-A;y.addPoint(w.positionScreen.x,w.positionScreen.y);y.addPoint(o.positionScreen.x,o.positionScreen.y);if(H.instersects(y)){W=0;for(R=M.materials.length;W<R;)if(S=M.materials[W++]){X=w;Y=o;S=S;aa=G++;if(x[aa]==null){x[aa]=
+document.createElementNS("http://www.w3.org/2000/svg","line");T==0&&x[aa].setAttribute("shape-rendering","crispEdges")}u=x[aa];u.setAttribute("x1",X.positionScreen.x);u.setAttribute("y1",X.positionScreen.y);u.setAttribute("x2",Y.positionScreen.x);u.setAttribute("y2",Y.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){v.__styleString=S.color.__styleString;u.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+
+S.linecap+"; stroke-linejoin: "+S.linejoin);b.appendChild(u)}}}}else if(M instanceof THREE.RenderableFace3){w=M.v1;o=M.v2;p=M.v3;w.positionScreen.x*=t;w.positionScreen.y*=-A;o.positionScreen.x*=t;o.positionScreen.y*=-A;p.positionScreen.x*=t;p.positionScreen.y*=-A;y.addPoint(w.positionScreen.x,w.positionScreen.y);y.addPoint(o.positionScreen.x,o.positionScreen.y);y.addPoint(p.positionScreen.x,p.positionScreen.y);if(H.instersects(y)){W=0;for(R=M.meshMaterials.length;W<R;){S=M.meshMaterials[W++];if(S instanceof
+THREE.MeshFaceMaterial){X=0;for(Y=M.faceMaterials.length;X<Y;)(S=M.faceMaterials[X++])&&c(w,o,p,M,S,U)}else S&&c(w,o,p,M,S,U)}}}else if(M instanceof THREE.RenderableFace4){w=M.v1;o=M.v2;p=M.v3;C=M.v4;w.positionScreen.x*=t;w.positionScreen.y*=-A;o.positionScreen.x*=t;o.positionScreen.y*=-A;p.positionScreen.x*=t;p.positionScreen.y*=-A;C.positionScreen.x*=t;C.positionScreen.y*=-A;y.addPoint(w.positionScreen.x,w.positionScreen.y);y.addPoint(o.positionScreen.x,o.positionScreen.y);y.addPoint(p.positionScreen.x,
+p.positionScreen.y);y.addPoint(C.positionScreen.x,C.positionScreen.y);if(H.instersects(y)){W=0;for(R=M.meshMaterials.length;W<R;){S=M.meshMaterials[W++];if(S instanceof THREE.MeshFaceMaterial){X=0;for(Y=M.faceMaterials.length;X<Y;)(S=M.faceMaterials[X++])&&d(w,o,p,C,M,S,U)}else S&&d(w,o,p,C,M,S,U)}}}}}};
+THREE.WebGLRenderer=function(a){function c(k,B){k.fragment_shader=B.fragment_shader;k.vertex_shader=B.vertex_shader;k.uniforms=Uniforms.clone(B.uniforms)}function d(k){if(t!=k.doubleSided){k.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);t=k.doubleSided}if(A!=k.flipSided){k.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);A=k.flipSided}}function e(k){if(k!=w){switch(k){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)}w=k}}function g(k,B){var n;if(k=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else if(k=="vertex")n=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,B);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function f(k){switch(k){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.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"),
 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,j=null,l=null,p,A=null,q=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],m=new THREE.Matrix4,B=new Float32Array(16),E=new Float32Array(16),H=new THREE.Vector4,x=true,I=new THREE.Color(0),t=0;if(a){if(a.antialias!==undefined)x=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)t=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(k,w,u){try{b=h.getContext("experimental-webgl",{antialias:k})}catch(n){console.log(n)}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(w.r,w.g,w.b,u);p=true})(x,I,t);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(k,w){h.width=k;h.height=w;b.viewport(0,0,h.width,h.height)};this.setClearColorHex=
-function(k,w){var u=new THREE.Color(k);b.clearColor(u.r,u.g,u.b,w)};this.setClearColor=function(k,w){b.clearColor(k.r,k.g,k.b,w)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,w){var u,n,o,v=0,D=0,y=0,C,z,F,J=this.lights,M=J.directional.colors,Q=J.directional.positions,S=J.point.colors,U=J.point.positions,ca=0,da=0;u=o=o=0;for(n=w.length;u<n;u++){o=w[u];C=o.color;z=o.position;F=o.intensity;if(o instanceof THREE.AmbientLight){v+=C.r;D+=C.g;y+=C.b}else if(o instanceof
-THREE.DirectionalLight){o=ca*3;M[o]=C.r*F;M[o+1]=C.g*F;M[o+2]=C.b*F;Q[o]=z.x;Q[o+1]=z.y;Q[o+2]=z.z;ca+=1}else if(o instanceof THREE.PointLight){o=da*3;S[o]=C.r*F;S[o+1]=C.g*F;S[o+2]=C.b*F;U[o]=z.x;U[o+1]=z.y;U[o+2]=z.z;da+=1}}for(u=ca*3;u<M.length;u++)M[u]=0;for(u=da*3;u<S.length;u++)S[u]=0;J.point.length=da;J.directional.length=ca;J.ambient[0]=v;J.ambient[1]=D;J.ambient[2]=y};this.createParticleBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=
-function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLNormalBuffer=b.createBuffer();k.__webGLTangentBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer();k.__webGLUVBuffer=b.createBuffer();k.__webGLUV2Buffer=b.createBuffer();k.__webGLFaceBuffer=b.createBuffer();k.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(k){var w=k.vertices.length;k.__vertexArray=new Float32Array(w*
-3);k.__colorArray=new Float32Array(w*3);k.__webGLLineCount=w};this.initParticleBuffers=function(k){var w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__sortArray=[];k.__webGLParticleCount=w};this.initMeshBuffers=function(k,w){var u,n,o=0,v=0,D=0,y=w.geometry.faces,C=k.faces;u=0;for(n=C.length;u<n;u++){fi=C[u];face=y[fi];if(face instanceof THREE.Face3){o+=3;v+=1;D+=3}else if(face instanceof THREE.Face4){o+=4;v+=2;D+=4}}k.__vertexArray=new Float32Array(o*
-3);k.__normalArray=new Float32Array(o*3);k.__tangentArray=new Float32Array(o*4);k.__colorArray=new Float32Array(o*3);k.__uvArray=new Float32Array(o*2);k.__uv2Array=new Float32Array(o*2);k.__faceArray=new Uint16Array(v*3);k.__lineArray=new Uint16Array(D*2);o=false;u=0;for(n=w.materials.length;u<n;u++){y=w.materials[u];if(y instanceof THREE.MeshFaceMaterial){y=0;for(C=k.materials.length;y<C;y++)if(k.materials[y]&&k.materials[y].shading!=undefined&&k.materials[y].shading==THREE.SmoothShading){o=true;
-break}}else if(y&&y.shading!=undefined&&y.shading==THREE.SmoothShading){o=true;break}if(o)break}k.__needsSmoothNormals=o;k.__webGLFaceCount=v*3;k.__webGLLineCount=D*2};this.setMeshBuffers=function(k,w,u){var n,o,v,D,y,C,z,F,J,M,Q=0,S=0,U=0,ca=0,da=0,T=0,O=0,Z=0,V=0,K=k.__vertexArray,W=k.__uvArray,ba=k.__uv2Array,ha=k.__normalArray,ea=k.__tangentArray,G=k.__colorArray,N=k.__faceArray,L=k.__lineArray,X=k.__needsSmoothNormals,$=w.geometry,ma=$.__dirtyVertices,ia=$.__dirtyElements,qa=$.__dirtyUvs,ta=
-$.__dirtyNormals,ua=$.__dirtyTangents,ka=$.__dirtyColors,ja=$.vertices,Fa=k.faces,Aa=$.faces,Ja=$.uvs,Ka=$.uvs2,ra=$.colors;w=0;for(n=Fa.length;w<n;w++){o=Fa[w];v=Aa[o];C=Ja[o];o=Ka[o];D=v.vertexNormals;y=v.normal;if(v instanceof THREE.Face3){if(ma){z=ja[v.a].position;F=ja[v.b].position;J=ja[v.c].position;K[S]=z.x;K[S+1]=z.y;K[S+2]=z.z;K[S+3]=F.x;K[S+4]=F.y;K[S+5]=F.z;K[S+6]=J.x;K[S+7]=J.y;K[S+8]=J.z;S+=9}if(ka&&ra.length){z=ra[v.a];F=ra[v.b];J=ra[v.c];G[V]=z.r;G[V+1]=z.g;G[V+2]=z.b;G[V+3]=F.r;G[V+
-4]=F.g;G[V+5]=F.b;G[V+6]=J.r;G[V+7]=J.g;G[V+8]=J.b;V+=9}if(ua&&$.hasTangents){z=ja[v.a].tangent;F=ja[v.b].tangent;J=ja[v.c].tangent;ea[O]=z.x;ea[O+1]=z.y;ea[O+2]=z.z;ea[O+3]=z.w;ea[O+4]=F.x;ea[O+5]=F.y;ea[O+6]=F.z;ea[O+7]=F.w;ea[O+8]=J.x;ea[O+9]=J.y;ea[O+10]=J.z;ea[O+11]=J.w;O+=12}if(ta)if(D.length==3&&X)for(v=0;v<3;v++){y=D[v];ha[T]=y.x;ha[T+1]=y.y;ha[T+2]=y.z;T+=3}else for(v=0;v<3;v++){ha[T]=y.x;ha[T+1]=y.y;ha[T+2]=y.z;T+=3}if(qa&&C)for(v=0;v<3;v++){D=C[v];W[U]=D.u;W[U+1]=D.v;U+=2}if(qa&&o)for(v=
-0;v<3;v++){C=o[v];ba[ca]=C.u;ba[ca+1]=C.v;ca+=2}if(ia){N[da]=Q;N[da+1]=Q+1;N[da+2]=Q+2;da+=3;L[Z]=Q;L[Z+1]=Q+1;L[Z+2]=Q;L[Z+3]=Q+2;L[Z+4]=Q+1;L[Z+5]=Q+2;Z+=6;Q+=3}}else if(v instanceof THREE.Face4){if(ma){z=ja[v.a].position;F=ja[v.b].position;J=ja[v.c].position;M=ja[v.d].position;K[S]=z.x;K[S+1]=z.y;K[S+2]=z.z;K[S+3]=F.x;K[S+4]=F.y;K[S+5]=F.z;K[S+6]=J.x;K[S+7]=J.y;K[S+8]=J.z;K[S+9]=M.x;K[S+10]=M.y;K[S+11]=M.z;S+=12}if(ka&&ra.length){z=ra[v.a];F=ra[v.b];J=ra[v.d];G[V]=z.r;G[V+1]=z.g;G[V+2]=z.b;G[V+
-3]=F.r;G[V+4]=F.g;G[V+5]=F.b;G[V+6]=J.r;G[V+7]=J.g;G[V+8]=J.b;G[V+9]=(void 0).r;G[V+10]=(void 0).g;G[V+11]=(void 0).b;V+=12}if(ua&&$.hasTangents){z=ja[v.a].tangent;F=ja[v.b].tangent;J=ja[v.c].tangent;v=ja[v.d].tangent;ea[O]=z.x;ea[O+1]=z.y;ea[O+2]=z.z;ea[O+3]=z.w;ea[O+4]=F.x;ea[O+5]=F.y;ea[O+6]=F.z;ea[O+7]=F.w;ea[O+8]=J.x;ea[O+9]=J.y;ea[O+10]=J.z;ea[O+11]=J.w;ea[O+12]=v.x;ea[O+13]=v.y;ea[O+14]=v.z;ea[O+15]=v.w;O+=16}if(ta)if(D.length==4&&X)for(v=0;v<4;v++){y=D[v];ha[T]=y.x;ha[T+1]=y.y;ha[T+2]=y.z;
-T+=3}else for(v=0;v<4;v++){ha[T]=y.x;ha[T+1]=y.y;ha[T+2]=y.z;T+=3}if(qa&&C)for(v=0;v<4;v++){D=C[v];W[U]=D.u;W[U+1]=D.v;U+=2}if(qa&&o)for(v=0;v<4;v++){C=o[v];ba[ca]=C.u;ba[ca+1]=C.v;ca+=2}if(ia){N[da]=Q;N[da+1]=Q+1;N[da+2]=Q+2;N[da+3]=Q;N[da+4]=Q+2;N[da+5]=Q+3;da+=6;L[Z]=Q;L[Z+1]=Q+1;L[Z+2]=Q;L[Z+3]=Q+3;L[Z+4]=Q+1;L[Z+5]=Q+2;L[Z+6]=Q+2;L[Z+7]=Q+3;Z+=8;Q+=4}}}if(ma){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,K,u)}if(ka&&ra.length){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);
-b.bufferData(b.ARRAY_BUFFER,G,u)}if(ta){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,u)}if(ua&&$.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,ea,u)}if(qa&&U>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,W,u)}if(qa&&ca>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,ba,u)}if(ia){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,
-N,u);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,L,u)}};this.setLineBuffers=function(k,w){var u,n,o,v=k.vertices,D=k.colors,y=v.length,C=D.length,z=k.__vertexArray,F=k.__colorArray,J=k.__dirtyColors;if(k.__dirtyVertices){for(u=0;u<y;u++){n=v[u].position;o=u*3;z[o]=n.x;z[o+1]=n.y;z[o+2]=n.z}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,z,w)}if(J){for(u=0;u<C;u++){color=D[u];o=u*3;F[o]=color.r;F[o+1]=color.g;F[o+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,
-k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,F,w)}};this.setParticleBuffers=function(k,w,u){var n,o,v,D=k.vertices,y=D.length,C=k.colors,z=C.length,F=k.__vertexArray,J=k.__colorArray,M=k.__sortArray,Q=k.__dirtyVertices,S=k.__dirtyColors;if(u.sortParticles){m.multiplySelf(u.matrix);for(n=0;n<y;n++){o=D[n].position;H.copy(o);m.multiplyVector3(H);M[n]=[H.z,n]}M.sort(function(U,ca){return ca[0]-U[0]});for(n=0;n<y;n++){o=D[M[n][1]].position;v=n*3;F[v]=o.x;F[v+1]=o.y;F[v+2]=o.z}for(n=0;n<z;n++){v=
-n*3;color=C[M[n][1]];J[v]=color.r;J[v+1]=color.g;J[v+2]=color.b}}else{if(Q)for(n=0;n<y;n++){o=D[n].position;v=n*3;F[v]=o.x;F[v+1]=o.y;F[v+2]=o.z}if(S)for(n=0;n<z;n++){color=C[n];v=n*3;J[v]=color.r;J[v+1]=color.g;J[v+2]=color.b}}if(Q||u.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,w)}if(S||u.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,J,w)}};this.initMaterial=function(k,w,u){var n,o;if(k instanceof THREE.MeshDepthMaterial)c(k,
-THREE.ShaderLib.depth);else if(k instanceof THREE.MeshNormalMaterial)c(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)c(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)c(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)c(k,THREE.ShaderLib.phong);else if(k instanceof THREE.LineBasicMaterial)c(k,THREE.ShaderLib.basic);else k instanceof THREE.ParticleBasicMaterial&&c(k,THREE.ShaderLib.particle_basic);var v,D,y,C;o=y=C=0;for(v=w.length;o<
-v;o++){D=w[o];D instanceof THREE.DirectionalLight&&y++;D instanceof THREE.PointLight&&C++}if(C+y<=4){w=y;C=C}else{w=Math.ceil(4*y/(C+y));C=4-w}o={directional:w,point:C};C=k.fragment_shader;w=k.vertex_shader;v={fog:u,map:k.map,env_map:k.env_map,light_map:k.light_map,vertex_colors:k.vertex_colors,maxDirLights:o.directional,maxPointLights:o.point};u=b.createProgram();o=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,
-v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":
-"",v.light_map?"#define USE_LIGHTMAP":"",v.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(u,g("fragment",o+C));b.attachShader(u,g("vertex",v+w));b.linkProgram(u);b.getProgramParameter(u,b.LINK_STATUS)||
-alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(u,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");u.uniforms={};u.attributes={};k.program=u;u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(n in k.uniforms)u.push(n);n=k.program;C=0;for(w=u.length;C<w;C++){o=u[C];n.uniforms[o]=b.getUniformLocation(n,o)}k=k.program;n=["position","normal","uv","uv2","tangent","color"];u=0;for(C=n.length;u<C;u++){w=n[u];k.attributes[w]=
-b.getAttribLocation(k,w)}};this.setProgram=function(k,w,u,n,o){n.program||this.initMaterial(n,w,u);var v=n.program,D=v.uniforms,y=n.uniforms;if(v!=j){b.useProgram(v);j=v;b.uniformMatrix4fv(D.projectionMatrix,false,B)}if(u&&(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial||n instanceof THREE.LineBasicMaterial||n instanceof THREE.ParticleBasicMaterial)){y.fogColor.value.setHex(u.color.hex);if(u instanceof THREE.Fog){y.fogNear.value=
-u.near;y.fogFar.value=u.far}else if(u instanceof THREE.FogExp2)y.fogDensity.value=u.density}if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){this.setupLights(v,w);w=this.lights;y.enableLighting.value=w.directional.length+w.point.length;y.ambientLightColor.value=w.ambient;y.directionalLightColor.value=w.directional.colors;y.directionalLightDirection.value=w.directional.positions;y.pointLightColor.value=w.point.colors;y.pointLightPosition.value=w.point.positions}if(n instanceof
-THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial){y.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);y.opacity.value=n.opacity;y.map.texture=n.map;y.light_map.texture=n.light_map;y.env_map.texture=n.env_map;y.reflectivity.value=n.reflectivity;y.refraction_ratio.value=n.refraction_ratio;y.combine.value=n.combine;y.useRefract.value=n.env_map&&n.env_map.mapping instanceof THREE.CubeRefractionMapping}if(n instanceof
-THREE.LineBasicMaterial){y.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);y.opacity.value=n.opacity}else if(n instanceof THREE.ParticleBasicMaterial){y.psColor.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);y.opacity.value=n.opacity;y.size.value=n.size;y.map.texture=n.map}else if(n instanceof THREE.MeshPhongMaterial){y.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);y.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);
-y.shininess.value=n.shininess}else if(n instanceof THREE.MeshDepthMaterial){y.mNear.value=k.near;y.mFar.value=k.far;y.opacity.value=n.opacity}else if(n instanceof THREE.MeshNormalMaterial)y.opacity.value=n.opacity;var C,z,F;for(C in y)if(F=v.uniforms[C]){u=y[C];z=u.type;w=u.value;if(z=="i")b.uniform1i(F,w);else if(z=="f")b.uniform1f(F,w);else if(z=="fv1")b.uniform1fv(F,w);else if(z=="fv")b.uniform3fv(F,w);else if(z=="v2")b.uniform2f(F,w.x,w.y);else if(z=="v3")b.uniform3f(F,w.x,w.y,w.z);else if(z==
-"c")b.uniform3f(F,w.r,w.g,w.b);else if(z=="t"){b.uniform1i(F,w);if(u=u.texture)if(u.image instanceof Array&&u.image.length==6){u=u;w=w;if(u.image.length==6){if(!u.image.__webGLTextureCube&&!u.image.__cubeMapInitialized&&u.image.loadCount==6){u.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,u.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(z=0;z<6;++z)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+z,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,u.image[z]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);u.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+w);b.bindTexture(b.TEXTURE_CUBE_MAP,u.image.__webGLTextureCube)}}else{u=u;w=w;if(!u.__webGLTexture&&u.image.loaded){u.__webGLTexture=b.createTexture();
-b.bindTexture(b.TEXTURE_2D,u.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,u.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(u.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(u.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(u.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(u.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+w);b.bindTexture(b.TEXTURE_2D,u.__webGLTexture)}}}b.uniformMatrix4fv(D.modelViewMatrix,
-false,o._modelViewMatrixArray);b.uniformMatrix3fv(D.normalMatrix,false,o._normalMatrixArray);if(n instanceof THREE.MeshShaderMaterial||n instanceof THREE.MeshPhongMaterial||n.env_map)b.uniform3f(D.cameraPosition,k.position.x,k.position.y,k.position.z);if(n instanceof THREE.MeshShaderMaterial||n.env_map)b.uniformMatrix4fv(D.objectMatrix,false,o._objectMatrixArray);if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(D.viewMatrix,
-false,E);return v};this.renderBuffer=function(k,w,u,n,o,v){k=this.setProgram(k,w,u,n,v).attributes;b.bindBuffer(b.ARRAY_BUFFER,o.__webGLVertexBuffer);b.vertexAttribPointer(k.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.position);if(k.color>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLColorBuffer);b.vertexAttribPointer(k.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.color)}if(k.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT,
-false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(o.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUVBuffer);b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(o.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2,
-2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2);if(v instanceof THREE.Mesh)if(n.wireframe){b.lineWidth(n.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);b.drawElements(b.LINES,o.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,o.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(n.linewidth);
-b.drawArrays(v,0,o.__webGLLineCount)}else v instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,o.__webGLParticleCount)};this.renderPass=function(k,w,u,n,o,v,D){var y,C,z,F,J;z=0;for(F=n.materials.length;z<F;z++){y=n.materials[z];if(y instanceof THREE.MeshFaceMaterial){y=0;for(C=o.materials.length;y<C;y++)if((J=o.materials[y])&&J.blending==v&&J.opacity<1==D){e(J.blending);this.setDepthTest(J.depth_test);this.renderBuffer(k,w,u,J,o,n)}}else if((J=y)&&J.blending==v&&J.opacity<1==D){e(J.blending);
-this.setDepthTest(J.depth_test);this.renderBuffer(k,w,u,J,o,n)}}};this.renderPassImmediate=function(k,w,u,n,o,v){var D,y,C,z;D=0;for(y=n.materials.length;D<y;D++)if((C=n.materials[D])&&C.blending==o&&C.opacity<1==v){e(C.blending);this.setDepthTest(C.depth_test);z=this.setProgram(k,w,u,C,n);n.render(function(F){var J=z;if(!F.__webGLVertexBuffer)F.__webGLVertexBuffer=b.createBuffer();if(!F.__webGLNormalBuffer)F.__webGLNormalBuffer=b.createBuffer();if(F.hasPos){b.bindBuffer(b.ARRAY_BUFFER,F.__webGLVertexBuffer);
-b.bufferData(b.ARRAY_BUFFER,F.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(J.attributes.position);b.vertexAttribPointer(J.attributes.position,3,b.FLOAT,false,0,0)}if(F.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,F.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,F.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(J.attributes.normal);b.vertexAttribPointer(J.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,F.count);F.count=0})}};this.render=function(k,w,u,n){var o,v,D,y,
-C=k.lights,z=k.fog;w.autoUpdateMatrix&&w.updateMatrix();w.matrix.flattenToArray(E);w.projectionMatrix.flattenToArray(B);m.multiply(w.projectionMatrix,w.matrix);q[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);q[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);q[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);q[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);q[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);q[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+
-m.n34);for(o=0;o<5;o++){y=q[o];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}this.initWebGLObjects(k,w);n=n!==undefined?n:true;if(u&&!u.__webGLFramebuffer){u.__webGLFramebuffer=b.createFramebuffer();u.__webGLRenderbuffer=b.createRenderbuffer();u.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,u.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,u.width,u.height);b.bindTexture(b.TEXTURE_2D,u.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,
-f(u.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(u.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(u.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(u.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(u.format),u.width,u.height,0,f(u.format),f(u.type),null);b.bindFramebuffer(b.FRAMEBUFFER,u.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,u.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,
-u.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(u){o=u.__webGLFramebuffer;y=u.width;D=u.height}else{o=null;y=h.width;D=h.height}if(o!=l){b.bindFramebuffer(b.FRAMEBUFFER,o);b.viewport(0,0,y,D);n&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);l=o}this.autoClear&&this.clear();o=k.__webGLObjects.length;for(n=0;n<o;n++){D=k.__webGLObjects[n];y=D.object;if(v=y.visible){if(!(v=!(y instanceof THREE.Mesh)))a:{v=void 0;
-for(var F=y.matrix,J=-y.geometry.boundingSphere.radius*Math.max(y.scale.x,Math.max(y.scale.y,y.scale.z)),M=0;M<6;M++){v=q[M].x*F.n14+q[M].y*F.n24+q[M].z*F.n34+q[M].w;if(v<=J){v=false;break a}}v=true}v=v}if(v){if(y.autoUpdateMatrix){y.updateMatrix();y.matrix.flattenToArray(y._objectMatrixArray)}this.setupMatrices(y,w);D.render=true}else D.render=false}v=k.__webGLObjectsImmediate.length;for(n=0;n<v;n++){y=k.__webGLObjectsImmediate[n].object;if(y.visible){if(y.autoUpdateMatrix){y.updateMatrix();y.matrix.flattenToArray(y._objectMatrixArray)}this.setupMatrices(y,
-w)}}for(n=0;n<o;n++){D=k.__webGLObjects[n];if(D.render){y=D.object;D=D.buffer;d(y);this.renderPass(w,C,z,y,D,THREE.NormalBlending,false)}}for(n=0;n<v;n++){y=k.__webGLObjectsImmediate[n].object;if(y.visible){d(y);this.renderPassImmediate(w,C,z,y,THREE.NormalBlending,false)}}for(n=0;n<o;n++){D=k.__webGLObjects[n];if(D.render){y=D.object;D=D.buffer;d(y);this.renderPass(w,C,z,y,D,THREE.AdditiveBlending,false);this.renderPass(w,C,z,y,D,THREE.SubtractiveBlending,false);this.renderPass(w,C,z,y,D,THREE.AdditiveBlending,
-true);this.renderPass(w,C,z,y,D,THREE.SubtractiveBlending,true);this.renderPass(w,C,z,y,D,THREE.NormalBlending,true);this.renderPass(w,C,z,y,D,THREE.BillboardBlending,false)}}for(n=0;n<v;n++){y=k.__webGLObjectsImmediate[n].object;if(y.visible){d(y);this.renderPassImmediate(w,C,z,y,THREE.NormalBlending,true)}}if(u&&u.min_filter!==THREE.NearestFilter&&u.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,u.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
-function(k,w){function u(J,M,Q,S){if(J[M]==undefined){k.__webGLObjects.push({buffer:Q,object:S});J[M]=1}}function n(J,M,Q){if(J[M]==undefined){k.__webGLObjectsImmediate.push({object:Q});J[M]=1}}var o,v,D,y,C,z,F;if(!k.__webGLObjects){k.__webGLObjects=[];k.__webGLObjectsMap={};k.__webGLObjectsImmediate=[]}o=0;for(v=k.objects.length;o<v;o++){D=k.objects[o];C=D.geometry;if(k.__webGLObjectsMap[D.id]==undefined){k.__webGLObjectsMap[D.id]={};D._modelViewMatrix=new THREE.Matrix4;D._normalMatrixArray=new Float32Array(9);
-D._modelViewMatrixArray=new Float32Array(16);D._objectMatrixArray=new Float32Array(16);D.matrix.flattenToArray(D._objectMatrixArray)}F=k.__webGLObjectsMap[D.id];if(D instanceof THREE.Mesh){for(y in C.geometryChunks){z=C.geometryChunks[y];if(!z.__webGLVertexBuffer){this.createMeshBuffers(z);this.initMeshBuffers(z,D);C.__dirtyVertices=true;C.__dirtyElements=true;C.__dirtyUvs=true;C.__dirtyNormals=true;C.__dirtyTangents=true;C.__dirtyColors=true}if(C.__dirtyVertices||C.__dirtyElements||C.__dirtyUvs||
-C.__dirtyNormals||C.__dirtyColors||C.__dirtyTangents)this.setMeshBuffers(z,D,b.DYNAMIC_DRAW);u(F,y,z,D)}C.__dirtyVertices=false;C.__dirtyElements=false;C.__dirtyUvs=false;C.__dirtyNormals=false;C.__dirtyTangents=false;C.__dirtyColors=false}else if(D instanceof THREE.Line){if(!C.__webGLVertexBuffer){this.createLineBuffers(C);this.initLineBuffers(C);C.__dirtyVertices=true;C.__dirtyColors=true}if(C.__dirtyVertices||C.__dirtyColors)this.setLineBuffers(C,b.DYNAMIC_DRAW);u(F,0,C,D);C.__dirtyVertices=false;
-C.__dirtyColors=false}else if(D instanceof THREE.ParticleSystem){if(!C.__webGLVertexBuffer){this.createParticleBuffers(C);this.initParticleBuffers(C);C.__dirtyVertices=true;C.__dirtyColors=true}if(C.__dirtyVertices||C.__dirtyColors||D.sortParticles)this.setParticleBuffers(C,b.DYNAMIC_DRAW,D,w);u(F,0,C,D);C.__dirtyVertices=false;C.__dirtyColors=false}else D instanceof THREE.MarchingCubes&&n(F,0,D)}};this.removeObject=function(k,w){var u,n;for(u=k.__webGLObjects.length-1;u>=0;u--){n=k.__webGLObjects[u].object;
-w==n&&k.__webGLObjects.splice(u,1)}};this.setupMatrices=function(k,w){k._modelViewMatrix.multiplyToArray(w.matrix,k.matrix,k._modelViewMatrixArray);k._normalMatrix=THREE.Matrix4.makeInvert3x3(k._modelViewMatrix).transposeIntoArray(k._normalMatrixArray)};this.setDepthTest=function(k){k?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(k,w){if(k){!w||w=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);
+b,j=null,l=null,t=null,A=null,w=null,o=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],p=new THREE.Matrix4,C=new Float32Array(16),H=new Float32Array(16),y=new THREE.Vector4,I=true,v=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)I=a.antialias;a.clearColor!==undefined&&v.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=h;this.autoClear=true;(function(k,B,n){try{b=h.getContext("experimental-webgl",
+{antialias:k})}catch(m){console.log(m)}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(B.r,B.g,B.b,n);_cullEnabled=true})(I,v,L);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=
+function(k,B){h.width=k;h.height=B;b.viewport(0,0,h.width,h.height)};this.setClearColorHex=function(k,B){var n=new THREE.Color(k);b.clearColor(n.r,n.g,n.b,B)};this.setClearColor=function(k,B){b.clearColor(k.r,k.g,k.b,B)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,B){var n,m,z,q=0,D=0,x=0,u,F,J,G=this.lights,T=G.directional.colors,U=G.directional.positions,O=G.point.colors,ba=G.point.positions,ca=0,W=0;n=z=z=0;for(m=B.length;n<m;n++){z=B[n];u=
+z.color;F=z.position;J=z.intensity;if(z instanceof THREE.AmbientLight){q+=u.r;D+=u.g;x+=u.b}else if(z instanceof THREE.DirectionalLight){z=ca*3;T[z]=u.r*J;T[z+1]=u.g*J;T[z+2]=u.b*J;U[z]=F.x;U[z+1]=F.y;U[z+2]=F.z;ca+=1}else if(z instanceof THREE.PointLight){z=W*3;O[z]=u.r*J;O[z+1]=u.g*J;O[z+2]=u.b*J;ba[z]=F.x;ba[z+1]=F.y;ba[z+2]=F.z;W+=1}}for(n=ca*3;n<T.length;n++)T[n]=0;for(n=W*3;n<O.length;n++)O[n]=0;G.point.length=W;G.directional.length=ca;G.ambient[0]=q;G.ambient[1]=D;G.ambient[2]=x};this.createParticleBuffers=
+function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer()};this.createMeshBuffers=function(k){k.__webGLVertexBuffer=b.createBuffer();k.__webGLNormalBuffer=b.createBuffer();k.__webGLTangentBuffer=b.createBuffer();k.__webGLColorBuffer=b.createBuffer();k.__webGLUVBuffer=b.createBuffer();k.__webGLUV2Buffer=b.createBuffer();k.__webGLFaceBuffer=b.createBuffer();
+k.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(k){var B=k.vertices.length;k.__vertexArray=new Float32Array(B*3);k.__colorArray=new Float32Array(B*3);k.__webGLLineCount=B};this.initParticleBuffers=function(k){var B=k.vertices.length;k.__vertexArray=new Float32Array(B*3);k.__colorArray=new Float32Array(B*3);k.__sortArray=[];k.__webGLParticleCount=B};this.initMeshBuffers=function(k,B){var n,m,z=0,q=0,D=0,x=B.geometry.faces,u=k.faces;n=0;for(m=u.length;n<m;n++){fi=u[n];face=x[fi];
+if(face instanceof THREE.Face3){z+=3;q+=1;D+=3}else if(face instanceof THREE.Face4){z+=4;q+=2;D+=4}}k.__vertexArray=new Float32Array(z*3);k.__normalArray=new Float32Array(z*3);k.__tangentArray=new Float32Array(z*4);k.__colorArray=new Float32Array(z*3);k.__uvArray=new Float32Array(z*2);k.__uv2Array=new Float32Array(z*2);k.__faceArray=new Uint16Array(q*3);k.__lineArray=new Uint16Array(D*2);z=false;n=0;for(m=B.materials.length;n<m;n++){x=B.materials[n];if(x instanceof THREE.MeshFaceMaterial){x=0;for(u=
+k.materials.length;x<u;x++)if(k.materials[x]&&k.materials[x].shading!=undefined&&k.materials[x].shading==THREE.SmoothShading){z=true;break}}else if(x&&x.shading!=undefined&&x.shading==THREE.SmoothShading){z=true;break}if(z)break}k.__needsSmoothNormals=z;k.__webGLFaceCount=q*3;k.__webGLLineCount=D*2};this.setMeshBuffers=function(k,B,n){var m,z,q,D,x,u,F,J,G,T,U=0,O=0,ba=0,ca=0,W=0,R=0,X=0,Y=0,M=0,S=k.__vertexArray,aa=k.__uvArray,ja=k.__uv2Array,ha=k.__normalArray,E=k.__tangentArray,K=k.__colorArray,
+N=k.__faceArray,V=k.__lineArray,da=k.__needsSmoothNormals,ga=B.geometry,ia=ga.__dirtyVertices,ta=ga.__dirtyElements,ra=ga.__dirtyUvs,va=ga.__dirtyNormals,ka=ga.__dirtyTangents,sa=ga.__dirtyColors,oa=ga.vertices,Ba=k.faces,Ja=ga.faces,Ka=ga.uvs,Ga=ga.uvs2,qa=ga.colors;B=0;for(m=Ba.length;B<m;B++){z=Ba[B];q=Ja[z];u=Ka[z];z=Ga[z];D=q.vertexNormals;x=q.normal;if(q instanceof THREE.Face3){if(ia){F=oa[q.a].position;J=oa[q.b].position;G=oa[q.c].position;S[O]=F.x;S[O+1]=F.y;S[O+2]=F.z;S[O+3]=J.x;S[O+4]=J.y;
+S[O+5]=J.z;S[O+6]=G.x;S[O+7]=G.y;S[O+8]=G.z;O+=9}if(sa&&qa.length){F=qa[q.a];J=qa[q.b];G=qa[q.c];K[M]=F.r;K[M+1]=F.g;K[M+2]=F.b;K[M+3]=J.r;K[M+4]=J.g;K[M+5]=J.b;K[M+6]=G.r;K[M+7]=G.g;K[M+8]=G.b;M+=9}if(ka&&ga.hasTangents){F=oa[q.a].tangent;J=oa[q.b].tangent;G=oa[q.c].tangent;E[X]=F.x;E[X+1]=F.y;E[X+2]=F.z;E[X+3]=F.w;E[X+4]=J.x;E[X+5]=J.y;E[X+6]=J.z;E[X+7]=J.w;E[X+8]=G.x;E[X+9]=G.y;E[X+10]=G.z;E[X+11]=G.w;X+=12}if(va)if(D.length==3&&da)for(q=0;q<3;q++){x=D[q];ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}else for(q=
+0;q<3;q++){ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}if(ra&&u)for(q=0;q<3;q++){D=u[q];aa[ba]=D.u;aa[ba+1]=D.v;ba+=2}if(ra&&z)for(q=0;q<3;q++){u=z[q];ja[ca]=u.u;ja[ca+1]=u.v;ca+=2}if(ta){N[W]=U;N[W+1]=U+1;N[W+2]=U+2;W+=3;V[Y]=U;V[Y+1]=U+1;V[Y+2]=U;V[Y+3]=U+2;V[Y+4]=U+1;V[Y+5]=U+2;Y+=6;U+=3}}else if(q instanceof THREE.Face4){if(ia){F=oa[q.a].position;J=oa[q.b].position;G=oa[q.c].position;T=oa[q.d].position;S[O]=F.x;S[O+1]=F.y;S[O+2]=F.z;S[O+3]=J.x;S[O+4]=J.y;S[O+5]=J.z;S[O+6]=G.x;S[O+7]=G.y;S[O+8]=G.z;
+S[O+9]=T.x;S[O+10]=T.y;S[O+11]=T.z;O+=12}if(sa&&qa.length){F=qa[q.a];J=qa[q.b];G=qa[q.c];T=qa[q.d];K[M]=F.r;K[M+1]=F.g;K[M+2]=F.b;K[M+3]=J.r;K[M+4]=J.g;K[M+5]=J.b;K[M+6]=G.r;K[M+7]=G.g;K[M+8]=G.b;K[M+9]=T.r;K[M+10]=T.g;K[M+11]=T.b;M+=12}if(ka&&ga.hasTangents){F=oa[q.a].tangent;J=oa[q.b].tangent;G=oa[q.c].tangent;q=oa[q.d].tangent;E[X]=F.x;E[X+1]=F.y;E[X+2]=F.z;E[X+3]=F.w;E[X+4]=J.x;E[X+5]=J.y;E[X+6]=J.z;E[X+7]=J.w;E[X+8]=G.x;E[X+9]=G.y;E[X+10]=G.z;E[X+11]=G.w;E[X+12]=q.x;E[X+13]=q.y;E[X+14]=q.z;E[X+
+15]=q.w;X+=16}if(va)if(D.length==4&&da)for(q=0;q<4;q++){x=D[q];ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}else for(q=0;q<4;q++){ha[R]=x.x;ha[R+1]=x.y;ha[R+2]=x.z;R+=3}if(ra&&u)for(q=0;q<4;q++){D=u[q];aa[ba]=D.u;aa[ba+1]=D.v;ba+=2}if(ra&&z)for(q=0;q<4;q++){u=z[q];ja[ca]=u.u;ja[ca+1]=u.v;ca+=2}if(ta){N[W]=U;N[W+1]=U+1;N[W+2]=U+2;N[W+3]=U;N[W+4]=U+2;N[W+5]=U+3;W+=6;V[Y]=U;V[Y+1]=U+1;V[Y+2]=U;V[Y+3]=U+3;V[Y+4]=U+1;V[Y+5]=U+2;V[Y+6]=U+2;V[Y+7]=U+3;Y+=8;U+=4}}}if(ia){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);
+b.bufferData(b.ARRAY_BUFFER,S,n)}if(sa&&qa.length){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,K,n)}if(va){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ha,n)}if(ka&&ga.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,E,n)}if(ra&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,aa,n)}if(ra&&ca>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,
+ja,n)}if(ta){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,V,n)}};this.setLineBuffers=function(k,B){var n,m,z,q=k.vertices,D=k.colors,x=q.length,u=D.length,F=k.__vertexArray,J=k.__colorArray,G=k.__dirtyColors;if(k.__dirtyVertices){for(n=0;n<x;n++){m=q[n].position;z=n*3;F[z]=m.x;F[z+1]=m.y;F[z+2]=m.z}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,
+F,B)}if(G){for(n=0;n<u;n++){color=D[n];z=n*3;J[z]=color.r;J[z+1]=color.g;J[z+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,J,B)}};this.setParticleBuffers=function(k,B,n){var m,z,q,D=k.vertices,x=D.length,u=k.colors,F=u.length,J=k.__vertexArray,G=k.__colorArray,T=k.__sortArray,U=k.__dirtyVertices,O=k.__dirtyColors;if(n.sortParticles){p.multiplySelf(n.matrix);for(m=0;m<x;m++){z=D[m].position;y.copy(z);p.multiplyVector3(y);T[m]=[y.z,m]}T.sort(function(ba,ca){return ca[0]-
+ba[0]});for(m=0;m<x;m++){z=D[T[m][1]].position;q=m*3;J[q]=z.x;J[q+1]=z.y;J[q+2]=z.z}for(m=0;m<F;m++){q=m*3;color=u[T[m][1]];G[q]=color.r;G[q+1]=color.g;G[q+2]=color.b}}else{if(U)for(m=0;m<x;m++){z=D[m].position;q=m*3;J[q]=z.x;J[q+1]=z.y;J[q+2]=z.z}if(O)for(m=0;m<F;m++){color=u[m];q=m*3;G[q]=color.r;G[q+1]=color.g;G[q+2]=color.b}}if(U||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,J,B)}if(O||n.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLColorBuffer);
+b.bufferData(b.ARRAY_BUFFER,G,B)}};this.initMaterial=function(k,B,n){var m,z;if(k instanceof THREE.MeshDepthMaterial)c(k,THREE.ShaderLib.depth);else if(k instanceof THREE.MeshNormalMaterial)c(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)c(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)c(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)c(k,THREE.ShaderLib.phong);else if(k instanceof THREE.LineBasicMaterial)c(k,THREE.ShaderLib.basic);
+else k instanceof THREE.ParticleBasicMaterial&&c(k,THREE.ShaderLib.particle_basic);var q,D,x,u;z=x=u=0;for(q=B.length;z<q;z++){D=B[z];D instanceof THREE.DirectionalLight&&x++;D instanceof THREE.PointLight&&u++}if(u+x<=4){B=x;u=u}else{B=Math.ceil(4*x/(u+x));u=4-B}z={directional:B,point:u};u=k.fragment_shader;B=k.vertex_shader;q={fog:n,map:k.map,env_map:k.env_map,light_map:k.light_map,vertex_colors:k.vertex_colors,maxDirLights:z.directional,maxPointLights:z.point};n=b.createProgram();z=["#ifdef GL_ES\nprecision highp float;\n#endif",
+"#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+q.maxPointLights,q.fog?"#define USE_FOG":"",q.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");q=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+q.maxDirLights,"#define MAX_POINT_LIGHTS "+
+q.maxPointLights,q.map?"#define USE_MAP":"",q.env_map?"#define USE_ENVMAP":"",q.light_map?"#define USE_LIGHTMAP":"",q.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(n,g("fragment",z+u));b.attachShader(n,
+g("vertex",q+B));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};k.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(m in k.uniforms)n.push(m);m=k.program;u=0;for(B=n.length;u<B;u++){z=n[u];m.uniforms[z]=b.getUniformLocation(m,z)}k=k.program;m=["position","normal",
+"uv","uv2","tangent","color"];n=0;for(u=m.length;n<u;n++){B=m[n];k.attributes[B]=b.getAttribLocation(k,B)}};this.setProgram=function(k,B,n,m,z){m.program||this.initMaterial(m,B,n);var q=m.program,D=q.uniforms,x=m.uniforms;if(q!=j){b.useProgram(q);j=q;b.uniformMatrix4fv(D.projectionMatrix,false,C)}if(n&&(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial||m instanceof THREE.LineBasicMaterial||m instanceof THREE.ParticleBasicMaterial)){x.fogColor.value.setHex(n.color.hex);
+if(n instanceof THREE.Fog){x.fogNear.value=n.near;x.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)x.fogDensity.value=n.density}if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){this.setupLights(q,B);B=this.lights;x.enableLighting.value=B.directional.length+B.point.length;x.ambientLightColor.value=B.ambient;x.directionalLightColor.value=B.directional.colors;x.directionalLightDirection.value=B.directional.positions;x.pointLightColor.value=B.point.colors;x.pointLightPosition.value=
+B.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial){x.diffuse.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);x.opacity.value=m.opacity;x.map.texture=m.map;x.light_map.texture=m.light_map;x.env_map.texture=m.env_map;x.reflectivity.value=m.reflectivity;x.refraction_ratio.value=m.refraction_ratio;x.combine.value=m.combine;x.useRefract.value=m.env_map&&m.env_map.mapping instanceof THREE.CubeRefractionMapping}if(m instanceof
+THREE.LineBasicMaterial){x.diffuse.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);x.opacity.value=m.opacity}else if(m instanceof THREE.ParticleBasicMaterial){x.psColor.value.setRGB(m.color.r*m.opacity,m.color.g*m.opacity,m.color.b*m.opacity);x.opacity.value=m.opacity;x.size.value=m.size;x.map.texture=m.map}else if(m instanceof THREE.MeshPhongMaterial){x.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);x.specular.value.setRGB(m.specular.r,m.specular.g,m.specular.b);
+x.shininess.value=m.shininess}else if(m instanceof THREE.MeshDepthMaterial){x.mNear.value=k.near;x.mFar.value=k.far;x.opacity.value=m.opacity}else if(m instanceof THREE.MeshNormalMaterial)x.opacity.value=m.opacity;var u,F,J;for(u in x)if(J=q.uniforms[u]){n=x[u];F=n.type;B=n.value;if(F=="i")b.uniform1i(J,B);else if(F=="f")b.uniform1f(J,B);else if(F=="fv1")b.uniform1fv(J,B);else if(F=="fv")b.uniform3fv(J,B);else if(F=="v2")b.uniform2f(J,B.x,B.y);else if(F=="v3")b.uniform3f(J,B.x,B.y,B.z);else if(F==
+"c")b.uniform3f(J,B.r,B.g,B.b);else if(F=="t"){b.uniform1i(J,B);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){n=n;B=B;if(n.image.length==6){if(!n.image.__webGLTextureCube&&!n.image.__cubeMapInitialized&&n.image.loadCount==6){n.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,n.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(F=0;F<6;++F)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+F,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image[F]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);n.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+B);b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{n=n;B=B;if(!n.__webGLTexture&&n.image.loaded){n.__webGLTexture=b.createTexture();
+b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(n.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+B);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture)}}}b.uniformMatrix4fv(D.modelViewMatrix,
+false,z._modelViewMatrixArray);b.uniformMatrix3fv(D.normalMatrix,false,z._normalMatrixArray);if(m instanceof THREE.MeshShaderMaterial||m instanceof THREE.MeshPhongMaterial||m.env_map)b.uniform3f(D.cameraPosition,k.position.x,k.position.y,k.position.z);if(m instanceof THREE.MeshShaderMaterial||m.env_map)b.uniformMatrix4fv(D.objectMatrix,false,z._objectMatrixArray);if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshShaderMaterial)b.uniformMatrix4fv(D.viewMatrix,
+false,H);return q};this.renderBuffer=function(k,B,n,m,z,q){k=this.setProgram(k,B,n,m,q).attributes;b.bindBuffer(b.ARRAY_BUFFER,z.__webGLVertexBuffer);b.vertexAttribPointer(k.position,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.position);if(k.color>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLColorBuffer);b.vertexAttribPointer(k.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.color)}if(k.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT,
+false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(z.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLUVBuffer);b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(z.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,z.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2,
+2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2);if(q instanceof THREE.Mesh)if(m.wireframe){b.lineWidth(m.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,z.__webGLLineBuffer);b.drawElements(b.LINES,z.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,z.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(q instanceof THREE.Line){q=q.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(m.linewidth);
+b.drawArrays(q,0,z.__webGLLineCount)}else q instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,z.__webGLParticleCount)};this.renderPass=function(k,B,n,m,z,q,D){var x,u,F,J,G;F=0;for(J=m.materials.length;F<J;F++){x=m.materials[F];if(x instanceof THREE.MeshFaceMaterial){x=0;for(u=z.materials.length;x<u;x++)if((G=z.materials[x])&&G.blending==q&&G.opacity<1==D){e(G.blending);this.setDepthTest(G.depth_test);this.renderBuffer(k,B,n,G,z,m)}}else if((G=x)&&G.blending==q&&G.opacity<1==D){e(G.blending);
+this.setDepthTest(G.depth_test);this.renderBuffer(k,B,n,G,z,m)}}};this.renderPassImmediate=function(k,B,n,m,z,q){var D,x,u,F;D=0;for(x=m.materials.length;D<x;D++)if((u=m.materials[D])&&u.blending==z&&u.opacity<1==q){e(u.blending);this.setDepthTest(u.depth_test);F=this.setProgram(k,B,n,u,m);m.render(function(J){var G=F;if(!J.__webGLVertexBuffer)J.__webGLVertexBuffer=b.createBuffer();if(!J.__webGLNormalBuffer)J.__webGLNormalBuffer=b.createBuffer();if(J.hasPos){b.bindBuffer(b.ARRAY_BUFFER,J.__webGLVertexBuffer);
+b.bufferData(b.ARRAY_BUFFER,J.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(G.attributes.position);b.vertexAttribPointer(G.attributes.position,3,b.FLOAT,false,0,0)}if(J.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,J.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,J.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(G.attributes.normal);b.vertexAttribPointer(G.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,J.count);J.count=0})}};this.render=function(k,B,n,m){var z,q,D,x,
+u=k.lights,F=k.fog;B.autoUpdateMatrix&&B.updateMatrix();B.matrix.flattenToArray(H);B.projectionMatrix.flattenToArray(C);p.multiply(B.projectionMatrix,B.matrix);o[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);o[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);o[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);o[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);o[4].set(p.n41-p.n31,p.n42-p.n32,p.n43-p.n33,p.n44-p.n34);o[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+
+p.n34);for(z=0;z<5;z++){x=o[z];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}this.initWebGLObjects(k,B);m=m!==undefined?m:true;if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=b.createFramebuffer();n.__webGLRenderbuffer=b.createRenderbuffer();n.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,n.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,n.width,n.height);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,
+f(n.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,f(n.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,f(n.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,f(n.min_filter));b.texImage2D(b.TEXTURE_2D,0,f(n.format),n.width,n.height,0,f(n.format),f(n.type),null);b.bindFramebuffer(b.FRAMEBUFFER,n.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,n.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,
+n.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}if(n){z=n.__webGLFramebuffer;x=n.width;D=n.height}else{z=null;x=h.width;D=h.height}if(z!=l){b.bindFramebuffer(b.FRAMEBUFFER,z);b.viewport(0,0,x,D);m&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);l=z}this.autoClear&&this.clear();z=k.__webGLObjects.length;for(m=0;m<z;m++){D=k.__webGLObjects[m];x=D.object;if(q=x.visible){if(!(q=!(x instanceof THREE.Mesh)))a:{q=void 0;
+for(var J=x.matrix,G=-x.geometry.boundingSphere.radius*Math.max(x.scale.x,Math.max(x.scale.y,x.scale.z)),T=0;T<6;T++){q=o[T].x*J.n14+o[T].y*J.n24+o[T].z*J.n34+o[T].w;if(q<=G){q=false;break a}}q=true}q=q}if(q){if(x.autoUpdateMatrix){x.updateMatrix();x.matrix.flattenToArray(x._objectMatrixArray)}this.setupMatrices(x,B);D.render=true}else D.render=false}q=k.__webGLObjectsImmediate.length;for(m=0;m<q;m++){x=k.__webGLObjectsImmediate[m].object;if(x.visible){if(x.autoUpdateMatrix){x.updateMatrix();x.matrix.flattenToArray(x._objectMatrixArray)}this.setupMatrices(x,
+B)}}for(m=0;m<z;m++){D=k.__webGLObjects[m];if(D.render){x=D.object;D=D.buffer;d(x);this.renderPass(B,u,F,x,D,THREE.NormalBlending,false)}}for(m=0;m<q;m++){x=k.__webGLObjectsImmediate[m].object;if(x.visible){d(x);this.renderPassImmediate(B,u,F,x,THREE.NormalBlending,false)}}for(m=0;m<z;m++){D=k.__webGLObjects[m];if(D.render){x=D.object;D=D.buffer;d(x);this.renderPass(B,u,F,x,D,THREE.AdditiveBlending,false);this.renderPass(B,u,F,x,D,THREE.SubtractiveBlending,false);this.renderPass(B,u,F,x,D,THREE.AdditiveBlending,
+true);this.renderPass(B,u,F,x,D,THREE.SubtractiveBlending,true);this.renderPass(B,u,F,x,D,THREE.NormalBlending,true);this.renderPass(B,u,F,x,D,THREE.BillboardBlending,false)}}for(m=0;m<q;m++){x=k.__webGLObjectsImmediate[m].object;if(x.visible){d(x);this.renderPassImmediate(B,u,F,x,THREE.NormalBlending,true)}}if(n&&n.min_filter!==THREE.NearestFilter&&n.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=
+function(k,B){function n(G,T,U,O){if(G[T]==undefined){k.__webGLObjects.push({buffer:U,object:O});G[T]=1}}function m(G,T,U){if(G[T]==undefined){k.__webGLObjectsImmediate.push({object:U});G[T]=1}}var z,q,D,x,u,F,J;if(!k.__webGLObjects){k.__webGLObjects=[];k.__webGLObjectsMap={};k.__webGLObjectsImmediate=[]}z=0;for(q=k.objects.length;z<q;z++){D=k.objects[z];u=D.geometry;if(k.__webGLObjectsMap[D.id]==undefined){k.__webGLObjectsMap[D.id]={};D._modelViewMatrix=new THREE.Matrix4;D._normalMatrixArray=new Float32Array(9);
+D._modelViewMatrixArray=new Float32Array(16);D._objectMatrixArray=new Float32Array(16);D.matrix.flattenToArray(D._objectMatrixArray)}J=k.__webGLObjectsMap[D.id];if(D instanceof THREE.Mesh){for(x in u.geometryChunks){F=u.geometryChunks[x];if(!F.__webGLVertexBuffer){this.createMeshBuffers(F);this.initMeshBuffers(F,D);u.__dirtyVertices=true;u.__dirtyElements=true;u.__dirtyUvs=true;u.__dirtyNormals=true;u.__dirtyTangents=true;u.__dirtyColors=true}if(u.__dirtyVertices||u.__dirtyElements||u.__dirtyUvs||
+u.__dirtyNormals||u.__dirtyColors||u.__dirtyTangents)this.setMeshBuffers(F,D,b.DYNAMIC_DRAW);n(J,x,F,D)}u.__dirtyVertices=false;u.__dirtyElements=false;u.__dirtyUvs=false;u.__dirtyNormals=false;u.__dirtyTangents=false;u.__dirtyColors=false}else if(D instanceof THREE.Line){if(!u.__webGLVertexBuffer){this.createLineBuffers(u);this.initLineBuffers(u);u.__dirtyVertices=true;u.__dirtyColors=true}if(u.__dirtyVertices||u.__dirtyColors)this.setLineBuffers(u,b.DYNAMIC_DRAW);n(J,0,u,D);u.__dirtyVertices=false;
+u.__dirtyColors=false}else if(D instanceof THREE.ParticleSystem){if(!u.__webGLVertexBuffer){this.createParticleBuffers(u);this.initParticleBuffers(u);u.__dirtyVertices=true;u.__dirtyColors=true}if(u.__dirtyVertices||u.__dirtyColors||D.sortParticles)this.setParticleBuffers(u,b.DYNAMIC_DRAW,D,B);n(J,0,u,D);u.__dirtyVertices=false;u.__dirtyColors=false}else D instanceof THREE.MarchingCubes&&m(J,0,D)}};this.removeObject=function(k,B){var n,m;for(n=k.__webGLObjects.length-1;n>=0;n--){m=k.__webGLObjects[n].object;
+B==m&&k.__webGLObjects.splice(n,1)}};this.setupMatrices=function(k,B){k._modelViewMatrix.multiplyToArray(B.matrix,k.matrix,k._modelViewMatrixArray);k._normalMatrix=THREE.Matrix4.makeInvert3x3(k._modelViewMatrix).transposeIntoArray(k._normalMatrixArray)};this.setDepthTest=function(k){k?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(k,B){if(k){!B||B=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="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}};
 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",
 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\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\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",
@@ -229,17 +229,17 @@ THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=ne
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var c=document.body,d="oldie";if(a){if(a.parent!==undefined)c=a.parent;if(a.id!==undefined)d=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
 THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var c=document.body,d="oldie";if(a){if(a.parent!==undefined)c=a.parent;if(a.id!==undefined)d=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a><br/>\n<br/>\nPlease try in\n<a href="http://www.google.com/chrome">Chrome 9+</a> /\n<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /\n<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>';e.id=
 d;d=e.style;d.fontFamily="monospace";d.fontSize="13px";d.textAlign="center";d.background="#eee";d.color="#000";d.padding="1em";d.width="475px";d.margin="5em auto 0";a.appendChild(e);c.appendChild(a);return e}};
 d;d=e.style;d.fontFamily="monospace";d.fontSize="13px";d.textAlign="center";d.background="#eee";d.color="#000";d.padding="1em";d.width="475px";d.margin="5em auto 0";a.appendChild(e);c.appendChild(a);return e}};
-var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,g=d?c.geometry:c,f=a.vertices,h=g.vertices,b=a.faces,j=g.faces,l=a.uvs;g=g.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var p=0,A=h.length;p<A;p++){var q=new THREE.Vertex(h[p].position.clone());d&&c.matrix.multiplyVector3(q.position);f.push(q)}p=0;for(A=j.length;p<A;p++){h=j[p];var m,B=h.vertexNormals;if(h instanceof THREE.Face3)m=new THREE.Face3(h.a+e,h.b+e,h.c+e);else if(h instanceof THREE.Face4)m=new THREE.Face4(h.a+
-e,h.b+e,h.c+e,h.d+e);m.centroid.copy(h.centroid);m.normal.copy(h.normal);d=0;for(f=B.length;d<f;d++){q=B[d];m.vertexNormals.push(q.clone())}m.materials=h.materials.slice();b.push(m)}p=0;for(A=g.length;p<A;p++){e=g[p];b=[];d=0;for(f=e.length;d<f;d++)b.push(new THREE.UV(e[d].u,e[d].v));l.push(b)}}},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,g=[];d=g.loadCount=0;for(e=
-a.length;d<e;++d){g[d]=new Image;g[d].loaded=0;g[d].onload=function(){g.loadCount+=1;this.loaded=true;c&&c(this)};g[d].src=a[d]}return g}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(p in n.objects)if(!z.objects[p]){E=n.objects[p];if(t=z.geometries[E.geometry]){u=[];for(i=0;i<E.materials.length;i++)u[i]=z.materials[E.materials[i]];H=E.position;r=E.rotation;s=E.scale;object=new THREE.Mesh(t,u);object.position.set(H[0],H[1],H[2]);
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;z.scene.addObject(object);z.objects[p]=object}}}function h(F){return function(J){z.geometries[F]=J;f();v-=1;b()}}function b(){e({total_models:y,total_textures:C,loaded_models:y-v,loaded_textures:C-D},z);v==0&&D==0&&d(z)}var j,l,p,A,q,m,B,E,H,x,I,t,k,w,u,n,o,v,D,y,C,z;n=g.data;o=new THREE.Loader;D=v=0;z={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
-g=function(){D-=1;b()};for(q in n.cameras){x=n.cameras[q];if(x.type=="perspective")k=new THREE.Camera(x.fov,x.aspect,x.near,x.far);else if(x.type=="ortho"){k=new THREE.Camera;k.projectionMatrix=THREE.Matrix4.makeOrtho(x.left,x.right,x.top,x.bottom,x.near,x.far)}H=x.position;x=x.target;k.position.set(H[0],H[1],H[2]);k.target.position.set(x[0],x[1],x[2]);z.cameras[q]=k}for(A in n.lights){q=n.lights[A];if(q.type=="directional"){H=q.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
-H[2]);light.position.normalize()}else if(q.type=="point"){H=q.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}x=q.color;i=q.intensity||1;light.color.setRGB(x[0]*i,x[1]*i,x[2]*i);z.scene.addLight(light);z.lights[A]=light}for(m in n.fogs){A=n.fogs[m];if(A.type=="linear")w=new THREE.Fog(0,A.near,A.far);else if(A.type=="exp2")w=new THREE.FogExp2(0,A.density);x=A.color;w.color.setRGB(x[0],x[1],x[2]);z.fogs[m]=w}if(z.cameras&&n.defaults.camera)z.currentCamera=z.cameras[n.defaults.camera];
-if(z.fogs&&n.defaults.fog)z.scene.fog=z.fogs[n.defaults.fog];x=n.defaults.bgcolor;z.bgColor=new THREE.Color;z.bgColor.setRGB(x[0],x[1],x[2]);z.bgColorAlpha=n.defaults.bgalpha;for(j in n.geometries){m=n.geometries[j];if(m.type=="bin_mesh"||m.type=="ascii_mesh")v+=1}y=v;for(j in n.geometries){m=n.geometries[j];if(m.type=="cube"){t=new Cube(m.width,m.height,m.depth,m.segments_width,m.segments_height,null,m.flipped,m.sides);z.geometries[j]=t}else if(m.type=="plane"){t=new Plane(m.width,m.height,m.segments_width,
-m.segments_height);z.geometries[j]=t}else if(m.type=="sphere"){t=new Sphere(m.radius,m.segments_width,m.segments_height);z.geometries[j]=t}else if(m.type=="cylinder"){t=new Cylinder(m.numSegs,m.topRad,m.botRad,m.height,m.topOffset,m.botOffset);z.geometries[j]=t}else if(m.type=="torus"){t=new Torus(m.radius,m.tube,m.segmentsR,m.segmentsT);z.geometries[j]=t}else if(m.type=="icosahedron"){t=new Icosahedron(m.subdivisions);z.geometries[j]=t}else if(m.type=="bin_mesh")o.loadBinary({model:m.url,callback:h(j)});
-else m.type=="ascii_mesh"&&o.loadAscii({model:m.url,callback:h(j)})}for(B in n.textures){j=n.textures[B];D+=j.url instanceof Array?j.url.length:1}C=D;for(B in n.textures){j=n.textures[B];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){m=ImageUtils.loadArray(j.url,g);m=new THREE.Texture(m,j.mapping)}else{m=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)m.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
-undefined)m.mag_filter=THREE[j.mag_filter]}z.textures[B]=m}for(l in n.materials){B=n.materials[l];for(I in B.parameters)if(I=="env_map"||I=="map"||I=="light_map")B.parameters[I]=z.textures[B.parameters[I]];else if(I=="shading")B.parameters[I]=B.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")B.parameters[I]=THREE[B.parameters[I]]?THREE[B.parameters[I]]:THREE.NormalBlending;else if(I=="combine")B.parameters[I]=B.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
-B=new THREE[B.type](B.parameters);z.materials[l]=B}f();c(z)}},addMesh:function(a,c,d,e,g,f,h,b,j,l){c=new THREE.Mesh(c,l);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=g;c.position.z=f;c.rotation.x=h;c.rotation.y=b;c.rotation.z=j;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,
+var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,g=d?c.geometry:c,f=a.vertices,h=g.vertices,b=a.faces,j=g.faces,l=a.uvs;g=g.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var t=0,A=h.length;t<A;t++){var w=new THREE.Vertex(h[t].position.clone());d&&c.matrix.multiplyVector3(w.position);f.push(w)}t=0;for(A=j.length;t<A;t++){h=j[t];var o,p=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(f=p.length;d<f;d++){w=p[d];o.vertexNormals.push(w.clone())}o.materials=h.materials.slice();b.push(o)}t=0;for(A=g.length;t<A;t++){e=g[t];b=[];d=0;for(f=e.length;d<f;d++)b.push(new THREE.UV(e[d].u,e[d].v));l.push(b)}}},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,g=[];d=g.loadCount=0;for(e=
+a.length;d<e;++d){g[d]=new Image;g[d].loaded=0;g[d].onload=function(){g.loadCount+=1;this.loaded=true;c&&c(this)};g[d].src=a[d]}return g}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(t in n.objects)if(!u.objects[t]){C=n.objects[t];if(v=u.geometries[C.geometry]){B=[];for(i=0;i<C.materials.length;i++)B[i]=u.materials[C.materials[i]];H=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(v,B);object.position.set(H[0],H[1],H[2]);
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;u.scene.addObject(object);u.objects[t]=object}}}function h(F){return function(J){u.geometries[F]=J;f();z-=1;b()}}function b(){e({total_models:D,total_textures:x,loaded_models:D-z,loaded_textures:x-q},u);z==0&&q==0&&d(u)}var j,l,t,A,w,o,p,C,H,y,I,v,L,k,B,n,m,z,q,D,x,u;n=g.data;m=new THREE.Loader;q=z=0;u={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
+g=function(){q-=1;b()};for(w in n.cameras){y=n.cameras[w];if(y.type=="perspective")L=new THREE.Camera(y.fov,y.aspect,y.near,y.far);else if(y.type=="ortho"){L=new THREE.Camera;L.projectionMatrix=THREE.Matrix4.makeOrtho(y.left,y.right,y.top,y.bottom,y.near,y.far)}H=y.position;y=y.target;L.position.set(H[0],H[1],H[2]);L.target.position.set(y[0],y[1],y[2]);u.cameras[w]=L}for(A in n.lights){w=n.lights[A];if(w.type=="directional"){H=w.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],
+H[2]);light.position.normalize()}else if(w.type=="point"){H=w.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}y=w.color;i=w.intensity||1;light.color.setRGB(y[0]*i,y[1]*i,y[2]*i);u.scene.addLight(light);u.lights[A]=light}for(o in n.fogs){A=n.fogs[o];if(A.type=="linear")k=new THREE.Fog(0,A.near,A.far);else if(A.type=="exp2")k=new THREE.FogExp2(0,A.density);y=A.color;k.color.setRGB(y[0],y[1],y[2]);u.fogs[o]=k}if(u.cameras&&n.defaults.camera)u.currentCamera=u.cameras[n.defaults.camera];
+if(u.fogs&&n.defaults.fog)u.scene.fog=u.fogs[n.defaults.fog];y=n.defaults.bgcolor;u.bgColor=new THREE.Color;u.bgColor.setRGB(y[0],y[1],y[2]);u.bgColorAlpha=n.defaults.bgalpha;for(j in n.geometries){o=n.geometries[j];if(o.type=="bin_mesh"||o.type=="ascii_mesh")z+=1}D=z;for(j in n.geometries){o=n.geometries[j];if(o.type=="cube"){v=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);u.geometries[j]=v}else if(o.type=="plane"){v=new Plane(o.width,o.height,o.segments_width,
+o.segments_height);u.geometries[j]=v}else if(o.type=="sphere"){v=new Sphere(o.radius,o.segments_width,o.segments_height);u.geometries[j]=v}else if(o.type=="cylinder"){v=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);u.geometries[j]=v}else if(o.type=="torus"){v=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);u.geometries[j]=v}else if(o.type=="icosahedron"){v=new Icosahedron(o.subdivisions);u.geometries[j]=v}else if(o.type=="bin_mesh")m.loadBinary({model:o.url,callback:h(j)});
+else o.type=="ascii_mesh"&&m.loadAscii({model:o.url,callback:h(j)})}for(p in n.textures){j=n.textures[p];q+=j.url instanceof Array?j.url.length:1}x=q;for(p in n.textures){j=n.textures[p];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){o=ImageUtils.loadArray(j.url,g);o=new THREE.Texture(o,j.mapping)}else{o=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)o.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
+undefined)o.mag_filter=THREE[j.mag_filter]}u.textures[p]=o}for(l in n.materials){p=n.materials[l];for(I in p.parameters)if(I=="env_map"||I=="map"||I=="light_map")p.parameters[I]=u.textures[p.parameters[I]];else if(I=="shading")p.parameters[I]=p.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")p.parameters[I]=THREE[p.parameters[I]]?THREE[p.parameters[I]]:THREE.NormalBlending;else if(I=="combine")p.parameters[I]=p.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
+p=new THREE[p.type](p.parameters);u.materials[l]=p}f();c(u)}},addMesh:function(a,c,d,e,g,f,h,b,j,l){c=new THREE.Mesh(c,l);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=g;c.position.z=f;c.rotation.x=h;c.rotation.y=b;c.rotation.z=j;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,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 g=Math.PI/2,f=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,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
 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 g=Math.PI/2,f=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,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
 SceneUtils.addMesh(a,c,1,0,-e,0,-g,0,f,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}",
 SceneUtils.addMesh(a,c,1,0,-e,0,-g,0,f,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}",
@@ -251,38 +251,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}"},
 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}"},
 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}",
 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,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;d=Array(f);for(c=e=0;c<f;++c){d[c]=Math.exp(-((c-g)*(c-g))/(2*a*a));e+=d[c]}for(c=0;c<f;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,g,f,h,b){function j(E,H,x,I,t,k,w,u){var n,o,v=e||1,D=g||1,y=v+1,C=D+1,z=t/2,F=k/2;t=t/v;var J=k/D,M=l.vertices.length;if(E=="x"&&H=="y"||E=="y"&&H=="x")n="z";else if(E=="x"&&H=="z"||E=="z"&&H=="x")n="y";else if(E==
-"z"&&H=="y"||E=="y"&&H=="z")n="x";for(o=0;o<C;o++)for(k=0;k<y;k++){var Q=new THREE.Vector3;Q[E]=(k*t-z)*x;Q[H]=(o*J-F)*I;Q[n]=w;l.vertices.push(new THREE.Vertex(Q))}for(o=0;o<D;o++)for(k=0;k<v;k++){l.faces.push(new THREE.Face4(k+y*o+M,k+y*(o+1)+M,k+1+y*(o+1)+M,k+1+y*o+M,null,u));l.uvs.push([new THREE.UV(k/v,o/D),new THREE.UV(k/v,(o+1)/D),new THREE.UV((k+1)/v,(o+1)/D),new THREE.UV((k+1)/v,o/D)])}}THREE.Geometry.call(this);var l=this,p=a/2,A=c/2,q=d/2;h=h?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=
-f;else{this.materials=[];for(var m=0;m<6;m++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(b!=undefined)for(var B in b)if(this.sides[B]!=undefined)this.sides[B]=b[B];this.sides.px&&j("z","y",1*h,-1,d,c,-p,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,d,c,p,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,d,A,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,d,-A,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,a,c,q,this.materials[4]);
-this.sides.nz&&j("x","y",-1*h,-1,a,c,-q,this.materials[5]);(function(){for(var E=[],H=[],x=0,I=l.vertices.length;x<I;x++){for(var t=l.vertices[x],k=false,w=0,u=E.length;w<u;w++){var n=E[w];if(t.position.x==n.position.x&&t.position.y==n.position.y&&t.position.z==n.position.z){H[x]=w;k=true;break}}if(!k){H[x]=E.length;E.push(new THREE.Vertex(t.position.clone()))}}x=0;for(I=l.faces.length;x<I;x++){t=l.faces[x];t.a=H[t.a];t.b=H[t.b];t.c=H[t.c];t.d=H[t.d]}l.vertices=E})();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,g,f=2*Math.ceil(a*3)+1;if(f>25)f=25;g=(f-1)*0.5;d=Array(f);for(c=e=0;c<f;++c){d[c]=Math.exp(-((c-g)*(c-g))/(2*a*a));e+=d[c]}for(c=0;c<f;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,g,f,h,b){function j(C,H,y,I,v,L,k,B){var n,m,z=e||1,q=g||1,D=z+1,x=q+1,u=v/2,F=L/2;v=v/z;var J=L/q,G=l.vertices.length;if(C=="x"&&H=="y"||C=="y"&&H=="x")n="z";else if(C=="x"&&H=="z"||C=="z"&&H=="x")n="y";else if(C==
+"z"&&H=="y"||C=="y"&&H=="z")n="x";for(m=0;m<x;m++)for(L=0;L<D;L++){var T=new THREE.Vector3;T[C]=(L*v-u)*y;T[H]=(m*J-F)*I;T[n]=k;l.vertices.push(new THREE.Vertex(T))}for(m=0;m<q;m++)for(L=0;L<z;L++){l.faces.push(new THREE.Face4(L+D*m+G,L+D*(m+1)+G,L+1+D*(m+1)+G,L+1+D*m+G,null,B));l.uvs.push([new THREE.UV(L/z,m/q),new THREE.UV(L/z,(m+1)/q),new THREE.UV((L+1)/z,(m+1)/q),new THREE.UV((L+1)/z,m/q)])}}THREE.Geometry.call(this);var l=this,t=a/2,A=c/2,w=d/2;h=h?-1:1;if(f!==undefined)if(f instanceof Array)this.materials=
+f;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([f])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(b!=undefined)for(var p in b)if(this.sides[p]!=undefined)this.sides[p]=b[p];this.sides.px&&j("z","y",1*h,-1,d,c,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,d,c,t,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,d,A,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,d,-A,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,a,c,w,this.materials[4]);
+this.sides.nz&&j("x","y",-1*h,-1,a,c,-w,this.materials[5]);(function(){for(var C=[],H=[],y=0,I=l.vertices.length;y<I;y++){for(var v=l.vertices[y],L=false,k=0,B=C.length;k<B;k++){var n=C[k];if(v.position.x==n.position.x&&v.position.y==n.position.y&&v.position.z==n.position.z){H[y]=k;L=true;break}}if(!L){H[y]=C.length;C.push(new THREE.Vertex(v.position.clone()))}}y=0;for(I=l.faces.length;y<I;y++){v=l.faces[y];v.a=H[v.a];v.b=H[v.b];v.c=H[v.c];v.d=H[v.d]}l.vertices=C})();this.computeCentroids();this.computeFaceNormals();
 this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,c,d,e,g){function f(l,p,A){h.vertices.push(new THREE.Vertex(new THREE.Vector3(l,p,A)))}THREE.Geometry.call(this);var h=this,b=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*b*j/a)*c,Math.cos(2*b*j/a)*c,0);for(j=0;j<a;j++)f(Math.sin(2*b*j/a)*d,Math.cos(2*b*j/a)*d,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(d!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(c!=0){f(0,0,e+g);for(j=a+a/2;j<
+var Cylinder=function(a,c,d,e,g){function f(l,t,A){h.vertices.push(new THREE.Vertex(new THREE.Vector3(l,t,A)))}THREE.Geometry.call(this);var h=this,b=Math.PI,j;for(j=0;j<a;j++)f(Math.sin(2*b*j/a)*c,Math.cos(2*b*j/a)*c,0);for(j=0;j<a;j++)f(Math.sin(2*b*j/a)*d,Math.cos(2*b*j/a)*d,e);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(d!=0){f(0,0,-g);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(c!=0){f(0,0,e+g);for(j=a+a/2;j<
 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-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 g,f=a/2,h=c/2;d=d||1;e=e||1;var b=d+1,j=e+1;a=a/d;var l=c/e;for(g=0;g<j;g++)for(c=0;c<b;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(g*l-h),0)));for(g=0;g<e;g++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+b*g,c+b*(g+1),c+1+b*(g+1),c+1+b*g));this.uvs.push([new THREE.UV(c/d,g/e),new THREE.UV(c/d,(g+1)/e),new THREE.UV((c+1)/d,(g+1)/e),new THREE.UV((c+1)/d,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 var Plane=function(a,c,d,e){THREE.Geometry.call(this);var g,f=a/2,h=c/2;d=d||1;e=e||1;var b=d+1,j=e+1;a=a/d;var l=c/e;for(g=0;g<j;g++)for(c=0;c<b;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(g*l-h),0)));for(g=0;g<e;g++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+b*g,c+b*(g+1),c+1+b*(g+1),c+1+b*g));this.uvs.push([new THREE.UV(c/d,g/e),new THREE.UV(c/d,(g+1)/e),new THREE.UV((c+1)/d,(g+1)/e),new THREE.UV((c+1)/d,g/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,c||8),h=Math.max(2,d||6);c=[];for(d=0;d<h+1;d++){e=d/h;var b=a*Math.cos(e*g),j=a*Math.sin(e*g),l=[],p=0;for(e=0;e<f;e++){var A=2*e/f,q=j*Math.sin(A*g);A=j*Math.cos(A*g);(d==0||d==h)&&e>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,b,q)))-1);l.push(p)}c.push(l)}var m,B,E;g=c.length;for(d=0;d<g;d++){f=c[d].length;if(d>0)for(e=0;e<f;e++){l=e==f-1;h=c[d][l?0:e+1];b=c[d][l?f-1:e];j=c[d-1][l?f-1:e];l=c[d-1][l?
-0:e+1];q=d/(g-1);m=(d-1)/(g-1);B=(e+1)/f;A=e/f;p=new THREE.UV(1-B,q);q=new THREE.UV(1-A,q);A=new THREE.UV(1-A,m);var H=new THREE.UV(1-B,m);if(d<c.length-1){m=this.vertices[h].position.clone();B=this.vertices[b].position.clone();E=this.vertices[j].position.clone();m.normalize();B.normalize();E.normalize();this.faces.push(new THREE.Face3(h,b,j,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([p,q,A])}if(d>1){m=this.vertices[h].position.clone();
-B=this.vertices[j].position.clone();E=this.vertices[l].position.clone();m.normalize();B.normalize();E.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([p,A,H])}}}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,g=Math.PI,f=Math.max(3,c||8),h=Math.max(2,d||6);c=[];for(d=0;d<h+1;d++){e=d/h;var b=a*Math.cos(e*g),j=a*Math.sin(e*g),l=[],t=0;for(e=0;e<f;e++){var A=2*e/f,w=j*Math.sin(A*g);A=j*Math.cos(A*g);(d==0||d==h)&&e>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,b,w)))-1);l.push(t)}c.push(l)}var o,p,C;g=c.length;for(d=0;d<g;d++){f=c[d].length;if(d>0)for(e=0;e<f;e++){l=e==f-1;h=c[d][l?0:e+1];b=c[d][l?f-1:e];j=c[d-1][l?f-1:e];l=c[d-1][l?
+0:e+1];w=d/(g-1);o=(d-1)/(g-1);p=(e+1)/f;A=e/f;t=new THREE.UV(1-p,w);w=new THREE.UV(1-A,w);A=new THREE.UV(1-A,o);var H=new THREE.UV(1-p,o);if(d<c.length-1){o=this.vertices[h].position.clone();p=this.vertices[b].position.clone();C=this.vertices[j].position.clone();o.normalize();p.normalize();C.normalize();this.faces.push(new THREE.Face3(h,b,j,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,w,A])}if(d>1){o=this.vertices[h].position.clone();
+p=this.vertices[j].position.clone();C=this.vertices[l].position.clone();o.normalize();p.normalize();C.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([t,A,H])}}}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 g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
 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 g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));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;g=(this.segmentsT+1)*c+d-1;var f=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][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;
 1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;g=(this.segmentsT+1)*c+d-1;var f=(this.segmentsT+1)*(c-1)+d-1,h=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][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(A,q,m){var B=Math.sqrt(A*A+q*q+m*m);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(A/B,q/B,m/B)))-1}function d(A,q,m,B){B.faces.push(new THREE.Face3(A,q,m))}function e(A,q){var m=g.vertices[A].position,B=g.vertices[q].position;return c((m.x+B.x)/2,(m.y+B.y)/2,(m.z+B.z)/2)}var g=this,f=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,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var b in f.faces){var j=e(f.faces[b].a,f.faces[b].b),l=e(f.faces[b].b,f.faces[b].c),p=e(f.faces[b].c,f.faces[b].a);d(f.faces[b].a,j,p,h);d(f.faces[b].b,l,j,h);d(f.faces[b].c,
-p,l,h);d(j,l,p,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+var Icosahedron=function(a){function c(A,w,o){var p=Math.sqrt(A*A+w*w+o*o);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(A/p,w/p,o/p)))-1}function d(A,w,o,p){p.faces.push(new THREE.Face3(A,w,o))}function e(A,w){var o=g.vertices[A].position,p=g.vertices[w].position;return c((o.x+p.x)/2,(o.y+p.y)/2,(o.z+p.z)/2)}var g=this,f=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,f);d(0,5,1,f);d(0,1,7,f);d(0,7,10,f);d(0,10,11,f);d(1,5,9,f);d(5,11,4,f);d(11,10,2,f);d(10,7,6,f);d(7,1,8,f);d(3,9,4,f);d(3,4,2,f);d(3,2,6,f);d(3,6,8,f);d(3,8,9,f);d(4,9,5,f);d(2,4,11,f);d(6,2,10,f);d(8,6,7,f);d(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var b in f.faces){var j=e(f.faces[b].a,f.faces[b].b),l=e(f.faces[b].b,f.faces[b].c),t=e(f.faces[b].c,f.faces[b].a);d(f.faces[b].a,j,t,h);d(f.faces[b].b,l,j,h);d(f.faces[b].c,
+t,l,h);d(j,l,t,h)}f.faces=h.faces}g.faces=f.faces;delete f;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=[],g=[],f=[],h=[],b=0;b<a.length;b++){this.vertices.push(new THREE.Vertex(a[b]));g[b]=this.vertices.length-1;e[b]=new THREE.Vector3(a[b].x,a[b].y,a[b].z)}for(var j=THREE.Matrix4.rotationZMatrix(c),l=0;l<=d+0.0010;l+=c){for(b=0;b<e.length;b++)if(l<d){e[b]=j.multiplyVector3(e[b].clone());this.vertices.push(new THREE.Vertex(e[b]));f[b]=this.vertices.length-1}else f=h;if(l==0)h=g;for(b=0;b<g.length-1;b++){this.faces.push(new THREE.Face4(f[b],
 function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],g=[],f=[],h=[],b=0;b<a.length;b++){this.vertices.push(new THREE.Vertex(a[b]));g[b]=this.vertices.length-1;e[b]=new THREE.Vector3(a[b].x,a[b].y,a[b].z)}for(var j=THREE.Matrix4.rotationZMatrix(c),l=0;l<=d+0.0010;l+=c){for(b=0;b<e.length;b++)if(l<d){e[b]=j.multiplyVector3(e[b].clone());this.vertices.push(new THREE.Vertex(e[b]));f[b]=this.vertices.length-1}else f=h;if(l==0)h=g;for(b=0;b<g.length-1;b++){this.faces.push(new THREE.Face4(f[b],
 f[b+1],g[b+1],g[b]));this.uvs.push([new THREE.UV(l/d,b/a.length),new THREE.UV(l/d,(b+1)/a.length),new THREE.UV((l-c)/d,(b+1)/a.length),new THREE.UV((l-c)/d,b/a.length)])}g=f;f=[]}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}
 f[b+1],g[b+1],g[b]));this.uvs.push([new THREE.UV(l/d,b/a.length),new THREE.UV(l/d,(b+1)/a.length),new THREE.UV((l-c)/d,(b+1)/a.length),new THREE.UV((l-c)/d,b/a.length)])}g=f;f=[]}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=
 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,g){return d+(e-d)*g};this.VIntX=function(d,e,g,f,h,b,j,l,p,A){h=(h-p)/(A-p);p=this.normal_cache;e[f]=b+h*this.delta;e[f+1]=j;e[f+2]=l;g[f]=this.lerp(p[d],p[d+3],h);g[f+1]=this.lerp(p[d+1],p[d+4],h);g[f+2]=this.lerp(p[d+2],p[d+5],h)};this.VIntY=function(d,e,g,f,h,b,j,l,p,A){h=(h-p)/(A-p);p=this.normal_cache;e[f]=b;e[f+1]=j+h*this.delta;e[f+
-2]=l;e=d+this.yd*3;g[f]=this.lerp(p[d],p[e],h);g[f+1]=this.lerp(p[d+1],p[e+1],h);g[f+2]=this.lerp(p[d+2],p[e+2],h)};this.VIntZ=function(d,e,g,f,h,b,j,l,p,A){h=(h-p)/(A-p);p=this.normal_cache;e[f]=b;e[f+1]=j;e[f+2]=l+h*this.delta;e=d+this.zd*3;g[f]=this.lerp(p[d],p[e],h);g[f+1]=this.lerp(p[d+1],p[e+1],h);g[f+2]=this.lerp(p[d+2],p[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,g,f,h,b){var j=f+1,l=f+this.yd,p=f+this.zd,A=j+this.yd,q=j+this.zd,m=f+this.yd+this.zd,B=j+this.yd+this.zd,E=0,H=this.field[f],x=this.field[j],I=this.field[l],t=this.field[A],k=this.field[p],w=this.field[q],u=this.field[m],n=this.field[B];if(H<h)E|=1;if(x<h)E|=2;if(I<h)E|=8;if(t<h)E|=4;if(k<h)E|=16;if(w<h)E|=32;if(u<h)E|=128;if(n<h)E|=64;var o=THREE.edgeTable[E];if(o==0)return 0;
-var v=this.delta,D=d+v,y=e+v;v=g+v;if(o&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,d,e,g,H,x)}if(o&2){this.compNorm(j);this.compNorm(A);this.VIntY(j*3,this.vlist,this.nlist,3,h,D,e,g,x,t)}if(o&4){this.compNorm(l);this.compNorm(A);this.VIntX(l*3,this.vlist,this.nlist,6,h,d,y,g,I,t)}if(o&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,h,d,e,g,H,I)}if(o&16){this.compNorm(p);this.compNorm(q);this.VIntX(p*3,this.vlist,this.nlist,12,h,d,e,v,
-k,w)}if(o&32){this.compNorm(q);this.compNorm(B);this.VIntY(q*3,this.vlist,this.nlist,15,h,D,e,v,w,n)}if(o&64){this.compNorm(m);this.compNorm(B);this.VIntX(m*3,this.vlist,this.nlist,18,h,d,y,v,u,n)}if(o&128){this.compNorm(p);this.compNorm(m);this.VIntY(p*3,this.vlist,this.nlist,21,h,d,e,v,k,u)}if(o&256){this.compNorm(f);this.compNorm(p);this.VIntZ(f*3,this.vlist,this.nlist,24,h,d,e,g,H,k)}if(o&512){this.compNorm(j);this.compNorm(q);this.VIntZ(j*3,this.vlist,this.nlist,27,h,D,e,g,x,w)}if(o&1024){this.compNorm(A);
-this.compNorm(B);this.VIntZ(A*3,this.vlist,this.nlist,30,h,D,y,g,t,n)}if(o&2048){this.compNorm(l);this.compNorm(m);this.VIntZ(l*3,this.vlist,this.nlist,33,h,d,y,g,I,u)}E<<=4;for(h=f=0;THREE.triTable[E+h]!=-1;){d=E+h;e=d+1;g=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[g],b);h+=3;f++}return f};this.posnormtriv=function(d,e,g,f,h,b){var j=this.count*3;this.positionArray[j]=d[g];this.positionArray[j+1]=d[g+1];this.positionArray[j+2]=d[g+2];this.positionArray[j+
+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,g){return d+(e-d)*g};this.VIntX=function(d,e,g,f,h,b,j,l,t,A){h=(h-t)/(A-t);t=this.normal_cache;e[f]=b+h*this.delta;e[f+1]=j;e[f+2]=l;g[f]=this.lerp(t[d],t[d+3],h);g[f+1]=this.lerp(t[d+1],t[d+4],h);g[f+2]=this.lerp(t[d+2],t[d+5],h)};this.VIntY=function(d,e,g,f,h,b,j,l,t,A){h=(h-t)/(A-t);t=this.normal_cache;e[f]=b;e[f+1]=j+h*this.delta;e[f+
+2]=l;e=d+this.yd*3;g[f]=this.lerp(t[d],t[e],h);g[f+1]=this.lerp(t[d+1],t[e+1],h);g[f+2]=this.lerp(t[d+2],t[e+2],h)};this.VIntZ=function(d,e,g,f,h,b,j,l,t,A){h=(h-t)/(A-t);t=this.normal_cache;e[f]=b;e[f+1]=j;e[f+2]=l+h*this.delta;e=d+this.zd*3;g[f]=this.lerp(t[d],t[e],h);g[f+1]=this.lerp(t[d+1],t[e+1],h);g[f+2]=this.lerp(t[d+2],t[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,g,f,h,b){var j=f+1,l=f+this.yd,t=f+this.zd,A=j+this.yd,w=j+this.zd,o=f+this.yd+this.zd,p=j+this.yd+this.zd,C=0,H=this.field[f],y=this.field[j],I=this.field[l],v=this.field[A],L=this.field[t],k=this.field[w],B=this.field[o],n=this.field[p];if(H<h)C|=1;if(y<h)C|=2;if(I<h)C|=8;if(v<h)C|=4;if(L<h)C|=16;if(k<h)C|=32;if(B<h)C|=128;if(n<h)C|=64;var m=THREE.edgeTable[C];if(m==0)return 0;
+var z=this.delta,q=d+z,D=e+z;z=g+z;if(m&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,h,d,e,g,H,y)}if(m&2){this.compNorm(j);this.compNorm(A);this.VIntY(j*3,this.vlist,this.nlist,3,h,q,e,g,y,v)}if(m&4){this.compNorm(l);this.compNorm(A);this.VIntX(l*3,this.vlist,this.nlist,6,h,d,D,g,I,v)}if(m&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,h,d,e,g,H,I)}if(m&16){this.compNorm(t);this.compNorm(w);this.VIntX(t*3,this.vlist,this.nlist,12,h,d,e,z,
+L,k)}if(m&32){this.compNorm(w);this.compNorm(p);this.VIntY(w*3,this.vlist,this.nlist,15,h,q,e,z,k,n)}if(m&64){this.compNorm(o);this.compNorm(p);this.VIntX(o*3,this.vlist,this.nlist,18,h,d,D,z,B,n)}if(m&128){this.compNorm(t);this.compNorm(o);this.VIntY(t*3,this.vlist,this.nlist,21,h,d,e,z,L,B)}if(m&256){this.compNorm(f);this.compNorm(t);this.VIntZ(f*3,this.vlist,this.nlist,24,h,d,e,g,H,L)}if(m&512){this.compNorm(j);this.compNorm(w);this.VIntZ(j*3,this.vlist,this.nlist,27,h,q,e,g,y,k)}if(m&1024){this.compNorm(A);
+this.compNorm(p);this.VIntZ(A*3,this.vlist,this.nlist,30,h,q,D,g,v,n)}if(m&2048){this.compNorm(l);this.compNorm(o);this.VIntZ(l*3,this.vlist,this.nlist,33,h,d,D,g,I,B)}C<<=4;for(h=f=0;THREE.triTable[C+h]!=-1;){d=C+h;e=d+1;g=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[g],b);h+=3;f++}return f};this.posnormtriv=function(d,e,g,f,h,b){var j=this.count*3;this.positionArray[j]=d[g];this.positionArray[j+1]=d[g+1];this.positionArray[j+2]=d[g+2];this.positionArray[j+
 3]=d[f];this.positionArray[j+4]=d[f+1];this.positionArray[j+5]=d[f+2];this.positionArray[j+6]=d[h];this.positionArray[j+7]=d[h+1];this.positionArray[j+8]=d[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&b(this)};this.begin=
 3]=d[f];this.positionArray[j+4]=d[f+1];this.positionArray[j+5]=d[f+2];this.positionArray[j+6]=d[h];this.positionArray[j+7]=d[h+1];this.positionArray[j+8]=d[h+2];this.normalArray[j]=e[g];this.normalArray[j+1]=e[g+1];this.normalArray[j+2]=e[g+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[h];this.normalArray[j+7]=e[h+1];this.normalArray[j+8]=e[h+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&b(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,g,f,h){var b=this.size*Math.sqrt(f/h),j=g*this.size,l=e*this.size,p=d*this.size,A=Math.floor(j-b);if(A<1)A=1;j=Math.floor(j+b);if(j>this.size-1)j=this.size-1;var q=Math.floor(l-b);if(q<1)q=1;l=Math.floor(l+b);if(l>this.size-1)l=this.size-1;var m=Math.floor(p-b);if(m<1)m=1;b=Math.floor(p+b);
-if(b>this.size-1)b=this.size-1;var B,E,H,x,I,t;for(A=A;A<j;A++){p=this.size2*A;E=A/this.size-g;I=E*E;for(E=q;E<l;E++){H=p+this.size*E;B=E/this.size-e;t=B*B;for(B=m;B<b;B++){x=B/this.size-d;x=f/(1.0E-6+x*x+t+I)-h;if(x>0)this.field[H+B]+=x}}}};this.addPlaneX=function(d,e){var g,f,h,b,j,l=this.size,p=this.yd,A=this.zd,q=this.field,m=l*Math.sqrt(d/e);if(m>l)m=l;for(g=0;g<m;g++){f=g/l;f=f*f;b=d/(1.0E-4+f)-e;if(b>0)for(f=0;f<l;f++){j=g+f*p;for(h=0;h<l;h++)q[A*h+j]+=b}}};this.addPlaneY=function(d,e){var g,
-f,h,b,j,l,p=this.size,A=this.yd,q=this.zd,m=this.field,B=p*Math.sqrt(d/e);if(B>p)B=p;for(f=0;f<B;f++){g=f/p;g=g*g;b=d/(1.0E-4+g)-e;if(b>0){j=f*A;for(g=0;g<p;g++){l=j+g;for(h=0;h<p;h++)m[q*h+l]+=b}}}};this.addPlaneZ=function(d,e){var g,f,h,b,j,l;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++){g=h/size;g=g*g;b=d/(1.0E-4+g)-e;if(b>0){j=zd*h;for(f=0;f<size;f++){l=j+f*yd;for(g=0;g<size;g++)field[l+g]+=b}}}};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,g,f,h,b,j,l,p,A,q=this.size-2;for(h=1;h<q;h++){A=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(f=1;f<q;f++){p=A+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<q;g++){b=(g-this.halfsize)/this.halfsize;e=p+g;this.polygonize(b,j,l,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(g){var f,h,b,j,l,p,A,q;for(f=
-0;f<g.count;f++){l=f*3;A=l+1;q=l+2;h=g.positionArray[l];b=g.positionArray[A];j=g.positionArray[q];p=new THREE.Vector3(h,b,j);h=g.normalArray[l];b=g.normalArray[A];j=g.normalArray[q];l=new THREE.Vector3(h,b,j);l.normalize();l=new THREE.Vertex(p,l);e.vertices.push(l)}nfaces=g.count/3;for(f=0;f<nfaces;f++){l=(d+f)*3;A=l+1;q=l+2;p=e.vertices[l].normal;h=e.vertices[A].normal;b=e.vertices[q].normal;l=new THREE.Face3(l,A,q,[p,h,b]);e.faces.push(l)}d+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
+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,g,f,h){var b=this.size*Math.sqrt(f/h),j=g*this.size,l=e*this.size,t=d*this.size,A=Math.floor(j-b);if(A<1)A=1;j=Math.floor(j+b);if(j>this.size-1)j=this.size-1;var w=Math.floor(l-b);if(w<1)w=1;l=Math.floor(l+b);if(l>this.size-1)l=this.size-1;var o=Math.floor(t-b);if(o<1)o=1;b=Math.floor(t+b);
+if(b>this.size-1)b=this.size-1;var p,C,H,y,I,v;for(A=A;A<j;A++){t=this.size2*A;C=A/this.size-g;I=C*C;for(C=w;C<l;C++){H=t+this.size*C;p=C/this.size-e;v=p*p;for(p=o;p<b;p++){y=p/this.size-d;y=f/(1.0E-6+y*y+v+I)-h;if(y>0)this.field[H+p]+=y}}}};this.addPlaneX=function(d,e){var g,f,h,b,j,l=this.size,t=this.yd,A=this.zd,w=this.field,o=l*Math.sqrt(d/e);if(o>l)o=l;for(g=0;g<o;g++){f=g/l;f=f*f;b=d/(1.0E-4+f)-e;if(b>0)for(f=0;f<l;f++){j=g+f*t;for(h=0;h<l;h++)w[A*h+j]+=b}}};this.addPlaneY=function(d,e){var g,
+f,h,b,j,l,t=this.size,A=this.yd,w=this.zd,o=this.field,p=t*Math.sqrt(d/e);if(p>t)p=t;for(f=0;f<p;f++){g=f/t;g=g*g;b=d/(1.0E-4+g)-e;if(b>0){j=f*A;for(g=0;g<t;g++){l=j+g;for(h=0;h<t;h++)o[w*h+l]+=b}}}};this.addPlaneZ=function(d,e){var g,f,h,b,j,l;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++){g=h/size;g=g*g;b=d/(1.0E-4+g)-e;if(b>0){j=zd*h;for(f=0;f<size;f++){l=j+f*yd;for(g=0;g<size;g++)field[l+g]+=b}}}};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,g,f,h,b,j,l,t,A,w=this.size-2;for(h=1;h<w;h++){A=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(f=1;f<w;f++){t=A+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<w;g++){b=(g-this.halfsize)/this.halfsize;e=t+g;this.polygonize(b,j,l,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(g){var f,h,b,j,l,t,A,w;for(f=
+0;f<g.count;f++){l=f*3;A=l+1;w=l+2;h=g.positionArray[l];b=g.positionArray[A];j=g.positionArray[w];t=new THREE.Vector3(h,b,j);h=g.normalArray[l];b=g.normalArray[A];j=g.normalArray[w];l=new THREE.Vector3(h,b,j);l.normalize();l=new THREE.Vertex(t,l);e.vertices.push(l)}nfaces=g.count/3;for(f=0;f<nfaces;f++){l=(d+f)*3;A=l+1;w=l+2;t=e.vertices[l].normal;h=e.vertices[A].normal;b=e.vertices[w].normal;l=new THREE.Face3(l,A,w,[t,h,b]);e.faces.push(l)}d+=nfaces;g.count=0});e.sortFacesByMaterial();return e};
 this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 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,
 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,
 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,
@@ -312,22 +312,23 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
 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(g){THREE.Loader.prototype.createModel(g.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
 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(g){THREE.Loader.prototype.createModel(g.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),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,g,e,f)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,g,f){var h=new XMLHttpRequest,b=e+"/"+a,j=0;
 THREE.Loader.prototype.extractUrlbase(c),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,d,g,e,f)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,g,f){var h=new XMLHttpRequest,b=e+"/"+a,j=0;
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,g,c):alert("Couldn't load ["+b+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",b,true);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,d,g,c):alert("Couldn't load ["+b+"] ["+h.status+"]");else if(h.readyState==3){if(f){if(j==0)j=h.getResponseHeader("Content-Length");f({total:j,loaded:h.responseText.length})}}else if(h.readyState==2)j=h.getResponseHeader("Content-Length")};h.open("GET",b,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 g=function(f){function h(G,N){var L=p(G,N),X=p(G,N+1),$=p(G,N+2),ma=p(G,N+3),ia=(ma<<1&255|$>>7)-127;L=($&127)<<16|X<<8|L;if(L==0&&ia==-127)return 0;return(1-2*(ma>>7))*(1+L*Math.pow(2,-23))*Math.pow(2,ia)}function b(G,N){var L=p(G,N),X=p(G,N+1),$=p(G,N+2);return(p(G,N+3)<<24)+($<<16)+(X<<8)+L}function j(G,N){var L=p(G,N);return(p(G,N+1)<<8)+L}function l(G,N){var L=p(G,N);return L>127?L-256:L}function p(G,N){return G.charCodeAt(N)&255}function A(G){var N,L,X;N=
-b(a,G);L=b(a,G+u);X=b(a,G+n);G=j(a,G+o);THREE.Loader.prototype.f3(x,N,L,X,G)}function q(G){var N,L,X,$,ma,ia;N=b(a,G);L=b(a,G+u);X=b(a,G+n);$=j(a,G+o);ma=b(a,G+v);ia=b(a,G+D);G=b(a,G+y);THREE.Loader.prototype.f3n(x,k,N,L,X,$,ma,ia,G)}function m(G){var N,L,X,$;N=b(a,G);L=b(a,G+C);X=b(a,G+z);$=b(a,G+F);G=j(a,G+J);THREE.Loader.prototype.f4(x,N,L,X,$,G)}function B(G){var N,L,X,$,ma,ia,qa,ta;N=b(a,G);L=b(a,G+C);X=b(a,G+z);$=b(a,G+F);ma=j(a,G+J);ia=b(a,G+M);qa=b(a,G+Q);ta=b(a,G+S);G=b(a,G+U);THREE.Loader.prototype.f4n(x,
-k,N,L,X,$,ma,ia,qa,ta,G)}function E(G){var N,L;N=b(a,G);L=b(a,G+ca);G=b(a,G+da);THREE.Loader.prototype.uv3(x.uvs,w[N*2],w[N*2+1],w[L*2],w[L*2+1],w[G*2],w[G*2+1])}function H(G){var N,L,X;N=b(a,G);L=b(a,G+T);X=b(a,G+O);G=b(a,G+Z);THREE.Loader.prototype.uv4(x.uvs,w[N*2],w[N*2+1],w[L*2],w[L*2+1],w[X*2],w[X*2+1],w[G*2],w[G*2+1])}var x=this,I=0,t,k=[],w=[],u,n,o,v,D,y,C,z,F,J,M,Q,S,U,ca,da,T,O,Z,V,K,W,ba,ha,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,f);t={signature:a.substr(I,
-8),header_bytes:p(a,I+8),vertex_coordinate_bytes:p(a,I+9),normal_coordinate_bytes:p(a,I+10),uv_coordinate_bytes:p(a,I+11),vertex_index_bytes:p(a,I+12),normal_index_bytes:p(a,I+13),uv_index_bytes:p(a,I+14),material_index_bytes:p(a,I+15),nvertices:b(a,I+16),nnormals:b(a,I+16+4),nuvs:b(a,I+16+8),ntri_flat:b(a,I+16+12),ntri_smooth:b(a,I+16+16),ntri_flat_uv:b(a,I+16+20),ntri_smooth_uv:b(a,I+16+24),nquad_flat:b(a,I+16+28),nquad_smooth:b(a,I+16+32),nquad_flat_uv:b(a,I+16+36),nquad_smooth_uv:b(a,I+16+40)};
-I+=t.header_bytes;u=t.vertex_index_bytes;n=t.vertex_index_bytes*2;o=t.vertex_index_bytes*3;v=t.vertex_index_bytes*3+t.material_index_bytes;D=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;y=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;z=t.vertex_index_bytes*2;F=t.vertex_index_bytes*3;J=t.vertex_index_bytes*4;M=t.vertex_index_bytes*4+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;S=t.vertex_index_bytes*
-4+t.material_index_bytes+t.normal_index_bytes*2;U=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;ca=t.uv_index_bytes;da=t.uv_index_bytes*2;T=t.uv_index_bytes;O=t.uv_index_bytes*2;Z=t.uv_index_bytes*3;f=t.vertex_index_bytes*3+t.material_index_bytes;ea=t.vertex_index_bytes*4+t.material_index_bytes;V=t.ntri_flat*f;K=t.ntri_smooth*(f+t.normal_index_bytes*3);W=t.ntri_flat_uv*(f+t.uv_index_bytes*3);ba=t.ntri_smooth_uv*(f+t.normal_index_bytes*3+t.uv_index_bytes*3);ha=t.nquad_flat*ea;
-f=t.nquad_smooth*(ea+t.normal_index_bytes*4);ea=t.nquad_flat_uv*(ea+t.uv_index_bytes*4);I+=function(G){var N,L,X,$=t.vertex_coordinate_bytes*3,ma=G+t.nvertices*$;for(G=G;G<ma;G+=$){N=h(a,G);L=h(a,G+t.vertex_coordinate_bytes);X=h(a,G+t.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(x,N,L,X)}return t.nvertices*$}(I);I+=function(G){var N,L,X,$=t.normal_coordinate_bytes*3,ma=G+t.nnormals*$;for(G=G;G<ma;G+=$){N=l(a,G);L=l(a,G+t.normal_coordinate_bytes);X=l(a,G+t.normal_coordinate_bytes*2);k.push(N/
-127,L/127,X/127)}return t.nnormals*$}(I);I+=function(G){var N,L,X=t.uv_coordinate_bytes*2,$=G+t.nuvs*X;for(G=G;G<$;G+=X){N=h(a,G);L=h(a,G+t.uv_coordinate_bytes);w.push(N,L)}return t.nuvs*X}(I);I=I;V=I+V;K=V+K;W=K+W;ba=W+ba;ha=ba+ha;f=ha+f;ea=f+ea;(function(G){var N,L=t.vertex_index_bytes*3+t.material_index_bytes,X=L+t.uv_index_bytes*3,$=G+t.ntri_flat_uv*X;for(N=G;N<$;N+=X){A(N);E(N+L)}return $-G})(K);(function(G){var N,L=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,X=L+t.uv_index_bytes*
-3,$=G+t.ntri_smooth_uv*X;for(N=G;N<$;N+=X){q(N);E(N+L)}return $-G})(W);(function(G){var N,L=t.vertex_index_bytes*4+t.material_index_bytes,X=L+t.uv_index_bytes*4,$=G+t.nquad_flat_uv*X;for(N=G;N<$;N+=X){m(N);H(N+L)}return $-G})(f);(function(G){var N,L=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,X=L+t.uv_index_bytes*4,$=G+t.nquad_smooth_uv*X;for(N=G;N<$;N+=X){B(N);H(N+L)}return $-G})(ea);(function(G){var N,L=t.vertex_index_bytes*3+t.material_index_bytes,X=G+t.ntri_flat*L;for(N=
-G;N<X;N+=L)A(N);return X-G})(I);(function(G){var N,L=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,X=G+t.ntri_smooth*L;for(N=G;N<X;N+=L)q(N);return X-G})(V);(function(G){var N,L=t.vertex_index_bytes*4+t.material_index_bytes,X=G+t.nquad_flat*L;for(N=G;N<X;N+=L)m(N);return X-G})(ba);(function(G){var N,L=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,X=G+t.nquad_smooth*L;for(N=G;N<X;N+=L)B(N);return X-G})(ha);this.computeCentroids();this.computeFaceNormals();
-this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(d))},createModel:function(a,c,d){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,b,j,l,p;h=0;for(b=a.vertices.length;h<b;h+=3){j=a.vertices[h];l=a.vertices[h+1];p=a.vertices[h+2];THREE.Loader.prototype.v(f,j,l,p)}})();(function(){function h(B,E){THREE.Loader.prototype.f3(f,B[E],B[E+1],B[E+2],B[E+3])}function b(B,E){THREE.Loader.prototype.f3n(f,
-a.normals,B[E],B[E+1],B[E+2],B[E+3],B[E+4],B[E+5],B[E+6])}function j(B,E){THREE.Loader.prototype.f4(f,B[E],B[E+1],B[E+2],B[E+3],B[E+4])}function l(B,E){THREE.Loader.prototype.f4n(f,a.normals,B[E],B[E+1],B[E+2],B[E+3],B[E+4],B[E+5],B[E+6],B[E+7],B[E+8])}function p(B,E){var H,x,I,t,k,w,u,n,o;H=B[E];x=B[E+1];I=B[E+2];t=a.uvs[H*2];u=a.uvs[H*2+1];k=a.uvs[x*2];n=a.uvs[x*2+1];w=a.uvs[I*2];o=a.uvs[I*2+1];THREE.Loader.prototype.uv3(f.uvs,t,u,k,n,w,o);if(a.uvs2){t=a.uvs2[H*2];u=a.uvs2[H*2+1];k=a.uvs2[x*2];
-n=a.uvs2[x*2+1];w=a.uvs2[I*2];o=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(f.uvs2,t,1-u,k,1-n,w,1-o)}}function A(B,E){var H,x,I,t,k,w,u,n,o,v,D,y;H=B[E];x=B[E+1];I=B[E+2];t=B[E+3];k=a.uvs[H*2];o=a.uvs[H*2+1];w=a.uvs[x*2];v=a.uvs[x*2+1];u=a.uvs[I*2];D=a.uvs[I*2+1];n=a.uvs[t*2];y=a.uvs[t*2+1];THREE.Loader.prototype.uv4(f.uvs,k,o,w,v,u,D,n,y);if(a.uvs2){k=a.uvs2[H*2];o=a.uvs2[H*2+1];w=a.uvs2[x*2];v=a.uvs2[x*2+1];u=a.uvs2[I*2];D=a.uvs2[I*2+1];n=a.uvs2[t*2];y=a.uvs2[t*2+1];THREE.Loader.prototype.uv4(f.uvs2,
-k,1-o,w,1-v,u,1-D,n,1-y)}}var q,m;q=0;for(m=a.triangles_uv.length;q<m;q+=7){h(a.triangles_uv,q);p(a.triangles_uv,q+4)}q=0;for(m=a.triangles_n_uv.length;q<m;q+=10){b(a.triangles_n_uv,q);p(a.triangles_n_uv,q+7)}q=0;for(m=a.quads_uv.length;q<m;q+=9){j(a.quads_uv,q);A(a.quads_uv,q+5)}q=0;for(m=a.quads_n_uv.length;q<m;q+=13){l(a.quads_n_uv,q);A(a.quads_n_uv,q+9)}q=0;for(m=a.triangles.length;q<m;q+=4)h(a.triangles,q);q=0;for(m=a.triangles_n.length;q<m;q+=7)b(a.triangles_n,q);q=0;for(m=a.quads.length;q<
-m;q+=5)j(a.quads,q);q=0;for(m=a.quads_n.length;q<m;q+=9)l(a.quads_n,q)})();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,g){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[g]))},f4:function(a,c,d,e,g,f){a.faces.push(new THREE.Face4(c,d,e,g,null,a.materials[f]))},f3n:function(a,c,d,e,g,f,h,b,j){f=
-a.materials[f];var l=c[b*3],p=c[b*3+1];b=c[b*3+2];var A=c[j*3],q=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(l,p,b),new THREE.Vector3(A,q,j)],f))},f4n:function(a,c,d,e,g,f,h,b,j,l,p){h=a.materials[h];var A=c[j*3],q=c[j*3+1];j=c[j*3+2];var m=c[l*3],B=c[l*3+1];l=c[l*3+2];var E=c[p*3],H=c[p*3+1];p=c[p*3+2];a.faces.push(new THREE.Face4(d,e,g,f,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(A,q,j),new THREE.Vector3(m,
-B,l),new THREE.Vector3(E,H,p)],h))},uv3:function(a,c,d,e,g,f,h){var b=[];b.push(new THREE.UV(c,d));b.push(new THREE.UV(e,g));b.push(new THREE.UV(f,h));a.push(b)},uv4:function(a,c,d,e,g,f,h,b,j){var l=[];l.push(new THREE.UV(c,d));l.push(new THREE.UV(e,g));l.push(new THREE.UV(f,h));l.push(new THREE.UV(b,j));a.push(l)},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,b){var j=new Image;j.onload=function(){if(!d(this.width)||!d(this.height)){var l=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),p=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));h.image.width=l;h.image.height=p;h.image.getContext("2d").drawImage(this,0,0,l,p)}else h.image=this;h.image.loaded=1};j.src=b}var g,f;if(a.map_diffuse&&c){f=document.createElement("canvas");g=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});e(g.map,c+"/"+
-a.map_diffuse)}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;g=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else g=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){f=document.createElement("canvas");g.light_map=new THREE.Texture(f);e(g.light_map,c+"/"+a.map_lightmap)}return g},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+createBinModel:function(a,c,d,e){var g=function(f){function h(E,K){var N=t(E,K),V=t(E,K+1),da=t(E,K+2),ga=t(E,K+3),ia=(ga<<1&255|da>>7)-127;N=(da&127)<<16|V<<8|N;if(N==0&&ia==-127)return 0;return(1-2*(ga>>7))*(1+N*Math.pow(2,-23))*Math.pow(2,ia)}function b(E,K){var N=t(E,K),V=t(E,K+1),da=t(E,K+2);return(t(E,K+3)<<24)+(da<<16)+(V<<8)+N}function j(E,K){var N=t(E,K);return(t(E,K+1)<<8)+N}function l(E,K){var N=t(E,K);return N>127?N-256:N}function t(E,K){return E.charCodeAt(K)&255}function A(E){var K,
+N,V;K=b(a,E);N=b(a,E+B);V=b(a,E+n);E=j(a,E+m);THREE.Loader.prototype.f3(y,K,N,V,E)}function w(E){var K,N,V,da,ga,ia;K=b(a,E);N=b(a,E+B);V=b(a,E+n);da=j(a,E+m);ga=b(a,E+z);ia=b(a,E+q);E=b(a,E+D);THREE.Loader.prototype.f3n(y,L,K,N,V,da,ga,ia,E)}function o(E){var K,N,V,da;K=b(a,E);N=b(a,E+x);V=b(a,E+u);da=b(a,E+F);E=j(a,E+J);THREE.Loader.prototype.f4(y,K,N,V,da,E)}function p(E){var K,N,V,da,ga,ia,ta,ra;K=b(a,E);N=b(a,E+x);V=b(a,E+u);da=b(a,E+F);ga=j(a,E+J);ia=b(a,E+G);ta=b(a,E+T);ra=b(a,E+U);E=b(a,E+
+O);THREE.Loader.prototype.f4n(y,L,K,N,V,da,ga,ia,ta,ra,E)}function C(E){var K,N;K=b(a,E);N=b(a,E+ba);E=b(a,E+ca);THREE.Loader.prototype.uv3(y.uvs,k[K*2],k[K*2+1],k[N*2],k[N*2+1],k[E*2],k[E*2+1])}function H(E){var K,N,V;K=b(a,E);N=b(a,E+W);V=b(a,E+R);E=b(a,E+X);THREE.Loader.prototype.uv4(y.uvs,k[K*2],k[K*2+1],k[N*2],k[N*2+1],k[V*2],k[V*2+1],k[E*2],k[E*2+1])}var y=this,I=0,v,L=[],k=[],B,n,m,z,q,D,x,u,F,J,G,T,U,O,ba,ca,W,R,X,Y,M,S,aa,ja,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,
+e,f);v={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:b(a,I+16),nnormals:b(a,I+16+4),nuvs:b(a,I+16+8),ntri_flat:b(a,I+16+12),ntri_smooth:b(a,I+16+16),ntri_flat_uv:b(a,I+16+20),ntri_smooth_uv:b(a,I+16+24),nquad_flat:b(a,I+16+28),nquad_smooth:b(a,I+16+32),nquad_flat_uv:b(a,I+16+36),
+nquad_smooth_uv:b(a,I+16+40)};I+=v.header_bytes;B=v.vertex_index_bytes;n=v.vertex_index_bytes*2;m=v.vertex_index_bytes*3;z=v.vertex_index_bytes*3+v.material_index_bytes;q=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes;D=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*2;x=v.vertex_index_bytes;u=v.vertex_index_bytes*2;F=v.vertex_index_bytes*3;J=v.vertex_index_bytes*4;G=v.vertex_index_bytes*4+v.material_index_bytes;T=v.vertex_index_bytes*4+v.material_index_bytes+
+v.normal_index_bytes;U=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*2;O=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*3;ba=v.uv_index_bytes;ca=v.uv_index_bytes*2;W=v.uv_index_bytes;R=v.uv_index_bytes*2;X=v.uv_index_bytes*3;f=v.vertex_index_bytes*3+v.material_index_bytes;ha=v.vertex_index_bytes*4+v.material_index_bytes;Y=v.ntri_flat*f;M=v.ntri_smooth*(f+v.normal_index_bytes*3);S=v.ntri_flat_uv*(f+v.uv_index_bytes*3);aa=v.ntri_smooth_uv*(f+v.normal_index_bytes*
+3+v.uv_index_bytes*3);ja=v.nquad_flat*ha;f=v.nquad_smooth*(ha+v.normal_index_bytes*4);ha=v.nquad_flat_uv*(ha+v.uv_index_bytes*4);I+=function(E){var K,N,V,da=v.vertex_coordinate_bytes*3,ga=E+v.nvertices*da;for(E=E;E<ga;E+=da){K=h(a,E);N=h(a,E+v.vertex_coordinate_bytes);V=h(a,E+v.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(y,K,N,V)}return v.nvertices*da}(I);I+=function(E){var K,N,V,da=v.normal_coordinate_bytes*3,ga=E+v.nnormals*da;for(E=E;E<ga;E+=da){K=l(a,E);N=l(a,E+v.normal_coordinate_bytes);
+V=l(a,E+v.normal_coordinate_bytes*2);L.push(K/127,N/127,V/127)}return v.nnormals*da}(I);I+=function(E){var K,N,V=v.uv_coordinate_bytes*2,da=E+v.nuvs*V;for(E=E;E<da;E+=V){K=h(a,E);N=h(a,E+v.uv_coordinate_bytes);k.push(K,N)}return v.nuvs*V}(I);I=I;Y=I+Y;M=Y+M;S=M+S;aa=S+aa;ja=aa+ja;f=ja+f;ha=f+ha;(function(E){var K,N=v.vertex_index_bytes*3+v.material_index_bytes,V=N+v.uv_index_bytes*3,da=E+v.ntri_flat_uv*V;for(K=E;K<da;K+=V){A(K);C(K+N)}return da-E})(M);(function(E){var K,N=v.vertex_index_bytes*3+v.material_index_bytes+
+v.normal_index_bytes*3,V=N+v.uv_index_bytes*3,da=E+v.ntri_smooth_uv*V;for(K=E;K<da;K+=V){w(K);C(K+N)}return da-E})(S);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes,V=N+v.uv_index_bytes*4,da=E+v.nquad_flat_uv*V;for(K=E;K<da;K+=V){o(K);H(K+N)}return da-E})(f);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*4,V=N+v.uv_index_bytes*4,da=E+v.nquad_smooth_uv*V;for(K=E;K<da;K+=V){p(K);H(K+N)}return da-E})(ha);(function(E){var K,N=v.vertex_index_bytes*
+3+v.material_index_bytes,V=E+v.ntri_flat*N;for(K=E;K<V;K+=N)A(K);return V-E})(I);(function(E){var K,N=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*3,V=E+v.ntri_smooth*N;for(K=E;K<V;K+=N)w(K);return V-E})(Y);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes,V=E+v.nquad_flat*N;for(K=E;K<V;K+=N)o(K);return V-E})(aa);(function(E){var K,N=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*4,V=E+v.nquad_smooth*N;for(K=E;K<V;K+=N)p(K);return V-E})(ja);
+this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(d))},createModel:function(a,c,d){var e=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){var h,b,j,l,t;h=0;for(b=a.vertices.length;h<b;h+=3){j=a.vertices[h];l=a.vertices[h+1];t=a.vertices[h+2];THREE.Loader.prototype.v(f,j,l,t)}if(a.colors){h=0;for(b=a.colors.length;h<b;h+=3){j=a.colors[h];l=
+a.colors[h+1];t=a.colors[h+2];THREE.Loader.prototype.vc(f,j,l,t)}}})();(function(){function h(p,C){THREE.Loader.prototype.f3(f,p[C],p[C+1],p[C+2],p[C+3])}function b(p,C){THREE.Loader.prototype.f3n(f,a.normals,p[C],p[C+1],p[C+2],p[C+3],p[C+4],p[C+5],p[C+6])}function j(p,C){THREE.Loader.prototype.f4(f,p[C],p[C+1],p[C+2],p[C+3],p[C+4])}function l(p,C){THREE.Loader.prototype.f4n(f,a.normals,p[C],p[C+1],p[C+2],p[C+3],p[C+4],p[C+5],p[C+6],p[C+7],p[C+8])}function t(p,C){var H,y,I,v,L,k,B,n,m;H=p[C];y=p[C+
+1];I=p[C+2];v=a.uvs[H*2];B=a.uvs[H*2+1];L=a.uvs[y*2];n=a.uvs[y*2+1];k=a.uvs[I*2];m=a.uvs[I*2+1];THREE.Loader.prototype.uv3(f.uvs,v,B,L,n,k,m);if(a.uvs2){v=a.uvs2[H*2];B=a.uvs2[H*2+1];L=a.uvs2[y*2];n=a.uvs2[y*2+1];k=a.uvs2[I*2];m=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(f.uvs2,v,1-B,L,1-n,k,1-m)}}function A(p,C){var H,y,I,v,L,k,B,n,m,z,q,D;H=p[C];y=p[C+1];I=p[C+2];v=p[C+3];L=a.uvs[H*2];m=a.uvs[H*2+1];k=a.uvs[y*2];z=a.uvs[y*2+1];B=a.uvs[I*2];q=a.uvs[I*2+1];n=a.uvs[v*2];D=a.uvs[v*2+1];THREE.Loader.prototype.uv4(f.uvs,
+L,m,k,z,B,q,n,D);if(a.uvs2){L=a.uvs2[H*2];m=a.uvs2[H*2+1];k=a.uvs2[y*2];z=a.uvs2[y*2+1];B=a.uvs2[I*2];q=a.uvs2[I*2+1];n=a.uvs2[v*2];D=a.uvs2[v*2+1];THREE.Loader.prototype.uv4(f.uvs2,L,1-m,k,1-z,B,1-q,n,1-D)}}var w,o;w=0;for(o=a.triangles_uv.length;w<o;w+=7){h(a.triangles_uv,w);t(a.triangles_uv,w+4)}w=0;for(o=a.triangles_n_uv.length;w<o;w+=10){b(a.triangles_n_uv,w);t(a.triangles_n_uv,w+7)}w=0;for(o=a.quads_uv.length;w<o;w+=9){j(a.quads_uv,w);A(a.quads_uv,w+5)}w=0;for(o=a.quads_n_uv.length;w<o;w+=13){l(a.quads_n_uv,
+w);A(a.quads_n_uv,w+9)}w=0;for(o=a.triangles.length;w<o;w+=4)h(a.triangles,w);w=0;for(o=a.triangles_n.length;w<o;w+=7)b(a.triangles_n,w);w=0;for(o=a.quads.length;w<o;w+=5)j(a.quads,w);w=0;for(o=a.quads_n.length;w<o;w+=9)l(a.quads_n,w)})();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)))},vc:function(a,c,d,e){var g=new THREE.Color(16777215);
+g.setRGB(c,d,e);a.colors.push(g)},f3:function(a,c,d,e,g){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[g]))},f4:function(a,c,d,e,g,f){a.faces.push(new THREE.Face4(c,d,e,g,null,a.materials[f]))},f3n:function(a,c,d,e,g,f,h,b,j){f=a.materials[f];var l=c[b*3],t=c[b*3+1];b=c[b*3+2];var A=c[j*3],w=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(l,t,b),new THREE.Vector3(A,w,j)],f))},f4n:function(a,c,d,e,g,f,h,b,j,l,t){h=a.materials[h];
+var A=c[j*3],w=c[j*3+1];j=c[j*3+2];var o=c[l*3],p=c[l*3+1];l=c[l*3+2];var C=c[t*3],H=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(d,e,g,f,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(A,w,j),new THREE.Vector3(o,p,l),new THREE.Vector3(C,H,t)],h))},uv3:function(a,c,d,e,g,f,h){var b=[];b.push(new THREE.UV(c,d));b.push(new THREE.UV(e,g));b.push(new THREE.UV(f,h));a.push(b)},uv4:function(a,c,d,e,g,f,h,b,j){var l=[];l.push(new THREE.UV(c,d));l.push(new THREE.UV(e,g));l.push(new THREE.UV(f,
+h));l.push(new THREE.UV(b,j));a.push(l)},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(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function e(b,j){var l=new Image;l.onload=function(){if(!d(this.width)||!d(this.height)){var t=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),A=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=t;b.image.height=
+A;b.image.getContext("2d").drawImage(this,0,0,t,A)}else b.image=this;b.image.loaded=1};l.src=j}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";if(a.map_diffuse&&c){h=document.createElement("canvas");f.map=new THREE.Texture(h);e(f.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f.color=h;f.opacity=a.transparency}else if(a.a_dbg_color)f.color=
+a.a_dbg_color;if(a.map_lightmap&&c){h=document.createElement("canvas");f.light_map=new THREE.Texture(h);e(f.light_map,c+"/"+a.map_lightmap)}return new THREE[g](f)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 130 - 0
examples/io_blender_colors.html

@@ -0,0 +1,130 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js - io - blender - vertex colors - webgl</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				color: #eee;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+
+				background-color: #000;
+				margin: 0px;
+				overflow: hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+			}
+
+			a {
+
+				color: #0080ff;
+			}
+
+		</style>
+	</head>
+	<body>
+
+		<div id="container"></div> 
+		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - vertex colors - blender export - webgl</div>
+
+		<script type="text/javascript" src="../build/ThreeExtras.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>		
+		
+		<script type="text/javascript">
+
+			if ( ! THREE.Detector.webgl ) THREE.Detector.addGetWebGLMessage();
+
+			var container, stats;
+
+			var camera, scene, renderer;
+
+			var mesh, mesh2, mesh3, light;
+
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+
+			init();
+			setInterval( loop, 1000 / 60 );
+
+
+			function init() {
+
+				container = document.getElementById( 'container' );
+
+				camera = new THREE.Camera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera.position.z = 1800;
+
+				scene = new THREE.Scene();
+				
+				//scene.addLight( new THREE.AmbientLight( 0x333333 )  );
+				
+				light = new THREE.DirectionalLight( 0xffffff );
+				light.position.set( 0, 0, 1 );
+				light.position.normalize();
+				scene.addLight( light );
+
+				var loader = new THREE.Loader();
+				loader.loadAscii( { model: "obj/cubecolors/cubecolors.js", callback: createScene } );
+				
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				container.appendChild( renderer.domElement );
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				container.appendChild( stats.domElement );
+
+				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			}
+
+			function createScene( geometry ) {
+			
+				geometry.materials[0][0].shading = THREE.FlatShading;
+				
+				var material = [ new THREE.MeshFaceMaterial(), 
+								 new THREE.MeshLambertMaterial( { color: 0xffffff, opacity:0.9, shading:THREE.FlatShading, wireframe: true, wireframe_linewidth: 2 } )  
+								];
+				mesh = SceneUtils.addMesh( scene, geometry, 250, 0, 0, 0, 0, 0, 0, material );
+				
+			}
+			
+			function onDocumentMouseMove( event ) {
+
+				mouseX = ( event.clientX - windowHalfX );
+				mouseY = ( event.clientY - windowHalfY );
+
+			}
+
+			function loop() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * 0.05;
+				camera.position.y += ( - mouseY - camera.position.y ) * 0.05;
+
+				if ( mesh ) {
+				
+					mesh.rotation.x += 0.01;
+					mesh.rotation.y += 0.01;
+					
+				}
+				
+				renderer.render( scene, camera );
+				stats.update();
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 7 - 0
examples/obj/cubecolors/.htaccess

@@ -0,0 +1,7 @@
+<Files *.js>
+SetOutputFilter DEFLATE
+</Files>
+
+<Files *.bin>
+SetOutputFilter DEFLATE
+</Files>

BIN
examples/obj/cubecolors/cubecolors.blend


File diff suppressed because it is too large
+ 27 - 0
examples/obj/cubecolors/cubecolors.js


+ 48 - 16
src/extras/io/Loader.js

@@ -766,7 +766,7 @@ THREE.Loader.prototype = {
 
 
 			function init_vertices() {
 			function init_vertices() {
 
 
-				var i, l, x, y, z;
+				var i, l, x, y, z, r, g, b;
 
 
 				for( i = 0, l = data.vertices.length; i < l; i += 3 ) {
 				for( i = 0, l = data.vertices.length; i < l; i += 3 ) {
 
 
@@ -777,6 +777,20 @@ THREE.Loader.prototype = {
 					THREE.Loader.prototype.v( scope, x, y, z );
 					THREE.Loader.prototype.v( scope, x, y, z );
 
 
 				}
 				}
+				
+				if ( data.colors ) {
+					
+					for( i = 0, l = data.colors.length; i < l; i += 3 ) {
+						
+						r = data.colors[ i     ];
+						g = data.colors[ i + 1 ];
+						b = data.colors[ i + 2 ];
+
+						THREE.Loader.prototype.vc( scope, r, g, b );
+					
+					}
+					
+				}
 
 
 			}
 			}
 
 
@@ -1004,6 +1018,14 @@ THREE.Loader.prototype = {
 
 
 	},
 	},
 
 
+	vc: function( scope, r, g, b ) {
+
+		var color = new THREE.Color( 0xffffff );
+		color.setRGB( r, g, b );
+		scope.colors.push( color );
+
+	},
+
 	f3: function( scope, a, b, c, mi ) {
 	f3: function( scope, a, b, c, mi ) {
 
 
 		var material = scope.materials[ mi ];
 		var material = scope.materials[ mi ];
@@ -1147,39 +1169,49 @@ THREE.Loader.prototype = {
 			
 			
 		}
 		}
 		
 		
-		var material, texture, color;
+		var material, mtype, mpars, texture, color;
 
 
+		// defaults
+		
+		mtype = "MeshLambertMaterial";
+		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, light_map: null, vertex_colors: m.vertex_colors };
+		
+		// parameters from model file
+		
+		if ( m.shading ) {
+			
+			if ( m.shading == "Phong" ) mtype = "MeshPhongMaterial";
+			
+		}
+		
 		if ( m.map_diffuse && texture_path ) {
 		if ( m.map_diffuse && texture_path ) {
 
 
 			texture = document.createElement( 'canvas' );
 			texture = document.createElement( 'canvas' );
-			material = new THREE.MeshLambertMaterial( { map: new THREE.Texture( texture ) } );
-
-			load_image( material.map, texture_path + "/" + m.map_diffuse );			
-
+			mpars.map = new THREE.Texture( texture );
+			load_image( mpars.map, texture_path + "/" + m.map_diffuse );
 
 
 		} else if ( m.col_diffuse ) {
 		} else if ( m.col_diffuse ) {
 
 
-			color = (m.col_diffuse[0]*255 << 16) + (m.col_diffuse[1]*255 << 8) + m.col_diffuse[2]*255;
-			material = new THREE.MeshLambertMaterial( { color: color, opacity: m.transparency } );
+			color = ( m.col_diffuse[0] * 255 << 16 ) + ( m.col_diffuse[1] * 255 << 8 ) + m.col_diffuse[2] * 255;
+			mpars.color = color;
+			mpars.opacity =  m.transparency;
 
 
 		} else if ( m.a_dbg_color ) {
 		} else if ( m.a_dbg_color ) {
 
 
-			material = new THREE.MeshLambertMaterial( { color: m.a_dbg_color } );
-
-		} else {
-
-			material = new THREE.MeshLambertMaterial( { color: 0xeeeeee } );
+			mpars.color = m.a_dbg_color;
 
 
 		}
 		}
-		
+
 		if ( m.map_lightmap && texture_path ) {
 		if ( m.map_lightmap && texture_path ) {
 
 
 			texture = document.createElement( 'canvas' );
 			texture = document.createElement( 'canvas' );
-			material.light_map = new THREE.Texture( texture );
+			mpars.light_map = new THREE.Texture( texture );
 			
 			
-			load_image( material.light_map, texture_path + "/" + m.map_lightmap );			
+			load_image( mpars.light_map, texture_path + "/" + m.map_lightmap );			
 
 
 		}
 		}
+		
+		material = new THREE[ mtype ]( mpars );
 
 
 		return material;
 		return material;
 
 

+ 17 - 15
src/renderers/WebGLRenderer.js

@@ -26,7 +26,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	// gl state cache
 	// gl state cache
 	
 	
-	_cullEnabled,
+	_oldDoubleSided = null,
+	_oldFlipSided = null,
 	_oldBlending = null,
 	_oldBlending = null,
 	
 	
 	// camera matrices caches
 	// camera matrices caches
@@ -531,7 +532,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					c1 = obj_colors[ face.a ];
 					c1 = obj_colors[ face.a ];
 					c2 = obj_colors[ face.b ];
 					c2 = obj_colors[ face.b ];
 					c3 = obj_colors[ face.c ];
 					c3 = obj_colors[ face.c ];
-					c3 = obj_colors[ face.d ];
+					c4 = obj_colors[ face.d ];
 
 
 					colorArray[ offset_color ]     = c1.r;
 					colorArray[ offset_color ]     = c1.r;
 					colorArray[ offset_color + 1 ] = c1.g;
 					colorArray[ offset_color + 1 ] = c1.g;
@@ -1364,34 +1365,35 @@ THREE.WebGLRenderer = function ( parameters ) {
 	
 	
 	function setObjectFaces( object ) {
 	function setObjectFaces( object ) {
 		
 		
-		if( object.doubleSided ) {
-
-			if ( _cullEnabled ) {
+		if ( _oldDoubleSided != object.doubleSided ) {
 			
 			
-				_gl.disable( _gl.CULL_FACE );
-				_cullEnabled = false;
+			if( object.doubleSided ) {
 				
 				
-			}
+				_gl.disable( _gl.CULL_FACE );
 
 
-		} else {
+			} else {
 
 
-			if ( ! _cullEnabled ) {
-			
 				_gl.enable( _gl.CULL_FACE );
 				_gl.enable( _gl.CULL_FACE );
-				_cullEnabled = true;
 			
 			
 			}
 			}
-
+			
+			_oldDoubleSided = object.doubleSided;
+		
+		}
+		
+		if ( _oldFlipSided != object.flipSided ) {
+		
 			if( object.flipSided ) {
 			if( object.flipSided ) {
 
 
 				_gl.frontFace( _gl.CW );
 				_gl.frontFace( _gl.CW );
 
 
-			}
-			else {
+			} else {
 
 
 				_gl.frontFace( _gl.CCW );
 				_gl.frontFace( _gl.CCW );
 
 
 			}
 			}
+			
+			_oldFlipSided = object.flipSided;
 
 
 		}
 		}
 		
 		

+ 3 - 0
utils/exporters/blender/2.55/scripts/op/io_mesh_threejs/__init__.py

@@ -36,6 +36,7 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
 
     use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to the exported mesh", default=True)
     use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to the exported mesh", default=True)
     use_normals = BoolProperty(name="Normals", description="Export normals", default=True)
     use_normals = BoolProperty(name="Normals", description="Export normals", default=True)
+    use_colors = BoolProperty(name="Colors", description="Export vertex colors", default=True)
     use_uv_coords = BoolProperty(name="UVs", description="Export texture coordinates", default=True)
     use_uv_coords = BoolProperty(name="UVs", description="Export texture coordinates", default=True)
 
 
     align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")]
     align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")]
@@ -63,6 +64,8 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
         row = layout.row()
         row = layout.row()
         row.prop(self.properties, "use_normals")
         row.prop(self.properties, "use_normals")
         row = layout.row()
         row = layout.row()
+        row.prop(self.properties, "use_colors")
+        row = layout.row()
         row.prop(self.properties, "use_uv_coords")
         row.prop(self.properties, "use_uv_coords")
         row = layout.row()
         row = layout.row()
         row.prop(self.properties, "align_model")
         row.prop(self.properties, "align_model")

+ 101 - 34
utils/exporters/blender/2.55/scripts/op/io_mesh_threejs/export_threejs.py

@@ -63,25 +63,27 @@ TEMPLATE_FILE_ASCII = """\
 
 
 var model = {
 var model = {
 
 
-	'materials': [%(materials)s],
+    'materials': [%(materials)s],
 
 
-	'normals': [%(normals)s],
+    'normals': [%(normals)s],
 
 
-	'vertices': [%(vertices)s],
+    'vertices': [%(vertices)s],
 
 
-	'uvs': [%(uvs)s],
+    'colors': [%(colors)s],
 
 
-	'triangles': [%(triangles)s],
-	'triangles_n': [%(triangles_n)s],
-	'triangles_uv': [%(triangles_uv)s],
-	'triangles_n_uv': [%(triangles_n_uv)s],
+    'uvs': [%(uvs)s],
 
 
-	'quads': [%(quads)s],
-	'quads_n': [%(quads_n)s],
-	'quads_uv': [%(quads_uv)s],
-	'quads_n_uv': [%(quads_n_uv)s],
+    'triangles': [%(triangles)s],
+    'triangles_n': [%(triangles_n)s],
+    'triangles_uv': [%(triangles_uv)s],
+    'triangles_n_uv': [%(triangles_n_uv)s],
 
 
-	'end': (new Date).getTime()
+    'quads': [%(quads)s],
+    'quads_n': [%(quads_n)s],
+    'quads_uv': [%(quads_uv)s],
+    'quads_n_uv': [%(quads_n_uv)s],
+
+    'end': (new Date).getTime()
 
 
 }
 }
 
 
@@ -106,6 +108,7 @@ TEMPLATE_TRI_N_UV = "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
 TEMPLATE_QUAD_N_UV = "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
 TEMPLATE_QUAD_N_UV = "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
 
 
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_N = "%f,%f,%f"
+TEMPLATE_C = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
 TEMPLATE_UV = "%f,%f"
 
 
 # #####################################################
 # #####################################################
@@ -219,6 +222,9 @@ def generate_vertex(v):
 def generate_normal(n):
 def generate_normal(n):
     return TEMPLATE_N % (n[0], n[1], n[2])
     return TEMPLATE_N % (n[0], n[1], n[2])
 
 
+def generate_vertex_color(c):
+    return TEMPLATE_C % (c[0], c[1], c[2])
+    
 def generate_uv(uv):
 def generate_uv(uv):
     return TEMPLATE_UV % (uv[0], 1.0 - uv[1])
     return TEMPLATE_UV % (uv[0], 1.0 - uv[1])
 
 
@@ -363,6 +369,45 @@ def generate_normals(normals, use_normals):
 
 
     return ",".join(generate_normal(n) for n in chunks)
     return ",".join(generate_normal(n) for n in chunks)
 
 
+# #####################################################
+# Vertex colors
+# #####################################################
+def extract_vertex_colors(mesh, use_colors):
+    if not use_colors:
+        return {}
+
+    colors = {}
+
+    color_layer = mesh.vertex_colors.active.data
+
+    for face_index, face in enumerate(mesh.faces):
+        
+        face_colors = color_layer[face_index]
+        face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
+        
+        for i, vertex_index in enumerate(face.vertices):
+
+            if vertex_index not in colors:
+                fc = face_colors[i]
+                colors[vertex_index] = fc[0], fc[1], fc[2]
+
+    # make sure all vertices have some color
+    for i in range(len(mesh.vertices)):
+        if i not in colors:
+            colors[i] = (0,0,0)
+            
+    return colors
+
+def generate_vertex_colors(colors, use_colors):
+    if not use_colors:
+        return ""
+
+    chunks = []
+    for vertex_index, color in sorted(colors.items(), key=operator.itemgetter(0)):
+        chunks.append(color)
+
+    return ",".join(generate_vertex_color(c) for c in chunks)
+
 # #####################################################
 # #####################################################
 # UVs
 # UVs
 # #####################################################
 # #####################################################
@@ -421,16 +466,19 @@ def generate_mtl(materials):
         mtl[m] = {
         mtl[m] = {
             'a_dbg_name': m,
             'a_dbg_name': m,
             'a_dbg_index': index,
             'a_dbg_index': index,
-            'a_dbg_color': generate_color(index)
+            'a_dbg_color': generate_color(index),
+            'vertex_colors' : False
         }
         }
     return mtl
     return mtl
 
 
 def value2string(v):
 def value2string(v):
-    if type(v)==str and v[0] != "0":
+    if type(v) == str and v[0] != "0":
         return '"%s"' % v
         return '"%s"' % v
+    elif type(v) == bool:
+        return str(v).lower()
     return str(v)
     return str(v)
 
 
-def generate_materials(mtl, materials):
+def generate_materials(mtl, materials, use_colors):
     """Generate JS array of materials objects
     """Generate JS array of materials objects
     """
     """
 
 
@@ -445,6 +493,7 @@ def generate_materials(mtl, materials):
         mtl[m]['a_dbg_name'] = m
         mtl[m]['a_dbg_name'] = m
         mtl[m]['a_dbg_index'] = index
         mtl[m]['a_dbg_index'] = index
         mtl[m]['a_dbg_color'] = generate_color(index)
         mtl[m]['a_dbg_color'] = generate_color(index)
+        mtl[m]['vertex_colors'] = use_colors
 
 
         mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
         mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
         mtl_string = "\t{\n%s\n\t}" % mtl_raw
         mtl_string = "\t{\n%s\n\t}" % mtl_raw
@@ -459,34 +508,41 @@ def extract_materials(mesh, scene):
     for m in mesh.materials:
     for m in mesh.materials:
         if m:
         if m:
             materials[m.name] = {}
             materials[m.name] = {}
-            materials[m.name]['col_diffuse'] = [m.diffuse_intensity * m.diffuse_color[0],
-                                                m.diffuse_intensity * m.diffuse_color[1],
-                                                m.diffuse_intensity * m.diffuse_color[2]]
+            material = materials[m.name]
+            
+            material['col_diffuse'] = [m.diffuse_intensity * m.diffuse_color[0],
+                                       m.diffuse_intensity * m.diffuse_color[1],
+                                       m.diffuse_intensity * m.diffuse_color[2]]
 
 
-            materials[m.name]['col_specular'] = [m.specular_intensity * m.specular_color[0],
-                                                 m.specular_intensity * m.specular_color[1],
-                                                 m.specular_intensity * m.specular_color[2]]
+            material['col_specular'] = [m.specular_intensity * m.specular_color[0],
+                                        m.specular_intensity * m.specular_color[1],
+                                        m.specular_intensity * m.specular_color[2]]
 
 
-            materials[m.name]['col_ambient'] = [m.ambient * world.ambient_color[0],
-                                                m.ambient * world.ambient_color[1],
-                                                m.ambient * world.ambient_color[2]]
+            material['col_ambient'] = [m.ambient * world.ambient_color[0],
+                                       m.ambient * world.ambient_color[1],
+                                       m.ambient * world.ambient_color[2]]
 
 
-            materials[m.name]['transparency'] = m.alpha
+            material['transparency'] = m.alpha
 
 
             # not sure about mapping values to Blinn-Phong shader
             # not sure about mapping values to Blinn-Phong shader
             # Blender uses INT from [1,511] with default 0
             # Blender uses INT from [1,511] with default 0
             # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness
             # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness
-            materials[m.name]["specular_coef"] = m.specular_hardness
+            material["specular_coef"] = m.specular_hardness
 
 
             if m.active_texture and m.active_texture.type == 'IMAGE':
             if m.active_texture and m.active_texture.type == 'IMAGE':
                 fn = bpy.path.abspath(m.active_texture.image.filepath)
                 fn = bpy.path.abspath(m.active_texture.image.filepath)
                 fn = os.path.normpath(fn)
                 fn = os.path.normpath(fn)
                 fn_strip = os.path.basename(fn)
                 fn_strip = os.path.basename(fn)
-                materials[m.name]['map_diffuse'] = fn_strip
+                material['map_diffuse'] = fn_strip
+                
+            if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0):
+                material['shading'] = "Phong"
+            else:
+                material['shading'] = "Lambert"
 
 
     return materials
     return materials
 
 
-def generate_materials_string(mesh, scene):
+def generate_materials_string(mesh, scene, use_colors):
 
 
     random.seed(42) # to get well defined color order for debug materials
     random.seed(42) # to get well defined color order for debug materials
 
 
@@ -508,12 +564,12 @@ def generate_materials_string(mesh, scene):
     # extract real materials from the mesh
     # extract real materials from the mesh
     mtl.update(extract_materials(mesh, scene))
     mtl.update(extract_materials(mesh, scene))
 
 
-    return generate_materials(mtl, materials)
+    return generate_materials(mtl, materials, use_colors)
 
 
 # #####################################################
 # #####################################################
 # ASCII exporter
 # ASCII exporter
 # #####################################################
 # #####################################################
-def generate_ascii_model(mesh, scene, use_normals, use_uv_coords, align_model):
+def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model):
 
 
     vertices = mesh.vertices[:]
     vertices = mesh.vertices[:]
 
 
@@ -527,6 +583,7 @@ def generate_ascii_model(mesh, scene, use_normals, use_uv_coords, align_model):
     sfaces = sort_faces(mesh.faces, use_normals, use_uv_coords)
     sfaces = sort_faces(mesh.faces, use_normals, use_uv_coords)
 
 
     normals = extract_vertex_normals(mesh, use_normals)
     normals = extract_vertex_normals(mesh, use_normals)
+    colors = extract_vertex_colors(mesh, use_colors)
     uvs = extract_uvs(mesh, use_uv_coords)
     uvs = extract_uvs(mesh, use_uv_coords)
 
 
     text = TEMPLATE_FILE_ASCII % {
     text = TEMPLATE_FILE_ASCII % {
@@ -544,8 +601,9 @@ def generate_ascii_model(mesh, scene, use_normals, use_uv_coords, align_model):
 
 
     "uvs"           : generate_uvs(uvs, use_uv_coords),
     "uvs"           : generate_uvs(uvs, use_uv_coords),
     "normals"       : generate_normals(normals, use_normals),
     "normals"       : generate_normals(normals, use_normals),
+    "colors"        : generate_vertex_colors(colors, use_colors),
 
 
-    "materials" : generate_materials_string(mesh, scene),
+    "materials" : generate_materials_string(mesh, scene, use_colors),
 
 
     "nvertex"   : len(mesh.vertices),
     "nvertex"   : len(mesh.vertices),
     "nface"     : len(mesh.faces),
     "nface"     : len(mesh.faces),
@@ -557,7 +615,7 @@ def generate_ascii_model(mesh, scene, use_normals, use_uv_coords, align_model):
 # #####################################################
 # #####################################################
 # Main
 # Main
 # #####################################################
 # #####################################################
-def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_uv_coords=True, align_model=1):
+def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_colors=True, use_uv_coords=True, align_model=1):
 
 
     def rvec3d(v):
     def rvec3d(v):
         return round(v[0], 6), round(v[1], 6), round(v[2], 6)
         return round(v[0], 6), round(v[1], 6), round(v[2], 6)
@@ -594,6 +652,10 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
 
 
     faceUV = (len(mesh.uv_textures) > 0)
     faceUV = (len(mesh.uv_textures) > 0)
     vertexUV = (len(mesh.sticky) > 0)
     vertexUV = (len(mesh.sticky) > 0)
+    vertexColors = len(mesh.vertex_colors) > 0
+
+    if not vertexColors:
+        use_colors = False
 
 
     if (not faceUV) and (not vertexUV):
     if (not faceUV) and (not vertexUV):
         use_uv_coords = False
         use_uv_coords = False
@@ -603,7 +665,12 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
         if not active_uv_layer:
         if not active_uv_layer:
             use_uv_coords = False
             use_uv_coords = False
 
 
-    text = generate_ascii_model(mesh, scene, use_normals, use_uv_coords, align_model)
+    if vertexColors:
+        active_col_layer = mesh.vertex_colors.active
+        if not active_col_layer:
+            use_colors = False
+
+    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model)
     file = open(filepath, 'w')
     file = open(filepath, 'w')
     file.write(text)
     file.write(text)
     file.close()
     file.close()

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