Browse Source

Fixed subtle yet brutal bug also known as "don't mess with streams" ;)

This one kept me puzzled for days. Premature optimization is indeed evil.

Manifestation was that MeshShaderMaterial mysteriously didn't work depending on what was going on elsewhere in the scene. I think mrdoob's problem with "basic" shader was caused by this bug.
alteredq 14 years ago
parent
commit
2163691b59
4 changed files with 163 additions and 166 deletions
  1. 78 78
      build/Three.js
  2. 15 15
      build/ThreeDebug.js
  3. 64 64
      build/ThreeExtras.js
  4. 6 9
      src/renderers/WebGLRenderer.js

+ 78 - 78
build/Three.js

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

+ 15 - 15
build/ThreeDebug.js

@@ -137,12 +137,12 @@ THREE.WebGLRenderer=function(a){function b(e,m){var f=c.createProgram(),p=[c.get
 e));c.attachShader(f,k("vertex",p+m));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
 c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var f=0;f<6;++f)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[f]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP,
 e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,h(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,h(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,h(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,h(e.min_filter));c.generateMipmap(c.TEXTURE_2D);
-c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function i(e,m){var f,p,l;f=0;for(p=m.length;f<p;f++){l=m[f];e.uniforms[l]=c.getUniformLocation(e,l)}}function q(e,m){var f,p,l;f=0;for(p=m.length;f<p;f++){l=m[f];e.attributes[l]=c.getAttribLocation(e,l);e.attributes[l]>=0&&c.enableVertexAttribArray(e.attributes[l])}}function k(e,m){var f;if(e=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")f=c.createShader(c.VERTEX_SHADER);
-c.shaderSource(f,m);c.compileShader(f);if(!c.getShaderParameter(f,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function h(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
-case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,A,y,x=new THREE.Matrix4,s,G=new Float32Array(16),N=new Float32Array(16),K=new Float32Array(16),J=new Float32Array(9),O=new Float32Array(16);a=function(e,m){if(e){var f,p,l,j=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=e.lights.length;f<p;f++){l=e.lights[f];l instanceof THREE.DirectionalLight&&j++;l instanceof
-THREE.PointLight&&pointLights++}if(pointLights+j<=m){maxDirLights=j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*j/(pointLights+j));maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a,4);this.domElement=n;this.autoClear=true;try{c=n.getContext("experimental-webgl",{antialias:true})}catch(E){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
-c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);A=y=function(e,m){var f=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
-"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
+c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function i(e,m){var f,p,l;f=0;for(p=m.length;f<p;f++){l=m[f];e.uniforms[l]=c.getUniformLocation(e,l)}}function q(e,m){var f,p,l;f=0;for(p=m.length;f<p;f++){l=m[f];e.attributes[l]=c.getAttribLocation(e,l)}}function k(e,m){var f;if(e=="fragment")f=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")f=c.createShader(c.VERTEX_SHADER);c.shaderSource(f,m);c.compileShader(f);if(!c.getShaderParameter(f,
+c.COMPILE_STATUS)){alert(c.getShaderInfoLog(f));return null}return f}function h(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;
+case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var n=document.createElement("canvas"),c,A,y,x=new THREE.Matrix4,s,G=new Float32Array(16),N=new Float32Array(16),K=new Float32Array(16),J=new Float32Array(9),O=new Float32Array(16);a=function(e,m){if(e){var f,p,l,j=pointLights=maxDirLights=maxPointLights=0;f=0;for(p=e.lights.length;f<p;f++){l=e.lights[f];l instanceof THREE.DirectionalLight&&j++;l instanceof THREE.PointLight&&pointLights++}if(pointLights+j<=m){maxDirLights=
+j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*j/(pointLights+j));maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a,4);this.domElement=n;this.autoClear=true;try{c=n.getContext("experimental-webgl",{antialias:true})}catch(E){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);
+c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);A=y=function(e,m){var f=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":
+"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",m?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 "",m?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",m?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",m?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
 p=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
@@ -166,13 +166,13 @@ f.program}else F=y;if(F!=A){c.useProgram(F);A=F}F==y&&this.setupLights(F,m);this
 6?g(B,I):d(B,I)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){l=f.color;j=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;v=f.map;t=f.env_map;m=f.combine==THREE.MixOperation;e=f.reflectivity;B=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;I=f.refraction_ratio;c.uniform4f(F.uniforms.mColor,l.r*j,l.g*j,l.b*j,j);c.uniform1i(F.uniforms.mixEnvMap,m);c.uniform1f(F.uniforms.mReflectivity,e);c.uniform1i(F.uniforms.useRefract,
 B);c.uniform1f(F.uniforms.mRefractionRatio,I)}if(f instanceof THREE.MeshNormalMaterial){j=f.opacity;c.uniform1f(F.uniforms.mOpacity,j);c.uniform1i(F.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){j=f.opacity;o=f.wireframe;C=f.wireframe_linewidth;c.uniform1f(F.uniforms.mOpacity,j);c.uniform1f(F.uniforms.m2Near,f.__2near);c.uniform1f(F.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(F.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(F.uniforms.material,3)}else if(f instanceof
 THREE.MeshPhongMaterial){l=f.ambient;e=f.specular;f=f.shininess;c.uniform4f(F.uniforms.mAmbient,l.r,l.g,l.b,j);c.uniform4f(F.uniforms.mSpecular,e.r,e.g,e.b,j);c.uniform1f(F.uniforms.mShininess,f);c.uniform1i(F.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(F.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(F.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(F.uniforms.material,5);t=f.env_map}if(v){d(v,0);c.uniform1i(F.uniforms.tMap,
-0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(t){g(t,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);j=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);if(j.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0)}if(j.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
-c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0)}if(j.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(j.uv);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(j.uv);if(o){c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
-0)}};this.renderPass=function(e,m,f,p,l,j){var o,C,v,t,I;v=0;for(t=f.material.length;v<t;v++){o=f.material[v];if(o instanceof THREE.MeshFaceMaterial){o=0;for(C=p.material.length;o<C;o++)if((I=p.material[o])&&I.blending==l&&I.opacity<1==j){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}else if((I=o)&&I.blending==l&&I.opacity<1==j){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}};this.render=function(e,m){var f,p,l,j,o=e.lights;this.initWebGLObjects(e);this.autoClear&&this.clear();
-m.autoUpdateMatrix&&m.updateMatrix();G.set(m.matrix.flatten());K.set(m.projectionMatrix.flatten());f=0;for(p=e.__webGLObjects.length;f<p;f++){l=e.__webGLObjects[f];j=l.object;l=l.buffer;if(j.visible){this.setupMatrices(j,m);this.renderPass(m,o,j,l,THREE.NormalBlending,false)}}f=0;for(p=e.__webGLObjects.length;f<p;f++){l=e.__webGLObjects[f];j=l.object;l=l.buffer;if(j.visible){this.setupMatrices(j,m);this.renderPass(m,o,j,l,THREE.AdditiveBlending,false);this.renderPass(m,o,j,l,THREE.SubtractiveBlending,
-false);this.renderPass(m,o,j,l,THREE.AdditiveBlending,true);this.renderPass(m,o,j,l,THREE.SubtractiveBlending,true);this.renderPass(m,o,j,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,f,p,l,j,o;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}m=0;for(f=e.objects.length;m<f;m++){p=e.objects[m];if(e.__webGLObjectsMap[p.id]==undefined)e.__webGLObjectsMap[p.id]={};o=e.__webGLObjectsMap[p.id];if(p instanceof THREE.Mesh)for(j in p.geometry.geometryChunks){l=p.geometry.geometryChunks[j];
-l.__webGLVertexBuffer||this.createBuffers(p,j);if(o[j]==undefined){l={buffer:l,object:p};e.__webGLObjects.push(l);o[j]=1}}}};this.removeObject=function(e,m){var f,p;for(f=e.__webGLObjects.length-1;f>=0;f--){p=e.__webGLObjects[f].object;m==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(m.matrix,e.matrix);N.set(x.flatten());s=THREE.Matrix4.makeInvert3x3(x).transpose();J.set(s.m);O.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,
-false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,O)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
-c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
+0);c.uniform1i(F.uniforms.enableMap,1)}else c.uniform1i(F.uniforms.enableMap,0);if(t){g(t,1);c.uniform1i(F.uniforms.tCube,1);c.uniform1i(F.uniforms.enableCubeMap,1)}else c.uniform1i(F.uniforms.enableCubeMap,0);j=F.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(j.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(j.position);if(j.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(j.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(j.normal)}if(j.tangent>=
+0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);c.vertexAttribPointer(j.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(j.tangent)}if(j.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.vertexAttribPointer(j.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(j.uv)}else c.disableVertexAttribArray(j.uv);if(o){c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,m,f,p,l,j){var o,C,v,t,I;v=0;for(t=f.material.length;v<t;v++){o=f.material[v];if(o instanceof THREE.MeshFaceMaterial){o=0;for(C=p.material.length;o<C;o++)if((I=p.material[o])&&I.blending==l&&I.opacity<1==j){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}else if((I=o)&&I.blending==l&&I.opacity<1==j){this.setBlending(I.blending);this.renderBuffer(e,m,I,p)}}};this.render=function(e,
+m){var f,p,l,j,o=e.lights;this.initWebGLObjects(e);this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();G.set(m.matrix.flatten());K.set(m.projectionMatrix.flatten());f=0;for(p=e.__webGLObjects.length;f<p;f++){l=e.__webGLObjects[f];j=l.object;l=l.buffer;if(j.visible){this.setupMatrices(j,m);this.renderPass(m,o,j,l,THREE.NormalBlending,false)}}f=0;for(p=e.__webGLObjects.length;f<p;f++){l=e.__webGLObjects[f];j=l.object;l=l.buffer;if(j.visible){this.setupMatrices(j,m);this.renderPass(m,o,
+j,l,THREE.AdditiveBlending,false);this.renderPass(m,o,j,l,THREE.SubtractiveBlending,false);this.renderPass(m,o,j,l,THREE.AdditiveBlending,true);this.renderPass(m,o,j,l,THREE.SubtractiveBlending,true);this.renderPass(m,o,j,l,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,f,p,l,j,o;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={}}m=0;for(f=e.objects.length;m<f;m++){p=e.objects[m];if(e.__webGLObjectsMap[p.id]==undefined)e.__webGLObjectsMap[p.id]={};o=e.__webGLObjectsMap[p.id];
+if(p instanceof THREE.Mesh)for(j in p.geometry.geometryChunks){l=p.geometry.geometryChunks[j];l.__webGLVertexBuffer||this.createBuffers(p,j);if(o[j]==undefined){l={buffer:l,object:p};e.__webGLObjects.push(l);o[j]=1}}}};this.removeObject=function(e,m){var f,p;for(f=e.__webGLObjects.length-1;f>=0;f--){p=e.__webGLObjects[f].object;m==p&&e.__webGLObjects.splice(f,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(m.matrix,e.matrix);N.set(x.flatten());s=THREE.Matrix4.makeInvert3x3(x).transpose();
+J.set(s.m);O.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,G);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,J);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,O)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);
+c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0}};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};

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


+ 6 - 9
src/renderers/WebGLRenderer.js

@@ -536,6 +536,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 		_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer );
 		_gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
+		_gl.enableVertexAttribArray( attributes.position );
 
 		// normals
 
@@ -543,6 +544,7 @@ THREE.WebGLRenderer = function ( scene ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer );
 			_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
+			_gl.enableVertexAttribArray( attributes.normal );
 
 		}
 
@@ -552,7 +554,8 @@ THREE.WebGLRenderer = function ( scene ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer );
 			_gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 );
-
+			_gl.enableVertexAttribArray( attributes.tangent );
+			
 		}
 
 		// uvs
@@ -560,11 +563,11 @@ THREE.WebGLRenderer = function ( scene ) {
 		if ( attributes.uv >= 0 ) {
 
 			if ( geometryChunk.__webGLUVBuffer ) {
-
+				
 				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer );
+				_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 );
 
 				_gl.enableVertexAttribArray( attributes.uv );
-				_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 );
 
 			} else {
 
@@ -1411,12 +1414,6 @@ THREE.WebGLRenderer = function ( scene ) {
 			id = identifiers[ i ];
 			program.attributes[ id ] = _gl.getAttribLocation( program, id );
 
-			if ( program.attributes[ id ] >= 0 ) {
-
-				_gl.enableVertexAttribArray( program.attributes[ id ] );
-
-			}
-
 		}
 
 	};

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