Browse Source

Merge remote branch 'alteredq/master'

Mr.doob 14 years ago
parent
commit
d313693509
5 changed files with 323 additions and 320 deletions
  1. 94 94
      build/Three.js
  2. 94 94
      build/ThreeDebug.js
  3. 93 93
      build/ThreeExtras.js
  4. 1 0
      examples/uqbiquity_test.html
  5. 41 39
      src/renderers/WebGLRenderer.js

+ 94 - 94
build/Three.js

@@ -12,48 +12,48 @@ THREE.Vector4=function(a,b,f,e){this.x=a||0;this.y=b||0;this.z=f||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,b,f,e){this.x=a;this.y=b;this.z=f;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,f,e){this.x=a;this.y=b;this.z=f;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,f,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){f=e[a];if(f instanceof THREE.Mesh)g=g.concat(this.intersectObject(f))}g.sort(function(j,o){return j.distance-o.distance});return g},intersectObject:function(a){function b(O,q,L,d){d=d.clone().subSelf(q);L=L.clone().subSelf(q);var h=O.clone().subSelf(q);O=d.dot(d);q=d.dot(L);d=d.dot(h);var r=L.dot(L);L=L.dot(h);h=1/(O*r-q*q);r=(r*d-q*L)*h;O=(O*L-q*d)*h;return r>0&&O>0&&r+O<1}var f,e,g,j,o,c,k,n,B,D,
-x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;f<e;f++){g=A.faces[f];D=this.origin.clone();x=this.direction.clone();j=a.matrix.multiplyVector3(M[g.a].position.clone());o=a.matrix.multiplyVector3(M[g.b].position.clone());c=a.matrix.multiplyVector3(M[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(M[g.d].position.clone()):null;n=a.rotationMatrix.multiplyVector3(g.normal.clone());B=x.dot(n);if(B<0){n=n.dot((new THREE.Vector3).sub(j,D))/B;D=D.addSelf(x.multiplyScalar(n));
-if(g instanceof THREE.Face3){if(b(D,j,o,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,o,k)||b(D,o,c,k)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}}return Q}};
-THREE.Rectangle=function(){function a(){j=e-b;o=g-f}var b,f,e,g,j,o,c=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,n,B,D){c=false;b=k;f=n;e=B;g=D;a()};this.addPoint=function(k,n){if(c){c=false;b=k;f=n;e=k;g=n}else{b=b<k?b:k;f=f<n?f:n;e=e>k?e:k;g=g>n?
-g:n}a()};this.add3Points=function(k,n,B,D,x,A){if(c){c=false;b=k<B?k<x?k:x:B<x?B:x;f=n<D?n<A?n:A:D<A?D:A;e=k>B?k>x?k:x:B>x?B:x;g=n>D?n>A?n:A:D>A?D:A}else{b=k<B?k<x?k<b?k:b:x<b?x:b:B<x?B<b?B:b:x<b?x:b;f=n<D?n<A?n<f?n:f:A<f?A:f:D<A?D<f?D:f:A<f?A:f;e=k>B?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=n>D?n>A?n>g?n:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();f=f<k.getTop()?f:k.getTop();
+THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){f=e[a];if(f instanceof THREE.Mesh)g=g.concat(this.intersectObject(f))}g.sort(function(j,p){return j.distance-p.distance});return g},intersectObject:function(a){function b(O,s,L,d){d=d.clone().subSelf(s);L=L.clone().subSelf(s);var h=O.clone().subSelf(s);O=d.dot(d);s=d.dot(L);d=d.dot(h);var q=L.dot(L);L=L.dot(h);h=1/(O*q-s*s);q=(q*d-s*L)*h;O=(O*L-s*d)*h;return q>0&&O>0&&q+O<1}var f,e,g,j,p,c,k,m,B,D,
+x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;f<e;f++){g=A.faces[f];D=this.origin.clone();x=this.direction.clone();j=a.matrix.multiplyVector3(M[g.a].position.clone());p=a.matrix.multiplyVector3(M[g.b].position.clone());c=a.matrix.multiplyVector3(M[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(M[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());B=x.dot(m);if(B<0){m=m.dot((new THREE.Vector3).sub(j,D))/B;D=D.addSelf(x.multiplyScalar(m));
+if(g instanceof THREE.Face3){if(b(D,j,p,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,p,k)||b(D,p,c,k)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}}return Q}};
+THREE.Rectangle=function(){function a(){j=e-b;p=g-f}var b,f,e,g,j,p,c=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,m,B,D){c=false;b=k;f=m;e=B;g=D;a()};this.addPoint=function(k,m){if(c){c=false;b=k;f=m;e=k;g=m}else{b=b<k?b:k;f=f<m?f:m;e=e>k?e:k;g=g>m?
+g:m}a()};this.add3Points=function(k,m,B,D,x,A){if(c){c=false;b=k<B?k<x?k:x:B<x?B:x;f=m<D?m<A?m:A:D<A?D:A;e=k>B?k>x?k:x:B>x?B:x;g=m>D?m>A?m:A:D>A?D:A}else{b=k<B?k<x?k<b?k:b:x<b?x:b:B<x?B<b?B:b:x<b?x:b;f=m<D?m<A?m<f?m:f:A<f?A:f:D<A?D<f?D:f:A<f?A:f;e=k>B?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=m>D?m>A?m>g?m:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();f=f<k.getTop()?f:k.getTop();
 e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString=
 e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString=
-function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
-THREE.Matrix4=function(a,b,f,e,g,j,o,c,k,n,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=o||0;this.n24=c||0;this.n31=k||0;this.n32=n||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||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,f,e,g,j,o,c,k,n,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=o;this.n24=c;this.n31=k;this.n32=n;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+p+" )"}};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,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=m||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||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,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=p;this.n24=c;this.n31=k;this.n32=m;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;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,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;
 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,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=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,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24*
 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,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24*
-g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+this.n43*e+this.n44*g;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 f=a.n11,e=a.n12,g=a.n13,j=a.n14,o=a.n21,c=a.n22,k=a.n23,n=a.n24,B=a.n31,D=a.n32,
-x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,q=a.n44,L=b.n11,d=b.n12,h=b.n13,r=b.n14,l=b.n21,m=b.n22,i=b.n23,t=b.n24,p=b.n31,y=b.n32,u=b.n33,s=b.n34,v=b.n41,W=b.n42,G=b.n43,S=b.n44;this.n11=f*L+e*l+g*p+j*v;this.n12=f*d+e*m+g*y+j*W;this.n13=f*h+e*i+g*u+j*G;this.n14=f*r+e*t+g*s+j*S;this.n21=o*L+c*l+k*p+n*v;this.n22=o*d+c*m+k*y+n*W;this.n23=o*h+c*i+k*u+n*G;this.n24=o*r+c*t+k*s+n*S;this.n31=B*L+D*l+x*p+A*v;this.n32=B*d+D*m+x*y+A*W;this.n33=B*h+D*i+x*u+A*G;this.n34=B*r+D*t+x*s+A*S;this.n41=M*L+Q*l+O*p+q*v;
-this.n42=M*d+Q*m+O*y+q*W;this.n43=M*h+Q*i+O*u+q*G;this.n44=M*r+Q*t+O*s+q*S;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,o=this.n22,c=this.n23,k=this.n24,n=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,q=a.n11,L=a.n21,d=a.n31,h=a.n41,r=a.n12,l=a.n22,m=a.n32,i=a.n42,t=a.n13,p=a.n23,y=a.n33,u=a.n43,s=a.n14,v=a.n24,W=a.n34;a=a.n44;this.n11=b*q+f*L+e*d+g*h;this.n12=b*r+f*l+e*m+g*i;this.n13=b*t+f*p+e*y+g*u;this.n14=
-b*s+f*v+e*W+g*a;this.n21=j*q+o*L+c*d+k*h;this.n22=j*r+o*l+c*m+k*i;this.n23=j*t+o*p+c*y+k*u;this.n24=j*s+o*v+c*W+k*a;this.n31=n*q+B*L+D*d+x*h;this.n32=n*r+B*l+D*m+x*i;this.n33=n*t+B*p+D*y+x*u;this.n34=n*s+B*v+D*W+x*a;this.n41=A*q+M*L+Q*d+O*h;this.n42=A*r+M*l+Q*m+O*i;this.n43=A*t+M*p+Q*y+O*u;this.n44=A*s+M*v+Q*W+O*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
+g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+this.n43*e+this.n44*g;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 f=a.n11,e=a.n12,g=a.n13,j=a.n14,p=a.n21,c=a.n22,k=a.n23,m=a.n24,B=a.n31,D=a.n32,
+x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,s=a.n44,L=b.n11,d=b.n12,h=b.n13,q=b.n14,n=b.n21,l=b.n22,i=b.n23,u=b.n24,o=b.n31,y=b.n32,t=b.n33,r=b.n34,v=b.n41,W=b.n42,G=b.n43,S=b.n44;this.n11=f*L+e*n+g*o+j*v;this.n12=f*d+e*l+g*y+j*W;this.n13=f*h+e*i+g*t+j*G;this.n14=f*q+e*u+g*r+j*S;this.n21=p*L+c*n+k*o+m*v;this.n22=p*d+c*l+k*y+m*W;this.n23=p*h+c*i+k*t+m*G;this.n24=p*q+c*u+k*r+m*S;this.n31=B*L+D*n+x*o+A*v;this.n32=B*d+D*l+x*y+A*W;this.n33=B*h+D*i+x*t+A*G;this.n34=B*q+D*u+x*r+A*S;this.n41=M*L+Q*n+O*o+s*v;
+this.n42=M*d+Q*l+O*y+s*W;this.n43=M*h+Q*i+O*t+s*G;this.n44=M*q+Q*u+O*r+s*S;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,p=this.n22,c=this.n23,k=this.n24,m=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,s=a.n11,L=a.n21,d=a.n31,h=a.n41,q=a.n12,n=a.n22,l=a.n32,i=a.n42,u=a.n13,o=a.n23,y=a.n33,t=a.n43,r=a.n14,v=a.n24,W=a.n34;a=a.n44;this.n11=b*s+f*L+e*d+g*h;this.n12=b*q+f*n+e*l+g*i;this.n13=b*u+f*o+e*y+g*t;this.n14=
+b*r+f*v+e*W+g*a;this.n21=j*s+p*L+c*d+k*h;this.n22=j*q+p*n+c*l+k*i;this.n23=j*u+p*o+c*y+k*t;this.n24=j*r+p*v+c*W+k*a;this.n31=m*s+B*L+D*d+x*h;this.n32=m*q+B*n+D*l+x*i;this.n33=m*u+B*o+D*y+x*t;this.n34=m*r+B*v+D*W+x*a;this.n41=A*s+M*L+Q*d+O*h;this.n42=A*q+M*n+Q*l+O*i;this.n43=A*u+M*o+Q*y+O*t;this.n44=A*r+M*v+Q*W+O*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
 a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
 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,f,e){var g=b[f];b[f]=b[e];
 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,f,e){var g=b[f];b[f]=b[e];
 b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
 b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e};
 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,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e};
 THREE.Matrix4.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;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.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;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 f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,o=a.x,c=a.y,k=a.z;f.n11=j*o*o+e;f.n12=j*o*c-g*k;f.n13=j*o*k+g*c;f.n21=j*o*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*o;f.n31=j*o*k-g*c;f.n32=j*c*k+g*o;f.n33=j*k*k+e;return f};
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,p=a.x,c=a.y,k=a.z;f.n11=j*p*p+e;f.n12=j*p*c-g*k;f.n13=j*p*k+g*c;f.n21=j*p*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*p;f.n31=j*p*k-g*c;f.n32=j*c*k+g*p;f.n33=j*k*k+e;return f};
 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 f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],n=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*o;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*n;a.m[8]=b*B;return a};
-THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var o,c,k;o=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);o.n11=c;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=k;o.n23=f;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)};
-THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var o,c,k,n;o=new THREE.Matrix4;c=b-a;k=f-e;n=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/n;o.n11=2/c;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/k;o.n23=0;o.n24=-f;o.n31=0;o.n32=0;o.n33=-2/n;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*m;a.m[8]=b*B;return a};
+THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var p,c,k;p=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=e;p.n34=g;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)};
+THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var p,c,k,m;p=new THREE.Matrix4;c=b-a;k=f-e;m=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/m;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/m;p.n34=-g;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Face3=function(a,b,f,e,g){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face3=function(a,b,f,e,g){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,b,f,e,g,j){this.a=a;this.b=b;this.c=f;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,f,e,g,j){this.a=a;this.b=b;this.c=f;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
-f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,e,g,j,o,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];if(a&&j.vertexNormals.length){c.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)c.addSelf(j.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];o=this.vertices[j.c];c.sub(o.position,
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,e,g,j,p,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];if(a&&j.vertexNormals.length){c.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)c.addSelf(j.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];p=this.vertices[j.c];c.sub(p.position,
 f.position);k.sub(b.position,f.position);c.crossSelf(k)}c.isZero()||c.normalize();j.normal.copy(c)}},computeVertexNormals:function(){var a,b,f=[],e;a=0;for(b=this.vertices.length;a<b;a++)f[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=
 f.position);k.sub(b.position,f.position);c.crossSelf(k)}c.isZero()||c.normalize();j.normal.copy(c)}},computeVertexNormals:function(){var a,b,f=[],e;a=0;for(b=this.vertices.length;a<b;a++)f[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=
-0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone();e.vertexNormals[3]=f[e.d].clone()}}},computeTangents:function(){function a(s,v,W,G,S,P,H){j=s.vertices[v].position;o=s.vertices[W].position;
-c=s.vertices[G].position;k=g[S];n=g[P];B=g[H];D=o.x-j.x;x=c.x-j.x;A=o.y-j.y;M=c.y-j.y;Q=o.z-j.z;O=c.z-j.z;q=n.u-k.u;L=B.u-k.u;d=n.v-k.v;h=B.v-k.v;r=1/(q*h-L*d);i.set((h*D-d*x)*r,(h*A-d*M)*r,(h*Q-d*O)*r);t.set((q*x-L*D)*r,(q*M-L*A)*r,(q*O-L*Q)*r);l[v].addSelf(i);l[W].addSelf(i);l[G].addSelf(i);m[v].addSelf(t);m[W].addSelf(t);m[G].addSelf(t)}var b,f,e,g,j,o,c,k,n,B,D,x,A,M,Q,O,q,L,d,h,r,l=[],m=[],i=new THREE.Vector3,t=new THREE.Vector3,p=new THREE.Vector3,y=new THREE.Vector3,u=new THREE.Vector3;b=0;
-for(f=this.vertices.length;b<f;b++){l[b]=new THREE.Vector3;m[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
-this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){u.copy(this.vertices[b].normal);e=l[b];p.copy(e);p.subSelf(u.multiplyScalar(u.dot(e))).normalize();y.cross(this.vertices[b].normal,e);e=y.dot(m[b]);e=e<0?-1:1;this.vertices[b].tangent.set(p.x,p.y,p.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
+0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone();e.vertexNormals[3]=f[e.d].clone()}}},computeTangents:function(){function a(r,v,W,G,S,P,H){j=r.vertices[v].position;p=r.vertices[W].position;
+c=r.vertices[G].position;k=g[S];m=g[P];B=g[H];D=p.x-j.x;x=c.x-j.x;A=p.y-j.y;M=c.y-j.y;Q=p.z-j.z;O=c.z-j.z;s=m.u-k.u;L=B.u-k.u;d=m.v-k.v;h=B.v-k.v;q=1/(s*h-L*d);i.set((h*D-d*x)*q,(h*A-d*M)*q,(h*Q-d*O)*q);u.set((s*x-L*D)*q,(s*M-L*A)*q,(s*O-L*Q)*q);n[v].addSelf(i);n[W].addSelf(i);n[G].addSelf(i);l[v].addSelf(u);l[W].addSelf(u);l[G].addSelf(u)}var b,f,e,g,j,p,c,k,m,B,D,x,A,M,Q,O,s,L,d,h,q,n=[],l=[],i=new THREE.Vector3,u=new THREE.Vector3,o=new THREE.Vector3,y=new THREE.Vector3,t=new THREE.Vector3;b=0;
+for(f=this.vertices.length;b<f;b++){n[b]=new THREE.Vector3;l[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
+this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){t.copy(this.vertices[b].normal);e=n[b];o.copy(e);o.subSelf(t.multiplyScalar(t.dot(e))).normalize();y.cross(this.vertices[b].normal,e);e=y.dot(l[b]);e=e<0?-1:1;this.vertices[b].tangent.set(o.x,o.y,o.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
 y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=this.vertices.length;b<f;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<
 y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=this.vertices.length;b<f;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<
 this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(B){var D=[];b=0;for(f=B.length;b<f;b++)B[b]==undefined?D.push("undefined"):D.push(B[b].toString());return D.join("_")}
 this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(B){var D=[];b=0;for(f=B.length;b<f;b++)B[b]==undefined?D.push("undefined"):D.push(B[b].toString());return D.join("_")}
-var b,f,e,g,j,o,c,k,n={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];o=j.materials;c=a(o);if(n[c]==undefined)n[c]={hash:c,counter:0};k=n[c].hash+"_"+n[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:o,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){n[c].counter+=1;k=n[c].hash+"_"+n[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:o,vertices:0}}this.geometryChunks[k].faces.push(e);
+var b,f,e,g,j,p,c,k,m={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];p=j.materials;c=a(p);if(m[c]==undefined)m[c]={hash:c,counter:0};k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){m[c].counter+=1;k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(e);
 this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
 THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
 this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
 this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
@@ -96,85 +96,85 @@ THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLine
 THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
 THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(m,i){return i.z-m.z}function b(m,i){var t=0,p=1,y=m.z+m.w,u=i.z+i.w,s=-m.z+m.w,v=-i.z+i.w;if(y>=0&&u>=0&&s>=0&&v>=0)return true;else if(y<0&&u<0||s<0&&v<0)return false;else{if(y<0)t=Math.max(t,y/(y-u));else if(u<0)p=Math.min(p,y/(y-u));if(s<0)t=Math.max(t,s/(s-v));else if(v<0)p=Math.min(p,s/(s-v));if(p<t)return false;else{m.lerpSelf(i,t);i.lerpSelf(m,1-p);return true}}}var f,e,g=[],j,o,c,k=[],n,B,D=[],x,A,M=[],Q=new THREE.Vector4,O=new THREE.Vector4,q=new THREE.Matrix4,
-L=new THREE.Matrix4,d=[],h=new THREE.Vector4,r=new THREE.Vector4,l;this.projectObjects=function(m,i,t){var p=[],y,u;e=0;q.multiply(i.projectionMatrix,i.matrix);d[0]=new THREE.Vector4(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);d[1]=new THREE.Vector4(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);d[2]=new THREE.Vector4(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);d[3]=new THREE.Vector4(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);d[4]=new THREE.Vector4(q.n41-q.n31,q.n42-q.n32,q.n43-
-q.n33,q.n44-q.n34);d[5]=new THREE.Vector4(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);i=0;for(y=d.length;i<y;i++){u=d[i];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}y=m.objects;m=0;for(i=y.length;m<i;m++){u=y[m];var s;if(!(s=!u.visible)){if(s=u instanceof THREE.Mesh){a:{s=void 0;for(var v=u.position,W=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),G=0;G<6;G++){s=d[G].x*v.x+d[G].y*v.y+d[G].z*v.z+d[G].w;if(s<=W){s=false;break a}}s=true}s=!s}s=s}if(!s){f=
-g[e]=g[e]||new THREE.RenderableObject;Q.copy(u.position);q.multiplyVector3(Q);f.object=u;f.z=Q.z;p.push(f);e++}}t&&p.sort(a);return p};this.projectScene=function(m,i,t){var p=[],y=i.near,u=i.far,s,v,W,G,S,P,H,X,K,E,F,U,T,C,N,V;c=B=A=0;i.autoUpdateMatrix&&i.updateMatrix();q.multiply(i.projectionMatrix,i.matrix);P=this.projectObjects(m,i,true);m=0;for(s=P.length;m<s;m++){H=P[m].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();X=H.matrix;K=H.rotationMatrix;E=H.materials;F=H.overdraw;if(H instanceof
-THREE.Mesh){U=H.geometry;T=U.vertices;v=0;for(W=T.length;v<W;v++){C=T[v];C.positionWorld.copy(C.position);X.multiplyVector3(C.positionWorld);G=C.positionScreen;G.copy(C.positionWorld);q.multiplyVector4(G);G.x/=G.w;G.y/=G.w;C.__visible=G.z>y&&G.z<u}U=U.faces;v=0;for(W=U.length;v<W;v++){C=U[v];if(C instanceof THREE.Face3){G=T[C.a];S=T[C.b];N=T[C.c];if(G.__visible&&S.__visible&&N.__visible)if(H.doubleSided||H.flipSided!=(N.positionScreen.x-G.positionScreen.x)*(S.positionScreen.y-G.positionScreen.y)-
+THREE.Projector=function(){function a(l,i){return i.z-l.z}function b(l,i){var u=0,o=1,y=l.z+l.w,t=i.z+i.w,r=-l.z+l.w,v=-i.z+i.w;if(y>=0&&t>=0&&r>=0&&v>=0)return true;else if(y<0&&t<0||r<0&&v<0)return false;else{if(y<0)u=Math.max(u,y/(y-t));else if(t<0)o=Math.min(o,y/(y-t));if(r<0)u=Math.max(u,r/(r-v));else if(v<0)o=Math.min(o,r/(r-v));if(o<u)return false;else{l.lerpSelf(i,u);i.lerpSelf(l,1-o);return true}}}var f,e,g=[],j,p,c,k=[],m,B,D=[],x,A,M=[],Q=new THREE.Vector4,O=new THREE.Vector4,s=new THREE.Matrix4,
+L=new THREE.Matrix4,d=[],h=new THREE.Vector4,q=new THREE.Vector4,n;this.projectObjects=function(l,i,u){var o=[],y,t;e=0;s.multiply(i.projectionMatrix,i.matrix);d[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);d[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);d[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);d[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);d[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
+s.n33,s.n44-s.n34);d[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);i=0;for(y=d.length;i<y;i++){t=d[i];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}y=l.objects;l=0;for(i=y.length;l<i;l++){t=y[l];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var v=t.position,W=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),G=0;G<6;G++){r=d[G].x*v.x+d[G].y*v.y+d[G].z*v.z+d[G].w;if(r<=W){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
+g[e]=g[e]||new THREE.RenderableObject;Q.copy(t.position);s.multiplyVector3(Q);f.object=t;f.z=Q.z;o.push(f);e++}}u&&o.sort(a);return o};this.projectScene=function(l,i,u){var o=[],y=i.near,t=i.far,r,v,W,G,S,P,H,X,K,E,F,U,T,C,N,V;c=B=A=0;i.autoUpdateMatrix&&i.updateMatrix();s.multiply(i.projectionMatrix,i.matrix);P=this.projectObjects(l,i,true);l=0;for(r=P.length;l<r;l++){H=P[l].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();X=H.matrix;K=H.rotationMatrix;E=H.materials;F=H.overdraw;if(H instanceof
+THREE.Mesh){U=H.geometry;T=U.vertices;v=0;for(W=T.length;v<W;v++){C=T[v];C.positionWorld.copy(C.position);X.multiplyVector3(C.positionWorld);G=C.positionScreen;G.copy(C.positionWorld);s.multiplyVector4(G);G.x/=G.w;G.y/=G.w;C.__visible=G.z>y&&G.z<t}U=U.faces;v=0;for(W=U.length;v<W;v++){C=U[v];if(C instanceof THREE.Face3){G=T[C.a];S=T[C.b];N=T[C.c];if(G.__visible&&S.__visible&&N.__visible)if(H.doubleSided||H.flipSided!=(N.positionScreen.x-G.positionScreen.x)*(S.positionScreen.y-G.positionScreen.y)-
 (N.positionScreen.y-G.positionScreen.y)*(S.positionScreen.x-G.positionScreen.x)<0){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(S.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);
 (N.positionScreen.y-G.positionScreen.y)*(S.positionScreen.x-G.positionScreen.x)<0){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(S.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);
-j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);N=C.vertexNormals;l=j.vertexNormalsWorld;G=0;for(S=N.length;G<S;G++){V=l[G]=l[G]||new THREE.Vector3;V.copy(N[G]);K.multiplyVector3(V)}j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[v]){j.uvs[0]=H.geometry.uvs[v][0];j.uvs[1]=H.geometry.uvs[v][1];j.uvs[2]=H.geometry.uvs[v][2]}p.push(j);c++}}else if(C instanceof THREE.Face4){G=T[C.a];S=T[C.b];N=T[C.c];V=T[C.d];if(G.__visible&&
+j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);N=C.vertexNormals;n=j.vertexNormalsWorld;G=0;for(S=N.length;G<S;G++){V=n[G]=n[G]||new THREE.Vector3;V.copy(N[G]);K.multiplyVector3(V)}j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[v]){j.uvs[0]=H.geometry.uvs[v][0];j.uvs[1]=H.geometry.uvs[v][1];j.uvs[2]=H.geometry.uvs[v][2]}o.push(j);c++}}else if(C instanceof THREE.Face4){G=T[C.a];S=T[C.b];N=T[C.c];V=T[C.d];if(G.__visible&&
 S.__visible&&N.__visible&&V.__visible)if(H.doubleSided||H.flipSided!=((V.positionScreen.x-G.positionScreen.x)*(S.positionScreen.y-G.positionScreen.y)-(V.positionScreen.y-G.positionScreen.y)*(S.positionScreen.x-G.positionScreen.x)<0||(S.positionScreen.x-N.positionScreen.x)*(V.positionScreen.y-N.positionScreen.y)-(S.positionScreen.y-N.positionScreen.y)*(V.positionScreen.x-N.positionScreen.x)<0)){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(S.positionWorld);
 S.__visible&&N.__visible&&V.__visible)if(H.doubleSided||H.flipSided!=((V.positionScreen.x-G.positionScreen.x)*(S.positionScreen.y-G.positionScreen.y)-(V.positionScreen.y-G.positionScreen.y)*(S.positionScreen.x-G.positionScreen.x)<0||(S.positionScreen.x-N.positionScreen.x)*(V.positionScreen.y-N.positionScreen.y)-(S.positionScreen.y-N.positionScreen.y)*(V.positionScreen.x-N.positionScreen.x)<0)){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(S.positionWorld);
-j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[v]){j.uvs[0]=H.geometry.uvs[v][0];
-j.uvs[1]=H.geometry.uvs[v][1];j.uvs[2]=H.geometry.uvs[v][3]}p.push(j);c++;o=k[c]=k[c]||new THREE.RenderableFace3;o.v1.positionWorld.copy(S.positionWorld);o.v2.positionWorld.copy(N.positionWorld);o.v3.positionWorld.copy(V.positionWorld);o.v1.positionScreen.copy(S.positionScreen);o.v2.positionScreen.copy(N.positionScreen);o.v3.positionScreen.copy(V.positionScreen);o.normalWorld.copy(j.normalWorld);o.centroidWorld.copy(j.centroidWorld);o.centroidScreen.copy(j.centroidScreen);o.z=o.centroidScreen.z;o.meshMaterials=
-E;o.faceMaterials=C.materials;o.overdraw=F;if(H.geometry.uvs[v]){o.uvs[0]=H.geometry.uvs[v][1];o.uvs[1]=H.geometry.uvs[v][2];o.uvs[2]=H.geometry.uvs[v][3]}p.push(o);c++}}}}else if(H instanceof THREE.Line){L.multiply(q,X);T=H.geometry.vertices;C=T[0];C.positionScreen.copy(C.position);L.multiplyVector4(C.positionScreen);v=1;for(W=T.length;v<W;v++){G=T[v];G.positionScreen.copy(G.position);L.multiplyVector4(G.positionScreen);S=T[v-1];h.copy(G.positionScreen);r.copy(S.positionScreen);if(b(h,r)){h.multiplyScalar(1/
-h.w);r.multiplyScalar(1/r.w);n=D[B]=D[B]||new THREE.RenderableLine;n.v1.positionScreen.copy(h);n.v2.positionScreen.copy(r);n.z=Math.max(h.z,r.z);n.materials=H.materials;p.push(n);B++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);q.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14));
-x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;p.push(x);A++}}}}t&&p.sort(a);return p};this.unprojectVector=function(m,i){var t=new THREE.Matrix4;t.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));t.multiplyVector3(m);return m}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(o,c){f=o;e=c;g=f/2;j=e/2};this.render=function(o,c){var k,n,B,D,x,A,M,Q;a=b.projectScene(o,c);k=0;for(n=a.length;k<n;k++){x=a[k];if(x instanceof THREE.RenderableParticle){M=x.x*g+g;Q=x.y*j+j;B=0;for(D=x.material.length;B<D;B++){A=x.material[B];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=M+"px";A.style.top=Q+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)n.globalAlpha=x=ba}function b(ba){if(A!=ba){switch(ba){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}A=ba}}var f=null,e=new THREE.Projector,g=document.createElement("canvas"),j,o,c,k,n=g.getContext("2d"),B=null,D=null,x=1,A=0,M=null,Q=null,O=1,q,L,d,h,r,l,m,i,t,p=new THREE.Color,
-y=new THREE.Color,u=new THREE.Color,s=new THREE.Color,v=new THREE.Color,W,G,S,P,H,X,K,E,F,U=new THREE.Rectangle,T=new THREE.Rectangle,C=new THREE.Rectangle,N=false,V=new THREE.Color,ea=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,La=Math.PI*2,Z=new THREE.Vector3,ra,sa,Ca,fa,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);fa=Ca.data;ta=document.createElement("canvas");
-ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ba,la){j=ba;o=la;c=j/2;k=o/2;g.width=j;g.height=o;U.set(-c,-k,c,k)};this.setClearColor=function(ba,la){B=ba!==null?new THREE.Color(ba):null;D=la;T.set(-c,-k,c,k);n.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!T.isEmpty()){T.inflate(1);T.minSelf(U);if(B!==null){b(THREE.NormalBlending);a(1);n.fillStyle=
-"rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+D+")";n.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight())}else n.clearRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());T.empty()}};this.render=function(ba,la){function Ma(w){var R,J,z,I=w.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);w=0;for(R=I.length;w<R;w++){J=I[w];z=J.color;if(J instanceof THREE.AmbientLight){ea.r+=z.r;ea.g+=z.g;ea.b+=z.b}else if(J instanceof THREE.DirectionalLight){ma.r+=z.r;ma.g+=
+j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(S.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[v]){j.uvs[0]=H.geometry.uvs[v][0];
+j.uvs[1]=H.geometry.uvs[v][1];j.uvs[2]=H.geometry.uvs[v][3]}o.push(j);c++;p=k[c]=k[c]||new THREE.RenderableFace3;p.v1.positionWorld.copy(S.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(V.positionWorld);p.v1.positionScreen.copy(S.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(V.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
+E;p.faceMaterials=C.materials;p.overdraw=F;if(H.geometry.uvs[v]){p.uvs[0]=H.geometry.uvs[v][1];p.uvs[1]=H.geometry.uvs[v][2];p.uvs[2]=H.geometry.uvs[v][3]}o.push(p);c++}}}}else if(H instanceof THREE.Line){L.multiply(s,X);T=H.geometry.vertices;C=T[0];C.positionScreen.copy(C.position);L.multiplyVector4(C.positionScreen);v=1;for(W=T.length;v<W;v++){G=T[v];G.positionScreen.copy(G.position);L.multiplyVector4(G.positionScreen);S=T[v-1];h.copy(G.positionScreen);q.copy(S.positionScreen);if(b(h,q)){h.multiplyScalar(1/
+h.w);q.multiplyScalar(1/q.w);m=D[B]=D[B]||new THREE.RenderableLine;m.v1.positionScreen.copy(h);m.v2.positionScreen.copy(q);m.z=Math.max(h.z,q.z);m.materials=H.materials;o.push(m);B++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);s.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14));
+x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;o.push(x);A++}}}}u&&o.sort(a);return o};this.unprojectVector=function(l,i){var u=new THREE.Matrix4;u.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));u.multiplyVector3(l);return l}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(p,c){f=p;e=c;g=f/2;j=e/2};this.render=function(p,c){var k,m,B,D,x,A,M,Q;a=b.projectScene(p,c);k=0;for(m=a.length;k<m;k++){x=a[k];if(x instanceof THREE.RenderableParticle){M=x.x*g+g;Q=x.y*j+j;B=0;for(D=x.material.length;B<D;B++){A=x.material[B];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=M+"px";A.style.top=Q+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)m.globalAlpha=x=ba}function b(ba){if(A!=ba){switch(ba){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}A=ba}}var f=null,e=new THREE.Projector,g=document.createElement("canvas"),j,p,c,k,m=g.getContext("2d"),B=null,D=null,x=1,A=0,M=null,Q=null,O=1,s,L,d,h,q,n,l,i,u,o=new THREE.Color,
+y=new THREE.Color,t=new THREE.Color,r=new THREE.Color,v=new THREE.Color,W,G,S,P,H,X,K,E,F,U=new THREE.Rectangle,T=new THREE.Rectangle,C=new THREE.Rectangle,N=false,V=new THREE.Color,ea=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,La=Math.PI*2,Z=new THREE.Vector3,ra,sa,Ca,fa,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);fa=Ca.data;ta=document.createElement("canvas");
+ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ba,la){j=ba;p=la;c=j/2;k=p/2;g.width=j;g.height=p;U.set(-c,-k,c,k)};this.setClearColor=function(ba,la){B=ba!==null?new THREE.Color(ba):null;D=la;T.set(-c,-k,c,k);m.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!T.isEmpty()){T.inflate(1);T.minSelf(U);if(B!==null){b(THREE.NormalBlending);a(1);m.fillStyle=
+"rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+D+")";m.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight())}else m.clearRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());T.empty()}};this.render=function(ba,la){function Ma(w){var R,J,z,I=w.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);w=0;for(R=I.length;w<R;w++){J=I[w];z=J.color;if(J instanceof THREE.AmbientLight){ea.r+=z.r;ea.g+=z.g;ea.b+=z.b}else if(J instanceof THREE.DirectionalLight){ma.r+=z.r;ma.g+=
 z.g;ma.b+=z.b}else if(J instanceof THREE.PointLight){na.r+=z.r;na.g+=z.g;na.b+=z.b}}}function ya(w,R,J,z){var I,Y,aa,ca,da=w.lights;w=0;for(I=da.length;w<I;w++){Y=da[w];aa=Y.color;ca=Y.intensity;if(Y instanceof THREE.DirectionalLight){Y=J.dot(Y.position)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,R);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(w,R,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z,
 z.g;ma.b+=z.b}else if(J instanceof THREE.PointLight){na.r+=z.r;na.g+=z.g;na.b+=z.b}}}function ya(w,R,J,z){var I,Y,aa,ca,da=w.lights;w=0;for(I=da.length;w<I;w++){Y=da[w];aa=Y.color;ca=Y.intensity;if(Y instanceof THREE.DirectionalLight){Y=J.dot(Y.position)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,R);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(w,R,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z,
-I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=R.scale.x*c;Y=R.scale.y*k;J=I*ca;z=Y*da;C.set(w.x-J,w.y-z,w.x+J,w.y+z);if(U.instersects(C)){n.save();n.translate(w.x,w.y);n.rotate(-R.rotation);n.scale(I,-Y);n.translate(-ca,-da);n.drawImage(aa,0,0);n.restore()}}}else if(J instanceof THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;p.r=J.color.r*V.r;p.g=J.color.g*V.g;p.b=J.color.b*V.b;p.updateStyleString()}else p.__styleString=
-J.color.__styleString;J=R.scale.x*c;z=R.scale.y*k;C.set(w.x-J,w.y-z,w.x+J,w.y+z);if(U.instersects(C)){I=p.__styleString;if(Q!=I)n.fillStyle=Q=I;n.save();n.translate(w.x,w.y);n.rotate(-R.rotation);n.scale(J,z);n.beginPath();n.arc(0,0,1,0,La,true);n.closePath();n.fill();n.restore()}}}}function Oa(w,R,J,z){if(z.opacity!=0){a(z.opacity);b(z.blending);n.beginPath();n.moveTo(w.positionScreen.x,w.positionScreen.y);n.lineTo(R.positionScreen.x,R.positionScreen.y);n.closePath();if(z instanceof THREE.LineBasicMaterial){p.__styleString=
-z.color.__styleString;w=z.linewidth;if(O!=w)n.lineWidth=O=w;w=p.__styleString;if(M!=w)n.strokeStyle=M=w;n.stroke();C.inflate(z.linewidth*2)}}}function Ha(w,R,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=w.positionScreen.x;r=w.positionScreen.y;l=R.positionScreen.x;m=R.positionScreen.y;i=J.positionScreen.x;t=J.positionScreen.y;n.beginPath();n.moveTo(h,r);n.lineTo(l,m);n.lineTo(i,t);n.lineTo(h,r);n.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof
-THREE.UVMapping&&ua(h,r,l,m,i,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;H=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;K=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=
-(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;F=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;ua(h,r,l,m,i,t,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ua(h,r,l,m,i,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&
-z.vertexNormalsWorld.length==3){y.r=u.r=s.r=ea.r;y.g=u.g=s.g=ea.g;y.b=u.b=s.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],u);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],s);v.r=(u.r+s.r)*0.5;v.g=(u.g+s.g)*0.5;v.b=(u.b+s.b)*0.5;S=Ia(y,u,s,v);ua(h,r,l,m,i,t,S,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);p.r=I.color.r*V.r;p.g=I.color.g*V.g;p.b=I.color.b*V.b;p.updateStyleString();I.wireframe?za(p.__styleString,
-I.wireframe_linewidth):Aa(p.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(w.positionScreen.z,W,G);u.r=u.g=u.b=1-Da(R.positionScreen.z,W,G);s.r=s.g=s.b=1-Da(J.positionScreen.z,W,G);v.r=(u.r+s.r)*0.5;v.g=(u.g+s.g)*0.5;v.b=(u.b+s.b)*0.5;S=Ia(y,u,s,v);ua(h,r,l,m,i,t,S,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){p.r=Ea(z.normalWorld.x);p.g=Ea(z.normalWorld.y);
-p.b=Ea(z.normalWorld.z);p.updateStyleString();I.wireframe?za(p.__styleString,I.wireframe_linewidth):Aa(p.__styleString)}}}function za(w,R){if(M!=w)n.strokeStyle=M=w;if(O!=R)n.lineWidth=O=R;n.stroke();C.inflate(R*2)}function Aa(w){if(Q!=w)n.fillStyle=Q=w;n.fill()}function ua(w,R,J,z,I,Y,aa,ca,da,ia,ga,ja,va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=w;z-=R;I-=w;Y-=R;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-
-ja*J)*ka;z=(ia*Y-ja*z)*ka;w=w-oa*ca-J*da;R=R-ga*ca-z*da;n.save();n.transform(oa,ga,J,z,w,R);n.clip();n.drawImage(aa,0,0);n.restore()}function Ia(w,R,J,z){var I=~~(w.r*255),Y=~~(w.g*255);w=~~(w.b*255);var aa=~~(R.r*255),ca=~~(R.g*255);R=~~(R.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=w<0?0:w>255?255:w;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=R<0?0:R>255?255:R;fa[8]=da<
-0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(w,R,J){w=(w-R)/(J-R);return w*w*(3-2*w)}function Ea(w){w=(w+1)*0.5;return w<0?0:w>1?1:w}function Fa(w,R){var J=R.x-w.x,z=R.y-w.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;R.x+=J;R.y+=z;w.x-=J;w.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;n.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,
-la,this.sortElements);(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){q=$;q.x*=c;q.y*=k;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(q,$,$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){q=$.v1;L=$.v2;q.positionScreen.x*=c;q.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;C.addPoint(q.positionScreen.x,q.positionScreen.y);C.addPoint(L.positionScreen.x,L.positionScreen.y);if(U.instersects(C)){ha=
-0;for(qa=$.materials.length;ha<qa;)Oa(q,L,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){q=$.v1;L=$.v2;d=$.v3;q.positionScreen.x*=c;q.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;d.positionScreen.x*=c;d.positionScreen.y*=k;if($.overdraw){Fa(q.positionScreen,L.positionScreen);Fa(L.positionScreen,d.positionScreen);Fa(d.positionScreen,q.positionScreen)}C.add3Points(q.positionScreen.x,q.positionScreen.y,L.positionScreen.x,L.positionScreen.y,d.positionScreen.x,
-d.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.meshMaterials.length;ha<qa;){wa=$.meshMaterials[ha++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(wa=$.faceMaterials[Ga++])&&Ha(q,L,d,$,wa,ba)}else Ha(q,L,d,$,wa,ba)}}}T.addRectangle(C)}n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(P,H,X){var K,E,F,U;K=0;for(E=P.lights.length;K<E;K++){F=P.lights[K];if(F instanceof THREE.DirectionalLight){U=H.normalWorld.dot(F.position)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){t.sub(F.position,H.centroidWorld);t.normalize();U=H.normalWorld.dot(t)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){s=e(v++);s.setAttribute("d","M "+P.positionScreen.x+
-" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=r.r;h.g=r.g;h.b=r.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear);
-d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(s)}function f(P,H,X,K,E,F,U){s=e(v++);s.setAttribute("d",
-"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=r.r;h.g=r.g;h.b=r.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i=
-1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(s)}
-function e(P){if(p[P]==null){p[P]=document.createElementNS("http://www.w3.org/2000/svg","path");S==0&&p[P].setAttribute("shape-rendering","crispEdges");return p[P]}return p[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,o=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,B,D,x,A,M,Q,O=new THREE.Rectangle,q=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),r=new THREE.Color(0),l=new THREE.Color(0),
-m=new THREE.Color(0),i,t=new THREE.Vector3,p=[],y=[],u=[],s,v,W,G,S=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":S=1;break;case "low":S=0}};this.setSize=function(P,H){k=P;n=H;B=k/2;D=n/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+n);c.setAttribute("width",k);c.setAttribute("height",n);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K,
-E,F,U,T,C,N;this.autoClear&&this.clear();j=o.projectScene(P,H,this.sortElements);G=W=v=0;if(L=P.lights.length>0){C=P.lights;r.setRGB(0,0,0);l.setRGB(0,0,0);m.setRGB(0,0,0);X=0;for(K=C.length;X<K;X++){E=C[X];F=E.color;if(E instanceof THREE.AmbientLight){r.r+=F.r;r.g+=F.g;r.b+=F.b}else if(E instanceof THREE.DirectionalLight){l.r+=F.r;l.g+=F.g;l.b+=F.b}else if(E instanceof THREE.PointLight){m.r+=F.r;m.g+=F.g;m.b+=F.b}}}X=0;for(K=j.length;X<K;X++){C=j[X];q.empty();if(C instanceof THREE.RenderableParticle){x=
-C;x.x*=B;x.y*=-D;E=0;for(F=C.materials.length;E<F;E++)if(N=C.materials[E]){U=x;T=C;N=N;var V=W++;if(y[V]==null){y[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");S==0&&y[V].setAttribute("shape-rendering","crispEdges")}s=y[V];s.setAttribute("cx",U.x);s.setAttribute("cy",U.y);s.setAttribute("r",T.scale.x*B);if(N instanceof THREE.ParticleCircleMaterial){if(L){h.r=r.r+l.r+m.r;h.g=r.g+l.g+m.g;h.b=r.b+l.b+m.b;d.r=N.color.r*h.r;d.g=N.color.g*h.g;d.b=N.color.b*h.b;d.updateStyleString()}else d=
-N.color;s.setAttribute("style","fill: "+d.__styleString)}c.appendChild(s)}}else if(C instanceof THREE.RenderableLine){x=C.v1;A=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);if(O.instersects(q)){E=0;for(F=C.materials.length;E<F;)if(N=C.materials[E++]){U=x;T=A;N=N;V=G++;if(u[V]==null){u[V]=document.createElementNS("http://www.w3.org/2000/svg","line");S==
-0&&u[V].setAttribute("shape-rendering","crispEdges")}s=u[V];s.setAttribute("x1",U.positionScreen.x);s.setAttribute("y1",U.positionScreen.y);s.setAttribute("x2",T.positionScreen.x);s.setAttribute("y2",T.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){d.__styleString=N.color.__styleString;s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);c.appendChild(s)}}}}else if(C instanceof
-THREE.RenderableFace3){x=C.v1;A=C.v2;M=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(q)){E=0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(T=C.faceMaterials.length;U<T;)(N=C.faceMaterials[U++])&&
-b(x,A,M,C,N,P)}else N&&b(x,A,M,C,N,P)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;A=C.v2;M=C.v3;Q=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;Q.positionScreen.x*=B;Q.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(M.positionScreen.x,M.positionScreen.y);q.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(q)){E=
+I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=R.scale.x*c;Y=R.scale.y*k;J=I*ca;z=Y*da;C.set(w.x-J,w.y-z,w.x+J,w.y+z);if(U.instersects(C)){m.save();m.translate(w.x,w.y);m.rotate(-R.rotation);m.scale(I,-Y);m.translate(-ca,-da);m.drawImage(aa,0,0);m.restore()}}}else if(J instanceof THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;o.r=J.color.r*V.r;o.g=J.color.g*V.g;o.b=J.color.b*V.b;o.updateStyleString()}else o.__styleString=
+J.color.__styleString;J=R.scale.x*c;z=R.scale.y*k;C.set(w.x-J,w.y-z,w.x+J,w.y+z);if(U.instersects(C)){I=o.__styleString;if(Q!=I)m.fillStyle=Q=I;m.save();m.translate(w.x,w.y);m.rotate(-R.rotation);m.scale(J,z);m.beginPath();m.arc(0,0,1,0,La,true);m.closePath();m.fill();m.restore()}}}}function Oa(w,R,J,z){if(z.opacity!=0){a(z.opacity);b(z.blending);m.beginPath();m.moveTo(w.positionScreen.x,w.positionScreen.y);m.lineTo(R.positionScreen.x,R.positionScreen.y);m.closePath();if(z instanceof THREE.LineBasicMaterial){o.__styleString=
+z.color.__styleString;w=z.linewidth;if(O!=w)m.lineWidth=O=w;w=o.__styleString;if(M!=w)m.strokeStyle=M=w;m.stroke();C.inflate(z.linewidth*2)}}}function Ha(w,R,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=w.positionScreen.x;q=w.positionScreen.y;n=R.positionScreen.x;l=R.positionScreen.y;i=J.positionScreen.x;u=J.positionScreen.y;m.beginPath();m.moveTo(h,q);m.lineTo(n,l);m.lineTo(i,u);m.lineTo(h,q);m.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof
+THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;H=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;K=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=
+(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;F=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;ua(h,q,n,l,i,u,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&
+z.vertexNormalsWorld.length==3){y.r=t.r=r.r=ea.r;y.g=t.g=r.g=ea.g;y.b=t.b=r.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],t);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],r);v.r=(t.r+r.r)*0.5;v.g=(t.g+r.g)*0.5;v.b=(t.b+r.b)*0.5;S=Ia(y,t,r,v);ua(h,q,n,l,i,u,S,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);o.r=I.color.r*V.r;o.g=I.color.g*V.g;o.b=I.color.b*V.b;o.updateStyleString();I.wireframe?za(o.__styleString,
+I.wireframe_linewidth):Aa(o.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(w.positionScreen.z,W,G);t.r=t.g=t.b=1-Da(R.positionScreen.z,W,G);r.r=r.g=r.b=1-Da(J.positionScreen.z,W,G);v.r=(t.r+r.r)*0.5;v.g=(t.g+r.g)*0.5;v.b=(t.b+r.b)*0.5;S=Ia(y,t,r,v);ua(h,q,n,l,i,u,S,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){o.r=Ea(z.normalWorld.x);o.g=Ea(z.normalWorld.y);
+o.b=Ea(z.normalWorld.z);o.updateStyleString();I.wireframe?za(o.__styleString,I.wireframe_linewidth):Aa(o.__styleString)}}}function za(w,R){if(M!=w)m.strokeStyle=M=w;if(O!=R)m.lineWidth=O=R;m.stroke();C.inflate(R*2)}function Aa(w){if(Q!=w)m.fillStyle=Q=w;m.fill()}function ua(w,R,J,z,I,Y,aa,ca,da,ia,ga,ja,va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=w;z-=R;I-=w;Y-=R;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-
+ja*J)*ka;z=(ia*Y-ja*z)*ka;w=w-oa*ca-J*da;R=R-ga*ca-z*da;m.save();m.transform(oa,ga,J,z,w,R);m.clip();m.drawImage(aa,0,0);m.restore()}function Ia(w,R,J,z){var I=~~(w.r*255),Y=~~(w.g*255);w=~~(w.b*255);var aa=~~(R.r*255),ca=~~(R.g*255);R=~~(R.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=w<0?0:w>255?255:w;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=R<0?0:R>255?255:R;fa[8]=da<
+0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(w,R,J){w=(w-R)/(J-R);return w*w*(3-2*w)}function Ea(w){w=(w+1)*0.5;return w<0?0:w>1?1:w}function Fa(w,R){var J=R.x-w.x,z=R.y-w.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;R.x+=J;R.y+=z;w.x-=J;w.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;m.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,
+la,this.sortElements);(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){s=$;s.x*=c;s.y*=k;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(s,$,$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){s=$.v1;L=$.v2;s.positionScreen.x*=c;s.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(L.positionScreen.x,L.positionScreen.y);if(U.instersects(C)){ha=
+0;for(qa=$.materials.length;ha<qa;)Oa(s,L,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){s=$.v1;L=$.v2;d=$.v3;s.positionScreen.x*=c;s.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;d.positionScreen.x*=c;d.positionScreen.y*=k;if($.overdraw){Fa(s.positionScreen,L.positionScreen);Fa(L.positionScreen,d.positionScreen);Fa(d.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,L.positionScreen.x,L.positionScreen.y,d.positionScreen.x,
+d.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.meshMaterials.length;ha<qa;){wa=$.meshMaterials[ha++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(wa=$.faceMaterials[Ga++])&&Ha(s,L,d,$,wa,ba)}else Ha(s,L,d,$,wa,ba)}}}T.addRectangle(C)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(P,H,X){var K,E,F,U;K=0;for(E=P.lights.length;K<E;K++){F=P.lights[K];if(F instanceof THREE.DirectionalLight){U=H.normalWorld.dot(F.position)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){u.sub(F.position,H.centroidWorld);u.normalize();U=H.normalWorld.dot(u)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){r=e(v++);r.setAttribute("d","M "+P.positionScreen.x+
+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear);
+d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(r)}function f(P,H,X,K,E,F,U){r=e(v++);r.setAttribute("d",
+"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i=
+1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(r)}
+function e(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");S==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,B,D,x,A,M,Q,O=new THREE.Rectangle,s=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),q=new THREE.Color(0),n=new THREE.Color(0),
+l=new THREE.Color(0),i,u=new THREE.Vector3,o=[],y=[],t=[],r,v,W,G,S=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":S=1;break;case "low":S=0}};this.setSize=function(P,H){k=P;m=H;B=k/2;D=m/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+m);c.setAttribute("width",k);c.setAttribute("height",m);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K,
+E,F,U,T,C,N;this.autoClear&&this.clear();j=p.projectScene(P,H,this.sortElements);G=W=v=0;if(L=P.lights.length>0){C=P.lights;q.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);X=0;for(K=C.length;X<K;X++){E=C[X];F=E.color;if(E instanceof THREE.AmbientLight){q.r+=F.r;q.g+=F.g;q.b+=F.b}else if(E instanceof THREE.DirectionalLight){n.r+=F.r;n.g+=F.g;n.b+=F.b}else if(E instanceof THREE.PointLight){l.r+=F.r;l.g+=F.g;l.b+=F.b}}}X=0;for(K=j.length;X<K;X++){C=j[X];s.empty();if(C instanceof THREE.RenderableParticle){x=
+C;x.x*=B;x.y*=-D;E=0;for(F=C.materials.length;E<F;E++)if(N=C.materials[E]){U=x;T=C;N=N;var V=W++;if(y[V]==null){y[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");S==0&&y[V].setAttribute("shape-rendering","crispEdges")}r=y[V];r.setAttribute("cx",U.x);r.setAttribute("cy",U.y);r.setAttribute("r",T.scale.x*B);if(N instanceof THREE.ParticleCircleMaterial){if(L){h.r=q.r+n.r+l.r;h.g=q.g+n.g+l.g;h.b=q.b+n.b+l.b;d.r=N.color.r*h.r;d.g=N.color.g*h.g;d.b=N.color.b*h.b;d.updateStyleString()}else d=
+N.color;r.setAttribute("style","fill: "+d.__styleString)}c.appendChild(r)}}else if(C instanceof THREE.RenderableLine){x=C.v1;A=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(A.positionScreen.x,A.positionScreen.y);if(O.instersects(s)){E=0;for(F=C.materials.length;E<F;)if(N=C.materials[E++]){U=x;T=A;N=N;V=G++;if(t[V]==null){t[V]=document.createElementNS("http://www.w3.org/2000/svg","line");S==
+0&&t[V].setAttribute("shape-rendering","crispEdges")}r=t[V];r.setAttribute("x1",U.positionScreen.x);r.setAttribute("y1",U.positionScreen.y);r.setAttribute("x2",T.positionScreen.x);r.setAttribute("y2",T.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){d.__styleString=N.color.__styleString;r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);c.appendChild(r)}}}}else if(C instanceof
+THREE.RenderableFace3){x=C.v1;A=C.v2;M=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(A.positionScreen.x,A.positionScreen.y);s.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(s)){E=0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(T=C.faceMaterials.length;U<T;)(N=C.faceMaterials[U++])&&
+b(x,A,M,C,N,P)}else N&&b(x,A,M,C,N,P)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;A=C.v2;M=C.v3;Q=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;Q.positionScreen.x*=B;Q.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(A.positionScreen.x,A.positionScreen.y);s.addPoint(M.positionScreen.x,M.positionScreen.y);s.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(s)){E=
 0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(T=C.faceMaterials.length;U<T;)(N=C.faceMaterials[U++])&&f(x,A,M,Q,C,N,P)}else N&&f(x,A,M,Q,C,N,P)}}}}}};
 0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(T=C.faceMaterials.length;U<T;)(N=C.faceMaterials[U++])&&f(x,A,M,Q,C,N,P)}else N&&f(x,A,M,Q,C,N,P)}}}}}};
 THREE.WebGLRenderer=function(a){function b(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function f(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;d.uniforms.map.texture=d.map;d.uniforms.env_map.texture=d.env_map;d.uniforms.reflectivity.value=d.reflectivity;d.uniforms.refraction_ratio.value=d.refraction_ratio;d.uniforms.combine.value=d.combine;d.uniforms.useRefract.value=
 THREE.WebGLRenderer=function(a){function b(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function f(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;d.uniforms.map.texture=d.map;d.uniforms.env_map.texture=d.env_map;d.uniforms.reflectivity.value=d.reflectivity;d.uniforms.refraction_ratio.value=d.refraction_ratio;d.uniforms.combine.value=d.combine;d.uniforms.useRefract.value=
 d.env_map&&d.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function e(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=
 d.env_map&&d.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function e(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=
-h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var r;if(d=="fragment")r=c.createShader(c.FRAGMENT_SHADER);else if(d=="vertex")r=c.createShader(c.VERTEX_SHADER);c.shaderSource(r,h);c.compileShader(r);if(!c.getShaderParameter(r,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(r));return null}return r}function j(d){switch(d){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,k=null,n=new THREE.Matrix4,B,D=new Float32Array(16),x=new Float32Array(16),A=new Float32Array(16),
-M=new Float32Array(9),Q=new Float32Array(16),O=true,q=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&q.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(d,h,r){try{c=o.getContext("experimental-webgl",{antialias:d})}catch(l){}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(h.r,h.g,h.b,r)})(O,q,L);this.setSize=function(d,h){o.width=d;o.height=h;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(d,h){var r=new THREE.Color(d);c.clearColor(r.r,r.g,r.b,h)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var r,l,m,i=0,t=0,p=0,y=[],u=[],s=[],v=[];r=0;for(l=h.length;r<l;r++){m=h[r];if(m instanceof THREE.AmbientLight){i+=
-m.color.r;t+=m.color.g;p+=m.color.b}else if(m instanceof THREE.DirectionalLight){y.push(m.color.r*m.intensity,m.color.g*m.intensity,m.color.b*m.intensity);u.push(m.position.x,m.position.y,m.position.z)}else if(m instanceof THREE.PointLight){s.push(m.color.r*m.intensity,m.color.g*m.intensity,m.color.b*m.intensity);v.push(m.position.x,m.position.y,m.position.z)}}return{ambient:[i,t,p],directional:{colors:y,positions:u},point:{colors:s,positions:v}}};this.createLineBuffers=function(d){var h,r,l,m=[],
-i=[],t=d.geometry.vertices;h=0;for(r=t.length;h<r;h++){l=t[h].position;m.push(l.x,l.y,l.z);i.push(h)}if(m.length){d.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(m),c.STATIC_DRAW);d.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(i),c.STATIC_DRAW);d.__webGLLineCount=i.length}};this.createBuffers=function(d,h){var r,l,
-m,i,t,p,y,u,s,v,W=[],G=[],S=[],P=[],H=[],X=[],K=0,E=d.geometry.geometryChunks[h],F;t=false;r=0;for(l=d.materials.length;r<l;r++){p=d.materials[r];if(p instanceof THREE.MeshFaceMaterial){p=0;for(F=E.materials.length;p<F;p++)if(E.materials[p]&&E.materials[p].shading!=undefined&&E.materials[p].shading==THREE.SmoothShading){t=true;break}}else if(p&&p.shading!=undefined&&p.shading==THREE.SmoothShading){t=true;break}if(t)break}F=t;r=0;for(l=E.faces.length;r<l;r++){m=E.faces[r];i=d.geometry.faces[m];t=i.vertexNormals;
-p=i.normal;m=d.geometry.uvs[m];if(i instanceof THREE.Face3){y=d.geometry.vertices[i.a].position;u=d.geometry.vertices[i.b].position;s=d.geometry.vertices[i.c].position;S.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;u=d.geometry.vertices[i.b].tangent;s=d.geometry.vertices[i.c].tangent;H.push(y.x,y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w)}if(t.length==3&&F)for(i=0;i<3;i++)P.push(t[i].x,t[i].y,t[i].z);else for(i=0;i<3;i++)P.push(p.x,p.y,p.z);
-if(m)for(i=0;i<3;i++)X.push(m[i].u,m[i].v);W.push(K,K+1,K+2);G.push(K,K+1,K,K+2,K+1,K+2);K+=3}else if(i instanceof THREE.Face4){y=d.geometry.vertices[i.a].position;u=d.geometry.vertices[i.b].position;s=d.geometry.vertices[i.c].position;v=d.geometry.vertices[i.d].position;S.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z,v.x,v.y,v.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;u=d.geometry.vertices[i.b].tangent;s=d.geometry.vertices[i.c].tangent;i=d.geometry.vertices[i.d].tangent;H.push(y.x,
-y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}if(t.length==4&&F)for(i=0;i<4;i++)P.push(t[i].x,t[i].y,t[i].z);else for(i=0;i<4;i++)P.push(p.x,p.y,p.z);if(m)for(i=0;i<4;i++)X.push(m[i].u,m[i].v);W.push(K,K+1,K+2,K,K+2,K+3);G.push(K,K+1,K,K+2,K,K+3,K+1,K+2,K+2,K+3);K+=4}}if(S.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,
+h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var q;if(d=="fragment")q=c.createShader(c.FRAGMENT_SHADER);else if(d=="vertex")q=c.createShader(c.VERTEX_SHADER);c.shaderSource(q,h);c.compileShader(q);if(!c.getShaderParameter(q,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(q));return null}return q}function j(d){switch(d){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 p=document.createElement("canvas"),c,k=null,m=new THREE.Matrix4,B,D=new Float32Array(16),x=new Float32Array(16),A=new Float32Array(16),
+M=new Float32Array(9),Q=new Float32Array(16),O=true,s=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&s.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=p;this.autoClear=true;(function(d,h,q){try{c=p.getContext("experimental-webgl",{antialias:d})}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(h.r,h.g,h.b,q)})(O,s,L);this.setSize=function(d,h){p.width=d;p.height=h;c.viewport(0,0,p.width,p.height)};this.setClearColor=function(d,h){var q=new THREE.Color(d);c.clearColor(q.r,q.g,q.b,h)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var q,n,l,i=0,u=0,o=0,y=[],t=[],r=[],v=[];q=0;for(n=h.length;q<n;q++){l=h[q];if(l instanceof THREE.AmbientLight){i+=
+l.color.r;u+=l.color.g;o+=l.color.b}else if(l instanceof THREE.DirectionalLight){y.push(l.color.r*l.intensity,l.color.g*l.intensity,l.color.b*l.intensity);t.push(l.position.x,l.position.y,l.position.z)}else if(l instanceof THREE.PointLight){r.push(l.color.r*l.intensity,l.color.g*l.intensity,l.color.b*l.intensity);v.push(l.position.x,l.position.y,l.position.z)}}return{ambient:[i,u,o],directional:{colors:y,positions:t},point:{colors:r,positions:v}}};this.createParticleBuffers=function(){};this.createLineBuffers=
+function(d){var h,q,n,l=[],i=[],u=d.geometry.vertices;h=0;for(q=u.length;h<q;h++){n=u[h].position;l.push(n.x,n.y,n.z);i.push(h)}if(l.length){d.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(l),c.STATIC_DRAW);d.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(i),c.STATIC_DRAW);d.__webGLLineCount=i.length}};this.createBuffers=
+function(d,h){var q,n,l,i,u,o,y,t,r,v,W=[],G=[],S=[],P=[],H=[],X=[],K=0,E=d.geometry.geometryChunks[h],F;u=false;q=0;for(n=d.materials.length;q<n;q++){o=d.materials[q];if(o instanceof THREE.MeshFaceMaterial){o=0;for(F=E.materials.length;o<F;o++)if(E.materials[o]&&E.materials[o].shading!=undefined&&E.materials[o].shading==THREE.SmoothShading){u=true;break}}else if(o&&o.shading!=undefined&&o.shading==THREE.SmoothShading){u=true;break}if(u)break}F=u;q=0;for(n=E.faces.length;q<n;q++){l=E.faces[q];i=d.geometry.faces[l];
+u=i.vertexNormals;o=i.normal;l=d.geometry.uvs[l];if(i instanceof THREE.Face3){y=d.geometry.vertices[i.a].position;t=d.geometry.vertices[i.b].position;r=d.geometry.vertices[i.c].position;S.push(y.x,y.y,y.z,t.x,t.y,t.z,r.x,r.y,r.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;t=d.geometry.vertices[i.b].tangent;r=d.geometry.vertices[i.c].tangent;H.push(y.x,y.y,y.z,y.w,t.x,t.y,t.z,t.w,r.x,r.y,r.z,r.w)}if(u.length==3&&F)for(i=0;i<3;i++)P.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<3;i++)P.push(o.x,
+o.y,o.z);if(l)for(i=0;i<3;i++)X.push(l[i].u,l[i].v);W.push(K,K+1,K+2);G.push(K,K+1,K,K+2,K+1,K+2);K+=3}else if(i instanceof THREE.Face4){y=d.geometry.vertices[i.a].position;t=d.geometry.vertices[i.b].position;r=d.geometry.vertices[i.c].position;v=d.geometry.vertices[i.d].position;S.push(y.x,y.y,y.z,t.x,t.y,t.z,r.x,r.y,r.z,v.x,v.y,v.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;t=d.geometry.vertices[i.b].tangent;r=d.geometry.vertices[i.c].tangent;i=d.geometry.vertices[i.d].tangent;
+H.push(y.x,y.y,y.z,y.w,t.x,t.y,t.z,t.w,r.x,r.y,r.z,r.w,i.x,i.y,i.z,i.w)}if(u.length==4&&F)for(i=0;i<4;i++)P.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<4;i++)P.push(o.x,o.y,o.z);if(l)for(i=0;i<4;i++)X.push(l[i].u,l[i].v);W.push(K,K+1,K+2,K,K+2,K+3);G.push(K,K+1,K,K+2,K,K+3,K+1,K+2,K+2,K+3);K+=4}}if(S.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(S),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,
 E.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);if(d.geometry.hasTangents){E.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}if(X.length>0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
 E.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);if(d.geometry.hasTangents){E.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}if(X.length>0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,r,l,m){var i,t,p,y;if(!l.program){if(l instanceof THREE.MeshDepthMaterial){b(l,THREE.ShaderLib.depth);l.uniforms.mNear.value=d.near;l.uniforms.mFar.value=d.far}else if(l instanceof
-THREE.MeshNormalMaterial)b(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial){b(l,THREE.ShaderLib.basic);f(l,r)}else if(l instanceof THREE.MeshLambertMaterial){b(l,THREE.ShaderLib.lambert);f(l,r)}else if(l instanceof THREE.MeshPhongMaterial){b(l,THREE.ShaderLib.phong);f(l,r)}else if(l instanceof THREE.LineBasicMaterial){b(l,THREE.ShaderLib.basic);e(l,r)}if(scene){var u,s,v;u=y=t=0;for(s=h.length;u<s;u++){v=h[u];v instanceof THREE.DirectionalLight&&y++;v instanceof THREE.PointLight&&
-t++}if(t+y<=4){u=y;t=t}else{u=Math.ceil(4*y/(t+y));t=4-u}t={directional:u,point:t}}else t={directional:1,point:3};y={fog:r,map:l.map,env_map:l.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=l.fragment_shader;u=l.vertex_shader;s=c.createProgram();v=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",
-y.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");y=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
-c.attachShader(s,g("fragment",v+t));c.attachShader(s,g("vertex",y+u));c.linkProgram(s);c.getProgramParameter(s,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(s,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");s.uniforms={};s.attributes={};l.program=s;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in l.uniforms)t.push(i);i=l.program;u=0;for(s=t.length;u<s;u++){v=t[u];i.uniforms[v]=c.getUniformLocation(i,
-v)}i=l.program;t=["position","normal","uv","tangent"];u=0;for(s=t.length;u<s;u++){v=t[u];i.attributes[v]=c.getAttribLocation(i,v)}}i=l.program;if(i!=k){c.useProgram(i);k=i}this.loadCamera(i,d);this.loadMatrices(i);if(l instanceof THREE.MeshPhongMaterial||l instanceof THREE.MeshLambertMaterial){d=this.setupLights(i,h);l.uniforms.enableLighting.value=d.directional.positions.length+d.point.positions.length;l.uniforms.ambientLightColor.value=d.ambient;l.uniforms.directionalLightColor.value=d.directional.colors;
-l.uniforms.directionalLightDirection.value=d.directional.positions;l.uniforms.pointLightColor.value=d.point.colors;l.uniforms.pointLightPosition.value=d.point.positions}if(l instanceof THREE.MeshBasicMaterial||l instanceof THREE.MeshLambertMaterial||l instanceof THREE.MeshPhongMaterial)f(l,r);l instanceof THREE.LineBasicMaterial&&e(l,r);if(l instanceof THREE.MeshPhongMaterial){l.uniforms.ambient.value.setRGB(l.ambient.r,l.ambient.g,l.ambient.b);l.uniforms.specular.value.setRGB(l.specular.r,l.specular.g,
-l.specular.b);l.uniforms.shininess.value=l.shininess}r=l.uniforms;for(p in r)if(t=i.uniforms[p]){h=r[p].type;d=r[p].value;if(h=="i")c.uniform1i(t,d);else if(h=="f")c.uniform1f(t,d);else if(h=="fv")c.uniform3fv(t,d);else if(h=="v2")c.uniform2f(t,d.x,d.y);else if(h=="v3")c.uniform3f(t,d.x,d.y,d.z);else if(h=="c")c.uniform3f(t,d.r,d.g,d.b);else if(h=="t"){c.uniform1i(t,d);if(h=r[p].texture)if(h.image instanceof Array&&h.image.length==6){h=h;d=d;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(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,
-h.image[t]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}else{h=h;d=d;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,j(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,
-j(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}}}p=i.attributes;c.bindBuffer(c.ARRAY_BUFFER,m.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.position);if(p.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLNormalBuffer);
-c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.normal)}if(p.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLTangentBuffer);c.vertexAttribPointer(p.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(m.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLUVBuffer);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.uv)}else c.disableVertexAttribArray(p.uv);if(l.wireframe||l instanceof THREE.LineBasicMaterial){p=
-l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&m.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);c.drawElements(l,m.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,m.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,r,l,m,i,t){var p,y,u,s,v;u=0;for(s=
-l.materials.length;u<s;u++){p=l.materials[u];if(p instanceof THREE.MeshFaceMaterial){p=0;for(y=m.materials.length;p<y;p++)if((v=m.materials[p])&&v.blending==i&&v.opacity<1==t){this.setBlending(v.blending);this.renderBuffer(d,h,r,v,m)}}else if((v=p)&&v.blending==i&&v.opacity<1==t){this.setBlending(v.blending);this.renderBuffer(d,h,r,v,m)}}};this.render=function(d,h){var r,l,m,i,t=d.lights,p=d.fog;this.initWebGLObjects(d);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();D.set(h.matrix.flatten());
-A.set(h.projectionMatrix.flatten());r=0;for(l=d.__webGLObjects.length;r<l;r++){m=d.__webGLObjects[r];i=m.object;m=m.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,t,p,i,m,THREE.NormalBlending,false)}}r=0;for(l=d.__webGLObjects.length;r<l;r++){m=d.__webGLObjects[r];i=m.object;m=m.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,t,p,i,m,THREE.AdditiveBlending,false);this.renderPass(h,t,p,i,m,THREE.SubtractiveBlending,false);this.renderPass(h,t,p,i,m,THREE.AdditiveBlending,
-true);this.renderPass(h,t,p,i,m,THREE.SubtractiveBlending,true);this.renderPass(h,t,p,i,m,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(d){var h,r,l,m,i,t;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={}}h=0;for(r=d.objects.length;h<r;h++){l=d.objects[h];if(d.__webGLObjectsMap[l.id]==undefined)d.__webGLObjectsMap[l.id]={};t=d.__webGLObjectsMap[l.id];if(l instanceof THREE.Mesh)for(i in l.geometry.geometryChunks){m=l.geometry.geometryChunks[i];m.__webGLVertexBuffer||this.createBuffers(l,
-i);if(t[i]==undefined){m={buffer:m,object:l};d.__webGLObjects.push(m);t[i]=1}}else if(l instanceof THREE.Line){l.__webGLVertexBuffer||this.createLineBuffers(l);i=0;if(t[i]==undefined){m={buffer:l,object:l};d.__webGLObjects.push(m);t[i]=1}}}};this.removeObject=function(d,h){var r,l;for(r=d.__webGLObjects.length-1;r>=0;r--){l=d.__webGLObjects[r].object;h==l&&d.__webGLObjects.splice(r,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();n.multiply(h.matrix,d.matrix);x.set(n.flatten());
-B=THREE.Matrix4.makeInvert3x3(n).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=
-function(d){switch(d){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(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=
-function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,q,n,l){var i,u,o,y;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=d.near;n.uniforms.mFar.value=d.far}else if(n instanceof
+THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);f(n,q)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);f(n,q)}else if(n instanceof THREE.MeshPhongMaterial){b(n,THREE.ShaderLib.phong);f(n,q)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,q)}var t,r,v;t=y=u=0;for(r=h.length;t<r;t++){v=h[t];v instanceof THREE.DirectionalLight&&y++;v instanceof THREE.PointLight&&u++}if(u+
+y<=4){t=y;u=u}else{t=Math.ceil(4*y/(u+y));u=4-t}u={directional:t,point:u};y={fog:q,map:n.map,env_map:n.env_map,maxDirLights:u.directional,maxPointLights:u.point};u=n.fragment_shader;t=n.vertex_shader;r=c.createProgram();v=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
+y=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(r,
+g("fragment",v+u));c.attachShader(r,g("vertex",y+t));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms={};r.attributes={};n.program=r;u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in n.uniforms)u.push(i);i=n.program;t=0;for(r=u.length;t<r;t++){v=u[t];i.uniforms[v]=c.getUniformLocation(i,v)}i=
+n.program;u=["position","normal","uv","tangent"];t=0;for(r=u.length;t<r;t++){v=u[t];i.attributes[v]=c.getAttribLocation(i,v)}}i=n.program;if(i!=k){c.useProgram(i);k=i}this.loadCamera(i,d);this.loadMatrices(i);if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){d=this.setupLights(i,h);n.uniforms.enableLighting.value=d.directional.positions.length+d.point.positions.length;n.uniforms.ambientLightColor.value=d.ambient;n.uniforms.directionalLightColor.value=d.directional.colors;
+n.uniforms.directionalLightDirection.value=d.directional.positions;n.uniforms.pointLightColor.value=d.point.colors;n.uniforms.pointLightPosition.value=d.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial)f(n,q);n instanceof THREE.LineBasicMaterial&&e(n,q);if(n instanceof THREE.MeshPhongMaterial){n.uniforms.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);n.uniforms.specular.value.setRGB(n.specular.r,n.specular.g,
+n.specular.b);n.uniforms.shininess.value=n.shininess}q=n.uniforms;for(o in q)if(u=i.uniforms[o]){h=q[o].type;d=q[o].value;if(h=="i")c.uniform1i(u,d);else if(h=="f")c.uniform1f(u,d);else if(h=="fv")c.uniform3fv(u,d);else if(h=="v2")c.uniform2f(u,d.x,d.y);else if(h=="v3")c.uniform3f(u,d.x,d.y,d.z);else if(h=="c")c.uniform3f(u,d.r,d.g,d.b);else if(h=="t"){c.uniform1i(u,d);if(h=q[o].texture)if(h.image instanceof Array&&h.image.length==6){h=h;d=d;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(u=0;u<6;++u)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,
+h.image[u]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}else{h=h;d=d;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,j(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,
+j(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}}}o=i.attributes;c.bindBuffer(c.ARRAY_BUFFER,l.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.position);if(o.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer);
+c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(l.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){o=
+n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&l.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);c.drawElements(n,l.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,l.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,q,n,l,i,u){var o,y,t,r,v;t=0;for(r=
+n.materials.length;t<r;t++){o=n.materials[t];if(o instanceof THREE.MeshFaceMaterial){o=0;for(y=l.materials.length;o<y;o++)if((v=l.materials[o])&&v.blending==i&&v.opacity<1==u){this.setBlending(v.blending);this.renderBuffer(d,h,q,v,l)}}else if((v=o)&&v.blending==i&&v.opacity<1==u){this.setBlending(v.blending);this.renderBuffer(d,h,q,v,l)}}};this.render=function(d,h){var q,n,l,i,u=d.lights,o=d.fog;this.initWebGLObjects(d);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();D.set(h.matrix.flatten());
+A.set(h.projectionMatrix.flatten());q=0;for(n=d.__webGLObjects.length;q<n;q++){l=d.__webGLObjects[q];i=l.object;l=l.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,u,o,i,l,THREE.NormalBlending,false)}}q=0;for(n=d.__webGLObjects.length;q<n;q++){l=d.__webGLObjects[q];i=l.object;l=l.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,u,o,i,l,THREE.AdditiveBlending,false);this.renderPass(h,u,o,i,l,THREE.SubtractiveBlending,false);this.renderPass(h,u,o,i,l,THREE.AdditiveBlending,
+true);this.renderPass(h,u,o,i,l,THREE.SubtractiveBlending,true);this.renderPass(h,u,o,i,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(d){function h(y,t,r,v){if(y[t]==undefined){d.__webGLObjects.push({buffer:r,object:v});y[t]=1}}var q,n,l,i,u,o;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={}}q=0;for(n=d.objects.length;q<n;q++){l=d.objects[q];if(d.__webGLObjectsMap[l.id]==undefined)d.__webGLObjectsMap[l.id]={};o=d.__webGLObjectsMap[l.id];if(l instanceof THREE.Mesh)for(i in l.geometry.geometryChunks){u=
+l.geometry.geometryChunks[i];u.__webGLVertexBuffer||this.createBuffers(l,i);h(o,i,u,l)}else if(l instanceof THREE.Line){l.__webGLVertexBuffer||this.createLineBuffers(l);h(o,0,l,l)}else if(l instanceof THREE.ParticleSystem){l.__webGLVertexBuffer||this.createParticleBuffers(l);h(o,0,l,l)}}};this.removeObject=function(d,h){var q,n;for(q=d.__webGLObjects.length-1;q>=0;q--){n=d.__webGLObjects[q].object;h==n&&d.__webGLObjects.splice(q,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();
+m.multiply(h.matrix,d.matrix);x.set(m.flatten());B=THREE.Matrix4.makeInvert3x3(m).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,
+h.position.y,h.position.z)};this.setBlending=function(d){switch(d){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(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};
+this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",

+ 94 - 94
build/ThreeDebug.js

@@ -12,48 +12,48 @@ THREE.Vector4=function(a,b,f,e){this.x=a||0;this.y=b||0;this.z=f||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,b,f,e){this.x=a;this.y=b;this.z=f;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,f,e){this.x=a;this.y=b;this.z=f;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,f,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){f=e[a];if(f instanceof THREE.Mesh)g=g.concat(this.intersectObject(f))}g.sort(function(j,o){return j.distance-o.distance});return g},intersectObject:function(a){function b(O,q,L,d){d=d.clone().subSelf(q);L=L.clone().subSelf(q);var h=O.clone().subSelf(q);O=d.dot(d);q=d.dot(L);d=d.dot(h);var r=L.dot(L);L=L.dot(h);h=1/(O*r-q*q);r=(r*d-q*L)*h;O=(O*L-q*d)*h;return r>0&&O>0&&r+O<1}var f,e,g,j,o,c,k,l,B,D,
-x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;f<e;f++){g=A.faces[f];D=this.origin.clone();x=this.direction.clone();j=a.matrix.multiplyVector3(M[g.a].position.clone());o=a.matrix.multiplyVector3(M[g.b].position.clone());c=a.matrix.multiplyVector3(M[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(M[g.d].position.clone()):null;l=a.rotationMatrix.multiplyVector3(g.normal.clone());B=x.dot(l);if(B<0){l=l.dot((new THREE.Vector3).sub(j,D))/B;D=D.addSelf(x.multiplyScalar(l));
-if(g instanceof THREE.Face3){if(b(D,j,o,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,o,k)||b(D,o,c,k)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}}return Q}};
-THREE.Rectangle=function(){function a(){j=e-b;o=g-f}var b,f,e,g,j,o,c=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return o};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,l,B,D){c=false;b=k;f=l;e=B;g=D;a()};this.addPoint=function(k,l){if(c){c=false;b=k;f=l;e=k;g=l}else{b=b<k?b:k;f=f<l?f:l;e=e>k?e:k;g=g>l?
-g:l}a()};this.add3Points=function(k,l,B,D,x,A){if(c){c=false;b=k<B?k<x?k:x:B<x?B:x;f=l<D?l<A?l:A:D<A?D:A;e=k>B?k>x?k:x:B>x?B:x;g=l>D?l>A?l:A:D>A?D:A}else{b=k<B?k<x?k<b?k:b:x<b?x:b:B<x?B<b?B:b:x<b?x:b;f=l<D?l<A?l<f?l:f:A<f?A:f:D<A?D<f?D:f:A<f?A:f;e=k>B?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=l>D?l>A?l>g?l:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();f=f<k.getTop()?f:k.getTop();
+THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){f=e[a];if(f instanceof THREE.Mesh)g=g.concat(this.intersectObject(f))}g.sort(function(j,p){return j.distance-p.distance});return g},intersectObject:function(a){function b(O,s,L,d){d=d.clone().subSelf(s);L=L.clone().subSelf(s);var h=O.clone().subSelf(s);O=d.dot(d);s=d.dot(L);d=d.dot(h);var q=L.dot(L);L=L.dot(h);h=1/(O*q-s*s);q=(q*d-s*L)*h;O=(O*L-s*d)*h;return q>0&&O>0&&q+O<1}var f,e,g,j,p,c,k,m,B,D,
+x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;f<e;f++){g=A.faces[f];D=this.origin.clone();x=this.direction.clone();j=a.matrix.multiplyVector3(M[g.a].position.clone());p=a.matrix.multiplyVector3(M[g.b].position.clone());c=a.matrix.multiplyVector3(M[g.c].position.clone());k=g instanceof THREE.Face4?a.matrix.multiplyVector3(M[g.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(g.normal.clone());B=x.dot(m);if(B<0){m=m.dot((new THREE.Vector3).sub(j,D))/B;D=D.addSelf(x.multiplyScalar(m));
+if(g instanceof THREE.Face3){if(b(D,j,p,c)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,p,k)||b(D,p,c,k)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};Q.push(g)}}}return Q}};
+THREE.Rectangle=function(){function a(){j=e-b;p=g-f}var b,f,e,g,j,p,c=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(k,m,B,D){c=false;b=k;f=m;e=B;g=D;a()};this.addPoint=function(k,m){if(c){c=false;b=k;f=m;e=k;g=m}else{b=b<k?b:k;f=f<m?f:m;e=e>k?e:k;g=g>m?
+g:m}a()};this.add3Points=function(k,m,B,D,x,A){if(c){c=false;b=k<B?k<x?k:x:B<x?B:x;f=m<D?m<A?m:A:D<A?D:A;e=k>B?k>x?k:x:B>x?B:x;g=m>D?m>A?m:A:D>A?D:A}else{b=k<B?k<x?k<b?k:b:x<b?x:b:B<x?B<b?B:b:x<b?x:b;f=m<D?m<A?m<f?m:f:A<f?A:f:D<A?D<f?D:f:A<f?A:f;e=k>B?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=m>D?m>A?m>g?m:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=b<k.getLeft()?b:k.getLeft();f=f<k.getTop()?f:k.getTop();
 e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString=
 e=e>k.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e<k.getRight()?e:k.getRight();g=g<k.getBottom()?g:k.getBottom();a()};this.instersects=function(k){return Math.min(e,k.getRight())-Math.max(b,k.getLeft())>=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString=
-function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+o+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
-THREE.Matrix4=function(a,b,f,e,g,j,o,c,k,l,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=o||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||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,f,e,g,j,o,c,k,l,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=o;this.n24=c;this.n31=k;this.n32=l;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+p+" )"}};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,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=m||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||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,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=p;this.n24=c;this.n31=k;this.n32=m;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;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,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;
 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,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=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,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24*
 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,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24*
-g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+this.n43*e+this.n44*g;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 f=a.n11,e=a.n12,g=a.n13,j=a.n14,o=a.n21,c=a.n22,k=a.n23,l=a.n24,B=a.n31,D=a.n32,
-x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,q=a.n44,L=b.n11,d=b.n12,h=b.n13,r=b.n14,m=b.n21,n=b.n22,i=b.n23,t=b.n24,p=b.n31,y=b.n32,u=b.n33,s=b.n34,w=b.n41,W=b.n42,G=b.n43,T=b.n44;this.n11=f*L+e*m+g*p+j*w;this.n12=f*d+e*n+g*y+j*W;this.n13=f*h+e*i+g*u+j*G;this.n14=f*r+e*t+g*s+j*T;this.n21=o*L+c*m+k*p+l*w;this.n22=o*d+c*n+k*y+l*W;this.n23=o*h+c*i+k*u+l*G;this.n24=o*r+c*t+k*s+l*T;this.n31=B*L+D*m+x*p+A*w;this.n32=B*d+D*n+x*y+A*W;this.n33=B*h+D*i+x*u+A*G;this.n34=B*r+D*t+x*s+A*T;this.n41=M*L+Q*m+O*p+q*w;
-this.n42=M*d+Q*n+O*y+q*W;this.n43=M*h+Q*i+O*u+q*G;this.n44=M*r+Q*t+O*s+q*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,o=this.n22,c=this.n23,k=this.n24,l=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,q=a.n11,L=a.n21,d=a.n31,h=a.n41,r=a.n12,m=a.n22,n=a.n32,i=a.n42,t=a.n13,p=a.n23,y=a.n33,u=a.n43,s=a.n14,w=a.n24,W=a.n34;a=a.n44;this.n11=b*q+f*L+e*d+g*h;this.n12=b*r+f*m+e*n+g*i;this.n13=b*t+f*p+e*y+g*u;this.n14=
-b*s+f*w+e*W+g*a;this.n21=j*q+o*L+c*d+k*h;this.n22=j*r+o*m+c*n+k*i;this.n23=j*t+o*p+c*y+k*u;this.n24=j*s+o*w+c*W+k*a;this.n31=l*q+B*L+D*d+x*h;this.n32=l*r+B*m+D*n+x*i;this.n33=l*t+B*p+D*y+x*u;this.n34=l*s+B*w+D*W+x*a;this.n41=A*q+M*L+Q*d+O*h;this.n42=A*r+M*m+Q*n+O*i;this.n43=A*t+M*p+Q*y+O*u;this.n44=A*s+M*w+Q*W+O*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
+g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+this.n43*e+this.n44*g;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 f=a.n11,e=a.n12,g=a.n13,j=a.n14,p=a.n21,c=a.n22,k=a.n23,m=a.n24,B=a.n31,D=a.n32,
+x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,s=a.n44,L=b.n11,d=b.n12,h=b.n13,q=b.n14,n=b.n21,l=b.n22,i=b.n23,u=b.n24,o=b.n31,y=b.n32,t=b.n33,r=b.n34,w=b.n41,W=b.n42,G=b.n43,T=b.n44;this.n11=f*L+e*n+g*o+j*w;this.n12=f*d+e*l+g*y+j*W;this.n13=f*h+e*i+g*t+j*G;this.n14=f*q+e*u+g*r+j*T;this.n21=p*L+c*n+k*o+m*w;this.n22=p*d+c*l+k*y+m*W;this.n23=p*h+c*i+k*t+m*G;this.n24=p*q+c*u+k*r+m*T;this.n31=B*L+D*n+x*o+A*w;this.n32=B*d+D*l+x*y+A*W;this.n33=B*h+D*i+x*t+A*G;this.n34=B*q+D*u+x*r+A*T;this.n41=M*L+Q*n+O*o+s*w;
+this.n42=M*d+Q*l+O*y+s*W;this.n43=M*h+Q*i+O*t+s*G;this.n44=M*q+Q*u+O*r+s*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,p=this.n22,c=this.n23,k=this.n24,m=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,s=a.n11,L=a.n21,d=a.n31,h=a.n41,q=a.n12,n=a.n22,l=a.n32,i=a.n42,u=a.n13,o=a.n23,y=a.n33,t=a.n43,r=a.n14,w=a.n24,W=a.n34;a=a.n44;this.n11=b*s+f*L+e*d+g*h;this.n12=b*q+f*n+e*l+g*i;this.n13=b*u+f*o+e*y+g*t;this.n14=
+b*r+f*w+e*W+g*a;this.n21=j*s+p*L+c*d+k*h;this.n22=j*q+p*n+c*l+k*i;this.n23=j*u+p*o+c*y+k*t;this.n24=j*r+p*w+c*W+k*a;this.n31=m*s+B*L+D*d+x*h;this.n32=m*q+B*n+D*l+x*i;this.n33=m*u+B*o+D*y+x*t;this.n34=m*r+B*w+D*W+x*a;this.n41=A*s+M*L+Q*d+O*h;this.n42=A*q+M*n+Q*l+O*i;this.n43=A*u+M*o+Q*y+O*t;this.n44=A*r+M*w+Q*W+O*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
 a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
 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,f,e){var g=b[f];b[f]=b[e];
 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,f,e){var g=b[f];b[f]=b[e];
 b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
 b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){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,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e};
 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,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e};
 THREE.Matrix4.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;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.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;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 f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,o=a.x,c=a.y,k=a.z;f.n11=j*o*o+e;f.n12=j*o*c-g*k;f.n13=j*o*k+g*c;f.n21=j*o*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*o;f.n31=j*o*k-g*c;f.n32=j*c*k+g*o;f.n33=j*k*k+e;return f};
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,p=a.x,c=a.y,k=a.z;f.n11=j*p*p+e;f.n12=j*p*c-g*k;f.n13=j*p*k+g*c;f.n21=j*p*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*p;f.n31=j*p*k-g*c;f.n32=j*c*k+g*p;f.n33=j*k*k+e;return f};
 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 f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],o=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*o;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*l;a.m[8]=b*B;return a};
-THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var o,c,k;o=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);o.n11=c;o.n12=0;o.n13=a;o.n14=0;o.n21=0;o.n22=k;o.n23=f;o.n24=0;o.n31=0;o.n32=0;o.n33=e;o.n34=g;o.n41=0;o.n42=0;o.n43=-1;o.n44=0;return o};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)};
-THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var o,c,k,l;o=new THREE.Matrix4;c=b-a;k=f-e;l=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/l;o.n11=2/c;o.n12=0;o.n13=0;o.n14=-a;o.n21=0;o.n22=2/k;o.n23=0;o.n24=-f;o.n31=0;o.n32=0;o.n33=-2/l;o.n34=-g;o.n41=0;o.n42=0;o.n43=0;o.n44=1;return o};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*m;a.m[8]=b*B;return a};
+THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var p,c,k;p=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=e;p.n34=g;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)};
+THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var p,c,k,m;p=new THREE.Matrix4;c=b-a;k=f-e;m=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/m;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/m;p.n34=-g;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Face3=function(a,b,f,e,g){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face3=function(a,b,f,e,g){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,b,f,e,g,j){this.a=a;this.b=b;this.c=f;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,f,e,g,j){this.a=a;this.b=b;this.c=f;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
-f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,e,g,j,o,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];if(a&&j.vertexNormals.length){c.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)c.addSelf(j.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];o=this.vertices[j.c];c.sub(o.position,
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,e,g,j,p,c=new THREE.Vector3,k=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];if(a&&j.vertexNormals.length){c.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)c.addSelf(j.vertexNormals[b]);c.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];p=this.vertices[j.c];c.sub(p.position,
 f.position);k.sub(b.position,f.position);c.crossSelf(k)}c.isZero()||c.normalize();j.normal.copy(c)}},computeVertexNormals:function(){var a,b,f=[],e;a=0;for(b=this.vertices.length;a<b;a++)f[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=
 f.position);k.sub(b.position,f.position);c.crossSelf(k)}c.isZero()||c.normalize();j.normal.copy(c)}},computeVertexNormals:function(){var a,b,f=[],e;a=0;for(b=this.vertices.length;a<b;a++)f[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){f[e.a].addSelf(e.normal);f[e.b].addSelf(e.normal);f[e.c].addSelf(e.normal);f[e.d].addSelf(e.normal)}}a=
