Răsfoiți Sursa

Cleaned up CanvasRenderer/MeshDepthMaterial code.
Moved near/far values from MeshDepthMaterial to Camera (CanvasRenderer/WebGLRenderer/WebGLRenderer2).

Mr.doob 14 ani în urmă
părinte
comite
e46346c9ba

+ 124 - 124
build/Three.js

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

+ 125 - 125
build/ThreeDebug.js

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

Fișier diff suprimat deoarece este prea mare
+ 108 - 108
build/ThreeExtras.js


+ 1 - 1
examples/camera_orthographic.html

@@ -41,7 +41,7 @@
 				info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - orthographic view';
 				container.appendChild( info );
 
-				camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, - 2000, 1000 );
 				camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 1000 );
 				camera.position.x = 200;
 				camera.position.y = 100;

+ 14 - 12
examples/materials.html

@@ -29,6 +29,7 @@
 			var particleLight, pointLight;
 
 			init();
+			// loop();
 			setInterval( loop, 1000 / 60 );
 
 			function init() {
@@ -69,18 +70,19 @@
 
 				var geometry = new Sphere( 100, 14, 7, false );
 
-				var materials = [];
-				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true } );
-				//materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ), overdraw: false, doubleSided: true } );
-				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
-				// materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
-				materials.push( { material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false } );
+				var materials = [
+
+					{ material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true },
+					{ material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true },
+					{ material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false },
+					{ material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false },
+					{ material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false }
+
+				];
 
 				for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
 

+ 1 - 1
examples/materials_depth.html

@@ -73,7 +73,7 @@
 
 				// Plane
 
-				var material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } );
+				var material = new THREE.MeshDepthMaterial();
 
 				plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material );
 				plane.rotation.x = - 90 * ( Math.PI / 180 );

+ 2 - 2
examples/materials_gl.html

@@ -16,7 +16,7 @@
 	<body>
 
 		<pre id="log"></pre>
-		
+
 		<script type="text/javascript" src="../build/ThreeExtras.js"></script>
 
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -78,7 +78,7 @@
 				materials.push( { material: new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ), overdraw: false, doubleSided: true } );
 
