Browse Source

Fixed implied globals in WebGLRenderer lights rgb init.

alteredq 14 years ago
parent
commit
a8416bc8c1
4 changed files with 419 additions and 419 deletions
  1. 137 137
      build/Three.js
  2. 138 138
      build/ThreeDebug.js
  3. 143 143
      build/ThreeExtras.js
  4. 1 1
      src/renderers/WebGLRenderer.js

+ 137 - 137
build/Three.js

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

+ 138 - 138
build/ThreeDebug.js

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

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


+ 1 - 1
src/renderers/WebGLRenderer.js

@@ -73,7 +73,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.setupLights = function ( program, lights ) {
 
-		var l, ll, light, r = g = b = 0,
+		var l, ll, light, r = 0, g = 0, b = 0,
 			dcolors = [], dpositions = [],
 			pcolors = [], ppositions = [];
 

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