Browse Source

Added dynamic geometry support also for WebGL lines. Changed line strip example to use Hilbert curves.

Also fixed tons of bugs in lines handling.

TODO: make some example for dynamic lines.
alteredq 14 years ago
parent
commit
0f5652390f
6 changed files with 474 additions and 382 deletions
  1. 107 106
      build/Three.js
  2. 108 107
      build/ThreeDebug.js
  3. 94 93
      build/ThreeExtras.js
  4. 55 19
      examples/lines_cubes_gl.html
  5. 1 1
      src/objects/Line.js
  6. 109 56
      src/renderers/WebGLRenderer.js

+ 107 - 106
build/Three.js

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

+ 108 - 107
build/ThreeDebug.js

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

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


+ 55 - 19
examples/lines_cubes_gl.html

@@ -54,7 +54,8 @@
 	<body>
 	<body>
 	
 	
 		<div id="info">
 		<div id="info">
-			<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - lines WebGL demo
+			<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - lines WebGL demo 
+			[<a href="http://en.wikipedia.org/wiki/Hilbert_curve">Hilbert curve</a> thanks to <a href="http://www.openprocessing.org/visuals/?visualID=15599">Thomas Diewald</a>]
 		</div>
 		</div>
 
 
 		<center>
 		<center>
@@ -99,7 +100,7 @@
 				container = document.createElement('div');
 				container = document.createElement('div');
 				document.body.appendChild(container);
 				document.body.appendChild(container);
 
 
