Kaynağa Gözat

Added support for "doubleSided" mesh property to WebGLRenderer.

Testing on current examples didn't show any noticeable performance degradation when enabling / disabling culling for every object in every frame.

"FlipSided" property could be probably done in very similar way, just setting "gl.frontFace( gl.CCW )" or "gl.frontFace( gl.CW )"
alteredq 14 yıl önce
ebeveyn
işleme
271ba6c524

+ 56 - 56
build/Three.js

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

+ 55 - 55
build/ThreeDebug.js

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

+ 7 - 7
build/ThreeExtras.js

@@ -178,13 +178,13 @@ l,u,n,s,I,p){var w,z,x,q,N;x=0;for(q=n.materials.length;x<q;x++){w=n.materials[x
 c.createFramebuffer();u.__webGLRenderbuffer=c.createRenderbuffer();u.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,u.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,u.width,u.height);c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(u.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(u.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(u.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
 h(u.min_filter));c.texImage2D(c.TEXTURE_2D,0,h(u.format),u.width,u.height,0,h(u.format),h(u.type),null);c.bindFramebuffer(c.FRAMEBUFFER,u.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,u.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,u.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}if(u){s=u.__webGLFramebuffer;p=u.width;I=u.height}else{s=
 null;p=j.width;I=j.height}if(s!=m){c.bindFramebuffer(c.FRAMEBUFFER,s);c.viewport(0,0,p,I);n&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);m=s}this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();r.set(l.matrix.flatten());A.set(l.projectionMatrix.flatten());n=0;for(s=f.__webGLObjects.length;n<s;n++){I=f.__webGLObjects[n];p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,l);this.renderPass(l,w,z,p,I,THREE.NormalBlending,false)}}n=0;for(s=f.__webGLObjects.length;n<s;n++){I=f.__webGLObjects[n];
-p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,l);this.renderPass(l,w,z,p,I,THREE.AdditiveBlending,false);this.renderPass(l,w,z,p,I,THREE.SubtractiveBlending,false);this.renderPass(l,w,z,p,I,THREE.AdditiveBlending,true);this.renderPass(l,w,z,p,I,THREE.SubtractiveBlending,true);this.renderPass(l,w,z,p,I,THREE.NormalBlending,true)}}if(u&&u.min_filter!==THREE.NearestFilter&&u.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,u.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
-null)}};this.initWebGLObjects=function(f){function l(x,q,N,G){if(x[q]==undefined){f.__webGLObjects.push({buffer:N,object:G});x[q]=1}}var u,n,s,I,p,w,z;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}u=0;for(n=f.objects.length;u<n;u++){s=f.objects[u];p=s.geometry;if(f.__webGLObjectsMap[s.id]==undefined)f.__webGLObjectsMap[s.id]={};z=f.__webGLObjectsMap[s.id];if(s instanceof THREE.Mesh){for(I in p.geometryChunks){w=p.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);
-this.initMeshBuffers(w,s);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(w,s,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements,p.__dirtyUvs,p.__dirtyNormals,p.__dirtyTangents);l(z,I,w,s)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=false}else if(s instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);
-this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements);l(z,0,p,s);p.__dirtyVertices=false;p.__dirtyElements=false}else if(s instanceof THREE.ParticleSystem){p.__webGLVertexBuffer||this.createParticleBuffers(p);l(z,0,p,s)}}};this.removeObject=function(f,l){var u,n;for(u=f.__webGLObjects.length-1;u>=0;u--){n=f.__webGLObjects[u].object;l==n&&f.__webGLObjects.splice(u,1)}};this.setupMatrices=function(f,
-l){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(l.matrix,f.matrix);y.set(v.flatten());D=THREE.Matrix4.makeInvert3x3(v).transpose();C.set(D.m);L.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,r);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,C);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,L)};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)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+p=I.object;I=I.buffer;if(p.visible){this.setupMatrices(p,l);p.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);this.renderPass(l,w,z,p,I,THREE.AdditiveBlending,false);this.renderPass(l,w,z,p,I,THREE.SubtractiveBlending,false);this.renderPass(l,w,z,p,I,THREE.AdditiveBlending,true);this.renderPass(l,w,z,p,I,THREE.SubtractiveBlending,true);this.renderPass(l,w,z,p,I,THREE.NormalBlending,true)}}if(u&&u.min_filter!==THREE.NearestFilter&&u.min_filter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,
+u.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){function l(x,q,N,G){if(x[q]==undefined){f.__webGLObjects.push({buffer:N,object:G});x[q]=1}}var u,n,s,I,p,w,z;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={}}u=0;for(n=f.objects.length;u<n;u++){s=f.objects[u];p=s.geometry;if(f.__webGLObjectsMap[s.id]==undefined)f.__webGLObjectsMap[s.id]={};z=f.__webGLObjectsMap[s.id];if(s instanceof THREE.Mesh){for(I in p.geometryChunks){w=
+p.geometryChunks[I];if(!w.__webGLVertexBuffer){this.createMeshBuffers(w);this.initMeshBuffers(w,s);p.__dirtyVertices=true;p.__dirtyElements=true;p.__dirtyUvs=true;p.__dirtyNormals=true;p.__dirtyTangents=true}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs)this.setMeshBuffers(w,s,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements,p.__dirtyUvs,p.__dirtyNormals,p.__dirtyTangents);l(z,I,w,s)}p.__dirtyVertices=false;p.__dirtyElements=false;p.__dirtyUvs=false;p.__dirtyNormals=false;p.__dirtyTangents=
+false}else if(s instanceof THREE.Line){if(!p.__webGLVertexBuffer){this.createLineBuffers(p);this.initLineBuffers(p);p.__dirtyVertices=true;p.__dirtyElements=true}p.__dirtyVertices&&this.setLineBuffers(p,c.DYNAMIC_DRAW,p.__dirtyVertices,p.__dirtyElements);l(z,0,p,s);p.__dirtyVertices=false;p.__dirtyElements=false}else if(s instanceof THREE.ParticleSystem){p.__webGLVertexBuffer||this.createParticleBuffers(p);l(z,0,p,s)}}};this.removeObject=function(f,l){var u,n;for(u=f.__webGLObjects.length-1;u>=0;u--){n=
+f.__webGLObjects[u].object;l==n&&f.__webGLObjects.splice(u,1)}};this.setupMatrices=function(f,l){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(l.matrix,f.matrix);y.set(v.flatten());D=THREE.Matrix4.makeInvert3x3(v).transpose();C.set(D.m);L.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,r);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,
+C);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,L)};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)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",

+ 1 - 1
examples/obj_convert_test.html

@@ -132,6 +132,7 @@
 				mesh.position.z = 0;
 				mesh.rotation.x = 1.57;
 				mesh.scale.x = mesh.scale.y = mesh.scale.z = 10;
+				mesh.doubleSided = true;
 				mesh.updateMatrix();
 				scene.addObject(mesh);
 
@@ -169,7 +170,6 @@
 				if ( render_gl ) {
 					try {
 						webglRenderer = new THREE.WebGLRenderer();
-						webglRenderer.setFaceCulling(0);
 						webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 						webglRenderer.domElement.style.position = "relative";
 						container.appendChild( webglRenderer.domElement );

+ 10 - 0
src/renderers/WebGLRenderer.js

@@ -953,6 +953,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				this.setupMatrices( object, camera );
 
+				if( object.doubleSided ) {
+					
+					_gl.disable( _gl.CULL_FACE );
+					
+				} else {
+					
+					_gl.enable( _gl.CULL_FACE );
+					
+				}
+				
 				// opaque blended materials
 
 				this.renderPass( camera, lights, fog, object, buffer, THREE.AdditiveBlending, false );