Browse Source

`THREE.Matrix4()` → `THREE.Matrix4( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 )`

Mr.doob 14 years ago
parent
commit
b13b9164b7
4 changed files with 308 additions and 283 deletions
  1. 95 95
      build/Three.js
  2. 95 95
      build/ThreeDebug.js
  3. 87 87
      build/ThreeExtras.js
  4. 31 6
      src/core/Matrix4.js

+ 95 - 95
build/Three.js

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

+ 95 - 95
build/ThreeDebug.js

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

+ 87 - 87
build/ThreeExtras.js

@@ -12,44 +12,44 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(j,k){return j.distance-k.distance});return f},intersectObject:function(a){function b(H,I,z,n){n=n.clone().subSelf(I);z=z.clone().subSelf(I);var h=H.clone().subSelf(I);H=n.dot(n);I=n.dot(z);n=n.dot(h);var o=z.dot(z);z=z.dot(h);h=1/(H*o-I*I);o=(o*n-I*z)*h;H=(H*z-I*n)*h;return o>0&&H>0&&o+H<1}var d,e,f,j,k,g,m,c,t,A,
-r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];A=this.origin.clone();r=this.direction.clone();j=a.matrix.multiplyVector3(v[f.a].position.clone());k=a.matrix.multiplyVector3(v[f.b].position.clone());g=a.matrix.multiplyVector3(v[f.c].position.clone());m=f instanceof THREE.Face4?a.matrix.multiplyVector3(v[f.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(f.normal.clone());t=r.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(j,A))/t;A=A.addSelf(r.multiplyScalar(c));
-if(f instanceof THREE.Face3){if(b(A,j,k,g)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};w.push(f)}}else if(f instanceof THREE.Face4)if(b(A,j,k,m)||b(A,k,g,m)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};w.push(f)}}}return w}};
-THREE.Rectangle=function(){function a(){j=e-b;k=f-d}var b,d,e,f,j,k,g=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(m,c,t,A){g=false;b=m;d=c;e=t;f=A;a()};this.addPoint=function(m,c){if(g){g=false;b=m;d=c;e=m;f=c}else{b=Math.min(b,m);d=Math.min(d,c);e=Math.max(e,
-m);f=Math.max(f,c)}a()};this.addRectangle=function(m){if(g){g=false;b=m.getLeft();d=m.getTop();e=m.getRight();f=m.getBottom()}else{b=Math.min(b,m.getLeft());d=Math.min(d,m.getTop());e=Math.max(e,m.getRight());f=Math.max(f,m.getBottom())}a()};this.inflate=function(m){b-=m;d-=m;e+=m;f+=m;a()};this.minSelf=function(m){b=Math.max(b,m.getLeft());d=Math.max(d,m.getTop());e=Math.min(e,m.getRight());f=Math.min(f,m.getBottom());a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=
-0&&Math.min(f,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
-THREE.Matrix4=function(){};
-THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.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},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=
-a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(a,b,d){var e=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=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},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*
-d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*
-a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,m=a.n23,c=a.n24,t=a.n31,A=a.n32,r=a.n33,u=a.n34,v=a.n41,w=a.n42,H=a.n43,I=a.n44,z=b.n11,n=b.n12,h=b.n13,o=b.n14,i=b.n21,y=b.n22,l=b.n23,p=b.n24,C=b.n31,B=b.n32,P=b.n33,J=b.n34,R=b.n41,T=b.n42,E=b.n43,
-V=b.n44;this.n11=d*z+e*i+f*C+j*R;this.n12=d*n+e*y+f*B+j*T;this.n13=d*h+e*l+f*P+j*E;this.n14=d*o+e*p+f*J+j*V;this.n21=k*z+g*i+m*C+c*R;this.n22=k*n+g*y+m*B+c*T;this.n23=k*h+g*l+m*P+c*E;this.n24=k*o+g*p+m*J+c*V;this.n31=t*z+A*i+r*C+u*R;this.n32=t*n+A*y+r*B+u*T;this.n33=t*h+A*l+r*P+u*E;this.n34=t*o+A*p+r*J+u*V;this.n41=v*z+w*i+H*C+I*R;this.n42=v*n+w*y+H*B+I*T;this.n43=v*h+w*l+H*P+I*E;this.n44=v*o+w*p+H*J+I*V},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22,
-g=this.n23,m=this.n24,c=this.n31,t=this.n32,A=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,H=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+m*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+m*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+m*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+m*a.n44;this.n31=c*a.n11+t*a.n21+A*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+
-A*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+A*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+A*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+H*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+H*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+H*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+H*a.n44},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a},determinant:function(){return this.n14*
-this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*
-this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,
-"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},
-toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};
-THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),f=Math.sin(b),j=1-e,k=a.x,g=a.y,m=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*m;d.n13=j*k*m+f*g;d.n21=j*k*g+f*m;d.n22=j*g*g+e;d.n23=j*g*m-f*k;d.n31=j*k*m-f*g;d.n32=j*g*m+f*k;d.n33=j*m*m+e;return d};
+THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(j,k){return j.distance-k.distance});return f},intersectObject:function(a){function b(H,I,z,n){n=n.clone().subSelf(I);z=z.clone().subSelf(I);var h=H.clone().subSelf(I);H=n.dot(n);I=n.dot(z);n=n.dot(h);var o=z.dot(z);z=z.dot(h);h=1/(H*o-I*I);o=(o*n-I*z)*h;H=(H*z-I*n)*h;return o>0&&H>0&&o+H<1}var d,e,f,j,k,g,l,c,t,A,
+r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d<e;d++){f=u.faces[d];A=this.origin.clone();r=this.direction.clone();j=a.matrix.multiplyVector3(v[f.a].position.clone());k=a.matrix.multiplyVector3(v[f.b].position.clone());g=a.matrix.multiplyVector3(v[f.c].position.clone());l=f instanceof THREE.Face4?a.matrix.multiplyVector3(v[f.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(f.normal.clone());t=r.dot(c);if(t<0){c=c.dot((new THREE.Vector3).sub(j,A))/t;A=A.addSelf(r.multiplyScalar(c));
+if(f instanceof THREE.Face3){if(b(A,j,k,g)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};w.push(f)}}else if(f instanceof THREE.Face4)if(b(A,j,k,l)||b(A,k,g,l)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};w.push(f)}}}return w}};
+THREE.Rectangle=function(){function a(){j=e-b;k=f-d}var b,d,e,f,j,k,g=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(l,c,t,A){g=false;b=l;d=c;e=t;f=A;a()};this.addPoint=function(l,c){if(g){g=false;b=l;d=c;e=l;f=c}else{b=Math.min(b,l);d=Math.min(d,c);e=Math.max(e,
+l);f=Math.max(f,c)}a()};this.addRectangle=function(l){if(g){g=false;b=l.getLeft();d=l.getTop();e=l.getRight();f=l.getBottom()}else{b=Math.min(b,l.getLeft());d=Math.min(d,l.getTop());e=Math.max(e,l.getRight());f=Math.max(f,l.getBottom())}a()};this.inflate=function(l){b-=l;d-=l;e+=l;f+=l;a()};this.minSelf=function(l){b=Math.max(b,l.getLeft());d=Math.max(d,l.getTop());e=Math.min(e,l.getRight());f=Math.min(f,l.getBottom());a()};this.instersects=function(l){return Math.min(e,l.getRight())-Math.max(b,l.getLeft())>=
+0&&Math.min(f,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
+THREE.Matrix4=function(a,b,d,e,f,j,k,g,l,c,t,A,r,u,v,w){this.n11=a||1;this.n12=b||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=j||1;this.n23=k||0;this.n24=g||0;this.n31=l||0;this.n32=c||0;this.n33=t||1;this.n34=A||0;this.n41=r||0;this.n42=u||0;this.n43=v||0;this.n44=w||1};
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,d,e,f,j,k,g,l,c,t,A,r,u,v,w){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=f;this.n22=j;this.n23=k;this.n24=g;this.n31=l;this.n32=c;this.n33=t;this.n34=A;this.n41=r;this.n42=u;this.n43=v;this.n44=w;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=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 b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
+f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,l=a.n23,c=a.n24,t=a.n31,A=a.n32,
+r=a.n33,u=a.n34,v=a.n41,w=a.n42,H=a.n43,I=a.n44,z=b.n11,n=b.n12,h=b.n13,o=b.n14,i=b.n21,y=b.n22,m=b.n23,p=b.n24,C=b.n31,B=b.n32,P=b.n33,J=b.n34,R=b.n41,T=b.n42,E=b.n43,V=b.n44;this.n11=d*z+e*i+f*C+j*R;this.n12=d*n+e*y+f*B+j*T;this.n13=d*h+e*m+f*P+j*E;this.n14=d*o+e*p+f*J+j*V;this.n21=k*z+g*i+l*C+c*R;this.n22=k*n+g*y+l*B+c*T;this.n23=k*h+g*m+l*P+c*E;this.n24=k*o+g*p+l*J+c*V;this.n31=t*z+A*i+r*C+u*R;this.n32=t*n+A*y+r*B+u*T;this.n33=t*h+A*m+r*P+u*E;this.n34=t*o+A*p+r*J+u*V;this.n41=v*z+w*i+H*C+I*R;
+this.n42=v*n+w*y+H*B+I*T;this.n43=v*h+w*m+H*P+I*E;this.n44=v*o+w*p+H*J+I*V;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22,g=this.n23,l=this.n24,c=this.n31,t=this.n32,A=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,H=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+l*a.n41;this.n22=
+j*a.n12+k*a.n22+g*a.n32+l*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+l*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+l*a.n44;this.n31=c*a.n11+t*a.n21+A*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+A*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+A*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+A*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+H*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+H*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+H*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+H*a.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=
+a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+
+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-
+this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;
+a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
+THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};
+THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),f=Math.sin(b),j=1-e,k=a.x,g=a.y,l=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*l;d.n13=j*k*l+f*g;d.n21=j*k*g+f*l;d.n22=j*g*g+e;d.n23=j*g*l-f*k;d.n31=j*k*l-f*g;d.n32=j*g*l+f*k;d.n33=j*l*l+e;return d};
 THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
 THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
 a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
 a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
 a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
 a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
 a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
 a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*t;return a};
-THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,m;k=new THREE.Matrix4;g=2*f/(b-a);m=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=m;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,m,c;k=new THREE.Matrix4;g=b-a;m=d-e;c=j-f;a=(b+a)/g;d=(d+e)/m;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/m;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*t;return a};
+THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,l;k=new THREE.Matrix4;g=2*f/(b-a);l=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=l;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)};
+THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,l,c;k=new THREE.Matrix4;g=b-a;l=d-e;c=j-f;a=(b+a)/g;d=(d+e)/l;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/l;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Face3=function(a,b,d,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face3=function(a,b,d,e,f){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,b,d,e,f,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.material=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,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,d,e,f,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.material=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,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={}};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={}};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,j,k,g=new THREE.Vector3,m=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];if(a&&j.vertexNormals.length){g.set(0,0,0);b=0;for(d=j.normal.length;b<d;b++)g.addSelf(j.vertexNormals[b]);g.divideScalar(3)}else{b=this.vertices[j.a];d=this.vertices[j.b];k=this.vertices[j.c];g.sub(k.position,
-d.position);m.sub(b.position,d.position);g.crossSelf(m)}g.isZero()||g.normalize();j.normal.copy(g)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,j,k,g=new THREE.Vector3,l=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];if(a&&j.vertexNormals.length){g.set(0,0,0);b=0;for(d=j.normal.length;b<d;b++)g.addSelf(j.vertexNormals[b]);g.divideScalar(3)}else{b=this.vertices[j.a];d=this.vertices[j.b];k=this.vertices[j.c];g.sub(k.position,
+d.position);l.sub(b.position,d.position);g.crossSelf(l)}g.isZero()||g.normalize();j.normal.copy(g)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
 0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,
 0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,
 this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;
 this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;
-if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var A=[];b=0;for(d=t.length;b<d;b++)t[b]==undefined?A.push("undefined"):A.push(t[b].toString());return A.join("_")}var b,d,e,f,j,k,g,m,c={};e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];k=j.material;g=a(k);if(c[g]==undefined)c[g]={hash:g,counter:0};m=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[m]==
-undefined)this.geometryChunks[m]={faces:[],material:k,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+j>65535){c[g].counter+=1;m=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],material:k,vertices:0}}this.geometryChunks[m].faces.push(e);this.geometryChunks[m].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
+if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var A=[];b=0;for(d=t.length;b<d;b++)t[b]==undefined?A.push("undefined"):A.push(t[b].toString());return A.join("_")}var b,d,e,f,j,k,g,l,c={};e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];k=j.material;g=a(k);if(c[g]==undefined)c[g]={hash:g,counter:0};l=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[l]==
+undefined)this.geometryChunks[l]={faces:[],material:k,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[l].vertices+j>65535){c[g].counter+=1;l=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],material:k,vertices:0}}this.geometryChunks[l].faces.push(e);this.geometryChunks[l].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
 THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
 THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
 THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
 THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
 THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
