Browse Source

Implemented Frustum checking to `Projector::projectObjects` (thanks errynp)
Added `boundingBox`, `boundingSphere` and `computeBoundingSphere` to Geometry.

Mr.doob 14 years ago
parent
commit
5e2c480b89

+ 118 - 115
build/Three.js

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

+ 116 - 113
build/ThreeDebug.js

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


+ 2 - 3
examples/particles_floor.html

@@ -47,9 +47,6 @@
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
-				renderer = new THREE.CanvasRenderer();
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
 				var material = new THREE.ParticleCircleMaterial( { color: 0xffffff, opacity: 1 } );
 				var material = new THREE.ParticleCircleMaterial( { color: 0xffffff, opacity: 1 } );
 
 
 				for ( var ix = 0; ix < AMOUNTX; ix++ ) {
 				for ( var ix = 0; ix < AMOUNTX; ix++ ) {
@@ -63,6 +60,8 @@
 					}
 					}
 				}
 				}
 
 
+				renderer = new THREE.CanvasRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
 				stats = new Stats();
 				stats = new Stats();

+ 2 - 3
examples/particles_random.html

@@ -44,9 +44,6 @@
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
-				renderer = new THREE.CanvasRenderer();
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
 				for ( var i = 0; i < 1000; i++ ) {
 				for ( var i = 0; i < 1000; i++ ) {
 
 
 					particle = new THREE.Particle( new THREE.ParticleCircleMaterial( { color: Math.random() * 0x808008 + 0x808080, opacity: 1 } ) );
 					particle = new THREE.Particle( new THREE.ParticleCircleMaterial( { color: Math.random() * 0x808008 + 0x808080, opacity: 1 } ) );
@@ -57,6 +54,8 @@
 					scene.addObject( particle );
 					scene.addObject( particle );
 				}
 				}
 
 
+				renderer = new THREE.CanvasRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
 				stats = new Stats();
 				stats = new Stats();

+ 3 - 3
examples/particles_sprites.html

@@ -44,9 +44,6 @@
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
-				renderer = new THREE.CanvasRenderer();
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
 				var material = new THREE.ParticleBasicMaterial( { map: createSprite(), blending: THREE.AdditiveBlending } );
 				var material = new THREE.ParticleBasicMaterial( { map: createSprite(), blending: THREE.AdditiveBlending } );
 
 
 				for ( var i = 0; i < 1000; i++ ) {
 				for ( var i = 0; i < 1000; i++ ) {
@@ -58,6 +55,9 @@
 					scene.addObject( particle );
 					scene.addObject( particle );
 				}
 				}
 
 
+				renderer = new THREE.CanvasRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.sortElements = false;
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
 				stats = new Stats();
 				stats = new Stats();

+ 8 - 6
examples/particles_waves.html

@@ -27,7 +27,7 @@
 			var container, stats;
 			var container, stats;
 			var camera, scene, renderer;
 			var camera, scene, renderer;
 
 
-			var particles, particle, count;
+			var particles, particle, count = 0;
 
 
 			var mouseX = 0, mouseY = 0;
 			var mouseX = 0, mouseY = 0;
 
 
@@ -47,9 +47,6 @@
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
-				renderer = new THREE.CanvasRenderer();
-				renderer.setSize( window.innerWidth, window.innerHeight );
-
 				particles = new Array();
 				particles = new Array();
 
 
 				var i = 0;
 				var i = 0;
@@ -63,11 +60,13 @@
 						particle.position.x = ix * SEPARATION - ( ( AMOUNTX * SEPARATION ) / 2 );
 						particle.position.x = ix * SEPARATION - ( ( AMOUNTX * SEPARATION ) / 2 );
 						particle.position.z = iy * SEPARATION - ( ( AMOUNTY * SEPARATION ) / 2 );
 						particle.position.z = iy * SEPARATION - ( ( AMOUNTY * SEPARATION ) / 2 );
 						scene.addObject( particle );
 						scene.addObject( particle );
+
 					}
 					}
-				}
 
 
-				count = 0;
+				}
 
 
+				renderer = new THREE.CanvasRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
 				stats = new Stats();
 				stats = new Stats();
@@ -99,6 +98,7 @@
 					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 
 
 				}
 				}
+
 			}
 			}
 
 
 			function onDocumentTouchMove( event ) {
 			function onDocumentTouchMove( event ) {
@@ -111,6 +111,7 @@
 					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 
 
 				}
 				}
+
 			}
 			}
 
 
 			//
 			//
@@ -138,6 +139,7 @@
 				stats.update();
 				stats.update();
 
 
 				count += 0.1;
 				count += 0.1;
+
 			}
 			}
 
 
 		</script>
 		</script>

+ 6 - 5
examples/webglrenderer2_sandbox.html

@@ -105,7 +105,7 @@
 
 
 			var container, stats;
 			var container, stats;
 
 
-			var camera, scene, webglRenderer;
+			var camera, scene, renderer;
 
 
 			var mesh, zmesh, lightMesh, geometry;
 			var mesh, zmesh, lightMesh, geometry;
 
 