-				camera = new THREE.Camera( 35, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera = new THREE.Camera( 33, window.innerWidth / window.innerHeight, 1, 10000 );
 				camera.position.z = 700;
 				camera.position.z = 700;
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
@@ -108,36 +109,29 @@
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
-				var vector, geometry_sphere = new THREE.Geometry(), geometry_cube = new THREE.Geometry();
-
-				for ( i = 0; i < 1500; i ++ ) {
-
-					vector = new THREE.Vector3( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 );					
-					vector.multiplyScalar( Math.random() * 10 + 250 );
-					geometry_cube.vertices.push( new THREE.Vertex( vector ) );
-
-					/*
-					vector = new THREE.Vector3( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 );					
-					vector.normalize();
-					vector.multiplyScalar( Math.random() * 10 + 250 );
-					geometry_sphere.vertices.push( new THREE.Vertex( vector ) );
-					*/
+				var geometry = new THREE.Geometry(),
+					points = hilbert3D( new THREE.Vector3( 0,0,0 ), 200.0, 4, 0, 1, 2, 3, 4, 5, 6, 7 );
 
 
+				for ( i = 0; i < points.length; i ++ ) {
+				
+					geometry.vertices.push( new THREE.Vertex( points[i] ) );
+				
 				}
 				}
+				
 
 
 				// lines
 				// lines
 
 
-				var line, p, scale = 0.3, d = 125, c1 = 0x553300, c2 = 0x555555, c3 = 0x552800, g1 = geometry_cube,
+				var line, p, scale = 0.3, d = 125, c1 = 0x553300, c2 = 0x555555, c3 = 0x992800, g1 = geometry,
 					m1 = new THREE.LineBasicMaterial( { color: c1, opacity: 1, blending: THREE.AdditiveBlending } ),
 					m1 = new THREE.LineBasicMaterial( { color: c1, opacity: 1, blending: THREE.AdditiveBlending } ),
 					m2 = new THREE.LineBasicMaterial( { color: c2, opacity: 1, blending: THREE.AdditiveBlending } ),
 					m2 = new THREE.LineBasicMaterial( { color: c2, opacity: 1, blending: THREE.AdditiveBlending } ),
 					m3 = new THREE.LineBasicMaterial( { color: c3, opacity: 1, blending: THREE.AdditiveBlending } ),
 					m3 = new THREE.LineBasicMaterial( { color: c3, opacity: 1, blending: THREE.AdditiveBlending } ),
-					parameters = [ [ m3, scale*0.5, [0,0,0],  g1 ], [ m2, scale*0.5, [d, 0, 0],  g1 ], [ m2, scale*0.5, [-d, 0, 0],  g1 ], 
+					parameters = [ [ m3, scale*0.5, [0,0,0],  g1 ], [ m2, scale*0.5, [d, 0, 0],  g1 ], [ m2, scale*0.5, [-d, 0, 0],  g1 ],
 								   [ m2, scale*0.5, [0,d,0],  g1 ], [ m2, scale*0.5, [d, d, 0],  g1 ], [ m2, scale*0.5, [-d, d, 0],  g1 ],
 								   [ m2, scale*0.5, [0,d,0],  g1 ], [ m2, scale*0.5, [d, d, 0],  g1 ], [ m2, scale*0.5, [-d, d, 0],  g1 ],
 								   [ m2, scale*0.5, [0,-d,0], g1 ], [ m2, scale*0.5, [d, -d, 0], g1 ], [ m2, scale*0.5, [-d, -d, 0], g1 ],
 								   [ m2, scale*0.5, [0,-d,0], g1 ], [ m2, scale*0.5, [d, -d, 0], g1 ], [ m2, scale*0.5, [-d, -d, 0], g1 ],
 								   
 								   
 								   [ m1, scale*0.5, [2*d, 0, 0],  g1 ], [ m1, scale*0.5, [-2*d, 0, 0],  g1 ],
 								   [ m1, scale*0.5, [2*d, 0, 0],  g1 ], [ m1, scale*0.5, [-2*d, 0, 0],  g1 ],
 								   [ m1, scale*0.5, [2*d, d, 0],  g1 ], [ m1, scale*0.5, [-2*d, d, 0],  g1 ],
 								   [ m1, scale*0.5, [2*d, d, 0],  g1 ], [ m1, scale*0.5, [-2*d, d, 0],  g1 ],
-								   [ m1, scale*0.5, [2*d, -d, 0], g1 ], [ m1, scale*0.5, [-2*d, -d, 0], g1 ],							   
+								   [ m1, scale*0.5, [2*d, -d, 0], g1 ], [ m1, scale*0.5, [-2*d, -d, 0], g1 ],
 								   ];
 								   ];
 				
 				
 				for ( i = 0; i < parameters.length; ++i ) {
 				for ( i = 0; i < parameters.length; ++i ) {
@@ -164,6 +158,48 @@
 				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
 				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
 			}
 			}
 
 
+			// port of Processing Java code by Thomas Diewald
+			// http://www.openprocessing.org/visuals/?visualID=15599
+			
+			function hilbert3D( center, side, iterations, v0, v1, v2, v3, v4, v5, v6, v7 ) {
+			
+				var half = side/2,
+					
+					vec_s = [
+			  
+					new THREE.Vector3( center.x - half, center.y + half, center.z - half ),
+					new THREE.Vector3( center.x - half, center.y + half, center.z + half ),
+					new THREE.Vector3( center.x - half, center.y - half, center.z + half ),
+					new THREE.Vector3( center.x - half, center.y - half, center.z - half ),
+					new THREE.Vector3( center.x + half, center.y - half, center.z - half ),
+					new THREE.Vector3( center.x + half, center.y - half, center.z + half ),
+					new THREE.Vector3( center.x + half, center.y + half, center.z + half ),
+					new THREE.Vector3( center.x + half, center.y + half, center.z - half )
+				
+					],
+  
+					vec = [ vec_s[ v0 ], vec_s[ v1 ], vec_s[ v2 ], vec_s[ v3 ], vec_s[ v4 ], vec_s[ v5 ], vec_s[ v6 ], vec_s[ v7 ] ];
+
+				if( --iterations >= 0 ) {
+			
+					var tmp = [];
+					
+					tmp = tmp.concat( hilbert3D ( vec[ 0 ], half, iterations, v0, v3, v4, v7, v6, v5, v2, v1 ) );
+					tmp = tmp.concat( hilbert3D ( vec[ 1 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) );
+					tmp = tmp.concat( hilbert3D ( vec[ 2 ], half, iterations, v0, v7, v6, v1, v2, v5, v4, v3 ) ); 
+					tmp = tmp.concat( hilbert3D ( vec[ 3 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) );
+					tmp = tmp.concat( hilbert3D ( vec[ 4 ], half, iterations, v2, v3, v0, v1, v6, v7, v4, v5 ) ); 
+					tmp = tmp.concat( hilbert3D ( vec[ 5 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
+					tmp = tmp.concat( hilbert3D ( vec[ 6 ], half, iterations, v4, v3, v2, v5, v6, v1, v0, v7 ) );
+					tmp = tmp.concat( hilbert3D ( vec[ 7 ], half, iterations, v6, v5, v2, v1, v0, v3, v4, v7 ) );
+					
+					return tmp;
+					
+				}
+			
+				return vec;
+			}
+			
 			//
 			//
 
 
 			function onDocumentMouseMove(event) {
 			function onDocumentMouseMove(event) {

+ 1 - 1
src/objects/Line.js

@@ -9,7 +9,7 @@ THREE.Line = function ( geometry, materials, type ) {
 	this.geometry = geometry;
 	this.geometry = geometry;
 	this.materials = materials instanceof Array ? materials : [ materials ];
 	this.materials = materials instanceof Array ? materials : [ materials ];
 	
 	
-	this.type = type !== undefined ? type : THREE.LineContinuous;
+	this.type = ( type != undefined ) ? type : THREE.LineStrip;
 
 
 };
 };
 
 

+ 109 - 56
src/renderers/WebGLRenderer.js

@@ -120,43 +120,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	this.createParticleBuffers = function( object ) {
+	this.createParticleBuffers = function( geometry ) {
+		
+		geometry.__webGLVertexBuffer = _gl.createBuffer();
+		geometry.__webGLFaceBuffer = _gl.createBuffer();
+	
 	};
 	};
 	
 	
-	this.createLineBuffers = function( object ) {
-		
-		var v, vl, vertex, 
-			vertexArray = [], lineArray = [], 
-			vertices = object.geometry.vertices;
-		
-		for ( v = 0, vl = vertices.length; v < vl; v++ ) {
-			
-			vertex = vertices[ v ].position;
-			vertexArray.push( vertex.x, vertex.y, vertex.z );
-			
-			lineArray.push( v );
-			
-		}
-			
-		if ( !vertexArray.length ) {
-
-			return;
-
-		}
-
-		object.__webGLVertexBuffer = _gl.createBuffer();
-		_gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLVertexBuffer );
-		_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertexArray ), _gl.STATIC_DRAW );
-		
-		object.__webGLLineBuffer = _gl.createBuffer();
-		_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, object.__webGLLineBuffer );
-		_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( lineArray ), _gl.STATIC_DRAW );
+	this.createLineBuffers = function( geometry ) {
 		
 		
-		object.__webGLLineCount = lineArray.length;
+		geometry.__webGLVertexBuffer = _gl.createBuffer();
+		geometry.__webGLLineBuffer = _gl.createBuffer();
 		
 		
 	};
 	};
-	
-	this.createBuffers = function ( geometryChunk ) {
+
+	this.createMeshBuffers = function( geometryChunk ) {
 		
 		
 		geometryChunk.__webGLVertexBuffer = _gl.createBuffer();
 		geometryChunk.__webGLVertexBuffer = _gl.createBuffer();
 		geometryChunk.__webGLNormalBuffer = _gl.createBuffer();
 		geometryChunk.__webGLNormalBuffer = _gl.createBuffer();
@@ -166,8 +144,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 		geometryChunk.__webGLLineBuffer = _gl.createBuffer();
 		geometryChunk.__webGLLineBuffer = _gl.createBuffer();
 		
 		
 	};
 	};
+
+	this.initLineBuffers = function( geometry ) {
+		
+		var nvertices = geometry.vertices.length;
+
+		geometry.__vertexArray = new Float32Array( nvertices * 3 );
+		geometry.__lineArray = new Uint16Array( nvertices );
+		
+		geometry.__webGLLineCount = nvertices;
 	
 	
-	this.initBuffers = function( geometryChunk, object ) {
+	};
+	
+	this.initMeshBuffers = function( geometryChunk, object ) {
 		
 		
 		var f, fl, nvertices = 0, ntris = 0, nlines = 0,
 		var f, fl, nvertices = 0, ntris = 0, nlines = 0,
 			obj_faces = object.geometry.faces, 
 			obj_faces = object.geometry.faces, 
@@ -208,13 +197,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		
 		geometryChunk.__webGLFaceCount = ntris * 3;
 		geometryChunk.__webGLFaceCount = ntris * 3;
 		geometryChunk.__webGLLineCount = nlines * 2;
 		geometryChunk.__webGLLineCount = nlines * 2;
-		
+	
 	};
 	};
 	
 	
-	this.setBuffers = function ( geometryChunk, object, hint, dirtyVertices, dirtyElements, dirtyUvs, dirtyNormals, dirtyTangents ) {
+	this.setMeshBuffers = function ( geometryChunk, object, hint, dirtyVertices, dirtyElements, dirtyUvs, dirtyNormals, dirtyTangents ) {
 
 
 		var f, fl, fi, face, vertexNormals, faceNormal, normal, uv, v1, v2, v3, v4, t1, t2, t3, t4, m, ml, i,
 		var f, fl, fi, face, vertexNormals, faceNormal, normal, uv, v1, v2, v3, v4, t1, t2, t3, t4, m, ml, i,
-			vertices, vn, uvi,
+			vn, uvi,
 		
 		
 		vertexIndex = 0,
 		vertexIndex = 0,
 
 
@@ -235,17 +224,20 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		
 		needsSmoothNormals = geometryChunk.__needsSmoothNormals,
 		needsSmoothNormals = geometryChunk.__needsSmoothNormals,
 		
 		
-		geometry = object.geometry;
+		geometry = object.geometry,
+		vertices = geometry.vertices,
+		chunk_faces = geometryChunk.faces,
+		obj_faces = geometry.faces,
+		obj_uvs = geometry.uvs;
 		
 		
-		for ( f = 0, fl = geometryChunk.faces.length; f < fl; f++ ) {
+		for ( f = 0, fl = chunk_faces.length; f < fl; f++ ) {
+			
+			fi = chunk_faces[ f ];
+			face = obj_faces[ fi ];
+			uv = obj_uvs[ fi ];
 			
 			
-			fi = geometryChunk.faces[ f ];
-
-			face = geometry.faces[ fi ];
 			vertexNormals = face.vertexNormals;
 			vertexNormals = face.vertexNormals;
 			faceNormal = face.normal;
 			faceNormal = face.normal;
-			uv = geometry.uvs[ fi ];
-			vertices = geometry.vertices;
 
 
 			if ( face instanceof THREE.Face3 ) {
 			if ( face instanceof THREE.Face3 ) {
 
 
@@ -552,6 +544,55 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.setLineBuffers = function( geometry, hint, dirtyVertices, dirtyElements ) {
+		
+		var v, vertex, offset,
+			vertices = geometry.vertices,
+			vl = vertices.length,
+		
+			vertexArray = geometry.__vertexArray, 
+			lineArray = geometry.__lineArray;
+		
+		if ( dirtyVertices ) {
+			
+			for ( v = 0; v < vl; v++ ) {
+				
+				vertex = vertices[ v ].position;
+				
+				offset = v * 3;
+				
+				vertexArray[ offset ]     = vertex.x;
+				vertexArray[ offset + 1 ] = vertex.y;
+				vertexArray[ offset + 2 ] = vertex.z;
+				
+			}
+
+		}
+		
+		// yeah, this is silly as order of element indices is currently fixed
+		// though this could change if some use case arises
+		
+		if ( dirtyElements ) {
+			
+			for ( v = 0; v < vl; v++ ) {
+				
+				lineArray[ v ] = v;
+				
+			}
+			
+		}
+
+		_gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer );
+		_gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint );
+		
+		_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometry.__webGLLineBuffer );
+		_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, lineArray, hint );
+		
+	};
+	
+	this.setParticleBuffers = function( geometry, hint, dirtyVertices, dirtyElements ) {
+	};
+	
 	function setMaterialShaders( material, shaders ) {
 	function setMaterialShaders( material, shaders ) {
 
 
 		material.fragment_shader = shaders.fragment_shader;
 		material.fragment_shader = shaders.fragment_shader;
@@ -642,7 +683,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		
 	};
 	};
 	
 	
-	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk ) {
+	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk, object ) {
 
 
 		var program, u, identifiers, attributes, parameters, vector_lights, maxLightCount, linewidth, primitives;
 		var program, u, identifiers, attributes, parameters, vector_lights, maxLightCount, linewidth, primitives;
 
 
@@ -800,7 +841,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			linewidth = material.wireframe_linewidth !== undefined ? material.wireframe_linewidth : 
 			linewidth = material.wireframe_linewidth !== undefined ? material.wireframe_linewidth : 
 					    material.linewidth !== undefined ? material.linewidth : 1;
 					    material.linewidth !== undefined ? material.linewidth : 1;
 			
 			
-			primitives = material instanceof THREE.LineBasicMaterial && geometryChunk.type == THREE.LineStrip ? _gl.LINE_STRIP : _gl.LINES;
+			primitives = material instanceof THREE.LineBasicMaterial && object.type == THREE.LineStrip ? _gl.LINE_STRIP : _gl.LINES;
 			
 			
 			_gl.lineWidth( linewidth );
 			_gl.lineWidth( linewidth );
 			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer );
 			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer );
@@ -834,7 +875,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 
 						this.setBlending( material.blending );
 						this.setBlending( material.blending );
-						this.renderBuffer( camera, lights, fog, material, geometryChunk );
+						this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
 
 
 					}
 					}
 
 
