Browse Source

Merge https://github.com/mrdoob/three.js

astrodud 14 years ago
parent
commit
2a7262ccd9
5 changed files with 191 additions and 276 deletions
  1. 82 82
      build/Three.js
  2. 83 83
      build/ThreeDebug.js
  3. 4 4
      build/ThreeExtras.js
  4. 11 9
      src/cameras/Camera.js
  5. 11 98
      src/extras/ShaderUtils.js

+ 82 - 82
build/Three.js

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

+ 83 - 83
build/ThreeDebug.js

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

+ 4 - 4
build/ThreeExtras.js

@@ -57,10 +57,10 @@ z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.
 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,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(v){var D=[];b=0;for(d=v.length;b<d;b++)v[b]==undefined?D.push("undefined"):D.push(v[b].toString());return D.join("_")}var b,d,e,g,h,j,c,i,l={};e=0;for(g=this.faces.length;e<g;e++){h=this.faces[e];
 j=h.materials;c=a(j);if(l[c]==undefined)l[c]={hash:c,counter:0};i=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0};h=h instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+h>65535){l[c].counter+=1;i=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(e);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.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)};
-THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
-THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
+THREE.Camera=function(a,b,d,e){this.fov=a;this.aspect=b;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
+this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()};
+THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;
+THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
 THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
 this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false};

+ 11 - 9
src/cameras/Camera.js

@@ -18,14 +18,16 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 	this.matrix = new THREE.Matrix4();
 
 	this.up = new THREE.Vector3( 0, 1, 0 );
+	
+	this.tmpVec = new THREE.Vector3();
 
 	this.translateX = function ( amount ) {
 
-		var vector = this.target.position.clone().subSelf( this.position ).normalize().multiplyScalar( amount );
-		vector.cross( vector.clone(), this.up );
-
-		this.position.addSelf( vector );
-		this.target.position.addSelf( vector );
+		this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
+		this.tmpVec.crossSelf( this.up );
+		
+		this.position.addSelf( this.tmpVec );
+		this.target.position.addSelf( this.tmpVec );
 
 	};
 
@@ -37,10 +39,10 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 
 	this.translateZ = function ( amount ) {
 
-		var vector = this.target.position.clone().subSelf( this.position ).normalize().multiplyScalar( amount );
-
-		this.position.subSelf( vector );
-		this.target.position.subSelf( vector );
+		this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
+		
+		this.position.subSelf( this.tmpVec );
+		this.target.position.subSelf( this.tmpVec );
 
 	};
 

+ 11 - 98
src/extras/ShaderUtils.js

@@ -262,28 +262,21 @@ var ShaderUtils = {
 			].join("\n")
 
 		},
-		/*
-		'hatching' : {
 
-			uniforms: {
-
-				"uSampler": { type: "t", value: 2, texture: null },
-
-				"uDirLightPos":	{ type: "v3", value: new THREE.Vector3() },
-				"uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
-
-				"uAmbientLightColor": { type: "c", value: new THREE.Color( 0x050505 ) }
+		'cube': {
 
-			},
+			uniforms: { "tCube": { type: "t", value: 1, texture: null } },
 
 			vertex_shader: [
 
-				"varying vec3 vNormal;",
+				"varying vec3 vViewPosition;",
 
 				"void main() {",
 
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+					"vViewPosition = cameraPosition - mPosition.xyz;",
+
 					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-					"vNormal = normalize( normalMatrix * normal );",
 
 				"}"
 
@@ -291,65 +284,21 @@ var ShaderUtils = {
 
 			fragment_shader: [
 
-				"uniform vec3 uDirLightPos;",
-				"uniform vec3 uDirLightColor;",
-
-				"uniform vec3 uAmbientLightColor;",
-
-				"uniform sampler2D uSampler;",
+				"uniform samplerCube tCube;",
 
-				"varying vec3 vNormal;",
+				"varying vec3 vViewPosition;",
 
 				"void main() {",
 
-					"float directionalLightWeighting = max(dot(normalize(vNormal), uDirLightPos), 0.0);",
-					"vec3 lightWeighting = uAmbientLightColor + uDirLightColor * directionalLightWeighting;",
-
-					"gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);",
-
-					"if (length(lightWeighting) < 1.00) {",
-
-						"if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {",
-
-							"gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
-
-						"}",
-
-					"}",
-
-					"if (length(lightWeighting) < 0.75) {",
-
-						"if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {",
-
-							"gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
-
-						"}",
-					"}",
-
-					"if (length(lightWeighting) < 0.50) {",
-
-						"if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
-
-							"gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
-
-						"}",
-					"}",
-
-					"if (length(lightWeighting) < 0.3465) {",
-
-						"if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {",
-
-							"gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);",
-
-						"}",
-					"}",
+					"vec3 wPos = cameraPosition - vViewPosition;",
+					"gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );",
 
 				"}"
 
 			].join("\n")
 
 		},
-		*/
+
 		'basic': {
 
 			uniforms: {},
@@ -374,42 +323,6 @@ var ShaderUtils = {
 
 			].join("\n")
 
-		},
-
-		'cube': {
-
-			uniforms: { "tCube": { type: "t", value: 1, texture: null } },
-
-			vertex_shader: [
-
-				"varying vec3 vViewPosition;",
-
-				"void main() {",
-
-					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
-					"vViewPosition = cameraPosition - mPosition.xyz;",
-
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragment_shader: [
-
-				"uniform samplerCube tCube;",
-
-				"varying vec3 vViewPosition;",
-
-				"void main() {",
-
-					"vec3 wPos = cameraPosition - vViewPosition;",
-					"gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );",
-
-				"}"
-
-			].join("\n")
-
 		}
 
 	}