@@ -167,9 +167,10 @@
 
 
 				}
 				}
 
 
-				webglRenderer = new THREE.WebGLRenderer2();
-				webglRenderer.setSize( window.innerWidth, window.innerHeight );
-				container.appendChild( webglRenderer.domElement );
+				renderer = new THREE.WebGLRenderer2();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				// renderer.sortObjects = false;
+				container.appendChild( renderer.domElement );
 
 
 				if ( statsEnabled ) {
 				if ( statsEnabled ) {
 
 
@@ -223,7 +224,7 @@
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.y += ( - mouseY - camera.position.y ) * .05;
 				camera.position.y += ( - mouseY - camera.position.y ) * .05;
 
 
-				webglRenderer.render( scene, camera );
+				renderer.render( scene, camera );
 
 
 				if ( statsEnabled ) stats.update();
 				if ( statsEnabled ) stats.update();
 
 

+ 2 - 1
src/cameras/Camera.js

@@ -8,6 +8,7 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 	this.target = { position: new THREE.Vector3() };
 	this.target = { position: new THREE.Vector3() };
 
 
 	this.up = new THREE.Vector3( 0, 1, 0 );
 	this.up = new THREE.Vector3( 0, 1, 0 );
+
 	this.matrix = new THREE.Matrix4();
 	this.matrix = new THREE.Matrix4();
 	this.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect, near, far );
 	this.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect, near, far );
 
 
@@ -23,7 +24,7 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 
 
 	};
 	};
 
 
-	/*
+	/* TODO
 	this.translateY = function ( amount ) {
 	this.translateY = function ( amount ) {
 
 
 	};
 	};

+ 19 - 0
src/core/Geometry.js

@@ -10,6 +10,9 @@ THREE.Geometry = function () {
 	this.faces = [];
 	this.faces = [];
 	this.uvs = [];
 	this.uvs = [];
 
 
+	this.boundingBox = null;
+	this.boundingSphere = null;
+
 	this.geometryChunks = {};
 	this.geometryChunks = {};
 
 
 	this.hasTangents = false;
 	this.hasTangents = false;
@@ -286,6 +289,8 @@ THREE.Geometry.prototype = {
 
 
 	computeBoundingBox: function () {
 	computeBoundingBox: function () {
 
 
+		var vertex;
+
 		if ( this.vertices.length > 0 ) {
 		if ( this.vertices.length > 0 ) {
 
 
 			this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
 			this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
@@ -332,6 +337,20 @@ THREE.Geometry.prototype = {
 
 
 	},
 	},
 
 
+	computeBoundingSphere: function () {
+
+		var radius = this.boundingSphere === null ? 0 : this.boundingSphere.radius;
+
+		for ( var v = 0, vl = this.vertices.length; v < vl; v ++ ) {
+
+			radius = Math.max( radius, this.vertices[ v ].position.length() );
+
+		}
+
+		this.boundingSphere = { radius: radius };
+
+	},
+
 	sortFacesByMaterial: function () {
 	sortFacesByMaterial: function () {
 
 
 		// TODO
 		// TODO

+ 4 - 4
src/core/Matrix4.js

@@ -262,10 +262,10 @@ THREE.Matrix4.prototype = {
 
 
 	flatten: function() {
 	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];
+		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 ];
 
 
 	},
 	},
 
 

+ 2 - 1
src/objects/Mesh.js

@@ -17,7 +17,8 @@ THREE.Mesh = function ( geometry, material/*, normUVs*/ ) {
 
 
 	// if ( normUVs ) this.normalizeUVs();
 	// if ( normUVs ) this.normalizeUVs();
 
 
-	this.geometry.computeBoundingBox();
+	// this.geometry.boundingBox ||this.geometry.computeBoundingBox();
+	this.geometry.boundingSphere || this.geometry.computeBoundingSphere();
 
 
 };
 };
 
 

+ 44 - 7
src/renderers/Projector.js

@@ -15,6 +15,7 @@ THREE.Projector = function() {
 	_vector4 = new THREE.Vector4(),
 	_vector4 = new THREE.Vector4(),
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenObjectMatrix = new THREE.Matrix4(),
 	_projScreenObjectMatrix = new THREE.Matrix4(),
+	_frustum = [],
 
 
 	_clippedVertex1PositionScreen = new THREE.Vector4(),
 	_clippedVertex1PositionScreen = new THREE.Vector4(),
 	_clippedVertex2PositionScreen = new THREE.Vector4(),
 	_clippedVertex2PositionScreen = new THREE.Vector4(),
@@ -29,13 +30,15 @@ THREE.Projector = function() {
 		_objectCount = 0;
 		_objectCount = 0;
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix );
 		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix );
 
 
