Browse Source

Fixed `Projector::projectObjects`.

Mr.doob 14 years ago
parent
commit
fca3aec67d
5 changed files with 350 additions and 338 deletions
  1. 118 118
      build/Three.js
  2. 119 119
      build/ThreeDebug.js
  3. 97 97
      build/ThreeExtras.js
  4. 5 4
      src/renderers/Projector.js
  5. 11 0
      src/renderers/WebGLRenderer2.js

+ 118 - 118
build/Three.js

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

+ 119 - 119
build/ThreeDebug.js

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

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


+ 5 - 4
src/renderers/Projector.js

@@ -12,7 +12,6 @@ THREE.Projector = function() {
 	_line, _lineCount, _linePool = [],
 	_line, _lineCount, _linePool = [],
 	_particle, _particleCount, _particlePool = [],
 	_particle, _particleCount, _particlePool = [],
 
 
-	_vector3 = new THREE.Vector3(),
 	_vector4 = new THREE.Vector4(),
 	_vector4 = new THREE.Vector4(),
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenObjectMatrix = new THREE.Matrix4(),
 	_projScreenObjectMatrix = new THREE.Matrix4(),
@@ -24,11 +23,13 @@ THREE.Projector = function() {
 
 
 	this.projectObjects = function ( scene, camera ) {
 	this.projectObjects = function ( scene, camera ) {
 
 
-		var o, ol, v, vl, f, fl, n, nl, objects, object;
+		var o, ol, objects, object;
 
 
 		_renderList = [];
 		_renderList = [];
 		_objectCount = 0;
 		_objectCount = 0;
 
 
+		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix );
+
 		objects = scene.objects;
 		objects = scene.objects;
 
 
 		for ( o = 0, ol = objects.length; o < ol; o++ ) {
 		for ( o = 0, ol = objects.length; o < ol; o++ ) {
@@ -41,10 +42,10 @@ THREE.Projector = function() {
 
 
 			_vector4.copy( object.position );
 			_vector4.copy( object.position );
 			_projScreenMatrix.multiplyVector4( _vector4 );
 			_projScreenMatrix.multiplyVector4( _vector4 );
-			_vector4.multiplyScalar( 1 / _vector4.w );
+			// _vector4.multiplyScalar( 1 / _vector4.w );
 
 
 			_object.object = object;
 			_object.object = object;
-			_object.z = _vector3.z;
+			_object.z = _vector4.z;
 
 
 			_renderList.push( _object );
 			_renderList.push( _object );
 
 

+ 11 - 0
src/renderers/WebGLRenderer2.js

@@ -73,6 +73,16 @@ THREE.WebGLRenderer2 = function () {
 		_viewMatrixArray.set( camera.matrix.flatten() );
 		_viewMatrixArray.set( camera.matrix.flatten() );
 		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 
 
+		/*
+		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
+
+			object = scene.objects[ o ];
+
+			renderObject( object );
+
+		}
+		*/
+
 		_renderList = _projector.projectObjects( scene, camera );
 		_renderList = _projector.projectObjects( scene, camera );
 
 
 		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
 		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
@@ -83,6 +93,7 @@ THREE.WebGLRenderer2 = function () {
 
 
 		}
 		}
 
 
+
 		function renderObject( object ) {
 		function renderObject( object ) {
 
 
 			var geometry, material, m, nl,
 			var geometry, material, m, nl,

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