@@ -86,42 +86,42 @@ THREE.Texture=function(a,b,d,e,f,j){this.image=a;this.mapping=b!==undefined?b:ne
 this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
-THREE.Projector=function(){function a(z,n){var h=0,o=1,i=z.z+z.w,y=n.z+n.w,l=-z.z+z.w,p=-n.z+n.w;if(i>=0&&y>=0&&l>=0&&p>=0)return true;else if(i<0&&y<0||l<0&&p<0)return false;else{if(i<0)h=Math.max(h,i/(i-y));else if(y<0)o=Math.min(o,i/(i-y));if(l<0)h=Math.max(h,l/(l-p));else if(p<0)o=Math.min(o,l/(l-p));if(o<h)return false;else{z.lerpSelf(n,h);n.lerpSelf(z,1-o);return true}}}var b=null,d,e,f,j=[],k,g,m=[],c,t,A=[],r=new THREE.Vector4,u=new THREE.Matrix4,v=new THREE.Matrix4,w=new THREE.Vector4,H=
-new THREE.Vector4,I;this.projectScene=function(z,n){var h,o,i,y,l,p,C,B,P,J,R,T,E,V,K,L,N;b=[];f=g=t=0;n.autoUpdateMatrix&&n.updateMatrix();u.multiply(n.projectionMatrix,n.matrix);C=z.objects;h=0;for(o=C.length;h<o;h++){B=C[h];B.autoUpdateMatrix&&B.updateMatrix();P=B.matrix;J=B.rotationMatrix;R=B.material;T=B.overdraw;if(B instanceof THREE.Mesh){E=B.geometry.vertices;i=0;for(y=E.length;i<y;i++){V=E[i];V.positionWorld.copy(V.position);P.multiplyVector3(V.positionWorld);K=V.positionScreen;K.copy(V.positionWorld);
-u.multiplyVector4(K);K.multiplyScalar(1/K.w);V.__visible=K.z>0&&K.z<1}V=B.geometry.faces;i=0;for(y=V.length;i<y;i++){K=V[i];if(K instanceof THREE.Face3){l=E[K.a];p=E[K.b];L=E[K.c];if(l.__visible&&p.__visible&&L.__visible)if(B.doubleSided||B.flipSided!=(L.positionScreen.x-l.positionScreen.x)*(p.positionScreen.y-l.positionScreen.y)-(L.positionScreen.y-l.positionScreen.y)*(p.positionScreen.x-l.positionScreen.x)<0){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(p.positionWorld);
-d.v3.positionWorld.copy(L.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(p.positionScreen);d.v3.positionScreen.copy(L.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);L=K.vertexNormals;I=d.vertexNormalsWorld;l=0;for(p=L.length;l<p;l++){N=I[l]=I[l]||new THREE.Vector3;N.copy(L[l]);J.multiplyVector3(N)}d.z=
-d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(B.geometry.uvs[i]){d.uvs[0]=B.geometry.uvs[i][0];d.uvs[1]=B.geometry.uvs[i][1];d.uvs[2]=B.geometry.uvs[i][2]}b.push(d);f++}}else if(K instanceof THREE.Face4){l=E[K.a];p=E[K.b];L=E[K.c];N=E[K.d];if(l.__visible&&p.__visible&&L.__visible&&N.__visible)if(B.doubleSided||B.flipSided!=((N.positionScreen.x-l.positionScreen.x)*(p.positionScreen.y-l.positionScreen.y)-(N.positionScreen.y-l.positionScreen.y)*(p.positionScreen.x-l.positionScreen.x)<
-0||(p.positionScreen.x-L.positionScreen.x)*(N.positionScreen.y-L.positionScreen.y)-(p.positionScreen.y-L.positionScreen.y)*(N.positionScreen.x-L.positionScreen.x)<0)){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(p.positionWorld);d.v3.positionWorld.copy(N.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(p.positionScreen);d.v3.positionScreen.copy(N.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);
+THREE.Projector=function(){function a(z,n){var h=0,o=1,i=z.z+z.w,y=n.z+n.w,m=-z.z+z.w,p=-n.z+n.w;if(i>=0&&y>=0&&m>=0&&p>=0)return true;else if(i<0&&y<0||m<0&&p<0)return false;else{if(i<0)h=Math.max(h,i/(i-y));else if(y<0)o=Math.min(o,i/(i-y));if(m<0)h=Math.max(h,m/(m-p));else if(p<0)o=Math.min(o,m/(m-p));if(o<h)return false;else{z.lerpSelf(n,h);n.lerpSelf(z,1-o);return true}}}var b=null,d,e,f,j=[],k,g,l=[],c,t,A=[],r=new THREE.Vector4,u=new THREE.Matrix4,v=new THREE.Matrix4,w=new THREE.Vector4,H=
+new THREE.Vector4,I;this.projectScene=function(z,n){var h,o,i,y,m,p,C,B,P,J,R,T,E,V,K,L,N;b=[];f=g=t=0;n.autoUpdateMatrix&&n.updateMatrix();u.multiply(n.projectionMatrix,n.matrix);C=z.objects;h=0;for(o=C.length;h<o;h++){B=C[h];B.autoUpdateMatrix&&B.updateMatrix();P=B.matrix;J=B.rotationMatrix;R=B.material;T=B.overdraw;if(B instanceof THREE.Mesh){E=B.geometry.vertices;i=0;for(y=E.length;i<y;i++){V=E[i];V.positionWorld.copy(V.position);P.multiplyVector3(V.positionWorld);K=V.positionScreen;K.copy(V.positionWorld);
+u.multiplyVector4(K);K.multiplyScalar(1/K.w);V.__visible=K.z>0&&K.z<1}V=B.geometry.faces;i=0;for(y=V.length;i<y;i++){K=V[i];if(K instanceof THREE.Face3){m=E[K.a];p=E[K.b];L=E[K.c];if(m.__visible&&p.__visible&&L.__visible)if(B.doubleSided||B.flipSided!=(L.positionScreen.x-m.positionScreen.x)*(p.positionScreen.y-m.positionScreen.y)-(L.positionScreen.y-m.positionScreen.y)*(p.positionScreen.x-m.positionScreen.x)<0){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(m.positionWorld);d.v2.positionWorld.copy(p.positionWorld);
+d.v3.positionWorld.copy(L.positionWorld);d.v1.positionScreen.copy(m.positionScreen);d.v2.positionScreen.copy(p.positionScreen);d.v3.positionScreen.copy(L.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);L=K.vertexNormals;I=d.vertexNormalsWorld;m=0;for(p=L.length;m<p;m++){N=I[m]=I[m]||new THREE.Vector3;N.copy(L[m]);J.multiplyVector3(N)}d.z=
+d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(B.geometry.uvs[i]){d.uvs[0]=B.geometry.uvs[i][0];d.uvs[1]=B.geometry.uvs[i][1];d.uvs[2]=B.geometry.uvs[i][2]}b.push(d);f++}}else if(K instanceof THREE.Face4){m=E[K.a];p=E[K.b];L=E[K.c];N=E[K.d];if(m.__visible&&p.__visible&&L.__visible&&N.__visible)if(B.doubleSided||B.flipSided!=((N.positionScreen.x-m.positionScreen.x)*(p.positionScreen.y-m.positionScreen.y)-(N.positionScreen.y-m.positionScreen.y)*(p.positionScreen.x-m.positionScreen.x)<
+0||(p.positionScreen.x-L.positionScreen.x)*(N.positionScreen.y-L.positionScreen.y)-(p.positionScreen.y-L.positionScreen.y)*(N.positionScreen.x-L.positionScreen.x)<0)){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(m.positionWorld);d.v2.positionWorld.copy(p.positionWorld);d.v3.positionWorld.copy(N.positionWorld);d.v1.positionScreen.copy(m.positionScreen);d.v2.positionScreen.copy(p.positionScreen);d.v3.positionScreen.copy(N.positionScreen);d.normalWorld.copy(K.normal);J.multiplyVector3(d.normalWorld);
 d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(B.geometry.uvs[i]){d.uvs[0]=B.geometry.uvs[i][0];d.uvs[1]=B.geometry.uvs[i][1];d.uvs[2]=B.geometry.uvs[i][3]}b.push(d);f++;e=j[f]=j[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(p.positionWorld);e.v2.positionWorld.copy(L.positionWorld);e.v3.positionWorld.copy(N.positionWorld);
 d.centroidWorld.copy(K.centroid);P.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);u.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=K.material;d.overdraw=T;if(B.geometry.uvs[i]){d.uvs[0]=B.geometry.uvs[i][0];d.uvs[1]=B.geometry.uvs[i][1];d.uvs[2]=B.geometry.uvs[i][3]}b.push(d);f++;e=j[f]=j[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(p.positionWorld);e.v2.positionWorld.copy(L.positionWorld);e.v3.positionWorld.copy(N.positionWorld);
 e.v1.positionScreen.copy(p.positionScreen);e.v2.positionScreen.copy(L.positionScreen);e.v3.positionScreen.copy(N.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=R;e.faceMaterial=K.material;e.overdraw=T;if(B.geometry.uvs[i]){e.uvs[0]=B.geometry.uvs[i][1];e.uvs[1]=B.geometry.uvs[i][2];e.uvs[2]=B.geometry.uvs[i][3]}b.push(e);f++}}}}else if(B instanceof THREE.Line){v.multiply(u,P);E=B.geometry.vertices;
 e.v1.positionScreen.copy(p.positionScreen);e.v2.positionScreen.copy(L.positionScreen);e.v3.positionScreen.copy(N.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=R;e.faceMaterial=K.material;e.overdraw=T;if(B.geometry.uvs[i]){e.uvs[0]=B.geometry.uvs[i][1];e.uvs[1]=B.geometry.uvs[i][2];e.uvs[2]=B.geometry.uvs[i][3]}b.push(e);f++}}}}else if(B instanceof THREE.Line){v.multiply(u,P);E=B.geometry.vertices;
-V=E[0];V.positionScreen.copy(V.position);v.multiplyVector4(V.positionScreen);i=1;for(y=E.length;i<y;i++){l=E[i];l.positionScreen.copy(l.position);v.multiplyVector4(l.positionScreen);p=E[i-1];w.copy(l.positionScreen);H.copy(p.positionScreen);if(a(w,H)){w.multiplyScalar(1/w.w);H.multiplyScalar(1/H.w);k=m[g]=m[g]||new THREE.RenderableLine;k.v1.positionScreen.copy(w);k.v2.positionScreen.copy(H);k.z=Math.max(w.z,H.z);k.material=B.material;b.push(k);g++}}}else if(B instanceof THREE.Particle){r.set(B.position.x,
+V=E[0];V.positionScreen.copy(V.position);v.multiplyVector4(V.positionScreen);i=1;for(y=E.length;i<y;i++){m=E[i];m.positionScreen.copy(m.position);v.multiplyVector4(m.positionScreen);p=E[i-1];w.copy(m.positionScreen);H.copy(p.positionScreen);if(a(w,H)){w.multiplyScalar(1/w.w);H.multiplyScalar(1/H.w);k=l[g]=l[g]||new THREE.RenderableLine;k.v1.positionScreen.copy(w);k.v2.positionScreen.copy(H);k.z=Math.max(w.z,H.z);k.material=B.material;b.push(k);g++}}}else if(B instanceof THREE.Particle){r.set(B.position.x,
 B.position.y,B.position.z,1);u.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=A[t]=A[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=B.material;b.push(c);t++}}}b.sort(function(Y,Q){return Q.z-Y.z});return b};this.unprojectVector=function(z,n){var h=new THREE.Matrix4;
 B.position.y,B.position.z,1);u.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=A[t]=A[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=B.material;b.push(c);t++}}}b.sort(function(Y,Q){return Q.z-Y.z});return b};this.unprojectVector=function(z,n){var h=new THREE.Matrix4;
 h.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));h.multiplyVector3(z);return z}};
 h.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));h.multiplyVector3(z);return z}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var m,c,t,A,r,u,v,w;a=b.projectScene(k,g);m=0;for(c=a.length;m<c;m++){r=a[m];if(r instanceof THREE.RenderableParticle){v=r.x*f+f;w=r.y*j+j;t=0;for(A=r.material.length;t<A;t++){u=r.material[t];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=v+"px";u.style.top=w+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,f,j,k,g=d.getContext("2d"),m=1,c=0,t=null,A=null,r=1,u=Math.min,v=Math.max,w,H,I,z,n,h,o,i,y,l=new THREE.Color,p=new THREE.Color,C=new THREE.Color,B=new THREE.Color,P=new THREE.Color,J,R,T,E,V,K,L,N,Y,Q,M=new THREE.Rectangle,W=new THREE.Rectangle,q=new THREE.Rectangle,s=false,x=new THREE.Color,G=new THREE.Color,U=new THREE.Color,ba=new THREE.Color,ga=Math.PI*2,$=new THREE.Vector3,ka,pa,Da,da,qa,wa,
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var l,c,t,A,r,u,v,w;a=b.projectScene(k,g);l=0;for(c=a.length;l<c;l++){r=a[l];if(r instanceof THREE.RenderableParticle){v=r.x*f+f;w=r.y*j+j;t=0;for(A=r.material.length;t<A;t++){u=r.material[t];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=v+"px";u.style.top=w+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,f,j,k,g=d.getContext("2d"),l=1,c=0,t=null,A=null,r=1,u=Math.min,v=Math.max,w,H,I,z,n,h,o,i,y,m=new THREE.Color,p=new THREE.Color,C=new THREE.Color,B=new THREE.Color,P=new THREE.Color,J,R,T,E,V,K,L,N,Y,Q,M=new THREE.Rectangle,W=new THREE.Rectangle,q=new THREE.Rectangle,s=false,x=new THREE.Color,G=new THREE.Color,U=new THREE.Color,ba=new THREE.Color,ga=Math.PI*2,$=new THREE.Vector3,ka,pa,Da,da,qa,wa,
 na=16;ka=document.createElement("canvas");ka.width=ka.height=2;pa=ka.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Da=pa.getImageData(0,0,2,2);da=Da.data;qa=document.createElement("canvas");qa.width=qa.height=na;wa=qa.getContext("2d");wa.translate(-na/2,-na/2);wa.scale(na,na);na--;this.domElement=d;this.autoClear=true;this.setSize=function(ia,xa){e=ia;f=xa;j=e/2;k=f/2;d.width=e;d.height=f;M.set(-j,-k,j,k)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(M);g.clearRect(W.getX(),
 na=16;ka=document.createElement("canvas");ka.width=ka.height=2;pa=ka.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Da=pa.getImageData(0,0,2,2);da=Da.data;qa=document.createElement("canvas");qa.width=qa.height=na;wa=qa.getContext("2d");wa.translate(-na/2,-na/2);wa.scale(na,na);na--;this.domElement=d;this.autoClear=true;this.setSize=function(ia,xa){e=ia;f=xa;j=e/2;k=f/2;d.width=e;d.height=f;M.set(-j,-k,j,k)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(M);g.clearRect(W.getX(),
 W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ia,xa){function Ma(D){var X,S,F,O=D.lights;G.setRGB(0,0,0);U.setRGB(0,0,0);ba.setRGB(0,0,0);D=0;for(X=O.length;D<X;D++){S=O[D];F=S.color;if(S instanceof THREE.AmbientLight){G.r+=F.r;G.g+=F.g;G.b+=F.b}else if(S instanceof THREE.DirectionalLight){U.r+=F.r;U.g+=F.g;U.b+=F.b}else if(S instanceof THREE.PointLight){ba.r+=F.r;ba.g+=F.g;ba.b+=F.b}}}function ya(D,X,S,F){var O,Z,ca,ea,fa=D.lights;D=0;for(O=fa.length;D<O;D++){Z=fa[D];ca=Z.color;
 W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ia,xa){function Ma(D){var X,S,F,O=D.lights;G.setRGB(0,0,0);U.setRGB(0,0,0);ba.setRGB(0,0,0);D=0;for(X=O.length;D<X;D++){S=O[D];F=S.color;if(S instanceof THREE.AmbientLight){G.r+=F.r;G.g+=F.g;G.b+=F.b}else if(S instanceof THREE.DirectionalLight){U.r+=F.r;U.g+=F.g;U.b+=F.b}else if(S instanceof THREE.PointLight){ba.r+=F.r;ba.g+=F.g;ba.b+=F.b}}}function ya(D,X,S,F){var O,Z,ca,ea,fa=D.lights;D=0;for(O=fa.length;D<O;D++){Z=fa[D];ca=Z.color;
 ea=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}}}function Na(D,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;O=X.scale.x*j;Z=X.scale.y*k;S=O*ea;F=Z*fa;q.set(D.x-S,D.y-F,D.x+S,
 ea=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}}}function Na(D,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;O=X.scale.x*j;Z=X.scale.y*k;S=O*ea;F=Z*fa;q.set(D.x-S,D.y-F,D.x+S,
-D.y+F);if(M.instersects(q)){g.save();g.translate(D.x,D.y);g.rotate(-X.rotation);g.scale(O,-Z);g.translate(-ea,-fa);g.drawImage(ca,0,0);g.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+U.r+ba.r;x.g=G.g+U.g+ba.g;x.b=G.b+U.b+ba.b;l.r=S.color.r*x.r;l.g=S.color.g*x.g;l.b=S.color.b*x.b;l.updateStyleString()}else l.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*k;q.set(D.x-S,D.y-F,D.x+S,D.y+F);if(M.instersects(q)){O=l.__styleString;if(A!=O)g.fillStyle=A=O;g.save();
-g.translate(D.x,D.y);g.rotate(-X.rotation);g.scale(S,F);g.beginPath();g.arc(0,0,1,0,ga,true);g.closePath();g.fill();g.restore()}}}}function Oa(D,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);g.beginPath();g.moveTo(D.positionScreen.x,D.positionScreen.y);g.lineTo(X.positionScreen.x,X.positionScreen.y);g.closePath();if(F instanceof THREE.LineBasicMaterial){l.__styleString=F.color.__styleString;D=F.linewidth;if(r!=D)g.lineWidth=r=D;D=l.__styleString;if(t!=D)g.strokeStyle=t=D;g.stroke();q.inflate(F.linewidth*
+D.y+F);if(M.instersects(q)){g.save();g.translate(D.x,D.y);g.rotate(-X.rotation);g.scale(O,-Z);g.translate(-ea,-fa);g.drawImage(ca,0,0);g.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+U.r+ba.r;x.g=G.g+U.g+ba.g;x.b=G.b+U.b+ba.b;m.r=S.color.r*x.r;m.g=S.color.g*x.g;m.b=S.color.b*x.b;m.updateStyleString()}else m.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*k;q.set(D.x-S,D.y-F,D.x+S,D.y+F);if(M.instersects(q)){O=m.__styleString;if(A!=O)g.fillStyle=A=O;g.save();
+g.translate(D.x,D.y);g.rotate(-X.rotation);g.scale(S,F);g.beginPath();g.arc(0,0,1,0,ga,true);g.closePath();g.fill();g.restore()}}}}function Oa(D,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);g.beginPath();g.moveTo(D.positionScreen.x,D.positionScreen.y);g.lineTo(X.positionScreen.x,X.positionScreen.y);g.closePath();if(F instanceof THREE.LineBasicMaterial){m.__styleString=F.color.__styleString;D=F.linewidth;if(r!=D)g.lineWidth=r=D;D=m.__styleString;if(t!=D)g.strokeStyle=t=D;g.stroke();q.inflate(F.linewidth*
 2)}}}function Ia(D,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);z=D.positionScreen.x;n=D.positionScreen.y;h=X.positionScreen.x;o=X.positionScreen.y;i=S.positionScreen.x;y=S.positionScreen.y;g.beginPath();g.moveTo(z,n);g.lineTo(h,o);g.lineTo(i,y);g.lineTo(z,n);g.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&ra(z,n,h,o,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof
 2)}}}function Ia(D,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);z=D.positionScreen.x;n=D.positionScreen.y;h=X.positionScreen.x;o=X.positionScreen.y;i=S.positionScreen.x;y=S.positionScreen.y;g.beginPath();g.moveTo(z,n);g.lineTo(h,o);g.lineTo(i,y);g.lineTo(z,n);g.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&ra(z,n,h,o,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof
 THREE.SphericalReflectionMapping){D=xa.matrix;$.copy(F.vertexNormalsWorld[0]);V=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;K=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;N=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;Q=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;ra(z,n,h,o,i,y,O.env_map.image,V,K,L,N,Y,Q)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):
 THREE.SphericalReflectionMapping){D=xa.matrix;$.copy(F.vertexNormalsWorld[0]);V=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;K=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;N=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;Q=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;ra(z,n,h,o,i,y,O.env_map.image,V,K,L,N,Y,Q)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):
 Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&ra(z,n,h,o,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){p.r=C.r=B.r=G.r;p.g=C.g=B.g=G.g;p.b=C.b=B.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],p);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],C);ya(Z,
 Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&ra(z,n,h,o,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){p.r=C.r=B.r=G.r;p.g=C.g=B.g=G.g;p.b=C.b=B.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],p);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],C);ya(Z,
-F.v3.positionWorld,F.vertexNormalsWorld[2],B);P.r=(C.r+B.r)*0.5;P.g=(C.g+B.g)*0.5;P.b=(C.b+B.b)*0.5;E=Ja(p,C,B,P);ra(z,n,h,o,i,y,E,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);l.r=O.color.r*x.r;l.g=O.color.g*x.g;l.b=O.color.b*x.b;l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){J=O.__2near;
-R=O.__farPlusNear;T=O.__farMinusNear;p.r=p.g=p.b=1-J/(R-D.positionScreen.z*T);C.r=C.g=C.b=1-J/(R-X.positionScreen.z*T);B.r=B.g=B.b=1-J/(R-S.positionScreen.z*T);P.r=(C.r+B.r)*0.5;P.g=(C.g+B.g)*0.5;P.b=(C.b+B.b)*0.5;E=Ja(p,C,B,P);ra(z,n,h,o,i,y,E,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(F.normalWorld.x);l.g=Fa(F.normalWorld.y);l.b=Fa(F.normalWorld.z);l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}}}function Aa(D,X){if(t!=D)g.strokeStyle=
-t=D;if(r!=X)g.lineWidth=r=X;g.stroke();q.inflate(X*2)}function Ba(D){if(A!=D)g.fillStyle=A=D;g.fill()}function ra(D,X,S,F,O,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=D;F-=X;O-=D;Z-=X;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*O)*ja;la=(ua*F-la*Z)*ja;S=(sa*O-ta*S)*ja;F=(sa*Z-ta*F)*ja;D=D-ma*ea-S*fa;X=X-la*ea-F*fa;g.save();g.transform(ma,la,S,F,D,X);g.clip();g.drawImage(ca,0,0);g.restore()}function Ea(D){if(m!=D)g.globalAlpha=
-m=D}function za(D){if(c!=D){switch(D){case THREE.NormalBlending:g.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:g.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:g.globalCompositeOperation="darker"}c=D}}function Ja(D,X,S,F){da[0]=v(0,u(255,~~(D.r*255)));da[1]=v(0,u(255,~~(D.g*255)));da[2]=v(0,u(255,~~(D.b*255)));da[4]=v(0,u(255,~~(X.r*255)));da[5]=v(0,u(255,~~(X.g*255)));da[6]=v(0,u(255,~~(X.b*255)));da[8]=v(0,u(255,~~(S.r*255)));da[9]=v(0,u(255,
+F.v3.positionWorld,F.vertexNormalsWorld[2],B);P.r=(C.r+B.r)*0.5;P.g=(C.g+B.g)*0.5;P.b=(C.b+B.b)*0.5;E=Ja(p,C,B,P);ra(z,n,h,o,i,y,E,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);m.r=O.color.r*x.r;m.g=O.color.g*x.g;m.b=O.color.b*x.b;m.updateStyleString();O.wireframe?Aa(m.__styleString,O.wireframe_linewidth):Ba(m.__styleString)}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){J=O.__2near;
+R=O.__farPlusNear;T=O.__farMinusNear;p.r=p.g=p.b=1-J/(R-D.positionScreen.z*T);C.r=C.g=C.b=1-J/(R-X.positionScreen.z*T);B.r=B.g=B.b=1-J/(R-S.positionScreen.z*T);P.r=(C.r+B.r)*0.5;P.g=(C.g+B.g)*0.5;P.b=(C.b+B.b)*0.5;E=Ja(p,C,B,P);ra(z,n,h,o,i,y,E,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){m.r=Fa(F.normalWorld.x);m.g=Fa(F.normalWorld.y);m.b=Fa(F.normalWorld.z);m.updateStyleString();O.wireframe?Aa(m.__styleString,O.wireframe_linewidth):Ba(m.__styleString)}}}function Aa(D,X){if(t!=D)g.strokeStyle=
+t=D;if(r!=X)g.lineWidth=r=X;g.stroke();q.inflate(X*2)}function Ba(D){if(A!=D)g.fillStyle=A=D;g.fill()}function ra(D,X,S,F,O,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=D;F-=X;O-=D;Z-=X;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*O)*ja;la=(ua*F-la*Z)*ja;S=(sa*O-ta*S)*ja;F=(sa*Z-ta*F)*ja;D=D-ma*ea-S*fa;X=X-la*ea-F*fa;g.save();g.transform(ma,la,S,F,D,X);g.clip();g.drawImage(ca,0,0);g.restore()}function Ea(D){if(l!=D)g.globalAlpha=
+l=D}function za(D){if(c!=D){switch(D){case THREE.NormalBlending:g.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:g.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:g.globalCompositeOperation="darker"}c=D}}function Ja(D,X,S,F){da[0]=v(0,u(255,~~(D.r*255)));da[1]=v(0,u(255,~~(D.g*255)));da[2]=v(0,u(255,~~(D.b*255)));da[4]=v(0,u(255,~~(X.r*255)));da[5]=v(0,u(255,~~(X.g*255)));da[6]=v(0,u(255,~~(X.b*255)));da[8]=v(0,u(255,~~(S.r*255)));da[9]=v(0,u(255,
 ~~(S.g*255)));da[10]=v(0,u(255,~~(S.b*255)));da[12]=v(0,u(255,~~(F.r*255)));da[13]=v(0,u(255,~~(F.g*255)));da[14]=v(0,u(255,~~(F.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(D){return D<0?u((1+D)*0.5,0.5):0.5+u(D*0.5,0.5)}function Ga(D,X){var S=X.x-D.x,F=X.y-D.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;D.x-=S;D.y-=F}var Ca,Ka,aa,ha,oa,Ha,La,va;g.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0;
 ~~(S.g*255)));da[10]=v(0,u(255,~~(S.b*255)));da[12]=v(0,u(255,~~(F.r*255)));da[13]=v(0,u(255,~~(F.g*255)));da[14]=v(0,u(255,~~(F.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(D){return D<0?u((1+D)*0.5,0.5):0.5+u(D*0.5,0.5)}function Ga(D,X){var S=X.x-D.x,F=X.y-D.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;D.x-=S;D.y-=F}var Ca,Ka,aa,ha,oa,Ha,La,va;g.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0;
 for(Ka=a.length;Ca<Ka;Ca++){aa=a[Ca];q.empty();if(aa instanceof THREE.RenderableParticle){w=aa;w.x*=j;w.y*=k;ha=0;for(oa=aa.material.length;ha<oa;ha++)Na(w,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){w=aa.v1;H=aa.v2;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(q)){ha=0;for(oa=aa.material.length;ha<oa;)Oa(w,H,aa,aa.material[ha++],
 for(Ka=a.length;Ca<Ka;Ca++){aa=a[Ca];q.empty();if(aa instanceof THREE.RenderableParticle){w=aa;w.x*=j;w.y*=k;ha=0;for(oa=aa.material.length;ha<oa;ha++)Na(w,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){w=aa.v1;H=aa.v2;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(H.positionScreen.x,H.positionScreen.y);if(M.instersects(q)){ha=0;for(oa=aa.material.length;ha<oa;)Oa(w,H,aa,aa.material[ha++],
 ia)}}else if(aa instanceof THREE.RenderableFace3){w=aa.v1;H=aa.v2;I=aa.v3;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;if(aa.overdraw){Ga(w.positionScreen,H.positionScreen);Ga(H.positionScreen,I.positionScreen);Ga(I.positionScreen,w.positionScreen)}q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(H.positionScreen.x,H.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);if(M.instersects(q)){ha=
 ia)}}else if(aa instanceof THREE.RenderableFace3){w=aa.v1;H=aa.v2;I=aa.v3;w.positionScreen.x*=j;w.positionScreen.y*=k;H.positionScreen.x*=j;H.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;if(aa.overdraw){Ga(w.positionScreen,H.positionScreen);Ga(H.positionScreen,I.positionScreen);Ga(I.positionScreen,w.positionScreen)}q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(H.positionScreen.x,H.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);if(M.instersects(q)){ha=
 0;for(oa=aa.meshMaterial.length;ha<oa;){va=aa.meshMaterial[ha++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterial.length;Ha<La;)(va=aa.faceMaterial[Ha++])&&Ia(w,H,I,aa,va,ia)}else Ia(w,H,I,aa,va,ia)}}}W.addRectangle(q)}g.setTransform(1,0,0,1,0,0)}};
 0;for(oa=aa.meshMaterial.length;ha<oa;){va=aa.meshMaterial[ha++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterial.length;Ha<La;)(va=aa.faceMaterial[Ha++])&&Ia(w,H,I,aa,va,ia)}else Ia(w,H,I,aa,va,ia)}}}W.addRectangle(q)}g.setTransform(1,0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function a(K,L,N){var Y,Q,M,W;Y=0;for(Q=K.lights.length;Y<Q;Y++){M=K.lights[Y];if(M instanceof THREE.DirectionalLight){W=L.normalWorld.dot(M.position)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){p.sub(M.position,L.centroidWorld);p.normalize();W=L.normalWorld.dot(p)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(K,L,N,Y,Q,M){J=e(R++);J.setAttribute("d","M "+K.positionScreen.x+
 THREE.SVGRenderer=function(){function a(K,L,N){var Y,Q,M,W;Y=0;for(Q=K.lights.length;Y<Q;Y++){M=K.lights[Y];if(M instanceof THREE.DirectionalLight){W=L.normalWorld.dot(M.position)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){p.sub(M.position,L.centroidWorld);p.normalize();W=L.normalWorld.dot(p)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(K,L,N,Y,Q,M){J=e(R++);J.setAttribute("d","M "+K.positionScreen.x+
-" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(z){h.r=o.r;h.g=o.g;h.b=o.b;a(M,Y,h);n.r=Q.color.r*h.r;n.g=Q.color.g*h.g;n.b=Q.color.b*h.b;n.updateStyleString()}else n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){l=1-Q.__2near/(Q.__farPlusNear-Y.z*Q.__farMinusNear);
-n.setRGB(l,l,l)}else Q instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Y.normalWorld.x),f(Y.normalWorld.y),f(Y.normalWorld.z));Q.wireframe?J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):J.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+Q.opacity);g.appendChild(J)}function d(K,L,N,Y,Q,M,W){J=e(R++);J.setAttribute("d",
-"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(z){h.r=o.r;h.g=o.g;h.b=o.b;a(W,Q,h);n.r=M.color.r*h.r;n.g=M.color.g*h.g;n.b=M.color.b*h.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){l=
-1-M.__2near/(M.__farPlusNear-Q.z*M.__farMinusNear);n.setRGB(l,l,l)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));M.wireframe?J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):J.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(J)}
-function e(K){if(C[K]==null){C[K]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&C[K].setAttribute("shape-rendering","crispEdges");return C[K]}return C[K]}function f(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,t,A,r,u,v,w,H=new THREE.Rectangle,I=new THREE.Rectangle,z=false,n=new THREE.Color(16777215),h=new THREE.Color(16777215),o=new THREE.Color(0),i=new THREE.Color(0),
-y=new THREE.Color(0),l,p=new THREE.Vector3,C=[],B=[],P=[],J,R,T,E,V=1;this.domElement=g;this.autoClear=true;this.setQuality=function(K){switch(K){case "high":V=1;break;case "low":V=0}};this.setSize=function(K,L){m=K;c=L;t=m/2;A=c/2;g.setAttribute("viewBox",-t+" "+-A+" "+m+" "+c);g.setAttribute("width",m);g.setAttribute("height",c);H.set(-t,-A,t,A)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(K,L){var N,Y,Q,M,W,q,s,x;this.autoClear&&this.clear();
+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(z){h.r=o.r;h.g=o.g;h.b=o.b;a(M,Y,h);n.r=Q.color.r*h.r;n.g=Q.color.g*h.g;n.b=Q.color.b*h.b;n.updateStyleString()}else n.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){m=1-Q.__2near/(Q.__farPlusNear-Y.z*Q.__farMinusNear);
+n.setRGB(m,m,m)}else Q instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Y.normalWorld.x),f(Y.normalWorld.y),f(Y.normalWorld.z));Q.wireframe?J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):J.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+Q.opacity);g.appendChild(J)}function d(K,L,N,Y,Q,M,W){J=e(R++);J.setAttribute("d",
+"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(z){h.r=o.r;h.g=o.g;h.b=o.b;a(W,Q,h);n.r=M.color.r*h.r;n.g=M.color.g*h.g;n.b=M.color.b*h.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){m=
+1-M.__2near/(M.__farPlusNear-Q.z*M.__farMinusNear);n.setRGB(m,m,m)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));M.wireframe?J.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):J.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(J)}
+function e(K){if(C[K]==null){C[K]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&C[K].setAttribute("shape-rendering","crispEdges");return C[K]}return C[K]}function f(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,t,A,r,u,v,w,H=new THREE.Rectangle,I=new THREE.Rectangle,z=false,n=new THREE.Color(16777215),h=new THREE.Color(16777215),o=new THREE.Color(0),i=new THREE.Color(0),
+y=new THREE.Color(0),m,p=new THREE.Vector3,C=[],B=[],P=[],J,R,T,E,V=1;this.domElement=g;this.autoClear=true;this.setQuality=function(K){switch(K){case "high":V=1;break;case "low":V=0}};this.setSize=function(K,L){l=K;c=L;t=l/2;A=c/2;g.setAttribute("viewBox",-t+" "+-A+" "+l+" "+c);g.setAttribute("width",l);g.setAttribute("height",c);H.set(-t,-A,t,A)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(K,L){var N,Y,Q,M,W,q,s,x;this.autoClear&&this.clear();
 j=k.projectScene(K,L);E=T=R=0;if(z=K.lights.length>0){s=K.lights;o.setRGB(0,0,0);i.setRGB(0,0,0);y.setRGB(0,0,0);N=0;for(Y=s.length;N<Y;N++){Q=s[N];M=Q.color;if(Q instanceof THREE.AmbientLight){o.r+=M.r;o.g+=M.g;o.b+=M.b}else if(Q instanceof THREE.DirectionalLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(Q instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}N=0;for(Y=j.length;N<Y;N++){s=j[N];I.empty();if(s instanceof THREE.RenderableParticle){r=s;r.x*=t;r.y*=-A;Q=0;for(M=s.material.length;Q<M;Q++)if(x=
 j=k.projectScene(K,L);E=T=R=0;if(z=K.lights.length>0){s=K.lights;o.setRGB(0,0,0);i.setRGB(0,0,0);y.setRGB(0,0,0);N=0;for(Y=s.length;N<Y;N++){Q=s[N];M=Q.color;if(Q instanceof THREE.AmbientLight){o.r+=M.r;o.g+=M.g;o.b+=M.b}else if(Q instanceof THREE.DirectionalLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(Q instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}N=0;for(Y=j.length;N<Y;N++){s=j[N];I.empty();if(s instanceof THREE.RenderableParticle){r=s;r.x*=t;r.y*=-A;Q=0;for(M=s.material.length;Q<M;Q++)if(x=
 s.material[Q]){W=r;q=s;x=x;var G=T++;if(B[G]==null){B[G]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&B[G].setAttribute("shape-rendering","crispEdges")}J=B[G];J.setAttribute("cx",W.x);J.setAttribute("cy",W.y);J.setAttribute("r",q.scale.x*t);if(x instanceof THREE.ParticleCircleMaterial){if(z){h.r=o.r+i.r+y.r;h.g=o.g+i.g+y.g;h.b=o.b+i.b+y.b;n.r=x.color.r*h.r;n.g=x.color.g*h.g;n.b=x.color.b*h.b;n.updateStyleString()}else n=x.color;J.setAttribute("style","fill: "+n.__styleString)}g.appendChild(J)}}else if(s instanceof
 s.material[Q]){W=r;q=s;x=x;var G=T++;if(B[G]==null){B[G]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&B[G].setAttribute("shape-rendering","crispEdges")}J=B[G];J.setAttribute("cx",W.x);J.setAttribute("cy",W.y);J.setAttribute("r",q.scale.x*t);if(x instanceof THREE.ParticleCircleMaterial){if(z){h.r=o.r+i.r+y.r;h.g=o.g+i.g+y.g;h.b=o.b+i.b+y.b;n.r=x.color.r*h.r;n.g=x.color.g*h.g;n.b=x.color.b*h.b;n.updateStyleString()}else n=x.color;J.setAttribute("style","fill: "+n.__styleString)}g.appendChild(J)}}else if(s instanceof
 THREE.RenderableLine){r=s.v1;u=s.v2;r.positionScreen.x*=t;r.positionScreen.y*=-A;u.positionScreen.x*=t;u.positionScreen.y*=-A;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.material.length;Q<M;)if(x=s.material[Q++]){W=r;q=u;x=x;G=E++;if(P[G]==null){P[G]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&P[G].setAttribute("shape-rendering","crispEdges")}J=P[G];J.setAttribute("x1",W.positionScreen.x);
 THREE.RenderableLine){r=s.v1;u=s.v2;r.positionScreen.x*=t;r.positionScreen.y*=-A;u.positionScreen.x*=t;u.positionScreen.y*=-A;I.addPoint(r.positionScreen.x,r.positionScreen.y);I.addPoint(u.positionScreen.x,u.positionScreen.y);if(H.instersects(I)){Q=0;for(M=s.material.length;Q<M;)if(x=s.material[Q++]){W=r;q=u;x=x;G=E++;if(P[G]==null){P[G]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&P[G].setAttribute("shape-rendering","crispEdges")}J=P[G];J.setAttribute("x1",W.positionScreen.x);
@@ -132,11 +132,11 @@ THREE.MeshFaceMaterial){W=0;for(q=s.faceMaterial.length;W<q;)(x=s.faceMaterial[W
 THREE.WebGLRenderer=function(a){function b(h,o){var i=c.createProgram();c.attachShader(i,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+h));c.attachShader(i,k("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+o));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,
 THREE.WebGLRenderer=function(a){function b(h,o){var i=c.createProgram();c.attachShader(i,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+h));c.attachShader(i,k("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+o));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,
 c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,o){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,
 c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,o){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,
 c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}function e(h,o){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,
 c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}function e(h,o){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,
-h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function f(h,o){var i,y,l;
-i=0;for(y=o.length;i<y;i++){l=o[i];h.uniforms[l]=c.getUniformLocation(h,l)}}function j(h,o){var i,y,l;i=0;for(y=o.length;i<y;i++){l=o[i];h.attributes[l]=c.getAttribLocation(h,l);h.attributes[l]>=0&&c.enableVertexAttribArray(h.attributes[l])}}function k(h,o){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER);c.shaderSource(i,o);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}
+h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function f(h,o){var i,y,m;
+i=0;for(y=o.length;i<y;i++){m=o[i];h.uniforms[m]=c.getUniformLocation(h,m)}}function j(h,o){var i,y,m;i=0;for(y=o.length;i<y;i++){m=o[i];h.attributes[m]=c.getAttribLocation(h,m);h.attributes[m]>=0&&c.enableVertexAttribArray(h.attributes[m])}}function k(h,o){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER);c.shaderSource(i,o);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}
 function g(h){switch(h){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}
 function g(h){switch(h){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}
-var m=document.createElement("canvas"),c,t,A,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),H=new Float32Array(16),I=new Float32Array(9),z=new Float32Array(16);a=function(h,o){if(h){var i,y,l,p=pointLights=maxDirLights=maxPointLights=0;i=0;for(y=h.lights.length;i<y;i++){l=h.lights[i];l instanceof THREE.DirectionalLight&&p++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+p<=o){maxDirLights=p;maxPointLights=pointLights}else{maxDirLights=Math.ceil(o*p/(pointLights+p));
-maxPointLights=o-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:o-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(n){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);
+var l=document.createElement("canvas"),c,t,A,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),H=new Float32Array(16),I=new Float32Array(9),z=new Float32Array(16);a=function(h,o){if(h){var i,y,m,p=pointLights=maxDirLights=maxPointLights=0;i=0;for(y=h.lights.length;i<y;i++){m=h.lights[i];m instanceof THREE.DirectionalLight&&p++;m instanceof THREE.PointLight&&pointLights++}if(pointLights+p<=o){maxDirLights=p;maxPointLights=pointLights}else{maxDirLights=Math.ceil(o*p/(pointLights+p));
+maxPointLights=o-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:o-1}}(a,4);this.domElement=l;this.autoClear=true;try{c=l.getContext("experimental-webgl",{antialias:true})}catch(n){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);
 c.clearColor(0,0,0,0);t=A=function(h,o){var i=[h?"#define MAX_DIR_LIGHTS "+h:"",o?"#define MAX_POINT_LIGHTS "+o:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",h?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",o?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",o?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":
 c.clearColor(0,0,0,0);t=A=function(h,o){var i=[h?"#define MAX_DIR_LIGHTS "+h:"",o?"#define MAX_POINT_LIGHTS "+o:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",h?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",o?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",o?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":
 "","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 "","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",o?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",h?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",h?"}":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",o?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",h?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",h?"}":"",o?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",o?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",o?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
@@ -148,65 +148,65 @@ o?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",o?"vec4 pointSpecular =
 "",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse  += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;":
 "",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse  += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",o?"totalLight += pointDiffuse + pointSpecular;":
 "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
 "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
 i=b(y,i);c.useProgram(i);f(i,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);h&&f(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&f(i,["pointLightNumber","pointLightColor",
 i=b(y,i);c.useProgram(i);f(i,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);h&&f(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);o&&f(i,["pointLightNumber","pointLightColor",
-"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);j(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,o){m.width=h;m.height=o;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,o){var i,y,l,p,C,B=[],
-P=[],J=[];p=[];C=[];c.uniform1i(h.uniforms.enableLighting,o.length);i=0;for(y=o.length;i<y;i++){l=o[i];if(l instanceof THREE.AmbientLight)B.push(l);else if(l instanceof THREE.DirectionalLight)J.push(l);else l instanceof THREE.PointLight&&P.push(l)}i=l=p=C=0;for(y=B.length;i<y;i++){l+=B[i].color.r;p+=B[i].color.g;C+=B[i].color.b}c.uniform3f(h.uniforms.ambientLightColor,l,p,C);p=[];C=[];i=0;for(y=J.length;i<y;i++){l=J[i];p.push(l.color.r*l.intensity);p.push(l.color.g*l.intensity);p.push(l.color.b*l.intensity);
-C.push(l.position.x);C.push(l.position.y);C.push(l.position.z)}if(J.length){c.uniform1i(h.uniforms.directionalLightNumber,J.length);c.uniform3fv(h.uniforms.directionalLightDirection,C);c.uniform3fv(h.uniforms.directionalLightColor,p)}p=[];C=[];i=0;for(y=P.length;i<y;i++){l=P[i];p.push(l.color.r*l.intensity);p.push(l.color.g*l.intensity);p.push(l.color.b*l.intensity);C.push(l.position.x);C.push(l.position.y);C.push(l.position.z)}if(P.length){c.uniform1i(h.uniforms.pointLightNumber,P.length);c.uniform3fv(h.uniforms.pointLightPosition,
-C);c.uniform3fv(h.uniforms.pointLightColor,p)}};this.createBuffers=function(h,o){var i,y,l,p,C,B,P,J,R=[],T=[],E=[],V=[],K=[],L=0,N=h.geometry.geometryChunks[o],Y;l=false;i=0;for(y=h.material.length;i<y;i++){meshMaterial=h.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){C=0;for(Y=N.material.length;C<Y;C++)if(N.material[C]&&N.material[C].shading!=undefined&&N.material[C].shading==THREE.SmoothShading){l=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
-THREE.SmoothShading){l=true;break}if(l)break}Y=l;i=0;for(y=N.faces.length;i<y;i++){l=N.faces[i];p=h.geometry.faces[l];C=p.vertexNormals;faceNormal=p.normal;l=h.geometry.uvs[l];if(p instanceof THREE.Face3){B=h.geometry.vertices[p.a].position;P=h.geometry.vertices[p.b].position;J=h.geometry.vertices[p.c].position;E.push(B.x,B.y,B.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);if(C.length==3&&Y)for(p=0;p<3;p++)V.push(C[p].x,C[p].y,C[p].z);else for(p=0;p<3;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);
-if(l)for(p=0;p<3;p++)K.push(l[p].u,l[p].v);R.push(L,L+1,L+2);T.push(L,L+1);T.push(L,L+2);T.push(L+1,L+2);L+=3}else if(p instanceof THREE.Face4){B=h.geometry.vertices[p.a].position;P=h.geometry.vertices[p.b].position;J=h.geometry.vertices[p.c].position;p=h.geometry.vertices[p.d].position;E.push(B.x,B.y,B.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);E.push(p.x,p.y,p.z);if(C.length==4&&Y)for(p=0;p<4;p++)V.push(C[p].x,C[p].y,C[p].z);else for(p=0;p<4;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(l)for(p=
-0;p<4;p++)K.push(l[p].u,l[p].v);R.push(L,L+1,L+2);R.push(L,L+2,L+3);T.push(L,L+1);T.push(L,L+2);T.push(L,L+3);T.push(L+1,L+2);T.push(L+2,L+3);L+=4}}if(E.length){N.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(E),c.STATIC_DRAW);N.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);if(K.length>0){N.__webGLUVBuffer=c.createBuffer();
+"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);j(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,o){l.width=h;l.height=o;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,o){var i,y,m,p,C,B=[],
+P=[],J=[];p=[];C=[];c.uniform1i(h.uniforms.enableLighting,o.length);i=0;for(y=o.length;i<y;i++){m=o[i];if(m instanceof THREE.AmbientLight)B.push(m);else if(m instanceof THREE.DirectionalLight)J.push(m);else m instanceof THREE.PointLight&&P.push(m)}i=m=p=C=0;for(y=B.length;i<y;i++){m+=B[i].color.r;p+=B[i].color.g;C+=B[i].color.b}c.uniform3f(h.uniforms.ambientLightColor,m,p,C);p=[];C=[];i=0;for(y=J.length;i<y;i++){m=J[i];p.push(m.color.r*m.intensity);p.push(m.color.g*m.intensity);p.push(m.color.b*m.intensity);
+C.push(m.position.x);C.push(m.position.y);C.push(m.position.z)}if(J.length){c.uniform1i(h.uniforms.directionalLightNumber,J.length);c.uniform3fv(h.uniforms.directionalLightDirection,C);c.uniform3fv(h.uniforms.directionalLightColor,p)}p=[];C=[];i=0;for(y=P.length;i<y;i++){m=P[i];p.push(m.color.r*m.intensity);p.push(m.color.g*m.intensity);p.push(m.color.b*m.intensity);C.push(m.position.x);C.push(m.position.y);C.push(m.position.z)}if(P.length){c.uniform1i(h.uniforms.pointLightNumber,P.length);c.uniform3fv(h.uniforms.pointLightPosition,
+C);c.uniform3fv(h.uniforms.pointLightColor,p)}};this.createBuffers=function(h,o){var i,y,m,p,C,B,P,J,R=[],T=[],E=[],V=[],K=[],L=0,N=h.geometry.geometryChunks[o],Y;m=false;i=0;for(y=h.material.length;i<y;i++){meshMaterial=h.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){C=0;for(Y=N.material.length;C<Y;C++)if(N.material[C]&&N.material[C].shading!=undefined&&N.material[C].shading==THREE.SmoothShading){m=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
+THREE.SmoothShading){m=true;break}if(m)break}Y=m;i=0;for(y=N.faces.length;i<y;i++){m=N.faces[i];p=h.geometry.faces[m];C=p.vertexNormals;faceNormal=p.normal;m=h.geometry.uvs[m];if(p instanceof THREE.Face3){B=h.geometry.vertices[p.a].position;P=h.geometry.vertices[p.b].position;J=h.geometry.vertices[p.c].position;E.push(B.x,B.y,B.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);if(C.length==3&&Y)for(p=0;p<3;p++)V.push(C[p].x,C[p].y,C[p].z);else for(p=0;p<3;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);
+if(m)for(p=0;p<3;p++)K.push(m[p].u,m[p].v);R.push(L,L+1,L+2);T.push(L,L+1);T.push(L,L+2);T.push(L+1,L+2);L+=3}else if(p instanceof THREE.Face4){B=h.geometry.vertices[p.a].position;P=h.geometry.vertices[p.b].position;J=h.geometry.vertices[p.c].position;p=h.geometry.vertices[p.d].position;E.push(B.x,B.y,B.z);E.push(P.x,P.y,P.z);E.push(J.x,J.y,J.z);E.push(p.x,p.y,p.z);if(C.length==4&&Y)for(p=0;p<4;p++)V.push(C[p].x,C[p].y,C[p].z);else for(p=0;p<4;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(m)for(p=
+0;p<4;p++)K.push(m[p].u,m[p].v);R.push(L,L+1,L+2);R.push(L,L+2,L+3);T.push(L,L+1);T.push(L,L+2);T.push(L,L+3);T.push(L+1,L+2);T.push(L+2,L+3);L+=4}}if(E.length){N.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(E),c.STATIC_DRAW);N.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);if(K.length>0){N.__webGLUVBuffer=c.createBuffer();
 c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=R.length;N.__webGLLineCount=T.length}};this.renderBuffer=
 c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=R.length;N.__webGLLineCount=T.length}};this.renderBuffer=
-function(h,o,i,y){var l,p,C,B,P,J,R,T,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)R.push(E);f(i.program,R);j(i.program,["position","normal","uv"])}E=i.program}else E=A;if(E!=t){c.useProgram(E);t=E}E==A&&this.setupLights(E,o);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){C=i.wireframe;
-B=i.wireframe_linewidth;h=E;o=i.uniforms;var V;for(l in o){T=o[l].type;R=o[l].value;V=h.uniforms[l];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);if(T=o[l].texture)T.image instanceof Array&&T.image.length==6?d(T,R):e(T,R)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){l=i.color;p=i.opacity;C=i.wireframe;B=i.wireframe_linewidth;P=i.map;J=i.env_map;o=i.combine==THREE.MixOperation;
-h=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;R=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,l.r*p,l.g*p,l.b*p,p);c.uniform1i(E.uniforms.mixEnvMap,o);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract,T);c.uniform1f(E.uniforms.mRefractionRatio,R)}if(i instanceof THREE.MeshNormalMaterial){p=i.opacity;c.uniform1f(E.uniforms.mOpacity,p);c.uniform1i(E.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){p=i.opacity;C=i.wireframe;
-B=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,p);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){l=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,l.r,l.g,l.b,p);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,p);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof
+function(h,o,i,y){var m,p,C,B,P,J,R,T,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)R.push(E);f(i.program,R);j(i.program,["position","normal","uv"])}E=i.program}else E=A;if(E!=t){c.useProgram(E);t=E}E==A&&this.setupLights(E,o);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){C=i.wireframe;
+B=i.wireframe_linewidth;h=E;o=i.uniforms;var V;for(m in o){T=o[m].type;R=o[m].value;V=h.uniforms[m];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);if(T=o[m].texture)T.image instanceof Array&&T.image.length==6?d(T,R):e(T,R)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){m=i.color;p=i.opacity;C=i.wireframe;B=i.wireframe_linewidth;P=i.map;J=i.env_map;o=i.combine==THREE.MixOperation;
+h=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;R=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,m.r*p,m.g*p,m.b*p,p);c.uniform1i(E.uniforms.mixEnvMap,o);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract,T);c.uniform1f(E.uniforms.mRefractionRatio,R)}if(i instanceof THREE.MeshNormalMaterial){p=i.opacity;c.uniform1f(E.uniforms.mOpacity,p);c.uniform1i(E.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){p=i.opacity;C=i.wireframe;
+B=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,p);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){m=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,m.r,m.g,m.b,p);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,p);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof
 THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);J=i.env_map}if(P){e(P,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(J){d(J,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);p=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,
 THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);J=i.env_map}if(P){e(P,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(J){d(J,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);p=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,
 y.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,y.__webGLNormalBuffer);c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);if(p.uv>=0)if(y.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.enableVertexAttribArray(p.uv);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(p.uv);if(C){c.lineWidth(B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);c.drawElements(c.LINES,y.__webGLLineCount,c.UNSIGNED_SHORT,
 y.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,y.__webGLNormalBuffer);c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);if(p.uv>=0)if(y.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.enableVertexAttribArray(p.uv);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(p.uv);if(C){c.lineWidth(B);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);c.drawElements(c.LINES,y.__webGLLineCount,c.UNSIGNED_SHORT,
-0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,y.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,o,i,y,l,p){var C,B,P,J,R;P=0;for(J=i.material.length;P<J;P++){C=i.material[P];if(C instanceof THREE.MeshFaceMaterial){C=0;for(B=y.material.length;C<B;C++)if((R=y.material[C])&&R.blending==l&&R.opacity<1==p){this.setBlending(R.blending);this.renderBuffer(h,o,R,y)}}else if((R=C)&&R.blending==l&&R.opacity<1==p){this.setBlending(R.blending);this.renderBuffer(h,
-o,R,y)}}};this.render=function(h,o){var i,y,l,p,C=h.lights;this.initWebGLObjects(h);this.autoClear&&this.clear();o.autoUpdateMatrix&&o.updateMatrix();i=0;for(y=h.__webGLObjects.length;i<y;i++){l=h.__webGLObjects[i];p=l.object;l=l.buffer;if(p.visible){this.setupMatrices(p,o);this.renderPass(o,C,p,l,THREE.NormalBlending,false)}}i=0;for(y=h.__webGLObjects.length;i<y;i++){l=h.__webGLObjects[i];p=l.object;l=l.buffer;if(p.visible){this.setupMatrices(p,o);this.renderPass(o,C,p,l,THREE.AdditiveBlending,false);
-this.renderPass(o,C,p,l,THREE.SubtractiveBlending,false);this.renderPass(o,C,p,l,THREE.AdditiveBlending,true);this.renderPass(o,C,p,l,THREE.SubtractiveBlending,true);this.renderPass(o,C,p,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(h){var o,i,y,l,p,C;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}o=0;for(i=h.objects.length;o<i;o++){y=h.objects[o];if(h.__webGLObjectsMap[y.id]==undefined)h.__webGLObjectsMap[y.id]={};C=h.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh)for(p in y.geometry.geometryChunks){l=
-y.geometry.geometryChunks[p];l.__webGLVertexBuffer||this.createBuffers(y,p);if(C[p]==undefined){l={buffer:l,object:y};h.__webGLObjects.push(l);C[p]=1}}}};this.removeObject=function(h,o){var i,y;for(i=h.__webGLObjects.length-1;i>=0;i--){y=h.__webGLObjects[i].object;o==y&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,o){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(o.matrix,h.matrix);v.set(o.matrix.flatten());w.set(r.flatten());H.set(o.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();
+0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,y.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,o,i,y,m,p){var C,B,P,J,R;P=0;for(J=i.material.length;P<J;P++){C=i.material[P];if(C instanceof THREE.MeshFaceMaterial){C=0;for(B=y.material.length;C<B;C++)if((R=y.material[C])&&R.blending==m&&R.opacity<1==p){this.setBlending(R.blending);this.renderBuffer(h,o,R,y)}}else if((R=C)&&R.blending==m&&R.opacity<1==p){this.setBlending(R.blending);this.renderBuffer(h,
+o,R,y)}}};this.render=function(h,o){var i,y,m,p,C=h.lights;this.initWebGLObjects(h);this.autoClear&&this.clear();o.autoUpdateMatrix&&o.updateMatrix();i=0;for(y=h.__webGLObjects.length;i<y;i++){m=h.__webGLObjects[i];p=m.object;m=m.buffer;if(p.visible){this.setupMatrices(p,o);this.renderPass(o,C,p,m,THREE.NormalBlending,false)}}i=0;for(y=h.__webGLObjects.length;i<y;i++){m=h.__webGLObjects[i];p=m.object;m=m.buffer;if(p.visible){this.setupMatrices(p,o);this.renderPass(o,C,p,m,THREE.AdditiveBlending,false);
+this.renderPass(o,C,p,m,THREE.SubtractiveBlending,false);this.renderPass(o,C,p,m,THREE.AdditiveBlending,true);this.renderPass(o,C,p,m,THREE.SubtractiveBlending,true);this.renderPass(o,C,p,m,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(h){var o,i,y,m,p,C;if(!h.__webGLObjects){h.__webGLObjects=[];h.__webGLObjectsMap={}}o=0;for(i=h.objects.length;o<i;o++){y=h.objects[o];if(h.__webGLObjectsMap[y.id]==undefined)h.__webGLObjectsMap[y.id]={};C=h.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh)for(p in y.geometry.geometryChunks){m=
+y.geometry.geometryChunks[p];m.__webGLVertexBuffer||this.createBuffers(y,p);if(C[p]==undefined){m={buffer:m,object:y};h.__webGLObjects.push(m);C[p]=1}}}};this.removeObject=function(h,o){var i,y;for(i=h.__webGLObjects.length-1;i>=0;i--){y=h.__webGLObjects[i].object;o==y&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,o){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(o.matrix,h.matrix);v.set(o.matrix.flatten());w.set(r.flatten());H.set(o.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();
 I.set(u.m);z.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,H);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,z)};this.loadCamera=function(h,o){c.uniform3f(h.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
 I.set(u.m);z.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,H);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,z)};this.loadCamera=function(h,o){c.uniform3f(h.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
 c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,o){if(h){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};
 c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,o){if(h){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
-var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,j=a.vertices,k=f.vertices,g=a.faces,m=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var t=0,A=k.length;t<A;t++){var r=new THREE.Vertex(k[t].position.clone());d&&b.matrix.multiplyVector3(r.position);j.push(r)}t=0;for(A=m.length;t<A;t++){k=m[t];var u,v=k.vertexNormals;if(k instanceof THREE.Face3)u=new THREE.Face3(k.a+e,k.b+e,k.c+e);else if(k instanceof THREE.Face4)u=new THREE.Face4(k.a+e,k.b+
+var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,j=a.vertices,k=f.vertices,g=a.faces,l=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var t=0,A=k.length;t<A;t++){var r=new THREE.Vertex(k[t].position.clone());d&&b.matrix.multiplyVector3(r.position);j.push(r)}t=0;for(A=l.length;t<A;t++){k=l[t];var u,v=k.vertexNormals;if(k instanceof THREE.Face3)u=new THREE.Face3(k.a+e,k.b+e,k.c+e);else if(k instanceof THREE.Face4)u=new THREE.Face4(k.a+e,k.b+
 e,k.c+e,k.d+e);u.centroid.copy(k.centroid);u.normal.copy(k.normal);d=0;for(j=v.length;d<j;d++){r=v[d];u.vertexNormals.push(r.clone())}u.material=k.material.slice();g.push(u)}t=0;for(A=f.length;t<A;t++){e=f[t];g=[];d=0;for(j=e.length;d<j;d++)g.push(new THREE.UV(e[d].u,e[d].v));c.push(g)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
 e,k.c+e,k.d+e);u.centroid.copy(k.centroid);u.normal.copy(k.normal);d=0;for(j=v.length;d<j;d++){r=v[d];u.vertexNormals.push(r.clone())}u.material=k.material.slice();g.push(u)}t=0;for(A=f.length;t<A;t++){e=f[t];g=[];d=0;for(j=e.length;d<j;d++)g.push(new THREE.UV(e[d].u,e[d].v));c.push(g)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
-new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,f,j,k,g,m,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=f;b.position.z=j;b.rotation.x=k;b.rotation.y=g;b.rotation.z=m;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,
+new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,f,j,k,g,l,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=f;b.position.z=j;b.rotation.x=k;b.rotation.y=g;b.rotation.z=l;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,
 b,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])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
 b,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])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
 return mesh},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var f=Math.PI/2,j=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,f,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,
 return mesh},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var f=Math.PI/2,j=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,f,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,
 b,1,0,-e,0,-f,0,j,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}",
 b,1,0,-e,0,-f,0,j,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}",
 vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"}}},
 vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"}}},
-Cube=function(a,b,d,e,f,j,k,g){function m(w,H,I,z,n,h,o,i){var y=e||1,l=f||1,p=y+1,C=l+1;n=n/y;h=h/l;var B=c.vertices.length,P;if(w=="x"&&H=="y"||w=="y"&&H=="x")P="z";else if(w=="x"&&H=="z"||w=="z"&&H=="x")P="y";else if(w=="z"&&H=="y"||w=="y"&&H=="z")P="x";for(iy=0;iy<C;iy++)for(ix=0;ix<p;ix++){var J=new THREE.Vector3;J[w]=(ix*n-t)*I;J[H]=(iy*h-A)*z;J[P]=o;c.vertices.push(new THREE.Vertex(J))}for(iy=0;iy<l;iy++)for(ix=0;ix<y;ix++){c.faces.push(new THREE.Face4(ix+p*iy+B,ix+p*(iy+1)+B,ix+1+p*(iy+1)+
-B,ix+1+p*iy+B,null,i));c.uvs.push([new THREE.UV(ix/y,iy/l),new THREE.UV(ix/y,(iy+1)/l),new THREE.UV((ix+1)/y,(iy+1)/l),new THREE.UV((ix+1)/y,iy/l)])}}THREE.Geometry.call(this);var c=this,t=a/2,A=b/2,r=d/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([j])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(g!=undefined)for(var v in g)if(this.sides[v]!=undefined)this.sides[v]=g[v];this.sides.px&&
-m("z","y",1*k,-1,d,b,-t,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,d,b,t,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,d,A,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,d,-A,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,b,r,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,b,-r,this.materials[5]);(function(){for(var w=[],H=[],I=0,z=c.vertices.length;I<z;I++){for(var n=c.vertices[I],h=false,o=0,i=w.length;o<i;o++){var y=w[o];if(n.position.x==y.position.x&&n.position.y==
+Cube=function(a,b,d,e,f,j,k,g){function l(w,H,I,z,n,h,o,i){var y=e||1,m=f||1,p=y+1,C=m+1;n=n/y;h=h/m;var B=c.vertices.length,P;if(w=="x"&&H=="y"||w=="y"&&H=="x")P="z";else if(w=="x"&&H=="z"||w=="z"&&H=="x")P="y";else if(w=="z"&&H=="y"||w=="y"&&H=="z")P="x";for(iy=0;iy<C;iy++)for(ix=0;ix<p;ix++){var J=new THREE.Vector3;J[w]=(ix*n-t)*I;J[H]=(iy*h-A)*z;J[P]=o;c.vertices.push(new THREE.Vertex(J))}for(iy=0;iy<m;iy++)for(ix=0;ix<y;ix++){c.faces.push(new THREE.Face4(ix+p*iy+B,ix+p*(iy+1)+B,ix+1+p*(iy+1)+
+B,ix+1+p*iy+B,null,i));c.uvs.push([new THREE.UV(ix/y,iy/m),new THREE.UV(ix/y,(iy+1)/m),new THREE.UV((ix+1)/y,(iy+1)/m),new THREE.UV((ix+1)/y,iy/m)])}}THREE.Geometry.call(this);var c=this,t=a/2,A=b/2,r=d/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var u=0;u<6;u++)this.materials.push([j])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(g!=undefined)for(var v in g)if(this.sides[v]!=undefined)this.sides[v]=g[v];this.sides.px&&
+l("z","y",1*k,-1,d,b,-t,this.materials[0]);this.sides.nx&&l("z","y",-1*k,-1,d,b,t,this.materials[1]);this.sides.py&&l("x","z",1*k,1,a,d,A,this.materials[2]);this.sides.ny&&l("x","z",1*k,-1,a,d,-A,this.materials[3]);this.sides.pz&&l("x","y",1*k,-1,a,b,r,this.materials[4]);this.sides.nz&&l("x","y",-1*k,-1,a,b,-r,this.materials[5]);(function(){for(var w=[],H=[],I=0,z=c.vertices.length;I<z;I++){for(var n=c.vertices[I],h=false,o=0,i=w.length;o<i;o++){var y=w[o];if(n.position.x==y.position.x&&n.position.y==
 y.position.y&&n.position.z==y.position.z){H[I]=o;h=true;break}}if(!h){H[I]=w.length;w.push(new THREE.Vertex(n.position.clone()))}}I=0;for(z=c.faces.length;I<z;I++){n=c.faces[I];n.a=H[n.a];n.b=H[n.b];n.c=H[n.c];n.d=H[n.d]}c.vertices=w})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 y.position.y&&n.position.z==y.position.z){H[I]=o;h=true;break}}if(!h){H[I]=w.length;w.push(new THREE.Vertex(n.position.clone()))}}I=0;for(z=c.faces.length;I<z;I++){n=c.faces[I];n.a=H[n.a];n.b=H[n.b];n.c=H[n.c];n.d=H[n.d]}c.vertices=w})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,b,d,e,f){function j(c,t,A){k.vertices.push(new THREE.Vertex(new THREE.Vector3(c,t,A)))}THREE.Geometry.call(this);var k=this,g=Math.PI,m;for(m=0;m<a;m++)j(Math.sin(2*g*m/a)*b,Math.cos(2*g*m/a)*b,0);for(m=0;m<a;m++)j(Math.sin(2*g*m/a)*d,Math.cos(2*g*m/a)*d,e);for(m=0;m<a;m++)k.faces.push(new THREE.Face4(m,m+a,a+(m+1)%a,(m+1)%a));if(d!=0){j(0,0,-f);for(m=a;m<a+a/2;m++)k.faces.push(new THREE.Face4(2*a,(2*m-2*a)%a,(2*m-2*a+1)%a,(2*m-2*a+2)%a))}if(b!=0){j(0,0,e+f);for(m=a+a/2;m<
-2*a;m++)k.faces.push(new THREE.Face4((2*m-2*a+2)%a+a,(2*m-2*a+1)%a+a,(2*m-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,b,d,e){THREE.Geometry.call(this);var f,j=a/2,k=b/2;d=d||1;e=e||1;var g=d+1,m=e+1;a=a/d;var c=b/e;for(f=0;f<m;f++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-j,-(f*c-k),0)));for(f=0;f<e;f++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+g*f,b+g*(f+1),b+1+g*(f+1),b+1+g*f));this.uvs.push([new THREE.UV(b/d,f/e),new THREE.UV(b/d,(f+1)/e),new THREE.UV((b+1)/d,(f+1)/e),new THREE.UV((b+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
+var Cylinder=function(a,b,d,e,f){function j(c,t,A){k.vertices.push(new THREE.Vertex(new THREE.Vector3(c,t,A)))}THREE.Geometry.call(this);var k=this,g=Math.PI,l;for(l=0;l<a;l++)j(Math.sin(2*g*l/a)*b,Math.cos(2*g*l/a)*b,0);for(l=0;l<a;l++)j(Math.sin(2*g*l/a)*d,Math.cos(2*g*l/a)*d,e);for(l=0;l<a;l++)k.faces.push(new THREE.Face4(l,l+a,a+(l+1)%a,(l+1)%a));if(d!=0){j(0,0,-f);for(l=a;l<a+a/2;l++)k.faces.push(new THREE.Face4(2*a,(2*l-2*a)%a,(2*l-2*a+1)%a,(2*l-2*a+2)%a))}if(b!=0){j(0,0,e+f);for(l=a+a/2;l<
+2*a;l++)k.faces.push(new THREE.Face4((2*l-2*a+2)%a+a,(2*l-2*a+1)%a+a,(2*l-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,b,d,e){THREE.Geometry.call(this);var f,j=a/2,k=b/2;d=d||1;e=e||1;var g=d+1,l=e+1;a=a/d;var c=b/e;for(f=0;f<l;f++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-j,-(f*c-k),0)));for(f=0;f<e;f++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+g*f,b+g*(f+1),b+1+g*(f+1),b+1+g*f));this.uvs.push([new THREE.UV(b/d,f/e),new THREE.UV(b/d,(f+1)/e),new THREE.UV((b+1)/d,(f+1)/e),new THREE.UV((b+1)/d,f/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,b,d){THREE.Geometry.call(this);var e,f=Math.PI,j=Math.max(3,b||8),k=Math.max(2,d||6);b=[];for(d=0;d<k+1;d++){e=d/k;var g=a*Math.cos(e*f),m=a*Math.sin(e*f),c=[],t=0;for(e=0;e<j;e++){var A=2*e/j,r=m*Math.sin(A*f);A=m*Math.cos(A*f);(d==0||d==k)&&e>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,g,r)))-1);c.push(t)}b.push(c)}var u,v;a=b.length;for(d=0;d<a;d++){f=b[d].length;if(d>0)for(e=0;e<f;e++){m=e==f-1;j=b[d][m?0:e+1];k=b[d][m?f-1:e];g=b[d-1][m?f-1:e];m=b[d-1][m?
+var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,f=Math.PI,j=Math.max(3,b||8),k=Math.max(2,d||6);b=[];for(d=0;d<k+1;d++){e=d/k;var g=a*Math.cos(e*f),l=a*Math.sin(e*f),c=[],t=0;for(e=0;e<j;e++){var A=2*e/j,r=l*Math.sin(A*f);A=l*Math.cos(A*f);(d==0||d==k)&&e>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,g,r)))-1);c.push(t)}b.push(c)}var u,v;a=b.length;for(d=0;d<a;d++){f=b[d].length;if(d>0)for(e=0;e<f;e++){l=e==f-1;j=b[d][l?0:e+1];k=b[d][l?f-1:e];g=b[d-1][l?f-1:e];l=b[d-1][l?
 0:e+1];t=d/(a-1);A=(d-1)/(a-1);u=(e+1)/f;r=e/f;c=new THREE.UV(1-u,t);t=new THREE.UV(1-r,t);r=new THREE.UV(1-r,A);var w=new THREE.UV(1-u,A);if(d<b.length-1){A=this.vertices[j].position.clone();u=this.vertices[k].position.clone();v=this.vertices[g].position.clone();A.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,k,g,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,r])}if(d>1){A=this.vertices[j].position.clone();
 0:e+1];t=d/(a-1);A=(d-1)/(a-1);u=(e+1)/f;r=e/f;c=new THREE.UV(1-u,t);t=new THREE.UV(1-r,t);r=new THREE.UV(1-r,A);var w=new THREE.UV(1-u,A);if(d<b.length-1){A=this.vertices[j].position.clone();u=this.vertices[k].position.clone();v=this.vertices[g].position.clone();A.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,k,g,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,r])}if(d>1){A=this.vertices[j].position.clone();
-u=this.vertices[g].position.clone();v=this.vertices[m].position.clone();A.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,m,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,r,w])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+u=this.vertices[g].position.clone();v=this.vertices[l].position.clone();A.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,l,[new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,r,w])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
 THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
 THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
 b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,
 b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,
 j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState==
 j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState==
 2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,s){var x=t(q,s),G=t(q,s+1),U=t(q,s+2),ba=t(q,s+3),ga=(ba<<1&255|U>>7)-127;x=(U&127)<<16|G<<8|x;if(x==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ga)}function g(q,s){var x=t(q,s),G=t(q,s+1),U=t(q,s+2);return(t(q,s+3)<<24)+(U<<
 2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,s){var x=t(q,s),G=t(q,s+1),U=t(q,s+2),ba=t(q,s+3),ga=(ba<<1&255|U>>7)-127;x=(U&127)<<16|G<<8|x;if(x==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ga)}function g(q,s){var x=t(q,s),G=t(q,s+1),U=t(q,s+2);return(t(q,s+3)<<24)+(U<<
-16)+(G<<8)+x}function m(q,s){var x=t(q,s);return(t(q,s+1)<<8)+x}function c(q,s){var x=t(q,s);return x>127?x-256:x}function t(q,s){return q.charCodeAt(s)&255}function A(q){var s,x,G;s=g(a,q);x=g(a,q+i);G=g(a,q+y);q=m(a,q+l);THREE.Loader.prototype.f3(I,s,x,G,q)}function r(q){var s,x,G,U,ba,ga;s=g(a,q);x=g(a,q+i);G=g(a,q+y);U=m(a,q+l);ba=g(a,q+p);ga=g(a,q+C);q=g(a,q+B);THREE.Loader.prototype.f3n(I,h,s,x,G,U,ba,ga,q)}function u(q){var s,x,G,U;s=g(a,q);x=g(a,q+P);G=g(a,q+J);U=g(a,q+R);q=m(a,q+T);THREE.Loader.prototype.f4(I,
-s,x,G,U,q)}function v(q){var s,x,G,U,ba,ga,$,ka;s=g(a,q);x=g(a,q+P);G=g(a,q+J);U=g(a,q+R);ba=m(a,q+T);ga=g(a,q+E);$=g(a,q+V);ka=g(a,q+K);q=g(a,q+L);THREE.Loader.prototype.f4n(I,h,s,x,G,U,ba,ga,$,ka,q)}function w(q){var s,x;s=g(a,q);x=g(a,q+N);q=g(a,q+Y);THREE.Loader.prototype.uv3(I,o[s*2],o[s*2+1],o[x*2],o[x*2+1],o[q*2],o[q*2+1])}function H(q){var s,x,G;s=g(a,q);x=g(a,q+Q);G=g(a,q+M);q=g(a,q+W);THREE.Loader.prototype.uv4(I,o[s*2],o[s*2+1],o[x*2],o[x*2+1],o[G*2],o[G*2+1],o[q*2],o[q*2+1])}var I=this,
-z=0,n,h=[],o=[],i,y,l,p,C,B,P,J,R,T,E,V,K,L,N,Y,Q,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,e,j);n={signature:a.substr(z,8),header_bytes:t(a,z+8),vertex_coordinate_bytes:t(a,z+9),normal_coordinate_bytes:t(a,z+10),uv_coordinate_bytes:t(a,z+11),vertex_index_bytes:t(a,z+12),normal_index_bytes:t(a,z+13),uv_index_bytes:t(a,z+14),material_index_bytes:t(a,z+15),nvertices:g(a,z+16),nnormals:g(a,z+16+4),nuvs:g(a,z+16+8),ntri_flat:g(a,z+16+12),ntri_smooth:g(a,z+16+16),ntri_flat_uv:g(a,
-z+16+20),ntri_smooth_uv:g(a,z+16+24),nquad_flat:g(a,z+16+28),nquad_smooth:g(a,z+16+32),nquad_flat_uv:g(a,z+16+36),nquad_smooth_uv:g(a,z+16+40)};z+=n.header_bytes;i=n.vertex_index_bytes;y=n.vertex_index_bytes*2;l=n.vertex_index_bytes*3;p=n.vertex_index_bytes*3+n.material_index_bytes;C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;J=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;T=n.vertex_index_bytes*
+16)+(G<<8)+x}function l(q,s){var x=t(q,s);return(t(q,s+1)<<8)+x}function c(q,s){var x=t(q,s);return x>127?x-256:x}function t(q,s){return q.charCodeAt(s)&255}function A(q){var s,x,G;s=g(a,q);x=g(a,q+i);G=g(a,q+y);q=l(a,q+m);THREE.Loader.prototype.f3(I,s,x,G,q)}function r(q){var s,x,G,U,ba,ga;s=g(a,q);x=g(a,q+i);G=g(a,q+y);U=l(a,q+m);ba=g(a,q+p);ga=g(a,q+C);q=g(a,q+B);THREE.Loader.prototype.f3n(I,h,s,x,G,U,ba,ga,q)}function u(q){var s,x,G,U;s=g(a,q);x=g(a,q+P);G=g(a,q+J);U=g(a,q+R);q=l(a,q+T);THREE.Loader.prototype.f4(I,
+s,x,G,U,q)}function v(q){var s,x,G,U,ba,ga,$,ka;s=g(a,q);x=g(a,q+P);G=g(a,q+J);U=g(a,q+R);ba=l(a,q+T);ga=g(a,q+E);$=g(a,q+V);ka=g(a,q+K);q=g(a,q+L);THREE.Loader.prototype.f4n(I,h,s,x,G,U,ba,ga,$,ka,q)}function w(q){var s,x;s=g(a,q);x=g(a,q+N);q=g(a,q+Y);THREE.Loader.prototype.uv3(I,o[s*2],o[s*2+1],o[x*2],o[x*2+1],o[q*2],o[q*2+1])}function H(q){var s,x,G;s=g(a,q);x=g(a,q+Q);G=g(a,q+M);q=g(a,q+W);THREE.Loader.prototype.uv4(I,o[s*2],o[s*2+1],o[x*2],o[x*2+1],o[G*2],o[G*2+1],o[q*2],o[q*2+1])}var I=this,
+z=0,n,h=[],o=[],i,y,m,p,C,B,P,J,R,T,E,V,K,L,N,Y,Q,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,e,j);n={signature:a.substr(z,8),header_bytes:t(a,z+8),vertex_coordinate_bytes:t(a,z+9),normal_coordinate_bytes:t(a,z+10),uv_coordinate_bytes:t(a,z+11),vertex_index_bytes:t(a,z+12),normal_index_bytes:t(a,z+13),uv_index_bytes:t(a,z+14),material_index_bytes:t(a,z+15),nvertices:g(a,z+16),nnormals:g(a,z+16+4),nuvs:g(a,z+16+8),ntri_flat:g(a,z+16+12),ntri_smooth:g(a,z+16+16),ntri_flat_uv:g(a,
+z+16+20),ntri_smooth_uv:g(a,z+16+24),nquad_flat:g(a,z+16+28),nquad_smooth:g(a,z+16+32),nquad_flat_uv:g(a,z+16+36),nquad_smooth_uv:g(a,z+16+40)};z+=n.header_bytes;i=n.vertex_index_bytes;y=n.vertex_index_bytes*2;m=n.vertex_index_bytes*3;p=n.vertex_index_bytes*3+n.material_index_bytes;C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;J=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;T=n.vertex_index_bytes*
 4;E=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;K=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;N=n.uv_index_bytes;Y=n.uv_index_bytes*2;Q=n.uv_index_bytes;M=n.uv_index_bytes*2;W=n.uv_index_bytes*3;z+=function(q){var s,x,G,U=n.vertex_coordinate_bytes*3,ba=q+n.nvertices*U;for(q=q;q<ba;q+=U){s=k(a,q);x=k(a,q+n.vertex_coordinate_bytes);G=
 4;E=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;K=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;N=n.uv_index_bytes;Y=n.uv_index_bytes*2;Q=n.uv_index_bytes;M=n.uv_index_bytes*2;W=n.uv_index_bytes*3;z+=function(q){var s,x,G,U=n.vertex_coordinate_bytes*3,ba=q+n.nvertices*U;for(q=q;q<ba;q+=U){s=k(a,q);x=k(a,q+n.vertex_coordinate_bytes);G=
 k(a,q+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,s,x,G)}return n.nvertices*U}(z);z+=function(q){var s,x,G,U=n.normal_coordinate_bytes*3,ba=q+n.nnormals*U;for(q=q;q<ba;q+=U){s=c(a,q);x=c(a,q+n.normal_coordinate_bytes);G=c(a,q+n.normal_coordinate_bytes*2);h.push(s/127,x/127,G/127)}return n.nnormals*U}(z);z+=function(q){var s,x,G=n.uv_coordinate_bytes*2,U=q+n.nuvs*G;for(q=q;q<U;q+=G){s=k(a,q);x=k(a,q+n.uv_coordinate_bytes);o.push(s,x)}return n.nuvs*G}(z);z+=function(q){var s,x=n.vertex_index_bytes*
 k(a,q+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(I,s,x,G)}return n.nvertices*U}(z);z+=function(q){var s,x,G,U=n.normal_coordinate_bytes*3,ba=q+n.nnormals*U;for(q=q;q<ba;q+=U){s=c(a,q);x=c(a,q+n.normal_coordinate_bytes);G=c(a,q+n.normal_coordinate_bytes*2);h.push(s/127,x/127,G/127)}return n.nnormals*U}(z);z+=function(q){var s,x,G=n.uv_coordinate_bytes*2,U=q+n.nuvs*G;for(q=q;q<U;q+=G){s=k(a,q);x=k(a,q+n.uv_coordinate_bytes);o.push(s,x)}return n.nuvs*G}(z);z+=function(q){var s,x=n.vertex_index_bytes*
 3+n.material_index_bytes,G=q+n.ntri_flat*x;for(s=q;s<G;s+=x)A(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=q+n.ntri_smooth*x;for(s=q;s<G;s+=x)r(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes,G=x+n.uv_index_bytes*3,U=q+n.ntri_flat_uv*G;for(s=q;s<U;s+=G){A(s);w(s+x)}return U-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=x+n.uv_index_bytes*3,
 3+n.material_index_bytes,G=q+n.ntri_flat*x;for(s=q;s<G;s+=x)A(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=q+n.ntri_smooth*x;for(s=q;s<G;s+=x)r(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes,G=x+n.uv_index_bytes*3,U=q+n.ntri_flat_uv*G;for(s=q;s<U;s+=G){A(s);w(s+x)}return U-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=x+n.uv_index_bytes*3,
 U=q+n.ntri_smooth_uv*G;for(s=q;s<U;s+=G){r(s);w(s+x)}return U-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=q+n.nquad_flat*x;for(s=q;s<G;s+=x)u(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=q+n.nquad_smooth*x;for(s=q;s<G;s+=x)v(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=x+n.uv_index_bytes*4,U=q+n.nquad_flat_uv*G;for(s=q;s<U;s+=G){u(s);H(s+x)}return U-q}(z);
 U=q+n.ntri_smooth_uv*G;for(s=q;s<U;s+=G){r(s);w(s+x)}return U-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=q+n.nquad_flat*x;for(s=q;s<G;s+=x)u(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=q+n.nquad_smooth*x;for(s=q;s<G;s+=x)v(s);return G-q}(z);z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=x+n.uv_index_bytes*4,U=q+n.nquad_flat_uv*G;for(s=q;s<U;s+=G){u(s);H(s+x)}return U-q}(z);
-z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=x+n.uv_index_bytes*4,U=q+n.nquad_smooth_uv*G;for(s=q;s<U;s+=G){v(s);H(s+x)}return U-q}(z);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,f);(function(){var k,g,m,c,t;k=0;for(g=
-a.vertices.length;k<g;k+=3){m=a.vertices[k];c=a.vertices[k+1];t=a.vertices[k+2];THREE.Loader.prototype.v(j,m,c,t)}})();(function(){function k(v,w){THREE.Loader.prototype.f3(j,v[w],v[w+1],v[w+2],v[w+3])}function g(v,w){THREE.Loader.prototype.f3n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6])}function m(v,w){THREE.Loader.prototype.f4(j,v[w],v[w+1],v[w+2],v[w+3],v[w+4])}function c(v,w){THREE.Loader.prototype.f4n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6],v[w+7],v[w+8])}function t(v,
+z+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=x+n.uv_index_bytes*4,U=q+n.nquad_smooth_uv*G;for(s=q;s<U;s+=G){v(s);H(s+x)}return U-q}(z);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,f);(function(){var k,g,l,c,t;k=0;for(g=
+a.vertices.length;k<g;k+=3){l=a.vertices[k];c=a.vertices[k+1];t=a.vertices[k+2];THREE.Loader.prototype.v(j,l,c,t)}})();(function(){function k(v,w){THREE.Loader.prototype.f3(j,v[w],v[w+1],v[w+2],v[w+3])}function g(v,w){THREE.Loader.prototype.f3n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6])}function l(v,w){THREE.Loader.prototype.f4(j,v[w],v[w+1],v[w+2],v[w+3],v[w+4])}function c(v,w){THREE.Loader.prototype.f4n(j,a.normals,v[w],v[w+1],v[w+2],v[w+3],v[w+4],v[w+5],v[w+6],v[w+7],v[w+8])}function t(v,
 w){var H,I,z;H=v[w];I=v[w+1];z=v[w+2];THREE.Loader.prototype.uv3(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1])}function A(v,w){var H,I,z,n;H=v[w];I=v[w+1];z=v[w+2];n=v[w+3];THREE.Loader.prototype.uv4(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,u;r=0;for(u=a.triangles.length;r<u;r+=4)k(a.triangles,r);r=0;for(u=a.triangles_uv.length;r<u;r+=7){k(a.triangles_uv,r);t(a.triangles_uv,r+4)}r=0;for(u=a.triangles_n.length;r<
 w){var H,I,z;H=v[w];I=v[w+1];z=v[w+2];THREE.Loader.prototype.uv3(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1])}function A(v,w){var H,I,z,n;H=v[w];I=v[w+1];z=v[w+2];n=v[w+3];THREE.Loader.prototype.uv4(j,a.uvs[H*2],a.uvs[H*2+1],a.uvs[I*2],a.uvs[I*2+1],a.uvs[z*2],a.uvs[z*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,u;r=0;for(u=a.triangles.length;r<u;r+=4)k(a.triangles,r);r=0;for(u=a.triangles_uv.length;r<u;r+=7){k(a.triangles_uv,r);t(a.triangles_uv,r+4)}r=0;for(u=a.triangles_n.length;r<
-u;r+=7)g(a.triangles_n,r);r=0;for(u=a.triangles_n_uv.length;r<u;r+=10){g(a.triangles_n_uv,r);t(a.triangles_n_uv,r+7)}r=0;for(u=a.quads.length;r<u;r+=5)m(a.quads,r);r=0;for(u=a.quads_uv.length;r<u;r+=9){m(a.quads_uv,r);A(a.quads_uv,r+5)}r=0;for(u=a.quads_n.length;r<u;r+=9)c(a.quads_n,r);r=0;for(u=a.quads_n_uv.length;r<u;r+=13){c(a.quads_n_uv,r);A(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=
-e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,j){a.faces.push(new THREE.Face4(b,d,e,f,null,a.materials[j]))},f3n:function(a,b,d,e,f,j,k,g,m){j=a.materials[j];var c=b[g*3],t=b[g*3+1];g=b[g*3+2];var A=b[m*3],r=b[m*3+1];m=b[m*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,t,g),new THREE.Vector3(A,
-r,m)],j))},f4n:function(a,b,d,e,f,j,k,g,m,c,t){k=a.materials[k];var A=b[m*3],r=b[m*3+1];m=b[m*3+2];var u=b[c*3],v=b[c*3+1];c=b[c*3+2];var w=b[t*3],H=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(d,e,f,j,[new THREE.Vector3(b[g*3],b[g*3+1],b[g*3+2]),new THREE.Vector3(A,r,m),new THREE.Vector3(u,v,c),new THREE.Vector3(w,H,t)],k))},uv3:function(a,b,d,e,f,j,k){var g=[];g.push(new THREE.UV(b,d));g.push(new THREE.UV(e,f));g.push(new THREE.UV(j,k));a.uvs.push(g)},uv4:function(a,b,d,e,f,j,k,g,m){var c=[];
-c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(j,k));c.push(new THREE.UV(g,m));a.uvs.push(c)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],d)]},createMaterial:function(a,b){function d(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}var e,f;if(a.map_diffuse&&b){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!d(this.width)||
+u;r+=7)g(a.triangles_n,r);r=0;for(u=a.triangles_n_uv.length;r<u;r+=10){g(a.triangles_n_uv,r);t(a.triangles_n_uv,r+7)}r=0;for(u=a.quads.length;r<u;r+=5)l(a.quads,r);r=0;for(u=a.quads_uv.length;r<u;r+=9){l(a.quads_uv,r);A(a.quads_uv,r+5)}r=0;for(u=a.quads_n.length;r<u;r+=9)c(a.quads_n,r);r=0;for(u=a.quads_n_uv.length;r<u;r+=13){c(a.quads_n_uv,r);A(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=
+e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,d,e)))},f3:function(a,b,d,e,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,j){a.faces.push(new THREE.Face4(b,d,e,f,null,a.materials[j]))},f3n:function(a,b,d,e,f,j,k,g,l){j=a.materials[j];var c=b[g*3],t=b[g*3+1];g=b[g*3+2];var A=b[l*3],r=b[l*3+1];l=b[l*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,t,g),new THREE.Vector3(A,
+r,l)],j))},f4n:function(a,b,d,e,f,j,k,g,l,c,t){k=a.materials[k];var A=b[l*3],r=b[l*3+1];l=b[l*3+2];var u=b[c*3],v=b[c*3+1];c=b[c*3+2];var w=b[t*3],H=b[t*3+1];t=b[t*3+2];a.faces.push(new THREE.Face4(d,e,f,j,[new THREE.Vector3(b[g*3],b[g*3+1],b[g*3+2]),new THREE.Vector3(A,r,l),new THREE.Vector3(u,v,c),new THREE.Vector3(w,H,t)],k))},uv3:function(a,b,d,e,f,j,k){var g=[];g.push(new THREE.UV(b,d));g.push(new THREE.UV(e,f));g.push(new THREE.UV(j,k));a.uvs.push(g)},uv4:function(a,b,d,e,f,j,k,g,l){var c=[];
+c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(j,k));c.push(new THREE.UV(g,l));a.uvs.push(c)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],d)]},createMaterial:function(a,b){function d(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}var e,f;if(a.map_diffuse&&b){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!d(this.width)||
 !d(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=j;e.map.image.height=k;e.map.image.getContext("2d").drawImage(this,0,0,j,k)}else e.map.image=this;e.map.image.loaded=1};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
 !d(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=j;e.map.image.height=k;e.map.image.getContext("2d").drawImage(this,0,0,j,k)}else e.map.image=this;e.map.image.loaded=1};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
 new THREE.MeshLambertMaterial({color:15658734});return e}};
 new THREE.MeshLambertMaterial({color:15658734});return e}};

+ 31 - 6
src/core/Matrix4.js

@@ -6,17 +6,17 @@
  * @author D1plo1d / http://github.com/D1plo1d
  * @author D1plo1d / http://github.com/D1plo1d
  */
  */
 
 
-THREE.Matrix4 = function () {
+THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+
+	this.n11 = n11 || 1; this.n12 = n12 || 0; this.n13 = n13 || 0; this.n14 = n14 || 0;
+	this.n21 = n21 || 0; this.n22 = n22 || 1; this.n23 = n23 || 0; this.n24 = n24 || 0;
+	this.n31 = n31 || 0; this.n32 = n32 || 0; this.n33 = n33 || 1; this.n34 = n34 || 0;
+	this.n41 = n41 || 0; this.n42 = n42 || 0; this.n43 = n43 || 0; this.n44 = n44 || 1;
 
 
 };
 };
 
 
 THREE.Matrix4.prototype = {
 THREE.Matrix4.prototype = {
 
 
-	n11: 1, n12: 0, n13: 0, n14: 0,
-	n21: 0, n22: 1, n23: 0, n24: 0,
-	n31: 0, n32: 0, n33: 1, n34: 0,
-	n41: 0, n42: 0, n43: 0, n44: 1,
-
 	identity: function () {
 	identity: function () {
 
 
 		this.n11 = 1; this.n12 = 0; this.n13 = 0; this.n14 = 0;
 		this.n11 = 1; this.n12 = 0; this.n13 = 0; this.n14 = 0;
@@ -24,6 +24,19 @@ THREE.Matrix4.prototype = {
 		this.n31 = 0; this.n32 = 0; this.n33 = 1; this.n34 = 0;
 		this.n31 = 0; this.n32 = 0; this.n33 = 1; this.n34 = 0;
 		this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
 		this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
 
 
+		return this;
+
+	},
+
+	set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+
+		this.n11 = n11; this.n12 = n12; this.n13 = n13; this.n14 = n14;
+		this.n21 = n21; this.n22 = n22; this.n23 = n23; this.n24 = n24;
+		this.n31 = n31; this.n32 = n32; this.n33 = n33; this.n34 = n34;
+		this.n41 = n41; this.n42 = n42; this.n43 = n43; this.n44 = n44;
+
+		return this;
+
 	},
 	},
 
 
 	copy: function ( m ) {
 	copy: function ( m ) {
@@ -33,6 +46,8 @@ THREE.Matrix4.prototype = {
 		this.n31 = m.n31; this.n32 = m.n32; this.n33 = m.n33; this.n34 = m.n34;
 		this.n31 = m.n31; this.n32 = m.n32; this.n33 = m.n33; this.n34 = m.n34;
 		this.n41 = m.n41; this.n42 = m.n42; this.n43 = m.n43; this.n44 = m.n44;
 		this.n41 = m.n41; this.n42 = m.n42; this.n43 = m.n43; this.n44 = m.n44;
 
 
+		return this;
+
 	},
 	},
 
 
 	lookAt: function ( eye, center, up ) {
 	lookAt: function ( eye, center, up ) {
@@ -48,6 +63,8 @@ THREE.Matrix4.prototype = {
 		this.n31 = z.x; this.n32 = z.y; this.n33 = z.z; this.n34 = - z.dot( eye );
 		this.n31 = z.x; this.n32 = z.y; this.n33 = z.z; this.n34 = - z.dot( eye );
 		this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
 		this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
 
 
+		return this;
+
 	},
 	},
 
 
 	multiplyVector3: function ( v ) {
 	multiplyVector3: function ( v ) {
@@ -122,6 +139,8 @@ THREE.Matrix4.prototype = {
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
 
 
+		return this;
+
 	},
 	},
 
 
 	multiplySelf: function ( m ) {
 	multiplySelf: function ( m ) {
@@ -151,6 +170,8 @@ THREE.Matrix4.prototype = {
 		this.n43 = n41 * m.n13 + n42 * m.n23 + n43 * m.n33 + n44 * m.n43;
 		this.n43 = n41 * m.n13 + n42 * m.n23 + n43 * m.n33 + n44 * m.n43;
 		this.n44 = n41 * m.n14 + n42 * m.n24 + n43 * m.n34 + n44 * m.n44;
 		this.n44 = n41 * m.n14 + n42 * m.n24 + n43 * m.n34 + n44 * m.n44;
 
 
+		return this;
+
 	},
 	},
 
 
 	multiplyScalar: function ( s ) {
 	multiplyScalar: function ( s ) {
@@ -160,6 +181,8 @@ THREE.Matrix4.prototype = {
 		this.n31 *= s; this.n32 *= s; this.n33 *= s; this.n34 *= s;
 		this.n31 *= s; this.n32 *= s; this.n33 *= s; this.n34 *= s;
 		this.n41 *= s; this.n42 *= s; this.n43 *= s; this.n44 *= s;
 		this.n41 *= s; this.n42 *= s; this.n43 *= s; this.n44 *= s;
 
 
+		return this;
+
 	},
 	},
 
 
 	determinant: function () {
 	determinant: function () {
@@ -223,10 +246,12 @@ THREE.Matrix4.prototype = {
 	clone: function () {
 	clone: function () {
 
 
 		var m = new THREE.Matrix4();
 		var m = new THREE.Matrix4();
+
 		m.n11 = this.n11; m.n12 = this.n12; m.n13 = this.n13; m.n14 = this.n14;
 		m.n11 = this.n11; m.n12 = this.n12; m.n13 = this.n13; m.n14 = this.n14;
 		m.n21 = this.n21; m.n22 = this.n22; m.n23 = this.n23; m.n24 = this.n24;
 		m.n21 = this.n21; m.n22 = this.n22; m.n23 = this.n23; m.n24 = this.n24;
 		m.n31 = this.n31; m.n32 = this.n32; m.n33 = this.n33; m.n34 = this.n34;
 		m.n31 = this.n31; m.n32 = this.n32; m.n33 = this.n33; m.n34 = this.n34;
 		m.n41 = this.n41; m.n42 = this.n42; m.n43 = this.n43; m.n44 = this.n44;
 		m.n41 = this.n41; m.n42 = this.n42; m.n43 = this.n43; m.n44 = this.n44;
+
 		return m;
 		return m;
 
 
 	},
 	},