浏览代码

ReflectionMapping working with MeshBasicMaterial/CanvasRenderer \:D/
TODO: Add computeVertexNormals on geometry so any object can use it.

Mr.doob 14 年之前
父节点
当前提交
1d7a14733b

+ 49 - 47
build/Three.js

@@ -5,9 +5,10 @@ THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this
 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,d){this.x=a||0;this.y=b||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;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,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-b*a.z;this.z=b*a.y-d*a.x;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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,
-0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1};
+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,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-b*a.z;this.z=b*a.y-d*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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
+Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
+THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1};
 THREE.Vector4.prototype={set:function(a,b,d,g){this.x=a;this.y=b;this.z=d;this.w=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
@@ -21,8 +22,8 @@ THREE.Matrix4=function(){};
 THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,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},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},lookAt:function(a,b,d){var g=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();g.cross(d,n).normalize();h.cross(n,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=n.x;this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var b=a.x,d=a.y,g=a.z,h=1/(this.n41*b+this.n42*
 d+this.n43*g+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*g+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*h;return a},transformVector4:function(a){var b=a.x,d=a.y,g=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*g+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 d=a.n11,g=a.n12,h=a.n13,n=a.n14,m=a.n21,q=a.n22,l=a.n23,c=a.n24,y=a.n31,G=a.n32,w=a.n33,F=a.n34,N=a.n41,J=a.n42,M=a.n43,r=a.n44,R=b.n11,B=b.n12,e=b.n13,f=b.n14,i=b.n21,o=b.n22,k=b.n23,j=b.n24,A=b.n31,s=b.n32,L=b.n33,u=b.n34,U=b.n41,P=b.n42,t=b.n43,
-H=b.n44;this.n11=d*R+g*i+h*A+n*U;this.n12=d*B+g*o+h*s+n*P;this.n13=d*e+g*k+h*L+n*t;this.n14=d*f+g*j+h*u+n*H;this.n21=m*R+q*i+l*A+c*U;this.n22=m*B+q*o+l*s+c*P;this.n23=m*e+q*k+l*L+c*t;this.n24=m*f+q*j+l*u+c*H;this.n31=y*R+G*i+w*A+F*U;this.n32=y*B+G*o+w*s+F*P;this.n33=y*e+G*k+w*L+F*t;this.n34=y*f+G*j+w*u+F*H;this.n41=N*R+J*i+M*A+r*U;this.n42=N*B+J*o+M*s+r*P;this.n43=N*e+J*k+M*L+r*t;this.n44=N*f+J*j+M*u+r*H},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,h=this.n14,n=this.n21,m=this.n22,
+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 d=a.n11,g=a.n12,h=a.n13,n=a.n14,m=a.n21,q=a.n22,l=a.n23,c=a.n24,y=a.n31,G=a.n32,w=a.n33,F=a.n34,N=a.n41,J=a.n42,M=a.n43,r=a.n44,R=b.n11,B=b.n12,e=b.n13,f=b.n14,i=b.n21,o=b.n22,k=b.n23,j=b.n24,A=b.n31,s=b.n32,L=b.n33,u=b.n34,T=b.n41,P=b.n42,t=b.n43,
+H=b.n44;this.n11=d*R+g*i+h*A+n*T;this.n12=d*B+g*o+h*s+n*P;this.n13=d*e+g*k+h*L+n*t;this.n14=d*f+g*j+h*u+n*H;this.n21=m*R+q*i+l*A+c*T;this.n22=m*B+q*o+l*s+c*P;this.n23=m*e+q*k+l*L+c*t;this.n24=m*f+q*j+l*u+c*H;this.n31=y*R+G*i+w*A+F*T;this.n32=y*B+G*o+w*s+F*P;this.n33=y*e+G*k+w*L+F*t;this.n34=y*f+G*j+w*u+F*H;this.n41=N*R+J*i+M*A+r*T;this.n42=N*B+J*o+M*s+r*P;this.n43=N*e+J*k+M*L+r*t;this.n44=N*f+J*j+M*u+r*H},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,h=this.n14,n=this.n21,m=this.n22,
 q=this.n23,l=this.n24,c=this.n31,y=this.n32,G=this.n33,w=this.n34,F=this.n41,N=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+h*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+h*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+h*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+h*a.n44;this.n21=n*a.n11+m*a.n21+q*a.n31+l*a.n41;this.n22=n*a.n12+m*a.n22+q*a.n32+l*a.n42;this.n23=n*a.n13+m*a.n23+q*a.n33+l*a.n43;this.n24=n*a.n14+m*a.n24+q*a.n34+l*a.n44;this.n31=c*a.n11+y*a.n21+G*a.n31+w*a.n41;this.n32=c*a.n12+y*a.n22+
 G*a.n32+w*a.n42;this.n33=c*a.n13+y*a.n23+G*a.n33+w*a.n43;this.n34=c*a.n14+y*a.n24+G*a.n34+w*a.n44;this.n41=F*a.n11+N*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+N*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+N*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+N*a.n24+J*a.n34+M*a.n44},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},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*
@@ -83,47 +84,48 @@ THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function()
 THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){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.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(R,B){var e=0,f=1,i=R.z+R.w,o=B.z+B.w,k=-R.z+R.w,j=-B.z+B.w;if(i>=0&&o>=0&&k>=0&&j>=0)return true;else if(i<0&&o<0||k<0&&j<0)return false;else{if(i<0)e=Math.max(e,i/(i-o));else if(o<0)f=Math.min(f,i/(i-o));if(k<0)e=Math.max(e,k/(k-j));else if(j<0)f=Math.min(f,k/(k-j));if(f<e)return false;else{R.lerpSelf(B,e);B.lerpSelf(R,1-f);return true}}}var b=null,d,g,h,n=[],m,q,l=[],c,y,G=[],w=new THREE.Vector4,F=new THREE.Matrix4,N=new THREE.Matrix4,J=new THREE.Vector4,M=
-new THREE.Vector4,r;this.projectScene=function(R,B){var e,f,i,o,k,j,A,s,L,u,U,P,t,H,p,z,x;b=[];h=q=y=0;B.autoUpdateMatrix&&B.updateMatrix();F.multiply(B.projectionMatrix,B.matrix);A=R.objects;e=0;for(f=A.length;e<f;e++){s=A[e];s.autoUpdateMatrix&&s.updateMatrix();L=s.matrix;u=s.rotationMatrix;U=s.material;P=s.overdraw;if(s instanceof THREE.Mesh){t=s.geometry.vertices;i=0;for(o=t.length;i<o;i++){H=t[i];H.positionWorld.copy(H.position);L.transformVector3(H.positionWorld);p=H.positionScreen;p.copy(H.positionWorld);
+new THREE.Vector4,r;this.projectScene=function(R,B){var e,f,i,o,k,j,A,s,L,u,T,P,t,H,p,z,x;b=[];h=q=y=0;B.autoUpdateMatrix&&B.updateMatrix();F.multiply(B.projectionMatrix,B.matrix);A=R.objects;e=0;for(f=A.length;e<f;e++){s=A[e];s.autoUpdateMatrix&&s.updateMatrix();L=s.matrix;u=s.rotationMatrix;T=s.material;P=s.overdraw;if(s instanceof THREE.Mesh){t=s.geometry.vertices;i=0;for(o=t.length;i<o;i++){H=t[i];H.positionWorld.copy(H.position);L.transformVector3(H.positionWorld);p=H.positionScreen;p.copy(H.positionWorld);
 F.transformVector4(p);p.multiplyScalar(1/p.w);H.__visible=p.z>0&&p.z<1}H=s.geometry.faces;i=0;for(o=H.length;i<o;i++){p=H[i];if(p instanceof THREE.Face3){k=t[p.a];j=t[p.b];z=t[p.c];if(k.__visible&&j.__visible&&z.__visible)if(s.doubleSided||s.flipSided!=(z.positionScreen.x-k.positionScreen.x)*(j.positionScreen.y-k.positionScreen.y)-(z.positionScreen.y-k.positionScreen.y)*(j.positionScreen.x-k.positionScreen.x)<0){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(k.positionWorld);d.v2.positionWorld.copy(j.positionWorld);
 d.v3.positionWorld.copy(z.positionWorld);d.v1.positionScreen.copy(k.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(z.positionScreen);d.normalWorld.copy(p.normal);u.transformVector3(d.normalWorld);d.centroidWorld.copy(p.centroid);L.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);F.transformVector3(d.centroidScreen);z=p.vertexNormals;r=d.vertexNormalsWorld;k=0;for(j=z.length;k<j;k++){x=r[k]=r[k]||new THREE.Vector3;x.copy(z[k]);u.transformVector3(x)}d.z=
-d.centroidScreen.z;d.meshMaterial=U;d.faceMaterial=p.material;d.overdraw=P;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][2]}b.push(d);h++}}else if(p instanceof THREE.Face4){k=t[p.a];j=t[p.b];z=t[p.c];x=t[p.d];if(k.__visible&&j.__visible&&z.__visible&&x.__visible)if(s.doubleSided||s.flipSided!=((x.positionScreen.x-k.positionScreen.x)*(j.positionScreen.y-k.positionScreen.y)-(x.positionScreen.y-k.positionScreen.y)*(j.positionScreen.x-k.positionScreen.x)<
+d.centroidScreen.z;d.meshMaterial=T;d.faceMaterial=p.material;d.overdraw=P;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][2]}b.push(d);h++}}else if(p instanceof THREE.Face4){k=t[p.a];j=t[p.b];z=t[p.c];x=t[p.d];if(k.__visible&&j.__visible&&z.__visible&&x.__visible)if(s.doubleSided||s.flipSided!=((x.positionScreen.x-k.positionScreen.x)*(j.positionScreen.y-k.positionScreen.y)-(x.positionScreen.y-k.positionScreen.y)*(j.positionScreen.x-k.positionScreen.x)<
 0||(j.positionScreen.x-z.positionScreen.x)*(x.positionScreen.y-z.positionScreen.y)-(j.positionScreen.y-z.positionScreen.y)*(x.positionScreen.x-z.positionScreen.x)<0)){d=n[h]=n[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(k.positionWorld);d.v2.positionWorld.copy(j.positionWorld);d.v3.positionWorld.copy(x.positionWorld);d.v1.positionScreen.copy(k.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(x.positionScreen);d.normalWorld.copy(p.normal);u.transformVector3(d.normalWorld);
-d.centroidWorld.copy(p.centroid);L.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);F.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=U;d.faceMaterial=p.material;d.overdraw=P;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][3]}b.push(d);h++;g=n[h]=n[h]||new THREE.RenderableFace3;g.v1.positionWorld.copy(j.positionWorld);g.v2.positionWorld.copy(z.positionWorld);g.v3.positionWorld.copy(x.positionWorld);
-g.v1.positionScreen.copy(j.positionScreen);g.v2.positionScreen.copy(z.positionScreen);g.v3.positionScreen.copy(x.positionScreen);g.normalWorld.copy(d.normalWorld);g.centroidWorld.copy(d.centroidWorld);g.centroidScreen.copy(d.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterial=U;g.faceMaterial=p.material;g.overdraw=P;if(s.geometry.uvs[i]){g.uvs[0]=s.geometry.uvs[i][1];g.uvs[1]=s.geometry.uvs[i][2];g.uvs[2]=s.geometry.uvs[i][3]}b.push(g);h++}}}}else if(s instanceof THREE.Line){N.multiply(F,L);t=s.geometry.vertices;
+d.centroidWorld.copy(p.centroid);L.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);F.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=T;d.faceMaterial=p.material;d.overdraw=P;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][3]}b.push(d);h++;g=n[h]=n[h]||new THREE.RenderableFace3;g.v1.positionWorld.copy(j.positionWorld);g.v2.positionWorld.copy(z.positionWorld);g.v3.positionWorld.copy(x.positionWorld);
+g.v1.positionScreen.copy(j.positionScreen);g.v2.positionScreen.copy(z.positionScreen);g.v3.positionScreen.copy(x.positionScreen);g.normalWorld.copy(d.normalWorld);g.centroidWorld.copy(d.centroidWorld);g.centroidScreen.copy(d.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterial=T;g.faceMaterial=p.material;g.overdraw=P;if(s.geometry.uvs[i]){g.uvs[0]=s.geometry.uvs[i][1];g.uvs[1]=s.geometry.uvs[i][2];g.uvs[2]=s.geometry.uvs[i][3]}b.push(g);h++}}}}else if(s instanceof THREE.Line){N.multiply(F,L);t=s.geometry.vertices;
 H=t[0];H.positionScreen.copy(H.position);N.transformVector4(H.positionScreen);i=1;for(o=t.length;i<o;i++){k=t[i];k.positionScreen.copy(k.position);N.transformVector4(k.positionScreen);j=t[i-1];J.copy(k.positionScreen);M.copy(j.positionScreen);if(a(J,M)){J.multiplyScalar(1/J.w);M.multiplyScalar(1/M.w);m=l[q]=l[q]||new THREE.RenderableLine;m.v1.positionScreen.copy(J);m.v2.positionScreen.copy(M);m.z=Math.max(J.z,M.z);m.material=s.material;b.push(m);q++}}}else if(s instanceof THREE.Particle){w.set(s.position.x,
-s.position.y,s.position.z,1);F.transformVector4(w);w.z/=w.w;if(w.z>0&&w.z<1){c=G[y]=G[y]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(w.x+B.projectionMatrix.n11)/(w.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(w.y+B.projectionMatrix.n22)/(w.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);y++}}}b.sort(function(O,E){return E.z-O.z});return b};this.unprojectVector=function(R,B){var e=new THREE.Matrix4;
+s.position.y,s.position.z,1);F.transformVector4(w);w.z/=w.w;if(w.z>0&&w.z<1){c=G[y]=G[y]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(w.x+B.projectionMatrix.n11)/(w.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(w.y+B.projectionMatrix.n22)/(w.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);y++}}}b.sort(function(O,D){return D.z-O.z});return b};this.unprojectVector=function(R,B){var e=new THREE.Matrix4;
 e.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));e.transformVector3(R);return R}};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,h,n;this.domElement=document.createElement("div");this.setSize=function(m,q){d=m;g=q;h=d/2;n=g/2};this.render=function(m,q){var l,c,y,G,w,F,N,J;a=b.projectScene(m,q);l=0;for(c=a.length;l<c;l++){w=a[l];if(w instanceof THREE.RenderableParticle){N=w.x*h+h;J=w.y*n+n;y=0;for(G=w.material.length;y<G;y++){F=w.material[y];if(F instanceof THREE.ParticleDOMMaterial){F=F.domElement;F.style.left=N+"px";F.style.top=J+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(I,Y,V,C){var v,K,$,S,X=I.lights;I=0;for(v=X.length;I<v;I++){K=X[I];$=K.color;S=K.intensity;if(K instanceof THREE.DirectionalLight){K=V.dot(K.position)*S;if(K>0){C.r+=$.r*K;C.g+=$.g*K;C.b+=$.b*K}}else if(K instanceof THREE.PointLight){sa.sub(K.position,Y);sa.normalize();K=V.dot(sa)*S;if(K>0){C.r+=$.r*K;C.g+=$.g*K;C.b+=$.b*K}}}}function b(I,Y,V,C,v,K){if(v.opacity!=0){n(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;U=Y.positionScreen.x;
-P=Y.positionScreen.y;t=V.positionScreen.x;H=V.positionScreen.y;var $=L,S=u,X=U,aa=P,Z=t,ca=H;r.beginPath();r.moveTo($,S);r.lineTo(X,aa);r.lineTo(Z,ca);r.lineTo($,S);r.closePath();if(v instanceof THREE.MeshBasicMaterial){if(v.map&&v.map.loaded)h(L,u,U,P,t,H,v.map.image,C.uvs[0].u,C.uvs[0].v,C.uvs[1].u,C.uvs[1].v,C.uvs[2].u,C.uvs[2].v);else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);v.env_map&&v.env_map.loaded&&v.env_map.mapping==THREE.ReflectionMapping&&h(L,
-u,U,P,t,H,v.env_map.image,C.vertexNormalsWorld[0].x*0.5+0.5,C.vertexNormalsWorld[0].y*0.5+0.5,C.vertexNormalsWorld[1].x*0.5+0.5,C.vertexNormalsWorld[1].y*0.5+0.5,C.vertexNormalsWorld[2].x*0.5+0.5,C.vertexNormalsWorld[2].y*0.5+0.5)}else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){h(L,u,U,P,t,H,v.map.image,C.uvs[0].u,C.uvs[0].v,C.uvs[1].u,C.uvs[1].v,C.uvs[2].u,C.uvs[2].v);m(THREE.SubtractiveBlending)}if(ta)if(!v.wireframe&&v.shading==THREE.SmoothShading&&C.vertexNormalsWorld.length==
-3){z.r=x.r=O.r=ga.r;z.g=x.g=O.g=ga.g;z.b=x.b=O.b=ga.b;a(K,C.v1.positionWorld,C.vertexNormalsWorld[0],z);a(K,C.v2.positionWorld,C.vertexNormalsWorld[1],x);a(K,C.v3.positionWorld,C.vertexNormalsWorld[2],O);E.r=(x.r+O.r)*0.5;E.g=(x.g+O.g)*0.5;E.b=(x.b+O.b)*0.5;Q=q(z,x,O,E);h(L,u,U,P,t,H,Q,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,C.centroidWorld,C.normalWorld,ha);p.r=v.color.r*ha.r;p.g=v.color.g*ha.g;p.b=v.color.b*ha.b;p.updateStyleString();v.wireframe?d(p.__styleString,v.wireframe_linewidth):
-g(p.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){D=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;z.r=z.g=z.b=1-D/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-D/(W-Y.positionScreen.z*ea);O.r=O.g=O.b=1-D/(W-V.positionScreen.z*ea);E.r=(x.r+O.r)*0.5;E.g=(x.g+O.g)*0.5;E.b=(x.b+O.b)*0.5;Q=q(z,x,O,E);h(L,u,U,P,t,H,Q,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){p.r=l(C.normalWorld.x);p.g=l(C.normalWorld.y);
-p.b=l(C.normalWorld.z);p.updateStyleString();v.wireframe?d(p.__styleString,v.wireframe_linewidth):g(p.__styleString)}}}function d(I,Y){if(e!=I)r.strokeStyle=e=I;if(i!=Y)r.lineWidth=i=Y;r.stroke();da.inflate(Y*2)}function g(I){if(f!=I)r.fillStyle=f=I;r.fill()}function h(I,Y,V,C,v,K,$,S,X,aa,Z,ca,ka){var ja,fa;ja=$.width-1;fa=$.height-1;S*=ja;X*=fa;aa*=ja;Z*=fa;ca*=ja;ka*=fa;V-=I;C-=Y;v-=I;K-=Y;aa-=S;Z-=X;ca-=S;ka-=X;fa=1/(aa*ka-ca*Z);ja=(ka*V-Z*v)*fa;Z=(ka*C-Z*K)*fa;V=(aa*v-ca*V)*fa;C=(aa*K-ca*C)*
-fa;I=I-ja*S-V*X;Y=Y-Z*S-C*X;r.save();r.transform(ja,Z,V,C,I,Y);r.clip();r.drawImage($,0,0);r.restore()}function n(I){if(R!=I)r.globalAlpha=R=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:r.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:r.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:r.globalCompositeOperation="darker"}B=I}}function q(I,Y,V,C){ia[0]=k(0,o(255,~~(I.r*255)));ia[1]=k(0,o(255,~~(I.g*255)));ia[2]=k(0,o(255,~~(I.b*255)));
-ia[4]=k(0,o(255,~~(Y.r*255)));ia[5]=k(0,o(255,~~(Y.g*255)));ia[6]=k(0,o(255,~~(Y.b*255)));ia[8]=k(0,o(255,~~(V.r*255)));ia[9]=k(0,o(255,~~(V.g*255)));ia[10]=k(0,o(255,~~(V.b*255)));ia[12]=k(0,o(255,~~(C.r*255)));ia[13]=k(0,o(255,~~(C.g*255)));ia[14]=k(0,o(255,~~(C.b*255)));oa.putImageData(ua,0,0);ra.drawImage(pa,0,0);return qa}function l(I){return I<0?o((1+I)*0.5,0.5):0.5+o(I*0.5,0.5)}function c(I,Y){var V=Y.x-I.x,C=Y.y-I.y,v=1/Math.sqrt(V*V+C*C);V*=v;C*=v;Y.x+=V;Y.y+=C;I.x-=V;I.y-=C}var y=null,G=
-new THREE.Projector,w=document.createElement("canvas"),F,N,J,M,r=w.getContext("2d"),R=1,B=0,e=null,f=null,i=1,o=Math.min,k=Math.max,j,A,s,L,u,U,P,t,H,p=new THREE.Color,z=new THREE.Color,x=new THREE.Color,O=new THREE.Color,E=new THREE.Color,D,W,ea,Q,T=new THREE.Rectangle,ba=new THREE.Rectangle,da=new THREE.Rectangle,ta=false,ha=new THREE.Color,ga=new THREE.Color,la=new THREE.Color,ma=new THREE.Color,xa=Math.PI*2,sa=new THREE.Vector3,pa,oa,ua,ia,qa,ra,na=16;pa=document.createElement("canvas");pa.width=
-pa.height=2;oa=pa.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);ua=oa.getImageData(0,0,2,2);ia=ua.data;qa=document.createElement("canvas");qa.width=qa.height=na;ra=qa.getContext("2d");ra.translate(-na/2,-na/2);ra.scale(na,na);na--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;N=Y;J=F/2;M=N/2;w.width=F;w.height=N;T.set(-J,-M,J,M)};this.clear=function(){if(!ba.isEmpty()){ba.inflate(1);ba.minSelf(T);r.clearRect(ba.getX(),ba.getY(),ba.getWidth(),ba.getHeight());
-ba.empty()}};this.render=function(I,Y){var V,C,v,K,$,S,X,aa;r.setTransform(1,0,0,-1,J,M);this.autoClear&&this.clear();y=G.projectScene(I,Y);if(ta=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);la.setRGB(0,0,0);ma.setRGB(0,0,0);V=0;for(C=$.length;V<C;V++){v=$[V];K=v.color;if(v instanceof THREE.AmbientLight){ga.r+=K.r;ga.g+=K.g;ga.b+=K.b}else if(v instanceof THREE.DirectionalLight){la.r+=K.r;la.g+=K.g;la.b+=K.b}else if(v instanceof THREE.PointLight){ma.r+=K.r;ma.g+=K.g;ma.b+=K.b}}}V=0;for(C=y.length;V<
-C;V++){v=y[V];da.empty();if(v instanceof THREE.RenderableParticle){j=v;j.x*=J;j.y*=M;K=0;for($=v.material.length;K<$;K++){S=j;X=v;var Z=v.material[K];if(Z.opacity!=0){n(Z.opacity);m(Z.blending);aa=void 0;var ca=void 0,ka=void 0,ja=void 0,fa=void 0,va=void 0,wa=void 0;if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){fa=Z.map;va=fa.width>>1;wa=fa.height>>1;ka=X.scale.x*J;ja=X.scale.y*M;aa=ka*va;ca=ja*wa;da.set(S.x-aa,S.y-ca,S.x+aa,S.y+ca);if(T.instersects(da)){r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);
-r.scale(ka,-ja);r.translate(-va,-wa);r.drawImage(fa,0,0);r.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(ta){ha.r=ga.r+la.r+ma.r;ha.g=ga.g+la.g+ma.g;ha.b=ga.b+la.b+ma.b;p.r=Z.color.r*ha.r;p.g=Z.color.g*ha.g;p.b=Z.color.b*ha.b;p.updateStyleString()}else p.__styleString=Z.color.__styleString;aa=X.scale.x*J;ca=X.scale.y*M;da.set(S.x-aa,S.y-ca,S.x+aa,S.y+ca);if(T.instersects(da)){Z=p.__styleString;if(f!=Z)r.fillStyle=f=Z;r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);r.scale(aa,
-ca);r.beginPath();r.arc(0,0,1,0,xa,true);r.closePath();r.fill();r.restore()}}}}}else if(v instanceof THREE.RenderableLine){j=v.v1;A=v.v2;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);if(T.instersects(da)){K=0;for($=v.material.length;K<$;){X=j;aa=A;S=v.material[K++];if(S.opacity!=0){n(S.opacity);m(S.blending);r.beginPath();r.moveTo(X.positionScreen.x,X.positionScreen.y);
-r.lineTo(aa.positionScreen.x,aa.positionScreen.y);r.closePath();if(S instanceof THREE.LineBasicMaterial){p.__styleString=S.color.__styleString;X=S.linewidth;if(i!=X)r.lineWidth=i=X;X=p.__styleString;if(e!=X)r.strokeStyle=e=X;r.stroke();da.inflate(S.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){j=v.v1;A=v.v2;s=v.v3;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;s.positionScreen.x*=J;s.positionScreen.y*=M;if(v.overdraw){c(j.positionScreen,A.positionScreen);
-c(A.positionScreen,s.positionScreen);c(s.positionScreen,j.positionScreen)}da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);da.addPoint(s.positionScreen.x,s.positionScreen.y);if(T.instersects(da)){K=0;for($=v.meshMaterial.length;K<$;){aa=v.meshMaterial[K++];if(aa instanceof THREE.MeshFaceMaterial){S=0;for(X=v.faceMaterial.length;S<X;)(aa=v.faceMaterial[S++])&&b(j,A,s,v,aa,I)}else b(j,A,s,v,aa,I)}}}ba.addRectangle(da)}r.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(p,z,x){var O,E,D,W;O=0;for(E=p.lights.length;O<E;O++){D=p.lights[O];if(D instanceof THREE.DirectionalLight){W=z.normalWorld.dot(D.position)*D.intensity;if(W>0){x.r+=D.color.r*W;x.g+=D.color.g*W;x.b+=D.color.b*W}}else if(D instanceof THREE.PointLight){j.sub(D.position,z.centroidWorld);j.normalize();W=z.normalWorld.dot(j)*D.intensity;if(W>0){x.r+=D.color.r*W;x.g+=D.color.g*W;x.b+=D.color.b*W}}}}function b(p,z,x,O,E,D){u=g(U++);u.setAttribute("d","M "+p.positionScreen.x+
-" "+p.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)B.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(D,O,e);B.r=E.color.r*e.r;B.g=E.color.g*e.g;B.b=E.color.b*e.b;B.updateStyleString()}else B.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){k=1-E.__2near/(E.__farPlusNear-O.z*E.__farMinusNear);
-B.setRGB(k,k,k)}else E instanceof THREE.MeshNormalMaterial&&B.setRGB(h(O.normalWorld.x),h(O.normalWorld.y),h(O.normalWorld.z));E.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+E.opacity);q.appendChild(u)}function d(p,z,x,O,E,D,W){u=g(U++);u.setAttribute("d",
-"M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(W,E,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){k=
-1-D.__2near/(D.__farPlusNear-E.z*D.__farMinusNear);B.setRGB(k,k,k)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(h(E.normalWorld.x),h(E.normalWorld.y),h(E.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);q.appendChild(u)}
+THREE.CanvasRenderer=function(){function a(I,Y,U,E){var v,K,$,S,X=I.lights;I=0;for(v=X.length;I<v;I++){K=X[I];$=K.color;S=K.intensity;if(K instanceof THREE.DirectionalLight){K=U.dot(K.position)*S;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}else if(K instanceof THREE.PointLight){aa.sub(K.position,Y);aa.normalize();K=U.dot(aa)*S;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}}}function b(I,Y,U,E,v,K){if(v.opacity!=0){n(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;T=Y.positionScreen.x;
+P=Y.positionScreen.y;t=U.positionScreen.x;H=U.positionScreen.y;var $=L,S=u,X=T,ba=P,Z=t,ca=H;r.beginPath();r.moveTo($,S);r.lineTo(X,ba);r.lineTo(Z,ca);r.lineTo($,S);r.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)h(L,u,T,P,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(E.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+
+aa.z*camera.matrix.n13)*0.5+0.5;ja=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[1]);za=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Aa=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[2]);Ba=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Ca=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*
+0.5+0.5;h(L,u,T,P,t,H,v.env_map.image,V,ja,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){h(L,u,T,P,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){z.r=x.r=O.r=ga.r;z.g=x.g=O.g=ga.g;z.b=x.b=O.b=ga.b;a(K,E.v1.positionWorld,
+E.vertexNormalsWorld[0],z);a(K,E.v2.positionWorld,E.vertexNormalsWorld[1],x);a(K,E.v3.positionWorld,E.vertexNormalsWorld[2],O);D.r=(x.r+O.r)*0.5;D.g=(x.g+O.g)*0.5;D.b=(x.b+O.b)*0.5;Q=q(z,x,O,D);h(L,u,T,P,t,H,Q,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,E.centroidWorld,E.normalWorld,ha);p.r=v.color.r*ha.r;p.g=v.color.g*ha.g;p.b=v.color.b*ha.b;p.updateStyleString();v.wireframe?d(p.__styleString,v.wireframe_linewidth):g(p.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):
+g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){C=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;z.r=z.g=z.b=1-C/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-C/(W-Y.positionScreen.z*ea);O.r=O.g=O.b=1-C/(W-U.positionScreen.z*ea);D.r=(x.r+O.r)*0.5;D.g=(x.g+O.g)*0.5;D.b=(x.b+O.b)*0.5;Q=q(z,x,O,D);h(L,u,T,P,t,H,Q,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){p.r=l(E.normalWorld.x);p.g=l(E.normalWorld.y);p.b=l(E.normalWorld.z);p.updateStyleString();v.wireframe?d(p.__styleString,
+v.wireframe_linewidth):g(p.__styleString)}}}function d(I,Y){if(e!=I)r.strokeStyle=e=I;if(i!=Y)r.lineWidth=i=Y;r.stroke();da.inflate(Y*2)}function g(I){if(f!=I)r.fillStyle=f=I;r.fill()}function h(I,Y,U,E,v,K,$,S,X,ba,Z,ca,la){var ka,fa;ka=$.width-1;fa=$.height-1;S*=ka;X*=fa;ba*=ka;Z*=fa;ca*=ka;la*=fa;U-=I;E-=Y;v-=I;K-=Y;ba-=S;Z-=X;ca-=S;la-=X;fa=1/(ba*la-ca*Z);ka=(la*U-Z*v)*fa;Z=(la*E-Z*K)*fa;U=(ba*v-ca*U)*fa;E=(ba*K-ca*E)*fa;I=I-ka*S-U*X;Y=Y-Z*S-E*X;r.save();r.transform(ka,Z,U,E,I,Y);r.clip();r.drawImage($,
+0,0);r.restore()}function n(I){if(R!=I)r.globalAlpha=R=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:r.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:r.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:r.globalCompositeOperation="darker"}B=I}}function q(I,Y,U,E){ia[0]=k(0,o(255,~~(I.r*255)));ia[1]=k(0,o(255,~~(I.g*255)));ia[2]=k(0,o(255,~~(I.b*255)));ia[4]=k(0,o(255,~~(Y.r*255)));ia[5]=k(0,o(255,~~(Y.g*255)));ia[6]=k(0,o(255,~~(Y.b*255)));
+ia[8]=k(0,o(255,~~(U.r*255)));ia[9]=k(0,o(255,~~(U.g*255)));ia[10]=k(0,o(255,~~(U.b*255)));ia[12]=k(0,o(255,~~(E.r*255)));ia[13]=k(0,o(255,~~(E.g*255)));ia[14]=k(0,o(255,~~(E.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?o((1+I)*0.5,0.5):0.5+o(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,E=Y.y-I.y,v=1/Math.sqrt(U*U+E*E);U*=v;E*=v;Y.x+=U;Y.y+=E;I.x-=U;I.y-=E}var y=null,G=new THREE.Projector,w=document.createElement("canvas"),F,N,J,M,r=w.getContext("2d"),R=1,B=
+0,e=null,f=null,i=1,o=Math.min,k=Math.max,j,A,s,L,u,T,P,t,H,p=new THREE.Color,z=new THREE.Color,x=new THREE.Color,O=new THREE.Color,D=new THREE.Color,C,W,ea,Q,V,ja,za,Aa,Ba,Ca,pa=new THREE.Rectangle,ma=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0,
+0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;N=Y;J=F/2;M=N/2;w.width=F;w.height=N;pa.set(-J,-M,J,M)};this.clear=function(){if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(pa);r.clearRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());ma.empty()}};this.render=function(I,Y){var U,E,v,K,$,S,X,ba;r.setTransform(1,
+0,0,-1,J,M);this.autoClear&&this.clear();y=G.projectScene(I,Y);if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);U=0;for(E=$.length;U<E;U++){v=$[U];K=v.color;if(v instanceof THREE.AmbientLight){ga.r+=K.r;ga.g+=K.g;ga.b+=K.b}else if(v instanceof THREE.DirectionalLight){na.r+=K.r;na.g+=K.g;na.b+=K.b}else if(v instanceof THREE.PointLight){oa.r+=K.r;oa.g+=K.g;oa.b+=K.b}}}U=0;for(E=y.length;U<E;U++){v=y[U];da.empty();if(v instanceof THREE.RenderableParticle){j=v;j.x*=
+J;j.y*=M;K=0;for($=v.material.length;K<$;K++){S=j;X=v;var Z=v.material[K];if(Z.opacity!=0){n(Z.opacity);m(Z.blending);ba=void 0;var ca=void 0,la=void 0,ka=void 0,fa=void 0,xa=void 0,ya=void 0;if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){fa=Z.map;xa=fa.width>>1;ya=fa.height>>1;la=X.scale.x*J;ka=X.scale.y*M;ba=la*xa;ca=ka*ya;da.set(S.x-ba,S.y-ca,S.x+ba,S.y+ca);if(pa.instersects(da)){r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);r.scale(la,-ka);r.translate(-xa,-ya);r.drawImage(fa,0,0);
+r.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(va){ha.r=ga.r+na.r+oa.r;ha.g=ga.g+na.g+oa.g;ha.b=ga.b+na.b+oa.b;p.r=Z.color.r*ha.r;p.g=Z.color.g*ha.g;p.b=Z.color.b*ha.b;p.updateStyleString()}else p.__styleString=Z.color.__styleString;ba=X.scale.x*J;ca=X.scale.y*M;da.set(S.x-ba,S.y-ca,S.x+ba,S.y+ca);if(pa.instersects(da)){Z=p.__styleString;if(f!=Z)r.fillStyle=f=Z;r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);r.scale(ba,ca);r.beginPath();r.arc(0,0,1,0,Da,true);r.closePath();
+r.fill();r.restore()}}}}}else if(v instanceof THREE.RenderableLine){j=v.v1;A=v.v2;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);if(pa.instersects(da)){K=0;for($=v.material.length;K<$;){X=j;ba=A;S=v.material[K++];if(S.opacity!=0){n(S.opacity);m(S.blending);r.beginPath();r.moveTo(X.positionScreen.x,X.positionScreen.y);r.lineTo(ba.positionScreen.x,ba.positionScreen.y);
+r.closePath();if(S instanceof THREE.LineBasicMaterial){p.__styleString=S.color.__styleString;X=S.linewidth;if(i!=X)r.lineWidth=i=X;X=p.__styleString;if(e!=X)r.strokeStyle=e=X;r.stroke();da.inflate(S.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){j=v.v1;A=v.v2;s=v.v3;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;s.positionScreen.x*=J;s.positionScreen.y*=M;if(v.overdraw){c(j.positionScreen,A.positionScreen);c(A.positionScreen,s.positionScreen);
+c(s.positionScreen,j.positionScreen)}da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);da.addPoint(s.positionScreen.x,s.positionScreen.y);if(pa.instersects(da)){K=0;for($=v.meshMaterial.length;K<$;){ba=v.meshMaterial[K++];if(ba instanceof THREE.MeshFaceMaterial){S=0;for(X=v.faceMaterial.length;S<X;)(ba=v.faceMaterial[S++])&&b(j,A,s,v,ba,I)}else b(j,A,s,v,ba,I)}}}ma.addRectangle(da)}r.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(p,z,x){var O,D,C,W;O=0;for(D=p.lights.length;O<D;O++){C=p.lights[O];if(C instanceof THREE.DirectionalLight){W=z.normalWorld.dot(C.position)*C.intensity;if(W>0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){j.sub(C.position,z.centroidWorld);j.normalize();W=z.normalWorld.dot(j)*C.intensity;if(W>0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}}}function b(p,z,x,O,D,C){u=g(T++);u.setAttribute("d","M "+p.positionScreen.x+
+" "+p.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(C,O,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){k=1-D.__2near/(D.__farPlusNear-O.z*D.__farMinusNear);
+B.setRGB(k,k,k)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(h(O.normalWorld.x),h(O.normalWorld.y),h(O.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);q.appendChild(u)}function d(p,z,x,O,D,C,W){u=g(T++);u.setAttribute("d",
+"M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(W,D,e);B.r=C.color.r*e.r;B.g=C.color.g*e.g;B.b=C.color.b*e.b;B.updateStyleString()}else B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){k=
+1-C.__2near/(C.__farPlusNear-D.z*C.__farMinusNear);B.setRGB(k,k,k)}else C instanceof THREE.MeshNormalMaterial&&B.setRGB(h(D.normalWorld.x),h(D.normalWorld.y),h(D.normalWorld.z));C.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+C.opacity);q.appendChild(u)}
 function g(p){if(A[p]==null){A[p]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&A[p].setAttribute("shape-rendering","crispEdges");return A[p]}return A[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 n=null,m=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,y,G,w,F,N,J,M=new THREE.Rectangle,r=new THREE.Rectangle,R=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),i=new THREE.Color(0),
-o=new THREE.Color(0),k,j=new THREE.Vector3,A=[],s=[],L=[],u,U,P,t,H=1;this.domElement=q;this.autoClear=true;this.setQuality=function(p){switch(p){case "high":H=1;break;case "low":H=0}};this.setSize=function(p,z){l=p;c=z;y=l/2;G=c/2;q.setAttribute("viewBox",-y+" "+-G+" "+l+" "+c);q.setAttribute("width",l);q.setAttribute("height",c);M.set(-y,-G,y,G)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(p,z){var x,O,E,D,W,ea,Q,T;this.autoClear&&this.clear();
-n=m.projectScene(p,z);t=P=U=0;if(R=p.lights.length>0){Q=p.lights;f.setRGB(0,0,0);i.setRGB(0,0,0);o.setRGB(0,0,0);x=0;for(O=Q.length;x<O;x++){E=Q[x];D=E.color;if(E instanceof THREE.AmbientLight){f.r+=D.r;f.g+=D.g;f.b+=D.b}else if(E instanceof THREE.DirectionalLight){i.r+=D.r;i.g+=D.g;i.b+=D.b}else if(E instanceof THREE.PointLight){o.r+=D.r;o.g+=D.g;o.b+=D.b}}}x=0;for(O=n.length;x<O;x++){Q=n[x];r.empty();if(Q instanceof THREE.RenderableParticle){w=Q;w.x*=y;w.y*=-G;E=0;for(D=Q.material.length;E<D;E++)if(T=
-Q.material[E]){W=w;ea=Q;T=T;var ba=P++;if(s[ba]==null){s[ba]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&s[ba].setAttribute("shape-rendering","crispEdges")}u=s[ba];u.setAttribute("cx",W.x);u.setAttribute("cy",W.y);u.setAttribute("r",ea.scale.x*y);if(T instanceof THREE.ParticleCircleMaterial){if(R){e.r=f.r+i.r+o.r;e.g=f.g+i.g+o.g;e.b=f.b+i.b+o.b;B.r=T.color.r*e.r;B.g=T.color.g*e.g;B.b=T.color.b*e.b;B.updateStyleString()}else B=T.color;u.setAttribute("style","fill: "+B.__styleString)}q.appendChild(u)}}else if(Q instanceof
-THREE.RenderableLine){w=Q.v1;F=Q.v2;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(M.instersects(r)){E=0;for(D=Q.material.length;E<D;)if(T=Q.material[E++]){W=w;ea=F;T=T;ba=t++;if(L[ba]==null){L[ba]=document.createElementNS("http://www.w3.org/2000/svg","line");H==0&&L[ba].setAttribute("shape-rendering","crispEdges")}u=L[ba];u.setAttribute("x1",W.positionScreen.x);
-u.setAttribute("y1",W.positionScreen.y);u.setAttribute("x2",ea.positionScreen.x);u.setAttribute("y2",ea.positionScreen.y);if(T instanceof THREE.LineBasicMaterial){B.__styleString=T.color.__styleString;u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin);q.appendChild(u)}}}}else if(Q instanceof THREE.RenderableFace3){w=Q.v1;F=Q.v2;N=Q.v3;w.positionScreen.x*=y;w.positionScreen.y*=
--G;F.positionScreen.x*=y;F.positionScreen.y*=-G;N.positionScreen.x*=y;N.positionScreen.y*=-G;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);if(M.instersects(r)){E=0;for(D=Q.meshMaterial.length;E<D;){T=Q.meshMaterial[E++];if(T instanceof THREE.MeshFaceMaterial){W=0;for(ea=Q.faceMaterial.length;W<ea;)(T=Q.faceMaterial[W++])&&b(w,F,N,Q,T,p)}else T&&b(w,F,N,Q,T,p)}}}else if(Q instanceof THREE.RenderableFace4){w=
-Q.v1;F=Q.v2;N=Q.v3;J=Q.v4;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;N.positionScreen.x*=y;N.positionScreen.y*=-G;J.positionScreen.x*=y;J.positionScreen.y*=-G;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);r.addPoint(J.positionScreen.x,J.positionScreen.y);if(M.instersects(r)){E=0;for(D=Q.meshMaterial.length;E<D;){T=Q.meshMaterial[E++];if(T instanceof
-THREE.MeshFaceMaterial){W=0;for(ea=Q.faceMaterial.length;W<ea;)(T=Q.faceMaterial[W++])&&d(w,F,N,J,Q,T,p)}else T&&d(w,F,N,J,Q,T,p)}}}}}};
+o=new THREE.Color(0),k,j=new THREE.Vector3,A=[],s=[],L=[],u,T,P,t,H=1;this.domElement=q;this.autoClear=true;this.setQuality=function(p){switch(p){case "high":H=1;break;case "low":H=0}};this.setSize=function(p,z){l=p;c=z;y=l/2;G=c/2;q.setAttribute("viewBox",-y+" "+-G+" "+l+" "+c);q.setAttribute("width",l);q.setAttribute("height",c);M.set(-y,-G,y,G)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(p,z){var x,O,D,C,W,ea,Q,V;this.autoClear&&this.clear();
+n=m.projectScene(p,z);t=P=T=0;if(R=p.lights.length>0){Q=p.lights;f.setRGB(0,0,0);i.setRGB(0,0,0);o.setRGB(0,0,0);x=0;for(O=Q.length;x<O;x++){D=Q[x];C=D.color;if(D instanceof THREE.AmbientLight){f.r+=C.r;f.g+=C.g;f.b+=C.b}else if(D instanceof THREE.DirectionalLight){i.r+=C.r;i.g+=C.g;i.b+=C.b}else if(D instanceof THREE.PointLight){o.r+=C.r;o.g+=C.g;o.b+=C.b}}}x=0;for(O=n.length;x<O;x++){Q=n[x];r.empty();if(Q instanceof THREE.RenderableParticle){w=Q;w.x*=y;w.y*=-G;D=0;for(C=Q.material.length;D<C;D++)if(V=
+Q.material[D]){W=w;ea=Q;V=V;var ja=P++;if(s[ja]==null){s[ja]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&s[ja].setAttribute("shape-rendering","crispEdges")}u=s[ja];u.setAttribute("cx",W.x);u.setAttribute("cy",W.y);u.setAttribute("r",ea.scale.x*y);if(V instanceof THREE.ParticleCircleMaterial){if(R){e.r=f.r+i.r+o.r;e.g=f.g+i.g+o.g;e.b=f.b+i.b+o.b;B.r=V.color.r*e.r;B.g=V.color.g*e.g;B.b=V.color.b*e.b;B.updateStyleString()}else B=V.color;u.setAttribute("style","fill: "+B.__styleString)}q.appendChild(u)}}else if(Q instanceof
+THREE.RenderableLine){w=Q.v1;F=Q.v2;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);if(M.instersects(r)){D=0;for(C=Q.material.length;D<C;)if(V=Q.material[D++]){W=w;ea=F;V=V;ja=t++;if(L[ja]==null){L[ja]=document.createElementNS("http://www.w3.org/2000/svg","line");H==0&&L[ja].setAttribute("shape-rendering","crispEdges")}u=L[ja];u.setAttribute("x1",W.positionScreen.x);
+u.setAttribute("y1",W.positionScreen.y);u.setAttribute("x2",ea.positionScreen.x);u.setAttribute("y2",ea.positionScreen.y);if(V instanceof THREE.LineBasicMaterial){B.__styleString=V.color.__styleString;u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+V.linewidth+"; stroke-opacity: "+V.opacity+"; stroke-linecap: "+V.linecap+"; stroke-linejoin: "+V.linejoin);q.appendChild(u)}}}}else if(Q instanceof THREE.RenderableFace3){w=Q.v1;F=Q.v2;N=Q.v3;w.positionScreen.x*=y;w.positionScreen.y*=
+-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;N.positionScreen.x*=y;N.positionScreen.y*=-G;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);if(M.instersects(r)){D=0;for(C=Q.meshMaterial.length;D<C;){V=Q.meshMaterial[D++];if(V instanceof THREE.MeshFaceMaterial){W=0;for(ea=Q.faceMaterial.length;W<ea;)(V=Q.faceMaterial[W++])&&b(w,F,N,Q,V,p)}else V&&b(w,F,N,Q,V,p)}}}else if(Q instanceof THREE.RenderableFace4){w=
+Q.v1;F=Q.v2;N=Q.v3;J=Q.v4;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;N.positionScreen.x*=y;N.positionScreen.y*=-G;J.positionScreen.x*=y;J.positionScreen.y*=-G;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(F.positionScreen.x,F.positionScreen.y);r.addPoint(N.positionScreen.x,N.positionScreen.y);r.addPoint(J.positionScreen.x,J.positionScreen.y);if(M.instersects(r)){D=0;for(C=Q.meshMaterial.length;D<C;){V=Q.meshMaterial[D++];if(V instanceof
+THREE.MeshFaceMaterial){W=0;for(ea=Q.faceMaterial.length;W<ea;)(V=Q.faceMaterial[W++])&&d(w,F,N,J,Q,V,p)}else V&&d(w,F,N,J,Q,V,p)}}}}}};
 THREE.WebGLRenderer=function(a){function b(e,f){var i=c.createProgram();c.attachShader(i,m("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+e));c.attachShader(i,m("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+f));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,
 c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};return i}function d(e,f){if(e instanceof THREE.TextureCube&&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 i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function g(e,f){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();
@@ -145,14 +147,14 @@ y=b(o,i);c.useProgram(y);h(y,["viewMatrix","modelViewMatrix","projectionMatrix",
 "pointLightPosition"]);c.uniform1i(y.uniforms.enableMap,0);c.uniform1i(y.uniforms.tMap,0);c.uniform1i(y.uniforms.enableCubeMap,0);c.uniform1i(y.uniforms.tCube,1);c.uniform1i(y.uniforms.mixEnvMap,0);c.uniform1i(y.uniforms.useRefract,0);n(y)})(a.directional,a.point);this.setSize=function(e,f){l.width=e;l.height=f;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,f){var i,o,k,j,A,s=[],L=[],u=[];j=[];A=[];c.uniform1i(e.uniforms.enableLighting,
 f.lights.length);i=0;for(o=f.lights.length;i<o;i++){k=f.lights[i];if(k instanceof THREE.AmbientLight)s.push(k);else if(k instanceof THREE.DirectionalLight)u.push(k);else k instanceof THREE.PointLight&&L.push(k)}i=k=j=A=0;for(o=s.length;i<o;i++){k+=s[i].color.r;j+=s[i].color.g;A+=s[i].color.b}c.uniform3f(e.uniforms.ambientLightColor,k,j,A);j=[];A=[];i=0;for(o=u.length;i<o;i++){k=u[i];j.push(k.color.r*k.intensity);j.push(k.color.g*k.intensity);j.push(k.color.b*k.intensity);A.push(k.position.x);A.push(k.position.y);
 A.push(k.position.z)}if(u.length){c.uniform1i(e.uniforms.directionalLightNumber,u.length);c.uniform3fv(e.uniforms.directionalLightDirection,A);c.uniform3fv(e.uniforms.directionalLightColor,j)}j=[];A=[];i=0;for(o=L.length;i<o;i++){k=L[i];j.push(k.color.r*k.intensity);j.push(k.color.g*k.intensity);j.push(k.color.b*k.intensity);A.push(k.position.x);A.push(k.position.y);A.push(k.position.z)}if(L.length){c.uniform1i(e.uniforms.pointLightNumber,L.length);c.uniform3fv(e.uniforms.pointLightPosition,A);c.uniform3fv(e.uniforms.pointLightColor,
-j)}};this.createBuffers=function(e,f){var i,o,k,j,A,s,L,u,U=[],P=[],t=[],H=[],p=[],z=0,x=e.materialFaceGroup[f],O;k=false;i=0;for(o=e.material.length;i<o;i++){meshMaterial=e.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){A=0;for(O=x.material.length;A<O;A++)if(x.material[A]&&x.material[A].shading!=undefined&&x.material[A].shading==THREE.SmoothShading){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){k=true;break}if(k)break}O=
-k;i=0;for(o=x.faces.length;i<o;i++){k=x.faces[i];j=e.geometry.faces[k];A=j.vertexNormals;faceNormal=j.normal;k=e.geometry.uvs[k];if(j instanceof THREE.Face3){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);if(A.length==3&&O)for(j=0;j<3;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<3;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<3;j++)p.push(k[j].u,k[j].v);U.push(z,
-z+1,z+2);P.push(z,z+1);P.push(z,z+2);P.push(z+1,z+2);z+=3}else if(j instanceof THREE.Face4){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;j=e.geometry.vertices[j.d].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);t.push(j.x,j.y,j.z);if(A.length==4&&O)for(j=0;j<4;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<4;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<4;j++)p.push(k[j].u,k[j].v);U.push(z,z+
-1,z+2);U.push(z,z+2,z+3);P.push(z,z+1);P.push(z,z+2);P.push(z,z+3);P.push(z+1,z+2);P.push(z+2,z+3);z+=4}}if(t.length){x.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(t),c.STATIC_DRAW);x.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);x.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);
-c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW);x.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(U),c.STATIC_DRAW);x.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);x.__webGLFaceCount=U.length;x.__webGLLineCount=P.length}};this.renderBuffer=function(e,f,i){var o,k,j,A,s,L,u,
-U,P,t;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in f.uniforms)u.push(t);h(f.program,u);n(f.program)}t=f.program}else t=y;if(t!=G){c.useProgram(t);G=t}if(f instanceof THREE.MeshShaderMaterial){u=t;U=f.uniforms;var H,p;for(k in U){H=U[k].type;P=U[k].value;p=u.uniforms[k];if(H=="i")c.uniform1i(p,P);else if(H=="f")c.uniform1f(p,P);else if(H==
-"t"){c.uniform1i(p,P);H=U[k].texture;if(H instanceof THREE.TextureCube)d(H,P);else H instanceof THREE.Texture&&g(H,P)}}this.loadCamera(t,e);this.loadMatrices(t)}else if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){e=f.color;o=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;s=f.map;L=f.env_map;u=f.combine==THREE.Mix;k=f.reflectivity;P=f.env_map&&f.env_map.mapping==THREE.RefractionMapping;U=f.refraction_ratio;c.uniform4f(t.uniforms.mColor,
-e.r*o,e.g*o,e.b*o,o);c.uniform1i(t.uniforms.mixEnvMap,u);c.uniform1f(t.uniforms.mReflectivity,k);c.uniform1i(t.uniforms.useRefract,P);c.uniform1f(t.uniforms.mRefractionRatio,U)}if(f instanceof THREE.MeshNormalMaterial){o=f.opacity;c.uniform1f(t.uniforms.mOpacity,o);c.uniform1i(t.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){o=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,o);c.uniform1f(t.uniforms.m2Near,f.__2near);c.uniform1f(t.uniforms.mFarPlusNear,
+j)}};this.createBuffers=function(e,f){var i,o,k,j,A,s,L,u,T=[],P=[],t=[],H=[],p=[],z=0,x=e.materialFaceGroup[f],O;k=false;i=0;for(o=e.material.length;i<o;i++){meshMaterial=e.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){A=0;for(O=x.material.length;A<O;A++)if(x.material[A]&&x.material[A].shading!=undefined&&x.material[A].shading==THREE.SmoothShading){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){k=true;break}if(k)break}O=
+k;i=0;for(o=x.faces.length;i<o;i++){k=x.faces[i];j=e.geometry.faces[k];A=j.vertexNormals;faceNormal=j.normal;k=e.geometry.uvs[k];if(j instanceof THREE.Face3){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);if(A.length==3&&O)for(j=0;j<3;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<3;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<3;j++)p.push(k[j].u,k[j].v);T.push(z,
+z+1,z+2);P.push(z,z+1);P.push(z,z+2);P.push(z+1,z+2);z+=3}else if(j instanceof THREE.Face4){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;j=e.geometry.vertices[j.d].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);t.push(j.x,j.y,j.z);if(A.length==4&&O)for(j=0;j<4;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<4;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<4;j++)p.push(k[j].u,k[j].v);T.push(z,z+
+1,z+2);T.push(z,z+2,z+3);P.push(z,z+1);P.push(z,z+2);P.push(z,z+3);P.push(z+1,z+2);P.push(z+2,z+3);z+=4}}if(t.length){x.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(t),c.STATIC_DRAW);x.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);x.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);
+c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW);x.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);x.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);x.__webGLFaceCount=T.length;x.__webGLLineCount=P.length}};this.renderBuffer=function(e,f,i){var o,k,j,A,s,L,u,
+T,P,t;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in f.uniforms)u.push(t);h(f.program,u);n(f.program)}t=f.program}else t=y;if(t!=G){c.useProgram(t);G=t}if(f instanceof THREE.MeshShaderMaterial){u=t;T=f.uniforms;var H,p;for(k in T){H=T[k].type;P=T[k].value;p=u.uniforms[k];if(H=="i")c.uniform1i(p,P);else if(H=="f")c.uniform1f(p,P);else if(H==
+"t"){c.uniform1i(p,P);H=T[k].texture;if(H instanceof THREE.TextureCube)d(H,P);else H instanceof THREE.Texture&&g(H,P)}}this.loadCamera(t,e);this.loadMatrices(t)}else if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){e=f.color;o=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;s=f.map;L=f.env_map;u=f.combine==THREE.Mix;k=f.reflectivity;P=f.env_map&&f.env_map.mapping==THREE.RefractionMapping;T=f.refraction_ratio;c.uniform4f(t.uniforms.mColor,
+e.r*o,e.g*o,e.b*o,o);c.uniform1i(t.uniforms.mixEnvMap,u);c.uniform1f(t.uniforms.mReflectivity,k);c.uniform1i(t.uniforms.useRefract,P);c.uniform1f(t.uniforms.mRefractionRatio,T)}if(f instanceof THREE.MeshNormalMaterial){o=f.opacity;c.uniform1f(t.uniforms.mOpacity,o);c.uniform1i(t.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){o=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,o);c.uniform1f(t.uniforms.m2Near,f.__2near);c.uniform1f(t.uniforms.mFarPlusNear,
 f.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(f instanceof THREE.MeshPhongMaterial){e=f.ambient;k=f.specular;f=f.shininess;c.uniform4f(t.uniforms.mAmbient,e.r,e.g,e.b,o);c.uniform4f(t.uniforms.mSpecular,k.r,k.g,k.b,o);c.uniform1f(t.uniforms.mShininess,f);c.uniform1i(t.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,
 0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);L=f.env_map}if(s){g(s,0);c.uniform1i(t.uniforms.tMap,0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(L){d(L,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLVertexBuffer);c.vertexAttribPointer(t.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLNormalBuffer);
 c.vertexAttribPointer(t.normal,3,c.FLOAT,false,0,0);if(s){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUVBuffer);c.enableVertexAttribArray(t.uv);c.vertexAttribPointer(t.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(t.uv);if(j){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);c.drawElements(c.LINES,i.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,i.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=

+ 56 - 54
build/ThreeDebug.js

@@ -5,13 +5,14 @@ THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this
 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,d){this.x=a||0;this.y=b||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;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,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-b*a.z;this.z=b*a.y-d*a.x;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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,
-0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1};
+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,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-b*a.z;this.z=b*a.y-d*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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
+Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
+THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1};
 THREE.Vector4.prototype={set:function(a,b,d,g){this.x=a;this.y=b;this.z=d;this.w=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,h=[];a=0;for(b=g.length;a<b;a++){d=g[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(o,m){return o.distance-m.distance});return h},intersectObject:function(a){function b(M,n,T,B){B=B.clone().subSelf(n);T=T.clone().subSelf(n);var e=M.clone().subSelf(n);M=B.dot(B);n=B.dot(T);B=B.dot(e);var f=T.dot(T);T=T.dot(e);e=1/(M*f-n*n);f=(f*B-n*T)*e;M=(M*T-n*B)*e;return f>0&&M>0&&f+M<1}var d,g,h,o,m,r,l,c,y,G,
+THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,h=[];a=0;for(b=g.length;a<b;a++){d=g[a];if(d instanceof THREE.Mesh)h=h.concat(this.intersectObject(d))}h.sort(function(o,m){return o.distance-m.distance});return h},intersectObject:function(a){function b(M,n,S,B){B=B.clone().subSelf(n);S=S.clone().subSelf(n);var e=M.clone().subSelf(n);M=B.dot(B);n=B.dot(S);B=B.dot(e);var f=S.dot(S);S=S.dot(e);e=1/(M*f-n*n);f=(f*B-n*S)*e;M=(M*S-n*B)*e;return f>0&&M>0&&f+M<1}var d,g,h,o,m,r,l,c,y,G,
 w,F=a.geometry,O=F.vertices,J=[];d=0;for(g=F.faces.length;d<g;d++){h=F.faces[d];G=this.origin.clone();w=this.direction.clone();o=a.matrix.transformVector3(O[h.a].position.clone());m=a.matrix.transformVector3(O[h.b].position.clone());r=a.matrix.transformVector3(O[h.c].position.clone());l=h instanceof THREE.Face4?a.matrix.transformVector3(O[h.d].position.clone()):null;c=a.rotationMatrix.transformVector3(h.normal.clone());y=w.dot(c);if(y<0){c=c.dot((new THREE.Vector3).sub(o,G))/y;G=G.addSelf(w.multiplyScalar(c));
 if(h instanceof THREE.Face3){if(b(G,o,m,r)){h={distance:this.origin.distanceTo(G),point:G,face:h,object:a};J.push(h)}}else if(h instanceof THREE.Face4)if(b(G,o,m,l)||b(G,m,r,l)){h={distance:this.origin.distanceTo(G),point:G,face:h,object:a};J.push(h)}}}return J}};
 THREE.Rectangle=function(){function a(){o=g-b;m=h-d}var b,d,g,h,o,m,r=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return o};this.getHeight=function(){return m};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return g};this.getBottom=function(){return h};this.set=function(l,c,y,G){r=false;b=l;d=c;g=y;h=G;a()};this.addPoint=function(l,c){if(r){r=false;b=l;d=c;g=l;h=c}else{b=Math.min(b,l);d=Math.min(d,c);g=Math.max(g,
@@ -21,8 +22,8 @@ THREE.Matrix4=function(){};
 THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,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},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},lookAt:function(a,b,d){var g=new THREE.Vector3,h=new THREE.Vector3,o=new THREE.Vector3;o.sub(a,b).normalize();g.cross(d,o).normalize();h.cross(o,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=o.x;this.n32=o.y;this.n33=o.z;this.n34=-o.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var b=a.x,d=a.y,g=a.z,h=1/(this.n41*b+this.n42*
 d+this.n43*g+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*g+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*h;return a},transformVector4:function(a){var b=a.x,d=a.y,g=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*g+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 d=a.n11,g=a.n12,h=a.n13,o=a.n14,m=a.n21,r=a.n22,l=a.n23,c=a.n24,y=a.n31,G=a.n32,w=a.n33,F=a.n34,O=a.n41,J=a.n42,M=a.n43,n=a.n44,T=b.n11,B=b.n12,e=b.n13,f=b.n14,i=b.n21,p=b.n22,k=b.n23,j=b.n24,A=b.n31,s=b.n32,L=b.n33,u=b.n34,U=b.n41,Q=b.n42,t=b.n43,
-H=b.n44;this.n11=d*T+g*i+h*A+o*U;this.n12=d*B+g*p+h*s+o*Q;this.n13=d*e+g*k+h*L+o*t;this.n14=d*f+g*j+h*u+o*H;this.n21=m*T+r*i+l*A+c*U;this.n22=m*B+r*p+l*s+c*Q;this.n23=m*e+r*k+l*L+c*t;this.n24=m*f+r*j+l*u+c*H;this.n31=y*T+G*i+w*A+F*U;this.n32=y*B+G*p+w*s+F*Q;this.n33=y*e+G*k+w*L+F*t;this.n34=y*f+G*j+w*u+F*H;this.n41=O*T+J*i+M*A+n*U;this.n42=O*B+J*p+M*s+n*Q;this.n43=O*e+J*k+M*L+n*t;this.n44=O*f+J*j+M*u+n*H},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,h=this.n14,o=this.n21,m=this.n22,
+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 d=a.n11,g=a.n12,h=a.n13,o=a.n14,m=a.n21,r=a.n22,l=a.n23,c=a.n24,y=a.n31,G=a.n32,w=a.n33,F=a.n34,O=a.n41,J=a.n42,M=a.n43,n=a.n44,S=b.n11,B=b.n12,e=b.n13,f=b.n14,i=b.n21,p=b.n22,k=b.n23,j=b.n24,A=b.n31,s=b.n32,L=b.n33,u=b.n34,T=b.n41,Q=b.n42,t=b.n43,
+H=b.n44;this.n11=d*S+g*i+h*A+o*T;this.n12=d*B+g*p+h*s+o*Q;this.n13=d*e+g*k+h*L+o*t;this.n14=d*f+g*j+h*u+o*H;this.n21=m*S+r*i+l*A+c*T;this.n22=m*B+r*p+l*s+c*Q;this.n23=m*e+r*k+l*L+c*t;this.n24=m*f+r*j+l*u+c*H;this.n31=y*S+G*i+w*A+F*T;this.n32=y*B+G*p+w*s+F*Q;this.n33=y*e+G*k+w*L+F*t;this.n34=y*f+G*j+w*u+F*H;this.n41=O*S+J*i+M*A+n*T;this.n42=O*B+J*p+M*s+n*Q;this.n43=O*e+J*k+M*L+n*t;this.n44=O*f+J*j+M*u+n*H},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,h=this.n14,o=this.n21,m=this.n22,
 r=this.n23,l=this.n24,c=this.n31,y=this.n32,G=this.n33,w=this.n34,F=this.n41,O=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+h*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+h*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+h*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+h*a.n44;this.n21=o*a.n11+m*a.n21+r*a.n31+l*a.n41;this.n22=o*a.n12+m*a.n22+r*a.n32+l*a.n42;this.n23=o*a.n13+m*a.n23+r*a.n33+l*a.n43;this.n24=o*a.n14+m*a.n24+r*a.n34+l*a.n44;this.n31=c*a.n11+y*a.n21+G*a.n31+w*a.n41;this.n32=c*a.n12+y*a.n22+
 G*a.n32+w*a.n42;this.n33=c*a.n13+y*a.n23+G*a.n33+w*a.n43;this.n34=c*a.n14+y*a.n24+G*a.n34+w*a.n44;this.n41=F*a.n11+O*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+O*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+O*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+O*a.n24+J*a.n34+M*a.n44},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},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*
@@ -82,55 +83,56 @@ this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new
 THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,g){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>)"}};
 THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){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.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(T,B){var e=0,f=1,i=T.z+T.w,p=B.z+B.w,k=-T.z+T.w,j=-B.z+B.w;if(i>=0&&p>=0&&k>=0&&j>=0)return true;else if(i<0&&p<0||k<0&&j<0)return false;else{if(i<0)e=Math.max(e,i/(i-p));else if(p<0)f=Math.min(f,i/(i-p));if(k<0)e=Math.max(e,k/(k-j));else if(j<0)f=Math.min(f,k/(k-j));if(f<e)return false;else{T.lerpSelf(B,e);B.lerpSelf(T,1-f);return true}}}var b=null,d,g,h,o=[],m,r,l=[],c,y,G=[],w=new THREE.Vector4,F=new THREE.Matrix4,O=new THREE.Matrix4,J=new THREE.Vector4,M=
-new THREE.Vector4,n;this.projectScene=function(T,B){var e,f,i,p,k,j,A,s,L,u,U,Q,t,H,q,z,x;b=[];h=r=y=0;B.autoUpdateMatrix&&B.updateMatrix();F.multiply(B.projectionMatrix,B.matrix);A=T.objects;e=0;for(f=A.length;e<f;e++){s=A[e];s.autoUpdateMatrix&&s.updateMatrix();L=s.matrix;u=s.rotationMatrix;U=s.material;Q=s.overdraw;if(s instanceof THREE.Mesh){t=s.geometry.vertices;i=0;for(p=t.length;i<p;i++){H=t[i];H.positionWorld.copy(H.position);L.transformVector3(H.positionWorld);q=H.positionScreen;q.copy(H.positionWorld);
+THREE.Projector=function(){function a(S,B){var e=0,f=1,i=S.z+S.w,p=B.z+B.w,k=-S.z+S.w,j=-B.z+B.w;if(i>=0&&p>=0&&k>=0&&j>=0)return true;else if(i<0&&p<0||k<0&&j<0)return false;else{if(i<0)e=Math.max(e,i/(i-p));else if(p<0)f=Math.min(f,i/(i-p));if(k<0)e=Math.max(e,k/(k-j));else if(j<0)f=Math.min(f,k/(k-j));if(f<e)return false;else{S.lerpSelf(B,e);B.lerpSelf(S,1-f);return true}}}var b=null,d,g,h,o=[],m,r,l=[],c,y,G=[],w=new THREE.Vector4,F=new THREE.Matrix4,O=new THREE.Matrix4,J=new THREE.Vector4,M=
+new THREE.Vector4,n;this.projectScene=function(S,B){var e,f,i,p,k,j,A,s,L,u,T,Q,t,H,q,z,x;b=[];h=r=y=0;B.autoUpdateMatrix&&B.updateMatrix();F.multiply(B.projectionMatrix,B.matrix);A=S.objects;e=0;for(f=A.length;e<f;e++){s=A[e];s.autoUpdateMatrix&&s.updateMatrix();L=s.matrix;u=s.rotationMatrix;T=s.material;Q=s.overdraw;if(s instanceof THREE.Mesh){t=s.geometry.vertices;i=0;for(p=t.length;i<p;i++){H=t[i];H.positionWorld.copy(H.position);L.transformVector3(H.positionWorld);q=H.positionScreen;q.copy(H.positionWorld);
 F.transformVector4(q);q.multiplyScalar(1/q.w);H.__visible=q.z>0&&q.z<1}H=s.geometry.faces;i=0;for(p=H.length;i<p;i++){q=H[i];if(q instanceof THREE.Face3){k=t[q.a];j=t[q.b];z=t[q.c];if(k.__visible&&j.__visible&&z.__visible)if(s.doubleSided||s.flipSided!=(z.positionScreen.x-k.positionScreen.x)*(j.positionScreen.y-k.positionScreen.y)-(z.positionScreen.y-k.positionScreen.y)*(j.positionScreen.x-k.positionScreen.x)<0){d=o[h]=o[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(k.positionWorld);d.v2.positionWorld.copy(j.positionWorld);
 d.v3.positionWorld.copy(z.positionWorld);d.v1.positionScreen.copy(k.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(z.positionScreen);d.normalWorld.copy(q.normal);u.transformVector3(d.normalWorld);d.centroidWorld.copy(q.centroid);L.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);F.transformVector3(d.centroidScreen);z=q.vertexNormals;n=d.vertexNormalsWorld;k=0;for(j=z.length;k<j;k++){x=n[k]=n[k]||new THREE.Vector3;x.copy(z[k]);u.transformVector3(x)}d.z=
-d.centroidScreen.z;d.meshMaterial=U;d.faceMaterial=q.material;d.overdraw=Q;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][2]}b.push(d);h++}}else if(q instanceof THREE.Face4){k=t[q.a];j=t[q.b];z=t[q.c];x=t[q.d];if(k.__visible&&j.__visible&&z.__visible&&x.__visible)if(s.doubleSided||s.flipSided!=((x.positionScreen.x-k.positionScreen.x)*(j.positionScreen.y-k.positionScreen.y)-(x.positionScreen.y-k.positionScreen.y)*(j.positionScreen.x-k.positionScreen.x)<
+d.centroidScreen.z;d.meshMaterial=T;d.faceMaterial=q.material;d.overdraw=Q;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][2]}b.push(d);h++}}else if(q instanceof THREE.Face4){k=t[q.a];j=t[q.b];z=t[q.c];x=t[q.d];if(k.__visible&&j.__visible&&z.__visible&&x.__visible)if(s.doubleSided||s.flipSided!=((x.positionScreen.x-k.positionScreen.x)*(j.positionScreen.y-k.positionScreen.y)-(x.positionScreen.y-k.positionScreen.y)*(j.positionScreen.x-k.positionScreen.x)<
 0||(j.positionScreen.x-z.positionScreen.x)*(x.positionScreen.y-z.positionScreen.y)-(j.positionScreen.y-z.positionScreen.y)*(x.positionScreen.x-z.positionScreen.x)<0)){d=o[h]=o[h]||new THREE.RenderableFace3;d.v1.positionWorld.copy(k.positionWorld);d.v2.positionWorld.copy(j.positionWorld);d.v3.positionWorld.copy(x.positionWorld);d.v1.positionScreen.copy(k.positionScreen);d.v2.positionScreen.copy(j.positionScreen);d.v3.positionScreen.copy(x.positionScreen);d.normalWorld.copy(q.normal);u.transformVector3(d.normalWorld);
-d.centroidWorld.copy(q.centroid);L.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);F.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=U;d.faceMaterial=q.material;d.overdraw=Q;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][3]}b.push(d);h++;g=o[h]=o[h]||new THREE.RenderableFace3;g.v1.positionWorld.copy(j.positionWorld);g.v2.positionWorld.copy(z.positionWorld);g.v3.positionWorld.copy(x.positionWorld);
-g.v1.positionScreen.copy(j.positionScreen);g.v2.positionScreen.copy(z.positionScreen);g.v3.positionScreen.copy(x.positionScreen);g.normalWorld.copy(d.normalWorld);g.centroidWorld.copy(d.centroidWorld);g.centroidScreen.copy(d.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterial=U;g.faceMaterial=q.material;g.overdraw=Q;if(s.geometry.uvs[i]){g.uvs[0]=s.geometry.uvs[i][1];g.uvs[1]=s.geometry.uvs[i][2];g.uvs[2]=s.geometry.uvs[i][3]}b.push(g);h++}}}}else if(s instanceof THREE.Line){O.multiply(F,L);t=s.geometry.vertices;
+d.centroidWorld.copy(q.centroid);L.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);F.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=T;d.faceMaterial=q.material;d.overdraw=Q;if(s.geometry.uvs[i]){d.uvs[0]=s.geometry.uvs[i][0];d.uvs[1]=s.geometry.uvs[i][1];d.uvs[2]=s.geometry.uvs[i][3]}b.push(d);h++;g=o[h]=o[h]||new THREE.RenderableFace3;g.v1.positionWorld.copy(j.positionWorld);g.v2.positionWorld.copy(z.positionWorld);g.v3.positionWorld.copy(x.positionWorld);
+g.v1.positionScreen.copy(j.positionScreen);g.v2.positionScreen.copy(z.positionScreen);g.v3.positionScreen.copy(x.positionScreen);g.normalWorld.copy(d.normalWorld);g.centroidWorld.copy(d.centroidWorld);g.centroidScreen.copy(d.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterial=T;g.faceMaterial=q.material;g.overdraw=Q;if(s.geometry.uvs[i]){g.uvs[0]=s.geometry.uvs[i][1];g.uvs[1]=s.geometry.uvs[i][2];g.uvs[2]=s.geometry.uvs[i][3]}b.push(g);h++}}}}else if(s instanceof THREE.Line){O.multiply(F,L);t=s.geometry.vertices;
 H=t[0];H.positionScreen.copy(H.position);O.transformVector4(H.positionScreen);i=1;for(p=t.length;i<p;i++){k=t[i];k.positionScreen.copy(k.position);O.transformVector4(k.positionScreen);j=t[i-1];J.copy(k.positionScreen);M.copy(j.positionScreen);if(a(J,M)){J.multiplyScalar(1/J.w);M.multiplyScalar(1/M.w);m=l[r]=l[r]||new THREE.RenderableLine;m.v1.positionScreen.copy(J);m.v2.positionScreen.copy(M);m.z=Math.max(J.z,M.z);m.material=s.material;b.push(m);r++}}}else if(s instanceof THREE.Particle){w.set(s.position.x,
-s.position.y,s.position.z,1);F.transformVector4(w);w.z/=w.w;if(w.z>0&&w.z<1){c=G[y]=G[y]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(w.x+B.projectionMatrix.n11)/(w.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(w.y+B.projectionMatrix.n22)/(w.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);y++}}}b.sort(function(P,E){return E.z-P.z});return b};this.unprojectVector=function(T,B){var e=new THREE.Matrix4;
-e.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));e.transformVector3(T);return T}};
+s.position.y,s.position.z,1);F.transformVector4(w);w.z/=w.w;if(w.z>0&&w.z<1){c=G[y]=G[y]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(w.x+B.projectionMatrix.n11)/(w.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(w.y+B.projectionMatrix.n22)/(w.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);y++}}}b.sort(function(P,D){return D.z-P.z});return b};this.unprojectVector=function(S,B){var e=new THREE.Matrix4;
+e.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));e.transformVector3(S);return S}};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,h,o;this.domElement=document.createElement("div");this.setSize=function(m,r){d=m;g=r;h=d/2;o=g/2};this.render=function(m,r){var l,c,y,G,w,F,O,J;a=b.projectScene(m,r);l=0;for(c=a.length;l<c;l++){w=a[l];if(w instanceof THREE.RenderableParticle){O=w.x*h+h;J=w.y*o+o;y=0;for(G=w.material.length;y<G;y++){F=w.material[y];if(F instanceof THREE.ParticleDOMMaterial){F=F.domElement;F.style.left=O+"px";F.style.top=J+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(I,Y,V,C){var v,K,$,N,X=I.lights;I=0;for(v=X.length;I<v;I++){K=X[I];$=K.color;N=K.intensity;if(K instanceof THREE.DirectionalLight){K=V.dot(K.position)*N;if(K>0){C.r+=$.r*K;C.g+=$.g*K;C.b+=$.b*K}}else if(K instanceof THREE.PointLight){sa.sub(K.position,Y);sa.normalize();K=V.dot(sa)*N;if(K>0){C.r+=$.r*K;C.g+=$.g*K;C.b+=$.b*K}}}}function b(I,Y,V,C,v,K){if(v.opacity!=0){o(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;U=Y.positionScreen.x;
-Q=Y.positionScreen.y;t=V.positionScreen.x;H=V.positionScreen.y;var $=L,N=u,X=U,aa=Q,Z=t,ca=H;n.beginPath();n.moveTo($,N);n.lineTo(X,aa);n.lineTo(Z,ca);n.lineTo($,N);n.closePath();if(v instanceof THREE.MeshBasicMaterial){if(v.map&&v.map.loaded)h(L,u,U,Q,t,H,v.map.image,C.uvs[0].u,C.uvs[0].v,C.uvs[1].u,C.uvs[1].v,C.uvs[2].u,C.uvs[2].v);else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);v.env_map&&v.env_map.loaded&&v.env_map.mapping==THREE.ReflectionMapping&&h(L,
-u,U,Q,t,H,v.env_map.image,C.vertexNormalsWorld[0].x*0.5+0.5,C.vertexNormalsWorld[0].y*0.5+0.5,C.vertexNormalsWorld[1].x*0.5+0.5,C.vertexNormalsWorld[1].y*0.5+0.5,C.vertexNormalsWorld[2].x*0.5+0.5,C.vertexNormalsWorld[2].y*0.5+0.5)}else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){h(L,u,U,Q,t,H,v.map.image,C.uvs[0].u,C.uvs[0].v,C.uvs[1].u,C.uvs[1].v,C.uvs[2].u,C.uvs[2].v);m(THREE.SubtractiveBlending)}if(ta)if(!v.wireframe&&v.shading==THREE.SmoothShading&&C.vertexNormalsWorld.length==
-3){z.r=x.r=P.r=ga.r;z.g=x.g=P.g=ga.g;z.b=x.b=P.b=ga.b;a(K,C.v1.positionWorld,C.vertexNormalsWorld[0],z);a(K,C.v2.positionWorld,C.vertexNormalsWorld[1],x);a(K,C.v3.positionWorld,C.vertexNormalsWorld[2],P);E.r=(x.r+P.r)*0.5;E.g=(x.g+P.g)*0.5;E.b=(x.b+P.b)*0.5;R=r(z,x,P,E);h(L,u,U,Q,t,H,R,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,C.centroidWorld,C.normalWorld,ha);q.r=v.color.r*ha.r;q.g=v.color.g*ha.g;q.b=v.color.b*ha.b;q.updateStyleString();v.wireframe?d(q.__styleString,v.wireframe_linewidth):
-g(q.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){D=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;z.r=z.g=z.b=1-D/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-D/(W-Y.positionScreen.z*ea);P.r=P.g=P.b=1-D/(W-V.positionScreen.z*ea);E.r=(x.r+P.r)*0.5;E.g=(x.g+P.g)*0.5;E.b=(x.b+P.b)*0.5;R=r(z,x,P,E);h(L,u,U,Q,t,H,R,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){q.r=l(C.normalWorld.x);q.g=l(C.normalWorld.y);
-q.b=l(C.normalWorld.z);q.updateStyleString();v.wireframe?d(q.__styleString,v.wireframe_linewidth):g(q.__styleString)}}}function d(I,Y){if(e!=I)n.strokeStyle=e=I;if(i!=Y)n.lineWidth=i=Y;n.stroke();da.inflate(Y*2)}function g(I){if(f!=I)n.fillStyle=f=I;n.fill()}function h(I,Y,V,C,v,K,$,N,X,aa,Z,ca,ka){var ja,fa;ja=$.width-1;fa=$.height-1;N*=ja;X*=fa;aa*=ja;Z*=fa;ca*=ja;ka*=fa;V-=I;C-=Y;v-=I;K-=Y;aa-=N;Z-=X;ca-=N;ka-=X;fa=1/(aa*ka-ca*Z);ja=(ka*V-Z*v)*fa;Z=(ka*C-Z*K)*fa;V=(aa*v-ca*V)*fa;C=(aa*K-ca*C)*
-fa;I=I-ja*N-V*X;Y=Y-Z*N-C*X;n.save();n.transform(ja,Z,V,C,I,Y);n.clip();n.drawImage($,0,0);n.restore()}function o(I){if(T!=I)n.globalAlpha=T=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}B=I}}function r(I,Y,V,C){ia[0]=k(0,p(255,~~(I.r*255)));ia[1]=k(0,p(255,~~(I.g*255)));ia[2]=k(0,p(255,~~(I.b*255)));
-ia[4]=k(0,p(255,~~(Y.r*255)));ia[5]=k(0,p(255,~~(Y.g*255)));ia[6]=k(0,p(255,~~(Y.b*255)));ia[8]=k(0,p(255,~~(V.r*255)));ia[9]=k(0,p(255,~~(V.g*255)));ia[10]=k(0,p(255,~~(V.b*255)));ia[12]=k(0,p(255,~~(C.r*255)));ia[13]=k(0,p(255,~~(C.g*255)));ia[14]=k(0,p(255,~~(C.b*255)));oa.putImageData(ua,0,0);ra.drawImage(pa,0,0);return qa}function l(I){return I<0?p((1+I)*0.5,0.5):0.5+p(I*0.5,0.5)}function c(I,Y){var V=Y.x-I.x,C=Y.y-I.y,v=1/Math.sqrt(V*V+C*C);V*=v;C*=v;Y.x+=V;Y.y+=C;I.x-=V;I.y-=C}var y=null,G=
-new THREE.Projector,w=document.createElement("canvas"),F,O,J,M,n=w.getContext("2d"),T=1,B=0,e=null,f=null,i=1,p=Math.min,k=Math.max,j,A,s,L,u,U,Q,t,H,q=new THREE.Color,z=new THREE.Color,x=new THREE.Color,P=new THREE.Color,E=new THREE.Color,D,W,ea,R,S=new THREE.Rectangle,ba=new THREE.Rectangle,da=new THREE.Rectangle,ta=false,ha=new THREE.Color,ga=new THREE.Color,la=new THREE.Color,ma=new THREE.Color,xa=Math.PI*2,sa=new THREE.Vector3,pa,oa,ua,ia,qa,ra,na=16;pa=document.createElement("canvas");pa.width=
-pa.height=2;oa=pa.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);ua=oa.getImageData(0,0,2,2);ia=ua.data;qa=document.createElement("canvas");qa.width=qa.height=na;ra=qa.getContext("2d");ra.translate(-na/2,-na/2);ra.scale(na,na);na--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;O=Y;J=F/2;M=O/2;w.width=F;w.height=O;S.set(-J,-M,J,M)};this.clear=function(){if(!ba.isEmpty()){ba.inflate(1);ba.minSelf(S);n.clearRect(ba.getX(),ba.getY(),ba.getWidth(),ba.getHeight());
-ba.empty()}};this.render=function(I,Y){var V,C,v,K,$,N,X,aa;n.setTransform(1,0,0,-1,J,M);this.autoClear&&this.clear();y=G.projectScene(I,Y);n.fillStyle="rgba(0, 255, 255, 0.5)";n.fillRect(S.getX(),S.getY(),S.getWidth(),S.getHeight());if(ta=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);la.setRGB(0,0,0);ma.setRGB(0,0,0);V=0;for(C=$.length;V<C;V++){v=$[V];K=v.color;if(v instanceof THREE.AmbientLight){ga.r+=K.r;ga.g+=K.g;ga.b+=K.b}else if(v instanceof THREE.DirectionalLight){la.r+=K.r;la.g+=K.g;la.b+=
-K.b}else if(v instanceof THREE.PointLight){ma.r+=K.r;ma.g+=K.g;ma.b+=K.b}}}V=0;for(C=y.length;V<C;V++){v=y[V];da.empty();if(v instanceof THREE.RenderableParticle){j=v;j.x*=J;j.y*=M;K=0;for($=v.material.length;K<$;K++)a:{N=j;X=v;var Z=v.material[K];if(Z.opacity!=0){o(Z.opacity);m(Z.blending);aa=void 0;var ca=void 0,ka=void 0,ja=void 0,fa=void 0,va=void 0,wa=void 0;if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){fa=Z.map;va=fa.width>>1;wa=fa.height>>1;ka=X.scale.x*J;ja=X.scale.y*M;aa=ka*va;ca=
-ja*wa;da.set(N.x-aa,N.y-ca,N.x+aa,N.y+ca);if(!S.instersects(da))break a;n.save();n.translate(N.x,N.y);n.rotate(-X.rotation);n.scale(ka,-ja);n.translate(-va,-wa);n.drawImage(fa,0,0);n.restore()}n.beginPath();n.moveTo(N.x-10,N.y);n.lineTo(N.x+10,N.y);n.moveTo(N.x,N.y-10);n.lineTo(N.x,N.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(Z instanceof THREE.ParticleCircleMaterial){if(ta){ha.r=ga.r+la.r+ma.r;ha.g=ga.g+la.g+ma.g;ha.b=ga.b+la.b+ma.b;q.r=Z.color.r*ha.r;q.g=Z.color.g*ha.g;
-q.b=Z.color.b*ha.b;q.updateStyleString()}else q.__styleString=Z.color.__styleString;aa=X.scale.x*J;ca=X.scale.y*M;da.set(N.x-aa,N.y-ca,N.x+aa,N.y+ca);if(S.instersects(da)){Z=q.__styleString;if(f!=Z)n.fillStyle=f=Z;n.save();n.translate(N.x,N.y);n.rotate(-X.rotation);n.scale(aa,ca);n.beginPath();n.arc(0,0,1,0,xa,true);n.closePath();n.fill();n.restore()}}}}}else if(v instanceof THREE.RenderableLine){j=v.v1;A=v.v2;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;
-da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);if(S.instersects(da)){K=0;for($=v.material.length;K<$;){X=j;aa=A;N=v.material[K++];if(N.opacity!=0){o(N.opacity);m(N.blending);n.beginPath();n.moveTo(X.positionScreen.x,X.positionScreen.y);n.lineTo(aa.positionScreen.x,aa.positionScreen.y);n.closePath();if(N instanceof THREE.LineBasicMaterial){q.__styleString=N.color.__styleString;X=N.linewidth;if(i!=X)n.lineWidth=i=X;X=q.__styleString;if(e!=X)n.strokeStyle=
-e=X;n.stroke();da.inflate(N.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){j=v.v1;A=v.v2;s=v.v3;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;s.positionScreen.x*=J;s.positionScreen.y*=M;if(v.overdraw){c(j.positionScreen,A.positionScreen);c(A.positionScreen,s.positionScreen);c(s.positionScreen,j.positionScreen)}da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);da.addPoint(s.positionScreen.x,
-s.positionScreen.y);if(S.instersects(da)){K=0;for($=v.meshMaterial.length;K<$;){aa=v.meshMaterial[K++];if(aa instanceof THREE.MeshFaceMaterial){N=0;for(X=v.faceMaterial.length;N<X;)(aa=v.faceMaterial[N++])&&b(j,A,s,v,aa,I)}else b(j,A,s,v,aa,I)}}}ba.addRectangle(da)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(ba.getX(),ba.getY(),ba.getWidth(),ba.getHeight());n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(q,z,x){var P,E,D,W;P=0;for(E=q.lights.length;P<E;P++){D=q.lights[P];if(D instanceof THREE.DirectionalLight){W=z.normalWorld.dot(D.position)*D.intensity;if(W>0){x.r+=D.color.r*W;x.g+=D.color.g*W;x.b+=D.color.b*W}}else if(D instanceof THREE.PointLight){j.sub(D.position,z.centroidWorld);j.normalize();W=z.normalWorld.dot(j)*D.intensity;if(W>0){x.r+=D.color.r*W;x.g+=D.color.g*W;x.b+=D.color.b*W}}}}function b(q,z,x,P,E,D){u=g(U++);u.setAttribute("d","M "+q.positionScreen.x+
-" "+q.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)B.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(T){e.r=f.r;e.g=f.g;e.b=f.b;a(D,P,e);B.r=E.color.r*e.r;B.g=E.color.g*e.g;B.b=E.color.b*e.b;B.updateStyleString()}else B.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){k=1-E.__2near/(E.__farPlusNear-P.z*E.__farMinusNear);
-B.setRGB(k,k,k)}else E instanceof THREE.MeshNormalMaterial&&B.setRGB(h(P.normalWorld.x),h(P.normalWorld.y),h(P.normalWorld.z));E.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+E.opacity);r.appendChild(u)}function d(q,z,x,P,E,D,W){u=g(U++);u.setAttribute("d",
-"M "+q.positionScreen.x+" "+q.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(T){e.r=f.r;e.g=f.g;e.b=f.b;a(W,E,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){k=
-1-D.__2near/(D.__farPlusNear-E.z*D.__farMinusNear);B.setRGB(k,k,k)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(h(E.normalWorld.x),h(E.normalWorld.y),h(E.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);r.appendChild(u)}
-function g(q){if(A[q]==null){A[q]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&A[q].setAttribute("shape-rendering","crispEdges");return A[q]}return A[q]}function h(q){return q<0?Math.min((1+q)*0.5,0.5):0.5+Math.min(q*0.5,0.5)}var o=null,m=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,y,G,w,F,O,J,M=new THREE.Rectangle,n=new THREE.Rectangle,T=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),i=new THREE.Color(0),
-p=new THREE.Color(0),k,j=new THREE.Vector3,A=[],s=[],L=[],u,U,Q,t,H=1;this.domElement=r;this.autoClear=true;this.setQuality=function(q){switch(q){case "high":H=1;break;case "low":H=0}};this.setSize=function(q,z){l=q;c=z;y=l/2;G=c/2;r.setAttribute("viewBox",-y+" "+-G+" "+l+" "+c);r.setAttribute("width",l);r.setAttribute("height",c);M.set(-y,-G,y,G)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(q,z){var x,P,E,D,W,ea,R,S;this.autoClear&&this.clear();
-o=m.projectScene(q,z);t=Q=U=0;if(T=q.lights.length>0){R=q.lights;f.setRGB(0,0,0);i.setRGB(0,0,0);p.setRGB(0,0,0);x=0;for(P=R.length;x<P;x++){E=R[x];D=E.color;if(E instanceof THREE.AmbientLight){f.r+=D.r;f.g+=D.g;f.b+=D.b}else if(E instanceof THREE.DirectionalLight){i.r+=D.r;i.g+=D.g;i.b+=D.b}else if(E instanceof THREE.PointLight){p.r+=D.r;p.g+=D.g;p.b+=D.b}}}x=0;for(P=o.length;x<P;x++){R=o[x];n.empty();if(R instanceof THREE.RenderableParticle){w=R;w.x*=y;w.y*=-G;E=0;for(D=R.material.length;E<D;E++)if(S=
-R.material[E]){W=w;ea=R;S=S;var ba=Q++;if(s[ba]==null){s[ba]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&s[ba].setAttribute("shape-rendering","crispEdges")}u=s[ba];u.setAttribute("cx",W.x);u.setAttribute("cy",W.y);u.setAttribute("r",ea.scale.x*y);if(S instanceof THREE.ParticleCircleMaterial){if(T){e.r=f.r+i.r+p.r;e.g=f.g+i.g+p.g;e.b=f.b+i.b+p.b;B.r=S.color.r*e.r;B.g=S.color.g*e.g;B.b=S.color.b*e.b;B.updateStyleString()}else B=S.color;u.setAttribute("style","fill: "+B.__styleString)}r.appendChild(u)}}else if(R instanceof
-THREE.RenderableLine){w=R.v1;F=R.v2;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;n.addPoint(w.positionScreen.x,w.positionScreen.y);n.addPoint(F.positionScreen.x,F.positionScreen.y);if(M.instersects(n)){E=0;for(D=R.material.length;E<D;)if(S=R.material[E++]){W=w;ea=F;S=S;ba=t++;if(L[ba]==null){L[ba]=document.createElementNS("http://www.w3.org/2000/svg","line");H==0&&L[ba].setAttribute("shape-rendering","crispEdges")}u=L[ba];u.setAttribute("x1",W.positionScreen.x);
-u.setAttribute("y1",W.positionScreen.y);u.setAttribute("x2",ea.positionScreen.x);u.setAttribute("y2",ea.positionScreen.y);if(S instanceof THREE.LineBasicMaterial){B.__styleString=S.color.__styleString;u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin);r.appendChild(u)}}}}else if(R instanceof THREE.RenderableFace3){w=R.v1;F=R.v2;O=R.v3;w.positionScreen.x*=y;w.positionScreen.y*=
--G;F.positionScreen.x*=y;F.positionScreen.y*=-G;O.positionScreen.x*=y;O.positionScreen.y*=-G;n.addPoint(w.positionScreen.x,w.positionScreen.y);n.addPoint(F.positionScreen.x,F.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);if(M.instersects(n)){E=0;for(D=R.meshMaterial.length;E<D;){S=R.meshMaterial[E++];if(S instanceof THREE.MeshFaceMaterial){W=0;for(ea=R.faceMaterial.length;W<ea;)(S=R.faceMaterial[W++])&&b(w,F,O,R,S,q)}else S&&b(w,F,O,R,S,q)}}}else if(R instanceof THREE.RenderableFace4){w=
-R.v1;F=R.v2;O=R.v3;J=R.v4;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;O.positionScreen.x*=y;O.positionScreen.y*=-G;J.positionScreen.x*=y;J.positionScreen.y*=-G;n.addPoint(w.positionScreen.x,w.positionScreen.y);n.addPoint(F.positionScreen.x,F.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);n.addPoint(J.positionScreen.x,J.positionScreen.y);if(M.instersects(n)){E=0;for(D=R.meshMaterial.length;E<D;){S=R.meshMaterial[E++];if(S instanceof
-THREE.MeshFaceMaterial){W=0;for(ea=R.faceMaterial.length;W<ea;)(S=R.faceMaterial[W++])&&d(w,F,O,J,R,S,q)}else S&&d(w,F,O,J,R,S,q)}}}}}};
+THREE.CanvasRenderer=function(){function a(I,Y,U,E){var v,K,$,N,X=I.lights;I=0;for(v=X.length;I<v;I++){K=X[I];$=K.color;N=K.intensity;if(K instanceof THREE.DirectionalLight){K=U.dot(K.position)*N;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}else if(K instanceof THREE.PointLight){aa.sub(K.position,Y);aa.normalize();K=U.dot(aa)*N;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}}}function b(I,Y,U,E,v,K){if(v.opacity!=0){o(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;T=Y.positionScreen.x;
+Q=Y.positionScreen.y;t=U.positionScreen.x;H=U.positionScreen.y;var $=L,N=u,X=T,ba=Q,Z=t,ca=H;n.beginPath();n.moveTo($,N);n.lineTo(X,ba);n.lineTo(Z,ca);n.lineTo($,N);n.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)h(L,u,T,Q,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(E.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+
+aa.z*camera.matrix.n13)*0.5+0.5;ka=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[1]);za=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Aa=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[2]);Ba=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Ca=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*
+0.5+0.5;h(L,u,T,Q,t,H,v.env_map.image,V,ka,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){h(L,u,T,Q,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){z.r=x.r=P.r=ga.r;z.g=x.g=P.g=ga.g;z.b=x.b=P.b=ga.b;a(K,E.v1.positionWorld,
+E.vertexNormalsWorld[0],z);a(K,E.v2.positionWorld,E.vertexNormalsWorld[1],x);a(K,E.v3.positionWorld,E.vertexNormalsWorld[2],P);D.r=(x.r+P.r)*0.5;D.g=(x.g+P.g)*0.5;D.b=(x.b+P.b)*0.5;R=r(z,x,P,D);h(L,u,T,Q,t,H,R,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,E.centroidWorld,E.normalWorld,ha);q.r=v.color.r*ha.r;q.g=v.color.g*ha.g;q.b=v.color.b*ha.b;q.updateStyleString();v.wireframe?d(q.__styleString,v.wireframe_linewidth):g(q.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):
+g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){C=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;z.r=z.g=z.b=1-C/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-C/(W-Y.positionScreen.z*ea);P.r=P.g=P.b=1-C/(W-U.positionScreen.z*ea);D.r=(x.r+P.r)*0.5;D.g=(x.g+P.g)*0.5;D.b=(x.b+P.b)*0.5;R=r(z,x,P,D);h(L,u,T,Q,t,H,R,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){q.r=l(E.normalWorld.x);q.g=l(E.normalWorld.y);q.b=l(E.normalWorld.z);q.updateStyleString();v.wireframe?d(q.__styleString,
+v.wireframe_linewidth):g(q.__styleString)}}}function d(I,Y){if(e!=I)n.strokeStyle=e=I;if(i!=Y)n.lineWidth=i=Y;n.stroke();da.inflate(Y*2)}function g(I){if(f!=I)n.fillStyle=f=I;n.fill()}function h(I,Y,U,E,v,K,$,N,X,ba,Z,ca,na){var la,fa;la=$.width-1;fa=$.height-1;N*=la;X*=fa;ba*=la;Z*=fa;ca*=la;na*=fa;U-=I;E-=Y;v-=I;K-=Y;ba-=N;Z-=X;ca-=N;na-=X;fa=1/(ba*na-ca*Z);la=(na*U-Z*v)*fa;Z=(na*E-Z*K)*fa;U=(ba*v-ca*U)*fa;E=(ba*K-ca*E)*fa;I=I-la*N-U*X;Y=Y-Z*N-E*X;n.save();n.transform(la,Z,U,E,I,Y);n.clip();n.drawImage($,
+0,0);n.restore()}function o(I){if(S!=I)n.globalAlpha=S=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}B=I}}function r(I,Y,U,E){ia[0]=k(0,p(255,~~(I.r*255)));ia[1]=k(0,p(255,~~(I.g*255)));ia[2]=k(0,p(255,~~(I.b*255)));ia[4]=k(0,p(255,~~(Y.r*255)));ia[5]=k(0,p(255,~~(Y.g*255)));ia[6]=k(0,p(255,~~(Y.b*255)));
+ia[8]=k(0,p(255,~~(U.r*255)));ia[9]=k(0,p(255,~~(U.g*255)));ia[10]=k(0,p(255,~~(U.b*255)));ia[12]=k(0,p(255,~~(E.r*255)));ia[13]=k(0,p(255,~~(E.g*255)));ia[14]=k(0,p(255,~~(E.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?p((1+I)*0.5,0.5):0.5+p(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,E=Y.y-I.y,v=1/Math.sqrt(U*U+E*E);U*=v;E*=v;Y.x+=U;Y.y+=E;I.x-=U;I.y-=E}var y=null,G=new THREE.Projector,w=document.createElement("canvas"),F,O,J,M,n=w.getContext("2d"),S=1,B=
+0,e=null,f=null,i=1,p=Math.min,k=Math.max,j,A,s,L,u,T,Q,t,H,q=new THREE.Color,z=new THREE.Color,x=new THREE.Color,P=new THREE.Color,D=new THREE.Color,C,W,ea,R,V,ka,za,Aa,Ba,Ca,ma=new THREE.Rectangle,ja=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,oa=new THREE.Color,pa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0,
+0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;O=Y;J=F/2;M=O/2;w.width=F;w.height=O;ma.set(-J,-M,J,M)};this.clear=function(){if(!ja.isEmpty()){ja.inflate(1);ja.minSelf(ma);n.clearRect(ja.getX(),ja.getY(),ja.getWidth(),ja.getHeight());ja.empty()}};this.render=function(I,Y){var U,E,v,K,$,N,X,ba;n.setTransform(1,
+0,0,-1,J,M);this.autoClear&&this.clear();y=G.projectScene(I,Y);n.fillStyle="rgba(0, 255, 255, 0.5)";n.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);oa.setRGB(0,0,0);pa.setRGB(0,0,0);U=0;for(E=$.length;U<E;U++){v=$[U];K=v.color;if(v instanceof THREE.AmbientLight){ga.r+=K.r;ga.g+=K.g;ga.b+=K.b}else if(v instanceof THREE.DirectionalLight){oa.r+=K.r;oa.g+=K.g;oa.b+=K.b}else if(v instanceof THREE.PointLight){pa.r+=K.r;pa.g+=K.g;pa.b+=K.b}}}U=
+0;for(E=y.length;U<E;U++){v=y[U];da.empty();if(v instanceof THREE.RenderableParticle){j=v;j.x*=J;j.y*=M;K=0;for($=v.material.length;K<$;K++)a:{N=j;X=v;var Z=v.material[K];if(Z.opacity!=0){o(Z.opacity);m(Z.blending);ba=void 0;var ca=void 0,na=void 0,la=void 0,fa=void 0,xa=void 0,ya=void 0;if(Z instanceof THREE.ParticleBasicMaterial){if(Z.map){fa=Z.map;xa=fa.width>>1;ya=fa.height>>1;na=X.scale.x*J;la=X.scale.y*M;ba=na*xa;ca=la*ya;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(!ma.instersects(da))break a;n.save();
+n.translate(N.x,N.y);n.rotate(-X.rotation);n.scale(na,-la);n.translate(-xa,-ya);n.drawImage(fa,0,0);n.restore()}n.beginPath();n.moveTo(N.x-10,N.y);n.lineTo(N.x+10,N.y);n.moveTo(N.x,N.y-10);n.lineTo(N.x,N.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(Z instanceof THREE.ParticleCircleMaterial){if(va){ha.r=ga.r+oa.r+pa.r;ha.g=ga.g+oa.g+pa.g;ha.b=ga.b+oa.b+pa.b;q.r=Z.color.r*ha.r;q.g=Z.color.g*ha.g;q.b=Z.color.b*ha.b;q.updateStyleString()}else q.__styleString=Z.color.__styleString;
+ba=X.scale.x*J;ca=X.scale.y*M;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(ma.instersects(da)){Z=q.__styleString;if(f!=Z)n.fillStyle=f=Z;n.save();n.translate(N.x,N.y);n.rotate(-X.rotation);n.scale(ba,ca);n.beginPath();n.arc(0,0,1,0,Da,true);n.closePath();n.fill();n.restore()}}}}}else if(v instanceof THREE.RenderableLine){j=v.v1;A=v.v2;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,
+A.positionScreen.y);if(ma.instersects(da)){K=0;for($=v.material.length;K<$;){X=j;ba=A;N=v.material[K++];if(N.opacity!=0){o(N.opacity);m(N.blending);n.beginPath();n.moveTo(X.positionScreen.x,X.positionScreen.y);n.lineTo(ba.positionScreen.x,ba.positionScreen.y);n.closePath();if(N instanceof THREE.LineBasicMaterial){q.__styleString=N.color.__styleString;X=N.linewidth;if(i!=X)n.lineWidth=i=X;X=q.__styleString;if(e!=X)n.strokeStyle=e=X;n.stroke();da.inflate(N.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){j=
+v.v1;A=v.v2;s=v.v3;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;s.positionScreen.x*=J;s.positionScreen.y*=M;if(v.overdraw){c(j.positionScreen,A.positionScreen);c(A.positionScreen,s.positionScreen);c(s.positionScreen,j.positionScreen)}da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);da.addPoint(s.positionScreen.x,s.positionScreen.y);if(ma.instersects(da)){K=0;for($=v.meshMaterial.length;K<$;){ba=v.meshMaterial[K++];
+if(ba instanceof THREE.MeshFaceMaterial){N=0;for(X=v.faceMaterial.length;N<X;)(ba=v.faceMaterial[N++])&&b(j,A,s,v,ba,I)}else b(j,A,s,v,ba,I)}}}ja.addRectangle(da)}n.lineWidth=1;n.strokeStyle="rgba( 255, 0, 0, 0.5 )";n.strokeRect(ja.getX(),ja.getY(),ja.getWidth(),ja.getHeight());n.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(q,z,x){var P,D,C,W;P=0;for(D=q.lights.length;P<D;P++){C=q.lights[P];if(C instanceof THREE.DirectionalLight){W=z.normalWorld.dot(C.position)*C.intensity;if(W>0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){j.sub(C.position,z.centroidWorld);j.normalize();W=z.normalWorld.dot(j)*C.intensity;if(W>0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}}}function b(q,z,x,P,D,C){u=g(T++);u.setAttribute("d","M "+q.positionScreen.x+
+" "+q.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(S){e.r=f.r;e.g=f.g;e.b=f.b;a(C,P,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){k=1-D.__2near/(D.__farPlusNear-P.z*D.__farMinusNear);
+B.setRGB(k,k,k)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(h(P.normalWorld.x),h(P.normalWorld.y),h(P.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);r.appendChild(u)}function d(q,z,x,P,D,C,W){u=g(T++);u.setAttribute("d",
+"M "+q.positionScreen.x+" "+q.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(S){e.r=f.r;e.g=f.g;e.b=f.b;a(W,D,e);B.r=C.color.r*e.r;B.g=C.color.g*e.g;B.b=C.color.b*e.b;B.updateStyleString()}else B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){k=
+1-C.__2near/(C.__farPlusNear-D.z*C.__farMinusNear);B.setRGB(k,k,k)}else C instanceof THREE.MeshNormalMaterial&&B.setRGB(h(D.normalWorld.x),h(D.normalWorld.y),h(D.normalWorld.z));C.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+C.opacity);r.appendChild(u)}
+function g(q){if(A[q]==null){A[q]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&A[q].setAttribute("shape-rendering","crispEdges");return A[q]}return A[q]}function h(q){return q<0?Math.min((1+q)*0.5,0.5):0.5+Math.min(q*0.5,0.5)}var o=null,m=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,y,G,w,F,O,J,M=new THREE.Rectangle,n=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),i=new THREE.Color(0),
+p=new THREE.Color(0),k,j=new THREE.Vector3,A=[],s=[],L=[],u,T,Q,t,H=1;this.domElement=r;this.autoClear=true;this.setQuality=function(q){switch(q){case "high":H=1;break;case "low":H=0}};this.setSize=function(q,z){l=q;c=z;y=l/2;G=c/2;r.setAttribute("viewBox",-y+" "+-G+" "+l+" "+c);r.setAttribute("width",l);r.setAttribute("height",c);M.set(-y,-G,y,G)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(q,z){var x,P,D,C,W,ea,R,V;this.autoClear&&this.clear();
+o=m.projectScene(q,z);t=Q=T=0;if(S=q.lights.length>0){R=q.lights;f.setRGB(0,0,0);i.setRGB(0,0,0);p.setRGB(0,0,0);x=0;for(P=R.length;x<P;x++){D=R[x];C=D.color;if(D instanceof THREE.AmbientLight){f.r+=C.r;f.g+=C.g;f.b+=C.b}else if(D instanceof THREE.DirectionalLight){i.r+=C.r;i.g+=C.g;i.b+=C.b}else if(D instanceof THREE.PointLight){p.r+=C.r;p.g+=C.g;p.b+=C.b}}}x=0;for(P=o.length;x<P;x++){R=o[x];n.empty();if(R instanceof THREE.RenderableParticle){w=R;w.x*=y;w.y*=-G;D=0;for(C=R.material.length;D<C;D++)if(V=
+R.material[D]){W=w;ea=R;V=V;var ka=Q++;if(s[ka]==null){s[ka]=document.createElementNS("http://www.w3.org/2000/svg","circle");H==0&&s[ka].setAttribute("shape-rendering","crispEdges")}u=s[ka];u.setAttribute("cx",W.x);u.setAttribute("cy",W.y);u.setAttribute("r",ea.scale.x*y);if(V instanceof THREE.ParticleCircleMaterial){if(S){e.r=f.r+i.r+p.r;e.g=f.g+i.g+p.g;e.b=f.b+i.b+p.b;B.r=V.color.r*e.r;B.g=V.color.g*e.g;B.b=V.color.b*e.b;B.updateStyleString()}else B=V.color;u.setAttribute("style","fill: "+B.__styleString)}r.appendChild(u)}}else if(R instanceof
+THREE.RenderableLine){w=R.v1;F=R.v2;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;n.addPoint(w.positionScreen.x,w.positionScreen.y);n.addPoint(F.positionScreen.x,F.positionScreen.y);if(M.instersects(n)){D=0;for(C=R.material.length;D<C;)if(V=R.material[D++]){W=w;ea=F;V=V;ka=t++;if(L[ka]==null){L[ka]=document.createElementNS("http://www.w3.org/2000/svg","line");H==0&&L[ka].setAttribute("shape-rendering","crispEdges")}u=L[ka];u.setAttribute("x1",W.positionScreen.x);
+u.setAttribute("y1",W.positionScreen.y);u.setAttribute("x2",ea.positionScreen.x);u.setAttribute("y2",ea.positionScreen.y);if(V instanceof THREE.LineBasicMaterial){B.__styleString=V.color.__styleString;u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+V.linewidth+"; stroke-opacity: "+V.opacity+"; stroke-linecap: "+V.linecap+"; stroke-linejoin: "+V.linejoin);r.appendChild(u)}}}}else if(R instanceof THREE.RenderableFace3){w=R.v1;F=R.v2;O=R.v3;w.positionScreen.x*=y;w.positionScreen.y*=
+-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;O.positionScreen.x*=y;O.positionScreen.y*=-G;n.addPoint(w.positionScreen.x,w.positionScreen.y);n.addPoint(F.positionScreen.x,F.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);if(M.instersects(n)){D=0;for(C=R.meshMaterial.length;D<C;){V=R.meshMaterial[D++];if(V instanceof THREE.MeshFaceMaterial){W=0;for(ea=R.faceMaterial.length;W<ea;)(V=R.faceMaterial[W++])&&b(w,F,O,R,V,q)}else V&&b(w,F,O,R,V,q)}}}else if(R instanceof THREE.RenderableFace4){w=
+R.v1;F=R.v2;O=R.v3;J=R.v4;w.positionScreen.x*=y;w.positionScreen.y*=-G;F.positionScreen.x*=y;F.positionScreen.y*=-G;O.positionScreen.x*=y;O.positionScreen.y*=-G;J.positionScreen.x*=y;J.positionScreen.y*=-G;n.addPoint(w.positionScreen.x,w.positionScreen.y);n.addPoint(F.positionScreen.x,F.positionScreen.y);n.addPoint(O.positionScreen.x,O.positionScreen.y);n.addPoint(J.positionScreen.x,J.positionScreen.y);if(M.instersects(n)){D=0;for(C=R.meshMaterial.length;D<C;){V=R.meshMaterial[D++];if(V instanceof
+THREE.MeshFaceMaterial){W=0;for(ea=R.faceMaterial.length;W<ea;)(V=R.faceMaterial[W++])&&d(w,F,O,J,R,V,q)}else V&&d(w,F,O,J,R,V,q)}}}}}};
 THREE.WebGLRenderer=function(a){function b(e,f){var i=c.createProgram();c.attachShader(i,m("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+e));c.attachShader(i,m("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+f));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,
 c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};return i}function d(e,f){if(e instanceof THREE.TextureCube&&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 i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function g(e,f){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,r(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,r(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+f);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}
 function h(e,f){var i,p,k;i=0;for(p=f.length;i<p;i++){k=f[i];e.uniforms[k]=c.getUniformLocation(e,k)}}function o(e){e.position=c.getAttribLocation(e,"position");c.enableVertexAttribArray(e.position);e.normal=c.getAttribLocation(e,"normal");c.enableVertexAttribArray(e.normal);e.uv=c.getAttribLocation(e,"uv");c.enableVertexAttribArray(e.uv)}function m(e,f){var i;if(e=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")i=c.createShader(c.VERTEX_SHADER);c.shaderSource(i,f);c.compileShader(i);
-if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}function r(e){switch(e){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var l=document.createElement("canvas"),c,y,G,w=new THREE.Matrix4,F,O=new Float32Array(16),J=new Float32Array(16),M=new Float32Array(16),n=new Float32Array(9),T=new Float32Array(16);a=function(e,f){if(e){var i,p,k,j=pointLights=maxDirLights=maxPointLights=
+if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}function r(e){switch(e){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var l=document.createElement("canvas"),c,y,G,w=new THREE.Matrix4,F,O=new Float32Array(16),J=new Float32Array(16),M=new Float32Array(16),n=new Float32Array(9),S=new Float32Array(16);a=function(e,f){if(e){var i,p,k,j=pointLights=maxDirLights=maxPointLights=
 0;i=0;for(p=e.lights.length;i<p;i++){k=e.lights[i];k instanceof THREE.DirectionalLight&&j++;k instanceof THREE.PointLight&&pointLights++}if(pointLights+j<=f){maxDirLights=j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(f*j/(pointLights+j));maxPointLights=f-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:f-1}}(a,4);this.domElement=l;this.autoClear=true;try{c=l.getContext("experimental-webgl",{antialias:true})}catch(B){}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);(function(e,f){var i=[e?"#define MAX_DIR_LIGHTS "+e:"",f?"#define MAX_POINT_LIGHTS "+f:"","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 ];":"",f?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",f?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",f?"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;",
@@ -146,14 +148,14 @@ y=b(p,i);c.useProgram(y);h(y,["viewMatrix","modelViewMatrix","projectionMatrix",
 "pointLightPosition"]);c.uniform1i(y.uniforms.enableMap,0);c.uniform1i(y.uniforms.tMap,0);c.uniform1i(y.uniforms.enableCubeMap,0);c.uniform1i(y.uniforms.tCube,1);c.uniform1i(y.uniforms.mixEnvMap,0);c.uniform1i(y.uniforms.useRefract,0);o(y)})(a.directional,a.point);this.setSize=function(e,f){l.width=e;l.height=f;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,f){var i,p,k,j,A,s=[],L=[],u=[];j=[];A=[];c.uniform1i(e.uniforms.enableLighting,
 f.lights.length);i=0;for(p=f.lights.length;i<p;i++){k=f.lights[i];if(k instanceof THREE.AmbientLight)s.push(k);else if(k instanceof THREE.DirectionalLight)u.push(k);else k instanceof THREE.PointLight&&L.push(k)}i=k=j=A=0;for(p=s.length;i<p;i++){k+=s[i].color.r;j+=s[i].color.g;A+=s[i].color.b}c.uniform3f(e.uniforms.ambientLightColor,k,j,A);j=[];A=[];i=0;for(p=u.length;i<p;i++){k=u[i];j.push(k.color.r*k.intensity);j.push(k.color.g*k.intensity);j.push(k.color.b*k.intensity);A.push(k.position.x);A.push(k.position.y);
 A.push(k.position.z)}if(u.length){c.uniform1i(e.uniforms.directionalLightNumber,u.length);c.uniform3fv(e.uniforms.directionalLightDirection,A);c.uniform3fv(e.uniforms.directionalLightColor,j)}j=[];A=[];i=0;for(p=L.length;i<p;i++){k=L[i];j.push(k.color.r*k.intensity);j.push(k.color.g*k.intensity);j.push(k.color.b*k.intensity);A.push(k.position.x);A.push(k.position.y);A.push(k.position.z)}if(L.length){c.uniform1i(e.uniforms.pointLightNumber,L.length);c.uniform3fv(e.uniforms.pointLightPosition,A);c.uniform3fv(e.uniforms.pointLightColor,
-j)}};this.createBuffers=function(e,f){var i,p,k,j,A,s,L,u,U=[],Q=[],t=[],H=[],q=[],z=0,x=e.materialFaceGroup[f],P;k=false;i=0;for(p=e.material.length;i<p;i++){meshMaterial=e.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){A=0;for(P=x.material.length;A<P;A++)if(x.material[A]&&x.material[A].shading!=undefined&&x.material[A].shading==THREE.SmoothShading){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){k=true;break}if(k)break}P=
-k;i=0;for(p=x.faces.length;i<p;i++){k=x.faces[i];j=e.geometry.faces[k];A=j.vertexNormals;faceNormal=j.normal;k=e.geometry.uvs[k];if(j instanceof THREE.Face3){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);if(A.length==3&&P)for(j=0;j<3;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<3;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<3;j++)q.push(k[j].u,k[j].v);U.push(z,
-z+1,z+2);Q.push(z,z+1);Q.push(z,z+2);Q.push(z+1,z+2);z+=3}else if(j instanceof THREE.Face4){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;j=e.geometry.vertices[j.d].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);t.push(j.x,j.y,j.z);if(A.length==4&&P)for(j=0;j<4;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<4;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<4;j++)q.push(k[j].u,k[j].v);U.push(z,z+
-1,z+2);U.push(z,z+2,z+3);Q.push(z,z+1);Q.push(z,z+2);Q.push(z,z+3);Q.push(z+1,z+2);Q.push(z+2,z+3);z+=4}}if(t.length){x.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(t),c.STATIC_DRAW);x.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);x.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);
-c.bufferData(c.ARRAY_BUFFER,new Float32Array(q),c.STATIC_DRAW);x.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(U),c.STATIC_DRAW);x.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);x.__webGLFaceCount=U.length;x.__webGLLineCount=Q.length}};this.renderBuffer=function(e,f,i){var p,k,j,A,s,L,u,
-U,Q,t;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in f.uniforms)u.push(t);h(f.program,u);o(f.program)}t=f.program}else t=y;if(t!=G){c.useProgram(t);G=t}if(f instanceof THREE.MeshShaderMaterial){u=t;U=f.uniforms;var H,q;for(k in U){H=U[k].type;Q=U[k].value;q=u.uniforms[k];if(H=="i")c.uniform1i(q,Q);else if(H=="f")c.uniform1f(q,Q);else if(H==
-"t"){c.uniform1i(q,Q);H=U[k].texture;if(H instanceof THREE.TextureCube)d(H,Q);else H instanceof THREE.Texture&&g(H,Q)}}this.loadCamera(t,e);this.loadMatrices(t)}else if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){e=f.color;p=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;s=f.map;L=f.env_map;u=f.combine==THREE.Mix;k=f.reflectivity;Q=f.env_map&&f.env_map.mapping==THREE.RefractionMapping;U=f.refraction_ratio;c.uniform4f(t.uniforms.mColor,
-e.r*p,e.g*p,e.b*p,p);c.uniform1i(t.uniforms.mixEnvMap,u);c.uniform1f(t.uniforms.mReflectivity,k);c.uniform1i(t.uniforms.useRefract,Q);c.uniform1f(t.uniforms.mRefractionRatio,U)}if(f instanceof THREE.MeshNormalMaterial){p=f.opacity;c.uniform1f(t.uniforms.mOpacity,p);c.uniform1i(t.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){p=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,p);c.uniform1f(t.uniforms.m2Near,f.__2near);c.uniform1f(t.uniforms.mFarPlusNear,
+j)}};this.createBuffers=function(e,f){var i,p,k,j,A,s,L,u,T=[],Q=[],t=[],H=[],q=[],z=0,x=e.materialFaceGroup[f],P;k=false;i=0;for(p=e.material.length;i<p;i++){meshMaterial=e.material[i];if(meshMaterial instanceof THREE.MeshFaceMaterial){A=0;for(P=x.material.length;A<P;A++)if(x.material[A]&&x.material[A].shading!=undefined&&x.material[A].shading==THREE.SmoothShading){k=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){k=true;break}if(k)break}P=
+k;i=0;for(p=x.faces.length;i<p;i++){k=x.faces[i];j=e.geometry.faces[k];A=j.vertexNormals;faceNormal=j.normal;k=e.geometry.uvs[k];if(j instanceof THREE.Face3){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);if(A.length==3&&P)for(j=0;j<3;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<3;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<3;j++)q.push(k[j].u,k[j].v);T.push(z,
+z+1,z+2);Q.push(z,z+1);Q.push(z,z+2);Q.push(z+1,z+2);z+=3}else if(j instanceof THREE.Face4){s=e.geometry.vertices[j.a].position;L=e.geometry.vertices[j.b].position;u=e.geometry.vertices[j.c].position;j=e.geometry.vertices[j.d].position;t.push(s.x,s.y,s.z);t.push(L.x,L.y,L.z);t.push(u.x,u.y,u.z);t.push(j.x,j.y,j.z);if(A.length==4&&P)for(j=0;j<4;j++)H.push(A[j].x,A[j].y,A[j].z);else for(j=0;j<4;j++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(k)for(j=0;j<4;j++)q.push(k[j].u,k[j].v);T.push(z,z+
+1,z+2);T.push(z,z+2,z+3);Q.push(z,z+1);Q.push(z,z+2);Q.push(z,z+3);Q.push(z+1,z+2);Q.push(z+2,z+3);z+=4}}if(t.length){x.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(t),c.STATIC_DRAW);x.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);x.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);
+c.bufferData(c.ARRAY_BUFFER,new Float32Array(q),c.STATIC_DRAW);x.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);x.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);x.__webGLFaceCount=T.length;x.__webGLLineCount=Q.length}};this.renderBuffer=function(e,f,i){var p,k,j,A,s,L,u,
+T,Q,t;if(f instanceof THREE.MeshShaderMaterial){if(!f.program){f.program=b(f.fragment_shader,f.vertex_shader);u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in f.uniforms)u.push(t);h(f.program,u);o(f.program)}t=f.program}else t=y;if(t!=G){c.useProgram(t);G=t}if(f instanceof THREE.MeshShaderMaterial){u=t;T=f.uniforms;var H,q;for(k in T){H=T[k].type;Q=T[k].value;q=u.uniforms[k];if(H=="i")c.uniform1i(q,Q);else if(H=="f")c.uniform1f(q,Q);else if(H==
+"t"){c.uniform1i(q,Q);H=T[k].texture;if(H instanceof THREE.TextureCube)d(H,Q);else H instanceof THREE.Texture&&g(H,Q)}}this.loadCamera(t,e);this.loadMatrices(t)}else if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){e=f.color;p=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;s=f.map;L=f.env_map;u=f.combine==THREE.Mix;k=f.reflectivity;Q=f.env_map&&f.env_map.mapping==THREE.RefractionMapping;T=f.refraction_ratio;c.uniform4f(t.uniforms.mColor,
+e.r*p,e.g*p,e.b*p,p);c.uniform1i(t.uniforms.mixEnvMap,u);c.uniform1f(t.uniforms.mReflectivity,k);c.uniform1i(t.uniforms.useRefract,Q);c.uniform1f(t.uniforms.mRefractionRatio,T)}if(f instanceof THREE.MeshNormalMaterial){p=f.opacity;c.uniform1f(t.uniforms.mOpacity,p);c.uniform1i(t.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){p=f.opacity;j=f.wireframe;A=f.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,p);c.uniform1f(t.uniforms.m2Near,f.__2near);c.uniform1f(t.uniforms.mFarPlusNear,
 f.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(f instanceof THREE.MeshPhongMaterial){e=f.ambient;k=f.specular;f=f.shininess;c.uniform4f(t.uniforms.mAmbient,e.r,e.g,e.b,p);c.uniform4f(t.uniforms.mSpecular,k.r,k.g,k.b,p);c.uniform1f(t.uniforms.mShininess,f);c.uniform1i(t.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,
 0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);L=f.env_map}if(s){g(s,0);c.uniform1i(t.uniforms.tMap,0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(L){d(L,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLVertexBuffer);c.vertexAttribPointer(t.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLNormalBuffer);
 c.vertexAttribPointer(t.normal,3,c.FLOAT,false,0,0);if(s){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUVBuffer);c.enableVertexAttribArray(t.uv);c.vertexAttribPointer(t.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(t.uv);if(j){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);c.drawElements(c.LINES,i.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,i.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=
@@ -161,7 +163,7 @@ function(e,f,i,p,k){var j,A,s,L,u;s=0;for(L=f.material.length;s<L;s++){j=f.mater
 f);this.setupLights(y,e);i=0;for(p=e.__webGLObjects.length;i<p;i++){webGLObject=e.__webGLObjects[i];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,f);this.loadMatrices(y);this.renderPass(f,webGLObject.__object,webGLObject,THREE.NormalBlending,false)}}i=0;for(p=e.__webGLObjects.length;i<p;i++){webGLObject=e.__webGLObjects[i];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,f);this.loadMatrices(y);this.renderPass(f,webGLObject.__object,webGLObject,THREE.AdditiveBlending,
 false);this.renderPass(f,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,false);this.renderPass(f,webGLObject.__object,webGLObject,THREE.AdditiveBlending,true);this.renderPass(f,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,true);this.renderPass(f,webGLObject.__object,webGLObject,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var f,i,p,k,j;if(!e.__webGLObjects)e.__webGLObjects=[];f=0;for(i=e.objects.length;f<i;f++){p=e.objects[f];if(p instanceof THREE.Mesh)for(k in p.materialFaceGroup){j=
 p.materialFaceGroup[k];if(!j.__webGLVertexBuffer){this.createBuffers(p,k);j.__object=p;e.__webGLObjects.push(j)}}}};this.removeObject=function(e,f){var i,p;for(i=e.__webGLObjects.length-1;i>=0;i--){p=e.__webGLObjects[i].__object;f==p&&e.__webGLObjects.splice(i,1)}};this.setupMatrices=function(e,f){e.autoUpdateMatrix&&e.updateMatrix();w.multiply(f.matrix,e.matrix);O.set(f.matrix.flatten());J.set(w.flatten());M.set(f.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(w).transpose();n.set(F.m);
-T.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,O);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,n);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,T)};this.loadCamera=function(e,f){c.uniform3f(e.uniforms.cameraPosition,f.position.x,f.position.y,f.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
+S.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,O);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,n);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,S)};this.loadCamera=function(e,f){c.uniform3f(e.uniforms.cameraPosition,f.position.x,f.position.y,f.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,f){if(e){!f||f=="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)}};
 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};

+ 62 - 61
build/ThreeExtras.js

@@ -5,9 +5,10 @@ THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this
 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,d){this.x=a||0;this.y=b||0;this.z=d||0};
 THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;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,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,
-0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
+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,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*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,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
+Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
+THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1};
 THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
@@ -21,8 +22,8 @@ THREE.Matrix4=function(){};
 THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,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},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},lookAt:function(a,b,d){var e=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*
 d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},transformVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;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 d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,m=a.n23,c=a.n24,s=a.n31,E=a.n32,r=a.n33,w=a.n34,v=a.n41,x=a.n42,L=a.n43,u=a.n44,A=b.n11,l=b.n12,h=b.n13,i=b.n14,n=b.n21,y=b.n22,p=b.n23,o=b.n24,G=b.n31,B=b.n32,R=b.n33,F=b.n34,W=b.n41,V=b.n42,D=b.n43,
-P=b.n44;this.n11=d*A+e*n+f*G+j*W;this.n12=d*l+e*y+f*B+j*V;this.n13=d*h+e*p+f*R+j*D;this.n14=d*i+e*o+f*F+j*P;this.n21=k*A+g*n+m*G+c*W;this.n22=k*l+g*y+m*B+c*V;this.n23=k*h+g*p+m*R+c*D;this.n24=k*i+g*o+m*F+c*P;this.n31=s*A+E*n+r*G+w*W;this.n32=s*l+E*y+r*B+w*V;this.n33=s*h+E*p+r*R+w*D;this.n34=s*i+E*o+r*F+w*P;this.n41=v*A+x*n+L*G+u*W;this.n42=v*l+x*y+L*B+u*V;this.n43=v*h+x*p+L*R+u*D;this.n44=v*i+x*o+L*F+u*P},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22,
+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 d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,m=a.n23,c=a.n24,s=a.n31,E=a.n32,r=a.n33,w=a.n34,v=a.n41,x=a.n42,L=a.n43,u=a.n44,A=b.n11,l=b.n12,h=b.n13,i=b.n14,n=b.n21,y=b.n22,p=b.n23,o=b.n24,G=b.n31,B=b.n32,Q=b.n33,F=b.n34,V=b.n41,U=b.n42,D=b.n43,
+P=b.n44;this.n11=d*A+e*n+f*G+j*V;this.n12=d*l+e*y+f*B+j*U;this.n13=d*h+e*p+f*Q+j*D;this.n14=d*i+e*o+f*F+j*P;this.n21=k*A+g*n+m*G+c*V;this.n22=k*l+g*y+m*B+c*U;this.n23=k*h+g*p+m*Q+c*D;this.n24=k*i+g*o+m*F+c*P;this.n31=s*A+E*n+r*G+w*V;this.n32=s*l+E*y+r*B+w*U;this.n33=s*h+E*p+r*Q+w*D;this.n34=s*i+E*o+r*F+w*P;this.n41=v*A+x*n+L*G+u*V;this.n42=v*l+x*y+L*B+u*U;this.n43=v*h+x*p+L*Q+u*D;this.n44=v*i+x*o+L*F+u*P},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22,
 g=this.n23,m=this.n24,c=this.n31,s=this.n32,E=this.n33,r=this.n34,w=this.n41,v=this.n42,x=this.n43,L=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+m*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+m*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+m*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+m*a.n44;this.n31=c*a.n11+s*a.n21+E*a.n31+r*a.n41;this.n32=c*a.n12+s*a.n22+
 E*a.n32+r*a.n42;this.n33=c*a.n13+s*a.n23+E*a.n33+r*a.n43;this.n34=c*a.n14+s*a.n24+E*a.n34+r*a.n44;this.n41=w*a.n11+v*a.n21+x*a.n31+L*a.n41;this.n42=w*a.n12+v*a.n22+x*a.n32+L*a.n42;this.n43=w*a.n13+v*a.n23+x*a.n33+L*a.n43;this.n44=w*a.n14+v*a.n24+x*a.n34+L*a.n44},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},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*
@@ -83,44 +84,44 @@ THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function()
 THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){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.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(A,l){var h=0,i=1,n=A.z+A.w,y=l.z+l.w,p=-A.z+A.w,o=-l.z+l.w;if(n>=0&&y>=0&&p>=0&&o>=0)return true;else if(n<0&&y<0||p<0&&o<0)return false;else{if(n<0)h=Math.max(h,n/(n-y));else if(y<0)i=Math.min(i,n/(n-y));if(p<0)h=Math.max(h,p/(p-o));else if(o<0)i=Math.min(i,p/(p-o));if(i<h)return false;else{A.lerpSelf(l,h);l.lerpSelf(A,1-i);return true}}}var b=null,d,e,f,j=[],k,g,m=[],c,s,E=[],r=new THREE.Vector4,w=new THREE.Matrix4,v=new THREE.Matrix4,x=new THREE.Vector4,L=
-new THREE.Vector4,u;this.projectScene=function(A,l){var h,i,n,y,p,o,G,B,R,F,W,V,D,P,C,K,I;b=[];f=g=s=0;l.autoUpdateMatrix&&l.updateMatrix();w.multiply(l.projectionMatrix,l.matrix);G=A.objects;h=0;for(i=G.length;h<i;h++){B=G[h];B.autoUpdateMatrix&&B.updateMatrix();R=B.matrix;F=B.rotationMatrix;W=B.material;V=B.overdraw;if(B instanceof THREE.Mesh){D=B.geometry.vertices;n=0;for(y=D.length;n<y;n++){P=D[n];P.positionWorld.copy(P.position);R.transformVector3(P.positionWorld);C=P.positionScreen;C.copy(P.positionWorld);
-w.transformVector4(C);C.multiplyScalar(1/C.w);P.__visible=C.z>0&&C.z<1}P=B.geometry.faces;n=0;for(y=P.length;n<y;n++){C=P[n];if(C instanceof THREE.Face3){p=D[C.a];o=D[C.b];K=D[C.c];if(p.__visible&&o.__visible&&K.__visible)if(B.doubleSided||B.flipSided!=(K.positionScreen.x-p.positionScreen.x)*(o.positionScreen.y-p.positionScreen.y)-(K.positionScreen.y-p.positionScreen.y)*(o.positionScreen.x-p.positionScreen.x)<0){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(p.positionWorld);d.v2.positionWorld.copy(o.positionWorld);
-d.v3.positionWorld.copy(K.positionWorld);d.v1.positionScreen.copy(p.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(K.positionScreen);d.normalWorld.copy(C.normal);F.transformVector3(d.normalWorld);d.centroidWorld.copy(C.centroid);R.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);w.transformVector3(d.centroidScreen);K=C.vertexNormals;u=d.vertexNormalsWorld;p=0;for(o=K.length;p<o;p++){I=u[p]=u[p]||new THREE.Vector3;I.copy(K[p]);F.transformVector3(I)}d.z=
-d.centroidScreen.z;d.meshMaterial=W;d.faceMaterial=C.material;d.overdraw=V;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][2]}b.push(d);f++}}else if(C instanceof THREE.Face4){p=D[C.a];o=D[C.b];K=D[C.c];I=D[C.d];if(p.__visible&&o.__visible&&K.__visible&&I.__visible)if(B.doubleSided||B.flipSided!=((I.positionScreen.x-p.positionScreen.x)*(o.positionScreen.y-p.positionScreen.y)-(I.positionScreen.y-p.positionScreen.y)*(o.positionScreen.x-p.positionScreen.x)<
-0||(o.positionScreen.x-K.positionScreen.x)*(I.positionScreen.y-K.positionScreen.y)-(o.positionScreen.y-K.positionScreen.y)*(I.positionScreen.x-K.positionScreen.x)<0)){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(p.positionWorld);d.v2.positionWorld.copy(o.positionWorld);d.v3.positionWorld.copy(I.positionWorld);d.v1.positionScreen.copy(p.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(I.positionScreen);d.normalWorld.copy(C.normal);F.transformVector3(d.normalWorld);
-d.centroidWorld.copy(C.centroid);R.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);w.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=W;d.faceMaterial=C.material;d.overdraw=V;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][3]}b.push(d);f++;e=j[f]=j[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(o.positionWorld);e.v2.positionWorld.copy(K.positionWorld);e.v3.positionWorld.copy(I.positionWorld);
-e.v1.positionScreen.copy(o.positionScreen);e.v2.positionScreen.copy(K.positionScreen);e.v3.positionScreen.copy(I.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=W;e.faceMaterial=C.material;e.overdraw=V;if(B.geometry.uvs[n]){e.uvs[0]=B.geometry.uvs[n][1];e.uvs[1]=B.geometry.uvs[n][2];e.uvs[2]=B.geometry.uvs[n][3]}b.push(e);f++}}}}else if(B instanceof THREE.Line){v.multiply(w,R);D=B.geometry.vertices;
+new THREE.Vector4,u;this.projectScene=function(A,l){var h,i,n,y,p,o,G,B,Q,F,V,U,D,P,C,J,I;b=[];f=g=s=0;l.autoUpdateMatrix&&l.updateMatrix();w.multiply(l.projectionMatrix,l.matrix);G=A.objects;h=0;for(i=G.length;h<i;h++){B=G[h];B.autoUpdateMatrix&&B.updateMatrix();Q=B.matrix;F=B.rotationMatrix;V=B.material;U=B.overdraw;if(B instanceof THREE.Mesh){D=B.geometry.vertices;n=0;for(y=D.length;n<y;n++){P=D[n];P.positionWorld.copy(P.position);Q.transformVector3(P.positionWorld);C=P.positionScreen;C.copy(P.positionWorld);
+w.transformVector4(C);C.multiplyScalar(1/C.w);P.__visible=C.z>0&&C.z<1}P=B.geometry.faces;n=0;for(y=P.length;n<y;n++){C=P[n];if(C instanceof THREE.Face3){p=D[C.a];o=D[C.b];J=D[C.c];if(p.__visible&&o.__visible&&J.__visible)if(B.doubleSided||B.flipSided!=(J.positionScreen.x-p.positionScreen.x)*(o.positionScreen.y-p.positionScreen.y)-(J.positionScreen.y-p.positionScreen.y)*(o.positionScreen.x-p.positionScreen.x)<0){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(p.positionWorld);d.v2.positionWorld.copy(o.positionWorld);
+d.v3.positionWorld.copy(J.positionWorld);d.v1.positionScreen.copy(p.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(J.positionScreen);d.normalWorld.copy(C.normal);F.transformVector3(d.normalWorld);d.centroidWorld.copy(C.centroid);Q.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);w.transformVector3(d.centroidScreen);J=C.vertexNormals;u=d.vertexNormalsWorld;p=0;for(o=J.length;p<o;p++){I=u[p]=u[p]||new THREE.Vector3;I.copy(J[p]);F.transformVector3(I)}d.z=
+d.centroidScreen.z;d.meshMaterial=V;d.faceMaterial=C.material;d.overdraw=U;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][2]}b.push(d);f++}}else if(C instanceof THREE.Face4){p=D[C.a];o=D[C.b];J=D[C.c];I=D[C.d];if(p.__visible&&o.__visible&&J.__visible&&I.__visible)if(B.doubleSided||B.flipSided!=((I.positionScreen.x-p.positionScreen.x)*(o.positionScreen.y-p.positionScreen.y)-(I.positionScreen.y-p.positionScreen.y)*(o.positionScreen.x-p.positionScreen.x)<
+0||(o.positionScreen.x-J.positionScreen.x)*(I.positionScreen.y-J.positionScreen.y)-(o.positionScreen.y-J.positionScreen.y)*(I.positionScreen.x-J.positionScreen.x)<0)){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(p.positionWorld);d.v2.positionWorld.copy(o.positionWorld);d.v3.positionWorld.copy(I.positionWorld);d.v1.positionScreen.copy(p.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(I.positionScreen);d.normalWorld.copy(C.normal);F.transformVector3(d.normalWorld);
+d.centroidWorld.copy(C.centroid);Q.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);w.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=V;d.faceMaterial=C.material;d.overdraw=U;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][3]}b.push(d);f++;e=j[f]=j[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(o.positionWorld);e.v2.positionWorld.copy(J.positionWorld);e.v3.positionWorld.copy(I.positionWorld);
+e.v1.positionScreen.copy(o.positionScreen);e.v2.positionScreen.copy(J.positionScreen);e.v3.positionScreen.copy(I.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=V;e.faceMaterial=C.material;e.overdraw=U;if(B.geometry.uvs[n]){e.uvs[0]=B.geometry.uvs[n][1];e.uvs[1]=B.geometry.uvs[n][2];e.uvs[2]=B.geometry.uvs[n][3]}b.push(e);f++}}}}else if(B instanceof THREE.Line){v.multiply(w,Q);D=B.geometry.vertices;
 P=D[0];P.positionScreen.copy(P.position);v.transformVector4(P.positionScreen);n=1;for(y=D.length;n<y;n++){p=D[n];p.positionScreen.copy(p.position);v.transformVector4(p.positionScreen);o=D[n-1];x.copy(p.positionScreen);L.copy(o.positionScreen);if(a(x,L)){x.multiplyScalar(1/x.w);L.multiplyScalar(1/L.w);k=m[g]=m[g]||new THREE.RenderableLine;k.v1.positionScreen.copy(x);k.v2.positionScreen.copy(L);k.z=Math.max(x.z,L.z);k.material=B.material;b.push(k);g++}}}else if(B instanceof THREE.Particle){r.set(B.position.x,
-B.position.y,B.position.z,1);w.transformVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=E[s]=E[s]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+l.projectionMatrix.n11)/(r.w+l.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+l.projectionMatrix.n22)/(r.w+l.projectionMatrix.n24));c.material=B.material;b.push(c);s++}}}b.sort(function(U,N){return N.z-U.z});return b};this.unprojectVector=function(A,l){var h=new THREE.Matrix4;
+B.position.y,B.position.z,1);w.transformVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=E[s]=E[s]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+l.projectionMatrix.n11)/(r.w+l.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+l.projectionMatrix.n22)/(r.w+l.projectionMatrix.n24));c.material=B.material;b.push(c);s++}}}b.sort(function(T,N){return N.z-T.z});return b};this.unprojectVector=function(A,l){var h=new THREE.Matrix4;
 h.multiply(THREE.Matrix4.makeInvert(l.matrix),THREE.Matrix4.makeInvert(l.projectionMatrix));h.transformVector3(A);return A}};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var m,c,s,E,r,w,v,x;a=b.projectScene(k,g);m=0;for(c=a.length;m<c;m++){r=a[m];if(r instanceof THREE.RenderableParticle){v=r.x*f+f;x=r.y*j+j;s=0;for(E=r.material.length;s<E;s++){w=r.material[s];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=v+"px";w.style.top=x+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(S,aa,Z,O){var H,T,ca,X,$=S.lights;S=0;for(H=$.length;S<H;S++){T=$[S];ca=T.color;X=T.intensity;if(T instanceof THREE.DirectionalLight){T=Z.dot(T.position)*X;if(T>0){O.r+=ca.r*T;O.g+=ca.g*T;O.b+=ca.b*T}}else if(T instanceof THREE.PointLight){ta.sub(T.position,aa);ta.normalize();T=Z.dot(ta)*X;if(T>0){O.r+=ca.r*T;O.g+=ca.g*T;O.b+=ca.b*T}}}}function b(S,aa,Z,O,H,T){if(H.opacity!=0){j(H.opacity);k(H.blending);R=S.positionScreen.x;F=S.positionScreen.y;W=aa.positionScreen.x;
-V=aa.positionScreen.y;D=Z.positionScreen.x;P=Z.positionScreen.y;var ca=R,X=F,$=W,da=V,ba=D,ha=P;u.beginPath();u.moveTo(ca,X);u.lineTo($,da);u.lineTo(ba,ha);u.lineTo(ca,X);u.closePath();if(H instanceof THREE.MeshBasicMaterial){if(H.map&&H.map.loaded)f(R,F,W,V,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):e(H.color.__styleString);H.env_map&&H.env_map.loaded&&H.env_map.mapping==THREE.ReflectionMapping&&
-f(R,F,W,V,D,P,H.env_map.image,O.vertexNormalsWorld[0].x*0.5+0.5,O.vertexNormalsWorld[0].y*0.5+0.5,O.vertexNormalsWorld[1].x*0.5+0.5,O.vertexNormalsWorld[1].y*0.5+0.5,O.vertexNormalsWorld[2].x*0.5+0.5,O.vertexNormalsWorld[2].y*0.5+0.5)}else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){f(R,F,W,V,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);k(THREE.SubtractiveBlending)}if(fa)if(!H.wireframe&&H.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==
-3){K.r=I.r=U.r=ga.r;K.g=I.g=U.g=ga.g;K.b=I.b=U.b=ga.b;a(T,O.v1.positionWorld,O.vertexNormalsWorld[0],K);a(T,O.v2.positionWorld,O.vertexNormalsWorld[1],I);a(T,O.v3.positionWorld,O.vertexNormalsWorld[2],U);N.r=(I.r+U.r)*0.5;N.g=(I.g+U.g)*0.5;N.b=(I.b+U.b)*0.5;t=g(K,I,U,N);f(R,F,W,V,D,P,t,0,0,1,0,0,1)}else{ea.r=ga.r;ea.g=ga.g;ea.b=ga.b;a(T,O.centroidWorld,O.normalWorld,ea);C.r=H.color.r*ea.r;C.g=H.color.g*ea.g;C.b=H.color.b*ea.b;C.updateStyleString();H.wireframe?d(C.__styleString,H.wireframe_linewidth):
-e(C.__styleString)}else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):e(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){M=H.__2near;Y=H.__farPlusNear;q=H.__farMinusNear;K.r=K.g=K.b=1-M/(Y-S.positionScreen.z*q);I.r=I.g=I.b=1-M/(Y-aa.positionScreen.z*q);U.r=U.g=U.b=1-M/(Y-Z.positionScreen.z*q);N.r=(I.r+U.r)*0.5;N.g=(I.g+U.g)*0.5;N.b=(I.b+U.b)*0.5;t=g(K,I,U,N);f(R,F,W,V,D,P,t,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){C.r=m(O.normalWorld.x);C.g=m(O.normalWorld.y);
-C.b=m(O.normalWorld.z);C.updateStyleString();H.wireframe?d(C.__styleString,H.wireframe_linewidth):e(C.__styleString)}}}function d(S,aa){if(h!=S)u.strokeStyle=h=S;if(n!=aa)u.lineWidth=n=aa;u.stroke();Q.inflate(aa*2)}function e(S){if(i!=S)u.fillStyle=i=S;u.fill()}function f(S,aa,Z,O,H,T,ca,X,$,da,ba,ha,ma){var ka,ia;ka=ca.width-1;ia=ca.height-1;X*=ka;$*=ia;da*=ka;ba*=ia;ha*=ka;ma*=ia;Z-=S;O-=aa;H-=S;T-=aa;da-=X;ba-=$;ha-=X;ma-=$;ia=1/(da*ma-ha*ba);ka=(ma*Z-ba*H)*ia;ba=(ma*O-ba*T)*ia;Z=(da*H-ha*Z)*ia;
-O=(da*T-ha*O)*ia;S=S-ka*X-Z*$;aa=aa-ba*X-O*$;u.save();u.transform(ka,ba,Z,O,S,aa);u.clip();u.drawImage(ca,0,0);u.restore()}function j(S){if(A!=S)u.globalAlpha=A=S}function k(S){if(l!=S){switch(S){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}l=S}}function g(S,aa,Z,O){ja[0]=p(0,y(255,~~(S.r*255)));ja[1]=p(0,y(255,~~(S.g*255)));ja[2]=p(0,
-y(255,~~(S.b*255)));ja[4]=p(0,y(255,~~(aa.r*255)));ja[5]=p(0,y(255,~~(aa.g*255)));ja[6]=p(0,y(255,~~(aa.b*255)));ja[8]=p(0,y(255,~~(Z.r*255)));ja[9]=p(0,y(255,~~(Z.g*255)));ja[10]=p(0,y(255,~~(Z.b*255)));ja[12]=p(0,y(255,~~(O.r*255)));ja[13]=p(0,y(255,~~(O.g*255)));ja[14]=p(0,y(255,~~(O.b*255)));pa.putImageData(ua,0,0);sa.drawImage(qa,0,0);return ra}function m(S){return S<0?y((1+S)*0.5,0.5):0.5+y(S*0.5,0.5)}function c(S,aa){var Z=aa.x-S.x,O=aa.y-S.y,H=1/Math.sqrt(Z*Z+O*O);Z*=H;O*=H;aa.x+=Z;aa.y+=
-O;S.x-=Z;S.y-=O}var s=null,E=new THREE.Projector,r=document.createElement("canvas"),w,v,x,L,u=r.getContext("2d"),A=1,l=0,h=null,i=null,n=1,y=Math.min,p=Math.max,o,G,B,R,F,W,V,D,P,C=new THREE.Color,K=new THREE.Color,I=new THREE.Color,U=new THREE.Color,N=new THREE.Color,M,Y,q,t,z=new THREE.Rectangle,J=new THREE.Rectangle,Q=new THREE.Rectangle,fa=false,ea=new THREE.Color,ga=new THREE.Color,la=new THREE.Color,na=new THREE.Color,xa=Math.PI*2,ta=new THREE.Vector3,qa,pa,ua,ja,ra,sa,oa=16;qa=document.createElement("canvas");
-qa.width=qa.height=2;pa=qa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);ua=pa.getImageData(0,0,2,2);ja=ua.data;ra=document.createElement("canvas");ra.width=ra.height=oa;sa=ra.getContext("2d");sa.translate(-oa/2,-oa/2);sa.scale(oa,oa);oa--;this.domElement=r;this.autoClear=true;this.setSize=function(S,aa){w=S;v=aa;x=w/2;L=v/2;r.width=w;r.height=v;z.set(-x,-L,x,L)};this.clear=function(){if(!J.isEmpty()){J.inflate(1);J.minSelf(z);u.clearRect(J.getX(),J.getY(),J.getWidth(),J.getHeight());
-J.empty()}};this.render=function(S,aa){var Z,O,H,T,ca,X,$,da;u.setTransform(1,0,0,-1,x,L);this.autoClear&&this.clear();s=E.projectScene(S,aa);if(fa=S.lights.length>0){ca=S.lights;ga.setRGB(0,0,0);la.setRGB(0,0,0);na.setRGB(0,0,0);Z=0;for(O=ca.length;Z<O;Z++){H=ca[Z];T=H.color;if(H instanceof THREE.AmbientLight){ga.r+=T.r;ga.g+=T.g;ga.b+=T.b}else if(H instanceof THREE.DirectionalLight){la.r+=T.r;la.g+=T.g;la.b+=T.b}else if(H instanceof THREE.PointLight){na.r+=T.r;na.g+=T.g;na.b+=T.b}}}Z=0;for(O=s.length;Z<
-O;Z++){H=s[Z];Q.empty();if(H instanceof THREE.RenderableParticle){o=H;o.x*=x;o.y*=L;T=0;for(ca=H.material.length;T<ca;T++){X=o;$=H;var ba=H.material[T];if(ba.opacity!=0){j(ba.opacity);k(ba.blending);da=void 0;var ha=void 0,ma=void 0,ka=void 0,ia=void 0,va=void 0,wa=void 0;if(ba instanceof THREE.ParticleBasicMaterial){if(ba.map){ia=ba.map;va=ia.width>>1;wa=ia.height>>1;ma=$.scale.x*x;ka=$.scale.y*L;da=ma*va;ha=ka*wa;Q.set(X.x-da,X.y-ha,X.x+da,X.y+ha);if(z.instersects(Q)){u.save();u.translate(X.x,X.y);
-u.rotate(-$.rotation);u.scale(ma,-ka);u.translate(-va,-wa);u.drawImage(ia,0,0);u.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(fa){ea.r=ga.r+la.r+na.r;ea.g=ga.g+la.g+na.g;ea.b=ga.b+la.b+na.b;C.r=ba.color.r*ea.r;C.g=ba.color.g*ea.g;C.b=ba.color.b*ea.b;C.updateStyleString()}else C.__styleString=ba.color.__styleString;da=$.scale.x*x;ha=$.scale.y*L;Q.set(X.x-da,X.y-ha,X.x+da,X.y+ha);if(z.instersects(Q)){ba=C.__styleString;if(i!=ba)u.fillStyle=i=ba;u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);
-u.scale(da,ha);u.beginPath();u.arc(0,0,1,0,xa,true);u.closePath();u.fill();u.restore()}}}}}else if(H instanceof THREE.RenderableLine){o=H.v1;G=H.v2;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;Q.addPoint(o.positionScreen.x,o.positionScreen.y);Q.addPoint(G.positionScreen.x,G.positionScreen.y);if(z.instersects(Q)){T=0;for(ca=H.material.length;T<ca;){$=o;da=G;X=H.material[T++];if(X.opacity!=0){j(X.opacity);k(X.blending);u.beginPath();u.moveTo($.positionScreen.x,
-$.positionScreen.y);u.lineTo(da.positionScreen.x,da.positionScreen.y);u.closePath();if(X instanceof THREE.LineBasicMaterial){C.__styleString=X.color.__styleString;$=X.linewidth;if(n!=$)u.lineWidth=n=$;$=C.__styleString;if(h!=$)u.strokeStyle=h=$;u.stroke();Q.inflate(X.linewidth*2)}}}}}else if(H instanceof THREE.RenderableFace3){o=H.v1;G=H.v2;B=H.v3;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;B.positionScreen.x*=x;B.positionScreen.y*=L;if(H.overdraw){c(o.positionScreen,
-G.positionScreen);c(G.positionScreen,B.positionScreen);c(B.positionScreen,o.positionScreen)}Q.addPoint(o.positionScreen.x,o.positionScreen.y);Q.addPoint(G.positionScreen.x,G.positionScreen.y);Q.addPoint(B.positionScreen.x,B.positionScreen.y);if(z.instersects(Q)){T=0;for(ca=H.meshMaterial.length;T<ca;){da=H.meshMaterial[T++];if(da instanceof THREE.MeshFaceMaterial){X=0;for($=H.faceMaterial.length;X<$;)(da=H.faceMaterial[X++])&&b(o,G,B,H,da,S)}else b(o,G,B,H,da,S)}}}J.addRectangle(Q)}u.setTransform(1,
-0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(C,K,I){var U,N,M,Y;U=0;for(N=C.lights.length;U<N;U++){M=C.lights[U];if(M instanceof THREE.DirectionalLight){Y=K.normalWorld.dot(M.position)*M.intensity;if(Y>0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}else if(M instanceof THREE.PointLight){o.sub(M.position,K.centroidWorld);o.normalize();Y=K.normalWorld.dot(o)*M.intensity;if(Y>0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}}}function b(C,K,I,U,N,M){F=e(W++);F.setAttribute("d","M "+C.positionScreen.x+
-" "+C.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(M,U,h);l.r=N.color.r*h.r;l.g=N.color.g*h.g;l.b=N.color.b*h.b;l.updateStyleString()}else l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){p=1-N.__2near/(N.__farPlusNear-U.z*N.__farMinusNear);
-l.setRGB(p,p,p)}else N instanceof THREE.MeshNormalMaterial&&l.setRGB(f(U.normalWorld.x),f(U.normalWorld.y),f(U.normalWorld.z));N.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+N.opacity);g.appendChild(F)}function d(C,K,I,U,N,M,Y){F=e(W++);F.setAttribute("d",
-"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+K.positionScreen.x+" "+K.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(Y,N,h);l.r=M.color.r*h.r;l.g=M.color.g*h.g;l.b=M.color.b*h.b;l.updateStyleString()}else l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){p=
+THREE.CanvasRenderer=function(){function a(R,aa,Z,O){var H,S,ca,X,$=R.lights;R=0;for(H=$.length;R<H;R++){S=$[R];ca=S.color;X=S.intensity;if(S instanceof THREE.DirectionalLight){S=Z.dot(S.position)*X;if(S>0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}else if(S instanceof THREE.PointLight){da.sub(S.position,aa);da.normalize();S=Z.dot(da)*X;if(S>0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}}}function b(R,aa,Z,O,H,S){if(H.opacity!=0){j(H.opacity);k(H.blending);Q=R.positionScreen.x;F=R.positionScreen.y;V=aa.positionScreen.x;
+U=aa.positionScreen.y;D=Z.positionScreen.x;P=Z.positionScreen.y;var ca=Q,X=F,$=V,ea=U,ba=D,fa=P;u.beginPath();u.moveTo(ca,X);u.lineTo($,ea);u.lineTo(ba,fa);u.lineTo(ca,X);u.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map&&H.map.loaded)f(Q,F,V,U,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);else if(H.env_map&&H.env_map.loaded){if(H.env_map.mapping==THREE.ReflectionMapping){da.copy(O.vertexNormalsWorld[0]);z=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+
+da.z*camera.matrix.n13)*0.5+0.5;K=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*0.5+0.5;da.copy(O.vertexNormalsWorld[1]);W=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+da.z*camera.matrix.n13)*0.5+0.5;ga=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*0.5+0.5;da.copy(O.vertexNormalsWorld[2]);ma=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+da.z*camera.matrix.n13)*0.5+0.5;ua=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*
+0.5+0.5;f(Q,F,V,U,D,P,H.env_map.image,z,K,W,ga,ma,ua)}}else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):e(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){f(Q,F,V,U,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);k(THREE.SubtractiveBlending)}if(za)if(!H.wireframe&&H.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){J.r=I.r=T.r=ja.r;J.g=I.g=T.g=ja.g;J.b=I.b=T.b=ja.b;a(S,O.v1.positionWorld,O.vertexNormalsWorld[0],
+J);a(S,O.v2.positionWorld,O.vertexNormalsWorld[1],I);a(S,O.v3.positionWorld,O.vertexNormalsWorld[2],T);N.r=(I.r+T.r)*0.5;N.g=(I.g+T.g)*0.5;N.b=(I.b+T.b)*0.5;t=g(J,I,T,N);f(Q,F,V,U,D,P,t,0,0,1,0,0,1)}else{ka.r=ja.r;ka.g=ja.g;ka.b=ja.b;a(S,O.centroidWorld,O.normalWorld,ka);C.r=H.color.r*ka.r;C.g=H.color.g*ka.g;C.b=H.color.b*ka.b;C.updateStyleString();H.wireframe?d(C.__styleString,H.wireframe_linewidth):e(C.__styleString)}else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):e(H.color.__styleString)}else if(H instanceof
+THREE.MeshDepthMaterial){M=H.__2near;Y=H.__farPlusNear;q=H.__farMinusNear;J.r=J.g=J.b=1-M/(Y-R.positionScreen.z*q);I.r=I.g=I.b=1-M/(Y-aa.positionScreen.z*q);T.r=T.g=T.b=1-M/(Y-Z.positionScreen.z*q);N.r=(I.r+T.r)*0.5;N.g=(I.g+T.g)*0.5;N.b=(I.b+T.b)*0.5;t=g(J,I,T,N);f(Q,F,V,U,D,P,t,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){C.r=m(O.normalWorld.x);C.g=m(O.normalWorld.y);C.b=m(O.normalWorld.z);C.updateStyleString();H.wireframe?d(C.__styleString,H.wireframe_linewidth):e(C.__styleString)}}}
+function d(R,aa){if(h!=R)u.strokeStyle=h=R;if(n!=aa)u.lineWidth=n=aa;u.stroke();ha.inflate(aa*2)}function e(R){if(i!=R)u.fillStyle=i=R;u.fill()}function f(R,aa,Z,O,H,S,ca,X,$,ea,ba,fa,oa){var na,ia;na=ca.width-1;ia=ca.height-1;X*=na;$*=ia;ea*=na;ba*=ia;fa*=na;oa*=ia;Z-=R;O-=aa;H-=R;S-=aa;ea-=X;ba-=$;fa-=X;oa-=$;ia=1/(ea*oa-fa*ba);na=(oa*Z-ba*H)*ia;ba=(oa*O-ba*S)*ia;Z=(ea*H-fa*Z)*ia;O=(ea*S-fa*O)*ia;R=R-na*X-Z*$;aa=aa-ba*X-O*$;u.save();u.transform(na,ba,Z,O,R,aa);u.clip();u.drawImage(ca,0,0);u.restore()}
+function j(R){if(A!=R)u.globalAlpha=A=R}function k(R){if(l!=R){switch(R){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}l=R}}function g(R,aa,Z,O){la[0]=p(0,y(255,~~(R.r*255)));la[1]=p(0,y(255,~~(R.g*255)));la[2]=p(0,y(255,~~(R.b*255)));la[4]=p(0,y(255,~~(aa.r*255)));la[5]=p(0,y(255,~~(aa.g*255)));la[6]=p(0,y(255,~~(aa.b*255)));la[8]=p(0,
+y(255,~~(Z.r*255)));la[9]=p(0,y(255,~~(Z.g*255)));la[10]=p(0,y(255,~~(Z.b*255)));la[12]=p(0,y(255,~~(O.r*255)));la[13]=p(0,y(255,~~(O.g*255)));la[14]=p(0,y(255,~~(O.b*255)));va.putImageData(Aa,0,0);ya.drawImage(wa,0,0);return xa}function m(R){return R<0?y((1+R)*0.5,0.5):0.5+y(R*0.5,0.5)}function c(R,aa){var Z=aa.x-R.x,O=aa.y-R.y,H=1/Math.sqrt(Z*Z+O*O);Z*=H;O*=H;aa.x+=Z;aa.y+=O;R.x-=Z;R.y-=O}var s=null,E=new THREE.Projector,r=document.createElement("canvas"),w,v,x,L,u=r.getContext("2d"),A=1,l=0,h=
+null,i=null,n=1,y=Math.min,p=Math.max,o,G,B,Q,F,V,U,D,P,C=new THREE.Color,J=new THREE.Color,I=new THREE.Color,T=new THREE.Color,N=new THREE.Color,M,Y,q,t,z,K,W,ga,ma,ua,pa=new THREE.Rectangle,qa=new THREE.Rectangle,ha=new THREE.Rectangle,za=false,ka=new THREE.Color,ja=new THREE.Color,ra=new THREE.Color,sa=new THREE.Color,Da=Math.PI*2,da=new THREE.Vector3,wa,va,Aa,la,xa,ya,ta=16;wa=document.createElement("canvas");wa.width=wa.height=2;va=wa.getContext("2d");va.fillStyle="rgba(0,0,0,1)";va.fillRect(0,
+0,2,2);Aa=va.getImageData(0,0,2,2);la=Aa.data;xa=document.createElement("canvas");xa.width=xa.height=ta;ya=xa.getContext("2d");ya.translate(-ta/2,-ta/2);ya.scale(ta,ta);ta--;this.domElement=r;this.autoClear=true;this.setSize=function(R,aa){w=R;v=aa;x=w/2;L=v/2;r.width=w;r.height=v;pa.set(-x,-L,x,L)};this.clear=function(){if(!qa.isEmpty()){qa.inflate(1);qa.minSelf(pa);u.clearRect(qa.getX(),qa.getY(),qa.getWidth(),qa.getHeight());qa.empty()}};this.render=function(R,aa){var Z,O,H,S,ca,X,$,ea;u.setTransform(1,
+0,0,-1,x,L);this.autoClear&&this.clear();s=E.projectScene(R,aa);if(za=R.lights.length>0){ca=R.lights;ja.setRGB(0,0,0);ra.setRGB(0,0,0);sa.setRGB(0,0,0);Z=0;for(O=ca.length;Z<O;Z++){H=ca[Z];S=H.color;if(H instanceof THREE.AmbientLight){ja.r+=S.r;ja.g+=S.g;ja.b+=S.b}else if(H instanceof THREE.DirectionalLight){ra.r+=S.r;ra.g+=S.g;ra.b+=S.b}else if(H instanceof THREE.PointLight){sa.r+=S.r;sa.g+=S.g;sa.b+=S.b}}}Z=0;for(O=s.length;Z<O;Z++){H=s[Z];ha.empty();if(H instanceof THREE.RenderableParticle){o=
+H;o.x*=x;o.y*=L;S=0;for(ca=H.material.length;S<ca;S++){X=o;$=H;var ba=H.material[S];if(ba.opacity!=0){j(ba.opacity);k(ba.blending);ea=void 0;var fa=void 0,oa=void 0,na=void 0,ia=void 0,Ba=void 0,Ca=void 0;if(ba instanceof THREE.ParticleBasicMaterial){if(ba.map){ia=ba.map;Ba=ia.width>>1;Ca=ia.height>>1;oa=$.scale.x*x;na=$.scale.y*L;ea=oa*Ba;fa=na*Ca;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(oa,-na);u.translate(-Ba,-Ca);u.drawImage(ia,
+0,0);u.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(za){ka.r=ja.r+ra.r+sa.r;ka.g=ja.g+ra.g+sa.g;ka.b=ja.b+ra.b+sa.b;C.r=ba.color.r*ka.r;C.g=ba.color.g*ka.g;C.b=ba.color.b*ka.b;C.updateStyleString()}else C.__styleString=ba.color.__styleString;ea=$.scale.x*x;fa=$.scale.y*L;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){ba=C.__styleString;if(i!=ba)u.fillStyle=i=ba;u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(ea,fa);u.beginPath();u.arc(0,0,1,0,Da,true);
+u.closePath();u.fill();u.restore()}}}}}else if(H instanceof THREE.RenderableLine){o=H.v1;G=H.v2;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;ha.addPoint(o.positionScreen.x,o.positionScreen.y);ha.addPoint(G.positionScreen.x,G.positionScreen.y);if(pa.instersects(ha)){S=0;for(ca=H.material.length;S<ca;){$=o;ea=G;X=H.material[S++];if(X.opacity!=0){j(X.opacity);k(X.blending);u.beginPath();u.moveTo($.positionScreen.x,$.positionScreen.y);u.lineTo(ea.positionScreen.x,
+ea.positionScreen.y);u.closePath();if(X instanceof THREE.LineBasicMaterial){C.__styleString=X.color.__styleString;$=X.linewidth;if(n!=$)u.lineWidth=n=$;$=C.__styleString;if(h!=$)u.strokeStyle=h=$;u.stroke();ha.inflate(X.linewidth*2)}}}}}else if(H instanceof THREE.RenderableFace3){o=H.v1;G=H.v2;B=H.v3;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;B.positionScreen.x*=x;B.positionScreen.y*=L;if(H.overdraw){c(o.positionScreen,G.positionScreen);c(G.positionScreen,
+B.positionScreen);c(B.positionScreen,o.positionScreen)}ha.addPoint(o.positionScreen.x,o.positionScreen.y);ha.addPoint(G.positionScreen.x,G.positionScreen.y);ha.addPoint(B.positionScreen.x,B.positionScreen.y);if(pa.instersects(ha)){S=0;for(ca=H.meshMaterial.length;S<ca;){ea=H.meshMaterial[S++];if(ea instanceof THREE.MeshFaceMaterial){X=0;for($=H.faceMaterial.length;X<$;)(ea=H.faceMaterial[X++])&&b(o,G,B,H,ea,R)}else b(o,G,B,H,ea,R)}}}qa.addRectangle(ha)}u.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(C,J,I){var T,N,M,Y;T=0;for(N=C.lights.length;T<N;T++){M=C.lights[T];if(M instanceof THREE.DirectionalLight){Y=J.normalWorld.dot(M.position)*M.intensity;if(Y>0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}else if(M instanceof THREE.PointLight){o.sub(M.position,J.centroidWorld);o.normalize();Y=J.normalWorld.dot(o)*M.intensity;if(Y>0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}}}function b(C,J,I,T,N,M){F=e(V++);F.setAttribute("d","M "+C.positionScreen.x+
+" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(M,T,h);l.r=N.color.r*h.r;l.g=N.color.g*h.g;l.b=N.color.b*h.b;l.updateStyleString()}else l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){p=1-N.__2near/(N.__farPlusNear-T.z*N.__farMinusNear);
+l.setRGB(p,p,p)}else N instanceof THREE.MeshNormalMaterial&&l.setRGB(f(T.normalWorld.x),f(T.normalWorld.y),f(T.normalWorld.z));N.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+N.opacity);g.appendChild(F)}function d(C,J,I,T,N,M,Y){F=e(V++);F.setAttribute("d",
+"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(Y,N,h);l.r=M.color.r*h.r;l.g=M.color.g*h.g;l.b=M.color.b*h.b;l.updateStyleString()}else l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){p=
 1-M.__2near/(M.__farPlusNear-N.z*M.__farMinusNear);l.setRGB(p,p,p)}else M instanceof THREE.MeshNormalMaterial&&l.setRGB(f(N.normalWorld.x),f(N.normalWorld.y),f(N.normalWorld.z));M.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(F)}
 function e(C){if(G[C]==null){G[C]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&G[C].setAttribute("shape-rendering","crispEdges");return G[C]}return G[C]}function f(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,s,E,r,w,v,x,L=new THREE.Rectangle,u=new THREE.Rectangle,A=false,l=new THREE.Color(16777215),h=new THREE.Color(16777215),i=new THREE.Color(0),n=new THREE.Color(0),
-y=new THREE.Color(0),p,o=new THREE.Vector3,G=[],B=[],R=[],F,W,V,D,P=1;this.domElement=g;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":P=1;break;case "low":P=0}};this.setSize=function(C,K){m=C;c=K;s=m/2;E=c/2;g.setAttribute("viewBox",-s+" "+-E+" "+m+" "+c);g.setAttribute("width",m);g.setAttribute("height",c);L.set(-s,-E,s,E)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(C,K){var I,U,N,M,Y,q,t,z;this.autoClear&&this.clear();
-j=k.projectScene(C,K);D=V=W=0;if(A=C.lights.length>0){t=C.lights;i.setRGB(0,0,0);n.setRGB(0,0,0);y.setRGB(0,0,0);I=0;for(U=t.length;I<U;I++){N=t[I];M=N.color;if(N instanceof THREE.AmbientLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(N instanceof THREE.DirectionalLight){n.r+=M.r;n.g+=M.g;n.b+=M.b}else if(N instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}I=0;for(U=j.length;I<U;I++){t=j[I];u.empty();if(t instanceof THREE.RenderableParticle){r=t;r.x*=s;r.y*=-E;N=0;for(M=t.material.length;N<M;N++)if(z=
-t.material[N]){Y=r;q=t;z=z;var J=V++;if(B[J]==null){B[J]=document.createElementNS("http://www.w3.org/2000/svg","circle");P==0&&B[J].setAttribute("shape-rendering","crispEdges")}F=B[J];F.setAttribute("cx",Y.x);F.setAttribute("cy",Y.y);F.setAttribute("r",q.scale.x*s);if(z instanceof THREE.ParticleCircleMaterial){if(A){h.r=i.r+n.r+y.r;h.g=i.g+n.g+y.g;h.b=i.b+n.b+y.b;l.r=z.color.r*h.r;l.g=z.color.g*h.g;l.b=z.color.b*h.b;l.updateStyleString()}else l=z.color;F.setAttribute("style","fill: "+l.__styleString)}g.appendChild(F)}}else if(t instanceof
-THREE.RenderableLine){r=t.v1;w=t.v2;r.positionScreen.x*=s;r.positionScreen.y*=-E;w.positionScreen.x*=s;w.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.material.length;N<M;)if(z=t.material[N++]){Y=r;q=w;z=z;J=D++;if(R[J]==null){R[J]=document.createElementNS("http://www.w3.org/2000/svg","line");P==0&&R[J].setAttribute("shape-rendering","crispEdges")}F=R[J];F.setAttribute("x1",Y.positionScreen.x);
+y=new THREE.Color(0),p,o=new THREE.Vector3,G=[],B=[],Q=[],F,V,U,D,P=1;this.domElement=g;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":P=1;break;case "low":P=0}};this.setSize=function(C,J){m=C;c=J;s=m/2;E=c/2;g.setAttribute("viewBox",-s+" "+-E+" "+m+" "+c);g.setAttribute("width",m);g.setAttribute("height",c);L.set(-s,-E,s,E)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(C,J){var I,T,N,M,Y,q,t,z;this.autoClear&&this.clear();
+j=k.projectScene(C,J);D=U=V=0;if(A=C.lights.length>0){t=C.lights;i.setRGB(0,0,0);n.setRGB(0,0,0);y.setRGB(0,0,0);I=0;for(T=t.length;I<T;I++){N=t[I];M=N.color;if(N instanceof THREE.AmbientLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(N instanceof THREE.DirectionalLight){n.r+=M.r;n.g+=M.g;n.b+=M.b}else if(N instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}I=0;for(T=j.length;I<T;I++){t=j[I];u.empty();if(t instanceof THREE.RenderableParticle){r=t;r.x*=s;r.y*=-E;N=0;for(M=t.material.length;N<M;N++)if(z=
+t.material[N]){Y=r;q=t;z=z;var K=U++;if(B[K]==null){B[K]=document.createElementNS("http://www.w3.org/2000/svg","circle");P==0&&B[K].setAttribute("shape-rendering","crispEdges")}F=B[K];F.setAttribute("cx",Y.x);F.setAttribute("cy",Y.y);F.setAttribute("r",q.scale.x*s);if(z instanceof THREE.ParticleCircleMaterial){if(A){h.r=i.r+n.r+y.r;h.g=i.g+n.g+y.g;h.b=i.b+n.b+y.b;l.r=z.color.r*h.r;l.g=z.color.g*h.g;l.b=z.color.b*h.b;l.updateStyleString()}else l=z.color;F.setAttribute("style","fill: "+l.__styleString)}g.appendChild(F)}}else if(t instanceof
+THREE.RenderableLine){r=t.v1;w=t.v2;r.positionScreen.x*=s;r.positionScreen.y*=-E;w.positionScreen.x*=s;w.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.material.length;N<M;)if(z=t.material[N++]){Y=r;q=w;z=z;K=D++;if(Q[K]==null){Q[K]=document.createElementNS("http://www.w3.org/2000/svg","line");P==0&&Q[K].setAttribute("shape-rendering","crispEdges")}F=Q[K];F.setAttribute("x1",Y.positionScreen.x);
 F.setAttribute("y1",Y.positionScreen.y);F.setAttribute("x2",q.positionScreen.x);F.setAttribute("y2",q.positionScreen.y);if(z instanceof THREE.LineBasicMaterial){l.__styleString=z.color.__styleString;F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+z.linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.linecap+"; stroke-linejoin: "+z.linejoin);g.appendChild(F)}}}}else if(t instanceof THREE.RenderableFace3){r=t.v1;w=t.v2;v=t.v3;r.positionScreen.x*=s;r.positionScreen.y*=
 -E;w.positionScreen.x*=s;w.positionScreen.y*=-E;v.positionScreen.x*=s;v.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(v.positionScreen.x,v.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.meshMaterial.length;N<M;){z=t.meshMaterial[N++];if(z instanceof THREE.MeshFaceMaterial){Y=0;for(q=t.faceMaterial.length;Y<q;)(z=t.faceMaterial[Y++])&&b(r,w,v,t,z,C)}else z&&b(r,w,v,t,z,C)}}}else if(t instanceof THREE.RenderableFace4){r=
 t.v1;w=t.v2;v=t.v3;x=t.v4;r.positionScreen.x*=s;r.positionScreen.y*=-E;w.positionScreen.x*=s;w.positionScreen.y*=-E;v.positionScreen.x*=s;v.positionScreen.y*=-E;x.positionScreen.x*=s;x.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(v.positionScreen.x,v.positionScreen.y);u.addPoint(x.positionScreen.x,x.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.meshMaterial.length;N<M;){z=t.meshMaterial[N++];if(z instanceof
@@ -143,21 +144,21 @@ i?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 pointSpecular =
 "",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse  += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",i?"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");
 s=b(y,n);c.useProgram(s);f(s,["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"]);h&&f(s,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);i&&f(s,["pointLightNumber","pointLightColor",
-"pointLightPosition"]);c.uniform1i(s.uniforms.enableMap,0);c.uniform1i(s.uniforms.tMap,0);c.uniform1i(s.uniforms.enableCubeMap,0);c.uniform1i(s.uniforms.tCube,1);c.uniform1i(s.uniforms.mixEnvMap,0);c.uniform1i(s.uniforms.useRefract,0);j(s)})(a.directional,a.point);this.setSize=function(h,i){m.width=h;m.height=i;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,i){var n,y,p,o,G,B=[],R=[],F=[];o=[];G=[];c.uniform1i(h.uniforms.enableLighting,
-i.lights.length);n=0;for(y=i.lights.length;n<y;n++){p=i.lights[n];if(p instanceof THREE.AmbientLight)B.push(p);else if(p instanceof THREE.DirectionalLight)F.push(p);else p instanceof THREE.PointLight&&R.push(p)}n=p=o=G=0;for(y=B.length;n<y;n++){p+=B[n].color.r;o+=B[n].color.g;G+=B[n].color.b}c.uniform3f(h.uniforms.ambientLightColor,p,o,G);o=[];G=[];n=0;for(y=F.length;n<y;n++){p=F[n];o.push(p.color.r*p.intensity);o.push(p.color.g*p.intensity);o.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);
-G.push(p.position.z)}if(F.length){c.uniform1i(h.uniforms.directionalLightNumber,F.length);c.uniform3fv(h.uniforms.directionalLightDirection,G);c.uniform3fv(h.uniforms.directionalLightColor,o)}o=[];G=[];n=0;for(y=R.length;n<y;n++){p=R[n];o.push(p.color.r*p.intensity);o.push(p.color.g*p.intensity);o.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);G.push(p.position.z)}if(R.length){c.uniform1i(h.uniforms.pointLightNumber,R.length);c.uniform3fv(h.uniforms.pointLightPosition,G);c.uniform3fv(h.uniforms.pointLightColor,
-o)}};this.createBuffers=function(h,i){var n,y,p,o,G,B,R,F,W=[],V=[],D=[],P=[],C=[],K=0,I=h.materialFaceGroup[i],U;p=false;n=0;for(y=h.material.length;n<y;n++){meshMaterial=h.material[n];if(meshMaterial instanceof THREE.MeshFaceMaterial){G=0;for(U=I.material.length;G<U;G++)if(I.material[G]&&I.material[G].shading!=undefined&&I.material[G].shading==THREE.SmoothShading){p=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){p=true;break}if(p)break}U=
-p;n=0;for(y=I.faces.length;n<y;n++){p=I.faces[n];o=h.geometry.faces[p];G=o.vertexNormals;faceNormal=o.normal;p=h.geometry.uvs[p];if(o instanceof THREE.Face3){B=h.geometry.vertices[o.a].position;R=h.geometry.vertices[o.b].position;F=h.geometry.vertices[o.c].position;D.push(B.x,B.y,B.z);D.push(R.x,R.y,R.z);D.push(F.x,F.y,F.z);if(G.length==3&&U)for(o=0;o<3;o++)P.push(G[o].x,G[o].y,G[o].z);else for(o=0;o<3;o++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(o=0;o<3;o++)C.push(p[o].u,p[o].v);W.push(K,
-K+1,K+2);V.push(K,K+1);V.push(K,K+2);V.push(K+1,K+2);K+=3}else if(o instanceof THREE.Face4){B=h.geometry.vertices[o.a].position;R=h.geometry.vertices[o.b].position;F=h.geometry.vertices[o.c].position;o=h.geometry.vertices[o.d].position;D.push(B.x,B.y,B.z);D.push(R.x,R.y,R.z);D.push(F.x,F.y,F.z);D.push(o.x,o.y,o.z);if(G.length==4&&U)for(o=0;o<4;o++)P.push(G[o].x,G[o].y,G[o].z);else for(o=0;o<4;o++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(o=0;o<4;o++)C.push(p[o].u,p[o].v);W.push(K,K+
-1,K+2);W.push(K,K+2,K+3);V.push(K,K+1);V.push(K,K+2);V.push(K,K+3);V.push(K+1,K+2);V.push(K+2,K+3);K+=4}}if(D.length){I.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);I.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);I.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLUVBuffer);
-c.bufferData(c.ARRAY_BUFFER,new Float32Array(C),c.STATIC_DRAW);I.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);I.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);I.__webGLFaceCount=W.length;I.__webGLLineCount=V.length}};this.renderBuffer=function(h,i,n){var y,p,o,G,B,R,F,
-W,V,D;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);F=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in i.uniforms)F.push(D);f(i.program,F);j(i.program)}D=i.program}else D=s;if(D!=E){c.useProgram(D);E=D}if(i instanceof THREE.MeshShaderMaterial){F=D;W=i.uniforms;var P,C;for(p in W){P=W[p].type;V=W[p].value;C=F.uniforms[p];if(P=="i")c.uniform1i(C,V);else if(P=="f")c.uniform1f(C,V);else if(P==
-"t"){c.uniform1i(C,V);P=W[p].texture;if(P instanceof THREE.TextureCube)d(P,V);else P instanceof THREE.Texture&&e(P,V)}}this.loadCamera(D,h);this.loadMatrices(D)}else if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){h=i.color;y=i.opacity;o=i.wireframe;G=i.wireframe_linewidth;B=i.map;R=i.env_map;F=i.combine==THREE.Mix;p=i.reflectivity;V=i.env_map&&i.env_map.mapping==THREE.RefractionMapping;W=i.refraction_ratio;c.uniform4f(D.uniforms.mColor,
-h.r*y,h.g*y,h.b*y,y);c.uniform1i(D.uniforms.mixEnvMap,F);c.uniform1f(D.uniforms.mReflectivity,p);c.uniform1i(D.uniforms.useRefract,V);c.uniform1f(D.uniforms.mRefractionRatio,W)}if(i instanceof THREE.MeshNormalMaterial){y=i.opacity;c.uniform1f(D.uniforms.mOpacity,y);c.uniform1i(D.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){y=i.opacity;o=i.wireframe;G=i.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,y);c.uniform1f(D.uniforms.m2Near,i.__2near);c.uniform1f(D.uniforms.mFarPlusNear,
+"pointLightPosition"]);c.uniform1i(s.uniforms.enableMap,0);c.uniform1i(s.uniforms.tMap,0);c.uniform1i(s.uniforms.enableCubeMap,0);c.uniform1i(s.uniforms.tCube,1);c.uniform1i(s.uniforms.mixEnvMap,0);c.uniform1i(s.uniforms.useRefract,0);j(s)})(a.directional,a.point);this.setSize=function(h,i){m.width=h;m.height=i;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,i){var n,y,p,o,G,B=[],Q=[],F=[];o=[];G=[];c.uniform1i(h.uniforms.enableLighting,
+i.lights.length);n=0;for(y=i.lights.length;n<y;n++){p=i.lights[n];if(p instanceof THREE.AmbientLight)B.push(p);else if(p instanceof THREE.DirectionalLight)F.push(p);else p instanceof THREE.PointLight&&Q.push(p)}n=p=o=G=0;for(y=B.length;n<y;n++){p+=B[n].color.r;o+=B[n].color.g;G+=B[n].color.b}c.uniform3f(h.uniforms.ambientLightColor,p,o,G);o=[];G=[];n=0;for(y=F.length;n<y;n++){p=F[n];o.push(p.color.r*p.intensity);o.push(p.color.g*p.intensity);o.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);
+G.push(p.position.z)}if(F.length){c.uniform1i(h.uniforms.directionalLightNumber,F.length);c.uniform3fv(h.uniforms.directionalLightDirection,G);c.uniform3fv(h.uniforms.directionalLightColor,o)}o=[];G=[];n=0;for(y=Q.length;n<y;n++){p=Q[n];o.push(p.color.r*p.intensity);o.push(p.color.g*p.intensity);o.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);G.push(p.position.z)}if(Q.length){c.uniform1i(h.uniforms.pointLightNumber,Q.length);c.uniform3fv(h.uniforms.pointLightPosition,G);c.uniform3fv(h.uniforms.pointLightColor,
+o)}};this.createBuffers=function(h,i){var n,y,p,o,G,B,Q,F,V=[],U=[],D=[],P=[],C=[],J=0,I=h.materialFaceGroup[i],T;p=false;n=0;for(y=h.material.length;n<y;n++){meshMaterial=h.material[n];if(meshMaterial instanceof THREE.MeshFaceMaterial){G=0;for(T=I.material.length;G<T;G++)if(I.material[G]&&I.material[G].shading!=undefined&&I.material[G].shading==THREE.SmoothShading){p=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){p=true;break}if(p)break}T=
+p;n=0;for(y=I.faces.length;n<y;n++){p=I.faces[n];o=h.geometry.faces[p];G=o.vertexNormals;faceNormal=o.normal;p=h.geometry.uvs[p];if(o instanceof THREE.Face3){B=h.geometry.vertices[o.a].position;Q=h.geometry.vertices[o.b].position;F=h.geometry.vertices[o.c].position;D.push(B.x,B.y,B.z);D.push(Q.x,Q.y,Q.z);D.push(F.x,F.y,F.z);if(G.length==3&&T)for(o=0;o<3;o++)P.push(G[o].x,G[o].y,G[o].z);else for(o=0;o<3;o++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(o=0;o<3;o++)C.push(p[o].u,p[o].v);V.push(J,
+J+1,J+2);U.push(J,J+1);U.push(J,J+2);U.push(J+1,J+2);J+=3}else if(o instanceof THREE.Face4){B=h.geometry.vertices[o.a].position;Q=h.geometry.vertices[o.b].position;F=h.geometry.vertices[o.c].position;o=h.geometry.vertices[o.d].position;D.push(B.x,B.y,B.z);D.push(Q.x,Q.y,Q.z);D.push(F.x,F.y,F.z);D.push(o.x,o.y,o.z);if(G.length==4&&T)for(o=0;o<4;o++)P.push(G[o].x,G[o].y,G[o].z);else for(o=0;o<4;o++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(o=0;o<4;o++)C.push(p[o].u,p[o].v);V.push(J,J+
+1,J+2);V.push(J,J+2,J+3);U.push(J,J+1);U.push(J,J+2);U.push(J,J+3);U.push(J+1,J+2);U.push(J+2,J+3);J+=4}}if(D.length){I.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);I.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);I.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,I.__webGLUVBuffer);
+c.bufferData(c.ARRAY_BUFFER,new Float32Array(C),c.STATIC_DRAW);I.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);I.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(U),c.STATIC_DRAW);I.__webGLFaceCount=V.length;I.__webGLLineCount=U.length}};this.renderBuffer=function(h,i,n){var y,p,o,G,B,Q,F,
+V,U,D;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);F=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in i.uniforms)F.push(D);f(i.program,F);j(i.program)}D=i.program}else D=s;if(D!=E){c.useProgram(D);E=D}if(i instanceof THREE.MeshShaderMaterial){F=D;V=i.uniforms;var P,C;for(p in V){P=V[p].type;U=V[p].value;C=F.uniforms[p];if(P=="i")c.uniform1i(C,U);else if(P=="f")c.uniform1f(C,U);else if(P==
+"t"){c.uniform1i(C,U);P=V[p].texture;if(P instanceof THREE.TextureCube)d(P,U);else P instanceof THREE.Texture&&e(P,U)}}this.loadCamera(D,h);this.loadMatrices(D)}else if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){h=i.color;y=i.opacity;o=i.wireframe;G=i.wireframe_linewidth;B=i.map;Q=i.env_map;F=i.combine==THREE.Mix;p=i.reflectivity;U=i.env_map&&i.env_map.mapping==THREE.RefractionMapping;V=i.refraction_ratio;c.uniform4f(D.uniforms.mColor,
+h.r*y,h.g*y,h.b*y,y);c.uniform1i(D.uniforms.mixEnvMap,F);c.uniform1f(D.uniforms.mReflectivity,p);c.uniform1i(D.uniforms.useRefract,U);c.uniform1f(D.uniforms.mRefractionRatio,V)}if(i instanceof THREE.MeshNormalMaterial){y=i.opacity;c.uniform1f(D.uniforms.mOpacity,y);c.uniform1i(D.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){y=i.opacity;o=i.wireframe;G=i.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,y);c.uniform1f(D.uniforms.m2Near,i.__2near);c.uniform1f(D.uniforms.mFarPlusNear,
 i.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){h=i.ambient;p=i.specular;i=i.shininess;c.uniform4f(D.uniforms.mAmbient,h.r,h.g,h.b,y);c.uniform4f(D.uniforms.mSpecular,p.r,p.g,p.b,y);c.uniform1f(D.uniforms.mShininess,i);c.uniform1i(D.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,
-0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);R=i.env_map}if(B){e(B,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(R){d(R,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(D.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);
+0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);Q=i.env_map}if(B){e(B,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(Q){d(Q,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(D.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);
 c.vertexAttribPointer(D.normal,3,c.FLOAT,false,0,0);if(B){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.enableVertexAttribArray(D.uv);c.vertexAttribPointer(D.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(D.uv);if(o){c.lineWidth(G);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=
-function(h,i,n,y,p){var o,G,B,R,F;B=0;for(R=i.material.length;B<R;B++){o=i.material[B];if(o instanceof THREE.MeshFaceMaterial){o=0;for(G=n.material.length;o<G;o++)if((F=n.material[o])&&F.blending==y&&F.opacity<1==p){this.setBlending(F.blending);this.renderBuffer(h,F,n)}}else if((F=o)&&F.blending==y&&F.opacity<1==p){this.setBlending(F.blending);this.renderBuffer(h,F,n)}}};this.render=function(h,i){var n,y;this.initWebGLObjects(h);this.autoClear&&this.clear();i.autoUpdateMatrix&&i.updateMatrix();this.loadCamera(s,
+function(h,i,n,y,p){var o,G,B,Q,F;B=0;for(Q=i.material.length;B<Q;B++){o=i.material[B];if(o instanceof THREE.MeshFaceMaterial){o=0;for(G=n.material.length;o<G;o++)if((F=n.material[o])&&F.blending==y&&F.opacity<1==p){this.setBlending(F.blending);this.renderBuffer(h,F,n)}}else if((F=o)&&F.blending==y&&F.opacity<1==p){this.setBlending(F.blending);this.renderBuffer(h,F,n)}}};this.render=function(h,i){var n,y;this.initWebGLObjects(h);this.autoClear&&this.clear();i.autoUpdateMatrix&&i.updateMatrix();this.loadCamera(s,
 i);this.setupLights(s,h);n=0;for(y=h.__webGLObjects.length;n<y;n++){webGLObject=h.__webGLObjects[n];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,i);this.loadMatrices(s);this.renderPass(i,webGLObject.__object,webGLObject,THREE.NormalBlending,false)}}n=0;for(y=h.__webGLObjects.length;n<y;n++){webGLObject=h.__webGLObjects[n];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,i);this.loadMatrices(s);this.renderPass(i,webGLObject.__object,webGLObject,THREE.AdditiveBlending,
 false);this.renderPass(i,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,false);this.renderPass(i,webGLObject.__object,webGLObject,THREE.AdditiveBlending,true);this.renderPass(i,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,true);this.renderPass(i,webGLObject.__object,webGLObject,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(h){var i,n,y,p,o;if(!h.__webGLObjects)h.__webGLObjects=[];i=0;for(n=h.objects.length;i<n;i++){y=h.objects[i];if(y instanceof THREE.Mesh)for(p in y.materialFaceGroup){o=
 y.materialFaceGroup[p];if(!o.__webGLVertexBuffer){this.createBuffers(y,p);o.__object=y;h.__webGLObjects.push(o)}}}};this.removeObject=function(h,i){var n,y;for(n=h.__webGLObjects.length-1;n>=0;n--){y=h.__webGLObjects[n].__object;i==y&&h.__webGLObjects.splice(n,1)}};this.setupMatrices=function(h,i){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(i.matrix,h.matrix);v.set(i.matrix.flatten());x.set(r.flatten());L.set(i.projectionMatrix.flatten());w=THREE.Matrix4.makeInvert3x3(r).transpose();u.set(w.m);
@@ -186,16 +187,16 @@ w=this.vertices[g].position.clone();v=this.vertices[m].position.clone();r.normal
 THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
 b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,
 j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState==
-2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,t){var z=s(q,t),J=s(q,t+1),Q=s(q,t+2),fa=s(q,t+3),ea=(fa<<1&255|Q>>7)-127;z=(Q&127)<<16|J<<8|z;if(z==0&&ea==-127)return 0;return(1-2*(fa>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ea)}function g(q,t){var z=s(q,t),J=s(q,t+1),Q=s(q,t+2);return(s(q,t+3)<<24)+(Q<<
-16)+(J<<8)+z}function m(q,t){var z=s(q,t);return(s(q,t+1)<<8)+z}function c(q,t){var z=s(q,t);return z>127?z-256:z}function s(q,t){return q.charCodeAt(t)&255}function E(q){var t,z,J;t=g(a,q);z=g(a,q+n);J=g(a,q+y);q=m(a,q+p);THREE.Loader.prototype.f3(u,t,z,J,q)}function r(q){var t,z,J,Q,fa,ea;t=g(a,q);z=g(a,q+n);J=g(a,q+y);Q=m(a,q+p);fa=g(a,q+o);ea=g(a,q+G);q=g(a,q+B);THREE.Loader.prototype.f3n(u,h,t,z,J,Q,fa,ea,q)}function w(q){var t,z,J,Q;t=g(a,q);z=g(a,q+R);J=g(a,q+F);Q=g(a,q+W);q=m(a,q+V);THREE.Loader.prototype.f4(u,
-t,z,J,Q,q)}function v(q){var t,z,J,Q,fa,ea,ga,la;t=g(a,q);z=g(a,q+R);J=g(a,q+F);Q=g(a,q+W);fa=m(a,q+V);ea=g(a,q+D);ga=g(a,q+P);la=g(a,q+C);q=g(a,q+K);THREE.Loader.prototype.f4n(u,h,t,z,J,Q,fa,ea,ga,la,q)}function x(q){var t,z;t=g(a,q);z=g(a,q+I);q=g(a,q+U);THREE.Loader.prototype.uv3(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[q*2],i[q*2+1])}function L(q){var t,z,J;t=g(a,q);z=g(a,q+N);J=g(a,q+M);q=g(a,q+Y);THREE.Loader.prototype.uv4(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[J*2],i[J*2+1],i[q*2],i[q*2+1])}var u=
-this,A=0,l,h=[],i=[],n,y,p,o,G,B,R,F,W,V,D,P,C,K,I,U,N,M,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,j);l={signature:a.substr(A,8),header_bytes:s(a,A+8),vertex_coordinate_bytes:s(a,A+9),normal_coordinate_bytes:s(a,A+10),uv_coordinate_bytes:s(a,A+11),vertex_index_bytes:s(a,A+12),normal_index_bytes:s(a,A+13),uv_index_bytes:s(a,A+14),material_index_bytes:s(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a,
-A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=l.header_bytes;n=l.vertex_index_bytes;y=l.vertex_index_bytes*2;p=l.vertex_index_bytes*3;o=l.vertex_index_bytes*3+l.material_index_bytes;G=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;B=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;R=l.vertex_index_bytes;F=l.vertex_index_bytes*2;W=l.vertex_index_bytes*3;V=l.vertex_index_bytes*
-4;D=l.vertex_index_bytes*4+l.material_index_bytes;P=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;C=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*2;K=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;I=l.uv_index_bytes;U=l.uv_index_bytes*2;N=l.uv_index_bytes;M=l.uv_index_bytes*2;Y=l.uv_index_bytes*3;A+=function(q){var t,z,J,Q=l.vertex_coordinate_bytes*3,fa=q+l.nvertices*Q;for(q=q;q<fa;q+=Q){t=k(a,q);z=k(a,q+l.vertex_coordinate_bytes);J=
-k(a,q+l.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,t,z,J)}return l.nvertices*Q}(A);A+=function(q){var t,z,J,Q=l.normal_coordinate_bytes*3,fa=q+l.nnormals*Q;for(q=q;q<fa;q+=Q){t=c(a,q);z=c(a,q+l.normal_coordinate_bytes);J=c(a,q+l.normal_coordinate_bytes*2);h.push(t/127,z/127,J/127)}return l.nnormals*Q}(A);A+=function(q){var t,z,J=l.uv_coordinate_bytes*2,Q=q+l.nuvs*J;for(q=q;q<Q;q+=J){t=k(a,q);z=k(a,q+l.uv_coordinate_bytes);i.push(t,z)}return l.nuvs*J}(A);A+=function(q){var t,z=l.vertex_index_bytes*
-3+l.material_index_bytes,J=q+l.ntri_flat*z;for(t=q;t<J;t+=z)E(t);return J-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,J=q+l.ntri_smooth*z;for(t=q;t<J;t+=z)r(t);return J-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes,J=z+l.uv_index_bytes*3,Q=q+l.ntri_flat_uv*J;for(t=q;t<Q;t+=J){E(t);x(t+z)}return Q-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,J=z+l.uv_index_bytes*3,
-Q=q+l.ntri_smooth_uv*J;for(t=q;t<Q;t+=J){r(t);x(t+z)}return Q-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes,J=q+l.nquad_flat*z;for(t=q;t<J;t+=z)w(t);return J-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,J=q+l.nquad_smooth*z;for(t=q;t<J;t+=z)v(t);return J-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes,J=z+l.uv_index_bytes*4,Q=q+l.nquad_flat_uv*J;for(t=q;t<Q;t+=J){w(t);L(t+z)}return Q-q}(A);
-A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,J=z+l.uv_index_bytes*4,Q=q+l.nquad_smooth_uv*J;for(t=q;t<Q;t+=J){v(t);L(t+z)}return Q-q}(A);this.computeCentroids();this.computeNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,f);(function(){var k,g,m,c,s;k=0;for(g=a.vertices.length;k<g;k+=3){m=
+2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,t){var z=s(q,t),K=s(q,t+1),W=s(q,t+2),ga=s(q,t+3),ma=(ga<<1&255|W>>7)-127;z=(W&127)<<16|K<<8|z;if(z==0&&ma==-127)return 0;return(1-2*(ga>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ma)}function g(q,t){var z=s(q,t),K=s(q,t+1),W=s(q,t+2);return(s(q,t+3)<<24)+(W<<
+16)+(K<<8)+z}function m(q,t){var z=s(q,t);return(s(q,t+1)<<8)+z}function c(q,t){var z=s(q,t);return z>127?z-256:z}function s(q,t){return q.charCodeAt(t)&255}function E(q){var t,z,K;t=g(a,q);z=g(a,q+n);K=g(a,q+y);q=m(a,q+p);THREE.Loader.prototype.f3(u,t,z,K,q)}function r(q){var t,z,K,W,ga,ma;t=g(a,q);z=g(a,q+n);K=g(a,q+y);W=m(a,q+p);ga=g(a,q+o);ma=g(a,q+G);q=g(a,q+B);THREE.Loader.prototype.f3n(u,h,t,z,K,W,ga,ma,q)}function w(q){var t,z,K,W;t=g(a,q);z=g(a,q+Q);K=g(a,q+F);W=g(a,q+V);q=m(a,q+U);THREE.Loader.prototype.f4(u,
+t,z,K,W,q)}function v(q){var t,z,K,W,ga,ma,ua,pa;t=g(a,q);z=g(a,q+Q);K=g(a,q+F);W=g(a,q+V);ga=m(a,q+U);ma=g(a,q+D);ua=g(a,q+P);pa=g(a,q+C);q=g(a,q+J);THREE.Loader.prototype.f4n(u,h,t,z,K,W,ga,ma,ua,pa,q)}function x(q){var t,z;t=g(a,q);z=g(a,q+I);q=g(a,q+T);THREE.Loader.prototype.uv3(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[q*2],i[q*2+1])}function L(q){var t,z,K;t=g(a,q);z=g(a,q+N);K=g(a,q+M);q=g(a,q+Y);THREE.Loader.prototype.uv4(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[K*2],i[K*2+1],i[q*2],i[q*2+1])}var u=
+this,A=0,l,h=[],i=[],n,y,p,o,G,B,Q,F,V,U,D,P,C,J,I,T,N,M,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,j);l={signature:a.substr(A,8),header_bytes:s(a,A+8),vertex_coordinate_bytes:s(a,A+9),normal_coordinate_bytes:s(a,A+10),uv_coordinate_bytes:s(a,A+11),vertex_index_bytes:s(a,A+12),normal_index_bytes:s(a,A+13),uv_index_bytes:s(a,A+14),material_index_bytes:s(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a,
+A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=l.header_bytes;n=l.vertex_index_bytes;y=l.vertex_index_bytes*2;p=l.vertex_index_bytes*3;o=l.vertex_index_bytes*3+l.material_index_bytes;G=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;B=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;Q=l.vertex_index_bytes;F=l.vertex_index_bytes*2;V=l.vertex_index_bytes*3;U=l.vertex_index_bytes*
+4;D=l.vertex_index_bytes*4+l.material_index_bytes;P=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;C=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*2;J=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;I=l.uv_index_bytes;T=l.uv_index_bytes*2;N=l.uv_index_bytes;M=l.uv_index_bytes*2;Y=l.uv_index_bytes*3;A+=function(q){var t,z,K,W=l.vertex_coordinate_bytes*3,ga=q+l.nvertices*W;for(q=q;q<ga;q+=W){t=k(a,q);z=k(a,q+l.vertex_coordinate_bytes);K=
+k(a,q+l.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,t,z,K)}return l.nvertices*W}(A);A+=function(q){var t,z,K,W=l.normal_coordinate_bytes*3,ga=q+l.nnormals*W;for(q=q;q<ga;q+=W){t=c(a,q);z=c(a,q+l.normal_coordinate_bytes);K=c(a,q+l.normal_coordinate_bytes*2);h.push(t/127,z/127,K/127)}return l.nnormals*W}(A);A+=function(q){var t,z,K=l.uv_coordinate_bytes*2,W=q+l.nuvs*K;for(q=q;q<W;q+=K){t=k(a,q);z=k(a,q+l.uv_coordinate_bytes);i.push(t,z)}return l.nuvs*K}(A);A+=function(q){var t,z=l.vertex_index_bytes*
+3+l.material_index_bytes,K=q+l.ntri_flat*z;for(t=q;t<K;t+=z)E(t);return K-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,K=q+l.ntri_smooth*z;for(t=q;t<K;t+=z)r(t);return K-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes,K=z+l.uv_index_bytes*3,W=q+l.ntri_flat_uv*K;for(t=q;t<W;t+=K){E(t);x(t+z)}return W-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,K=z+l.uv_index_bytes*3,
+W=q+l.ntri_smooth_uv*K;for(t=q;t<W;t+=K){r(t);x(t+z)}return W-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes,K=q+l.nquad_flat*z;for(t=q;t<K;t+=z)w(t);return K-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,K=q+l.nquad_smooth*z;for(t=q;t<K;t+=z)v(t);return K-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes,K=z+l.uv_index_bytes*4,W=q+l.nquad_flat_uv*K;for(t=q;t<W;t+=K){w(t);L(t+z)}return W-q}(A);
+A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,K=z+l.uv_index_bytes*4,W=q+l.nquad_smooth_uv*K;for(t=q;t<W;t+=K){v(t);L(t+z)}return W-q}(A);this.computeCentroids();this.computeNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,f);(function(){var k,g,m,c,s;k=0;for(g=a.vertices.length;k<g;k+=3){m=
 a.vertices[k];c=a.vertices[k+1];s=a.vertices[k+2];THREE.Loader.prototype.v(j,m,c,s)}})();(function(){function k(v,x){THREE.Loader.prototype.f3(j,v[x],v[x+1],v[x+2],v[x+3])}function g(v,x){THREE.Loader.prototype.f3n(j,a.normals,v[x],v[x+1],v[x+2],v[x+3],v[x+4],v[x+5],v[x+6])}function m(v,x){THREE.Loader.prototype.f4(j,v[x],v[x+1],v[x+2],v[x+3],v[x+4])}function c(v,x){THREE.Loader.prototype.f4n(j,a.normals,v[x],v[x+1],v[x+2],v[x+3],v[x+4],v[x+5],v[x+6],v[x+7],v[x+8])}function s(v,x){var L,u,A;L=v[x];
 u=v[x+1];A=v[x+2];THREE.Loader.prototype.uv3(j,a.uvs[L*2],a.uvs[L*2+1],a.uvs[u*2],a.uvs[u*2+1],a.uvs[A*2],a.uvs[A*2+1])}function E(v,x){var L,u,A,l;L=v[x];u=v[x+1];A=v[x+2];l=v[x+3];THREE.Loader.prototype.uv4(j,a.uvs[L*2],a.uvs[L*2+1],a.uvs[u*2],a.uvs[u*2+1],a.uvs[A*2],a.uvs[A*2+1],a.uvs[l*2],a.uvs[l*2+1])}var r,w;r=0;for(w=a.triangles.length;r<w;r+=4)k(a.triangles,r);r=0;for(w=a.triangles_uv.length;r<w;r+=7){k(a.triangles_uv,r);s(a.triangles_uv,r+4)}r=0;for(w=a.triangles_n.length;r<w;r+=7)g(a.triangles_n,
 r);r=0;for(w=a.triangles_n_uv.length;r<w;r+=10){g(a.triangles_n_uv,r);s(a.triangles_n_uv,r+7)}r=0;for(w=a.quads.length;r<w;r+=5)m(a.quads,r);r=0;for(w=a.quads_uv.length;r<w;r+=9){m(a.quads_uv,r);E(a.quads_uv,r+5)}r=0;for(w=a.quads_n.length;r<w;r+=9)c(a.quads_n,r);r=0;for(w=a.quads_n_uv.length;r<w;r+=13){c(a.quads_n_uv,r);E(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,

+ 2 - 2
examples/canvasrenderer_sandbox.html

@@ -133,12 +133,12 @@
 				objects = [];
 
 				geometry = new Sphere( 100, 16, 8 );
-				material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/uvgrid.png', THREE.ReflectionMapping ) } );
+				material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', THREE.ReflectionMapping ) } );
 
 				for ( var i = 0; i < 10; i ++ ) {
 
 					sphere = new THREE.Mesh( geometry, material );
-					sphere.overdraw = true;
+					// sphere.overdraw = true;
 
 					sphere.position.x = Math.random() * 1000 - 500;
 					sphere.position.y = Math.random() * 1000 - 500;

+ 3 - 1
examples/materials.html

@@ -60,6 +60,7 @@
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
 
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
+		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 
@@ -120,7 +121,8 @@
 				// materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { map: loadImage( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
+				materials.push( { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg', THREE.UVMapping ) } ), overdraw: false, doubleSided: false } );
+				materials.push( { material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', THREE.ReflectionMapping ) } ), overdraw: false, doubleSided: false } );
 
 				for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
 

二进制
examples/textures/envmap.png


+ 0 - 1
examples/textures/uvgrid.nfo

@@ -1 +0,0 @@
-http://www.flickr.com/photos/seeminglee/1791052516/

二进制
examples/textures/uvgrid.png


+ 22 - 12
src/core/Vector3.js

@@ -34,11 +34,11 @@ THREE.Vector3.prototype = {
 
 	},
 
-	add: function ( v1, v2 ) {
+	add: function ( a, b ) {
 
-		this.x = v1.x + v2.x;
-		this.y = v1.y + v2.y;
-		this.z = v1.z + v2.z;
+		this.x = a.x + b.x;
+		this.y = a.y + b.y;
+		this.z = a.z + b.z;
 
 		return this;
 
@@ -64,11 +64,11 @@ THREE.Vector3.prototype = {
 
 	},
 
-	sub: function( v1, v2 ) {
+	sub: function( a, b ) {
 
-		this.x = v1.x - v2.x;
-		this.y = v1.y - v2.y;
-		this.z = v1.z - v2.z;
+		this.x = a.x - b.x;
+		this.y = a.y - b.y;
+		this.z = a.z - b.z;
 
 		return this;
 
@@ -84,11 +84,11 @@ THREE.Vector3.prototype = {
 
 	},
 
-	cross: function ( v1, v2 ) {
+	cross: function ( a, b ) {
 
-		this.x = v1.y * v2.z - v1.z * v2.y;
-		this.y = v1.z * v2.x - v1.x * v2.z;
-		this.z = v1.x * v2.y - v1.y * v2.x;
+		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;
 
@@ -106,6 +106,16 @@ THREE.Vector3.prototype = {
 
 	},
 
+	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 ( v ) {
 
 		this.x *= v.x;

+ 17 - 6
src/renderers/CanvasRenderer.js

@@ -30,6 +30,7 @@ THREE.CanvasRenderer = function () {
 	_2near, _farPlusNear, _farMinusNear,
 
 	_bitmap,
+	_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
 
 	_clipRect = new THREE.Rectangle(),
 	_clearRect = new THREE.Rectangle(),
@@ -470,17 +471,23 @@ THREE.CanvasRenderer = function () {
 				fillPath( material.color.__styleString );
 				*/
 
-			} else {
+			} else if ( material.env_map && material.env_map.loaded ) {
 
-				material.wireframe ? strokePath( material.color.__styleString, material.wireframe_linewidth ) : fillPath( material.color.__styleString );
+				if ( material.env_map.mapping == THREE.ReflectionMapping ) {
 
-			}
+					_vector3.copy( element.vertexNormalsWorld[ 0 ] );
+					_uv1x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5;
+					_uv1y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5;
 
-			if ( material.env_map && material.env_map.loaded ) {
+					_vector3.copy( element.vertexNormalsWorld[ 1 ] );
+					_uv2x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5;
+					_uv2y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5;
 
-				if ( material.env_map.mapping == THREE.ReflectionMapping ) {
+					_vector3.copy( element.vertexNormalsWorld[ 2 ] );
+					_uv3x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5;
+					_uv3y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5;
 
-					texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.env_map.image, element.vertexNormalsWorld[ 0 ].x * 0.5 + 0.5, element.vertexNormalsWorld[ 0 ].y * 0.5 + 0.5, element.vertexNormalsWorld[ 1 ].x * 0.5 + 0.5, element.vertexNormalsWorld[ 1 ].y * 0.5 + 0.5, element.vertexNormalsWorld[ 2 ].x * 0.5 + 0.5, element.vertexNormalsWorld[ 2 ].y * 0.5 + 0.5 );
+					texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.env_map.image, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y );
 
 				}/* else if ( material.env_map.mapping == THREE.RefractionMapping ) {
 
@@ -488,6 +495,10 @@ THREE.CanvasRenderer = function () {
 
 				}*/
 
+			} else {
+
+				material.wireframe ? strokePath( material.color.__styleString, material.wireframe_linewidth ) : fillPath( material.color.__styleString );
+
 			}
 
 		} else if ( material instanceof THREE.MeshLambertMaterial ) {