-0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone();e.vertexNormals[3]=f[e.d].clone()}}},computeTangents:function(){function a(s,w,W,G,T,P,H){j=s.vertices[w].position;o=s.vertices[W].position;
-c=s.vertices[G].position;k=g[T];l=g[P];B=g[H];D=o.x-j.x;x=c.x-j.x;A=o.y-j.y;M=c.y-j.y;Q=o.z-j.z;O=c.z-j.z;q=l.u-k.u;L=B.u-k.u;d=l.v-k.v;h=B.v-k.v;r=1/(q*h-L*d);i.set((h*D-d*x)*r,(h*A-d*M)*r,(h*Q-d*O)*r);t.set((q*x-L*D)*r,(q*M-L*A)*r,(q*O-L*Q)*r);m[w].addSelf(i);m[W].addSelf(i);m[G].addSelf(i);n[w].addSelf(t);n[W].addSelf(t);n[G].addSelf(t)}var b,f,e,g,j,o,c,k,l,B,D,x,A,M,Q,O,q,L,d,h,r,m=[],n=[],i=new THREE.Vector3,t=new THREE.Vector3,p=new THREE.Vector3,y=new THREE.Vector3,u=new THREE.Vector3;b=0;
-for(f=this.vertices.length;b<f;b++){m[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
-this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){u.copy(this.vertices[b].normal);e=m[b];p.copy(e);p.subSelf(u.multiplyScalar(u.dot(e))).normalize();y.cross(this.vertices[b].normal,e);e=y.dot(n[b]);e=e<0?-1:1;this.vertices[b].tangent.set(p.x,p.y,p.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
+0;for(b=this.vertices.length;a<b;a++)f[a].normalize();a=0;for(b=this.faces.length;a<b;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=f[e.a].clone();e.vertexNormals[1]=f[e.b].clone();e.vertexNormals[2]=f[e.c].clone();e.vertexNormals[3]=f[e.d].clone()}}},computeTangents:function(){function a(r,w,W,G,T,P,H){j=r.vertices[w].position;p=r.vertices[W].position;
+c=r.vertices[G].position;k=g[T];m=g[P];B=g[H];D=p.x-j.x;x=c.x-j.x;A=p.y-j.y;M=c.y-j.y;Q=p.z-j.z;O=c.z-j.z;s=m.u-k.u;L=B.u-k.u;d=m.v-k.v;h=B.v-k.v;q=1/(s*h-L*d);i.set((h*D-d*x)*q,(h*A-d*M)*q,(h*Q-d*O)*q);u.set((s*x-L*D)*q,(s*M-L*A)*q,(s*O-L*Q)*q);n[w].addSelf(i);n[W].addSelf(i);n[G].addSelf(i);l[w].addSelf(u);l[W].addSelf(u);l[G].addSelf(u)}var b,f,e,g,j,p,c,k,m,B,D,x,A,M,Q,O,s,L,d,h,q,n=[],l=[],i=new THREE.Vector3,u=new THREE.Vector3,o=new THREE.Vector3,y=new THREE.Vector3,t=new THREE.Vector3;b=0;
+for(f=this.vertices.length;b<f;b++){n[b]=new THREE.Vector3;l[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
+this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){t.copy(this.vertices[b].normal);e=n[b];o.copy(e);o.subSelf(t.multiplyScalar(t.dot(e))).normalize();y.cross(this.vertices[b].normal,e);e=y.dot(l[b]);e=e<0?-1:1;this.vertices[b].tangent.set(o.x,o.y,o.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
 y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=this.vertices.length;b<f;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<
 y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=this.vertices.length;b<f;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<
 this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(B){var D=[];b=0;for(f=B.length;b<f;b++)B[b]==undefined?D.push("undefined"):D.push(B[b].toString());return D.join("_")}
 this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(B){var D=[];b=0;for(f=B.length;b<f;b++)B[b]==undefined?D.push("undefined"):D.push(B[b].toString());return D.join("_")}
-var b,f,e,g,j,o,c,k,l={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];o=j.materials;c=a(o);if(l[c]==undefined)l[c]={hash:c,counter:0};k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:o,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:o,vertices:0}}this.geometryChunks[k].faces.push(e);
+var b,f,e,g,j,p,c,k,m={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];p=j.materials;c=a(p);if(m[c]==undefined)m[c]={hash:c,counter:0};k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[k].vertices+j>65535){m[c].counter+=1;k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(e);
 this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
 THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);
 this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
 this.position.subSelf(g);this.target.position.subSelf(g)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
@@ -96,86 +96,86 @@ THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLine
 THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
 THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(n,i){return i.z-n.z}function b(n,i){var t=0,p=1,y=n.z+n.w,u=i.z+i.w,s=-n.z+n.w,w=-i.z+i.w;if(y>=0&&u>=0&&s>=0&&w>=0)return true;else if(y<0&&u<0||s<0&&w<0)return false;else{if(y<0)t=Math.max(t,y/(y-u));else if(u<0)p=Math.min(p,y/(y-u));if(s<0)t=Math.max(t,s/(s-w));else if(w<0)p=Math.min(p,s/(s-w));if(p<t)return false;else{n.lerpSelf(i,t);i.lerpSelf(n,1-p);return true}}}var f,e,g=[],j,o,c,k=[],l,B,D=[],x,A,M=[],Q=new THREE.Vector4,O=new THREE.Vector4,q=new THREE.Matrix4,
-L=new THREE.Matrix4,d=[],h=new THREE.Vector4,r=new THREE.Vector4,m;this.projectObjects=function(n,i,t){var p=[],y,u;e=0;q.multiply(i.projectionMatrix,i.matrix);d[0]=new THREE.Vector4(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);d[1]=new THREE.Vector4(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);d[2]=new THREE.Vector4(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);d[3]=new THREE.Vector4(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);d[4]=new THREE.Vector4(q.n41-q.n31,q.n42-q.n32,q.n43-
-q.n33,q.n44-q.n34);d[5]=new THREE.Vector4(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);i=0;for(y=d.length;i<y;i++){u=d[i];u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z))}y=n.objects;n=0;for(i=y.length;n<i;n++){u=y[n];var s;if(!(s=!u.visible)){if(s=u instanceof THREE.Mesh){a:{s=void 0;for(var w=u.position,W=-u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)),G=0;G<6;G++){s=d[G].x*w.x+d[G].y*w.y+d[G].z*w.z+d[G].w;if(s<=W){s=false;break a}}s=true}s=!s}s=s}if(!s){f=
-g[e]=g[e]||new THREE.RenderableObject;Q.copy(u.position);q.multiplyVector3(Q);f.object=u;f.z=Q.z;p.push(f);e++}}t&&p.sort(a);return p};this.projectScene=function(n,i,t){var p=[],y=i.near,u=i.far,s,w,W,G,T,P,H,X,K,E,F,U,R,C,N,V;c=B=A=0;i.autoUpdateMatrix&&i.updateMatrix();q.multiply(i.projectionMatrix,i.matrix);P=this.projectObjects(n,i,true);n=0;for(s=P.length;n<s;n++){H=P[n].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();X=H.matrix;K=H.rotationMatrix;E=H.materials;F=H.overdraw;if(H instanceof
-THREE.Mesh){U=H.geometry;R=U.vertices;w=0;for(W=R.length;w<W;w++){C=R[w];C.positionWorld.copy(C.position);X.multiplyVector3(C.positionWorld);G=C.positionScreen;G.copy(C.positionWorld);q.multiplyVector4(G);G.x/=G.w;G.y/=G.w;C.__visible=G.z>y&&G.z<u}U=U.faces;w=0;for(W=U.length;w<W;w++){C=U[w];if(C instanceof THREE.Face3){G=R[C.a];T=R[C.b];N=R[C.c];if(G.__visible&&T.__visible&&N.__visible)if(H.doubleSided||H.flipSided!=(N.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-
+THREE.Projector=function(){function a(l,i){return i.z-l.z}function b(l,i){var u=0,o=1,y=l.z+l.w,t=i.z+i.w,r=-l.z+l.w,w=-i.z+i.w;if(y>=0&&t>=0&&r>=0&&w>=0)return true;else if(y<0&&t<0||r<0&&w<0)return false;else{if(y<0)u=Math.max(u,y/(y-t));else if(t<0)o=Math.min(o,y/(y-t));if(r<0)u=Math.max(u,r/(r-w));else if(w<0)o=Math.min(o,r/(r-w));if(o<u)return false;else{l.lerpSelf(i,u);i.lerpSelf(l,1-o);return true}}}var f,e,g=[],j,p,c,k=[],m,B,D=[],x,A,M=[],Q=new THREE.Vector4,O=new THREE.Vector4,s=new THREE.Matrix4,
+L=new THREE.Matrix4,d=[],h=new THREE.Vector4,q=new THREE.Vector4,n;this.projectObjects=function(l,i,u){var o=[],y,t;e=0;s.multiply(i.projectionMatrix,i.matrix);d[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);d[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);d[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);d[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);d[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
+s.n33,s.n44-s.n34);d[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);i=0;for(y=d.length;i<y;i++){t=d[i];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}y=l.objects;l=0;for(i=y.length;l<i;l++){t=y[l];var r;if(!(r=!t.visible)){if(r=t instanceof THREE.Mesh){a:{r=void 0;for(var w=t.position,W=-t.geometry.boundingSphere.radius*Math.max(t.scale.x,Math.max(t.scale.y,t.scale.z)),G=0;G<6;G++){r=d[G].x*w.x+d[G].y*w.y+d[G].z*w.z+d[G].w;if(r<=W){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
+g[e]=g[e]||new THREE.RenderableObject;Q.copy(t.position);s.multiplyVector3(Q);f.object=t;f.z=Q.z;o.push(f);e++}}u&&o.sort(a);return o};this.projectScene=function(l,i,u){var o=[],y=i.near,t=i.far,r,w,W,G,T,P,H,X,K,E,F,U,R,C,N,V;c=B=A=0;i.autoUpdateMatrix&&i.updateMatrix();s.multiply(i.projectionMatrix,i.matrix);P=this.projectObjects(l,i,true);l=0;for(r=P.length;l<r;l++){H=P[l].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();X=H.matrix;K=H.rotationMatrix;E=H.materials;F=H.overdraw;if(H instanceof
+THREE.Mesh){U=H.geometry;R=U.vertices;w=0;for(W=R.length;w<W;w++){C=R[w];C.positionWorld.copy(C.position);X.multiplyVector3(C.positionWorld);G=C.positionScreen;G.copy(C.positionWorld);s.multiplyVector4(G);G.x/=G.w;G.y/=G.w;C.__visible=G.z>y&&G.z<t}U=U.faces;w=0;for(W=U.length;w<W;w++){C=U[w];if(C instanceof THREE.Face3){G=R[C.a];T=R[C.b];N=R[C.c];if(G.__visible&&T.__visible&&N.__visible)if(H.doubleSided||H.flipSided!=(N.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-
 (N.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(T.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);
 (N.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(T.positionWorld);j.v3.positionWorld.copy(N.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(N.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);
-j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);N=C.vertexNormals;m=j.vertexNormalsWorld;G=0;for(T=N.length;G<T;G++){V=m[G]=m[G]||new THREE.Vector3;V.copy(N[G]);K.multiplyVector3(V)}j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][2]}p.push(j);c++}}else if(C instanceof THREE.Face4){G=R[C.a];T=R[C.b];N=R[C.c];V=R[C.d];if(G.__visible&&
+j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);N=C.vertexNormals;n=j.vertexNormalsWorld;G=0;for(T=N.length;G<T;G++){V=n[G]=n[G]||new THREE.Vector3;V.copy(N[G]);K.multiplyVector3(V)}j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][2]}o.push(j);c++}}else if(C instanceof THREE.Face4){G=R[C.a];T=R[C.b];N=R[C.c];V=R[C.d];if(G.__visible&&
 T.__visible&&N.__visible&&V.__visible)if(H.doubleSided||H.flipSided!=((V.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-(V.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0||(T.positionScreen.x-N.positionScreen.x)*(V.positionScreen.y-N.positionScreen.y)-(T.positionScreen.y-N.positionScreen.y)*(V.positionScreen.x-N.positionScreen.x)<0)){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(T.positionWorld);
 T.__visible&&N.__visible&&V.__visible)if(H.doubleSided||H.flipSided!=((V.positionScreen.x-G.positionScreen.x)*(T.positionScreen.y-G.positionScreen.y)-(V.positionScreen.y-G.positionScreen.y)*(T.positionScreen.x-G.positionScreen.x)<0||(T.positionScreen.x-N.positionScreen.x)*(V.positionScreen.y-N.positionScreen.y)-(T.positionScreen.y-N.positionScreen.y)*(V.positionScreen.x-N.positionScreen.x)<0)){j=k[c]=k[c]||new THREE.RenderableFace3;j.v1.positionWorld.copy(G.positionWorld);j.v2.positionWorld.copy(T.positionWorld);
-j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];
-j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][3]}p.push(j);c++;o=k[c]=k[c]||new THREE.RenderableFace3;o.v1.positionWorld.copy(T.positionWorld);o.v2.positionWorld.copy(N.positionWorld);o.v3.positionWorld.copy(V.positionWorld);o.v1.positionScreen.copy(T.positionScreen);o.v2.positionScreen.copy(N.positionScreen);o.v3.positionScreen.copy(V.positionScreen);o.normalWorld.copy(j.normalWorld);o.centroidWorld.copy(j.centroidWorld);o.centroidScreen.copy(j.centroidScreen);o.z=o.centroidScreen.z;o.meshMaterials=
-E;o.faceMaterials=C.materials;o.overdraw=F;if(H.geometry.uvs[w]){o.uvs[0]=H.geometry.uvs[w][1];o.uvs[1]=H.geometry.uvs[w][2];o.uvs[2]=H.geometry.uvs[w][3]}p.push(o);c++}}}}else if(H instanceof THREE.Line){L.multiply(q,X);R=H.geometry.vertices;C=R[0];C.positionScreen.copy(C.position);L.multiplyVector4(C.positionScreen);w=1;for(W=R.length;w<W;w++){G=R[w];G.positionScreen.copy(G.position);L.multiplyVector4(G.positionScreen);T=R[w-1];h.copy(G.positionScreen);r.copy(T.positionScreen);if(b(h,r)){h.multiplyScalar(1/
-h.w);r.multiplyScalar(1/r.w);l=D[B]=D[B]||new THREE.RenderableLine;l.v1.positionScreen.copy(h);l.v2.positionScreen.copy(r);l.z=Math.max(h.z,r.z);l.materials=H.materials;p.push(l);B++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);q.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14));
-x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;p.push(x);A++}}}}t&&p.sort(a);return p};this.unprojectVector=function(n,i){var t=new THREE.Matrix4;t.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));t.multiplyVector3(n);return n}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(o,c){f=o;e=c;g=f/2;j=e/2};this.render=function(o,c){var k,l,B,D,x,A,M,Q;a=b.projectScene(o,c);k=0;for(l=a.length;k<l;k++){x=a[k];if(x instanceof THREE.RenderableParticle){M=x.x*g+g;Q=x.y*j+j;B=0;for(D=x.material.length;B<D;B++){A=x.material[B];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=M+"px";A.style.top=Q+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)l.globalAlpha=x=ba}function b(ba){if(A!=ba){switch(ba){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}A=ba}}var f=null,e=new THREE.Projector,g=document.createElement("canvas"),j,o,c,k,l=g.getContext("2d"),B=null,D=null,x=1,A=0,M=null,Q=null,O=1,q,L,d,h,r,m,n,i,t,p=new THREE.Color,
-y=new THREE.Color,u=new THREE.Color,s=new THREE.Color,w=new THREE.Color,W,G,T,P,H,X,K,E,F,U=new THREE.Rectangle,R=new THREE.Rectangle,C=new THREE.Rectangle,N=false,V=new THREE.Color,ea=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,La=Math.PI*2,Z=new THREE.Vector3,ra,sa,Ca,fa,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);fa=Ca.data;ta=document.createElement("canvas");
-ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ba,la){j=ba;o=la;c=j/2;k=o/2;g.width=j;g.height=o;U.set(-c,-k,c,k)};this.setClearColor=function(ba,la){B=ba!==null?new THREE.Color(ba):null;D=la;R.set(-c,-k,c,k);l.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!R.isEmpty()){R.inflate(1);R.minSelf(U);if(B!==null){b(THREE.NormalBlending);a(1);l.fillStyle=
-"rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+D+")";l.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight())}else l.clearRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());R.empty()}};this.render=function(ba,la){function Ma(v){var S,J,z,I=v.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);v=0;for(S=I.length;v<S;v++){J=I[v];z=J.color;if(J instanceof THREE.AmbientLight){ea.r+=z.r;ea.g+=z.g;ea.b+=z.b}else if(J instanceof THREE.DirectionalLight){ma.r+=z.r;ma.g+=
+j.v3.positionWorld.copy(V.positionWorld);j.v1.positionScreen.copy(G.positionScreen);j.v2.positionScreen.copy(T.positionScreen);j.v3.positionScreen.copy(V.positionScreen);j.normalWorld.copy(C.normal);K.multiplyVector3(j.normalWorld);j.centroidWorld.copy(C.centroid);X.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=E;j.faceMaterials=C.materials;j.overdraw=F;if(H.geometry.uvs[w]){j.uvs[0]=H.geometry.uvs[w][0];
+j.uvs[1]=H.geometry.uvs[w][1];j.uvs[2]=H.geometry.uvs[w][3]}o.push(j);c++;p=k[c]=k[c]||new THREE.RenderableFace3;p.v1.positionWorld.copy(T.positionWorld);p.v2.positionWorld.copy(N.positionWorld);p.v3.positionWorld.copy(V.positionWorld);p.v1.positionScreen.copy(T.positionScreen);p.v2.positionScreen.copy(N.positionScreen);p.v3.positionScreen.copy(V.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
+E;p.faceMaterials=C.materials;p.overdraw=F;if(H.geometry.uvs[w]){p.uvs[0]=H.geometry.uvs[w][1];p.uvs[1]=H.geometry.uvs[w][2];p.uvs[2]=H.geometry.uvs[w][3]}o.push(p);c++}}}}else if(H instanceof THREE.Line){L.multiply(s,X);R=H.geometry.vertices;C=R[0];C.positionScreen.copy(C.position);L.multiplyVector4(C.positionScreen);w=1;for(W=R.length;w<W;w++){G=R[w];G.positionScreen.copy(G.position);L.multiplyVector4(G.positionScreen);T=R[w-1];h.copy(G.positionScreen);q.copy(T.positionScreen);if(b(h,q)){h.multiplyScalar(1/
+h.w);q.multiplyScalar(1/q.w);m=D[B]=D[B]||new THREE.RenderableLine;m.v1.positionScreen.copy(h);m.v2.positionScreen.copy(q);m.z=Math.max(h.z,q.z);m.materials=H.materials;o.push(m);B++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);s.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14));
+x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;o.push(x);A++}}}}u&&o.sort(a);return o};this.unprojectVector=function(l,i){var u=new THREE.Matrix4;u.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));u.multiplyVector3(l);return l}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(p,c){f=p;e=c;g=f/2;j=e/2};this.render=function(p,c){var k,m,B,D,x,A,M,Q;a=b.projectScene(p,c);k=0;for(m=a.length;k<m;k++){x=a[k];if(x instanceof THREE.RenderableParticle){M=x.x*g+g;Q=x.y*j+j;B=0;for(D=x.material.length;B<D;B++){A=x.material[B];if(A instanceof THREE.ParticleDOMMaterial){A=A.domElement;A.style.left=M+"px";A.style.top=Q+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ba){if(x!=ba)m.globalAlpha=x=ba}function b(ba){if(A!=ba){switch(ba){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}A=ba}}var f=null,e=new THREE.Projector,g=document.createElement("canvas"),j,p,c,k,m=g.getContext("2d"),B=null,D=null,x=1,A=0,M=null,Q=null,O=1,s,L,d,h,q,n,l,i,u,o=new THREE.Color,
+y=new THREE.Color,t=new THREE.Color,r=new THREE.Color,w=new THREE.Color,W,G,T,P,H,X,K,E,F,U=new THREE.Rectangle,R=new THREE.Rectangle,C=new THREE.Rectangle,N=false,V=new THREE.Color,ea=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,La=Math.PI*2,Z=new THREE.Vector3,ra,sa,Ca,fa,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);fa=Ca.data;ta=document.createElement("canvas");
+ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ba,la){j=ba;p=la;c=j/2;k=p/2;g.width=j;g.height=p;U.set(-c,-k,c,k)};this.setClearColor=function(ba,la){B=ba!==null?new THREE.Color(ba):null;D=la;R.set(-c,-k,c,k);m.setTransform(1,0,0,-1,c,k);this.clear()};this.clear=function(){if(!R.isEmpty()){R.inflate(1);R.minSelf(U);if(B!==null){b(THREE.NormalBlending);a(1);m.fillStyle=
+"rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+D+")";m.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight())}else m.clearRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());R.empty()}};this.render=function(ba,la){function Ma(v){var S,J,z,I=v.lights;ea.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);v=0;for(S=I.length;v<S;v++){J=I[v];z=J.color;if(J instanceof THREE.AmbientLight){ea.r+=z.r;ea.g+=z.g;ea.b+=z.b}else if(J instanceof THREE.DirectionalLight){ma.r+=z.r;ma.g+=
 z.g;ma.b+=z.b}else if(J instanceof THREE.PointLight){na.r+=z.r;na.g+=z.g;na.b+=z.b}}}function ya(v,S,J,z){var I,Y,aa,ca,da=v.lights;v=0;for(I=da.length;v<I;v++){Y=da[v];aa=Y.color;ca=Y.intensity;if(Y instanceof THREE.DirectionalLight){Y=J.dot(Y.position)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,S);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(v,S,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z,
 z.g;ma.b+=z.b}else if(J instanceof THREE.PointLight){na.r+=z.r;na.g+=z.g;na.b+=z.b}}}function ya(v,S,J,z){var I,Y,aa,ca,da=v.lights;v=0;for(I=da.length;v<I;v++){Y=da[v];aa=Y.color;ca=Y.intensity;if(Y instanceof THREE.DirectionalLight){Y=J.dot(Y.position)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,S);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(v,S,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z,
-I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=S.scale.x*c;Y=S.scale.y*k;J=I*ca;z=Y*da;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(!U.instersects(C))return;l.save();l.translate(v.x,v.y);l.rotate(-S.rotation);l.scale(I,-Y);l.translate(-ca,-da);l.drawImage(aa,0,0);l.restore()}l.beginPath();l.moveTo(v.x-10,v.y);l.lineTo(v.x+10,v.y);l.moveTo(v.x,v.y-10);l.lineTo(v.x,v.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(J instanceof
-THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;p.r=J.color.r*V.r;p.g=J.color.g*V.g;p.b=J.color.b*V.b;p.updateStyleString()}else p.__styleString=J.color.__styleString;J=S.scale.x*c;z=S.scale.y*k;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(U.instersects(C)){I=p.__styleString;if(Q!=I)l.fillStyle=Q=I;l.save();l.translate(v.x,v.y);l.rotate(-S.rotation);l.scale(J,z);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(v,S,J,z){if(z.opacity!=
-0){a(z.opacity);b(z.blending);l.beginPath();l.moveTo(v.positionScreen.x,v.positionScreen.y);l.lineTo(S.positionScreen.x,S.positionScreen.y);l.closePath();if(z instanceof THREE.LineBasicMaterial){p.__styleString=z.color.__styleString;v=z.linewidth;if(O!=v)l.lineWidth=O=v;v=p.__styleString;if(M!=v)l.strokeStyle=M=v;l.stroke();C.inflate(z.linewidth*2)}}}function Ha(v,S,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=v.positionScreen.x;r=v.positionScreen.y;m=S.positionScreen.x;n=S.positionScreen.y;
-i=J.positionScreen.x;t=J.positionScreen.y;l.beginPath();l.moveTo(h,r);l.lineTo(m,n);l.lineTo(i,t);l.lineTo(h,r);l.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ua(h,r,m,n,i,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*v.n11+Z.y*
-v.n12+Z.z*v.n13)*0.5+0.5;H=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;K=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;F=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;ua(h,r,m,n,i,t,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof
-THREE.UVMapping&&ua(h,r,m,n,i,t,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){y.r=u.r=s.r=ea.r;y.g=u.g=s.g=ea.g;y.b=u.b=s.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],u);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],s);w.r=(u.r+s.r)*0.5;w.g=(u.g+s.g)*0.5;w.b=(u.b+s.b)*0.5;T=Ia(y,u,s,w);ua(h,
-r,m,n,i,t,T,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);p.r=I.color.r*V.r;p.g=I.color.g*V.g;p.b=I.color.b*V.b;p.updateStyleString();I.wireframe?za(p.__styleString,I.wireframe_linewidth):Aa(p.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(v.positionScreen.z,W,G);u.r=u.g=u.b=1-Da(S.positionScreen.z,W,G);s.r=s.g=s.b=1-Da(J.positionScreen.z,
-W,G);w.r=(u.r+s.r)*0.5;w.g=(u.g+s.g)*0.5;w.b=(u.b+s.b)*0.5;T=Ia(y,u,s,w);ua(h,r,m,n,i,t,T,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){p.r=Ea(z.normalWorld.x);p.g=Ea(z.normalWorld.y);p.b=Ea(z.normalWorld.z);p.updateStyleString();I.wireframe?za(p.__styleString,I.wireframe_linewidth):Aa(p.__styleString)}}}function za(v,S){if(M!=v)l.strokeStyle=M=v;if(O!=S)l.lineWidth=O=S;l.stroke();C.inflate(S*2)}function Aa(v){if(Q!=v)l.fillStyle=Q=v;l.fill()}function ua(v,S,J,z,I,Y,aa,ca,da,ia,ga,ja,
-va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=v;z-=S;I-=v;Y-=S;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-ja*J)*ka;z=(ia*Y-ja*z)*ka;v=v-oa*ca-J*da;S=S-ga*ca-z*da;l.save();l.transform(oa,ga,J,z,v,S);l.clip();l.drawImage(aa,0,0);l.restore()}function Ia(v,S,J,z){var I=~~(v.r*255),Y=~~(v.g*255);v=~~(v.b*255);var aa=~~(S.r*255),ca=~~(S.g*255);S=~~(S.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*
+I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=S.scale.x*c;Y=S.scale.y*k;J=I*ca;z=Y*da;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(!U.instersects(C))return;m.save();m.translate(v.x,v.y);m.rotate(-S.rotation);m.scale(I,-Y);m.translate(-ca,-da);m.drawImage(aa,0,0);m.restore()}m.beginPath();m.moveTo(v.x-10,v.y);m.lineTo(v.x+10,v.y);m.moveTo(v.x,v.y-10);m.lineTo(v.x,v.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(J instanceof
+THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;o.r=J.color.r*V.r;o.g=J.color.g*V.g;o.b=J.color.b*V.b;o.updateStyleString()}else o.__styleString=J.color.__styleString;J=S.scale.x*c;z=S.scale.y*k;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(U.instersects(C)){I=o.__styleString;if(Q!=I)m.fillStyle=Q=I;m.save();m.translate(v.x,v.y);m.rotate(-S.rotation);m.scale(J,z);m.beginPath();m.arc(0,0,1,0,La,true);m.closePath();m.fill();m.restore()}}}}function Oa(v,S,J,z){if(z.opacity!=
+0){a(z.opacity);b(z.blending);m.beginPath();m.moveTo(v.positionScreen.x,v.positionScreen.y);m.lineTo(S.positionScreen.x,S.positionScreen.y);m.closePath();if(z instanceof THREE.LineBasicMaterial){o.__styleString=z.color.__styleString;v=z.linewidth;if(O!=v)m.lineWidth=O=v;v=o.__styleString;if(M!=v)m.strokeStyle=M=v;m.stroke();C.inflate(z.linewidth*2)}}}function Ha(v,S,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=v.positionScreen.x;q=v.positionScreen.y;n=S.positionScreen.x;l=S.positionScreen.y;
+i=J.positionScreen.x;u=J.positionScreen.y;m.beginPath();m.moveTo(h,q);m.lineTo(n,l);m.lineTo(i,u);m.lineTo(h,q);m.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*v.n11+Z.y*
+v.n12+Z.z*v.n13)*0.5+0.5;H=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;K=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;F=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;ua(h,q,n,l,i,u,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof
+THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){y.r=t.r=r.r=ea.r;y.g=t.g=r.g=ea.g;y.b=t.b=r.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],t);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],r);w.r=(t.r+r.r)*0.5;w.g=(t.g+r.g)*0.5;w.b=(t.b+r.b)*0.5;T=Ia(y,t,r,w);ua(h,
+q,n,l,i,u,T,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);o.r=I.color.r*V.r;o.g=I.color.g*V.g;o.b=I.color.b*V.b;o.updateStyleString();I.wireframe?za(o.__styleString,I.wireframe_linewidth):Aa(o.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(v.positionScreen.z,W,G);t.r=t.g=t.b=1-Da(S.positionScreen.z,W,G);r.r=r.g=r.b=1-Da(J.positionScreen.z,
+W,G);w.r=(t.r+r.r)*0.5;w.g=(t.g+r.g)*0.5;w.b=(t.b+r.b)*0.5;T=Ia(y,t,r,w);ua(h,q,n,l,i,u,T,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){o.r=Ea(z.normalWorld.x);o.g=Ea(z.normalWorld.y);o.b=Ea(z.normalWorld.z);o.updateStyleString();I.wireframe?za(o.__styleString,I.wireframe_linewidth):Aa(o.__styleString)}}}function za(v,S){if(M!=v)m.strokeStyle=M=v;if(O!=S)m.lineWidth=O=S;m.stroke();C.inflate(S*2)}function Aa(v){if(Q!=v)m.fillStyle=Q=v;m.fill()}function ua(v,S,J,z,I,Y,aa,ca,da,ia,ga,ja,
+va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=v;z-=S;I-=v;Y-=S;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-ja*J)*ka;z=(ia*Y-ja*z)*ka;v=v-oa*ca-J*da;S=S-ga*ca-z*da;m.save();m.transform(oa,ga,J,z,v,S);m.clip();m.drawImage(aa,0,0);m.restore()}function Ia(v,S,J,z){var I=~~(v.r*255),Y=~~(v.g*255);v=~~(v.b*255);var aa=~~(S.r*255),ca=~~(S.g*255);S=~~(S.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*
 255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=v<0?0:v>255?255:v;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=S<0?0:S>255?255:S;fa[8]=da<0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(v,S,J){v=(v-S)/(J-S);return v*v*(3-2*v)}function Ea(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Fa(v,
 255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=v<0?0:v>255?255:v;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=S<0?0:S>255?255:S;fa[8]=da<0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(v,S,J){v=(v-S)/(J-S);return v*v*(3-2*v)}function Ea(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Fa(v,
-S){var J=S.x-v.x,z=S.y-v.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;S.x+=J;S.y+=z;v.x-=J;v.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,la,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){q=$;q.x*=c;q.y*=k;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(q,$,
-$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){q=$.v1;L=$.v2;q.positionScreen.x*=c;q.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;C.addPoint(q.positionScreen.x,q.positionScreen.y);C.addPoint(L.positionScreen.x,L.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.materials.length;ha<qa;)Oa(q,L,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){q=$.v1;L=$.v2;d=$.v3;q.positionScreen.x*=c;q.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=
-k;d.positionScreen.x*=c;d.positionScreen.y*=k;if($.overdraw){Fa(q.positionScreen,L.positionScreen);Fa(L.positionScreen,d.positionScreen);Fa(d.positionScreen,q.positionScreen)}C.add3Points(q.positionScreen.x,q.positionScreen.y,L.positionScreen.x,L.positionScreen.y,d.positionScreen.x,d.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.meshMaterials.length;ha<qa;){wa=$.meshMaterials[ha++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(wa=$.faceMaterials[Ga++])&&
-Ha(q,L,d,$,wa,ba)}else Ha(q,L,d,$,wa,ba)}}}R.addRectangle(C)}l.lineWidth=1;l.strokeStyle="rgba( 255, 0, 0, 0.5 )";l.strokeRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());l.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(P,H,X){var K,E,F,U;K=0;for(E=P.lights.length;K<E;K++){F=P.lights[K];if(F instanceof THREE.DirectionalLight){U=H.normalWorld.dot(F.position)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){t.sub(F.position,H.centroidWorld);t.normalize();U=H.normalWorld.dot(t)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){s=e(w++);s.setAttribute("d","M "+P.positionScreen.x+
-" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=r.r;h.g=r.g;h.b=r.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear);
-d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(s)}function f(P,H,X,K,E,F,U){s=e(w++);s.setAttribute("d",
-"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=r.r;h.g=r.g;h.b=r.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i=
-1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):s.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(s)}
-function e(P){if(p[P]==null){p[P]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&p[P].setAttribute("shape-rendering","crispEdges");return p[P]}return p[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,o=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,B,D,x,A,M,Q,O=new THREE.Rectangle,q=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),r=new THREE.Color(0),m=new THREE.Color(0),
-n=new THREE.Color(0),i,t=new THREE.Vector3,p=[],y=[],u=[],s,w,W,G,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":T=1;break;case "low":T=0}};this.setSize=function(P,H){k=P;l=H;B=k/2;D=l/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K,
-E,F,U,R,C,N;this.autoClear&&this.clear();j=o.projectScene(P,H,this.sortElements);G=W=w=0;if(L=P.lights.length>0){C=P.lights;r.setRGB(0,0,0);m.setRGB(0,0,0);n.setRGB(0,0,0);X=0;for(K=C.length;X<K;X++){E=C[X];F=E.color;if(E instanceof THREE.AmbientLight){r.r+=F.r;r.g+=F.g;r.b+=F.b}else if(E instanceof THREE.DirectionalLight){m.r+=F.r;m.g+=F.g;m.b+=F.b}else if(E instanceof THREE.PointLight){n.r+=F.r;n.g+=F.g;n.b+=F.b}}}X=0;for(K=j.length;X<K;X++){C=j[X];q.empty();if(C instanceof THREE.RenderableParticle){x=
-C;x.x*=B;x.y*=-D;E=0;for(F=C.materials.length;E<F;E++)if(N=C.materials[E]){U=x;R=C;N=N;var V=W++;if(y[V]==null){y[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&y[V].setAttribute("shape-rendering","crispEdges")}s=y[V];s.setAttribute("cx",U.x);s.setAttribute("cy",U.y);s.setAttribute("r",R.scale.x*B);if(N instanceof THREE.ParticleCircleMaterial){if(L){h.r=r.r+m.r+n.r;h.g=r.g+m.g+n.g;h.b=r.b+m.b+n.b;d.r=N.color.r*h.r;d.g=N.color.g*h.g;d.b=N.color.b*h.b;d.updateStyleString()}else d=
-N.color;s.setAttribute("style","fill: "+d.__styleString)}c.appendChild(s)}}else if(C instanceof THREE.RenderableLine){x=C.v1;A=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);if(O.instersects(q)){E=0;for(F=C.materials.length;E<F;)if(N=C.materials[E++]){U=x;R=A;N=N;V=G++;if(u[V]==null){u[V]=document.createElementNS("http://www.w3.org/2000/svg","line");T==
-0&&u[V].setAttribute("shape-rendering","crispEdges")}s=u[V];s.setAttribute("x1",U.positionScreen.x);s.setAttribute("y1",U.positionScreen.y);s.setAttribute("x2",R.positionScreen.x);s.setAttribute("y2",R.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){d.__styleString=N.color.__styleString;s.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);c.appendChild(s)}}}}else if(C instanceof
-THREE.RenderableFace3){x=C.v1;A=C.v2;M=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(q)){E=0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&
-b(x,A,M,C,N,P)}else N&&b(x,A,M,C,N,P)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;A=C.v2;M=C.v3;Q=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;Q.positionScreen.x*=B;Q.positionScreen.y*=-D;q.addPoint(x.positionScreen.x,x.positionScreen.y);q.addPoint(A.positionScreen.x,A.positionScreen.y);q.addPoint(M.positionScreen.x,M.positionScreen.y);q.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(q)){E=
+S){var J=S.x-v.x,z=S.y-v.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;S.x+=J;S.y+=z;v.x-=J;v.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;m.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,la,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba<Ja;Ba++){$=f[Ba];C.empty();if($ instanceof THREE.RenderableParticle){s=$;s.x*=c;s.y*=k;ha=0;for(qa=$.materials.length;ha<qa;ha++)Na(s,$,
+$.materials[ha],ba)}else if($ instanceof THREE.RenderableLine){s=$.v1;L=$.v2;s.positionScreen.x*=c;s.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=k;C.addPoint(s.positionScreen.x,s.positionScreen.y);C.addPoint(L.positionScreen.x,L.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.materials.length;ha<qa;)Oa(s,L,$,$.materials[ha++],ba)}}else if($ instanceof THREE.RenderableFace3){s=$.v1;L=$.v2;d=$.v3;s.positionScreen.x*=c;s.positionScreen.y*=k;L.positionScreen.x*=c;L.positionScreen.y*=
+k;d.positionScreen.x*=c;d.positionScreen.y*=k;if($.overdraw){Fa(s.positionScreen,L.positionScreen);Fa(L.positionScreen,d.positionScreen);Fa(d.positionScreen,s.positionScreen)}C.add3Points(s.positionScreen.x,s.positionScreen.y,L.positionScreen.x,L.positionScreen.y,d.positionScreen.x,d.positionScreen.y);if(U.instersects(C)){ha=0;for(qa=$.meshMaterials.length;ha<qa;){wa=$.meshMaterials[ha++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=$.faceMaterials.length;Ga<Ka;)(wa=$.faceMaterials[Ga++])&&
+Ha(s,L,d,$,wa,ba)}else Ha(s,L,d,$,wa,ba)}}}R.addRectangle(C)}m.lineWidth=1;m.strokeStyle="rgba( 255, 0, 0, 0.5 )";m.strokeRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(P,H,X){var K,E,F,U;K=0;for(E=P.lights.length;K<E;K++){F=P.lights[K];if(F instanceof THREE.DirectionalLight){U=H.normalWorld.dot(F.position)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){u.sub(F.position,H.centroidWorld);u.normalize();U=H.normalWorld.dot(u)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){r=e(w++);r.setAttribute("d","M "+P.positionScreen.x+
+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear);
+d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(r)}function f(P,H,X,K,E,F,U){r=e(w++);r.setAttribute("d",
+"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i=
+1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(r)}
+function e(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,B,D,x,A,M,Q,O=new THREE.Rectangle,s=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),q=new THREE.Color(0),n=new THREE.Color(0),
+l=new THREE.Color(0),i,u=new THREE.Vector3,o=[],y=[],t=[],r,w,W,G,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":T=1;break;case "low":T=0}};this.setSize=function(P,H){k=P;m=H;B=k/2;D=m/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+m);c.setAttribute("width",k);c.setAttribute("height",m);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K,
+E,F,U,R,C,N;this.autoClear&&this.clear();j=p.projectScene(P,H,this.sortElements);G=W=w=0;if(L=P.lights.length>0){C=P.lights;q.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);X=0;for(K=C.length;X<K;X++){E=C[X];F=E.color;if(E instanceof THREE.AmbientLight){q.r+=F.r;q.g+=F.g;q.b+=F.b}else if(E instanceof THREE.DirectionalLight){n.r+=F.r;n.g+=F.g;n.b+=F.b}else if(E instanceof THREE.PointLight){l.r+=F.r;l.g+=F.g;l.b+=F.b}}}X=0;for(K=j.length;X<K;X++){C=j[X];s.empty();if(C instanceof THREE.RenderableParticle){x=
+C;x.x*=B;x.y*=-D;E=0;for(F=C.materials.length;E<F;E++)if(N=C.materials[E]){U=x;R=C;N=N;var V=W++;if(y[V]==null){y[V]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&y[V].setAttribute("shape-rendering","crispEdges")}r=y[V];r.setAttribute("cx",U.x);r.setAttribute("cy",U.y);r.setAttribute("r",R.scale.x*B);if(N instanceof THREE.ParticleCircleMaterial){if(L){h.r=q.r+n.r+l.r;h.g=q.g+n.g+l.g;h.b=q.b+n.b+l.b;d.r=N.color.r*h.r;d.g=N.color.g*h.g;d.b=N.color.b*h.b;d.updateStyleString()}else d=
+N.color;r.setAttribute("style","fill: "+d.__styleString)}c.appendChild(r)}}else if(C instanceof THREE.RenderableLine){x=C.v1;A=C.v2;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(A.positionScreen.x,A.positionScreen.y);if(O.instersects(s)){E=0;for(F=C.materials.length;E<F;)if(N=C.materials[E++]){U=x;R=A;N=N;V=G++;if(t[V]==null){t[V]=document.createElementNS("http://www.w3.org/2000/svg","line");T==
+0&&t[V].setAttribute("shape-rendering","crispEdges")}r=t[V];r.setAttribute("x1",U.positionScreen.x);r.setAttribute("y1",U.positionScreen.y);r.setAttribute("x2",R.positionScreen.x);r.setAttribute("y2",R.positionScreen.y);if(N instanceof THREE.LineBasicMaterial){d.__styleString=N.color.__styleString;r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+N.linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.linecap+"; stroke-linejoin: "+N.linejoin);c.appendChild(r)}}}}else if(C instanceof
+THREE.RenderableFace3){x=C.v1;A=C.v2;M=C.v3;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(A.positionScreen.x,A.positionScreen.y);s.addPoint(M.positionScreen.x,M.positionScreen.y);if(O.instersects(s)){E=0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&
+b(x,A,M,C,N,P)}else N&&b(x,A,M,C,N,P)}}}else if(C instanceof THREE.RenderableFace4){x=C.v1;A=C.v2;M=C.v3;Q=C.v4;x.positionScreen.x*=B;x.positionScreen.y*=-D;A.positionScreen.x*=B;A.positionScreen.y*=-D;M.positionScreen.x*=B;M.positionScreen.y*=-D;Q.positionScreen.x*=B;Q.positionScreen.y*=-D;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(A.positionScreen.x,A.positionScreen.y);s.addPoint(M.positionScreen.x,M.positionScreen.y);s.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(s)){E=
 0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&f(x,A,M,Q,C,N,P)}else N&&f(x,A,M,Q,C,N,P)}}}}}};
 0;for(F=C.meshMaterials.length;E<F;){N=C.meshMaterials[E++];if(N instanceof THREE.MeshFaceMaterial){U=0;for(R=C.faceMaterials.length;U<R;)(N=C.faceMaterials[U++])&&f(x,A,M,Q,C,N,P)}else N&&f(x,A,M,Q,C,N,P)}}}}}};
 THREE.WebGLRenderer=function(a){function b(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function f(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;d.uniforms.map.texture=d.map;d.uniforms.env_map.texture=d.env_map;d.uniforms.reflectivity.value=d.reflectivity;d.uniforms.refraction_ratio.value=d.refraction_ratio;d.uniforms.combine.value=d.combine;d.uniforms.useRefract.value=
 THREE.WebGLRenderer=function(a){function b(d,h){d.fragment_shader=h.fragment_shader;d.vertex_shader=h.vertex_shader;d.uniforms=Uniforms.clone(h.uniforms)}function f(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;d.uniforms.map.texture=d.map;d.uniforms.env_map.texture=d.env_map;d.uniforms.reflectivity.value=d.reflectivity;d.uniforms.refraction_ratio.value=d.refraction_ratio;d.uniforms.combine.value=d.combine;d.uniforms.useRefract.value=
 d.env_map&&d.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function e(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=
 d.env_map&&d.env_map.mapping instanceof THREE.CubeRefractionMapping;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function e(d,h){d.uniforms.color.value.setRGB(d.color.r*d.opacity,d.color.g*d.opacity,d.color.b*d.opacity);d.uniforms.opacity.value=d.opacity;if(h){d.uniforms.fogColor.value.setHex(h.color.hex);if(h instanceof THREE.Fog){d.uniforms.fogNear.value=
-h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var r;if(d=="fragment")r=c.createShader(c.FRAGMENT_SHADER);else if(d=="vertex")r=c.createShader(c.VERTEX_SHADER);c.shaderSource(r,h);c.compileShader(r);if(!c.getShaderParameter(r,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(r));return null}return r}function j(d){switch(d){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,k=null,l=new THREE.Matrix4,B,D=new Float32Array(16),x=new Float32Array(16),A=new Float32Array(16),
-M=new Float32Array(9),Q=new Float32Array(16),O=true,q=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&q.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=o;this.autoClear=true;(function(d,h,r){try{c=o.getContext("experimental-webgl",{antialias:d})}catch(m){}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(h.r,h.g,h.b,r)})(O,q,L);this.setSize=function(d,h){o.width=d;o.height=h;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(d,h){var r=new THREE.Color(d);c.clearColor(r.r,r.g,r.b,h)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var r,m,n,i=0,t=0,p=0,y=[],u=[],s=[],w=[];r=0;for(m=h.length;r<m;r++){n=h[r];if(n instanceof THREE.AmbientLight){i+=
-n.color.r;t+=n.color.g;p+=n.color.b}else if(n instanceof THREE.DirectionalLight){y.push(n.color.r*n.intensity,n.color.g*n.intensity,n.color.b*n.intensity);u.push(n.position.x,n.position.y,n.position.z)}else if(n instanceof THREE.PointLight){s.push(n.color.r*n.intensity,n.color.g*n.intensity,n.color.b*n.intensity);w.push(n.position.x,n.position.y,n.position.z)}}return{ambient:[i,t,p],directional:{colors:y,positions:u},point:{colors:s,positions:w}}};this.createLineBuffers=function(d){var h,r,m,n=[],
-i=[],t=d.geometry.vertices;h=0;for(r=t.length;h<r;h++){m=t[h].position;n.push(m.x,m.y,m.z);i.push(h)}if(n.length){d.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(n),c.STATIC_DRAW);d.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(i),c.STATIC_DRAW);d.__webGLLineCount=i.length}};this.createBuffers=function(d,h){var r,m,
-n,i,t,p,y,u,s,w,W=[],G=[],T=[],P=[],H=[],X=[],K=0,E=d.geometry.geometryChunks[h],F;t=false;r=0;for(m=d.materials.length;r<m;r++){p=d.materials[r];if(p instanceof THREE.MeshFaceMaterial){p=0;for(F=E.materials.length;p<F;p++)if(E.materials[p]&&E.materials[p].shading!=undefined&&E.materials[p].shading==THREE.SmoothShading){t=true;break}}else if(p&&p.shading!=undefined&&p.shading==THREE.SmoothShading){t=true;break}if(t)break}F=t;r=0;for(m=E.faces.length;r<m;r++){n=E.faces[r];i=d.geometry.faces[n];t=i.vertexNormals;
-p=i.normal;n=d.geometry.uvs[n];if(i instanceof THREE.Face3){y=d.geometry.vertices[i.a].position;u=d.geometry.vertices[i.b].position;s=d.geometry.vertices[i.c].position;T.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;u=d.geometry.vertices[i.b].tangent;s=d.geometry.vertices[i.c].tangent;H.push(y.x,y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w)}if(t.length==3&&F)for(i=0;i<3;i++)P.push(t[i].x,t[i].y,t[i].z);else for(i=0;i<3;i++)P.push(p.x,p.y,p.z);
-if(n)for(i=0;i<3;i++)X.push(n[i].u,n[i].v);W.push(K,K+1,K+2);G.push(K,K+1,K,K+2,K+1,K+2);K+=3}else if(i instanceof THREE.Face4){y=d.geometry.vertices[i.a].position;u=d.geometry.vertices[i.b].position;s=d.geometry.vertices[i.c].position;w=d.geometry.vertices[i.d].position;T.push(y.x,y.y,y.z,u.x,u.y,u.z,s.x,s.y,s.z,w.x,w.y,w.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;u=d.geometry.vertices[i.b].tangent;s=d.geometry.vertices[i.c].tangent;i=d.geometry.vertices[i.d].tangent;H.push(y.x,
-y.y,y.z,y.w,u.x,u.y,u.z,u.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}if(t.length==4&&F)for(i=0;i<4;i++)P.push(t[i].x,t[i].y,t[i].z);else for(i=0;i<4;i++)P.push(p.x,p.y,p.z);if(n)for(i=0;i<4;i++)X.push(n[i].u,n[i].v);W.push(K,K+1,K+2,K,K+2,K+3);G.push(K,K+1,K,K+2,K,K+3,K+1,K+2,K+2,K+3);K+=4}}if(T.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,
+h.near;d.uniforms.fogFar.value=h.far}else if(h instanceof THREE.FogExp2)d.uniforms.fogDensity.value=h.density}}function g(d,h){var q;if(d=="fragment")q=c.createShader(c.FRAGMENT_SHADER);else if(d=="vertex")q=c.createShader(c.VERTEX_SHADER);c.shaderSource(q,h);c.compileShader(q);if(!c.getShaderParameter(q,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(q));return null}return q}function j(d){switch(d){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 p=document.createElement("canvas"),c,k=null,m=new THREE.Matrix4,B,D=new Float32Array(16),x=new Float32Array(16),A=new Float32Array(16),
+M=new Float32Array(9),Q=new Float32Array(16),O=true,s=new THREE.Color(0),L=0;if(a){if(a.antialias!==undefined)O=a.antialias;a.clearColor!==undefined&&s.setHex(a.clearColor);if(a.clearAlpha!==undefined)L=a.clearAlpha}this.domElement=p;this.autoClear=true;(function(d,h,q){try{c=p.getContext("experimental-webgl",{antialias:d})}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(h.r,h.g,h.b,q)})(O,s,L);this.setSize=function(d,h){p.width=d;p.height=h;c.viewport(0,0,p.width,p.height)};this.setClearColor=function(d,h){var q=new THREE.Color(d);c.clearColor(q.r,q.g,q.b,h)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(d,h){var q,n,l,i=0,u=0,o=0,y=[],t=[],r=[],w=[];q=0;for(n=h.length;q<n;q++){l=h[q];if(l instanceof THREE.AmbientLight){i+=
+l.color.r;u+=l.color.g;o+=l.color.b}else if(l instanceof THREE.DirectionalLight){y.push(l.color.r*l.intensity,l.color.g*l.intensity,l.color.b*l.intensity);t.push(l.position.x,l.position.y,l.position.z)}else if(l instanceof THREE.PointLight){r.push(l.color.r*l.intensity,l.color.g*l.intensity,l.color.b*l.intensity);w.push(l.position.x,l.position.y,l.position.z)}}return{ambient:[i,u,o],directional:{colors:y,positions:t},point:{colors:r,positions:w}}};this.createParticleBuffers=function(){};this.createLineBuffers=
+function(d){var h,q,n,l=[],i=[],u=d.geometry.vertices;h=0;for(q=u.length;h<q;h++){n=u[h].position;l.push(n.x,n.y,n.z);i.push(h)}if(l.length){d.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(l),c.STATIC_DRAW);d.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(i),c.STATIC_DRAW);d.__webGLLineCount=i.length}};this.createBuffers=
+function(d,h){var q,n,l,i,u,o,y,t,r,w,W=[],G=[],T=[],P=[],H=[],X=[],K=0,E=d.geometry.geometryChunks[h],F;u=false;q=0;for(n=d.materials.length;q<n;q++){o=d.materials[q];if(o instanceof THREE.MeshFaceMaterial){o=0;for(F=E.materials.length;o<F;o++)if(E.materials[o]&&E.materials[o].shading!=undefined&&E.materials[o].shading==THREE.SmoothShading){u=true;break}}else if(o&&o.shading!=undefined&&o.shading==THREE.SmoothShading){u=true;break}if(u)break}F=u;q=0;for(n=E.faces.length;q<n;q++){l=E.faces[q];i=d.geometry.faces[l];
+u=i.vertexNormals;o=i.normal;l=d.geometry.uvs[l];if(i instanceof THREE.Face3){y=d.geometry.vertices[i.a].position;t=d.geometry.vertices[i.b].position;r=d.geometry.vertices[i.c].position;T.push(y.x,y.y,y.z,t.x,t.y,t.z,r.x,r.y,r.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;t=d.geometry.vertices[i.b].tangent;r=d.geometry.vertices[i.c].tangent;H.push(y.x,y.y,y.z,y.w,t.x,t.y,t.z,t.w,r.x,r.y,r.z,r.w)}if(u.length==3&&F)for(i=0;i<3;i++)P.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<3;i++)P.push(o.x,
+o.y,o.z);if(l)for(i=0;i<3;i++)X.push(l[i].u,l[i].v);W.push(K,K+1,K+2);G.push(K,K+1,K,K+2,K+1,K+2);K+=3}else if(i instanceof THREE.Face4){y=d.geometry.vertices[i.a].position;t=d.geometry.vertices[i.b].position;r=d.geometry.vertices[i.c].position;w=d.geometry.vertices[i.d].position;T.push(y.x,y.y,y.z,t.x,t.y,t.z,r.x,r.y,r.z,w.x,w.y,w.z);if(d.geometry.hasTangents){y=d.geometry.vertices[i.a].tangent;t=d.geometry.vertices[i.b].tangent;r=d.geometry.vertices[i.c].tangent;i=d.geometry.vertices[i.d].tangent;
+H.push(y.x,y.y,y.z,y.w,t.x,t.y,t.z,t.w,r.x,r.y,r.z,r.w,i.x,i.y,i.z,i.w)}if(u.length==4&&F)for(i=0;i<4;i++)P.push(u[i].x,u[i].y,u[i].z);else for(i=0;i<4;i++)P.push(o.x,o.y,o.z);if(l)for(i=0;i<4;i++)X.push(l[i].u,l[i].v);W.push(K,K+1,K+2,K,K+2,K+3);G.push(K,K+1,K,K+2,K,K+3,K+1,K+2,K+2,K+3);K+=4}}if(T.length){E.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW);E.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,
 E.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);if(d.geometry.hasTangents){E.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}if(X.length>0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
 E.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);if(d.geometry.hasTangents){E.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW)}if(X.length>0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,r,m,n){var i,t,p,y;if(!m.program){if(m instanceof THREE.MeshDepthMaterial){b(m,THREE.ShaderLib.depth);m.uniforms.mNear.value=d.near;m.uniforms.mFar.value=d.far}else if(m instanceof
-THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial){b(m,THREE.ShaderLib.basic);f(m,r)}else if(m instanceof THREE.MeshLambertMaterial){b(m,THREE.ShaderLib.lambert);f(m,r)}else if(m instanceof THREE.MeshPhongMaterial){b(m,THREE.ShaderLib.phong);f(m,r)}else if(m instanceof THREE.LineBasicMaterial){b(m,THREE.ShaderLib.basic);e(m,r)}if(scene){var u,s,w;u=y=t=0;for(s=h.length;u<s;u++){w=h[u];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&
-t++}if(t+y<=4){u=y;t=t}else{u=Math.ceil(4*y/(t+y));t=4-u}t={directional:u,point:t}}else t={directional:1,point:3};y={fog:r,map:m.map,env_map:m.env_map,maxDirLights:t.directional,maxPointLights:t.point};t=m.fragment_shader;u=m.vertex_shader;s=c.createProgram();w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",
-y.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");y=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
-c.attachShader(s,g("fragment",w+t));c.attachShader(s,g("vertex",y+u));c.linkProgram(s);c.getProgramParameter(s,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(s,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");s.uniforms={};s.attributes={};m.program=s;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in m.uniforms)t.push(i);i=m.program;u=0;for(s=t.length;u<s;u++){w=t[u];i.uniforms[w]=c.getUniformLocation(i,
-w)}i=m.program;t=["position","normal","uv","tangent"];u=0;for(s=t.length;u<s;u++){w=t[u];i.attributes[w]=c.getAttribLocation(i,w)}}i=m.program;if(i!=k){c.useProgram(i);k=i}this.loadCamera(i,d);this.loadMatrices(i);if(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial){d=this.setupLights(i,h);m.uniforms.enableLighting.value=d.directional.positions.length+d.point.positions.length;m.uniforms.ambientLightColor.value=d.ambient;m.uniforms.directionalLightColor.value=d.directional.colors;
-m.uniforms.directionalLightDirection.value=d.directional.positions;m.uniforms.pointLightColor.value=d.point.colors;m.uniforms.pointLightPosition.value=d.point.positions}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial)f(m,r);m instanceof THREE.LineBasicMaterial&&e(m,r);if(m instanceof THREE.MeshPhongMaterial){m.uniforms.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);m.uniforms.specular.value.setRGB(m.specular.r,m.specular.g,
-m.specular.b);m.uniforms.shininess.value=m.shininess}r=m.uniforms;for(p in r)if(t=i.uniforms[p]){h=r[p].type;d=r[p].value;if(h=="i")c.uniform1i(t,d);else if(h=="f")c.uniform1f(t,d);else if(h=="fv")c.uniform3fv(t,d);else if(h=="v2")c.uniform2f(t,d.x,d.y);else if(h=="v3")c.uniform3f(t,d.x,d.y,d.z);else if(h=="c")c.uniform3f(t,d.r,d.g,d.b);else if(h=="t"){c.uniform1i(t,d);if(h=r[p].texture)if(h.image instanceof Array&&h.image.length==6){h=h;d=d;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(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,
-h.image[t]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}else{h=h;d=d;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,j(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,
-j(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}}}p=i.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.position);if(p.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);
-c.vertexAttribPointer(p.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.normal)}if(p.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(p.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(p.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(p.uv)}else c.disableVertexAttribArray(p.uv);if(m.wireframe||m instanceof THREE.LineBasicMaterial){p=
-m.wireframe_linewidth!==undefined?m.wireframe_linewidth:m.linewidth!==undefined?m.linewidth:1;m=m instanceof THREE.LineBasicMaterial&&n.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(m,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,r,m,n,i,t){var p,y,u,s,w;u=0;for(s=
-m.materials.length;u<s;u++){p=m.materials[u];if(p instanceof THREE.MeshFaceMaterial){p=0;for(y=n.materials.length;p<y;p++)if((w=n.materials[p])&&w.blending==i&&w.opacity<1==t){this.setBlending(w.blending);this.renderBuffer(d,h,r,w,n)}}else if((w=p)&&w.blending==i&&w.opacity<1==t){this.setBlending(w.blending);this.renderBuffer(d,h,r,w,n)}}};this.render=function(d,h){var r,m,n,i,t=d.lights,p=d.fog;this.initWebGLObjects(d);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();D.set(h.matrix.flatten());
-A.set(h.projectionMatrix.flatten());r=0;for(m=d.__webGLObjects.length;r<m;r++){n=d.__webGLObjects[r];i=n.object;n=n.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,t,p,i,n,THREE.NormalBlending,false)}}r=0;for(m=d.__webGLObjects.length;r<m;r++){n=d.__webGLObjects[r];i=n.object;n=n.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,t,p,i,n,THREE.AdditiveBlending,false);this.renderPass(h,t,p,i,n,THREE.SubtractiveBlending,false);this.renderPass(h,t,p,i,n,THREE.AdditiveBlending,
-true);this.renderPass(h,t,p,i,n,THREE.SubtractiveBlending,true);this.renderPass(h,t,p,i,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(d){var h,r,m,n,i,t;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={}}h=0;for(r=d.objects.length;h<r;h++){m=d.objects[h];if(d.__webGLObjectsMap[m.id]==undefined)d.__webGLObjectsMap[m.id]={};t=d.__webGLObjectsMap[m.id];if(m instanceof THREE.Mesh)for(i in m.geometry.geometryChunks){n=m.geometry.geometryChunks[i];n.__webGLVertexBuffer||this.createBuffers(m,
-i);if(t[i]==undefined){n={buffer:n,object:m};d.__webGLObjects.push(n);t[i]=1}}else if(m instanceof THREE.Line){m.__webGLVertexBuffer||this.createLineBuffers(m);i=0;if(t[i]==undefined){n={buffer:m,object:m};d.__webGLObjects.push(n);t[i]=1}}}};this.removeObject=function(d,h){var r,m;for(r=d.__webGLObjects.length-1;r>=0;r--){m=d.__webGLObjects[r].object;h==m&&d.__webGLObjects.splice(r,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(h.matrix,d.matrix);x.set(l.flatten());
-B=THREE.Matrix4.makeInvert3x3(l).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=
-function(d){switch(d){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(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=
-function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,q,n,l){var i,u,o,y;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=d.near;n.uniforms.mFar.value=d.far}else if(n instanceof
+THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);f(n,q)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);f(n,q)}else if(n instanceof THREE.MeshPhongMaterial){b(n,THREE.ShaderLib.phong);f(n,q)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,q)}var t,r,w;t=y=u=0;for(r=h.length;t<r;t++){w=h[t];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&u++}if(u+
+y<=4){t=y;u=u}else{t=Math.ceil(4*y/(u+y));u=4-t}u={directional:t,point:u};y={fog:q,map:n.map,env_map:n.env_map,maxDirLights:u.directional,maxPointLights:u.point};u=n.fragment_shader;t=n.vertex_shader;r=c.createProgram();w=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
+y=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(r,
+g("fragment",w+u));c.attachShader(r,g("vertex",y+t));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms={};r.attributes={};n.program=r;u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in n.uniforms)u.push(i);i=n.program;t=0;for(r=u.length;t<r;t++){w=u[t];i.uniforms[w]=c.getUniformLocation(i,w)}i=
+n.program;u=["position","normal","uv","tangent"];t=0;for(r=u.length;t<r;t++){w=u[t];i.attributes[w]=c.getAttribLocation(i,w)}}i=n.program;if(i!=k){c.useProgram(i);k=i}this.loadCamera(i,d);this.loadMatrices(i);if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){d=this.setupLights(i,h);n.uniforms.enableLighting.value=d.directional.positions.length+d.point.positions.length;n.uniforms.ambientLightColor.value=d.ambient;n.uniforms.directionalLightColor.value=d.directional.colors;
+n.uniforms.directionalLightDirection.value=d.directional.positions;n.uniforms.pointLightColor.value=d.point.colors;n.uniforms.pointLightPosition.value=d.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial)f(n,q);n instanceof THREE.LineBasicMaterial&&e(n,q);if(n instanceof THREE.MeshPhongMaterial){n.uniforms.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);n.uniforms.specular.value.setRGB(n.specular.r,n.specular.g,
+n.specular.b);n.uniforms.shininess.value=n.shininess}q=n.uniforms;for(o in q)if(u=i.uniforms[o]){h=q[o].type;d=q[o].value;if(h=="i")c.uniform1i(u,d);else if(h=="f")c.uniform1f(u,d);else if(h=="fv")c.uniform3fv(u,d);else if(h=="v2")c.uniform2f(u,d.x,d.y);else if(h=="v3")c.uniform3f(u,d.x,d.y,d.z);else if(h=="c")c.uniform3f(u,d.r,d.g,d.b);else if(h=="t"){c.uniform1i(u,d);if(h=q[o].texture)if(h.image instanceof Array&&h.image.length==6){h=h;d=d;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(u=0;u<6;++u)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,
+h.image[u]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}else{h=h;d=d;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,j(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,
+j(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,j(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,j(h.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}}}o=i.attributes;c.bindBuffer(c.ARRAY_BUFFER,l.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.position);if(o.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer);
+c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(l.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){o=
+n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&l.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);c.drawElements(n,l.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,l.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,q,n,l,i,u){var o,y,t,r,w;t=0;for(r=
+n.materials.length;t<r;t++){o=n.materials[t];if(o instanceof THREE.MeshFaceMaterial){o=0;for(y=l.materials.length;o<y;o++)if((w=l.materials[o])&&w.blending==i&&w.opacity<1==u){this.setBlending(w.blending);this.renderBuffer(d,h,q,w,l)}}else if((w=o)&&w.blending==i&&w.opacity<1==u){this.setBlending(w.blending);this.renderBuffer(d,h,q,w,l)}}};this.render=function(d,h){var q,n,l,i,u=d.lights,o=d.fog;this.initWebGLObjects(d);this.autoClear&&this.clear();h.autoUpdateMatrix&&h.updateMatrix();D.set(h.matrix.flatten());
+A.set(h.projectionMatrix.flatten());q=0;for(n=d.__webGLObjects.length;q<n;q++){l=d.__webGLObjects[q];i=l.object;l=l.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,u,o,i,l,THREE.NormalBlending,false)}}q=0;for(n=d.__webGLObjects.length;q<n;q++){l=d.__webGLObjects[q];i=l.object;l=l.buffer;if(i.visible){this.setupMatrices(i,h);this.renderPass(h,u,o,i,l,THREE.AdditiveBlending,false);this.renderPass(h,u,o,i,l,THREE.SubtractiveBlending,false);this.renderPass(h,u,o,i,l,THREE.AdditiveBlending,
+true);this.renderPass(h,u,o,i,l,THREE.SubtractiveBlending,true);this.renderPass(h,u,o,i,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(d){function h(y,t,r,w){if(y[t]==undefined){d.__webGLObjects.push({buffer:r,object:w});y[t]=1}}var q,n,l,i,u,o;if(!d.__webGLObjects){d.__webGLObjects=[];d.__webGLObjectsMap={}}q=0;for(n=d.objects.length;q<n;q++){l=d.objects[q];if(d.__webGLObjectsMap[l.id]==undefined)d.__webGLObjectsMap[l.id]={};o=d.__webGLObjectsMap[l.id];if(l instanceof THREE.Mesh)for(i in l.geometry.geometryChunks){u=
+l.geometry.geometryChunks[i];u.__webGLVertexBuffer||this.createBuffers(l,i);h(o,i,u,l)}else if(l instanceof THREE.Line){l.__webGLVertexBuffer||this.createLineBuffers(l);h(o,0,l,l)}else if(l instanceof THREE.ParticleSystem){l.__webGLVertexBuffer||this.createParticleBuffers(l);h(o,0,l,l)}}};this.removeObject=function(d,h){var q,n;for(q=d.__webGLObjects.length-1;q>=0;q--){n=d.__webGLObjects[q].object;h==n&&d.__webGLObjects.splice(q,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();
+m.multiply(h.matrix,d.matrix);x.set(m.flatten());B=THREE.Matrix4.makeInvert3x3(m).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,
+h.position.y,h.position.z)};this.setBlending=function(d){switch(d){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(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};
+this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",

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


+ 1 - 0
examples/uqbiquity_test.html

@@ -38,6 +38,7 @@
 		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
 		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
 		<script type="text/javascript" src="../src/objects/Object3D.js"></script>
 		<script type="text/javascript" src="../src/objects/Object3D.js"></script>
 		<script type="text/javascript" src="../src/objects/Particle.js"></script>
 		<script type="text/javascript" src="../src/objects/Particle.js"></script>
+		<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
 		<script type="text/javascript" src="../src/objects/Line.js"></script>
 		<script type="text/javascript" src="../src/objects/Line.js"></script>
 		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
 		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
 		<script type="text/javascript" src="../src/materials/Material.js"></script>
 		<script type="text/javascript" src="../src/materials/Material.js"></script>

+ 41 - 39
src/renderers/WebGLRenderer.js

@@ -116,6 +116,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.createParticleBuffers = function( object ) {
+	};
+	
 	this.createLineBuffers = function( object ) {
 	this.createLineBuffers = function( object ) {
 		
 		
 		var v, vl, vertex, 
 		var v, vl, vertex, 
@@ -727,7 +730,18 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	this.initWebGLObjects = function( scene ) {
 	this.initWebGLObjects = function( scene ) {
 
 
-		var o, ol, object, globject, g, geometryChunk, objmap;
+		function add_buffer( objmap, id, buffer, object ) {
+			
+			if ( objmap[ id ] == undefined ) {
+
+				scene.__webGLObjects.push( { buffer: buffer, object: object } );
+				objmap[ id ] = 1;
+
+			}
+			
+		};
+		
+		var o, ol, object, g, geometryChunk, objmap;
 
 
 		if ( !scene.__webGLObjects ) {
 		if ( !scene.__webGLObjects ) {
 
 
@@ -766,14 +780,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 					// create separate wrapper per each use of VBO
 					// create separate wrapper per each use of VBO
 
 
-					if ( objmap[ g ] == undefined ) {
-
-						globject = { buffer: geometryChunk, object: object };
-						scene.__webGLObjects.push( globject );
-
-						objmap[ g ] = 1;
-
-					}
+					add_buffer( objmap, g, geometryChunk, object );
 
 
 				}
 				}
 
 
@@ -786,20 +793,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 					
 					
 				}
 				}
 				
 				
-				g = 0;
+				add_buffer( objmap, 0, object, object );
 				
 				
-				if ( objmap[ g ] == undefined ) {
 
 
-					globject = { buffer: object, object: object };
-					scene.__webGLObjects.push( globject );
-
-					objmap[ g ] = 1;
+			} else if ( object instanceof THREE.ParticleSystem ) {
 
 
+				if( ! object.__webGLVertexBuffer ) {
+				
+					this.createParticleBuffers( object );
+					
 				}
 				}
-
-			}/*  else if ( object instanceof THREE.ParticleSystem ) {
-
-			}else if ( object instanceof THREE.Particle ) {
+				
+				add_buffer( objmap, 0, object, object );
+				
+				
+			}/*else if ( object instanceof THREE.Particle ) {
 
 
 			}*/
 			}*/
 
 
@@ -1275,37 +1283,31 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	function allocateLights( lights, maxLights ) {
 	function allocateLights( lights, maxLights ) {
 
 
-		if ( scene ) {
-
-			var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
-			dirLights = pointLights = maxDirLights = maxPointLights = 0;
-
-			for ( l = 0, ll = lights.length; l < ll; l++ ) {
-
-				light = lights[ l ];
+		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
+		dirLights = pointLights = maxDirLights = maxPointLights = 0;
 
 
-				if ( light instanceof THREE.DirectionalLight ) dirLights++;
-				if ( light instanceof THREE.PointLight ) pointLights++;
+		for ( l = 0, ll = lights.length; l < ll; l++ ) {
 
 
-			}
+			light = lights[ l ];
 
 
-			if ( ( pointLights + dirLights ) <= maxLights ) {
+			if ( light instanceof THREE.DirectionalLight ) dirLights++;
+			if ( light instanceof THREE.PointLight ) pointLights++;
 
 
-				maxDirLights = dirLights;
-				maxPointLights = pointLights;
+		}
 
 
-			} else {
+		if ( ( pointLights + dirLights ) <= maxLights ) {
 
 
-				maxDirLights = Math.ceil( maxLights * dirLights / ( pointLights + dirLights ) );
-				maxPointLights = maxLights - maxDirLights;
+			maxDirLights = dirLights;
+			maxPointLights = pointLights;
 
 
-			}
+		} else {
 
 
-			return { 'directional' : maxDirLights, 'point' : maxPointLights };
+			maxDirLights = Math.ceil( maxLights * dirLights / ( pointLights + dirLights ) );
+			maxPointLights = maxLights - maxDirLights;
 
 
 		}
 		}
 
 
-		return { 'directional' : 1, 'point' : maxLights - 1 };
+		return { 'directional' : maxDirLights, 'point' : maxPointLights };
 
 
 	};
 	};
 
 

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