+		computeFrustum( _projScreenMatrix );
+
 		objects = scene.objects;
 		objects = scene.objects;
 
 
 		for ( o = 0, ol = objects.length; o < ol; o++ ) {
 		for ( o = 0, ol = objects.length; o < ol; o++ ) {
 
 
 			object = objects[ o ];
 			object = objects[ o ];
 
 
-			if ( object.visible === false ) continue;
+			if ( object.visible === false || isInFrustum( object ) === false ) continue;
 
 
 			_object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject();
 			_object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject();
 
 
@@ -372,6 +375,46 @@ THREE.Projector = function() {
 
 
 	};
 	};
 
 
+	function painterSort( a, b ) {
+
+		return b.z - a.z;
+
+	}
+
+	function computeFrustum( m ) {
+
+		_frustum[ 0 ] = new THREE.Vector4( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 );
+		_frustum[ 1 ] = new THREE.Vector4( m.n41 + m.n11, m.n42 + m.n12, m.n43 + m.n13, m.n44 + m.n14 );
+		_frustum[ 2 ] = new THREE.Vector4( m.n41 + m.n21, m.n42 + m.n22, m.n43 + m.n23, m.n44 + m.n24 );
+		_frustum[ 3 ] = new THREE.Vector4( m.n41 - m.n21, m.n42 - m.n22, m.n43 - m.n23, m.n44 - m.n24 );
+		_frustum[ 4 ] = new THREE.Vector4( m.n41 - m.n31, m.n42 - m.n32, m.n43 - m.n33, m.n44 - m.n34 );
+		_frustum[ 5 ] = new THREE.Vector4( m.n41 + m.n31, m.n42 + m.n32, m.n43 + m.n33, m.n44 + m.n34 );
+
+		for ( var i = 0, l = _frustum.length; i < l; i ++ ) {
+
+			var plane = _frustum[ i ];
+			plane.divideScalar( Math.sqrt( plane.x * plane.x + plane.y * plane.y + plane.z * plane.z ) );
+
+		}
+
+	}
+
+	function isInFrustum( object ) {
+
+		var d, position = object.position,
+		radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) );
+
+		for ( var i = 0; i < 6; i ++ ) {
+
+			d = _frustum[ i ].x * position.x + _frustum[ i ].y * position.y + _frustum[ i ].z * position.z + _frustum[ i ].w;
+			if ( d <= radius ) return false;
+
+		}
+
+		return true;
+
+	}
+
 	function clipLine( s1, s2 ) {
 	function clipLine( s1, s2 ) {
 
 
 		var alpha1 = 0, alpha2 = 1,
 		var alpha1 = 0, alpha2 = 1,
@@ -442,10 +485,4 @@ THREE.Projector = function() {
 
 
 	}
 	}
 
 
-	function painterSort( a, b ) {
-
-		return b.z - a.z;
-
-	}
-
 };
 };

+ 8 - 11
src/renderers/WebGLRenderer2.js

@@ -78,9 +78,7 @@ THREE.WebGLRenderer2 = function () {
 		/*
 		/*
 		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
 		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
 
 
-			object = scene.objects[ o ];
-
-			renderObject( object );
+			renderObject( scene.objects[ o ] );
 
 
 		}
 		}
 		*/
 		*/
@@ -89,13 +87,10 @@ THREE.WebGLRenderer2 = function () {
 
 
 		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
 		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
 
 
-			object = _renderList[ o ];
-
-			renderObject( object.object );
+			renderObject( _renderList[ o ].object );
 
 
 		}
 		}
 
 
-
 		function renderObject( object ) {
 		function renderObject( object ) {
 
 
 			var geometry, material, m, nl,
 			var geometry, material, m, nl,
@@ -242,8 +237,6 @@ THREE.WebGLRenderer2 = function () {
 
 
 		function buildBuffers( geometry ) {
 		function buildBuffers( geometry ) {
 
 
-			// TODO: Handle 65535
-
 			var itemCount = 0, vertexIndex, group,
 			var itemCount = 0, vertexIndex, group,
 			f, fl, face, v1, v2, v3, vertexNormals, normal, uv,
 			f, fl, face, v1, v2, v3, vertexNormals, normal, uv,
 			vertexGroups = [], faceGroups = [], lineGroups = [], normalGroups = [], uvGroups = [],
 			vertexGroups = [], faceGroups = [], lineGroups = [], normalGroups = [], uvGroups = [],
@@ -470,8 +463,12 @@ THREE.WebGLRenderer2 = function () {
 
 
 					pfs += 'uniform sampler2D tMap;\n';
 					pfs += 'uniform sampler2D tMap;\n';
 					pfs += 'varying vec2 vUv;\n';
 					pfs += 'varying vec2 vUv;\n';
-					// fs += 'vec4 mapColor = texture2D( tMap, vUv );\n';
-					// fs += 'mapColor.xyz *= mapColor.w;\n';
+
+					/* Premultiply alpha
+					fs += 'vec4 mapColor = texture2D( tMap, vUv );\n';
+					fs += 'mapColor.xyz *= mapColor.w;\n';
+					*/
+
 					fs += 'gl_FragColor *= texture2D( tMap, vUv );\n';
 					fs += 'gl_FragColor *= texture2D( tMap, vUv );\n';
 
 
 					identifiers.push( 'tMap' );
 					identifiers.push( 'tMap' );

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