Browse Source

Fixed tangents generation for quads.

alteredq 14 years ago
parent
commit
b5ac3abbb6
4 changed files with 203 additions and 206 deletions
  1. 68 68
      build/Three.js
  2. 66 66
      build/ThreeDebug.js
  3. 62 62
      build/ThreeExtras.js
  4. 7 10
      src/core/Geometry.js

+ 68 - 68
build/Three.js

@@ -13,20 +13,20 @@ THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray.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(k,p){return k.distance-p.distance});return i},intersectObject:function(a){function b(Q,s,T,B){B=B.clone().subSelf(s);T=T.clone().subSelf(s);var L=Q.clone().subSelf(s);Q=B.dot(B);s=B.dot(T);B=B.dot(L);var N=T.dot(T);T=T.dot(L);L=1/(Q*N-s*s);N=(N*B-s*T)*L;Q=(Q*T-s*B)*L;return N>0&&Q>0&&N+Q<1}var f,d,i,k,p,n,o,z,c,C,
-w,u=a.geometry,I=u.vertices,R=[];f=0;for(d=u.faces.length;f<d;f++){i=u.faces[f];C=this.origin.clone();w=this.direction.clone();k=a.matrix.multiplyVector3(I[i.a].position.clone());p=a.matrix.multiplyVector3(I[i.b].position.clone());n=a.matrix.multiplyVector3(I[i.c].position.clone());o=i instanceof THREE.Face4?a.matrix.multiplyVector3(I[i.d].position.clone()):null;z=a.rotationMatrix.multiplyVector3(i.normal.clone());c=w.dot(z);if(c<0){z=z.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(w.multiplyScalar(z));
+w,v=a.geometry,J=v.vertices,R=[];f=0;for(d=v.faces.length;f<d;f++){i=v.faces[f];C=this.origin.clone();w=this.direction.clone();k=a.matrix.multiplyVector3(J[i.a].position.clone());p=a.matrix.multiplyVector3(J[i.b].position.clone());n=a.matrix.multiplyVector3(J[i.c].position.clone());o=i instanceof THREE.Face4?a.matrix.multiplyVector3(J[i.d].position.clone()):null;z=a.rotationMatrix.multiplyVector3(i.normal.clone());c=w.dot(z);if(c<0){z=z.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(w.multiplyScalar(z));
 if(i instanceof THREE.Face3){if(b(C,k,p,n)){i={distance:this.origin.distanceTo(C),point:C,face:i,object:a};R.push(i)}}else if(i instanceof THREE.Face4)if(b(C,k,p,o)||b(C,p,n,o)){i={distance:this.origin.distanceTo(C),point:C,face:i,object:a};R.push(i)}}}return R}};
 THREE.Rectangle=function(){function a(){k=d-b;p=i-f}var b,f,d,i,k,p,n=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return k};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,z,c,C){n=false;b=o;f=z;d=c;i=C;a()};this.addPoint=function(o,z){if(n){n=false;b=o;f=z;d=o;i=z}else{b=b<o?b:o;f=f<z?f:z;d=d>o?d:o;i=i>z?
-i:z}a()};this.add3Points=function(o,z,c,C,w,u){if(n){n=false;b=o<c?o<w?o:w:c<w?c:w;f=z<C?z<u?z:u:C<u?C:u;d=o>c?o>w?o:w:c>w?c:w;i=z>C?z>u?z:u:C>u?C:u}else{b=o<c?o<w?o<b?o:b:w<b?w:b:c<w?c<b?c:b:w<b?w:b;f=z<C?z<u?z<f?z:f:u<f?u:f:C<u?C<f?C:f:u<f?u:f;d=o>c?o>w?o>d?o:d:w>d?w:d:c>w?c>d?c:d:w>d?w:d;i=z>C?z>u?z>i?z:i:u>i?u:i:C>u?C>i?C:i:u>i?u:i}a()};this.addRectangle=function(o){if(n){n=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();
+i:z}a()};this.add3Points=function(o,z,c,C,w,v){if(n){n=false;b=o<c?o<w?o:w:c<w?c:w;f=z<C?z<v?z:v:C<v?C:v;d=o>c?o>w?o:w:c>w?c:w;i=z>C?z>v?z:v:C>v?C:v}else{b=o<c?o<w?o<b?o:b:w<b?w:b:c<w?c<b?c:b:w<b?w:b;f=z<C?z<v?z<f?z:f:v<f?v:f:C<v?C<f?C:f:v<f?v:f;d=o>c?o>w?o>d?o:d:w>d?w:d:c>w?c>d?c:d:w>d?w:d;i=z>C?z>v?z>i?z:i:v>i?v:i:C>v?C>i?C:i:v>i?v:i}a()};this.addRectangle=function(o){if(n){n=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(){n=true;i=d=f=b=0;a()};this.isEmpty=function(){return n};this.toString=
 function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+i+", width: "+k+", 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,k,p,n,o,z,c,C,w,u,I,R){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=k||1;this.n23=p||0;this.n24=n||0;this.n31=o||0;this.n32=z||0;this.n33=c||1;this.n34=C||0;this.n41=w||0;this.n42=u||0;this.n43=I||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,i,k,p,n,o,z,c,C,w,u,I,R){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=k;this.n23=p;this.n24=n;this.n31=o;this.n32=z;this.n33=c;this.n34=C;this.n41=w;this.n42=u;this.n43=I;this.n44=R;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,b,f,d,i,k,p,n,o,z,c,C,w,v,J,R){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=k||1;this.n23=p||0;this.n24=n||0;this.n31=o||0;this.n32=z||0;this.n33=c||1;this.n34=C||0;this.n41=w||0;this.n42=v||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,i,k,p,n,o,z,c,C,w,v,J,R){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=k;this.n23=p;this.n24=n;this.n31=o;this.n32=z;this.n33=c;this.n34=C;this.n41=w;this.n42=v;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,i=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();i.cross(k,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=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,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,k=a.n14,p=a.n21,n=a.n22,o=a.n23,z=a.n24,c=a.n31,C=a.n32,
-w=a.n33,u=a.n34,I=a.n41,R=a.n42,Q=a.n43,s=a.n44,T=b.n11,B=b.n12,L=b.n13,N=b.n14,e=b.n21,j=b.n22,g=b.n23,h=b.n24,m=b.n31,l=b.n32,q=b.n33,r=b.n34,y=b.n41,J=b.n42,E=b.n43,G=b.n44;this.n11=f*T+d*e+i*m+k*y;this.n12=f*B+d*j+i*l+k*J;this.n13=f*L+d*g+i*q+k*E;this.n14=f*N+d*h+i*r+k*G;this.n21=p*T+n*e+o*m+z*y;this.n22=p*B+n*j+o*l+z*J;this.n23=p*L+n*g+o*q+z*E;this.n24=p*N+n*h+o*r+z*G;this.n31=c*T+C*e+w*m+u*y;this.n32=c*B+C*j+w*l+u*J;this.n33=c*L+C*g+w*q+u*E;this.n34=c*N+C*h+w*r+u*G;this.n41=I*T+R*e+Q*m+s*y;
-this.n42=I*B+R*j+Q*l+s*J;this.n43=I*L+R*g+Q*q+s*E;this.n44=I*N+R*h+Q*r+s*G;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,k=this.n21,p=this.n22,n=this.n23,o=this.n24,z=this.n31,c=this.n32,C=this.n33,w=this.n34,u=this.n41,I=this.n42,R=this.n43,Q=this.n44,s=a.n11,T=a.n21,B=a.n31,L=a.n41,N=a.n12,e=a.n22,j=a.n32,g=a.n42,h=a.n13,m=a.n23,l=a.n33,q=a.n43,r=a.n14,y=a.n24,J=a.n34;a=a.n44;this.n11=b*s+f*T+d*B+i*L;this.n12=b*N+f*e+d*j+i*g;this.n13=b*h+f*m+d*l+i*q;this.n14=
-b*r+f*y+d*J+i*a;this.n21=k*s+p*T+n*B+o*L;this.n22=k*N+p*e+n*j+o*g;this.n23=k*h+p*m+n*l+o*q;this.n24=k*r+p*y+n*J+o*a;this.n31=z*s+c*T+C*B+w*L;this.n32=z*N+c*e+C*j+w*g;this.n33=z*h+c*m+C*l+w*q;this.n34=z*r+c*y+C*J+w*a;this.n41=u*s+I*T+R*B+Q*L;this.n42=u*N+I*e+R*j+Q*g;this.n43=u*h+I*m+R*l+Q*q;this.n44=u*r+I*y+R*J+Q*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*=
+w=a.n33,v=a.n34,J=a.n41,R=a.n42,Q=a.n43,s=a.n44,T=b.n11,B=b.n12,L=b.n13,N=b.n14,e=b.n21,j=b.n22,g=b.n23,h=b.n24,m=b.n31,l=b.n32,q=b.n33,r=b.n34,y=b.n41,K=b.n42,F=b.n43,E=b.n44;this.n11=f*T+d*e+i*m+k*y;this.n12=f*B+d*j+i*l+k*K;this.n13=f*L+d*g+i*q+k*F;this.n14=f*N+d*h+i*r+k*E;this.n21=p*T+n*e+o*m+z*y;this.n22=p*B+n*j+o*l+z*K;this.n23=p*L+n*g+o*q+z*F;this.n24=p*N+n*h+o*r+z*E;this.n31=c*T+C*e+w*m+v*y;this.n32=c*B+C*j+w*l+v*K;this.n33=c*L+C*g+w*q+v*F;this.n34=c*N+C*h+w*r+v*E;this.n41=J*T+R*e+Q*m+s*y;
+this.n42=J*B+R*j+Q*l+s*K;this.n43=J*L+R*g+Q*q+s*F;this.n44=J*N+R*h+Q*r+s*E;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,k=this.n21,p=this.n22,n=this.n23,o=this.n24,z=this.n31,c=this.n32,C=this.n33,w=this.n34,v=this.n41,J=this.n42,R=this.n43,Q=this.n44,s=a.n11,T=a.n21,B=a.n31,L=a.n41,N=a.n12,e=a.n22,j=a.n32,g=a.n42,h=a.n13,m=a.n23,l=a.n33,q=a.n43,r=a.n14,y=a.n24,K=a.n34;a=a.n44;this.n11=b*s+f*T+d*B+i*L;this.n12=b*N+f*e+d*j+i*g;this.n13=b*h+f*m+d*l+i*q;this.n14=
+b*r+f*y+d*K+i*a;this.n21=k*s+p*T+n*B+o*L;this.n22=k*N+p*e+n*j+o*g;this.n23=k*h+p*m+n*l+o*q;this.n24=k*r+p*y+n*K+o*a;this.n31=z*s+c*T+C*B+w*L;this.n32=z*N+c*e+C*j+w*g;this.n33=z*h+c*m+C*l+w*q;this.n34=z*r+c*y+C*K+w*a;this.n41=v*s+J*T+R*B+Q*L;this.n42=v*N+J*e+R*j+Q*g;this.n43=v*h+J*m+R*l+Q*q;this.n44=v*r+J*y+R*K+Q*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 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,
@@ -47,9 +47,9 @@ THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){
 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,i,k,p,n=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){k=this.vertices[d];k.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;d++){k=this.faces[d];if(a&&k.vertexNormals.length){n.set(0,0,0);b=0;for(f=k.normal.length;b<f;b++)n.addSelf(k.vertexNormals[b]);n.divideScalar(3)}else{b=this.vertices[k.a];f=this.vertices[k.b];p=this.vertices[k.c];n.sub(p.position,
 f.position);o.sub(b.position,f.position);n.crossSelf(o)}n.isZero()||n.normalize();k.normal.copy(n)}},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(r,y,J,E){k=r.vertices[y].position;p=r.vertices[J].position;
-n=r.vertices[E].position;o=i[0];z=i[1];c=i[2];C=p.x-k.x;w=n.x-k.x;u=p.y-k.y;I=n.y-k.y;R=p.z-k.z;Q=n.z-k.z;s=z.u-o.u;T=c.u-o.u;B=z.v-o.v;L=c.v-o.v;N=1/(s*L-T*B);h.set((L*C-B*w)*N,(L*u-B*I)*N,(L*R-B*Q)*N);m.set((s*w-T*C)*N,(s*I-T*u)*N,(s*Q-T*R)*N);j[y].addSelf(h);j[J].addSelf(h);j[E].addSelf(h);g[y].addSelf(m);g[J].addSelf(m);g[E].addSelf(m)}var b,f,d,i,k,p,n,o,z,c,C,w,u,I,R,Q,s,T,B,L,N,e,j=[],g=[],h=new THREE.Vector3,m=new THREE.Vector3,l=new THREE.Vector3,q=new THREE.Vector3;e=new THREE.Vector3;b=
-0;for(f=this.vertices.length;b<f;b++){j[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]);
+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(r,y,K,F,E,I,t){k=r.vertices[y].position;p=r.vertices[K].position;
+n=r.vertices[F].position;o=i[E];z=i[I];c=i[t];C=p.x-k.x;w=n.x-k.x;v=p.y-k.y;J=n.y-k.y;R=p.z-k.z;Q=n.z-k.z;s=z.u-o.u;T=c.u-o.u;B=z.v-o.v;L=c.v-o.v;N=1/(s*L-T*B);h.set((L*C-B*w)*N,(L*v-B*J)*N,(L*R-B*Q)*N);m.set((s*w-T*C)*N,(s*J-T*v)*N,(s*Q-T*R)*N);j[y].addSelf(h);j[K].addSelf(h);j[F].addSelf(h);g[y].addSelf(m);g[K].addSelf(m);g[F].addSelf(m)}var b,f,d,i,k,p,n,o,z,c,C,w,v,J,R,Q,s,T,B,L,N,e,j=[],g=[],h=new THREE.Vector3,m=new THREE.Vector3,l=new THREE.Vector3,q=new THREE.Vector3;e=new THREE.Vector3;b=
+0;for(f=this.vertices.length;b<f;b++){j[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,0,1,2);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,0,1,2);a(this,d.a,d.b,d.d,0,1,3);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++){e.copy(this.vertices[b].normal);d=j[b];l.copy(d);l.subSelf(e.multiplyScalar(e.dot(d))).normalize();q.cross(this.vertices[b].normal,d);test=q.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(l.x,l.y,l.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(z){var c=[];b=0;for(f=z.length;b<f;b++)z[b]==undefined?c.push("undefined"):c.push(z[b].toString());return c.join("_")}
@@ -94,51 +94,51 @@ THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,th
 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.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(j,g){return g.z-j.z}function b(j,g){var h=0,m=1,l=j.z+j.w,q=g.z+g.w,r=-j.z+j.w,y=-g.z+g.w;if(l>=0&&q>=0&&r>=0&&y>=0)return true;else if(l<0&&q<0||r<0&&y<0)return false;else{if(l<0)h=Math.max(h,l/(l-q));else if(q<0)m=Math.min(m,l/(l-q));if(r<0)h=Math.max(h,r/(r-y));else if(y<0)m=Math.min(m,r/(r-y));if(m<h)return false;else{j.lerpSelf(g,h);g.lerpSelf(j,1-m);return true}}}var f,d,i=[],k,p,n,o=[],z,c,C=[],w,u,I=[],R=new THREE.Vector4,Q=new THREE.Vector4,s=new THREE.Matrix4,
+THREE.Projector=function(){function a(j,g){return g.z-j.z}function b(j,g){var h=0,m=1,l=j.z+j.w,q=g.z+g.w,r=-j.z+j.w,y=-g.z+g.w;if(l>=0&&q>=0&&r>=0&&y>=0)return true;else if(l<0&&q<0||r<0&&y<0)return false;else{if(l<0)h=Math.max(h,l/(l-q));else if(q<0)m=Math.min(m,l/(l-q));if(r<0)h=Math.max(h,r/(r-y));else if(y<0)m=Math.min(m,r/(r-y));if(m<h)return false;else{j.lerpSelf(g,h);g.lerpSelf(j,1-m);return true}}}var f,d,i=[],k,p,n,o=[],z,c,C=[],w,v,J=[],R=new THREE.Vector4,Q=new THREE.Vector4,s=new THREE.Matrix4,
 T=new THREE.Matrix4,B=[],L=new THREE.Vector4,N=new THREE.Vector4,e;this.projectObjects=function(j,g,h){var m=[],l,q;d=0;s.multiply(g.projectionMatrix,g.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);g=0;for(l=B.length;g<l;g++){q=B[g];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}l=j.objects;j=0;for(g=l.length;j<g;j++){q=l[j];var r;if(!(r=!q.visible)){if(r=q instanceof THREE.Mesh){a:{r=void 0;for(var y=q.position,J=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),E=0;E<6;E++){r=B[E].x*y.x+B[E].y*y.y+B[E].z*y.z+B[E].w;if(r<=J){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
-i[d]=i[d]||new THREE.RenderableObject;R.copy(q.position);s.multiplyVector3(R);f.object=q;f.z=R.z;m.push(f);d++}}h&&m.sort(a);return m};this.projectScene=function(j,g,h){var m=[],l=g.near,q=g.far,r,y,J,E,G,K,v,S,W,F,x,H,U,D,O,Y;n=c=u=0;g.autoUpdateMatrix&&g.updateMatrix();s.multiply(g.projectionMatrix,g.matrix);K=this.projectObjects(j,g,true);j=0;for(r=K.length;j<r;j++){v=K[j].object;if(v.visible){v.autoUpdateMatrix&&v.updateMatrix();S=v.matrix;W=v.rotationMatrix;F=v.materials;x=v.overdraw;if(v instanceof
-THREE.Mesh){H=v.geometry;U=H.vertices;y=0;for(J=U.length;y<J;y++){D=U[y];D.positionWorld.copy(D.position);S.multiplyVector3(D.positionWorld);E=D.positionScreen;E.copy(D.positionWorld);s.multiplyVector4(E);E.x/=E.w;E.y/=E.w;D.__visible=E.z>l&&E.z<q}H=H.faces;y=0;for(J=H.length;y<J;y++){D=H[y];if(D instanceof THREE.Face3){E=U[D.a];G=U[D.b];O=U[D.c];if(E.__visible&&G.__visible&&O.__visible)if(v.doubleSided||v.flipSided!=(O.positionScreen.x-E.positionScreen.x)*(G.positionScreen.y-E.positionScreen.y)-
-(O.positionScreen.y-E.positionScreen.y)*(G.positionScreen.x-E.positionScreen.x)<0){k=o[n]=o[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(E.positionWorld);k.v2.positionWorld.copy(G.positionWorld);k.v3.positionWorld.copy(O.positionWorld);k.v1.positionScreen.copy(E.positionScreen);k.v2.positionScreen.copy(G.positionScreen);k.v3.positionScreen.copy(O.positionScreen);k.normalWorld.copy(D.normal);W.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);S.multiplyVector3(k.centroidWorld);
-k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);O=D.vertexNormals;e=k.vertexNormalsWorld;E=0;for(G=O.length;E<G;E++){Y=e[E]=e[E]||new THREE.Vector3;Y.copy(O[E]);W.multiplyVector3(Y)}k.z=k.centroidScreen.z;k.meshMaterials=F;k.faceMaterials=D.materials;k.overdraw=x;if(v.geometry.uvs[y]){k.uvs[0]=v.geometry.uvs[y][0];k.uvs[1]=v.geometry.uvs[y][1];k.uvs[2]=v.geometry.uvs[y][2]}m.push(k);n++}}else if(D instanceof THREE.Face4){E=U[D.a];G=U[D.b];O=U[D.c];Y=U[D.d];if(E.__visible&&
-G.__visible&&O.__visible&&Y.__visible)if(v.doubleSided||v.flipSided!=((Y.positionScreen.x-E.positionScreen.x)*(G.positionScreen.y-E.positionScreen.y)-(Y.positionScreen.y-E.positionScreen.y)*(G.positionScreen.x-E.positionScreen.x)<0||(G.positionScreen.x-O.positionScreen.x)*(Y.positionScreen.y-O.positionScreen.y)-(G.positionScreen.y-O.positionScreen.y)*(Y.positionScreen.x-O.positionScreen.x)<0)){k=o[n]=o[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(E.positionWorld);k.v2.positionWorld.copy(G.positionWorld);
-k.v3.positionWorld.copy(Y.positionWorld);k.v1.positionScreen.copy(E.positionScreen);k.v2.positionScreen.copy(G.positionScreen);k.v3.positionScreen.copy(Y.positionScreen);k.normalWorld.copy(D.normal);W.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);S.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=F;k.faceMaterials=D.materials;k.overdraw=x;if(v.geometry.uvs[y]){k.uvs[0]=v.geometry.uvs[y][0];
-k.uvs[1]=v.geometry.uvs[y][1];k.uvs[2]=v.geometry.uvs[y][3]}m.push(k);n++;p=o[n]=o[n]||new THREE.RenderableFace3;p.v1.positionWorld.copy(G.positionWorld);p.v2.positionWorld.copy(O.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(G.positionScreen);p.v2.positionScreen.copy(O.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(k.normalWorld);p.centroidWorld.copy(k.centroidWorld);p.centroidScreen.copy(k.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
-F;p.faceMaterials=D.materials;p.overdraw=x;if(v.geometry.uvs[y]){p.uvs[0]=v.geometry.uvs[y][1];p.uvs[1]=v.geometry.uvs[y][2];p.uvs[2]=v.geometry.uvs[y][3]}m.push(p);n++}}}}else if(v instanceof THREE.Line){T.multiply(s,S);U=v.geometry.vertices;D=U[0];D.positionScreen.copy(D.position);T.multiplyVector4(D.positionScreen);y=1;for(J=U.length;y<J;y++){E=U[y];E.positionScreen.copy(E.position);T.multiplyVector4(E.positionScreen);G=U[y-1];L.copy(E.positionScreen);N.copy(G.positionScreen);if(b(L,N)){L.multiplyScalar(1/
-L.w);N.multiplyScalar(1/N.w);z=C[c]=C[c]||new THREE.RenderableLine;z.v1.positionScreen.copy(L);z.v2.positionScreen.copy(N);z.z=Math.max(L.z,N.z);z.materials=v.materials;m.push(z);c++}}}else if(v instanceof THREE.Particle){Q.set(v.position.x,v.position.y,v.position.z,1);s.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){w=I[u]=I[u]||new THREE.RenderableParticle;w.x=Q.x/Q.w;w.y=Q.y/Q.w;w.z=Q.z;w.rotation=v.rotation.z;w.scale.x=v.scale.x*Math.abs(w.x-(Q.x+g.projectionMatrix.n11)/(Q.w+g.projectionMatrix.n14));
-w.scale.y=v.scale.y*Math.abs(w.y-(Q.y+g.projectionMatrix.n22)/(Q.w+g.projectionMatrix.n24));w.materials=v.materials;m.push(w);u++}}}}h&&m.sort(a);return m};this.unprojectVector=function(j,g){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));h.multiplyVector3(j);return j}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,k;this.domElement=document.createElement("div");this.setSize=function(p,n){f=p;d=n;i=f/2;k=d/2};this.render=function(p,n){var o,z,c,C,w,u,I,R;a=b.projectScene(p,n);o=0;for(z=a.length;o<z;o++){w=a[o];if(w instanceof THREE.RenderableParticle){I=w.x*i+i;R=w.y*k+k;c=0;for(C=w.material.length;c<C;c++){u=w.material[c];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=I+"px";u.style.top=R+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,k,p,n=f.getContext("2d"),o=1,z=0,c=null,C=null,w=1,u,I,R,Q,s,T,B,L,N,e=new THREE.Color,j=new THREE.Color,g=new THREE.Color,h=new THREE.Color,m=new THREE.Color,l,q,r,y,J,E,G,K,v,S=new THREE.Rectangle,W=new THREE.Rectangle,F=new THREE.Rectangle,x=false,H=new THREE.Color,U=new THREE.Color,D=new THREE.Color,O=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=16;oa=document.createElement("canvas");
+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);g=0;for(l=B.length;g<l;g++){q=B[g];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}l=j.objects;j=0;for(g=l.length;j<g;j++){q=l[j];var r;if(!(r=!q.visible)){if(r=q instanceof THREE.Mesh){a:{r=void 0;for(var y=q.position,K=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),F=0;F<6;F++){r=B[F].x*y.x+B[F].y*y.y+B[F].z*y.z+B[F].w;if(r<=K){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
+i[d]=i[d]||new THREE.RenderableObject;R.copy(q.position);s.multiplyVector3(R);f.object=q;f.z=R.z;m.push(f);d++}}h&&m.sort(a);return m};this.projectScene=function(j,g,h){var m=[],l=g.near,q=g.far,r,y,K,F,E,I,t,S,W,G,x,H,U,D,O,Y;n=c=v=0;g.autoUpdateMatrix&&g.updateMatrix();s.multiply(g.projectionMatrix,g.matrix);I=this.projectObjects(j,g,true);j=0;for(r=I.length;j<r;j++){t=I[j].object;if(t.visible){t.autoUpdateMatrix&&t.updateMatrix();S=t.matrix;W=t.rotationMatrix;G=t.materials;x=t.overdraw;if(t instanceof
+THREE.Mesh){H=t.geometry;U=H.vertices;y=0;for(K=U.length;y<K;y++){D=U[y];D.positionWorld.copy(D.position);S.multiplyVector3(D.positionWorld);F=D.positionScreen;F.copy(D.positionWorld);s.multiplyVector4(F);F.x/=F.w;F.y/=F.w;D.__visible=F.z>l&&F.z<q}H=H.faces;y=0;for(K=H.length;y<K;y++){D=H[y];if(D instanceof THREE.Face3){F=U[D.a];E=U[D.b];O=U[D.c];if(F.__visible&&E.__visible&&O.__visible)if(t.doubleSided||t.flipSided!=(O.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-
+(O.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0){k=o[n]=o[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(F.positionWorld);k.v2.positionWorld.copy(E.positionWorld);k.v3.positionWorld.copy(O.positionWorld);k.v1.positionScreen.copy(F.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(O.positionScreen);k.normalWorld.copy(D.normal);W.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);S.multiplyVector3(k.centroidWorld);
+k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);O=D.vertexNormals;e=k.vertexNormalsWorld;F=0;for(E=O.length;F<E;F++){Y=e[F]=e[F]||new THREE.Vector3;Y.copy(O[F]);W.multiplyVector3(Y)}k.z=k.centroidScreen.z;k.meshMaterials=G;k.faceMaterials=D.materials;k.overdraw=x;if(t.geometry.uvs[y]){k.uvs[0]=t.geometry.uvs[y][0];k.uvs[1]=t.geometry.uvs[y][1];k.uvs[2]=t.geometry.uvs[y][2]}m.push(k);n++}}else if(D instanceof THREE.Face4){F=U[D.a];E=U[D.b];O=U[D.c];Y=U[D.d];if(F.__visible&&
+E.__visible&&O.__visible&&Y.__visible)if(t.doubleSided||t.flipSided!=((Y.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-(Y.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0||(E.positionScreen.x-O.positionScreen.x)*(Y.positionScreen.y-O.positionScreen.y)-(E.positionScreen.y-O.positionScreen.y)*(Y.positionScreen.x-O.positionScreen.x)<0)){k=o[n]=o[n]||new THREE.RenderableFace3;k.v1.positionWorld.copy(F.positionWorld);k.v2.positionWorld.copy(E.positionWorld);
+k.v3.positionWorld.copy(Y.positionWorld);k.v1.positionScreen.copy(F.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(Y.positionScreen);k.normalWorld.copy(D.normal);W.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);S.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);s.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=G;k.faceMaterials=D.materials;k.overdraw=x;if(t.geometry.uvs[y]){k.uvs[0]=t.geometry.uvs[y][0];
+k.uvs[1]=t.geometry.uvs[y][1];k.uvs[2]=t.geometry.uvs[y][3]}m.push(k);n++;p=o[n]=o[n]||new THREE.RenderableFace3;p.v1.positionWorld.copy(E.positionWorld);p.v2.positionWorld.copy(O.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(E.positionScreen);p.v2.positionScreen.copy(O.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(k.normalWorld);p.centroidWorld.copy(k.centroidWorld);p.centroidScreen.copy(k.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
+G;p.faceMaterials=D.materials;p.overdraw=x;if(t.geometry.uvs[y]){p.uvs[0]=t.geometry.uvs[y][1];p.uvs[1]=t.geometry.uvs[y][2];p.uvs[2]=t.geometry.uvs[y][3]}m.push(p);n++}}}}else if(t instanceof THREE.Line){T.multiply(s,S);U=t.geometry.vertices;D=U[0];D.positionScreen.copy(D.position);T.multiplyVector4(D.positionScreen);y=1;for(K=U.length;y<K;y++){F=U[y];F.positionScreen.copy(F.position);T.multiplyVector4(F.positionScreen);E=U[y-1];L.copy(F.positionScreen);N.copy(E.positionScreen);if(b(L,N)){L.multiplyScalar(1/
+L.w);N.multiplyScalar(1/N.w);z=C[c]=C[c]||new THREE.RenderableLine;z.v1.positionScreen.copy(L);z.v2.positionScreen.copy(N);z.z=Math.max(L.z,N.z);z.materials=t.materials;m.push(z);c++}}}else if(t instanceof THREE.Particle){Q.set(t.position.x,t.position.y,t.position.z,1);s.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){w=J[v]=J[v]||new THREE.RenderableParticle;w.x=Q.x/Q.w;w.y=Q.y/Q.w;w.z=Q.z;w.rotation=t.rotation.z;w.scale.x=t.scale.x*Math.abs(w.x-(Q.x+g.projectionMatrix.n11)/(Q.w+g.projectionMatrix.n14));
+w.scale.y=t.scale.y*Math.abs(w.y-(Q.y+g.projectionMatrix.n22)/(Q.w+g.projectionMatrix.n24));w.materials=t.materials;m.push(w);v++}}}}h&&m.sort(a);return m};this.unprojectVector=function(j,g){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));h.multiplyVector3(j);return j}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,k;this.domElement=document.createElement("div");this.setSize=function(p,n){f=p;d=n;i=f/2;k=d/2};this.render=function(p,n){var o,z,c,C,w,v,J,R;a=b.projectScene(p,n);o=0;for(z=a.length;o<z;o++){w=a[o];if(w instanceof THREE.RenderableParticle){J=w.x*i+i;R=w.y*k+k;c=0;for(C=w.material.length;c<C;c++){v=w.material[c];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=J+"px";v.style.top=R+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,k,p,n=f.getContext("2d"),o=1,z=0,c=null,C=null,w=1,v,J,R,Q,s,T,B,L,N,e=new THREE.Color,j=new THREE.Color,g=new THREE.Color,h=new THREE.Color,m=new THREE.Color,l,q,r,y,K,F,E,I,t,S=new THREE.Rectangle,W=new THREE.Rectangle,G=new THREE.Rectangle,x=false,H=new THREE.Color,U=new THREE.Color,D=new THREE.Color,O=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=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);Aa=pa.getImageData(0,0,2,2);da=Aa.data;qa=document.createElement("canvas");qa.width=qa.height=la;ua=qa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ma){d=ga;i=ma;k=d/2;p=i/2;f.width=d;f.height=i;S.set(-k,-p,k,p)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(S);n.clearRect(W.getX(),
-W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ga,ma){function Ka(t){var V,P,A,M=t.lights;U.setRGB(0,0,0);D.setRGB(0,0,0);O.setRGB(0,0,0);t=0;for(V=M.length;t<V;t++){P=M[t];A=P.color;if(P instanceof THREE.AmbientLight){U.r+=A.r;U.g+=A.g;U.b+=A.b}else if(P instanceof THREE.DirectionalLight){D.r+=A.r;D.g+=A.g;D.b+=A.b}else if(P instanceof THREE.PointLight){O.r+=A.r;O.g+=A.g;O.b+=A.b}}}function va(t,V,P,A){var M,X,aa,ba,ca=t.lights;t=0;for(M=ca.length;t<M;t++){X=ca[t];aa=X.color;
-ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,V);Z.normalize();X=P.dot(Z)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}}}function La(t,V,P){if(P.opacity!=0){Ba(P.opacity);wa(P.blending);var A,M,X,aa,ba,ca;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){aa=P.map;ba=aa.width>>1;ca=aa.height>>1;M=V.scale.x*k;X=V.scale.y*p;P=M*ba;A=X*ca;F.set(t.x-P,t.y-A,t.x+P,
-t.y+A);if(S.instersects(F)){n.save();n.translate(t.x,t.y);n.rotate(-V.rotation);n.scale(M,-X);n.translate(-ba,-ca);n.drawImage(aa,0,0);n.restore()}}}else if(P instanceof THREE.ParticleCircleMaterial){if(x){H.r=U.r+D.r+O.r;H.g=U.g+D.g+O.g;H.b=U.b+D.b+O.b;e.r=P.color.r*H.r;e.g=P.color.g*H.g;e.b=P.color.b*H.b;e.updateStyleString()}else e.__styleString=P.color.__styleString;P=V.scale.x*k;A=V.scale.y*p;F.set(t.x-P,t.y-A,t.x+P,t.y+A);if(S.instersects(F)){M=e.__styleString;if(C!=M)n.fillStyle=C=M;n.save();
-n.translate(t.x,t.y);n.rotate(-V.rotation);n.scale(P,A);n.beginPath();n.arc(0,0,1,0,Y,true);n.closePath();n.fill();n.restore()}}}}function Ma(t,V,P,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);n.beginPath();n.moveTo(t.positionScreen.x,t.positionScreen.y);n.lineTo(V.positionScreen.x,V.positionScreen.y);n.closePath();if(A instanceof THREE.LineBasicMaterial){e.__styleString=A.color.__styleString;t=A.linewidth;if(w!=t)n.lineWidth=w=t;t=e.__styleString;if(c!=t)n.strokeStyle=c=t;n.stroke();F.inflate(A.linewidth*
-2)}}}function Ga(t,V,P,A,M,X){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);Q=t.positionScreen.x;s=t.positionScreen.y;T=V.positionScreen.x;B=V.positionScreen.y;L=P.positionScreen.x;N=P.positionScreen.y;n.beginPath();n.moveTo(Q,s);n.lineTo(T,B);n.lineTo(L,N);n.lineTo(Q,s);n.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof THREE.UVMapping&&ra(Q,s,T,B,L,N,M.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(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof
-THREE.SphericalReflectionMapping){t=ma.matrix;Z.copy(A.vertexNormalsWorld[0]);y=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;J=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[1]);E=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;G=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[2]);K=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;v=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;ra(Q,s,T,B,L,N,M.env_map.image,y,J,E,G,K,v)}}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):
+W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ga,ma){function Ka(u){var V,P,A,M=u.lights;U.setRGB(0,0,0);D.setRGB(0,0,0);O.setRGB(0,0,0);u=0;for(V=M.length;u<V;u++){P=M[u];A=P.color;if(P instanceof THREE.AmbientLight){U.r+=A.r;U.g+=A.g;U.b+=A.b}else if(P instanceof THREE.DirectionalLight){D.r+=A.r;D.g+=A.g;D.b+=A.b}else if(P instanceof THREE.PointLight){O.r+=A.r;O.g+=A.g;O.b+=A.b}}}function va(u,V,P,A){var M,X,aa,ba,ca=u.lights;u=0;for(M=ca.length;u<M;u++){X=ca[u];aa=X.color;
+ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,V);Z.normalize();X=P.dot(Z)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}}}function La(u,V,P){if(P.opacity!=0){Ba(P.opacity);wa(P.blending);var A,M,X,aa,ba,ca;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){aa=P.map;ba=aa.width>>1;ca=aa.height>>1;M=V.scale.x*k;X=V.scale.y*p;P=M*ba;A=X*ca;G.set(u.x-P,u.y-A,u.x+P,
+u.y+A);if(S.instersects(G)){n.save();n.translate(u.x,u.y);n.rotate(-V.rotation);n.scale(M,-X);n.translate(-ba,-ca);n.drawImage(aa,0,0);n.restore()}}}else if(P instanceof THREE.ParticleCircleMaterial){if(x){H.r=U.r+D.r+O.r;H.g=U.g+D.g+O.g;H.b=U.b+D.b+O.b;e.r=P.color.r*H.r;e.g=P.color.g*H.g;e.b=P.color.b*H.b;e.updateStyleString()}else e.__styleString=P.color.__styleString;P=V.scale.x*k;A=V.scale.y*p;G.set(u.x-P,u.y-A,u.x+P,u.y+A);if(S.instersects(G)){M=e.__styleString;if(C!=M)n.fillStyle=C=M;n.save();
+n.translate(u.x,u.y);n.rotate(-V.rotation);n.scale(P,A);n.beginPath();n.arc(0,0,1,0,Y,true);n.closePath();n.fill();n.restore()}}}}function Ma(u,V,P,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);n.beginPath();n.moveTo(u.positionScreen.x,u.positionScreen.y);n.lineTo(V.positionScreen.x,V.positionScreen.y);n.closePath();if(A instanceof THREE.LineBasicMaterial){e.__styleString=A.color.__styleString;u=A.linewidth;if(w!=u)n.lineWidth=w=u;u=e.__styleString;if(c!=u)n.strokeStyle=c=u;n.stroke();G.inflate(A.linewidth*
+2)}}}function Ga(u,V,P,A,M,X){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);Q=u.positionScreen.x;s=u.positionScreen.y;T=V.positionScreen.x;B=V.positionScreen.y;L=P.positionScreen.x;N=P.positionScreen.y;n.beginPath();n.moveTo(Q,s);n.lineTo(T,B);n.lineTo(L,N);n.lineTo(Q,s);n.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof THREE.UVMapping&&ra(Q,s,T,B,L,N,M.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(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof
+THREE.SphericalReflectionMapping){u=ma.matrix;Z.copy(A.vertexNormalsWorld[0]);y=(Z.x*u.n11+Z.y*u.n12+Z.z*u.n13)*0.5+0.5;K=-(Z.x*u.n21+Z.y*u.n22+Z.z*u.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[1]);F=(Z.x*u.n11+Z.y*u.n12+Z.z*u.n13)*0.5+0.5;E=-(Z.x*u.n21+Z.y*u.n22+Z.z*u.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[2]);I=(Z.x*u.n11+Z.y*u.n12+Z.z*u.n13)*0.5+0.5;t=-(Z.x*u.n21+Z.y*u.n22+Z.z*u.n23)*0.5+0.5;ra(Q,s,T,B,L,N,M.env_map.image,y,K,F,E,I,t)}}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):
 ya(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&ra(Q,s,T,B,L,N,M.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);wa(THREE.SubtractiveBlending)}if(x)if(!M.wireframe&&M.shading==THREE.SmoothShading&&A.vertexNormalsWorld.length==3){j.r=g.r=h.r=U.r;j.g=g.g=h.g=U.g;j.b=g.b=h.b=U.b;va(X,A.v1.positionWorld,A.vertexNormalsWorld[0],j);va(X,A.v2.positionWorld,A.vertexNormalsWorld[1],g);va(X,
 A.v3.positionWorld,A.vertexNormalsWorld[2],h);m.r=(g.r+h.r)*0.5;m.g=(g.g+h.g)*0.5;m.b=(g.b+h.b)*0.5;r=Ha(j,g,h,m);ra(Q,s,T,B,L,N,r,0,0,1,0,0,1)}else{H.r=U.r;H.g=U.g;H.b=U.b;va(X,A.centroidWorld,A.normalWorld,H);e.r=M.color.r*H.r;e.g=M.color.g*H.g;e.b=M.color.b*H.b;e.updateStyleString();M.wireframe?xa(e.__styleString,M.wireframe_linewidth):ya(e.__styleString)}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):ya(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){l=ma.near;
-q=ma.far;j.r=j.g=j.b=1-Ca(t.positionScreen.z,l,q);g.r=g.g=g.b=1-Ca(V.positionScreen.z,l,q);h.r=h.g=h.b=1-Ca(P.positionScreen.z,l,q);m.r=(g.r+h.r)*0.5;m.g=(g.g+h.g)*0.5;m.b=(g.b+h.b)*0.5;r=Ha(j,g,h,m);ra(Q,s,T,B,L,N,r,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){e.r=Da(A.normalWorld.x);e.g=Da(A.normalWorld.y);e.b=Da(A.normalWorld.z);e.updateStyleString();M.wireframe?xa(e.__styleString,M.wireframe_linewidth):ya(e.__styleString)}}}function xa(t,V){if(c!=t)n.strokeStyle=c=t;if(w!=V)n.lineWidth=
-w=V;n.stroke();F.inflate(V*2)}function ya(t){if(C!=t)n.fillStyle=C=t;n.fill()}function ra(t,V,P,A,M,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;P-=t;A-=V;M-=t;X-=V;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*P-ea*M)*ja;ea=(sa*A-ea*X)*ja;P=(ha*M-ia*P)*ja;A=(ha*X-ia*A)*ja;t=t-ka*ba-P*ca;V=V-ea*ba-A*ca;n.save();n.transform(ka,ea,P,A,t,V);n.clip();n.drawImage(aa,0,0);n.restore()}function Ba(t){if(o!=t)n.globalAlpha=o=t}function wa(t){if(z!=
-t){switch(t){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}z=t}}function Ha(t,V,P,A){var M=~~(t.r*255),X=~~(t.g*255);t=~~(t.b*255);var aa=~~(V.r*255),ba=~~(V.g*255);V=~~(V.b*255);var ca=~~(P.r*255),ha=~~(P.g*255);P=~~(P.b*255);var ea=~~(A.r*255),ia=~~(A.g*255);A=~~(A.b*255);da[0]=M<0?0:M>255?255:M;da[1]=X<0?0:X>255?255:X;da[2]=t<0?0:t>
-255?255:t;da[4]=aa<0?0:aa>255?255:aa;da[5]=ba<0?0:ba>255?255:ba;da[6]=V<0?0:V>255?255:V;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=P<0?0:P>255?255:P;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=A<0?0:A>255?255:A;pa.putImageData(Aa,0,0);ua.drawImage(oa,0,0);return qa}function Ca(t,V,P){t=(t-V)/(P-V);return t*t*(3-2*t)}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,M=1/Math.sqrt(P*P+A*A);P*=M;A*=M;V.x+=P;V.y+=A;t.x-=P;t.y-=
-A}var za,Ia,$,fa,na,Fa,Ja,ta;n.setTransform(1,0,0,-1,k,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);(x=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];F.empty();if($ instanceof THREE.RenderableParticle){u=$;u.x*=k;u.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(u,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){u=$.v1;I=$.v2;u.positionScreen.x*=k;u.positionScreen.y*=p;I.positionScreen.x*=k;I.positionScreen.y*=p;F.addPoint(u.positionScreen.x,
-u.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(S.instersects(F)){fa=0;for(na=$.materials.length;fa<na;)Ma(u,I,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){u=$.v1;I=$.v2;R=$.v3;u.positionScreen.x*=k;u.positionScreen.y*=p;I.positionScreen.x*=k;I.positionScreen.y*=p;R.positionScreen.x*=k;R.positionScreen.y*=p;if($.overdraw){Ea(u.positionScreen,I.positionScreen);Ea(I.positionScreen,R.positionScreen);Ea(R.positionScreen,u.positionScreen)}F.add3Points(u.positionScreen.x,
-u.positionScreen.y,I.positionScreen.x,I.positionScreen.y,R.positionScreen.x,R.positionScreen.y);if(S.instersects(F)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(u,I,R,$,ta,ga)}else Ga(u,I,R,$,ta,ga)}}}W.addRectangle(F)}n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(K,v,S){var W,F,x,H;W=0;for(F=K.lights.length;W<F;W++){x=K.lights[W];if(x instanceof THREE.DirectionalLight){H=v.normalWorld.dot(x.position)*x.intensity;if(H>0){S.r+=x.color.r*H;S.g+=x.color.g*H;S.b+=x.color.b*H}}else if(x instanceof THREE.PointLight){h.sub(x.position,v.centroidWorld);h.normalize();H=v.normalWorld.dot(h)*x.intensity;if(H>0){S.r+=x.color.r*H;S.g+=x.color.g*H;S.b+=x.color.b*H}}}}function b(K,v,S,W,F,x){r=d(y++);r.setAttribute("d","M "+K.positionScreen.x+
-" "+K.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)B.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(T){L.r=N.r;L.g=N.g;L.b=N.b;a(x,W,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){g=1-F.__2near/(F.__farPlusNear-W.z*F.__farMinusNear);
-B.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&B.setRGB(i(W.normalWorld.x),i(W.normalWorld.y),i(W.normalWorld.z));F.wireframe?r.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):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+F.opacity);n.appendChild(r)}function f(K,v,S,W,F,x,H){r=d(y++);r.setAttribute("d",
-"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(T){L.r=N.r;L.g=N.g;L.b=N.b;a(H,F,L);B.r=x.color.r*L.r;B.g=x.color.g*L.g;B.b=x.color.b*L.b;B.updateStyleString()}else B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){g=
-1-x.__2near/(x.__farPlusNear-F.z*x.__farMinusNear);B.setRGB(g,g,g)}else x instanceof THREE.MeshNormalMaterial&&B.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));x.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+x.wireframe_linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframe_linecap+"; stroke-linejoin: "+x.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+x.opacity);n.appendChild(r)}
-function d(K){if(m[K]==null){m[K]=document.createElementNS("http://www.w3.org/2000/svg","path");G==0&&m[K].setAttribute("shape-rendering","crispEdges");return m[K]}return m[K]}function i(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var k=null,p=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,z,c,C,w,u,I,R,Q=new THREE.Rectangle,s=new THREE.Rectangle,T=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),N=new THREE.Color(0),e=new THREE.Color(0),
-j=new THREE.Color(0),g,h=new THREE.Vector3,m=[],l=[],q=[],r,y,J,E,G=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":G=1;break;case "low":G=0}};this.setSize=function(K,v){o=K;z=v;c=o/2;C=z/2;n.setAttribute("viewBox",-c+" "+-C+" "+o+" "+z);n.setAttribute("width",o);n.setAttribute("height",z);Q.set(-c,-C,c,C)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(K,v){var S,W,
-F,x,H,U,D,O;this.autoClear&&this.clear();k=p.projectScene(K,v,this.sortElements);E=J=y=0;if(T=K.lights.length>0){D=K.lights;N.setRGB(0,0,0);e.setRGB(0,0,0);j.setRGB(0,0,0);S=0;for(W=D.length;S<W;S++){F=D[S];x=F.color;if(F instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(F instanceof THREE.DirectionalLight){e.r+=x.r;e.g+=x.g;e.b+=x.b}else if(F instanceof THREE.PointLight){j.r+=x.r;j.g+=x.g;j.b+=x.b}}}S=0;for(W=k.length;S<W;S++){D=k[S];s.empty();if(D instanceof THREE.RenderableParticle){w=
-D;w.x*=c;w.y*=-C;F=0;for(x=D.materials.length;F<x;F++)if(O=D.materials[F]){H=w;U=D;O=O;var Y=J++;if(l[Y]==null){l[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");G==0&&l[Y].setAttribute("shape-rendering","crispEdges")}r=l[Y];r.setAttribute("cx",H.x);r.setAttribute("cy",H.y);r.setAttribute("r",U.scale.x*c);if(O instanceof THREE.ParticleCircleMaterial){if(T){L.r=N.r+e.r+j.r;L.g=N.g+e.g+j.g;L.b=N.b+e.b+j.b;B.r=O.color.r*L.r;B.g=O.color.g*L.g;B.b=O.color.b*L.b;B.updateStyleString()}else B=
-O.color;r.setAttribute("style","fill: "+B.__styleString)}n.appendChild(r)}}else if(D instanceof THREE.RenderableLine){w=D.v1;u=D.v2;w.positionScreen.x*=c;w.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);if(Q.instersects(s)){F=0;for(x=D.materials.length;F<x;)if(O=D.materials[F++]){H=w;U=u;O=O;Y=E++;if(q[Y]==null){q[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");G==
+q=ma.far;j.r=j.g=j.b=1-Ca(u.positionScreen.z,l,q);g.r=g.g=g.b=1-Ca(V.positionScreen.z,l,q);h.r=h.g=h.b=1-Ca(P.positionScreen.z,l,q);m.r=(g.r+h.r)*0.5;m.g=(g.g+h.g)*0.5;m.b=(g.b+h.b)*0.5;r=Ha(j,g,h,m);ra(Q,s,T,B,L,N,r,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){e.r=Da(A.normalWorld.x);e.g=Da(A.normalWorld.y);e.b=Da(A.normalWorld.z);e.updateStyleString();M.wireframe?xa(e.__styleString,M.wireframe_linewidth):ya(e.__styleString)}}}function xa(u,V){if(c!=u)n.strokeStyle=c=u;if(w!=V)n.lineWidth=
+w=V;n.stroke();G.inflate(V*2)}function ya(u){if(C!=u)n.fillStyle=C=u;n.fill()}function ra(u,V,P,A,M,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;P-=u;A-=V;M-=u;X-=V;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*P-ea*M)*ja;ea=(sa*A-ea*X)*ja;P=(ha*M-ia*P)*ja;A=(ha*X-ia*A)*ja;u=u-ka*ba-P*ca;V=V-ea*ba-A*ca;n.save();n.transform(ka,ea,P,A,u,V);n.clip();n.drawImage(aa,0,0);n.restore()}function Ba(u){if(o!=u)n.globalAlpha=o=u}function wa(u){if(z!=
+u){switch(u){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}z=u}}function Ha(u,V,P,A){var M=~~(u.r*255),X=~~(u.g*255);u=~~(u.b*255);var aa=~~(V.r*255),ba=~~(V.g*255);V=~~(V.b*255);var ca=~~(P.r*255),ha=~~(P.g*255);P=~~(P.b*255);var ea=~~(A.r*255),ia=~~(A.g*255);A=~~(A.b*255);da[0]=M<0?0:M>255?255:M;da[1]=X<0?0:X>255?255:X;da[2]=u<0?0:u>
+255?255:u;da[4]=aa<0?0:aa>255?255:aa;da[5]=ba<0?0:ba>255?255:ba;da[6]=V<0?0:V>255?255:V;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=P<0?0:P>255?255:P;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=A<0?0:A>255?255:A;pa.putImageData(Aa,0,0);ua.drawImage(oa,0,0);return qa}function Ca(u,V,P){u=(u-V)/(P-V);return u*u*(3-2*u)}function Da(u){u=(u+1)*0.5;return u<0?0:u>1?1:u}function Ea(u,V){var P=V.x-u.x,A=V.y-u.y,M=1/Math.sqrt(P*P+A*A);P*=M;A*=M;V.x+=P;V.y+=A;u.x-=P;u.y-=
+A}var za,Ia,$,fa,na,Fa,Ja,ta;n.setTransform(1,0,0,-1,k,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);(x=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];G.empty();if($ instanceof THREE.RenderableParticle){v=$;v.x*=k;v.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(v,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){v=$.v1;J=$.v2;v.positionScreen.x*=k;v.positionScreen.y*=p;J.positionScreen.x*=k;J.positionScreen.y*=p;G.addPoint(v.positionScreen.x,
+v.positionScreen.y);G.addPoint(J.positionScreen.x,J.positionScreen.y);if(S.instersects(G)){fa=0;for(na=$.materials.length;fa<na;)Ma(v,J,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){v=$.v1;J=$.v2;R=$.v3;v.positionScreen.x*=k;v.positionScreen.y*=p;J.positionScreen.x*=k;J.positionScreen.y*=p;R.positionScreen.x*=k;R.positionScreen.y*=p;if($.overdraw){Ea(v.positionScreen,J.positionScreen);Ea(J.positionScreen,R.positionScreen);Ea(R.positionScreen,v.positionScreen)}G.add3Points(v.positionScreen.x,
+v.positionScreen.y,J.positionScreen.x,J.positionScreen.y,R.positionScreen.x,R.positionScreen.y);if(S.instersects(G)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(v,J,R,$,ta,ga)}else Ga(v,J,R,$,ta,ga)}}}W.addRectangle(G)}n.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(I,t,S){var W,G,x,H;W=0;for(G=I.lights.length;W<G;W++){x=I.lights[W];if(x instanceof THREE.DirectionalLight){H=t.normalWorld.dot(x.position)*x.intensity;if(H>0){S.r+=x.color.r*H;S.g+=x.color.g*H;S.b+=x.color.b*H}}else if(x instanceof THREE.PointLight){h.sub(x.position,t.centroidWorld);h.normalize();H=t.normalWorld.dot(h)*x.intensity;if(H>0){S.r+=x.color.r*H;S.g+=x.color.g*H;S.b+=x.color.b*H}}}}function b(I,t,S,W,G,x){r=d(y++);r.setAttribute("d","M "+I.positionScreen.x+
+" "+I.positionScreen.y+" L "+t.positionScreen.x+" "+t.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)B.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(T){L.r=N.r;L.g=N.g;L.b=N.b;a(x,W,L);B.r=G.color.r*L.r;B.g=G.color.g*L.g;B.b=G.color.b*L.b;B.updateStyleString()}else B.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){g=1-G.__2near/(G.__farPlusNear-W.z*G.__farMinusNear);
+B.setRGB(g,g,g)}else G instanceof THREE.MeshNormalMaterial&&B.setRGB(i(W.normalWorld.x),i(W.normalWorld.y),i(W.normalWorld.z));G.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+G.opacity);n.appendChild(r)}function f(I,t,S,W,G,x,H){r=d(y++);r.setAttribute("d",
+"M "+I.positionScreen.x+" "+I.positionScreen.y+" L "+t.positionScreen.x+" "+t.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(T){L.r=N.r;L.g=N.g;L.b=N.b;a(H,G,L);B.r=x.color.r*L.r;B.g=x.color.g*L.g;B.b=x.color.b*L.b;B.updateStyleString()}else B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){g=
+1-x.__2near/(x.__farPlusNear-G.z*x.__farMinusNear);B.setRGB(g,g,g)}else x instanceof THREE.MeshNormalMaterial&&B.setRGB(i(G.normalWorld.x),i(G.normalWorld.y),i(G.normalWorld.z));x.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+x.wireframe_linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframe_linecap+"; stroke-linejoin: "+x.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+x.opacity);n.appendChild(r)}
+function d(I){if(m[I]==null){m[I]=document.createElementNS("http://www.w3.org/2000/svg","path");E==0&&m[I].setAttribute("shape-rendering","crispEdges");return m[I]}return m[I]}function i(I){return I<0?Math.min((1+I)*0.5,0.5):0.5+Math.min(I*0.5,0.5)}var k=null,p=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,z,c,C,w,v,J,R,Q=new THREE.Rectangle,s=new THREE.Rectangle,T=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),N=new THREE.Color(0),e=new THREE.Color(0),
+j=new THREE.Color(0),g,h=new THREE.Vector3,m=[],l=[],q=[],r,y,K,F,E=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(I){switch(I){case "high":E=1;break;case "low":E=0}};this.setSize=function(I,t){o=I;z=t;c=o/2;C=z/2;n.setAttribute("viewBox",-c+" "+-C+" "+o+" "+z);n.setAttribute("width",o);n.setAttribute("height",z);Q.set(-c,-C,c,C)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(I,t){var S,W,
+G,x,H,U,D,O;this.autoClear&&this.clear();k=p.projectScene(I,t,this.sortElements);F=K=y=0;if(T=I.lights.length>0){D=I.lights;N.setRGB(0,0,0);e.setRGB(0,0,0);j.setRGB(0,0,0);S=0;for(W=D.length;S<W;S++){G=D[S];x=G.color;if(G instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(G instanceof THREE.DirectionalLight){e.r+=x.r;e.g+=x.g;e.b+=x.b}else if(G instanceof THREE.PointLight){j.r+=x.r;j.g+=x.g;j.b+=x.b}}}S=0;for(W=k.length;S<W;S++){D=k[S];s.empty();if(D instanceof THREE.RenderableParticle){w=
+D;w.x*=c;w.y*=-C;G=0;for(x=D.materials.length;G<x;G++)if(O=D.materials[G]){H=w;U=D;O=O;var Y=K++;if(l[Y]==null){l[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");E==0&&l[Y].setAttribute("shape-rendering","crispEdges")}r=l[Y];r.setAttribute("cx",H.x);r.setAttribute("cy",H.y);r.setAttribute("r",U.scale.x*c);if(O instanceof THREE.ParticleCircleMaterial){if(T){L.r=N.r+e.r+j.r;L.g=N.g+e.g+j.g;L.b=N.b+e.b+j.b;B.r=O.color.r*L.r;B.g=O.color.g*L.g;B.b=O.color.b*L.b;B.updateStyleString()}else B=
+O.color;r.setAttribute("style","fill: "+B.__styleString)}n.appendChild(r)}}else if(D instanceof THREE.RenderableLine){w=D.v1;v=D.v2;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(v.positionScreen.x,v.positionScreen.y);if(Q.instersects(s)){G=0;for(x=D.materials.length;G<x;)if(O=D.materials[G++]){H=w;U=v;O=O;Y=F++;if(q[Y]==null){q[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");E==
 0&&q[Y].setAttribute("shape-rendering","crispEdges")}r=q[Y];r.setAttribute("x1",H.positionScreen.x);r.setAttribute("y1",H.positionScreen.y);r.setAttribute("x2",U.positionScreen.x);r.setAttribute("y2",U.positionScreen.y);if(O instanceof THREE.LineBasicMaterial){B.__styleString=O.color.__styleString;r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+O.linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.linecap+"; stroke-linejoin: "+O.linejoin);n.appendChild(r)}}}}else if(D instanceof
-THREE.RenderableFace3){w=D.v1;u=D.v2;I=D.v3;w.positionScreen.x*=c;w.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;I.positionScreen.x*=c;I.positionScreen.y*=-C;s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(I.positionScreen.x,I.positionScreen.y);if(Q.instersects(s)){F=0;for(x=D.meshMaterials.length;F<x;){O=D.meshMaterials[F++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(U=D.faceMaterials.length;H<U;)(O=D.faceMaterials[H++])&&
-b(w,u,I,D,O,K)}else O&&b(w,u,I,D,O,K)}}}else if(D instanceof THREE.RenderableFace4){w=D.v1;u=D.v2;I=D.v3;R=D.v4;w.positionScreen.x*=c;w.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;I.positionScreen.x*=c;I.positionScreen.y*=-C;R.positionScreen.x*=c;R.positionScreen.y*=-C;s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(u.positionScreen.x,u.positionScreen.y);s.addPoint(I.positionScreen.x,I.positionScreen.y);s.addPoint(R.positionScreen.x,R.positionScreen.y);if(Q.instersects(s)){F=
-0;for(x=D.meshMaterials.length;F<x;){O=D.meshMaterials[F++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(U=D.faceMaterials.length;H<U;)(O=D.faceMaterials[H++])&&f(w,u,I,R,D,O,K)}else O&&f(w,u,I,R,D,O,K)}}}}}};
+THREE.RenderableFace3){w=D.v1;v=D.v2;J=D.v3;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(J.positionScreen.x,J.positionScreen.y);if(Q.instersects(s)){G=0;for(x=D.meshMaterials.length;G<x;){O=D.meshMaterials[G++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(U=D.faceMaterials.length;H<U;)(O=D.faceMaterials[H++])&&
+b(w,v,J,D,O,I)}else O&&b(w,v,J,D,O,I)}}}else if(D instanceof THREE.RenderableFace4){w=D.v1;v=D.v2;J=D.v3;R=D.v4;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;R.positionScreen.x*=c;R.positionScreen.y*=-C;s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(v.positionScreen.x,v.positionScreen.y);s.addPoint(J.positionScreen.x,J.positionScreen.y);s.addPoint(R.positionScreen.x,R.positionScreen.y);if(Q.instersects(s)){G=
+0;for(x=D.meshMaterials.length;G<x;){O=D.meshMaterials[G++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(U=D.faceMaterials.length;H<U;)(O=D.faceMaterials[H++])&&f(w,v,J,R,D,O,I)}else O&&f(w,v,J,R,D,O,I)}}}}}};
 THREE.WebGLRenderer=function(a){function b(e,j){e.fragment_shader=j.fragment_shader;e.vertex_shader=j.vertex_shader;var g=j.uniforms,h,m,l={};for(h in g){l[h]={};for(m in uniforms[h]){parameter_src=g[h][m];parameter_dst=l[h][m];parameter_dst=parameter_src instanceof THREE.Color||parameter_src instanceof THREE.Vector3||parameter_src instanceof THREE.Texture?parameter_src.clone():parameter_src}}e.uniforms=l}function f(e,j,g){var h=c.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
 g?"#define USE_FOG":"",g instanceof THREE.FogExp2?"#define FOG_EXP2":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var m=[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,
 n("fragment",g+e));c.attachShader(h,n("vertex",m+j));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,j){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);
@@ -146,7 +146,7 @@ c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParame
 j);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,j){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+j);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,j){var g,h,m;g=0;for(h=j.length;g<h;g++){m=j[g];e.uniforms[m]=c.getUniformLocation(e,m)}}function p(e,j){var g,h,m;g=0;for(h=j.length;g<h;g++){m=j[g];e.attributes[m]=c.getAttribLocation(e,m)}}function n(e,j){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER);c.shaderSource(g,
 j);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}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 z=document.createElement("canvas"),c,C,w,u=new THREE.Matrix4,I,R=new Float32Array(16),Q=new Float32Array(16),s=new Float32Array(16),T=new Float32Array(9),B=new Float32Array(16),L=function(e,j){if(e){var g,h,m,l=pointLights=maxDirLights=maxPointLights=0;g=0;for(h=e.lights.length;g<h;g++){m=e.lights[g];m instanceof THREE.DirectionalLight&&l++;m instanceof
+case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var z=document.createElement("canvas"),c,C,w,v=new THREE.Matrix4,J,R=new Float32Array(16),Q=new Float32Array(16),s=new Float32Array(16),T=new Float32Array(9),B=new Float32Array(16),L=function(e,j){if(e){var g,h,m,l=pointLights=maxDirLights=maxPointLights=0;g=0;for(h=e.lights.length;g<h;g++){m=e.lights[g];m instanceof THREE.DirectionalLight&&l++;m instanceof
 THREE.PointLight&&pointLights++}if(pointLights+l<=j){maxDirLights=l;maxPointLights=pointLights}else{maxDirLights=Math.ceil(j*l/(pointLights+l));maxPointLights=j-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:j-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=z;this.autoClear=true;
 (function(e,j,g){try{c=z.getContext("experimental-webgl",{antialias:e})}catch(h){}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(j.r,j.g,j.b,g)})(antialias,clearColor,clearAlpha);C=w=function(e,j,g){var h=[e?"#define MAX_DIR_LIGHTS "+e:"",j?"#define MAX_POINT_LIGHTS "+
 j:"","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 ];":"",j?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",j?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",j?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
@@ -161,26 +161,26 @@ j?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",j?"vec4 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;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
 h=f(m,h,g);c.useProgram(h);k(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);g&&k(h,["fogColor","fogNear","fogFar","fogDensity"]);e&&k(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);j&&k(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}(L.directional,L.point,fog);this.setSize=function(e,j){z.width=e;z.height=j;c.viewport(0,0,z.width,z.height)};this.setClearColor=function(e,j){var g=new THREE.Color(e);c.clearColor(g.r,g.g,g.b,j)};this.clear=
-function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,j){var g,h,m,l,q,r=[],y=[],J=[];l=[];q=[];c.uniform1i(e.uniforms.enableLighting,j.length);g=0;for(h=j.length;g<h;g++){m=j[g];if(m instanceof THREE.AmbientLight)r.push(m);else if(m instanceof THREE.DirectionalLight)J.push(m);else m instanceof THREE.PointLight&&y.push(m)}g=m=l=q=0;for(h=r.length;g<h;g++){m+=r[g].color.r;l+=r[g].color.g;q+=r[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,m,l,q);l=[];q=[];g=0;
-for(h=J.length;g<h;g++){m=J[g];l.push(m.color.r*m.intensity);l.push(m.color.g*m.intensity);l.push(m.color.b*m.intensity);q.push(m.position.x);q.push(m.position.y);q.push(m.position.z)}if(J.length){c.uniform1i(e.uniforms.directionalLightNumber,J.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,l)}l=[];q=[];g=0;for(h=y.length;g<h;g++){m=y[g];l.push(m.color.r*m.intensity);l.push(m.color.g*m.intensity);l.push(m.color.b*m.intensity);q.push(m.position.x);
-q.push(m.position.y);q.push(m.position.z)}if(y.length){c.uniform1i(e.uniforms.pointLightNumber,y.length);c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,l)}};this.createBuffers=function(e,j){var g,h,m,l,q,r,y,J,E,G=[],K=[],v=[],S=[],W=[],F=[],x=0,H=e.geometry.geometryChunks[j],U;m=false;g=0;for(h=e.materials.length;g<h;g++){meshMaterial=e.materials[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(U=H.materials.length;q<U;q++)if(H.materials[q]&&H.materials[q].shading!=
-undefined&&H.materials[q].shading==THREE.SmoothShading){m=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){m=true;break}if(m)break}U=m;g=0;for(h=H.faces.length;g<h;g++){m=H.faces[g];l=e.geometry.faces[m];q=l.vertexNormals;faceNormal=l.normal;m=e.geometry.uvs[m];if(l instanceof THREE.Face3){r=e.geometry.vertices[l.a].position;y=e.geometry.vertices[l.b].position;J=e.geometry.vertices[l.c].position;v.push(r.x,r.y,r.z);v.push(y.x,y.y,y.z);v.push(J.x,
-J.y,J.z);if(e.geometry.hasTangents){r=e.geometry.vertices[l.a].tangent;y=e.geometry.vertices[l.b].tangent;J=e.geometry.vertices[l.c].tangent;W.push(r.x,r.y,r.z,r.w);W.push(y.x,y.y,y.z,y.w);W.push(J.x,J.y,J.z,J.w)}if(q.length==3&&U)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(m)for(l=0;l<3;l++)F.push(m[l].u,m[l].v);G.push(x,x+1,x+2);K.push(x,x+1);K.push(x,x+2);K.push(x+1,x+2);x+=3}else if(l instanceof THREE.Face4){r=e.geometry.vertices[l.a].position;
-y=e.geometry.vertices[l.b].position;J=e.geometry.vertices[l.c].position;E=e.geometry.vertices[l.d].position;v.push(r.x,r.y,r.z);v.push(y.x,y.y,y.z);v.push(J.x,J.y,J.z);v.push(E.x,E.y,E.z);if(e.geometry.hasTangents){r=e.geometry.vertices[l.a].tangent;y=e.geometry.vertices[l.b].tangent;J=e.geometry.vertices[l.c].tangent;l=e.geometry.vertices[l.d].tangent;W.push(r.x,r.y,r.z,r.w);W.push(y.x,y.y,y.z,y.w);W.push(J.x,J.y,J.z,J.w);W.push(l.x,l.y,l.z,l.w)}if(q.length==4&&U)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(m)for(l=0;l<4;l++)F.push(m[l].u,m[l].v);G.push(x,x+1,x+2);G.push(x,x+2,x+3);K.push(x,x+1);K.push(x,x+2);K.push(x,x+3);K.push(x+1,x+2);K.push(x+2,x+3);x+=4}}if(v.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(v),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
-new Float32Array(S),c.STATIC_DRAW);if(e.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}if(F.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
-new Uint16Array(G),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(K),c.STATIC_DRAW);H.__webGLFaceCount=G.length;H.__webGLLineCount=K.length}};this.renderBuffer=function(e,j,g,h,m){var l,q,r,y,J,E,G,K,v;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){b(h,N.depth);
-h.uniforms.mNear.value=e.near;h.uniforms.mFar.value=e.far}else h instanceof THREE.MeshNormalMaterial&&b(h,N.normal);h.program=f(h.fragment_shader,h.vertex_shader,null);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in h.uniforms)G.push(v);k(h.program,G);p(h.program,["position","normal","uv","tangent"])}v=h.program}else v=w;if(v!=C){c.useProgram(v);C=v}v==w&&this.setupLights(v,j);this.loadCamera(v,e);this.loadMatrices(v);if(h instanceof THREE.MeshShaderMaterial||
-h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){r=h.wireframe;y=h.wireframe_linewidth;e=v;j=h.uniforms;var S;for(l in j){K=j[l].type;G=j[l].value;S=e.uniforms[l];if(K=="i")c.uniform1i(S,G);else if(K=="f")c.uniform1f(S,G);else if(K=="v3")c.uniform3f(S,G.x,G.y,G.z);else if(K=="c")c.uniform3f(S,G.r,G.g,G.b);else if(K=="t"){c.uniform1i(S,G);if(K=j[l].texture)K.image instanceof Array&&K.image.length==6?d(K,G):i(K,G)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||
-h instanceof THREE.MeshBasicMaterial){l=h.color;q=h.opacity;r=h.wireframe;y=h.wireframe_linewidth;J=h.map;E=h.env_map;j=h.combine==THREE.MixOperation;e=h.reflectivity;K=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;G=h.refraction_ratio;c.uniform4f(v.uniforms.mColor,l.r*q,l.g*q,l.b*q,q);c.uniform1i(v.uniforms.mixEnvMap,j);c.uniform1f(v.uniforms.mReflectivity,e);c.uniform1i(v.uniforms.useRefract,K);c.uniform1f(v.uniforms.mRefractionRatio,G);if(g){c.uniform3f(v.uniforms.fogColor,
-g.color.r,g.color.g,g.color.b);if(g instanceof THREE.Fog){c.uniform1f(v.uniforms.fogNear,g.near);c.uniform1f(v.uniforms.fogFar,g.far)}else g instanceof THREE.FogExp2&&c.uniform1f(v.uniforms.fogDensity,g.density)}}if(h instanceof THREE.MeshPhongMaterial){g=h.ambient;l=h.specular;h=h.shininess;c.uniform4f(v.uniforms.mAmbient,g.r,g.g,g.b,q);c.uniform4f(v.uniforms.mSpecular,l.r,l.g,l.b,q);c.uniform1f(v.uniforms.mShininess,h);c.uniform1i(v.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(v.uniforms.material,
-1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(v.uniforms.material,0);if(J){i(J,0);c.uniform1i(v.uniforms.tMap,0);c.uniform1i(v.uniforms.enableMap,1)}else c.uniform1i(v.uniforms.enableMap,0);if(E){d(E,1);c.uniform1i(v.uniforms.tCube,1);c.uniform1i(v.uniforms.enableCubeMap,1)}else c.uniform1i(v.uniforms.enableCubeMap,0);q=v.attributes;c.bindBuffer(c.ARRAY_BUFFER,m.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>=
+function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,j){var g,h,m,l,q,r=[],y=[],K=[];l=[];q=[];c.uniform1i(e.uniforms.enableLighting,j.length);g=0;for(h=j.length;g<h;g++){m=j[g];if(m instanceof THREE.AmbientLight)r.push(m);else if(m instanceof THREE.DirectionalLight)K.push(m);else m instanceof THREE.PointLight&&y.push(m)}g=m=l=q=0;for(h=r.length;g<h;g++){m+=r[g].color.r;l+=r[g].color.g;q+=r[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,m,l,q);l=[];q=[];g=0;
+for(h=K.length;g<h;g++){m=K[g];l.push(m.color.r*m.intensity);l.push(m.color.g*m.intensity);l.push(m.color.b*m.intensity);q.push(m.position.x);q.push(m.position.y);q.push(m.position.z)}if(K.length){c.uniform1i(e.uniforms.directionalLightNumber,K.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,l)}l=[];q=[];g=0;for(h=y.length;g<h;g++){m=y[g];l.push(m.color.r*m.intensity);l.push(m.color.g*m.intensity);l.push(m.color.b*m.intensity);q.push(m.position.x);
+q.push(m.position.y);q.push(m.position.z)}if(y.length){c.uniform1i(e.uniforms.pointLightNumber,y.length);c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,l)}};this.createBuffers=function(e,j){var g,h,m,l,q,r,y,K,F,E=[],I=[],t=[],S=[],W=[],G=[],x=0,H=e.geometry.geometryChunks[j],U;m=false;g=0;for(h=e.materials.length;g<h;g++){meshMaterial=e.materials[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(U=H.materials.length;q<U;q++)if(H.materials[q]&&H.materials[q].shading!=
+undefined&&H.materials[q].shading==THREE.SmoothShading){m=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){m=true;break}if(m)break}U=m;g=0;for(h=H.faces.length;g<h;g++){m=H.faces[g];l=e.geometry.faces[m];q=l.vertexNormals;faceNormal=l.normal;m=e.geometry.uvs[m];if(l instanceof THREE.Face3){r=e.geometry.vertices[l.a].position;y=e.geometry.vertices[l.b].position;K=e.geometry.vertices[l.c].position;t.push(r.x,r.y,r.z);t.push(y.x,y.y,y.z);t.push(K.x,
+K.y,K.z);if(e.geometry.hasTangents){r=e.geometry.vertices[l.a].tangent;y=e.geometry.vertices[l.b].tangent;K=e.geometry.vertices[l.c].tangent;W.push(r.x,r.y,r.z,r.w);W.push(y.x,y.y,y.z,y.w);W.push(K.x,K.y,K.z,K.w)}if(q.length==3&&U)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(m)for(l=0;l<3;l++)G.push(m[l].u,m[l].v);E.push(x,x+1,x+2);I.push(x,x+1);I.push(x,x+2);I.push(x+1,x+2);x+=3}else if(l instanceof THREE.Face4){r=e.geometry.vertices[l.a].position;
+y=e.geometry.vertices[l.b].position;K=e.geometry.vertices[l.c].position;F=e.geometry.vertices[l.d].position;t.push(r.x,r.y,r.z);t.push(y.x,y.y,y.z);t.push(K.x,K.y,K.z);t.push(F.x,F.y,F.z);if(e.geometry.hasTangents){r=e.geometry.vertices[l.a].tangent;y=e.geometry.vertices[l.b].tangent;K=e.geometry.vertices[l.c].tangent;l=e.geometry.vertices[l.d].tangent;W.push(r.x,r.y,r.z,r.w);W.push(y.x,y.y,y.z,y.w);W.push(K.x,K.y,K.z,K.w);W.push(l.x,l.y,l.z,l.w)}if(q.length==4&&U)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(m)for(l=0;l<4;l++)G.push(m[l].u,m[l].v);E.push(x,x+1,x+2);E.push(x,x+2,x+3);I.push(x,x+1);I.push(x,x+2);I.push(x,x+3);I.push(x+1,x+2);I.push(x+2,x+3);x+=4}}if(t.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(t),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
+new Float32Array(S),c.STATIC_DRAW);if(e.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}if(G.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(G),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
+new Uint16Array(E),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);H.__webGLFaceCount=E.length;H.__webGLLineCount=I.length}};this.renderBuffer=function(e,j,g,h,m){var l,q,r,y,K,F,E,I,t;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){b(h,N.depth);
+h.uniforms.mNear.value=e.near;h.uniforms.mFar.value=e.far}else h instanceof THREE.MeshNormalMaterial&&b(h,N.normal);h.program=f(h.fragment_shader,h.vertex_shader,null);E=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in h.uniforms)E.push(t);k(h.program,E);p(h.program,["position","normal","uv","tangent"])}t=h.program}else t=w;if(t!=C){c.useProgram(t);C=t}t==w&&this.setupLights(t,j);this.loadCamera(t,e);this.loadMatrices(t);if(h instanceof THREE.MeshShaderMaterial||
+h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){r=h.wireframe;y=h.wireframe_linewidth;e=t;j=h.uniforms;var S;for(l in j){I=j[l].type;E=j[l].value;S=e.uniforms[l];if(I=="i")c.uniform1i(S,E);else if(I=="f")c.uniform1f(S,E);else if(I=="v3")c.uniform3f(S,E.x,E.y,E.z);else if(I=="c")c.uniform3f(S,E.r,E.g,E.b);else if(I=="t"){c.uniform1i(S,E);if(I=j[l].texture)I.image instanceof Array&&I.image.length==6?d(I,E):i(I,E)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||
+h instanceof THREE.MeshBasicMaterial){l=h.color;q=h.opacity;r=h.wireframe;y=h.wireframe_linewidth;K=h.map;F=h.env_map;j=h.combine==THREE.MixOperation;e=h.reflectivity;I=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;E=h.refraction_ratio;c.uniform4f(t.uniforms.mColor,l.r*q,l.g*q,l.b*q,q);c.uniform1i(t.uniforms.mixEnvMap,j);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract,I);c.uniform1f(t.uniforms.mRefractionRatio,E);if(g){c.uniform3f(t.uniforms.fogColor,
+g.color.r,g.color.g,g.color.b);if(g instanceof THREE.Fog){c.uniform1f(t.uniforms.fogNear,g.near);c.uniform1f(t.uniforms.fogFar,g.far)}else g instanceof THREE.FogExp2&&c.uniform1f(t.uniforms.fogDensity,g.density)}}if(h instanceof THREE.MeshPhongMaterial){g=h.ambient;l=h.specular;h=h.shininess;c.uniform4f(t.uniforms.mAmbient,g.r,g.g,g.b,q);c.uniform4f(t.uniforms.mSpecular,l.r,l.g,l.b,q);c.uniform1f(t.uniforms.mShininess,h);c.uniform1i(t.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,
+1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(t.uniforms.material,0);if(K){i(K,0);c.uniform1i(t.uniforms.tMap,0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(F){d(F,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);q=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,m.__webGLVertexBuffer);c.vertexAttribPointer(q.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.position);if(q.normal>=
 0){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(m.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(r){c.lineWidth(y);
-c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);c.drawElements(c.LINES,m.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,m.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,j,g,h,m,l,q){var r,y,J,E,G;J=0;for(E=h.materials.length;J<E;J++){r=h.materials[J];if(r instanceof THREE.MeshFaceMaterial){r=0;for(y=m.materials.length;r<y;r++)if((G=m.materials[r])&&G.blending==l&&G.opacity<1==q){this.setBlending(G.blending);
-this.renderBuffer(e,j,g,G,m)}}else if((G=r)&&G.blending==l&&G.opacity<1==q){this.setBlending(G.blending);this.renderBuffer(e,j,g,G,m)}}};this.render=function(e,j){var g,h,m,l,q=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();j.autoUpdateMatrix&&j.updateMatrix();R.set(j.matrix.flatten());s.set(j.projectionMatrix.flatten());g=0;for(h=e.__webGLObjects.length;g<h;g++){m=e.__webGLObjects[g];l=m.object;m=m.buffer;if(l.visible){this.setupMatrices(l,j);this.renderPass(j,q,r,l,m,THREE.NormalBlending,
+c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);c.drawElements(c.LINES,m.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,m.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,j,g,h,m,l,q){var r,y,K,F,E;K=0;for(F=h.materials.length;K<F;K++){r=h.materials[K];if(r instanceof THREE.MeshFaceMaterial){r=0;for(y=m.materials.length;r<y;r++)if((E=m.materials[r])&&E.blending==l&&E.opacity<1==q){this.setBlending(E.blending);
+this.renderBuffer(e,j,g,E,m)}}else if((E=r)&&E.blending==l&&E.opacity<1==q){this.setBlending(E.blending);this.renderBuffer(e,j,g,E,m)}}};this.render=function(e,j){var g,h,m,l,q=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();j.autoUpdateMatrix&&j.updateMatrix();R.set(j.matrix.flatten());s.set(j.projectionMatrix.flatten());g=0;for(h=e.__webGLObjects.length;g<h;g++){m=e.__webGLObjects[g];l=m.object;m=m.buffer;if(l.visible){this.setupMatrices(l,j);this.renderPass(j,q,r,l,m,THREE.NormalBlending,
 false)}}g=0;for(h=e.__webGLObjects.length;g<h;g++){m=e.__webGLObjects[g];l=m.object;m=m.buffer;if(l.visible){this.setupMatrices(l,j);this.renderPass(j,q,r,l,m,THREE.AdditiveBlending,false);this.renderPass(j,q,r,l,m,THREE.SubtractiveBlending,false);this.renderPass(j,q,r,l,m,THREE.AdditiveBlending,true);this.renderPass(j,q,r,l,m,THREE.SubtractiveBlending,true);this.renderPass(j,q,r,l,m,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var j,g,h,m,l,q;if(!e.__webGLObjects){e.__webGLObjects=
 [];e.__webGLObjectsMap={}}j=0;for(g=e.objects.length;j<g;j++){h=e.objects[j];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){m=h.geometry.geometryChunks[l];m.__webGLVertexBuffer||this.createBuffers(h,l);if(q[l]==undefined){m={buffer:m,object:h};e.__webGLObjects.push(m);q[l]=1}}}};this.removeObject=function(e,j){var g,h;for(g=e.__webGLObjects.length-1;g>=0;g--){h=e.__webGLObjects[g].object;
-j==h&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,j){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(j.matrix,e.matrix);Q.set(u.flatten());I=THREE.Matrix4.makeInvert3x3(u).transpose();T.set(I.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,R);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,Q);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,s);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,T);c.uniformMatrix4fv(e.uniforms.objectMatrix,
+j==h&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,j){e.autoUpdateMatrix&&e.updateMatrix();v.multiply(j.matrix,e.matrix);Q.set(v.flatten());J=THREE.Matrix4.makeInvert3x3(v).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,Q);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,j){c.uniform3f(e.uniforms.cameraPosition,j.position.x,j.position.y,j.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,j){if(e){!j||j=="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 N={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}"}}};

+ 66 - 66
build/ThreeDebug.js

@@ -13,20 +13,20 @@ THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray.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(k,p){return k.distance-p.distance});return i},intersectObject:function(a){function b(Q,t,U,B){B=B.clone().subSelf(t);U=U.clone().subSelf(t);var L=Q.clone().subSelf(t);Q=B.dot(B);t=B.dot(U);B=B.dot(L);var N=U.dot(U);U=U.dot(L);L=1/(Q*N-t*t);N=(N*B-t*U)*L;Q=(Q*U-t*B)*L;return N>0&&Q>0&&N+Q<1}var f,d,i,k,p,l,o,z,c,C,
-w,u=a.geometry,I=u.vertices,S=[];f=0;for(d=u.faces.length;f<d;f++){i=u.faces[f];C=this.origin.clone();w=this.direction.clone();k=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;z=a.rotationMatrix.multiplyVector3(i.normal.clone());c=w.dot(z);if(c<0){z=z.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(w.multiplyScalar(z));
+w,v=a.geometry,J=v.vertices,S=[];f=0;for(d=v.faces.length;f<d;f++){i=v.faces[f];C=this.origin.clone();w=this.direction.clone();k=a.matrix.multiplyVector3(J[i.a].position.clone());p=a.matrix.multiplyVector3(J[i.b].position.clone());l=a.matrix.multiplyVector3(J[i.c].position.clone());o=i instanceof THREE.Face4?a.matrix.multiplyVector3(J[i.d].position.clone()):null;z=a.rotationMatrix.multiplyVector3(i.normal.clone());c=w.dot(z);if(c<0){z=z.dot((new THREE.Vector3).sub(k,C))/c;C=C.addSelf(w.multiplyScalar(z));
 if(i instanceof THREE.Face3){if(b(C,k,p,l)){i={distance:this.origin.distanceTo(C),point:C,face:i,object:a};S.push(i)}}else if(i instanceof THREE.Face4)if(b(C,k,p,o)||b(C,p,l,o)){i={distance:this.origin.distanceTo(C),point:C,face:i,object:a};S.push(i)}}}return S}};
 THREE.Rectangle=function(){function a(){k=d-b;p=i-f}var b,f,d,i,k,p,l=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return k};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,z,c,C){l=false;b=o;f=z;d=c;i=C;a()};this.addPoint=function(o,z){if(l){l=false;b=o;f=z;d=o;i=z}else{b=b<o?b:o;f=f<z?f:z;d=d>o?d:o;i=i>z?
-i:z}a()};this.add3Points=function(o,z,c,C,w,u){if(l){l=false;b=o<c?o<w?o:w:c<w?c:w;f=z<C?z<u?z:u:C<u?C:u;d=o>c?o>w?o:w:c>w?c:w;i=z>C?z>u?z:u:C>u?C:u}else{b=o<c?o<w?o<b?o:b:w<b?w:b:c<w?c<b?c:b:w<b?w:b;f=z<C?z<u?z<f?z:f:u<f?u:f:C<u?C<f?C:f:u<f?u:f;d=o>c?o>w?o>d?o:d:w>d?w:d:c>w?c>d?c:d:w>d?w:d;i=z>C?z>u?z>i?z:i:u>i?u:i:C>u?C>i?C: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();
+i:z}a()};this.add3Points=function(o,z,c,C,w,v){if(l){l=false;b=o<c?o<w?o:w:c<w?c:w;f=z<C?z<v?z:v:C<v?C:v;d=o>c?o>w?o:w:c>w?c:w;i=z>C?z>v?z:v:C>v?C:v}else{b=o<c?o<w?o<b?o:b:w<b?w:b:c<w?c<b?c:b:w<b?w:b;f=z<C?z<v?z<f?z:f:v<f?v:f:C<v?C<f?C:f:v<f?v:f;d=o>c?o>w?o>d?o:d:w>d?w:d:c>w?c>d?c:d:w>d?w:d;i=z>C?z>v?z>i?z:i:v>i?v:i:C>v?C>i?C:i:v>i?v: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: "+k+", 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,k,p,l,o,z,c,C,w,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=k||1;this.n23=p||0;this.n24=l||0;this.n31=o||0;this.n32=z||0;this.n33=c||1;this.n34=C||0;this.n41=w||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,k,p,l,o,z,c,C,w,u,I,S){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=k;this.n23=p;this.n24=l;this.n31=o;this.n32=z;this.n33=c;this.n34=C;this.n41=w;this.n42=u;this.n43=I;this.n44=S;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,b,f,d,i,k,p,l,o,z,c,C,w,v,J,S){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=i||0;this.n22=k||1;this.n23=p||0;this.n24=l||0;this.n31=o||0;this.n32=z||0;this.n33=c||1;this.n34=C||0;this.n41=w||0;this.n42=v||0;this.n43=J||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,k,p,l,o,z,c,C,w,v,J,S){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=i;this.n22=k;this.n23=p;this.n24=l;this.n31=o;this.n32=z;this.n33=c;this.n34=C;this.n41=w;this.n42=v;this.n43=J;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,k=new THREE.Vector3;k.sub(a,b).normalize();d.cross(f,k).normalize();i.cross(k,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=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,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,k=a.n14,p=a.n21,l=a.n22,o=a.n23,z=a.n24,c=a.n31,C=a.n32,
-w=a.n33,u=a.n34,I=a.n41,S=a.n42,Q=a.n43,t=a.n44,U=b.n11,B=b.n12,L=b.n13,N=b.n14,e=b.n21,j=b.n22,g=b.n23,h=b.n24,n=b.n31,m=b.n32,q=b.n33,r=b.n34,y=b.n41,J=b.n42,E=b.n43,G=b.n44;this.n11=f*U+d*e+i*n+k*y;this.n12=f*B+d*j+i*m+k*J;this.n13=f*L+d*g+i*q+k*E;this.n14=f*N+d*h+i*r+k*G;this.n21=p*U+l*e+o*n+z*y;this.n22=p*B+l*j+o*m+z*J;this.n23=p*L+l*g+o*q+z*E;this.n24=p*N+l*h+o*r+z*G;this.n31=c*U+C*e+w*n+u*y;this.n32=c*B+C*j+w*m+u*J;this.n33=c*L+C*g+w*q+u*E;this.n34=c*N+C*h+w*r+u*G;this.n41=I*U+S*e+Q*n+t*y;
-this.n42=I*B+S*j+Q*m+t*J;this.n43=I*L+S*g+Q*q+t*E;this.n44=I*N+S*h+Q*r+t*G;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,k=this.n21,p=this.n22,l=this.n23,o=this.n24,z=this.n31,c=this.n32,C=this.n33,w=this.n34,u=this.n41,I=this.n42,S=this.n43,Q=this.n44,t=a.n11,U=a.n21,B=a.n31,L=a.n41,N=a.n12,e=a.n22,j=a.n32,g=a.n42,h=a.n13,n=a.n23,m=a.n33,q=a.n43,r=a.n14,y=a.n24,J=a.n34;a=a.n44;this.n11=b*t+f*U+d*B+i*L;this.n12=b*N+f*e+d*j+i*g;this.n13=b*h+f*n+d*m+i*q;this.n14=
-b*r+f*y+d*J+i*a;this.n21=k*t+p*U+l*B+o*L;this.n22=k*N+p*e+l*j+o*g;this.n23=k*h+p*n+l*m+o*q;this.n24=k*r+p*y+l*J+o*a;this.n31=z*t+c*U+C*B+w*L;this.n32=z*N+c*e+C*j+w*g;this.n33=z*h+c*n+C*m+w*q;this.n34=z*r+c*y+C*J+w*a;this.n41=u*t+I*U+S*B+Q*L;this.n42=u*N+I*e+S*j+Q*g;this.n43=u*h+I*n+S*m+Q*q;this.n44=u*r+I*y+S*J+Q*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*=
+w=a.n33,v=a.n34,J=a.n41,S=a.n42,Q=a.n43,t=a.n44,U=b.n11,B=b.n12,L=b.n13,N=b.n14,e=b.n21,j=b.n22,g=b.n23,h=b.n24,n=b.n31,m=b.n32,q=b.n33,r=b.n34,y=b.n41,K=b.n42,F=b.n43,E=b.n44;this.n11=f*U+d*e+i*n+k*y;this.n12=f*B+d*j+i*m+k*K;this.n13=f*L+d*g+i*q+k*F;this.n14=f*N+d*h+i*r+k*E;this.n21=p*U+l*e+o*n+z*y;this.n22=p*B+l*j+o*m+z*K;this.n23=p*L+l*g+o*q+z*F;this.n24=p*N+l*h+o*r+z*E;this.n31=c*U+C*e+w*n+v*y;this.n32=c*B+C*j+w*m+v*K;this.n33=c*L+C*g+w*q+v*F;this.n34=c*N+C*h+w*r+v*E;this.n41=J*U+S*e+Q*n+t*y;
+this.n42=J*B+S*j+Q*m+t*K;this.n43=J*L+S*g+Q*q+t*F;this.n44=J*N+S*h+Q*r+t*E;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,i=this.n14,k=this.n21,p=this.n22,l=this.n23,o=this.n24,z=this.n31,c=this.n32,C=this.n33,w=this.n34,v=this.n41,J=this.n42,S=this.n43,Q=this.n44,t=a.n11,U=a.n21,B=a.n31,L=a.n41,N=a.n12,e=a.n22,j=a.n32,g=a.n42,h=a.n13,n=a.n23,m=a.n33,q=a.n43,r=a.n14,y=a.n24,K=a.n34;a=a.n44;this.n11=b*t+f*U+d*B+i*L;this.n12=b*N+f*e+d*j+i*g;this.n13=b*h+f*n+d*m+i*q;this.n14=
+b*r+f*y+d*K+i*a;this.n21=k*t+p*U+l*B+o*L;this.n22=k*N+p*e+l*j+o*g;this.n23=k*h+p*n+l*m+o*q;this.n24=k*r+p*y+l*K+o*a;this.n31=z*t+c*U+C*B+w*L;this.n32=z*N+c*e+C*j+w*g;this.n33=z*h+c*n+C*m+w*q;this.n34=z*r+c*y+C*K+w*a;this.n41=v*t+J*U+S*B+Q*L;this.n42=v*N+J*e+S*j+Q*g;this.n43=v*h+J*n+S*m+Q*q;this.n44=v*r+J*y+S*K+Q*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 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,
@@ -47,9 +47,9 @@ THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){
 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,i,k,p,l=new THREE.Vector3,o=new THREE.Vector3;d=0;for(i=this.vertices.length;d<i;d++){k=this.vertices[d];k.normal.set(0,0,0)}d=0;for(i=this.faces.length;d<i;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];p=this.vertices[k.c];l.sub(p.position,
 f.position);o.sub(b.position,f.position);l.crossSelf(o)}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(r,y,J,E){k=r.vertices[y].position;p=r.vertices[J].position;
-l=r.vertices[E].position;o=i[0];z=i[1];c=i[2];C=p.x-k.x;w=l.x-k.x;u=p.y-k.y;I=l.y-k.y;S=p.z-k.z;Q=l.z-k.z;t=z.u-o.u;U=c.u-o.u;B=z.v-o.v;L=c.v-o.v;N=1/(t*L-U*B);h.set((L*C-B*w)*N,(L*u-B*I)*N,(L*S-B*Q)*N);n.set((t*w-U*C)*N,(t*I-U*u)*N,(t*Q-U*S)*N);j[y].addSelf(h);j[J].addSelf(h);j[E].addSelf(h);g[y].addSelf(n);g[J].addSelf(n);g[E].addSelf(n)}var b,f,d,i,k,p,l,o,z,c,C,w,u,I,S,Q,t,U,B,L,N,e,j=[],g=[],h=new THREE.Vector3,n=new THREE.Vector3,m=new THREE.Vector3,q=new THREE.Vector3;e=new THREE.Vector3;b=
-0;for(f=this.vertices.length;b<f;b++){j[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]);
+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(r,y,K,F,E,I,u){k=r.vertices[y].position;p=r.vertices[K].position;
+l=r.vertices[F].position;o=i[E];z=i[I];c=i[u];C=p.x-k.x;w=l.x-k.x;v=p.y-k.y;J=l.y-k.y;S=p.z-k.z;Q=l.z-k.z;t=z.u-o.u;U=c.u-o.u;B=z.v-o.v;L=c.v-o.v;N=1/(t*L-U*B);h.set((L*C-B*w)*N,(L*v-B*J)*N,(L*S-B*Q)*N);n.set((t*w-U*C)*N,(t*J-U*v)*N,(t*Q-U*S)*N);j[y].addSelf(h);j[K].addSelf(h);j[F].addSelf(h);g[y].addSelf(n);g[K].addSelf(n);g[F].addSelf(n)}var b,f,d,i,k,p,l,o,z,c,C,w,v,J,S,Q,t,U,B,L,N,e,j=[],g=[],h=new THREE.Vector3,n=new THREE.Vector3,m=new THREE.Vector3,q=new THREE.Vector3;e=new THREE.Vector3;b=
+0;for(f=this.vertices.length;b<f;b++){j[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,0,1,2);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,0,1,2);a(this,d.a,d.b,d.d,0,1,3);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++){e.copy(this.vertices[b].normal);d=j[b];m.copy(d);m.subSelf(e.multiplyScalar(e.dot(d))).normalize();q.cross(this.vertices[b].normal,d);test=q.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(m.x,m.y,m.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(z){var c=[];b=0;for(f=z.length;b<f;b++)z[b]==undefined?c.push("undefined"):c.push(z[b].toString());return c.join("_")}
@@ -94,52 +94,52 @@ THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,th
 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.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(j,g){return g.z-j.z}function b(j,g){var h=0,n=1,m=j.z+j.w,q=g.z+g.w,r=-j.z+j.w,y=-g.z+g.w;if(m>=0&&q>=0&&r>=0&&y>=0)return true;else if(m<0&&q<0||r<0&&y<0)return false;else{if(m<0)h=Math.max(h,m/(m-q));else if(q<0)n=Math.min(n,m/(m-q));if(r<0)h=Math.max(h,r/(r-y));else if(y<0)n=Math.min(n,r/(r-y));if(n<h)return false;else{j.lerpSelf(g,h);g.lerpSelf(j,1-n);return true}}}var f,d,i=[],k,p,l,o=[],z,c,C=[],w,u,I=[],S=new THREE.Vector4,Q=new THREE.Vector4,t=new THREE.Matrix4,
+THREE.Projector=function(){function a(j,g){return g.z-j.z}function b(j,g){var h=0,n=1,m=j.z+j.w,q=g.z+g.w,r=-j.z+j.w,y=-g.z+g.w;if(m>=0&&q>=0&&r>=0&&y>=0)return true;else if(m<0&&q<0||r<0&&y<0)return false;else{if(m<0)h=Math.max(h,m/(m-q));else if(q<0)n=Math.min(n,m/(m-q));if(r<0)h=Math.max(h,r/(r-y));else if(y<0)n=Math.min(n,r/(r-y));if(n<h)return false;else{j.lerpSelf(g,h);g.lerpSelf(j,1-n);return true}}}var f,d,i=[],k,p,l,o=[],z,c,C=[],w,v,J=[],S=new THREE.Vector4,Q=new THREE.Vector4,t=new THREE.Matrix4,
 U=new THREE.Matrix4,B=[],L=new THREE.Vector4,N=new THREE.Vector4,e;this.projectObjects=function(j,g,h){var n=[],m,q;d=0;t.multiply(g.projectionMatrix,g.matrix);B[0]=new THREE.Vector4(t.n41-t.n11,t.n42-t.n12,t.n43-t.n13,t.n44-t.n14);B[1]=new THREE.Vector4(t.n41+t.n11,t.n42+t.n12,t.n43+t.n13,t.n44+t.n14);B[2]=new THREE.Vector4(t.n41+t.n21,t.n42+t.n22,t.n43+t.n23,t.n44+t.n24);B[3]=new THREE.Vector4(t.n41-t.n21,t.n42-t.n22,t.n43-t.n23,t.n44-t.n24);B[4]=new THREE.Vector4(t.n41-t.n31,t.n42-t.n32,t.n43-
-t.n33,t.n44-t.n34);B[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);g=0;for(m=B.length;g<m;g++){q=B[g];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}m=j.objects;j=0;for(g=m.length;j<g;j++){q=m[j];var r;if(!(r=!q.visible)){if(r=q instanceof THREE.Mesh){a:{r=void 0;for(var y=q.position,J=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),E=0;E<6;E++){r=B[E].x*y.x+B[E].y*y.y+B[E].z*y.z+B[E].w;if(r<=J){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
-i[d]=i[d]||new THREE.RenderableObject;S.copy(q.position);t.multiplyVector3(S);f.object=q;f.z=S.z;n.push(f);d++}}h&&n.sort(a);return n};this.projectScene=function(j,g,h){var n=[],m=g.near,q=g.far,r,y,J,E,G,K,v,R,T,F,x,H,V,D,O,Y;l=c=u=0;g.autoUpdateMatrix&&g.updateMatrix();t.multiply(g.projectionMatrix,g.matrix);K=this.projectObjects(j,g,true);j=0;for(r=K.length;j<r;j++){v=K[j].object;if(v.visible){v.autoUpdateMatrix&&v.updateMatrix();R=v.matrix;T=v.rotationMatrix;F=v.materials;x=v.overdraw;if(v instanceof
-THREE.Mesh){H=v.geometry;V=H.vertices;y=0;for(J=V.length;y<J;y++){D=V[y];D.positionWorld.copy(D.position);R.multiplyVector3(D.positionWorld);E=D.positionScreen;E.copy(D.positionWorld);t.multiplyVector4(E);E.x/=E.w;E.y/=E.w;D.__visible=E.z>m&&E.z<q}H=H.faces;y=0;for(J=H.length;y<J;y++){D=H[y];if(D instanceof THREE.Face3){E=V[D.a];G=V[D.b];O=V[D.c];if(E.__visible&&G.__visible&&O.__visible)if(v.doubleSided||v.flipSided!=(O.positionScreen.x-E.positionScreen.x)*(G.positionScreen.y-E.positionScreen.y)-
-(O.positionScreen.y-E.positionScreen.y)*(G.positionScreen.x-E.positionScreen.x)<0){k=o[l]=o[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(E.positionWorld);k.v2.positionWorld.copy(G.positionWorld);k.v3.positionWorld.copy(O.positionWorld);k.v1.positionScreen.copy(E.positionScreen);k.v2.positionScreen.copy(G.positionScreen);k.v3.positionScreen.copy(O.positionScreen);k.normalWorld.copy(D.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);R.multiplyVector3(k.centroidWorld);
-k.centroidScreen.copy(k.centroidWorld);t.multiplyVector3(k.centroidScreen);O=D.vertexNormals;e=k.vertexNormalsWorld;E=0;for(G=O.length;E<G;E++){Y=e[E]=e[E]||new THREE.Vector3;Y.copy(O[E]);T.multiplyVector3(Y)}k.z=k.centroidScreen.z;k.meshMaterials=F;k.faceMaterials=D.materials;k.overdraw=x;if(v.geometry.uvs[y]){k.uvs[0]=v.geometry.uvs[y][0];k.uvs[1]=v.geometry.uvs[y][1];k.uvs[2]=v.geometry.uvs[y][2]}n.push(k);l++}}else if(D instanceof THREE.Face4){E=V[D.a];G=V[D.b];O=V[D.c];Y=V[D.d];if(E.__visible&&
-G.__visible&&O.__visible&&Y.__visible)if(v.doubleSided||v.flipSided!=((Y.positionScreen.x-E.positionScreen.x)*(G.positionScreen.y-E.positionScreen.y)-(Y.positionScreen.y-E.positionScreen.y)*(G.positionScreen.x-E.positionScreen.x)<0||(G.positionScreen.x-O.positionScreen.x)*(Y.positionScreen.y-O.positionScreen.y)-(G.positionScreen.y-O.positionScreen.y)*(Y.positionScreen.x-O.positionScreen.x)<0)){k=o[l]=o[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(E.positionWorld);k.v2.positionWorld.copy(G.positionWorld);
-k.v3.positionWorld.copy(Y.positionWorld);k.v1.positionScreen.copy(E.positionScreen);k.v2.positionScreen.copy(G.positionScreen);k.v3.positionScreen.copy(Y.positionScreen);k.normalWorld.copy(D.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);R.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);t.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=F;k.faceMaterials=D.materials;k.overdraw=x;if(v.geometry.uvs[y]){k.uvs[0]=v.geometry.uvs[y][0];
-k.uvs[1]=v.geometry.uvs[y][1];k.uvs[2]=v.geometry.uvs[y][3]}n.push(k);l++;p=o[l]=o[l]||new THREE.RenderableFace3;p.v1.positionWorld.copy(G.positionWorld);p.v2.positionWorld.copy(O.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(G.positionScreen);p.v2.positionScreen.copy(O.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(k.normalWorld);p.centroidWorld.copy(k.centroidWorld);p.centroidScreen.copy(k.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
-F;p.faceMaterials=D.materials;p.overdraw=x;if(v.geometry.uvs[y]){p.uvs[0]=v.geometry.uvs[y][1];p.uvs[1]=v.geometry.uvs[y][2];p.uvs[2]=v.geometry.uvs[y][3]}n.push(p);l++}}}}else if(v instanceof THREE.Line){U.multiply(t,R);V=v.geometry.vertices;D=V[0];D.positionScreen.copy(D.position);U.multiplyVector4(D.positionScreen);y=1;for(J=V.length;y<J;y++){E=V[y];E.positionScreen.copy(E.position);U.multiplyVector4(E.positionScreen);G=V[y-1];L.copy(E.positionScreen);N.copy(G.positionScreen);if(b(L,N)){L.multiplyScalar(1/
-L.w);N.multiplyScalar(1/N.w);z=C[c]=C[c]||new THREE.RenderableLine;z.v1.positionScreen.copy(L);z.v2.positionScreen.copy(N);z.z=Math.max(L.z,N.z);z.materials=v.materials;n.push(z);c++}}}else if(v instanceof THREE.Particle){Q.set(v.position.x,v.position.y,v.position.z,1);t.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){w=I[u]=I[u]||new THREE.RenderableParticle;w.x=Q.x/Q.w;w.y=Q.y/Q.w;w.z=Q.z;w.rotation=v.rotation.z;w.scale.x=v.scale.x*Math.abs(w.x-(Q.x+g.projectionMatrix.n11)/(Q.w+g.projectionMatrix.n14));
-w.scale.y=v.scale.y*Math.abs(w.y-(Q.y+g.projectionMatrix.n22)/(Q.w+g.projectionMatrix.n24));w.materials=v.materials;n.push(w);u++}}}}h&&n.sort(a);return n};this.unprojectVector=function(j,g){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));h.multiplyVector3(j);return j}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,k;this.domElement=document.createElement("div");this.setSize=function(p,l){f=p;d=l;i=f/2;k=d/2};this.render=function(p,l){var o,z,c,C,w,u,I,S;a=b.projectScene(p,l);o=0;for(z=a.length;o<z;o++){w=a[o];if(w instanceof THREE.RenderableParticle){I=w.x*i+i;S=w.y*k+k;c=0;for(C=w.material.length;c<C;c++){u=w.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,k,p,l=f.getContext("2d"),o=1,z=0,c=null,C=null,w=1,u,I,S,Q,t,U,B,L,N,e=new THREE.Color,j=new THREE.Color,g=new THREE.Color,h=new THREE.Color,n=new THREE.Color,m,q,r,y,J,E,G,K,v,R=new THREE.Rectangle,T=new THREE.Rectangle,F=new THREE.Rectangle,x=false,H=new THREE.Color,V=new THREE.Color,D=new THREE.Color,O=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=16;oa=document.createElement("canvas");
+t.n33,t.n44-t.n34);B[5]=new THREE.Vector4(t.n41+t.n31,t.n42+t.n32,t.n43+t.n33,t.n44+t.n34);g=0;for(m=B.length;g<m;g++){q=B[g];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}m=j.objects;j=0;for(g=m.length;j<g;j++){q=m[j];var r;if(!(r=!q.visible)){if(r=q instanceof THREE.Mesh){a:{r=void 0;for(var y=q.position,K=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),F=0;F<6;F++){r=B[F].x*y.x+B[F].y*y.y+B[F].z*y.z+B[F].w;if(r<=K){r=false;break a}}r=true}r=!r}r=r}if(!r){f=
+i[d]=i[d]||new THREE.RenderableObject;S.copy(q.position);t.multiplyVector3(S);f.object=q;f.z=S.z;n.push(f);d++}}h&&n.sort(a);return n};this.projectScene=function(j,g,h){var n=[],m=g.near,q=g.far,r,y,K,F,E,I,u,R,T,G,x,H,V,D,O,Y;l=c=v=0;g.autoUpdateMatrix&&g.updateMatrix();t.multiply(g.projectionMatrix,g.matrix);I=this.projectObjects(j,g,true);j=0;for(r=I.length;j<r;j++){u=I[j].object;if(u.visible){u.autoUpdateMatrix&&u.updateMatrix();R=u.matrix;T=u.rotationMatrix;G=u.materials;x=u.overdraw;if(u instanceof
+THREE.Mesh){H=u.geometry;V=H.vertices;y=0;for(K=V.length;y<K;y++){D=V[y];D.positionWorld.copy(D.position);R.multiplyVector3(D.positionWorld);F=D.positionScreen;F.copy(D.positionWorld);t.multiplyVector4(F);F.x/=F.w;F.y/=F.w;D.__visible=F.z>m&&F.z<q}H=H.faces;y=0;for(K=H.length;y<K;y++){D=H[y];if(D instanceof THREE.Face3){F=V[D.a];E=V[D.b];O=V[D.c];if(F.__visible&&E.__visible&&O.__visible)if(u.doubleSided||u.flipSided!=(O.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-
+(O.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0){k=o[l]=o[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(F.positionWorld);k.v2.positionWorld.copy(E.positionWorld);k.v3.positionWorld.copy(O.positionWorld);k.v1.positionScreen.copy(F.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(O.positionScreen);k.normalWorld.copy(D.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);R.multiplyVector3(k.centroidWorld);
+k.centroidScreen.copy(k.centroidWorld);t.multiplyVector3(k.centroidScreen);O=D.vertexNormals;e=k.vertexNormalsWorld;F=0;for(E=O.length;F<E;F++){Y=e[F]=e[F]||new THREE.Vector3;Y.copy(O[F]);T.multiplyVector3(Y)}k.z=k.centroidScreen.z;k.meshMaterials=G;k.faceMaterials=D.materials;k.overdraw=x;if(u.geometry.uvs[y]){k.uvs[0]=u.geometry.uvs[y][0];k.uvs[1]=u.geometry.uvs[y][1];k.uvs[2]=u.geometry.uvs[y][2]}n.push(k);l++}}else if(D instanceof THREE.Face4){F=V[D.a];E=V[D.b];O=V[D.c];Y=V[D.d];if(F.__visible&&
+E.__visible&&O.__visible&&Y.__visible)if(u.doubleSided||u.flipSided!=((Y.positionScreen.x-F.positionScreen.x)*(E.positionScreen.y-F.positionScreen.y)-(Y.positionScreen.y-F.positionScreen.y)*(E.positionScreen.x-F.positionScreen.x)<0||(E.positionScreen.x-O.positionScreen.x)*(Y.positionScreen.y-O.positionScreen.y)-(E.positionScreen.y-O.positionScreen.y)*(Y.positionScreen.x-O.positionScreen.x)<0)){k=o[l]=o[l]||new THREE.RenderableFace3;k.v1.positionWorld.copy(F.positionWorld);k.v2.positionWorld.copy(E.positionWorld);
+k.v3.positionWorld.copy(Y.positionWorld);k.v1.positionScreen.copy(F.positionScreen);k.v2.positionScreen.copy(E.positionScreen);k.v3.positionScreen.copy(Y.positionScreen);k.normalWorld.copy(D.normal);T.multiplyVector3(k.normalWorld);k.centroidWorld.copy(D.centroid);R.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);t.multiplyVector3(k.centroidScreen);k.z=k.centroidScreen.z;k.meshMaterials=G;k.faceMaterials=D.materials;k.overdraw=x;if(u.geometry.uvs[y]){k.uvs[0]=u.geometry.uvs[y][0];
+k.uvs[1]=u.geometry.uvs[y][1];k.uvs[2]=u.geometry.uvs[y][3]}n.push(k);l++;p=o[l]=o[l]||new THREE.RenderableFace3;p.v1.positionWorld.copy(E.positionWorld);p.v2.positionWorld.copy(O.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(E.positionScreen);p.v2.positionScreen.copy(O.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(k.normalWorld);p.centroidWorld.copy(k.centroidWorld);p.centroidScreen.copy(k.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
+G;p.faceMaterials=D.materials;p.overdraw=x;if(u.geometry.uvs[y]){p.uvs[0]=u.geometry.uvs[y][1];p.uvs[1]=u.geometry.uvs[y][2];p.uvs[2]=u.geometry.uvs[y][3]}n.push(p);l++}}}}else if(u instanceof THREE.Line){U.multiply(t,R);V=u.geometry.vertices;D=V[0];D.positionScreen.copy(D.position);U.multiplyVector4(D.positionScreen);y=1;for(K=V.length;y<K;y++){F=V[y];F.positionScreen.copy(F.position);U.multiplyVector4(F.positionScreen);E=V[y-1];L.copy(F.positionScreen);N.copy(E.positionScreen);if(b(L,N)){L.multiplyScalar(1/
+L.w);N.multiplyScalar(1/N.w);z=C[c]=C[c]||new THREE.RenderableLine;z.v1.positionScreen.copy(L);z.v2.positionScreen.copy(N);z.z=Math.max(L.z,N.z);z.materials=u.materials;n.push(z);c++}}}else if(u instanceof THREE.Particle){Q.set(u.position.x,u.position.y,u.position.z,1);t.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){w=J[v]=J[v]||new THREE.RenderableParticle;w.x=Q.x/Q.w;w.y=Q.y/Q.w;w.z=Q.z;w.rotation=u.rotation.z;w.scale.x=u.scale.x*Math.abs(w.x-(Q.x+g.projectionMatrix.n11)/(Q.w+g.projectionMatrix.n14));
+w.scale.y=u.scale.y*Math.abs(w.y-(Q.y+g.projectionMatrix.n22)/(Q.w+g.projectionMatrix.n24));w.materials=u.materials;n.push(w);v++}}}}h&&n.sort(a);return n};this.unprojectVector=function(j,g){var h=new THREE.Matrix4;h.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));h.multiplyVector3(j);return j}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,i,k;this.domElement=document.createElement("div");this.setSize=function(p,l){f=p;d=l;i=f/2;k=d/2};this.render=function(p,l){var o,z,c,C,w,v,J,S;a=b.projectScene(p,l);o=0;for(z=a.length;o<z;o++){w=a[o];if(w instanceof THREE.RenderableParticle){J=w.x*i+i;S=w.y*k+k;c=0;for(C=w.material.length;c<C;c++){v=w.material[c];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=J+"px";v.style.top=S+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,i,k,p,l=f.getContext("2d"),o=1,z=0,c=null,C=null,w=1,v,J,S,Q,t,U,B,L,N,e=new THREE.Color,j=new THREE.Color,g=new THREE.Color,h=new THREE.Color,n=new THREE.Color,m,q,r,y,K,F,E,I,u,R=new THREE.Rectangle,T=new THREE.Rectangle,G=new THREE.Rectangle,x=false,H=new THREE.Color,V=new THREE.Color,D=new THREE.Color,O=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=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);Aa=pa.getImageData(0,0,2,2);da=Aa.data;qa=document.createElement("canvas");qa.width=qa.height=la;ua=qa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ma){d=ga;i=ma;k=d/2;p=i/2;f.width=d;f.height=i;R.set(-k,-p,k,p)};this.clear=function(){if(!T.isEmpty()){T.inflate(1);T.minSelf(R);l.clearRect(T.getX(),
 T.getY(),T.getWidth(),T.getHeight());T.empty()}};this.render=function(ga,ma){function Ka(s){var W,P,A,M=s.lights;V.setRGB(0,0,0);D.setRGB(0,0,0);O.setRGB(0,0,0);s=0;for(W=M.length;s<W;s++){P=M[s];A=P.color;if(P instanceof THREE.AmbientLight){V.r+=A.r;V.g+=A.g;V.b+=A.b}else if(P instanceof THREE.DirectionalLight){D.r+=A.r;D.g+=A.g;D.b+=A.b}else if(P instanceof THREE.PointLight){O.r+=A.r;O.g+=A.g;O.b+=A.b}}}function va(s,W,P,A){var M,X,aa,ba,ca=s.lights;s=0;for(M=ca.length;s<M;s++){X=ca[s];aa=X.color;
-ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=P.dot(Z)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}}}function La(s,W,P){if(P.opacity!=0){Ba(P.opacity);wa(P.blending);var A,M,X,aa,ba,ca;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){aa=P.map;ba=aa.width>>1;ca=aa.height>>1;M=W.scale.x*k;X=W.scale.y*p;P=M*ba;A=X*ca;F.set(s.x-P,s.y-A,s.x+P,
-s.y+A);if(!R.instersects(F))return;l.save();l.translate(s.x,s.y);l.rotate(-W.rotation);l.scale(M,-X);l.translate(-ba,-ca);l.drawImage(aa,0,0);l.restore()}l.beginPath();l.moveTo(s.x-10,s.y);l.lineTo(s.x+10,s.y);l.moveTo(s.x,s.y-10);l.lineTo(s.x,s.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(P instanceof THREE.ParticleCircleMaterial){if(x){H.r=V.r+D.r+O.r;H.g=V.g+D.g+O.g;H.b=V.b+D.b+O.b;e.r=P.color.r*H.r;e.g=P.color.g*H.g;e.b=P.color.b*H.b;e.updateStyleString()}else e.__styleString=
-P.color.__styleString;P=W.scale.x*k;A=W.scale.y*p;F.set(s.x-P,s.y-A,s.x+P,s.y+A);if(R.instersects(F)){M=e.__styleString;if(C!=M)l.fillStyle=C=M;l.save();l.translate(s.x,s.y);l.rotate(-W.rotation);l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Y,true);l.closePath();l.fill();l.restore()}}}}function Ma(s,W,P,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);l.beginPath();l.moveTo(s.positionScreen.x,s.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){e.__styleString=
-A.color.__styleString;s=A.linewidth;if(w!=s)l.lineWidth=w=s;s=e.__styleString;if(c!=s)l.strokeStyle=c=s;l.stroke();F.inflate(A.linewidth*2)}}}function Ga(s,W,P,A,M,X){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);Q=s.positionScreen.x;t=s.positionScreen.y;U=W.positionScreen.x;B=W.positionScreen.y;L=P.positionScreen.x;N=P.positionScreen.y;l.beginPath();l.moveTo(Q,t);l.lineTo(U,B);l.lineTo(L,N);l.lineTo(Q,t);l.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof
-THREE.UVMapping&&ra(Q,t,U,B,L,N,M.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(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=ma.matrix;Z.copy(A.vertexNormalsWorld[0]);y=(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;J=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[1]);E=(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;G=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[2]);K=
-(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;v=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;ra(Q,t,U,B,L,N,M.env_map.image,y,J,E,G,K,v)}}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):ya(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&ra(Q,t,U,B,L,N,M.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);wa(THREE.SubtractiveBlending)}if(x)if(!M.wireframe&&M.shading==THREE.SmoothShading&&
+ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=P.dot(X.position)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,W);Z.normalize();X=P.dot(Z)*ba;if(X>0){A.r+=aa.r*X;A.g+=aa.g*X;A.b+=aa.b*X}}}}function La(s,W,P){if(P.opacity!=0){Ba(P.opacity);wa(P.blending);var A,M,X,aa,ba,ca;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){aa=P.map;ba=aa.width>>1;ca=aa.height>>1;M=W.scale.x*k;X=W.scale.y*p;P=M*ba;A=X*ca;G.set(s.x-P,s.y-A,s.x+P,
+s.y+A);if(!R.instersects(G))return;l.save();l.translate(s.x,s.y);l.rotate(-W.rotation);l.scale(M,-X);l.translate(-ba,-ca);l.drawImage(aa,0,0);l.restore()}l.beginPath();l.moveTo(s.x-10,s.y);l.lineTo(s.x+10,s.y);l.moveTo(s.x,s.y-10);l.lineTo(s.x,s.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(P instanceof THREE.ParticleCircleMaterial){if(x){H.r=V.r+D.r+O.r;H.g=V.g+D.g+O.g;H.b=V.b+D.b+O.b;e.r=P.color.r*H.r;e.g=P.color.g*H.g;e.b=P.color.b*H.b;e.updateStyleString()}else e.__styleString=
+P.color.__styleString;P=W.scale.x*k;A=W.scale.y*p;G.set(s.x-P,s.y-A,s.x+P,s.y+A);if(R.instersects(G)){M=e.__styleString;if(C!=M)l.fillStyle=C=M;l.save();l.translate(s.x,s.y);l.rotate(-W.rotation);l.scale(P,A);l.beginPath();l.arc(0,0,1,0,Y,true);l.closePath();l.fill();l.restore()}}}}function Ma(s,W,P,A){if(A.opacity!=0){Ba(A.opacity);wa(A.blending);l.beginPath();l.moveTo(s.positionScreen.x,s.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(A instanceof THREE.LineBasicMaterial){e.__styleString=
+A.color.__styleString;s=A.linewidth;if(w!=s)l.lineWidth=w=s;s=e.__styleString;if(c!=s)l.strokeStyle=c=s;l.stroke();G.inflate(A.linewidth*2)}}}function Ga(s,W,P,A,M,X){if(M.opacity!=0){Ba(M.opacity);wa(M.blending);Q=s.positionScreen.x;t=s.positionScreen.y;U=W.positionScreen.x;B=W.positionScreen.y;L=P.positionScreen.x;N=P.positionScreen.y;l.beginPath();l.moveTo(Q,t);l.lineTo(U,B);l.lineTo(L,N);l.lineTo(Q,t);l.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof
+THREE.UVMapping&&ra(Q,t,U,B,L,N,M.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(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=ma.matrix;Z.copy(A.vertexNormalsWorld[0]);y=(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;K=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[1]);F=(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;E=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;Z.copy(A.vertexNormalsWorld[2]);I=
+(Z.x*s.n11+Z.y*s.n12+Z.z*s.n13)*0.5+0.5;u=-(Z.x*s.n21+Z.y*s.n22+Z.z*s.n23)*0.5+0.5;ra(Q,t,U,B,L,N,M.env_map.image,y,K,F,E,I,u)}}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):ya(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof THREE.UVMapping&&ra(Q,t,U,B,L,N,M.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);wa(THREE.SubtractiveBlending)}if(x)if(!M.wireframe&&M.shading==THREE.SmoothShading&&
 A.vertexNormalsWorld.length==3){j.r=g.r=h.r=V.r;j.g=g.g=h.g=V.g;j.b=g.b=h.b=V.b;va(X,A.v1.positionWorld,A.vertexNormalsWorld[0],j);va(X,A.v2.positionWorld,A.vertexNormalsWorld[1],g);va(X,A.v3.positionWorld,A.vertexNormalsWorld[2],h);n.r=(g.r+h.r)*0.5;n.g=(g.g+h.g)*0.5;n.b=(g.b+h.b)*0.5;r=Ha(j,g,h,n);ra(Q,t,U,B,L,N,r,0,0,1,0,0,1)}else{H.r=V.r;H.g=V.g;H.b=V.b;va(X,A.centroidWorld,A.normalWorld,H);e.r=M.color.r*H.r;e.g=M.color.g*H.g;e.b=M.color.b*H.b;e.updateStyleString();M.wireframe?xa(e.__styleString,
 M.wireframe_linewidth):ya(e.__styleString)}else M.wireframe?xa(M.color.__styleString,M.wireframe_linewidth):ya(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){m=ma.near;q=ma.far;j.r=j.g=j.b=1-Ca(s.positionScreen.z,m,q);g.r=g.g=g.b=1-Ca(W.positionScreen.z,m,q);h.r=h.g=h.b=1-Ca(P.positionScreen.z,m,q);n.r=(g.r+h.r)*0.5;n.g=(g.g+h.g)*0.5;n.b=(g.b+h.b)*0.5;r=Ha(j,g,h,n);ra(Q,t,U,B,L,N,r,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){e.r=Da(A.normalWorld.x);e.g=Da(A.normalWorld.y);
-e.b=Da(A.normalWorld.z);e.updateStyleString();M.wireframe?xa(e.__styleString,M.wireframe_linewidth):ya(e.__styleString)}}}function xa(s,W){if(c!=s)l.strokeStyle=c=s;if(w!=W)l.lineWidth=w=W;l.stroke();F.inflate(W*2)}function ya(s){if(C!=s)l.fillStyle=C=s;l.fill()}function ra(s,W,P,A,M,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;P-=s;A-=W;M-=s;X-=W;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*P-ea*M)*ja;ea=(sa*A-ea*X)*ja;P=(ha*M-
+e.b=Da(A.normalWorld.z);e.updateStyleString();M.wireframe?xa(e.__styleString,M.wireframe_linewidth):ya(e.__styleString)}}}function xa(s,W){if(c!=s)l.strokeStyle=c=s;if(w!=W)l.lineWidth=w=W;l.stroke();G.inflate(W*2)}function ya(s){if(C!=s)l.fillStyle=C=s;l.fill()}function ra(s,W,P,A,M,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;P-=s;A-=W;M-=s;X-=W;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*P-ea*M)*ja;ea=(sa*A-ea*X)*ja;P=(ha*M-
 ia*P)*ja;A=(ha*X-ia*A)*ja;s=s-ka*ba-P*ca;W=W-ea*ba-A*ca;l.save();l.transform(ka,ea,P,A,s,W);l.clip();l.drawImage(aa,0,0);l.restore()}function Ba(s){if(o!=s)l.globalAlpha=o=s}function wa(s){if(z!=s){switch(s){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}z=s}}function Ha(s,W,P,A){var M=~~(s.r*255),X=~~(s.g*255);s=~~(s.b*255);var aa=~~(W.r*
 255),ba=~~(W.g*255);W=~~(W.b*255);var ca=~~(P.r*255),ha=~~(P.g*255);P=~~(P.b*255);var ea=~~(A.r*255),ia=~~(A.g*255);A=~~(A.b*255);da[0]=M<0?0:M>255?255:M;da[1]=X<0?0:X>255?255:X;da[2]=s<0?0:s>255?255:s;da[4]=aa<0?0:aa>255?255:aa;da[5]=ba<0?0:ba>255?255:ba;da[6]=W<0?0:W>255?255:W;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=P<0?0:P>255?255:P;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=A<0?0:A>255?255:A;pa.putImageData(Aa,0,0);ua.drawImage(oa,0,0);return qa}function Ca(s,
-W,P){s=(s-W)/(P-W);return s*s*(3-2*s)}function Da(s){s=(s+1)*0.5;return s<0?0:s>1?1:s}function Ea(s,W){var P=W.x-s.x,A=W.y-s.y,M=1/Math.sqrt(P*P+A*A);P*=M;A*=M;W.x+=P;W.y+=A;s.x-=P;s.y-=A}var za,Ia,$,fa,na,Fa,Ja,ta;l.setTransform(1,0,0,-1,k,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());(x=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];F.empty();if($ instanceof
-THREE.RenderableParticle){u=$;u.x*=k;u.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(u,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){u=$.v1;I=$.v2;u.positionScreen.x*=k;u.positionScreen.y*=p;I.positionScreen.x*=k;I.positionScreen.y*=p;F.addPoint(u.positionScreen.x,u.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(R.instersects(F)){fa=0;for(na=$.materials.length;fa<na;)Ma(u,I,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){u=$.v1;I=
-$.v2;S=$.v3;u.positionScreen.x*=k;u.positionScreen.y*=p;I.positionScreen.x*=k;I.positionScreen.y*=p;S.positionScreen.x*=k;S.positionScreen.y*=p;if($.overdraw){Ea(u.positionScreen,I.positionScreen);Ea(I.positionScreen,S.positionScreen);Ea(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(R.instersects(F)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof
-THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(u,I,S,$,ta,ga)}else Ga(u,I,S,$,ta,ga)}}}T.addRectangle(F)}l.lineWidth=1;l.strokeStyle="rgba( 255, 0, 0, 0.5 )";l.strokeRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());l.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(K,v,R){var T,F,x,H;T=0;for(F=K.lights.length;T<F;T++){x=K.lights[T];if(x instanceof THREE.DirectionalLight){H=v.normalWorld.dot(x.position)*x.intensity;if(H>0){R.r+=x.color.r*H;R.g+=x.color.g*H;R.b+=x.color.b*H}}else if(x instanceof THREE.PointLight){h.sub(x.position,v.centroidWorld);h.normalize();H=v.normalWorld.dot(h)*x.intensity;if(H>0){R.r+=x.color.r*H;R.g+=x.color.g*H;R.b+=x.color.b*H}}}}function b(K,v,R,T,F,x){r=d(y++);r.setAttribute("d","M "+K.positionScreen.x+
-" "+K.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)B.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;a(x,T,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){g=1-F.__2near/(F.__farPlusNear-T.z*F.__farMinusNear);
-B.setRGB(g,g,g)}else F instanceof THREE.MeshNormalMaterial&&B.setRGB(i(T.normalWorld.x),i(T.normalWorld.y),i(T.normalWorld.z));F.wireframe?r.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):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+F.opacity);l.appendChild(r)}function f(K,v,R,T,F,x,H){r=d(y++);r.setAttribute("d",
-"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;a(H,F,L);B.r=x.color.r*L.r;B.g=x.color.g*L.g;B.b=x.color.b*L.b;B.updateStyleString()}else B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){g=
-1-x.__2near/(x.__farPlusNear-F.z*x.__farMinusNear);B.setRGB(g,g,g)}else x instanceof THREE.MeshNormalMaterial&&B.setRGB(i(F.normalWorld.x),i(F.normalWorld.y),i(F.normalWorld.z));x.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+x.wireframe_linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframe_linecap+"; stroke-linejoin: "+x.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+x.opacity);l.appendChild(r)}
-function d(K){if(n[K]==null){n[K]=document.createElementNS("http://www.w3.org/2000/svg","path");G==0&&n[K].setAttribute("shape-rendering","crispEdges");return n[K]}return n[K]}function i(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var k=null,p=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,z,c,C,w,u,I,S,Q=new THREE.Rectangle,t=new THREE.Rectangle,U=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),N=new THREE.Color(0),e=new THREE.Color(0),
-j=new THREE.Color(0),g,h=new THREE.Vector3,n=[],m=[],q=[],r,y,J,E,G=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(K){switch(K){case "high":G=1;break;case "low":G=0}};this.setSize=function(K,v){o=K;z=v;c=o/2;C=z/2;l.setAttribute("viewBox",-c+" "+-C+" "+o+" "+z);l.setAttribute("width",o);l.setAttribute("height",z);Q.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(K,v){var R,T,
-F,x,H,V,D,O;this.autoClear&&this.clear();k=p.projectScene(K,v,this.sortElements);E=J=y=0;if(U=K.lights.length>0){D=K.lights;N.setRGB(0,0,0);e.setRGB(0,0,0);j.setRGB(0,0,0);R=0;for(T=D.length;R<T;R++){F=D[R];x=F.color;if(F instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(F instanceof THREE.DirectionalLight){e.r+=x.r;e.g+=x.g;e.b+=x.b}else if(F instanceof THREE.PointLight){j.r+=x.r;j.g+=x.g;j.b+=x.b}}}R=0;for(T=k.length;R<T;R++){D=k[R];t.empty();if(D instanceof THREE.RenderableParticle){w=
-D;w.x*=c;w.y*=-C;F=0;for(x=D.materials.length;F<x;F++)if(O=D.materials[F]){H=w;V=D;O=O;var Y=J++;if(m[Y]==null){m[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");G==0&&m[Y].setAttribute("shape-rendering","crispEdges")}r=m[Y];r.setAttribute("cx",H.x);r.setAttribute("cy",H.y);r.setAttribute("r",V.scale.x*c);if(O instanceof THREE.ParticleCircleMaterial){if(U){L.r=N.r+e.r+j.r;L.g=N.g+e.g+j.g;L.b=N.b+e.b+j.b;B.r=O.color.r*L.r;B.g=O.color.g*L.g;B.b=O.color.b*L.b;B.updateStyleString()}else B=
-O.color;r.setAttribute("style","fill: "+B.__styleString)}l.appendChild(r)}}else if(D instanceof THREE.RenderableLine){w=D.v1;u=D.v2;w.positionScreen.x*=c;w.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);if(Q.instersects(t)){F=0;for(x=D.materials.length;F<x;)if(O=D.materials[F++]){H=w;V=u;O=O;Y=E++;if(q[Y]==null){q[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");G==
+W,P){s=(s-W)/(P-W);return s*s*(3-2*s)}function Da(s){s=(s+1)*0.5;return s<0?0:s>1?1:s}function Ea(s,W){var P=W.x-s.x,A=W.y-s.y,M=1/Math.sqrt(P*P+A*A);P*=M;A*=M;W.x+=P;W.y+=A;s.x-=P;s.y-=A}var za,Ia,$,fa,na,Fa,Ja,ta;l.setTransform(1,0,0,-1,k,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());(x=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];G.empty();if($ instanceof
+THREE.RenderableParticle){v=$;v.x*=k;v.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(v,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){v=$.v1;J=$.v2;v.positionScreen.x*=k;v.positionScreen.y*=p;J.positionScreen.x*=k;J.positionScreen.y*=p;G.addPoint(v.positionScreen.x,v.positionScreen.y);G.addPoint(J.positionScreen.x,J.positionScreen.y);if(R.instersects(G)){fa=0;for(na=$.materials.length;fa<na;)Ma(v,J,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){v=$.v1;J=
+$.v2;S=$.v3;v.positionScreen.x*=k;v.positionScreen.y*=p;J.positionScreen.x*=k;J.positionScreen.y*=p;S.positionScreen.x*=k;S.positionScreen.y*=p;if($.overdraw){Ea(v.positionScreen,J.positionScreen);Ea(J.positionScreen,S.positionScreen);Ea(S.positionScreen,v.positionScreen)}G.add3Points(v.positionScreen.x,v.positionScreen.y,J.positionScreen.x,J.positionScreen.y,S.positionScreen.x,S.positionScreen.y);if(R.instersects(G)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof
+THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(v,J,S,$,ta,ga)}else Ga(v,J,S,$,ta,ga)}}}T.addRectangle(G)}l.lineWidth=1;l.strokeStyle="rgba( 255, 0, 0, 0.5 )";l.strokeRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());l.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(I,u,R){var T,G,x,H;T=0;for(G=I.lights.length;T<G;T++){x=I.lights[T];if(x instanceof THREE.DirectionalLight){H=u.normalWorld.dot(x.position)*x.intensity;if(H>0){R.r+=x.color.r*H;R.g+=x.color.g*H;R.b+=x.color.b*H}}else if(x instanceof THREE.PointLight){h.sub(x.position,u.centroidWorld);h.normalize();H=u.normalWorld.dot(h)*x.intensity;if(H>0){R.r+=x.color.r*H;R.g+=x.color.g*H;R.b+=x.color.b*H}}}}function b(I,u,R,T,G,x){r=d(y++);r.setAttribute("d","M "+I.positionScreen.x+
+" "+I.positionScreen.y+" L "+u.positionScreen.x+" "+u.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)B.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;a(x,T,L);B.r=G.color.r*L.r;B.g=G.color.g*L.g;B.b=G.color.b*L.b;B.updateStyleString()}else B.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){g=1-G.__2near/(G.__farPlusNear-T.z*G.__farMinusNear);
+B.setRGB(g,g,g)}else G instanceof THREE.MeshNormalMaterial&&B.setRGB(i(T.normalWorld.x),i(T.normalWorld.y),i(T.normalWorld.z));G.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+G.opacity);l.appendChild(r)}function f(I,u,R,T,G,x,H){r=d(y++);r.setAttribute("d",
+"M "+I.positionScreen.x+" "+I.positionScreen.y+" L "+u.positionScreen.x+" "+u.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;a(H,G,L);B.r=x.color.r*L.r;B.g=x.color.g*L.g;B.b=x.color.b*L.b;B.updateStyleString()}else B.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){g=
+1-x.__2near/(x.__farPlusNear-G.z*x.__farMinusNear);B.setRGB(g,g,g)}else x instanceof THREE.MeshNormalMaterial&&B.setRGB(i(G.normalWorld.x),i(G.normalWorld.y),i(G.normalWorld.z));x.wireframe?r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+x.wireframe_linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframe_linecap+"; stroke-linejoin: "+x.wireframe_linejoin):r.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+x.opacity);l.appendChild(r)}
+function d(I){if(n[I]==null){n[I]=document.createElementNS("http://www.w3.org/2000/svg","path");E==0&&n[I].setAttribute("shape-rendering","crispEdges");return n[I]}return n[I]}function i(I){return I<0?Math.min((1+I)*0.5,0.5):0.5+Math.min(I*0.5,0.5)}var k=null,p=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,z,c,C,w,v,J,S,Q=new THREE.Rectangle,t=new THREE.Rectangle,U=false,B=new THREE.Color(16777215),L=new THREE.Color(16777215),N=new THREE.Color(0),e=new THREE.Color(0),
+j=new THREE.Color(0),g,h=new THREE.Vector3,n=[],m=[],q=[],r,y,K,F,E=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(I){switch(I){case "high":E=1;break;case "low":E=0}};this.setSize=function(I,u){o=I;z=u;c=o/2;C=z/2;l.setAttribute("viewBox",-c+" "+-C+" "+o+" "+z);l.setAttribute("width",o);l.setAttribute("height",z);Q.set(-c,-C,c,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(I,u){var R,T,
+G,x,H,V,D,O;this.autoClear&&this.clear();k=p.projectScene(I,u,this.sortElements);F=K=y=0;if(U=I.lights.length>0){D=I.lights;N.setRGB(0,0,0);e.setRGB(0,0,0);j.setRGB(0,0,0);R=0;for(T=D.length;R<T;R++){G=D[R];x=G.color;if(G instanceof THREE.AmbientLight){N.r+=x.r;N.g+=x.g;N.b+=x.b}else if(G instanceof THREE.DirectionalLight){e.r+=x.r;e.g+=x.g;e.b+=x.b}else if(G instanceof THREE.PointLight){j.r+=x.r;j.g+=x.g;j.b+=x.b}}}R=0;for(T=k.length;R<T;R++){D=k[R];t.empty();if(D instanceof THREE.RenderableParticle){w=
+D;w.x*=c;w.y*=-C;G=0;for(x=D.materials.length;G<x;G++)if(O=D.materials[G]){H=w;V=D;O=O;var Y=K++;if(m[Y]==null){m[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");E==0&&m[Y].setAttribute("shape-rendering","crispEdges")}r=m[Y];r.setAttribute("cx",H.x);r.setAttribute("cy",H.y);r.setAttribute("r",V.scale.x*c);if(O instanceof THREE.ParticleCircleMaterial){if(U){L.r=N.r+e.r+j.r;L.g=N.g+e.g+j.g;L.b=N.b+e.b+j.b;B.r=O.color.r*L.r;B.g=O.color.g*L.g;B.b=O.color.b*L.b;B.updateStyleString()}else B=
+O.color;r.setAttribute("style","fill: "+B.__styleString)}l.appendChild(r)}}else if(D instanceof THREE.RenderableLine){w=D.v1;v=D.v2;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);if(Q.instersects(t)){G=0;for(x=D.materials.length;G<x;)if(O=D.materials[G++]){H=w;V=v;O=O;Y=F++;if(q[Y]==null){q[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");E==
 0&&q[Y].setAttribute("shape-rendering","crispEdges")}r=q[Y];r.setAttribute("x1",H.positionScreen.x);r.setAttribute("y1",H.positionScreen.y);r.setAttribute("x2",V.positionScreen.x);r.setAttribute("y2",V.positionScreen.y);if(O instanceof THREE.LineBasicMaterial){B.__styleString=O.color.__styleString;r.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+O.linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.linecap+"; stroke-linejoin: "+O.linejoin);l.appendChild(r)}}}}else if(D instanceof
-THREE.RenderableFace3){w=D.v1;u=D.v2;I=D.v3;w.positionScreen.x*=c;w.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;I.positionScreen.x*=c;I.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(I.positionScreen.x,I.positionScreen.y);if(Q.instersects(t)){F=0;for(x=D.meshMaterials.length;F<x;){O=D.meshMaterials[F++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(V=D.faceMaterials.length;H<V;)(O=D.faceMaterials[H++])&&
-b(w,u,I,D,O,K)}else O&&b(w,u,I,D,O,K)}}}else if(D instanceof THREE.RenderableFace4){w=D.v1;u=D.v2;I=D.v3;S=D.v4;w.positionScreen.x*=c;w.positionScreen.y*=-C;u.positionScreen.x*=c;u.positionScreen.y*=-C;I.positionScreen.x*=c;I.positionScreen.y*=-C;S.positionScreen.x*=c;S.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(I.positionScreen.x,I.positionScreen.y);t.addPoint(S.positionScreen.x,S.positionScreen.y);if(Q.instersects(t)){F=
-0;for(x=D.meshMaterials.length;F<x;){O=D.meshMaterials[F++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(V=D.faceMaterials.length;H<V;)(O=D.faceMaterials[H++])&&f(w,u,I,S,D,O,K)}else O&&f(w,u,I,S,D,O,K)}}}}}};
+THREE.RenderableFace3){w=D.v1;v=D.v2;J=D.v3;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(J.positionScreen.x,J.positionScreen.y);if(Q.instersects(t)){G=0;for(x=D.meshMaterials.length;G<x;){O=D.meshMaterials[G++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(V=D.faceMaterials.length;H<V;)(O=D.faceMaterials[H++])&&
+b(w,v,J,D,O,I)}else O&&b(w,v,J,D,O,I)}}}else if(D instanceof THREE.RenderableFace4){w=D.v1;v=D.v2;J=D.v3;S=D.v4;w.positionScreen.x*=c;w.positionScreen.y*=-C;v.positionScreen.x*=c;v.positionScreen.y*=-C;J.positionScreen.x*=c;J.positionScreen.y*=-C;S.positionScreen.x*=c;S.positionScreen.y*=-C;t.addPoint(w.positionScreen.x,w.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(J.positionScreen.x,J.positionScreen.y);t.addPoint(S.positionScreen.x,S.positionScreen.y);if(Q.instersects(t)){G=
+0;for(x=D.meshMaterials.length;G<x;){O=D.meshMaterials[G++];if(O instanceof THREE.MeshFaceMaterial){H=0;for(V=D.faceMaterials.length;H<V;)(O=D.faceMaterials[H++])&&f(w,v,J,S,D,O,I)}else O&&f(w,v,J,S,D,O,I)}}}}}};
 THREE.WebGLRenderer=function(a){function b(e,j){e.fragment_shader=j.fragment_shader;e.vertex_shader=j.vertex_shader;var g=j.uniforms,h,n,m={};for(h in g){m[h]={};for(n in uniforms[h]){parameter_src=g[h][n];parameter_dst=m[h][n];parameter_dst=parameter_src instanceof THREE.Color||parameter_src instanceof THREE.Vector3||parameter_src instanceof THREE.Texture?parameter_src.clone():parameter_src}}e.uniforms=m}function f(e,j,g){var h=c.createProgram();g=["#ifdef GL_ES\nprecision highp float;\n#endif",
 g?"#define USE_FOG":"",g instanceof THREE.FogExp2?"#define FOG_EXP2":"","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",g+e));c.attachShader(h,l("vertex",n+j));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,j){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);
@@ -147,7 +147,7 @@ c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParame
 j);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function i(e,j){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+j);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function k(e,j){var g,h,n;g=0;for(h=j.length;g<h;g++){n=j[g];e.uniforms[n]=c.getUniformLocation(e,n)}}function p(e,j){var g,h,n;g=0;for(h=j.length;g<h;g++){n=j[g];e.attributes[n]=c.getAttribLocation(e,n)}}function l(e,j){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER);c.shaderSource(g,
 j);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}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 z=document.createElement("canvas"),c,C,w,u=new THREE.Matrix4,I,S=new Float32Array(16),Q=new Float32Array(16),t=new Float32Array(16),U=new Float32Array(9),B=new Float32Array(16),L=function(e,j){if(e){var g,h,n,m=pointLights=maxDirLights=maxPointLights=0;g=0;for(h=e.lights.length;g<h;g++){n=e.lights[g];n instanceof THREE.DirectionalLight&&m++;n instanceof
+case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var z=document.createElement("canvas"),c,C,w,v=new THREE.Matrix4,J,S=new Float32Array(16),Q=new Float32Array(16),t=new Float32Array(16),U=new Float32Array(9),B=new Float32Array(16),L=function(e,j){if(e){var g,h,n,m=pointLights=maxDirLights=maxPointLights=0;g=0;for(h=e.lights.length;g<h;g++){n=e.lights[g];n instanceof THREE.DirectionalLight&&m++;n instanceof
 THREE.PointLight&&pointLights++}if(pointLights+m<=j){maxDirLights=m;maxPointLights=pointLights}else{maxDirLights=Math.ceil(j*m/(pointLights+m));maxPointLights=j-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:j-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=z;this.autoClear=true;
 (function(e,j,g){try{c=z.getContext("experimental-webgl",{antialias:e})}catch(h){}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(j.r,j.g,j.b,g)})(antialias,clearColor,clearAlpha);C=w=function(e,j,g){var h=[e?"#define MAX_DIR_LIGHTS "+e:"",j?"#define MAX_POINT_LIGHTS "+
 j:"","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 ];":"",j?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",j?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",j?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
@@ -162,26 +162,26 @@ j?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",j?"vec4 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;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
 h=f(n,h,g);c.useProgram(h);k(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);g&&k(h,["fogColor","fogNear","fogFar","fogDensity"]);e&&k(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);j&&k(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}(L.directional,L.point,fog);this.setSize=function(e,j){z.width=e;z.height=j;c.viewport(0,0,z.width,z.height)};this.setClearColor=function(e,j){var g=new THREE.Color(e);c.clearColor(g.r,g.g,g.b,j)};this.clear=
-function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,j){var g,h,n,m,q,r=[],y=[],J=[];m=[];q=[];c.uniform1i(e.uniforms.enableLighting,j.length);g=0;for(h=j.length;g<h;g++){n=j[g];if(n instanceof THREE.AmbientLight)r.push(n);else if(n instanceof THREE.DirectionalLight)J.push(n);else n instanceof THREE.PointLight&&y.push(n)}g=n=m=q=0;for(h=r.length;g<h;g++){n+=r[g].color.r;m+=r[g].color.g;q+=r[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,m,q);m=[];q=[];g=0;
-for(h=J.length;g<h;g++){n=J[g];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);q.push(n.position.x);q.push(n.position.y);q.push(n.position.z)}if(J.length){c.uniform1i(e.uniforms.directionalLightNumber,J.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,m)}m=[];q=[];g=0;for(h=y.length;g<h;g++){n=y[g];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);q.push(n.position.x);
-q.push(n.position.y);q.push(n.position.z)}if(y.length){c.uniform1i(e.uniforms.pointLightNumber,y.length);c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,m)}};this.createBuffers=function(e,j){var g,h,n,m,q,r,y,J,E,G=[],K=[],v=[],R=[],T=[],F=[],x=0,H=e.geometry.geometryChunks[j],V;n=false;g=0;for(h=e.materials.length;g<h;g++){meshMaterial=e.materials[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(V=H.materials.length;q<V;q++)if(H.materials[q]&&H.materials[q].shading!=
-undefined&&H.materials[q].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}V=n;g=0;for(h=H.faces.length;g<h;g++){n=H.faces[g];m=e.geometry.faces[n];q=m.vertexNormals;faceNormal=m.normal;n=e.geometry.uvs[n];if(m instanceof THREE.Face3){r=e.geometry.vertices[m.a].position;y=e.geometry.vertices[m.b].position;J=e.geometry.vertices[m.c].position;v.push(r.x,r.y,r.z);v.push(y.x,y.y,y.z);v.push(J.x,
-J.y,J.z);if(e.geometry.hasTangents){r=e.geometry.vertices[m.a].tangent;y=e.geometry.vertices[m.b].tangent;J=e.geometry.vertices[m.c].tangent;T.push(r.x,r.y,r.z,r.w);T.push(y.x,y.y,y.z,y.w);T.push(J.x,J.y,J.z,J.w)}if(q.length==3&&V)for(m=0;m<3;m++)R.push(q[m].x,q[m].y,q[m].z);else for(m=0;m<3;m++)R.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<3;m++)F.push(n[m].u,n[m].v);G.push(x,x+1,x+2);K.push(x,x+1);K.push(x,x+2);K.push(x+1,x+2);x+=3}else if(m instanceof THREE.Face4){r=e.geometry.vertices[m.a].position;
-y=e.geometry.vertices[m.b].position;J=e.geometry.vertices[m.c].position;E=e.geometry.vertices[m.d].position;v.push(r.x,r.y,r.z);v.push(y.x,y.y,y.z);v.push(J.x,J.y,J.z);v.push(E.x,E.y,E.z);if(e.geometry.hasTangents){r=e.geometry.vertices[m.a].tangent;y=e.geometry.vertices[m.b].tangent;J=e.geometry.vertices[m.c].tangent;m=e.geometry.vertices[m.d].tangent;T.push(r.x,r.y,r.z,r.w);T.push(y.x,y.y,y.z,y.w);T.push(J.x,J.y,J.z,J.w);T.push(m.x,m.y,m.z,m.w)}if(q.length==4&&V)for(m=0;m<4;m++)R.push(q[m].x,q[m].y,
-q[m].z);else for(m=0;m<4;m++)R.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<4;m++)F.push(n[m].u,n[m].v);G.push(x,x+1,x+2);G.push(x,x+2,x+3);K.push(x,x+1);K.push(x,x+2);K.push(x,x+3);K.push(x+1,x+2);K.push(x+2,x+3);x+=4}}if(v.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(v),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
-new Float32Array(R),c.STATIC_DRAW);if(e.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}if(F.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(F),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
-new Uint16Array(G),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(K),c.STATIC_DRAW);H.__webGLFaceCount=G.length;H.__webGLLineCount=K.length}};this.renderBuffer=function(e,j,g,h,n){var m,q,r,y,J,E,G,K,v;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){b(h,N.depth);
-h.uniforms.mNear.value=e.near;h.uniforms.mFar.value=e.far}else h instanceof THREE.MeshNormalMaterial&&b(h,N.normal);h.program=f(h.fragment_shader,h.vertex_shader,null);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(v in h.uniforms)G.push(v);k(h.program,G);p(h.program,["position","normal","uv","tangent"])}v=h.program}else v=w;if(v!=C){c.useProgram(v);C=v}v==w&&this.setupLights(v,j);this.loadCamera(v,e);this.loadMatrices(v);if(h instanceof THREE.MeshShaderMaterial||
-h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){r=h.wireframe;y=h.wireframe_linewidth;e=v;j=h.uniforms;var R;for(m in j){K=j[m].type;G=j[m].value;R=e.uniforms[m];if(K=="i")c.uniform1i(R,G);else if(K=="f")c.uniform1f(R,G);else if(K=="v3")c.uniform3f(R,G.x,G.y,G.z);else if(K=="c")c.uniform3f(R,G.r,G.g,G.b);else if(K=="t"){c.uniform1i(R,G);if(K=j[m].texture)K.image instanceof Array&&K.image.length==6?d(K,G):i(K,G)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||
-h instanceof THREE.MeshBasicMaterial){m=h.color;q=h.opacity;r=h.wireframe;y=h.wireframe_linewidth;J=h.map;E=h.env_map;j=h.combine==THREE.MixOperation;e=h.reflectivity;K=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;G=h.refraction_ratio;c.uniform4f(v.uniforms.mColor,m.r*q,m.g*q,m.b*q,q);c.uniform1i(v.uniforms.mixEnvMap,j);c.uniform1f(v.uniforms.mReflectivity,e);c.uniform1i(v.uniforms.useRefract,K);c.uniform1f(v.uniforms.mRefractionRatio,G);if(g){c.uniform3f(v.uniforms.fogColor,
-g.color.r,g.color.g,g.color.b);if(g instanceof THREE.Fog){c.uniform1f(v.uniforms.fogNear,g.near);c.uniform1f(v.uniforms.fogFar,g.far)}else g instanceof THREE.FogExp2&&c.uniform1f(v.uniforms.fogDensity,g.density)}}if(h instanceof THREE.MeshPhongMaterial){g=h.ambient;m=h.specular;h=h.shininess;c.uniform4f(v.uniforms.mAmbient,g.r,g.g,g.b,q);c.uniform4f(v.uniforms.mSpecular,m.r,m.g,m.b,q);c.uniform1f(v.uniforms.mShininess,h);c.uniform1i(v.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(v.uniforms.material,
-1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(v.uniforms.material,0);if(J){i(J,0);c.uniform1i(v.uniforms.tMap,0);c.uniform1i(v.uniforms.enableMap,1)}else c.uniform1i(v.uniforms.enableMap,0);if(E){d(E,1);c.uniform1i(v.uniforms.tCube,1);c.uniform1i(v.uniforms.enableCubeMap,1)}else c.uniform1i(v.uniforms.enableCubeMap,0);q=v.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>=
+function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,j){var g,h,n,m,q,r=[],y=[],K=[];m=[];q=[];c.uniform1i(e.uniforms.enableLighting,j.length);g=0;for(h=j.length;g<h;g++){n=j[g];if(n instanceof THREE.AmbientLight)r.push(n);else if(n instanceof THREE.DirectionalLight)K.push(n);else n instanceof THREE.PointLight&&y.push(n)}g=n=m=q=0;for(h=r.length;g<h;g++){n+=r[g].color.r;m+=r[g].color.g;q+=r[g].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,m,q);m=[];q=[];g=0;
+for(h=K.length;g<h;g++){n=K[g];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.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.directionalLightNumber,K.length);c.uniform3fv(e.uniforms.directionalLightDirection,q);c.uniform3fv(e.uniforms.directionalLightColor,m)}m=[];q=[];g=0;for(h=y.length;g<h;g++){n=y[g];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);q.push(n.position.x);
+q.push(n.position.y);q.push(n.position.z)}if(y.length){c.uniform1i(e.uniforms.pointLightNumber,y.length);c.uniform3fv(e.uniforms.pointLightPosition,q);c.uniform3fv(e.uniforms.pointLightColor,m)}};this.createBuffers=function(e,j){var g,h,n,m,q,r,y,K,F,E=[],I=[],u=[],R=[],T=[],G=[],x=0,H=e.geometry.geometryChunks[j],V;n=false;g=0;for(h=e.materials.length;g<h;g++){meshMaterial=e.materials[g];if(meshMaterial instanceof THREE.MeshFaceMaterial){q=0;for(V=H.materials.length;q<V;q++)if(H.materials[q]&&H.materials[q].shading!=
+undefined&&H.materials[q].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}V=n;g=0;for(h=H.faces.length;g<h;g++){n=H.faces[g];m=e.geometry.faces[n];q=m.vertexNormals;faceNormal=m.normal;n=e.geometry.uvs[n];if(m instanceof THREE.Face3){r=e.geometry.vertices[m.a].position;y=e.geometry.vertices[m.b].position;K=e.geometry.vertices[m.c].position;u.push(r.x,r.y,r.z);u.push(y.x,y.y,y.z);u.push(K.x,
+K.y,K.z);if(e.geometry.hasTangents){r=e.geometry.vertices[m.a].tangent;y=e.geometry.vertices[m.b].tangent;K=e.geometry.vertices[m.c].tangent;T.push(r.x,r.y,r.z,r.w);T.push(y.x,y.y,y.z,y.w);T.push(K.x,K.y,K.z,K.w)}if(q.length==3&&V)for(m=0;m<3;m++)R.push(q[m].x,q[m].y,q[m].z);else for(m=0;m<3;m++)R.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<3;m++)G.push(n[m].u,n[m].v);E.push(x,x+1,x+2);I.push(x,x+1);I.push(x,x+2);I.push(x+1,x+2);x+=3}else if(m instanceof THREE.Face4){r=e.geometry.vertices[m.a].position;
+y=e.geometry.vertices[m.b].position;K=e.geometry.vertices[m.c].position;F=e.geometry.vertices[m.d].position;u.push(r.x,r.y,r.z);u.push(y.x,y.y,y.z);u.push(K.x,K.y,K.z);u.push(F.x,F.y,F.z);if(e.geometry.hasTangents){r=e.geometry.vertices[m.a].tangent;y=e.geometry.vertices[m.b].tangent;K=e.geometry.vertices[m.c].tangent;m=e.geometry.vertices[m.d].tangent;T.push(r.x,r.y,r.z,r.w);T.push(y.x,y.y,y.z,y.w);T.push(K.x,K.y,K.z,K.w);T.push(m.x,m.y,m.z,m.w)}if(q.length==4&&V)for(m=0;m<4;m++)R.push(q[m].x,q[m].y,
+q[m].z);else for(m=0;m<4;m++)R.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<4;m++)G.push(n[m].u,n[m].v);E.push(x,x+1,x+2);E.push(x,x+2,x+3);I.push(x,x+1);I.push(x,x+2);I.push(x,x+3);I.push(x+1,x+2);I.push(x+2,x+3);x+=4}}if(u.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(u),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,
+new Float32Array(R),c.STATIC_DRAW);if(e.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}if(G.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(G),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
+new Uint16Array(E),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(I),c.STATIC_DRAW);H.__webGLFaceCount=E.length;H.__webGLLineCount=I.length}};this.renderBuffer=function(e,j,g,h,n){var m,q,r,y,K,F,E,I,u;if(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){if(!h.program){if(h instanceof THREE.MeshDepthMaterial){b(h,N.depth);
+h.uniforms.mNear.value=e.near;h.uniforms.mFar.value=e.far}else h instanceof THREE.MeshNormalMaterial&&b(h,N.normal);h.program=f(h.fragment_shader,h.vertex_shader,null);E=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in h.uniforms)E.push(u);k(h.program,E);p(h.program,["position","normal","uv","tangent"])}u=h.program}else u=w;if(u!=C){c.useProgram(u);C=u}u==w&&this.setupLights(u,j);this.loadCamera(u,e);this.loadMatrices(u);if(h instanceof THREE.MeshShaderMaterial||
+h instanceof THREE.MeshDepthMaterial||h instanceof THREE.MeshNormalMaterial){r=h.wireframe;y=h.wireframe_linewidth;e=u;j=h.uniforms;var R;for(m in j){I=j[m].type;E=j[m].value;R=e.uniforms[m];if(I=="i")c.uniform1i(R,E);else if(I=="f")c.uniform1f(R,E);else if(I=="v3")c.uniform3f(R,E.x,E.y,E.z);else if(I=="c")c.uniform3f(R,E.r,E.g,E.b);else if(I=="t"){c.uniform1i(R,E);if(I=j[m].texture)I.image instanceof Array&&I.image.length==6?d(I,E):i(I,E)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||
+h instanceof THREE.MeshBasicMaterial){m=h.color;q=h.opacity;r=h.wireframe;y=h.wireframe_linewidth;K=h.map;F=h.env_map;j=h.combine==THREE.MixOperation;e=h.reflectivity;I=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;E=h.refraction_ratio;c.uniform4f(u.uniforms.mColor,m.r*q,m.g*q,m.b*q,q);c.uniform1i(u.uniforms.mixEnvMap,j);c.uniform1f(u.uniforms.mReflectivity,e);c.uniform1i(u.uniforms.useRefract,I);c.uniform1f(u.uniforms.mRefractionRatio,E);if(g){c.uniform3f(u.uniforms.fogColor,
+g.color.r,g.color.g,g.color.b);if(g instanceof THREE.Fog){c.uniform1f(u.uniforms.fogNear,g.near);c.uniform1f(u.uniforms.fogFar,g.far)}else g instanceof THREE.FogExp2&&c.uniform1f(u.uniforms.fogDensity,g.density)}}if(h instanceof THREE.MeshPhongMaterial){g=h.ambient;m=h.specular;h=h.shininess;c.uniform4f(u.uniforms.mAmbient,g.r,g.g,g.b,q);c.uniform4f(u.uniforms.mSpecular,m.r,m.g,m.b,q);c.uniform1f(u.uniforms.mShininess,h);c.uniform1i(u.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,
+1);else h instanceof THREE.MeshBasicMaterial&&c.uniform1i(u.uniforms.material,0);if(K){i(K,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(F){d(F,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap,0);q=u.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(r){c.lineWidth(y);
-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,j,g,h,n,m,q){var r,y,J,E,G;J=0;for(E=h.materials.length;J<E;J++){r=h.materials[J];if(r instanceof THREE.MeshFaceMaterial){r=0;for(y=n.materials.length;r<y;r++)if((G=n.materials[r])&&G.blending==m&&G.opacity<1==q){this.setBlending(G.blending);
-this.renderBuffer(e,j,g,G,n)}}else if((G=r)&&G.blending==m&&G.opacity<1==q){this.setBlending(G.blending);this.renderBuffer(e,j,g,G,n)}}};this.render=function(e,j){var g,h,n,m,q=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();j.autoUpdateMatrix&&j.updateMatrix();S.set(j.matrix.flatten());t.set(j.projectionMatrix.flatten());g=0;for(h=e.__webGLObjects.length;g<h;g++){n=e.__webGLObjects[g];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,q,r,m,n,THREE.NormalBlending,
+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,j,g,h,n,m,q){var r,y,K,F,E;K=0;for(F=h.materials.length;K<F;K++){r=h.materials[K];if(r instanceof THREE.MeshFaceMaterial){r=0;for(y=n.materials.length;r<y;r++)if((E=n.materials[r])&&E.blending==m&&E.opacity<1==q){this.setBlending(E.blending);
+this.renderBuffer(e,j,g,E,n)}}else if((E=r)&&E.blending==m&&E.opacity<1==q){this.setBlending(E.blending);this.renderBuffer(e,j,g,E,n)}}};this.render=function(e,j){var g,h,n,m,q=e.lights,r=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();j.autoUpdateMatrix&&j.updateMatrix();S.set(j.matrix.flatten());t.set(j.projectionMatrix.flatten());g=0;for(h=e.__webGLObjects.length;g<h;g++){n=e.__webGLObjects[g];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,q,r,m,n,THREE.NormalBlending,
 false)}}g=0;for(h=e.__webGLObjects.length;g<h;g++){n=e.__webGLObjects[g];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,j);this.renderPass(j,q,r,m,n,THREE.AdditiveBlending,false);this.renderPass(j,q,r,m,n,THREE.SubtractiveBlending,false);this.renderPass(j,q,r,m,n,THREE.AdditiveBlending,true);this.renderPass(j,q,r,m,n,THREE.SubtractiveBlending,true);this.renderPass(j,q,r,m,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var j,g,h,n,m,q;if(!e.__webGLObjects){e.__webGLObjects=
 [];e.__webGLObjectsMap={}}j=0;for(g=e.objects.length;j<g;j++){h=e.objects[j];if(e.__webGLObjectsMap[h.id]==undefined)e.__webGLObjectsMap[h.id]={};q=e.__webGLObjectsMap[h.id];if(h instanceof THREE.Mesh)for(m in h.geometry.geometryChunks){n=h.geometry.geometryChunks[m];n.__webGLVertexBuffer||this.createBuffers(h,m);if(q[m]==undefined){n={buffer:n,object:h};e.__webGLObjects.push(n);q[m]=1}}}};this.removeObject=function(e,j){var g,h;for(g=e.__webGLObjects.length-1;g>=0;g--){h=e.__webGLObjects[g].object;
-j==h&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,j){e.autoUpdateMatrix&&e.updateMatrix();u.multiply(j.matrix,e.matrix);Q.set(u.flatten());I=THREE.Matrix4.makeInvert3x3(u).transpose();U.set(I.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,S);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,Q);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,t);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,U);c.uniformMatrix4fv(e.uniforms.objectMatrix,
+j==h&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,j){e.autoUpdateMatrix&&e.updateMatrix();v.multiply(j.matrix,e.matrix);Q.set(v.flatten());J=THREE.Matrix4.makeInvert3x3(v).transpose();U.set(J.m);B.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,S);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,Q);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,t);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,U);c.uniformMatrix4fv(e.uniforms.objectMatrix,
 false,B)};this.loadCamera=function(e,j){c.uniform3f(e.uniforms.cameraPosition,j.position.x,j.position.y,j.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,j){if(e){!j||j=="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 N={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}"}}};

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


+ 7 - 10
src/core/Geometry.js

@@ -192,15 +192,15 @@ THREE.Geometry.prototype = {
 
 		}
 
-		function handleTriangle( context, a, b, c ) {
+		function handleTriangle( context, a, b, c, ua, ub, uc ) {
 
 			vA = context.vertices[ a ].position;
 			vB = context.vertices[ b ].position;
 			vC = context.vertices[ c ].position;
 
-			uvA = uv[ 0 ];
-			uvB = uv[ 1 ];
-			uvC = uv[ 2 ];
+			uvA = uv[ ua ];
+			uvB = uv[ ub ];
+			uvC = uv[ uc ];
 
 			x1 = vB.x - vA.x;
 			x2 = vC.x - vA.x;
@@ -239,7 +239,7 @@ THREE.Geometry.prototype = {
 
 			if ( face instanceof THREE.Face3 ) {
 
-				handleTriangle( this, face.a, face.b, face.c );
+				handleTriangle( this, face.a, face.b, face.c, 0, 1, 2 );
 
 				this.vertices[ face.a ].normal.copy( face.vertexNormals[ 0 ] );
 				this.vertices[ face.b ].normal.copy( face.vertexNormals[ 1 ] );
@@ -248,11 +248,8 @@ THREE.Geometry.prototype = {
 
 			} else if ( face instanceof THREE.Face4 ) {
 
-				handleTriangle( this, face.a, face.b, face.c );
-
-				// this messes up everything
-				// quads need to be handled differently
-				//handleTriangle( this, face.a, face.c, face.d );
+				handleTriangle( this, face.a, face.b, face.c, 0, 1, 2 );
+				handleTriangle( this, face.a, face.b, face.d, 0, 1, 3 );
 
 				this.vertices[ face.a ].normal.copy( face.vertexNormals[ 0 ] );
 				this.vertices[ face.b ].normal.copy( face.vertexNormals[ 1 ] );

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