@@ -846,7 +887,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 				if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 				if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 
 					this.setBlending( material.blending );
 					this.setBlending( material.blending );
-					this.renderBuffer( camera, lights, fog, material, geometryChunk );
+					this.renderBuffer( camera, lights, fog, material, geometryChunk, object );
 
 
 				}
 				}
 
 
@@ -973,8 +1014,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 					if( ! geometryChunk.__webGLVertexBuffer ) {
 					if( ! geometryChunk.__webGLVertexBuffer ) {
 
 
-						this.createBuffers( geometryChunk );
-						this.initBuffers( geometryChunk, object );
+						this.createMeshBuffers( geometryChunk );
+						this.initMeshBuffers( geometryChunk, object );
 						
 						
 						geometry.__dirtyVertices = true;
 						geometry.__dirtyVertices = true;
 						geometry.__dirtyElements = true;
 						geometry.__dirtyElements = true;
@@ -986,7 +1027,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 					if( geometry.__dirtyVertices || geometry.__dirtyElements || geometry.__dirtyUvs ) {
 					if( geometry.__dirtyVertices || geometry.__dirtyElements || geometry.__dirtyUvs ) {
 
 
-						this.setBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW, 
+						this.setMeshBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW,
 										 geometry.__dirtyVertices, geometry.__dirtyElements, geometry.__dirtyUvs,
 										 geometry.__dirtyVertices, geometry.__dirtyElements, geometry.__dirtyUvs,
 										 geometry.__dirtyNormals, geometry.__dirtyTangents );
 										 geometry.__dirtyNormals, geometry.__dirtyTangents );
 						
 						
@@ -1008,24 +1049,36 @@ THREE.WebGLRenderer = function ( parameters ) {
 			} else if ( object instanceof THREE.Line ) {
 			} else if ( object instanceof THREE.Line ) {
 				
 				
 				
 				
-				if( ! object.__webGLVertexBuffer ) {
+				if( ! geometry.__webGLVertexBuffer ) {
 				
 				
-					this.createLineBuffers( object );
+					this.createLineBuffers( geometry );
+					this.initLineBuffers( geometry );
+					
+					geometry.__dirtyVertices = true;
+					geometry.__dirtyElements = true;
 					
 					
 				}
 				}
 				
 				
-				add_buffer( objmap, 0, object, object );
+				if( geometry.__dirtyVertices ) {
+					
+					this.setLineBuffers( geometry, _gl.DYNAMIC_DRAW, geometry.__dirtyVertices, geometry.__dirtyElements );
+					
+				}
 				
 				
+				add_buffer( objmap, 0, geometry, object );
+				
+				geometry.__dirtyVertices = false;
+				geometry.__dirtyElements = false;
 
 
 			} else if ( object instanceof THREE.ParticleSystem ) {
 			} else if ( object instanceof THREE.ParticleSystem ) {
 
 
-				if( ! object.__webGLVertexBuffer ) {
+				if( ! geometry.__webGLVertexBuffer ) {
 				
 				
-					this.createParticleBuffers( object );
+					this.createParticleBuffers( geometry );
 					
 					
 				}
 				}
 				
 				
-				add_buffer( objmap, 0, object, object );
+				add_buffer( objmap, 0, geometry, object );
 				
 				
 				
 				
 			}/*else if ( object instanceof THREE.Particle ) {
 			}/*else if ( object instanceof THREE.Particle ) {

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