-				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
+				materials.push( { material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshLambertMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 

+ 14 - 1
src/cameras/Camera.js

@@ -4,13 +4,18 @@
 
 THREE.Camera = function ( fov, aspect, near, far ) {
 
+	this.fov = fov;
+	this.aspect = aspect;
+	this.near = near;
+	this.far = far;
+
 	this.position = new THREE.Vector3();
 	this.target = { position: new THREE.Vector3() };
 
 	this.up = new THREE.Vector3( 0, 1, 0 );
 
 	this.matrix = new THREE.Matrix4();
-	this.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect, near, far );
+	this.projectionMatrix = null;
 
 	this.autoUpdateMatrix = true;
 
@@ -45,6 +50,14 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 
 	};
 
+	this.updateProjectionMatrix = function () {
+
+		this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
+
+	};
+
+	this.updateProjectionMatrix();
+
 	this.toString = function () {
 
 		return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )';

+ 1 - 1
src/core/Vertex.js

@@ -13,7 +13,7 @@ THREE.Vertex = function ( position, normal ) {
 	this.normalScreen = new THREE.Vector3();
 
 	this.tangent = new THREE.Vector4();
-	
+
 	this.__visible = true;
 
 }

+ 0 - 11
src/materials/MeshDepthMaterial.js

@@ -2,8 +2,6 @@
  * @author mr.doob / http://mrdoob.com/
  *
  * parameters = {
- *  near: <float>,
- *  far: <float>,
  *  opacity: <float>,
  *  blending: THREE.NormalBlending
  * } 
@@ -11,9 +9,6 @@
 
 THREE.MeshDepthMaterial = function ( parameters ) {
 
-	this.near = 1;
-	this.far = 1000;
-
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
@@ -25,17 +20,11 @@ THREE.MeshDepthMaterial = function ( parameters ) {
 
 	if ( parameters ) {
 
-		if ( parameters.near !== undefined ) this.near = parameters.near;
-		if ( parameters.far !== undefined ) this.far = parameters.far;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 
 	}
 
-	this.__2near = 2 * this.near;
-	this.__farPlusNear = this.far + this.near;
-	this.__farMinusNear = this.far - this.near;
-
 };
 
 THREE.MeshDepthMaterial.prototype = {

+ 19 - 7
src/renderers/CanvasRenderer.js

@@ -25,7 +25,8 @@ THREE.CanvasRenderer = function () {
 	_color2 = new THREE.Color(),
 	_color3 = new THREE.Color(),
 	_color4 = new THREE.Color(),
-	_2near, _farPlusNear, _farMinusNear,
+
+	_near, _far,
 
 	_bitmap,
 	_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
@@ -575,13 +576,12 @@ THREE.CanvasRenderer = function () {
 				_color.setRGB( _w, _w, _w );
 				*/
 
-				_2near = material.__2near;
-				_farPlusNear = material.__farPlusNear;
-				_farMinusNear = material.__farMinusNear;
+				_near = camera.near;
+				_far = camera.far;
 
-				_color1.r = _color1.g = _color1.b = 1 - ( _2near / ( _farPlusNear - v1.positionScreen.z * _farMinusNear ) );
-				_color2.r = _color2.g = _color2.b = 1 - ( _2near / ( _farPlusNear - v2.positionScreen.z * _farMinusNear ) );
-				_color3.r = _color3.g = _color3.b = 1 - ( _2near / ( _farPlusNear - v3.positionScreen.z * _farMinusNear ) );
+				_color1.r = _color1.g = _color1.b = 1 - smoothstep( v1.positionScreen.z, _near, _far );
+				_color2.r = _color2.g = _color2.b = 1 - smoothstep( v2.positionScreen.z, _near, _far );
+				_color3.r = _color3.g = _color3.b = 1 - smoothstep( v3.positionScreen.z, _near, _far );
 
 				_color4.r = ( _color2.r + _color3.r ) * 0.5;
 				_color4.g = ( _color2.g + _color3.g ) * 0.5;
@@ -789,6 +789,18 @@ THREE.CanvasRenderer = function () {
 
 		}
 
+		function smoothstep( value, min, max ) {
+
+			/*
+			if ( value <= min ) return 0;
+			if ( value >= max ) return 1;
+			*/
+
+			var x = ( value - min ) / ( max - min );
+			return x * x * ( 3 - 2 * x );
+
+		}
+
 		function normalToComponent( normal ) {
 
 			var component = ( normal + 1 ) * 0.5;

+ 5 - 7
src/renderers/Projector.js

@@ -64,7 +64,7 @@ THREE.Projector = function() {
 
 	this.projectScene = function ( scene, camera, sort ) {
 
-		var renderList = [],
+		var renderList = [], near = camera.near, far = camera.far,
 		o, ol, v, vl, f, fl, n, nl, objects, object,
 		objectMatrix, objectRotationMatrix, objectMaterials, objectOverdraw,
 		geometry, vertices, vertex, vertexPositionScreen,
@@ -99,7 +99,7 @@ THREE.Projector = function() {
 
 				vertices = geometry.vertices;
 
-				for ( v = 0, vl = vertices.length; v < vl; v++ ) {
+				for ( v = 0, vl = vertices.length; v < vl; v ++ ) {
 
 					vertex = vertices[ v ];
 
@@ -110,12 +110,10 @@ THREE.Projector = function() {
 					vertexPositionScreen.copy( vertex.positionWorld );
 					_projScreenMatrix.multiplyVector4( vertexPositionScreen );
 
-					// Perform the perspective divide. TODO: This should be be performend 
-					// post clipping (imagine if the vertex lies at the same location as 
-					// the camera, causing a divide by w = 0).
-					vertexPositionScreen.multiplyScalar( 1 / vertexPositionScreen.w );
+					vertexPositionScreen.x /= vertexPositionScreen.w;
+					vertexPositionScreen.y /= vertexPositionScreen.w;
 
-					vertex.__visible = vertexPositionScreen.z > 0 && vertexPositionScreen.z < 1;
+					vertex.__visible = vertexPositionScreen.z > near && vertexPositionScreen.z < far;
 
 				}
 

+ 2 - 2
src/renderers/WebGLRenderer.js

@@ -390,8 +390,8 @@ THREE.WebGLRenderer = function ( scene, antialias ) {
 
 					setMaterialShaders( material, ShaderLib[ 'depth' ] );
 
-					material.uniforms.mNear.value = material.near;
-					material.uniforms.mFar.value = material.far;
+					material.uniforms.mNear.value = camera.near;
+					material.uniforms.mFar.value = camera.far;
 
 				} else if ( material instanceof THREE.MeshNormalMaterial ) {
 

+ 2 - 2
src/renderers/WebGLRenderer2.js

@@ -189,8 +189,8 @@ THREE.WebGLRenderer2 = function ( antialias ) {
 
 						} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
-							_gl.uniform1f( uniforms.mNear, material.near );
-							_gl.uniform1f( uniforms.mFar, material.far );
+							_gl.uniform1f( uniforms.mNear, camera.near );
+							_gl.uniform1f( uniforms.mFar, camera.far );
 							_gl.uniform1f( uniforms.mOpacity, material.opacity );
 
 						}

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff