瀏覽代碼

`texture.loaded = true` → `texture.image.loaded = true`

Mr.doob 14 年之前
父節點
當前提交
a030086cf5

+ 65 - 65
build/Three.js

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

+ 55 - 55
build/ThreeDebug.js

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

+ 76 - 76
build/ThreeExtras.js

@@ -12,20 +12,20 @@ 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};
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(a){function b(I,E,y,n){n=n.clone().subSelf(E);y=y.clone().subSelf(E);var i=I.clone().subSelf(E);I=n.dot(n);E=n.dot(y);n=n.dot(i);var m=y.dot(y);y=y.dot(i);i=1/(I*m-E*E);m=(m*n-E*y)*i;I=(I*y-E*n)*i;return m>0&&I>0&&m+I<1}var d,e,g,j,k,f,p,c,v,C,
-r,t=a.geometry,u=t.vertices,w=[];d=0;for(e=t.faces.length;d<e;d++){g=t.faces[d];C=this.origin.clone();r=this.direction.clone();j=a.matrix.multiplyVector3(u[g.a].position.clone());k=a.matrix.multiplyVector3(u[g.b].position.clone());f=a.matrix.multiplyVector3(u[g.c].position.clone());p=g instanceof THREE.Face4?a.matrix.multiplyVector3(u[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());v=r.dot(c);if(v<0){c=c.dot((new THREE.Vector3).sub(j,C))/v;C=C.addSelf(r.multiplyScalar(c));
-if(g instanceof THREE.Face3){if(b(C,j,k,f)){g={distance:this.origin.distanceTo(C),point:C,face:g,object:a};w.push(g)}}else if(g instanceof THREE.Face4)if(b(C,j,k,p)||b(C,k,f,p)){g={distance:this.origin.distanceTo(C),point:C,face:g,object:a};w.push(g)}}}return w}};
-THREE.Rectangle=function(){function a(){j=e-b;k=g-d}var b,d,e,g,j,k,f=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(p,c,v,C){f=false;b=p;d=c;e=v;g=C;a()};this.addPoint=function(p,c){if(f){f=false;b=p;d=c;e=p;g=c}else{b=Math.min(b,p);d=Math.min(d,c);e=Math.max(e,
+THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(a){function b(I,F,y,n){n=n.clone().subSelf(F);y=y.clone().subSelf(F);var i=I.clone().subSelf(F);I=n.dot(n);F=n.dot(y);n=n.dot(i);var m=y.dot(y);y=y.dot(i);i=1/(I*m-F*F);m=(m*n-F*y)*i;I=(I*y-F*n)*i;return m>0&&I>0&&m+I<1}var d,e,g,j,k,f,p,c,v,D,
+r,t=a.geometry,u=t.vertices,w=[];d=0;for(e=t.faces.length;d<e;d++){g=t.faces[d];D=this.origin.clone();r=this.direction.clone();j=a.matrix.multiplyVector3(u[g.a].position.clone());k=a.matrix.multiplyVector3(u[g.b].position.clone());f=a.matrix.multiplyVector3(u[g.c].position.clone());p=g instanceof THREE.Face4?a.matrix.multiplyVector3(u[g.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(g.normal.clone());v=r.dot(c);if(v<0){c=c.dot((new THREE.Vector3).sub(j,D))/v;D=D.addSelf(r.multiplyScalar(c));
+if(g instanceof THREE.Face3){if(b(D,j,k,f)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};w.push(g)}}else if(g instanceof THREE.Face4)if(b(D,j,k,p)||b(D,k,f,p)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};w.push(g)}}}return w}};
+THREE.Rectangle=function(){function a(){j=e-b;k=g-d}var b,d,e,g,j,k,f=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(p,c,v,D){f=false;b=p;d=c;e=v;g=D;a()};this.addPoint=function(p,c){if(f){f=false;b=p;d=c;e=p;g=c}else{b=Math.min(b,p);d=Math.min(d,c);e=Math.max(e,
 p);g=Math.max(g,c)}a()};this.addRectangle=function(p){if(f){f=false;b=p.getLeft();d=p.getTop();e=p.getRight();g=p.getBottom()}else{b=Math.min(b,p.getLeft());d=Math.min(d,p.getTop());e=Math.max(e,p.getRight());g=Math.max(g,p.getBottom())}a()};this.inflate=function(p){b-=p;d-=p;e+=p;g+=p;a()};this.minSelf=function(p){b=Math.max(b,p.getLeft());d=Math.max(d,p.getTop());e=Math.min(e,p.getRight());g=Math.min(g,p.getBottom());a()};this.instersects=function(p){return Math.min(e,p.getRight())-Math.max(b,p.getLeft())>=
 0&&Math.min(g,p.getBottom())-Math.max(d,p.getTop())>=0};this.empty=function(){f=true;g=e=d=b=0;a()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+j+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
 THREE.Matrix4=function(){};
 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,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=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)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*
-a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,j=a.n14,k=a.n21,f=a.n22,p=a.n23,c=a.n24,v=a.n31,C=a.n32,r=a.n33,t=a.n34,u=a.n41,w=a.n42,I=a.n43,E=a.n44,y=b.n11,n=b.n12,i=b.n13,m=b.n14,h=b.n21,z=b.n22,l=b.n23,o=b.n24,B=b.n31,A=b.n32,Q=b.n33,K=b.n34,R=b.n41,T=b.n42,D=b.n43,
-V=b.n44;this.n11=d*y+e*h+g*B+j*R;this.n12=d*n+e*z+g*A+j*T;this.n13=d*i+e*l+g*Q+j*D;this.n14=d*m+e*o+g*K+j*V;this.n21=k*y+f*h+p*B+c*R;this.n22=k*n+f*z+p*A+c*T;this.n23=k*i+f*l+p*Q+c*D;this.n24=k*m+f*o+p*K+c*V;this.n31=v*y+C*h+r*B+t*R;this.n32=v*n+C*z+r*A+t*T;this.n33=v*i+C*l+r*Q+t*D;this.n34=v*m+C*o+r*K+t*V;this.n41=u*y+w*h+I*B+E*R;this.n42=u*n+w*z+I*A+E*T;this.n43=u*i+w*l+I*Q+E*D;this.n44=u*m+w*o+I*K+E*V},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,j=this.n21,k=this.n22,
-f=this.n23,p=this.n24,c=this.n31,v=this.n32,C=this.n33,r=this.n34,t=this.n41,u=this.n42,w=this.n43,I=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+g*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+g*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+g*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+g*a.n44;this.n21=j*a.n11+k*a.n21+f*a.n31+p*a.n41;this.n22=j*a.n12+k*a.n22+f*a.n32+p*a.n42;this.n23=j*a.n13+k*a.n23+f*a.n33+p*a.n43;this.n24=j*a.n14+k*a.n24+f*a.n34+p*a.n44;this.n31=c*a.n11+v*a.n21+C*a.n31+r*a.n41;this.n32=c*a.n12+v*a.n22+
-C*a.n32+r*a.n42;this.n33=c*a.n13+v*a.n23+C*a.n33+r*a.n43;this.n34=c*a.n14+v*a.n24+C*a.n34+r*a.n44;this.n41=t*a.n11+u*a.n21+w*a.n31+I*a.n41;this.n42=t*a.n12+u*a.n22+w*a.n32+I*a.n42;this.n43=t*a.n13+u*a.n23+w*a.n33+I*a.n43;this.n44=t*a.n14+u*a.n24+w*a.n34+I*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*
+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,g=a.n13,j=a.n14,k=a.n21,f=a.n22,p=a.n23,c=a.n24,v=a.n31,D=a.n32,r=a.n33,t=a.n34,u=a.n41,w=a.n42,I=a.n43,F=a.n44,y=b.n11,n=b.n12,i=b.n13,m=b.n14,h=b.n21,z=b.n22,l=b.n23,o=b.n24,B=b.n31,A=b.n32,Q=b.n33,K=b.n34,R=b.n41,T=b.n42,E=b.n43,
+V=b.n44;this.n11=d*y+e*h+g*B+j*R;this.n12=d*n+e*z+g*A+j*T;this.n13=d*i+e*l+g*Q+j*E;this.n14=d*m+e*o+g*K+j*V;this.n21=k*y+f*h+p*B+c*R;this.n22=k*n+f*z+p*A+c*T;this.n23=k*i+f*l+p*Q+c*E;this.n24=k*m+f*o+p*K+c*V;this.n31=v*y+D*h+r*B+t*R;this.n32=v*n+D*z+r*A+t*T;this.n33=v*i+D*l+r*Q+t*E;this.n34=v*m+D*o+r*K+t*V;this.n41=u*y+w*h+I*B+F*R;this.n42=u*n+w*z+I*A+F*T;this.n43=u*i+w*l+I*Q+F*E;this.n44=u*m+w*o+I*K+F*V},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,j=this.n21,k=this.n22,
+f=this.n23,p=this.n24,c=this.n31,v=this.n32,D=this.n33,r=this.n34,t=this.n41,u=this.n42,w=this.n43,I=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+g*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+g*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+g*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+g*a.n44;this.n21=j*a.n11+k*a.n21+f*a.n31+p*a.n41;this.n22=j*a.n12+k*a.n22+f*a.n32+p*a.n42;this.n23=j*a.n13+k*a.n23+f*a.n33+p*a.n43;this.n24=j*a.n14+k*a.n24+f*a.n34+p*a.n44;this.n31=c*a.n11+v*a.n21+D*a.n31+r*a.n41;this.n32=c*a.n12+v*a.n22+
+D*a.n32+r*a.n42;this.n33=c*a.n13+v*a.n23+D*a.n33+r*a.n43;this.n34=c*a.n14+v*a.n24+D*a.n34+r*a.n44;this.n41=t*a.n11+u*a.n21+w*a.n31+I*a.n41;this.n42=t*a.n12+u*a.n22+w*a.n32+I*a.n42;this.n43=t*a.n13+u*a.n23+w*a.n33+I*a.n43;this.n44=t*a.n14+u*a.n24+w*a.n34+I*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*
 this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var g=b[d];b[d]=b[e];b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,
 "n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},
@@ -48,7 +48,7 @@ d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},co
 d.position);p.sub(b.position,d.position);f.crossSelf(p)}f.isZero()||f.normalize();j.normal.copy(f)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
 0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,
 this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;
-if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(v){var C=[];b=0;for(d=v.length;b<d;b++)v[b]==undefined?C.push("undefined"):C.push(v[b].toString());return C.join("_")}var b,d,e,g,j,k,f,p,c={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];k=j.material;f=a(k);if(c[f]==undefined)c[f]={hash:f,counter:0};p=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[p]==
+if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(v){var D=[];b=0;for(d=v.length;b<d;b++)v[b]==undefined?D.push("undefined"):D.push(v[b].toString());return D.join("_")}var b,d,e,g,j,k,f,p,c={};e=0;for(g=this.faces.length;e<g;e++){j=this.faces[e];k=j.material;f=a(k);if(c[f]==undefined)c[f]={hash:f,counter:0};p=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[p]==
 undefined)this.geometryChunks[p]={faces:[],material:k,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[p].vertices+j>65535){c[f].counter+=1;p=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[p]==undefined)this.geometryChunks[p]={faces:[],material:k,vertices:0}}this.geometryChunks[p].faces.push(e);this.geometryChunks[p].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
 THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
@@ -86,48 +86,48 @@ THREE.Texture=function(a,b,d,e,g,j){this.image=a;this.mapping=b!==undefined?b:ne
 this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.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(y,n){var i=0,m=1,h=y.z+y.w,z=n.z+n.w,l=-y.z+y.w,o=-n.z+n.w;if(h>=0&&z>=0&&l>=0&&o>=0)return true;else if(h<0&&z<0||l<0&&o<0)return false;else{if(h<0)i=Math.max(i,h/(h-z));else if(z<0)m=Math.min(m,h/(h-z));if(l<0)i=Math.max(i,l/(l-o));else if(o<0)m=Math.min(m,l/(l-o));if(m<i)return false;else{y.lerpSelf(n,i);n.lerpSelf(y,1-m);return true}}}var b=null,d,e,g,j=[],k,f,p=[],c,v,C=[],r=new THREE.Vector4,t=new THREE.Matrix4,u=new THREE.Matrix4,w=new THREE.Vector4,I=
-new THREE.Vector4,E;this.projectScene=function(y,n){var i,m,h,z,l,o,B,A,Q,K,R,T,D,V,J,L,N;b=[];g=f=v=0;n.autoUpdateMatrix&&n.updateMatrix();t.multiply(n.projectionMatrix,n.matrix);B=y.objects;i=0;for(m=B.length;i<m;i++){A=B[i];A.autoUpdateMatrix&&A.updateMatrix();Q=A.matrix;K=A.rotationMatrix;R=A.material;T=A.overdraw;if(A instanceof THREE.Mesh){D=A.geometry.vertices;h=0;for(z=D.length;h<z;h++){V=D[h];V.positionWorld.copy(V.position);Q.multiplyVector3(V.positionWorld);J=V.positionScreen;J.copy(V.positionWorld);
-t.multiplyVector4(J);J.multiplyScalar(1/J.w);V.__visible=J.z>0&&J.z<1}V=A.geometry.faces;h=0;for(z=V.length;h<z;h++){J=V[h];if(J instanceof THREE.Face3){l=D[J.a];o=D[J.b];L=D[J.c];if(l.__visible&&o.__visible&&L.__visible)if(A.doubleSided||A.flipSided!=(L.positionScreen.x-l.positionScreen.x)*(o.positionScreen.y-l.positionScreen.y)-(L.positionScreen.y-l.positionScreen.y)*(o.positionScreen.x-l.positionScreen.x)<0){d=j[g]=j[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(o.positionWorld);
-d.v3.positionWorld.copy(L.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(L.positionScreen);d.normalWorld.copy(J.normal);K.multiplyVector3(d.normalWorld);d.centroidWorld.copy(J.centroid);Q.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);t.multiplyVector3(d.centroidScreen);L=J.vertexNormals;E=d.vertexNormalsWorld;l=0;for(o=L.length;l<o;l++){N=E[l]=E[l]||new THREE.Vector3;N.copy(L[l]);K.multiplyVector3(N)}d.z=
-d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=J.material;d.overdraw=T;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][2]}b.push(d);g++}}else if(J instanceof THREE.Face4){l=D[J.a];o=D[J.b];L=D[J.c];N=D[J.d];if(l.__visible&&o.__visible&&L.__visible&&N.__visible)if(A.doubleSided||A.flipSided!=((N.positionScreen.x-l.positionScreen.x)*(o.positionScreen.y-l.positionScreen.y)-(N.positionScreen.y-l.positionScreen.y)*(o.positionScreen.x-l.positionScreen.x)<
+THREE.Projector=function(){function a(y,n){var i=0,m=1,h=y.z+y.w,z=n.z+n.w,l=-y.z+y.w,o=-n.z+n.w;if(h>=0&&z>=0&&l>=0&&o>=0)return true;else if(h<0&&z<0||l<0&&o<0)return false;else{if(h<0)i=Math.max(i,h/(h-z));else if(z<0)m=Math.min(m,h/(h-z));if(l<0)i=Math.max(i,l/(l-o));else if(o<0)m=Math.min(m,l/(l-o));if(m<i)return false;else{y.lerpSelf(n,i);n.lerpSelf(y,1-m);return true}}}var b=null,d,e,g,j=[],k,f,p=[],c,v,D=[],r=new THREE.Vector4,t=new THREE.Matrix4,u=new THREE.Matrix4,w=new THREE.Vector4,I=
+new THREE.Vector4,F;this.projectScene=function(y,n){var i,m,h,z,l,o,B,A,Q,K,R,T,E,V,J,L,N;b=[];g=f=v=0;n.autoUpdateMatrix&&n.updateMatrix();t.multiply(n.projectionMatrix,n.matrix);B=y.objects;i=0;for(m=B.length;i<m;i++){A=B[i];A.autoUpdateMatrix&&A.updateMatrix();Q=A.matrix;K=A.rotationMatrix;R=A.material;T=A.overdraw;if(A instanceof THREE.Mesh){E=A.geometry.vertices;h=0;for(z=E.length;h<z;h++){V=E[h];V.positionWorld.copy(V.position);Q.multiplyVector3(V.positionWorld);J=V.positionScreen;J.copy(V.positionWorld);
+t.multiplyVector4(J);J.multiplyScalar(1/J.w);V.__visible=J.z>0&&J.z<1}V=A.geometry.faces;h=0;for(z=V.length;h<z;h++){J=V[h];if(J instanceof THREE.Face3){l=E[J.a];o=E[J.b];L=E[J.c];if(l.__visible&&o.__visible&&L.__visible)if(A.doubleSided||A.flipSided!=(L.positionScreen.x-l.positionScreen.x)*(o.positionScreen.y-l.positionScreen.y)-(L.positionScreen.y-l.positionScreen.y)*(o.positionScreen.x-l.positionScreen.x)<0){d=j[g]=j[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(o.positionWorld);
+d.v3.positionWorld.copy(L.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(L.positionScreen);d.normalWorld.copy(J.normal);K.multiplyVector3(d.normalWorld);d.centroidWorld.copy(J.centroid);Q.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);t.multiplyVector3(d.centroidScreen);L=J.vertexNormals;F=d.vertexNormalsWorld;l=0;for(o=L.length;l<o;l++){N=F[l]=F[l]||new THREE.Vector3;N.copy(L[l]);K.multiplyVector3(N)}d.z=
+d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=J.material;d.overdraw=T;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][2]}b.push(d);g++}}else if(J instanceof THREE.Face4){l=E[J.a];o=E[J.b];L=E[J.c];N=E[J.d];if(l.__visible&&o.__visible&&L.__visible&&N.__visible)if(A.doubleSided||A.flipSided!=((N.positionScreen.x-l.positionScreen.x)*(o.positionScreen.y-l.positionScreen.y)-(N.positionScreen.y-l.positionScreen.y)*(o.positionScreen.x-l.positionScreen.x)<
 0||(o.positionScreen.x-L.positionScreen.x)*(N.positionScreen.y-L.positionScreen.y)-(o.positionScreen.y-L.positionScreen.y)*(N.positionScreen.x-L.positionScreen.x)<0)){d=j[g]=j[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(l.positionWorld);d.v2.positionWorld.copy(o.positionWorld);d.v3.positionWorld.copy(N.positionWorld);d.v1.positionScreen.copy(l.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(N.positionScreen);d.normalWorld.copy(J.normal);K.multiplyVector3(d.normalWorld);
 d.centroidWorld.copy(J.centroid);Q.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);t.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=R;d.faceMaterial=J.material;d.overdraw=T;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][3]}b.push(d);g++;e=j[g]=j[g]||new THREE.RenderableFace3;e.v1.positionWorld.copy(o.positionWorld);e.v2.positionWorld.copy(L.positionWorld);e.v3.positionWorld.copy(N.positionWorld);
-e.v1.positionScreen.copy(o.positionScreen);e.v2.positionScreen.copy(L.positionScreen);e.v3.positionScreen.copy(N.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=R;e.faceMaterial=J.material;e.overdraw=T;if(A.geometry.uvs[h]){e.uvs[0]=A.geometry.uvs[h][1];e.uvs[1]=A.geometry.uvs[h][2];e.uvs[2]=A.geometry.uvs[h][3]}b.push(e);g++}}}}else if(A instanceof THREE.Line){u.multiply(t,Q);D=A.geometry.vertices;
-V=D[0];V.positionScreen.copy(V.position);u.multiplyVector4(V.positionScreen);h=1;for(z=D.length;h<z;h++){l=D[h];l.positionScreen.copy(l.position);u.multiplyVector4(l.positionScreen);o=D[h-1];w.copy(l.positionScreen);I.copy(o.positionScreen);if(a(w,I)){w.multiplyScalar(1/w.w);I.multiplyScalar(1/I.w);k=p[f]=p[f]||new THREE.RenderableLine;k.v1.positionScreen.copy(w);k.v2.positionScreen.copy(I);k.z=Math.max(w.z,I.z);k.material=A.material;b.push(k);f++}}}else if(A instanceof THREE.Particle){r.set(A.position.x,
-A.position.y,A.position.z,1);t.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=C[v]=C[v]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=A.rotation.z;c.scale.x=A.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=A.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=A.material;b.push(c);v++}}}b.sort(function(Y,P){return P.z-Y.z});return b};this.unprojectVector=function(y,n){var i=new THREE.Matrix4;
+e.v1.positionScreen.copy(o.positionScreen);e.v2.positionScreen.copy(L.positionScreen);e.v3.positionScreen.copy(N.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=R;e.faceMaterial=J.material;e.overdraw=T;if(A.geometry.uvs[h]){e.uvs[0]=A.geometry.uvs[h][1];e.uvs[1]=A.geometry.uvs[h][2];e.uvs[2]=A.geometry.uvs[h][3]}b.push(e);g++}}}}else if(A instanceof THREE.Line){u.multiply(t,Q);E=A.geometry.vertices;
+V=E[0];V.positionScreen.copy(V.position);u.multiplyVector4(V.positionScreen);h=1;for(z=E.length;h<z;h++){l=E[h];l.positionScreen.copy(l.position);u.multiplyVector4(l.positionScreen);o=E[h-1];w.copy(l.positionScreen);I.copy(o.positionScreen);if(a(w,I)){w.multiplyScalar(1/w.w);I.multiplyScalar(1/I.w);k=p[f]=p[f]||new THREE.RenderableLine;k.v1.positionScreen.copy(w);k.v2.positionScreen.copy(I);k.z=Math.max(w.z,I.z);k.material=A.material;b.push(k);f++}}}else if(A instanceof THREE.Particle){r.set(A.position.x,
+A.position.y,A.position.z,1);t.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=D[v]=D[v]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=A.rotation.z;c.scale.x=A.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=A.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=A.material;b.push(c);v++}}}b.sort(function(Y,P){return P.z-Y.z});return b};this.unprojectVector=function(y,n){var i=new THREE.Matrix4;
 i.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));i.multiplyVector3(y);return y}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,j;this.domElement=document.createElement("div");this.setSize=function(k,f){d=k;e=f;g=d/2;j=e/2};this.render=function(k,f){var p,c,v,C,r,t,u,w;a=b.projectScene(k,f);p=0;for(c=a.length;p<c;p++){r=a[p];if(r instanceof THREE.RenderableParticle){u=r.x*g+g;w=r.y*j+j;v=0;for(C=r.material.length;v<C;v++){t=r.material[v];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=u+"px";t.style.top=w+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,g,j,k,f=d.getContext("2d"),p=1,c=0,v=null,C=null,r=1,t=Math.min,u=Math.max,w,I,E,y,n,i,m,h,z,l=new THREE.Color,o=new THREE.Color,B=new THREE.Color,A=new THREE.Color,Q=new THREE.Color,K,R,T,D,V,J,L,N,Y,P,M=new THREE.Rectangle,W=new THREE.Rectangle,q=new THREE.Rectangle,s=false,x=new THREE.Color,G=new THREE.Color,U=new THREE.Color,ca=new THREE.Color,ha=Math.PI*2,$=new THREE.Vector3,la,qa,Da,ea,ra,xa,
-oa=16;la=document.createElement("canvas");la.width=la.height=2;qa=la.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);Da=qa.getImageData(0,0,2,2);ea=Da.data;ra=document.createElement("canvas");ra.width=ra.height=oa;xa=ra.getContext("2d");xa.translate(-oa/2,-oa/2);xa.scale(oa,oa);oa--;this.domElement=d;this.autoClear=true;this.setSize=function(ja,ba){e=ja;g=ba;j=e/2;k=g/2;d.width=e;d.height=g;M.set(-j,-k,j,k)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(M);f.clearRect(W.getX(),
-W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ja,ba){function Ma(H){var X,S,F,O=H.lights;G.setRGB(0,0,0);U.setRGB(0,0,0);ca.setRGB(0,0,0);H=0;for(X=O.length;H<X;H++){S=O[H];F=S.color;if(S instanceof THREE.AmbientLight){G.r+=F.r;G.g+=F.g;G.b+=F.b}else if(S instanceof THREE.DirectionalLight){U.r+=F.r;U.g+=F.g;U.b+=F.b}else if(S instanceof THREE.PointLight){ca.r+=F.r;ca.g+=F.g;ca.b+=F.b}}}function ya(H,X,S,F){var O,Z,da,fa,ga=H.lights;H=0;for(O=ga.length;H<O;H++){Z=ga[H];da=Z.color;
-fa=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*fa;if(Z>0){F.r+=da.r*Z;F.g+=da.g*Z;F.b+=da.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*fa;if(Z>0){F.r+=da.r*Z;F.g+=da.g*Z;F.b+=da.b*Z}}}}function Na(H,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,da,fa,ga;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){da=S.map;fa=da.width>>1;ga=da.height>>1;O=X.scale.x*j;Z=X.scale.y*k;S=O*fa;F=Z*ga;q.set(H.x-S,H.y-F,H.x+S,
-H.y+F);if(M.instersects(q)){f.save();f.translate(H.x,H.y);f.rotate(-X.rotation);f.scale(O,-Z);f.translate(-fa,-ga);f.drawImage(da,0,0);f.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+U.r+ca.r;x.g=G.g+U.g+ca.g;x.b=G.b+U.b+ca.b;l.r=S.color.r*x.r;l.g=S.color.g*x.g;l.b=S.color.b*x.b;l.updateStyleString()}else l.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*k;q.set(H.x-S,H.y-F,H.x+S,H.y+F);if(M.instersects(q)){O=l.__styleString;if(C!=O)f.fillStyle=C=O;f.save();
-f.translate(H.x,H.y);f.rotate(-X.rotation);f.scale(S,F);f.beginPath();f.arc(0,0,1,0,ha,true);f.closePath();f.fill();f.restore()}}}}function Oa(H,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);f.beginPath();f.moveTo(H.positionScreen.x,H.positionScreen.y);f.lineTo(X.positionScreen.x,X.positionScreen.y);f.closePath();if(F instanceof THREE.LineBasicMaterial){l.__styleString=F.color.__styleString;H=F.linewidth;if(r!=H)f.lineWidth=r=H;H=l.__styleString;if(v!=H)f.strokeStyle=v=H;f.stroke();q.inflate(F.linewidth*
-2)}}}function Ia(H,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);y=H.positionScreen.x;n=H.positionScreen.y;i=X.positionScreen.x;m=X.positionScreen.y;h=S.positionScreen.x;z=S.positionScreen.y;f.beginPath();f.moveTo(y,n);f.lineTo(i,m);f.lineTo(h,z);f.lineTo(y,n);f.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map&&!O.wireframe)O.map.mapping instanceof THREE.UVMapping&&sa(y,n,i,m,h,z,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(O.env_map){if(O.env_map.mapping instanceof
-THREE.SphericalReflectionMapping){$.copy(F.vertexNormalsWorld[0]);V=($.x*ba.matrix.n11+$.y*ba.matrix.n12+$.z*ba.matrix.n13)*0.5+0.5;J=-($.x*ba.matrix.n21+$.y*ba.matrix.n22+$.z*ba.matrix.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*ba.matrix.n11+$.y*ba.matrix.n12+$.z*ba.matrix.n13)*0.5+0.5;N=-($.x*ba.matrix.n21+$.y*ba.matrix.n22+$.z*ba.matrix.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*ba.matrix.n11+$.y*ba.matrix.n12+$.z*ba.matrix.n13)*0.5+0.5;P=-($.x*ba.matrix.n21+$.y*ba.matrix.n22+
-$.z*ba.matrix.n23)*0.5+0.5;sa(y,n,i,m,h,z,O.env_map.image,V,J,L,N,Y,P)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&sa(y,n,i,m,h,z,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){o.r=B.r=A.r=G.r;
-o.g=B.g=A.g=G.g;o.b=B.b=A.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],o);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],B);ya(Z,F.v3.positionWorld,F.vertexNormalsWorld[2],A);Q.r=(B.r+A.r)*0.5;Q.g=(B.g+A.g)*0.5;Q.b=(B.b+A.b)*0.5;D=Ja(o,B,A,Q);sa(y,n,i,m,h,z,D,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);l.r=O.color.r*x.r;l.g=O.color.g*x.g;l.b=O.color.b*x.b;l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}else O.wireframe?
-Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){K=O.__2near;R=O.__farPlusNear;T=O.__farMinusNear;o.r=o.g=o.b=1-K/(R-H.positionScreen.z*T);B.r=B.g=B.b=1-K/(R-X.positionScreen.z*T);A.r=A.g=A.b=1-K/(R-S.positionScreen.z*T);Q.r=(B.r+A.r)*0.5;Q.g=(B.g+A.g)*0.5;Q.b=(B.b+A.b)*0.5;D=Ja(o,B,A,Q);sa(y,n,i,m,h,z,D,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(F.normalWorld.x);l.g=Fa(F.normalWorld.y);l.b=Fa(F.normalWorld.z);
-l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}}}function Aa(H,X){if(v!=H)f.strokeStyle=v=H;if(r!=X)f.lineWidth=r=X;f.stroke();q.inflate(X*2)}function Ba(H){if(C!=H)f.fillStyle=C=H;f.fill()}function sa(H,X,S,F,O,Z,da,fa,ga,ta,ma,ua,va){var na,ka;na=da.width-1;ka=da.height-1;fa*=na;ga*=ka;ta*=na;ma*=ka;ua*=na;va*=ka;S-=H;F-=X;O-=H;Z-=X;ta-=fa;ma-=ga;ua-=fa;va-=ga;ka=1/(ta*va-ua*ma);na=(va*S-ma*O)*ka;ma=(va*F-ma*Z)*ka;S=(ta*O-ua*S)*ka;F=(ta*Z-ua*F)*ka;
-H=H-na*fa-S*ga;X=X-ma*fa-F*ga;f.save();f.transform(na,ma,S,F,H,X);f.clip();f.drawImage(da,0,0);f.restore()}function Ea(H){if(p!=H)f.globalAlpha=p=H}function za(H){if(c!=H){switch(H){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=H}}function Ja(H,X,S,F){ea[0]=u(0,t(255,~~(H.r*255)));ea[1]=u(0,t(255,~~(H.g*255)));ea[2]=u(0,t(255,~~(H.b*
-255)));ea[4]=u(0,t(255,~~(X.r*255)));ea[5]=u(0,t(255,~~(X.g*255)));ea[6]=u(0,t(255,~~(X.b*255)));ea[8]=u(0,t(255,~~(S.r*255)));ea[9]=u(0,t(255,~~(S.g*255)));ea[10]=u(0,t(255,~~(S.b*255)));ea[12]=u(0,t(255,~~(F.r*255)));ea[13]=u(0,t(255,~~(F.g*255)));ea[14]=u(0,t(255,~~(F.b*255)));qa.putImageData(Da,0,0);xa.drawImage(la,0,0);return ra}function Fa(H){return H<0?t((1+H)*0.5,0.5):0.5+t(H*0.5,0.5)}function Ga(H,X){var S=X.x-H.x,F=X.y-H.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;H.x-=S;H.y-=F}var Ca,
-Ka,aa,ia,pa,Ha,La,wa;f.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ja,ba);(s=ja.lights.length>0)&&Ma(ja);Ca=0;for(Ka=a.length;Ca<Ka;Ca++){aa=a[Ca];q.empty();if(aa instanceof THREE.RenderableParticle){w=aa;w.x*=j;w.y*=k;ia=0;for(pa=aa.material.length;ia<pa;ia++)Na(w,aa,aa.material[ia],ja)}else if(aa instanceof THREE.RenderableLine){w=aa.v1;I=aa.v2;w.positionScreen.x*=j;w.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;q.addPoint(w.positionScreen.x,w.positionScreen.y);
-q.addPoint(I.positionScreen.x,I.positionScreen.y);if(M.instersects(q)){ia=0;for(pa=aa.material.length;ia<pa;)Oa(w,I,aa,aa.material[ia++],ja)}}else if(aa instanceof THREE.RenderableFace3){w=aa.v1;I=aa.v2;E=aa.v3;w.positionScreen.x*=j;w.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;E.positionScreen.x*=j;E.positionScreen.y*=k;if(aa.overdraw){Ga(w.positionScreen,I.positionScreen);Ga(I.positionScreen,E.positionScreen);Ga(E.positionScreen,w.positionScreen)}q.addPoint(w.positionScreen.x,
-w.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);q.addPoint(E.positionScreen.x,E.positionScreen.y);if(M.instersects(q)){ia=0;for(pa=aa.meshMaterial.length;ia<pa;){wa=aa.meshMaterial[ia++];if(wa instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterial.length;Ha<La;)(wa=aa.faceMaterial[Ha++])&&Ia(w,I,E,aa,wa,ja)}else Ia(w,I,E,aa,wa,ja)}}}W.addRectangle(q)}f.setTransform(1,0,0,1,0,0)}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,j;this.domElement=document.createElement("div");this.setSize=function(k,f){d=k;e=f;g=d/2;j=e/2};this.render=function(k,f){var p,c,v,D,r,t,u,w;a=b.projectScene(k,f);p=0;for(c=a.length;p<c;p++){r=a[p];if(r instanceof THREE.RenderableParticle){u=r.x*g+g;w=r.y*j+j;v=0;for(D=r.material.length;v<D;v++){t=r.material[v];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=u+"px";t.style.top=w+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,g,j,k,f=d.getContext("2d"),p=1,c=0,v=null,D=null,r=1,t=Math.min,u=Math.max,w,I,F,y,n,i,m,h,z,l=new THREE.Color,o=new THREE.Color,B=new THREE.Color,A=new THREE.Color,Q=new THREE.Color,K,R,T,E,V,J,L,N,Y,P,M=new THREE.Rectangle,W=new THREE.Rectangle,q=new THREE.Rectangle,s=false,x=new THREE.Color,H=new THREE.Color,U=new THREE.Color,ba=new THREE.Color,ga=Math.PI*2,$=new THREE.Vector3,ka,pa,Da,da,qa,wa,
+na=16;ka=document.createElement("canvas");ka.width=ka.height=2;pa=ka.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Da=pa.getImageData(0,0,2,2);da=Da.data;qa=document.createElement("canvas");qa.width=qa.height=na;wa=qa.getContext("2d");wa.translate(-na/2,-na/2);wa.scale(na,na);na--;this.domElement=d;this.autoClear=true;this.setSize=function(ia,xa){e=ia;g=xa;j=e/2;k=g/2;d.width=e;d.height=g;M.set(-j,-k,j,k)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(M);f.clearRect(W.getX(),
+W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ia,xa){function Ma(C){var X,S,G,O=C.lights;H.setRGB(0,0,0);U.setRGB(0,0,0);ba.setRGB(0,0,0);C=0;for(X=O.length;C<X;C++){S=O[C];G=S.color;if(S instanceof THREE.AmbientLight){H.r+=G.r;H.g+=G.g;H.b+=G.b}else if(S instanceof THREE.DirectionalLight){U.r+=G.r;U.g+=G.g;U.b+=G.b}else if(S instanceof THREE.PointLight){ba.r+=G.r;ba.g+=G.g;ba.b+=G.b}}}function ya(C,X,S,G){var O,Z,ca,ea,fa=C.lights;C=0;for(O=fa.length;C<O;C++){Z=fa[C];ca=Z.color;
+ea=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=S.dot(Z.position)*ea;if(Z>0){G.r+=ca.r*Z;G.g+=ca.g*Z;G.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*ea;if(Z>0){G.r+=ca.r*Z;G.g+=ca.g*Z;G.b+=ca.b*Z}}}}function Na(C,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var G,O,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;O=X.scale.x*j;Z=X.scale.y*k;S=O*ea;G=Z*fa;q.set(C.x-S,C.y-G,C.x+S,
+C.y+G);if(M.instersects(q)){f.save();f.translate(C.x,C.y);f.rotate(-X.rotation);f.scale(O,-Z);f.translate(-ea,-fa);f.drawImage(ca,0,0);f.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=H.r+U.r+ba.r;x.g=H.g+U.g+ba.g;x.b=H.b+U.b+ba.b;l.r=S.color.r*x.r;l.g=S.color.g*x.g;l.b=S.color.b*x.b;l.updateStyleString()}else l.__styleString=S.color.__styleString;S=X.scale.x*j;G=X.scale.y*k;q.set(C.x-S,C.y-G,C.x+S,C.y+G);if(M.instersects(q)){O=l.__styleString;if(D!=O)f.fillStyle=D=O;f.save();
+f.translate(C.x,C.y);f.rotate(-X.rotation);f.scale(S,G);f.beginPath();f.arc(0,0,1,0,ga,true);f.closePath();f.fill();f.restore()}}}}function Oa(C,X,S,G){if(G.opacity!=0){Ea(G.opacity);za(G.blending);f.beginPath();f.moveTo(C.positionScreen.x,C.positionScreen.y);f.lineTo(X.positionScreen.x,X.positionScreen.y);f.closePath();if(G instanceof THREE.LineBasicMaterial){l.__styleString=G.color.__styleString;C=G.linewidth;if(r!=C)f.lineWidth=r=C;C=l.__styleString;if(v!=C)f.strokeStyle=v=C;f.stroke();q.inflate(G.linewidth*
+2)}}}function Ia(C,X,S,G,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);y=C.positionScreen.x;n=C.positionScreen.y;i=X.positionScreen.x;m=X.positionScreen.y;h=S.positionScreen.x;z=S.positionScreen.y;f.beginPath();f.moveTo(y,n);f.lineTo(i,m);f.lineTo(h,z);f.lineTo(y,n);f.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&ra(y,n,i,m,h,z,O.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof
+THREE.SphericalReflectionMapping){C=xa.matrix;$.copy(G.vertexNormalsWorld[0]);V=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;J=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;$.copy(G.vertexNormalsWorld[1]);L=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;N=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;$.copy(G.vertexNormalsWorld[2]);Y=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;P=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;ra(y,n,i,m,h,z,O.env_map.image,V,J,L,N,Y,P)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):
+Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&ra(y,n,i,m,h,z,O.map.image,G.uvs[0].u,G.uvs[0].v,G.uvs[1].u,G.uvs[1].v,G.uvs[2].u,G.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&G.vertexNormalsWorld.length==3){o.r=B.r=A.r=H.r;o.g=B.g=A.g=H.g;o.b=B.b=A.b=H.b;ya(Z,G.v1.positionWorld,G.vertexNormalsWorld[0],o);ya(Z,G.v2.positionWorld,G.vertexNormalsWorld[1],B);ya(Z,
+G.v3.positionWorld,G.vertexNormalsWorld[2],A);Q.r=(B.r+A.r)*0.5;Q.g=(B.g+A.g)*0.5;Q.b=(B.b+A.b)*0.5;E=Ja(o,B,A,Q);ra(y,n,i,m,h,z,E,0,0,1,0,0,1)}else{x.r=H.r;x.g=H.g;x.b=H.b;ya(Z,G.centroidWorld,G.normalWorld,x);l.r=O.color.r*x.r;l.g=O.color.g*x.g;l.b=O.color.b*x.b;l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){K=O.__2near;
+R=O.__farPlusNear;T=O.__farMinusNear;o.r=o.g=o.b=1-K/(R-C.positionScreen.z*T);B.r=B.g=B.b=1-K/(R-X.positionScreen.z*T);A.r=A.g=A.b=1-K/(R-S.positionScreen.z*T);Q.r=(B.r+A.r)*0.5;Q.g=(B.g+A.g)*0.5;Q.b=(B.b+A.b)*0.5;E=Ja(o,B,A,Q);ra(y,n,i,m,h,z,E,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(G.normalWorld.x);l.g=Fa(G.normalWorld.y);l.b=Fa(G.normalWorld.z);l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}}}function Aa(C,X){if(v!=C)f.strokeStyle=
+v=C;if(r!=X)f.lineWidth=r=X;f.stroke();q.inflate(X*2)}function Ba(C){if(D!=C)f.fillStyle=D=C;f.fill()}function ra(C,X,S,G,O,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=C;G-=X;O-=C;Z-=X;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*O)*ja;la=(ua*G-la*Z)*ja;S=(sa*O-ta*S)*ja;G=(sa*Z-ta*G)*ja;C=C-ma*ea-S*fa;X=X-la*ea-G*fa;f.save();f.transform(ma,la,S,G,C,X);f.clip();f.drawImage(ca,0,0);f.restore()}function Ea(C){if(p!=C)f.globalAlpha=
+p=C}function za(C){if(c!=C){switch(C){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=C}}function Ja(C,X,S,G){da[0]=u(0,t(255,~~(C.r*255)));da[1]=u(0,t(255,~~(C.g*255)));da[2]=u(0,t(255,~~(C.b*255)));da[4]=u(0,t(255,~~(X.r*255)));da[5]=u(0,t(255,~~(X.g*255)));da[6]=u(0,t(255,~~(X.b*255)));da[8]=u(0,t(255,~~(S.r*255)));da[9]=u(0,t(255,
+~~(S.g*255)));da[10]=u(0,t(255,~~(S.b*255)));da[12]=u(0,t(255,~~(G.r*255)));da[13]=u(0,t(255,~~(G.g*255)));da[14]=u(0,t(255,~~(G.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(C){return C<0?t((1+C)*0.5,0.5):0.5+t(C*0.5,0.5)}function Ga(C,X){var S=X.x-C.x,G=X.y-C.y,O=1/Math.sqrt(S*S+G*G);S*=O;G*=O;X.x+=S;X.y+=G;C.x-=S;C.y-=G}var Ca,Ka,aa,ha,oa,Ha,La,va;f.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0;
+for(Ka=a.length;Ca<Ka;Ca++){aa=a[Ca];q.empty();if(aa instanceof THREE.RenderableParticle){w=aa;w.x*=j;w.y*=k;ha=0;for(oa=aa.material.length;ha<oa;ha++)Na(w,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){w=aa.v1;I=aa.v2;w.positionScreen.x*=j;w.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);if(M.instersects(q)){ha=0;for(oa=aa.material.length;ha<oa;)Oa(w,I,aa,aa.material[ha++],
+ia)}}else if(aa instanceof THREE.RenderableFace3){w=aa.v1;I=aa.v2;F=aa.v3;w.positionScreen.x*=j;w.positionScreen.y*=k;I.positionScreen.x*=j;I.positionScreen.y*=k;F.positionScreen.x*=j;F.positionScreen.y*=k;if(aa.overdraw){Ga(w.positionScreen,I.positionScreen);Ga(I.positionScreen,F.positionScreen);Ga(F.positionScreen,w.positionScreen)}q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);q.addPoint(F.positionScreen.x,F.positionScreen.y);if(M.instersects(q)){ha=
+0;for(oa=aa.meshMaterial.length;ha<oa;){va=aa.meshMaterial[ha++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(La=aa.faceMaterial.length;Ha<La;)(va=aa.faceMaterial[Ha++])&&Ia(w,I,F,aa,va,ia)}else Ia(w,I,F,aa,va,ia)}}}W.addRectangle(q)}f.setTransform(1,0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function a(J,L,N){var Y,P,M,W;Y=0;for(P=J.lights.length;Y<P;Y++){M=J.lights[Y];if(M instanceof THREE.DirectionalLight){W=L.normalWorld.dot(M.position)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){o.sub(M.position,L.centroidWorld);o.normalize();W=L.normalWorld.dot(o)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(J,L,N,Y,P,M){K=e(R++);K.setAttribute("d","M "+J.positionScreen.x+
 " "+J.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)n.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(y){i.r=m.r;i.g=m.g;i.b=m.b;a(M,Y,i);n.r=P.color.r*i.r;n.g=P.color.g*i.g;n.b=P.color.b*i.b;n.updateStyleString()}else n.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){l=1-P.__2near/(P.__farPlusNear-Y.z*P.__farMinusNear);
 n.setRGB(l,l,l)}else P instanceof THREE.MeshNormalMaterial&&n.setRGB(g(Y.normalWorld.x),g(Y.normalWorld.y),g(Y.normalWorld.z));P.wireframe?K.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+P.wireframe_linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframe_linecap+"; stroke-linejoin: "+P.wireframe_linejoin):K.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+P.opacity);f.appendChild(K)}function d(J,L,N,Y,P,M,W){K=e(R++);K.setAttribute("d",
 "M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(y){i.r=m.r;i.g=m.g;i.b=m.b;a(W,P,i);n.r=M.color.r*i.r;n.g=M.color.g*i.g;n.b=M.color.b*i.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){l=
 1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);n.setRGB(l,l,l)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));M.wireframe?K.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):K.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);f.appendChild(K)}
-function e(J){if(B[J]==null){B[J]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&B[J].setAttribute("shape-rendering","crispEdges");return B[J]}return B[J]}function g(J){return J<0?Math.min((1+J)*0.5,0.5):0.5+Math.min(J*0.5,0.5)}var j=null,k=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,c,v,C,r,t,u,w,I=new THREE.Rectangle,E=new THREE.Rectangle,y=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),m=new THREE.Color(0),h=new THREE.Color(0),
-z=new THREE.Color(0),l,o=new THREE.Vector3,B=[],A=[],Q=[],K,R,T,D,V=1;this.domElement=f;this.autoClear=true;this.setQuality=function(J){switch(J){case "high":V=1;break;case "low":V=0}};this.setSize=function(J,L){p=J;c=L;v=p/2;C=c/2;f.setAttribute("viewBox",-v+" "+-C+" "+p+" "+c);f.setAttribute("width",p);f.setAttribute("height",c);I.set(-v,-C,v,C)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(J,L){var N,Y,P,M,W,q,s,x;this.autoClear&&this.clear();
-j=k.projectScene(J,L);D=T=R=0;if(y=J.lights.length>0){s=J.lights;m.setRGB(0,0,0);h.setRGB(0,0,0);z.setRGB(0,0,0);N=0;for(Y=s.length;N<Y;N++){P=s[N];M=P.color;if(P instanceof THREE.AmbientLight){m.r+=M.r;m.g+=M.g;m.b+=M.b}else if(P instanceof THREE.DirectionalLight){h.r+=M.r;h.g+=M.g;h.b+=M.b}else if(P instanceof THREE.PointLight){z.r+=M.r;z.g+=M.g;z.b+=M.b}}}N=0;for(Y=j.length;N<Y;N++){s=j[N];E.empty();if(s instanceof THREE.RenderableParticle){r=s;r.x*=v;r.y*=-C;P=0;for(M=s.material.length;P<M;P++)if(x=
-s.material[P]){W=r;q=s;x=x;var G=T++;if(A[G]==null){A[G]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&A[G].setAttribute("shape-rendering","crispEdges")}K=A[G];K.setAttribute("cx",W.x);K.setAttribute("cy",W.y);K.setAttribute("r",q.scale.x*v);if(x instanceof THREE.ParticleCircleMaterial){if(y){i.r=m.r+h.r+z.r;i.g=m.g+h.g+z.g;i.b=m.b+h.b+z.b;n.r=x.color.r*i.r;n.g=x.color.g*i.g;n.b=x.color.b*i.b;n.updateStyleString()}else n=x.color;K.setAttribute("style","fill: "+n.__styleString)}f.appendChild(K)}}else if(s instanceof
-THREE.RenderableLine){r=s.v1;t=s.v2;r.positionScreen.x*=v;r.positionScreen.y*=-C;t.positionScreen.x*=v;t.positionScreen.y*=-C;E.addPoint(r.positionScreen.x,r.positionScreen.y);E.addPoint(t.positionScreen.x,t.positionScreen.y);if(I.instersects(E)){P=0;for(M=s.material.length;P<M;)if(x=s.material[P++]){W=r;q=t;x=x;G=D++;if(Q[G]==null){Q[G]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&Q[G].setAttribute("shape-rendering","crispEdges")}K=Q[G];K.setAttribute("x1",W.positionScreen.x);
+function e(J){if(B[J]==null){B[J]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&B[J].setAttribute("shape-rendering","crispEdges");return B[J]}return B[J]}function g(J){return J<0?Math.min((1+J)*0.5,0.5):0.5+Math.min(J*0.5,0.5)}var j=null,k=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,c,v,D,r,t,u,w,I=new THREE.Rectangle,F=new THREE.Rectangle,y=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),m=new THREE.Color(0),h=new THREE.Color(0),
+z=new THREE.Color(0),l,o=new THREE.Vector3,B=[],A=[],Q=[],K,R,T,E,V=1;this.domElement=f;this.autoClear=true;this.setQuality=function(J){switch(J){case "high":V=1;break;case "low":V=0}};this.setSize=function(J,L){p=J;c=L;v=p/2;D=c/2;f.setAttribute("viewBox",-v+" "+-D+" "+p+" "+c);f.setAttribute("width",p);f.setAttribute("height",c);I.set(-v,-D,v,D)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(J,L){var N,Y,P,M,W,q,s,x;this.autoClear&&this.clear();
+j=k.projectScene(J,L);E=T=R=0;if(y=J.lights.length>0){s=J.lights;m.setRGB(0,0,0);h.setRGB(0,0,0);z.setRGB(0,0,0);N=0;for(Y=s.length;N<Y;N++){P=s[N];M=P.color;if(P instanceof THREE.AmbientLight){m.r+=M.r;m.g+=M.g;m.b+=M.b}else if(P instanceof THREE.DirectionalLight){h.r+=M.r;h.g+=M.g;h.b+=M.b}else if(P instanceof THREE.PointLight){z.r+=M.r;z.g+=M.g;z.b+=M.b}}}N=0;for(Y=j.length;N<Y;N++){s=j[N];F.empty();if(s instanceof THREE.RenderableParticle){r=s;r.x*=v;r.y*=-D;P=0;for(M=s.material.length;P<M;P++)if(x=
+s.material[P]){W=r;q=s;x=x;var H=T++;if(A[H]==null){A[H]=document.createElementNS("http://www.w3.org/2000/svg","circle");V==0&&A[H].setAttribute("shape-rendering","crispEdges")}K=A[H];K.setAttribute("cx",W.x);K.setAttribute("cy",W.y);K.setAttribute("r",q.scale.x*v);if(x instanceof THREE.ParticleCircleMaterial){if(y){i.r=m.r+h.r+z.r;i.g=m.g+h.g+z.g;i.b=m.b+h.b+z.b;n.r=x.color.r*i.r;n.g=x.color.g*i.g;n.b=x.color.b*i.b;n.updateStyleString()}else n=x.color;K.setAttribute("style","fill: "+n.__styleString)}f.appendChild(K)}}else if(s instanceof
+THREE.RenderableLine){r=s.v1;t=s.v2;r.positionScreen.x*=v;r.positionScreen.y*=-D;t.positionScreen.x*=v;t.positionScreen.y*=-D;F.addPoint(r.positionScreen.x,r.positionScreen.y);F.addPoint(t.positionScreen.x,t.positionScreen.y);if(I.instersects(F)){P=0;for(M=s.material.length;P<M;)if(x=s.material[P++]){W=r;q=t;x=x;H=E++;if(Q[H]==null){Q[H]=document.createElementNS("http://www.w3.org/2000/svg","line");V==0&&Q[H].setAttribute("shape-rendering","crispEdges")}K=Q[H];K.setAttribute("x1",W.positionScreen.x);
 K.setAttribute("y1",W.positionScreen.y);K.setAttribute("x2",q.positionScreen.x);K.setAttribute("y2",q.positionScreen.y);if(x instanceof THREE.LineBasicMaterial){n.__styleString=x.color.__styleString;K.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+x.linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.linecap+"; stroke-linejoin: "+x.linejoin);f.appendChild(K)}}}}else if(s instanceof THREE.RenderableFace3){r=s.v1;t=s.v2;u=s.v3;r.positionScreen.x*=v;r.positionScreen.y*=
--C;t.positionScreen.x*=v;t.positionScreen.y*=-C;u.positionScreen.x*=v;u.positionScreen.y*=-C;E.addPoint(r.positionScreen.x,r.positionScreen.y);E.addPoint(t.positionScreen.x,t.positionScreen.y);E.addPoint(u.positionScreen.x,u.positionScreen.y);if(I.instersects(E)){P=0;for(M=s.meshMaterial.length;P<M;){x=s.meshMaterial[P++];if(x instanceof THREE.MeshFaceMaterial){W=0;for(q=s.faceMaterial.length;W<q;)(x=s.faceMaterial[W++])&&b(r,t,u,s,x,J)}else x&&b(r,t,u,s,x,J)}}}else if(s instanceof THREE.RenderableFace4){r=
-s.v1;t=s.v2;u=s.v3;w=s.v4;r.positionScreen.x*=v;r.positionScreen.y*=-C;t.positionScreen.x*=v;t.positionScreen.y*=-C;u.positionScreen.x*=v;u.positionScreen.y*=-C;w.positionScreen.x*=v;w.positionScreen.y*=-C;E.addPoint(r.positionScreen.x,r.positionScreen.y);E.addPoint(t.positionScreen.x,t.positionScreen.y);E.addPoint(u.positionScreen.x,u.positionScreen.y);E.addPoint(w.positionScreen.x,w.positionScreen.y);if(I.instersects(E)){P=0;for(M=s.meshMaterial.length;P<M;){x=s.meshMaterial[P++];if(x instanceof
+-D;t.positionScreen.x*=v;t.positionScreen.y*=-D;u.positionScreen.x*=v;u.positionScreen.y*=-D;F.addPoint(r.positionScreen.x,r.positionScreen.y);F.addPoint(t.positionScreen.x,t.positionScreen.y);F.addPoint(u.positionScreen.x,u.positionScreen.y);if(I.instersects(F)){P=0;for(M=s.meshMaterial.length;P<M;){x=s.meshMaterial[P++];if(x instanceof THREE.MeshFaceMaterial){W=0;for(q=s.faceMaterial.length;W<q;)(x=s.faceMaterial[W++])&&b(r,t,u,s,x,J)}else x&&b(r,t,u,s,x,J)}}}else if(s instanceof THREE.RenderableFace4){r=
+s.v1;t=s.v2;u=s.v3;w=s.v4;r.positionScreen.x*=v;r.positionScreen.y*=-D;t.positionScreen.x*=v;t.positionScreen.y*=-D;u.positionScreen.x*=v;u.positionScreen.y*=-D;w.positionScreen.x*=v;w.positionScreen.y*=-D;F.addPoint(r.positionScreen.x,r.positionScreen.y);F.addPoint(t.positionScreen.x,t.positionScreen.y);F.addPoint(u.positionScreen.x,u.positionScreen.y);F.addPoint(w.positionScreen.x,w.positionScreen.y);if(I.instersects(F)){P=0;for(M=s.meshMaterial.length;P<M;){x=s.meshMaterial[P++];if(x instanceof
 THREE.MeshFaceMaterial){W=0;for(q=s.faceMaterial.length;W<q;)(x=s.faceMaterial[W++])&&d(r,t,u,w,s,x,J)}else x&&d(r,t,u,w,s,x,J)}}}}}};
 THREE.WebGLRenderer=function(a){function b(i,m){var h=c.createProgram();c.attachShader(h,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+i));c.attachShader(h,k("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+m));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,
 c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(i,m){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.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,
@@ -135,9 +135,9 @@ c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMA
 i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(i.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function g(i,m){var h,z,l;
 h=0;for(z=m.length;h<z;h++){l=m[h];i.uniforms[l]=c.getUniformLocation(i,l)}}function j(i,m){var h,z,l;h=0;for(z=m.length;h<z;h++){l=m[h];i.attributes[l]=c.getAttribLocation(i,l);i.attributes[l]>=0&&c.enableVertexAttribArray(i.attributes[l])}}function k(i,m){var h;if(i=="fragment")h=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")h=c.createShader(c.VERTEX_SHADER);c.shaderSource(h,m);c.compileShader(h);if(!c.getShaderParameter(h,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(h));return null}return h}
 function f(i){switch(i){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}
-var p=document.createElement("canvas"),c,v,C,r=new THREE.Matrix4,t,u=new Float32Array(16),w=new Float32Array(16),I=new Float32Array(16),E=new Float32Array(9),y=new Float32Array(16);a=function(i,m){if(i){var h,z,l,o=pointLights=maxDirLights=maxPointLights=0;h=0;for(z=i.lights.length;h<z;h++){l=i.lights[h];l instanceof THREE.DirectionalLight&&o++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+o<=m){maxDirLights=o;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*o/(pointLights+o));
+var p=document.createElement("canvas"),c,v,D,r=new THREE.Matrix4,t,u=new Float32Array(16),w=new Float32Array(16),I=new Float32Array(16),F=new Float32Array(9),y=new Float32Array(16);a=function(i,m){if(i){var h,z,l,o=pointLights=maxDirLights=maxPointLights=0;h=0;for(z=i.lights.length;h<z;h++){l=i.lights[h];l instanceof THREE.DirectionalLight&&o++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+o<=m){maxDirLights=o;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*o/(pointLights+o));
 maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a,4);this.domElement=p;this.autoClear=true;try{c=p.getContext("experimental-webgl",{antialias:true})}catch(n){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);
-c.clearColor(0,0,0,0);v=C=function(i,m){var h=[i?"#define MAX_DIR_LIGHTS "+i:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":
+c.clearColor(0,0,0,0);v=D=function(i,m){var h=[i?"#define MAX_DIR_LIGHTS "+i:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":
 "","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",m?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 "",m?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",m?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",m?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
@@ -151,62 +151,62 @@ h=b(z,h);c.useProgram(h);g(h,["viewMatrix","modelViewMatrix","projectionMatrix",
 "pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);j(h,["position","normal","uv"]);return h}(a.directional,a.point);this.setSize=function(i,m){p.width=i;p.height=m;c.viewport(0,0,p.width,p.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,m){var h,z,l,o,B,A=[],
 Q=[],K=[];o=[];B=[];c.uniform1i(i.uniforms.enableLighting,m.length);h=0;for(z=m.length;h<z;h++){l=m[h];if(l instanceof THREE.AmbientLight)A.push(l);else if(l instanceof THREE.DirectionalLight)K.push(l);else l instanceof THREE.PointLight&&Q.push(l)}h=l=o=B=0;for(z=A.length;h<z;h++){l+=A[h].color.r;o+=A[h].color.g;B+=A[h].color.b}c.uniform3f(i.uniforms.ambientLightColor,l,o,B);o=[];B=[];h=0;for(z=K.length;h<z;h++){l=K[h];o.push(l.color.r*l.intensity);o.push(l.color.g*l.intensity);o.push(l.color.b*l.intensity);
 B.push(l.position.x);B.push(l.position.y);B.push(l.position.z)}if(K.length){c.uniform1i(i.uniforms.directionalLightNumber,K.length);c.uniform3fv(i.uniforms.directionalLightDirection,B);c.uniform3fv(i.uniforms.directionalLightColor,o)}o=[];B=[];h=0;for(z=Q.length;h<z;h++){l=Q[h];o.push(l.color.r*l.intensity);o.push(l.color.g*l.intensity);o.push(l.color.b*l.intensity);B.push(l.position.x);B.push(l.position.y);B.push(l.position.z)}if(Q.length){c.uniform1i(i.uniforms.pointLightNumber,Q.length);c.uniform3fv(i.uniforms.pointLightPosition,
-B);c.uniform3fv(i.uniforms.pointLightColor,o)}};this.createBuffers=function(i,m){var h,z,l,o,B,A,Q,K,R=[],T=[],D=[],V=[],J=[],L=0,N=i.geometry.geometryChunks[m],Y;l=false;h=0;for(z=i.material.length;h<z;h++){meshMaterial=i.material[h];if(meshMaterial instanceof THREE.MeshFaceMaterial){B=0;for(Y=N.material.length;B<Y;B++)if(N.material[B]&&N.material[B].shading!=undefined&&N.material[B].shading==THREE.SmoothShading){l=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
-THREE.SmoothShading){l=true;break}if(l)break}Y=l;h=0;for(z=N.faces.length;h<z;h++){l=N.faces[h];o=i.geometry.faces[l];B=o.vertexNormals;faceNormal=o.normal;l=i.geometry.uvs[l];if(o instanceof THREE.Face3){A=i.geometry.vertices[o.a].position;Q=i.geometry.vertices[o.b].position;K=i.geometry.vertices[o.c].position;D.push(A.x,A.y,A.z);D.push(Q.x,Q.y,Q.z);D.push(K.x,K.y,K.z);if(B.length==3&&Y)for(o=0;o<3;o++)V.push(B[o].x,B[o].y,B[o].z);else for(o=0;o<3;o++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);
-if(l)for(o=0;o<3;o++)J.push(l[o].u,l[o].v);R.push(L,L+1,L+2);T.push(L,L+1);T.push(L,L+2);T.push(L+1,L+2);L+=3}else if(o instanceof THREE.Face4){A=i.geometry.vertices[o.a].position;Q=i.geometry.vertices[o.b].position;K=i.geometry.vertices[o.c].position;o=i.geometry.vertices[o.d].position;D.push(A.x,A.y,A.z);D.push(Q.x,Q.y,Q.z);D.push(K.x,K.y,K.z);D.push(o.x,o.y,o.z);if(B.length==4&&Y)for(o=0;o<4;o++)V.push(B[o].x,B[o].y,B[o].z);else for(o=0;o<4;o++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(l)for(o=
-0;o<4;o++)J.push(l[o].u,l[o].v);R.push(L,L+1,L+2);R.push(L,L+2,L+3);T.push(L,L+1);T.push(L,L+2);T.push(L,L+3);T.push(L+1,L+2);T.push(L+2,L+3);L+=4}}if(D.length){N.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);N.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);if(J.length>0){N.__webGLUVBuffer=c.createBuffer();
+B);c.uniform3fv(i.uniforms.pointLightColor,o)}};this.createBuffers=function(i,m){var h,z,l,o,B,A,Q,K,R=[],T=[],E=[],V=[],J=[],L=0,N=i.geometry.geometryChunks[m],Y;l=false;h=0;for(z=i.material.length;h<z;h++){meshMaterial=i.material[h];if(meshMaterial instanceof THREE.MeshFaceMaterial){B=0;for(Y=N.material.length;B<Y;B++)if(N.material[B]&&N.material[B].shading!=undefined&&N.material[B].shading==THREE.SmoothShading){l=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
+THREE.SmoothShading){l=true;break}if(l)break}Y=l;h=0;for(z=N.faces.length;h<z;h++){l=N.faces[h];o=i.geometry.faces[l];B=o.vertexNormals;faceNormal=o.normal;l=i.geometry.uvs[l];if(o instanceof THREE.Face3){A=i.geometry.vertices[o.a].position;Q=i.geometry.vertices[o.b].position;K=i.geometry.vertices[o.c].position;E.push(A.x,A.y,A.z);E.push(Q.x,Q.y,Q.z);E.push(K.x,K.y,K.z);if(B.length==3&&Y)for(o=0;o<3;o++)V.push(B[o].x,B[o].y,B[o].z);else for(o=0;o<3;o++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);
+if(l)for(o=0;o<3;o++)J.push(l[o].u,l[o].v);R.push(L,L+1,L+2);T.push(L,L+1);T.push(L,L+2);T.push(L+1,L+2);L+=3}else if(o instanceof THREE.Face4){A=i.geometry.vertices[o.a].position;Q=i.geometry.vertices[o.b].position;K=i.geometry.vertices[o.c].position;o=i.geometry.vertices[o.d].position;E.push(A.x,A.y,A.z);E.push(Q.x,Q.y,Q.z);E.push(K.x,K.y,K.z);E.push(o.x,o.y,o.z);if(B.length==4&&Y)for(o=0;o<4;o++)V.push(B[o].x,B[o].y,B[o].z);else for(o=0;o<4;o++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(l)for(o=
+0;o<4;o++)J.push(l[o].u,l[o].v);R.push(L,L+1,L+2);R.push(L,L+2,L+3);T.push(L,L+1);T.push(L,L+2);T.push(L,L+3);T.push(L+1,L+2);T.push(L+2,L+3);L+=4}}if(E.length){N.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(E),c.STATIC_DRAW);N.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,N.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW);if(J.length>0){N.__webGLUVBuffer=c.createBuffer();
 c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(J),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=R.length;N.__webGLLineCount=T.length}};this.renderBuffer=
-function(i,m,h,z){var l,o,B,A,Q,K,R,T,D;if(h instanceof THREE.MeshShaderMaterial){if(!h.program){h.program=b(h.fragment_shader,h.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in h.uniforms)R.push(D);g(h.program,R);j(h.program,["position","normal","uv"])}D=h.program}else D=C;if(D!=v){c.useProgram(D);v=D}D==C&&this.setupLights(D,m);this.loadCamera(D,i);this.loadMatrices(D);if(h instanceof THREE.MeshShaderMaterial){B=h.wireframe;
-A=h.wireframe_linewidth;i=D;m=h.uniforms;var V;for(l in m){T=m[l].type;R=m[l].value;V=i.uniforms[l];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);if(T=m[l].texture)T.image instanceof Array&&T.image.length==6?d(T,R):e(T,R)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){l=h.color;o=h.opacity;B=h.wireframe;A=h.wireframe_linewidth;Q=h.map;K=h.env_map;m=h.combine==THREE.MixOperation;
-i=h.reflectivity;T=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;R=h.refraction_ratio;c.uniform4f(D.uniforms.mColor,l.r*o,l.g*o,l.b*o,o);c.uniform1i(D.uniforms.mixEnvMap,m);c.uniform1f(D.uniforms.mReflectivity,i);c.uniform1i(D.uniforms.useRefract,T);c.uniform1f(D.uniforms.mRefractionRatio,R)}if(h instanceof THREE.MeshNormalMaterial){o=h.opacity;c.uniform1f(D.uniforms.mOpacity,o);c.uniform1i(D.uniforms.material,4)}else if(h instanceof THREE.MeshDepthMaterial){o=h.opacity;B=h.wireframe;
-A=h.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,o);c.uniform1f(D.uniforms.m2Near,h.__2near);c.uniform1f(D.uniforms.mFarPlusNear,h.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,h.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(h instanceof THREE.MeshPhongMaterial){l=h.ambient;i=h.specular;h=h.shininess;c.uniform4f(D.uniforms.mAmbient,l.r,l.g,l.b,o);c.uniform4f(D.uniforms.mSpecular,i.r,i.g,i.b,o);c.uniform1f(D.uniforms.mShininess,h);c.uniform1i(D.uniforms.material,2)}else if(h instanceof
-THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(h instanceof THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,0);else if(h instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);K=h.env_map}if(Q){e(Q,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(K){d(K,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);o=D.attributes;c.bindBuffer(c.ARRAY_BUFFER,
+function(i,m,h,z){var l,o,B,A,Q,K,R,T,E;if(h instanceof THREE.MeshShaderMaterial){if(!h.program){h.program=b(h.fragment_shader,h.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in h.uniforms)R.push(E);g(h.program,R);j(h.program,["position","normal","uv"])}E=h.program}else E=D;if(E!=v){c.useProgram(E);v=E}E==D&&this.setupLights(E,m);this.loadCamera(E,i);this.loadMatrices(E);if(h instanceof THREE.MeshShaderMaterial){B=h.wireframe;
+A=h.wireframe_linewidth;i=E;m=h.uniforms;var V;for(l in m){T=m[l].type;R=m[l].value;V=i.uniforms[l];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);if(T=m[l].texture)T.image instanceof Array&&T.image.length==6?d(T,R):e(T,R)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){l=h.color;o=h.opacity;B=h.wireframe;A=h.wireframe_linewidth;Q=h.map;K=h.env_map;m=h.combine==THREE.MixOperation;
+i=h.reflectivity;T=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;R=h.refraction_ratio;c.uniform4f(E.uniforms.mColor,l.r*o,l.g*o,l.b*o,o);c.uniform1i(E.uniforms.mixEnvMap,m);c.uniform1f(E.uniforms.mReflectivity,i);c.uniform1i(E.uniforms.useRefract,T);c.uniform1f(E.uniforms.mRefractionRatio,R)}if(h instanceof THREE.MeshNormalMaterial){o=h.opacity;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1i(E.uniforms.material,4)}else if(h instanceof THREE.MeshDepthMaterial){o=h.opacity;B=h.wireframe;
+A=h.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1f(E.uniforms.m2Near,h.__2near);c.uniform1f(E.uniforms.mFarPlusNear,h.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,h.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(h instanceof THREE.MeshPhongMaterial){l=h.ambient;i=h.specular;h=h.shininess;c.uniform4f(E.uniforms.mAmbient,l.r,l.g,l.b,o);c.uniform4f(E.uniforms.mSpecular,i.r,i.g,i.b,o);c.uniform1f(E.uniforms.mShininess,h);c.uniform1i(E.uniforms.material,2)}else if(h instanceof
+THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(h instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(h instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);K=h.env_map}if(Q){e(Q,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(K){d(K,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);o=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,
 z.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,z.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);if(o.uv>=0)if(z.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.enableVertexAttribArray(o.uv);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(o.uv);if(B){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLLineBuffer);c.drawElements(c.LINES,z.__webGLLineCount,c.UNSIGNED_SHORT,
 0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,z.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,m,h,z,l,o){var B,A,Q,K,R;Q=0;for(K=h.material.length;Q<K;Q++){B=h.material[Q];if(B instanceof THREE.MeshFaceMaterial){B=0;for(A=z.material.length;B<A;B++)if((R=z.material[B])&&R.blending==l&&R.opacity<1==o){this.setBlending(R.blending);this.renderBuffer(i,m,R,z)}}else if((R=B)&&R.blending==l&&R.opacity<1==o){this.setBlending(R.blending);this.renderBuffer(i,
 m,R,z)}}};this.render=function(i,m){var h,z,l,o,B=i.lights;this.initWebGLObjects(i);this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();h=0;for(z=i.__webGLObjects.length;h<z;h++){l=i.__webGLObjects[h];o=l.object;l=l.buffer;if(o.visible){this.setupMatrices(o,m);this.renderPass(m,B,o,l,THREE.NormalBlending,false)}}h=0;for(z=i.__webGLObjects.length;h<z;h++){l=i.__webGLObjects[h];o=l.object;l=l.buffer;if(o.visible){this.setupMatrices(o,m);this.renderPass(m,B,o,l,THREE.AdditiveBlending,false);
 this.renderPass(m,B,o,l,THREE.SubtractiveBlending,false);this.renderPass(m,B,o,l,THREE.AdditiveBlending,true);this.renderPass(m,B,o,l,THREE.SubtractiveBlending,true);this.renderPass(m,B,o,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var m,h,z,l,o,B;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}m=0;for(h=i.objects.length;m<h;m++){z=i.objects[m];if(i.__webGLObjectsMap[z.id]==undefined)i.__webGLObjectsMap[z.id]={};B=i.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh)for(o in z.geometry.geometryChunks){l=
 z.geometry.geometryChunks[o];l.__webGLVertexBuffer||this.createBuffers(z,o);if(B[o]==undefined){l={buffer:l,object:z};i.__webGLObjects.push(l);B[o]=1}}}};this.removeObject=function(i,m){var h,z;for(h=i.__webGLObjects.length-1;h>=0;h--){z=i.__webGLObjects[h].object;m==z&&i.__webGLObjects.splice(h,1)}};this.setupMatrices=function(i,m){i.autoUpdateMatrix&&i.updateMatrix();r.multiply(m.matrix,i.matrix);u.set(m.matrix.flatten());w.set(r.flatten());I.set(m.projectionMatrix.flatten());t=THREE.Matrix4.makeInvert3x3(r).transpose();
-E.set(t.m);y.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,u);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,I);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,E);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,y)};this.loadCamera=function(i,m){c.uniform3f(i.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
+F.set(t.m);y.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,u);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,I);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,F);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,y)};this.loadCamera=function(i,m){c.uniform3f(i.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(i){switch(i){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(i,m){if(i){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="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};
-var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,j=a.vertices,k=g.vertices,f=a.faces,p=g.faces,c=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var v=0,C=k.length;v<C;v++){var r=new THREE.Vertex(k[v].position.clone());d&&b.matrix.multiplyVector3(r.position);j.push(r)}v=0;for(C=p.length;v<C;v++){k=p[v];var t,u=k.vertexNormals;if(k instanceof THREE.Face3)t=new THREE.Face3(k.a+e,k.b+e,k.c+e);else if(k instanceof THREE.Face4)t=new THREE.Face4(k.a+e,k.b+
-e,k.c+e,k.d+e);t.centroid.copy(k.centroid);t.normal.copy(k.normal);d=0;for(j=u.length;d<j;d++){r=u[d];t.vertexNormals.push(r.clone())}t.material=k.material.slice();f.push(t)}v=0;for(C=g.length;v<C;v++){e=g[v];f=[];d=0;for(j=e.length;d<j;d++)f.push(new THREE.UV(e[d].u,e[d].v));c.push(f)}}},ImageUtils={loadTexture:function(a,b){var d=new THREE.Texture(null,b),e=new Image;e.onload=function(){d.image=this;d.loaded=true};e.src=a;return d},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<
-d;++b){e[b]=new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=1};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,g,j,k,f,p,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;b.position.z=j;b.rotation.x=k;b.rotation.y=f;b.rotation.z=p;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,
+var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,j=a.vertices,k=g.vertices,f=a.faces,p=g.faces,c=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var v=0,D=k.length;v<D;v++){var r=new THREE.Vertex(k[v].position.clone());d&&b.matrix.multiplyVector3(r.position);j.push(r)}v=0;for(D=p.length;v<D;v++){k=p[v];var t,u=k.vertexNormals;if(k instanceof THREE.Face3)t=new THREE.Face3(k.a+e,k.b+e,k.c+e);else if(k instanceof THREE.Face4)t=new THREE.Face4(k.a+e,k.b+
+e,k.c+e,k.d+e);t.centroid.copy(k.centroid);t.normal.copy(k.normal);d=0;for(j=u.length;d<j;d++){r=u[d];t.vertexNormals.push(r.clone())}t.material=k.material.slice();f.push(t)}v=0;for(D=g.length;v<D;v++){e=g[v];f=[];d=0;for(j=e.length;d<j;d++)f.push(new THREE.UV(e[d].u,e[d].v));c.push(f)}}},ImageUtils={loadTexture:function(a,b){var d=new Image;d.onload=function(){this.loaded=true};d.src=a;return new THREE.Texture(d,b)},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=
+new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=true};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,g,j,k,f,p,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=g;b.position.z=j;b.rotation.x=k;b.rotation.y=f;b.rotation.z=p;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,
 b,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(mesh);
 return mesh},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,b);var g=Math.PI/2,j=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,g,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,
 b,1,0,-e,0,-g,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"}}},
-Cube=function(a,b,d,e,g,j,k){function f(t,u,w,I,E,y,n,i){var m=e||1,h=g||1,z=m+1,l=h+1;E=E/m;y=y/h;var o=p.vertices.length,B;if(t=="x"&&u=="y"||t=="y"&&u=="x")B="z";else if(t=="x"&&u=="z"||t=="z"&&u=="x")B="y";else if(t=="z"&&u=="y"||t=="y"&&u=="z")B="x";for(iy=0;iy<l;iy++)for(ix=0;ix<z;ix++){var A=new THREE.Vector3;A[t]=(ix*E-c)*w;A[u]=(iy*y-v)*I;A[B]=n;p.vertices.push(new THREE.Vertex(A))}for(iy=0;iy<h;iy++)for(ix=0;ix<m;ix++){p.faces.push(new THREE.Face4(ix+z*iy+o,ix+z*(iy+1)+o,ix+1+z*(iy+1)+o,
-ix+1+z*iy+o,null,i));p.uvs.push([new THREE.UV(ix/m,iy/h),new THREE.UV(ix/m,(iy+1)/h),new THREE.UV((ix+1)/m,(iy+1)/h),new THREE.UV((ix+1)/m,iy/h)])}}THREE.Geometry.call(this);var p=this,c=a/2,v=b/2,C=d/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var r=0;r<6;r++)this.materials.push([j])}else this.materials=[];f("z","y",1*k,-1,d,b,-c,this.materials[0]);f("z","y",-1*k,-1,d,b,c,this.materials[1]);f("x","z",1*k,1,a,d,v,this.materials[2]);f("x","z",1*k,-1,
-a,d,-v,this.materials[3]);f("x","y",1*k,-1,a,b,C,this.materials[4]);f("x","y",-1*k,-1,a,b,-C,this.materials[5]);(function(){for(var t=[],u=[],w=0,I=p.vertices.length;w<I;w++){for(var E=p.vertices[w],y=false,n=0,i=t.length;n<i;n++){var m=t[n];if(E.position.x==m.position.x&&E.position.y==m.position.y&&E.position.z==m.position.z){u[w]=n;y=true;break}}if(!y){u[w]=t.length;t.push(new THREE.Vertex(E.position.clone()))}}w=0;for(I=p.faces.length;w<I;w++){E=p.faces[w];E.a=u[E.a];E.b=u[E.b];E.c=u[E.c];E.d=
-u[E.d]}p.vertices=t})();this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
+Cube=function(a,b,d,e,g,j,k){function f(t,u,w,I,F,y,n,i){var m=e||1,h=g||1,z=m+1,l=h+1;F=F/m;y=y/h;var o=p.vertices.length,B;if(t=="x"&&u=="y"||t=="y"&&u=="x")B="z";else if(t=="x"&&u=="z"||t=="z"&&u=="x")B="y";else if(t=="z"&&u=="y"||t=="y"&&u=="z")B="x";for(iy=0;iy<l;iy++)for(ix=0;ix<z;ix++){var A=new THREE.Vector3;A[t]=(ix*F-c)*w;A[u]=(iy*y-v)*I;A[B]=n;p.vertices.push(new THREE.Vertex(A))}for(iy=0;iy<h;iy++)for(ix=0;ix<m;ix++){p.faces.push(new THREE.Face4(ix+z*iy+o,ix+z*(iy+1)+o,ix+1+z*(iy+1)+o,
+ix+1+z*iy+o,null,i));p.uvs.push([new THREE.UV(ix/m,iy/h),new THREE.UV(ix/m,(iy+1)/h),new THREE.UV((ix+1)/m,(iy+1)/h),new THREE.UV((ix+1)/m,iy/h)])}}THREE.Geometry.call(this);var p=this,c=a/2,v=b/2,D=d/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var r=0;r<6;r++)this.materials.push([j])}else this.materials=[];f("z","y",1*k,-1,d,b,-c,this.materials[0]);f("z","y",-1*k,-1,d,b,c,this.materials[1]);f("x","z",1*k,1,a,d,v,this.materials[2]);f("x","z",1*k,-1,
+a,d,-v,this.materials[3]);f("x","y",1*k,-1,a,b,D,this.materials[4]);f("x","y",-1*k,-1,a,b,-D,this.materials[5]);(function(){for(var t=[],u=[],w=0,I=p.vertices.length;w<I;w++){for(var F=p.vertices[w],y=false,n=0,i=t.length;n<i;n++){var m=t[n];if(F.position.x==m.position.x&&F.position.y==m.position.y&&F.position.z==m.position.z){u[w]=n;y=true;break}}if(!y){u[w]=t.length;t.push(new THREE.Vertex(F.position.clone()))}}w=0;for(I=p.faces.length;w<I;w++){F=p.faces[w];F.a=u[F.a];F.b=u[F.b];F.c=u[F.c];F.d=
+u[F.d]}p.vertices=t})();this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(a,b,d,e,g){function j(p,c,v){k.vertices.push(new THREE.Vertex(new THREE.Vector3(p,c,v)))}THREE.Geometry.call(this);var k=this,f;for(f=0;f<a;f++)j(Math.sin(6.283*f/a)*b,Math.cos(6.283*f/a)*b,0);for(f=0;f<a;f++)j(Math.sin(6.283*f/a)*d,Math.cos(6.283*f/a)*d,e);for(f=0;f<a;f++)k.faces.push(new THREE.Face4(f,f+a,a+(f+1)%a,(f+1)%a));if(d!=0){j(0,0,-g);for(f=a;f<a+a/2;f++)k.faces.push(new THREE.Face4(2*a,(2*f-2*a)%a,(2*f-2*a+1)%a,(2*f-2*a+2)%a))}if(b!=0){j(0,0,e+g);for(f=a+a/2;f<2*
 a;f++)k.faces.push(new THREE.Face4((2*f-2*a+2)%a+a,(2*f-2*a+1)%a+a,(2*f-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 var Plane=function(a,b,d,e){THREE.Geometry.call(this);var g,j=a/2,k=b/2;d=d||1;e=e||1;var f=d+1,p=e+1;a=a/d;var c=b/e;for(g=0;g<p;g++)for(b=0;b<f;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-j,-(g*c-k),0)));for(g=0;g<e;g++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+f*g,b+f*(g+1),b+1+f*(g+1),b+1+f*g));this.uvs.push([new THREE.UV(b/d,g/e),new THREE.UV(b/d,(g+1)/e),new THREE.UV((b+1)/d,(g+1)/e),new THREE.UV((b+1)/d,g/e)])}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var k=a*Math.cos(e*Math.PI),f=a*Math.sin(e*Math.PI),p=[],c=0;for(e=0;e<g;e++){var v=2*e/g,C=f*Math.sin(v*Math.PI);v=f*Math.cos(v*Math.PI);(d==0||d==j)&&e>0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,C)))-1);p.push(c)}b.push(p)}var r,t,u;a=b.length;for(d=0;d<a;d++){g=b[d].length;if(d>0)for(e=0;e<g;e++){p=e==g-1;j=b[d][p?0:e+1];k=b[d][p?g-1:e];f=b[d-1][p?
-g-1:e];p=b[d-1][p?0:e+1];C=d/(a-1);r=(d-1)/(a-1);t=(e+1)/g;v=e/g;c=new THREE.UV(1-t,C);C=new THREE.UV(1-v,C);v=new THREE.UV(1-v,r);var w=new THREE.UV(1-t,r);if(d<b.length-1){r=this.vertices[j].position.clone();t=this.vertices[k].position.clone();u=this.vertices[f].position.clone();r.normalize();t.normalize();u.normalize();this.faces.push(new THREE.Face3(j,k,f,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([c,C,v])}if(d>1){r=this.vertices[j].position.clone();
+var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var k=a*Math.cos(e*Math.PI),f=a*Math.sin(e*Math.PI),p=[],c=0;for(e=0;e<g;e++){var v=2*e/g,D=f*Math.sin(v*Math.PI);v=f*Math.cos(v*Math.PI);(d==0||d==j)&&e>0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,D)))-1);p.push(c)}b.push(p)}var r,t,u;a=b.length;for(d=0;d<a;d++){g=b[d].length;if(d>0)for(e=0;e<g;e++){p=e==g-1;j=b[d][p?0:e+1];k=b[d][p?g-1:e];f=b[d-1][p?
+g-1:e];p=b[d-1][p?0:e+1];D=d/(a-1);r=(d-1)/(a-1);t=(e+1)/g;v=e/g;c=new THREE.UV(1-t,D);D=new THREE.UV(1-v,D);v=new THREE.UV(1-v,r);var w=new THREE.UV(1-t,r);if(d<b.length-1){r=this.vertices[j].position.clone();t=this.vertices[k].position.clone();u=this.vertices[f].position.clone();r.normalize();t.normalize();u.normalize();this.faces.push(new THREE.Face3(j,k,f,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([c,D,v])}if(d>1){r=this.vertices[j].position.clone();
 t=this.vertices[f].position.clone();u=this.vertices[p].position.clone();r.normalize();t.normalize();u.normalize();this.faces.push(new THREE.Face3(j,f,p,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([c,v,w])}}}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null};
 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(g){THREE.Loader.prototype.createModel(g.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,
 j.data.materials,b,d,g)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,g){var j=new XMLHttpRequest,k=e+"/"+a,f=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(g){if(f==0)f=j.getResponseHeader("Content-Length");g({total:f,loaded:j.responseText.length})}}else if(j.readyState==
-2)f=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 g=function(j){function k(q,s){var x=v(q,s),G=v(q,s+1),U=v(q,s+2),ca=v(q,s+3),ha=(ca<<1&255|U>>7)-127;x=(U&127)<<16|G<<8|x;if(x==0&&ha==-127)return 0;return(1-2*(ca>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ha)}function f(q,s){var x=v(q,s),G=v(q,s+1),U=v(q,s+2);return(v(q,s+3)<<24)+(U<<
-16)+(G<<8)+x}function p(q,s){var x=v(q,s);return(v(q,s+1)<<8)+x}function c(q,s){var x=v(q,s);return x>127?x-256:x}function v(q,s){return q.charCodeAt(s)&255}function C(q){var s,x,G;s=f(a,q);x=f(a,q+h);G=f(a,q+z);q=p(a,q+l);THREE.Loader.prototype.f3(E,s,x,G,q)}function r(q){var s,x,G,U,ca,ha;s=f(a,q);x=f(a,q+h);G=f(a,q+z);U=p(a,q+l);ca=f(a,q+o);ha=f(a,q+B);q=f(a,q+A);THREE.Loader.prototype.f3n(E,i,s,x,G,U,ca,ha,q)}function t(q){var s,x,G,U;s=f(a,q);x=f(a,q+Q);G=f(a,q+K);U=f(a,q+R);q=p(a,q+T);THREE.Loader.prototype.f4(E,
-s,x,G,U,q)}function u(q){var s,x,G,U,ca,ha,$,la;s=f(a,q);x=f(a,q+Q);G=f(a,q+K);U=f(a,q+R);ca=p(a,q+T);ha=f(a,q+D);$=f(a,q+V);la=f(a,q+J);q=f(a,q+L);THREE.Loader.prototype.f4n(E,i,s,x,G,U,ca,ha,$,la,q)}function w(q){var s,x;s=f(a,q);x=f(a,q+N);q=f(a,q+Y);THREE.Loader.prototype.uv3(E,m[s*2],m[s*2+1],m[x*2],m[x*2+1],m[q*2],m[q*2+1])}function I(q){var s,x,G;s=f(a,q);x=f(a,q+P);G=f(a,q+M);q=f(a,q+W);THREE.Loader.prototype.uv4(E,m[s*2],m[s*2+1],m[x*2],m[x*2+1],m[G*2],m[G*2+1],m[q*2],m[q*2+1])}var E=this,
-y=0,n,i=[],m=[],h,z,l,o,B,A,Q,K,R,T,D,V,J,L,N,Y,P,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,e,j);n={signature:a.substr(y,8),header_bytes:v(a,y+8),vertex_coordinate_bytes:v(a,y+9),normal_coordinate_bytes:v(a,y+10),uv_coordinate_bytes:v(a,y+11),vertex_index_bytes:v(a,y+12),normal_index_bytes:v(a,y+13),uv_index_bytes:v(a,y+14),material_index_bytes:v(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a,
+2)f=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 g=function(j){function k(q,s){var x=v(q,s),H=v(q,s+1),U=v(q,s+2),ba=v(q,s+3),ga=(ba<<1&255|U>>7)-127;x=(U&127)<<16|H<<8|x;if(x==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ga)}function f(q,s){var x=v(q,s),H=v(q,s+1),U=v(q,s+2);return(v(q,s+3)<<24)+(U<<
+16)+(H<<8)+x}function p(q,s){var x=v(q,s);return(v(q,s+1)<<8)+x}function c(q,s){var x=v(q,s);return x>127?x-256:x}function v(q,s){return q.charCodeAt(s)&255}function D(q){var s,x,H;s=f(a,q);x=f(a,q+h);H=f(a,q+z);q=p(a,q+l);THREE.Loader.prototype.f3(F,s,x,H,q)}function r(q){var s,x,H,U,ba,ga;s=f(a,q);x=f(a,q+h);H=f(a,q+z);U=p(a,q+l);ba=f(a,q+o);ga=f(a,q+B);q=f(a,q+A);THREE.Loader.prototype.f3n(F,i,s,x,H,U,ba,ga,q)}function t(q){var s,x,H,U;s=f(a,q);x=f(a,q+Q);H=f(a,q+K);U=f(a,q+R);q=p(a,q+T);THREE.Loader.prototype.f4(F,
+s,x,H,U,q)}function u(q){var s,x,H,U,ba,ga,$,ka;s=f(a,q);x=f(a,q+Q);H=f(a,q+K);U=f(a,q+R);ba=p(a,q+T);ga=f(a,q+E);$=f(a,q+V);ka=f(a,q+J);q=f(a,q+L);THREE.Loader.prototype.f4n(F,i,s,x,H,U,ba,ga,$,ka,q)}function w(q){var s,x;s=f(a,q);x=f(a,q+N);q=f(a,q+Y);THREE.Loader.prototype.uv3(F,m[s*2],m[s*2+1],m[x*2],m[x*2+1],m[q*2],m[q*2+1])}function I(q){var s,x,H;s=f(a,q);x=f(a,q+P);H=f(a,q+M);q=f(a,q+W);THREE.Loader.prototype.uv4(F,m[s*2],m[s*2+1],m[x*2],m[x*2+1],m[H*2],m[H*2+1],m[q*2],m[q*2+1])}var F=this,
+y=0,n,i=[],m=[],h,z,l,o,B,A,Q,K,R,T,E,V,J,L,N,Y,P,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,e,j);n={signature:a.substr(y,8),header_bytes:v(a,y+8),vertex_coordinate_bytes:v(a,y+9),normal_coordinate_bytes:v(a,y+10),uv_coordinate_bytes:v(a,y+11),vertex_index_bytes:v(a,y+12),normal_index_bytes:v(a,y+13),uv_index_bytes:v(a,y+14),material_index_bytes:v(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a,
 y+16+20),ntri_smooth_uv:f(a,y+16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=n.header_bytes;h=n.vertex_index_bytes;z=n.vertex_index_bytes*2;l=n.vertex_index_bytes*3;o=n.vertex_index_bytes*3+n.material_index_bytes;B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;Q=n.vertex_index_bytes;K=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;T=n.vertex_index_bytes*
-4;D=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;J=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;N=n.uv_index_bytes;Y=n.uv_index_bytes*2;P=n.uv_index_bytes;M=n.uv_index_bytes*2;W=n.uv_index_bytes*3;y+=function(q){var s,x,G,U=n.vertex_coordinate_bytes*3,ca=q+n.nvertices*U;for(q=q;q<ca;q+=U){s=k(a,q);x=k(a,q+n.vertex_coordinate_bytes);G=
-k(a,q+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(E,s,x,G)}return n.nvertices*U}(y);y+=function(q){var s,x,G,U=n.normal_coordinate_bytes*3,ca=q+n.nnormals*U;for(q=q;q<ca;q+=U){s=c(a,q);x=c(a,q+n.normal_coordinate_bytes);G=c(a,q+n.normal_coordinate_bytes*2);i.push(s/127,x/127,G/127)}return n.nnormals*U}(y);y+=function(q){var s,x,G=n.uv_coordinate_bytes*2,U=q+n.nuvs*G;for(q=q;q<U;q+=G){s=k(a,q);x=k(a,q+n.uv_coordinate_bytes);m.push(s,x)}return n.nuvs*G}(y);y+=function(q){var s,x=n.vertex_index_bytes*
-3+n.material_index_bytes,G=q+n.ntri_flat*x;for(s=q;s<G;s+=x)C(s);return G-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=q+n.ntri_smooth*x;for(s=q;s<G;s+=x)r(s);return G-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes,G=x+n.uv_index_bytes*3,U=q+n.ntri_flat_uv*G;for(s=q;s<U;s+=G){C(s);w(s+x)}return U-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,G=x+n.uv_index_bytes*3,
-U=q+n.ntri_smooth_uv*G;for(s=q;s<U;s+=G){r(s);w(s+x)}return U-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=q+n.nquad_flat*x;for(s=q;s<G;s+=x)t(s);return G-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=q+n.nquad_smooth*x;for(s=q;s<G;s+=x)u(s);return G-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,G=x+n.uv_index_bytes*4,U=q+n.nquad_flat_uv*G;for(s=q;s<U;s+=G){t(s);I(s+x)}return U-q}(y);
-y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,G=x+n.uv_index_bytes*4,U=q+n.nquad_smooth_uv*G;for(s=q;s<U;s+=G){u(s);I(s+x)}return U-q}(y);this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,g);(function(){var k,f,p,c,v;k=0;for(f=
+4;E=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;J=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;N=n.uv_index_bytes;Y=n.uv_index_bytes*2;P=n.uv_index_bytes;M=n.uv_index_bytes*2;W=n.uv_index_bytes*3;y+=function(q){var s,x,H,U=n.vertex_coordinate_bytes*3,ba=q+n.nvertices*U;for(q=q;q<ba;q+=U){s=k(a,q);x=k(a,q+n.vertex_coordinate_bytes);H=
+k(a,q+n.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(F,s,x,H)}return n.nvertices*U}(y);y+=function(q){var s,x,H,U=n.normal_coordinate_bytes*3,ba=q+n.nnormals*U;for(q=q;q<ba;q+=U){s=c(a,q);x=c(a,q+n.normal_coordinate_bytes);H=c(a,q+n.normal_coordinate_bytes*2);i.push(s/127,x/127,H/127)}return n.nnormals*U}(y);y+=function(q){var s,x,H=n.uv_coordinate_bytes*2,U=q+n.nuvs*H;for(q=q;q<U;q+=H){s=k(a,q);x=k(a,q+n.uv_coordinate_bytes);m.push(s,x)}return n.nuvs*H}(y);y+=function(q){var s,x=n.vertex_index_bytes*
+3+n.material_index_bytes,H=q+n.ntri_flat*x;for(s=q;s<H;s+=x)D(s);return H-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,H=q+n.ntri_smooth*x;for(s=q;s<H;s+=x)r(s);return H-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes,H=x+n.uv_index_bytes*3,U=q+n.ntri_flat_uv*H;for(s=q;s<U;s+=H){D(s);w(s+x)}return U-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,H=x+n.uv_index_bytes*3,
+U=q+n.ntri_smooth_uv*H;for(s=q;s<U;s+=H){r(s);w(s+x)}return U-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,H=q+n.nquad_flat*x;for(s=q;s<H;s+=x)t(s);return H-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,H=q+n.nquad_smooth*x;for(s=q;s<H;s+=x)u(s);return H-q}(y);y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes,H=x+n.uv_index_bytes*4,U=q+n.nquad_flat_uv*H;for(s=q;s<U;s+=H){t(s);I(s+x)}return U-q}(y);
+y+=function(q){var s,x=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,H=x+n.uv_index_bytes*4,U=q+n.nquad_smooth_uv*H;for(s=q;s<U;s+=H){u(s);I(s+x)}return U-q}(y);this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g(d))},createModel:function(a,b,d){var e=function(g){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,g);(function(){var k,f,p,c,v;k=0;for(f=
 a.vertices.length;k<f;k+=3){p=a.vertices[k];c=a.vertices[k+1];v=a.vertices[k+2];THREE.Loader.prototype.v(j,p,c,v)}})();(function(){function k(u,w){THREE.Loader.prototype.f3(j,u[w],u[w+1],u[w+2],u[w+3])}function f(u,w){THREE.Loader.prototype.f3n(j,a.normals,u[w],u[w+1],u[w+2],u[w+3],u[w+4],u[w+5],u[w+6])}function p(u,w){THREE.Loader.prototype.f4(j,u[w],u[w+1],u[w+2],u[w+3],u[w+4])}function c(u,w){THREE.Loader.prototype.f4n(j,a.normals,u[w],u[w+1],u[w+2],u[w+3],u[w+4],u[w+5],u[w+6],u[w+7],u[w+8])}function v(u,
-w){var I,E,y;I=u[w];E=u[w+1];y=u[w+2];THREE.Loader.prototype.uv3(j,a.uvs[I*2],a.uvs[I*2+1],a.uvs[E*2],a.uvs[E*2+1],a.uvs[y*2],a.uvs[y*2+1])}function C(u,w){var I,E,y,n;I=u[w];E=u[w+1];y=u[w+2];n=u[w+3];THREE.Loader.prototype.uv4(j,a.uvs[I*2],a.uvs[I*2+1],a.uvs[E*2],a.uvs[E*2+1],a.uvs[y*2],a.uvs[y*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,t;r=0;for(t=a.triangles.length;r<t;r+=4)k(a.triangles,r);r=0;for(t=a.triangles_uv.length;r<t;r+=7){k(a.triangles_uv,r);v(a.triangles_uv,r+4)}r=0;for(t=a.triangles_n.length;r<
-t;r+=7)f(a.triangles_n,r);r=0;for(t=a.triangles_n_uv.length;r<t;r+=10){f(a.triangles_n_uv,r);v(a.triangles_n_uv,r+7)}r=0;for(t=a.quads.length;r<t;r+=5)p(a.quads,r);r=0;for(t=a.quads_uv.length;r<t;r+=9){p(a.quads_uv,r);C(a.quads_uv,r+5)}r=0;for(t=a.quads_n.length;r<t;r+=9)c(a.quads_n,r);r=0;for(t=a.quads_n_uv.length;r<t;r+=13){c(a.quads_n_uv,r);C(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};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,d,e)))},f3:function(a,b,d,e,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,j){a.faces.push(new THREE.Face4(b,d,e,g,null,a.materials[j]))},f3n:function(a,b,d,e,g,j,k,f,p){j=a.materials[j];var c=b[f*3],v=b[f*3+1];f=b[f*3+2];var C=b[p*3],r=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,v,f),new THREE.Vector3(C,
-r,p)],j))},f4n:function(a,b,d,e,g,j,k,f,p,c,v){k=a.materials[k];var C=b[p*3],r=b[p*3+1];p=b[p*3+2];var t=b[c*3],u=b[c*3+1];c=b[c*3+2];var w=b[v*3],I=b[v*3+1];v=b[v*3+2];a.faces.push(new THREE.Face4(d,e,g,j,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(C,r,p),new THREE.Vector3(t,u,c),new THREE.Vector3(w,I,v)],k))},uv3:function(a,b,d,e,g,j,k){var f=[];f.push(new THREE.UV(b,d));f.push(new THREE.UV(e,g));f.push(new THREE.UV(j,k));a.uvs.push(f)},uv4:function(a,b,d,e,g,j,k,f,p){var c=[];
+w){var I,F,y;I=u[w];F=u[w+1];y=u[w+2];THREE.Loader.prototype.uv3(j,a.uvs[I*2],a.uvs[I*2+1],a.uvs[F*2],a.uvs[F*2+1],a.uvs[y*2],a.uvs[y*2+1])}function D(u,w){var I,F,y,n;I=u[w];F=u[w+1];y=u[w+2];n=u[w+3];THREE.Loader.prototype.uv4(j,a.uvs[I*2],a.uvs[I*2+1],a.uvs[F*2],a.uvs[F*2+1],a.uvs[y*2],a.uvs[y*2+1],a.uvs[n*2],a.uvs[n*2+1])}var r,t;r=0;for(t=a.triangles.length;r<t;r+=4)k(a.triangles,r);r=0;for(t=a.triangles_uv.length;r<t;r+=7){k(a.triangles_uv,r);v(a.triangles_uv,r+4)}r=0;for(t=a.triangles_n.length;r<
+t;r+=7)f(a.triangles_n,r);r=0;for(t=a.triangles_n_uv.length;r<t;r+=10){f(a.triangles_n_uv,r);v(a.triangles_n_uv,r+7)}r=0;for(t=a.quads.length;r<t;r+=5)p(a.quads,r);r=0;for(t=a.quads_uv.length;r<t;r+=9){p(a.quads_uv,r);D(a.quads_uv,r+5)}r=0;for(t=a.quads_n.length;r<t;r+=9)c(a.quads_n,r);r=0;for(t=a.quads_n_uv.length;r<t;r+=13){c(a.quads_n_uv,r);D(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};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,d,e)))},f3:function(a,b,d,e,g){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[g]))},f4:function(a,b,d,e,g,j){a.faces.push(new THREE.Face4(b,d,e,g,null,a.materials[j]))},f3n:function(a,b,d,e,g,j,k,f,p){j=a.materials[j];var c=b[f*3],v=b[f*3+1];f=b[f*3+2];var D=b[p*3],r=b[p*3+1];p=b[p*3+2];a.faces.push(new THREE.Face3(d,e,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,v,f),new THREE.Vector3(D,
+r,p)],j))},f4n:function(a,b,d,e,g,j,k,f,p,c,v){k=a.materials[k];var D=b[p*3],r=b[p*3+1];p=b[p*3+2];var t=b[c*3],u=b[c*3+1];c=b[c*3+2];var w=b[v*3],I=b[v*3+1];v=b[v*3+2];a.faces.push(new THREE.Face4(d,e,g,j,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(D,r,p),new THREE.Vector3(t,u,c),new THREE.Vector3(w,I,v)],k))},uv3:function(a,b,d,e,g,j,k){var f=[];f.push(new THREE.UV(b,d));f.push(new THREE.UV(e,g));f.push(new THREE.UV(j,k));a.uvs.push(f)},uv4:function(a,b,d,e,g,j,k,f,p){var c=[];
 c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,g));c.push(new THREE.UV(j,k));c.push(new THREE.UV(f,p));a.uvs.push(c)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],d)]},createMaterial:function(a,b){function d(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}var e,g;if(a.map_diffuse&&b){g=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!d(this.width)||
 !d(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=j;e.map.image.height=k;e.map.image.getContext("2d").drawImage(this,0,0,j,k)}else e.map.image=this;e.map.image.loaded=1};g.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):
 new THREE.MeshLambertMaterial({color:15658734});return e}};

+ 12 - 14
examples/geometry_panorama.html

@@ -40,7 +40,7 @@
 			var camera, scene, renderer;
 
 			var fov = 75,
-			texture_placeholder, wireframe,
+			texture_placeholder,
 			isUserInteracting = false,
 			onMouseDownMouseX = 0, onMouseDownMouseY = 0,
 			lon = 90, onMouseDownLon = 0,
@@ -63,19 +63,20 @@
 				texture_placeholder.width = 128;
 				texture_placeholder.height = 128;
 
-				wireframe = new THREE.MeshBasicMaterial( { color: 0xffffff, opacity: 0, wireframe: true } );
-
 				var context = texture_placeholder.getContext( '2d' );
 				context.fillStyle = 'rgb( 200, 200, 200 )';
 				context.fillRect( 0, 0, texture_placeholder.width, texture_placeholder.height );
 
-				var materials = [];
-				materials.push( [ loadTexture( 'textures/cube/skybox/px.jpg' ), wireframe ] ); // right
-				materials.push( [ loadTexture( 'textures/cube/skybox/nx.jpg' ), wireframe ] ); // left
-				materials.push( [ loadTexture( 'textures/cube/skybox/py.jpg' ), wireframe ] ); // top
-				materials.push( [ loadTexture( 'textures/cube/skybox/ny.jpg' ), wireframe ] ); // bottom
-				materials.push( [ loadTexture( 'textures/cube/skybox/pz.jpg' ), wireframe ] ); // back
-				materials.push( [ loadTexture( 'textures/cube/skybox/nz.jpg' ), wireframe ] ); // front
+				var materials = [
+
+					loadTexture( 'textures/cube/skybox/px.jpg' ), // right
+					loadTexture( 'textures/cube/skybox/nx.jpg' ), // left
+					loadTexture( 'textures/cube/skybox/py.jpg' ), // top
+					loadTexture( 'textures/cube/skybox/ny.jpg' ), // bottom
+					loadTexture( 'textures/cube/skybox/pz.jpg' ), // back
+					loadTexture( 'textures/cube/skybox/nz.jpg' ) // front
+
+				];
 
 				mesh = new THREE.Mesh( new Cube( 300, 300, 300, 7, 7, materials, true ), new THREE.MeshFaceMaterial() );
 				mesh.overdraw = true;
@@ -104,8 +105,8 @@
 
 				image.onload = function () {
 
+					this.loaded = true;
 					material.map.image = this;
-					material.map.loaded = true;
 					render();
 
 				};
@@ -121,8 +122,6 @@
 
 				isUserInteracting = true;
 
-				wireframe.opacity = 0.2;
-
 				onPointerDownPointerX = event.clientX;
 				onPointerDownPointerY = event.clientY;
 
@@ -145,7 +144,6 @@
 			function onDocumentMouseUp( event ) {
 
 				isUserInteracting = false;
-				wireframe.opacity = 0;
 				render();
 
 			}

+ 12 - 14
examples/geometry_panorama_fisheye.html

@@ -39,7 +39,7 @@
 			var camera, scene, renderer;
 
 			var fov = 75,
-			texture_placeholder, wireframe,
+			texture_placeholder,
 			isUserInteracting = false,
 			onMouseDownMouseX = 0, onMouseDownMouseY = 0,
 			lon = 90, onMouseDownLon = 0,
@@ -62,19 +62,20 @@
 				texture_placeholder.width = 128;
 				texture_placeholder.height = 128;
 
-				wireframe = new THREE.MeshBasicMaterial( { color: 0xffffff, opacity: 0, wireframe: true } );
-
 				var context = texture_placeholder.getContext( '2d' );
 				context.fillStyle = 'rgb( 200, 200, 200 )';
 				context.fillRect( 0, 0, texture_placeholder.width, texture_placeholder.height );
 
-				var materials = [];
-				materials.push( [ loadTexture( 'textures/cube/skybox/px.jpg' ), wireframe ] ); // right
-				materials.push( [ loadTexture( 'textures/cube/skybox/nx.jpg' ), wireframe ] ); // left
-				materials.push( [ loadTexture( 'textures/cube/skybox/py.jpg' ), wireframe ] ); // top
-				materials.push( [ loadTexture( 'textures/cube/skybox/ny.jpg' ), wireframe ] ); // bottom
-				materials.push( [ loadTexture( 'textures/cube/skybox/pz.jpg' ), wireframe ] ); // back
-				materials.push( [ loadTexture( 'textures/cube/skybox/nz.jpg' ), wireframe ] ); // front
+				var materials = [
+
+					loadTexture( 'textures/cube/skybox/px.jpg' ), // right
+					loadTexture( 'textures/cube/skybox/nx.jpg' ), // left
+					loadTexture( 'textures/cube/skybox/py.jpg' ), // top
+					loadTexture( 'textures/cube/skybox/ny.jpg' ), // bottom
+					loadTexture( 'textures/cube/skybox/pz.jpg' ), // back
+					loadTexture( 'textures/cube/skybox/nz.jpg' ) // front
+
+				];
 
 				mesh = new THREE.Mesh( new Cube( 300, 300, 300, 7, 7, materials, true ), new THREE.MeshFaceMaterial() );
 				mesh.overdraw = true;
@@ -113,8 +114,8 @@
 
 				image.onload = function () {
 
+					this.loaded = true;
 					material.map.image = this;
-					material.map.loaded = true;
 					render();
 
 				};
@@ -130,8 +131,6 @@
 
 				isUserInteracting = true;
 
-				wireframe.opacity = 0.2;
-
 				onPointerDownPointerX = event.clientX;
 				onPointerDownPointerY = event.clientY;
 
@@ -154,7 +153,6 @@
 			function onDocumentMouseUp( event ) {
 
 				isUserInteracting = false;
-				wireframe.opacity = 0;
 				render();
 
 			}

+ 1 - 1
examples/geometry_terrain.html

@@ -70,7 +70,7 @@
 				var heightMap = height( 1024, 1024 );
 
 				var texture = new THREE.Texture( shadow( heightMap ) );
-				texture.loaded = true;
+				texture.image.loaded = true;
 
 				var material = new THREE.MeshBasicMaterial( { map: texture } );
 

+ 2 - 1
examples/materials_video.html

@@ -74,6 +74,7 @@
 				// 
 
 				texture = document.createElement( 'canvas' );
+				texture.loaded = true;
 				texture.width = 480;
 				texture.height = 204;
 
@@ -82,11 +83,11 @@
 				textureContext.fillRect( 0, 0, 480, 204 );
 
 				var map = new THREE.Texture( texture );
-				map.loaded = true;
 
 				var material = new THREE.MeshBasicMaterial( { map: map } );
 
 				textureReflection = document.createElement( 'canvas' );
+				textureReflection.loaded = true;
 				textureReflection.width = 480;
 				textureReflection.height = 204;
 

+ 52 - 55
examples/obj_convert_test.html

@@ -21,7 +21,7 @@
 			.inactive { background:#999; color:#eee }
 		</style>
 	</head>
-	
+
 	<body>
 		<div id="d">
 			<h1>OBJ to Three.js converter test</h1>
@@ -30,19 +30,19 @@
 			<span id="rwebgl" class="button">WebGL renderer</span>
 			<br/>
 
-			<p>Models by <a href="http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1">Reallusion<a> 
+			<p>Models by <a href="http://sketchup.google.com/3dwarehouse/details?mid=2c6fd128fca34052adc5f5b98d513da1">Reallusion<a>
 			<a href="http://sketchup.google.com/3dwarehouse/details?mid=f526cc4abf7cb68d76cab47c765b7255">iClone</a>.
-			
+
 			<p>Using a modified version of <a href="http://github.com/alteredq/three.js">Three.js</a> by mrdoob.
-			
+
 			<br/>
 			<p>Best viewed in Chrome 8/9 or Firefox 4 using WebGL renderer.
 			<p>Canvas renderer is very slow on anything other than Chrome.
 		</div>
-		
+
 		<pre id="log"></pre>
 
-		<script type="text/javascript" src="../build/Three.js"></script> 
+		<script type="text/javascript" src="../build/Three.js"></script>
 
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
@@ -56,37 +56,34 @@
 			var SCREEN_HEIGHT = window.innerHeight;
 			var FLOOR = -250;
 
-			var container;
-			var stats;
+			var container,stats;
 
-			var camera;
-			var scene;
+			var camera, scene;
 			var canvasRenderer, webglRenderer;
 
 			var mesh, zmesh, geometry;
-			
-			var mouseX = 0;
-			var mouseY = 0;
 
-			var windowHalfX = window.innerWidth >> 1;
-			var windowHalfY = window.innerHeight >> 1;
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
 
 			var render_canvas = 1, render_gl = 1;
 			var has_gl = 0;
-			
+
 			var bcanvas = document.getElementById("rcanvas");
 			var bwebgl = document.getElementById("rwebgl");
-			
+
 			document.addEventListener('mousemove', onDocumentMouseMove, false);
 
 			init();
-			
+
 			loop();
-			
+
 			render_canvas = !has_gl;
 			bwebgl.style.display = has_gl ? "inline" : "none";
 			bcanvas.className = render_canvas ? "button" : "button inactive";
-			
+
 			setInterval(loop, 1000/60);
 
 
@@ -100,9 +97,9 @@
 				camera.updateMatrix();
 
 				scene = new THREE.Scene();
-				
+
 				// GROUND
-				
+
 				var x = document.createElement( "canvas" );
 				var xc = x.getContext("2d");
 				x.width = x.height = 128;
@@ -116,10 +113,10 @@
 				xc.fillRect(64, 64, 64, 64);
 				xc.fillStyle = "#555";
 				xc.fillRect(96, 96, 32, 32);
-				
-				var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x, THREE.UVMapping, THREE.Repeat, THREE.Repeat ) } );
+
+				var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping ) } );
 				xm.map.image.loaded = 1;
-				
+
 				geometry = new Plane( 100, 100, 15, 10 );
 				for(var i=0; i<geometry.uvs.length; i++) {
 					var uvs = geometry.uvs[i];
@@ -127,7 +124,7 @@
 						uvs[j].u *= 10;
 						uvs[j].v *= 10;
 					}
-					
+
 				}
 				mesh = new THREE.Mesh( geometry, xm );
 				mesh.position.x = 0;
@@ -137,9 +134,9 @@
 				mesh.scale.x = mesh.scale.y = mesh.scale.z = 10;
 				mesh.updateMatrix();
 				scene.addObject(mesh);
-				
+
 				// SPHERES
-				
+
 				sphere = new Sphere( 100, 16, 8, 1 );
 				for (var i=0; i<10; i++) {
 					mesh = new THREE.Mesh( sphere, new THREE.MeshLambertMaterial( { color: 0xdddddd } ) );
@@ -151,7 +148,7 @@
 					mesh.updateMatrix();
 					scene.addObject(mesh);
 				}
-				
+
 
 				// LIGHTS
 
@@ -191,10 +188,10 @@
 				stats.domElement.style.top = '0px';
 				stats.domElement.style.zIndex = 100;
 				container.appendChild( stats.domElement );
-				
+
 				bcanvas.addEventListener("click", toggleCanvas, false);
 				bwebgl.addEventListener("click", toggleWebGL, false);
-				
+
 				var loader = new THREE.Loader();
 				//loader.loadAscii( "obj/male02/Male02_slim.js",     function( geometry ) { createScene( geometry,  90, 50, FLOOR, 105 ) }, "obj/male02" );
 				//loader.loadAscii( "obj/female02/Female02_slim.js", function( geometry ) { createScene( geometry, -80, 50, FLOOR, 0 ) },   "obj/female02" );
@@ -205,7 +202,7 @@
 			}
 
 			function createScene( geometry, x, y, z, b ) {
-				
+
 				zmesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial(), 1 );
 				zmesh.position.x = x;
 				zmesh.position.z = y;
@@ -214,15 +211,15 @@
 				zmesh.overdraw = true;
 				zmesh.updateMatrix();
 				scene.addObject(zmesh);
-				
+
 				createMaterialsPalette( geometry.materials, 100, b );
-                
+
 			}
 
 			function createMaterialsPalette( materials, size, bottom ) {
-				
+
 				for ( var i=0; i<materials.length; ++i ) {
-					
+
 					// material
 					mesh = new THREE.Mesh( new Plane( size, size ), materials[i] );
 					mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
@@ -232,7 +229,7 @@
 					mesh.doubleSided = true;
 					mesh.updateMatrix();
 					scene.addObject(mesh);
-					
+
 					// number
 					var x = document.createElement( "canvas" );
 					var xc = x.getContext("2d");
@@ -242,10 +239,10 @@
 					xc.fillStyle = "orange";
 					xc.font = "50pt arial bold";
 					xc.fillText(i, 10, 64);
-					
+
 					var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x ) } );
 					xm.map.image.loaded = 1;
-					
+
 					mesh = new THREE.Mesh( new Plane( size, size ), xm );
 					mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
 					mesh.position.y = FLOOR + size/2 + bottom;
@@ -255,9 +252,9 @@
 					mesh.updateMatrix();
 					scene.addObject(mesh);
 				}
-				
+
 			}
-			
+
 			function onDocumentMouseMove(event) {
 
 				mouseX = ( event.clientX - windowHalfX );
@@ -284,40 +281,40 @@
 			}
 
 			function log( text ) {
-			
+
 				var e = document.getElementById("log");
 				e.innerHTML = text + "<br/>" + e.innerHTML;
-				
+
 			}
-			
+
 			function toggleCanvas() {
-			
+
 				render_canvas = !render_canvas;
 				bcanvas.className = render_canvas ? "button" : "button inactive";
-				
+
 				render_gl = !render_canvas;
 				bwebgl.className = render_gl ? "button" : "button inactive";
-				
+
 				if( has_gl )
 					webglRenderer.domElement.style.display = render_gl ? "block" : "none";
-				
+
 				canvasRenderer.domElement.style.display = render_canvas ? "block" : "none";
-				
+
 			}
-			
+
 			function toggleWebGL() {
-			
+
 				render_gl = !render_gl;
 				bwebgl.className = render_gl ? "button" : "button inactive";
-				
+
 				render_canvas = !render_gl;
 				bcanvas.className = render_canvas ? "button" : "button inactive";
-				
+
 				if( has_gl )
 					webglRenderer.domElement.style.display = render_gl ? "block" : "none";
-					
+
 				canvasRenderer.domElement.style.display = render_canvas ? "block" : "none";
-				
+
 			}
 		</script>
 

+ 3 - 12
src/extras/ImageUtils.js

@@ -2,20 +2,11 @@ var ImageUtils = {
 
 	loadTexture: function ( path, mapping ) {
 
-		var texture = new THREE.Texture( null, mapping );
-
 		var image = new Image();
-
-		image.onload = function () {
-
-			texture.image = this;
-			texture.loaded = true;
-
-		};
-
+		image.onload = function () { this.loaded = true; };
 		image.src = path;
 
-		return texture;
+		return new THREE.Texture( image, mapping );
 
 	},
 
@@ -29,7 +20,7 @@ var ImageUtils = {
 
 			images[ i ] = new Image();
 			images[ i ].loaded = 0;
-			images[ i ].onload = function () { images.loadCount += 1; this.loaded = 1; }
+			images[ i ].onload = function () { images.loadCount += 1; this.loaded = true; }
 			images[ i ].src = array[ i ];
 
 		}

+ 26 - 16
src/renderers/CanvasRenderer.js

@@ -462,37 +462,47 @@ THREE.CanvasRenderer = function () {
 
 			if ( material instanceof THREE.MeshBasicMaterial ) {
 
-				if ( material.map && !material.wireframe ) {
+				if ( material.map/* && !material.wireframe*/ ) {
 
-					if ( material.map.mapping instanceof THREE.UVMapping ) {
+					if ( material.map.image.loaded ) {
 
-						texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.map.image, element.uvs[ 0 ].u, element.uvs[ 0 ].v, element.uvs[ 1 ].u, element.uvs[ 1 ].v, element.uvs[ 2 ].u, element.uvs[ 2 ].v );
+						if ( material.map.mapping instanceof THREE.UVMapping ) {
+
+							texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.map.image, element.uvs[ 0 ].u, element.uvs[ 0 ].v, element.uvs[ 1 ].u, element.uvs[ 1 ].v, element.uvs[ 2 ].u, element.uvs[ 2 ].v );
+
+						}
 
 					}
 
 				} else if ( material.env_map ) {
 
-					if ( material.env_map.mapping instanceof THREE.SphericalReflectionMapping ) {
+					if ( material.env_map.image.loaded ) {
+
+						if ( material.env_map.mapping instanceof THREE.SphericalReflectionMapping ) {
+
+							var cameraMatrix = camera.matrix;
 
-						_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;
+							_vector3.copy( element.vertexNormalsWorld[ 0 ] );
+							_uv1x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5;
+							_uv1y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5;
 
-						_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;
+							_vector3.copy( element.vertexNormalsWorld[ 1 ] );
+							_uv2x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5;
+							_uv2y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5;
 
-						_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;
+							_vector3.copy( element.vertexNormalsWorld[ 2 ] );
+							_uv3x = ( _vector3.x * cameraMatrix.n11 + _vector3.y * cameraMatrix.n12 + _vector3.z * cameraMatrix.n13 ) * 0.5 + 0.5;
+							_uv3y = - ( _vector3.x * cameraMatrix.n21 + _vector3.y * cameraMatrix.n22 + _vector3.z * cameraMatrix.n23 ) * 0.5 + 0.5;
 
-						texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.env_map.image, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y );
+							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 ) {
+						}/* else if ( material.env_map.mapping == THREE.RefractionMapping ) {
 
 						
 
-					}*/
+						}*/
+
+					}
 
 				} else {