瀏覽代碼

Merge branch 'master' of git://github.com/mrdoob/three.js

Mikael Emtinger 14 年之前
父節點
當前提交
b0e904eb29

+ 290 - 287
build/Three.js

@@ -8,47 +8,48 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(b,d,c){this.x=b;this.y=d;this.z=c;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b,
 d){this.set(b.y*d.z-b.z*d.y,b.z*d.x-b.x*d.z,b.x*d.y-b.y*d.x);return this},crossSelf:function(b){var d=this.x,c=this.y,f=this.z;this.set(c*b.z-f*b.y,f*b.x-d*b.z,d*b.y-c*b.x);return this},multiply:function(b,d){this.set(b.x*d.x,b.y*d.y,b.z*d.z);return this},multiplySelf:function(b){this.set(this.x*b.x,this.y*b.y,this.z*b.z);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b,this.z*b);return this},divideSelf:function(b){this.set(this.x/b.x,this.y/b.y,this.z/b.z);return this},divideScalar:function(b){this.set(this.x/
 b,this.y/b,this.z/b);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x,c=this.y-b.y;b=this.z-b.z;return d*d+c*c+b*b},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var b=
-this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){this.y=Math.asin(b.n13);var d=Math.cos(this.y);if(Math.abs(d)>1.0E-5){this.x=Math.atan2(-b.n23/d,b.n33/d);this.z=Math.atan2(-b.n13/d,b.n11/d)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var d=Math.cos(this.y);this.y=Math.asin(b.n13);if(Math.abs(d)>1.0E-5){this.x=Math.atan2(-b.n23/d,b.n33/d);this.z=Math.atan2(-b.n12/d,b.n11/d)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,c,f){this.set(b||0,d||0,c||0,f||1)};
 THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b<d;b++){c=f[b];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(H,G,X,A){A=A.clone().subSelf(G);X=X.clone().subSelf(G);var M=H.clone().subSelf(G);H=A.dot(A);G=A.dot(X);A=A.dot(M);var Q=X.dot(X);X=X.dot(M);M=1/(H*Q-G*G);Q=(Q*A-G*X)*M;H=(H*X-G*A)*M;return Q>0&&H>0&&Q+H<1}var c,f,g,h,j,k,m,p,o,u,
-y,t=b.geometry,B=t.vertices,F=[];c=0;for(f=t.faces.length;c<f;c++){g=t.faces[c];u=this.origin.clone();y=this.direction.clone();m=b.matrixWorld;h=m.multiplyVector3(B[g.a].position.clone());j=m.multiplyVector3(B[g.b].position.clone());k=m.multiplyVector3(B[g.c].position.clone());m=g instanceof THREE.Face4?m.multiplyVector3(B[g.d].position.clone()):null;p=b.matrixRotationWorld.multiplyVector3(g.normal.clone());o=y.dot(p);if(b.doubleSided||(b.flipSided?o>0:o<0)){p=p.dot((new THREE.Vector3).sub(h,u))/
-o;u=u.addSelf(y.multiplyScalar(p));if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};F.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,m)||d(u,j,k,m))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};F.push(g)}}}return F}};
-THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,p,o,u){k=!1;d=m;c=p;f=o;g=u;b()};this.addPoint=function(m,p){if(k){k=!1;d=m;c=p;f=m;g=p}else{d=d<m?d:m;c=c<p?c:p;f=f>m?f:m;g=g>p?g:p}b()};
-this.add3Points=function(m,p,o,u,y,t){if(k){k=!1;d=m<o?m<y?m:y:o<y?o:y;c=p<u?p<t?p:t:u<t?u:t;f=m>o?m>y?m:y:o>y?o:y;g=p>u?p>t?p:t:u>t?u:t}else{d=m<o?m<y?m<d?m:d:y<d?y:d:o<y?o<d?o:d:y<d?y:d;c=p<u?p<t?p<c?p:c:t<c?t:c:u<t?u<c?u:c:t<c?t:c;f=m>o?m>y?m>f?m:f:y>f?y:f:o>y?o>f?o:f:y>f?y:f;g=p>u?p>t?p>g?p:g:t>g?t:g:u>t?u>g?u:g:t>g?t:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=d<m.getLeft()?d:m.getLeft();c=c<m.getTop()?c:m.getTop();f=f>m.getRight()?
+THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b<d;b++){c=f[b];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(H,J,W,B){B=B.clone().subSelf(J);W=W.clone().subSelf(J);var U=H.clone().subSelf(J);H=B.dot(B);J=B.dot(W);B=B.dot(U);var N=W.dot(W);W=W.dot(U);U=1/(H*N-J*J);N=(N*B-J*W)*U;H=(H*W-J*B)*U;return N>0&&H>0&&N+H<1}var c,f,g,h,j,k,m,o,p,t,
+z,u=b.geometry,A=u.vertices,E=[];c=0;for(f=u.faces.length;c<f;c++){g=u.faces[c];t=this.origin.clone();z=this.direction.clone();m=b.matrixWorld;h=m.multiplyVector3(A[g.a].position.clone());j=m.multiplyVector3(A[g.b].position.clone());k=m.multiplyVector3(A[g.c].position.clone());m=g instanceof THREE.Face4?m.multiplyVector3(A[g.d].position.clone()):null;o=b.matrixRotationWorld.multiplyVector3(g.normal.clone());p=z.dot(o);if(b.doubleSided||(b.flipSided?p>0:p<0)){o=o.dot((new THREE.Vector3).sub(h,t))/
+p;t=t.addSelf(z.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(t,h,j,k)){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};E.push(g)}}else if(g instanceof THREE.Face4&&(d(t,h,j,m)||d(t,j,k,m))){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};E.push(g)}}}return E}};
+THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,o,p,t){k=!1;d=m;c=o;f=p;g=t;b()};this.addPoint=function(m,o){if(k){k=!1;d=m;c=o;f=m;g=o}else{d=d<m?d:m;c=c<o?c:o;f=f>m?f:m;g=g>o?g:o}b()};
+this.add3Points=function(m,o,p,t,z,u){if(k){k=!1;d=m<p?m<z?m:z:p<z?p:z;c=o<t?o<u?o:u:t<u?t:u;f=m>p?m>z?m:z:p>z?p:z;g=o>t?o>u?o:u:t>u?t:u}else{d=m<p?m<z?m<d?m:d:z<d?z:d:p<z?p<d?p:d:z<d?z:d;c=o<t?o<u?o<c?o:c:u<c?u:c:t<u?t<c?t:c:u<c?u:c;f=m>p?m>z?m>f?m:f:z>f?z:f:p>z?p>f?p:f:z>f?z:f;g=o>t?o>u?o>g?o:g:u>g?u:g:t>u?t>g?t:g:u>g?u:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=d<m.getLeft()?d:m.getLeft();c=c<m.getTop()?c:m.getTop();f=f>m.getRight()?
 f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}b()};this.inflate=function(m){d-=m;c-=m;f+=m;g+=m;b()};this.minSelf=function(m){d=d>m.getLeft()?d:m.getLeft();c=c>m.getTop()?c:m.getTop();f=f<m.getRight()?f:m.getRight();g=g<m.getBottom()?g:m.getBottom();b()};this.instersects=function(m){return Math.min(f,m.getRight())-Math.max(d,m.getLeft())>=0&&Math.min(g,m.getBottom())-Math.max(c,m.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};
-THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,p,o,u,y,t,B,F){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,p||0,o||1,u||0,y||0,t||0,B||0,F||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,p,o,u,y,t,B,F){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=p;this.n33=o;this.n34=u;this.n41=y;this.n42=t;this.n43=B;this.n44=F;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1,
+THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,o,p,t,z,u,A,E){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,o||0,p||1,t||0,z||0,u||0,A||0,E||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,o,p,t,z,u,A,E){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=o;this.n33=p;this.n34=t;this.n41=z;this.n42=u;this.n43=A;this.n44=E;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1,
 g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23*
 f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize();
-return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,t=b.n34,B=b.n41,F=b.n42,H=b.n43,G=b.n44,X=d.n11,A=d.n12,M=d.n13,Q=d.n14,R=d.n21,Da=d.n22,
-ma=d.n23,va=d.n24,ca=d.n31,e=d.n32,ea=d.n33,ya=d.n34;this.n11=c*X+f*R+g*ca;this.n12=c*A+f*Da+g*e;this.n13=c*M+f*ma+g*ea;this.n14=c*Q+f*va+g*ya+h;this.n21=j*X+k*R+m*ca;this.n22=j*A+k*Da+m*e;this.n23=j*M+k*ma+m*ea;this.n24=j*Q+k*va+m*ya+p;this.n31=o*X+u*R+y*ca;this.n32=o*A+u*Da+y*e;this.n33=o*M+u*ma+y*ea;this.n34=o*Q+u*va+y*ya+t;this.n41=B*X+F*R+H*ca;this.n42=B*A+F*Da+H*e;this.n43=B*M+F*ma+H*ea;this.n44=B*Q+F*va+H*ya+G;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]=
+return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,t=b.n32,z=b.n33,u=b.n34,A=b.n41,E=b.n42,H=b.n43,J=b.n44,W=d.n11,B=d.n12,U=d.n13,N=d.n14,O=d.n21,ua=d.n22,
+la=d.n23,pa=d.n24,ga=d.n31,ha=d.n32,e=d.n33,oa=d.n34;this.n11=c*W+f*O+g*ga;this.n12=c*B+f*ua+g*ha;this.n13=c*U+f*la+g*e;this.n14=c*N+f*pa+g*oa+h;this.n21=j*W+k*O+m*ga;this.n22=j*B+k*ua+m*ha;this.n23=j*U+k*la+m*e;this.n24=j*N+k*pa+m*oa+o;this.n31=p*W+t*O+z*ga;this.n32=p*B+t*ua+z*ha;this.n33=p*U+t*la+z*e;this.n34=p*N+t*pa+z*oa+u;this.n41=A*W+E*O+H*ga;this.n42=A*B+E*ua+H*ha;this.n43=A*U+E*la+H*e;this.n44=A*N+E*pa+H*oa+J;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]=
 this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=
-b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,p=this.n32,o=this.n33,u=this.n34,y=this.n41,t=this.n42,B=this.n43,F=this.n44;return f*j*p*y-c*k*p*y-f*h*o*y+d*k*o*y+c*h*u*y-d*j*u*y-f*j*m*t+c*k*m*t+f*g*o*t-b*k*o*t-c*g*u*t+b*j*u*t+f*h*m*B-d*k*m*B-f*g*p*B+b*k*p*B+d*g*u*B-b*h*u*B-c*h*m*F+d*j*m*F+c*g*p*F-b*j*p*F-d*g*o*F+b*h*o*F},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
+b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,o=this.n32,p=this.n33,t=this.n34,z=this.n41,u=this.n42,A=this.n43,E=this.n44;return f*j*o*z-c*k*o*z-f*h*p*z+d*k*p*z+c*h*t*z-d*j*t*z-f*j*m*u+c*k*m*u+f*g*p*u-b*k*p*u-c*g*t*u+b*j*t*u+f*h*m*A-d*k*m*A-f*g*o*A+b*k*o*A+d*g*t*A-b*h*t*A-c*h*m*E+d*j*m*E+c*g*o*E-b*j*o*E-d*g*p*E+b*h*p*E},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
 this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=
 this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;
 b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,
 0,1);return this},setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g=
-1-c,h=b.x,j=b.y,k=b.z,m=g*h,p=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,p*j+c,p*k-f*h,0,m*k-f*j,p*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+d*h;this.n33=
-b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var p=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(p+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+p);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this},extractPosition:function(b){this.n14=
+1-c,h=b.x,j=b.y,k=b.z,m=g*h,o=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,o*j+c,o*k-f*h,0,m*k-f*j,o*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+d*h;this.n33=
+b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var o=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(o+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+o);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this},extractPosition:function(b){this.n14=
 b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
-THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,t=b.n34,B=b.n41,F=b.n42,H=b.n43,G=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*t*F-p*y*F+p*u*H-k*t*H-m*u*G+k*y*G;d.n12=h*y*F-g*t*F-h*u*H+f*t*H+g*u*G-f*y*G;d.n13=g*p*F-h*m*F+h*k*H-f*p*H-g*k*G+f*m*G;d.n14=h*m*u-g*p*u-h*k*y+f*p*y+g*k*t-f*m*t;d.n21=p*y*B-m*t*B-p*o*H+j*t*H+m*o*G-j*y*G;d.n22=g*t*B-h*y*B+h*o*H-c*t*H-g*o*G+c*y*G;d.n23=h*m*B-g*p*B-h*j*H+c*p*H+g*j*G-c*m*G;
-d.n24=g*p*o-h*m*o+h*j*y-c*p*y-g*j*t+c*m*t;d.n31=k*t*B-p*u*B+p*o*F-j*t*F-k*o*G+j*u*G;d.n32=h*u*B-f*t*B-h*o*F+c*t*F+f*o*G-c*u*G;d.n33=g*p*B-h*k*B+h*j*F-c*p*F-f*j*G+c*k*G;d.n34=h*k*o-f*p*o-h*j*u+c*p*u+f*j*t-c*k*t;d.n41=m*u*B-k*y*B-m*o*F+j*y*F+k*o*H-j*u*H;d.n42=f*y*B-g*u*B+g*o*F-c*y*F-f*o*H+c*u*H;d.n43=g*k*B-f*m*B-g*j*F+c*m*F+f*j*H-c*k*H;d.n44=f*m*o-g*k*o+g*j*u-c*m*u-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d};
-THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*p;c[7]=b*o;c[8]=b*u;return d};
+THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,t=b.n32,z=b.n33,u=b.n34,A=b.n41,E=b.n42,H=b.n43,J=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*u*E-o*z*E+o*t*H-k*u*H-m*t*J+k*z*J;d.n12=h*z*E-g*u*E-h*t*H+f*u*H+g*t*J-f*z*J;d.n13=g*o*E-h*m*E+h*k*H-f*o*H-g*k*J+f*m*J;d.n14=h*m*t-g*o*t-h*k*z+f*o*z+g*k*u-f*m*u;d.n21=o*z*A-m*u*A-o*p*H+j*u*H+m*p*J-j*z*J;d.n22=g*u*A-h*z*A+h*p*H-c*u*H-g*p*J+c*z*J;d.n23=h*m*A-g*o*A-h*j*H+c*o*H+g*j*J-c*m*J;
+d.n24=g*o*p-h*m*p+h*j*z-c*o*z-g*j*u+c*m*u;d.n31=k*u*A-o*t*A+o*p*E-j*u*E-k*p*J+j*t*J;d.n32=h*t*A-f*u*A-h*p*E+c*u*E+f*p*J-c*t*J;d.n33=g*o*A-h*k*A+h*j*E-c*o*E-f*j*J+c*k*J;d.n34=h*k*p-f*o*p-h*j*t+c*o*t+f*j*u-c*k*u;d.n41=m*t*A-k*z*A-m*p*E+j*z*E+k*p*H-j*t*H;d.n42=f*z*A-g*t*A+g*p*E-c*z*E-f*p*H+c*t*H;d.n43=g*k*A-f*m*A-g*j*E+c*m*E+f*j*H-c*k*H;d.n44=f*m*p-g*k*p+g*j*t-c*m*t-f*j*z+c*k*z;d.multiplyScalar(1/b.determinant());return d};
+THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*o;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*o;c[7]=b*p;c[8]=b*t;return d};
 THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)};
-THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,p;j=new THREE.Matrix4;k=d-b;m=c-f;p=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((h+g)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,o;j=new THREE.Matrix4;k=d-b;m=c-f;o=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+g)/o);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
-THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(this.position,b,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
+THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
 undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d instanceof THREE.Scene===!1&&d!==undefined;)d=d.parent;d!==undefined&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(b,d,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,
 d,c)}};THREE.Quaternion=function(b,d,c,f){this.set(b||0,d||0,c||0,f!==undefined?f:1)};
-THREE.Quaternion.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,c=b.x*d,f=b.y*d,g=b.z*d;b=Math.cos(f);f=Math.sin(f);d=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var j=b*d,k=f*g;this.w=j*h-k*c;this.x=j*c+k*h;this.y=f*d*h+b*g*c;this.z=b*g*h-f*d*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,c=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=d*b+g*h+c*k-f*j;this.y=c*b+g*j+f*h-d*k;this.z=f*b+g*k+d*j-c*h;this.w=g*b-d*h-c*j-f*k;return this},
-multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,p=m*c+j*g-k*f,o=m*f+k*c-h*g,u=m*g+h*f-j*c;c=-h*c-j*f-k*g;d.x=p*m+c*-h+o*-k-u*-j;d.y=o*m+c*-j+u*-h-p*-k;d.z=u*m+c*-k+p*-j-o*-h;return d}};
-THREE.Quaternion.slerp=function(b,d,c,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010){c.w=0.5*(b.w+d.w);c.x=0.5*(b.x+d.x);c.y=0.5*(b.y+d.y);c.z=0.5*(b.z+d.z);return c}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=b.w*g+d.w*f;c.x=b.x*g+d.x*f;c.y=b.y*g+d.y*f;c.z=b.z*g+d.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,c=b.x*d,f=b.y*d,g=b.z*d;b=Math.cos(f);f=Math.sin(f);d=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var j=b*d,k=f*g;this.w=j*h-k*c;this.x=j*c+k*h;this.y=f*d*h+b*g*c;this.z=b*g*h-f*d*c;return this},setFromAxisAngle:function(b,d){var c=d/2,f=Math.sin(c);this.x=b.x*f;this.y=
+b.y*f;this.z=b.z*f;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},
+multiplySelf:function(b){var d=this.x,c=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=d*b+g*h+c*k-f*j;this.y=c*b+g*j+f*h-d*k;this.z=f*b+g*k+d*j-c*h;this.w=g*b-d*h-c*j-f*k;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,o=m*c+j*g-k*f,p=
+m*f+k*c-h*g,t=m*g+h*f-j*c;c=-h*c-j*f-k*g;d.x=o*m+c*-h+p*-k-t*-j;d.y=p*m+c*-j+t*-h-o*-k;d.z=t*m+c*-k+o*-j-p*-h;return d}};
+THREE.Quaternion.slerp=function(b,d,c,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001){c.w=0.5*(b.w+d.w);c.x=0.5*(b.x+d.x);c.y=0.5*(b.y+d.y);c.z=0.5*(b.z+d.z);return c}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=b.w*g+d.w*f;c.x=b.x*g+d.x*f;c.y=b.y*g+d.y*f;c.z=b.z*g+d.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,c,f,g,h){this.a=b;this.b=d;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,c,f,g,h,j){this.a=b;this.b=d;this.c=c;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -56,22 +57,22 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,c,f,g,h,j,k=new THREE.Vector3,m=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];if(b&&h.vertexNormals.length){k.set(0,0,0);d=0;for(c=h.vertexNormals.length;d<c;d++)k.addSelf(h.vertexNormals[d]);k.divideScalar(3)}else{d=this.vertices[h.a];c=this.vertices[h.b];j=this.vertices[h.c];k.sub(j.position,c.position);m.sub(d.position,c.position);k.crossSelf(m)}k.isZero()||
 k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var b,d,c,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)f[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=
 this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)f[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3){f[c.a].addSelf(c.normal);f[c.b].addSelf(c.normal);f[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){f[c.a].addSelf(c.normal);f[c.b].addSelf(c.normal);f[c.c].addSelf(c.normal);f[c.d].addSelf(c.normal)}}b=0;for(d=this.vertices.length;b<d;b++)f[b].normalize();b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(f[c.a]);
-c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(oa,pa,sa,ga,aa,na,Ea){k=oa.vertices[pa].position;m=oa.vertices[sa].position;p=oa.vertices[ga].position;o=j[aa];u=j[na];y=j[Ea];t=m.x-k.x;B=p.x-k.x;F=m.y-k.y;H=p.y-k.y;G=m.z-k.z;X=p.z-k.z;A=u.u-o.u;M=y.u-o.u;Q=u.v-o.v;R=y.v-o.v;Da=1/(A*
-R-M*Q);e.set((R*t-Q*B)*Da,(R*F-Q*H)*Da,(R*G-Q*X)*Da);ea.set((A*B-M*t)*Da,(A*H-M*F)*Da,(A*X-M*G)*Da);va[pa].addSelf(e);va[sa].addSelf(e);va[ga].addSelf(e);ca[pa].addSelf(ea);ca[sa].addSelf(ea);ca[ga].addSelf(ea)}var d,c,f,g,h,j,k,m,p,o,u,y,t,B,F,H,G,X,A,M,Q,R,Da,ma,va=[],ca=[],e=new THREE.Vector3,ea=new THREE.Vector3,ya=new THREE.Vector3,Ba=new THREE.Vector3,Fa=new THREE.Vector3;d=0;for(c=this.vertices.length;d<c;d++){va[d]=new THREE.Vector3;ca[d]=new THREE.Vector3}d=0;for(c=this.faces.length;d<c;d++){h=
-this.faces[d];j=this.faceVertexUvs[0][d];if(h instanceof THREE.Face3)b(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){b(this,h.a,h.b,h.c,0,1,2);b(this,h.a,h.b,h.d,0,1,3)}}var Z=["a","b","c","d"];d=0;for(c=this.faces.length;d<c;d++){h=this.faces[d];for(f=0;f<h.vertexNormals.length;f++){Fa.copy(h.vertexNormals[f]);g=h[Z[f]];ma=va[g];ya.copy(ma);ya.subSelf(Fa.multiplyScalar(Fa.dot(ma))).normalize();Ba.cross(h.vertexNormals[f],ma);g=Ba.dot(ca[g]);g=g<0?-1:1;h.vertexTangents[f]=new THREE.Vector4(ya.x,
-ya.y,ya.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;d<c;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
+c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(fa,va,sa,wa,ca,ja,ma){k=fa.vertices[va].position;m=fa.vertices[sa].position;o=fa.vertices[wa].position;p=j[ca];t=j[ja];z=j[ma];u=m.x-k.x;A=o.x-k.x;E=m.y-k.y;H=o.y-k.y;J=m.z-k.z;W=o.z-k.z;B=t.u-p.u;U=z.u-p.u;N=t.v-p.v;O=z.v-p.v;ua=1/(B*
+O-U*N);ha.set((O*u-N*A)*ua,(O*E-N*H)*ua,(O*J-N*W)*ua);e.set((B*A-U*u)*ua,(B*H-U*E)*ua,(B*W-U*J)*ua);pa[va].addSelf(ha);pa[sa].addSelf(ha);pa[wa].addSelf(ha);ga[va].addSelf(e);ga[sa].addSelf(e);ga[wa].addSelf(e)}var d,c,f,g,h,j,k,m,o,p,t,z,u,A,E,H,J,W,B,U,N,O,ua,la,pa=[],ga=[],ha=new THREE.Vector3,e=new THREE.Vector3,oa=new THREE.Vector3,Da=new THREE.Vector3,Aa=new THREE.Vector3;d=0;for(c=this.vertices.length;d<c;d++){pa[d]=new THREE.Vector3;ga[d]=new THREE.Vector3}d=0;for(c=this.faces.length;d<c;d++){h=
+this.faces[d];j=this.faceVertexUvs[0][d];if(h instanceof THREE.Face3)b(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){b(this,h.a,h.b,h.c,0,1,2);b(this,h.a,h.b,h.d,0,1,3)}}var ka=["a","b","c","d"];d=0;for(c=this.faces.length;d<c;d++){h=this.faces[d];for(f=0;f<h.vertexNormals.length;f++){Aa.copy(h.vertexNormals[f]);g=h[ka[f]];la=pa[g];oa.copy(la);oa.subSelf(Aa.multiplyScalar(Aa.dot(la))).normalize();Da.cross(h.vertexNormals[f],la);g=Da.dot(ga[g]);g=g<0?-1:1;h.vertexTangents[f]=new THREE.Vector4(oa.x,
+oa.y,oa.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;d<c;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
 if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;d<c;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere=
-{radius:b}},computeEdgeFaces:function(){function b(m,p){return Math.min(m,p)+"_"+Math.max(m,p)}function d(m,p,o){if(m[p]===undefined){m[p]={set:{},array:[]};m[p].set[o]=1;m[p].array.push(o)}else if(m[p].set[o]===undefined){m[p].set[o]=1;m[p].array.push(o)}}var c,f,g,h,j,k={};c=0;for(f=this.faces.length;c<f;c++){j=this.faces[c];if(j instanceof THREE.Face3){g=b(j.a,j.b);d(k,g,c);g=b(j.b,j.c);d(k,g,c);g=b(j.a,j.c);d(k,g,c)}else if(j instanceof THREE.Face4){g=b(j.b,j.d);d(k,g,c);g=b(j.a,j.b);d(k,g,c);
+{radius:b}},computeEdgeFaces:function(){function b(m,o){return Math.min(m,o)+"_"+Math.max(m,o)}function d(m,o,p){if(m[o]===undefined){m[o]={set:{},array:[]};m[o].set[p]=1;m[o].array.push(p)}else if(m[o].set[p]===undefined){m[o].set[p]=1;m[o].array.push(p)}}var c,f,g,h,j,k={};c=0;for(f=this.faces.length;c<f;c++){j=this.faces[c];if(j instanceof THREE.Face3){g=b(j.a,j.b);d(k,g,c);g=b(j.b,j.c);d(k,g,c);g=b(j.a,j.c);d(k,g,c)}else if(j instanceof THREE.Face4){g=b(j.b,j.d);d(k,g,c);g=b(j.a,j.b);d(k,g,c);
 g=b(j.a,j.d);d(k,g,c);g=b(j.b,j.c);d(k,g,c);g=b(j.c,j.d);d(k,g,c)}}c=0;for(f=this.edges.length;c<f;c++){j=this.edges[c];g=j.vertexIndices[0];h=j.vertexIndices[1];j.faceIndices=k[b(g,h)].array;for(g=0;g<j.faceIndices.length;g++){h=j.faceIndices[g];j.faces.push(this.faces[h])}}}};THREE.GeometryIdCounter=0;
-THREE.Spline=function(b){function d(t,B,F,H,G,X,A){t=(F-t)*0.5;H=(H-B)*0.5;return(2*(B-F)+t+H)*A+(-3*(B-F)-2*t-H)*X+t*G+B}this.points=b;var c=[],f={x:0,y:0,z:0},g,h,j,k,m,p,o,u,y;this.initFromArray=function(t){this.points=[];for(var B=0;B<t.length;B++)this.points[B]={x:t[B][0],y:t[B][1],z:t[B][2]}};this.getPoint=function(t){g=(this.points.length-1)*t;h=Math.floor(g);j=g-h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]];
-u=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(p.x,o.x,u.x,y.x,j,k,m);f.y=d(p.y,o.y,u.y,y.y,j,k,m);f.z=d(p.z,o.z,u.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var t,B,F=this.points.length,H=[];for(t=0;t<F;t++){B=this.points[t];H[t]=[B.x,B.y,B.z]}return H};this.getLength=function(t){var B,F,H=B=B=0,G=new THREE.Vector3,X=new THREE.Vector3,A=[],M=0;A[0]=0;t||(t=100);F=this.points.length*t;G.copy(this.points[0]);for(t=1;t<F;t++){B=t/F;position=this.getPoint(B);X.copy(position);
-M+=X.distanceTo(G);G.copy(position);B*=this.points.length-1;B=Math.floor(B);if(B!=H){A[B]=M;H=B}}A[A.length]=M;return{chunks:A,total:M}};this.reparametrizeByArcLength=function(t){var B,F,H,G,X,A,M=[],Q=new THREE.Vector3,R=this.getLength();M.push(Q.copy(this.points[0]).clone());for(B=1;B<this.points.length;B++){F=R.chunks[B]-R.chunks[B-1];A=Math.ceil(t*F/R.total);G=(B-1)/(this.points.length-1);X=B/(this.points.length-1);for(F=1;F<A-1;F++){H=G+F*(1/A)*(X-G);position=this.getPoint(H);M.push(Q.copy(position).clone())}M.push(Q.copy(this.points[B]).clone())}this.points=
-M}};THREE.Edge=function(b,d,c,f){this.vertices=[b,d];this.vertexIndices=[c,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,d,c,f,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=c||0.1;this.far=f||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
-THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(b,d,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);d=!0}else if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,c)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(b,d,c){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,d,c){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=d||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.LensFlare=function(b,d,c,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=undefined;b!==undefined&&this.add(b,d,c,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
+THREE.Spline=function(b){function d(u,A,E,H,J,W,B){u=(E-u)*0.5;H=(H-A)*0.5;return(2*(A-E)+u+H)*B+(-3*(A-E)-2*u-H)*W+u*J+A}this.points=b;var c=[],f={x:0,y:0,z:0},g,h,j,k,m,o,p,t,z;this.initFromArray=function(u){this.points=[];for(var A=0;A<u.length;A++)this.points[A]={x:u[A][0],y:u[A][1],z:u[A][2]}};this.getPoint=function(u){g=(this.points.length-1)*u;h=Math.floor(g);j=g-h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;o=this.points[c[0]];p=this.points[c[1]];
+t=this.points[c[2]];z=this.points[c[3]];k=j*j;m=j*k;f.x=d(o.x,p.x,t.x,z.x,j,k,m);f.y=d(o.y,p.y,t.y,z.y,j,k,m);f.z=d(o.z,p.z,t.z,z.z,j,k,m);return f};this.getControlPointsArray=function(){var u,A,E=this.points.length,H=[];for(u=0;u<E;u++){A=this.points[u];H[u]=[A.x,A.y,A.z]}return H};this.getLength=function(u){var A,E,H=A=A=0,J=new THREE.Vector3,W=new THREE.Vector3,B=[],U=0;B[0]=0;u||(u=100);E=this.points.length*u;J.copy(this.points[0]);for(u=1;u<E;u++){A=u/E;position=this.getPoint(A);W.copy(position);
+U+=W.distanceTo(J);J.copy(position);A*=this.points.length-1;A=Math.floor(A);if(A!=H){B[A]=U;H=A}}B[B.length]=U;return{chunks:B,total:U}};this.reparametrizeByArcLength=function(u){var A,E,H,J,W,B,U=[],N=new THREE.Vector3,O=this.getLength();U.push(N.copy(this.points[0]).clone());for(A=1;A<this.points.length;A++){E=O.chunks[A]-O.chunks[A-1];B=Math.ceil(u*E/O.total);J=(A-1)/(this.points.length-1);W=A/(this.points.length-1);for(E=1;E<B-1;E++){H=J+E*(1/B)*(W-J);position=this.getPoint(H);U.push(N.copy(position).clone())}U.push(N.copy(this.points[A]).clone())}this.points=
+U}};THREE.Edge=function(b,d,c,f){this.vertices=[b,d];this.vertexIndices=[c,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,d,c,f,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=c||0.1;this.far=f||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
+THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(b,d,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);d=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;d=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,c)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
+THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,d,c){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,d,c){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=d||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;
+THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.LensFlare=function(b,d,c,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=undefined;b!==undefined&&this.add(b,d,c,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
 THREE.LensFlare.prototype.add=function(b,d,c,f){d===undefined&&(d=-1);c===undefined&&(c=0);if(f===undefined)f=THREE.BillboardBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:b,size:d,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:f})};
 THREE.LensFlare.prototype.updateLensFlares=function(){var b,d=this.lensFlares.length,c,f=-this.positionScreen.x*2,g=-this.positionScreen.y*2;for(b=0;b<d;b++){c=this.lensFlares[b];c.x=this.positionScreen.x+f*c.distance;c.y=this.positionScreen.y+g*c.distance;c.wantedRotation=c.x*Math.PI*0.25;c.rotation+=(c.wantedRotation-c.rotation)*0.25}};
 THREE.Material=function(b){this.id=THREE.MaterialCounter.value++;b=b||{};this.opacity=b.opacity!==undefined?b.opacity:1;this.transparent=b.transparent!==undefined?b.transparent:!1;this.blending=b.blending!==undefined?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==undefined?b.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
@@ -120,13 +121,13 @@ THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=functi
 THREE.LOD.prototype.update=function(b,d,c){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}if(this.LODs.length>1){b=c.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f<this.LODs.length;f++)if(b>=this.LODs[f].visibleAtDistance){this.LODs[f-1].object3D.visible=
 !1;this.LODs[f].object3D.visible=!0}else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,c)};THREE.ShadowVolume=function(b,d){if(b instanceof THREE.Mesh){THREE.Mesh.call(this,b.geometry,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);b.addChild(this)}else THREE.Mesh.call(this,b,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);this.calculateShadowVolumeGeometry()};
 THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,c,f,g,h,j,k,m,p,o,u,y,t,B=new THREE.Geometry;B.vertices=this.geometry.vertices;f=B.faces=this.geometry.faces;var F=B.egdes=this.geometry.edges,H=B.edgeFaces=[];g=0;var G=[];b=0;for(d=f.length;b<d;b++){c=f[b];G.push(g);g+=c instanceof THREE.Face3?3:4;c.vertexNormals[0]=c.normal;c.vertexNormals[1]=c.normal;c.vertexNormals[2]=c.normal;if(c instanceof THREE.Face4)c.vertexNormals[3]=
-c.normal}b=0;for(d=F.length;b<d;b++){k=F[b];c=k.faces[0];f=k.faces[1];g=k.faceIndices[0];h=k.faceIndices[1];j=k.vertexIndices[0];k=k.vertexIndices[1];if(c.a===j){m="a";o=G[g]+0}else if(c.b===j){m="b";o=G[g]+1}else if(c.c===j){m="c";o=G[g]+2}else if(c.d===j){m="d";o=G[g]+3}if(c.a===k){m+="a";u=G[g]+0}else if(c.b===k){m+="b";u=G[g]+1}else if(c.c===k){m+="c";u=G[g]+2}else if(c.d===k){m+="d";u=G[g]+3}if(f.a===j){p="a";y=G[h]+0}else if(f.b===j){p="b";y=G[h]+1}else if(f.c===j){p="c";y=G[h]+2}else if(f.d===
-j){p="d";y=G[h]+3}if(f.a===k){p+="a";t=G[h]+0}else if(f.b===k){p+="b";t=G[h]+1}else if(f.c===k){p+="c";t=G[h]+2}else if(f.d===k){p+="d";t=G[h]+3}if(m==="ac"||m==="ad"||m==="ca"||m==="da"){if(o>u){c=o;o=u;u=c}}else if(o<u){c=o;o=u;u=c}if(p==="ac"||p==="ad"||p==="ca"||p==="da"){if(y>t){c=y;y=t;t=c}}else if(y<t){c=y;y=t;t=c}c=new THREE.Face4(o,u,y,t);c.normal.set(1,0,0);H.push(c)}this.geometry=B}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,c=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var h=g.length,j,k,m,p,o,u=["a","b","c","d"];for(m=0;m<h;m++){k=d.length;j=g[m];if(j instanceof THREE.Face4){p=4;k=new THREE.Face4(k,k+1,k+2,k+3)}else{p=3;k=new THREE.Face3(k,k+1,k+2)}k.normal.copy(j.normal);c.push(k);
-for(k=0;k<p;k++){o=b[j[u[k]]];d.push(new THREE.Vertex(o.position.clone()))}}for(h=0;h<g.length-1;h++){b=c[h];for(j=h+1;j<g.length;j++){k=c[j];k=this.facesShareEdge(d,b,k);if(k!==undefined){k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]);k.normal.set(1,0,0);f.push(k)}}}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,c){var f,g,h,j,k,m,p,o,u,y,t,B,F,H=0,G=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=c instanceof THREE.Face4?4:3;for(B=0;B<f;B++){h=d[G[B]];k=b[h];for(F=0;F<g;F++){j=c[G[F]];m=b[j];if(Math.abs(k.position.x-m.position.x)<1.0E-4&&Math.abs(k.position.y-m.position.y)<1.0E-4&&Math.abs(k.position.z-m.position.z)<1.0E-4){H++;if(H===1){p=k;o=m;u=h;y=j;t=G[B]}if(H===2){t+=G[B];return t==="ad"||t==="ac"?{faces:[d,c],vertices:[p,o,m,k],indices:[u,
-y,j,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,c],vertices:[p,k,m,o],indices:[u,h,j,y],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};
+THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,c,f,g,h,j,k,m,o,p,t,z,u,A=new THREE.Geometry;A.vertices=this.geometry.vertices;f=A.faces=this.geometry.faces;var E=A.egdes=this.geometry.edges,H=A.edgeFaces=[];g=0;var J=[];b=0;for(d=f.length;b<d;b++){c=f[b];J.push(g);g+=c instanceof THREE.Face3?3:4;c.vertexNormals[0]=c.normal;c.vertexNormals[1]=c.normal;c.vertexNormals[2]=c.normal;if(c instanceof THREE.Face4)c.vertexNormals[3]=
+c.normal}b=0;for(d=E.length;b<d;b++){k=E[b];c=k.faces[0];f=k.faces[1];g=k.faceIndices[0];h=k.faceIndices[1];j=k.vertexIndices[0];k=k.vertexIndices[1];if(c.a===j){m="a";p=J[g]+0}else if(c.b===j){m="b";p=J[g]+1}else if(c.c===j){m="c";p=J[g]+2}else if(c.d===j){m="d";p=J[g]+3}if(c.a===k){m+="a";t=J[g]+0}else if(c.b===k){m+="b";t=J[g]+1}else if(c.c===k){m+="c";t=J[g]+2}else if(c.d===k){m+="d";t=J[g]+3}if(f.a===j){o="a";z=J[h]+0}else if(f.b===j){o="b";z=J[h]+1}else if(f.c===j){o="c";z=J[h]+2}else if(f.d===
+j){o="d";z=J[h]+3}if(f.a===k){o+="a";u=J[h]+0}else if(f.b===k){o+="b";u=J[h]+1}else if(f.c===k){o+="c";u=J[h]+2}else if(f.d===k){o+="d";u=J[h]+3}if(m==="ac"||m==="ad"||m==="ca"||m==="da"){if(p>t){c=p;p=t;t=c}}else if(p<t){c=p;p=t;t=c}if(o==="ac"||o==="ad"||o==="ca"||o==="da"){if(z>u){c=z;z=u;u=c}}else if(z<u){c=z;z=u;u=c}c=new THREE.Face4(p,t,z,u);c.normal.set(1,0,0);H.push(c)}this.geometry=A}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
+THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,c=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var h=g.length,j,k,m,o,p,t=["a","b","c","d"];for(m=0;m<h;m++){k=d.length;j=g[m];if(j instanceof THREE.Face4){o=4;k=new THREE.Face4(k,k+1,k+2,k+3)}else{o=3;k=new THREE.Face3(k,k+1,k+2)}k.normal.copy(j.normal);c.push(k);
+for(k=0;k<o;k++){p=b[j[t[k]]];d.push(new THREE.Vertex(p.position.clone()))}}for(h=0;h<g.length-1;h++){b=c[h];for(j=h+1;j<g.length;j++){k=c[j];k=this.facesShareEdge(d,b,k);if(k!==undefined){k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]);k.normal.set(1,0,0);f.push(k)}}}};
+THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,c){var f,g,h,j,k,m,o,p,t,z,u,A,E,H=0,J=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=c instanceof THREE.Face4?4:3;for(A=0;A<f;A++){h=d[J[A]];k=b[h];for(E=0;E<g;E++){j=c[J[E]];m=b[j];if(Math.abs(k.position.x-m.position.x)<1.0E-4&&Math.abs(k.position.y-m.position.y)<1.0E-4&&Math.abs(k.position.z-m.position.z)<1.0E-4){H++;if(H===1){o=k;p=m;t=h;z=j;u=J[A]}if(H===2){u+=J[A];return u==="ad"||u==="ac"?{faces:[d,c],vertices:[o,p,m,k],indices:[t,
+z,j,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,c],vertices:[o,k,m,p],indices:[t,h,j,z],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};
 THREE.Sprite=function(b){THREE.Object3D.call(this);if(b.material!==undefined){this.material=b.material;this.map=undefined;this.blending=material.blending}else if(b.map!==undefined){this.map=b.map instanceof THREE.Texture?b.map:ImageUtils.loadTexture(b.map);this.material=undefined;this.blending=b.blending!==undefined?b.blending:THREE.NormalBlending}this.useScreenCoordinates=b.useScreenCoordinates!==undefined?b.useScreenCoordinates:!0;this.mergeWith3D=b.mergeWith3D!==undefined?b.mergeWith3D:!this.useScreenCoordinates;
 this.affectedByDistance=b.affectedByDistance!==undefined?b.affectedByDistance:!this.useScreenCoordinates;this.alignment=b.alignment instanceof THREE.Vector2?b.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.supr=THREE.Object3D.prototype;
 THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,this.scale.y)}this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
@@ -135,58 +136,58 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1){this.objects.push(b);this.__objectsAdded.push(b)}for(var d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};
 THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else if(b instanceof THREE.Sound){d=this.sounds.indexOf(b);d!==-1&&this.sounds.splice(d,1)}else if(!(b instanceof THREE.Camera)){d=this.objects.indexOf(b);if(d!==-1){this.objects.splice(d,1);this.__objectsRemoved.push(b)}}for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,c){this.color=new THREE.Color(b);this.near=d||1;this.far=c||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==undefined?d:2.5E-4};
-THREE.Projector=function(){function b(){var e=m[k]=m[k]||new THREE.RenderableVertex;k++;return e}function d(e,ea){return ea.z-e.z}function c(e,ea){var ya=0,Ba=1,Fa=e.z+e.w,Z=ea.z+ea.w,oa=-e.z+e.w,pa=-ea.z+ea.w;if(Fa>=0&&Z>=0&&oa>=0&&pa>=0)return!0;else if(Fa<0&&Z<0||oa<0&&pa<0)return!1;else{if(Fa<0)ya=Math.max(ya,Fa/(Fa-Z));else Z<0&&(Ba=Math.min(Ba,Fa/(Fa-Z)));if(oa<0)ya=Math.max(ya,oa/(oa-pa));else pa<0&&(Ba=Math.min(Ba,oa/(oa-pa)));if(Ba<ya)return!1;else{e.lerpSelf(ea,ya);ea.lerpSelf(e,1-Ba);return!0}}}
-var f,g,h=[],j,k,m=[],p,o,u=[],y,t=[],B,F,H=[],G,X,A=[],M=new THREE.Vector4,Q=new THREE.Vector4,R=new THREE.Matrix4,Da=new THREE.Matrix4,ma=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],va=new THREE.Vector4,ca=new THREE.Vector4;this.projectVector=function(e,ea){R.multiply(ea.projectionMatrix,ea.matrixWorldInverse);R.multiplyVector3(e);return e};this.unprojectVector=function(e,ea){R.multiply(ea.matrixWorld,THREE.Matrix4.makeInvert(ea.projectionMatrix));
-R.multiplyVector3(e);return e};this.projectObjects=function(e,ea,ya){ea=[];var Ba,Fa,Z;g=0;Fa=e.objects;e=0;for(Ba=Fa.length;e<Ba;e++){Z=Fa[e];var oa;if(!(oa=!Z.visible))if(oa=Z instanceof THREE.Mesh){a:{oa=void 0;for(var pa=Z.matrixWorld,sa=-Z.geometry.boundingSphere.radius*Math.max(Z.scale.x,Math.max(Z.scale.y,Z.scale.z)),ga=0;ga<6;ga++){oa=ma[ga].x*pa.n14+ma[ga].y*pa.n24+ma[ga].z*pa.n34+ma[ga].w;if(oa<=sa){oa=!1;break a}}oa=!0}oa=!oa}if(!oa){oa=h[g]=h[g]||new THREE.RenderableObject;g++;f=oa;M.copy(Z.position);
-R.multiplyVector3(M);f.object=Z;f.z=M.z;ea.push(f)}}ya&&ea.sort(d);return ea};this.projectScene=function(e,ea,ya){var Ba=[],Fa=ea.near,Z=ea.far,oa,pa,sa,ga,aa,na,Ea,ja,la,ua,Ra,Ya,Za,Na,T,P,N;X=F=y=o=0;ea.matrixAutoUpdate&&ea.updateMatrix();e.update(undefined,!1,ea);R.multiply(ea.projectionMatrix,ea.matrixWorldInverse);ma[0].set(R.n41-R.n11,R.n42-R.n12,R.n43-R.n13,R.n44-R.n14);ma[1].set(R.n41+R.n11,R.n42+R.n12,R.n43+R.n13,R.n44+R.n14);ma[2].set(R.n41+R.n21,R.n42+R.n22,R.n43+R.n23,R.n44+R.n24);ma[3].set(R.n41-
-R.n21,R.n42-R.n22,R.n43-R.n23,R.n44-R.n24);ma[4].set(R.n41-R.n31,R.n42-R.n32,R.n43-R.n33,R.n44-R.n34);ma[5].set(R.n41+R.n31,R.n42+R.n32,R.n43+R.n33,R.n44+R.n34);for(oa=0;oa<6;oa++){la=ma[oa];la.divideScalar(Math.sqrt(la.x*la.x+la.y*la.y+la.z*la.z))}la=this.projectObjects(e,ea,!0);e=0;for(oa=la.length;e<oa;e++){ua=la[e].object;if(ua.visible){Ra=ua.matrixWorld;Ya=ua.matrixRotationWorld;Za=ua.materials;Na=ua.overdraw;k=0;if(ua instanceof THREE.Mesh){T=ua.geometry;ga=T.vertices;P=T.faces;T=T.faceVertexUvs;
-pa=0;for(sa=ga.length;pa<sa;pa++){j=b();j.positionWorld.copy(ga[pa].position);Ra.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);R.multiplyVector4(j.positionScreen);j.positionScreen.x/=j.positionScreen.w;j.positionScreen.y/=j.positionScreen.w;j.visible=j.positionScreen.z>Fa&&j.positionScreen.z<Z}ga=0;for(pa=P.length;ga<pa;ga++){sa=P[ga];if(sa instanceof THREE.Face3){aa=m[sa.a];na=m[sa.b];Ea=m[sa.c];if(aa.visible&&na.visible&&Ea.visible&&(ua.doubleSided||ua.flipSided!=(Ea.positionScreen.x-
-aa.positionScreen.x)*(na.positionScreen.y-aa.positionScreen.y)-(Ea.positionScreen.y-aa.positionScreen.y)*(na.positionScreen.x-aa.positionScreen.x)<0)){ja=u[o]=u[o]||new THREE.RenderableFace3;o++;p=ja;p.v1.copy(aa);p.v2.copy(na);p.v3.copy(Ea)}else continue}else if(sa instanceof THREE.Face4){aa=m[sa.a];na=m[sa.b];Ea=m[sa.c];ja=m[sa.d];if(aa.visible&&na.visible&&Ea.visible&&ja.visible&&(ua.doubleSided||ua.flipSided!=((ja.positionScreen.x-aa.positionScreen.x)*(na.positionScreen.y-aa.positionScreen.y)-
-(ja.positionScreen.y-aa.positionScreen.y)*(na.positionScreen.x-aa.positionScreen.x)<0||(na.positionScreen.x-Ea.positionScreen.x)*(ja.positionScreen.y-Ea.positionScreen.y)-(na.positionScreen.y-Ea.positionScreen.y)*(ja.positionScreen.x-Ea.positionScreen.x)<0))){N=t[y]=t[y]||new THREE.RenderableFace4;y++;p=N;p.v1.copy(aa);p.v2.copy(na);p.v3.copy(Ea);p.v4.copy(ja)}else continue}p.normalWorld.copy(sa.normal);Ya.multiplyVector3(p.normalWorld);p.centroidWorld.copy(sa.centroid);Ra.multiplyVector3(p.centroidWorld);
-p.centroidScreen.copy(p.centroidWorld);R.multiplyVector3(p.centroidScreen);Ea=sa.vertexNormals;aa=0;for(na=Ea.length;aa<na;aa++){ja=p.vertexNormalsWorld[aa];ja.copy(Ea[aa]);Ya.multiplyVector3(ja)}aa=0;for(na=T.length;aa<na;aa++)if(N=T[aa][ga]){Ea=0;for(ja=N.length;Ea<ja;Ea++)p.uvs[aa][Ea]=N[Ea]}p.meshMaterials=Za;p.faceMaterials=sa.materials;p.overdraw=Na;p.z=p.centroidScreen.z;Ba.push(p)}}else if(ua instanceof THREE.Line){Da.multiply(R,Ra);ga=ua.geometry.vertices;aa=b();aa.positionScreen.copy(ga[0].position);
-Da.multiplyVector4(aa.positionScreen);pa=1;for(sa=ga.length;pa<sa;pa++){aa=b();aa.positionScreen.copy(ga[pa].position);Da.multiplyVector4(aa.positionScreen);na=m[k-2];va.copy(aa.positionScreen);ca.copy(na.positionScreen);if(c(va,ca)){va.multiplyScalar(1/va.w);ca.multiplyScalar(1/ca.w);Ra=H[F]=H[F]||new THREE.RenderableLine;F++;B=Ra;B.v1.positionScreen.copy(va);B.v2.positionScreen.copy(ca);B.z=Math.max(va.z,ca.z);B.materials=ua.materials;Ba.push(B)}}}else if(ua instanceof THREE.Particle){Q.set(ua.position.x,
-ua.position.y,ua.position.z,1);R.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){Ra=A[X]=A[X]||new THREE.RenderableParticle;X++;G=Ra;G.x=Q.x/Q.w;G.y=Q.y/Q.w;G.z=Q.z;G.rotation=ua.rotation.z;G.scale.x=ua.scale.x*Math.abs(G.x-(Q.x+ea.projectionMatrix.n11)/(Q.w+ea.projectionMatrix.n14));G.scale.y=ua.scale.y*Math.abs(G.y-(Q.y+ea.projectionMatrix.n22)/(Q.w+ea.projectionMatrix.n24));G.materials=ua.materials;Ba.push(G)}}}}ya&&Ba.sort(d);return Ba}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,p,o,u,y,t,B,F;b=d.projectScene(j,k);m=0;for(p=b.length;m<p;m++){y=b[m];if(y instanceof THREE.RenderableParticle){B=y.x*g+g;F=y.y*h+h;o=0;for(u=y.material.length;o<u;o++){t=y.material[o];if(t instanceof THREE.ParticleDOMMaterial){t=t.domElement;t.style.left=B+"px";t.style.top=F+"px"}}}}}};
-THREE.CanvasRenderer=function(){function b(ta){if(t!=ta)o.globalAlpha=t=ta}function d(ta){if(B!=ta){switch(ta){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}B=ta}}function c(ta){if(F!=ta)o.strokeStyle=F=ta}var f=null,g=new THREE.Projector,h=document.createElement("canvas"),j,k,m,p,o=h.getContext("2d"),u=new THREE.Color(0),y=0,t=1,B=0,
-F=null,H=null,G=null,X=null,A=null,M,Q,R,Da,ma=new THREE.RenderableVertex,va=new THREE.RenderableVertex,ca,e,ea,ya,Ba,Fa,Z,oa,pa,sa,ga,aa,na=new THREE.Color,Ea=new THREE.Color,ja=new THREE.Color,la=new THREE.Color,ua=new THREE.Color,Ra,Ya,Za,Na,T,P,N,Ca,Ka,n,C=new THREE.Rectangle,w=new THREE.Rectangle,x=new THREE.Rectangle,z=!1,J=new THREE.Color,K=new THREE.Color,I=new THREE.Color,S=new THREE.Color,D=new THREE.Vector3,O,L,$,V,xa,Ja,za=16;O=document.createElement("canvas");O.width=O.height=2;L=O.getContext("2d");
-L.fillStyle="rgba(0,0,0,1)";L.fillRect(0,0,2,2);$=L.getImageData(0,0,2,2);V=$.data;xa=document.createElement("canvas");xa.width=xa.height=za;Ja=xa.getContext("2d");Ja.translate(-za/2,-za/2);Ja.scale(za,za);za--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ta,Oa){j=ta;k=Oa;m=j/2;p=k/2;h.width=j;h.height=k;C.set(-m,-p,m,p);t=1;B=0;A=X=G=H=F=null};this.setClearColor=function(ta,Oa){u=ta;y=Oa};this.setClearColorHex=function(ta,Oa){u.setHex(ta);y=Oa};
-this.clear=function(){o.setTransform(1,0,0,-1,m,p);if(!w.isEmpty()){w.inflate(1);w.minSelf(C);if(u.hex==0&&y==0)o.clearRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());else{d(THREE.NormalBlending);b(1);o.fillStyle="rgba("+Math.floor(u.r*255)+","+Math.floor(u.g*255)+","+Math.floor(u.b*255)+","+y+")";o.fillRect(w.getX(),w.getY(),w.getWidth(),w.getHeight())}w.empty()}};this.render=function(ta,Oa){function Ga(W){var ia,ka,da,ra=W.lights;K.setRGB(0,0,0);I.setRGB(0,0,0);S.setRGB(0,0,0);W=0;for(ia=ra.length;W<
-ia;W++){ka=ra[W];da=ka.color;if(ka instanceof THREE.AmbientLight){K.r+=da.r;K.g+=da.g;K.b+=da.b}else if(ka instanceof THREE.DirectionalLight){I.r+=da.r;I.g+=da.g;I.b+=da.b}else if(ka instanceof THREE.PointLight){S.r+=da.r;S.g+=da.g;S.b+=da.b}}}function wa(W,ia,ka,da){var ra,qa,ha,Y,Ia=W.lights;W=0;for(ra=Ia.length;W<ra;W++){qa=Ia[W];ha=qa.color;if(qa instanceof THREE.DirectionalLight){Y=ka.dot(qa.position);if(!(Y<=0)){Y*=qa.intensity;da.r+=ha.r*Y;da.g+=ha.g*Y;da.b+=ha.b*Y}}else if(qa instanceof THREE.PointLight){Y=
-ka.dot(D.sub(qa.position,ia).normalize());if(!(Y<=0)){Y*=qa.distance==0?1:1-Math.min(ia.distanceTo(qa.position)/qa.distance,1);if(Y!=0){Y*=qa.intensity;da.r+=ha.r*Y;da.g+=ha.g*Y;da.b+=ha.b*Y}}}}}function Ha(W,ia,ka){b(ka.opacity);d(ka.blending);var da,ra,qa,ha,Y,Ia;if(ka instanceof THREE.ParticleBasicMaterial){if(ka.map){ha=ka.map.image;Y=ha.width>>1;Ia=ha.height>>1;ka=ia.scale.x*m;qa=ia.scale.y*p;da=ka*Y;ra=qa*Ia;x.set(W.x-da,W.y-ra,W.x+da,W.y+ra);if(C.instersects(x)){o.save();o.translate(W.x,W.y);
-o.rotate(-ia.rotation);o.scale(ka,-qa);o.translate(-Y,-Ia);o.drawImage(ha,0,0);o.restore()}}}else if(ka instanceof THREE.ParticleCanvasMaterial){da=ia.scale.x*m;ra=ia.scale.y*p;x.set(W.x-da,W.y-ra,W.x+da,W.y+ra);if(C.instersects(x)){c(ka.color.__styleString);qa=ka.color.__styleString;if(H!=qa)o.fillStyle=H=qa;o.save();o.translate(W.x,W.y);o.rotate(-ia.rotation);o.scale(da,ra);ka.program(o);o.restore()}}}function Ua(W,ia,ka,da){b(da.opacity);d(da.blending);o.beginPath();o.moveTo(W.positionScreen.x,
-W.positionScreen.y);o.lineTo(ia.positionScreen.x,ia.positionScreen.y);o.closePath();if(da instanceof THREE.LineBasicMaterial){na.__styleString=da.color.__styleString;W=da.linewidth;if(G!=W)o.lineWidth=G=W;W=da.linecap;if(X!=W)o.lineCap=X=W;W=da.linejoin;if(A!=W)o.lineJoin=A=W;c(na.__styleString);o.stroke();x.inflate(da.linewidth*2)}}function E(W,ia,ka,da,ra,qa,ha,Y,Ia){b(Y.opacity);d(Y.blending);ca=W.positionScreen.x;e=W.positionScreen.y;ea=ia.positionScreen.x;ya=ia.positionScreen.y;Ba=ka.positionScreen.x;
-Fa=ka.positionScreen.y;v(ca,e,ea,ya,Ba,Fa);if(Y instanceof THREE.MeshBasicMaterial)if(Y.map){if(Y.map.mapping instanceof THREE.UVMapping){Na=ha.uvs[0];Pa(ca,e,ea,ya,Ba,Fa,Y.map.image,Na[da].u,Na[da].v,Na[ra].u,Na[ra].v,Na[qa].u,Na[qa].v)}}else if(Y.envMap){if(Y.envMap.mapping instanceof THREE.SphericalReflectionMapping){W=Oa.matrixWorldInverse;D.copy(ha.vertexNormalsWorld[0]);T=(D.x*W.n11+D.y*W.n12+D.z*W.n13)*0.5+0.5;P=-(D.x*W.n21+D.y*W.n22+D.z*W.n23)*0.5+0.5;D.copy(ha.vertexNormalsWorld[1]);N=(D.x*
-W.n11+D.y*W.n12+D.z*W.n13)*0.5+0.5;Ca=-(D.x*W.n21+D.y*W.n22+D.z*W.n23)*0.5+0.5;D.copy(ha.vertexNormalsWorld[2]);Ka=(D.x*W.n11+D.y*W.n12+D.z*W.n13)*0.5+0.5;n=-(D.x*W.n21+D.y*W.n22+D.z*W.n23)*0.5+0.5;Pa(ca,e,ea,ya,Ba,Fa,Y.envMap.image,T,P,N,Ca,Ka,n)}}else Y.wireframe?db(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){if(Y.map.mapping instanceof THREE.UVMapping){Na=ha.uvs[0];
-Pa(ca,e,ea,ya,Ba,Fa,Y.map.image,Na[da].u,Na[da].v,Na[ra].u,Na[ra].v,Na[qa].u,Na[qa].v)}d(THREE.SubtractiveBlending)}if(z)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==3){Ea.r=ja.r=la.r=K.r;Ea.g=ja.g=la.g=K.g;Ea.b=ja.b=la.b=K.b;wa(Ia,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Ea);wa(Ia,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ja);wa(Ia,ha.v3.positionWorld,ha.vertexNormalsWorld[2],la);ua.r=(ja.r+la.r)*0.5;ua.g=(ja.g+la.g)*0.5;ua.b=(ja.b+la.b)*0.5;Za=hb(Ea,ja,la,
-ua);Pa(ca,e,ea,ya,Ba,Fa,Za,0,0,1,0,0,1)}else{J.r=K.r;J.g=K.g;J.b=K.b;wa(Ia,ha.centroidWorld,ha.normalWorld,J);na.r=Y.color.r*J.r;na.g=Y.color.g*J.g;na.b=Y.color.b*J.b;na.updateStyleString();Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}else Y.wireframe?db(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){Ra=Oa.near;Ya=Oa.far;Ea.r=
-Ea.g=Ea.b=1-eb(W.positionScreen.z,Ra,Ya);ja.r=ja.g=ja.b=1-eb(ia.positionScreen.z,Ra,Ya);la.r=la.g=la.b=1-eb(ka.positionScreen.z,Ra,Ya);ua.r=(ja.r+la.r)*0.5;ua.g=(ja.g+la.g)*0.5;ua.b=(ja.b+la.b)*0.5;Za=hb(Ea,ja,la,ua);Pa(ca,e,ea,ya,Ba,Fa,Za,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){na.r=$a(ha.normalWorld.x);na.g=$a(ha.normalWorld.y);na.b=$a(ha.normalWorld.z);na.updateStyleString();Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}}
-function fa(W,ia,ka,da,ra,qa,ha,Y,Ia){b(Y.opacity);d(Y.blending);if(Y.map||Y.envMap){E(W,ia,da,0,1,3,ha,Y,Ia);E(ra,ka,qa,1,2,3,ha,Y,Ia)}else{ca=W.positionScreen.x;e=W.positionScreen.y;ea=ia.positionScreen.x;ya=ia.positionScreen.y;Ba=ka.positionScreen.x;Fa=ka.positionScreen.y;Z=da.positionScreen.x;oa=da.positionScreen.y;pa=ra.positionScreen.x;sa=ra.positionScreen.y;ga=qa.positionScreen.x;aa=qa.positionScreen.y;if(Y instanceof THREE.MeshBasicMaterial){bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(Y.color.__styleString,
-Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString)}else if(Y instanceof THREE.MeshLambertMaterial)if(z)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==4){Ea.r=ja.r=la.r=ua.r=K.r;Ea.g=ja.g=la.g=ua.g=K.g;Ea.b=ja.b=la.b=ua.b=K.b;wa(Ia,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Ea);wa(Ia,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ja);wa(Ia,ha.v4.positionWorld,ha.vertexNormalsWorld[3],la);wa(Ia,ha.v3.positionWorld,ha.vertexNormalsWorld[2],
-ua);Za=hb(Ea,ja,la,ua);v(ca,e,ea,ya,Z,oa);Pa(ca,e,ea,ya,Z,oa,Za,0,0,1,0,0,1);v(pa,sa,Ba,Fa,ga,aa);Pa(pa,sa,Ba,Fa,ga,aa,Za,1,0,1,1,0,1)}else{J.r=K.r;J.g=K.g;J.b=K.b;wa(Ia,ha.centroidWorld,ha.normalWorld,J);na.r=Y.color.r*J.r;na.g=Y.color.g*J.g;na.b=Y.color.b*J.b;na.updateStyleString();bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}else{bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(Y.color.__styleString,Y.wireframeLinewidth,
-Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString)}else if(Y instanceof THREE.MeshNormalMaterial){na.r=$a(ha.normalWorld.x);na.g=$a(ha.normalWorld.y);na.b=$a(ha.normalWorld.z);na.updateStyleString();bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){Ra=Oa.near;Ya=Oa.far;Ea.r=Ea.g=Ea.b=1-eb(W.positionScreen.z,Ra,Ya);ja.r=ja.g=ja.b=1-eb(ia.positionScreen.z,
-Ra,Ya);la.r=la.g=la.b=1-eb(da.positionScreen.z,Ra,Ya);ua.r=ua.g=ua.b=1-eb(ka.positionScreen.z,Ra,Ya);Za=hb(Ea,ja,la,ua);v(ca,e,ea,ya,Z,oa);Pa(ca,e,ea,ya,Z,oa,Za,0,0,1,0,0,1);v(pa,sa,Ba,Fa,ga,aa);Pa(pa,sa,Ba,Fa,ga,aa,Za,1,0,1,1,0,1)}}}function v(W,ia,ka,da,ra,qa){o.beginPath();o.moveTo(W,ia);o.lineTo(ka,da);o.lineTo(ra,qa);o.lineTo(W,ia);o.closePath()}function bb(W,ia,ka,da,ra,qa,ha,Y){o.beginPath();o.moveTo(W,ia);o.lineTo(ka,da);o.lineTo(ra,qa);o.lineTo(ha,Y);o.lineTo(W,ia);o.closePath()}function db(W,
-ia,ka,da){if(G!=ia)o.lineWidth=G=ia;if(X!=ka)o.lineCap=X=ka;if(A!=da)o.lineJoin=A=da;c(W);o.stroke();x.inflate(ia*2)}function Ma(W){if(H!=W)o.fillStyle=H=W;o.fill()}function Pa(W,ia,ka,da,ra,qa,ha,Y,Ia,Va,Ta,ib,Wa){var fb,gb;fb=ha.width-1;gb=ha.height-1;Y*=fb;Ia*=gb;Va*=fb;Ta*=gb;ib*=fb;Wa*=gb;ka-=W;da-=ia;ra-=W;qa-=ia;Va-=Y;Ta-=Ia;ib-=Y;Wa-=Ia;fb=Va*Wa-ib*Ta;if(fb!=0){gb=1/fb;fb=(Wa*ka-Ta*ra)*gb;Ta=(Wa*da-Ta*qa)*gb;ka=(Va*ra-ib*ka)*gb;da=(Va*qa-ib*da)*gb;W=W-fb*Y-ka*Ia;ia=ia-Ta*Y-da*Ia;o.save();
-o.transform(fb,Ta,ka,da,W,ia);o.clip();o.drawImage(ha,0,0);o.restore()}}function hb(W,ia,ka,da){var ra=~~(W.r*255),qa=~~(W.g*255);W=~~(W.b*255);var ha=~~(ia.r*255),Y=~~(ia.g*255);ia=~~(ia.b*255);var Ia=~~(ka.r*255),Va=~~(ka.g*255);ka=~~(ka.b*255);var Ta=~~(da.r*255),ib=~~(da.g*255);da=~~(da.b*255);V[0]=ra<0?0:ra>255?255:ra;V[1]=qa<0?0:qa>255?255:qa;V[2]=W<0?0:W>255?255:W;V[4]=ha<0?0:ha>255?255:ha;V[5]=Y<0?0:Y>255?255:Y;V[6]=ia<0?0:ia>255?255:ia;V[8]=Ia<0?0:Ia>255?255:Ia;V[9]=Va<0?0:Va>255?255:Va;
-V[10]=ka<0?0:ka>255?255:ka;V[12]=Ta<0?0:Ta>255?255:Ta;V[13]=ib<0?0:ib>255?255:ib;V[14]=da<0?0:da>255?255:da;L.putImageData($,0,0);Ja.drawImage(O,0,0);return xa}function eb(W,ia,ka){W=(W-ia)/(ka-ia);return W*W*(3-2*W)}function $a(W){W=(W+1)*0.5;return W<0?0:W>1?1:W}function ab(W,ia){var ka=ia.x-W.x,da=ia.y-W.y,ra=1/Math.sqrt(ka*ka+da*da);ka*=ra;da*=ra;ia.x+=ka;ia.y+=da;W.x-=ka;W.y-=da}var La,cb,Aa,U,Qa,Sa,jb,Xa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,p);f=g.projectScene(ta,Oa,this.sortElements);
-(z=ta.lights.length>0)&&Ga(ta);La=0;for(cb=f.length;La<cb;La++){Aa=f[La];x.empty();if(Aa instanceof THREE.RenderableParticle){M=Aa;M.x*=m;M.y*=p;U=0;for(Qa=Aa.materials.length;U<Qa;){Xa=Aa.materials[U++];Xa.opacity!=0&&Ha(M,Aa,Xa,ta)}}else if(Aa instanceof THREE.RenderableLine){M=Aa.v1;Q=Aa.v2;M.positionScreen.x*=m;M.positionScreen.y*=p;Q.positionScreen.x*=m;Q.positionScreen.y*=p;x.addPoint(M.positionScreen.x,M.positionScreen.y);x.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(C.instersects(x)){U=
-0;for(Qa=Aa.materials.length;U<Qa;){Xa=Aa.materials[U++];Xa.opacity!=0&&Ua(M,Q,Aa,Xa,ta)}}}else if(Aa instanceof THREE.RenderableFace3){M=Aa.v1;Q=Aa.v2;R=Aa.v3;M.positionScreen.x*=m;M.positionScreen.y*=p;Q.positionScreen.x*=m;Q.positionScreen.y*=p;R.positionScreen.x*=m;R.positionScreen.y*=p;if(Aa.overdraw){ab(M.positionScreen,Q.positionScreen);ab(Q.positionScreen,R.positionScreen);ab(R.positionScreen,M.positionScreen)}x.add3Points(M.positionScreen.x,M.positionScreen.y,Q.positionScreen.x,Q.positionScreen.y,
-R.positionScreen.x,R.positionScreen.y);if(C.instersects(x)){U=0;for(Qa=Aa.meshMaterials.length;U<Qa;){Xa=Aa.meshMaterials[U++];if(Xa instanceof THREE.MeshFaceMaterial){Sa=0;for(jb=Aa.faceMaterials.length;Sa<jb;)(Xa=Aa.faceMaterials[Sa++])&&Xa.opacity!=0&&E(M,Q,R,0,1,2,Aa,Xa,ta)}else Xa.opacity!=0&&E(M,Q,R,0,1,2,Aa,Xa,ta)}}}else if(Aa instanceof THREE.RenderableFace4){M=Aa.v1;Q=Aa.v2;R=Aa.v3;Da=Aa.v4;M.positionScreen.x*=m;M.positionScreen.y*=p;Q.positionScreen.x*=m;Q.positionScreen.y*=p;R.positionScreen.x*=
-m;R.positionScreen.y*=p;Da.positionScreen.x*=m;Da.positionScreen.y*=p;ma.positionScreen.copy(Q.positionScreen);va.positionScreen.copy(Da.positionScreen);if(Aa.overdraw){ab(M.positionScreen,Q.positionScreen);ab(Q.positionScreen,Da.positionScreen);ab(Da.positionScreen,M.positionScreen);ab(R.positionScreen,ma.positionScreen);ab(R.positionScreen,va.positionScreen)}x.addPoint(M.positionScreen.x,M.positionScreen.y);x.addPoint(Q.positionScreen.x,Q.positionScreen.y);x.addPoint(R.positionScreen.x,R.positionScreen.y);
-x.addPoint(Da.positionScreen.x,Da.positionScreen.y);if(C.instersects(x)){U=0;for(Qa=Aa.meshMaterials.length;U<Qa;){Xa=Aa.meshMaterials[U++];if(Xa instanceof THREE.MeshFaceMaterial){Sa=0;for(jb=Aa.faceMaterials.length;Sa<jb;)(Xa=Aa.faceMaterials[Sa++])&&Xa.opacity!=0&&fa(M,Q,R,Da,ma,va,Aa,Xa,ta)}else Xa.opacity!=0&&fa(M,Q,R,Da,ma,va,Aa,Xa,ta)}}}w.addRectangle(x)}o.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function b(Z,oa,pa){var sa,ga,aa,na;sa=0;for(ga=Z.lights.length;sa<ga;sa++){aa=Z.lights[sa];if(aa instanceof THREE.DirectionalLight){na=oa.normalWorld.dot(aa.position)*aa.intensity;if(na>0){pa.r+=aa.color.r*na;pa.g+=aa.color.g*na;pa.b+=aa.color.b*na}}else if(aa instanceof THREE.PointLight){va.sub(aa.position,oa.centroidWorld);va.normalize();na=oa.normalWorld.dot(va)*aa.intensity;if(na>0){pa.r+=aa.color.r*na;pa.g+=aa.color.g*na;pa.b+=aa.color.b*na}}}}function d(Z,oa,pa,
-sa,ga,aa){ea=f(ya++);ea.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)A.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(X){M.r=Q.r;M.g=Q.g;M.b=Q.b;b(aa,sa,M);A.r=ga.color.r*M.r;A.g=ga.color.g*M.g;A.b=ga.color.b*M.b;A.updateStyleString()}else A.__styleString=ga.color.__styleString;else if(ga instanceof
-THREE.MeshDepthMaterial){ma=1-ga.__2near/(ga.__farPlusNear-sa.z*ga.__farMinusNear);A.setRGB(ma,ma,ma)}else ga instanceof THREE.MeshNormalMaterial&&A.setRGB(g(sa.normalWorld.x),g(sa.normalWorld.y),g(sa.normalWorld.z));ga.wireframe?ea.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):ea.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+
-ga.opacity);k.appendChild(ea)}function c(Z,oa,pa,sa,ga,aa,na){ea=f(ya++);ea.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)A.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(X){M.r=Q.r;M.g=Q.g;M.b=Q.b;b(na,ga,M);A.r=aa.color.r*M.r;A.g=aa.color.g*M.g;
-A.b=aa.color.b*M.b;A.updateStyleString()}else A.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){ma=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);A.setRGB(ma,ma,ma)}else aa instanceof THREE.MeshNormalMaterial&&A.setRGB(g(ga.normalWorld.x),g(ga.normalWorld.y),g(ga.normalWorld.z));aa.wireframe?ea.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+
-"; stroke-linejoin: "+aa.wireframeLinejoin):ea.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+aa.opacity);k.appendChild(ea)}function f(Z){if(ca[Z]==null){ca[Z]=document.createElementNS("http://www.w3.org/2000/svg","path");Fa==0&&ca[Z].setAttribute("shape-rendering","crispEdges")}return ca[Z]}function g(Z){return Z<0?Math.min((1+Z)*0.5,0.5):0.5+Math.min(Z*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,o,u,y,t,B,F,H=new THREE.Rectangle,
-G=new THREE.Rectangle,X=!1,A=new THREE.Color(16777215),M=new THREE.Color(16777215),Q=new THREE.Color(0),R=new THREE.Color(0),Da=new THREE.Color(0),ma,va=new THREE.Vector3,ca=[],e=[],ea,ya,Ba,Fa=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(Z){switch(Z){case "high":Fa=1;break;case "low":Fa=0}};this.setSize=function(Z,oa){m=Z;p=oa;o=m/2;u=p/2;k.setAttribute("viewBox",-o+" "+-u+" "+m+" "+p);k.setAttribute("width",m);k.setAttribute("height",p);
-H.set(-o,-u,o,u)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(Z,oa){var pa,sa,ga,aa,na,Ea,ja,la;this.autoClear&&this.clear();h=j.projectScene(Z,oa,this.sortElements);Ba=ya=0;if(X=Z.lights.length>0){ja=Z.lights;Q.setRGB(0,0,0);R.setRGB(0,0,0);Da.setRGB(0,0,0);pa=0;for(sa=ja.length;pa<sa;pa++){ga=ja[pa];aa=ga.color;if(ga instanceof THREE.AmbientLight){Q.r+=aa.r;Q.g+=aa.g;Q.b+=aa.b}else if(ga instanceof THREE.DirectionalLight){R.r+=aa.r;R.g+=
-aa.g;R.b+=aa.b}else if(ga instanceof THREE.PointLight){Da.r+=aa.r;Da.g+=aa.g;Da.b+=aa.b}}}pa=0;for(sa=h.length;pa<sa;pa++){ja=h[pa];G.empty();if(ja instanceof THREE.RenderableParticle){y=ja;y.x*=o;y.y*=-u;ga=0;for(aa=ja.materials.length;ga<aa;)ga++}else if(ja instanceof THREE.RenderableLine){y=ja.v1;t=ja.v2;y.positionScreen.x*=o;y.positionScreen.y*=-u;t.positionScreen.x*=o;t.positionScreen.y*=-u;G.addPoint(y.positionScreen.x,y.positionScreen.y);G.addPoint(t.positionScreen.x,t.positionScreen.y);if(H.instersects(G)){ga=
-0;for(aa=ja.materials.length;ga<aa;)if((la=ja.materials[ga++])&&la.opacity!=0){na=y;Ea=t;var ua=Ba++;if(e[ua]==null){e[ua]=document.createElementNS("http://www.w3.org/2000/svg","line");Fa==0&&e[ua].setAttribute("shape-rendering","crispEdges")}ea=e[ua];ea.setAttribute("x1",na.positionScreen.x);ea.setAttribute("y1",na.positionScreen.y);ea.setAttribute("x2",Ea.positionScreen.x);ea.setAttribute("y2",Ea.positionScreen.y);if(la instanceof THREE.LineBasicMaterial){A.__styleString=la.color.__styleString;
-ea.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+la.linewidth+"; stroke-opacity: "+la.opacity+"; stroke-linecap: "+la.linecap+"; stroke-linejoin: "+la.linejoin);k.appendChild(ea)}}}}else if(ja instanceof THREE.RenderableFace3){y=ja.v1;t=ja.v2;B=ja.v3;y.positionScreen.x*=o;y.positionScreen.y*=-u;t.positionScreen.x*=o;t.positionScreen.y*=-u;B.positionScreen.x*=o;B.positionScreen.y*=-u;G.addPoint(y.positionScreen.x,y.positionScreen.y);G.addPoint(t.positionScreen.x,t.positionScreen.y);
-G.addPoint(B.positionScreen.x,B.positionScreen.y);if(H.instersects(G)){ga=0;for(aa=ja.meshMaterials.length;ga<aa;){la=ja.meshMaterials[ga++];if(la instanceof THREE.MeshFaceMaterial){na=0;for(Ea=ja.faceMaterials.length;na<Ea;)(la=ja.faceMaterials[na++])&&la.opacity!=0&&d(y,t,B,ja,la,Z)}else la&&la.opacity!=0&&d(y,t,B,ja,la,Z)}}}else if(ja instanceof THREE.RenderableFace4){y=ja.v1;t=ja.v2;B=ja.v3;F=ja.v4;y.positionScreen.x*=o;y.positionScreen.y*=-u;t.positionScreen.x*=o;t.positionScreen.y*=-u;B.positionScreen.x*=
-o;B.positionScreen.y*=-u;F.positionScreen.x*=o;F.positionScreen.y*=-u;G.addPoint(y.positionScreen.x,y.positionScreen.y);G.addPoint(t.positionScreen.x,t.positionScreen.y);G.addPoint(B.positionScreen.x,B.positionScreen.y);G.addPoint(F.positionScreen.x,F.positionScreen.y);if(H.instersects(G)){ga=0;for(aa=ja.meshMaterials.length;ga<aa;){la=ja.meshMaterials[ga++];if(la instanceof THREE.MeshFaceMaterial){na=0;for(Ea=ja.faceMaterials.length;na<Ea;)(la=ja.faceMaterials[na++])&&la.opacity!=0&&c(y,t,B,F,ja,
-la,Z)}else la&&la.opacity!=0&&c(y,t,B,F,ja,la,Z)}}}}}};
+THREE.Projector=function(){function b(){var ha=m[k]=m[k]||new THREE.RenderableVertex;k++;return ha}function d(ha,e){return e.z-ha.z}function c(ha,e){var oa=0,Da=1,Aa=ha.z+ha.w,ka=e.z+e.w,fa=-ha.z+ha.w,va=-e.z+e.w;if(Aa>=0&&ka>=0&&fa>=0&&va>=0)return!0;else if(Aa<0&&ka<0||fa<0&&va<0)return!1;else{if(Aa<0)oa=Math.max(oa,Aa/(Aa-ka));else ka<0&&(Da=Math.min(Da,Aa/(Aa-ka)));if(fa<0)oa=Math.max(oa,fa/(fa-va));else va<0&&(Da=Math.min(Da,fa/(fa-va)));if(Da<oa)return!1;else{ha.lerpSelf(e,oa);e.lerpSelf(ha,
+1-Da);return!0}}}var f,g,h=[],j,k,m=[],o,p,t=[],z,u=[],A,E,H=[],J,W,B=[],U=new THREE.Vector4,N=new THREE.Vector4,O=new THREE.Matrix4,ua=new THREE.Matrix4,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],pa=new THREE.Vector4,ga=new THREE.Vector4;this.projectVector=function(ha,e){O.multiply(e.projectionMatrix,e.matrixWorldInverse);O.multiplyVector3(ha);return ha};this.unprojectVector=function(ha,e){O.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));
+O.multiplyVector3(ha);return ha};this.projectObjects=function(ha,e,oa){e=[];var Da,Aa,ka;g=0;Aa=ha.objects;ha=0;for(Da=Aa.length;ha<Da;ha++){ka=Aa[ha];var fa;if(!(fa=!ka.visible))if(fa=ka instanceof THREE.Mesh){a:{fa=void 0;for(var va=ka.matrixWorld,sa=-ka.geometry.boundingSphere.radius*Math.max(ka.scale.x,Math.max(ka.scale.y,ka.scale.z)),wa=0;wa<6;wa++){fa=la[wa].x*va.n14+la[wa].y*va.n24+la[wa].z*va.n34+la[wa].w;if(fa<=sa){fa=!1;break a}}fa=!0}fa=!fa}if(!fa){fa=h[g]=h[g]||new THREE.RenderableObject;
+g++;f=fa;U.copy(ka.position);O.multiplyVector3(U);f.object=ka;f.z=U.z;e.push(f)}}oa&&e.sort(d);return e};this.projectScene=function(ha,e,oa){var Da=[],Aa=e.near,ka=e.far,fa,va,sa,wa,ca,ja,ma,Fa,ia,da,Ja,Xa,Za,Ta,R,S,P;W=E=z=p=0;e.matrixAutoUpdate&&e.update(undefined,!0);ha.update(undefined,!1,e);O.multiply(e.projectionMatrix,e.matrixWorldInverse);la[0].set(O.n41-O.n11,O.n42-O.n12,O.n43-O.n13,O.n44-O.n14);la[1].set(O.n41+O.n11,O.n42+O.n12,O.n43+O.n13,O.n44+O.n14);la[2].set(O.n41+O.n21,O.n42+O.n22,
+O.n43+O.n23,O.n44+O.n24);la[3].set(O.n41-O.n21,O.n42-O.n22,O.n43-O.n23,O.n44-O.n24);la[4].set(O.n41-O.n31,O.n42-O.n32,O.n43-O.n33,O.n44-O.n34);la[5].set(O.n41+O.n31,O.n42+O.n32,O.n43+O.n33,O.n44+O.n34);for(fa=0;fa<6;fa++){ia=la[fa];ia.divideScalar(Math.sqrt(ia.x*ia.x+ia.y*ia.y+ia.z*ia.z))}ia=this.projectObjects(ha,e,!0);ha=0;for(fa=ia.length;ha<fa;ha++){da=ia[ha].object;if(da.visible){Ja=da.matrixWorld;Xa=da.matrixRotationWorld;Za=da.materials;Ta=da.overdraw;k=0;if(da instanceof THREE.Mesh){R=da.geometry;
+wa=R.vertices;S=R.faces;R=R.faceVertexUvs;va=0;for(sa=wa.length;va<sa;va++){j=b();j.positionWorld.copy(wa[va].position);Ja.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);O.multiplyVector4(j.positionScreen);j.positionScreen.x/=j.positionScreen.w;j.positionScreen.y/=j.positionScreen.w;j.visible=j.positionScreen.z>Aa&&j.positionScreen.z<ka}wa=0;for(va=S.length;wa<va;wa++){sa=S[wa];if(sa instanceof THREE.Face3){ca=m[sa.a];ja=m[sa.b];ma=m[sa.c];if(ca.visible&&ja.visible&&ma.visible&&
+(da.doubleSided||da.flipSided!=(ma.positionScreen.x-ca.positionScreen.x)*(ja.positionScreen.y-ca.positionScreen.y)-(ma.positionScreen.y-ca.positionScreen.y)*(ja.positionScreen.x-ca.positionScreen.x)<0)){Fa=t[p]=t[p]||new THREE.RenderableFace3;p++;o=Fa;o.v1.copy(ca);o.v2.copy(ja);o.v3.copy(ma)}else continue}else if(sa instanceof THREE.Face4){ca=m[sa.a];ja=m[sa.b];ma=m[sa.c];Fa=m[sa.d];if(ca.visible&&ja.visible&&ma.visible&&Fa.visible&&(da.doubleSided||da.flipSided!=((Fa.positionScreen.x-ca.positionScreen.x)*
+(ja.positionScreen.y-ca.positionScreen.y)-(Fa.positionScreen.y-ca.positionScreen.y)*(ja.positionScreen.x-ca.positionScreen.x)<0||(ja.positionScreen.x-ma.positionScreen.x)*(Fa.positionScreen.y-ma.positionScreen.y)-(ja.positionScreen.y-ma.positionScreen.y)*(Fa.positionScreen.x-ma.positionScreen.x)<0))){P=u[z]=u[z]||new THREE.RenderableFace4;z++;o=P;o.v1.copy(ca);o.v2.copy(ja);o.v3.copy(ma);o.v4.copy(Fa)}else continue}o.normalWorld.copy(sa.normal);Xa.multiplyVector3(o.normalWorld);o.centroidWorld.copy(sa.centroid);
+Ja.multiplyVector3(o.centroidWorld);o.centroidScreen.copy(o.centroidWorld);O.multiplyVector3(o.centroidScreen);ma=sa.vertexNormals;ca=0;for(ja=ma.length;ca<ja;ca++){Fa=o.vertexNormalsWorld[ca];Fa.copy(ma[ca]);Xa.multiplyVector3(Fa)}ca=0;for(ja=R.length;ca<ja;ca++)if(P=R[ca][wa]){ma=0;for(Fa=P.length;ma<Fa;ma++)o.uvs[ca][ma]=P[ma]}o.meshMaterials=Za;o.faceMaterials=sa.materials;o.overdraw=Ta;o.z=o.centroidScreen.z;Da.push(o)}}else if(da instanceof THREE.Line){ua.multiply(O,Ja);wa=da.geometry.vertices;
+ca=b();ca.positionScreen.copy(wa[0].position);ua.multiplyVector4(ca.positionScreen);va=1;for(sa=wa.length;va<sa;va++){ca=b();ca.positionScreen.copy(wa[va].position);ua.multiplyVector4(ca.positionScreen);ja=m[k-2];pa.copy(ca.positionScreen);ga.copy(ja.positionScreen);if(c(pa,ga)){pa.multiplyScalar(1/pa.w);ga.multiplyScalar(1/ga.w);Ja=H[E]=H[E]||new THREE.RenderableLine;E++;A=Ja;A.v1.positionScreen.copy(pa);A.v2.positionScreen.copy(ga);A.z=Math.max(pa.z,ga.z);A.materials=da.materials;Da.push(A)}}}else if(da instanceof
+THREE.Particle){N.set(da.position.x,da.position.y,da.position.z,1);O.multiplyVector4(N);N.z/=N.w;if(N.z>0&&N.z<1){Ja=B[W]=B[W]||new THREE.RenderableParticle;W++;J=Ja;J.x=N.x/N.w;J.y=N.y/N.w;J.z=N.z;J.rotation=da.rotation.z;J.scale.x=da.scale.x*Math.abs(J.x-(N.x+e.projectionMatrix.n11)/(N.w+e.projectionMatrix.n14));J.scale.y=da.scale.y*Math.abs(J.y-(N.y+e.projectionMatrix.n22)/(N.w+e.projectionMatrix.n24));J.materials=da.materials;Da.push(J)}}}}oa&&Da.sort(d);return Da}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,o,p,t,z,u,A,E;b=d.projectScene(j,k);m=0;for(o=b.length;m<o;m++){z=b[m];if(z instanceof THREE.RenderableParticle){A=z.x*g+g;E=z.y*h+h;p=0;for(t=z.material.length;p<t;p++){u=z.material[p];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=A+"px";u.style.top=E+"px"}}}}}};
+THREE.CanvasRenderer=function(){function b(Ga){if(A!=Ga)t.globalAlpha=A=Ga}function d(Ga){if(E!=Ga){switch(Ga){case THREE.NormalBlending:t.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:t.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:t.globalCompositeOperation="darker"}E=Ga}}function c(Ga){if(H!=Ga)t.strokeStyle=H=Ga}var f=this,g=null,h=new THREE.Projector,j=document.createElement("canvas"),k,m,o,p,t=j.getContext("2d"),z=new THREE.Color(0),u=0,A=
+1,E=0,H=null,J=null,W=null,B=null,U=null,N,O,ua,la,pa=new THREE.RenderableVertex,ga=new THREE.RenderableVertex,ha,e,oa,Da,Aa,ka,fa,va,sa,wa,ca,ja,ma=new THREE.Color,Fa=new THREE.Color,ia=new THREE.Color,da=new THREE.Color,Ja=new THREE.Color,Xa,Za,Ta,R,S,P,Ba,La,n,C,w=new THREE.Rectangle,x=new THREE.Rectangle,y=new THREE.Rectangle,Q=!1,K=new THREE.Color,F=new THREE.Color,T=new THREE.Color,G=new THREE.Color,I=new THREE.Vector3,L,Z,Y,qa,Ka,Ca,Ha=16;L=document.createElement("canvas");L.width=L.height=
+2;Z=L.getContext("2d");Z.fillStyle="rgba(0,0,0,1)";Z.fillRect(0,0,2,2);Y=Z.getImageData(0,0,2,2);qa=Y.data;Ka=document.createElement("canvas");Ka.width=Ka.height=Ha;Ca=Ka.getContext("2d");Ca.translate(-Ha/2,-Ha/2);Ca.scale(Ha,Ha);Ha--;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setSize=function(Ga,xa){k=Ga;m=xa;o=k/2;p=m/2;j.width=k;j.height=m;w.set(-o,-p,o,p);A=1;E=0;U=B=W=J=H=null};this.setClearColor=function(Ga,xa){z=Ga;u=xa};
+this.setClearColorHex=function(Ga,xa){z.setHex(Ga);u=xa};this.clear=function(){t.setTransform(1,0,0,-1,o,p);if(!x.isEmpty()){x.inflate(1);x.minSelf(w);if(z.hex==0&&u==0)t.clearRect(x.getX(),x.getY(),x.getWidth(),x.getHeight());else{d(THREE.NormalBlending);b(1);t.fillStyle="rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b*255)+","+u+")";t.fillRect(x.getX(),x.getY(),x.getWidth(),x.getHeight())}x.empty()}};this.render=function(Ga,xa){function Ea(V){var na,ea,$,ta=V.lights;F.setRGB(0,
+0,0);T.setRGB(0,0,0);G.setRGB(0,0,0);V=0;for(na=ta.length;V<na;V++){ea=ta[V];$=ea.color;if(ea instanceof THREE.AmbientLight){F.r+=$.r;F.g+=$.g;F.b+=$.b}else if(ea instanceof THREE.DirectionalLight){T.r+=$.r;T.g+=$.g;T.b+=$.b}else if(ea instanceof THREE.PointLight){G.r+=$.r;G.g+=$.g;G.b+=$.b}}}function za(V,na,ea,$){var ta,ra,ya,X,Ia=V.lights;V=0;for(ta=Ia.length;V<ta;V++){ra=Ia[V];ya=ra.color;if(ra instanceof THREE.DirectionalLight){X=ea.dot(ra.position);if(!(X<=0)){X*=ra.intensity;$.r+=ya.r*X;$.g+=
+ya.g*X;$.b+=ya.b*X}}else if(ra instanceof THREE.PointLight){X=ea.dot(I.sub(ra.position,na).normalize());if(!(X<=0)){X*=ra.distance==0?1:1-Math.min(na.distanceTo(ra.position)/ra.distance,1);if(X!=0){X*=ra.intensity;$.r+=ya.r*X;$.g+=ya.g*X;$.b+=ya.b*X}}}}}function Ua(V,na,ea){b(ea.opacity);d(ea.blending);var $,ta,ra,ya,X,Ia;if(ea instanceof THREE.ParticleBasicMaterial){if(ea.map){ya=ea.map.image;X=ya.width>>1;Ia=ya.height>>1;ea=na.scale.x*o;ra=na.scale.y*p;$=ea*X;ta=ra*Ia;y.set(V.x-$,V.y-ta,V.x+$,V.y+
+ta);if(w.instersects(y)){t.save();t.translate(V.x,V.y);t.rotate(-na.rotation);t.scale(ea,-ra);t.translate(-X,-Ia);t.drawImage(ya,0,0);t.restore()}}}else if(ea instanceof THREE.ParticleCanvasMaterial){$=na.scale.x*o;ta=na.scale.y*p;y.set(V.x-$,V.y-ta,V.x+$,V.y+ta);if(w.instersects(y)){c(ea.color.__styleString);ra=ea.color.__styleString;if(J!=ra)t.fillStyle=J=ra;t.save();t.translate(V.x,V.y);t.rotate(-na.rotation);t.scale($,ta);ea.program(t);t.restore()}}}function D(V,na,ea,$){b($.opacity);d($.blending);
+t.beginPath();t.moveTo(V.positionScreen.x,V.positionScreen.y);t.lineTo(na.positionScreen.x,na.positionScreen.y);t.closePath();if($ instanceof THREE.LineBasicMaterial){ma.__styleString=$.color.__styleString;V=$.linewidth;if(W!=V)t.lineWidth=W=V;V=$.linecap;if(B!=V)t.lineCap=B=V;V=$.linejoin;if(U!=V)t.lineJoin=U=V;c(ma.__styleString);t.stroke();y.inflate($.linewidth*2)}}function aa(V,na,ea,$,ta,ra,ya,X,Ia){f.data.vertices+=3;f.data.faces++;b(X.opacity);d(X.blending);ha=V.positionScreen.x;e=V.positionScreen.y;
+oa=na.positionScreen.x;Da=na.positionScreen.y;Aa=ea.positionScreen.x;ka=ea.positionScreen.y;ab(ha,e,oa,Da,Aa,ka);if(X instanceof THREE.MeshBasicMaterial)if(X.map){if(X.map.mapping instanceof THREE.UVMapping){R=ya.uvs[0];cb(ha,e,oa,Da,Aa,ka,X.map.image,R[$].u,R[$].v,R[ta].u,R[ta].v,R[ra].u,R[ra].v)}}else if(X.envMap){if(X.envMap.mapping instanceof THREE.SphericalReflectionMapping){V=xa.matrixWorldInverse;I.copy(ya.vertexNormalsWorld[0]);S=(I.x*V.n11+I.y*V.n12+I.z*V.n13)*0.5+0.5;P=-(I.x*V.n21+I.y*V.n22+
+I.z*V.n23)*0.5+0.5;I.copy(ya.vertexNormalsWorld[1]);Ba=(I.x*V.n11+I.y*V.n12+I.z*V.n13)*0.5+0.5;La=-(I.x*V.n21+I.y*V.n22+I.z*V.n23)*0.5+0.5;I.copy(ya.vertexNormalsWorld[2]);n=(I.x*V.n11+I.y*V.n12+I.z*V.n13)*0.5+0.5;C=-(I.x*V.n21+I.y*V.n22+I.z*V.n23)*0.5+0.5;cb(ha,e,oa,Da,Aa,ka,X.envMap.image,S,P,Ba,La,n,C)}}else X.wireframe?Oa(X.color.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(X.color.__styleString);else if(X instanceof THREE.MeshLambertMaterial){if(X.map&&!X.wireframe){if(X.map.mapping instanceof
+THREE.UVMapping){R=ya.uvs[0];cb(ha,e,oa,Da,Aa,ka,X.map.image,R[$].u,R[$].v,R[ta].u,R[ta].v,R[ra].u,R[ra].v)}d(THREE.SubtractiveBlending)}if(Q)if(!X.wireframe&&X.shading==THREE.SmoothShading&&ya.vertexNormalsWorld.length==3){Fa.r=ia.r=da.r=F.r;Fa.g=ia.g=da.g=F.g;Fa.b=ia.b=da.b=F.b;za(Ia,ya.v1.positionWorld,ya.vertexNormalsWorld[0],Fa);za(Ia,ya.v2.positionWorld,ya.vertexNormalsWorld[1],ia);za(Ia,ya.v3.positionWorld,ya.vertexNormalsWorld[2],da);Ja.r=(ia.r+da.r)*0.5;Ja.g=(ia.g+da.g)*0.5;Ja.b=(ia.b+da.b)*
+0.5;Ta=hb(Fa,ia,da,Ja);cb(ha,e,oa,Da,Aa,ka,Ta,0,0,1,0,0,1)}else{K.r=F.r;K.g=F.g;K.b=F.b;za(Ia,ya.centroidWorld,ya.normalWorld,K);ma.r=X.color.r*K.r;ma.g=X.color.g*K.g;ma.b=X.color.b*K.b;ma.updateStyleString();X.wireframe?Oa(ma.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(ma.__styleString)}else X.wireframe?Oa(X.color.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){Xa=
+xa.near;Za=xa.far;Fa.r=Fa.g=Fa.b=1-Wa(V.positionScreen.z,Xa,Za);ia.r=ia.g=ia.b=1-Wa(na.positionScreen.z,Xa,Za);da.r=da.g=da.b=1-Wa(ea.positionScreen.z,Xa,Za);Ja.r=(ia.r+da.r)*0.5;Ja.g=(ia.g+da.g)*0.5;Ja.b=(ia.b+da.b)*0.5;Ta=hb(Fa,ia,da,Ja);cb(ha,e,oa,Da,Aa,ka,Ta,0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){ma.r=$a(ya.normalWorld.x);ma.g=$a(ya.normalWorld.y);ma.b=$a(ya.normalWorld.z);ma.updateStyleString();X.wireframe?Oa(ma.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):
+Qa(ma.__styleString)}}function v(V,na,ea,$,ta,ra,ya,X,Ia){f.data.vertices+=4;f.data.faces++;b(X.opacity);d(X.blending);if(X.map||X.envMap){aa(V,na,$,0,1,3,ya,X,Ia);aa(ta,ea,ra,1,2,3,ya,X,Ia)}else{ha=V.positionScreen.x;e=V.positionScreen.y;oa=na.positionScreen.x;Da=na.positionScreen.y;Aa=ea.positionScreen.x;ka=ea.positionScreen.y;fa=$.positionScreen.x;va=$.positionScreen.y;sa=ta.positionScreen.x;wa=ta.positionScreen.y;ca=ra.positionScreen.x;ja=ra.positionScreen.y;if(X instanceof THREE.MeshBasicMaterial){fb(ha,
+e,oa,Da,Aa,ka,fa,va);X.wireframe?Oa(X.color.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(X.color.__styleString)}else if(X instanceof THREE.MeshLambertMaterial)if(Q)if(!X.wireframe&&X.shading==THREE.SmoothShading&&ya.vertexNormalsWorld.length==4){Fa.r=ia.r=da.r=Ja.r=F.r;Fa.g=ia.g=da.g=Ja.g=F.g;Fa.b=ia.b=da.b=Ja.b=F.b;za(Ia,ya.v1.positionWorld,ya.vertexNormalsWorld[0],Fa);za(Ia,ya.v2.positionWorld,ya.vertexNormalsWorld[1],ia);za(Ia,ya.v4.positionWorld,ya.vertexNormalsWorld[3],
+da);za(Ia,ya.v3.positionWorld,ya.vertexNormalsWorld[2],Ja);Ta=hb(Fa,ia,da,Ja);ab(ha,e,oa,Da,fa,va);cb(ha,e,oa,Da,fa,va,Ta,0,0,1,0,0,1);ab(sa,wa,Aa,ka,ca,ja);cb(sa,wa,Aa,ka,ca,ja,Ta,1,0,1,1,0,1)}else{K.r=F.r;K.g=F.g;K.b=F.b;za(Ia,ya.centroidWorld,ya.normalWorld,K);ma.r=X.color.r*K.r;ma.g=X.color.g*K.g;ma.b=X.color.b*K.b;ma.updateStyleString();fb(ha,e,oa,Da,Aa,ka,fa,va);X.wireframe?Oa(ma.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(ma.__styleString)}else{fb(ha,e,oa,
+Da,Aa,ka,fa,va);X.wireframe?Oa(X.color.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(X.color.__styleString)}else if(X instanceof THREE.MeshNormalMaterial){ma.r=$a(ya.normalWorld.x);ma.g=$a(ya.normalWorld.y);ma.b=$a(ya.normalWorld.z);ma.updateStyleString();fb(ha,e,oa,Da,Aa,ka,fa,va);X.wireframe?Oa(ma.__styleString,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):Qa(ma.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){Xa=xa.near;Za=xa.far;Fa.r=
+Fa.g=Fa.b=1-Wa(V.positionScreen.z,Xa,Za);ia.r=ia.g=ia.b=1-Wa(na.positionScreen.z,Xa,Za);da.r=da.g=da.b=1-Wa($.positionScreen.z,Xa,Za);Ja.r=Ja.g=Ja.b=1-Wa(ea.positionScreen.z,Xa,Za);Ta=hb(Fa,ia,da,Ja);ab(ha,e,oa,Da,fa,va);cb(ha,e,oa,Da,fa,va,Ta,0,0,1,0,0,1);ab(sa,wa,Aa,ka,ca,ja);cb(sa,wa,Aa,ka,ca,ja,Ta,1,0,1,1,0,1)}}}function ab(V,na,ea,$,ta,ra){t.beginPath();t.moveTo(V,na);t.lineTo(ea,$);t.lineTo(ta,ra);t.lineTo(V,na);t.closePath()}function fb(V,na,ea,$,ta,ra,ya,X){t.beginPath();t.moveTo(V,na);t.lineTo(ea,
+$);t.lineTo(ta,ra);t.lineTo(ya,X);t.lineTo(V,na);t.closePath()}function Oa(V,na,ea,$){if(W!=na)t.lineWidth=W=na;if(B!=ea)t.lineCap=B=ea;if(U!=$)t.lineJoin=U=$;c(V);t.stroke();y.inflate(na*2)}function Qa(V){if(J!=V)t.fillStyle=J=V;t.fill()}function cb(V,na,ea,$,ta,ra,ya,X,Ia,Ya,eb,Sa,kb){var gb,db;gb=ya.width-1;db=ya.height-1;X*=gb;Ia*=db;Ya*=gb;eb*=db;Sa*=gb;kb*=db;ea-=V;$-=na;ta-=V;ra-=na;Ya-=X;eb-=Ia;Sa-=X;kb-=Ia;gb=Ya*kb-Sa*eb;if(gb!=0){db=1/gb;gb=(kb*ea-eb*ta)*db;eb=(kb*$-eb*ra)*db;ea=(Ya*ta-
+Sa*ea)*db;$=(Ya*ra-Sa*$)*db;V=V-gb*X-ea*Ia;na=na-eb*X-$*Ia;t.save();t.transform(gb,eb,ea,$,V,na);t.clip();t.drawImage(ya,0,0);t.restore()}}function hb(V,na,ea,$){var ta=~~(V.r*255),ra=~~(V.g*255);V=~~(V.b*255);var ya=~~(na.r*255),X=~~(na.g*255);na=~~(na.b*255);var Ia=~~(ea.r*255),Ya=~~(ea.g*255);ea=~~(ea.b*255);var eb=~~($.r*255),Sa=~~($.g*255);$=~~($.b*255);qa[0]=ta<0?0:ta>255?255:ta;qa[1]=ra<0?0:ra>255?255:ra;qa[2]=V<0?0:V>255?255:V;qa[4]=ya<0?0:ya>255?255:ya;qa[5]=X<0?0:X>255?255:X;qa[6]=na<0?
+0:na>255?255:na;qa[8]=Ia<0?0:Ia>255?255:Ia;qa[9]=Ya<0?0:Ya>255?255:Ya;qa[10]=ea<0?0:ea>255?255:ea;qa[12]=eb<0?0:eb>255?255:eb;qa[13]=Sa<0?0:Sa>255?255:Sa;qa[14]=$<0?0:$>255?255:$;Z.putImageData(Y,0,0);Ca.drawImage(L,0,0);return Ka}function Wa(V,na,ea){V=(V-na)/(ea-na);return V*V*(3-2*V)}function $a(V){V=(V+1)*0.5;return V<0?0:V>1?1:V}function Ma(V,na){var ea=na.x-V.x,$=na.y-V.y,ta=1/Math.sqrt(ea*ea+$*$);ea*=ta;$*=ta;na.x+=ea;na.y+=$;V.x-=ea;V.y-=$}var bb,Va,M,Na,Ra,ib,jb,Pa;this.autoClear?this.clear():
+t.setTransform(1,0,0,-1,o,p);f.data.vertices=0;f.data.faces=0;g=h.projectScene(Ga,xa,this.sortElements);(Q=Ga.lights.length>0)&&Ea(Ga);bb=0;for(Va=g.length;bb<Va;bb++){M=g[bb];y.empty();if(M instanceof THREE.RenderableParticle){N=M;N.x*=o;N.y*=p;Na=0;for(Ra=M.materials.length;Na<Ra;){Pa=M.materials[Na++];Pa.opacity!=0&&Ua(N,M,Pa,Ga)}}else if(M instanceof THREE.RenderableLine){N=M.v1;O=M.v2;N.positionScreen.x*=o;N.positionScreen.y*=p;O.positionScreen.x*=o;O.positionScreen.y*=p;y.addPoint(N.positionScreen.x,
+N.positionScreen.y);y.addPoint(O.positionScreen.x,O.positionScreen.y);if(w.instersects(y)){Na=0;for(Ra=M.materials.length;Na<Ra;){Pa=M.materials[Na++];Pa.opacity!=0&&D(N,O,M,Pa,Ga)}}}else if(M instanceof THREE.RenderableFace3){N=M.v1;O=M.v2;ua=M.v3;N.positionScreen.x*=o;N.positionScreen.y*=p;O.positionScreen.x*=o;O.positionScreen.y*=p;ua.positionScreen.x*=o;ua.positionScreen.y*=p;if(M.overdraw){Ma(N.positionScreen,O.positionScreen);Ma(O.positionScreen,ua.positionScreen);Ma(ua.positionScreen,N.positionScreen)}y.add3Points(N.positionScreen.x,
+N.positionScreen.y,O.positionScreen.x,O.positionScreen.y,ua.positionScreen.x,ua.positionScreen.y);if(w.instersects(y)){Na=0;for(Ra=M.meshMaterials.length;Na<Ra;){Pa=M.meshMaterials[Na++];if(Pa instanceof THREE.MeshFaceMaterial){ib=0;for(jb=M.faceMaterials.length;ib<jb;)(Pa=M.faceMaterials[ib++])&&Pa.opacity!=0&&aa(N,O,ua,0,1,2,M,Pa,Ga)}else Pa.opacity!=0&&aa(N,O,ua,0,1,2,M,Pa,Ga)}}}else if(M instanceof THREE.RenderableFace4){N=M.v1;O=M.v2;ua=M.v3;la=M.v4;N.positionScreen.x*=o;N.positionScreen.y*=
+p;O.positionScreen.x*=o;O.positionScreen.y*=p;ua.positionScreen.x*=o;ua.positionScreen.y*=p;la.positionScreen.x*=o;la.positionScreen.y*=p;pa.positionScreen.copy(O.positionScreen);ga.positionScreen.copy(la.positionScreen);if(M.overdraw){Ma(N.positionScreen,O.positionScreen);Ma(O.positionScreen,la.positionScreen);Ma(la.positionScreen,N.positionScreen);Ma(ua.positionScreen,pa.positionScreen);Ma(ua.positionScreen,ga.positionScreen)}y.addPoint(N.positionScreen.x,N.positionScreen.y);y.addPoint(O.positionScreen.x,
+O.positionScreen.y);y.addPoint(ua.positionScreen.x,ua.positionScreen.y);y.addPoint(la.positionScreen.x,la.positionScreen.y);if(w.instersects(y)){Na=0;for(Ra=M.meshMaterials.length;Na<Ra;){Pa=M.meshMaterials[Na++];if(Pa instanceof THREE.MeshFaceMaterial){ib=0;for(jb=M.faceMaterials.length;ib<jb;)(Pa=M.faceMaterials[ib++])&&Pa.opacity!=0&&v(N,O,ua,la,pa,ga,M,Pa,Ga)}else Pa.opacity!=0&&v(N,O,ua,la,pa,ga,M,Pa,Ga)}}}x.addRectangle(y)}t.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function b(fa,va,sa){var wa,ca,ja,ma;wa=0;for(ca=fa.lights.length;wa<ca;wa++){ja=fa.lights[wa];if(ja instanceof THREE.DirectionalLight){ma=va.normalWorld.dot(ja.position)*ja.intensity;if(ma>0){sa.r+=ja.color.r*ma;sa.g+=ja.color.g*ma;sa.b+=ja.color.b*ma}}else if(ja instanceof THREE.PointLight){ga.sub(ja.position,va.centroidWorld);ga.normalize();ma=va.normalWorld.dot(ga)*ja.intensity;if(ma>0){sa.r+=ja.color.r*ma;sa.g+=ja.color.g*ma;sa.b+=ja.color.b*ma}}}}function d(fa,va,
+sa,wa,ca,ja){h.data.vertices+=3;h.data.faces++;oa=f(Da++);oa.setAttribute("d","M "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+va.positionScreen.x+" "+va.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(ca instanceof THREE.MeshBasicMaterial)U.__styleString=ca.color.__styleString;else if(ca instanceof THREE.MeshLambertMaterial)if(B){N.r=O.r;N.g=O.g;N.b=O.b;b(ja,wa,N);U.r=ca.color.r*N.r;U.g=ca.color.g*N.g;U.b=ca.color.b*N.b;U.updateStyleString()}else U.__styleString=
+ca.color.__styleString;else if(ca instanceof THREE.MeshDepthMaterial){pa=1-ca.__2near/(ca.__farPlusNear-wa.z*ca.__farMinusNear);U.setRGB(pa,pa,pa)}else ca instanceof THREE.MeshNormalMaterial&&U.setRGB(g(wa.normalWorld.x),g(wa.normalWorld.y),g(wa.normalWorld.z));ca.wireframe?oa.setAttribute("style","fill: none; stroke: "+U.__styleString+"; stroke-width: "+ca.wireframeLinewidth+"; stroke-opacity: "+ca.opacity+"; stroke-linecap: "+ca.wireframeLinecap+"; stroke-linejoin: "+ca.wireframeLinejoin):oa.setAttribute("style",
+"fill: "+U.__styleString+"; fill-opacity: "+ca.opacity);m.appendChild(oa)}function c(fa,va,sa,wa,ca,ja,ma){h.data.vertices+=4;h.data.faces++;oa=f(Da++);oa.setAttribute("d","M "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+va.positionScreen.x+" "+va.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(ja instanceof THREE.MeshBasicMaterial)U.__styleString=ja.color.__styleString;else if(ja instanceof THREE.MeshLambertMaterial)if(B){N.r=
+O.r;N.g=O.g;N.b=O.b;b(ma,ca,N);U.r=ja.color.r*N.r;U.g=ja.color.g*N.g;U.b=ja.color.b*N.b;U.updateStyleString()}else U.__styleString=ja.color.__styleString;else if(ja instanceof THREE.MeshDepthMaterial){pa=1-ja.__2near/(ja.__farPlusNear-ca.z*ja.__farMinusNear);U.setRGB(pa,pa,pa)}else ja instanceof THREE.MeshNormalMaterial&&U.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));ja.wireframe?oa.setAttribute("style","fill: none; stroke: "+U.__styleString+"; stroke-width: "+ja.wireframeLinewidth+
+"; stroke-opacity: "+ja.opacity+"; stroke-linecap: "+ja.wireframeLinecap+"; stroke-linejoin: "+ja.wireframeLinejoin):oa.setAttribute("style","fill: "+U.__styleString+"; fill-opacity: "+ja.opacity);m.appendChild(oa)}function f(fa){if(ha[fa]==null){ha[fa]=document.createElementNS("http://www.w3.org/2000/svg","path");ka==0&&ha[fa].setAttribute("shape-rendering","crispEdges")}return ha[fa]}function g(fa){return fa<0?Math.min((1+fa)*0.5,0.5):0.5+Math.min(fa*0.5,0.5)}var h=this,j=null,k=new THREE.Projector,
+m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,p,t,z,u,A,E,H,J=new THREE.Rectangle,W=new THREE.Rectangle,B=!1,U=new THREE.Color(16777215),N=new THREE.Color(16777215),O=new THREE.Color(0),ua=new THREE.Color(0),la=new THREE.Color(0),pa,ga=new THREE.Vector3,ha=[],e=[],oa,Da,Aa,ka=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(fa){switch(fa){case "high":ka=1;break;case "low":ka=0}};this.setSize=function(fa,
+va){o=fa;p=va;t=o/2;z=p/2;m.setAttribute("viewBox",-t+" "+-z+" "+o+" "+p);m.setAttribute("width",o);m.setAttribute("height",p);J.set(-t,-z,t,z)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(fa,va){var sa,wa,ca,ja,ma,Fa,ia,da;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;j=k.projectScene(fa,va,this.sortElements);Aa=Da=0;if(B=fa.lights.length>0){ia=fa.lights;O.setRGB(0,0,0);ua.setRGB(0,0,0);la.setRGB(0,0,0);sa=0;for(wa=ia.length;sa<
+wa;sa++){ca=ia[sa];ja=ca.color;if(ca instanceof THREE.AmbientLight){O.r+=ja.r;O.g+=ja.g;O.b+=ja.b}else if(ca instanceof THREE.DirectionalLight){ua.r+=ja.r;ua.g+=ja.g;ua.b+=ja.b}else if(ca instanceof THREE.PointLight){la.r+=ja.r;la.g+=ja.g;la.b+=ja.b}}}sa=0;for(wa=j.length;sa<wa;sa++){ia=j[sa];W.empty();if(ia instanceof THREE.RenderableParticle){u=ia;u.x*=t;u.y*=-z;ca=0;for(ja=ia.materials.length;ca<ja;)ca++}else if(ia instanceof THREE.RenderableLine){u=ia.v1;A=ia.v2;u.positionScreen.x*=t;u.positionScreen.y*=
+-z;A.positionScreen.x*=t;A.positionScreen.y*=-z;W.addPoint(u.positionScreen.x,u.positionScreen.y);W.addPoint(A.positionScreen.x,A.positionScreen.y);if(J.instersects(W)){ca=0;for(ja=ia.materials.length;ca<ja;)if((da=ia.materials[ca++])&&da.opacity!=0){ma=u;Fa=A;var Ja=Aa++;if(e[Ja]==null){e[Ja]=document.createElementNS("http://www.w3.org/2000/svg","line");ka==0&&e[Ja].setAttribute("shape-rendering","crispEdges")}oa=e[Ja];oa.setAttribute("x1",ma.positionScreen.x);oa.setAttribute("y1",ma.positionScreen.y);
+oa.setAttribute("x2",Fa.positionScreen.x);oa.setAttribute("y2",Fa.positionScreen.y);if(da instanceof THREE.LineBasicMaterial){U.__styleString=da.color.__styleString;oa.setAttribute("style","fill: none; stroke: "+U.__styleString+"; stroke-width: "+da.linewidth+"; stroke-opacity: "+da.opacity+"; stroke-linecap: "+da.linecap+"; stroke-linejoin: "+da.linejoin);m.appendChild(oa)}}}}else if(ia instanceof THREE.RenderableFace3){u=ia.v1;A=ia.v2;E=ia.v3;u.positionScreen.x*=t;u.positionScreen.y*=-z;A.positionScreen.x*=
+t;A.positionScreen.y*=-z;E.positionScreen.x*=t;E.positionScreen.y*=-z;W.addPoint(u.positionScreen.x,u.positionScreen.y);W.addPoint(A.positionScreen.x,A.positionScreen.y);W.addPoint(E.positionScreen.x,E.positionScreen.y);if(J.instersects(W)){ca=0;for(ja=ia.meshMaterials.length;ca<ja;){da=ia.meshMaterials[ca++];if(da instanceof THREE.MeshFaceMaterial){ma=0;for(Fa=ia.faceMaterials.length;ma<Fa;)(da=ia.faceMaterials[ma++])&&da.opacity!=0&&d(u,A,E,ia,da,fa)}else da&&da.opacity!=0&&d(u,A,E,ia,da,fa)}}}else if(ia instanceof
+THREE.RenderableFace4){u=ia.v1;A=ia.v2;E=ia.v3;H=ia.v4;u.positionScreen.x*=t;u.positionScreen.y*=-z;A.positionScreen.x*=t;A.positionScreen.y*=-z;E.positionScreen.x*=t;E.positionScreen.y*=-z;H.positionScreen.x*=t;H.positionScreen.y*=-z;W.addPoint(u.positionScreen.x,u.positionScreen.y);W.addPoint(A.positionScreen.x,A.positionScreen.y);W.addPoint(E.positionScreen.x,E.positionScreen.y);W.addPoint(H.positionScreen.x,H.positionScreen.y);if(J.instersects(W)){ca=0;for(ja=ia.meshMaterials.length;ca<ja;){da=
+ia.meshMaterials[ca++];if(da instanceof THREE.MeshFaceMaterial){ma=0;for(Fa=ia.faceMaterials.length;ma<Fa;)(da=ia.faceMaterials[ma++])&&da.opacity!=0&&c(u,A,E,H,ia,da,fa)}else da&&da.opacity!=0&&c(u,A,E,H,ia,da,fa)}}}}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
@@ -217,119 +218,120 @@ THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.Shade
 "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
 THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
 THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(n,C,w){var x,z,J,K=n.vertices,I=K.length,S=n.colors,D=S.length,O=n.__vertexArray,L=n.__colorArray,$=n.__sortArray,V=n.__dirtyVertices,xa=n.__dirtyColors;if(w.sortParticles){Ra.multiplySelf(w.matrixWorld);for(x=0;x<I;x++){z=K[x].position;Na.copy(z);Ra.multiplyVector3(Na);$[x]=[Na.z,x]}$.sort(function(Ja,za){return za[0]-Ja[0]});for(x=0;x<I;x++){z=K[$[x][1]].position;J=x*3;O[J]=z.x;O[J+1]=z.y;O[J+2]=z.z}for(x=0;x<D;x++){J=x*3;color=S[$[x][1]];L[J]=color.r;
-L[J+1]=color.g;L[J+2]=color.b}}else{if(V)for(x=0;x<I;x++){z=K[x].position;J=x*3;O[J]=z.x;O[J+1]=z.y;O[J+2]=z.z}if(xa)for(x=0;x<D;x++){color=S[x];J=x*3;L[J]=color.r;L[J+1]=color.g;L[J+2]=color.b}}if(V||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,O,C)}if(xa||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,L,C)}}function c(n,C,w,x,z){x.program||oa.initMaterial(x,C,w,z);var J=x.program,K=J.uniforms,I=x.uniforms;
-if(J!=Ba){e.useProgram(J);Ba=J}e.uniformMatrix4fv(K.projectionMatrix,!1,Ya);if(w&&(x instanceof THREE.MeshBasicMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshPhongMaterial||x instanceof THREE.LineBasicMaterial||x instanceof THREE.ParticleBasicMaterial||x.fog)){I.fogColor.value=w.color;if(w instanceof THREE.Fog){I.fogNear.value=w.near;I.fogFar.value=w.far}else if(w instanceof THREE.FogExp2)I.fogDensity.value=w.density}if(x instanceof THREE.MeshPhongMaterial||x instanceof THREE.MeshLambertMaterial||
-x.lights){var S,D,O=0,L=0,$=0,V,xa,Ja,za,ta=T,Oa=ta.directional.colors,Ga=ta.directional.positions,wa=ta.point.colors,Ha=ta.point.positions,Ua=ta.point.distances,E=0,fa=0;w=D=za=0;for(S=C.length;w<S;w++){D=C[w];V=D.color;xa=D.position;Ja=D.intensity;za=D.distance;if(D instanceof THREE.AmbientLight){O+=V.r;L+=V.g;$+=V.b}else if(D instanceof THREE.DirectionalLight){za=E*3;Oa[za]=V.r*Ja;Oa[za+1]=V.g*Ja;Oa[za+2]=V.b*Ja;Ga[za]=xa.x;Ga[za+1]=xa.y;Ga[za+2]=xa.z;E+=1}else if(D instanceof THREE.PointLight){D=
-fa*3;wa[D]=V.r*Ja;wa[D+1]=V.g*Ja;wa[D+2]=V.b*Ja;Ha[D]=xa.x;Ha[D+1]=xa.y;Ha[D+2]=xa.z;Ua[fa]=za;fa+=1}}for(w=E*3;w<Oa.length;w++)Oa[w]=0;for(w=fa*3;w<wa.length;w++)wa[w]=0;ta.point.length=fa;ta.directional.length=E;ta.ambient[0]=O;ta.ambient[1]=L;ta.ambient[2]=$;w=T;I.enableLighting.value=w.directional.length+w.point.length;I.ambientLightColor.value=w.ambient;I.directionalLightColor.value=w.directional.colors;I.directionalLightDirection.value=w.directional.positions;I.pointLightColor.value=w.point.colors;
-I.pointLightPosition.value=w.point.positions;I.pointLightDistance.value=w.point.distances}if(x instanceof THREE.MeshBasicMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshPhongMaterial){I.diffuse.value=x.color;I.opacity.value=x.opacity;I.map.texture=x.map;I.lightMap.texture=x.lightMap;I.envMap.texture=x.envMap;I.reflectivity.value=x.reflectivity;I.refractionRatio.value=x.refractionRatio;I.combine.value=x.combine;I.useRefract.value=x.envMap&&x.envMap.mapping instanceof THREE.CubeRefractionMapping}if(x instanceof
-THREE.LineBasicMaterial){I.diffuse.value=x.color;I.opacity.value=x.opacity}else if(x instanceof THREE.ParticleBasicMaterial){I.psColor.value=x.color;I.opacity.value=x.opacity;I.size.value=x.size;I.scale.value=ea.height/2;I.map.texture=x.map}else if(x instanceof THREE.MeshPhongMaterial){I.ambient.value=x.ambient;I.specular.value=x.specular;I.shininess.value=x.shininess}else if(x instanceof THREE.MeshDepthMaterial){I.mNear.value=n.near;I.mFar.value=n.far;I.opacity.value=x.opacity}else if(x instanceof
-THREE.MeshNormalMaterial)I.opacity.value=x.opacity;for(var v in I)if(L=J.uniforms[v]){S=I[v];O=S.type;w=S.value;if(O=="i")e.uniform1i(L,w);else if(O=="f")e.uniform1f(L,w);else if(O=="fv1")e.uniform1fv(L,w);else if(O=="fv")e.uniform3fv(L,w);else if(O=="v2")e.uniform2f(L,w.x,w.y);else if(O=="v3")e.uniform3f(L,w.x,w.y,w.z);else if(O=="v4")e.uniform4f(L,w.x,w.y,w.z,w.w);else if(O=="c")e.uniform3f(L,w.r,w.g,w.b);else if(O=="t"){e.uniform1i(L,w);if(S=S.texture)if(S.image instanceof Array&&S.image.length==
-6){if(S.image.length==6){if(S.needsUpdate){if(S.__webglInit){e.bindTexture(e.TEXTURE_CUBE_MAP,S.image.__webglTextureCube);for(O=0;O<6;++O)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,0,0,e.RGBA,e.UNSIGNED_BYTE,S.image[O])}else{S.image.__webglTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,S.image.__webglTextureCube);for(O=0;O<6;++O)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,S.image[O]);S.__webglInit=!0}Q(e.TEXTURE_CUBE_MAP,S,S.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,
-null);S.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_CUBE_MAP,S.image.__webglTextureCube)}}else R(S,w)}}e.uniformMatrix4fv(K.modelViewMatrix,!1,z._modelViewMatrixArray);e.uniformMatrix3fv(K.normalMatrix,!1,z._normalMatrixArray);(x instanceof THREE.MeshShaderMaterial||x instanceof THREE.MeshPhongMaterial||x.envMap)&&e.uniform3f(K.cameraPosition,n.position.x,n.position.y,n.position.z);(x instanceof THREE.MeshShaderMaterial||x.envMap||x.skinning)&&e.uniformMatrix4fv(K.objectMatrix,
-!1,z._objectMatrixArray);(x instanceof THREE.MeshPhongMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshShaderMaterial||x.skinning)&&e.uniformMatrix4fv(K.viewMatrix,!1,Za);if(x instanceof THREE.ShadowVolumeDynamicMaterial){n=I.directionalLightDirection.value;n[0]=-C[1].position.x;n[1]=-C[1].position.y;n[2]=-C[1].position.z;e.uniform3fv(K.directionalLightDirection,n);e.uniformMatrix4fv(K.objectMatrix,!1,z._objectMatrixArray);e.uniformMatrix4fv(K.viewMatrix,!1,Za)}if(x.skinning){e.uniformMatrix4fv(K.cameraInverseMatrix,
-!1,Za);e.uniformMatrix4fv(K.boneGlobalMatrices,!1,z.boneMatrices)}return J}function f(n,C,w,x,z,J){if(x.opacity!=0){var K;n=c(n,C,w,x,J).attributes;if(x.morphTargets){C=x.program.attributes;J.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[J.morphTargetBase]):e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(C.position,3,e.FLOAT,!1,0,0);if(J.morphTargetForcedOrder.length){w=0;for(var I=J.morphTargetForcedOrder,S=J.morphTargetInfluences;w<x.numSupportedMorphTargets&&
-w<I.length;){e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[I[w]]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0);J.__webglMorphTargetInfluences[w]=S[I[w]];w++}}else{I=[];var D=-1,O=0;S=J.morphTargetInfluences;var L,$=S.length;w=0;for(J.morphTargetBase!==-1&&(I[J.morphTargetBase]=!0);w<x.numSupportedMorphTargets;){for(L=0;L<$;L++)if(!I[L]&&S[L]>D){O=L;D=S[O]}e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[O]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0);
-J.__webglMorphTargetInfluences[w]=D;I[O]=1;D=-1;w++}}e.uniform1fv(x.program.uniforms.morphTargetInfluences,J.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}if(z.__webglCustomAttributes)for(K in z.__webglCustomAttributes)if(n[K]>=0){C=z.__webglCustomAttributes[K];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(n[K],C.size,e.FLOAT,!1,0,0)}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglColorBuffer);
-e.vertexAttribPointer(n.color,3,e.FLOAT,!1,0,0)}if(n.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,!1,0,0)}if(n.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglTangentBuffer);e.vertexAttribPointer(n.tangent,4,e.FLOAT,!1,0,0)}if(n.uv>=0)if(z.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,z.__webglUVBuffer);e.vertexAttribPointer(n.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv)}else e.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(z.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,
-z.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(x.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex,
-4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(J instanceof THREE.Mesh)if(x.wireframe){e.lineWidth(x.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglLineBuffer);e.drawElements(e.LINES,z.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglFaceBuffer);e.drawElements(e.TRIANGLES,z.__webglFaceCount,e.UNSIGNED_SHORT,0)}else if(J instanceof THREE.Line){J=J.type==THREE.LineStrip?
-e.LINE_STRIP:e.LINES;e.lineWidth(x.linewidth);e.drawArrays(J,0,z.__webglLineCount)}else if(J instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,z.__webglParticleCount);else J instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,z.__webglVertexCount)}}function g(n,C,w){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray,
-e.DYNAMIC_DRAW);e.enableVertexAttribArray(C.attributes.position);e.vertexAttribPointer(C.attributes.position,3,e.FLOAT,!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(w==THREE.FlatShading){var x,z,J,K,I,S,D,O,L,$,V=n.count*3;for($=0;$<V;$+=9){w=n.normalArray;x=w[$];z=w[$+1];J=w[$+2];K=w[$+3];S=w[$+4];O=w[$+5];I=w[$+6];D=w[$+7];L=w[$+8];x=(x+K+I)/3;z=(z+S+D)/3;J=(J+O+L)/3;w[$]=x;w[$+1]=z;w[$+2]=J;w[$+3]=x;w[$+4]=z;w[$+5]=J;w[$+6]=x;w[$+7]=z;w[$+8]=J}}e.bufferData(e.ARRAY_BUFFER,
-n.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(C.attributes.normal);e.vertexAttribPointer(C.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,n.count);n.count=0}function h(n){if(pa!=n.doubleSided){n.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);pa=n.doubleSided}if(sa!=n.flipSided){n.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);sa=n.flipSided}}function j(n){if(aa!=n){n?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);aa=n}}function k(n){ua[0].set(n.n41-n.n11,n.n42-
-n.n12,n.n43-n.n13,n.n44-n.n14);ua[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);ua[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);ua[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);ua[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);ua[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var C;for(n=0;n<6;n++){C=ua[n];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function m(n){for(var C=n.matrixWorld,w=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,
-Math.max(n.scale.y,n.scale.z)),x=0;x<6;x++){n=ua[x].x*C.n14+ua[x].y*C.n24+ua[x].z*C.n34+ua[x].w;if(n<=w)return!1}return!0}function p(n,C){n.list[n.count]=C;n.count+=1}function o(n){var C,w,x=n.object,z=n.opaque,J=n.transparent;J.count=0;n=z.count=0;for(C=x.materials.length;n<C;n++){w=x.materials[n];w.transparent?p(J,w):p(z,w)}}function u(n){var C,w,x,z,J=n.object,K=n.buffer,I=n.opaque,S=n.transparent;S.count=0;n=I.count=0;for(x=J.materials.length;n<x;n++){C=J.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=
-0;for(w=K.materials.length;C<w;C++)(z=K.materials[C])&&(z.transparent?p(S,z):p(I,z))}else(z=C)&&(z.transparent?p(S,z):p(I,z))}}function y(n,C){return C.z-n.z}function t(n){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,e.KEEP);e.stencilOpSeparate(e.FRONT,e.KEEP,e.DECR,e.KEEP);var C,w=n.lights.length,x,z=n.lights,J=[],K,I,S,D,O,L=n.__webglShadowVolumes.length;
-for(C=0;C<w;C++){x=n.lights[C];if(x instanceof THREE.DirectionalLight){J[0]=-x.position.x;J[1]=-x.position.y;J[2]=-x.position.z;for(O=0;O<L;O++){x=n.__webglShadowVolumes[O].object;K=n.__webglShadowVolumes[O].buffer;I=x.materials[0];I.program||oa.initMaterial(I,z,undefined,x);I=I.program;S=I.uniforms;D=I.attributes;if(Ba!==I){e.useProgram(I);Ba=I;e.uniformMatrix4fv(S.projectionMatrix,!1,Ya);e.uniformMatrix4fv(S.viewMatrix,!1,Za);e.uniform3fv(S.directionalLightDirection,J)}x.matrixWorld.flattenToArray(x._objectMatrixArray);
-e.uniformMatrix4fv(S.objectMatrix,!1,x._objectMatrixArray);e.bindBuffer(e.ARRAY_BUFFER,K.__webglVertexBuffer);e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,K.__webglNormalBuffer);e.vertexAttribPointer(D.normal,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,K.__webglFaceBuffer);e.cullFace(e.FRONT);e.drawElements(e.TRIANGLES,K.__webglFaceCount,e.UNSIGNED_SHORT,0);e.cullFace(e.BACK);e.drawElements(e.TRIANGLES,K.__webglFaceCount,e.UNSIGNED_SHORT,0)}}}e.disable(e.POLYGON_OFFSET_FILL);
-e.colorMask(!0,!0,!0,!0);e.stencilFunc(e.NOTEQUAL,0,255);e.stencilOp(e.KEEP,e.KEEP,e.KEEP);e.disable(e.DEPTH_TEST);ga="";Ba=P.program;e.useProgram(P.program);e.uniformMatrix4fv(P.projectionLocation,!1,Ya);e.uniform1f(P.darknessLocation,P.darkness);e.bindBuffer(e.ARRAY_BUFFER,P.vertexBuffer);e.vertexAttribPointer(P.vertexLocation,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(P.vertexLocation);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.blendEquation(e.FUNC_ADD);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,P.elementBuffer);
-e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.disable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(Z)}function B(n,C){var w,x,z;w=_sprite.attributes;var J=_sprite.uniforms,K=la/ja,I,S=[],D=ja*0.5,O=la*0.5,L=!0;e.useProgram(_sprite.program);Ba=_sprite.program;ga="";if(!Ka){e.enableVertexAttribArray(_sprite.attributes.position);e.enableVertexAttribArray(_sprite.attributes.uv);Ka=!0}e.disable(e.CULL_FACE);e.enable(e.BLEND);e.depthMask(!0);e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);
-e.vertexAttribPointer(w.position,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(w.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.uniformMatrix4fv(J.projectionMatrix,!1,Ya);e.activeTexture(e.TEXTURE0);e.uniform1i(J.map,0);w=0;for(x=n.__webglSprites.length;w<x;w++){z=n.__webglSprites[w];if(z.useScreenCoordinates)z.z=-z.position.z;else{z._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,z.matrixWorld,z._modelViewMatrixArray);z.z=-z._modelViewMatrix.n34}}n.__webglSprites.sort(y);
-w=0;for(x=n.__webglSprites.length;w<x;w++){z=n.__webglSprites[w];if(z.material===undefined&&z.map&&z.map.image&&z.map.image.width){if(z.useScreenCoordinates){e.uniform1i(J.useScreenCoordinates,1);e.uniform3f(J.screenPosition,(z.position.x-D)/D,(O-z.position.y)/O,Math.max(0,Math.min(1,z.position.z)))}else{e.uniform1i(J.useScreenCoordinates,0);e.uniform1i(J.affectedByDistance,z.affectedByDistance?1:0);e.uniformMatrix4fv(J.modelViewMatrix,!1,z._modelViewMatrixArray)}I=z.map.image.width/(z.affectedByDistance?
-1:la);S[0]=I*K*z.scale.x;S[1]=I*z.scale.y;e.uniform2f(J.uvScale,z.uvScale.x,z.uvScale.y);e.uniform2f(J.uvOffset,z.uvOffset.x,z.uvOffset.y);e.uniform2f(J.alignment,z.alignment.x,z.alignment.y);e.uniform1f(J.opacity,z.opacity);e.uniform1f(J.rotation,z.rotation);e.uniform2fv(J.scale,S);if(z.mergeWith3D&&!L){e.enable(e.DEPTH_TEST);L=!0}else if(!z.mergeWith3D&&L){e.disable(e.DEPTH_TEST);L=!1}M(z.blending);R(z.map,0);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);
-e.depthMask(Z)}function F(n,C){var w,x,z=n.__webglLensFlares.length,J,K,I,S=new THREE.Vector3,D=la/ja,O=ja*0.5,L=la*0.5,$=16/la,V=[$*D,$],xa=[1,1,0],Ja=[1,1],za=N.uniforms;w=N.attributes;e.useProgram(N.program);Ba=N.program;ga="";if(!Ca){e.enableVertexAttribArray(N.attributes.vertex);e.enableVertexAttribArray(N.attributes.uv);Ca=!0}e.uniform1i(za.occlusionMap,0);e.uniform1i(za.map,1);e.bindBuffer(e.ARRAY_BUFFER,N.vertexBuffer);e.vertexAttribPointer(w.vertex,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(w.uv,
-2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,N.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,N.occlusionTexture);e.activeTexture(e.TEXTURE1);for(x=0;x<z;x++){w=n.__webglLensFlares[x].object;S.set(w.matrixWorld.n14,w.matrixWorld.n24,w.matrixWorld.n34);C.matrixWorldInverse.multiplyVector3(S);C.projectionMatrix.multiplyVector3(S);xa[0]=S.x;xa[1]=S.y;xa[2]=S.z;Ja[0]=xa[0]*O+O;Ja[1]=xa[1]*L+L;if(N.hasVertexTexture||Ja[0]>0&&Ja[0]<
-ja&&Ja[1]>0&&Ja[1]<la){e.bindTexture(e.TEXTURE_2D,N.tempTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGB,Ja[0]-8,Ja[1]-8,16,16,0);e.uniform1i(za.renderType,0);e.uniform2fv(za.scale,V);e.uniform3fv(za.screenPosition,xa);e.disable(e.BLEND);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.bindTexture(e.TEXTURE_2D,N.occlusionTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,Ja[0]-8,Ja[1]-8,16,16,0);e.uniform1i(za.renderType,1);e.disable(e.DEPTH_TEST);e.bindTexture(e.TEXTURE_2D,N.tempTexture);
-e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);w.positionScreen.x=xa[0];w.positionScreen.y=xa[1];w.positionScreen.z=xa[2];w.customUpdateCallback?w.customUpdateCallback(w):w.updateLensFlares();e.uniform1i(za.renderType,2);e.enable(e.BLEND);J=0;for(K=w.lensFlares.length;J<K;J++){I=w.lensFlares[J];if(I.opacity>0.0010&&I.scale>0.0010){xa[0]=I.x;xa[1]=I.y;xa[2]=I.z;$=I.size*I.scale/la;V[0]=$*D;V[1]=$;e.uniform3fv(za.screenPosition,xa);e.uniform2fv(za.scale,V);e.uniform1f(za.rotation,I.rotation);e.uniform1f(za.opacity,
-I.opacity);M(I.blending);R(I.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(Z)}function H(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function G(n){var C,w,x,z,J;if(n instanceof THREE.Mesh){w=n.geometry;for(C in w.geometryGroups){x=w.geometryGroups[C];J=!1;for(z in x.__webglCustomAttributes)if(x.__webglCustomAttributes[z].needsUpdate){J=
-!0;break}if(w.__dirtyVertices||w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents||J){J=e.DYNAMIC_DRAW;var K=void 0,I=void 0,S=void 0,D=void 0;S=void 0;var O=void 0,L=void 0,$=void 0,V=void 0,xa=void 0,Ja=void 0,za=void 0,ta=void 0,Oa=void 0,Ga=void 0,wa=void 0,Ha=void 0,Ua=void 0;L=void 0;$=void 0;D=void 0;V=void 0;D=void 0;var E=void 0,fa=void 0;L=void 0;E=void 0;fa=void 0;var v=void 0,bb=void 0;E=void 0;fa=void 0;v=void 0;bb=void 0;E=void 0;
-fa=void 0;v=void 0;bb=void 0;E=void 0;fa=void 0;v=void 0;D=void 0;V=void 0;O=void 0;S=void 0;S=void 0;E=void 0;fa=void 0;v=void 0;var db=void 0,Ma=0,Pa=0,hb=0,eb=0,$a=0,ab=0,La=0,cb=0,Aa=0,U=0,Qa=0;fa=E=0;var Sa=x.__vertexArray,jb=x.__uvArray,Xa=x.__uv2Array,W=x.__normalArray,ia=x.__tangentArray,ka=x.__colorArray,da=x.__skinVertexAArray,ra=x.__skinVertexBArray,qa=x.__skinIndexArray,ha=x.__skinWeightArray,Y=x.__morphTargetsArrays,Ia=x.__webglCustomAttributes;v=void 0;var Va=x.__faceArray,Ta=x.__lineArray,
-ib=x.__needsSmoothNormals;Ja=x.__vertexColorType;xa=x.__uvType;za=x.__normalType;var Wa=n.geometry,fb=Wa.__dirtyVertices,gb=Wa.__dirtyElements,qb=Wa.__dirtyUvs,rb=Wa.__dirtyNormals,sb=Wa.__dirtyTangents,tb=Wa.__dirtyColors,ub=Wa.__dirtyMorphTargets,mb=Wa.vertices,vb=x.faces,yb=Wa.faces,wb=Wa.faceVertexUvs[0],xb=Wa.faceVertexUvs[1],nb=Wa.skinVerticesA,ob=Wa.skinVerticesB,pb=Wa.skinIndices,kb=Wa.skinWeights,lb=n instanceof THREE.ShadowVolume?Wa.edgeFaces:undefined;morphTargets=Wa.morphTargets;if(Ia)for(db in Ia){Ia[db].offset=
-0;Ia[db].offsetSrc=0}K=0;for(I=vb.length;K<I;K++){S=vb[K];D=yb[S];wb&&(ta=wb[S]);xb&&(Oa=xb[S]);S=D.vertexNormals;O=D.normal;L=D.vertexColors;$=D.color;V=D.vertexTangents;if(D instanceof THREE.Face3){if(fb){Ga=mb[D.a].position;wa=mb[D.b].position;Ha=mb[D.c].position;Sa[Pa]=Ga.x;Sa[Pa+1]=Ga.y;Sa[Pa+2]=Ga.z;Sa[Pa+3]=wa.x;Sa[Pa+4]=wa.y;Sa[Pa+5]=wa.z;Sa[Pa+6]=Ha.x;Sa[Pa+7]=Ha.y;Sa[Pa+8]=Ha.z;Pa+=9}if(Ia)for(db in Ia){v=Ia[db];if(v.needsUpdate){E=v.offset;fa=v.offsetSrc;if(v.size===1){if(v.boundTo===undefined||
-v.boundTo==="vertices"){v.array[E+0]=v.value[D.a];v.array[E+1]=v.value[D.b];v.array[E+2]=v.value[D.c]}else if(v.boundTo==="faces"){v.array[E+0]=v.value[fa];v.array[E+1]=v.value[fa];v.array[E+2]=v.value[fa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){v.array[E+0]=v.value[fa+0];v.array[E+1]=v.value[fa+1];v.array[E+2]=v.value[fa+2];v.offsetSrc+=3}v.offset+=3}else{if(v.boundTo===undefined||v.boundTo==="vertices"){Ga=v.value[D.a];wa=v.value[D.b];Ha=v.value[D.c]}else if(v.boundTo==="faces"){Ga=v.value[fa];
-wa=v.value[fa];Ha=v.value[fa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){Ga=v.value[fa+0];wa=v.value[fa+1];Ha=v.value[fa+2];v.offsetSrc+=3}if(v.size===2){v.array[E+0]=Ga.x;v.array[E+1]=Ga.y;v.array[E+2]=wa.x;v.array[E+3]=wa.y;v.array[E+4]=Ha.x;v.array[E+5]=Ha.y;v.offset+=6}else if(v.size===3){if(v.type==="c"){v.array[E+0]=Ga.r;v.array[E+1]=Ga.g;v.array[E+2]=Ga.b;v.array[E+3]=wa.r;v.array[E+4]=wa.g;v.array[E+5]=wa.b;v.array[E+6]=Ha.r;v.array[E+7]=Ha.g;v.array[E+8]=Ha.b}else{v.array[E+0]=Ga.x;
-v.array[E+1]=Ga.y;v.array[E+2]=Ga.z;v.array[E+3]=wa.x;v.array[E+4]=wa.y;v.array[E+5]=wa.z;v.array[E+6]=Ha.x;v.array[E+7]=Ha.y;v.array[E+8]=Ha.z}v.offset+=9}else{v.array[E+0]=Ga.x;v.array[E+1]=Ga.y;v.array[E+2]=Ga.z;v.array[E+3]=Ga.w;v.array[E+4]=wa.x;v.array[E+5]=wa.y;v.array[E+6]=wa.z;v.array[E+7]=wa.w;v.array[E+8]=Ha.x;v.array[E+9]=Ha.y;v.array[E+10]=Ha.z;v.array[E+11]=Ha.w;v.offset+=12}}}}if(ub){E=0;for(fa=morphTargets.length;E<fa;E++){Ga=morphTargets[E].vertices[D.a].position;wa=morphTargets[E].vertices[D.b].position;
-Ha=morphTargets[E].vertices[D.c].position;v=Y[E];v[Qa+0]=Ga.x;v[Qa+1]=Ga.y;v[Qa+2]=Ga.z;v[Qa+3]=wa.x;v[Qa+4]=wa.y;v[Qa+5]=wa.z;v[Qa+6]=Ha.x;v[Qa+7]=Ha.y;v[Qa+8]=Ha.z}Qa+=9}if(kb.length){E=kb[D.a];fa=kb[D.b];v=kb[D.c];ha[U]=E.x;ha[U+1]=E.y;ha[U+2]=E.z;ha[U+3]=E.w;ha[U+4]=fa.x;ha[U+5]=fa.y;ha[U+6]=fa.z;ha[U+7]=fa.w;ha[U+8]=v.x;ha[U+9]=v.y;ha[U+10]=v.z;ha[U+11]=v.w;E=pb[D.a];fa=pb[D.b];v=pb[D.c];qa[U]=E.x;qa[U+1]=E.y;qa[U+2]=E.z;qa[U+3]=E.w;qa[U+4]=fa.x;qa[U+5]=fa.y;qa[U+6]=fa.z;qa[U+7]=fa.w;qa[U+8]=
-v.x;qa[U+9]=v.y;qa[U+10]=v.z;qa[U+11]=v.w;E=nb[D.a];fa=nb[D.b];v=nb[D.c];da[U]=E.x;da[U+1]=E.y;da[U+2]=E.z;da[U+3]=1;da[U+4]=fa.x;da[U+5]=fa.y;da[U+6]=fa.z;da[U+7]=1;da[U+8]=v.x;da[U+9]=v.y;da[U+10]=v.z;da[U+11]=1;E=ob[D.a];fa=ob[D.b];v=ob[D.c];ra[U]=E.x;ra[U+1]=E.y;ra[U+2]=E.z;ra[U+3]=1;ra[U+4]=fa.x;ra[U+5]=fa.y;ra[U+6]=fa.z;ra[U+7]=1;ra[U+8]=v.x;ra[U+9]=v.y;ra[U+10]=v.z;ra[U+11]=1;U+=12}if(tb&&Ja){if(L.length==3&&Ja==THREE.VertexColors){D=L[0];E=L[1];fa=L[2]}else fa=E=D=$;ka[Aa]=D.r;ka[Aa+1]=D.g;
-ka[Aa+2]=D.b;ka[Aa+3]=E.r;ka[Aa+4]=E.g;ka[Aa+5]=E.b;ka[Aa+6]=fa.r;ka[Aa+7]=fa.g;ka[Aa+8]=fa.b;Aa+=9}if(sb&&Wa.hasTangents){L=V[0];$=V[1];D=V[2];ia[La]=L.x;ia[La+1]=L.y;ia[La+2]=L.z;ia[La+3]=L.w;ia[La+4]=$.x;ia[La+5]=$.y;ia[La+6]=$.z;ia[La+7]=$.w;ia[La+8]=D.x;ia[La+9]=D.y;ia[La+10]=D.z;ia[La+11]=D.w;La+=12}if(rb&&za)if(S.length==3&&ib)for(V=0;V<3;V++){O=S[V];W[ab]=O.x;W[ab+1]=O.y;W[ab+2]=O.z;ab+=3}else for(V=0;V<3;V++){W[ab]=O.x;W[ab+1]=O.y;W[ab+2]=O.z;ab+=3}if(qb&&ta!==undefined&&xa)for(V=0;V<3;V++){S=
-ta[V];jb[hb]=S.u;jb[hb+1]=S.v;hb+=2}if(qb&&Oa!==undefined&&xa)for(V=0;V<3;V++){S=Oa[V];Xa[eb]=S.u;Xa[eb+1]=S.v;eb+=2}if(gb){Va[$a]=Ma;Va[$a+1]=Ma+1;Va[$a+2]=Ma+2;$a+=3;Ta[cb]=Ma;Ta[cb+1]=Ma+1;Ta[cb+2]=Ma;Ta[cb+3]=Ma+2;Ta[cb+4]=Ma+1;Ta[cb+5]=Ma+2;cb+=6;Ma+=3}}else if(D instanceof THREE.Face4){if(fb){Ga=mb[D.a].position;wa=mb[D.b].position;Ha=mb[D.c].position;Ua=mb[D.d].position;Sa[Pa]=Ga.x;Sa[Pa+1]=Ga.y;Sa[Pa+2]=Ga.z;Sa[Pa+3]=wa.x;Sa[Pa+4]=wa.y;Sa[Pa+5]=wa.z;Sa[Pa+6]=Ha.x;Sa[Pa+7]=Ha.y;Sa[Pa+8]=Ha.z;
-Sa[Pa+9]=Ua.x;Sa[Pa+10]=Ua.y;Sa[Pa+11]=Ua.z;Pa+=12}if(Ia)for(db in Ia){v=Ia[db];if(v.needsUpdate){E=v.offset;fa=v.offsetSrc;if(v.size===1){if(v.boundTo===undefined||v.boundTo==="vertices"){v.array[E+0]=v.value[D.a];v.array[E+1]=v.value[D.b];v.array[E+2]=v.value[D.c];v.array[E+2]=v.value[D.d]}else if(v.boundTo==="faces"){v.array[E+0]=v.value[fa];v.array[E+1]=v.value[fa];v.array[E+2]=v.value[fa];v.array[E+2]=v.value[fa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){v.array[E+0]=v.value[fa+0];v.array[E+
-1]=v.value[fa+1];v.array[E+2]=v.value[fa+2];v.array[E+2]=v.value[fa+3];v.offsetSrc+=4}v.offset+=4}else{if(v.boundTo===undefined||v.boundTo==="vertices"){Ga=v.value[D.a];wa=v.value[D.b];Ha=v.value[D.c];Ua=v.value[D.d]}else if(v.boundTo==="faces"){Ga=v.value[fa];wa=v.value[fa];Ha=v.value[fa];Ua=v.value[fa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){Ga=v.value[fa+0];wa=v.value[fa+1];Ha=v.value[fa+2];Ua=v.value[fa+3];v.offsetSrc+=4}if(v.size===2){v.array[E+0]=Ga.x;v.array[E+1]=Ga.y;v.array[E+2]=
-wa.x;v.array[E+3]=wa.y;v.array[E+4]=Ha.x;v.array[E+5]=Ha.y;v.array[E+6]=Ua.x;v.array[E+7]=Ua.y;v.offset+=8}else if(v.size===3){if(v.type==="c"){v.array[E+0]=Ga.r;v.array[E+1]=Ga.g;v.array[E+2]=Ga.b;v.array[E+3]=wa.r;v.array[E+4]=wa.g;v.array[E+5]=wa.b;v.array[E+6]=Ha.r;v.array[E+7]=Ha.g;v.array[E+8]=Ha.b;v.array[E+9]=Ua.r;v.array[E+10]=Ua.g;v.array[E+11]=Ua.b}else{v.array[E+0]=Ga.x;v.array[E+1]=Ga.y;v.array[E+2]=Ga.z;v.array[E+3]=wa.x;v.array[E+4]=wa.y;v.array[E+5]=wa.z;v.array[E+6]=Ha.x;v.array[E+
-7]=Ha.y;v.array[E+8]=Ha.z;v.array[E+9]=Ua.x;v.array[E+10]=Ua.y;v.array[E+11]=Ua.z}v.offset+=12}else{v.array[E+0]=Ga.x;v.array[E+1]=Ga.y;v.array[E+2]=Ga.z;v.array[E+3]=Ga.w;v.array[E+4]=wa.x;v.array[E+5]=wa.y;v.array[E+6]=wa.z;v.array[E+7]=wa.w;v.array[E+8]=Ha.x;v.array[E+9]=Ha.y;v.array[E+10]=Ha.z;v.array[E+11]=Ha.w;v.array[E+12]=Ua.x;v.array[E+13]=Ua.y;v.array[E+14]=Ua.z;v.array[E+15]=Ua.w;v.offset+=16}}}}if(ub){E=0;for(fa=morphTargets.length;E<fa;E++){Ga=morphTargets[E].vertices[D.a].position;wa=
-morphTargets[E].vertices[D.b].position;Ha=morphTargets[E].vertices[D.c].position;Ua=morphTargets[E].vertices[D.d].position;v=Y[E];v[Qa+0]=Ga.x;v[Qa+1]=Ga.y;v[Qa+2]=Ga.z;v[Qa+3]=wa.x;v[Qa+4]=wa.y;v[Qa+5]=wa.z;v[Qa+6]=Ha.x;v[Qa+7]=Ha.y;v[Qa+8]=Ha.z;v[Qa+9]=Ua.x;v[Qa+10]=Ua.y;v[Qa+11]=Ua.z}Qa+=12}if(kb.length){E=kb[D.a];fa=kb[D.b];v=kb[D.c];bb=kb[D.d];ha[U]=E.x;ha[U+1]=E.y;ha[U+2]=E.z;ha[U+3]=E.w;ha[U+4]=fa.x;ha[U+5]=fa.y;ha[U+6]=fa.z;ha[U+7]=fa.w;ha[U+8]=v.x;ha[U+9]=v.y;ha[U+10]=v.z;ha[U+11]=v.w;ha[U+
-12]=bb.x;ha[U+13]=bb.y;ha[U+14]=bb.z;ha[U+15]=bb.w;E=pb[D.a];fa=pb[D.b];v=pb[D.c];bb=pb[D.d];qa[U]=E.x;qa[U+1]=E.y;qa[U+2]=E.z;qa[U+3]=E.w;qa[U+4]=fa.x;qa[U+5]=fa.y;qa[U+6]=fa.z;qa[U+7]=fa.w;qa[U+8]=v.x;qa[U+9]=v.y;qa[U+10]=v.z;qa[U+11]=v.w;qa[U+12]=bb.x;qa[U+13]=bb.y;qa[U+14]=bb.z;qa[U+15]=bb.w;E=nb[D.a];fa=nb[D.b];v=nb[D.c];bb=nb[D.d];da[U]=E.x;da[U+1]=E.y;da[U+2]=E.z;da[U+3]=1;da[U+4]=fa.x;da[U+5]=fa.y;da[U+6]=fa.z;da[U+7]=1;da[U+8]=v.x;da[U+9]=v.y;da[U+10]=v.z;da[U+11]=1;da[U+12]=bb.x;da[U+13]=
-bb.y;da[U+14]=bb.z;da[U+15]=1;E=ob[D.a];fa=ob[D.b];v=ob[D.c];D=ob[D.d];ra[U]=E.x;ra[U+1]=E.y;ra[U+2]=E.z;ra[U+3]=1;ra[U+4]=fa.x;ra[U+5]=fa.y;ra[U+6]=fa.z;ra[U+7]=1;ra[U+8]=v.x;ra[U+9]=v.y;ra[U+10]=v.z;ra[U+11]=1;ra[U+12]=D.x;ra[U+13]=D.y;ra[U+14]=D.z;ra[U+15]=1;U+=16}if(tb&&Ja){if(L.length==4&&Ja==THREE.VertexColors){D=L[0];E=L[1];fa=L[2];L=L[3]}else L=fa=E=D=$;ka[Aa]=D.r;ka[Aa+1]=D.g;ka[Aa+2]=D.b;ka[Aa+3]=E.r;ka[Aa+4]=E.g;ka[Aa+5]=E.b;ka[Aa+6]=fa.r;ka[Aa+7]=fa.g;ka[Aa+8]=fa.b;ka[Aa+9]=L.r;ka[Aa+
-10]=L.g;ka[Aa+11]=L.b;Aa+=12}if(sb&&Wa.hasTangents){L=V[0];$=V[1];D=V[2];V=V[3];ia[La]=L.x;ia[La+1]=L.y;ia[La+2]=L.z;ia[La+3]=L.w;ia[La+4]=$.x;ia[La+5]=$.y;ia[La+6]=$.z;ia[La+7]=$.w;ia[La+8]=D.x;ia[La+9]=D.y;ia[La+10]=D.z;ia[La+11]=D.w;ia[La+12]=V.x;ia[La+13]=V.y;ia[La+14]=V.z;ia[La+15]=V.w;La+=16}if(rb&&za)if(S.length==4&&ib)for(V=0;V<4;V++){O=S[V];W[ab]=O.x;W[ab+1]=O.y;W[ab+2]=O.z;ab+=3}else for(V=0;V<4;V++){W[ab]=O.x;W[ab+1]=O.y;W[ab+2]=O.z;ab+=3}if(qb&&ta!==undefined&&xa)for(V=0;V<4;V++){S=ta[V];
-jb[hb]=S.u;jb[hb+1]=S.v;hb+=2}if(qb&&Oa!==undefined&&xa)for(V=0;V<4;V++){S=Oa[V];Xa[eb]=S.u;Xa[eb+1]=S.v;eb+=2}if(gb){Va[$a]=Ma;Va[$a+1]=Ma+1;Va[$a+2]=Ma+3;Va[$a+3]=Ma+1;Va[$a+4]=Ma+2;Va[$a+5]=Ma+3;$a+=6;Ta[cb]=Ma;Ta[cb+1]=Ma+1;Ta[cb+2]=Ma;Ta[cb+3]=Ma+3;Ta[cb+4]=Ma+1;Ta[cb+5]=Ma+2;Ta[cb+6]=Ma+2;Ta[cb+7]=Ma+3;cb+=8;Ma+=4}}}if(lb){K=0;for(I=lb.length;K<I;K++){Va[$a]=lb[K].a;Va[$a+1]=lb[K].b;Va[$a+2]=lb[K].c;Va[$a+3]=lb[K].a;Va[$a+4]=lb[K].c;Va[$a+5]=lb[K].d;$a+=6}}if(fb){e.bindBuffer(e.ARRAY_BUFFER,
-x.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Sa,J)}if(Ia)for(db in Ia){v=Ia[db];if(v.needsUpdate){e.bindBuffer(e.ARRAY_BUFFER,v.buffer);e.bufferData(e.ARRAY_BUFFER,v.array,J);v.needsUpdate=!1}}if(ub){E=0;for(fa=morphTargets.length;E<fa;E++){e.bindBuffer(e.ARRAY_BUFFER,x.__webglMorphTargetsBuffers[E]);e.bufferData(e.ARRAY_BUFFER,Y[E],J)}}if(tb&&Aa>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ka,J)}if(rb){e.bindBuffer(e.ARRAY_BUFFER,x.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,
-W,J)}if(sb&&Wa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,x.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ia,J)}if(qb&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,jb,J)}if(qb&&eb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Xa,J)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Va,J);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,
-Ta,J)}if(U>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,da,J);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ra,J);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,qa,J);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ha,J)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=
-!1}else if(n instanceof THREE.Ribbon){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Ja=n.vertices;x=n.colors;za=Ja.length;J=x.length;ta=n.__vertexArray;K=n.__colorArray;Oa=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I<za;I++){xa=Ja[I].position;z=I*3;ta[z]=xa.x;ta[z+1]=xa.y;ta[z+2]=xa.z}e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ta,C)}if(Oa){for(I=0;I<J;I++){color=x[I];z=I*3;K[z]=color.r;K[z+1]=color.g;K[z+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,
-n.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,C)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Line){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Ja=n.vertices;x=n.colors;za=Ja.length;J=x.length;ta=n.__vertexArray;K=n.__colorArray;Oa=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I<za;I++){xa=Ja[I].position;z=I*3;ta[z]=xa.x;ta[z+1]=xa.y;ta[z+2]=xa.z}e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ta,C)}if(Oa){for(I=
-0;I<J;I++){color=x[I];z=I*3;K[z]=color.r;K[z+1]=color.g;K[z+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,C)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(n instanceof THREE.ParticleSystem){w=n.geometry;(w.__dirtyVertices||w.__dirtyColors||n.sortParticles)&&d(w,e.DYNAMIC_DRAW,n);w.__dirtyVertices=!1;w.__dirtyColors=!1}}function X(n){function C($){var V=[];w=0;for(x=$.length;w<x;w++)$[w]==undefined?V.push("undefined"):V.push($[w].id);return V.join("_")}
-var w,x,z,J,K,I,S,D,O={},L=n.morphTargets!==undefined?n.morphTargets.length:0;n.geometryGroups={};z=0;for(J=n.faces.length;z<J;z++){K=n.faces[z];I=K.materials;S=C(I);O[S]==undefined&&(O[S]={hash:S,counter:0});D=O[S].hash+"_"+O[S].counter;n.geometryGroups[D]==undefined&&(n.geometryGroups[D]={faces:[],materials:I,vertices:0,numMorphTargets:L});K=K instanceof THREE.Face3?3:4;if(n.geometryGroups[D].vertices+K>65535){O[S].counter+=1;D=O[S].hash+"_"+O[S].counter;n.geometryGroups[D]==undefined&&(n.geometryGroups[D]=
-{faces:[],materials:I,vertices:0,numMorphTargets:L})}n.geometryGroups[D].faces.push(z);n.geometryGroups[D].vertices+=K}}function A(n,C,w){n.push({buffer:C,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(n){if(n!=ga){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);
-e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}ga=n}}function Q(n,C,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,ca(C.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,ca(C.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,ca(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ca(C.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,
-e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,va(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,va(C.minFilter))}}function R(n,C){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,
-n.image);n.__webglInit=!0}Q(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+C);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function Da(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer();n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,
-e.TEXTURE_WRAP_S,ca(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,ca(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,ca(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,ca(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,ca(n.format),n.width,n.height,0,ca(n.format),ca(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,
-0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,
-null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,w;if(n){C=n.__webglFramebuffer;w=n.width;n=n.height}else{C=null;w=ja;n=la}if(C!=Fa){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(na,Ea,w,n);Fa=C}}function ma(n,C){var w;if(n=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,C);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(C);
-return null}return w}function va(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function ca(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;
-case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;
-case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var e,ea=document.createElement("canvas"),ya=[],Ba=null,Fa=null,Z=!0,oa=this,pa=null,sa=null,ga=null,aa=null,na=0,Ea=0,ja=0,la=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ra=new THREE.Matrix4,Ya=new Float32Array(16),Za=new Float32Array(16),Na=new THREE.Vector4,
-T={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.maxMorphTargets=8;this.domElement=ea;this.autoClear=!0;this.sortObjects=!0;(function(n,C,w,x){try{if(!(e=ea.getContext("experimental-webgl",{antialias:n,
-stencil:x})))throw"Error creating WebGL context.";}catch(z){console.error(z)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r,
-C.g,C.b,w)})(antialias,clearColor,clearAlpha,stencil);this.context=e;if(stencil){var P={};P.vertices=new Float32Array(12);P.faces=new Uint16Array(6);P.darkness=0.5;P.vertices[0]=-20;P.vertices[1]=-20;P.vertices[2]=-1;P.vertices[3]=20;P.vertices[4]=-20;P.vertices[5]=-1;P.vertices[6]=20;P.vertices[7]=20;P.vertices[8]=-1;P.vertices[9]=-20;P.vertices[10]=20;P.vertices[11]=-1;P.faces[0]=0;P.faces[1]=1;P.faces[2]=2;P.faces[3]=0;P.faces[4]=2;P.faces[5]=3;P.vertexBuffer=e.createBuffer();P.elementBuffer=e.createBuffer();
-e.bindBuffer(e.ARRAY_BUFFER,P.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,P.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,P.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,P.faces,e.STATIC_DRAW);P.program=e.createProgram();e.attachShader(P.program,ma("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(P.program,ma("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(P.program);P.vertexLocation=e.getAttribLocation(P.program,"position");P.projectionLocation=
-e.getUniformLocation(P.program,"projectionMatrix");P.darknessLocation=e.getUniformLocation(P.program,"darkness")}var N={};N.vertices=new Float32Array(16);N.faces=new Uint16Array(6);b=0;N.vertices[b++]=-1;N.vertices[b++]=-1;N.vertices[b++]=0;N.vertices[b++]=0;N.vertices[b++]=1;N.vertices[b++]=-1;N.vertices[b++]=1;N.vertices[b++]=0;N.vertices[b++]=1;N.vertices[b++]=1;N.vertices[b++]=1;N.vertices[b++]=1;N.vertices[b++]=-1;N.vertices[b++]=1;N.vertices[b++]=0;N.vertices[b++]=1;b=0;N.faces[b++]=0;N.faces[b++]=
-1;N.faces[b++]=2;N.faces[b++]=0;N.faces[b++]=2;N.faces[b++]=3;N.vertexBuffer=e.createBuffer();N.elementBuffer=e.createBuffer();N.tempTexture=e.createTexture();N.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,N.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,N.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,N.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,N.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,N.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,
-null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,N.occlusionTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,
-e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){N.hasVertexTexture=!1;N.program=e.createProgram();e.attachShader(N.program,ma("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(N.program,ma("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{N.hasVertexTexture=!0;N.program=e.createProgram();e.attachShader(N.program,ma("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));
-e.attachShader(N.program,ma("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(N.program);N.attributes={};N.uniforms={};N.attributes.vertex=e.getAttribLocation(N.program,"position");N.attributes.uv=e.getAttribLocation(N.program,"UV");N.uniforms.renderType=e.getUniformLocation(N.program,"renderType");N.uniforms.map=e.getUniformLocation(N.program,"map");N.uniforms.occlusionMap=e.getUniformLocation(N.program,"occlusionMap");N.uniforms.opacity=e.getUniformLocation(N.program,
-"opacity");N.uniforms.scale=e.getUniformLocation(N.program,"scale");N.uniforms.rotation=e.getUniformLocation(N.program,"rotation");N.uniforms.screenPosition=e.getUniformLocation(N.program,"screenPosition");var Ca=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=
-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
-_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,ma("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,ma("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");
-_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");
-_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var Ka=!1;this.setSize=function(n,C){ea.width=
-n;ea.height=C;this.setViewport(0,0,ea.width,ea.height)};this.setViewport=function(n,C,w,x){na=n;Ea=C;ja=w;la=x;e.viewport(na,Ea,ja,la)};this.setScissor=function(n,C,w,x){e.scissor(n,C,w,x)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){Z=n;e.depthMask(n)};this.setClearColorHex=function(n,C){var w=new THREE.Color(n);e.clearColor(w.r,w.g,w.b,C)};this.setClearColor=function(n,C){e.clearColor(n.r,n.g,n.b,C)};this.clear=
-function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){P.darkness=n};this.initMaterial=function(n,C,w,x){var z,J,K;if(n instanceof THREE.MeshDepthMaterial)K="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)K="shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)K="normal";else if(n instanceof THREE.MeshBasicMaterial)K="basic";else if(n instanceof THREE.MeshLambertMaterial)K="lambert";else if(n instanceof
-THREE.MeshPhongMaterial)K="phong";else if(n instanceof THREE.LineBasicMaterial)K="basic";else n instanceof THREE.ParticleBasicMaterial&&(K="particle_basic");if(K){var I=THREE.ShaderLib[K];n.uniforms=THREE.UniformsUtils.clone(I.uniforms);n.vertexShader=I.vertexShader;n.fragmentShader=I.fragmentShader}var S,D,O;S=O=I=0;for(D=C.length;S<D;S++){J=C[S];J instanceof THREE.DirectionalLight&&O++;J instanceof THREE.PointLight&&I++}if(I+O<=4)C=O;else{C=Math.ceil(4*O/(I+O));I=4-C}J={directional:C,point:I};O=
-50;if(x!==undefined&&x instanceof THREE.SkinnedMesh)O=x.bones.length;var L;a:{S=n.fragmentShader;D=n.vertexShader;I=n.uniforms;C=n.attributes;w={map:!!n.map,envMap:!!n.envMap,lightMap:!!n.lightMap,vertexColors:n.vertexColors,fog:w,sizeAttenuation:n.sizeAttenuation,skinning:n.skinning,morphTargets:n.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:J.directional,maxPointLights:J.point,maxBones:O};var $;J=[];if(K)J.push(K);else{J.push(S);J.push(D)}for($ in w){J.push($);J.push(w[$])}K=J.join();
-$=0;for(J=ya.length;$<J;$++)if(ya[$].code==K){L=ya[$].program;break a}$=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
-prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,"#define MAX_BONES "+w.maxBones,w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"",w.skinning?"#define USE_SKINNING":"",w.morphTargets?"#define USE_MORPHTARGETS":"",w.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-e.attachShader($,ma("fragment",prefix_fragment+S));e.attachShader($,ma("vertex",prefix_vertex+D));e.linkProgram($);e.getProgramParameter($,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter($,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");$.uniforms={};$.attributes={};var V;S=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(V in I)S.push(V);
-V=S;I=0;for(S=V.length;I<S;I++){D=V[I];$.uniforms[D]=e.getUniformLocation($,D)}S=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(V=0;V<w.maxMorphTargets;V++)S.push("morphTarget"+V);for(L in C)S.push(L);L=S;V=0;for(C=L.length;V<C;V++){w=L[V];$.attributes[w]=e.getAttribLocation($,w)}ya.push({program:$,code:K});L=$}n.program=L;L=n.program.attributes;e.enableVertexAttribArray(L.position);L.color>=0&&e.enableVertexAttribArray(L.color);L.normal>=
-0&&e.enableVertexAttribArray(L.normal);L.tangent>=0&&e.enableVertexAttribArray(L.tangent);if(n.skinning&&L.skinVertexA>=0&&L.skinVertexB>=0&&L.skinIndex>=0&&L.skinWeight>=0){e.enableVertexAttribArray(L.skinVertexA);e.enableVertexAttribArray(L.skinVertexB);e.enableVertexAttribArray(L.skinIndex);e.enableVertexAttribArray(L.skinWeight)}for(z in n.attributes)L[z]>=0&&e.enableVertexAttribArray(L[z]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(L.morphTarget0>=0){e.enableVertexAttribArray(L.morphTarget0);
+THREE.WebGLRenderer=function(b){function d(n,C,w){var x,y,Q,K=n.vertices,F=K.length,T=n.colors,G=T.length,I=n.__vertexArray,L=n.__colorArray,Z=n.__sortArray,Y=n.__dirtyVertices,qa=n.__dirtyColors;if(w.sortParticles){Ja.multiplySelf(w.matrixWorld);for(x=0;x<F;x++){y=K[x].position;Ta.copy(y);Ja.multiplyVector3(Ta);Z[x]=[Ta.z,x]}Z.sort(function(Ka,Ca){return Ca[0]-Ka[0]});for(x=0;x<F;x++){y=K[Z[x][1]].position;Q=x*3;I[Q]=y.x;I[Q+1]=y.y;I[Q+2]=y.z}for(x=0;x<G;x++){Q=x*3;color=T[Z[x][1]];L[Q]=color.r;
+L[Q+1]=color.g;L[Q+2]=color.b}}else{if(Y)for(x=0;x<F;x++){y=K[x].position;Q=x*3;I[Q]=y.x;I[Q+1]=y.y;I[Q+2]=y.z}if(qa)for(x=0;x<G;x++){color=T[x];Q=x*3;L[Q]=color.r;L[Q+1]=color.g;L[Q+2]=color.b}}if(Y||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,I,C)}if(qa||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,L,C)}}function c(n,C,w,x,y){x.program||ha.initMaterial(x,C,w,y);var Q=x.program,K=Q.uniforms,F=x.uniforms;
+if(Q!=Aa){e.useProgram(Q);Aa=Q}e.uniformMatrix4fv(K.projectionMatrix,!1,Xa);if(w&&(x instanceof THREE.MeshBasicMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshPhongMaterial||x instanceof THREE.LineBasicMaterial||x instanceof THREE.ParticleBasicMaterial||x.fog)){F.fogColor.value=w.color;if(w instanceof THREE.Fog){F.fogNear.value=w.near;F.fogFar.value=w.far}else if(w instanceof THREE.FogExp2)F.fogDensity.value=w.density}if(x instanceof THREE.MeshPhongMaterial||x instanceof THREE.MeshLambertMaterial||
+x.lights){var T,G,I=0,L=0,Z=0,Y,qa,Ka,Ca,Ha=R,Ga=Ha.directional.colors,xa=Ha.directional.positions,Ea=Ha.point.colors,za=Ha.point.positions,Ua=Ha.point.distances,D=0,aa=0;w=G=Ca=0;for(T=C.length;w<T;w++){G=C[w];Y=G.color;qa=G.position;Ka=G.intensity;Ca=G.distance;if(G instanceof THREE.AmbientLight){I+=Y.r;L+=Y.g;Z+=Y.b}else if(G instanceof THREE.DirectionalLight){Ca=D*3;Ga[Ca]=Y.r*Ka;Ga[Ca+1]=Y.g*Ka;Ga[Ca+2]=Y.b*Ka;xa[Ca]=qa.x;xa[Ca+1]=qa.y;xa[Ca+2]=qa.z;D+=1}else if(G instanceof THREE.PointLight){G=
+aa*3;Ea[G]=Y.r*Ka;Ea[G+1]=Y.g*Ka;Ea[G+2]=Y.b*Ka;za[G]=qa.x;za[G+1]=qa.y;za[G+2]=qa.z;Ua[aa]=Ca;aa+=1}}for(w=D*3;w<Ga.length;w++)Ga[w]=0;for(w=aa*3;w<Ea.length;w++)Ea[w]=0;Ha.point.length=aa;Ha.directional.length=D;Ha.ambient[0]=I;Ha.ambient[1]=L;Ha.ambient[2]=Z;w=R;F.enableLighting.value=w.directional.length+w.point.length;F.ambientLightColor.value=w.ambient;F.directionalLightColor.value=w.directional.colors;F.directionalLightDirection.value=w.directional.positions;F.pointLightColor.value=w.point.colors;
+F.pointLightPosition.value=w.point.positions;F.pointLightDistance.value=w.point.distances}if(x instanceof THREE.MeshBasicMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshPhongMaterial){F.diffuse.value=x.color;F.opacity.value=x.opacity;F.map.texture=x.map;F.lightMap.texture=x.lightMap;F.envMap.texture=x.envMap;F.reflectivity.value=x.reflectivity;F.refractionRatio.value=x.refractionRatio;F.combine.value=x.combine;F.useRefract.value=x.envMap&&x.envMap.mapping instanceof THREE.CubeRefractionMapping}if(x instanceof
+THREE.LineBasicMaterial){F.diffuse.value=x.color;F.opacity.value=x.opacity}else if(x instanceof THREE.ParticleBasicMaterial){F.psColor.value=x.color;F.opacity.value=x.opacity;F.size.value=x.size;F.scale.value=oa.height/2;F.map.texture=x.map}else if(x instanceof THREE.MeshPhongMaterial){F.ambient.value=x.ambient;F.specular.value=x.specular;F.shininess.value=x.shininess}else if(x instanceof THREE.MeshDepthMaterial){F.mNear.value=n.near;F.mFar.value=n.far;F.opacity.value=x.opacity}else if(x instanceof
+THREE.MeshNormalMaterial)F.opacity.value=x.opacity;for(var v in F)if(L=Q.uniforms[v]){T=F[v];I=T.type;w=T.value;if(I=="i")e.uniform1i(L,w);else if(I=="f")e.uniform1f(L,w);else if(I=="fv1")e.uniform1fv(L,w);else if(I=="fv")e.uniform3fv(L,w);else if(I=="v2")e.uniform2f(L,w.x,w.y);else if(I=="v3")e.uniform3f(L,w.x,w.y,w.z);else if(I=="v4")e.uniform4f(L,w.x,w.y,w.z,w.w);else if(I=="c")e.uniform3f(L,w.r,w.g,w.b);else if(I=="t"){e.uniform1i(L,w);if(T=T.texture)if(T.image instanceof Array&&T.image.length==
+6){if(T.image.length==6){if(T.needsUpdate){if(T.__webglInit){e.bindTexture(e.TEXTURE_CUBE_MAP,T.image.__webglTextureCube);for(I=0;I<6;++I)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+I,0,0,0,e.RGBA,e.UNSIGNED_BYTE,T.image[I])}else{T.image.__webglTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,T.image.__webglTextureCube);for(I=0;I<6;++I)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+I,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,T.image[I]);T.__webglInit=!0}N(e.TEXTURE_CUBE_MAP,T,T.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,
+null);T.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_CUBE_MAP,T.image.__webglTextureCube)}}else O(T,w)}}e.uniformMatrix4fv(K.modelViewMatrix,!1,y._modelViewMatrixArray);e.uniformMatrix3fv(K.normalMatrix,!1,y._normalMatrixArray);(x instanceof THREE.MeshShaderMaterial||x instanceof THREE.MeshPhongMaterial||x.envMap)&&e.uniform3f(K.cameraPosition,n.position.x,n.position.y,n.position.z);(x instanceof THREE.MeshShaderMaterial||x.envMap||x.skinning)&&e.uniformMatrix4fv(K.objectMatrix,
+!1,y._objectMatrixArray);(x instanceof THREE.MeshPhongMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshShaderMaterial||x.skinning)&&e.uniformMatrix4fv(K.viewMatrix,!1,Za);if(x instanceof THREE.ShadowVolumeDynamicMaterial){n=F.directionalLightDirection.value;n[0]=-C[1].position.x;n[1]=-C[1].position.y;n[2]=-C[1].position.z;e.uniform3fv(K.directionalLightDirection,n);e.uniformMatrix4fv(K.objectMatrix,!1,y._objectMatrixArray);e.uniformMatrix4fv(K.viewMatrix,!1,Za)}if(x.skinning){e.uniformMatrix4fv(K.cameraInverseMatrix,
+!1,Za);e.uniformMatrix4fv(K.boneGlobalMatrices,!1,y.boneMatrices)}return Q}function f(n,C,w,x,y,Q){if(x.opacity!=0){var K;n=c(n,C,w,x,Q).attributes;if(x.morphTargets){C=x.program.attributes;Q.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,y.__webglMorphTargetsBuffers[Q.morphTargetBase]):e.bindBuffer(e.ARRAY_BUFFER,y.__webglVertexBuffer);e.vertexAttribPointer(C.position,3,e.FLOAT,!1,0,0);if(Q.morphTargetForcedOrder.length){w=0;for(var F=Q.morphTargetForcedOrder,T=Q.morphTargetInfluences;w<x.numSupportedMorphTargets&&
+w<F.length;){e.bindBuffer(e.ARRAY_BUFFER,y.__webglMorphTargetsBuffers[F[w]]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0);Q.__webglMorphTargetInfluences[w]=T[F[w]];w++}}else{F=[];var G=-1,I=0;T=Q.morphTargetInfluences;var L,Z=T.length;w=0;for(Q.morphTargetBase!==-1&&(F[Q.morphTargetBase]=!0);w<x.numSupportedMorphTargets;){for(L=0;L<Z;L++)if(!F[L]&&T[L]>G){I=L;G=T[I]}e.bindBuffer(e.ARRAY_BUFFER,y.__webglMorphTargetsBuffers[I]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0);
+Q.__webglMorphTargetInfluences[w]=G;F[I]=1;G=-1;w++}}e.uniform1fv(x.program.uniforms.morphTargetInfluences,Q.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,y.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}if(y.__webglCustomAttributes)for(K in y.__webglCustomAttributes)if(n[K]>=0){C=y.__webglCustomAttributes[K];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(n[K],C.size,e.FLOAT,!1,0,0)}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webglColorBuffer);
+e.vertexAttribPointer(n.color,3,e.FLOAT,!1,0,0)}if(n.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webglNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,!1,0,0)}if(n.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webglTangentBuffer);e.vertexAttribPointer(n.tangent,4,e.FLOAT,!1,0,0)}if(n.uv>=0)if(y.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webglUVBuffer);e.vertexAttribPointer(n.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv)}else e.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(y.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,
+y.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(x.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex,
+4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(Q instanceof THREE.Mesh){if(x.wireframe){e.lineWidth(x.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webglLineBuffer);e.drawElements(e.LINES,y.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webglFaceBuffer);e.drawElements(e.TRIANGLES,y.__webglFaceCount,e.UNSIGNED_SHORT,0)}ha.data.vertices+=y.__webglFaceCount;ha.data.faces+=
+y.__webglFaceCount/3}else if(Q instanceof THREE.Line){Q=Q.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(x.linewidth);e.drawArrays(Q,0,y.__webglLineCount)}else if(Q instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webglParticleCount);else Q instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webglVertexCount)}}function g(n,C,w){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER,
+n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(C.attributes.position);e.vertexAttribPointer(C.attributes.position,3,e.FLOAT,!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(w==THREE.FlatShading){var x,y,Q,K,F,T,G,I,L,Z,Y=n.count*3;for(Z=0;Z<Y;Z+=9){w=n.normalArray;x=w[Z];y=w[Z+1];Q=w[Z+2];K=w[Z+3];T=w[Z+4];I=w[Z+5];F=w[Z+6];G=w[Z+7];L=w[Z+8];x=(x+K+F)/3;y=(y+T+G)/3;Q=(Q+I+L)/3;w[Z]=x;w[Z+1]=y;w[Z+2]=Q;w[Z+3]=
+x;w[Z+4]=y;w[Z+5]=Q;w[Z+6]=x;w[Z+7]=y;w[Z+8]=Q}}e.bufferData(e.ARRAY_BUFFER,n.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(C.attributes.normal);e.vertexAttribPointer(C.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,n.count);n.count=0}function h(n){if(va!=n.doubleSided){n.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);va=n.doubleSided}if(sa!=n.flipSided){n.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);sa=n.flipSided}}function j(n){if(ca!=n){n?e.enable(e.DEPTH_TEST):
+e.disable(e.DEPTH_TEST);ca=n}}function k(n){da[0].set(n.n41-n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);da[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);da[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);da[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);da[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);da[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var C;for(n=0;n<6;n++){C=da[n];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function m(n){for(var C=
+n.matrixWorld,w=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),x=0;x<6;x++){n=da[x].x*C.n14+da[x].y*C.n24+da[x].z*C.n34+da[x].w;if(n<=w)return!1}return!0}function o(n,C){n.list[n.count]=C;n.count+=1}function p(n){var C,w,x=n.object,y=n.opaque,Q=n.transparent;Q.count=0;n=y.count=0;for(C=x.materials.length;n<C;n++){w=x.materials[n];w.transparent?o(Q,w):o(y,w)}}function t(n){var C,w,x,y,Q=n.object,K=n.buffer,F=n.opaque,T=n.transparent;T.count=0;n=F.count=0;for(x=
+Q.materials.length;n<x;n++){C=Q.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=0;for(w=K.materials.length;C<w;C++)(y=K.materials[C])&&(y.transparent?o(T,y):o(F,y))}else(y=C)&&(y.transparent?o(T,y):o(F,y))}}function z(n,C){return C.z-n.z}function u(n){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,e.KEEP);e.stencilOpSeparate(e.FRONT,
+e.KEEP,e.DECR,e.KEEP);var C,w=n.lights.length,x,y=n.lights,Q=[],K,F,T,G,I,L=n.__webglShadowVolumes.length;for(C=0;C<w;C++){x=n.lights[C];if(x instanceof THREE.DirectionalLight){Q[0]=-x.position.x;Q[1]=-x.position.y;Q[2]=-x.position.z;for(I=0;I<L;I++){x=n.__webglShadowVolumes[I].object;K=n.__webglShadowVolumes[I].buffer;F=x.materials[0];F.program||ha.initMaterial(F,y,undefined,x);F=F.program;T=F.uniforms;G=F.attributes;if(Aa!==F){e.useProgram(F);Aa=F;e.uniformMatrix4fv(T.projectionMatrix,!1,Xa);e.uniformMatrix4fv(T.viewMatrix,
+!1,Za);e.uniform3fv(T.directionalLightDirection,Q)}x.matrixWorld.flattenToArray(x._objectMatrixArray);e.uniformMatrix4fv(T.objectMatrix,!1,x._objectMatrixArray);e.bindBuffer(e.ARRAY_BUFFER,K.__webglVertexBuffer);e.vertexAttribPointer(G.position,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,K.__webglNormalBuffer);e.vertexAttribPointer(G.normal,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,K.__webglFaceBuffer);e.cullFace(e.FRONT);e.drawElements(e.TRIANGLES,K.__webglFaceCount,e.UNSIGNED_SHORT,
+0);e.cullFace(e.BACK);e.drawElements(e.TRIANGLES,K.__webglFaceCount,e.UNSIGNED_SHORT,0)}}}e.disable(e.POLYGON_OFFSET_FILL);e.colorMask(!0,!0,!0,!0);e.stencilFunc(e.NOTEQUAL,0,255);e.stencilOp(e.KEEP,e.KEEP,e.KEEP);e.disable(e.DEPTH_TEST);wa="";Aa=S.program;e.useProgram(S.program);e.uniformMatrix4fv(S.projectionLocation,!1,Xa);e.uniform1f(S.darknessLocation,S.darkness);e.bindBuffer(e.ARRAY_BUFFER,S.vertexBuffer);e.vertexAttribPointer(S.vertexLocation,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(S.vertexLocation);
+e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.blendEquation(e.FUNC_ADD);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,S.elementBuffer);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.disable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(fa)}function A(n,C){var w,x,y;w=_sprite.attributes;var Q=_sprite.uniforms,K=ia/Fa,F,T=[],G=Fa*0.5,I=ia*0.5,L=!0;e.useProgram(_sprite.program);Aa=_sprite.program;wa="";if(!La){e.enableVertexAttribArray(_sprite.attributes.position);e.enableVertexAttribArray(_sprite.attributes.uv);
+La=!0}e.disable(e.CULL_FACE);e.enable(e.BLEND);e.depthMask(!0);e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.vertexAttribPointer(w.position,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(w.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.uniformMatrix4fv(Q.projectionMatrix,!1,Xa);e.activeTexture(e.TEXTURE0);e.uniform1i(Q.map,0);w=0;for(x=n.__webglSprites.length;w<x;w++){y=n.__webglSprites[w];if(y.useScreenCoordinates)y.z=-y.position.z;else{y._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,
+y.matrixWorld,y._modelViewMatrixArray);y.z=-y._modelViewMatrix.n34}}n.__webglSprites.sort(z);w=0;for(x=n.__webglSprites.length;w<x;w++){y=n.__webglSprites[w];if(y.material===undefined&&y.map&&y.map.image&&y.map.image.width){if(y.useScreenCoordinates){e.uniform1i(Q.useScreenCoordinates,1);e.uniform3f(Q.screenPosition,(y.position.x-G)/G,(I-y.position.y)/I,Math.max(0,Math.min(1,y.position.z)))}else{e.uniform1i(Q.useScreenCoordinates,0);e.uniform1i(Q.affectedByDistance,y.affectedByDistance?1:0);e.uniformMatrix4fv(Q.modelViewMatrix,
+!1,y._modelViewMatrixArray)}F=y.map.image.width/(y.affectedByDistance?1:ia);T[0]=F*K*y.scale.x;T[1]=F*y.scale.y;e.uniform2f(Q.uvScale,y.uvScale.x,y.uvScale.y);e.uniform2f(Q.uvOffset,y.uvOffset.x,y.uvOffset.y);e.uniform2f(Q.alignment,y.alignment.x,y.alignment.y);e.uniform1f(Q.opacity,y.opacity);e.uniform1f(Q.rotation,y.rotation);e.uniform2fv(Q.scale,T);if(y.mergeWith3D&&!L){e.enable(e.DEPTH_TEST);L=!0}else if(!y.mergeWith3D&&L){e.disable(e.DEPTH_TEST);L=!1}U(y.blending);O(y.map,0);e.drawElements(e.TRIANGLES,
+6,e.UNSIGNED_SHORT,0)}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(fa)}function E(n,C){var w,x,y=n.__webglLensFlares.length,Q,K,F,T=new THREE.Vector3,G=ia/Fa,I=Fa*0.5,L=ia*0.5,Z=16/ia,Y=[Z*G,Z],qa=[1,1,0],Ka=[1,1],Ca=P.uniforms;w=P.attributes;e.useProgram(P.program);Aa=P.program;wa="";if(!Ba){e.enableVertexAttribArray(P.attributes.vertex);e.enableVertexAttribArray(P.attributes.uv);Ba=!0}e.uniform1i(Ca.occlusionMap,0);e.uniform1i(Ca.map,1);e.bindBuffer(e.ARRAY_BUFFER,P.vertexBuffer);e.vertexAttribPointer(w.vertex,
+2,e.FLOAT,!1,16,0);e.vertexAttribPointer(w.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,P.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,P.occlusionTexture);e.activeTexture(e.TEXTURE1);for(x=0;x<y;x++){w=n.__webglLensFlares[x].object;T.set(w.matrixWorld.n14,w.matrixWorld.n24,w.matrixWorld.n34);C.matrixWorldInverse.multiplyVector3(T);C.projectionMatrix.multiplyVector3(T);qa[0]=T.x;qa[1]=T.y;qa[2]=T.z;Ka[0]=qa[0]*I+I;Ka[1]=qa[1]*
+L+L;if(P.hasVertexTexture||Ka[0]>0&&Ka[0]<Fa&&Ka[1]>0&&Ka[1]<ia){e.bindTexture(e.TEXTURE_2D,P.tempTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGB,Ka[0]-8,Ka[1]-8,16,16,0);e.uniform1i(Ca.renderType,0);e.uniform2fv(Ca.scale,Y);e.uniform3fv(Ca.screenPosition,qa);e.disable(e.BLEND);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.bindTexture(e.TEXTURE_2D,P.occlusionTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,Ka[0]-8,Ka[1]-8,16,16,0);e.uniform1i(Ca.renderType,1);e.disable(e.DEPTH_TEST);
+e.bindTexture(e.TEXTURE_2D,P.tempTexture);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);w.positionScreen.x=qa[0];w.positionScreen.y=qa[1];w.positionScreen.z=qa[2];w.customUpdateCallback?w.customUpdateCallback(w):w.updateLensFlares();e.uniform1i(Ca.renderType,2);e.enable(e.BLEND);Q=0;for(K=w.lensFlares.length;Q<K;Q++){F=w.lensFlares[Q];if(F.opacity>0.001&&F.scale>0.001){qa[0]=F.x;qa[1]=F.y;qa[2]=F.z;Z=F.size*F.scale/ia;Y[0]=Z*G;Y[1]=Z;e.uniform3fv(Ca.screenPosition,qa);e.uniform2fv(Ca.scale,Y);
+e.uniform1f(Ca.rotation,F.rotation);e.uniform1f(Ca.opacity,F.opacity);U(F.blending);O(F.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(fa)}function H(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function J(n){var C,w,x,y,Q;if(n instanceof THREE.Mesh){w=n.geometry;for(C in w.geometryGroups){x=
+w.geometryGroups[C];Q=!1;for(y in x.__webglCustomAttributes)if(x.__webglCustomAttributes[y].needsUpdate){Q=!0;break}if(w.__dirtyVertices||w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents||Q){Q=e.DYNAMIC_DRAW;var K=void 0,F=void 0,T=void 0,G=void 0;T=void 0;var I=void 0,L=void 0,Z=void 0,Y=void 0,qa=void 0,Ka=void 0,Ca=void 0,Ha=void 0,Ga=void 0,xa=void 0,Ea=void 0,za=void 0,Ua=void 0;L=void 0;Z=void 0;G=void 0;Y=void 0;G=void 0;var D=void 0,
+aa=void 0;L=void 0;D=void 0;aa=void 0;var v=void 0,ab=void 0;D=void 0;aa=void 0;v=void 0;ab=void 0;D=void 0;aa=void 0;v=void 0;ab=void 0;D=void 0;aa=void 0;v=void 0;G=void 0;Y=void 0;I=void 0;T=void 0;T=void 0;D=void 0;aa=void 0;v=void 0;var fb=void 0,Oa=0,Qa=0,cb=0,hb=0,Wa=0,$a=0,Ma=0,bb=0,Va=0,M=0,Na=0;aa=D=0;var Ra=x.__vertexArray,ib=x.__uvArray,jb=x.__uv2Array,Pa=x.__normalArray,V=x.__tangentArray,na=x.__colorArray,ea=x.__skinVertexAArray,$=x.__skinVertexBArray,ta=x.__skinIndexArray,ra=x.__skinWeightArray,
+ya=x.__morphTargetsArrays,X=x.__webglCustomAttributes;v=void 0;var Ia=x.__faceArray,Ya=x.__lineArray,eb=x.__needsSmoothNormals;Ka=x.__vertexColorType;qa=x.__uvType;Ca=x.__normalType;var Sa=n.geometry,kb=Sa.__dirtyVertices,gb=Sa.__dirtyElements,db=Sa.__dirtyUvs,rb=Sa.__dirtyNormals,sb=Sa.__dirtyTangents,tb=Sa.__dirtyColors,ub=Sa.__dirtyMorphTargets,nb=Sa.vertices,vb=x.faces,yb=Sa.faces,wb=Sa.faceVertexUvs[0],xb=Sa.faceVertexUvs[1],ob=Sa.skinVerticesA,pb=Sa.skinVerticesB,qb=Sa.skinIndices,lb=Sa.skinWeights,
+mb=n instanceof THREE.ShadowVolume?Sa.edgeFaces:undefined;morphTargets=Sa.morphTargets;if(X)for(fb in X){X[fb].offset=0;X[fb].offsetSrc=0}K=0;for(F=vb.length;K<F;K++){T=vb[K];G=yb[T];wb&&(Ha=wb[T]);xb&&(Ga=xb[T]);T=G.vertexNormals;I=G.normal;L=G.vertexColors;Z=G.color;Y=G.vertexTangents;if(G instanceof THREE.Face3){if(kb){xa=nb[G.a].position;Ea=nb[G.b].position;za=nb[G.c].position;Ra[Qa]=xa.x;Ra[Qa+1]=xa.y;Ra[Qa+2]=xa.z;Ra[Qa+3]=Ea.x;Ra[Qa+4]=Ea.y;Ra[Qa+5]=Ea.z;Ra[Qa+6]=za.x;Ra[Qa+7]=za.y;Ra[Qa+8]=
+za.z;Qa+=9}if(X)for(fb in X){v=X[fb];if(v.needsUpdate){D=v.offset;aa=v.offsetSrc;if(v.size===1){if(v.boundTo===undefined||v.boundTo==="vertices"){v.array[D+0]=v.value[G.a];v.array[D+1]=v.value[G.b];v.array[D+2]=v.value[G.c]}else if(v.boundTo==="faces"){v.array[D+0]=v.value[aa];v.array[D+1]=v.value[aa];v.array[D+2]=v.value[aa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){v.array[D+0]=v.value[aa+0];v.array[D+1]=v.value[aa+1];v.array[D+2]=v.value[aa+2];v.offsetSrc+=3}v.offset+=3}else{if(v.boundTo===
+undefined||v.boundTo==="vertices"){xa=v.value[G.a];Ea=v.value[G.b];za=v.value[G.c]}else if(v.boundTo==="faces"){xa=v.value[aa];Ea=v.value[aa];za=v.value[aa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){xa=v.value[aa+0];Ea=v.value[aa+1];za=v.value[aa+2];v.offsetSrc+=3}if(v.size===2){v.array[D+0]=xa.x;v.array[D+1]=xa.y;v.array[D+2]=Ea.x;v.array[D+3]=Ea.y;v.array[D+4]=za.x;v.array[D+5]=za.y;v.offset+=6}else if(v.size===3){if(v.type==="c"){v.array[D+0]=xa.r;v.array[D+1]=xa.g;v.array[D+2]=xa.b;v.array[D+
+3]=Ea.r;v.array[D+4]=Ea.g;v.array[D+5]=Ea.b;v.array[D+6]=za.r;v.array[D+7]=za.g;v.array[D+8]=za.b}else{v.array[D+0]=xa.x;v.array[D+1]=xa.y;v.array[D+2]=xa.z;v.array[D+3]=Ea.x;v.array[D+4]=Ea.y;v.array[D+5]=Ea.z;v.array[D+6]=za.x;v.array[D+7]=za.y;v.array[D+8]=za.z}v.offset+=9}else{v.array[D+0]=xa.x;v.array[D+1]=xa.y;v.array[D+2]=xa.z;v.array[D+3]=xa.w;v.array[D+4]=Ea.x;v.array[D+5]=Ea.y;v.array[D+6]=Ea.z;v.array[D+7]=Ea.w;v.array[D+8]=za.x;v.array[D+9]=za.y;v.array[D+10]=za.z;v.array[D+11]=za.w;v.offset+=
+12}}}}if(ub){D=0;for(aa=morphTargets.length;D<aa;D++){xa=morphTargets[D].vertices[G.a].position;Ea=morphTargets[D].vertices[G.b].position;za=morphTargets[D].vertices[G.c].position;v=ya[D];v[Na+0]=xa.x;v[Na+1]=xa.y;v[Na+2]=xa.z;v[Na+3]=Ea.x;v[Na+4]=Ea.y;v[Na+5]=Ea.z;v[Na+6]=za.x;v[Na+7]=za.y;v[Na+8]=za.z}Na+=9}if(lb.length){D=lb[G.a];aa=lb[G.b];v=lb[G.c];ra[M]=D.x;ra[M+1]=D.y;ra[M+2]=D.z;ra[M+3]=D.w;ra[M+4]=aa.x;ra[M+5]=aa.y;ra[M+6]=aa.z;ra[M+7]=aa.w;ra[M+8]=v.x;ra[M+9]=v.y;ra[M+10]=v.z;ra[M+11]=v.w;
+D=qb[G.a];aa=qb[G.b];v=qb[G.c];ta[M]=D.x;ta[M+1]=D.y;ta[M+2]=D.z;ta[M+3]=D.w;ta[M+4]=aa.x;ta[M+5]=aa.y;ta[M+6]=aa.z;ta[M+7]=aa.w;ta[M+8]=v.x;ta[M+9]=v.y;ta[M+10]=v.z;ta[M+11]=v.w;D=ob[G.a];aa=ob[G.b];v=ob[G.c];ea[M]=D.x;ea[M+1]=D.y;ea[M+2]=D.z;ea[M+3]=1;ea[M+4]=aa.x;ea[M+5]=aa.y;ea[M+6]=aa.z;ea[M+7]=1;ea[M+8]=v.x;ea[M+9]=v.y;ea[M+10]=v.z;ea[M+11]=1;D=pb[G.a];aa=pb[G.b];v=pb[G.c];$[M]=D.x;$[M+1]=D.y;$[M+2]=D.z;$[M+3]=1;$[M+4]=aa.x;$[M+5]=aa.y;$[M+6]=aa.z;$[M+7]=1;$[M+8]=v.x;$[M+9]=v.y;$[M+10]=v.z;
+$[M+11]=1;M+=12}if(tb&&Ka){if(L.length==3&&Ka==THREE.VertexColors){G=L[0];D=L[1];aa=L[2]}else aa=D=G=Z;na[Va]=G.r;na[Va+1]=G.g;na[Va+2]=G.b;na[Va+3]=D.r;na[Va+4]=D.g;na[Va+5]=D.b;na[Va+6]=aa.r;na[Va+7]=aa.g;na[Va+8]=aa.b;Va+=9}if(sb&&Sa.hasTangents){L=Y[0];Z=Y[1];G=Y[2];V[Ma]=L.x;V[Ma+1]=L.y;V[Ma+2]=L.z;V[Ma+3]=L.w;V[Ma+4]=Z.x;V[Ma+5]=Z.y;V[Ma+6]=Z.z;V[Ma+7]=Z.w;V[Ma+8]=G.x;V[Ma+9]=G.y;V[Ma+10]=G.z;V[Ma+11]=G.w;Ma+=12}if(rb&&Ca)if(T.length==3&&eb)for(Y=0;Y<3;Y++){I=T[Y];Pa[$a]=I.x;Pa[$a+1]=I.y;Pa[$a+
+2]=I.z;$a+=3}else for(Y=0;Y<3;Y++){Pa[$a]=I.x;Pa[$a+1]=I.y;Pa[$a+2]=I.z;$a+=3}if(db&&Ha!==undefined&&qa)for(Y=0;Y<3;Y++){T=Ha[Y];ib[cb]=T.u;ib[cb+1]=T.v;cb+=2}if(db&&Ga!==undefined&&qa)for(Y=0;Y<3;Y++){T=Ga[Y];jb[hb]=T.u;jb[hb+1]=T.v;hb+=2}if(gb){Ia[Wa]=Oa;Ia[Wa+1]=Oa+1;Ia[Wa+2]=Oa+2;Wa+=3;Ya[bb]=Oa;Ya[bb+1]=Oa+1;Ya[bb+2]=Oa;Ya[bb+3]=Oa+2;Ya[bb+4]=Oa+1;Ya[bb+5]=Oa+2;bb+=6;Oa+=3}}else if(G instanceof THREE.Face4){if(kb){xa=nb[G.a].position;Ea=nb[G.b].position;za=nb[G.c].position;Ua=nb[G.d].position;
+Ra[Qa]=xa.x;Ra[Qa+1]=xa.y;Ra[Qa+2]=xa.z;Ra[Qa+3]=Ea.x;Ra[Qa+4]=Ea.y;Ra[Qa+5]=Ea.z;Ra[Qa+6]=za.x;Ra[Qa+7]=za.y;Ra[Qa+8]=za.z;Ra[Qa+9]=Ua.x;Ra[Qa+10]=Ua.y;Ra[Qa+11]=Ua.z;Qa+=12}if(X)for(fb in X){v=X[fb];if(v.needsUpdate){D=v.offset;aa=v.offsetSrc;if(v.size===1){if(v.boundTo===undefined||v.boundTo==="vertices"){v.array[D+0]=v.value[G.a];v.array[D+1]=v.value[G.b];v.array[D+2]=v.value[G.c];v.array[D+2]=v.value[G.d]}else if(v.boundTo==="faces"){v.array[D+0]=v.value[aa];v.array[D+1]=v.value[aa];v.array[D+
+2]=v.value[aa];v.array[D+2]=v.value[aa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){v.array[D+0]=v.value[aa+0];v.array[D+1]=v.value[aa+1];v.array[D+2]=v.value[aa+2];v.array[D+2]=v.value[aa+3];v.offsetSrc+=4}v.offset+=4}else{if(v.boundTo===undefined||v.boundTo==="vertices"){xa=v.value[G.a];Ea=v.value[G.b];za=v.value[G.c];Ua=v.value[G.d]}else if(v.boundTo==="faces"){xa=v.value[aa];Ea=v.value[aa];za=v.value[aa];Ua=v.value[aa];v.offsetSrc++}else if(v.boundTo==="faceVertices"){xa=v.value[aa+0];Ea=
+v.value[aa+1];za=v.value[aa+2];Ua=v.value[aa+3];v.offsetSrc+=4}if(v.size===2){v.array[D+0]=xa.x;v.array[D+1]=xa.y;v.array[D+2]=Ea.x;v.array[D+3]=Ea.y;v.array[D+4]=za.x;v.array[D+5]=za.y;v.array[D+6]=Ua.x;v.array[D+7]=Ua.y;v.offset+=8}else if(v.size===3){if(v.type==="c"){v.array[D+0]=xa.r;v.array[D+1]=xa.g;v.array[D+2]=xa.b;v.array[D+3]=Ea.r;v.array[D+4]=Ea.g;v.array[D+5]=Ea.b;v.array[D+6]=za.r;v.array[D+7]=za.g;v.array[D+8]=za.b;v.array[D+9]=Ua.r;v.array[D+10]=Ua.g;v.array[D+11]=Ua.b}else{v.array[D+
+0]=xa.x;v.array[D+1]=xa.y;v.array[D+2]=xa.z;v.array[D+3]=Ea.x;v.array[D+4]=Ea.y;v.array[D+5]=Ea.z;v.array[D+6]=za.x;v.array[D+7]=za.y;v.array[D+8]=za.z;v.array[D+9]=Ua.x;v.array[D+10]=Ua.y;v.array[D+11]=Ua.z}v.offset+=12}else{v.array[D+0]=xa.x;v.array[D+1]=xa.y;v.array[D+2]=xa.z;v.array[D+3]=xa.w;v.array[D+4]=Ea.x;v.array[D+5]=Ea.y;v.array[D+6]=Ea.z;v.array[D+7]=Ea.w;v.array[D+8]=za.x;v.array[D+9]=za.y;v.array[D+10]=za.z;v.array[D+11]=za.w;v.array[D+12]=Ua.x;v.array[D+13]=Ua.y;v.array[D+14]=Ua.z;
+v.array[D+15]=Ua.w;v.offset+=16}}}}if(ub){D=0;for(aa=morphTargets.length;D<aa;D++){xa=morphTargets[D].vertices[G.a].position;Ea=morphTargets[D].vertices[G.b].position;za=morphTargets[D].vertices[G.c].position;Ua=morphTargets[D].vertices[G.d].position;v=ya[D];v[Na+0]=xa.x;v[Na+1]=xa.y;v[Na+2]=xa.z;v[Na+3]=Ea.x;v[Na+4]=Ea.y;v[Na+5]=Ea.z;v[Na+6]=za.x;v[Na+7]=za.y;v[Na+8]=za.z;v[Na+9]=Ua.x;v[Na+10]=Ua.y;v[Na+11]=Ua.z}Na+=12}if(lb.length){D=lb[G.a];aa=lb[G.b];v=lb[G.c];ab=lb[G.d];ra[M]=D.x;ra[M+1]=D.y;
+ra[M+2]=D.z;ra[M+3]=D.w;ra[M+4]=aa.x;ra[M+5]=aa.y;ra[M+6]=aa.z;ra[M+7]=aa.w;ra[M+8]=v.x;ra[M+9]=v.y;ra[M+10]=v.z;ra[M+11]=v.w;ra[M+12]=ab.x;ra[M+13]=ab.y;ra[M+14]=ab.z;ra[M+15]=ab.w;D=qb[G.a];aa=qb[G.b];v=qb[G.c];ab=qb[G.d];ta[M]=D.x;ta[M+1]=D.y;ta[M+2]=D.z;ta[M+3]=D.w;ta[M+4]=aa.x;ta[M+5]=aa.y;ta[M+6]=aa.z;ta[M+7]=aa.w;ta[M+8]=v.x;ta[M+9]=v.y;ta[M+10]=v.z;ta[M+11]=v.w;ta[M+12]=ab.x;ta[M+13]=ab.y;ta[M+14]=ab.z;ta[M+15]=ab.w;D=ob[G.a];aa=ob[G.b];v=ob[G.c];ab=ob[G.d];ea[M]=D.x;ea[M+1]=D.y;ea[M+2]=D.z;
+ea[M+3]=1;ea[M+4]=aa.x;ea[M+5]=aa.y;ea[M+6]=aa.z;ea[M+7]=1;ea[M+8]=v.x;ea[M+9]=v.y;ea[M+10]=v.z;ea[M+11]=1;ea[M+12]=ab.x;ea[M+13]=ab.y;ea[M+14]=ab.z;ea[M+15]=1;D=pb[G.a];aa=pb[G.b];v=pb[G.c];G=pb[G.d];$[M]=D.x;$[M+1]=D.y;$[M+2]=D.z;$[M+3]=1;$[M+4]=aa.x;$[M+5]=aa.y;$[M+6]=aa.z;$[M+7]=1;$[M+8]=v.x;$[M+9]=v.y;$[M+10]=v.z;$[M+11]=1;$[M+12]=G.x;$[M+13]=G.y;$[M+14]=G.z;$[M+15]=1;M+=16}if(tb&&Ka){if(L.length==4&&Ka==THREE.VertexColors){G=L[0];D=L[1];aa=L[2];L=L[3]}else L=aa=D=G=Z;na[Va]=G.r;na[Va+1]=G.g;
+na[Va+2]=G.b;na[Va+3]=D.r;na[Va+4]=D.g;na[Va+5]=D.b;na[Va+6]=aa.r;na[Va+7]=aa.g;na[Va+8]=aa.b;na[Va+9]=L.r;na[Va+10]=L.g;na[Va+11]=L.b;Va+=12}if(sb&&Sa.hasTangents){L=Y[0];Z=Y[1];G=Y[2];Y=Y[3];V[Ma]=L.x;V[Ma+1]=L.y;V[Ma+2]=L.z;V[Ma+3]=L.w;V[Ma+4]=Z.x;V[Ma+5]=Z.y;V[Ma+6]=Z.z;V[Ma+7]=Z.w;V[Ma+8]=G.x;V[Ma+9]=G.y;V[Ma+10]=G.z;V[Ma+11]=G.w;V[Ma+12]=Y.x;V[Ma+13]=Y.y;V[Ma+14]=Y.z;V[Ma+15]=Y.w;Ma+=16}if(rb&&Ca)if(T.length==4&&eb)for(Y=0;Y<4;Y++){I=T[Y];Pa[$a]=I.x;Pa[$a+1]=I.y;Pa[$a+2]=I.z;$a+=3}else for(Y=
+0;Y<4;Y++){Pa[$a]=I.x;Pa[$a+1]=I.y;Pa[$a+2]=I.z;$a+=3}if(db&&Ha!==undefined&&qa)for(Y=0;Y<4;Y++){T=Ha[Y];ib[cb]=T.u;ib[cb+1]=T.v;cb+=2}if(db&&Ga!==undefined&&qa)for(Y=0;Y<4;Y++){T=Ga[Y];jb[hb]=T.u;jb[hb+1]=T.v;hb+=2}if(gb){Ia[Wa]=Oa;Ia[Wa+1]=Oa+1;Ia[Wa+2]=Oa+3;Ia[Wa+3]=Oa+1;Ia[Wa+4]=Oa+2;Ia[Wa+5]=Oa+3;Wa+=6;Ya[bb]=Oa;Ya[bb+1]=Oa+1;Ya[bb+2]=Oa;Ya[bb+3]=Oa+3;Ya[bb+4]=Oa+1;Ya[bb+5]=Oa+2;Ya[bb+6]=Oa+2;Ya[bb+7]=Oa+3;bb+=8;Oa+=4}}}if(mb){K=0;for(F=mb.length;K<F;K++){Ia[Wa]=mb[K].a;Ia[Wa+1]=mb[K].b;Ia[Wa+
+2]=mb[K].c;Ia[Wa+3]=mb[K].a;Ia[Wa+4]=mb[K].c;Ia[Wa+5]=mb[K].d;Wa+=6}}if(kb){e.bindBuffer(e.ARRAY_BUFFER,x.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ra,Q)}if(X)for(fb in X){v=X[fb];if(v.needsUpdate){e.bindBuffer(e.ARRAY_BUFFER,v.buffer);e.bufferData(e.ARRAY_BUFFER,v.array,Q);v.needsUpdate=!1}}if(ub){D=0;for(aa=morphTargets.length;D<aa;D++){e.bindBuffer(e.ARRAY_BUFFER,x.__webglMorphTargetsBuffers[D]);e.bufferData(e.ARRAY_BUFFER,ya[D],Q)}}if(tb&&Va>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglColorBuffer);
+e.bufferData(e.ARRAY_BUFFER,na,Q)}if(rb){e.bindBuffer(e.ARRAY_BUFFER,x.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,Q)}if(sb&&Sa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,x.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,V,Q)}if(db&&cb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,ib,Q)}if(db&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,jb,Q)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,
+Ia,Q);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ya,Q)}if(M>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,ea,Q);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,$,Q);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ta,Q);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ra,Q)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=
+!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Ka=n.vertices;x=n.colors;Ca=Ka.length;Q=x.length;Ha=n.__vertexArray;K=n.__colorArray;Ga=n.__dirtyColors;if(n.__dirtyVertices){for(F=0;F<Ca;F++){qa=Ka[F].position;y=F*3;Ha[y]=qa.x;Ha[y+1]=qa.y;Ha[y+2]=qa.z}e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ha,C)}if(Ga){for(F=
+0;F<Q;F++){color=x[F];y=F*3;K[y]=color.r;K[y+1]=color.g;K[y+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,C)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Line){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Ka=n.vertices;x=n.colors;Ca=Ka.length;Q=x.length;Ha=n.__vertexArray;K=n.__colorArray;Ga=n.__dirtyColors;if(n.__dirtyVertices){for(F=0;F<Ca;F++){qa=Ka[F].position;y=F*3;Ha[y]=qa.x;Ha[y+1]=qa.y;Ha[y+2]=
+qa.z}e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ha,C)}if(Ga){for(F=0;F<Q;F++){color=x[F];y=F*3;K[y]=color.r;K[y+1]=color.g;K[y+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,C)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(n instanceof THREE.ParticleSystem){w=n.geometry;(w.__dirtyVertices||w.__dirtyColors||n.sortParticles)&&d(w,e.DYNAMIC_DRAW,n);w.__dirtyVertices=!1;w.__dirtyColors=!1}}function W(n){function C(Z){var Y=
+[];w=0;for(x=Z.length;w<x;w++)Z[w]==undefined?Y.push("undefined"):Y.push(Z[w].id);return Y.join("_")}var w,x,y,Q,K,F,T,G,I={},L=n.morphTargets!==undefined?n.morphTargets.length:0;n.geometryGroups={};y=0;for(Q=n.faces.length;y<Q;y++){K=n.faces[y];F=K.materials;T=C(F);I[T]==undefined&&(I[T]={hash:T,counter:0});G=I[T].hash+"_"+I[T].counter;n.geometryGroups[G]==undefined&&(n.geometryGroups[G]={faces:[],materials:F,vertices:0,numMorphTargets:L});K=K instanceof THREE.Face3?3:4;if(n.geometryGroups[G].vertices+
+K>65535){I[T].counter+=1;G=I[T].hash+"_"+I[T].counter;n.geometryGroups[G]==undefined&&(n.geometryGroups[G]={faces:[],materials:F,vertices:0,numMorphTargets:L})}n.geometryGroups[G].faces.push(y);n.geometryGroups[G].vertices+=K}}function B(n,C,w){n.push({buffer:C,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function U(n){if(n!=wa){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);
+e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}wa=n}}function N(n,C,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,ga(C.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,ga(C.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,ga(C.magFilter));
+e.texParameteri(n,e.TEXTURE_MIN_FILTER,ga(C.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,pa(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,pa(C.minFilter))}}function O(n,C){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{n.__webglTexture=e.createTexture();
+e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image);n.__webglInit=!0}N(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+C);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function ua(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer();
+n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,ga(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,ga(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,ga(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,ga(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,ga(n.format),n.width,n.height,0,ga(n.format),ga(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,
+n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,
+n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,w;if(n){C=n.__webglFramebuffer;w=n.width;n=n.height}else{C=null;w=Fa;n=ia}if(C!=ka){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(ja,ma,w,n);ka=C}}function la(n,C){var w;if(n=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,
+C);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(C);return null}return w}function pa(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function ga(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;
+case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;
+case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var ha=this,e,oa=document.createElement("canvas"),Da=[],Aa=null,ka=null,fa=!0,va=null,sa=null,wa=null,ca=null,ja=0,ma=0,Fa=0,ia=0,da=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
+new THREE.Vector4,new THREE.Vector4],Ja=new THREE.Matrix4,Xa=new Float32Array(16),Za=new Float32Array(16),Ta=new THREE.Vector4,R={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0,
+faces:0};this.maxMorphTargets=8;this.domElement=oa;this.autoClear=!0;this.sortObjects=!0;(function(n,C,w,x){try{if(!(e=oa.getContext("experimental-webgl",{antialias:n,stencil:x})))throw"Error creating WebGL context.";}catch(y){console.error(y)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);
+e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r,C.g,C.b,w)})(antialias,clearColor,clearAlpha,stencil);this.context=e;if(stencil){var S={};S.vertices=new Float32Array(12);S.faces=new Uint16Array(6);S.darkness=0.5;S.vertices[0]=-20;S.vertices[1]=-20;S.vertices[2]=-1;S.vertices[3]=20;S.vertices[4]=-20;S.vertices[5]=-1;S.vertices[6]=20;S.vertices[7]=20;S.vertices[8]=-1;S.vertices[9]=
+-20;S.vertices[10]=20;S.vertices[11]=-1;S.faces[0]=0;S.faces[1]=1;S.faces[2]=2;S.faces[3]=0;S.faces[4]=2;S.faces[5]=3;S.vertexBuffer=e.createBuffer();S.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,S.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,S.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,S.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,S.faces,e.STATIC_DRAW);S.program=e.createProgram();e.attachShader(S.program,la("fragment",THREE.ShaderLib.shadowPost.fragmentShader));
+e.attachShader(S.program,la("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(S.program);S.vertexLocation=e.getAttribLocation(S.program,"position");S.projectionLocation=e.getUniformLocation(S.program,"projectionMatrix");S.darknessLocation=e.getUniformLocation(S.program,"darkness")}var P={};P.vertices=new Float32Array(16);P.faces=new Uint16Array(6);b=0;P.vertices[b++]=-1;P.vertices[b++]=-1;P.vertices[b++]=0;P.vertices[b++]=0;P.vertices[b++]=1;P.vertices[b++]=-1;P.vertices[b++]=1;P.vertices[b++]=
+0;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=-1;P.vertices[b++]=1;P.vertices[b++]=0;P.vertices[b++]=1;b=0;P.faces[b++]=0;P.faces[b++]=1;P.faces[b++]=2;P.faces[b++]=0;P.faces[b++]=2;P.faces[b++]=3;P.vertexBuffer=e.createBuffer();P.elementBuffer=e.createBuffer();P.tempTexture=e.createTexture();P.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,P.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,P.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
+P.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,P.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,P.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,P.occlusionTexture);e.texImage2D(e.TEXTURE_2D,
+0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){P.hasVertexTexture=!1;P.program=e.createProgram();e.attachShader(P.program,la("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(P.program,
+la("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{P.hasVertexTexture=!0;P.program=e.createProgram();e.attachShader(P.program,la("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(P.program,la("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(P.program);P.attributes={};P.uniforms={};P.attributes.vertex=e.getAttribLocation(P.program,"position");P.attributes.uv=e.getAttribLocation(P.program,"UV");P.uniforms.renderType=e.getUniformLocation(P.program,
+"renderType");P.uniforms.map=e.getUniformLocation(P.program,"map");P.uniforms.occlusionMap=e.getUniformLocation(P.program,"occlusionMap");P.uniforms.opacity=e.getUniformLocation(P.program,"opacity");P.uniforms.scale=e.getUniformLocation(P.program,"scale");P.uniforms.rotation=e.getUniformLocation(P.program,"rotation");P.uniforms.screenPosition=e.getUniformLocation(P.program,"screenPosition");var Ba=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=
+-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=
+e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,la("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,la("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program);
+_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=
+e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=
+e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var La=!1;this.setSize=function(n,C){oa.width=n;oa.height=C;this.setViewport(0,0,oa.width,oa.height)};this.setViewport=function(n,C,w,x){ja=n;ma=C;Fa=w;ia=x;e.viewport(ja,ma,Fa,ia)};this.setScissor=function(n,C,w,x){e.scissor(n,C,w,x)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){fa=
+n;e.depthMask(n)};this.setClearColorHex=function(n,C){var w=new THREE.Color(n);e.clearColor(w.r,w.g,w.b,C)};this.setClearColor=function(n,C){e.clearColor(n.r,n.g,n.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){S.darkness=n};this.initMaterial=function(n,C,w,x){var y,Q,K;if(n instanceof THREE.MeshDepthMaterial)K="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)K="shadowVolumeDynamic";else if(n instanceof
+THREE.MeshNormalMaterial)K="normal";else if(n instanceof THREE.MeshBasicMaterial)K="basic";else if(n instanceof THREE.MeshLambertMaterial)K="lambert";else if(n instanceof THREE.MeshPhongMaterial)K="phong";else if(n instanceof THREE.LineBasicMaterial)K="basic";else n instanceof THREE.ParticleBasicMaterial&&(K="particle_basic");if(K){var F=THREE.ShaderLib[K];n.uniforms=THREE.UniformsUtils.clone(F.uniforms);n.vertexShader=F.vertexShader;n.fragmentShader=F.fragmentShader}var T,G,I;T=I=F=0;for(G=C.length;T<
+G;T++){Q=C[T];Q instanceof THREE.DirectionalLight&&I++;Q instanceof THREE.PointLight&&F++}if(F+I<=4)C=I;else{C=Math.ceil(4*I/(F+I));F=4-C}Q={directional:C,point:F};I=50;if(x!==undefined&&x instanceof THREE.SkinnedMesh)I=x.bones.length;var L;a:{T=n.fragmentShader;G=n.vertexShader;F=n.uniforms;C=n.attributes;w={map:!!n.map,envMap:!!n.envMap,lightMap:!!n.lightMap,vertexColors:n.vertexColors,fog:w,sizeAttenuation:n.sizeAttenuation,skinning:n.skinning,morphTargets:n.morphTargets,maxMorphTargets:this.maxMorphTargets,
+maxDirLights:Q.directional,maxPointLights:Q.point,maxBones:I};var Z;Q=[];if(K)Q.push(K);else{Q.push(T);Q.push(G)}for(Z in w){Q.push(Z);Q.push(w[Z])}K=Q.join();Z=0;for(Q=Da.length;Z<Q;Z++)if(Da[Z].code==K){L=Da[Z].program;break a}Z=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":
+"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,"#define MAX_BONES "+w.maxBones,w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?
+"#define USE_COLOR":"",w.skinning?"#define USE_SKINNING":"",w.morphTargets?"#define USE_MORPHTARGETS":"",w.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+e.attachShader(Z,la("fragment",prefix_fragment+T));e.attachShader(Z,la("vertex",prefix_vertex+G));e.linkProgram(Z);e.getProgramParameter(Z,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(Z,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");Z.uniforms={};Z.attributes={};var Y;T=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(Y in F)T.push(Y);
+Y=T;F=0;for(T=Y.length;F<T;F++){G=Y[F];Z.uniforms[G]=e.getUniformLocation(Z,G)}T=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(Y=0;Y<w.maxMorphTargets;Y++)T.push("morphTarget"+Y);for(L in C)T.push(L);L=T;Y=0;for(C=L.length;Y<C;Y++){w=L[Y];Z.attributes[w]=e.getAttribLocation(Z,w)}Da.push({program:Z,code:K});L=Z}n.program=L;L=n.program.attributes;e.enableVertexAttribArray(L.position);L.color>=0&&e.enableVertexAttribArray(L.color);L.normal>=
+0&&e.enableVertexAttribArray(L.normal);L.tangent>=0&&e.enableVertexAttribArray(L.tangent);if(n.skinning&&L.skinVertexA>=0&&L.skinVertexB>=0&&L.skinIndex>=0&&L.skinWeight>=0){e.enableVertexAttribArray(L.skinVertexA);e.enableVertexAttribArray(L.skinVertexB);e.enableVertexAttribArray(L.skinIndex);e.enableVertexAttribArray(L.skinWeight)}for(y in n.attributes)L[y]>=0&&e.enableVertexAttribArray(L[y]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(L.morphTarget0>=0){e.enableVertexAttribArray(L.morphTarget0);
 n.numSupportedMorphTargets++}if(L.morphTarget1>=0){e.enableVertexAttribArray(L.morphTarget1);n.numSupportedMorphTargets++}if(L.morphTarget2>=0){e.enableVertexAttribArray(L.morphTarget2);n.numSupportedMorphTargets++}if(L.morphTarget3>=0){e.enableVertexAttribArray(L.morphTarget3);n.numSupportedMorphTargets++}if(L.morphTarget4>=0){e.enableVertexAttribArray(L.morphTarget4);n.numSupportedMorphTargets++}if(L.morphTarget5>=0){e.enableVertexAttribArray(L.morphTarget5);n.numSupportedMorphTargets++}if(L.morphTarget6>=
-0){e.enableVertexAttribArray(L.morphTarget6);n.numSupportedMorphTargets++}if(L.morphTarget7>=0){e.enableVertexAttribArray(L.morphTarget7);n.numSupportedMorphTargets++}x.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(z=this.maxMorphTargets;n<z;n++)x.__webglMorphTargetInfluences[n]=0}};this.render=function(n,C,w,x){var z,J,K,I,S,D,O,L,$=n.lights,V=n.fog;C.matrixAutoUpdate&&C.updateMatrix();n.update(undefined,!1,C);C.matrixWorldInverse.flattenToArray(Za);C.projectionMatrix.flattenToArray(Ya);
-Ra.multiply(C.projectionMatrix,C.matrixWorldInverse);k(Ra);this.initWebGLObjects(n);Da(w);(this.autoClear||x)&&this.clear();S=n.__webglObjects.length;for(x=0;x<S;x++){z=n.__webglObjects[x];O=z.object;if(O.visible)if(!(O instanceof THREE.Mesh)||m(O)){O.matrixWorld.flattenToArray(O._objectMatrixArray);H(O,C);u(z);z.render=!0;if(this.sortObjects){Na.copy(O.position);Ra.multiplyVector3(Na);z.z=Na.z}}else z.render=!1;else z.render=!1}this.sortObjects&&n.__webglObjects.sort(y);D=n.__webglObjectsImmediate.length;
-for(x=0;x<D;x++){z=n.__webglObjectsImmediate[x];O=z.object;if(O.visible){O.matrixAutoUpdate&&O.matrixWorld.flattenToArray(O._objectMatrixArray);H(O,C);o(z)}}M(THREE.NormalBlending);for(x=0;x<S;x++){z=n.__webglObjects[x];if(z.render){O=z.object;L=z.buffer;K=z.opaque;h(O);for(z=0;z<K.count;z++){I=K.list[z];j(I.depthTest);f(C,$,V,I,L,O)}}}for(x=0;x<D;x++){z=n.__webglObjectsImmediate[x];O=z.object;if(O.visible){K=z.opaque;h(O);for(z=0;z<K.count;z++){I=K.list[z];j(I.depthTest);J=c(C,$,V,I,O);O.render(function(xa){g(xa,
-J,I.shading)})}}}for(x=0;x<S;x++){z=n.__webglObjects[x];if(z.render){O=z.object;L=z.buffer;K=z.transparent;h(O);for(z=0;z<K.count;z++){I=K.list[z];M(I.blending);j(I.depthTest);f(C,$,V,I,L,O)}}}for(x=0;x<D;x++){z=n.__webglObjectsImmediate[x];O=z.object;if(O.visible){K=z.transparent;h(O);for(z=0;z<K.count;z++){I=K.list[z];M(I.blending);j(I.depthTest);J=c(C,$,V,I,O);O.render(function(xa){g(xa,J,I.shading)})}}}n.__webglSprites.length&&B(n,C);stencil&&n.__webglShadowVolumes.length&&n.lights.length&&t(n);
-n.__webglLensFlares.length&&F(n,C);if(w&&w.minFilter!==THREE.NearestFilter&&w.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,w.__webglTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(n){if(!n.__webglObjects){n.__webglObjects=[];n.__webglObjectsImmediate=[];n.__webglShadowVolumes=[];n.__webglLensFlares=[];n.__webglSprites=[]}for(;n.__objectsAdded.length;){var C=n.__objectsAdded[0],w=n,x=void 0,z=void 0,J=void 0;if(C._modelViewMatrix==
-undefined){C._modelViewMatrix=new THREE.Matrix4;C._normalMatrixArray=new Float32Array(9);C._modelViewMatrixArray=new Float32Array(16);C._objectMatrixArray=new Float32Array(16);C.matrixWorld.flattenToArray(C._objectMatrixArray)}if(C instanceof THREE.Mesh){z=C.geometry;z.geometryGroups==undefined&&X(z);for(x in z.geometryGroups){J=z.geometryGroups[x];if(!J.__webglVertexBuffer){var K=J;K.__webglVertexBuffer=e.createBuffer();K.__webglNormalBuffer=e.createBuffer();K.__webglTangentBuffer=e.createBuffer();
-K.__webglColorBuffer=e.createBuffer();K.__webglUVBuffer=e.createBuffer();K.__webglUV2Buffer=e.createBuffer();K.__webglSkinVertexABuffer=e.createBuffer();K.__webglSkinVertexBBuffer=e.createBuffer();K.__webglSkinIndicesBuffer=e.createBuffer();K.__webglSkinWeightsBuffer=e.createBuffer();K.__webglFaceBuffer=e.createBuffer();K.__webglLineBuffer=e.createBuffer();if(K.numMorphTargets){var I=void 0,S=void 0;K.__webglMorphTargetsBuffers=[];I=0;for(S=K.numMorphTargets;I<S;I++)K.__webglMorphTargetsBuffers.push(e.createBuffer())}K=
-J;I=C;var D=void 0,O=void 0,L=void 0;L=void 0;var $=void 0,V=void 0,xa=void 0,Ja=xa=S=0;O=void 0;L=void 0;var za=void 0;D=void 0;O=void 0;$=I.geometry;za=$.faces;V=K.faces;D=0;for(O=V.length;D<O;D++){L=V[D];L=za[L];if(L instanceof THREE.Face3){S+=3;xa+=1;Ja+=3}else if(L instanceof THREE.Face4){S+=4;xa+=2;Ja+=4}}D=K;O=I;za=void 0;V=void 0;var ta=void 0,Oa=void 0;ta=void 0;L=[];za=0;for(V=O.materials.length;za<V;za++){ta=O.materials[za];if(ta instanceof THREE.MeshFaceMaterial){ta=0;for(l=D.materials.length;ta<
-l;ta++)(Oa=D.materials[ta])&&L.push(Oa)}else(Oa=ta)&&L.push(Oa)}D=L;a:{O=void 0;za=void 0;V=D.length;for(O=0;O<V;O++){za=D[O];if(za.map||za.lightMap||za instanceof THREE.MeshShaderMaterial){O=!0;break a}}O=!1}a:{za=D;V=void 0;L=void 0;ta=za.length;for(V=0;V<ta;V++){L=za[V];if(!(L instanceof THREE.MeshBasicMaterial&&!L.envMap||L instanceof THREE.MeshDepthMaterial)){za=L&&L.shading!=undefined&&L.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}za=!1}a:{V=void 0;L=void 0;ta=
-D.length;for(V=0;V<ta;V++){L=D[V];if(L.vertexColors){L=L.vertexColors;break a}}L=!1}K.__vertexArray=new Float32Array(S*3);if(za)K.__normalArray=new Float32Array(S*3);if($.hasTangents)K.__tangentArray=new Float32Array(S*4);if(L)K.__colorArray=new Float32Array(S*3);if(O){if($.faceUvs.length>0||$.faceVertexUvs.length>0)K.__uvArray=new Float32Array(S*2);if($.faceUvs.length>1||$.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(S*2)}if(I.geometry.skinWeights.length&&I.geometry.skinIndices.length){K.__skinVertexAArray=
-new Float32Array(S*4);K.__skinVertexBArray=new Float32Array(S*4);K.__skinIndexArray=new Float32Array(S*4);K.__skinWeightArray=new Float32Array(S*4)}K.__faceArray=new Uint16Array(xa*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(Ja*2);if(K.numMorphTargets){K.__morphTargetsArrays=[];$=0;for(V=K.numMorphTargets;$<V;$++)K.__morphTargetsArrays.push(new Float32Array(S*3))}K.__needsSmoothNormals=za==THREE.SmoothShading;K.__uvType=O;K.__vertexColorType=L;K.__normalType=
-za;K.__webglFaceCount=xa*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0);K.__webglLineCount=Ja*2;$=0;for(V=D.length;$<V;$++)if(D[$].attributes){K.__webglCustomAttributes={};for(a in D[$].attributes){O=D[$].attributes[a];xa=1;if(O.type==="v2")xa=2;else if(O.type==="v3")xa=3;else if(O.type==="v4")xa=4;else O.type==="c"&&(xa=3);O.size=xa;O.needsUpdate=!0;O.array=new Float32Array(S*xa);O.buffer=e.createBuffer();K.__webglCustomAttributes[a]=O}}z.__dirtyVertices=!0;z.__dirtyMorphTargets=!0;z.__dirtyElements=
-!0;z.__dirtyUvs=!0;z.__dirtyNormals=!0;z.__dirtyTangents=!0;z.__dirtyColors=!0}C instanceof THREE.ShadowVolume?A(w.__webglShadowVolumes,J,C):A(w.__webglObjects,J,C)}}else if(C instanceof THREE.LensFlare)A(w.__webglLensFlares,undefined,C);else if(C instanceof THREE.Ribbon){z=C.geometry;if(!z.__webglVertexBuffer){x=z;x.__webglVertexBuffer=e.createBuffer();x.__webglColorBuffer=e.createBuffer();x=z;J=x.vertices.length;x.__vertexArray=new Float32Array(J*3);x.__colorArray=new Float32Array(J*3);x.__webglVertexCount=
-J;z.__dirtyVertices=!0;z.__dirtyColors=!0}A(w.__webglObjects,z,C)}else if(C instanceof THREE.Line){z=C.geometry;if(!z.__webglVertexBuffer){x=z;x.__webglVertexBuffer=e.createBuffer();x.__webglColorBuffer=e.createBuffer();x=z;J=x.vertices.length;x.__vertexArray=new Float32Array(J*3);x.__colorArray=new Float32Array(J*3);x.__webglLineCount=J;z.__dirtyVertices=!0;z.__dirtyColors=!0}A(w.__webglObjects,z,C)}else if(C instanceof THREE.ParticleSystem){z=C.geometry;if(!z.__webglVertexBuffer){x=z;x.__webglVertexBuffer=
-e.createBuffer();x.__webglColorBuffer=e.createBuffer();x=z;J=x.vertices.length;x.__vertexArray=new Float32Array(J*3);x.__colorArray=new Float32Array(J*3);x.__sortArray=[];x.__webglParticleCount=J;z.__dirtyVertices=!0;z.__dirtyColors=!0}A(w.__webglObjects,z,C)}else if(THREE.MarchingCubes!==undefined&&C instanceof THREE.MarchingCubes)w.__webglObjectsImmediate.push({object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}});else C instanceof THREE.Sprite&&w.__webglSprites.push(C);n.__objectsAdded.splice(0,
-1)}for(;n.__objectsRemoved.length;){C=n.__objectsRemoved[0];w=n;z=void 0;x=void 0;for(z=w.__webglObjects.length-1;z>=0;z--){x=w.__webglObjects[z].object;if(C==x){w.__webglObjects.splice(z,1);break}}n.__objectsRemoved.splice(0,1)}C=0;for(w=n.__webglObjects.length;C<w;C++)G(n.__webglObjects[C].object,n);C=0;for(w=n.__webglShadowVolumes.length;C<w;C++)G(n.__webglShadowVolumes[C].object,n);C=0;for(w=n.__webglLensFlares.length;C<w;C++)G(n.__webglLensFlares[C].object,n)};this.setFaceCulling=function(n,
-C){if(n){!C||C=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(n=="back")e.cullFace(e.BACK);else n=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+0){e.enableVertexAttribArray(L.morphTarget6);n.numSupportedMorphTargets++}if(L.morphTarget7>=0){e.enableVertexAttribArray(L.morphTarget7);n.numSupportedMorphTargets++}x.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(y=this.maxMorphTargets;n<y;n++)x.__webglMorphTargetInfluences[n]=0}};this.render=function(n,C,w,x){var y,Q,K,F,T,G,I,L,Z=n.lights,Y=n.fog;ha.data.vertices=0;ha.data.faces=0;C.matrixAutoUpdate&&C.update(undefined,!0);n.update(undefined,!1,C);C.matrixWorldInverse.flattenToArray(Za);
+C.projectionMatrix.flattenToArray(Xa);Ja.multiply(C.projectionMatrix,C.matrixWorldInverse);k(Ja);this.initWebGLObjects(n);ua(w);(this.autoClear||x)&&this.clear();T=n.__webglObjects.length;for(x=0;x<T;x++){y=n.__webglObjects[x];I=y.object;if(I.visible)if(!(I instanceof THREE.Mesh)||m(I)){I.matrixWorld.flattenToArray(I._objectMatrixArray);H(I,C);t(y);y.render=!0;if(this.sortObjects){Ta.copy(I.position);Ja.multiplyVector3(Ta);y.z=Ta.z}}else y.render=!1;else y.render=!1}this.sortObjects&&n.__webglObjects.sort(z);
+G=n.__webglObjectsImmediate.length;for(x=0;x<G;x++){y=n.__webglObjectsImmediate[x];I=y.object;if(I.visible){I.matrixAutoUpdate&&I.matrixWorld.flattenToArray(I._objectMatrixArray);H(I,C);p(y)}}U(THREE.NormalBlending);for(x=0;x<T;x++){y=n.__webglObjects[x];if(y.render){I=y.object;L=y.buffer;K=y.opaque;h(I);for(y=0;y<K.count;y++){F=K.list[y];j(F.depthTest);f(C,Z,Y,F,L,I)}}}for(x=0;x<G;x++){y=n.__webglObjectsImmediate[x];I=y.object;if(I.visible){K=y.opaque;h(I);for(y=0;y<K.count;y++){F=K.list[y];j(F.depthTest);
+Q=c(C,Z,Y,F,I);I.render(function(qa){g(qa,Q,F.shading)})}}}for(x=0;x<T;x++){y=n.__webglObjects[x];if(y.render){I=y.object;L=y.buffer;K=y.transparent;h(I);for(y=0;y<K.count;y++){F=K.list[y];U(F.blending);j(F.depthTest);f(C,Z,Y,F,L,I)}}}for(x=0;x<G;x++){y=n.__webglObjectsImmediate[x];I=y.object;if(I.visible){K=y.transparent;h(I);for(y=0;y<K.count;y++){F=K.list[y];U(F.blending);j(F.depthTest);Q=c(C,Z,Y,F,I);I.render(function(qa){g(qa,Q,F.shading)})}}}n.__webglSprites.length&&A(n,C);stencil&&n.__webglShadowVolumes.length&&
+n.lights.length&&u(n);n.__webglLensFlares.length&&E(n,C);if(w&&w.minFilter!==THREE.NearestFilter&&w.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,w.__webglTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(n){if(!n.__webglObjects){n.__webglObjects=[];n.__webglObjectsImmediate=[];n.__webglShadowVolumes=[];n.__webglLensFlares=[];n.__webglSprites=[]}for(;n.__objectsAdded.length;){var C=n.__objectsAdded[0],w=n,x=void 0,y=void 0,Q=void 0;
+if(C._modelViewMatrix==undefined){C._modelViewMatrix=new THREE.Matrix4;C._normalMatrixArray=new Float32Array(9);C._modelViewMatrixArray=new Float32Array(16);C._objectMatrixArray=new Float32Array(16);C.matrixWorld.flattenToArray(C._objectMatrixArray)}if(C instanceof THREE.Mesh){y=C.geometry;y.geometryGroups==undefined&&W(y);for(x in y.geometryGroups){Q=y.geometryGroups[x];if(!Q.__webglVertexBuffer){var K=Q;K.__webglVertexBuffer=e.createBuffer();K.__webglNormalBuffer=e.createBuffer();K.__webglTangentBuffer=
+e.createBuffer();K.__webglColorBuffer=e.createBuffer();K.__webglUVBuffer=e.createBuffer();K.__webglUV2Buffer=e.createBuffer();K.__webglSkinVertexABuffer=e.createBuffer();K.__webglSkinVertexBBuffer=e.createBuffer();K.__webglSkinIndicesBuffer=e.createBuffer();K.__webglSkinWeightsBuffer=e.createBuffer();K.__webglFaceBuffer=e.createBuffer();K.__webglLineBuffer=e.createBuffer();if(K.numMorphTargets){var F=void 0,T=void 0;K.__webglMorphTargetsBuffers=[];F=0;for(T=K.numMorphTargets;F<T;F++)K.__webglMorphTargetsBuffers.push(e.createBuffer())}K=
+Q;F=C;var G=void 0,I=void 0,L=void 0;L=void 0;var Z=void 0,Y=void 0,qa=void 0,Ka=qa=T=0;I=void 0;L=void 0;var Ca=void 0;G=void 0;I=void 0;Z=F.geometry;Ca=Z.faces;Y=K.faces;G=0;for(I=Y.length;G<I;G++){L=Y[G];L=Ca[L];if(L instanceof THREE.Face3){T+=3;qa+=1;Ka+=3}else if(L instanceof THREE.Face4){T+=4;qa+=2;Ka+=4}}G=K;I=F;Ca=void 0;Y=void 0;var Ha=void 0,Ga=void 0;Ha=void 0;L=[];Ca=0;for(Y=I.materials.length;Ca<Y;Ca++){Ha=I.materials[Ca];if(Ha instanceof THREE.MeshFaceMaterial){Ha=0;for(l=G.materials.length;Ha<
+l;Ha++)(Ga=G.materials[Ha])&&L.push(Ga)}else(Ga=Ha)&&L.push(Ga)}G=L;a:{I=void 0;Ca=void 0;Y=G.length;for(I=0;I<Y;I++){Ca=G[I];if(Ca.map||Ca.lightMap||Ca instanceof THREE.MeshShaderMaterial){I=!0;break a}}I=!1}a:{Ca=G;Y=void 0;L=void 0;Ha=Ca.length;for(Y=0;Y<Ha;Y++){L=Ca[Y];if(!(L instanceof THREE.MeshBasicMaterial&&!L.envMap||L instanceof THREE.MeshDepthMaterial)){Ca=L&&L.shading!=undefined&&L.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}Ca=!1}a:{Y=void 0;L=void 0;Ha=
+G.length;for(Y=0;Y<Ha;Y++){L=G[Y];if(L.vertexColors){L=L.vertexColors;break a}}L=!1}K.__vertexArray=new Float32Array(T*3);if(Ca)K.__normalArray=new Float32Array(T*3);if(Z.hasTangents)K.__tangentArray=new Float32Array(T*4);if(L)K.__colorArray=new Float32Array(T*3);if(I){if(Z.faceUvs.length>0||Z.faceVertexUvs.length>0)K.__uvArray=new Float32Array(T*2);if(Z.faceUvs.length>1||Z.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(T*2)}if(F.geometry.skinWeights.length&&F.geometry.skinIndices.length){K.__skinVertexAArray=
+new Float32Array(T*4);K.__skinVertexBArray=new Float32Array(T*4);K.__skinIndexArray=new Float32Array(T*4);K.__skinWeightArray=new Float32Array(T*4)}K.__faceArray=new Uint16Array(qa*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(Ka*2);if(K.numMorphTargets){K.__morphTargetsArrays=[];Z=0;for(Y=K.numMorphTargets;Z<Y;Z++)K.__morphTargetsArrays.push(new Float32Array(T*3))}K.__needsSmoothNormals=Ca==THREE.SmoothShading;K.__uvType=I;K.__vertexColorType=L;K.__normalType=
+Ca;K.__webglFaceCount=qa*3+(F.geometry.edgeFaces?F.geometry.edgeFaces.length*6:0);K.__webglLineCount=Ka*2;Z=0;for(Y=G.length;Z<Y;Z++)if(G[Z].attributes){K.__webglCustomAttributes={};for(a in G[Z].attributes){I=G[Z].attributes[a];qa=1;if(I.type==="v2")qa=2;else if(I.type==="v3")qa=3;else if(I.type==="v4")qa=4;else I.type==="c"&&(qa=3);I.size=qa;I.needsUpdate=!0;I.array=new Float32Array(T*qa);I.buffer=e.createBuffer();K.__webglCustomAttributes[a]=I}}y.__dirtyVertices=!0;y.__dirtyMorphTargets=!0;y.__dirtyElements=
+!0;y.__dirtyUvs=!0;y.__dirtyNormals=!0;y.__dirtyTangents=!0;y.__dirtyColors=!0}C instanceof THREE.ShadowVolume?B(w.__webglShadowVolumes,Q,C):B(w.__webglObjects,Q,C)}}else if(C instanceof THREE.LensFlare)B(w.__webglLensFlares,undefined,C);else if(C instanceof THREE.Ribbon){y=C.geometry;if(!y.__webglVertexBuffer){x=y;x.__webglVertexBuffer=e.createBuffer();x.__webglColorBuffer=e.createBuffer();x=y;Q=x.vertices.length;x.__vertexArray=new Float32Array(Q*3);x.__colorArray=new Float32Array(Q*3);x.__webglVertexCount=
+Q;y.__dirtyVertices=!0;y.__dirtyColors=!0}B(w.__webglObjects,y,C)}else if(C instanceof THREE.Line){y=C.geometry;if(!y.__webglVertexBuffer){x=y;x.__webglVertexBuffer=e.createBuffer();x.__webglColorBuffer=e.createBuffer();x=y;Q=x.vertices.length;x.__vertexArray=new Float32Array(Q*3);x.__colorArray=new Float32Array(Q*3);x.__webglLineCount=Q;y.__dirtyVertices=!0;y.__dirtyColors=!0}B(w.__webglObjects,y,C)}else if(C instanceof THREE.ParticleSystem){y=C.geometry;if(!y.__webglVertexBuffer){x=y;x.__webglVertexBuffer=
+e.createBuffer();x.__webglColorBuffer=e.createBuffer();x=y;Q=x.vertices.length;x.__vertexArray=new Float32Array(Q*3);x.__colorArray=new Float32Array(Q*3);x.__sortArray=[];x.__webglParticleCount=Q;y.__dirtyVertices=!0;y.__dirtyColors=!0}B(w.__webglObjects,y,C)}else if(THREE.MarchingCubes!==undefined&&C instanceof THREE.MarchingCubes)w.__webglObjectsImmediate.push({object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}});else C instanceof THREE.Sprite&&w.__webglSprites.push(C);n.__objectsAdded.splice(0,
+1)}for(;n.__objectsRemoved.length;){C=n.__objectsRemoved[0];w=n;y=void 0;x=void 0;if(C instanceof THREE.Mesh)for(y=w.__webglObjects.length-1;y>=0;y--){x=w.__webglObjects[y].object;if(C==x){w.__webglObjects.splice(y,1);break}}else if(C instanceof THREE.Sprite)for(y=w.__webglSprites.length-1;y>=0;y--){x=w.__webglSprites[y];if(C==x){w.__webglSprites.splice(y,1);break}}n.__objectsRemoved.splice(0,1)}C=0;for(w=n.__webglObjects.length;C<w;C++)J(n.__webglObjects[C].object,n);C=0;for(w=n.__webglShadowVolumes.length;C<
+w;C++)J(n.__webglShadowVolumes[C].object,n);C=0;for(w=n.__webglLensFlares.length;C<w;C++)J(n.__webglLensFlares[C].object,n)};this.setFaceCulling=function(n,C){if(n){!C||C=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(n=="back")e.cullFace(e.BACK);else n=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.WebGLRenderTarget=function(b,d,c){this.width=b;this.height=d;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBAFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==
 undefined?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==undefined?c.stencilBuffer:!0};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,c){c&&b.update(undefined,!1,d);c=b.sounds;var f,g=c.length;for(f=0;f<g;f++){b=c[f];this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34);this.soundPosition.subSelf(d.position);if(b.isPlaying&&b.isLoaded){b.isAddedToDOM||b.addToDOM(this.domElement);b.calculateVolumeAndPan(this.soundPosition)}}}};
@@ -338,26 +340,26 @@ THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
 THREE.AnimationHandler=function(){var b=[],d={},c={};c.update=function(g){for(var h=0;h<b.length;h++)b[h].update(g)};c.addToUpdate=function(g){b.indexOf(g)===-1&&b.push(g)};c.removeFromUpdate=function(g){g=b.indexOf(g);g!==-1&&b.splice(g,1)};c.add=function(g){d[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");d[g.name]=g;if(g.initialized!==!0){for(var h=0;h<g.hierarchy.length;h++){for(var j=0;j<g.hierarchy[h].keys.length;j++){if(g.hierarchy[h].keys[j].time<
-0)g.hierarchy[h].keys[j].time=0;if(g.hierarchy[h].keys[j].rot!==undefined&&!(g.hierarchy[h].keys[j].rot instanceof THREE.Quaternion)){var k=g.hierarchy[h].keys[j].rot;g.hierarchy[h].keys[j].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(g.hierarchy[h].keys[0].morphTargets!==undefined){k={};for(j=0;j<g.hierarchy[h].keys.length;j++)for(var m=0;m<g.hierarchy[h].keys[j].morphTargets.length;m++){var p=g.hierarchy[h].keys[j].morphTargets[m];k[p]=-1}g.hierarchy[h].usedMorphTargets=k;for(j=0;j<g.hierarchy[h].keys.length;j++){var o=
-{};for(p in k){for(m=0;m<g.hierarchy[h].keys[j].morphTargets.length;m++)if(g.hierarchy[h].keys[j].morphTargets[m]===p){o[p]=g.hierarchy[h].keys[j].morphTargetsInfluences[m];break}m===g.hierarchy[h].keys[j].morphTargets.length&&(o[p]=0)}g.hierarchy[h].keys[j].morphTargetsInfluences=o}}for(j=1;j<g.hierarchy[h].keys.length;j++)if(g.hierarchy[h].keys[j].time===g.hierarchy[h].keys[j-1].time){g.hierarchy[h].keys.splice(j,1);j--}for(j=1;j<g.hierarchy[h].keys.length;j++)g.hierarchy[h].keys[j].index=j}j=parseInt(g.length*
+0)g.hierarchy[h].keys[j].time=0;if(g.hierarchy[h].keys[j].rot!==undefined&&!(g.hierarchy[h].keys[j].rot instanceof THREE.Quaternion)){var k=g.hierarchy[h].keys[j].rot;g.hierarchy[h].keys[j].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(g.hierarchy[h].keys[0].morphTargets!==undefined){k={};for(j=0;j<g.hierarchy[h].keys.length;j++)for(var m=0;m<g.hierarchy[h].keys[j].morphTargets.length;m++){var o=g.hierarchy[h].keys[j].morphTargets[m];k[o]=-1}g.hierarchy[h].usedMorphTargets=k;for(j=0;j<g.hierarchy[h].keys.length;j++){var p=
+{};for(o in k){for(m=0;m<g.hierarchy[h].keys[j].morphTargets.length;m++)if(g.hierarchy[h].keys[j].morphTargets[m]===o){p[o]=g.hierarchy[h].keys[j].morphTargetsInfluences[m];break}m===g.hierarchy[h].keys[j].morphTargets.length&&(p[o]=0)}g.hierarchy[h].keys[j].morphTargetsInfluences=p}}for(j=1;j<g.hierarchy[h].keys.length;j++)if(g.hierarchy[h].keys[j].time===g.hierarchy[h].keys[j-1].time){g.hierarchy[h].keys.splice(j,1);j--}for(j=1;j<g.hierarchy[h].keys.length;j++)g.hierarchy[h].keys[j].index=j}j=parseInt(g.length*
 g.fps,10);g.JIT={};g.JIT.hierarchy=[];for(h=0;h<g.hierarchy.length;h++)g.JIT.hierarchy.push(Array(j));g.initialized=!0}};c.get=function(g){if(typeof g==="string")if(d[g])return d[g];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+g);return null}};c.parse=function(g){var h=[];if(g instanceof THREE.SkinnedMesh)for(var j=0;j<g.bones.length;j++)h.push(g.bones[j]);else f(g,h);return h};var f=function(g,h){h.push(g);for(var j=0;j<g.children.length;j++)f(g.children[j],h)};c.LINEAR=
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(b,d,c,f){this.root=b;this.data=THREE.AnimationHandler.get(d);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=c!==undefined?c:THREE.AnimationHandler.LINEAR;this.JITCompile=f!==undefined?f:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(b,d){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==undefined?b:!0;this.currentTime=d!==undefined?d:0;var c,f=this.hierarchy.length,g;for(c=0;c<f;c++){g=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===undefined){g.animationCache={};g.animationCache.prevKey={pos:0,rot:0,scl:0};g.animationCache.nextKey={pos:0,rot:0,scl:0};g.animationCache.originalMatrix=
 g instanceof THREE.Bone?g.skinMatrix:g.matrix}var h=g.animationCache.prevKey;g=g.animationCache.nextKey;h.pos=this.data.hierarchy[c].keys[0];h.rot=this.data.hierarchy[c].keys[0];h.scl=this.data.hierarchy[c].keys[0];g.pos=this.getNextKeyWith("pos",c,1);g.rot=this.getNextKeyWith("rot",c,1);g.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==undefined){if(this.hierarchy[b]instanceof THREE.Bone)this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix;else this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix;delete this.hierarchy[b].animationCache}};
-THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],c,f,g,h,j,k,m,p,o=this.data.JIT.hierarchy,u,y;this.currentTime+=b*this.timeScale;y=this.currentTime;u=this.currentTime%=this.data.length;p=parseInt(Math.min(u*this.data.fps,this.data.length*this.data.fps),10);for(var t=0,B=this.hierarchy.length;t<B;t++){b=this.hierarchy[t];m=b.animationCache;if(this.JITCompile&&o[t][p]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=o[t][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
-!1}else{b.matrix=o[t][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var F=0;F<3;F++){c=d[F];j=m.prevKey[c];k=m.nextKey[c];if(k.time<=y){if(u<y)if(this.loop){j=this.data.hierarchy[t].keys[0];for(k=this.getNextKeyWith(c,t,1);k.time<u;){j=k;k=this.getNextKeyWith(c,t,k.index+1)}}else{this.stop();return}else{do{j=k;k=this.getNextKeyWith(c,t,k.index+1)}while(k.time<
-u)}m.prevKey[c]=j;m.nextKey[c]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(u-j.time)/(k.time-j.time);g=j[c];h=k[c];if(f<0||f>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+t);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",t,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",t,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;t<this.hierarchy.length;t++)o[t][p]=this.hierarchy[t]instanceof THREE.Bone?this.hierarchy[t].skinMatrix.clone():this.hierarchy[t].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var c=[],f=[],g,h,j,k,m,p;g=(b.length-1)*d;h=Math.floor(g);g-=h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>b.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];p=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],p[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],p[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],p[2],g,c,j);return f};
+THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],c,f,g,h,j,k,m,o,p=this.data.JIT.hierarchy,t,z;this.currentTime+=b*this.timeScale;z=this.currentTime;t=this.currentTime%=this.data.length;o=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,A=this.hierarchy.length;u<A;u++){b=this.hierarchy[u];m=b.animationCache;if(this.JITCompile&&p[u][o]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=p[u][o];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
+!1}else{b.matrix=p[u][o];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var E=0;E<3;E++){c=d[E];j=m.prevKey[c];k=m.nextKey[c];if(k.time<=z){if(t<z)if(this.loop){j=this.data.hierarchy[u].keys[0];for(k=this.getNextKeyWith(c,u,1);k.time<t;){j=k;k=this.getNextKeyWith(c,u,k.index+1)}}else{this.stop();return}else{do{j=k;k=this.getNextKeyWith(c,u,k.index+1)}while(k.time<
+t)}m.prevKey[c]=j;m.nextKey[c]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(t-j.time)/(k.time-j.time);g=j[c];h=k[c];if(f<0||f>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",u,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c===
+"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&p[0][o]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u<this.hierarchy.length;u++)p[u][o]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var c=[],f=[],g,h,j,k,m,o;g=(b.length-1)*d;h=Math.floor(g);g-=h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>b.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];o=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],o[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],o[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],o[2],g,c,j);return f};
 THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<f.length-1?c:f.length-1;else c%=f.length;for(;c<f.length;c++)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]};
-var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,p=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var o=0,u=j.length;o<u;o++){var y=new THREE.Vertex(j[o].position.clone());c&&d.matrix.multiplyVector3(y.position);h.push(y)}o=0;for(u=m.length;o<u;o++){j=m[o];var t,B,F=j.vertexNormals;y=j.vertexColors;if(j instanceof THREE.Face3)t=new THREE.Face3(j.a+f,j.b+f,j.c+
-f);else j instanceof THREE.Face4&&(t=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));t.normal.copy(j.normal);c=0;for(h=F.length;c<h;c++){B=F[c];t.vertexNormals.push(B.clone())}t.color.copy(j.color);c=0;for(h=y.length;c<h;c++){B=y[c];t.vertexColors.push(B.clone())}t.materials=j.materials.slice();t.centroid.copy(j.centroid);k.push(t)}o=0;for(u=g.length;o<u;o++){f=g[o];k=[];c=0;for(h=f.length;c<h;c++)k.push(new THREE.UV(f[c].u,f[c].v));p.push(k)}}};
+var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,o=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var p=0,t=j.length;p<t;p++){var z=new THREE.Vertex(j[p].position.clone());c&&d.matrix.multiplyVector3(z.position);h.push(z)}p=0;for(t=m.length;p<t;p++){j=m[p];var u,A,E=j.vertexNormals;z=j.vertexColors;if(j instanceof THREE.Face3)u=new THREE.Face3(j.a+f,j.b+f,j.c+
+f);else j instanceof THREE.Face4&&(u=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));u.normal.copy(j.normal);c=0;for(h=E.length;c<h;c++){A=E[c];u.vertexNormals.push(A.clone())}u.color.copy(j.color);c=0;for(h=z.length;c<h;c++){A=z[c];u.vertexColors.push(A.clone())}u.materials=j.materials.slice();u.centroid.copy(j.centroid);k.push(u)}p=0;for(t=g.length;p<t;p++){f=g[p];k=[];c=0;for(h=f.length;c<h;c++)k.push(new THREE.UV(f[c].u,f[c].v));o.push(k)}}};
 THREE.ImageUtils={loadTexture:function(b,d,c){var f=new Image,g=new THREE.Texture(f,d);f.onload=function(){g.needsUpdate=!0;c&&c(this)};f.src=b;return g},loadTextureCube:function(b,d,c){var f,g=[],h=new THREE.Texture(g,d);d=g.loadCount=0;for(f=b.length;d<f;++d){g[d]=new Image;g[d].onload=function(){g.loadCount+=1;if(g.loadCount==6)h.needsUpdate=!0;c&&c(this)};g[d].src=b[d]}return h}};
-THREE.SceneUtils={addMesh:function(b,d,c,f,g,h,j,k,m,p){d=new THREE.Mesh(d,p);d.scale.x=d.scale.y=d.scale.z=c;d.position.x=f;d.position.y=g;d.position.z=h;d.rotation.x=j;d.rotation.y=k;d.rotation.z=m;b.addObject(d);return d},addPanoramaCubeWebGL:function(b,d,c){var f=THREE.ShaderUtils.lib.cube;f.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:f.uniforms});d=new THREE.Mesh(new THREE.Cube(d,d,d,1,1,1,null,!0),c);b.addObject(d);
+THREE.SceneUtils={addMesh:function(b,d,c,f,g,h,j,k,m,o){d=new THREE.Mesh(d,o);d.scale.x=d.scale.y=d.scale.z=c;d.position.x=f;d.position.y=g;d.position.z=h;d.rotation.x=j;d.rotation.y=k;d.rotation.z=m;b.addObject(d);return d},addPanoramaCubeWebGL:function(b,d,c){var f=THREE.ShaderUtils.lib.cube;f.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:f.uniforms});d=new THREE.Mesh(new THREE.Cube(d,d,d,1,1,1,null,!0),c);b.addObject(d);
 return d},addPanoramaCube:function(b,d,c){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));d=new THREE.Mesh(new THREE.Cube(d,d,d,1,1,f,!0),
 new THREE.MeshFaceMaterial);b.addObject(d);return d},addPanoramaCubePlanes:function(b,d,c){var f=d/2;d=new THREE.Plane(d,d);var g=Math.PI,h=Math.PI/2;THREE.SceneUtils.addMesh(b,d,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));THREE.SceneUtils.addMesh(b,d,1,-f,0,0,0,h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));THREE.SceneUtils.addMesh(b,d,1,f,0,0,0,-h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));THREE.SceneUtils.addMesh(b,d,1,0,f,0,h,
 0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));THREE.SceneUtils.addMesh(b,d,1,0,-f,0,-h,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))},showHierarchy:function(b,d){THREE.SceneUtils.traverseHierarchy(b,function(c){c.visible=d})},traverseHierarchy:function(b,d){var c,f,g=b.children.length;for(f=0;f<g;f++){c=b.children[f];d(c);THREE.SceneUtils.traverseHierarchy(c,d)}}};
@@ -371,7 +373,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var d,c,f,g,h=2*Math.ceil(b*3)+1;h>25&&(h=25);g=(h-1)*0.5;c=Array(h);for(d=f=0;d<h;++d){c[d]=Math.exp(-((d-g)*(d-g))/(2*b*b));f+=c[d]}for(d=0;d<h;++d)c[d]/=f;return c}};
-THREE.QuakeCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=
+THREE.QuakeCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=
 b.lookSpeed;if(b.noFly!==undefined)this.noFly=b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.activeLook!==undefined)this.activeLook=b.activeLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax=b.heightMax;if(b.constrainVertical!==undefined)this.constrainVertical=
 b.constrainVertical;if(b.verticalMin!==undefined)this.verticalMin=b.verticalMin;if(b.verticalMax!==undefined)this.verticalMax=b.verticalMax;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();
 c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};this.onKeyDown=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=
@@ -380,16 +382,16 @@ this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0
 this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var f=this.target.position,g=this.position;f.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);f.y=g.y+100*Math.cos(this.phi);f.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-
 this.verticalMin)/3.14+this.verticalMin;f=this.target.position;g=this.position;f.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);f.y=g.y+100*Math.cos(this.phi);f.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",
 d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};
-THREE.PathCamera=function(b){function d(p,o,u,y){var t={name:u,fps:0.6,length:y,hierarchy:[]},B,F=o.getControlPointsArray(),H=o.getLength(),G=F.length,X=0;B=G-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:F[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[B]={time:y,pos:F[B],rot:[0,0,0,1],scl:[1,1,1]};for(B=1;B<G-1;B++){X=y*H.chunks[B]/H.total;o.keys[B]={time:X,pos:F[B]}}t.hierarchy[0]=o;THREE.AnimationHandler.add(t);return new THREE.Animation(p,u,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(p,o){var u,
-y,t=new THREE.Geometry;for(u=0;u<p.points.length*o;u++){y=u/(p.points.length*o);y=p.getPoint(y);t.vertices[u]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return t}function f(p,o){var u=c(o,10),y=c(o,10),t=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(u,t);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);p.addChild(lineObj);particleObj.scale.set(1,1,1);p.addChild(particleObj);y=new Sphere(1,
-16,8);t=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){u=new THREE.Mesh(y,t);u.position.copy(o.points[i]);u.updateMatrix();p.addChild(u)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
+THREE.PathCamera=function(b){function d(o,p,t,z){var u={name:t,fps:0.6,length:z,hierarchy:[]},A,E=p.getControlPointsArray(),H=p.getLength(),J=E.length,W=0;A=J-1;p={parent:-1,keys:[]};p.keys[0]={time:0,pos:E[0],rot:[0,0,0,1],scl:[1,1,1]};p.keys[A]={time:z,pos:E[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A<J-1;A++){W=z*H.chunks[A]/H.total;p.keys[A]={time:W,pos:E[A]}}u.hierarchy[0]=p;THREE.AnimationHandler.add(u);return new THREE.Animation(o,t,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(o,p){var t,
+z,u=new THREE.Geometry;for(t=0;t<o.points.length*p;t++){z=t/(o.points.length*p);z=o.getPoint(z);u.vertices[t]=new THREE.Vertex(new THREE.Vector3(z.x,z.y,z.z))}return u}function f(o,p){var t=c(p,10),z=c(p,10),u=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(t,u);particleObj=new THREE.ParticleSystem(z,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);o.addChild(lineObj);particleObj.scale.set(1,1,1);o.addChild(particleObj);z=new Sphere(1,
+16,8);u=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<p.points.length;i++){t=new THREE.Mesh(z,u);t.position.copy(p.points[i]);t.updateMatrix();o.addChild(t)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
 !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(b){if(b.duration!==undefined)this.duration=b.duration*1E3;if(b.waypoints!==undefined)this.waypoints=b.waypoints;if(b.useConstantSpeed!==undefined)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==undefined)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==undefined)this.createDebugPath=b.createDebugPath;
 if(b.createDebugDummy!==undefined)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==undefined)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==undefined)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==undefined)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=
-this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,u){var y,t;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;y=this.phi%g;this.phi=y>=0?y:y+g;y=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange;
-this.phi=(this.phi-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0];y=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,u)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
+this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(o,p,t){var z,u;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;z=this.phi%g;this.phi=z>=0?z:z+g;z=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange;
+this.phi=(this.phi-z[0])*(u[1]-u[0])/(z[1]-z[0])+u[0];z=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(u[1]-u[0])/(z[1]-z[0])+u[0];z=this.target.position;z.x=100*Math.sin(this.phi)*Math.cos(this.theta);z.y=100*Math.cos(this.phi);z.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,p,t)};this.onMouseMove=function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=
-d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(p,o){return function(){o.apply(p,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.tdiff=0;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==undefined)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.autoForward!==
+d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(o,p){return function(){p.apply(o,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
+THREE.FlyCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.tdiff=0;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==undefined)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.autoForward!==
 undefined)this.autoForward=b.autoForward;if(b.domElement!==undefined)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=(new Date).getTime();this.handleEvent=function(c){if(typeof this[c.type]=="function")this[c.type](c)};this.keydown=
 function(c){if(!c.altKey){switch(c.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;
 break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(c){switch(c.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=
@@ -399,79 +401,80 @@ c;c=this.tdiff*this.movementSpeed;var f=this.tdiff*this.rollSpeed;this.translate
 function(){var c=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-c+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=
 function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1);
 window.addEventListener("keyup",d(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
-THREE.Cube=function(b,d,c,f,g,h,j,k,m){function p(H,G,X,A,M,Q,R,Da){var ma,va,ca=f||1,e=g||1,ea=M/2,ya=Q/2,Ba=o.vertices.length;if(H=="x"&&G=="y"||H=="y"&&G=="x")ma="z";else if(H=="x"&&G=="z"||H=="z"&&G=="x"){ma="y";e=h||1}else if(H=="z"&&G=="y"||H=="y"&&G=="z"){ma="x";ca=h||1}var Fa=ca+1,Z=e+1;M/=ca;var oa=Q/e;for(va=0;va<Z;va++)for(Q=0;Q<Fa;Q++){var pa=new THREE.Vector3;pa[H]=(Q*M-ea)*X;pa[G]=(va*oa-ya)*A;pa[ma]=R;o.vertices.push(new THREE.Vertex(pa))}for(va=0;va<e;va++)for(Q=0;Q<ca;Q++){o.faces.push(new THREE.Face4(Q+
-Fa*va+Ba,Q+Fa*(va+1)+Ba,Q+1+Fa*(va+1)+Ba,Q+1+Fa*va+Ba,null,null,Da));o.faceVertexUvs[0].push([new THREE.UV(Q/ca,va/e),new THREE.UV(Q/ca,(va+1)/e),new THREE.UV((Q+1)/ca,(va+1)/e),new THREE.UV((Q+1)/ca,va/e)])}}THREE.Geometry.call(this);var o=this,u=b/2,y=d/2,t=c/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var B=0;B<6;B++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=undefined)for(var F in m)this.sides[F]!=
-undefined&&(this.sides[F]=m[F]);this.sides.px&&p("z","y",1*k,-1,c,d,-u,this.materials[0]);this.sides.nx&&p("z","y",-1*k,-1,c,d,u,this.materials[1]);this.sides.py&&p("x","z",1*k,1,b,c,y,this.materials[2]);this.sides.ny&&p("x","z",1*k,-1,b,c,-y,this.materials[3]);this.sides.pz&&p("x","y",1*k,-1,b,d,t,this.materials[4]);this.sides.nz&&p("x","y",-1*k,-1,b,d,-t,this.materials[5]);(function(){for(var H=[],G=[],X=0,A=o.vertices.length;X<A;X++){for(var M=o.vertices[X],Q=!1,R=0,Da=H.length;R<Da;R++){var ma=
-H[R];if(M.position.x==ma.position.x&&M.position.y==ma.position.y&&M.position.z==ma.position.z){G[X]=R;Q=!0;break}}if(!Q){G[X]=H.length;H.push(new THREE.Vertex(M.position.clone()))}}X=0;for(A=o.faces.length;X<A;X++){M=o.faces[X];M.a=G[M.a];M.b=G[M.b];M.c=G[M.c];M.d=G[M.d]}o.vertices=H})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
-THREE.Cylinder=function(b,d,c,f,g,h){function j(y,t,B){k.vertices.push(new THREE.Vertex(new THREE.Vector3(y,t,B)))}THREE.Geometry.call(this);var k=this,m,p=Math.PI*2,o=f/2;for(m=0;m<b;m++)j(Math.sin(p*m/b)*d,Math.cos(p*m/b)*d,-o);for(m=0;m<b;m++)j(Math.sin(p*m/b)*c,Math.cos(p*m/b)*c,o);for(m=0;m<b;m++)k.faces.push(new THREE.Face4(m,m+b,b+(m+1)%b,(m+1)%b));if(c>0){j(0,0,-o-(h||0));for(m=b;m<b+b/2;m++)k.faces.push(new THREE.Face4(2*b,(2*m-2*b)%b,(2*m-2*b+1)%b,(2*m-2*b+2)%b))}if(d>0){j(0,0,o+(g||0));
-for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m<b;m++){d=[];c=this.faces[m];g=this.vertices[c.a];h=this.vertices[c.b];o=this.vertices[c.c];var u=this.vertices[c.d];d.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/p,0.5+g.position.z/f));d.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/p,0.5+h.position.z/f));d.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/p,0.5+o.position.z/
-f));c instanceof THREE.Face4&&d.push(new THREE.UV(0.5+Math.atan2(u.position.x,u.position.y)/p,0.5+u.position.z/f));this.faceVertexUvs[0].push(d)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
-THREE.Icosahedron=function(b){function d(u,y,t){var B=Math.sqrt(u*u+y*y+t*t);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(u/B,y/B,t/B)))-1}function c(u,y,t,B){B.faces.push(new THREE.Face3(u,y,t))}function f(u,y){var t=g.vertices[u].position,B=g.vertices[y].position;return d((t.x+B.x)/2,(t.y+B.y)/2,(t.z+B.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;d(-1,b,0);d(1,b,0);d(-1,-b,0);d(1,-b,0);d(0,-1,b);d(0,1,b);d(0,-1,-b);d(0,
-1,-b);d(b,0,-1);d(b,0,1);d(-b,0,-1);d(-b,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var m=f(h.faces[k].a,h.faces[k].b),p=f(h.faces[k].b,h.faces[k].c),o=f(h.faces[k].c,h.faces[k].a);c(h.faces[k].a,m,o,j);c(h.faces[k].b,p,m,j);c(h.faces[k].c,
-o,p,j);c(m,p,o,j)}h.faces=j.faces}g.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
-THREE.Lathe=function(b,d,c){THREE.Geometry.call(this);this.steps=d||12;this.angle=c||2*Math.PI;d=this.angle/this.steps;c=[];for(var f=[],g=[],h=[],j=(new THREE.Matrix4).setRotationZ(d),k=0;k<b.length;k++){this.vertices.push(new THREE.Vertex(b[k]));c[k]=b[k].clone();f[k]=this.vertices.length-1}for(var m=0;m<=this.angle+0.0010;m+=d){for(k=0;k<c.length;k++)if(m<this.angle){c[k]=j.multiplyVector3(c[k].clone());this.vertices.push(new THREE.Vertex(c[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=f);
+THREE.Cube=function(b,d,c,f,g,h,j,k,m){function o(H,J,W,B,U,N,O,ua){var la,pa,ga=f||1,ha=g||1,e=U/2,oa=N/2,Da=p.vertices.length;if(H=="x"&&J=="y"||H=="y"&&J=="x")la="z";else if(H=="x"&&J=="z"||H=="z"&&J=="x"){la="y";ha=h||1}else if(H=="z"&&J=="y"||H=="y"&&J=="z"){la="x";ga=h||1}var Aa=ga+1,ka=ha+1;U/=ga;var fa=N/ha;for(pa=0;pa<ka;pa++)for(N=0;N<Aa;N++){var va=new THREE.Vector3;va[H]=(N*U-e)*W;va[J]=(pa*fa-oa)*B;va[la]=O;p.vertices.push(new THREE.Vertex(va))}for(pa=0;pa<ha;pa++)for(N=0;N<ga;N++){p.faces.push(new THREE.Face4(N+
+Aa*pa+Da,N+Aa*(pa+1)+Da,N+1+Aa*(pa+1)+Da,N+1+Aa*pa+Da,null,null,ua));p.faceVertexUvs[0].push([new THREE.UV(N/ga,pa/ha),new THREE.UV(N/ga,(pa+1)/ha),new THREE.UV((N+1)/ga,(pa+1)/ha),new THREE.UV((N+1)/ga,pa/ha)])}}THREE.Geometry.call(this);var p=this,t=b/2,z=d/2,u=c/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=undefined)for(var E in m)this.sides[E]!=
+undefined&&(this.sides[E]=m[E]);this.sides.px&&o("z","y",1*k,-1,c,d,-t,this.materials[0]);this.sides.nx&&o("z","y",-1*k,-1,c,d,t,this.materials[1]);this.sides.py&&o("x","z",1*k,1,b,c,z,this.materials[2]);this.sides.ny&&o("x","z",1*k,-1,b,c,-z,this.materials[3]);this.sides.pz&&o("x","y",1*k,-1,b,d,u,this.materials[4]);this.sides.nz&&o("x","y",-1*k,-1,b,d,-u,this.materials[5]);(function(){for(var H=[],J=[],W=0,B=p.vertices.length;W<B;W++){for(var U=p.vertices[W],N=!1,O=0,ua=H.length;O<ua;O++){var la=
+H[O];if(U.position.x==la.position.x&&U.position.y==la.position.y&&U.position.z==la.position.z){J[W]=O;N=!0;break}}if(!N){J[W]=H.length;H.push(new THREE.Vertex(U.position.clone()))}}W=0;for(B=p.faces.length;W<B;W++){U=p.faces[W];U.a=J[U.a];U.b=J[U.b];U.c=J[U.c];U.d=J[U.d]}p.vertices=H})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
+THREE.Cylinder=function(b,d,c,f,g,h){function j(z,u,A){k.vertices.push(new THREE.Vertex(new THREE.Vector3(z,u,A)))}THREE.Geometry.call(this);var k=this,m,o=Math.PI*2,p=f/2;for(m=0;m<b;m++)j(Math.sin(o*m/b)*d,Math.cos(o*m/b)*d,-p);for(m=0;m<b;m++)j(Math.sin(o*m/b)*c,Math.cos(o*m/b)*c,p);for(m=0;m<b;m++)k.faces.push(new THREE.Face4(m,m+b,b+(m+1)%b,(m+1)%b));if(c>0){j(0,0,-p-(h||0));for(m=b;m<b+b/2;m++)k.faces.push(new THREE.Face4(2*b,(2*m-2*b)%b,(2*m-2*b+1)%b,(2*m-2*b+2)%b))}if(d>0){j(0,0,p+(g||0));
+for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m<b;m++){d=[];c=this.faces[m];g=this.vertices[c.a];h=this.vertices[c.b];p=this.vertices[c.c];var t=this.vertices[c.d];d.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/o,0.5+g.position.z/f));d.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/o,0.5+h.position.z/f));d.push(new THREE.UV(0.5+Math.atan2(p.position.x,p.position.y)/o,0.5+p.position.z/
+f));c instanceof THREE.Face4&&d.push(new THREE.UV(0.5+Math.atan2(t.position.x,t.position.y)/o,0.5+t.position.z/f));this.faceVertexUvs[0].push(d)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
+THREE.Icosahedron=function(b){function d(t,z,u){var A=Math.sqrt(t*t+z*z+u*u);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(t/A,z/A,u/A)))-1}function c(t,z,u,A){A.faces.push(new THREE.Face3(t,z,u))}function f(t,z){var u=g.vertices[t].position,A=g.vertices[z].position;return d((u.x+A.x)/2,(u.y+A.y)/2,(u.z+A.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;d(-1,b,0);d(1,b,0);d(-1,-b,0);d(1,-b,0);d(0,-1,b);d(0,1,b);d(0,-1,-b);d(0,
+1,-b);d(b,0,-1);d(b,0,1);d(-b,0,-1);d(-b,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var m=f(h.faces[k].a,h.faces[k].b),o=f(h.faces[k].b,h.faces[k].c),p=f(h.faces[k].c,h.faces[k].a);c(h.faces[k].a,m,p,j);c(h.faces[k].b,o,m,j);c(h.faces[k].c,
+p,o,j);c(m,o,p,j)}h.faces=j.faces}g.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
+THREE.Lathe=function(b,d,c){THREE.Geometry.call(this);this.steps=d||12;this.angle=c||2*Math.PI;d=this.angle/this.steps;c=[];for(var f=[],g=[],h=[],j=(new THREE.Matrix4).setRotationZ(d),k=0;k<b.length;k++){this.vertices.push(new THREE.Vertex(b[k]));c[k]=b[k].clone();f[k]=this.vertices.length-1}for(var m=0;m<=this.angle+0.001;m+=d){for(k=0;k<c.length;k++)if(m<this.angle){c[k]=j.multiplyVector3(c[k].clone());this.vertices.push(new THREE.Vertex(c[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=f);
 for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],f[k+1],f[k]));this.faceVertexUvs[0].push([new THREE.UV(1-m/this.angle,k/b.length),new THREE.UV(1-m/this.angle,(k+1)/b.length),new THREE.UV(1-(m-d)/this.angle,(k+1)/b.length),new THREE.UV(1-(m-d)/this.angle,k/b.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
-THREE.Plane=function(b,d,c,f){THREE.Geometry.call(this);var g,h=b/2,j=d/2;c=c||1;f=f||1;var k=c+1,m=f+1;b/=c;var p=d/f;for(g=0;g<m;g++)for(d=0;d<k;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*b-h,-(g*p-j),0)));for(g=0;g<f;g++)for(d=0;d<c;d++){this.faces.push(new THREE.Face4(d+k*g,d+k*(g+1),d+1+k*(g+1),d+1+k*g));this.faceVertexUvs[0].push([new THREE.UV(d/c,g/f),new THREE.UV(d/c,(g+1)/f),new THREE.UV((d+1)/c,(g+1)/f),new THREE.UV((d+1)/c,g/f)])}this.computeCentroids();this.computeFaceNormals()};
+THREE.Plane=function(b,d,c,f){THREE.Geometry.call(this);var g,h=b/2,j=d/2;c=c||1;f=f||1;var k=c+1,m=f+1;b/=c;var o=d/f;for(g=0;g<m;g++)for(d=0;d<k;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*b-h,-(g*o-j),0)));for(g=0;g<f;g++)for(d=0;d<c;d++){this.faces.push(new THREE.Face4(d+k*g,d+k*(g+1),d+1+k*(g+1),d+1+k*g));this.faceVertexUvs[0].push([new THREE.UV(d/c,g/f),new THREE.UV(d/c,(g+1)/f),new THREE.UV((d+1)/c,(g+1)/f),new THREE.UV((d+1)/c,g/f)])}this.computeCentroids();this.computeFaceNormals()};
 THREE.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
-THREE.Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c<j+1;c++){f=c/j;var k=b*Math.cos(f*g),m=b*Math.sin(f*g),p=[],o=0;for(f=0;f<h;f++){var u=2*f/h,y=m*Math.sin(u*g);u=m*Math.cos(u*g);(c==0||c==j)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,y)))-1);p.push(o)}d.push(p)}var t,B,F;g=d.length;for(c=0;c<g;c++){h=d[c].length;if(c>0)for(f=0;f<h;f++){p=f==h-1;j=d[c][p?0:f+1];k=d[c][p?h-1:f];m=d[c-1][p?h-1:f];p=d[c-
-1][p?0:f+1];y=c/(g-1);t=(c-1)/(g-1);B=(f+1)/h;u=f/h;o=new THREE.UV(1-B,y);y=new THREE.UV(1-u,y);u=new THREE.UV(1-u,t);var H=new THREE.UV(1-B,t);if(c<d.length-1){t=this.vertices[j].position.clone();B=this.vertices[k].position.clone();F=this.vertices[m].position.clone();t.normalize();B.normalize();F.normalize();this.faces.push(new THREE.Face3(j,k,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(F.x,F.y,F.z)]));this.faceVertexUvs[0].push([o,y,u])}if(c>1){t=this.vertices[j].position.clone();
-B=this.vertices[m].position.clone();F=this.vertices[p].position.clone();t.normalize();B.normalize();F.normalize();this.faces.push(new THREE.Face3(j,m,p,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(F.x,F.y,F.z)]));this.faceVertexUvs[0].push([o,u,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
+THREE.Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c<j+1;c++){f=c/j;var k=b*Math.cos(f*g),m=b*Math.sin(f*g),o=[],p=0;for(f=0;f<h;f++){var t=2*f/h,z=m*Math.sin(t*g);t=m*Math.cos(t*g);(c==0||c==j)&&f>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,z)))-1);o.push(p)}d.push(o)}var u,A,E;g=d.length;for(c=0;c<g;c++){h=d[c].length;if(c>0)for(f=0;f<h;f++){o=f==h-1;j=d[c][o?0:f+1];k=d[c][o?h-1:f];m=d[c-1][o?h-1:f];o=d[c-
+1][o?0:f+1];z=c/(g-1);u=(c-1)/(g-1);A=(f+1)/h;t=f/h;p=new THREE.UV(1-A,z);z=new THREE.UV(1-t,z);t=new THREE.UV(1-t,u);var H=new THREE.UV(1-A,u);if(c<d.length-1){u=this.vertices[j].position.clone();A=this.vertices[k].position.clone();E=this.vertices[m].position.clone();u.normalize();A.normalize();E.normalize();this.faces.push(new THREE.Face3(j,k,m,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(E.x,E.y,E.z)]));this.faceVertexUvs[0].push([p,z,t])}if(c>1){u=this.vertices[j].position.clone();
+A=this.vertices[m].position.clone();E=this.vertices[o].position.clone();u.normalize();A.normalize();E.normalize();this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(E.x,E.y,E.z)]));this.faceVertexUvs[0].push([p,t,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
 THREE.Torus=function(b,d,c,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c=
 1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
-THREE.TorusKnot=function(b,d,c,f,g,h,j){function k(u,y,t,B,F,H){y=t/B*u;t=Math.cos(y);return new THREE.Vector3(F*(2+t)*0.5*Math.cos(u),F*(2+t)*Math.sin(u)*0.5,H*F*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(d=0;d<this.segmentsT;++d){var m=
+THREE.TorusKnot=function(b,d,c,f,g,h,j){function k(t,z,u,A,E,H){z=u/A*t;u=Math.cos(z);return new THREE.Vector3(E*(2+u)*0.5*Math.cos(t),E*(2+u)*Math.sin(t)*0.5,H*E*Math.sin(z)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(d=0;d<this.segmentsT;++d){var m=
 b/this.segmentsR*2*this.p*Math.PI;j=d/this.segmentsT*2*Math.PI;g=k(m,j,this.q,this.p,this.radius,this.heightScale);m=k(m+0.01,j,this.q,this.p,this.radius,this.heightScale);c.x=m.x-g.x;c.y=m.y-g.y;c.z=m.z-g.z;f.x=m.x+g.x;f.y=m.y+g.y;f.z=m.z+g.z;h.cross(c,f);f.cross(h,c);h.normalize();f.normalize();m=-this.tube*Math.cos(j);j=this.tube*Math.sin(j);g.x+=m*f.x+j*h.x;g.y+=m*f.y+j*h.y;g.z+=m*f.z+j*h.z;this.grid[b][d]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(d=
-0;d<this.segmentsT;++d){f=(b+1)%this.segmentsR;h=(d+1)%this.segmentsT;g=this.grid[b][d];c=this.grid[f][d];f=this.grid[f][h];h=this.grid[b][h];j=new THREE.UV(b/this.segmentsR,d/this.segmentsT);m=new THREE.UV((b+1)/this.segmentsR,d/this.segmentsT);var p=new THREE.UV((b+1)/this.segmentsR,(d+1)/this.segmentsT),o=new THREE.UV(b/this.segmentsR,(d+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,c,f,h));this.faceVertexUvs[0].push([j,m,p,o])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
+0;d<this.segmentsT;++d){f=(b+1)%this.segmentsR;h=(d+1)%this.segmentsT;g=this.grid[b][d];c=this.grid[f][d];f=this.grid[f][h];h=this.grid[b][h];j=new THREE.UV(b/this.segmentsR,d/this.segmentsT);m=new THREE.UV((b+1)/this.segmentsR,d/this.segmentsT);var o=new THREE.UV((b+1)/this.segmentsR,(d+1)/this.segmentsT),p=new THREE.UV(b/this.segmentsR,(d+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,c,f,h));this.faceVertexUvs[0].push([j,m,o,p])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
 THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={addStatusElement:function(){var b=document.createElement("div");b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="rgba(0,0,0,0.25)";b.style.color="#fff";b.style.width="120px";b.style.padding="0.5em 0.5em 0.5em 0.5em";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var d="Loaded ";d+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/1E3).toFixed(2)+" KB";
-this.statusDomElement.innerHTML=d},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,d,c){b.materials=[];for(var f=0;f<d.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],c)]},createMaterial:function(b,d){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function f(k,m){var p=new Image;p.onload=function(){if(!c(this.width)||!c(this.height)){var o=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),u=Math.pow(2,Math.round(Math.log(this.height)/
-Math.LN2));k.image.width=o;k.image.height=u;k.image.getContext("2d").drawImage(this,0,0,o,u)}else k.image=this;k.needsUpdate=!0};p.src=m}var g,h,j;g="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,wireframe:b.wireframe};if(b.shading)if(b.shading=="Phong")g="MeshPhongMaterial";else b.shading=="Basic"&&(g="MeshBasicMaterial");if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(b.blending==
+this.statusDomElement.innerHTML=d},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,d,c){b.materials=[];for(var f=0;f<d.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],c)]},createMaterial:function(b,d){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function f(k,m){var o=new Image;o.onload=function(){if(!c(this.width)||!c(this.height)){var p=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),t=Math.pow(2,Math.round(Math.log(this.height)/
+Math.LN2));k.image.width=p;k.image.height=t;k.image.getContext("2d").drawImage(this,0,0,p,t)}else k.image=this;k.needsUpdate=!0};o.src=m}var g,h,j;g="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,wireframe:b.wireframe};if(b.shading)if(b.shading=="Phong")g="MeshPhongMaterial";else b.shading=="Basic"&&(g="MeshBasicMaterial");if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(b.blending==
 "Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==undefined)h.transparent=b.transparent;if(b.depthTest!==undefined)h.depthTest=b.depthTest;if(b.vertexColors!==undefined)if(b.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(b.vertexColors)h.vertexColors=THREE.VertexColors;if(b.mapDiffuse&&d){j=document.createElement("canvas");h.map=new THREE.Texture(j);h.map.sourceFile=b.mapDiffuse;f(h.map,d+"/"+b.mapDiffuse)}else if(b.colorDiffuse){j=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*
 255<<8)+b.colorDiffuse[2]*255;h.color=j;h.opacity=b.transparency}else if(b.DbgColor)h.color=b.DbgColor;if(b.mapLightmap&&d){j=document.createElement("canvas");h.lightMap=new THREE.Texture(j);h.lightMap.sourceFile=b.mapLightmap;f(h.lightMap,d+"/"+b.mapLightmap)}return new THREE[g](h)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(b){var d=this,c=b.model,f=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(c);b=new Worker(c);b.onmessage=function(h){d.createModel(h.data,f,g);d.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(b,d,c){var f=new THREE.Geometry;this.init_materials(f,b.materials,c);(function(){if(b.version===undefined||b.version!=2)console.error("Deprecated file format.");else{var g,h,j,k,m,p,o,u,y,t,B,F,H,G,X,A=b.faces;t=b.vertices;var M=b.normals,Q=b.colors;p=b.scale!==undefined?b.scale:1;var R=0;for(g=0;g<b.uvs.length;g++)b.uvs[g].length&&R++;for(g=0;g<R;g++){f.faceUvs[g]=[];f.faceVertexUvs[g]=[]}k=0;for(m=t.length;k<m;){o=new THREE.Vertex;o.position.x=t[k++]/
-p;o.position.y=t[k++]/p;o.position.z=t[k++]/p;f.vertices.push(o)}k=0;for(m=A.length;k<m;){t=A[k++];p=t&1;j=t&2;g=t&4;h=t&8;u=t&16;o=t&32;B=t&64;t&=128;if(p){F=new THREE.Face4;F.a=A[k++];F.b=A[k++];F.c=A[k++];F.d=A[k++];p=4}else{F=new THREE.Face3;F.a=A[k++];F.b=A[k++];F.c=A[k++];p=3}if(j){j=A[k++];F.materials=f.materials[j]}j=f.faces.length;if(g)for(g=0;g<R;g++){H=b.uvs[g];y=A[k++];X=H[y*2];y=H[y*2+1];f.faceUvs[g][j]=new THREE.UV(X,y)}if(h)for(g=0;g<R;g++){H=b.uvs[g];G=[];for(h=0;h<p;h++){y=A[k++];
-X=H[y*2];y=H[y*2+1];G[h]=new THREE.UV(X,y)}f.faceVertexUvs[g][j]=G}if(u){u=A[k++]*3;h=new THREE.Vector3;h.x=M[u++];h.y=M[u++];h.z=M[u];F.normal=h}if(o)for(g=0;g<p;g++){u=A[k++]*3;h=new THREE.Vector3;h.x=M[u++];h.y=M[u++];h.z=M[u];F.vertexNormals.push(h)}if(B){o=A[k++];o=new THREE.Color(Q[o]);F.color=o}if(t)for(g=0;g<p;g++){o=A[k++];o=new THREE.Color(Q[o]);F.vertexColors.push(o)}f.faces.push(F)}}})();(function(){var g,h,j,k;if(b.skinWeights){g=0;for(h=b.skinWeights.length;g<h;g+=2){j=b.skinWeights[g];
-k=b.skinWeights[g+1];f.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(b.skinIndices){g=0;for(h=b.skinIndices.length;g<h;g+=2){j=b.skinIndices[g];k=b.skinIndices[g+1];f.skinIndices.push(new THREE.Vector4(j,k,0,0))}}f.bones=b.bones;f.animation=b.animation})();(function(){if(b.morphTargets!==undefined){var g,h,j,k,m,p;g=0;for(h=b.morphTargets.length;g<h;g++){f.morphTargets[g]={};f.morphTargets[g].name=b.morphTargets[g].name;f.morphTargets[g].vertices=[];m=f.morphTargets[g].vertices;p=b.morphTargets[g].vertices;
-j=0;for(k=p.length;j<k;j+=3)m.push(new THREE.Vertex(new THREE.Vector3(p[j],p[j+1],p[j+2])))}}if(b.morphColors!==undefined){var o,u;g=0;for(h=b.morphColors.length;g<h;g++){f.morphColors[g]={};f.morphColors[g].name=b.morphColors[g].name;f.morphColors[g].colors=[];p=f.morphColors[g].colors;o=b.morphColors[g].colors;k=0;for(m=o.length;k<m;k+=3){u=new THREE.Color(16755200);u.setRGB(o[j],o[j+1],o[j+2]);p.push(u)}}}})();(function(){if(b.edges!==undefined){var g,h,j;for(g=0;g<b.edges.length;g+=2){h=b.edges[g];
+THREE.JSONLoader.prototype.createModel=function(b,d,c){var f=new THREE.Geometry;this.init_materials(f,b.materials,c);(function(){if(b.version===undefined||b.version!=2)console.error("Deprecated file format.");else{var g,h,j,k,m,o,p,t,z,u,A,E,H,J,W,B=b.faces;u=b.vertices;var U=b.normals,N=b.colors;o=b.scale!==undefined?b.scale:1;var O=0;for(g=0;g<b.uvs.length;g++)b.uvs[g].length&&O++;for(g=0;g<O;g++){f.faceUvs[g]=[];f.faceVertexUvs[g]=[]}k=0;for(m=u.length;k<m;){p=new THREE.Vertex;p.position.x=u[k++]/
+o;p.position.y=u[k++]/o;p.position.z=u[k++]/o;f.vertices.push(p)}k=0;for(m=B.length;k<m;){u=B[k++];o=u&1;j=u&2;g=u&4;h=u&8;t=u&16;p=u&32;A=u&64;u&=128;if(o){E=new THREE.Face4;E.a=B[k++];E.b=B[k++];E.c=B[k++];E.d=B[k++];o=4}else{E=new THREE.Face3;E.a=B[k++];E.b=B[k++];E.c=B[k++];o=3}if(j){j=B[k++];E.materials=f.materials[j]}j=f.faces.length;if(g)for(g=0;g<O;g++){H=b.uvs[g];z=B[k++];W=H[z*2];z=H[z*2+1];f.faceUvs[g][j]=new THREE.UV(W,z)}if(h)for(g=0;g<O;g++){H=b.uvs[g];J=[];for(h=0;h<o;h++){z=B[k++];
+W=H[z*2];z=H[z*2+1];J[h]=new THREE.UV(W,z)}f.faceVertexUvs[g][j]=J}if(t){t=B[k++]*3;h=new THREE.Vector3;h.x=U[t++];h.y=U[t++];h.z=U[t];E.normal=h}if(p)for(g=0;g<o;g++){t=B[k++]*3;h=new THREE.Vector3;h.x=U[t++];h.y=U[t++];h.z=U[t];E.vertexNormals.push(h)}if(A){p=B[k++];p=new THREE.Color(N[p]);E.color=p}if(u)for(g=0;g<o;g++){p=B[k++];p=new THREE.Color(N[p]);E.vertexColors.push(p)}f.faces.push(E)}}})();(function(){var g,h,j,k;if(b.skinWeights){g=0;for(h=b.skinWeights.length;g<h;g+=2){j=b.skinWeights[g];
+k=b.skinWeights[g+1];f.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(b.skinIndices){g=0;for(h=b.skinIndices.length;g<h;g+=2){j=b.skinIndices[g];k=b.skinIndices[g+1];f.skinIndices.push(new THREE.Vector4(j,k,0,0))}}f.bones=b.bones;f.animation=b.animation})();(function(){if(b.morphTargets!==undefined){var g,h,j,k,m,o;g=0;for(h=b.morphTargets.length;g<h;g++){f.morphTargets[g]={};f.morphTargets[g].name=b.morphTargets[g].name;f.morphTargets[g].vertices=[];m=f.morphTargets[g].vertices;o=b.morphTargets[g].vertices;
+j=0;for(k=o.length;j<k;j+=3)m.push(new THREE.Vertex(new THREE.Vector3(o[j],o[j+1],o[j+2])))}}if(b.morphColors!==undefined){var p,t;g=0;for(h=b.morphColors.length;g<h;g++){f.morphColors[g]={};f.morphColors[g].name=b.morphColors[g].name;f.morphColors[g].colors=[];o=f.morphColors[g].colors;p=b.morphColors[g].colors;k=0;for(m=p.length;k<m;k+=3){t=new THREE.Color(16755200);t.setRGB(p[j],p[j+1],p[j+2]);o.push(t)}}}})();(function(){if(b.edges!==undefined){var g,h,j;for(g=0;g<b.edges.length;g+=2){h=b.edges[g];
 j=b.edges[g+1];f.edges.push(new THREE.Edge(f.vertices[h],f.vertices[j],h,j))}}})();f.computeCentroids();f.computeFaceNormals();f.computeEdgeFaces();d(f)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(b){var d=b.model,c=b.callback,f=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(d),g=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(d);b=(new Date).getTime();d=new Worker(d);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;d.onmessage=function(j){THREE.BinaryLoader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,c,g,f,h)};d.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};
 d.postMessage(b)},loadAjaxBuffers:function(b,d,c,f,g,h){var j=new XMLHttpRequest,k=f+"/"+b,m=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,c,g,d):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(h){m==0&&(m=j.getResponseHeader("Content-Length"));h({total:m,loaded:j.responseText.length})}}else j.readyState==2&&(m=j.getResponseHeader("Content-Length"))};j.open("GET",k,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
-j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,d,c,f){var g=function(h){function j(T,P){var N=o(T,P),Ca=o(T,P+1),Ka=o(T,P+2),n=o(T,P+3),C=(n<<1&255|Ka>>7)-127;N|=(Ka&127)<<16|Ca<<8;if(N==0&&C==-127)return 0;return(1-2*(n>>7))*(1+N*Math.pow(2,-23))*Math.pow(2,C)}function k(T,P){var N=o(T,P),Ca=o(T,P+1),Ka=o(T,P+2);return(o(T,P+3)<<24)+(Ka<<16)+(Ca<<8)+N}function m(T,P){var N=o(T,P);return(o(T,P+1)<<8)+N}function p(T,P){var N=o(T,P);return N>127?N-256:N}function o(T,
-P){return T.charCodeAt(P)&255}function u(T){var P,N,Ca;P=k(b,T);N=k(b,T+R);Ca=k(b,T+Da);T=m(b,T+ma);THREE.BinaryLoader.prototype.f3(G,P,N,Ca,T)}function y(T){var P,N,Ca,Ka,n,C;P=k(b,T);N=k(b,T+R);Ca=k(b,T+Da);Ka=m(b,T+ma);n=k(b,T+va);C=k(b,T+ca);T=k(b,T+e);THREE.BinaryLoader.prototype.f3n(G,M,P,N,Ca,Ka,n,C,T)}function t(T){var P,N,Ca,Ka;P=k(b,T);N=k(b,T+ea);Ca=k(b,T+ya);Ka=k(b,T+Ba);T=m(b,T+Fa);THREE.BinaryLoader.prototype.f4(G,P,N,Ca,Ka,T)}function B(T){var P,N,Ca,Ka,n,C,w,x;P=k(b,T);N=k(b,T+ea);
-Ca=k(b,T+ya);Ka=k(b,T+Ba);n=m(b,T+Fa);C=k(b,T+Z);w=k(b,T+oa);x=k(b,T+pa);T=k(b,T+sa);THREE.BinaryLoader.prototype.f4n(G,M,P,N,Ca,Ka,n,C,w,x,T)}function F(T){var P,N;P=k(b,T);N=k(b,T+ga);T=k(b,T+aa);THREE.BinaryLoader.prototype.uv3(G.faceVertexUvs[0],Q[P*2],Q[P*2+1],Q[N*2],Q[N*2+1],Q[T*2],Q[T*2+1])}function H(T){var P,N,Ca;P=k(b,T);N=k(b,T+na);Ca=k(b,T+Ea);T=k(b,T+ja);THREE.BinaryLoader.prototype.uv4(G.faceVertexUvs[0],Q[P*2],Q[P*2+1],Q[N*2],Q[N*2+1],Q[Ca*2],Q[Ca*2+1],Q[T*2],Q[T*2+1])}var G=this,X=
-0,A,M=[],Q=[],R,Da,ma,va,ca,e,ea,ya,Ba,Fa,Z,oa,pa,sa,ga,aa,na,Ea,ja,la,ua,Ra,Ya,Za,Na;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(G,f,h);A={signature:b.substr(X,8),header_bytes:o(b,X+8),vertex_coordinate_bytes:o(b,X+9),normal_coordinate_bytes:o(b,X+10),uv_coordinate_bytes:o(b,X+11),vertex_index_bytes:o(b,X+12),normal_index_bytes:o(b,X+13),uv_index_bytes:o(b,X+14),material_index_bytes:o(b,X+15),nvertices:k(b,X+16),nnormals:k(b,X+16+4),nuvs:k(b,X+16+8),ntri_flat:k(b,X+16+12),ntri_smooth:k(b,
-X+16+16),ntri_flat_uv:k(b,X+16+20),ntri_smooth_uv:k(b,X+16+24),nquad_flat:k(b,X+16+28),nquad_smooth:k(b,X+16+32),nquad_flat_uv:k(b,X+16+36),nquad_smooth_uv:k(b,X+16+40)};X+=A.header_bytes;R=A.vertex_index_bytes;Da=A.vertex_index_bytes*2;ma=A.vertex_index_bytes*3;va=A.vertex_index_bytes*3+A.material_index_bytes;ca=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;e=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;ea=A.vertex_index_bytes;ya=A.vertex_index_bytes*
-2;Ba=A.vertex_index_bytes*3;Fa=A.vertex_index_bytes*4;Z=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;pa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;sa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;ga=A.uv_index_bytes;aa=A.uv_index_bytes*2;na=A.uv_index_bytes;Ea=A.uv_index_bytes*2;ja=A.uv_index_bytes*3;h=A.vertex_index_bytes*3+A.material_index_bytes;Na=A.vertex_index_bytes*4+A.material_index_bytes;
-la=A.ntri_flat*h;ua=A.ntri_smooth*(h+A.normal_index_bytes*3);Ra=A.ntri_flat_uv*(h+A.uv_index_bytes*3);Ya=A.ntri_smooth_uv*(h+A.normal_index_bytes*3+A.uv_index_bytes*3);Za=A.nquad_flat*Na;h=A.nquad_smooth*(Na+A.normal_index_bytes*4);Na=A.nquad_flat_uv*(Na+A.uv_index_bytes*4);X+=function(T){for(var P,N,Ca,Ka=A.vertex_coordinate_bytes*3,n=T+A.nvertices*Ka;T<n;T+=Ka){P=j(b,T);N=j(b,T+A.vertex_coordinate_bytes);Ca=j(b,T+A.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(G,P,N,Ca)}return A.nvertices*
-Ka}(X);X+=function(T){for(var P,N,Ca,Ka=A.normal_coordinate_bytes*3,n=T+A.nnormals*Ka;T<n;T+=Ka){P=p(b,T);N=p(b,T+A.normal_coordinate_bytes);Ca=p(b,T+A.normal_coordinate_bytes*2);M.push(P/127,N/127,Ca/127)}return A.nnormals*Ka}(X);X+=function(T){for(var P,N,Ca=A.uv_coordinate_bytes*2,Ka=T+A.nuvs*Ca;T<Ka;T+=Ca){P=j(b,T);N=j(b,T+A.uv_coordinate_bytes);Q.push(P,N)}return A.nuvs*Ca}(X);la=X+la;ua=la+ua;Ra=ua+Ra;Ya=Ra+Ya;Za=Ya+Za;h=Za+h;Na=h+Na;(function(T){var P,N=A.vertex_index_bytes*3+A.material_index_bytes,
-Ca=N+A.uv_index_bytes*3,Ka=T+A.ntri_flat_uv*Ca;for(P=T;P<Ka;P+=Ca){u(P);F(P+N)}return Ka-T})(ua);(function(T){var P,N=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,Ca=N+A.uv_index_bytes*3,Ka=T+A.ntri_smooth_uv*Ca;for(P=T;P<Ka;P+=Ca){y(P);F(P+N)}return Ka-T})(Ra);(function(T){var P,N=A.vertex_index_bytes*4+A.material_index_bytes,Ca=N+A.uv_index_bytes*4,Ka=T+A.nquad_flat_uv*Ca;for(P=T;P<Ka;P+=Ca){t(P);H(P+N)}return Ka-T})(h);(function(T){var P,N=A.vertex_index_bytes*4+A.material_index_bytes+
-A.normal_index_bytes*4,Ca=N+A.uv_index_bytes*4,Ka=T+A.nquad_smooth_uv*Ca;for(P=T;P<Ka;P+=Ca){B(P);H(P+N)}return Ka-T})(Na);(function(T){var P,N=A.vertex_index_bytes*3+A.material_index_bytes,Ca=T+A.ntri_flat*N;for(P=T;P<Ca;P+=N)u(P);return Ca-T})(X);(function(T){var P,N=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,Ca=T+A.ntri_smooth*N;for(P=T;P<Ca;P+=N)y(P);return Ca-T})(la);(function(T){var P,N=A.vertex_index_bytes*4+A.material_index_bytes,Ca=T+A.nquad_flat*N;for(P=T;P<Ca;P+=
-N)t(P);return Ca-T})(Ya);(function(T){var P,N=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*4,Ca=T+A.nquad_smooth*N;for(P=T;P<Ca;P+=N)B(P);return Ca-T})(Za);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(c))},v:function(b,d,c,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(d,c,f)))},f3:function(b,d,c,f,g){b.faces.push(new THREE.Face3(d,c,f,null,null,b.materials[g]))},f4:function(b,d,c,f,g,h){b.faces.push(new THREE.Face4(d,
-c,f,g,null,null,b.materials[h]))},f3n:function(b,d,c,f,g,h,j,k,m){h=b.materials[h];var p=d[k*3],o=d[k*3+1];k=d[k*3+2];var u=d[m*3],y=d[m*3+1];m=d[m*3+2];b.faces.push(new THREE.Face3(c,f,g,[new THREE.Vector3(d[j*3],d[j*3+1],d[j*3+2]),new THREE.Vector3(p,o,k),new THREE.Vector3(u,y,m)],null,h))},f4n:function(b,d,c,f,g,h,j,k,m,p,o){j=b.materials[j];var u=d[m*3],y=d[m*3+1];m=d[m*3+2];var t=d[p*3],B=d[p*3+1];p=d[p*3+2];var F=d[o*3],H=d[o*3+1];o=d[o*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*
-3],d[k*3+1],d[k*3+2]),new THREE.Vector3(u,y,m),new THREE.Vector3(t,B,p),new THREE.Vector3(F,H,o)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,m){var p=[];p.push(new THREE.UV(d,c));p.push(new THREE.UV(f,g));p.push(new THREE.UV(h,j));p.push(new THREE.UV(k,m));b.push(p)}};THREE.SceneLoader=function(){};
-THREE.SceneLoader.prototype={load:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(ga,aa){return aa=="relativeToHTML"?ga:h+"/"+ga}function m(){for(t in ca.objects)if(!Z.objects[t]){X=ca.objects[t];if(R=Z.geometries[X.geometry]){va=[];for(sa=0;sa<X.materials.length;sa++)va[sa]=Z.materials[X.materials[sa]];A=X.position;r=X.rotation;q=X.quaternion;s=X.scale;q=0;va.length==0&&(va[0]=new THREE.MeshFaceMaterial);object=
-new THREE.Mesh(R,va);object.position.set(A[0],A[1],A[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=X.visible;Z.scene.addObject(object);Z.objects[t]=object;if(X.meshCollider){var ga=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(ga)}}}}function p(ga){return function(aa){Z.geometries[ga]=aa;m();ea-=1;o()}}function o(){f({total_models:Ba,total_textures:Fa,
-loaded_models:Ba-ea,loaded_textures:Fa-ya},Z);ea==0&&ya==0&&c(Z)}var u,y,t,B,F,H,G,X,A,M,Q,R,Da,ma,va,ca,e,ea,ya,Ba,Fa,Z;ca=j.data;j=new THREE.BinaryLoader;e=new THREE.JSONLoader;ya=ea=0;Z={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(ca.transform){var oa=ca.transform.position;M=ca.transform.rotation;var pa=ca.transform.scale;oa&&Z.scene.position.set(oa[0],oa[1],oa[2]);M&&Z.scene.rotation.set(M[0],M[1],M[2]);pa&&Z.scene.scale.set(pa[0],pa[1],
-pa[2]);(oa||M||pa)&&Z.scene.updateMatrix()}oa=function(){ya-=1;o()};for(F in ca.cameras){M=ca.cameras[F];if(M.type=="perspective")Da=new THREE.Camera(M.fov,M.aspect,M.near,M.far);else if(M.type=="ortho"){Da=new THREE.Camera;Da.projectionMatrix=THREE.Matrix4.makeOrtho(M.left,M.right,M.top,M.bottom,M.near,M.far)}A=M.position;M=M.target;Da.position.set(A[0],A[1],A[2]);Da.target.position.set(M[0],M[1],M[2]);Z.cameras[F]=Da}for(B in ca.lights){F=ca.lights[B];Da=F.color!==undefined?F.color:16777215;M=F.intensity!==
-undefined?F.intensity:1;if(F.type=="directional"){A=F.direction;light=new THREE.DirectionalLight(Da,M);light.position.set(A[0],A[1],A[2]);light.position.normalize()}else if(F.type=="point"){A=F.position;light=new THREE.PointLight(Da,M);light.position.set(A[0],A[1],A[2])}Z.scene.addLight(light);Z.lights[B]=light}for(H in ca.fogs){B=ca.fogs[H];if(B.type=="linear")ma=new THREE.Fog(0,B.near,B.far);else B.type=="exp2"&&(ma=new THREE.FogExp2(0,B.density));M=B.color;ma.color.setRGB(M[0],M[1],M[2]);Z.fogs[H]=
-ma}if(Z.cameras&&ca.defaults.camera)Z.currentCamera=Z.cameras[ca.defaults.camera];if(Z.fogs&&ca.defaults.fog)Z.scene.fog=Z.fogs[ca.defaults.fog];M=ca.defaults.bgcolor;Z.bgColor=new THREE.Color;Z.bgColor.setRGB(M[0],M[1],M[2]);Z.bgColorAlpha=ca.defaults.bgalpha;for(u in ca.geometries){H=ca.geometries[u];if(H.type=="bin_mesh"||H.type=="ascii_mesh")ea+=1}Ba=ea;for(u in ca.geometries){H=ca.geometries[u];if(H.type=="cube"){R=new THREE.Cube(H.width,H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,
-null,H.flipped,H.sides);Z.geometries[u]=R}else if(H.type=="plane"){R=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight);Z.geometries[u]=R}else if(H.type=="sphere"){R=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight);Z.geometries[u]=R}else if(H.type=="cylinder"){R=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset);Z.geometries[u]=R}else if(H.type=="torus"){R=new THREE.Torus(H.radius,H.tube,H.segmentsR,H.segmentsT);Z.geometries[u]=R}else if(H.type==
-"icosahedron"){R=new THREE.Icosahedron(H.subdivisions);Z.geometries[u]=R}else if(H.type=="bin_mesh")j.load({model:k(H.url,ca.urlBaseType),callback:p(u)});else H.type=="ascii_mesh"&&e.load({model:k(H.url,ca.urlBaseType),callback:p(u)})}for(G in ca.textures){u=ca.textures[G];ya+=u.url instanceof Array?u.url.length:1}Fa=ya;for(G in ca.textures){u=ca.textures[G];if(u.mapping!=undefined&&THREE[u.mapping]!=undefined)u.mapping=new THREE[u.mapping];if(u.url instanceof Array){H=[];for(var sa=0;sa<u.url.length;sa++)H[sa]=
-k(u.url[sa],ca.urlBaseType);H=THREE.ImageUtils.loadTextureCube(H,u.mapping,oa)}else{H=THREE.ImageUtils.loadTexture(k(u.url,ca.urlBaseType),u.mapping,oa);if(THREE[u.minFilter]!=undefined)H.minFilter=THREE[u.minFilter];if(THREE[u.magFilter]!=undefined)H.magFilter=THREE[u.magFilter]}Z.textures[G]=H}for(y in ca.materials){G=ca.materials[y];for(Q in G.parameters)if(Q=="envMap"||Q=="map"||Q=="lightMap")G.parameters[Q]=Z.textures[G.parameters[Q]];else if(Q=="shading")G.parameters[Q]=G.parameters[Q]=="flat"?
-THREE.FlatShading:THREE.SmoothShading;else if(Q=="blending")G.parameters[Q]=THREE[G.parameters[Q]]?THREE[G.parameters[Q]]:THREE.NormalBlending;else Q=="combine"&&(G.parameters[Q]=G.parameters[Q]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);G=new THREE[G.type](G.parameters);Z.materials[y]=G}m();d(Z)}}};
+j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,d,c,f){var g=function(h){function j(R,S){var P=p(R,S),Ba=p(R,S+1),La=p(R,S+2),n=p(R,S+3),C=(n<<1&255|La>>7)-127;P|=(La&127)<<16|Ba<<8;if(P==0&&C==-127)return 0;return(1-2*(n>>7))*(1+P*Math.pow(2,-23))*Math.pow(2,C)}function k(R,S){var P=p(R,S),Ba=p(R,S+1),La=p(R,S+2);return(p(R,S+3)<<24)+(La<<16)+(Ba<<8)+P}function m(R,S){var P=p(R,S);return(p(R,S+1)<<8)+P}function o(R,S){var P=p(R,S);return P>127?P-256:P}function p(R,
+S){return R.charCodeAt(S)&255}function t(R){var S,P,Ba;S=k(b,R);P=k(b,R+O);Ba=k(b,R+ua);R=m(b,R+la);THREE.BinaryLoader.prototype.f3(J,S,P,Ba,R)}function z(R){var S,P,Ba,La,n,C;S=k(b,R);P=k(b,R+O);Ba=k(b,R+ua);La=m(b,R+la);n=k(b,R+pa);C=k(b,R+ga);R=k(b,R+ha);THREE.BinaryLoader.prototype.f3n(J,U,S,P,Ba,La,n,C,R)}function u(R){var S,P,Ba,La;S=k(b,R);P=k(b,R+e);Ba=k(b,R+oa);La=k(b,R+Da);R=m(b,R+Aa);THREE.BinaryLoader.prototype.f4(J,S,P,Ba,La,R)}function A(R){var S,P,Ba,La,n,C,w,x;S=k(b,R);P=k(b,R+e);
+Ba=k(b,R+oa);La=k(b,R+Da);n=m(b,R+Aa);C=k(b,R+ka);w=k(b,R+fa);x=k(b,R+va);R=k(b,R+sa);THREE.BinaryLoader.prototype.f4n(J,U,S,P,Ba,La,n,C,w,x,R)}function E(R){var S,P;S=k(b,R);P=k(b,R+wa);R=k(b,R+ca);THREE.BinaryLoader.prototype.uv3(J.faceVertexUvs[0],N[S*2],N[S*2+1],N[P*2],N[P*2+1],N[R*2],N[R*2+1])}function H(R){var S,P,Ba;S=k(b,R);P=k(b,R+ja);Ba=k(b,R+ma);R=k(b,R+Fa);THREE.BinaryLoader.prototype.uv4(J.faceVertexUvs[0],N[S*2],N[S*2+1],N[P*2],N[P*2+1],N[Ba*2],N[Ba*2+1],N[R*2],N[R*2+1])}var J=this,
+W=0,B,U=[],N=[],O,ua,la,pa,ga,ha,e,oa,Da,Aa,ka,fa,va,sa,wa,ca,ja,ma,Fa,ia,da,Ja,Xa,Za,Ta;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(J,f,h);B={signature:b.substr(W,8),header_bytes:p(b,W+8),vertex_coordinate_bytes:p(b,W+9),normal_coordinate_bytes:p(b,W+10),uv_coordinate_bytes:p(b,W+11),vertex_index_bytes:p(b,W+12),normal_index_bytes:p(b,W+13),uv_index_bytes:p(b,W+14),material_index_bytes:p(b,W+15),nvertices:k(b,W+16),nnormals:k(b,W+16+4),nuvs:k(b,W+16+8),ntri_flat:k(b,W+16+12),
+ntri_smooth:k(b,W+16+16),ntri_flat_uv:k(b,W+16+20),ntri_smooth_uv:k(b,W+16+24),nquad_flat:k(b,W+16+28),nquad_smooth:k(b,W+16+32),nquad_flat_uv:k(b,W+16+36),nquad_smooth_uv:k(b,W+16+40)};W+=B.header_bytes;O=B.vertex_index_bytes;ua=B.vertex_index_bytes*2;la=B.vertex_index_bytes*3;pa=B.vertex_index_bytes*3+B.material_index_bytes;ga=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes;ha=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*2;e=B.vertex_index_bytes;oa=B.vertex_index_bytes*
+2;Da=B.vertex_index_bytes*3;Aa=B.vertex_index_bytes*4;ka=B.vertex_index_bytes*4+B.material_index_bytes;fa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes;va=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*2;sa=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*3;wa=B.uv_index_bytes;ca=B.uv_index_bytes*2;ja=B.uv_index_bytes;ma=B.uv_index_bytes*2;Fa=B.uv_index_bytes*3;h=B.vertex_index_bytes*3+B.material_index_bytes;Ta=B.vertex_index_bytes*4+B.material_index_bytes;
+ia=B.ntri_flat*h;da=B.ntri_smooth*(h+B.normal_index_bytes*3);Ja=B.ntri_flat_uv*(h+B.uv_index_bytes*3);Xa=B.ntri_smooth_uv*(h+B.normal_index_bytes*3+B.uv_index_bytes*3);Za=B.nquad_flat*Ta;h=B.nquad_smooth*(Ta+B.normal_index_bytes*4);Ta=B.nquad_flat_uv*(Ta+B.uv_index_bytes*4);W+=function(R){for(var S,P,Ba,La=B.vertex_coordinate_bytes*3,n=R+B.nvertices*La;R<n;R+=La){S=j(b,R);P=j(b,R+B.vertex_coordinate_bytes);Ba=j(b,R+B.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(J,S,P,Ba)}return B.nvertices*
+La}(W);W+=function(R){for(var S,P,Ba,La=B.normal_coordinate_bytes*3,n=R+B.nnormals*La;R<n;R+=La){S=o(b,R);P=o(b,R+B.normal_coordinate_bytes);Ba=o(b,R+B.normal_coordinate_bytes*2);U.push(S/127,P/127,Ba/127)}return B.nnormals*La}(W);W+=function(R){for(var S,P,Ba=B.uv_coordinate_bytes*2,La=R+B.nuvs*Ba;R<La;R+=Ba){S=j(b,R);P=j(b,R+B.uv_coordinate_bytes);N.push(S,P)}return B.nuvs*Ba}(W);ia=W+ia;da=ia+da;Ja=da+Ja;Xa=Ja+Xa;Za=Xa+Za;h=Za+h;Ta=h+Ta;(function(R){var S,P=B.vertex_index_bytes*3+B.material_index_bytes,
+Ba=P+B.uv_index_bytes*3,La=R+B.ntri_flat_uv*Ba;for(S=R;S<La;S+=Ba){t(S);E(S+P)}return La-R})(da);(function(R){var S,P=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,Ba=P+B.uv_index_bytes*3,La=R+B.ntri_smooth_uv*Ba;for(S=R;S<La;S+=Ba){z(S);E(S+P)}return La-R})(Ja);(function(R){var S,P=B.vertex_index_bytes*4+B.material_index_bytes,Ba=P+B.uv_index_bytes*4,La=R+B.nquad_flat_uv*Ba;for(S=R;S<La;S+=Ba){u(S);H(S+P)}return La-R})(h);(function(R){var S,P=B.vertex_index_bytes*4+B.material_index_bytes+
+B.normal_index_bytes*4,Ba=P+B.uv_index_bytes*4,La=R+B.nquad_smooth_uv*Ba;for(S=R;S<La;S+=Ba){A(S);H(S+P)}return La-R})(Ta);(function(R){var S,P=B.vertex_index_bytes*3+B.material_index_bytes,Ba=R+B.ntri_flat*P;for(S=R;S<Ba;S+=P)t(S);return Ba-R})(W);(function(R){var S,P=B.vertex_index_bytes*3+B.material_index_bytes+B.normal_index_bytes*3,Ba=R+B.ntri_smooth*P;for(S=R;S<Ba;S+=P)z(S);return Ba-R})(ia);(function(R){var S,P=B.vertex_index_bytes*4+B.material_index_bytes,Ba=R+B.nquad_flat*P;for(S=R;S<Ba;S+=
+P)u(S);return Ba-R})(Xa);(function(R){var S,P=B.vertex_index_bytes*4+B.material_index_bytes+B.normal_index_bytes*4,Ba=R+B.nquad_smooth*P;for(S=R;S<Ba;S+=P)A(S);return Ba-R})(Za);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(c))},v:function(b,d,c,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(d,c,f)))},f3:function(b,d,c,f,g){b.faces.push(new THREE.Face3(d,c,f,null,null,b.materials[g]))},f4:function(b,d,c,f,g,h){b.faces.push(new THREE.Face4(d,
+c,f,g,null,null,b.materials[h]))},f3n:function(b,d,c,f,g,h,j,k,m){h=b.materials[h];var o=d[k*3],p=d[k*3+1];k=d[k*3+2];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];b.faces.push(new THREE.Face3(c,f,g,[new THREE.Vector3(d[j*3],d[j*3+1],d[j*3+2]),new THREE.Vector3(o,p,k),new THREE.Vector3(t,z,m)],null,h))},f4n:function(b,d,c,f,g,h,j,k,m,o,p){j=b.materials[j];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];var u=d[o*3],A=d[o*3+1];o=d[o*3+2];var E=d[p*3],H=d[p*3+1];p=d[p*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*
+3],d[k*3+1],d[k*3+2]),new THREE.Vector3(t,z,m),new THREE.Vector3(u,A,o),new THREE.Vector3(E,H,p)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,m){var o=[];o.push(new THREE.UV(d,c));o.push(new THREE.UV(f,g));o.push(new THREE.UV(h,j));o.push(new THREE.UV(k,m));b.push(o)}};THREE.SceneLoader=function(){};
+THREE.SceneLoader.prototype={load:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(wa,ca){return ca=="relativeToHTML"?wa:h+"/"+wa}function m(){for(u in ga.objects)if(!ka.objects[u]){W=ga.objects[u];if(O=ka.geometries[W.geometry]){pa=[];for(sa=0;sa<W.materials.length;sa++)pa[sa]=ka.materials[W.materials[sa]];B=W.position;r=W.rotation;q=W.quaternion;s=W.scale;q=0;pa.length==0&&(pa[0]=new THREE.MeshFaceMaterial);
+pa.length>1&&(pa=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,pa);object.position.set(B[0],B[1],B[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=W.visible;ka.scene.addObject(object);ka.objects[u]=object;if(W.meshCollider){var wa=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(wa)}}}}function o(wa){return function(ca){ka.geometries[wa]=ca;m();
+e-=1;p()}}function p(){f({total_models:Da,total_textures:Aa,loaded_models:Da-e,loaded_textures:Aa-oa},ka);e==0&&oa==0&&c(ka)}var t,z,u,A,E,H,J,W,B,U,N,O,ua,la,pa,ga,ha,e,oa,Da,Aa,ka;ga=j.data;j=new THREE.BinaryLoader;ha=new THREE.JSONLoader;oa=e=0;ka={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(ga.transform){var fa=ga.transform.position;U=ga.transform.rotation;var va=ga.transform.scale;fa&&ka.scene.position.set(fa[0],fa[1],fa[2]);U&&ka.scene.rotation.set(U[0],
+U[1],U[2]);va&&ka.scene.scale.set(va[0],va[1],va[2]);(fa||U||va)&&ka.scene.updateMatrix()}fa=function(){oa-=1;p()};for(E in ga.cameras){U=ga.cameras[E];if(U.type=="perspective")ua=new THREE.Camera(U.fov,U.aspect,U.near,U.far);else if(U.type=="ortho"){ua=new THREE.Camera;ua.projectionMatrix=THREE.Matrix4.makeOrtho(U.left,U.right,U.top,U.bottom,U.near,U.far)}B=U.position;U=U.target;ua.position.set(B[0],B[1],B[2]);ua.target.position.set(U[0],U[1],U[2]);ka.cameras[E]=ua}for(A in ga.lights){E=ga.lights[A];
+ua=E.color!==undefined?E.color:16777215;U=E.intensity!==undefined?E.intensity:1;if(E.type=="directional"){B=E.direction;light=new THREE.DirectionalLight(ua,U);light.position.set(B[0],B[1],B[2]);light.position.normalize()}else if(E.type=="point"){B=E.position;light=new THREE.PointLight(ua,U);light.position.set(B[0],B[1],B[2])}ka.scene.addLight(light);ka.lights[A]=light}for(H in ga.fogs){A=ga.fogs[H];if(A.type=="linear")la=new THREE.Fog(0,A.near,A.far);else A.type=="exp2"&&(la=new THREE.FogExp2(0,A.density));
+U=A.color;la.color.setRGB(U[0],U[1],U[2]);ka.fogs[H]=la}if(ka.cameras&&ga.defaults.camera)ka.currentCamera=ka.cameras[ga.defaults.camera];if(ka.fogs&&ga.defaults.fog)ka.scene.fog=ka.fogs[ga.defaults.fog];U=ga.defaults.bgcolor;ka.bgColor=new THREE.Color;ka.bgColor.setRGB(U[0],U[1],U[2]);ka.bgColorAlpha=ga.defaults.bgalpha;for(t in ga.geometries){H=ga.geometries[t];if(H.type=="bin_mesh"||H.type=="ascii_mesh")e+=1}Da=e;for(t in ga.geometries){H=ga.geometries[t];if(H.type=="cube"){O=new THREE.Cube(H.width,
+H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,null,H.flipped,H.sides);ka.geometries[t]=O}else if(H.type=="plane"){O=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight);ka.geometries[t]=O}else if(H.type=="sphere"){O=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight);ka.geometries[t]=O}else if(H.type=="cylinder"){O=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset);ka.geometries[t]=O}else if(H.type=="torus"){O=new THREE.Torus(H.radius,
+H.tube,H.segmentsR,H.segmentsT);ka.geometries[t]=O}else if(H.type=="icosahedron"){O=new THREE.Icosahedron(H.subdivisions);ka.geometries[t]=O}else if(H.type=="bin_mesh")j.load({model:k(H.url,ga.urlBaseType),callback:o(t)});else H.type=="ascii_mesh"&&ha.load({model:k(H.url,ga.urlBaseType),callback:o(t)})}for(J in ga.textures){t=ga.textures[J];oa+=t.url instanceof Array?t.url.length:1}Aa=oa;for(J in ga.textures){t=ga.textures[J];if(t.mapping!=undefined&&THREE[t.mapping]!=undefined)t.mapping=new THREE[t.mapping];
+if(t.url instanceof Array){H=[];for(var sa=0;sa<t.url.length;sa++)H[sa]=k(t.url[sa],ga.urlBaseType);H=THREE.ImageUtils.loadTextureCube(H,t.mapping,fa)}else{H=THREE.ImageUtils.loadTexture(k(t.url,ga.urlBaseType),t.mapping,fa);if(THREE[t.minFilter]!=undefined)H.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=undefined)H.magFilter=THREE[t.magFilter]}ka.textures[J]=H}for(z in ga.materials){J=ga.materials[z];for(N in J.parameters)if(N=="envMap"||N=="map"||N=="lightMap")J.parameters[N]=ka.textures[J.parameters[N]];
+else if(N=="shading")J.parameters[N]=J.parameters[N]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(N=="blending")J.parameters[N]=THREE[J.parameters[N]]?THREE[J.parameters[N]]:THREE.NormalBlending;else if(N=="combine")J.parameters[N]=J.parameters[N]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(N=="vertexColors")if(J.parameters[N]=="face")J.parameters[N]=THREE.FaceColors;else if(J.parameters[N])J.parameters[N]=THREE.VertexColors;J=new THREE[J.type](J.parameters);ka.materials[z]=
+J}m();d(ka)}}};
 THREE.MarchingCubes=function(b,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
-0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,f,g){return c+(f-c)*g};this.VIntX=function(c,f,g,h,j,k,m,p,o,u){j=(j-o)/(u-o);o=this.normal_cache;f[h]=k+j*this.delta;f[h+1]=m;f[h+2]=p;g[h]=this.lerp(o[c],o[c+3],j);g[h+1]=this.lerp(o[c+1],o[c+4],j);g[h+2]=this.lerp(o[c+2],o[c+5],j)};this.VIntY=function(c,f,g,h,j,k,m,p,o,u){j=(j-o)/(u-o);o=this.normal_cache;f[h]=k;f[h+1]=m+j*this.delta;f[h+
-2]=p;f=c+this.yd*3;g[h]=this.lerp(o[c],o[f],j);g[h+1]=this.lerp(o[c+1],o[f+1],j);g[h+2]=this.lerp(o[c+2],o[f+2],j)};this.VIntZ=function(c,f,g,h,j,k,m,p,o,u){j=(j-o)/(u-o);o=this.normal_cache;f[h]=k;f[h+1]=m;f[h+2]=p+j*this.delta;f=c+this.zd*3;g[h]=this.lerp(o[c],o[f],j);g[h+1]=this.lerp(o[c+1],o[f+1],j);g[h+2]=this.lerp(o[c+2],o[f+2],j)};this.compNorm=function(c){var f=c*3;if(this.normal_cache[f]==0){this.normal_cache[f]=this.field[c-1]-this.field[c+1];this.normal_cache[f+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[f+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,f,g,h,j,k){var m=h+1,p=h+this.yd,o=h+this.zd,u=m+this.yd,y=m+this.zd,t=h+this.yd+this.zd,B=m+this.yd+this.zd,F=0,H=this.field[h],G=this.field[m],X=this.field[p],A=this.field[u],M=this.field[o],Q=this.field[y],R=this.field[t],Da=this.field[B];H<j&&(F|=1);G<j&&(F|=2);X<j&&(F|=8);A<j&&(F|=4);M<j&&(F|=16);Q<j&&(F|=32);R<j&&(F|=128);Da<j&&(F|=64);var ma=THREE.edgeTable[F];if(ma==0)return 0;
-var va=this.delta,ca=c+va,e=f+va;va=g+va;if(ma&1){this.compNorm(h);this.compNorm(m);this.VIntX(h*3,this.vlist,this.nlist,0,j,c,f,g,H,G)}if(ma&2){this.compNorm(m);this.compNorm(u);this.VIntY(m*3,this.vlist,this.nlist,3,j,ca,f,g,G,A)}if(ma&4){this.compNorm(p);this.compNorm(u);this.VIntX(p*3,this.vlist,this.nlist,6,j,c,e,g,X,A)}if(ma&8){this.compNorm(h);this.compNorm(p);this.VIntY(h*3,this.vlist,this.nlist,9,j,c,f,g,H,X)}if(ma&16){this.compNorm(o);this.compNorm(y);this.VIntX(o*3,this.vlist,this.nlist,
-12,j,c,f,va,M,Q)}if(ma&32){this.compNorm(y);this.compNorm(B);this.VIntY(y*3,this.vlist,this.nlist,15,j,ca,f,va,Q,Da)}if(ma&64){this.compNorm(t);this.compNorm(B);this.VIntX(t*3,this.vlist,this.nlist,18,j,c,e,va,R,Da)}if(ma&128){this.compNorm(o);this.compNorm(t);this.VIntY(o*3,this.vlist,this.nlist,21,j,c,f,va,M,R)}if(ma&256){this.compNorm(h);this.compNorm(o);this.VIntZ(h*3,this.vlist,this.nlist,24,j,c,f,g,H,M)}if(ma&512){this.compNorm(m);this.compNorm(y);this.VIntZ(m*3,this.vlist,this.nlist,27,j,ca,
-f,g,G,Q)}if(ma&1024){this.compNorm(u);this.compNorm(B);this.VIntZ(u*3,this.vlist,this.nlist,30,j,ca,e,g,A,Da)}if(ma&2048){this.compNorm(p);this.compNorm(t);this.VIntZ(p*3,this.vlist,this.nlist,33,j,c,e,g,X,R)}F<<=4;for(j=h=0;THREE.triTable[F+j]!=-1;){c=F+j;f=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[f],3*THREE.triTable[g],k);j+=3;h++}return h};this.posnormtriv=function(c,f,g,h,j,k){var m=this.count*3;this.positionArray[m]=c[g];this.positionArray[m+1]=c[g+
-1];this.positionArray[m+2]=c[g+2];this.positionArray[m+3]=c[h];this.positionArray[m+4]=c[h+1];this.positionArray[m+5]=c[h+2];this.positionArray[m+6]=c[j];this.positionArray[m+7]=c[j+1];this.positionArray[m+8]=c[j+2];this.normalArray[m]=f[g];this.normalArray[m+1]=f[g+1];this.normalArray[m+2]=f[g+2];this.normalArray[m+3]=f[h];this.normalArray[m+4]=f[h+1];this.normalArray[m+5]=f[h+2];this.normalArray[m+6]=f[j];this.normalArray[m+7]=f[j+1];this.normalArray[m+8]=f[j+2];this.hasPos=!0;this.hasNormal=!0;
-this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;f<this.positionArray.length;f++)this.positionArray[f]=0;c(this)}};this.addBall=function(c,f,g,h,j){var k=this.size*Math.sqrt(h/j),m=g*this.size,p=f*this.size,o=c*this.size,u=Math.floor(m-k);u<1&&(u=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var y=Math.floor(p-k);y<1&&(y=1);p=Math.floor(p+k);p>this.size-1&&(p=
-this.size-1);var t=Math.floor(o-k);t<1&&(t=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var B,F,H,G,X,A;u<m;u++){o=this.size2*u;F=u/this.size-g;X=F*F;for(F=y;F<p;F++){H=o+this.size*F;B=F/this.size-f;A=B*B;for(B=t;B<k;B++){G=B/this.size-c;G=h/(1.0E-6+G*G+A+X)-j;G>0&&(this.field[H+B]+=G)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,p=this.size,o=this.yd,u=this.zd,y=this.field,t=p*Math.sqrt(c/f);t>p&&(t=p);for(g=0;g<t;g++){h=g/p;h*=h;k=c/(1.0E-4+h)-f;if(k>0)for(h=0;h<p;h++){m=g+h*o;for(j=
-0;j<p;j++)y[u*j+m]+=k}}};this.addPlaneY=function(c,f){var g,h,j,k,m,p,o=this.size,u=this.yd,y=this.zd,t=this.field,B=o*Math.sqrt(c/f);B>o&&(B=o);for(h=0;h<B;h++){g=h/o;g*=g;k=c/(1.0E-4+g)-f;if(k>0){m=h*u;for(g=0;g<o;g++){p=m+g;for(j=0;j<o;j++)t[y*j+p]+=k}}}};this.addPlaneZ=function(c,f){var g,h,j,k,m,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/f);dist>size&&(dist=size);for(j=0;j<dist;j++){g=j/size;g*=g;k=c/(1.0E-4+g)-f;if(k>0){m=zd*j;for(h=0;h<size;h++){p=m+h*yd;
-for(g=0;g<size;g++)field[p+g]+=k}}}};this.reset=function(){var c;for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var f,g,h,j,k,m,p,o,u,y=this.size-2;for(j=1;j<y;j++){u=this.size2*j;p=(j-this.halfsize)/this.halfsize;for(h=1;h<y;h++){o=u+this.size*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<y;g++){k=(g-this.halfsize)/this.halfsize;f=o+g;this.polygonize(k,m,p,f,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,f=new THREE.Geometry,
-g=[];this.render(function(h){var j,k,m,p,o,u,y,t;for(j=0;j<h.count;j++){y=j*3;o=y+1;t=y+2;k=h.positionArray[y];m=h.positionArray[o];p=h.positionArray[t];u=new THREE.Vector3(k,m,p);k=h.normalArray[y];m=h.normalArray[o];p=h.normalArray[t];y=new THREE.Vector3(k,m,p);y.normalize();o=new THREE.Vertex(u);f.vertices.push(o);g.push(y)}nfaces=h.count/3;for(j=0;j<nfaces;j++){y=(c+j)*3;o=y+1;t=y+2;u=g[y];k=g[o];m=g[t];y=new THREE.Face3(y,o,t,[u,k,m]);f.faces.push(y)}c+=nfaces;h.count=0});return f};this.init(b)};
+0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,f,g){return c+(f-c)*g};this.VIntX=function(c,f,g,h,j,k,m,o,p,t){j=(j-p)/(t-p);p=this.normal_cache;f[h]=k+j*this.delta;f[h+1]=m;f[h+2]=o;g[h]=this.lerp(p[c],p[c+3],j);g[h+1]=this.lerp(p[c+1],p[c+4],j);g[h+2]=this.lerp(p[c+2],p[c+5],j)};this.VIntY=function(c,f,g,h,j,k,m,o,p,t){j=(j-p)/(t-p);p=this.normal_cache;f[h]=k;f[h+1]=m+j*this.delta;f[h+
+2]=o;f=c+this.yd*3;g[h]=this.lerp(p[c],p[f],j);g[h+1]=this.lerp(p[c+1],p[f+1],j);g[h+2]=this.lerp(p[c+2],p[f+2],j)};this.VIntZ=function(c,f,g,h,j,k,m,o,p,t){j=(j-p)/(t-p);p=this.normal_cache;f[h]=k;f[h+1]=m;f[h+2]=o+j*this.delta;f=c+this.zd*3;g[h]=this.lerp(p[c],p[f],j);g[h+1]=this.lerp(p[c+1],p[f+1],j);g[h+2]=this.lerp(p[c+2],p[f+2],j)};this.compNorm=function(c){var f=c*3;if(this.normal_cache[f]==0){this.normal_cache[f]=this.field[c-1]-this.field[c+1];this.normal_cache[f+1]=this.field[c-this.yd]-
+this.field[c+this.yd];this.normal_cache[f+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,f,g,h,j,k){var m=h+1,o=h+this.yd,p=h+this.zd,t=m+this.yd,z=m+this.zd,u=h+this.yd+this.zd,A=m+this.yd+this.zd,E=0,H=this.field[h],J=this.field[m],W=this.field[o],B=this.field[t],U=this.field[p],N=this.field[z],O=this.field[u],ua=this.field[A];H<j&&(E|=1);J<j&&(E|=2);W<j&&(E|=8);B<j&&(E|=4);U<j&&(E|=16);N<j&&(E|=32);O<j&&(E|=128);ua<j&&(E|=64);var la=THREE.edgeTable[E];if(la==0)return 0;
+var pa=this.delta,ga=c+pa,ha=f+pa;pa=g+pa;if(la&1){this.compNorm(h);this.compNorm(m);this.VIntX(h*3,this.vlist,this.nlist,0,j,c,f,g,H,J)}if(la&2){this.compNorm(m);this.compNorm(t);this.VIntY(m*3,this.vlist,this.nlist,3,j,ga,f,g,J,B)}if(la&4){this.compNorm(o);this.compNorm(t);this.VIntX(o*3,this.vlist,this.nlist,6,j,c,ha,g,W,B)}if(la&8){this.compNorm(h);this.compNorm(o);this.VIntY(h*3,this.vlist,this.nlist,9,j,c,f,g,H,W)}if(la&16){this.compNorm(p);this.compNorm(z);this.VIntX(p*3,this.vlist,this.nlist,
+12,j,c,f,pa,U,N)}if(la&32){this.compNorm(z);this.compNorm(A);this.VIntY(z*3,this.vlist,this.nlist,15,j,ga,f,pa,N,ua)}if(la&64){this.compNorm(u);this.compNorm(A);this.VIntX(u*3,this.vlist,this.nlist,18,j,c,ha,pa,O,ua)}if(la&128){this.compNorm(p);this.compNorm(u);this.VIntY(p*3,this.vlist,this.nlist,21,j,c,f,pa,U,O)}if(la&256){this.compNorm(h);this.compNorm(p);this.VIntZ(h*3,this.vlist,this.nlist,24,j,c,f,g,H,U)}if(la&512){this.compNorm(m);this.compNorm(z);this.VIntZ(m*3,this.vlist,this.nlist,27,j,
+ga,f,g,J,N)}if(la&1024){this.compNorm(t);this.compNorm(A);this.VIntZ(t*3,this.vlist,this.nlist,30,j,ga,ha,g,B,ua)}if(la&2048){this.compNorm(o);this.compNorm(u);this.VIntZ(o*3,this.vlist,this.nlist,33,j,c,ha,g,W,O)}E<<=4;for(j=h=0;THREE.triTable[E+j]!=-1;){c=E+j;f=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[f],3*THREE.triTable[g],k);j+=3;h++}return h};this.posnormtriv=function(c,f,g,h,j,k){var m=this.count*3;this.positionArray[m]=c[g];this.positionArray[m+
+1]=c[g+1];this.positionArray[m+2]=c[g+2];this.positionArray[m+3]=c[h];this.positionArray[m+4]=c[h+1];this.positionArray[m+5]=c[h+2];this.positionArray[m+6]=c[j];this.positionArray[m+7]=c[j+1];this.positionArray[m+8]=c[j+2];this.normalArray[m]=f[g];this.normalArray[m+1]=f[g+1];this.normalArray[m+2]=f[g+2];this.normalArray[m+3]=f[h];this.normalArray[m+4]=f[h+1];this.normalArray[m+5]=f[h+2];this.normalArray[m+6]=f[j];this.normalArray[m+7]=f[j+1];this.normalArray[m+8]=f[j+2];this.hasPos=!0;this.hasNormal=
+!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;f<this.positionArray.length;f++)this.positionArray[f]=0;c(this)}};this.addBall=function(c,f,g,h,j){var k=this.size*Math.sqrt(h/j),m=g*this.size,o=f*this.size,p=c*this.size,t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var z=Math.floor(o-k);z<1&&(z=1);o=Math.floor(o+k);o>this.size-1&&
+(o=this.size-1);var u=Math.floor(p-k);u<1&&(u=1);k=Math.floor(p+k);k>this.size-1&&(k=this.size-1);for(var A,E,H,J,W,B;t<m;t++){p=this.size2*t;E=t/this.size-g;W=E*E;for(E=z;E<o;E++){H=p+this.size*E;A=E/this.size-f;B=A*A;for(A=u;A<k;A++){J=A/this.size-c;J=h/(1.0E-6+J*J+B+W)-j;J>0&&(this.field[H+A]+=J)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,o=this.size,p=this.yd,t=this.zd,z=this.field,u=o*Math.sqrt(c/f);u>o&&(u=o);for(g=0;g<u;g++){h=g/o;h*=h;k=c/(1.0E-4+h)-f;if(k>0)for(h=0;h<o;h++){m=g+h*p;for(j=
+0;j<o;j++)z[t*j+m]+=k}}};this.addPlaneY=function(c,f){var g,h,j,k,m,o,p=this.size,t=this.yd,z=this.zd,u=this.field,A=p*Math.sqrt(c/f);A>p&&(A=p);for(h=0;h<A;h++){g=h/p;g*=g;k=c/(1.0E-4+g)-f;if(k>0){m=h*t;for(g=0;g<p;g++){o=m+g;for(j=0;j<p;j++)u[z*j+o]+=k}}}};this.addPlaneZ=function(c,f){var g,h,j,k,m,o;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/f);dist>size&&(dist=size);for(j=0;j<dist;j++){g=j/size;g*=g;k=c/(1.0E-4+g)-f;if(k>0){m=zd*j;for(h=0;h<size;h++){o=m+h*yd;
+for(g=0;g<size;g++)field[o+g]+=k}}}};this.reset=function(){var c;for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var f,g,h,j,k,m,o,p,t,z=this.size-2;for(j=1;j<z;j++){t=this.size2*j;o=(j-this.halfsize)/this.halfsize;for(h=1;h<z;h++){p=t+this.size*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<z;g++){k=(g-this.halfsize)/this.halfsize;f=p+g;this.polygonize(k,m,o,f,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,f=new THREE.Geometry,
+g=[];this.render(function(h){var j,k,m,o,p,t,z,u;for(j=0;j<h.count;j++){z=j*3;p=z+1;u=z+2;k=h.positionArray[z];m=h.positionArray[p];o=h.positionArray[u];t=new THREE.Vector3(k,m,o);k=h.normalArray[z];m=h.normalArray[p];o=h.normalArray[u];z=new THREE.Vector3(k,m,o);z.normalize();p=new THREE.Vertex(t);f.vertices.push(p);g.push(z)}nfaces=h.count/3;for(j=0;j<nfaces;j++){z=(c+j)*3;p=z+1;u=z+2;t=g[z];k=g[p];m=g[u];z=new THREE.Face3(z,p,u,[t,k,m]);f.faces.push(z)}c+=nfaces;h.count=0});return f};this.init(b)};
 THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
@@ -505,8 +508,8 @@ THREE.CollisionSystem.prototype.rayMesh=function(b,d){for(var c=this.makeRayLoca
 THREE.CollisionSystem.prototype.rayTriangle=function(b,d,c,f,g,h){var j=THREE.CollisionSystem.__v1,k=THREE.CollisionSystem.__v2;j.sub(c,d);k.sub(f,c);g.cross(j,k);k=g.dot(b.direction);if(!(k<0))return Number.MAX_VALUE;j=g.dot(d)-g.dot(b.origin);if(!(j<=0))return Number.MAX_VALUE;if(!(j>=k*h))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);if(Math.abs(g.x)>Math.abs(g.y))if(Math.abs(g.x)>Math.abs(g.z)){b=k.y-d.y;g=c.y-d.y;h=f.y-d.y;
 k=k.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=k.x-d.x;g=c.x-d.x;h=f.x-d.x;k=k.y-d.y;c=c.y-d.y;f=f.y-d.y}else if(Math.abs(g.y)>Math.abs(g.z)){b=k.x-d.x;g=c.x-d.x;h=f.x-d.x;k=k.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=k.x-d.x;g=c.x-d.x;h=f.x-d.x;k=k.y-d.y;c=c.y-d.y;f=f.y-d.y}d=g*f-c*h;if(d==0)return Number.MAX_VALUE;d=1/d;f=(b*f-k*h)*d;if(!(f>=0))return Number.MAX_VALUE;d*=g*k-c*b;if(!(d>=0))return Number.MAX_VALUE;if(!(1-f-d>=0))return Number.MAX_VALUE;return j};
 THREE.CollisionSystem.prototype.makeRayLocal=function(b,d){var c=new THREE.Ray(b.origin.clone(),b.direction.clone()),f=THREE.Matrix4.makeInvert(d.matrixWorld);f.multiplyVector3(c.origin);f.rotateAxis(c.direction);c.direction.normalize();return c};
-THREE.CollisionSystem.prototype.rayBox=function(b,d){var c;c=d.dynamic&&d.mesh&&d.mesh.matrixWorld?this.makeRayLocal(b,d.mesh):new THREE.Ray(b.origin.clone(),b.direction.clone());var f=0,g=0,h=0,j=0,k=0,m=0,p=!0;if(c.origin.x<d.min.x){f=d.min.x-c.origin.x;f/=c.direction.x;p=!1;j=-1}else if(c.origin.x>d.max.x){f=d.max.x-c.origin.x;f/=c.direction.x;p=!1;j=1}if(c.origin.y<d.min.y){g=d.min.y-c.origin.y;g/=c.direction.y;p=!1;k=-1}else if(c.origin.y>d.max.y){g=d.max.y-c.origin.y;g/=c.direction.y;p=!1;k=
-1}if(c.origin.z<d.min.z){h=d.min.z-c.origin.z;h/=c.direction.z;p=!1;m=-1}else if(c.origin.z>d.max.z){h=d.max.z-c.origin.z;h/=c.direction.z;p=!1;m=1}if(p)return-1;p=0;if(g>f){p=1;f=g}if(h>f){p=2;f=h}switch(p){case 0:k=c.origin.y+c.direction.y*f;if(k<d.min.y||k>d.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(c<d.min.z||c>d.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(j,0,0);break;case 1:j=c.origin.x+c.direction.x*f;if(j<d.min.x||j>d.max.x)return Number.MAX_VALUE;c=c.origin.z+
+THREE.CollisionSystem.prototype.rayBox=function(b,d){var c;c=d.dynamic&&d.mesh&&d.mesh.matrixWorld?this.makeRayLocal(b,d.mesh):new THREE.Ray(b.origin.clone(),b.direction.clone());var f=0,g=0,h=0,j=0,k=0,m=0,o=!0;if(c.origin.x<d.min.x){f=d.min.x-c.origin.x;f/=c.direction.x;o=!1;j=-1}else if(c.origin.x>d.max.x){f=d.max.x-c.origin.x;f/=c.direction.x;o=!1;j=1}if(c.origin.y<d.min.y){g=d.min.y-c.origin.y;g/=c.direction.y;o=!1;k=-1}else if(c.origin.y>d.max.y){g=d.max.y-c.origin.y;g/=c.direction.y;o=!1;k=
+1}if(c.origin.z<d.min.z){h=d.min.z-c.origin.z;h/=c.direction.z;o=!1;m=-1}else if(c.origin.z>d.max.z){h=d.max.z-c.origin.z;h/=c.direction.z;o=!1;m=1}if(o)return-1;o=0;if(g>f){o=1;f=g}if(h>f){o=2;f=h}switch(o){case 0:k=c.origin.y+c.direction.y*f;if(k<d.min.y||k>d.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(c<d.min.z||c>d.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(j,0,0);break;case 1:j=c.origin.x+c.direction.x*f;if(j<d.min.x||j>d.max.x)return Number.MAX_VALUE;c=c.origin.z+
 c.direction.z*f;if(c<d.min.z||c>d.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,k,0);break;case 2:j=c.origin.x+c.direction.x*f;if(j<d.min.x||j>d.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*f;if(k<d.min.y||k>d.max.y)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,0,m)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,d){var c=b.direction.dot(d.normal),f=d.point.dot(d.normal);if(c<0)c=(f-b.origin.dot(d.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE};
 THREE.CollisionSystem.prototype.raySphere=function(b,d){var c=d.center.clone().subSelf(b.origin);if(c.lengthSq<d.radiusSq)return-1;var f=c.dot(b.direction.clone());if(f<=0)return Number.MAX_VALUE;c=d.radiusSq-(c.lengthSq()-f*f);if(c>=0)return Math.abs(f)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionUtils={};
 THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var d=b.geometry.boundingBox,c=new THREE.Vector3(d.x[0],d.y[0],d.z[0]);d=new THREE.Vector3(d.x[1],d.y[1],d.z[1]);c=new THREE.BoxCollider(c,d);c.mesh=b;return c};THREE.CollisionUtils.MeshAABB=function(b){var d=THREE.CollisionUtils.MeshOBB(b);d.min.addSelf(b.position);d.max.addSelf(b.position);d.dynamic=!1;return d};

+ 66 - 65
build/custom/ThreeCanvas.js

@@ -8,25 +8,25 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var b=Math.cos(this.y);this.y=Math.asin(a.n13);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n12/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};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,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(D,z,U,V){V=V.clone().subSelf(z);U=U.clone().subSelf(z);var B=D.clone().subSelf(z);D=V.dot(V);z=V.dot(U);V=V.dot(B);var u=U.dot(U);U=U.dot(B);B=1/(D*u-z*z);u=(u*V-z*U)*B;D=(D*U-z*V)*B;return u>0&&D>0&&u+D<1}var c,d,e,h,f,k,g,i,j,o,
-p,r=a.geometry,y=r.vertices,A=[];c=0;for(d=r.faces.length;c<d;c++){e=r.faces[c];o=this.origin.clone();p=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(y[e.a].position.clone());f=g.multiplyVector3(y[e.b].position.clone());k=g.multiplyVector3(y[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(y[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());j=p.dot(i);if(a.doubleSided||(a.flipSided?j>0:j<0)){i=i.dot((new THREE.Vector3).sub(h,o))/
-j;o=o.addSelf(p.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(o,h,f,k)){e={distance:this.origin.distanceTo(o),point:o,face:e,object:a};A.push(e)}}else if(e instanceof THREE.Face4&&(b(o,h,f,g)||b(o,f,k,g))){e={distance:this.origin.distanceTo(o),point:o,face:e,object:a};A.push(e)}}}return A}};
-THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,j,o){k=!1;b=g;c=i;d=j;e=o;a()};this.addPoint=function(g,i){if(k){k=!1;b=g;c=i;d=g;e=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;e=e>i?e:i}a()};
-this.add3Points=function(g,i,j,o,p,r){if(k){k=!1;b=g<j?g<p?g:p:j<p?j:p;c=i<o?i<r?i:r:o<r?o:r;d=g>j?g>p?g:p:j>p?j:p;e=i>o?i>r?i:r:o>r?o:r}else{b=g<j?g<p?g<b?g:b:p<b?p:b:j<p?j<b?j:b:p<b?p:b;c=i<o?i<r?i<c?i:c:r<c?r:c:o<r?o<c?o:c:r<c?r:c;d=g>j?g>p?g>d?g:d:p>d?p:d:j>p?j>d?j:d:p>d?p:d;e=i>o?i>r?i>e?i:e:r>e?r:e:o>r?o>e?o:e:r>e?r:e}a()};this.addRectangle=function(g){if(k){k=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(D,z,T,U){U=U.clone().subSelf(z);T=T.clone().subSelf(z);var X=D.clone().subSelf(z);D=U.dot(U);z=U.dot(T);U=U.dot(X);var s=T.dot(T);T=T.dot(X);X=1/(D*s-z*z);s=(s*U-z*T)*X;D=(D*T-z*U)*X;return s>0&&D>0&&s+D<1}var c,d,e,h,f,k,g,i,n,j,
+p,r=a.geometry,y=r.vertices,A=[];c=0;for(d=r.faces.length;c<d;c++){e=r.faces[c];j=this.origin.clone();p=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(y[e.a].position.clone());f=g.multiplyVector3(y[e.b].position.clone());k=g.multiplyVector3(y[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(y[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=p.dot(i);if(a.doubleSided||(a.flipSided?n>0:n<0)){i=i.dot((new THREE.Vector3).sub(h,j))/
+n;j=j.addSelf(p.multiplyScalar(i));if(e instanceof THREE.Face3){if(b(j,h,f,k)){e={distance:this.origin.distanceTo(j),point:j,face:e,object:a};A.push(e)}}else if(e instanceof THREE.Face4&&(b(j,h,f,g)||b(j,f,k,g))){e={distance:this.origin.distanceTo(j),point:j,face:e,object:a};A.push(e)}}}return A}};
+THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,n,j){k=!1;b=g;c=i;d=n;e=j;a()};this.addPoint=function(g,i){if(k){k=!1;b=g;c=i;d=g;e=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;e=e>i?e:i}a()};
+this.add3Points=function(g,i,n,j,p,r){if(k){k=!1;b=g<n?g<p?g:p:n<p?n:p;c=i<j?i<r?i:r:j<r?j:r;d=g>n?g>p?g:p:n>p?n:p;e=i>j?i>r?i:r:j>r?j:r}else{b=g<n?g<p?g<b?g:b:p<b?p:b:n<p?n<b?n:b:p<b?p:b;c=i<j?i<r?i<c?i:c:r<c?r:c:j<r?j<c?j:c:r<c?r:c;d=g>n?g>p?g>d?g:d:p>d?p:d:n>p?n>d?n:d:p>d?p:d;e=i>j?i>r?i>e?i:e:r>e?r:e:j>r?j>e?j:e:r>e?r:e}a()};this.addRectangle=function(g){if(k){k=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
 d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){k=!0;e=d=c=b=0;a()};this.isEmpty=function(){return k}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,h,f,k,g,i,j,o,p,r,y,A){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,k||0,g||0,i||0,j||1,o||0,p||0,r||0,y||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,k,g,i,j,o,p,r,y,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=k;this.n31=g;this.n32=i;this.n33=j;this.n34=o;this.n41=p;this.n42=r;this.n43=y;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
+THREE.Matrix4=function(a,b,c,d,e,h,f,k,g,i,n,j,p,r,y,A){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,k||0,g||0,i||0,n||1,j||0,p||0,r||0,y||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,k,g,i,n,j,p,r,y,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=k;this.n31=g;this.n32=i;this.n33=n;this.n34=j;this.n41=p;this.n42=r;this.n43=y;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
 e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;d.cross(c,h).normalize();if(d.length()===0){h.x+=1.0E-4;d.cross(c,h).normalize()}e.cross(h,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=h.x;this.n21=d.y;this.n22=e.y;this.n23=h.y;this.n31=d.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
 d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
-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 c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,j=a.n31,o=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44,U=b.n11,V=b.n12,B=b.n13,u=b.n14,n=b.n21,Y=b.n22,
-Z=b.n23,aa=b.n24,P=b.n31,w=b.n32,t=b.n33,K=b.n34;this.n11=c*U+d*n+e*P;this.n12=c*V+d*Y+e*w;this.n13=c*B+d*Z+e*t;this.n14=c*u+d*aa+e*K+h;this.n21=f*U+k*n+g*P;this.n22=f*V+k*Y+g*w;this.n23=f*B+k*Z+g*t;this.n24=f*u+k*aa+g*K+i;this.n31=j*U+o*n+p*P;this.n32=j*V+o*Y+p*w;this.n33=j*B+o*Z+p*t;this.n34=j*u+o*aa+p*K+r;this.n41=y*U+A*n+D*P;this.n42=y*V+A*Y+D*w;this.n43=y*B+A*Z+D*t;this.n44=y*u+A*aa+D*K+z;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;
+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 c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,n=a.n31,j=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44,T=b.n11,U=b.n12,X=b.n13,s=b.n14,o=b.n21,L=b.n22,
+R=b.n23,aa=b.n24,ba=b.n31,w=b.n32,u=b.n33,H=b.n34;this.n11=c*T+d*o+e*ba;this.n12=c*U+d*L+e*w;this.n13=c*X+d*R+e*u;this.n14=c*s+d*aa+e*H+h;this.n21=f*T+k*o+g*ba;this.n22=f*U+k*L+g*w;this.n23=f*X+k*R+g*u;this.n24=f*s+k*aa+g*H+i;this.n31=n*T+j*o+p*ba;this.n32=n*U+j*L+p*w;this.n33=n*X+j*R+p*u;this.n34=n*s+j*aa+p*H+r;this.n41=y*T+A*o+D*ba;this.n42=y*U+A*L+D*w;this.n43=y*X+A*R+D*u;this.n44=y*s+A*aa+D*H+z;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;
 c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,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(){var a=
-this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,k=this.n24,g=this.n31,i=this.n32,j=this.n33,o=this.n34,p=this.n41,r=this.n42,y=this.n43,A=this.n44;return d*f*i*p-c*k*i*p-d*h*j*p+b*k*j*p+c*h*o*p-b*f*o*p-d*f*g*r+c*k*g*r+d*e*j*r-a*k*j*r-c*e*o*r+a*f*o*r+d*h*g*y-b*k*g*y-d*e*i*y+a*k*i*y+b*e*o*y-a*h*o*y-c*h*g*A+b*f*g*A+c*e*i*A-a*f*i*A-b*e*j*A+a*h*j*A},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,k=this.n24,g=this.n31,i=this.n32,n=this.n33,j=this.n34,p=this.n41,r=this.n42,y=this.n43,A=this.n44;return d*f*i*p-c*k*i*p-d*h*n*p+b*k*n*p+c*h*j*p-b*f*j*p-d*f*g*r+c*k*g*r+d*e*n*r-a*k*n*r-c*e*j*r+a*f*j*r+d*h*g*y-b*k*g*y-d*e*i*y+a*k*i*y+b*e*j*y-a*h*j*y-c*h*g*A+b*f*g*A+c*e*i*A-a*f*i*A-b*e*n*A+a*h*n*A},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
 this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;
 this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
 this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
@@ -34,21 +34,22 @@ b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:functio
 h+c,g*f-d*k,g*k+d*f,0,g*f+d*k,i*f+c,i*k-d*h,0,g*k-d*f,i*k+d*h,e*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var f=a*c,k=b*c;this.n11=e*h;this.n12=-e*d;this.n13=c;this.n21=k*h+a*d;this.n22=-k*d+a*h;this.n23=-b*e;this.n31=-f*h+b*d;this.n32=f*d+b*h;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=
 a.x,c=a.y,d=a.z,e=a.w,h=b+b,f=c+c,k=d+d;a=b*h;var g=b*f;b*=k;var i=c*f;c*=k;d*=k;h*=e;f*=e;e*=k;this.n11=1-(i+d);this.n12=g-e;this.n13=b+f;this.n21=g+e;this.n22=1-(a+d);this.n23=c-h;this.n31=b-f;this.n32=c+h;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
 a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,j=a.n31,o=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*r*A-i*p*A+i*o*D-k*r*D-g*o*z+k*p*z;b.n12=h*p*A-e*r*A-h*o*D+d*r*D+e*o*z-d*p*z;b.n13=e*i*A-h*g*A+h*k*D-d*i*D-e*k*z+d*g*z;b.n14=h*g*o-e*i*o-h*k*p+d*i*p+e*k*r-d*g*r;b.n21=i*p*y-g*r*y-i*j*D+f*r*D+g*j*z-f*p*z;b.n22=e*r*y-h*p*y+h*j*D-c*r*D-e*j*z+c*p*z;b.n23=h*g*y-e*i*y-h*f*D+c*i*D+e*f*z-c*g*z;
-b.n24=e*i*j-h*g*j+h*f*p-c*i*p-e*f*r+c*g*r;b.n31=k*r*y-i*o*y+i*j*A-f*r*A-k*j*z+f*o*z;b.n32=h*o*y-d*r*y-h*j*A+c*r*A+d*j*z-c*o*z;b.n33=e*i*y-h*k*y+h*f*A-c*i*A-d*f*z+c*k*z;b.n34=h*k*j-d*i*j-h*f*o+c*i*o+d*f*r-c*k*r;b.n41=g*o*y-k*p*y-g*j*A+f*p*A+k*j*D-f*o*D;b.n42=d*p*y-e*o*y+e*j*A-c*p*A-d*j*D+c*o*D;b.n43=e*k*y-d*g*y-e*f*A+c*g*A+d*f*D-c*k*D;b.n44=d*g*j-e*k*j+e*f*o-c*g*o-d*f*p+c*k*p;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,o=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*k;c[5]=a*g;c[6]=a*i;c[7]=a*j;c[8]=a*o;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,k=a.n22,g=a.n23,i=a.n24,n=a.n31,j=a.n32,p=a.n33,r=a.n34,y=a.n41,A=a.n42,D=a.n43,z=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*r*A-i*p*A+i*j*D-k*r*D-g*j*z+k*p*z;b.n12=h*p*A-e*r*A-h*j*D+d*r*D+e*j*z-d*p*z;b.n13=e*i*A-h*g*A+h*k*D-d*i*D-e*k*z+d*g*z;b.n14=h*g*j-e*i*j-h*k*p+d*i*p+e*k*r-d*g*r;b.n21=i*p*y-g*r*y-i*n*D+f*r*D+g*n*z-f*p*z;b.n22=e*r*y-h*p*y+h*n*D-c*r*D-e*n*z+c*p*z;b.n23=h*g*y-e*i*y-h*f*D+c*i*D+e*f*z-c*g*z;
+b.n24=e*i*n-h*g*n+h*f*p-c*i*p-e*f*r+c*g*r;b.n31=k*r*y-i*j*y+i*n*A-f*r*A-k*n*z+f*j*z;b.n32=h*j*y-d*r*y-h*n*A+c*r*A+d*n*z-c*j*z;b.n33=e*i*y-h*k*y+h*f*A-c*i*A-d*f*z+c*k*z;b.n34=h*k*n-d*i*n-h*f*j+c*i*j+d*f*r-c*k*r;b.n41=g*j*y-k*p*y-g*n*A+f*p*A+k*n*D-f*j*D;b.n42=d*p*y-e*j*y+e*n*A-c*p*A-d*n*D+c*j*D;b.n43=e*k*y-d*g*y-e*f*A+c*g*A+d*f*D-c*k*D;b.n44=d*g*n-e*k*n+e*f*j-c*g*j-d*f*p+c*k*p;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,j=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*k;c[5]=a*g;c[6]=a*i;c[7]=a*n;c[8]=a*j;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(h+e)/(h-e);f.n34=-2*h*e/(h-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,k,g,i;f=new THREE.Matrix4;k=b-a;g=c-d;i=h-e;f.n11=2/k;f.n12=0;f.n13=0;f.n14=-((b+a)/k);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((h+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
-THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
 undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
 b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,k=d*e;this.w=f*h-k*c;this.x=f*c+k*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,k=a.z;a=a.w;this.x=b*a+e*h+c*k-d*f;this.y=c*a+e*f+d*h-b*k;this.z=d*a+e*k+b*f-c*h;this.w=e*a-b*h-c*f-d*k;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,k=this.z,g=this.w,i=g*c+f*e-k*d,j=g*d+k*c-h*e,o=g*e+h*d-f*c;c=-h*c-f*d-k*e;b.x=i*g+c*-h+j*-k-o*-f;b.y=j*g+c*-f+o*-h-i*-k;b.z=o*g+c*-k+i*-f-j*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,k=d*e;this.w=f*h-k*c;this.x=f*c+k*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
+a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},
+multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,k=a.z;a=a.w;this.x=b*a+e*h+c*k-d*f;this.y=c*a+e*f+d*h-b*k;this.z=d*a+e*k+b*f-c*h;this.w=e*a-b*h-c*f-d*k;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,k=this.z,g=this.w,i=g*c+f*e-k*d,n=
+g*d+k*c-h*e,j=g*e+h*d-f*c;c=-h*c-f*d-k*e;b.x=i*g+c*-h+n*-k-j*-f;b.y=n*g+c*-f+j*-h-i*-k;b.z=j*g+c*-k+i*-f-n*-h;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -56,20 +57,19 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,h,f,k=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){h=this.faces[d];if(a&&h.vertexNormals.length){k.set(0,0,0);b=0;for(c=h.vertexNormals.length;b<c;b++)k.addSelf(h.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];f=this.vertices[h.c];k.sub(f.position,c.position);g.sub(b.position,c.position);k.crossSelf(g)}k.isZero()||
 k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);
-c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(E,R,S,W,H,C,F){k=E.vertices[R].position;g=E.vertices[S].position;i=E.vertices[W].position;j=f[H];o=f[C];p=f[F];r=g.x-k.x;y=i.x-k.x;A=g.y-k.y;D=i.y-k.y;z=g.z-k.z;U=i.z-k.z;V=o.u-j.u;B=p.u-j.u;u=o.v-j.v;n=p.v-j.v;Y=1/(V*n-B*u);w.set((n*
-r-u*y)*Y,(n*A-u*D)*Y,(n*z-u*U)*Y);t.set((V*y-B*r)*Y,(V*D-B*A)*Y,(V*U-B*z)*Y);aa[R].addSelf(w);aa[S].addSelf(w);aa[W].addSelf(w);P[R].addSelf(t);P[S].addSelf(t);P[W].addSelf(t)}var b,c,d,e,h,f,k,g,i,j,o,p,r,y,A,D,z,U,V,B,u,n,Y,Z,aa=[],P=[],w=new THREE.Vector3,t=new THREE.Vector3,K=new THREE.Vector3,N=new THREE.Vector3,Q=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];f=this.faceVertexUvs[0][b];
-if(h instanceof THREE.Face3)a(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){a(this,h.a,h.b,h.c,0,1,2);a(this,h.a,h.b,h.d,0,1,3)}}var T=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(d=0;d<h.vertexNormals.length;d++){Q.copy(h.vertexNormals[d]);e=h[T[d]];Z=aa[e];K.copy(Z);K.subSelf(Q.multiplyScalar(Q.dot(Z))).normalize();N.cross(h.vertexNormals[d],Z);e=N.dot(P[e]);e=e<0?-1:1;h.vertexTangents[d]=new THREE.Vector4(K.x,K.y,K.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(E,O,S,V,F,Y,B){k=E.vertices[O].position;g=E.vertices[S].position;i=E.vertices[V].position;n=f[F];j=f[Y];p=f[B];r=g.x-k.x;y=i.x-k.x;A=g.y-k.y;D=i.y-k.y;z=g.z-k.z;T=i.z-k.z;U=j.u-n.u;X=p.u-n.u;s=j.v-n.v;o=p.v-n.v;L=1/(U*o-X*s);w.set((o*
+r-s*y)*L,(o*A-s*D)*L,(o*z-s*T)*L);u.set((U*y-X*r)*L,(U*D-X*A)*L,(U*T-X*z)*L);aa[O].addSelf(w);aa[S].addSelf(w);aa[V].addSelf(w);ba[O].addSelf(u);ba[S].addSelf(u);ba[V].addSelf(u)}var b,c,d,e,h,f,k,g,i,n,j,p,r,y,A,D,z,T,U,X,s,o,L,R,aa=[],ba=[],w=new THREE.Vector3,u=new THREE.Vector3,H=new THREE.Vector3,M=new THREE.Vector3,P=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;ba[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];f=this.faceVertexUvs[0][b];
+if(h instanceof THREE.Face3)a(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){a(this,h.a,h.b,h.c,0,1,2);a(this,h.a,h.b,h.d,0,1,3)}}var I=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(d=0;d<h.vertexNormals.length;d++){P.copy(h.vertexNormals[d]);e=h[I[d]];R=aa[e];H.copy(R);H.subSelf(P.multiplyScalar(P.dot(R))).normalize();M.cross(h.vertexNormals[d],R);e=M.dot(ba[e]);e=e<0?-1:1;h.vertexTangents[d]=new THREE.Vector4(H.x,H.y,H.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(g,i){return Math.min(g,
-i)+"_"+Math.max(g,i)}function b(g,i,j){if(g[i]===undefined){g[i]={set:{},array:[]};g[i].set[j]=1;g[i].array.push(j)}else if(g[i].set[j]===undefined){g[i].set[j]=1;g[i].array.push(j)}}var c,d,e,h,f,k={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(k,e,c);e=a(f.b,f.c);b(k,e,c);e=a(f.a,f.c);b(k,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(k,e,c);e=a(f.a,f.b);b(k,e,c);e=a(f.a,f.d);b(k,e,c);e=a(f.b,f.c);b(k,e,c);e=a(f.c,f.d);b(k,e,c)}}c=0;for(d=
+i)+"_"+Math.max(g,i)}function b(g,i,n){if(g[i]===undefined){g[i]={set:{},array:[]};g[i].set[n]=1;g[i].array.push(n)}else if(g[i].set[n]===undefined){g[i].set[n]=1;g[i].array.push(n)}}var c,d,e,h,f,k={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(k,e,c);e=a(f.b,f.c);b(k,e,c);e=a(f.a,f.c);b(k,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(k,e,c);e=a(f.a,f.b);b(k,e,c);e=a(f.a,f.d);b(k,e,c);e=a(f.b,f.c);b(k,e,c);e=a(f.c,f.d);b(k,e,c)}}c=0;for(d=
 this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];h=f.vertexIndices[1];f.faceIndices=k[a(e,h)].array;for(e=0;e<f.faceIndices.length;e++){h=f.faceIndices[e];f.faces.push(this.faces[h])}}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.Material=function(a){this.id=THREE.MaterialCounter.value++;a=a||{};this.opacity=a.opacity!==undefined?a.opacity:1;this.transparent=a.transparent!==undefined?a.transparent:!1;this.blending=a.blending!==undefined?a.blending:THREE.NormalBlending;this.depthTest=a.depthTest!==undefined?a.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
-THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;
+THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.Material=function(a){this.id=THREE.MaterialCounter.value++;a=a||{};this.opacity=a.opacity!==undefined?a.opacity:1;this.transparent=a.transparent!==undefined?a.transparent:!1;this.blending=a.blending!==undefined?a.blending:THREE.NormalBlending;this.depthTest=a.depthTest!==undefined?a.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;
+THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==undefined?a.linewidth:1;this.linecap=a.linecap!==undefined?a.linecap:"round";this.linejoin=a.linejoin!==undefined?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
 THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==undefined?a.map:null;this.lightMap=a.lightMap!==undefined?a.lightMap:null;this.envMap=a.envMap!==undefined?a.envMap:null;this.combine=a.combine!==undefined?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==undefined?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==undefined?a.refractionRatio:0.98;this.shading=
 a.shading!==undefined?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==undefined?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==undefined?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==undefined?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==undefined?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==undefined?a.vertexColors:!1;this.skinning=a.skinning!==undefined?a.skinning:!1;this.morphTargets=a.morphTargets!==undefined?
@@ -102,42 +102,43 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var w=g[k]=g[k]||new THREE.RenderableVertex;k++;return w}function b(w,t){return t.z-w.z}function c(w,t){var K=0,N=1,Q=w.z+w.w,T=t.z+t.w,E=-w.z+w.w,R=-t.z+t.w;if(Q>=0&&T>=0&&E>=0&&R>=0)return!0;else if(Q<0&&T<0||E<0&&R<0)return!1;else{if(Q<0)K=Math.max(K,Q/(Q-T));else T<0&&(N=Math.min(N,Q/(Q-T)));if(E<0)K=Math.max(K,E/(E-R));else R<0&&(N=Math.min(N,E/(E-R)));if(N<K)return!1;else{w.lerpSelf(t,K);t.lerpSelf(w,1-N);return!0}}}var d,e,h=[],f,k,g=[],i,j,o=[],p,r=
-[],y,A,D=[],z,U,V=[],B=new THREE.Vector4,u=new THREE.Vector4,n=new THREE.Matrix4,Y=new THREE.Matrix4,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],aa=new THREE.Vector4,P=new THREE.Vector4;this.projectVector=function(w,t){n.multiply(t.projectionMatrix,t.matrixWorldInverse);n.multiplyVector3(w);return w};this.unprojectVector=function(w,t){n.multiply(t.matrixWorld,THREE.Matrix4.makeInvert(t.projectionMatrix));n.multiplyVector3(w);return w};
-this.projectObjects=function(w,t,K){t=[];var N,Q,T;e=0;Q=w.objects;w=0;for(N=Q.length;w<N;w++){T=Q[w];var E;if(!(E=!T.visible))if(E=T instanceof THREE.Mesh){a:{E=void 0;for(var R=T.matrixWorld,S=-T.geometry.boundingSphere.radius*Math.max(T.scale.x,Math.max(T.scale.y,T.scale.z)),W=0;W<6;W++){E=Z[W].x*R.n14+Z[W].y*R.n24+Z[W].z*R.n34+Z[W].w;if(E<=S){E=!1;break a}}E=!0}E=!E}if(!E){E=h[e]=h[e]||new THREE.RenderableObject;e++;d=E;B.copy(T.position);n.multiplyVector3(B);d.object=T;d.z=B.z;t.push(d)}}K&&
-t.sort(b);return t};this.projectScene=function(w,t,K){var N=[],Q=t.near,T=t.far,E,R,S,W,H,C,F,I,M,G,da,ia,ja,fa,pa,Da,wa;U=A=p=j=0;t.matrixAutoUpdate&&t.updateMatrix();w.update(undefined,!1,t);n.multiply(t.projectionMatrix,t.matrixWorldInverse);Z[0].set(n.n41-n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);Z[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);Z[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);Z[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);Z[4].set(n.n41-n.n31,n.n42-
-n.n32,n.n43-n.n33,n.n44-n.n34);Z[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);for(E=0;E<6;E++){M=Z[E];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}M=this.projectObjects(w,t,!0);w=0;for(E=M.length;w<E;w++){G=M[w].object;if(G.visible){da=G.matrixWorld;ia=G.matrixRotationWorld;ja=G.materials;fa=G.overdraw;k=0;if(G instanceof THREE.Mesh){pa=G.geometry;W=pa.vertices;Da=pa.faces;pa=pa.faceVertexUvs;R=0;for(S=W.length;R<S;R++){f=a();f.positionWorld.copy(W[R].position);da.multiplyVector3(f.positionWorld);
-f.positionScreen.copy(f.positionWorld);n.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>Q&&f.positionScreen.z<T}W=0;for(R=Da.length;W<R;W++){S=Da[W];if(S instanceof THREE.Face3){H=g[S.a];C=g[S.b];F=g[S.c];if(H.visible&&C.visible&&F.visible&&(G.doubleSided||G.flipSided!=(F.positionScreen.x-H.positionScreen.x)*(C.positionScreen.y-H.positionScreen.y)-(F.positionScreen.y-H.positionScreen.y)*(C.positionScreen.x-
-H.positionScreen.x)<0)){I=o[j]=o[j]||new THREE.RenderableFace3;j++;i=I;i.v1.copy(H);i.v2.copy(C);i.v3.copy(F)}else continue}else if(S instanceof THREE.Face4){H=g[S.a];C=g[S.b];F=g[S.c];I=g[S.d];if(H.visible&&C.visible&&F.visible&&I.visible&&(G.doubleSided||G.flipSided!=((I.positionScreen.x-H.positionScreen.x)*(C.positionScreen.y-H.positionScreen.y)-(I.positionScreen.y-H.positionScreen.y)*(C.positionScreen.x-H.positionScreen.x)<0||(C.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-
-(C.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0))){wa=r[p]=r[p]||new THREE.RenderableFace4;p++;i=wa;i.v1.copy(H);i.v2.copy(C);i.v3.copy(F);i.v4.copy(I)}else continue}i.normalWorld.copy(S.normal);ia.multiplyVector3(i.normalWorld);i.centroidWorld.copy(S.centroid);da.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);n.multiplyVector3(i.centroidScreen);F=S.vertexNormals;H=0;for(C=F.length;H<C;H++){I=i.vertexNormalsWorld[H];I.copy(F[H]);ia.multiplyVector3(I)}H=
-0;for(C=pa.length;H<C;H++)if(wa=pa[H][W]){F=0;for(I=wa.length;F<I;F++)i.uvs[H][F]=wa[F]}i.meshMaterials=ja;i.faceMaterials=S.materials;i.overdraw=fa;i.z=i.centroidScreen.z;N.push(i)}}else if(G instanceof THREE.Line){Y.multiply(n,da);W=G.geometry.vertices;H=a();H.positionScreen.copy(W[0].position);Y.multiplyVector4(H.positionScreen);R=1;for(S=W.length;R<S;R++){H=a();H.positionScreen.copy(W[R].position);Y.multiplyVector4(H.positionScreen);C=g[k-2];aa.copy(H.positionScreen);P.copy(C.positionScreen);
-if(c(aa,P)){aa.multiplyScalar(1/aa.w);P.multiplyScalar(1/P.w);da=D[A]=D[A]||new THREE.RenderableLine;A++;y=da;y.v1.positionScreen.copy(aa);y.v2.positionScreen.copy(P);y.z=Math.max(aa.z,P.z);y.materials=G.materials;N.push(y)}}}else if(G instanceof THREE.Particle){u.set(G.position.x,G.position.y,G.position.z,1);n.multiplyVector4(u);u.z/=u.w;if(u.z>0&&u.z<1){da=V[U]=V[U]||new THREE.RenderableParticle;U++;z=da;z.x=u.x/u.w;z.y=u.y/u.w;z.z=u.z;z.rotation=G.rotation.z;z.scale.x=G.scale.x*Math.abs(z.x-(u.x+
-t.projectionMatrix.n11)/(u.w+t.projectionMatrix.n14));z.scale.y=G.scale.y*Math.abs(z.y-(u.y+t.projectionMatrix.n22)/(u.w+t.projectionMatrix.n24));z.materials=G.materials;N.push(z)}}}}K&&N.sort(b);return N}};
-THREE.CanvasRenderer=function(){function a($){if(r!=$)j.globalAlpha=r=$}function b($){if(y!=$){switch($){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}y=$}}function c($){if(A!=$)j.strokeStyle=A=$}var d=null,e=new THREE.Projector,h=document.createElement("canvas"),f,k,g,i,j=h.getContext("2d"),o=new THREE.Color(0),p=0,r=1,y=0,A=null,D=null,
-z=null,U=null,V=null,B,u,n,Y,Z=new THREE.RenderableVertex,aa=new THREE.RenderableVertex,P,w,t,K,N,Q,T,E,R,S,W,H,C=new THREE.Color,F=new THREE.Color,I=new THREE.Color,M=new THREE.Color,G=new THREE.Color,da,ia,ja,fa,pa,Da,wa,Wa,Xa,Ya,Ba=new THREE.Rectangle,ka=new THREE.Rectangle,ea=new THREE.Rectangle,Ua=!1,ha=new THREE.Color,ga=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,ba=new THREE.Vector3,Ha,Ia,Va,la,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");
-Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);la=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function($,ma){f=$;k=ma;g=f/2;i=k/2;h.width=f;h.height=k;Ba.set(-g,-i,g,i);r=1;y=0;V=U=z=D=A=null};this.setClearColor=function($,ma){o=$;p=ma};this.setClearColorHex=function($,ma){o.setHex($);p=
-ma};this.clear=function(){j.setTransform(1,0,0,-1,g,i);if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(Ba);if(o.hex==0&&p==0)j.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());else{b(THREE.NormalBlending);a(1);j.fillStyle="rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+p+")";j.fillRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight())}ka.empty()}};this.render=function($,ma){function ab(m){var x,s,q,L=m.lights;ga.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);
-m=0;for(x=L.length;m<x;m++){s=L[m];q=s.color;if(s instanceof THREE.AmbientLight){ga.r+=q.r;ga.g+=q.g;ga.b+=q.b}else if(s instanceof THREE.DirectionalLight){Ma.r+=q.r;Ma.g+=q.g;Ma.b+=q.b}else if(s instanceof THREE.PointLight){Na.r+=q.r;Na.g+=q.g;Na.b+=q.b}}}function ra(m,x,s,q){var L,J,v,l,X=m.lights;m=0;for(L=X.length;m<L;m++){J=X[m];v=J.color;if(J instanceof THREE.DirectionalLight){l=s.dot(J.position);if(!(l<=0)){l*=J.intensity;q.r+=v.r*l;q.g+=v.g*l;q.b+=v.b*l}}else if(J instanceof THREE.PointLight){l=
-s.dot(ba.sub(J.position,x).normalize());if(!(l<=0)){l*=J.distance==0?1:1-Math.min(x.distanceTo(J.position)/J.distance,1);if(l!=0){l*=J.intensity;q.r+=v.r*l;q.g+=v.g*l;q.b+=v.b*l}}}}}function bb(m,x,s){a(s.opacity);b(s.blending);var q,L,J,v,l,X;if(s instanceof THREE.ParticleBasicMaterial){if(s.map){v=s.map.image;l=v.width>>1;X=v.height>>1;s=x.scale.x*g;J=x.scale.y*i;q=s*l;L=J*X;ea.set(m.x-q,m.y-L,m.x+q,m.y+L);if(Ba.instersects(ea)){j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);j.scale(s,-J);
-j.translate(-l,-X);j.drawImage(v,0,0);j.restore()}}}else if(s instanceof THREE.ParticleCanvasMaterial){q=x.scale.x*g;L=x.scale.y*i;ea.set(m.x-q,m.y-L,m.x+q,m.y+L);if(Ba.instersects(ea)){c(s.color.__styleString);J=s.color.__styleString;if(D!=J)j.fillStyle=D=J;j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);j.scale(q,L);s.program(j);j.restore()}}}function cb(m,x,s,q){a(q.opacity);b(q.blending);j.beginPath();j.moveTo(m.positionScreen.x,m.positionScreen.y);j.lineTo(x.positionScreen.x,x.positionScreen.y);
-j.closePath();if(q instanceof THREE.LineBasicMaterial){C.__styleString=q.color.__styleString;m=q.linewidth;if(z!=m)j.lineWidth=z=m;m=q.linecap;if(U!=m)j.lineCap=U=m;m=q.linejoin;if(V!=m)j.lineJoin=V=m;c(C.__styleString);j.stroke();ea.inflate(q.linewidth*2)}}function Pa(m,x,s,q,L,J,v,l,X){a(l.opacity);b(l.blending);P=m.positionScreen.x;w=m.positionScreen.y;t=x.positionScreen.x;K=x.positionScreen.y;N=s.positionScreen.x;Q=s.positionScreen.y;Ka(P,w,t,K,N,Q);if(l instanceof THREE.MeshBasicMaterial)if(l.map){if(l.map.mapping instanceof
-THREE.UVMapping){fa=v.uvs[0];sa(P,w,t,K,N,Q,l.map.image,fa[q].u,fa[q].v,fa[L].u,fa[L].v,fa[J].u,fa[J].v)}}else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=ma.matrixWorldInverse;ba.copy(v.vertexNormalsWorld[0]);pa=(ba.x*m.n11+ba.y*m.n12+ba.z*m.n13)*0.5+0.5;Da=-(ba.x*m.n21+ba.y*m.n22+ba.z*m.n23)*0.5+0.5;ba.copy(v.vertexNormalsWorld[1]);wa=(ba.x*m.n11+ba.y*m.n12+ba.z*m.n13)*0.5+0.5;Wa=-(ba.x*m.n21+ba.y*m.n22+ba.z*m.n23)*0.5+0.5;ba.copy(v.vertexNormalsWorld[2]);Xa=
-(ba.x*m.n11+ba.y*m.n12+ba.z*m.n13)*0.5+0.5;Ya=-(ba.x*m.n21+ba.y*m.n22+ba.z*m.n23)*0.5+0.5;sa(P,w,t,K,N,Q,l.envMap.image,pa,Da,wa,Wa,Xa,Ya)}}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString);else if(l instanceof THREE.MeshLambertMaterial){if(l.map&&!l.wireframe){if(l.map.mapping instanceof THREE.UVMapping){fa=v.uvs[0];sa(P,w,t,K,N,Q,l.map.image,fa[q].u,fa[q].v,fa[L].u,fa[L].v,fa[J].u,fa[J].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!l.wireframe&&
-l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3){F.r=I.r=M.r=ga.r;F.g=I.g=M.g=ga.g;F.b=I.b=M.b=ga.b;ra(X,v.v1.positionWorld,v.vertexNormalsWorld[0],F);ra(X,v.v2.positionWorld,v.vertexNormalsWorld[1],I);ra(X,v.v3.positionWorld,v.vertexNormalsWorld[2],M);G.r=(I.r+M.r)*0.5;G.g=(I.g+M.g)*0.5;G.b=(I.b+M.b)*0.5;ja=Qa(F,I,M,G);sa(P,w,t,K,N,Q,ja,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;ra(X,v.centroidWorld,v.normalWorld,ha);C.r=l.color.r*ha.r;C.g=l.color.g*ha.g;C.b=l.color.b*ha.b;C.updateStyleString();
-l.wireframe?xa(C.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(C.__styleString)}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){da=ma.near;ia=ma.far;F.r=F.g=F.b=1-Ca(m.positionScreen.z,da,ia);I.r=I.g=I.b=1-Ca(x.positionScreen.z,da,ia);M.r=M.g=M.b=1-Ca(s.positionScreen.z,da,ia);G.r=(I.r+M.r)*0.5;G.g=(I.g+M.g)*0.5;G.b=(I.b+M.b)*0.5;ja=Qa(F,I,
-M,G);sa(P,w,t,K,N,Q,ja,0,0,1,0,0,1)}else if(l instanceof THREE.MeshNormalMaterial){C.r=Fa(v.normalWorld.x);C.g=Fa(v.normalWorld.y);C.b=Fa(v.normalWorld.z);C.updateStyleString();l.wireframe?xa(C.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(C.__styleString)}}function Za(m,x,s,q,L,J,v,l,X){a(l.opacity);b(l.blending);if(l.map||l.envMap){Pa(m,x,q,0,1,3,v,l,X);Pa(L,s,J,1,2,3,v,l,X)}else{P=m.positionScreen.x;w=m.positionScreen.y;t=x.positionScreen.x;K=x.positionScreen.y;
-N=s.positionScreen.x;Q=s.positionScreen.y;T=q.positionScreen.x;E=q.positionScreen.y;R=L.positionScreen.x;S=L.positionScreen.y;W=J.positionScreen.x;H=J.positionScreen.y;if(l instanceof THREE.MeshBasicMaterial){Ra(P,w,t,K,N,Q,T,E);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshLambertMaterial)if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==4){F.r=I.r=M.r=G.r=
-ga.r;F.g=I.g=M.g=G.g=ga.g;F.b=I.b=M.b=G.b=ga.b;ra(X,v.v1.positionWorld,v.vertexNormalsWorld[0],F);ra(X,v.v2.positionWorld,v.vertexNormalsWorld[1],I);ra(X,v.v4.positionWorld,v.vertexNormalsWorld[3],M);ra(X,v.v3.positionWorld,v.vertexNormalsWorld[2],G);ja=Qa(F,I,M,G);Ka(P,w,t,K,T,E);sa(P,w,t,K,T,E,ja,0,0,1,0,0,1);Ka(R,S,N,Q,W,H);sa(R,S,N,Q,W,H,ja,1,0,1,1,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;ra(X,v.centroidWorld,v.normalWorld,ha);C.r=l.color.r*ha.r;C.g=l.color.g*ha.g;C.b=l.color.b*ha.b;C.updateStyleString();
-Ra(P,w,t,K,N,Q,T,E);l.wireframe?xa(C.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(C.__styleString)}else{Ra(P,w,t,K,N,Q,T,E);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshNormalMaterial){C.r=Fa(v.normalWorld.x);C.g=Fa(v.normalWorld.y);C.b=Fa(v.normalWorld.z);C.updateStyleString();Ra(P,w,t,K,N,Q,T,E);l.wireframe?xa(C.__styleString,l.wireframeLinewidth,l.wireframeLinecap,
-l.wireframeLinejoin):ya(C.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){da=ma.near;ia=ma.far;F.r=F.g=F.b=1-Ca(m.positionScreen.z,da,ia);I.r=I.g=I.b=1-Ca(x.positionScreen.z,da,ia);M.r=M.g=M.b=1-Ca(q.positionScreen.z,da,ia);G.r=G.g=G.b=1-Ca(s.positionScreen.z,da,ia);ja=Qa(F,I,M,G);Ka(P,w,t,K,T,E);sa(P,w,t,K,T,E,ja,0,0,1,0,0,1);Ka(R,S,N,Q,W,H);sa(R,S,N,Q,W,H,ja,1,0,1,1,0,1)}}}function Ka(m,x,s,q,L,J){j.beginPath();j.moveTo(m,x);j.lineTo(s,q);j.lineTo(L,J);j.lineTo(m,x);j.closePath()}function Ra(m,
-x,s,q,L,J,v,l){j.beginPath();j.moveTo(m,x);j.lineTo(s,q);j.lineTo(L,J);j.lineTo(v,l);j.lineTo(m,x);j.closePath()}function xa(m,x,s,q){if(z!=x)j.lineWidth=z=x;if(U!=s)j.lineCap=U=s;if(V!=q)j.lineJoin=V=q;c(m);j.stroke();ea.inflate(x*2)}function ya(m){if(D!=m)j.fillStyle=D=m;j.fill()}function sa(m,x,s,q,L,J,v,l,X,ta,na,ua,La){var qa,va;qa=v.width-1;va=v.height-1;l*=qa;X*=va;ta*=qa;na*=va;ua*=qa;La*=va;s-=m;q-=x;L-=m;J-=x;ta-=l;na-=X;ua-=l;La-=X;qa=ta*La-ua*na;if(qa!=0){va=1/qa;qa=(La*s-na*L)*va;na=
-(La*q-na*J)*va;s=(ta*L-ua*s)*va;q=(ta*J-ua*q)*va;m=m-qa*l-s*X;x=x-na*l-q*X;j.save();j.transform(qa,na,s,q,m,x);j.clip();j.drawImage(v,0,0);j.restore()}}function Qa(m,x,s,q){var L=~~(m.r*255),J=~~(m.g*255);m=~~(m.b*255);var v=~~(x.r*255),l=~~(x.g*255);x=~~(x.b*255);var X=~~(s.r*255),ta=~~(s.g*255);s=~~(s.b*255);var na=~~(q.r*255),ua=~~(q.g*255);q=~~(q.b*255);la[0]=L<0?0:L>255?255:L;la[1]=J<0?0:J>255?255:J;la[2]=m<0?0:m>255?255:m;la[4]=v<0?0:v>255?255:v;la[5]=l<0?0:l>255?255:l;la[6]=x<0?0:x>255?255:
-x;la[8]=X<0?0:X>255?255:X;la[9]=ta<0?0:ta>255?255:ta;la[10]=s<0?0:s>255?255:s;la[12]=na<0?0:na>255?255:na;la[13]=ua<0?0:ua>255?255:ua;la[14]=q<0?0:q>255?255:q;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Ca(m,x,s){m=(m-x)/(s-x);return m*m*(3-2*m)}function Fa(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function za(m,x){var s=x.x-m.x,q=x.y-m.y,L=1/Math.sqrt(s*s+q*q);s*=L;q*=L;x.x+=s;x.y+=q;m.x-=s;m.y-=q}var Sa,$a,O,oa,Aa,Ga,Ta,ca;this.autoClear?this.clear():j.setTransform(1,0,0,-1,g,i);d=
-e.projectScene($,ma,this.sortElements);(Ua=$.lights.length>0)&&ab($);Sa=0;for($a=d.length;Sa<$a;Sa++){O=d[Sa];ea.empty();if(O instanceof THREE.RenderableParticle){B=O;B.x*=g;B.y*=i;oa=0;for(Aa=O.materials.length;oa<Aa;){ca=O.materials[oa++];ca.opacity!=0&&bb(B,O,ca,$)}}else if(O instanceof THREE.RenderableLine){B=O.v1;u=O.v2;B.positionScreen.x*=g;B.positionScreen.y*=i;u.positionScreen.x*=g;u.positionScreen.y*=i;ea.addPoint(B.positionScreen.x,B.positionScreen.y);ea.addPoint(u.positionScreen.x,u.positionScreen.y);
-if(Ba.instersects(ea)){oa=0;for(Aa=O.materials.length;oa<Aa;){ca=O.materials[oa++];ca.opacity!=0&&cb(B,u,O,ca,$)}}}else if(O instanceof THREE.RenderableFace3){B=O.v1;u=O.v2;n=O.v3;B.positionScreen.x*=g;B.positionScreen.y*=i;u.positionScreen.x*=g;u.positionScreen.y*=i;n.positionScreen.x*=g;n.positionScreen.y*=i;if(O.overdraw){za(B.positionScreen,u.positionScreen);za(u.positionScreen,n.positionScreen);za(n.positionScreen,B.positionScreen)}ea.add3Points(B.positionScreen.x,B.positionScreen.y,u.positionScreen.x,
-u.positionScreen.y,n.positionScreen.x,n.positionScreen.y);if(Ba.instersects(ea)){oa=0;for(Aa=O.meshMaterials.length;oa<Aa;){ca=O.meshMaterials[oa++];if(ca instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=O.faceMaterials.length;Ga<Ta;)(ca=O.faceMaterials[Ga++])&&ca.opacity!=0&&Pa(B,u,n,0,1,2,O,ca,$)}else ca.opacity!=0&&Pa(B,u,n,0,1,2,O,ca,$)}}}else if(O instanceof THREE.RenderableFace4){B=O.v1;u=O.v2;n=O.v3;Y=O.v4;B.positionScreen.x*=g;B.positionScreen.y*=i;u.positionScreen.x*=g;u.positionScreen.y*=
-i;n.positionScreen.x*=g;n.positionScreen.y*=i;Y.positionScreen.x*=g;Y.positionScreen.y*=i;Z.positionScreen.copy(u.positionScreen);aa.positionScreen.copy(Y.positionScreen);if(O.overdraw){za(B.positionScreen,u.positionScreen);za(u.positionScreen,Y.positionScreen);za(Y.positionScreen,B.positionScreen);za(n.positionScreen,Z.positionScreen);za(n.positionScreen,aa.positionScreen)}ea.addPoint(B.positionScreen.x,B.positionScreen.y);ea.addPoint(u.positionScreen.x,u.positionScreen.y);ea.addPoint(n.positionScreen.x,
-n.positionScreen.y);ea.addPoint(Y.positionScreen.x,Y.positionScreen.y);if(Ba.instersects(ea)){oa=0;for(Aa=O.meshMaterials.length;oa<Aa;){ca=O.meshMaterials[oa++];if(ca instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=O.faceMaterials.length;Ga<Ta;)(ca=O.faceMaterials[Ga++])&&ca.opacity!=0&&Za(B,u,n,Y,Z,aa,O,ca,$)}else ca.opacity!=0&&Za(B,u,n,Y,Z,aa,O,ca,$)}}}ka.addRectangle(ea)}j.setTransform(1,0,0,1,0,0)}};
+THREE.Projector=function(){function a(){var w=g[k]=g[k]||new THREE.RenderableVertex;k++;return w}function b(w,u){return u.z-w.z}function c(w,u){var H=0,M=1,P=w.z+w.w,I=u.z+u.w,E=-w.z+w.w,O=-u.z+u.w;if(P>=0&&I>=0&&E>=0&&O>=0)return!0;else if(P<0&&I<0||E<0&&O<0)return!1;else{if(P<0)H=Math.max(H,P/(P-I));else I<0&&(M=Math.min(M,P/(P-I)));if(E<0)H=Math.max(H,E/(E-O));else O<0&&(M=Math.min(M,E/(E-O)));if(M<H)return!1;else{w.lerpSelf(u,H);u.lerpSelf(w,1-M);return!0}}}var d,e,h=[],f,k,g=[],i,n,j=[],p,r=
+[],y,A,D=[],z,T,U=[],X=new THREE.Vector4,s=new THREE.Vector4,o=new THREE.Matrix4,L=new THREE.Matrix4,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],aa=new THREE.Vector4,ba=new THREE.Vector4;this.projectVector=function(w,u){o.multiply(u.projectionMatrix,u.matrixWorldInverse);o.multiplyVector3(w);return w};this.unprojectVector=function(w,u){o.multiply(u.matrixWorld,THREE.Matrix4.makeInvert(u.projectionMatrix));o.multiplyVector3(w);return w};
+this.projectObjects=function(w,u,H){u=[];var M,P,I;e=0;P=w.objects;w=0;for(M=P.length;w<M;w++){I=P[w];var E;if(!(E=!I.visible))if(E=I instanceof THREE.Mesh){a:{E=void 0;for(var O=I.matrixWorld,S=-I.geometry.boundingSphere.radius*Math.max(I.scale.x,Math.max(I.scale.y,I.scale.z)),V=0;V<6;V++){E=R[V].x*O.n14+R[V].y*O.n24+R[V].z*O.n34+R[V].w;if(E<=S){E=!1;break a}}E=!0}E=!E}if(!E){E=h[e]=h[e]||new THREE.RenderableObject;e++;d=E;X.copy(I.position);o.multiplyVector3(X);d.object=I;d.z=X.z;u.push(d)}}H&&
+u.sort(b);return u};this.projectScene=function(w,u,H){var M=[],P=u.near,I=u.far,E,O,S,V,F,Y,B,Q,K,C,Z,ia,ma,ja,ca,Da,wa;T=A=p=n=0;u.matrixAutoUpdate&&u.update(undefined,!0);w.update(undefined,!1,u);o.multiply(u.projectionMatrix,u.matrixWorldInverse);R[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);R[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);R[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);R[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);R[4].set(o.n41-o.n31,
+o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);R[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(E=0;E<6;E++){K=R[E];K.divideScalar(Math.sqrt(K.x*K.x+K.y*K.y+K.z*K.z))}K=this.projectObjects(w,u,!0);w=0;for(E=K.length;w<E;w++){C=K[w].object;if(C.visible){Z=C.matrixWorld;ia=C.matrixRotationWorld;ma=C.materials;ja=C.overdraw;k=0;if(C instanceof THREE.Mesh){ca=C.geometry;V=ca.vertices;Da=ca.faces;ca=ca.faceVertexUvs;O=0;for(S=V.length;O<S;O++){f=a();f.positionWorld.copy(V[O].position);Z.multiplyVector3(f.positionWorld);
+f.positionScreen.copy(f.positionWorld);o.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>P&&f.positionScreen.z<I}V=0;for(O=Da.length;V<O;V++){S=Da[V];if(S instanceof THREE.Face3){F=g[S.a];Y=g[S.b];B=g[S.c];if(F.visible&&Y.visible&&B.visible&&(C.doubleSided||C.flipSided!=(B.positionScreen.x-F.positionScreen.x)*(Y.positionScreen.y-F.positionScreen.y)-(B.positionScreen.y-F.positionScreen.y)*(Y.positionScreen.x-
+F.positionScreen.x)<0)){Q=j[n]=j[n]||new THREE.RenderableFace3;n++;i=Q;i.v1.copy(F);i.v2.copy(Y);i.v3.copy(B)}else continue}else if(S instanceof THREE.Face4){F=g[S.a];Y=g[S.b];B=g[S.c];Q=g[S.d];if(F.visible&&Y.visible&&B.visible&&Q.visible&&(C.doubleSided||C.flipSided!=((Q.positionScreen.x-F.positionScreen.x)*(Y.positionScreen.y-F.positionScreen.y)-(Q.positionScreen.y-F.positionScreen.y)*(Y.positionScreen.x-F.positionScreen.x)<0||(Y.positionScreen.x-B.positionScreen.x)*(Q.positionScreen.y-B.positionScreen.y)-
+(Y.positionScreen.y-B.positionScreen.y)*(Q.positionScreen.x-B.positionScreen.x)<0))){wa=r[p]=r[p]||new THREE.RenderableFace4;p++;i=wa;i.v1.copy(F);i.v2.copy(Y);i.v3.copy(B);i.v4.copy(Q)}else continue}i.normalWorld.copy(S.normal);ia.multiplyVector3(i.normalWorld);i.centroidWorld.copy(S.centroid);Z.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);B=S.vertexNormals;F=0;for(Y=B.length;F<Y;F++){Q=i.vertexNormalsWorld[F];Q.copy(B[F]);ia.multiplyVector3(Q)}F=
+0;for(Y=ca.length;F<Y;F++)if(wa=ca[F][V]){B=0;for(Q=wa.length;B<Q;B++)i.uvs[F][B]=wa[B]}i.meshMaterials=ma;i.faceMaterials=S.materials;i.overdraw=ja;i.z=i.centroidScreen.z;M.push(i)}}else if(C instanceof THREE.Line){L.multiply(o,Z);V=C.geometry.vertices;F=a();F.positionScreen.copy(V[0].position);L.multiplyVector4(F.positionScreen);O=1;for(S=V.length;O<S;O++){F=a();F.positionScreen.copy(V[O].position);L.multiplyVector4(F.positionScreen);Y=g[k-2];aa.copy(F.positionScreen);ba.copy(Y.positionScreen);
+if(c(aa,ba)){aa.multiplyScalar(1/aa.w);ba.multiplyScalar(1/ba.w);Z=D[A]=D[A]||new THREE.RenderableLine;A++;y=Z;y.v1.positionScreen.copy(aa);y.v2.positionScreen.copy(ba);y.z=Math.max(aa.z,ba.z);y.materials=C.materials;M.push(y)}}}else if(C instanceof THREE.Particle){s.set(C.position.x,C.position.y,C.position.z,1);o.multiplyVector4(s);s.z/=s.w;if(s.z>0&&s.z<1){Z=U[T]=U[T]||new THREE.RenderableParticle;T++;z=Z;z.x=s.x/s.w;z.y=s.y/s.w;z.z=s.z;z.rotation=C.rotation.z;z.scale.x=C.scale.x*Math.abs(z.x-(s.x+
+u.projectionMatrix.n11)/(s.w+u.projectionMatrix.n14));z.scale.y=C.scale.y*Math.abs(z.y-(s.y+u.projectionMatrix.n22)/(s.w+u.projectionMatrix.n24));z.materials=C.materials;M.push(z)}}}}H&&M.sort(b);return M}};
+THREE.CanvasRenderer=function(){function a($){if(y!=$)j.globalAlpha=y=$}function b($){if(A!=$){switch($){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}A=$}}function c($){if(D!=$)j.strokeStyle=D=$}var d=this,e=null,h=new THREE.Projector,f=document.createElement("canvas"),k,g,i,n,j=f.getContext("2d"),p=new THREE.Color(0),r=0,y=1,A=0,D=null,
+z=null,T=null,U=null,X=null,s,o,L,R,aa=new THREE.RenderableVertex,ba=new THREE.RenderableVertex,w,u,H,M,P,I,E,O,S,V,F,Y,B=new THREE.Color,Q=new THREE.Color,K=new THREE.Color,C=new THREE.Color,Z=new THREE.Color,ia,ma,ja,ca,Da,wa,Wa,Xa,Ya,Za,Ba=new THREE.Rectangle,ka=new THREE.Rectangle,fa=new THREE.Rectangle,Ua=!1,ha=new THREE.Color,ga=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,da=new THREE.Vector3,Ha,Ia,Va,la,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");
+Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);la=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setSize=function($,na){k=$;g=na;i=k/2;n=g/2;f.width=k;f.height=g;Ba.set(-i,-n,i,n);y=1;A=0;X=U=T=z=D=null};this.setClearColor=function($,na){p=$;r=na};this.setClearColorHex=
+function($,na){p.setHex($);r=na};this.clear=function(){j.setTransform(1,0,0,-1,i,n);if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(Ba);if(p.hex==0&&r==0)j.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());else{b(THREE.NormalBlending);a(1);j.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+r+")";j.fillRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight())}ka.empty()}};this.render=function($,na){function bb(m){var x,t,q,J=m.lights;ga.setRGB(0,0,0);Ma.setRGB(0,
+0,0);Na.setRGB(0,0,0);m=0;for(x=J.length;m<x;m++){t=J[m];q=t.color;if(t instanceof THREE.AmbientLight){ga.r+=q.r;ga.g+=q.g;ga.b+=q.b}else if(t instanceof THREE.DirectionalLight){Ma.r+=q.r;Ma.g+=q.g;Ma.b+=q.b}else if(t instanceof THREE.PointLight){Na.r+=q.r;Na.g+=q.g;Na.b+=q.b}}}function ra(m,x,t,q){var J,G,v,l,W=m.lights;m=0;for(J=W.length;m<J;m++){G=W[m];v=G.color;if(G instanceof THREE.DirectionalLight){l=t.dot(G.position);if(!(l<=0)){l*=G.intensity;q.r+=v.r*l;q.g+=v.g*l;q.b+=v.b*l}}else if(G instanceof
+THREE.PointLight){l=t.dot(da.sub(G.position,x).normalize());if(!(l<=0)){l*=G.distance==0?1:1-Math.min(x.distanceTo(G.position)/G.distance,1);if(l!=0){l*=G.intensity;q.r+=v.r*l;q.g+=v.g*l;q.b+=v.b*l}}}}}function cb(m,x,t){a(t.opacity);b(t.blending);var q,J,G,v,l,W;if(t instanceof THREE.ParticleBasicMaterial){if(t.map){v=t.map.image;l=v.width>>1;W=v.height>>1;t=x.scale.x*i;G=x.scale.y*n;q=t*l;J=G*W;fa.set(m.x-q,m.y-J,m.x+q,m.y+J);if(Ba.instersects(fa)){j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);
+j.scale(t,-G);j.translate(-l,-W);j.drawImage(v,0,0);j.restore()}}}else if(t instanceof THREE.ParticleCanvasMaterial){q=x.scale.x*i;J=x.scale.y*n;fa.set(m.x-q,m.y-J,m.x+q,m.y+J);if(Ba.instersects(fa)){c(t.color.__styleString);G=t.color.__styleString;if(z!=G)j.fillStyle=z=G;j.save();j.translate(m.x,m.y);j.rotate(-x.rotation);j.scale(q,J);t.program(j);j.restore()}}}function db(m,x,t,q){a(q.opacity);b(q.blending);j.beginPath();j.moveTo(m.positionScreen.x,m.positionScreen.y);j.lineTo(x.positionScreen.x,
+x.positionScreen.y);j.closePath();if(q instanceof THREE.LineBasicMaterial){B.__styleString=q.color.__styleString;m=q.linewidth;if(T!=m)j.lineWidth=T=m;m=q.linecap;if(U!=m)j.lineCap=U=m;m=q.linejoin;if(X!=m)j.lineJoin=X=m;c(B.__styleString);j.stroke();fa.inflate(q.linewidth*2)}}function Pa(m,x,t,q,J,G,v,l,W){d.data.vertices+=3;d.data.faces++;a(l.opacity);b(l.blending);w=m.positionScreen.x;u=m.positionScreen.y;H=x.positionScreen.x;M=x.positionScreen.y;P=t.positionScreen.x;I=t.positionScreen.y;Ka(w,
+u,H,M,P,I);if(l instanceof THREE.MeshBasicMaterial)if(l.map){if(l.map.mapping instanceof THREE.UVMapping){ca=v.uvs[0];sa(w,u,H,M,P,I,l.map.image,ca[q].u,ca[q].v,ca[J].u,ca[J].v,ca[G].u,ca[G].v)}}else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=na.matrixWorldInverse;da.copy(v.vertexNormalsWorld[0]);Da=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+0.5;wa=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;da.copy(v.vertexNormalsWorld[1]);Wa=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+
+0.5;Xa=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;da.copy(v.vertexNormalsWorld[2]);Ya=(da.x*m.n11+da.y*m.n12+da.z*m.n13)*0.5+0.5;Za=-(da.x*m.n21+da.y*m.n22+da.z*m.n23)*0.5+0.5;sa(w,u,H,M,P,I,l.envMap.image,Da,wa,Wa,Xa,Ya,Za)}}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString);else if(l instanceof THREE.MeshLambertMaterial){if(l.map&&!l.wireframe){if(l.map.mapping instanceof THREE.UVMapping){ca=v.uvs[0];sa(w,u,H,M,P,I,l.map.image,
+ca[q].u,ca[q].v,ca[J].u,ca[J].v,ca[G].u,ca[G].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3){Q.r=K.r=C.r=ga.r;Q.g=K.g=C.g=ga.g;Q.b=K.b=C.b=ga.b;ra(W,v.v1.positionWorld,v.vertexNormalsWorld[0],Q);ra(W,v.v2.positionWorld,v.vertexNormalsWorld[1],K);ra(W,v.v3.positionWorld,v.vertexNormalsWorld[2],C);Z.r=(K.r+C.r)*0.5;Z.g=(K.g+C.g)*0.5;Z.b=(K.b+C.b)*0.5;ja=Qa(Q,K,C,Z);sa(w,u,H,M,P,I,ja,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;
+ra(W,v.centroidWorld,v.normalWorld,ha);B.r=l.color.r*ha.r;B.g=l.color.g*ha.g;B.b=l.color.b*ha.b;B.updateStyleString();l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){ia=na.near;ma=na.far;Q.r=Q.g=Q.b=1-Ca(m.positionScreen.z,ia,ma);K.r=K.g=K.b=1-Ca(x.positionScreen.z,
+ia,ma);C.r=C.g=C.b=1-Ca(t.positionScreen.z,ia,ma);Z.r=(K.r+C.r)*0.5;Z.g=(K.g+C.g)*0.5;Z.b=(K.b+C.b)*0.5;ja=Qa(Q,K,C,Z);sa(w,u,H,M,P,I,ja,0,0,1,0,0,1)}else if(l instanceof THREE.MeshNormalMaterial){B.r=Fa(v.normalWorld.x);B.g=Fa(v.normalWorld.y);B.b=Fa(v.normalWorld.z);B.updateStyleString();l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}}function $a(m,x,t,q,J,G,v,l,W){d.data.vertices+=4;d.data.faces++;a(l.opacity);b(l.blending);if(l.map||
+l.envMap){Pa(m,x,q,0,1,3,v,l,W);Pa(J,t,G,1,2,3,v,l,W)}else{w=m.positionScreen.x;u=m.positionScreen.y;H=x.positionScreen.x;M=x.positionScreen.y;P=t.positionScreen.x;I=t.positionScreen.y;E=q.positionScreen.x;O=q.positionScreen.y;S=J.positionScreen.x;V=J.positionScreen.y;F=G.positionScreen.x;Y=G.positionScreen.y;if(l instanceof THREE.MeshBasicMaterial){Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof
+THREE.MeshLambertMaterial)if(Ua)if(!l.wireframe&&l.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==4){Q.r=K.r=C.r=Z.r=ga.r;Q.g=K.g=C.g=Z.g=ga.g;Q.b=K.b=C.b=Z.b=ga.b;ra(W,v.v1.positionWorld,v.vertexNormalsWorld[0],Q);ra(W,v.v2.positionWorld,v.vertexNormalsWorld[1],K);ra(W,v.v4.positionWorld,v.vertexNormalsWorld[3],C);ra(W,v.v3.positionWorld,v.vertexNormalsWorld[2],Z);ja=Qa(Q,K,C,Z);Ka(w,u,H,M,E,O);sa(w,u,H,M,E,O,ja,0,0,1,0,0,1);Ka(S,V,P,I,F,Y);sa(S,V,P,I,F,Y,ja,1,0,1,1,0,1)}else{ha.r=ga.r;
+ha.g=ga.g;ha.b=ga.b;ra(W,v.centroidWorld,v.normalWorld,ha);B.r=l.color.r*ha.r;B.g=l.color.g*ha.g;B.b=l.color.b*ha.b;B.updateStyleString();Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else{Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(l.color.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(l.color.__styleString)}else if(l instanceof THREE.MeshNormalMaterial){B.r=Fa(v.normalWorld.x);B.g=Fa(v.normalWorld.y);
+B.b=Fa(v.normalWorld.z);B.updateStyleString();Ra(w,u,H,M,P,I,E,O);l.wireframe?xa(B.__styleString,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):ya(B.__styleString)}else if(l instanceof THREE.MeshDepthMaterial){ia=na.near;ma=na.far;Q.r=Q.g=Q.b=1-Ca(m.positionScreen.z,ia,ma);K.r=K.g=K.b=1-Ca(x.positionScreen.z,ia,ma);C.r=C.g=C.b=1-Ca(q.positionScreen.z,ia,ma);Z.r=Z.g=Z.b=1-Ca(t.positionScreen.z,ia,ma);ja=Qa(Q,K,C,Z);Ka(w,u,H,M,E,O);sa(w,u,H,M,E,O,ja,0,0,1,0,0,1);Ka(S,V,P,I,F,Y);sa(S,V,
+P,I,F,Y,ja,1,0,1,1,0,1)}}}function Ka(m,x,t,q,J,G){j.beginPath();j.moveTo(m,x);j.lineTo(t,q);j.lineTo(J,G);j.lineTo(m,x);j.closePath()}function Ra(m,x,t,q,J,G,v,l){j.beginPath();j.moveTo(m,x);j.lineTo(t,q);j.lineTo(J,G);j.lineTo(v,l);j.lineTo(m,x);j.closePath()}function xa(m,x,t,q){if(T!=x)j.lineWidth=T=x;if(U!=t)j.lineCap=U=t;if(X!=q)j.lineJoin=X=q;c(m);j.stroke();fa.inflate(x*2)}function ya(m){if(z!=m)j.fillStyle=z=m;j.fill()}function sa(m,x,t,q,J,G,v,l,W,ta,oa,ua,La){var qa,va;qa=v.width-1;va=
+v.height-1;l*=qa;W*=va;ta*=qa;oa*=va;ua*=qa;La*=va;t-=m;q-=x;J-=m;G-=x;ta-=l;oa-=W;ua-=l;La-=W;qa=ta*La-ua*oa;if(qa!=0){va=1/qa;qa=(La*t-oa*J)*va;oa=(La*q-oa*G)*va;t=(ta*J-ua*t)*va;q=(ta*G-ua*q)*va;m=m-qa*l-t*W;x=x-oa*l-q*W;j.save();j.transform(qa,oa,t,q,m,x);j.clip();j.drawImage(v,0,0);j.restore()}}function Qa(m,x,t,q){var J=~~(m.r*255),G=~~(m.g*255);m=~~(m.b*255);var v=~~(x.r*255),l=~~(x.g*255);x=~~(x.b*255);var W=~~(t.r*255),ta=~~(t.g*255);t=~~(t.b*255);var oa=~~(q.r*255),ua=~~(q.g*255);q=~~(q.b*
+255);la[0]=J<0?0:J>255?255:J;la[1]=G<0?0:G>255?255:G;la[2]=m<0?0:m>255?255:m;la[4]=v<0?0:v>255?255:v;la[5]=l<0?0:l>255?255:l;la[6]=x<0?0:x>255?255:x;la[8]=W<0?0:W>255?255:W;la[9]=ta<0?0:ta>255?255:ta;la[10]=t<0?0:t>255?255:t;la[12]=oa<0?0:oa>255?255:oa;la[13]=ua<0?0:ua>255?255:ua;la[14]=q<0?0:q>255?255:q;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Ca(m,x,t){m=(m-x)/(t-x);return m*m*(3-2*m)}function Fa(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function za(m,x){var t=x.x-m.x,q=x.y-m.y,
+J=1/Math.sqrt(t*t+q*q);t*=J;q*=J;x.x+=t;x.y+=q;m.x-=t;m.y-=q}var Sa,ab,N,pa,Aa,Ga,Ta,ea;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);d.data.vertices=0;d.data.faces=0;e=h.projectScene($,na,this.sortElements);(Ua=$.lights.length>0)&&bb($);Sa=0;for(ab=e.length;Sa<ab;Sa++){N=e[Sa];fa.empty();if(N instanceof THREE.RenderableParticle){s=N;s.x*=i;s.y*=n;pa=0;for(Aa=N.materials.length;pa<Aa;){ea=N.materials[pa++];ea.opacity!=0&&cb(s,N,ea,$)}}else if(N instanceof THREE.RenderableLine){s=N.v1;o=
+N.v2;s.positionScreen.x*=i;s.positionScreen.y*=n;o.positionScreen.x*=i;o.positionScreen.y*=n;fa.addPoint(s.positionScreen.x,s.positionScreen.y);fa.addPoint(o.positionScreen.x,o.positionScreen.y);if(Ba.instersects(fa)){pa=0;for(Aa=N.materials.length;pa<Aa;){ea=N.materials[pa++];ea.opacity!=0&&db(s,o,N,ea,$)}}}else if(N instanceof THREE.RenderableFace3){s=N.v1;o=N.v2;L=N.v3;s.positionScreen.x*=i;s.positionScreen.y*=n;o.positionScreen.x*=i;o.positionScreen.y*=n;L.positionScreen.x*=i;L.positionScreen.y*=
+n;if(N.overdraw){za(s.positionScreen,o.positionScreen);za(o.positionScreen,L.positionScreen);za(L.positionScreen,s.positionScreen)}fa.add3Points(s.positionScreen.x,s.positionScreen.y,o.positionScreen.x,o.positionScreen.y,L.positionScreen.x,L.positionScreen.y);if(Ba.instersects(fa)){pa=0;for(Aa=N.meshMaterials.length;pa<Aa;){ea=N.meshMaterials[pa++];if(ea instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=N.faceMaterials.length;Ga<Ta;)(ea=N.faceMaterials[Ga++])&&ea.opacity!=0&&Pa(s,o,L,0,1,2,N,ea,$)}else ea.opacity!=
+0&&Pa(s,o,L,0,1,2,N,ea,$)}}}else if(N instanceof THREE.RenderableFace4){s=N.v1;o=N.v2;L=N.v3;R=N.v4;s.positionScreen.x*=i;s.positionScreen.y*=n;o.positionScreen.x*=i;o.positionScreen.y*=n;L.positionScreen.x*=i;L.positionScreen.y*=n;R.positionScreen.x*=i;R.positionScreen.y*=n;aa.positionScreen.copy(o.positionScreen);ba.positionScreen.copy(R.positionScreen);if(N.overdraw){za(s.positionScreen,o.positionScreen);za(o.positionScreen,R.positionScreen);za(R.positionScreen,s.positionScreen);za(L.positionScreen,
+aa.positionScreen);za(L.positionScreen,ba.positionScreen)}fa.addPoint(s.positionScreen.x,s.positionScreen.y);fa.addPoint(o.positionScreen.x,o.positionScreen.y);fa.addPoint(L.positionScreen.x,L.positionScreen.y);fa.addPoint(R.positionScreen.x,R.positionScreen.y);if(Ba.instersects(fa)){pa=0;for(Aa=N.meshMaterials.length;pa<Aa;){ea=N.meshMaterials[pa++];if(ea instanceof THREE.MeshFaceMaterial){Ga=0;for(Ta=N.faceMaterials.length;Ga<Ta;)(ea=N.faceMaterials[Ga++])&&ea.opacity!=0&&$a(s,o,L,R,aa,ba,N,ea,
+$)}else ea.opacity!=0&&$a(s,o,L,R,aa,ba,N,ea,$)}}}ka.addRectangle(fa)}j.setTransform(1,0,0,1,0,0)}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};

+ 12 - 11
build/custom/ThreeDOM.js

@@ -8,7 +8,7 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var b=Math.cos(this.y);this.y=Math.asin(a.n13);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n12/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
@@ -41,20 +41,21 @@ THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,j,g,i;f=new THREE.Matrix4;j=b-a;g=c-d;i=h-e;f.n11=2/j;f.n12=0;f.n13=0;f.n14=-((b+a)/j);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((h+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
-THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
 undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
 b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,j=d*e;this.w=f*h-j*c;this.x=f*c+j*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*h+c*j-d*f;this.y=c*a+e*f+d*h-b*j;this.z=d*a+e*j+b*f-c*h;this.w=e*a-b*h-c*f-d*j;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,j=this.z,g=this.w,i=g*c+f*e-j*d,l=g*d+j*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-j*e;b.x=i*g+c*-h+l*-j-k*-f;b.y=l*g+c*-f+k*-h-i*-j;b.z=k*g+c*-j+i*-f-l*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,j=d*e;this.w=f*h-j*c;this.x=f*c+j*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
+a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},
+multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*h+c*j-d*f;this.y=c*a+e*f+d*h-b*j;this.z=d*a+e*j+b*f-c*h;this.w=e*a-b*h-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,j=this.z,g=this.w,i=g*c+f*e-j*d,l=
+g*d+j*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-j*e;b.x=i*g+c*-h+l*-j-k*-f;b.y=l*g+c*-f+k*-h-i*-j;b.z=k*g+c*-j+i*-f-l*-h;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
-THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
+THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
 THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
@@ -70,8 +71,8 @@ THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.proto
 THREE.Projector=function(){function a(){var u=g[j]=g[j]||new THREE.RenderableVertex;j++;return u}function b(u,s){return s.z-u.z}function c(u,s){var I=0,J=1,M=u.z+u.w,E=s.z+s.w,w=-u.z+u.w,z=-s.z+s.w;if(M>=0&&E>=0&&w>=0&&z>=0)return!0;else if(M<0&&E<0||w<0&&z<0)return!1;else{if(M<0)I=Math.max(I,M/(M-E));else E<0&&(J=Math.min(J,M/(M-E)));if(w<0)I=Math.max(I,w/(w-z));else z<0&&(J=Math.min(J,w/(w-z)));if(J<I)return!1;else{u.lerpSelf(s,I);s.lerpSelf(u,1-J);return!0}}}var d,e,h=[],f,j,g=[],i,l,k=[],m,n=
 [],p,q,t=[],r,C,G=[],K=new THREE.Vector4,x=new THREE.Vector4,o=new THREE.Matrix4,Q=new THREE.Matrix4,H=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(u,s){o.multiply(s.projectionMatrix,s.matrixWorldInverse);o.multiplyVector3(u);return u};this.unprojectVector=function(u,s){o.multiply(s.matrixWorld,THREE.Matrix4.makeInvert(s.projectionMatrix));o.multiplyVector3(u);return u};
 this.projectObjects=function(u,s,I){s=[];var J,M,E;e=0;M=u.objects;u=0;for(J=M.length;u<J;u++){E=M[u];var w;if(!(w=!E.visible))if(w=E instanceof THREE.Mesh){a:{w=void 0;for(var z=E.matrixWorld,A=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),D=0;D<6;D++){w=H[D].x*z.n14+H[D].y*z.n24+H[D].z*z.n34+H[D].w;if(w<=A){w=!1;break a}}w=!0}w=!w}if(!w){w=h[e]=h[e]||new THREE.RenderableObject;e++;d=w;K.copy(E.position);o.multiplyVector3(K);d.object=E;d.z=K.z;s.push(d)}}I&&
-s.sort(b);return s};this.projectScene=function(u,s,I){var J=[],M=s.near,E=s.far,w,z,A,D,v,F,B,L,P,y,R,U,W,X,S,V,T;C=q=m=l=0;s.matrixAutoUpdate&&s.updateMatrix();u.update(undefined,!1,s);o.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);H[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);H[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);H[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);H[4].set(o.n41-o.n31,o.n42-o.n32,
-o.n43-o.n33,o.n44-o.n34);H[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(w=0;w<6;w++){P=H[w];P.divideScalar(Math.sqrt(P.x*P.x+P.y*P.y+P.z*P.z))}P=this.projectObjects(u,s,!0);u=0;for(w=P.length;u<w;u++){y=P[u].object;if(y.visible){R=y.matrixWorld;U=y.matrixRotationWorld;W=y.materials;X=y.overdraw;j=0;if(y instanceof THREE.Mesh){S=y.geometry;D=S.vertices;V=S.faces;S=S.faceVertexUvs;z=0;for(A=D.length;z<A;z++){f=a();f.positionWorld.copy(D[z].position);R.multiplyVector3(f.positionWorld);
+s.sort(b);return s};this.projectScene=function(u,s,I){var J=[],M=s.near,E=s.far,w,z,A,D,v,F,B,L,P,y,R,U,W,X,S,V,T;C=q=m=l=0;s.matrixAutoUpdate&&s.update(undefined,!0);u.update(undefined,!1,s);o.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);H[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);H[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);H[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);H[4].set(o.n41-o.n31,o.n42-
+o.n32,o.n43-o.n33,o.n44-o.n34);H[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(w=0;w<6;w++){P=H[w];P.divideScalar(Math.sqrt(P.x*P.x+P.y*P.y+P.z*P.z))}P=this.projectObjects(u,s,!0);u=0;for(w=P.length;u<w;u++){y=P[u].object;if(y.visible){R=y.matrixWorld;U=y.matrixRotationWorld;W=y.materials;X=y.overdraw;j=0;if(y instanceof THREE.Mesh){S=y.geometry;D=S.vertices;V=S.faces;S=S.faceVertexUvs;z=0;for(A=D.length;z<A;z++){f=a();f.positionWorld.copy(D[z].position);R.multiplyVector3(f.positionWorld);
 f.positionScreen.copy(f.positionWorld);o.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>M&&f.positionScreen.z<E}D=0;for(z=V.length;D<z;D++){A=V[D];if(A instanceof THREE.Face3){v=g[A.a];F=g[A.b];B=g[A.c];if(v.visible&&F.visible&&B.visible&&(y.doubleSided||y.flipSided!=(B.positionScreen.x-v.positionScreen.x)*(F.positionScreen.y-v.positionScreen.y)-(B.positionScreen.y-v.positionScreen.y)*(F.positionScreen.x-
 v.positionScreen.x)<0)){L=k[l]=k[l]||new THREE.RenderableFace3;l++;i=L;i.v1.copy(v);i.v2.copy(F);i.v3.copy(B)}else continue}else if(A instanceof THREE.Face4){v=g[A.a];F=g[A.b];B=g[A.c];L=g[A.d];if(v.visible&&F.visible&&B.visible&&L.visible&&(y.doubleSided||y.flipSided!=((L.positionScreen.x-v.positionScreen.x)*(F.positionScreen.y-v.positionScreen.y)-(L.positionScreen.y-v.positionScreen.y)*(F.positionScreen.x-v.positionScreen.x)<0||(F.positionScreen.x-B.positionScreen.x)*(L.positionScreen.y-B.positionScreen.y)-
 (F.positionScreen.y-B.positionScreen.y)*(L.positionScreen.x-B.positionScreen.x)<0))){T=n[m]=n[m]||new THREE.RenderableFace4;m++;i=T;i.v1.copy(v);i.v2.copy(F);i.v3.copy(B);i.v4.copy(L)}else continue}i.normalWorld.copy(A.normal);U.multiplyVector3(i.normalWorld);i.centroidWorld.copy(A.centroid);R.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);B=A.vertexNormals;v=0;for(F=B.length;v<F;v++){L=i.vertexNormalsWorld[v];L.copy(B[v]);U.multiplyVector3(L)}v=

+ 34 - 34
build/custom/ThreeExtras.js

@@ -33,7 +33,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var d,b,e,c,f=2*Math.ceil(a*3)+1;f>25&&(f=25);c=(f-1)*0.5;b=Array(f);for(d=e=0;d<f;++d){b[d]=Math.exp(-((d-c)*(d-c))/(2*a*a));e+=b[d]}for(d=0;d<f;++d)b[d]/=e;return b}};
-THREE.QuakeCamera=function(a){function d(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=
+THREE.QuakeCamera=function(a){function d(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=
 a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=
 a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();
 b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=
@@ -42,16 +42,16 @@ this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0
 this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var e=this.target.position,c=this.position;e.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);e.y=c.y+100*Math.cos(this.phi);e.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-
 this.verticalMin)/3.14+this.verticalMin;e=this.target.position;c=this.position;e.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);e.y=c.y+100*Math.cos(this.phi);e.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",
 d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(a,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(a));this.target.position.addSelf(d.multiplyScalar(a))};
-THREE.PathCamera=function(a){function d(l,k,m,p){var o={name:m,fps:0.6,length:p,hierarchy:[]},x,w=k.getControlPointsArray(),u=k.getLength(),B=w.length,z=0;x=B-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:w[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[x]={time:p,pos:w[x],rot:[0,0,0,1],scl:[1,1,1]};for(x=1;x<B-1;x++){z=p*u.chunks[x]/u.total;k.keys[x]={time:z,pos:w[x]}}o.hierarchy[0]=k;THREE.AnimationHandler.add(o);return new THREE.Animation(l,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var m,
+THREE.PathCamera=function(a){function d(l,k,m,p){var o={name:m,fps:0.6,length:p,hierarchy:[]},x,w=k.getControlPointsArray(),u=k.getLength(),A=w.length,z=0;x=A-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:w[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[x]={time:p,pos:w[x],rot:[0,0,0,1],scl:[1,1,1]};for(x=1;x<A-1;x++){z=p*u.chunks[x]/u.total;k.keys[x]={time:z,pos:w[x]}}o.hierarchy[0]=k;THREE.AnimationHandler.add(o);return new THREE.Animation(l,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var m,
 p,o=new THREE.Geometry;for(m=0;m<l.points.length*k;m++){p=m/(l.points.length*k);p=l.getPoint(p);o.vertices[m]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return o}function e(l,k){var m=b(k,10),p=b(k,10),o=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(m,o);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);p=new Sphere(1,
-16,8);o=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){m=new THREE.Mesh(p,o);m.position.copy(k.points[i]);m.updateMatrix();l.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
+16,8);o=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){m=new THREE.Mesh(p,o);m.position.copy(k.points[i]);m.updateMatrix();l.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
 !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
 if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
 this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var c=Math.PI*2,f=Math.PI/180;this.update=function(l,k,m){var p,o;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;p=this.phi%c;this.phi=p>=0?p:p+c;p=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange;
 this.phi=(this.phi-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0];p=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,m)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
 d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(a){function d(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.tdiff=0;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==
+THREE.FlyCamera=function(a){function d(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.tdiff=0;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==
 undefined)this.autoForward=a.autoForward;if(a.domElement!==undefined)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=(new Date).getTime();this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=
 function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;
 break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=
@@ -61,17 +61,17 @@ b;b=this.tdiff*this.movementSpeed;var e=this.tdiff*this.rollSpeed;this.translate
 function(){var b=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=
 function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1);
 window.addEventListener("keyup",d(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
-THREE.Cube=function(a,d,b,e,c,f,g,h,j){function l(u,B,z,n,y,C,G,K){var J,I,E=e||1,L=c||1,P=y/2,Q=C/2,R=k.vertices.length;if(u=="x"&&B=="y"||u=="y"&&B=="x")J="z";else if(u=="x"&&B=="z"||u=="z"&&B=="x"){J="y";L=f||1}else if(u=="z"&&B=="y"||u=="y"&&B=="z"){J="x";E=f||1}var M=E+1,F=L+1;y/=E;var N=C/L;for(I=0;I<F;I++)for(C=0;C<M;C++){var O=new THREE.Vector3;O[u]=(C*y-P)*z;O[B]=(I*N-Q)*n;O[J]=G;k.vertices.push(new THREE.Vertex(O))}for(I=0;I<L;I++)for(C=0;C<E;C++){k.faces.push(new THREE.Face4(C+M*I+R,C+
-M*(I+1)+R,C+1+M*(I+1)+R,C+1+M*I+R,null,null,K));k.faceVertexUvs[0].push([new THREE.UV(C/E,I/L),new THREE.UV(C/E,(I+1)/L),new THREE.UV((C+1)/E,(I+1)/L),new THREE.UV((C+1)/E,I/L)])}}THREE.Geometry.call(this);var k=this,m=a/2,p=d/2,o=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var x=0;x<6;x++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var w in j)this.sides[w]!=undefined&&(this.sides[w]=
-j[w]);this.sides.px&&l("z","y",1*h,-1,b,d,-m,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,d,m,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,d,o,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,d,-o,this.materials[5]);(function(){for(var u=[],B=[],z=0,n=k.vertices.length;z<n;z++){for(var y=k.vertices[z],C=!1,G=0,K=u.length;G<K;G++){var J=u[G];if(y.position.x==J.position.x&&
-y.position.y==J.position.y&&y.position.z==J.position.z){B[z]=G;C=!0;break}}if(!C){B[z]=u.length;u.push(new THREE.Vertex(y.position.clone()))}}z=0;for(n=k.faces.length;z<n;z++){y=k.faces[z];y.a=B[y.a];y.b=B[y.b];y.c=B[y.c];y.d=B[y.d]}k.vertices=u})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
+THREE.Cube=function(a,d,b,e,c,f,g,h,j){function l(u,A,z,n,y,B,G,K){var J,H,E=e||1,L=c||1,P=y/2,Q=B/2,R=k.vertices.length;if(u=="x"&&A=="y"||u=="y"&&A=="x")J="z";else if(u=="x"&&A=="z"||u=="z"&&A=="x"){J="y";L=f||1}else if(u=="z"&&A=="y"||u=="y"&&A=="z"){J="x";E=f||1}var M=E+1,F=L+1;y/=E;var N=B/L;for(H=0;H<F;H++)for(B=0;B<M;B++){var O=new THREE.Vector3;O[u]=(B*y-P)*z;O[A]=(H*N-Q)*n;O[J]=G;k.vertices.push(new THREE.Vertex(O))}for(H=0;H<L;H++)for(B=0;B<E;B++){k.faces.push(new THREE.Face4(B+M*H+R,B+
+M*(H+1)+R,B+1+M*(H+1)+R,B+1+M*H+R,null,null,K));k.faceVertexUvs[0].push([new THREE.UV(B/E,H/L),new THREE.UV(B/E,(H+1)/L),new THREE.UV((B+1)/E,(H+1)/L),new THREE.UV((B+1)/E,H/L)])}}THREE.Geometry.call(this);var k=this,m=a/2,p=d/2,o=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var x=0;x<6;x++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var w in j)this.sides[w]!=undefined&&(this.sides[w]=
+j[w]);this.sides.px&&l("z","y",1*h,-1,b,d,-m,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,d,m,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,d,o,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,d,-o,this.materials[5]);(function(){for(var u=[],A=[],z=0,n=k.vertices.length;z<n;z++){for(var y=k.vertices[z],B=!1,G=0,K=u.length;G<K;G++){var J=u[G];if(y.position.x==J.position.x&&
+y.position.y==J.position.y&&y.position.z==J.position.z){A[z]=G;B=!0;break}}if(!B){A[z]=u.length;u.push(new THREE.Vertex(y.position.clone()))}}z=0;for(n=k.faces.length;z<n;z++){y=k.faces[z];y.a=A[y.a];y.b=A[y.b];y.c=A[y.c];y.d=A[y.d]}k.vertices=u})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
 THREE.Cylinder=function(a,d,b,e,c,f){function g(p,o,x){h.vertices.push(new THREE.Vertex(new THREE.Vector3(p,o,x)))}THREE.Geometry.call(this);var h=this,j,l=Math.PI*2,k=e/2;for(j=0;j<a;j++)g(Math.sin(l*j/a)*d,Math.cos(l*j/a)*d,-k);for(j=0;j<a;j++)g(Math.sin(l*j/a)*b,Math.cos(l*j/a)*b,k);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(b>0){g(0,0,-k-(f||0));for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(d>0){g(0,0,k+(c||0));
 for(j=a+a/2;j<2*a;j++)h.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j<a;j++){d=[];b=this.faces[j];c=this.vertices[b.a];f=this.vertices[b.b];k=this.vertices[b.c];var m=this.vertices[b.d];d.push(new THREE.UV(0.5+Math.atan2(c.position.x,c.position.y)/l,0.5+c.position.z/e));d.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/l,0.5+f.position.z/e));d.push(new THREE.UV(0.5+Math.atan2(k.position.x,k.position.y)/l,0.5+k.position.z/
 e));b instanceof THREE.Face4&&d.push(new THREE.UV(0.5+Math.atan2(m.position.x,m.position.y)/l,0.5+m.position.z/e));this.faceVertexUvs[0].push(d)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
 THREE.Icosahedron=function(a){function d(m,p,o){var x=Math.sqrt(m*m+p*p+o*o);return c.vertices.push(new THREE.Vertex(new THREE.Vector3(m/x,p/x,o/x)))-1}function b(m,p,o,x){x.faces.push(new THREE.Face3(m,p,o))}function e(m,p){var o=c.vertices[m].position,x=c.vertices[p].position;return d((o.x+x.x)/2,(o.y+x.y)/2,(o.z+x.z)/2)}var c=this,f=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;d(-1,a,0);d(1,a,0);d(-1,-a,0);d(1,-a,0);d(0,-1,a);d(0,1,a);d(0,-1,-a);d(0,
 1,-a);d(a,0,-1);d(a,0,1);d(-a,0,-1);d(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in f.faces){var j=e(f.faces[h].a,f.faces[h].b),l=e(f.faces[h].b,f.faces[h].c),k=e(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,j,k,g);b(f.faces[h].b,l,j,g);b(f.faces[h].c,
 k,l,g);b(j,l,k,g)}f.faces=g.faces}c.faces=f.faces;delete f;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
-THREE.Lathe=function(a,d,b){THREE.Geometry.call(this);this.steps=d||12;this.angle=b||2*Math.PI;d=this.angle/this.steps;b=[];for(var e=[],c=[],f=[],g=(new THREE.Matrix4).setRotationZ(d),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.0010;j+=d){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));c[h]=this.vertices.length-1}else c=f;j==0&&(f=e);
+THREE.Lathe=function(a,d,b){THREE.Geometry.call(this);this.steps=d||12;this.angle=b||2*Math.PI;d=this.angle/this.steps;b=[];for(var e=[],c=[],f=[],g=(new THREE.Matrix4).setRotationZ(d),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.001;j+=d){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));c[h]=this.vertices.length-1}else c=f;j==0&&(f=e);
 for(h=0;h<e.length-1;h++){this.faces.push(new THREE.Face4(c[h],c[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,h/a.length),new THREE.UV(1-j/this.angle,(h+1)/a.length),new THREE.UV(1-(j-d)/this.angle,(h+1)/a.length),new THREE.UV(1-(j-d)/this.angle,h/a.length)])}e=c;c=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
 THREE.Plane=function(a,d,b,e){THREE.Geometry.call(this);var c,f=a/2,g=d/2;b=b||1;e=e||1;var h=b+1,j=e+1;a/=b;var l=d/e;for(c=0;c<j;c++)for(d=0;d<h;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*a-f,-(c*l-g),0)));for(c=0;c<e;c++)for(d=0;d<b;d++){this.faces.push(new THREE.Face4(d+h*c,d+h*(c+1),d+1+h*(c+1),d+1+h*c));this.faceVertexUvs[0].push([new THREE.UV(d/b,c/e),new THREE.UV(d/b,(c+1)/e),new THREE.UV((d+1)/b,(c+1)/e),new THREE.UV((d+1)/b,c/e)])}this.computeCentroids();this.computeFaceNormals()};
 THREE.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
@@ -90,47 +90,47 @@ Math.LN2));h.image.width=k;h.image.height=m;h.image.getContext("2d").drawImage(t
 "Multiply")f.blending=THREE.MultiplyBlending;if(a.transparent!==undefined)f.transparent=a.transparent;if(a.depthTest!==undefined)f.depthTest=a.depthTest;if(a.vertexColors!==undefined)if(a.vertexColors=="face")f.vertexColors=THREE.FaceColors;else if(a.vertexColors)f.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&d){g=document.createElement("canvas");f.map=new THREE.Texture(g);f.map.sourceFile=a.mapDiffuse;e(f.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*
 255<<8)+a.colorDiffuse[2]*255;f.color=g;f.opacity=a.transparency}else if(a.DbgColor)f.color=a.DbgColor;if(a.mapLightmap&&d){g=document.createElement("canvas");f.lightMap=new THREE.Texture(g);f.lightMap.sourceFile=a.mapLightmap;e(f.lightMap,d+"/"+a.mapLightmap)}return new THREE[c](f)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(a){var d=this,b=a.model,e=a.callback,c=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(f){d.createModel(f.data,e,c);d.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(a,d,b){var e=new THREE.Geometry;this.init_materials(e,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var c,f,g,h,j,l,k,m,p,o,x,w,u,B,z,n=a.faces;o=a.vertices;var y=a.normals,C=a.colors;l=a.scale!==undefined?a.scale:1;var G=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&G++;for(c=0;c<G;c++){e.faceUvs[c]=[];e.faceVertexUvs[c]=[]}h=0;for(j=o.length;h<j;){k=new THREE.Vertex;k.position.x=o[h++]/
-l;k.position.y=o[h++]/l;k.position.z=o[h++]/l;e.vertices.push(k)}h=0;for(j=n.length;h<j;){o=n[h++];l=o&1;g=o&2;c=o&4;f=o&8;m=o&16;k=o&32;x=o&64;o&=128;if(l){w=new THREE.Face4;w.a=n[h++];w.b=n[h++];w.c=n[h++];w.d=n[h++];l=4}else{w=new THREE.Face3;w.a=n[h++];w.b=n[h++];w.c=n[h++];l=3}if(g){g=n[h++];w.materials=e.materials[g]}g=e.faces.length;if(c)for(c=0;c<G;c++){u=a.uvs[c];p=n[h++];z=u[p*2];p=u[p*2+1];e.faceUvs[c][g]=new THREE.UV(z,p)}if(f)for(c=0;c<G;c++){u=a.uvs[c];B=[];for(f=0;f<l;f++){p=n[h++];
-z=u[p*2];p=u[p*2+1];B[f]=new THREE.UV(z,p)}e.faceVertexUvs[c][g]=B}if(m){m=n[h++]*3;f=new THREE.Vector3;f.x=y[m++];f.y=y[m++];f.z=y[m];w.normal=f}if(k)for(c=0;c<l;c++){m=n[h++]*3;f=new THREE.Vector3;f.x=y[m++];f.y=y[m++];f.z=y[m];w.vertexNormals.push(f)}if(x){k=n[h++];k=new THREE.Color(C[k]);w.color=k}if(o)for(c=0;c<l;c++){k=n[h++];k=new THREE.Color(C[k]);w.vertexColors.push(k)}e.faces.push(w)}}})();(function(){var c,f,g,h;if(a.skinWeights){c=0;for(f=a.skinWeights.length;c<f;c+=2){g=a.skinWeights[c];
+THREE.JSONLoader.prototype.createModel=function(a,d,b){var e=new THREE.Geometry;this.init_materials(e,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var c,f,g,h,j,l,k,m,p,o,x,w,u,A,z,n=a.faces;o=a.vertices;var y=a.normals,B=a.colors;l=a.scale!==undefined?a.scale:1;var G=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&G++;for(c=0;c<G;c++){e.faceUvs[c]=[];e.faceVertexUvs[c]=[]}h=0;for(j=o.length;h<j;){k=new THREE.Vertex;k.position.x=o[h++]/
+l;k.position.y=o[h++]/l;k.position.z=o[h++]/l;e.vertices.push(k)}h=0;for(j=n.length;h<j;){o=n[h++];l=o&1;g=o&2;c=o&4;f=o&8;m=o&16;k=o&32;x=o&64;o&=128;if(l){w=new THREE.Face4;w.a=n[h++];w.b=n[h++];w.c=n[h++];w.d=n[h++];l=4}else{w=new THREE.Face3;w.a=n[h++];w.b=n[h++];w.c=n[h++];l=3}if(g){g=n[h++];w.materials=e.materials[g]}g=e.faces.length;if(c)for(c=0;c<G;c++){u=a.uvs[c];p=n[h++];z=u[p*2];p=u[p*2+1];e.faceUvs[c][g]=new THREE.UV(z,p)}if(f)for(c=0;c<G;c++){u=a.uvs[c];A=[];for(f=0;f<l;f++){p=n[h++];
+z=u[p*2];p=u[p*2+1];A[f]=new THREE.UV(z,p)}e.faceVertexUvs[c][g]=A}if(m){m=n[h++]*3;f=new THREE.Vector3;f.x=y[m++];f.y=y[m++];f.z=y[m];w.normal=f}if(k)for(c=0;c<l;c++){m=n[h++]*3;f=new THREE.Vector3;f.x=y[m++];f.y=y[m++];f.z=y[m];w.vertexNormals.push(f)}if(x){k=n[h++];k=new THREE.Color(B[k]);w.color=k}if(o)for(c=0;c<l;c++){k=n[h++];k=new THREE.Color(B[k]);w.vertexColors.push(k)}e.faces.push(w)}}})();(function(){var c,f,g,h;if(a.skinWeights){c=0;for(f=a.skinWeights.length;c<f;c+=2){g=a.skinWeights[c];
 h=a.skinWeights[c+1];e.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){c=0;for(f=a.skinIndices.length;c<f;c+=2){g=a.skinIndices[c];h=a.skinIndices[c+1];e.skinIndices.push(new THREE.Vector4(g,h,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var c,f,g,h,j,l;c=0;for(f=a.morphTargets.length;c<f;c++){e.morphTargets[c]={};e.morphTargets[c].name=a.morphTargets[c].name;e.morphTargets[c].vertices=[];j=e.morphTargets[c].vertices;l=a.morphTargets[c].vertices;
 g=0;for(h=l.length;g<h;g+=3)j.push(new THREE.Vertex(new THREE.Vector3(l[g],l[g+1],l[g+2])))}}if(a.morphColors!==undefined){var k,m;c=0;for(f=a.morphColors.length;c<f;c++){e.morphColors[c]={};e.morphColors[c].name=a.morphColors[c].name;e.morphColors[c].colors=[];l=e.morphColors[c].colors;k=a.morphColors[c].colors;h=0;for(j=k.length;h<j;h+=3){m=new THREE.Color(16755200);m.setRGB(k[g],k[g+1],k[g+2]);l.push(m)}}}})();(function(){if(a.edges!==undefined){var c,f,g;for(c=0;c<a.edges.length;c+=2){f=a.edges[c];
 g=a.edges[c+1];e.edges.push(new THREE.Edge(e.vertices[f],e.vertices[g],f,g))}}})();e.computeCentroids();e.computeFaceNormals();e.computeEdgeFaces();d(e)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(a){var d=a.model,b=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(d),c=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(d);a=(new Date).getTime();d=new Worker(d);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;d.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,c,e,f)};d.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
 d.postMessage(a)},loadAjaxBuffers:function(a,d,b,e,c,f){var g=new XMLHttpRequest,h=e+"/"+a,j=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,c,d):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(f){j==0&&(j=g.getResponseHeader("Content-Length"));f({total:j,loaded:g.responseText.length})}}else g.readyState==2&&(j=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
-g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,d,b,e){var c=function(f){function g(t,v){var A=k(t,v),D=k(t,v+1),H=k(t,v+2),S=k(t,v+3),V=(S<<1&255|H>>7)-127;A|=(H&127)<<16|D<<8;if(A==0&&V==-127)return 0;return(1-2*(S>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,V)}function h(t,v){var A=k(t,v),D=k(t,v+1),H=k(t,v+2);return(k(t,v+3)<<24)+(H<<16)+(D<<8)+A}function j(t,v){var A=k(t,v);return(k(t,v+1)<<8)+A}function l(t,v){var A=k(t,v);return A>127?A-256:A}function k(t,
-v){return t.charCodeAt(v)&255}function m(t){var v,A,D;v=h(a,t);A=h(a,t+G);D=h(a,t+K);t=j(a,t+J);THREE.BinaryLoader.prototype.f3(B,v,A,D,t)}function p(t){var v,A,D,H,S,V;v=h(a,t);A=h(a,t+G);D=h(a,t+K);H=j(a,t+J);S=h(a,t+I);V=h(a,t+E);t=h(a,t+L);THREE.BinaryLoader.prototype.f3n(B,y,v,A,D,H,S,V,t)}function o(t){var v,A,D,H;v=h(a,t);A=h(a,t+P);D=h(a,t+Q);H=h(a,t+R);t=j(a,t+M);THREE.BinaryLoader.prototype.f4(B,v,A,D,H,t)}function x(t){var v,A,D,H,S,V,ca,da;v=h(a,t);A=h(a,t+P);D=h(a,t+Q);H=h(a,t+R);S=j(a,
-t+M);V=h(a,t+F);ca=h(a,t+N);da=h(a,t+O);t=h(a,t+T);THREE.BinaryLoader.prototype.f4n(B,y,v,A,D,H,S,V,ca,da,t)}function w(t){var v,A;v=h(a,t);A=h(a,t+U);t=h(a,t+X);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[t*2],C[t*2+1])}function u(t){var v,A,D;v=h(a,t);A=h(a,t+ea);D=h(a,t+fa);t=h(a,t+ga);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[D*2],C[D*2+1],C[t*2],C[t*2+1])}var B=this,z=0,n,y=[],C=[],G,K,J,I,E,L,P,Q,R,M,F,N,O,
-T,U,X,ea,fa,ga,Y,Z,$,aa,ba,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,e,f);n={signature:a.substr(z,8),header_bytes:k(a,z+8),vertex_coordinate_bytes:k(a,z+9),normal_coordinate_bytes:k(a,z+10),uv_coordinate_bytes:k(a,z+11),vertex_index_bytes:k(a,z+12),normal_index_bytes:k(a,z+13),uv_index_bytes:k(a,z+14),material_index_bytes:k(a,z+15),nvertices:h(a,z+16),nnormals:h(a,z+16+4),nuvs:h(a,z+16+8),ntri_flat:h(a,z+16+12),ntri_smooth:h(a,z+16+16),ntri_flat_uv:h(a,z+16+20),ntri_smooth_uv:h(a,
-z+16+24),nquad_flat:h(a,z+16+28),nquad_smooth:h(a,z+16+32),nquad_flat_uv:h(a,z+16+36),nquad_smooth_uv:h(a,z+16+40)};z+=n.header_bytes;G=n.vertex_index_bytes;K=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;I=n.vertex_index_bytes*3+n.material_index_bytes;E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;Q=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;M=n.vertex_index_bytes*4;F=n.vertex_index_bytes*
+g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,d,b,e){var c=function(f){function g(t,v){var C=k(t,v),D=k(t,v+1),I=k(t,v+2),S=k(t,v+3),V=(S<<1&255|I>>7)-127;C|=(I&127)<<16|D<<8;if(C==0&&V==-127)return 0;return(1-2*(S>>7))*(1+C*Math.pow(2,-23))*Math.pow(2,V)}function h(t,v){var C=k(t,v),D=k(t,v+1),I=k(t,v+2);return(k(t,v+3)<<24)+(I<<16)+(D<<8)+C}function j(t,v){var C=k(t,v);return(k(t,v+1)<<8)+C}function l(t,v){var C=k(t,v);return C>127?C-256:C}function k(t,
+v){return t.charCodeAt(v)&255}function m(t){var v,C,D;v=h(a,t);C=h(a,t+G);D=h(a,t+K);t=j(a,t+J);THREE.BinaryLoader.prototype.f3(A,v,C,D,t)}function p(t){var v,C,D,I,S,V;v=h(a,t);C=h(a,t+G);D=h(a,t+K);I=j(a,t+J);S=h(a,t+H);V=h(a,t+E);t=h(a,t+L);THREE.BinaryLoader.prototype.f3n(A,y,v,C,D,I,S,V,t)}function o(t){var v,C,D,I;v=h(a,t);C=h(a,t+P);D=h(a,t+Q);I=h(a,t+R);t=j(a,t+M);THREE.BinaryLoader.prototype.f4(A,v,C,D,I,t)}function x(t){var v,C,D,I,S,V,ca,da;v=h(a,t);C=h(a,t+P);D=h(a,t+Q);I=h(a,t+R);S=j(a,
+t+M);V=h(a,t+F);ca=h(a,t+N);da=h(a,t+O);t=h(a,t+T);THREE.BinaryLoader.prototype.f4n(A,y,v,C,D,I,S,V,ca,da,t)}function w(t){var v,C;v=h(a,t);C=h(a,t+U);t=h(a,t+X);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],B[v*2],B[v*2+1],B[C*2],B[C*2+1],B[t*2],B[t*2+1])}function u(t){var v,C,D;v=h(a,t);C=h(a,t+ea);D=h(a,t+fa);t=h(a,t+ga);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],B[v*2],B[v*2+1],B[C*2],B[C*2+1],B[D*2],B[D*2+1],B[t*2],B[t*2+1])}var A=this,z=0,n,y=[],B=[],G,K,J,H,E,L,P,Q,R,M,F,N,O,
+T,U,X,ea,fa,ga,Y,Z,$,aa,ba,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,e,f);n={signature:a.substr(z,8),header_bytes:k(a,z+8),vertex_coordinate_bytes:k(a,z+9),normal_coordinate_bytes:k(a,z+10),uv_coordinate_bytes:k(a,z+11),vertex_index_bytes:k(a,z+12),normal_index_bytes:k(a,z+13),uv_index_bytes:k(a,z+14),material_index_bytes:k(a,z+15),nvertices:h(a,z+16),nnormals:h(a,z+16+4),nuvs:h(a,z+16+8),ntri_flat:h(a,z+16+12),ntri_smooth:h(a,z+16+16),ntri_flat_uv:h(a,z+16+20),ntri_smooth_uv:h(a,
+z+16+24),nquad_flat:h(a,z+16+28),nquad_smooth:h(a,z+16+32),nquad_flat_uv:h(a,z+16+36),nquad_smooth_uv:h(a,z+16+40)};z+=n.header_bytes;G=n.vertex_index_bytes;K=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;H=n.vertex_index_bytes*3+n.material_index_bytes;E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;Q=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;M=n.vertex_index_bytes*4;F=n.vertex_index_bytes*
 4+n.material_index_bytes;N=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;O=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;U=n.uv_index_bytes;X=n.uv_index_bytes*2;ea=n.uv_index_bytes;fa=n.uv_index_bytes*2;ga=n.uv_index_bytes*3;f=n.vertex_index_bytes*3+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes;Y=n.ntri_flat*f;Z=n.ntri_smooth*(f+n.normal_index_bytes*3);$=n.ntri_flat_uv*
-(f+n.uv_index_bytes*3);aa=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);ba=n.nquad_flat*W;f=n.nquad_smooth*(W+n.normal_index_bytes*4);W=n.nquad_flat_uv*(W+n.uv_index_bytes*4);z+=function(t){for(var v,A,D,H=n.vertex_coordinate_bytes*3,S=t+n.nvertices*H;t<S;t+=H){v=g(a,t);A=g(a,t+n.vertex_coordinate_bytes);D=g(a,t+n.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(B,v,A,D)}return n.nvertices*H}(z);z+=function(t){for(var v,A,D,H=n.normal_coordinate_bytes*3,S=t+n.nnormals*H;t<
-S;t+=H){v=l(a,t);A=l(a,t+n.normal_coordinate_bytes);D=l(a,t+n.normal_coordinate_bytes*2);y.push(v/127,A/127,D/127)}return n.nnormals*H}(z);z+=function(t){for(var v,A,D=n.uv_coordinate_bytes*2,H=t+n.nuvs*D;t<H;t+=D){v=g(a,t);A=g(a,t+n.uv_coordinate_bytes);C.push(v,A)}return n.nuvs*D}(z);Y=z+Y;Z=Y+Z;$=Z+$;aa=$+aa;ba=aa+ba;f=ba+f;W=f+W;(function(t){var v,A=n.vertex_index_bytes*3+n.material_index_bytes,D=A+n.uv_index_bytes*3,H=t+n.ntri_flat_uv*D;for(v=t;v<H;v+=D){m(v);w(v+A)}return H-t})(Z);(function(t){var v,
-A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,D=A+n.uv_index_bytes*3,H=t+n.ntri_smooth_uv*D;for(v=t;v<H;v+=D){p(v);w(v+A)}return H-t})($);(function(t){var v,A=n.vertex_index_bytes*4+n.material_index_bytes,D=A+n.uv_index_bytes*4,H=t+n.nquad_flat_uv*D;for(v=t;v<H;v+=D){o(v);u(v+A)}return H-t})(f);(function(t){var v,A=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,D=A+n.uv_index_bytes*4,H=t+n.nquad_smooth_uv*D;for(v=t;v<H;v+=D){x(v);u(v+A)}return H-t})(W);
-(function(t){var v,A=n.vertex_index_bytes*3+n.material_index_bytes,D=t+n.ntri_flat*A;for(v=t;v<D;v+=A)m(v);return D-t})(z);(function(t){var v,A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,D=t+n.ntri_smooth*A;for(v=t;v<D;v+=A)p(v);return D-t})(Y);(function(t){var v,A=n.vertex_index_bytes*4+n.material_index_bytes,D=t+n.nquad_flat*A;for(v=t;v<D;v+=A)o(v);return D-t})(aa);(function(t){var v,A=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,D=t+n.nquad_smooth*
-A;for(v=t;v<D;v+=A)x(v);return D-t})(ba);this.computeCentroids();this.computeFaceNormals()};c.prototype=new THREE.Geometry;c.prototype.constructor=c;d(new c(b))},v:function(a,d,b,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(d,b,e)))},f3:function(a,d,b,e,c){a.faces.push(new THREE.Face3(d,b,e,null,null,a.materials[c]))},f4:function(a,d,b,e,c,f){a.faces.push(new THREE.Face4(d,b,e,c,null,null,a.materials[f]))},f3n:function(a,d,b,e,c,f,g,h,j){f=a.materials[f];var l=d[h*3],k=d[h*3+1];h=d[h*3+2];
+(f+n.uv_index_bytes*3);aa=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);ba=n.nquad_flat*W;f=n.nquad_smooth*(W+n.normal_index_bytes*4);W=n.nquad_flat_uv*(W+n.uv_index_bytes*4);z+=function(t){for(var v,C,D,I=n.vertex_coordinate_bytes*3,S=t+n.nvertices*I;t<S;t+=I){v=g(a,t);C=g(a,t+n.vertex_coordinate_bytes);D=g(a,t+n.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(A,v,C,D)}return n.nvertices*I}(z);z+=function(t){for(var v,C,D,I=n.normal_coordinate_bytes*3,S=t+n.nnormals*I;t<
+S;t+=I){v=l(a,t);C=l(a,t+n.normal_coordinate_bytes);D=l(a,t+n.normal_coordinate_bytes*2);y.push(v/127,C/127,D/127)}return n.nnormals*I}(z);z+=function(t){for(var v,C,D=n.uv_coordinate_bytes*2,I=t+n.nuvs*D;t<I;t+=D){v=g(a,t);C=g(a,t+n.uv_coordinate_bytes);B.push(v,C)}return n.nuvs*D}(z);Y=z+Y;Z=Y+Z;$=Z+$;aa=$+aa;ba=aa+ba;f=ba+f;W=f+W;(function(t){var v,C=n.vertex_index_bytes*3+n.material_index_bytes,D=C+n.uv_index_bytes*3,I=t+n.ntri_flat_uv*D;for(v=t;v<I;v+=D){m(v);w(v+C)}return I-t})(Z);(function(t){var v,
+C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,D=C+n.uv_index_bytes*3,I=t+n.ntri_smooth_uv*D;for(v=t;v<I;v+=D){p(v);w(v+C)}return I-t})($);(function(t){var v,C=n.vertex_index_bytes*4+n.material_index_bytes,D=C+n.uv_index_bytes*4,I=t+n.nquad_flat_uv*D;for(v=t;v<I;v+=D){o(v);u(v+C)}return I-t})(f);(function(t){var v,C=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,D=C+n.uv_index_bytes*4,I=t+n.nquad_smooth_uv*D;for(v=t;v<I;v+=D){x(v);u(v+C)}return I-t})(W);
+(function(t){var v,C=n.vertex_index_bytes*3+n.material_index_bytes,D=t+n.ntri_flat*C;for(v=t;v<D;v+=C)m(v);return D-t})(z);(function(t){var v,C=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,D=t+n.ntri_smooth*C;for(v=t;v<D;v+=C)p(v);return D-t})(Y);(function(t){var v,C=n.vertex_index_bytes*4+n.material_index_bytes,D=t+n.nquad_flat*C;for(v=t;v<D;v+=C)o(v);return D-t})(aa);(function(t){var v,C=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,D=t+n.nquad_smooth*
+C;for(v=t;v<D;v+=C)x(v);return D-t})(ba);this.computeCentroids();this.computeFaceNormals()};c.prototype=new THREE.Geometry;c.prototype.constructor=c;d(new c(b))},v:function(a,d,b,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(d,b,e)))},f3:function(a,d,b,e,c){a.faces.push(new THREE.Face3(d,b,e,null,null,a.materials[c]))},f4:function(a,d,b,e,c,f){a.faces.push(new THREE.Face4(d,b,e,c,null,null,a.materials[f]))},f3n:function(a,d,b,e,c,f,g,h,j){f=a.materials[f];var l=d[h*3],k=d[h*3+1];h=d[h*3+2];
 var m=d[j*3],p=d[j*3+1];j=d[j*3+2];a.faces.push(new THREE.Face3(b,e,c,[new THREE.Vector3(d[g*3],d[g*3+1],d[g*3+2]),new THREE.Vector3(l,k,h),new THREE.Vector3(m,p,j)],null,f))},f4n:function(a,d,b,e,c,f,g,h,j,l,k){g=a.materials[g];var m=d[j*3],p=d[j*3+1];j=d[j*3+2];var o=d[l*3],x=d[l*3+1];l=d[l*3+2];var w=d[k*3],u=d[k*3+1];k=d[k*3+2];a.faces.push(new THREE.Face4(b,e,c,f,[new THREE.Vector3(d[h*3],d[h*3+1],d[h*3+2]),new THREE.Vector3(m,p,j),new THREE.Vector3(o,x,l),new THREE.Vector3(w,u,k)],null,g))},
 uv3:function(a,d,b,e,c,f,g){var h=[];h.push(new THREE.UV(d,b));h.push(new THREE.UV(e,c));h.push(new THREE.UV(f,g));a.push(h)},uv4:function(a,d,b,e,c,f,g,h,j){var l=[];l.push(new THREE.UV(d,b));l.push(new THREE.UV(e,c));l.push(new THREE.UV(f,g));l.push(new THREE.UV(h,j));a.push(l)}};THREE.SceneLoader=function(){};
-THREE.SceneLoader.prototype={load:function(a,d,b,e){var c=new Worker(a);c.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);c.onmessage=function(g){function h(U,X){return X=="relativeToHTML"?U:f+"/"+U}function j(){for(o in E.objects)if(!F.objects[o]){z=E.objects[o];if(G=F.geometries[z.geometry]){I=[];for(T=0;T<z.materials.length;T++)I[T]=F.materials[z.materials[T]];n=z.position;r=z.rotation;q=z.quaternion;s=z.scale;q=0;I.length==0&&(I[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(G,
-I);object.position.set(n[0],n[1],n[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;F.scene.addObject(object);F.objects[o]=object;if(z.meshCollider){var U=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(U)}}}}function l(U){return function(X){F.geometries[U]=X;j();P-=1;k()}}function k(){e({total_models:R,total_textures:M,loaded_models:R-P,loaded_textures:M-
-Q},F);P==0&&Q==0&&b(F)}var m,p,o,x,w,u,B,z,n,y,C,G,K,J,I,E,L,P,Q,R,M,F;E=g.data;g=new THREE.BinaryLoader;L=new THREE.JSONLoader;Q=P=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(E.transform){var N=E.transform.position;y=E.transform.rotation;var O=E.transform.scale;N&&F.scene.position.set(N[0],N[1],N[2]);y&&F.scene.rotation.set(y[0],y[1],y[2]);O&&F.scene.scale.set(O[0],O[1],O[2]);(N||y||O)&&F.scene.updateMatrix()}N=function(){Q-=1;k()};
-for(w in E.cameras){y=E.cameras[w];if(y.type=="perspective")K=new THREE.Camera(y.fov,y.aspect,y.near,y.far);else if(y.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(y.left,y.right,y.top,y.bottom,y.near,y.far)}n=y.position;y=y.target;K.position.set(n[0],n[1],n[2]);K.target.position.set(y[0],y[1],y[2]);F.cameras[w]=K}for(x in E.lights){w=E.lights[x];K=w.color!==undefined?w.color:16777215;y=w.intensity!==undefined?w.intensity:1;if(w.type=="directional"){n=w.direction;light=
-new THREE.DirectionalLight(K,y);light.position.set(n[0],n[1],n[2]);light.position.normalize()}else if(w.type=="point"){n=w.position;light=new THREE.PointLight(K,y);light.position.set(n[0],n[1],n[2])}F.scene.addLight(light);F.lights[x]=light}for(u in E.fogs){x=E.fogs[u];if(x.type=="linear")J=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(J=new THREE.FogExp2(0,x.density));y=x.color;J.color.setRGB(y[0],y[1],y[2]);F.fogs[u]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];
+THREE.SceneLoader.prototype={load:function(a,d,b,e){var c=new Worker(a);c.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);c.onmessage=function(g){function h(U,X){return X=="relativeToHTML"?U:f+"/"+U}function j(){for(o in E.objects)if(!F.objects[o]){z=E.objects[o];if(G=F.geometries[z.geometry]){H=[];for(T=0;T<z.materials.length;T++)H[T]=F.materials[z.materials[T]];n=z.position;r=z.rotation;q=z.quaternion;s=z.scale;q=0;H.length==0&&(H[0]=new THREE.MeshFaceMaterial);H.length>1&&(H=[new THREE.MeshFaceMaterial]);
+object=new THREE.Mesh(G,H);object.position.set(n[0],n[1],n[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=z.visible;F.scene.addObject(object);F.objects[o]=object;if(z.meshCollider){var U=THREE.CollisionUtils.MeshColliderWBox(object);THREE.Collisions.colliders.push(U)}}}}function l(U){return function(X){F.geometries[U]=X;j();P-=1;k()}}function k(){e({total_models:R,total_textures:M,
+loaded_models:R-P,loaded_textures:M-Q},F);P==0&&Q==0&&b(F)}var m,p,o,x,w,u,A,z,n,y,B,G,K,J,H,E,L,P,Q,R,M,F;E=g.data;g=new THREE.BinaryLoader;L=new THREE.JSONLoader;Q=P=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};if(E.transform){var N=E.transform.position;y=E.transform.rotation;var O=E.transform.scale;N&&F.scene.position.set(N[0],N[1],N[2]);y&&F.scene.rotation.set(y[0],y[1],y[2]);O&&F.scene.scale.set(O[0],O[1],O[2]);(N||y||O)&&F.scene.updateMatrix()}N=
+function(){Q-=1;k()};for(w in E.cameras){y=E.cameras[w];if(y.type=="perspective")K=new THREE.Camera(y.fov,y.aspect,y.near,y.far);else if(y.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(y.left,y.right,y.top,y.bottom,y.near,y.far)}n=y.position;y=y.target;K.position.set(n[0],n[1],n[2]);K.target.position.set(y[0],y[1],y[2]);F.cameras[w]=K}for(x in E.lights){w=E.lights[x];K=w.color!==undefined?w.color:16777215;y=w.intensity!==undefined?w.intensity:1;if(w.type=="directional"){n=
+w.direction;light=new THREE.DirectionalLight(K,y);light.position.set(n[0],n[1],n[2]);light.position.normalize()}else if(w.type=="point"){n=w.position;light=new THREE.PointLight(K,y);light.position.set(n[0],n[1],n[2])}F.scene.addLight(light);F.lights[x]=light}for(u in E.fogs){x=E.fogs[u];if(x.type=="linear")J=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(J=new THREE.FogExp2(0,x.density));y=x.color;J.color.setRGB(y[0],y[1],y[2]);F.fogs[u]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];
 if(F.fogs&&E.defaults.fog)F.scene.fog=F.fogs[E.defaults.fog];y=E.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(y[0],y[1],y[2]);F.bgColorAlpha=E.defaults.bgalpha;for(m in E.geometries){u=E.geometries[m];if(u.type=="bin_mesh"||u.type=="ascii_mesh")P+=1}R=P;for(m in E.geometries){u=E.geometries[m];if(u.type=="cube"){G=new THREE.Cube(u.width,u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides);F.geometries[m]=G}else if(u.type=="plane"){G=new THREE.Plane(u.width,
 u.height,u.segmentsWidth,u.segmentsHeight);F.geometries[m]=G}else if(u.type=="sphere"){G=new THREE.Sphere(u.radius,u.segmentsWidth,u.segmentsHeight);F.geometries[m]=G}else if(u.type=="cylinder"){G=new THREE.Cylinder(u.numSegs,u.topRad,u.botRad,u.height,u.topOffset,u.botOffset);F.geometries[m]=G}else if(u.type=="torus"){G=new THREE.Torus(u.radius,u.tube,u.segmentsR,u.segmentsT);F.geometries[m]=G}else if(u.type=="icosahedron"){G=new THREE.Icosahedron(u.subdivisions);F.geometries[m]=G}else if(u.type==
-"bin_mesh")g.load({model:h(u.url,E.urlBaseType),callback:l(m)});else u.type=="ascii_mesh"&&L.load({model:h(u.url,E.urlBaseType),callback:l(m)})}for(B in E.textures){m=E.textures[B];Q+=m.url instanceof Array?m.url.length:1}M=Q;for(B in E.textures){m=E.textures[B];if(m.mapping!=undefined&&THREE[m.mapping]!=undefined)m.mapping=new THREE[m.mapping];if(m.url instanceof Array){u=[];for(var T=0;T<m.url.length;T++)u[T]=h(m.url[T],E.urlBaseType);u=THREE.ImageUtils.loadTextureCube(u,m.mapping,N)}else{u=THREE.ImageUtils.loadTexture(h(m.url,
-E.urlBaseType),m.mapping,N);if(THREE[m.minFilter]!=undefined)u.minFilter=THREE[m.minFilter];if(THREE[m.magFilter]!=undefined)u.magFilter=THREE[m.magFilter]}F.textures[B]=u}for(p in E.materials){B=E.materials[p];for(C in B.parameters)if(C=="envMap"||C=="map"||C=="lightMap")B.parameters[C]=F.textures[B.parameters[C]];else if(C=="shading")B.parameters[C]=B.parameters[C]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(C=="blending")B.parameters[C]=THREE[B.parameters[C]]?THREE[B.parameters[C]]:THREE.NormalBlending;
-else C=="combine"&&(B.parameters[C]=B.parameters[C]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);B=new THREE[B.type](B.parameters);F.materials[p]=B}j();d(F)}}};
+"bin_mesh")g.load({model:h(u.url,E.urlBaseType),callback:l(m)});else u.type=="ascii_mesh"&&L.load({model:h(u.url,E.urlBaseType),callback:l(m)})}for(A in E.textures){m=E.textures[A];Q+=m.url instanceof Array?m.url.length:1}M=Q;for(A in E.textures){m=E.textures[A];if(m.mapping!=undefined&&THREE[m.mapping]!=undefined)m.mapping=new THREE[m.mapping];if(m.url instanceof Array){u=[];for(var T=0;T<m.url.length;T++)u[T]=h(m.url[T],E.urlBaseType);u=THREE.ImageUtils.loadTextureCube(u,m.mapping,N)}else{u=THREE.ImageUtils.loadTexture(h(m.url,
+E.urlBaseType),m.mapping,N);if(THREE[m.minFilter]!=undefined)u.minFilter=THREE[m.minFilter];if(THREE[m.magFilter]!=undefined)u.magFilter=THREE[m.magFilter]}F.textures[A]=u}for(p in E.materials){A=E.materials[p];for(B in A.parameters)if(B=="envMap"||B=="map"||B=="lightMap")A.parameters[B]=F.textures[A.parameters[B]];else if(B=="shading")A.parameters[B]=A.parameters[B]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(B=="blending")A.parameters[B]=THREE[A.parameters[B]]?THREE[A.parameters[B]]:THREE.NormalBlending;
+else if(B=="combine")A.parameters[B]=A.parameters[B]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(B=="vertexColors")if(A.parameters[B]=="face")A.parameters[B]=THREE.FaceColors;else if(A.parameters[B])A.parameters[B]=THREE.VertexColors;A=new THREE[A.type](A.parameters);F.materials[p]=A}j();d(F)}}};
 THREE.MarchingCubes=function(a,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,e,c){return b+(e-b)*c};this.VIntX=function(b,e,c,f,g,h,j,l,k,m){g=(g-k)/(m-k);k=this.normal_cache;e[f]=h+g*this.delta;e[f+1]=j;e[f+2]=l;c[f]=this.lerp(k[b],k[b+3],g);c[f+1]=this.lerp(k[b+1],k[b+4],g);c[f+2]=this.lerp(k[b+2],k[b+5],g)};this.VIntY=function(b,e,c,f,g,h,j,l,k,m){g=(g-k)/(m-k);k=this.normal_cache;e[f]=h;e[f+1]=j+g*this.delta;e[f+
 2]=l;e=b+this.yd*3;c[f]=this.lerp(k[b],k[e],g);c[f+1]=this.lerp(k[b+1],k[e+1],g);c[f+2]=this.lerp(k[b+2],k[e+2],g)};this.VIntZ=function(b,e,c,f,g,h,j,l,k,m){g=(g-k)/(m-k);k=this.normal_cache;e[f]=h;e[f+1]=j;e[f+2]=l+g*this.delta;e=b+this.zd*3;c[f]=this.lerp(k[b],k[e],g);c[f+1]=this.lerp(k[b+1],k[e+1],g);c[f+2]=this.lerp(k[b+2],k[e+2],g)};this.compNorm=function(b){var e=b*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[b-1]-this.field[b+1];this.normal_cache[e+1]=this.field[b-this.yd]-
-this.field[b+this.yd];this.normal_cache[e+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,e,c,f,g,h){var j=f+1,l=f+this.yd,k=f+this.zd,m=j+this.yd,p=j+this.zd,o=f+this.yd+this.zd,x=j+this.yd+this.zd,w=0,u=this.field[f],B=this.field[j],z=this.field[l],n=this.field[m],y=this.field[k],C=this.field[p],G=this.field[o],K=this.field[x];u<g&&(w|=1);B<g&&(w|=2);z<g&&(w|=8);n<g&&(w|=4);y<g&&(w|=16);C<g&&(w|=32);G<g&&(w|=128);K<g&&(w|=64);var J=THREE.edgeTable[w];if(J==0)return 0;
-var I=this.delta,E=b+I,L=e+I;I=c+I;if(J&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,g,b,e,c,u,B)}if(J&2){this.compNorm(j);this.compNorm(m);this.VIntY(j*3,this.vlist,this.nlist,3,g,E,e,c,B,n)}if(J&4){this.compNorm(l);this.compNorm(m);this.VIntX(l*3,this.vlist,this.nlist,6,g,b,L,c,z,n)}if(J&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,g,b,e,c,u,z)}if(J&16){this.compNorm(k);this.compNorm(p);this.VIntX(k*3,this.vlist,this.nlist,12,g,b,e,I,
-y,C)}if(J&32){this.compNorm(p);this.compNorm(x);this.VIntY(p*3,this.vlist,this.nlist,15,g,E,e,I,C,K)}if(J&64){this.compNorm(o);this.compNorm(x);this.VIntX(o*3,this.vlist,this.nlist,18,g,b,L,I,G,K)}if(J&128){this.compNorm(k);this.compNorm(o);this.VIntY(k*3,this.vlist,this.nlist,21,g,b,e,I,y,G)}if(J&256){this.compNorm(f);this.compNorm(k);this.VIntZ(f*3,this.vlist,this.nlist,24,g,b,e,c,u,y)}if(J&512){this.compNorm(j);this.compNorm(p);this.VIntZ(j*3,this.vlist,this.nlist,27,g,E,e,c,B,C)}if(J&1024){this.compNorm(m);
+this.field[b+this.yd];this.normal_cache[e+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,e,c,f,g,h){var j=f+1,l=f+this.yd,k=f+this.zd,m=j+this.yd,p=j+this.zd,o=f+this.yd+this.zd,x=j+this.yd+this.zd,w=0,u=this.field[f],A=this.field[j],z=this.field[l],n=this.field[m],y=this.field[k],B=this.field[p],G=this.field[o],K=this.field[x];u<g&&(w|=1);A<g&&(w|=2);z<g&&(w|=8);n<g&&(w|=4);y<g&&(w|=16);B<g&&(w|=32);G<g&&(w|=128);K<g&&(w|=64);var J=THREE.edgeTable[w];if(J==0)return 0;
+var H=this.delta,E=b+H,L=e+H;H=c+H;if(J&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,g,b,e,c,u,A)}if(J&2){this.compNorm(j);this.compNorm(m);this.VIntY(j*3,this.vlist,this.nlist,3,g,E,e,c,A,n)}if(J&4){this.compNorm(l);this.compNorm(m);this.VIntX(l*3,this.vlist,this.nlist,6,g,b,L,c,z,n)}if(J&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,g,b,e,c,u,z)}if(J&16){this.compNorm(k);this.compNorm(p);this.VIntX(k*3,this.vlist,this.nlist,12,g,b,e,H,
+y,B)}if(J&32){this.compNorm(p);this.compNorm(x);this.VIntY(p*3,this.vlist,this.nlist,15,g,E,e,H,B,K)}if(J&64){this.compNorm(o);this.compNorm(x);this.VIntX(o*3,this.vlist,this.nlist,18,g,b,L,H,G,K)}if(J&128){this.compNorm(k);this.compNorm(o);this.VIntY(k*3,this.vlist,this.nlist,21,g,b,e,H,y,G)}if(J&256){this.compNorm(f);this.compNorm(k);this.VIntZ(f*3,this.vlist,this.nlist,24,g,b,e,c,u,y)}if(J&512){this.compNorm(j);this.compNorm(p);this.VIntZ(j*3,this.vlist,this.nlist,27,g,E,e,c,A,B)}if(J&1024){this.compNorm(m);
 this.compNorm(x);this.VIntZ(m*3,this.vlist,this.nlist,30,g,E,L,c,n,K)}if(J&2048){this.compNorm(l);this.compNorm(o);this.VIntZ(l*3,this.vlist,this.nlist,33,g,b,L,c,z,G)}w<<=4;for(g=f=0;THREE.triTable[w+g]!=-1;){b=w+g;e=b+1;c=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[e],3*THREE.triTable[c],h);g+=3;f++}return f};this.posnormtriv=function(b,e,c,f,g,h){var j=this.count*3;this.positionArray[j]=b[c];this.positionArray[j+1]=b[c+1];this.positionArray[j+2]=b[c+2];this.positionArray[j+
 3]=b[f];this.positionArray[j+4]=b[f+1];this.positionArray[j+5]=b[f+2];this.positionArray[j+6]=b[g];this.positionArray[j+7]=b[g+1];this.positionArray[j+8]=b[g+2];this.normalArray[j]=e[c];this.normalArray[j+1]=e[c+1];this.normalArray[j+2]=e[c+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[g];this.normalArray[j+7]=e[g+1];this.normalArray[j+8]=e[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
 function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;b(this)}};this.addBall=function(b,e,c,f,g){var h=this.size*Math.sqrt(f/g),j=c*this.size,l=e*this.size,k=b*this.size,m=Math.floor(j-h);m<1&&(m=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var p=Math.floor(l-h);p<1&&(p=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);h=Math.floor(k+h);
-h>this.size-1&&(h=this.size-1);for(var x,w,u,B,z,n;m<j;m++){k=this.size2*m;w=m/this.size-c;z=w*w;for(w=p;w<l;w++){u=k+this.size*w;x=w/this.size-e;n=x*x;for(x=o;x<h;x++){B=x/this.size-b;B=f/(1.0E-6+B*B+n+z)-g;B>0&&(this.field[u+x]+=B)}}}};this.addPlaneX=function(b,e){var c,f,g,h,j,l=this.size,k=this.yd,m=this.zd,p=this.field,o=l*Math.sqrt(b/e);o>l&&(o=l);for(c=0;c<o;c++){f=c/l;f*=f;h=b/(1.0E-4+f)-e;if(h>0)for(f=0;f<l;f++){j=c+f*k;for(g=0;g<l;g++)p[m*g+j]+=h}}};this.addPlaneY=function(b,e){var c,f,
+h>this.size-1&&(h=this.size-1);for(var x,w,u,A,z,n;m<j;m++){k=this.size2*m;w=m/this.size-c;z=w*w;for(w=p;w<l;w++){u=k+this.size*w;x=w/this.size-e;n=x*x;for(x=o;x<h;x++){A=x/this.size-b;A=f/(1.0E-6+A*A+n+z)-g;A>0&&(this.field[u+x]+=A)}}}};this.addPlaneX=function(b,e){var c,f,g,h,j,l=this.size,k=this.yd,m=this.zd,p=this.field,o=l*Math.sqrt(b/e);o>l&&(o=l);for(c=0;c<o;c++){f=c/l;f*=f;h=b/(1.0E-4+f)-e;if(h>0)for(f=0;f<l;f++){j=c+f*k;for(g=0;g<l;g++)p[m*g+j]+=h}}};this.addPlaneY=function(b,e){var c,f,
 g,h,j,l,k=this.size,m=this.yd,p=this.zd,o=this.field,x=k*Math.sqrt(b/e);x>k&&(x=k);for(f=0;f<x;f++){c=f/k;c*=c;h=b/(1.0E-4+c)-e;if(h>0){j=f*m;for(c=0;c<k;c++){l=j+c;for(g=0;g<k;g++)o[p*g+l]+=h}}}};this.addPlaneZ=function(b,e){var c,f,g,h,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/e);dist>size&&(dist=size);for(g=0;g<dist;g++){c=g/size;c*=c;h=b/(1.0E-4+c)-e;if(h>0){j=zd*g;for(f=0;f<size;f++){l=j+f*yd;for(c=0;c<size;c++)field[l+c]+=h}}}};this.reset=function(){var b;
 for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var e,c,f,g,h,j,l,k,m,p=this.size-2;for(g=1;g<p;g++){m=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++){k=m+this.size*f;j=(f-this.halfsize)/this.halfsize;for(c=1;c<p;c++){h=(c-this.halfsize)/this.halfsize;e=k+c;this.polygonize(h,j,l,e,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,e=new THREE.Geometry,c=[];this.render(function(f){var g,h,j,l,k,m,p,o;for(g=
 0;g<f.count;g++){p=g*3;k=p+1;o=p+2;h=f.positionArray[p];j=f.positionArray[k];l=f.positionArray[o];m=new THREE.Vector3(h,j,l);h=f.normalArray[p];j=f.normalArray[k];l=f.normalArray[o];p=new THREE.Vector3(h,j,l);p.normalize();k=new THREE.Vertex(m);e.vertices.push(k);c.push(p)}nfaces=f.count/3;for(g=0;g<nfaces;g++){p=(b+g)*3;k=p+1;o=p+2;m=c[p];h=c[k];j=c[o];p=new THREE.Face3(p,k,o,[m,h,j]);e.faces.push(p)}b+=nfaces;f.count=0});return e};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;

+ 54 - 54
build/custom/ThreeSVG.js

@@ -8,25 +8,25 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var b=Math.cos(this.y);this.y=Math.asin(a.n13);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n12/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};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,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(B,t,K,x){x=x.clone().subSelf(t);K=K.clone().subSelf(t);var G=B.clone().subSelf(t);B=x.dot(x);t=x.dot(K);x=x.dot(G);var C=K.dot(K);K=K.dot(G);G=1/(B*C-t*t);C=(C*x-t*K)*G;B=(B*K-t*x)*G;return C>0&&B>0&&C+B<1}var c,d,e,h,f,i,g,j,k,m,
-l,o=a.geometry,r=o.vertices,u=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();l=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(r[e.a].position.clone());f=g.multiplyVector3(r[e.b].position.clone());i=g.multiplyVector3(r[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(r[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());k=l.dot(j);if(a.doubleSided||(a.flipSided?k>0:k<0)){j=j.dot((new THREE.Vector3).sub(h,m))/
-k;m=m.addSelf(l.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(m,h,f,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};u.push(e)}}else if(e instanceof THREE.Face4&&(b(m,h,f,g)||b(m,f,i,g))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};u.push(e)}}}return u}};
-THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,j,k,m){i=!1;b=g;c=j;d=k;e=m;a()};this.addPoint=function(g,j){if(i){i=!1;b=g;c=j;d=g;e=j}else{b=b<g?b:g;c=c<j?c:j;d=d>g?d:g;e=e>j?e:j}a()};
-this.add3Points=function(g,j,k,m,l,o){if(i){i=!1;b=g<k?g<l?g:l:k<l?k:l;c=j<m?j<o?j:o:m<o?m:o;d=g>k?g>l?g:l:k>l?k:l;e=j>m?j>o?j:o:m>o?m:o}else{b=g<k?g<l?g<b?g:b:l<b?l:b:k<l?k<b?k:b:l<b?l:b;c=j<m?j<o?j<c?j:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=g>k?g>l?g>d?g:d:l>d?l:d:k>l?k>d?k:d:l>d?l:d;e=j>m?j>o?j>e?j:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(g){if(i){i=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(h,f){return h.distance-f.distance});return e},intersectObject:function(a){function b(y,u,H,I){I=I.clone().subSelf(u);H=H.clone().subSelf(u);var D=y.clone().subSelf(u);y=I.dot(I);u=I.dot(H);I=I.dot(D);var w=H.dot(H);H=H.dot(D);D=1/(y*w-u*u);w=(w*I-u*H)*D;y=(y*H-u*I)*D;return w>0&&y>0&&w+y<1}var c,d,e,h,f,i,g,j,m,k,
+n,l=a.geometry,r=l.vertices,s=[];c=0;for(d=l.faces.length;c<d;c++){e=l.faces[c];k=this.origin.clone();n=this.direction.clone();g=a.matrixWorld;h=g.multiplyVector3(r[e.a].position.clone());f=g.multiplyVector3(r[e.b].position.clone());i=g.multiplyVector3(r[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(r[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());m=n.dot(j);if(a.doubleSided||(a.flipSided?m>0:m<0)){j=j.dot((new THREE.Vector3).sub(h,k))/
+m;k=k.addSelf(n.multiplyScalar(j));if(e instanceof THREE.Face3){if(b(k,h,f,i)){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};s.push(e)}}else if(e instanceof THREE.Face4&&(b(k,h,f,g)||b(k,f,i,g))){e={distance:this.origin.distanceTo(k),point:k,face:e,object:a};s.push(e)}}}return s}};
+THREE.Rectangle=function(){function a(){h=d-b;f=e-c}var b,c,d,e,h,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,j,m,k){i=!1;b=g;c=j;d=m;e=k;a()};this.addPoint=function(g,j){if(i){i=!1;b=g;c=j;d=g;e=j}else{b=b<g?b:g;c=c<j?c:j;d=d>g?d:g;e=e>j?e:j}a()};
+this.add3Points=function(g,j,m,k,n,l){if(i){i=!1;b=g<m?g<n?g:n:m<n?m:n;c=j<k?j<l?j:l:k<l?k:l;d=g>m?g>n?g:n:m>n?m:n;e=j>k?j>l?j:l:k>l?k:l}else{b=g<m?g<n?g<b?g:b:n<b?n:b:m<n?m<b?m:b:n<b?n:b;c=j<k?j<l?j<c?j:c:l<c?l:c:k<l?k<c?k:c:l<c?l:c;d=g>m?g>n?g>d?g:d:n>d?n:d:m>n?m>d?m:d:n>d?n:d;e=j>k?j>l?j>e?j:e:l>e?l:e:k>l?k>e?k:e:l>e?l:e}a()};this.addRectangle=function(g){if(i){i=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
 d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,h,f,i,g,j,k,m,l,o,r,u){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,i||0,g||0,j||0,k||1,m||0,l||0,o||0,r||0,u||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,i,g,j,k,m,l,o,r,u){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=i;this.n31=g;this.n32=j;this.n33=k;this.n34=m;this.n41=l;this.n42=o;this.n43=r;this.n44=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
+THREE.Matrix4=function(a,b,c,d,e,h,f,i,g,j,m,k,n,l,r,s){this.set(a||1,b||0,c||0,d||0,e||0,h||1,f||0,i||0,g||0,j||0,m||1,k||0,n||0,l||0,r||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,h,f,i,g,j,m,k,n,l,r,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=h;this.n23=f;this.n24=i;this.n31=g;this.n32=j;this.n33=m;this.n34=k;this.n41=n;this.n42=l;this.n43=r;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
 e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;d.cross(c,h).normalize();if(d.length()===0){h.x+=1.0E-4;d.cross(c,h).normalize()}e.cross(h,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=h.x;this.n21=d.y;this.n22=e.y;this.n23=h.y;this.n31=d.z;this.n32=e.z;this.n33=h.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
 d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
-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 c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,k=a.n31,m=a.n32,l=a.n33,o=a.n34,r=a.n41,u=a.n42,B=a.n43,t=a.n44,K=b.n11,x=b.n12,G=b.n13,C=b.n14,p=b.n21,O=b.n22,
-H=b.n23,P=b.n24,M=b.n31,A=b.n32,s=b.n33,L=b.n34;this.n11=c*K+d*p+e*M;this.n12=c*x+d*O+e*A;this.n13=c*G+d*H+e*s;this.n14=c*C+d*P+e*L+h;this.n21=f*K+i*p+g*M;this.n22=f*x+i*O+g*A;this.n23=f*G+i*H+g*s;this.n24=f*C+i*P+g*L+j;this.n31=k*K+m*p+l*M;this.n32=k*x+m*O+l*A;this.n33=k*G+m*H+l*s;this.n34=k*C+m*P+l*L+o;this.n41=r*K+u*p+B*M;this.n42=r*x+u*O+B*A;this.n43=r*G+u*H+B*s;this.n44=r*C+u*P+B*L+t;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
+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 c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,m=a.n31,k=a.n32,n=a.n33,l=a.n34,r=a.n41,s=a.n42,y=a.n43,u=a.n44,H=b.n11,I=b.n12,D=b.n13,w=b.n14,o=b.n21,O=b.n22,
+J=b.n23,K=b.n24,P=b.n31,C=b.n32,x=b.n33,F=b.n34;this.n11=c*H+d*o+e*P;this.n12=c*I+d*O+e*C;this.n13=c*D+d*J+e*x;this.n14=c*w+d*K+e*F+h;this.n21=f*H+i*o+g*P;this.n22=f*I+i*O+g*C;this.n23=f*D+i*J+g*x;this.n24=f*w+i*K+g*F+j;this.n31=m*H+k*o+n*P;this.n32=m*I+k*O+n*C;this.n33=m*D+k*J+n*x;this.n34=m*w+k*K+n*F+l;this.n41=r*H+s*o+y*P;this.n42=r*I+s*O+y*C;this.n43=r*D+s*J+y*x;this.n44=r*w+s*K+y*F+u;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
 this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,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(){var a=
-this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,i=this.n24,g=this.n31,j=this.n32,k=this.n33,m=this.n34,l=this.n41,o=this.n42,r=this.n43,u=this.n44;return d*f*j*l-c*i*j*l-d*h*k*l+b*i*k*l+c*h*m*l-b*f*m*l-d*f*g*o+c*i*g*o+d*e*k*o-a*i*k*o-c*e*m*o+a*f*m*o+d*h*g*r-b*i*g*r-d*e*j*r+a*i*j*r+b*e*m*r-a*h*m*r-c*h*g*u+b*f*g*u+c*e*j*u-a*f*j*u-b*e*k*u+a*h*k*u},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,h=this.n22,f=this.n23,i=this.n24,g=this.n31,j=this.n32,m=this.n33,k=this.n34,n=this.n41,l=this.n42,r=this.n43,s=this.n44;return d*f*j*n-c*i*j*n-d*h*m*n+b*i*m*n+c*h*k*n-b*f*k*n-d*f*g*l+c*i*g*l+d*e*m*l-a*i*m*l-c*e*k*l+a*f*k*l+d*h*g*r-b*i*g*r-d*e*j*r+a*i*j*r+b*e*k*r-a*h*k*r-c*h*g*s+b*f*g*s+c*e*j*s-a*f*j*s-b*e*m*s+a*h*m*s},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
 this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;
 this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
 this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
@@ -34,21 +34,22 @@ b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:functio
 h+c,g*f-d*i,g*i+d*f,0,g*f+d*i,j*f+c,j*i-d*h,0,g*i-d*f,j*i+d*h,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var f=a*c,i=b*c;this.n11=e*h;this.n12=-e*d;this.n13=c;this.n21=i*h+a*d;this.n22=-i*d+a*h;this.n23=-b*e;this.n31=-f*h+b*d;this.n32=f*d+b*h;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=
 a.x,c=a.y,d=a.z,e=a.w,h=b+b,f=c+c,i=d+d;a=b*h;var g=b*f;b*=i;var j=c*f;c*=i;d*=i;h*=e;f*=e;e*=i;this.n11=1-(j+d);this.n12=g-e;this.n13=b+f;this.n21=g+e;this.n22=1-(a+d);this.n23=c-h;this.n31=b-f;this.n32=c+h;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
 a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,k=a.n31,m=a.n32,l=a.n33,o=a.n34,r=a.n41,u=a.n42,B=a.n43,t=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*o*u-j*l*u+j*m*B-i*o*B-g*m*t+i*l*t;b.n12=h*l*u-e*o*u-h*m*B+d*o*B+e*m*t-d*l*t;b.n13=e*j*u-h*g*u+h*i*B-d*j*B-e*i*t+d*g*t;b.n14=h*g*m-e*j*m-h*i*l+d*j*l+e*i*o-d*g*o;b.n21=j*l*r-g*o*r-j*k*B+f*o*B+g*k*t-f*l*t;b.n22=e*o*r-h*l*r+h*k*B-c*o*B-e*k*t+c*l*t;b.n23=h*g*r-e*j*r-h*f*B+c*j*B+e*f*t-c*g*t;
-b.n24=e*j*k-h*g*k+h*f*l-c*j*l-e*f*o+c*g*o;b.n31=i*o*r-j*m*r+j*k*u-f*o*u-i*k*t+f*m*t;b.n32=h*m*r-d*o*r-h*k*u+c*o*u+d*k*t-c*m*t;b.n33=e*j*r-h*i*r+h*f*u-c*j*u-d*f*t+c*i*t;b.n34=h*i*k-d*j*k-h*f*m+c*j*m+d*f*o-c*i*o;b.n41=g*m*r-i*l*r-g*k*u+f*l*u+i*k*B-f*m*B;b.n42=d*l*r-e*m*r+e*k*u-c*l*u-d*k*B+c*m*B;b.n43=e*i*r-d*g*r-e*f*u+c*g*u+d*f*B-c*i*B;b.n44=d*g*k-e*i*k+e*f*m-c*g*m-d*f*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*i;c[5]=a*g;c[6]=a*j;c[7]=a*k;c[8]=a*m;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,h=a.n14,f=a.n21,i=a.n22,g=a.n23,j=a.n24,m=a.n31,k=a.n32,n=a.n33,l=a.n34,r=a.n41,s=a.n42,y=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*l*s-j*n*s+j*k*y-i*l*y-g*k*u+i*n*u;b.n12=h*n*s-e*l*s-h*k*y+d*l*y+e*k*u-d*n*u;b.n13=e*j*s-h*g*s+h*i*y-d*j*y-e*i*u+d*g*u;b.n14=h*g*k-e*j*k-h*i*n+d*j*n+e*i*l-d*g*l;b.n21=j*n*r-g*l*r-j*m*y+f*l*y+g*m*u-f*n*u;b.n22=e*l*r-h*n*r+h*m*y-c*l*y-e*m*u+c*n*u;b.n23=h*g*r-e*j*r-h*f*y+c*j*y+e*f*u-c*g*u;
+b.n24=e*j*m-h*g*m+h*f*n-c*j*n-e*f*l+c*g*l;b.n31=i*l*r-j*k*r+j*m*s-f*l*s-i*m*u+f*k*u;b.n32=h*k*r-d*l*r-h*m*s+c*l*s+d*m*u-c*k*u;b.n33=e*j*r-h*i*r+h*f*s-c*j*s-d*f*u+c*i*u;b.n34=h*i*m-d*j*m-h*f*k+c*j*k+d*f*l-c*i*l;b.n41=g*k*r-i*n*r-g*m*s+f*n*s+i*m*y-f*k*y;b.n42=d*n*r-e*k*r+e*m*s-c*n*s-d*m*y+c*k*y;b.n43=e*i*r-d*g*r-e*f*s+c*g*s+d*f*y-c*i*y;b.n44=d*g*m-e*i*m+e*f*k-c*g*k-d*f*n+c*i*n;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,h=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*h;c[3]=a*f;c[4]=a*i;c[5]=a*g;c[6]=a*j;c[7]=a*m;c[8]=a*k;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,h){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(h+e)/(h-e);f.n34=-2*h*e/(h-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,h){var f,i,g,j;f=new THREE.Matrix4;i=b-a;g=c-d;j=h-e;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/g;f.n23=0;f.n24=-((c+d)/g);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((h+e)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
-THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
 undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
 b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,i=d*e;this.w=f*h-i*c;this.x=f*c+i*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+e*h+c*i-d*f;this.y=c*a+e*f+d*h-b*i;this.z=d*a+e*i+b*f-c*h;this.w=e*a-b*h-c*f-d*i;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,i=this.z,g=this.w,j=g*c+f*e-i*d,k=g*d+i*c-h*e,m=g*e+h*d-f*c;c=-h*c-f*d-i*e;b.x=j*g+c*-h+k*-i-m*-f;b.y=k*g+c*-f+m*-h-j*-i;b.z=m*g+c*-i+j*-f-k*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var f=a*b,i=d*e;this.w=f*h-i*c;this.x=f*c+i*h;this.y=d*b*h+a*e*c;this.z=a*e*h-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=
+a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},
+multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+e*h+c*i-d*f;this.y=c*a+e*f+d*h-b*i;this.z=d*a+e*i+b*f-c*h;this.w=e*a-b*h-c*f-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,i=this.z,g=this.w,j=g*c+f*e-i*d,m=
+g*d+i*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-i*e;b.x=j*g+c*-h+m*-i-k*-f;b.y=m*g+c*-f+k*-h-j*-i;b.z=k*g+c*-i+j*-f-m*-h;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -56,21 +57,20 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,h,f,i=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){h=this.faces[d];if(a&&h.vertexNormals.length){i.set(0,0,0);b=0;for(c=h.vertexNormals.length;b<c;b++)i.addSelf(h.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[h.a];c=this.vertices[h.b];f=this.vertices[h.c];i.sub(f.position,c.position);g.sub(b.position,c.position);i.crossSelf(g)}i.isZero()||
 i.normalize();h.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);
-c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(z,y,D,q,n,E,I){i=z.vertices[y].position;g=z.vertices[D].position;j=z.vertices[q].position;k=f[n];m=f[E];l=f[I];o=g.x-i.x;r=j.x-i.x;u=g.y-i.y;B=j.y-i.y;t=g.z-i.z;K=j.z-i.z;x=m.u-k.u;G=l.u-k.u;C=m.v-k.v;p=l.v-k.v;O=1/(x*p-G*C);A.set((p*
-o-C*r)*O,(p*u-C*B)*O,(p*t-C*K)*O);s.set((x*r-G*o)*O,(x*B-G*u)*O,(x*K-G*t)*O);P[y].addSelf(A);P[D].addSelf(A);P[q].addSelf(A);M[y].addSelf(s);M[D].addSelf(s);M[q].addSelf(s)}var b,c,d,e,h,f,i,g,j,k,m,l,o,r,u,B,t,K,x,G,C,p,O,H,P=[],M=[],A=new THREE.Vector3,s=new THREE.Vector3,L=new THREE.Vector3,Q=new THREE.Vector3,N=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){P[b]=new THREE.Vector3;M[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];f=this.faceVertexUvs[0][b];
-if(h instanceof THREE.Face3)a(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){a(this,h.a,h.b,h.c,0,1,2);a(this,h.a,h.b,h.d,0,1,3)}}var v=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(d=0;d<h.vertexNormals.length;d++){N.copy(h.vertexNormals[d]);e=h[v[d]];H=P[e];L.copy(H);L.subSelf(N.multiplyScalar(N.dot(H))).normalize();Q.cross(h.vertexNormals[d],H);e=Q.dot(M[e]);e=e<0?-1:1;h.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(t,G,z,E,p,q,A){i=t.vertices[G].position;g=t.vertices[z].position;j=t.vertices[E].position;m=f[p];k=f[q];n=f[A];l=g.x-i.x;r=j.x-i.x;s=g.y-i.y;y=j.y-i.y;u=g.z-i.z;H=j.z-i.z;I=k.u-m.u;D=n.u-m.u;w=k.v-m.v;o=n.v-m.v;O=1/(I*o-D*w);C.set((o*
+l-w*r)*O,(o*s-w*y)*O,(o*u-w*H)*O);x.set((I*r-D*l)*O,(I*y-D*s)*O,(I*H-D*u)*O);K[G].addSelf(C);K[z].addSelf(C);K[E].addSelf(C);P[G].addSelf(x);P[z].addSelf(x);P[E].addSelf(x)}var b,c,d,e,h,f,i,g,j,m,k,n,l,r,s,y,u,H,I,D,w,o,O,J,K=[],P=[],C=new THREE.Vector3,x=new THREE.Vector3,F=new THREE.Vector3,M=new THREE.Vector3,Q=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){K[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];f=this.faceVertexUvs[0][b];
+if(h instanceof THREE.Face3)a(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){a(this,h.a,h.b,h.c,0,1,2);a(this,h.a,h.b,h.d,0,1,3)}}var L=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){h=this.faces[b];for(d=0;d<h.vertexNormals.length;d++){Q.copy(h.vertexNormals[d]);e=h[L[d]];J=K[e];F.copy(J);F.subSelf(Q.multiplyScalar(Q.dot(J))).normalize();M.cross(h.vertexNormals[d],J);e=M.dot(P[e]);e=e<0?-1:1;h.vertexTangents[d]=new THREE.Vector4(F.x,F.y,F.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(g,j){return Math.min(g,
-j)+"_"+Math.max(g,j)}function b(g,j,k){if(g[j]===undefined){g[j]={set:{},array:[]};g[j].set[k]=1;g[j].array.push(k)}else if(g[j].set[k]===undefined){g[j].set[k]=1;g[j].array.push(k)}}var c,d,e,h,f,i={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.a,f.c);b(i,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(i,e,c);e=a(f.a,f.b);b(i,e,c);e=a(f.a,f.d);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.c,f.d);b(i,e,c)}}c=0;for(d=
+j)+"_"+Math.max(g,j)}function b(g,j,m){if(g[j]===undefined){g[j]={set:{},array:[]};g[j].set[m]=1;g[j].array.push(m)}else if(g[j].set[m]===undefined){g[j].set[m]=1;g[j].array.push(m)}}var c,d,e,h,f,i={};c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];if(f instanceof THREE.Face3){e=a(f.a,f.b);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.a,f.c);b(i,e,c)}else if(f instanceof THREE.Face4){e=a(f.b,f.d);b(i,e,c);e=a(f.a,f.b);b(i,e,c);e=a(f.a,f.d);b(i,e,c);e=a(f.b,f.c);b(i,e,c);e=a(f.c,f.d);b(i,e,c)}}c=0;for(d=
 this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];h=f.vertexIndices[1];f.faceIndices=i[a(e,h)].array;for(e=0;e<f.faceIndices.length;e++){h=f.faceIndices[e];f.faces.push(this.faces[h])}}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.Material=function(a){this.id=THREE.MaterialCounter.value++;a=a||{};this.opacity=a.opacity!==undefined?a.opacity:1;this.transparent=a.transparent!==undefined?a.transparent:!1;this.blending=a.blending!==undefined?a.blending:THREE.NormalBlending;this.depthTest=a.depthTest!==undefined?a.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
-THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.MaterialCounter={value:0};THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==undefined?a.linewidth:1;this.linecap=a.linecap!==undefined?a.linecap:"round";this.linejoin=a.linejoin!==undefined?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1};THREE.LineBasicMaterial.prototype=new THREE.Material;
-THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;
+THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.Material=function(a){this.id=THREE.MaterialCounter.value++;a=a||{};this.opacity=a.opacity!==undefined?a.opacity:1;this.transparent=a.transparent!==undefined?a.transparent:!1;this.blending=a.blending!==undefined?a.blending:THREE.NormalBlending;this.depthTest=a.depthTest!==undefined?a.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;
+THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.MaterialCounter={value:0};
+THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==undefined?a.linewidth:1;this.linecap=a.linecap!==undefined?a.linecap:"round";this.linejoin=a.linejoin!==undefined?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:!1};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
 THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==undefined?a.map:null;this.lightMap=a.lightMap!==undefined?a.lightMap:null;this.envMap=a.envMap!==undefined?a.envMap:null;this.combine=a.combine!==undefined?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==undefined?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==undefined?a.refractionRatio:0.98;this.shading=
 a.shading!==undefined?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==undefined?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth!==undefined?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==undefined?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==undefined?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==undefined?a.vertexColors:!1;this.skinning=a.skinning!==undefined?a.skinning:!1;this.morphTargets=a.morphTargets!==undefined?
 a.morphTargets:!1};THREE.MeshBasicMaterial.prototype=new THREE.Material;THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
@@ -98,30 +98,30 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var A=g[i]=g[i]||new THREE.RenderableVertex;i++;return A}function b(A,s){return s.z-A.z}function c(A,s){var L=0,Q=1,N=A.z+A.w,v=s.z+s.w,z=-A.z+A.w,y=-s.z+s.w;if(N>=0&&v>=0&&z>=0&&y>=0)return!0;else if(N<0&&v<0||z<0&&y<0)return!1;else{if(N<0)L=Math.max(L,N/(N-v));else v<0&&(Q=Math.min(Q,N/(N-v)));if(z<0)L=Math.max(L,z/(z-y));else y<0&&(Q=Math.min(Q,z/(z-y)));if(Q<L)return!1;else{A.lerpSelf(s,L);s.lerpSelf(A,1-Q);return!0}}}var d,e,h=[],f,i,g=[],j,k,m=[],l,o=
-[],r,u,B=[],t,K,x=[],G=new THREE.Vector4,C=new THREE.Vector4,p=new THREE.Matrix4,O=new THREE.Matrix4,H=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],P=new THREE.Vector4,M=new THREE.Vector4;this.projectVector=function(A,s){p.multiply(s.projectionMatrix,s.matrixWorldInverse);p.multiplyVector3(A);return A};this.unprojectVector=function(A,s){p.multiply(s.matrixWorld,THREE.Matrix4.makeInvert(s.projectionMatrix));p.multiplyVector3(A);return A};
-this.projectObjects=function(A,s,L){s=[];var Q,N,v;e=0;N=A.objects;A=0;for(Q=N.length;A<Q;A++){v=N[A];var z;if(!(z=!v.visible))if(z=v instanceof THREE.Mesh){a:{z=void 0;for(var y=v.matrixWorld,D=-v.geometry.boundingSphere.radius*Math.max(v.scale.x,Math.max(v.scale.y,v.scale.z)),q=0;q<6;q++){z=H[q].x*y.n14+H[q].y*y.n24+H[q].z*y.n34+H[q].w;if(z<=D){z=!1;break a}}z=!0}z=!z}if(!z){z=h[e]=h[e]||new THREE.RenderableObject;e++;d=z;G.copy(v.position);p.multiplyVector3(G);d.object=v;d.z=G.z;s.push(d)}}L&&
-s.sort(b);return s};this.projectScene=function(A,s,L){var Q=[],N=s.near,v=s.far,z,y,D,q,n,E,I,w,F,J,R,U,W,X,S,V,T;K=u=l=k=0;s.matrixAutoUpdate&&s.updateMatrix();A.update(undefined,!1,s);p.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);H[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);H[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);H[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);H[4].set(p.n41-p.n31,p.n42-p.n32,
-p.n43-p.n33,p.n44-p.n34);H[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);for(z=0;z<6;z++){F=H[z];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}F=this.projectObjects(A,s,!0);A=0;for(z=F.length;A<z;A++){J=F[A].object;if(J.visible){R=J.matrixWorld;U=J.matrixRotationWorld;W=J.materials;X=J.overdraw;i=0;if(J instanceof THREE.Mesh){S=J.geometry;q=S.vertices;V=S.faces;S=S.faceVertexUvs;y=0;for(D=q.length;y<D;y++){f=a();f.positionWorld.copy(q[y].position);R.multiplyVector3(f.positionWorld);
-f.positionScreen.copy(f.positionWorld);p.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>N&&f.positionScreen.z<v}q=0;for(y=V.length;q<y;q++){D=V[q];if(D instanceof THREE.Face3){n=g[D.a];E=g[D.b];I=g[D.c];if(n.visible&&E.visible&&I.visible&&(J.doubleSided||J.flipSided!=(I.positionScreen.x-n.positionScreen.x)*(E.positionScreen.y-n.positionScreen.y)-(I.positionScreen.y-n.positionScreen.y)*(E.positionScreen.x-
-n.positionScreen.x)<0)){w=m[k]=m[k]||new THREE.RenderableFace3;k++;j=w;j.v1.copy(n);j.v2.copy(E);j.v3.copy(I)}else continue}else if(D instanceof THREE.Face4){n=g[D.a];E=g[D.b];I=g[D.c];w=g[D.d];if(n.visible&&E.visible&&I.visible&&w.visible&&(J.doubleSided||J.flipSided!=((w.positionScreen.x-n.positionScreen.x)*(E.positionScreen.y-n.positionScreen.y)-(w.positionScreen.y-n.positionScreen.y)*(E.positionScreen.x-n.positionScreen.x)<0||(E.positionScreen.x-I.positionScreen.x)*(w.positionScreen.y-I.positionScreen.y)-
-(E.positionScreen.y-I.positionScreen.y)*(w.positionScreen.x-I.positionScreen.x)<0))){T=o[l]=o[l]||new THREE.RenderableFace4;l++;j=T;j.v1.copy(n);j.v2.copy(E);j.v3.copy(I);j.v4.copy(w)}else continue}j.normalWorld.copy(D.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(D.centroid);R.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.multiplyVector3(j.centroidScreen);I=D.vertexNormals;n=0;for(E=I.length;n<E;n++){w=j.vertexNormalsWorld[n];w.copy(I[n]);U.multiplyVector3(w)}n=
-0;for(E=S.length;n<E;n++)if(T=S[n][q]){I=0;for(w=T.length;I<w;I++)j.uvs[n][I]=T[I]}j.meshMaterials=W;j.faceMaterials=D.materials;j.overdraw=X;j.z=j.centroidScreen.z;Q.push(j)}}else if(J instanceof THREE.Line){O.multiply(p,R);q=J.geometry.vertices;n=a();n.positionScreen.copy(q[0].position);O.multiplyVector4(n.positionScreen);y=1;for(D=q.length;y<D;y++){n=a();n.positionScreen.copy(q[y].position);O.multiplyVector4(n.positionScreen);E=g[i-2];P.copy(n.positionScreen);M.copy(E.positionScreen);if(c(P,M)){P.multiplyScalar(1/
-P.w);M.multiplyScalar(1/M.w);R=B[u]=B[u]||new THREE.RenderableLine;u++;r=R;r.v1.positionScreen.copy(P);r.v2.positionScreen.copy(M);r.z=Math.max(P.z,M.z);r.materials=J.materials;Q.push(r)}}}else if(J instanceof THREE.Particle){C.set(J.position.x,J.position.y,J.position.z,1);p.multiplyVector4(C);C.z/=C.w;if(C.z>0&&C.z<1){R=x[K]=x[K]||new THREE.RenderableParticle;K++;t=R;t.x=C.x/C.w;t.y=C.y/C.w;t.z=C.z;t.rotation=J.rotation.z;t.scale.x=J.scale.x*Math.abs(t.x-(C.x+s.projectionMatrix.n11)/(C.w+s.projectionMatrix.n14));
-t.scale.y=J.scale.y*Math.abs(t.y-(C.y+s.projectionMatrix.n22)/(C.w+s.projectionMatrix.n24));t.materials=J.materials;Q.push(t)}}}}L&&Q.sort(b);return Q}};
-THREE.SVGRenderer=function(){function a(v,z,y){var D,q,n,E;D=0;for(q=v.lights.length;D<q;D++){n=v.lights[D];if(n instanceof THREE.DirectionalLight){E=z.normalWorld.dot(n.position)*n.intensity;if(E>0){y.r+=n.color.r*E;y.g+=n.color.g*E;y.b+=n.color.b*E}}else if(n instanceof THREE.PointLight){P.sub(n.position,z.centroidWorld);P.normalize();E=z.normalWorld.dot(P)*n.intensity;if(E>0){y.r+=n.color.r*E;y.g+=n.color.g*E;y.b+=n.color.b*E}}}}function b(v,z,y,D,q,n){s=d(L++);s.setAttribute("d","M "+v.positionScreen.x+
-" "+v.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)x.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(K){G.r=C.r;G.g=C.g;G.b=C.b;a(n,D,G);x.r=q.color.r*G.r;x.g=q.color.g*G.g;x.b=q.color.b*G.b;x.updateStyleString()}else x.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){H=1-q.__2near/(q.__farPlusNear-D.z*q.__farMinusNear);
-x.setRGB(H,H,H)}else q instanceof THREE.MeshNormalMaterial&&x.setRGB(e(D.normalWorld.x),e(D.normalWorld.y),e(D.normalWorld.z));q.wireframe?s.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):s.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+q.opacity);i.appendChild(s)}function c(v,z,y,D,q,n,E){s=d(L++);s.setAttribute("d",
-"M "+v.positionScreen.x+" "+v.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)x.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(K){G.r=C.r;G.g=C.g;G.b=C.b;a(E,q,G);x.r=n.color.r*G.r;x.g=n.color.g*G.g;x.b=n.color.b*G.b;x.updateStyleString()}else x.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshDepthMaterial){H=
-1-n.__2near/(n.__farPlusNear-q.z*n.__farMinusNear);x.setRGB(H,H,H)}else n instanceof THREE.MeshNormalMaterial&&x.setRGB(e(q.normalWorld.x),e(q.normalWorld.y),e(q.normalWorld.z));n.wireframe?s.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):s.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+n.opacity);i.appendChild(s)}
-function d(v){if(M[v]==null){M[v]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&M[v].setAttribute("shape-rendering","crispEdges")}return M[v]}function e(v){return v<0?Math.min((1+v)*0.5,0.5):0.5+Math.min(v*0.5,0.5)}var h=null,f=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,j,k,m,l,o,r,u,B=new THREE.Rectangle,t=new THREE.Rectangle,K=!1,x=new THREE.Color(16777215),G=new THREE.Color(16777215),C=new THREE.Color(0),p=new THREE.Color(0),O=new THREE.Color(0),
-H,P=new THREE.Vector3,M=[],A=[],s,L,Q,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(v){switch(v){case "high":N=1;break;case "low":N=0}};this.setSize=function(v,z){g=v;j=z;k=g/2;m=j/2;i.setAttribute("viewBox",-k+" "+-m+" "+g+" "+j);i.setAttribute("width",g);i.setAttribute("height",j);B.set(-k,-m,k,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(v,z){var y,D,q,n,E,I,w,F;this.autoClear&&
-this.clear();h=f.projectScene(v,z,this.sortElements);Q=L=0;if(K=v.lights.length>0){w=v.lights;C.setRGB(0,0,0);p.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(D=w.length;y<D;y++){q=w[y];n=q.color;if(q instanceof THREE.AmbientLight){C.r+=n.r;C.g+=n.g;C.b+=n.b}else if(q instanceof THREE.DirectionalLight){p.r+=n.r;p.g+=n.g;p.b+=n.b}else if(q instanceof THREE.PointLight){O.r+=n.r;O.g+=n.g;O.b+=n.b}}}y=0;for(D=h.length;y<D;y++){w=h[y];t.empty();if(w instanceof THREE.RenderableParticle){l=w;l.x*=k;l.y*=-m;q=0;for(n=
-w.materials.length;q<n;)q++}else if(w instanceof THREE.RenderableLine){l=w.v1;o=w.v2;l.positionScreen.x*=k;l.positionScreen.y*=-m;o.positionScreen.x*=k;o.positionScreen.y*=-m;t.addPoint(l.positionScreen.x,l.positionScreen.y);t.addPoint(o.positionScreen.x,o.positionScreen.y);if(B.instersects(t)){q=0;for(n=w.materials.length;q<n;)if((F=w.materials[q++])&&F.opacity!=0){E=l;I=o;var J=Q++;if(A[J]==null){A[J]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&A[J].setAttribute("shape-rendering",
-"crispEdges")}s=A[J];s.setAttribute("x1",E.positionScreen.x);s.setAttribute("y1",E.positionScreen.y);s.setAttribute("x2",I.positionScreen.x);s.setAttribute("y2",I.positionScreen.y);if(F instanceof THREE.LineBasicMaterial){x.__styleString=F.color.__styleString;s.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+F.linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.linecap+"; stroke-linejoin: "+F.linejoin);i.appendChild(s)}}}}else if(w instanceof THREE.RenderableFace3){l=
-w.v1;o=w.v2;r=w.v3;l.positionScreen.x*=k;l.positionScreen.y*=-m;o.positionScreen.x*=k;o.positionScreen.y*=-m;r.positionScreen.x*=k;r.positionScreen.y*=-m;t.addPoint(l.positionScreen.x,l.positionScreen.y);t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(r.positionScreen.x,r.positionScreen.y);if(B.instersects(t)){q=0;for(n=w.meshMaterials.length;q<n;){F=w.meshMaterials[q++];if(F instanceof THREE.MeshFaceMaterial){E=0;for(I=w.faceMaterials.length;E<I;)(F=w.faceMaterials[E++])&&F.opacity!=
-0&&b(l,o,r,w,F,v)}else F&&F.opacity!=0&&b(l,o,r,w,F,v)}}}else if(w instanceof THREE.RenderableFace4){l=w.v1;o=w.v2;r=w.v3;u=w.v4;l.positionScreen.x*=k;l.positionScreen.y*=-m;o.positionScreen.x*=k;o.positionScreen.y*=-m;r.positionScreen.x*=k;r.positionScreen.y*=-m;u.positionScreen.x*=k;u.positionScreen.y*=-m;t.addPoint(l.positionScreen.x,l.positionScreen.y);t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);
-if(B.instersects(t)){q=0;for(n=w.meshMaterials.length;q<n;){F=w.meshMaterials[q++];if(F instanceof THREE.MeshFaceMaterial){E=0;for(I=w.faceMaterials.length;E<I;)(F=w.faceMaterials[E++])&&F.opacity!=0&&c(l,o,r,u,w,F,v)}else F&&F.opacity!=0&&c(l,o,r,u,w,F,v)}}}}}};
+THREE.Projector=function(){function a(){var C=g[i]=g[i]||new THREE.RenderableVertex;i++;return C}function b(C,x){return x.z-C.z}function c(C,x){var F=0,M=1,Q=C.z+C.w,L=x.z+x.w,t=-C.z+C.w,G=-x.z+x.w;if(Q>=0&&L>=0&&t>=0&&G>=0)return!0;else if(Q<0&&L<0||t<0&&G<0)return!1;else{if(Q<0)F=Math.max(F,Q/(Q-L));else L<0&&(M=Math.min(M,Q/(Q-L)));if(t<0)F=Math.max(F,t/(t-G));else G<0&&(M=Math.min(M,t/(t-G)));if(M<F)return!1;else{C.lerpSelf(x,F);x.lerpSelf(C,1-M);return!0}}}var d,e,h=[],f,i,g=[],j,m,k=[],n,l=
+[],r,s,y=[],u,H,I=[],D=new THREE.Vector4,w=new THREE.Vector4,o=new THREE.Matrix4,O=new THREE.Matrix4,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Vector4,P=new THREE.Vector4;this.projectVector=function(C,x){o.multiply(x.projectionMatrix,x.matrixWorldInverse);o.multiplyVector3(C);return C};this.unprojectVector=function(C,x){o.multiply(x.matrixWorld,THREE.Matrix4.makeInvert(x.projectionMatrix));o.multiplyVector3(C);return C};
+this.projectObjects=function(C,x,F){x=[];var M,Q,L;e=0;Q=C.objects;C=0;for(M=Q.length;C<M;C++){L=Q[C];var t;if(!(t=!L.visible))if(t=L instanceof THREE.Mesh){a:{t=void 0;for(var G=L.matrixWorld,z=-L.geometry.boundingSphere.radius*Math.max(L.scale.x,Math.max(L.scale.y,L.scale.z)),E=0;E<6;E++){t=J[E].x*G.n14+J[E].y*G.n24+J[E].z*G.n34+J[E].w;if(t<=z){t=!1;break a}}t=!0}t=!t}if(!t){t=h[e]=h[e]||new THREE.RenderableObject;e++;d=t;D.copy(L.position);o.multiplyVector3(D);d.object=L;d.z=D.z;x.push(d)}}F&&
+x.sort(b);return x};this.projectScene=function(C,x,F){var M=[],Q=x.near,L=x.far,t,G,z,E,p,q,A,N,B,v,R,U,W,X,S,V,T;H=s=n=m=0;x.matrixAutoUpdate&&x.update(undefined,!0);C.update(undefined,!1,x);o.multiply(x.projectionMatrix,x.matrixWorldInverse);J[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);J[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);J[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);J[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);J[4].set(o.n41-o.n31,o.n42-
+o.n32,o.n43-o.n33,o.n44-o.n34);J[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(t=0;t<6;t++){B=J[t];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}B=this.projectObjects(C,x,!0);C=0;for(t=B.length;C<t;C++){v=B[C].object;if(v.visible){R=v.matrixWorld;U=v.matrixRotationWorld;W=v.materials;X=v.overdraw;i=0;if(v instanceof THREE.Mesh){S=v.geometry;E=S.vertices;V=S.faces;S=S.faceVertexUvs;G=0;for(z=E.length;G<z;G++){f=a();f.positionWorld.copy(E[G].position);R.multiplyVector3(f.positionWorld);
+f.positionScreen.copy(f.positionWorld);o.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>Q&&f.positionScreen.z<L}E=0;for(G=V.length;E<G;E++){z=V[E];if(z instanceof THREE.Face3){p=g[z.a];q=g[z.b];A=g[z.c];if(p.visible&&q.visible&&A.visible&&(v.doubleSided||v.flipSided!=(A.positionScreen.x-p.positionScreen.x)*(q.positionScreen.y-p.positionScreen.y)-(A.positionScreen.y-p.positionScreen.y)*(q.positionScreen.x-
+p.positionScreen.x)<0)){N=k[m]=k[m]||new THREE.RenderableFace3;m++;j=N;j.v1.copy(p);j.v2.copy(q);j.v3.copy(A)}else continue}else if(z instanceof THREE.Face4){p=g[z.a];q=g[z.b];A=g[z.c];N=g[z.d];if(p.visible&&q.visible&&A.visible&&N.visible&&(v.doubleSided||v.flipSided!=((N.positionScreen.x-p.positionScreen.x)*(q.positionScreen.y-p.positionScreen.y)-(N.positionScreen.y-p.positionScreen.y)*(q.positionScreen.x-p.positionScreen.x)<0||(q.positionScreen.x-A.positionScreen.x)*(N.positionScreen.y-A.positionScreen.y)-
+(q.positionScreen.y-A.positionScreen.y)*(N.positionScreen.x-A.positionScreen.x)<0))){T=l[n]=l[n]||new THREE.RenderableFace4;n++;j=T;j.v1.copy(p);j.v2.copy(q);j.v3.copy(A);j.v4.copy(N)}else continue}j.normalWorld.copy(z.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(z.centroid);R.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);o.multiplyVector3(j.centroidScreen);A=z.vertexNormals;p=0;for(q=A.length;p<q;p++){N=j.vertexNormalsWorld[p];N.copy(A[p]);U.multiplyVector3(N)}p=
+0;for(q=S.length;p<q;p++)if(T=S[p][E]){A=0;for(N=T.length;A<N;A++)j.uvs[p][A]=T[A]}j.meshMaterials=W;j.faceMaterials=z.materials;j.overdraw=X;j.z=j.centroidScreen.z;M.push(j)}}else if(v instanceof THREE.Line){O.multiply(o,R);E=v.geometry.vertices;p=a();p.positionScreen.copy(E[0].position);O.multiplyVector4(p.positionScreen);G=1;for(z=E.length;G<z;G++){p=a();p.positionScreen.copy(E[G].position);O.multiplyVector4(p.positionScreen);q=g[i-2];K.copy(p.positionScreen);P.copy(q.positionScreen);if(c(K,P)){K.multiplyScalar(1/
+K.w);P.multiplyScalar(1/P.w);R=y[s]=y[s]||new THREE.RenderableLine;s++;r=R;r.v1.positionScreen.copy(K);r.v2.positionScreen.copy(P);r.z=Math.max(K.z,P.z);r.materials=v.materials;M.push(r)}}}else if(v instanceof THREE.Particle){w.set(v.position.x,v.position.y,v.position.z,1);o.multiplyVector4(w);w.z/=w.w;if(w.z>0&&w.z<1){R=I[H]=I[H]||new THREE.RenderableParticle;H++;u=R;u.x=w.x/w.w;u.y=w.y/w.w;u.z=w.z;u.rotation=v.rotation.z;u.scale.x=v.scale.x*Math.abs(u.x-(w.x+x.projectionMatrix.n11)/(w.w+x.projectionMatrix.n14));
+u.scale.y=v.scale.y*Math.abs(u.y-(w.y+x.projectionMatrix.n22)/(w.w+x.projectionMatrix.n24));u.materials=v.materials;M.push(u)}}}}F&&M.sort(b);return M}};
+THREE.SVGRenderer=function(){function a(t,G,z){var E,p,q,A;E=0;for(p=t.lights.length;E<p;E++){q=t.lights[E];if(q instanceof THREE.DirectionalLight){A=G.normalWorld.dot(q.position)*q.intensity;if(A>0){z.r+=q.color.r*A;z.g+=q.color.g*A;z.b+=q.color.b*A}}else if(q instanceof THREE.PointLight){P.sub(q.position,G.centroidWorld);P.normalize();A=G.normalWorld.dot(P)*q.intensity;if(A>0){z.r+=q.color.r*A;z.g+=q.color.g*A;z.b+=q.color.b*A}}}}function b(t,G,z,E,p,q){h.data.vertices+=3;h.data.faces++;F=d(M++);
+F.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+z.positionScreen.x+","+z.positionScreen.y+"z");if(p instanceof THREE.MeshBasicMaterial)D.__styleString=p.color.__styleString;else if(p instanceof THREE.MeshLambertMaterial)if(I){w.r=o.r;w.g=o.g;w.b=o.b;a(q,E,w);D.r=p.color.r*w.r;D.g=p.color.g*w.g;D.b=p.color.b*w.b;D.updateStyleString()}else D.__styleString=p.color.__styleString;else if(p instanceof THREE.MeshDepthMaterial){K=1-p.__2near/
+(p.__farPlusNear-E.z*p.__farMinusNear);D.setRGB(K,K,K)}else p instanceof THREE.MeshNormalMaterial&&D.setRGB(e(E.normalWorld.x),e(E.normalWorld.y),e(E.normalWorld.z));p.wireframe?F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):F.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+p.opacity);g.appendChild(F)}function c(t,
+G,z,E,p,q,A){h.data.vertices+=4;h.data.faces++;F=d(M++);F.setAttribute("d","M "+t.positionScreen.x+" "+t.positionScreen.y+" L "+G.positionScreen.x+" "+G.positionScreen.y+" L "+z.positionScreen.x+","+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(q instanceof THREE.MeshBasicMaterial)D.__styleString=q.color.__styleString;else if(q instanceof THREE.MeshLambertMaterial)if(I){w.r=o.r;w.g=o.g;w.b=o.b;a(A,p,w);D.r=q.color.r*w.r;D.g=q.color.g*w.g;D.b=q.color.b*w.b;D.updateStyleString()}else D.__styleString=
+q.color.__styleString;else if(q instanceof THREE.MeshDepthMaterial){K=1-q.__2near/(q.__farPlusNear-p.z*q.__farMinusNear);D.setRGB(K,K,K)}else q instanceof THREE.MeshNormalMaterial&&D.setRGB(e(p.normalWorld.x),e(p.normalWorld.y),e(p.normalWorld.z));q.wireframe?F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):F.setAttribute("style","fill: "+
+D.__styleString+"; fill-opacity: "+q.opacity);g.appendChild(F)}function d(t){if(C[t]==null){C[t]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&C[t].setAttribute("shape-rendering","crispEdges")}return C[t]}function e(t){return t<0?Math.min((1+t)*0.5,0.5):0.5+Math.min(t*0.5,0.5)}var h=this,f=null,i=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,k,n,l,r,s,y,u=new THREE.Rectangle,H=new THREE.Rectangle,I=!1,D=new THREE.Color(16777215),w=new THREE.Color(16777215),
+o=new THREE.Color(0),O=new THREE.Color(0),J=new THREE.Color(0),K,P=new THREE.Vector3,C=[],x=[],F,M,Q,L=1;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(t){switch(t){case "high":L=1;break;case "low":L=0}};this.setSize=function(t,G){j=t;m=G;k=j/2;n=m/2;g.setAttribute("viewBox",-k+" "+-n+" "+j+" "+m);g.setAttribute("width",j);g.setAttribute("height",m);u.set(-k,-n,k,n)};this.clear=function(){for(;g.childNodes.length>
+0;)g.removeChild(g.childNodes[0])};this.render=function(t,G){var z,E,p,q,A,N,B,v;this.autoClear&&this.clear();h.data.vertices=0;h.data.faces=0;f=i.projectScene(t,G,this.sortElements);Q=M=0;if(I=t.lights.length>0){B=t.lights;o.setRGB(0,0,0);O.setRGB(0,0,0);J.setRGB(0,0,0);z=0;for(E=B.length;z<E;z++){p=B[z];q=p.color;if(p instanceof THREE.AmbientLight){o.r+=q.r;o.g+=q.g;o.b+=q.b}else if(p instanceof THREE.DirectionalLight){O.r+=q.r;O.g+=q.g;O.b+=q.b}else if(p instanceof THREE.PointLight){J.r+=q.r;J.g+=
+q.g;J.b+=q.b}}}z=0;for(E=f.length;z<E;z++){B=f[z];H.empty();if(B instanceof THREE.RenderableParticle){l=B;l.x*=k;l.y*=-n;p=0;for(q=B.materials.length;p<q;)p++}else if(B instanceof THREE.RenderableLine){l=B.v1;r=B.v2;l.positionScreen.x*=k;l.positionScreen.y*=-n;r.positionScreen.x*=k;r.positionScreen.y*=-n;H.addPoint(l.positionScreen.x,l.positionScreen.y);H.addPoint(r.positionScreen.x,r.positionScreen.y);if(u.instersects(H)){p=0;for(q=B.materials.length;p<q;)if((v=B.materials[p++])&&v.opacity!=0){A=
+l;N=r;var R=Q++;if(x[R]==null){x[R]=document.createElementNS("http://www.w3.org/2000/svg","line");L==0&&x[R].setAttribute("shape-rendering","crispEdges")}F=x[R];F.setAttribute("x1",A.positionScreen.x);F.setAttribute("y1",A.positionScreen.y);F.setAttribute("x2",N.positionScreen.x);F.setAttribute("y2",N.positionScreen.y);if(v instanceof THREE.LineBasicMaterial){D.__styleString=v.color.__styleString;F.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+v.linewidth+"; stroke-opacity: "+
+v.opacity+"; stroke-linecap: "+v.linecap+"; stroke-linejoin: "+v.linejoin);g.appendChild(F)}}}}else if(B instanceof THREE.RenderableFace3){l=B.v1;r=B.v2;s=B.v3;l.positionScreen.x*=k;l.positionScreen.y*=-n;r.positionScreen.x*=k;r.positionScreen.y*=-n;s.positionScreen.x*=k;s.positionScreen.y*=-n;H.addPoint(l.positionScreen.x,l.positionScreen.y);H.addPoint(r.positionScreen.x,r.positionScreen.y);H.addPoint(s.positionScreen.x,s.positionScreen.y);if(u.instersects(H)){p=0;for(q=B.meshMaterials.length;p<
+q;){v=B.meshMaterials[p++];if(v instanceof THREE.MeshFaceMaterial){A=0;for(N=B.faceMaterials.length;A<N;)(v=B.faceMaterials[A++])&&v.opacity!=0&&b(l,r,s,B,v,t)}else v&&v.opacity!=0&&b(l,r,s,B,v,t)}}}else if(B instanceof THREE.RenderableFace4){l=B.v1;r=B.v2;s=B.v3;y=B.v4;l.positionScreen.x*=k;l.positionScreen.y*=-n;r.positionScreen.x*=k;r.positionScreen.y*=-n;s.positionScreen.x*=k;s.positionScreen.y*=-n;y.positionScreen.x*=k;y.positionScreen.y*=-n;H.addPoint(l.positionScreen.x,l.positionScreen.y);
+H.addPoint(r.positionScreen.x,r.positionScreen.y);H.addPoint(s.positionScreen.x,s.positionScreen.y);H.addPoint(y.positionScreen.x,y.positionScreen.y);if(u.instersects(H)){p=0;for(q=B.meshMaterials.length;p<q;){v=B.meshMaterials[p++];if(v instanceof THREE.MeshFaceMaterial){A=0;for(N=B.faceMaterials.length;A<N;)(v=B.faceMaterials[A++])&&v.opacity!=0&&c(l,r,s,y,B,v,t)}else v&&v.opacity!=0&&c(l,r,s,y,B,v,t)}}}}}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};

+ 132 - 131
build/custom/ThreeWebGL.js

@@ -8,11 +8,11 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(b,d,e){this.x=b;this.y=d;this.z=e;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b,
 d){this.set(b.y*d.z-b.z*d.y,b.z*d.x-b.x*d.z,b.x*d.y-b.y*d.x);return this},crossSelf:function(b){var d=this.x,e=this.y,g=this.z;this.set(e*b.z-g*b.y,g*b.x-d*b.z,d*b.y-e*b.x);return this},multiply:function(b,d){this.set(b.x*d.x,b.y*d.y,b.z*d.z);return this},multiplySelf:function(b){this.set(this.x*b.x,this.y*b.y,this.z*b.z);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b,this.z*b);return this},divideSelf:function(b){this.set(this.x/b.x,this.y/b.y,this.z/b.z);return this},divideScalar:function(b){this.set(this.x/
 b,this.y/b,this.z/b);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x,e=this.y-b.y;b=this.z-b.z;return d*d+e*e+b*b},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var b=
-this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){this.y=Math.asin(b.n13);var d=Math.cos(this.y);if(Math.abs(d)>1.0E-5){this.x=Math.atan2(-b.n23/d,b.n33/d);this.z=Math.atan2(-b.n13/d,b.n11/d)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var d=Math.cos(this.y);this.y=Math.asin(b.n13);if(Math.abs(d)>1.0E-5){this.x=Math.atan2(-b.n23/d,b.n33/d);this.z=Math.atan2(-b.n12/d,b.n11/d)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,e,g){this.set(b||0,d||0,e||0,g||1)};
 THREE.Vector4.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;this.w=g;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,e,g=b.objects,h=[];b=0;for(d=g.length;b<d;b++){e=g[b];e instanceof THREE.Mesh&&(h=h.concat(this.intersectObject(e)))}h.sort(function(o,n){return o.distance-n.distance});return h},intersectObject:function(b){function d(V,L,sa,da){da=da.clone().subSelf(L);sa=sa.clone().subSelf(L);var oa=V.clone().subSelf(L);V=da.dot(da);L=da.dot(sa);da=da.dot(oa);var Z=sa.dot(sa);sa=sa.dot(oa);oa=1/(V*Z-L*L);Z=(Z*da-L*sa)*oa;V=(V*sa-L*da)*oa;return Z>0&&V>0&&Z+V<
+THREE.Ray.prototype={intersectScene:function(b){var d,e,g=b.objects,h=[];b=0;for(d=g.length;b<d;b++){e=g[b];e instanceof THREE.Mesh&&(h=h.concat(this.intersectObject(e)))}h.sort(function(o,n){return o.distance-n.distance});return h},intersectObject:function(b){function d(U,L,ra,da){da=da.clone().subSelf(L);ra=ra.clone().subSelf(L);var pa=U.clone().subSelf(L);U=da.dot(da);L=da.dot(ra);da=da.dot(pa);var $=ra.dot(ra);ra=ra.dot(pa);pa=1/(U*$-L*L);$=($*da-L*ra)*pa;U=(U*ra-L*da)*pa;return $>0&&U>0&&$+U<
 1}var e,g,h,o,n,p,q,v,E,F,H,I=b.geometry,M=I.vertices,N=[];e=0;for(g=I.faces.length;e<g;e++){h=I.faces[e];F=this.origin.clone();H=this.direction.clone();q=b.matrixWorld;o=q.multiplyVector3(M[h.a].position.clone());n=q.multiplyVector3(M[h.b].position.clone());p=q.multiplyVector3(M[h.c].position.clone());q=h instanceof THREE.Face4?q.multiplyVector3(M[h.d].position.clone()):null;v=b.matrixRotationWorld.multiplyVector3(h.normal.clone());E=H.dot(v);if(b.doubleSided||(b.flipSided?E>0:E<0)){v=v.dot((new THREE.Vector3).sub(o,
 F))/E;F=F.addSelf(H.multiplyScalar(v));if(h instanceof THREE.Face3){if(d(F,o,n,p)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:b};N.push(h)}}else if(h instanceof THREE.Face4&&(d(F,o,n,q)||d(F,n,p,q))){h={distance:this.origin.distanceTo(F),point:F,face:h,object:b};N.push(h)}}}return N}};
 THREE.Rectangle=function(){function b(){o=g-d;n=h-e}var d,e,g,h,o,n,p=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return o};this.getHeight=function(){return n};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return g};this.getBottom=function(){return h};this.set=function(q,v,E,F){p=!1;d=q;e=v;g=E;h=F;b()};this.addPoint=function(q,v){if(p){p=!1;d=q;e=v;g=q;h=v}else{d=d<q?d:q;e=e<v?e:v;g=g>q?g:q;h=h>v?h:v}b()};
@@ -23,8 +23,8 @@ THREE.Matrix4=function(b,d,e,g,h,o,n,p,q,v,E,F,H,I,M,N){this.set(b||1,d||0,e||0,
 THREE.Matrix4.prototype={set:function(b,d,e,g,h,o,n,p,q,v,E,F,H,I,M,N){this.n11=b;this.n12=d;this.n13=e;this.n14=g;this.n21=h;this.n22=o;this.n23=n;this.n24=p;this.n31=q;this.n32=v;this.n33=E;this.n34=F;this.n41=H;this.n42=I;this.n43=M;this.n44=N;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var g=THREE.Matrix4.__v1,
 h=THREE.Matrix4.__v2,o=THREE.Matrix4.__v3;o.sub(b,d).normalize();if(o.length()===0)o.z=1;g.cross(e,o).normalize();if(g.length()===0){o.x+=1.0E-4;g.cross(e,o).normalize()}h.cross(o,g).normalize();this.n11=g.x;this.n12=h.x;this.n13=o.x;this.n21=g.y;this.n22=h.y;this.n23=o.y;this.n31=g.z;this.n32=h.z;this.n33=o.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,g=b.z,h=1/(this.n41*d+this.n42*e+this.n43*g+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*g+this.n14)*h;b.y=(this.n21*d+this.n22*e+this.n23*
 g+this.n24)*h;b.z=(this.n31*d+this.n32*e+this.n33*g+this.n34)*h;return b},multiplyVector4:function(b){var d=b.x,e=b.y,g=b.z,h=b.w;b.x=this.n11*d+this.n12*e+this.n13*g+this.n14*h;b.y=this.n21*d+this.n22*e+this.n23*g+this.n24*h;b.z=this.n31*d+this.n32*e+this.n33*g+this.n34*h;b.w=this.n41*d+this.n42*e+this.n43*g+this.n44*h;return b},rotateAxis:function(b){var d=b.x,e=b.y,g=b.z;b.x=d*this.n11+e*this.n12+g*this.n13;b.y=d*this.n21+e*this.n22+g*this.n23;b.z=d*this.n31+e*this.n32+g*this.n33;b.normalize();
-return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,g=b.n12,h=b.n13,o=b.n14,n=b.n21,p=b.n22,q=b.n23,v=b.n24,E=b.n31,F=b.n32,H=b.n33,I=b.n34,M=b.n41,N=b.n42,V=b.n43,L=b.n44,sa=d.n11,da=d.n12,oa=d.n13,Z=d.n14,K=d.n21,Ia=d.n22,
-ca=d.n23,Ea=d.n24,fa=d.n31,c=d.n32,S=d.n33,pa=d.n34;this.n11=e*sa+g*K+h*fa;this.n12=e*da+g*Ia+h*c;this.n13=e*oa+g*ca+h*S;this.n14=e*Z+g*Ea+h*pa+o;this.n21=n*sa+p*K+q*fa;this.n22=n*da+p*Ia+q*c;this.n23=n*oa+p*ca+q*S;this.n24=n*Z+p*Ea+q*pa+v;this.n31=E*sa+F*K+H*fa;this.n32=E*da+F*Ia+H*c;this.n33=E*oa+F*ca+H*S;this.n34=E*Z+F*Ea+H*pa+I;this.n41=M*sa+N*K+V*fa;this.n42=M*da+N*Ia+V*c;this.n43=M*oa+N*ca+V*S;this.n44=M*Z+N*Ea+V*pa+L;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;
+return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,g=b.n12,h=b.n13,o=b.n14,n=b.n21,p=b.n22,q=b.n23,v=b.n24,E=b.n31,F=b.n32,H=b.n33,I=b.n34,M=b.n41,N=b.n42,U=b.n43,L=b.n44,ra=d.n11,da=d.n12,pa=d.n13,$=d.n14,K=d.n21,Ia=d.n22,
+ca=d.n23,Fa=d.n24,fa=d.n31,V=d.n32,c=d.n33,ga=d.n34;this.n11=e*ra+g*K+h*fa;this.n12=e*da+g*Ia+h*V;this.n13=e*pa+g*ca+h*c;this.n14=e*$+g*Fa+h*ga+o;this.n21=n*ra+p*K+q*fa;this.n22=n*da+p*Ia+q*V;this.n23=n*pa+p*ca+q*c;this.n24=n*$+p*Fa+q*ga+v;this.n31=E*ra+F*K+H*fa;this.n32=E*da+F*Ia+H*V;this.n33=E*pa+F*ca+H*c;this.n34=E*$+F*Fa+H*ga+I;this.n41=M*ra+N*K+U*fa;this.n42=M*da+N*Ia+U*V;this.n43=M*pa+N*ca+U*c;this.n44=M*$+N*Fa+U*ga+L;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;
 e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=
 b;return this},determinant:function(){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,h=this.n21,o=this.n22,n=this.n23,p=this.n24,q=this.n31,v=this.n32,E=this.n33,F=this.n34,H=this.n41,I=this.n42,M=this.n43,N=this.n44;return g*n*v*H-e*p*v*H-g*o*E*H+d*p*E*H+e*o*F*H-d*n*F*H-g*n*q*I+e*p*q*I+g*h*E*I-b*p*E*I-e*h*F*I+b*n*F*I+g*o*q*M-d*p*q*M-g*h*v*M+b*p*v*M+d*h*F*M-b*o*F*M-e*o*q*N+d*n*q*N+e*h*v*N-b*n*v*N-d*h*E*N+b*o*E*N},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
 this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=
@@ -34,21 +34,22 @@ b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=t
 1-e,o=b.x,n=b.y,p=b.z,q=h*o,v=h*n;this.set(q*o+e,q*n-g*p,q*p+g*n,0,q*n+g*p,v*n+e,v*p-g*o,0,q*p-g*n,v*p+g*o,h*p*p+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,e=b.y,g=b.z;b=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);var o=Math.cos(g);g=Math.sin(g);var n=b*e,p=d*e;this.n11=h*o;this.n12=-h*g;this.n13=e;this.n21=p*o+b*g;this.n22=-p*g+b*o;this.n23=-d*h;this.n31=-n*o+d*g;this.n32=n*g+d*o;this.n33=
 b*h;return this},setRotationFromQuaternion:function(b){var d=b.x,e=b.y,g=b.z,h=b.w,o=d+d,n=e+e,p=g+g;b=d*o;var q=d*n;d*=p;var v=e*n;e*=p;g*=p;o*=h;n*=h;h*=p;this.n11=1-(v+g);this.n12=q-h;this.n13=d+n;this.n21=q+h;this.n22=1-(b+g);this.n23=e-o;this.n31=d-n;this.n32=e+o;this.n33=1-(b+v);return this},scale:function(b){var d=b.x,e=b.y;b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=
 b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var e=1/d.x,g=1/d.y,h=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*g;this.n22=b.n22*g;this.n32=b.n32*g;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}};
-THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,g=b.n12,h=b.n13,o=b.n14,n=b.n21,p=b.n22,q=b.n23,v=b.n24,E=b.n31,F=b.n32,H=b.n33,I=b.n34,M=b.n41,N=b.n42,V=b.n43,L=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=q*I*N-v*H*N+v*F*V-p*I*V-q*F*L+p*H*L;d.n12=o*H*N-h*I*N-o*F*V+g*I*V+h*F*L-g*H*L;d.n13=h*v*N-o*q*N+o*p*V-g*v*V-h*p*L+g*q*L;d.n14=o*q*F-h*v*F-o*p*H+g*v*H+h*p*I-g*q*I;d.n21=v*H*M-q*I*M-v*E*V+n*I*V+q*E*L-n*H*L;d.n22=h*I*M-o*H*M+o*E*V-e*I*V-h*E*L+e*H*L;d.n23=o*q*M-h*v*M-o*n*V+e*v*V+h*n*L-e*q*L;
-d.n24=h*v*E-o*q*E+o*n*H-e*v*H-h*n*I+e*q*I;d.n31=p*I*M-v*F*M+v*E*N-n*I*N-p*E*L+n*F*L;d.n32=o*F*M-g*I*M-o*E*N+e*I*N+g*E*L-e*F*L;d.n33=h*v*M-o*p*M+o*n*N-e*v*N-g*n*L+e*p*L;d.n34=o*p*E-g*v*E-o*n*F+e*v*F+g*n*I-e*p*I;d.n41=q*F*M-p*H*M-q*E*N+n*H*N+p*E*V-n*F*V;d.n42=g*H*M-h*F*M+h*E*N-e*H*N-g*E*V+e*F*V;d.n43=h*p*M-g*q*M-h*n*N+e*q*N+g*n*V-e*p*V;d.n44=g*q*E-h*p*E+h*n*F-e*q*F-g*n*H+e*p*H;d.multiplyScalar(1/b.determinant());return d};
+THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,g=b.n12,h=b.n13,o=b.n14,n=b.n21,p=b.n22,q=b.n23,v=b.n24,E=b.n31,F=b.n32,H=b.n33,I=b.n34,M=b.n41,N=b.n42,U=b.n43,L=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=q*I*N-v*H*N+v*F*U-p*I*U-q*F*L+p*H*L;d.n12=o*H*N-h*I*N-o*F*U+g*I*U+h*F*L-g*H*L;d.n13=h*v*N-o*q*N+o*p*U-g*v*U-h*p*L+g*q*L;d.n14=o*q*F-h*v*F-o*p*H+g*v*H+h*p*I-g*q*I;d.n21=v*H*M-q*I*M-v*E*U+n*I*U+q*E*L-n*H*L;d.n22=h*I*M-o*H*M+o*E*U-e*I*U-h*E*L+e*H*L;d.n23=o*q*M-h*v*M-o*n*U+e*v*U+h*n*L-e*q*L;
+d.n24=h*v*E-o*q*E+o*n*H-e*v*H-h*n*I+e*q*I;d.n31=p*I*M-v*F*M+v*E*N-n*I*N-p*E*L+n*F*L;d.n32=o*F*M-g*I*M-o*E*N+e*I*N+g*E*L-e*F*L;d.n33=h*v*M-o*p*M+o*n*N-e*v*N-g*n*L+e*p*L;d.n34=o*p*E-g*v*E-o*n*F+e*v*F+g*n*I-e*p*I;d.n41=q*F*M-p*H*M-q*E*N+n*H*N+p*E*U-n*F*U;d.n42=g*H*M-h*F*M+h*E*N-e*H*N-g*E*U+e*F*U;d.n43=h*p*M-g*q*M-h*n*N+e*q*N+g*n*U-e*p*U;d.n44=g*q*E-h*p*E+h*n*F-e*q*F-g*n*H+e*p*H;d.multiplyScalar(1/b.determinant());return d};
 THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,g=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,o=b.n32*b.n21-b.n31*b.n22,n=-b.n33*b.n12+b.n32*b.n13,p=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,v=b.n23*b.n12-b.n22*b.n13,E=-b.n23*b.n11+b.n21*b.n13,F=b.n22*b.n11-b.n21*b.n12;b=b.n11*g+b.n21*n+b.n31*v;if(b==0)throw"matrix not invertible";b=1/b;e[0]=b*g;e[1]=b*h;e[2]=b*o;e[3]=b*n;e[4]=b*p;e[5]=b*q;e[6]=b*v;e[7]=b*E;e[8]=b*F;return d};
 THREE.Matrix4.makeFrustum=function(b,d,e,g,h,o){var n;n=new THREE.Matrix4;n.n11=2*h/(d-b);n.n12=0;n.n13=(d+b)/(d-b);n.n14=0;n.n21=0;n.n22=2*h/(g-e);n.n23=(g+e)/(g-e);n.n24=0;n.n31=0;n.n32=0;n.n33=-(o+h)/(o-h);n.n34=-2*o*h/(o-h);n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(b,d,e,g){var h;b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*d,b*d,h,b,e,g)};
 THREE.Matrix4.makeOrtho=function(b,d,e,g,h,o){var n,p,q,v;n=new THREE.Matrix4;p=d-b;q=e-g;v=o-h;n.n11=2/p;n.n12=0;n.n13=0;n.n14=-((d+b)/p);n.n21=0;n.n22=2/q;n.n23=0;n.n24=-((e+g)/q);n.n31=0;n.n32=0;n.n33=-2/v;n.n34=-((o+h)/v);n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
-THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(this.position,b,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
+THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
 undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d instanceof THREE.Scene===!1&&d!==undefined;)d=d.parent;d!==undefined&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(b,d,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var g=this.children.length;b<g;b++)this.children[b].update(this.matrixWorld,
 d,e)}};THREE.Quaternion=function(b,d,e,g){this.set(b||0,d||0,e||0,g!==undefined?g:1)};
-THREE.Quaternion.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;this.w=g;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,g=b.y*d,h=b.z*d;b=Math.cos(g);g=Math.sin(g);d=Math.cos(-h);h=Math.sin(-h);var o=Math.cos(e);e=Math.sin(e);var n=b*d,p=g*h;this.w=n*o-p*e;this.x=n*e+p*o;this.y=g*d*o+b*h*e;this.z=b*h*o-g*d*e;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,e=this.y,g=this.z,h=this.w,o=b.x,n=b.y,p=b.z;b=b.w;this.x=d*b+h*o+e*p-g*n;this.y=e*b+h*n+g*o-d*p;this.z=g*b+h*p+d*n-e*o;this.w=h*b-d*o-e*n-g*p;return this},
-multiplyVector3:function(b,d){d||(d=b);var e=b.x,g=b.y,h=b.z,o=this.x,n=this.y,p=this.z,q=this.w,v=q*e+n*h-p*g,E=q*g+p*e-o*h,F=q*h+o*g-n*e;e=-o*e-n*g-p*h;d.x=v*q+e*-o+E*-p-F*-n;d.y=E*q+e*-n+F*-o-v*-p;d.z=F*q+e*-p+v*-n-E*-o;return d}};
-THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var o=Math.acos(h),n=Math.sqrt(1-h*h);if(Math.abs(n)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*o)/n;g=Math.sin(g*o)/n;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;this.w=g;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,g=b.y*d,h=b.z*d;b=Math.cos(g);g=Math.sin(g);d=Math.cos(-h);h=Math.sin(-h);var o=Math.cos(e);e=Math.sin(e);var n=b*d,p=g*h;this.w=n*o-p*e;this.x=n*e+p*o;this.y=g*d*o+b*h*e;this.z=b*h*o-g*d*e;return this},setFromAxisAngle:function(b,d){var e=d/2,g=Math.sin(e);this.x=b.x*g;this.y=
+b.y*g;this.z=b.z*g;this.w=Math.cos(e);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},
+multiplySelf:function(b){var d=this.x,e=this.y,g=this.z,h=this.w,o=b.x,n=b.y,p=b.z;b=b.w;this.x=d*b+h*o+e*p-g*n;this.y=e*b+h*n+g*o-d*p;this.z=g*b+h*p+d*n-e*o;this.w=h*b-d*o-e*n-g*p;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,g=b.y,h=b.z,o=this.x,n=this.y,p=this.z,q=this.w,v=q*e+n*h-p*g,E=
+q*g+p*e-o*h,F=q*h+o*g-n*e;e=-o*e-n*g-p*h;d.x=v*q+e*-o+E*-p-F*-n;d.y=E*q+e*-n+F*-o-v*-p;d.z=F*q+e*-p+v*-n-E*-o;return d}};
+THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var o=Math.acos(h),n=Math.sqrt(1-h*h);if(Math.abs(n)<0.001){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*o)/n;g=Math.sin(g*o)/n;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,g,h,o){this.a=b;this.b=d;this.c=e;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=o instanceof Array?o:[o];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,g,h,o,n){this.a=b;this.b=d;this.c=e;this.d=g;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=o instanceof THREE.Color?o:new THREE.Color;this.vertexColors=o instanceof Array?o:[];this.vertexTangents=[];this.materials=n instanceof Array?n:[n];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -56,19 +57,19 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,e;b=0;for(d=this.f
 e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,e,g,h,o,n,p=new THREE.Vector3,q=new THREE.Vector3;g=0;for(h=this.faces.length;g<h;g++){o=this.faces[g];if(b&&o.vertexNormals.length){p.set(0,0,0);d=0;for(e=o.vertexNormals.length;d<e;d++)p.addSelf(o.vertexNormals[d]);p.divideScalar(3)}else{d=this.vertices[o.a];e=this.vertices[o.b];n=this.vertices[o.c];p.sub(n.position,e.position);q.sub(d.position,e.position);p.crossSelf(q)}p.isZero()||
 p.normalize();o.normal.copy(p)}},computeVertexNormals:function(){var b,d,e,g;if(this.__tmpVertices==undefined){g=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)g[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{g=
 this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)g[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3){g[e.a].addSelf(e.normal);g[e.b].addSelf(e.normal);g[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){g[e.a].addSelf(e.normal);g[e.b].addSelf(e.normal);g[e.c].addSelf(e.normal);g[e.d].addSelf(e.normal)}}b=0;for(d=this.vertices.length;b<d;b++)g[b].normalize();b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(g[e.a]);
-e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(g[e.a]);e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c]);e.vertexNormals[3].copy(g[e.d])}}},computeTangents:function(){function b(aa,ma,na,ga,Y,wa,qa){p=aa.vertices[ma].position;q=aa.vertices[na].position;v=aa.vertices[ga].position;E=n[Y];F=n[wa];H=n[qa];I=q.x-p.x;M=v.x-p.x;N=q.y-p.y;V=v.y-p.y;L=q.z-p.z;sa=v.z-p.z;da=F.u-E.u;oa=H.u-E.u;Z=F.v-E.v;K=H.v-E.v;Ia=1/(da*
-K-oa*Z);c.set((K*I-Z*M)*Ia,(K*N-Z*V)*Ia,(K*L-Z*sa)*Ia);S.set((da*M-oa*I)*Ia,(da*V-oa*N)*Ia,(da*sa-oa*L)*Ia);Ea[ma].addSelf(c);Ea[na].addSelf(c);Ea[ga].addSelf(c);fa[ma].addSelf(S);fa[na].addSelf(S);fa[ga].addSelf(S)}var d,e,g,h,o,n,p,q,v,E,F,H,I,M,N,V,L,sa,da,oa,Z,K,Ia,ca,Ea=[],fa=[],c=new THREE.Vector3,S=new THREE.Vector3,pa=new THREE.Vector3,ra=new THREE.Vector3,Fa=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){Ea[d]=new THREE.Vector3;fa[d]=new THREE.Vector3}d=0;for(e=this.faces.length;d<
-e;d++){o=this.faces[d];n=this.faceVertexUvs[0][d];if(o instanceof THREE.Face3)b(this,o.a,o.b,o.c,0,1,2);else if(o instanceof THREE.Face4){b(this,o.a,o.b,o.c,0,1,2);b(this,o.a,o.b,o.d,0,1,3)}}var ta=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){o=this.faces[d];for(g=0;g<o.vertexNormals.length;g++){Fa.copy(o.vertexNormals[g]);h=o[ta[g]];ca=Ea[h];pa.copy(ca);pa.subSelf(Fa.multiplyScalar(Fa.dot(ca))).normalize();ra.cross(o.vertexNormals[g],ca);h=ra.dot(fa[h]);h=h<0?-1:1;o.vertexTangents[g]=new THREE.Vector4(pa.x,
-pa.y,pa.z,h)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
+e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(g[e.a]);e.vertexNormals[1].copy(g[e.b]);e.vertexNormals[2].copy(g[e.c]);e.vertexNormals[3].copy(g[e.d])}}},computeTangents:function(){function b(Y,na,oa,ha,Z,va,qa){p=Y.vertices[na].position;q=Y.vertices[oa].position;v=Y.vertices[ha].position;E=n[Z];F=n[va];H=n[qa];I=q.x-p.x;M=v.x-p.x;N=q.y-p.y;U=v.y-p.y;L=q.z-p.z;ra=v.z-p.z;da=F.u-E.u;pa=H.u-E.u;$=F.v-E.v;K=H.v-E.v;Ia=1/(da*K-
+pa*$);V.set((K*I-$*M)*Ia,(K*N-$*U)*Ia,(K*L-$*ra)*Ia);c.set((da*M-pa*I)*Ia,(da*U-pa*N)*Ia,(da*ra-pa*L)*Ia);Fa[na].addSelf(V);Fa[oa].addSelf(V);Fa[ha].addSelf(V);fa[na].addSelf(c);fa[oa].addSelf(c);fa[ha].addSelf(c)}var d,e,g,h,o,n,p,q,v,E,F,H,I,M,N,U,L,ra,da,pa,$,K,Ia,ca,Fa=[],fa=[],V=new THREE.Vector3,c=new THREE.Vector3,ga=new THREE.Vector3,xa=new THREE.Vector3,sa=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){Fa[d]=new THREE.Vector3;fa[d]=new THREE.Vector3}d=0;for(e=this.faces.length;d<
+e;d++){o=this.faces[d];n=this.faceVertexUvs[0][d];if(o instanceof THREE.Face3)b(this,o.a,o.b,o.c,0,1,2);else if(o instanceof THREE.Face4){b(this,o.a,o.b,o.c,0,1,2);b(this,o.a,o.b,o.d,0,1,3)}}var ya=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){o=this.faces[d];for(g=0;g<o.vertexNormals.length;g++){sa.copy(o.vertexNormals[g]);h=o[ya[g]];ca=Fa[h];ga.copy(ca);ga.subSelf(sa.multiplyScalar(sa.dot(ca))).normalize();xa.cross(o.vertexNormals[g],ca);h=xa.dot(fa[h]);h=h<0?-1:1;o.vertexTangents[g]=new THREE.Vector4(ga.x,
+ga.y,ga.z,h)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
 if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,e=this.vertices.length;d<e;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere=
 {radius:b}},computeEdgeFaces:function(){function b(q,v){return Math.min(q,v)+"_"+Math.max(q,v)}function d(q,v,E){if(q[v]===undefined){q[v]={set:{},array:[]};q[v].set[E]=1;q[v].array.push(E)}else if(q[v].set[E]===undefined){q[v].set[E]=1;q[v].array.push(E)}}var e,g,h,o,n,p={};e=0;for(g=this.faces.length;e<g;e++){n=this.faces[e];if(n instanceof THREE.Face3){h=b(n.a,n.b);d(p,h,e);h=b(n.b,n.c);d(p,h,e);h=b(n.a,n.c);d(p,h,e)}else if(n instanceof THREE.Face4){h=b(n.b,n.d);d(p,h,e);h=b(n.a,n.b);d(p,h,e);
 h=b(n.a,n.d);d(p,h,e);h=b(n.b,n.c);d(p,h,e);h=b(n.c,n.d);d(p,h,e)}}e=0;for(g=this.edges.length;e<g;e++){n=this.edges[e];h=n.vertexIndices[0];o=n.vertexIndices[1];n.faceIndices=p[b(h,o)].array;for(h=0;h<n.faceIndices.length;h++){o=n.faceIndices[h];n.faces.push(this.faces[o])}}}};THREE.GeometryIdCounter=0;
 THREE.Camera=function(b,d,e,g,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=e||0.1;this.far=g||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
-THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(b,d,e){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);d=!0}else if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(b,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1;this.distance=e||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=d||1;this.distance=e||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.LensFlare=function(b,d,e,g){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=undefined;b!==undefined&&this.add(b,d,e,g)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
+THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(b,d,e){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);d=!0}else{this.matrixAutoUpdate&&this.updateMatrix();if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;d=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
+THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=d||1;this.distance=e||0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=d||1;this.distance=e||0};THREE.PointLight.prototype=new THREE.Light;
+THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.LensFlare=function(b,d,e,g){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=undefined;b!==undefined&&this.add(b,d,e,g)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
 THREE.LensFlare.prototype.add=function(b,d,e,g){d===undefined&&(d=-1);e===undefined&&(e=0);if(g===undefined)g=THREE.BillboardBlending;e=Math.min(e,Math.max(0,e));this.lensFlares.push({texture:b,size:d,distance:e,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:g})};
 THREE.LensFlare.prototype.updateLensFlares=function(){var b,d=this.lensFlares.length,e,g=-this.positionScreen.x*2,h=-this.positionScreen.y*2;for(b=0;b<d;b++){e=this.lensFlares[b];e.x=this.positionScreen.x+g*e.distance;e.y=this.positionScreen.y+h*e.distance;e.wantedRotation=e.x*Math.PI*0.25;e.rotation+=(e.wantedRotation-e.rotation)*0.25}};
 THREE.Material=function(b){this.id=THREE.MaterialCounter.value++;b=b||{};this.opacity=b.opacity!==undefined?b.opacity:1;this.transparent=b.transparent!==undefined?b.transparent:!1;this.blending=b.blending!==undefined?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==undefined?b.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
@@ -116,27 +117,27 @@ THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=functi
 THREE.LOD.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}if(this.LODs.length>1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var g=1;g<this.LODs.length;g++)if(b>=this.LODs[g].visibleAtDistance){this.LODs[g-1].object3D.visible=
 !1;this.LODs[g].object3D.visible=!0}else break;for(;g<this.LODs.length;g++)this.LODs[g].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.ShadowVolume=function(b,d){if(b instanceof THREE.Mesh){THREE.Mesh.call(this,b.geometry,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);b.addChild(this)}else THREE.Mesh.call(this,b,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);this.calculateShadowVolumeGeometry()};
 THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,e,g,h,o,n,p,q,v,E,F,H,I,M=new THREE.Geometry;M.vertices=this.geometry.vertices;g=M.faces=this.geometry.faces;var N=M.egdes=this.geometry.edges,V=M.edgeFaces=[];h=0;var L=[];b=0;for(d=g.length;b<d;b++){e=g[b];L.push(h);h+=e instanceof THREE.Face3?3:4;e.vertexNormals[0]=e.normal;e.vertexNormals[1]=e.normal;e.vertexNormals[2]=e.normal;if(e instanceof THREE.Face4)e.vertexNormals[3]=
+THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,d,e,g,h,o,n,p,q,v,E,F,H,I,M=new THREE.Geometry;M.vertices=this.geometry.vertices;g=M.faces=this.geometry.faces;var N=M.egdes=this.geometry.edges,U=M.edgeFaces=[];h=0;var L=[];b=0;for(d=g.length;b<d;b++){e=g[b];L.push(h);h+=e instanceof THREE.Face3?3:4;e.vertexNormals[0]=e.normal;e.vertexNormals[1]=e.normal;e.vertexNormals[2]=e.normal;if(e instanceof THREE.Face4)e.vertexNormals[3]=
 e.normal}b=0;for(d=N.length;b<d;b++){p=N[b];e=p.faces[0];g=p.faces[1];h=p.faceIndices[0];o=p.faceIndices[1];n=p.vertexIndices[0];p=p.vertexIndices[1];if(e.a===n){q="a";E=L[h]+0}else if(e.b===n){q="b";E=L[h]+1}else if(e.c===n){q="c";E=L[h]+2}else if(e.d===n){q="d";E=L[h]+3}if(e.a===p){q+="a";F=L[h]+0}else if(e.b===p){q+="b";F=L[h]+1}else if(e.c===p){q+="c";F=L[h]+2}else if(e.d===p){q+="d";F=L[h]+3}if(g.a===n){v="a";H=L[o]+0}else if(g.b===n){v="b";H=L[o]+1}else if(g.c===n){v="c";H=L[o]+2}else if(g.d===
-n){v="d";H=L[o]+3}if(g.a===p){v+="a";I=L[o]+0}else if(g.b===p){v+="b";I=L[o]+1}else if(g.c===p){v+="c";I=L[o]+2}else if(g.d===p){v+="d";I=L[o]+3}if(q==="ac"||q==="ad"||q==="ca"||q==="da"){if(E>F){e=E;E=F;F=e}}else if(E<F){e=E;E=F;F=e}if(v==="ac"||v==="ad"||v==="ca"||v==="da"){if(H>I){e=H;H=I;I=e}}else if(H<I){e=H;H=I;I=e}e=new THREE.Face4(E,F,H,I);e.normal.set(1,0,0);V.push(e)}this.geometry=M}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
+n){v="d";H=L[o]+3}if(g.a===p){v+="a";I=L[o]+0}else if(g.b===p){v+="b";I=L[o]+1}else if(g.c===p){v+="c";I=L[o]+2}else if(g.d===p){v+="d";I=L[o]+3}if(q==="ac"||q==="ad"||q==="ca"||q==="da"){if(E>F){e=E;E=F;F=e}}else if(E<F){e=E;E=F;F=e}if(v==="ac"||v==="ad"||v==="ca"||v==="da"){if(H>I){e=H;H=I;I=e}}else if(H<I){e=H;H=I;I=e}e=new THREE.Face4(E,F,H,I);e.normal.set(1,0,0);U.push(e)}this.geometry=M}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
 THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,g=this.geometry.edgeFaces,h=b.faces;b=b.vertices;var o=h.length,n,p,q,v,E,F=["a","b","c","d"];for(q=0;q<o;q++){p=d.length;n=h[q];if(n instanceof THREE.Face4){v=4;p=new THREE.Face4(p,p+1,p+2,p+3)}else{v=3;p=new THREE.Face3(p,p+1,p+2)}p.normal.copy(n.normal);e.push(p);
 for(p=0;p<v;p++){E=b[n[F[p]]];d.push(new THREE.Vertex(E.position.clone()))}}for(o=0;o<h.length-1;o++){b=e[o];for(n=o+1;n<h.length;n++){p=e[n];p=this.facesShareEdge(d,b,p);if(p!==undefined){p=new THREE.Face4(p.indices[0],p.indices[3],p.indices[2],p.indices[1]);p.normal.set(1,0,0);g.push(p)}}}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var g,h,o,n,p,q,v,E,F,H,I,M,N,V=0,L=["a","b","c","d"];g=d instanceof THREE.Face4?4:3;h=e instanceof THREE.Face4?4:3;for(M=0;M<g;M++){o=d[L[M]];p=b[o];for(N=0;N<h;N++){n=e[L[N]];q=b[n];if(Math.abs(p.position.x-q.position.x)<1.0E-4&&Math.abs(p.position.y-q.position.y)<1.0E-4&&Math.abs(p.position.z-q.position.z)<1.0E-4){V++;if(V===1){v=p;E=q;F=o;H=n;I=L[M]}if(V===2){I+=L[M];return I==="ad"||I==="ac"?{faces:[d,e],vertices:[v,E,q,p],indices:[F,
+THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var g,h,o,n,p,q,v,E,F,H,I,M,N,U=0,L=["a","b","c","d"];g=d instanceof THREE.Face4?4:3;h=e instanceof THREE.Face4?4:3;for(M=0;M<g;M++){o=d[L[M]];p=b[o];for(N=0;N<h;N++){n=e[L[N]];q=b[n];if(Math.abs(p.position.x-q.position.x)<1.0E-4&&Math.abs(p.position.y-q.position.y)<1.0E-4&&Math.abs(p.position.z-q.position.z)<1.0E-4){U++;if(U===1){v=p;E=q;F=o;H=n;I=L[M]}if(U===2){I+=L[M];return I==="ad"||I==="ac"?{faces:[d,e],vertices:[v,E,q,p],indices:[F,
 H,n,o],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[v,p,q,E],indices:[F,o,n,H],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
 THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1){this.objects.push(b);this.__objectsAdded.push(b)}for(var d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};
 THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else if(b instanceof THREE.Sound){d=this.sounds.indexOf(b);d!==-1&&this.sounds.splice(d,1)}else if(!(b instanceof THREE.Camera)){d=this.objects.indexOf(b);if(d!==-1){this.objects.splice(d,1);this.__objectsRemoved.push(b)}}for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,e){this.color=new THREE.Color(b);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==undefined?d:2.5E-4};
-THREE.Projector=function(){function b(){var c=q[p]=q[p]||new THREE.RenderableVertex;p++;return c}function d(c,S){return S.z-c.z}function e(c,S){var pa=0,ra=1,Fa=c.z+c.w,ta=S.z+S.w,aa=-c.z+c.w,ma=-S.z+S.w;if(Fa>=0&&ta>=0&&aa>=0&&ma>=0)return!0;else if(Fa<0&&ta<0||aa<0&&ma<0)return!1;else{if(Fa<0)pa=Math.max(pa,Fa/(Fa-ta));else ta<0&&(ra=Math.min(ra,Fa/(Fa-ta)));if(aa<0)pa=Math.max(pa,aa/(aa-ma));else ma<0&&(ra=Math.min(ra,aa/(aa-ma)));if(ra<pa)return!1;else{c.lerpSelf(S,pa);S.lerpSelf(c,1-ra);return!0}}}
-var g,h,o=[],n,p,q=[],v,E,F=[],H,I=[],M,N,V=[],L,sa,da=[],oa=new THREE.Vector4,Z=new THREE.Vector4,K=new THREE.Matrix4,Ia=new THREE.Matrix4,ca=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ea=new THREE.Vector4,fa=new THREE.Vector4;this.projectVector=function(c,S){K.multiply(S.projectionMatrix,S.matrixWorldInverse);K.multiplyVector3(c);return c};this.unprojectVector=function(c,S){K.multiply(S.matrixWorld,THREE.Matrix4.makeInvert(S.projectionMatrix));
-K.multiplyVector3(c);return c};this.projectObjects=function(c,S,pa){S=[];var ra,Fa,ta;h=0;Fa=c.objects;c=0;for(ra=Fa.length;c<ra;c++){ta=Fa[c];var aa;if(!(aa=!ta.visible))if(aa=ta instanceof THREE.Mesh){a:{aa=void 0;for(var ma=ta.matrixWorld,na=-ta.geometry.boundingSphere.radius*Math.max(ta.scale.x,Math.max(ta.scale.y,ta.scale.z)),ga=0;ga<6;ga++){aa=ca[ga].x*ma.n14+ca[ga].y*ma.n24+ca[ga].z*ma.n34+ca[ga].w;if(aa<=na){aa=!1;break a}}aa=!0}aa=!aa}if(!aa){aa=o[h]=o[h]||new THREE.RenderableObject;h++;
-g=aa;oa.copy(ta.position);K.multiplyVector3(oa);g.object=ta;g.z=oa.z;S.push(g)}}pa&&S.sort(d);return S};this.projectScene=function(c,S,pa){var ra=[],Fa=S.near,ta=S.far,aa,ma,na,ga,Y,wa,qa,ya,za,$,Pa,Ta,Xa,Ua,Sa,R,J;sa=N=H=E=0;S.matrixAutoUpdate&&S.updateMatrix();c.update(undefined,!1,S);K.multiply(S.projectionMatrix,S.matrixWorldInverse);ca[0].set(K.n41-K.n11,K.n42-K.n12,K.n43-K.n13,K.n44-K.n14);ca[1].set(K.n41+K.n11,K.n42+K.n12,K.n43+K.n13,K.n44+K.n14);ca[2].set(K.n41+K.n21,K.n42+K.n22,K.n43+K.n23,
-K.n44+K.n24);ca[3].set(K.n41-K.n21,K.n42-K.n22,K.n43-K.n23,K.n44-K.n24);ca[4].set(K.n41-K.n31,K.n42-K.n32,K.n43-K.n33,K.n44-K.n34);ca[5].set(K.n41+K.n31,K.n42+K.n32,K.n43+K.n33,K.n44+K.n34);for(aa=0;aa<6;aa++){za=ca[aa];za.divideScalar(Math.sqrt(za.x*za.x+za.y*za.y+za.z*za.z))}za=this.projectObjects(c,S,!0);c=0;for(aa=za.length;c<aa;c++){$=za[c].object;if($.visible){Pa=$.matrixWorld;Ta=$.matrixRotationWorld;Xa=$.materials;Ua=$.overdraw;p=0;if($ instanceof THREE.Mesh){Sa=$.geometry;ga=Sa.vertices;
-R=Sa.faces;Sa=Sa.faceVertexUvs;ma=0;for(na=ga.length;ma<na;ma++){n=b();n.positionWorld.copy(ga[ma].position);Pa.multiplyVector3(n.positionWorld);n.positionScreen.copy(n.positionWorld);K.multiplyVector4(n.positionScreen);n.positionScreen.x/=n.positionScreen.w;n.positionScreen.y/=n.positionScreen.w;n.visible=n.positionScreen.z>Fa&&n.positionScreen.z<ta}ga=0;for(ma=R.length;ga<ma;ga++){na=R[ga];if(na instanceof THREE.Face3){Y=q[na.a];wa=q[na.b];qa=q[na.c];if(Y.visible&&wa.visible&&qa.visible&&($.doubleSided||
-$.flipSided!=(qa.positionScreen.x-Y.positionScreen.x)*(wa.positionScreen.y-Y.positionScreen.y)-(qa.positionScreen.y-Y.positionScreen.y)*(wa.positionScreen.x-Y.positionScreen.x)<0)){ya=F[E]=F[E]||new THREE.RenderableFace3;E++;v=ya;v.v1.copy(Y);v.v2.copy(wa);v.v3.copy(qa)}else continue}else if(na instanceof THREE.Face4){Y=q[na.a];wa=q[na.b];qa=q[na.c];ya=q[na.d];if(Y.visible&&wa.visible&&qa.visible&&ya.visible&&($.doubleSided||$.flipSided!=((ya.positionScreen.x-Y.positionScreen.x)*(wa.positionScreen.y-
-Y.positionScreen.y)-(ya.positionScreen.y-Y.positionScreen.y)*(wa.positionScreen.x-Y.positionScreen.x)<0||(wa.positionScreen.x-qa.positionScreen.x)*(ya.positionScreen.y-qa.positionScreen.y)-(wa.positionScreen.y-qa.positionScreen.y)*(ya.positionScreen.x-qa.positionScreen.x)<0))){J=I[H]=I[H]||new THREE.RenderableFace4;H++;v=J;v.v1.copy(Y);v.v2.copy(wa);v.v3.copy(qa);v.v4.copy(ya)}else continue}v.normalWorld.copy(na.normal);Ta.multiplyVector3(v.normalWorld);v.centroidWorld.copy(na.centroid);Pa.multiplyVector3(v.centroidWorld);
-v.centroidScreen.copy(v.centroidWorld);K.multiplyVector3(v.centroidScreen);qa=na.vertexNormals;Y=0;for(wa=qa.length;Y<wa;Y++){ya=v.vertexNormalsWorld[Y];ya.copy(qa[Y]);Ta.multiplyVector3(ya)}Y=0;for(wa=Sa.length;Y<wa;Y++)if(J=Sa[Y][ga]){qa=0;for(ya=J.length;qa<ya;qa++)v.uvs[Y][qa]=J[qa]}v.meshMaterials=Xa;v.faceMaterials=na.materials;v.overdraw=Ua;v.z=v.centroidScreen.z;ra.push(v)}}else if($ instanceof THREE.Line){Ia.multiply(K,Pa);ga=$.geometry.vertices;Y=b();Y.positionScreen.copy(ga[0].position);
-Ia.multiplyVector4(Y.positionScreen);ma=1;for(na=ga.length;ma<na;ma++){Y=b();Y.positionScreen.copy(ga[ma].position);Ia.multiplyVector4(Y.positionScreen);wa=q[p-2];Ea.copy(Y.positionScreen);fa.copy(wa.positionScreen);if(e(Ea,fa)){Ea.multiplyScalar(1/Ea.w);fa.multiplyScalar(1/fa.w);Pa=V[N]=V[N]||new THREE.RenderableLine;N++;M=Pa;M.v1.positionScreen.copy(Ea);M.v2.positionScreen.copy(fa);M.z=Math.max(Ea.z,fa.z);M.materials=$.materials;ra.push(M)}}}else if($ instanceof THREE.Particle){Z.set($.position.x,
-$.position.y,$.position.z,1);K.multiplyVector4(Z);Z.z/=Z.w;if(Z.z>0&&Z.z<1){Pa=da[sa]=da[sa]||new THREE.RenderableParticle;sa++;L=Pa;L.x=Z.x/Z.w;L.y=Z.y/Z.w;L.z=Z.z;L.rotation=$.rotation.z;L.scale.x=$.scale.x*Math.abs(L.x-(Z.x+S.projectionMatrix.n11)/(Z.w+S.projectionMatrix.n14));L.scale.y=$.scale.y*Math.abs(L.y-(Z.y+S.projectionMatrix.n22)/(Z.w+S.projectionMatrix.n24));L.materials=$.materials;ra.push(L)}}}}pa&&ra.sort(d);return ra}};
+THREE.Projector=function(){function b(){var V=q[p]=q[p]||new THREE.RenderableVertex;p++;return V}function d(V,c){return c.z-V.z}function e(V,c){var ga=0,xa=1,sa=V.z+V.w,ya=c.z+c.w,Y=-V.z+V.w,na=-c.z+c.w;if(sa>=0&&ya>=0&&Y>=0&&na>=0)return!0;else if(sa<0&&ya<0||Y<0&&na<0)return!1;else{if(sa<0)ga=Math.max(ga,sa/(sa-ya));else ya<0&&(xa=Math.min(xa,sa/(sa-ya)));if(Y<0)ga=Math.max(ga,Y/(Y-na));else na<0&&(xa=Math.min(xa,Y/(Y-na)));if(xa<ga)return!1;else{V.lerpSelf(c,ga);c.lerpSelf(V,1-xa);return!0}}}var g,
+h,o=[],n,p,q=[],v,E,F=[],H,I=[],M,N,U=[],L,ra,da=[],pa=new THREE.Vector4,$=new THREE.Vector4,K=new THREE.Matrix4,Ia=new THREE.Matrix4,ca=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Fa=new THREE.Vector4,fa=new THREE.Vector4;this.projectVector=function(V,c){K.multiply(c.projectionMatrix,c.matrixWorldInverse);K.multiplyVector3(V);return V};this.unprojectVector=function(V,c){K.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));
+K.multiplyVector3(V);return V};this.projectObjects=function(V,c,ga){c=[];var xa,sa,ya;h=0;sa=V.objects;V=0;for(xa=sa.length;V<xa;V++){ya=sa[V];var Y;if(!(Y=!ya.visible))if(Y=ya instanceof THREE.Mesh){a:{Y=void 0;for(var na=ya.matrixWorld,oa=-ya.geometry.boundingSphere.radius*Math.max(ya.scale.x,Math.max(ya.scale.y,ya.scale.z)),ha=0;ha<6;ha++){Y=ca[ha].x*na.n14+ca[ha].y*na.n24+ca[ha].z*na.n34+ca[ha].w;if(Y<=oa){Y=!1;break a}}Y=!0}Y=!Y}if(!Y){Y=o[h]=o[h]||new THREE.RenderableObject;h++;g=Y;pa.copy(ya.position);
+K.multiplyVector3(pa);g.object=ya;g.z=pa.z;c.push(g)}}ga&&c.sort(d);return c};this.projectScene=function(V,c,ga){var xa=[],sa=c.near,ya=c.far,Y,na,oa,ha,Z,va,qa,za,Aa,aa,Pa,Ta,Xa,Ua,Sa,R,J;ra=N=H=E=0;c.matrixAutoUpdate&&c.update(undefined,!0);V.update(undefined,!1,c);K.multiply(c.projectionMatrix,c.matrixWorldInverse);ca[0].set(K.n41-K.n11,K.n42-K.n12,K.n43-K.n13,K.n44-K.n14);ca[1].set(K.n41+K.n11,K.n42+K.n12,K.n43+K.n13,K.n44+K.n14);ca[2].set(K.n41+K.n21,K.n42+K.n22,K.n43+K.n23,K.n44+K.n24);ca[3].set(K.n41-
+K.n21,K.n42-K.n22,K.n43-K.n23,K.n44-K.n24);ca[4].set(K.n41-K.n31,K.n42-K.n32,K.n43-K.n33,K.n44-K.n34);ca[5].set(K.n41+K.n31,K.n42+K.n32,K.n43+K.n33,K.n44+K.n34);for(Y=0;Y<6;Y++){Aa=ca[Y];Aa.divideScalar(Math.sqrt(Aa.x*Aa.x+Aa.y*Aa.y+Aa.z*Aa.z))}Aa=this.projectObjects(V,c,!0);V=0;for(Y=Aa.length;V<Y;V++){aa=Aa[V].object;if(aa.visible){Pa=aa.matrixWorld;Ta=aa.matrixRotationWorld;Xa=aa.materials;Ua=aa.overdraw;p=0;if(aa instanceof THREE.Mesh){Sa=aa.geometry;ha=Sa.vertices;R=Sa.faces;Sa=Sa.faceVertexUvs;
+na=0;for(oa=ha.length;na<oa;na++){n=b();n.positionWorld.copy(ha[na].position);Pa.multiplyVector3(n.positionWorld);n.positionScreen.copy(n.positionWorld);K.multiplyVector4(n.positionScreen);n.positionScreen.x/=n.positionScreen.w;n.positionScreen.y/=n.positionScreen.w;n.visible=n.positionScreen.z>sa&&n.positionScreen.z<ya}ha=0;for(na=R.length;ha<na;ha++){oa=R[ha];if(oa instanceof THREE.Face3){Z=q[oa.a];va=q[oa.b];qa=q[oa.c];if(Z.visible&&va.visible&&qa.visible&&(aa.doubleSided||aa.flipSided!=(qa.positionScreen.x-
+Z.positionScreen.x)*(va.positionScreen.y-Z.positionScreen.y)-(qa.positionScreen.y-Z.positionScreen.y)*(va.positionScreen.x-Z.positionScreen.x)<0)){za=F[E]=F[E]||new THREE.RenderableFace3;E++;v=za;v.v1.copy(Z);v.v2.copy(va);v.v3.copy(qa)}else continue}else if(oa instanceof THREE.Face4){Z=q[oa.a];va=q[oa.b];qa=q[oa.c];za=q[oa.d];if(Z.visible&&va.visible&&qa.visible&&za.visible&&(aa.doubleSided||aa.flipSided!=((za.positionScreen.x-Z.positionScreen.x)*(va.positionScreen.y-Z.positionScreen.y)-(za.positionScreen.y-
+Z.positionScreen.y)*(va.positionScreen.x-Z.positionScreen.x)<0||(va.positionScreen.x-qa.positionScreen.x)*(za.positionScreen.y-qa.positionScreen.y)-(va.positionScreen.y-qa.positionScreen.y)*(za.positionScreen.x-qa.positionScreen.x)<0))){J=I[H]=I[H]||new THREE.RenderableFace4;H++;v=J;v.v1.copy(Z);v.v2.copy(va);v.v3.copy(qa);v.v4.copy(za)}else continue}v.normalWorld.copy(oa.normal);Ta.multiplyVector3(v.normalWorld);v.centroidWorld.copy(oa.centroid);Pa.multiplyVector3(v.centroidWorld);v.centroidScreen.copy(v.centroidWorld);
+K.multiplyVector3(v.centroidScreen);qa=oa.vertexNormals;Z=0;for(va=qa.length;Z<va;Z++){za=v.vertexNormalsWorld[Z];za.copy(qa[Z]);Ta.multiplyVector3(za)}Z=0;for(va=Sa.length;Z<va;Z++)if(J=Sa[Z][ha]){qa=0;for(za=J.length;qa<za;qa++)v.uvs[Z][qa]=J[qa]}v.meshMaterials=Xa;v.faceMaterials=oa.materials;v.overdraw=Ua;v.z=v.centroidScreen.z;xa.push(v)}}else if(aa instanceof THREE.Line){Ia.multiply(K,Pa);ha=aa.geometry.vertices;Z=b();Z.positionScreen.copy(ha[0].position);Ia.multiplyVector4(Z.positionScreen);
+na=1;for(oa=ha.length;na<oa;na++){Z=b();Z.positionScreen.copy(ha[na].position);Ia.multiplyVector4(Z.positionScreen);va=q[p-2];Fa.copy(Z.positionScreen);fa.copy(va.positionScreen);if(e(Fa,fa)){Fa.multiplyScalar(1/Fa.w);fa.multiplyScalar(1/fa.w);Pa=U[N]=U[N]||new THREE.RenderableLine;N++;M=Pa;M.v1.positionScreen.copy(Fa);M.v2.positionScreen.copy(fa);M.z=Math.max(Fa.z,fa.z);M.materials=aa.materials;xa.push(M)}}}else if(aa instanceof THREE.Particle){$.set(aa.position.x,aa.position.y,aa.position.z,1);
+K.multiplyVector4($);$.z/=$.w;if($.z>0&&$.z<1){Pa=da[ra]=da[ra]||new THREE.RenderableParticle;ra++;L=Pa;L.x=$.x/$.w;L.y=$.y/$.w;L.z=$.z;L.rotation=aa.rotation.z;L.scale.x=aa.scale.x*Math.abs(L.x-($.x+c.projectionMatrix.n11)/($.w+c.projectionMatrix.n14));L.scale.y=aa.scale.y*Math.abs(L.y-($.y+c.projectionMatrix.n22)/($.w+c.projectionMatrix.n24));L.materials=aa.materials;xa.push(L)}}}}ga&&xa.sort(d);return xa}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,e){e&&b.update(undefined,!1,d);e=b.sounds;var g,h=e.length;for(g=0;g<h;g++){b=e[g];this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34);this.soundPosition.subSelf(d.position);if(b.isPlaying&&b.isLoaded){b.isAddedToDOM||b.addToDOM(this.domElement);b.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
@@ -169,118 +170,118 @@ THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.Shade
 "void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
 THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
 THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(f,s,j){var k,m,w,x=f.vertices,u=x.length,A=f.colors,t=A.length,y=f.__vertexArray,z=f.__colorArray,D=f.__sortArray,B=f.__dirtyVertices,O=f.__dirtyColors;if(j.sortParticles){Pa.multiplySelf(j.matrixWorld);for(k=0;k<u;k++){m=x[k].position;Ua.copy(m);Pa.multiplyVector3(Ua);D[k]=[Ua.z,k]}D.sort(function(W,P){return P[0]-W[0]});for(k=0;k<u;k++){m=x[D[k][1]].position;w=k*3;y[w]=m.x;y[w+1]=m.y;y[w+2]=m.z}for(k=0;k<t;k++){w=k*3;color=A[D[k][1]];z[w]=color.r;z[w+1]=
-color.g;z[w+2]=color.b}}else{if(B)for(k=0;k<u;k++){m=x[k].position;w=k*3;y[w]=m.x;y[w+1]=m.y;y[w+2]=m.z}if(O)for(k=0;k<t;k++){color=A[k];w=k*3;z[w]=color.r;z[w+1]=color.g;z[w+2]=color.b}}if(B||j.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,y,s)}if(O||j.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,z,s)}}function e(f,s,j,k,m){k.program||aa.initMaterial(k,s,j,m);var w=k.program,x=w.uniforms,u=k.uniforms;
-if(w!=ra){c.useProgram(w);ra=w}c.uniformMatrix4fv(x.projectionMatrix,!1,Ta);if(j&&(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial||k instanceof THREE.LineBasicMaterial||k instanceof THREE.ParticleBasicMaterial||k.fog)){u.fogColor.value=j.color;if(j instanceof THREE.Fog){u.fogNear.value=j.near;u.fogFar.value=j.far}else if(j instanceof THREE.FogExp2)u.fogDensity.value=j.density}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||
-k.lights){var A,t,y=0,z=0,D=0,B,O,W,P,X=Sa,Ga=X.directional.colors,T=X.directional.positions,Q=X.point.colors,U=X.point.positions,ua=X.point.distances,r=0,G=0;j=t=P=0;for(A=s.length;j<A;j++){t=s[j];B=t.color;O=t.position;W=t.intensity;P=t.distance;if(t instanceof THREE.AmbientLight){y+=B.r;z+=B.g;D+=B.b}else if(t instanceof THREE.DirectionalLight){P=r*3;Ga[P]=B.r*W;Ga[P+1]=B.g*W;Ga[P+2]=B.b*W;T[P]=O.x;T[P+1]=O.y;T[P+2]=O.z;r+=1}else if(t instanceof THREE.PointLight){t=G*3;Q[t]=B.r*W;Q[t+1]=B.g*W;
-Q[t+2]=B.b*W;U[t]=O.x;U[t+1]=O.y;U[t+2]=O.z;ua[G]=P;G+=1}}for(j=r*3;j<Ga.length;j++)Ga[j]=0;for(j=G*3;j<Q.length;j++)Q[j]=0;X.point.length=G;X.directional.length=r;X.ambient[0]=y;X.ambient[1]=z;X.ambient[2]=D;j=Sa;u.enableLighting.value=j.directional.length+j.point.length;u.ambientLightColor.value=j.ambient;u.directionalLightColor.value=j.directional.colors;u.directionalLightDirection.value=j.directional.positions;u.pointLightColor.value=j.point.colors;u.pointLightPosition.value=j.point.positions;
+THREE.WebGLRenderer=function(b){function d(f,r,j){var k,m,w,x=f.vertices,u=x.length,A=f.colors,t=A.length,y=f.__vertexArray,z=f.__colorArray,D=f.__sortArray,B=f.__dirtyVertices,O=f.__dirtyColors;if(j.sortParticles){Pa.multiplySelf(j.matrixWorld);for(k=0;k<u;k++){m=x[k].position;Ua.copy(m);Pa.multiplyVector3(Ua);D[k]=[Ua.z,k]}D.sort(function(W,P){return P[0]-W[0]});for(k=0;k<u;k++){m=x[D[k][1]].position;w=k*3;y[w]=m.x;y[w+1]=m.y;y[w+2]=m.z}for(k=0;k<t;k++){w=k*3;color=A[D[k][1]];z[w]=color.r;z[w+1]=
+color.g;z[w+2]=color.b}}else{if(B)for(k=0;k<u;k++){m=x[k].position;w=k*3;y[w]=m.x;y[w+1]=m.y;y[w+2]=m.z}if(O)for(k=0;k<t;k++){color=A[k];w=k*3;z[w]=color.r;z[w+1]=color.g;z[w+2]=color.b}}if(B||j.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,y,r)}if(O||j.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,z,r)}}function e(f,r,j,k,m){k.program||V.initMaterial(k,r,j,m);var w=k.program,x=w.uniforms,u=k.uniforms;if(w!=
+sa){c.useProgram(w);sa=w}c.uniformMatrix4fv(x.projectionMatrix,!1,Ta);if(j&&(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial||k instanceof THREE.LineBasicMaterial||k instanceof THREE.ParticleBasicMaterial||k.fog)){u.fogColor.value=j.color;if(j instanceof THREE.Fog){u.fogNear.value=j.near;u.fogFar.value=j.far}else if(j instanceof THREE.FogExp2)u.fogDensity.value=j.density}if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||
+k.lights){var A,t,y=0,z=0,D=0,B,O,W,P,X=Sa,Ga=X.directional.colors,S=X.directional.positions,Q=X.point.colors,T=X.point.positions,ta=X.point.distances,s=0,G=0;j=t=P=0;for(A=r.length;j<A;j++){t=r[j];B=t.color;O=t.position;W=t.intensity;P=t.distance;if(t instanceof THREE.AmbientLight){y+=B.r;z+=B.g;D+=B.b}else if(t instanceof THREE.DirectionalLight){P=s*3;Ga[P]=B.r*W;Ga[P+1]=B.g*W;Ga[P+2]=B.b*W;S[P]=O.x;S[P+1]=O.y;S[P+2]=O.z;s+=1}else if(t instanceof THREE.PointLight){t=G*3;Q[t]=B.r*W;Q[t+1]=B.g*W;
+Q[t+2]=B.b*W;T[t]=O.x;T[t+1]=O.y;T[t+2]=O.z;ta[G]=P;G+=1}}for(j=s*3;j<Ga.length;j++)Ga[j]=0;for(j=G*3;j<Q.length;j++)Q[j]=0;X.point.length=G;X.directional.length=s;X.ambient[0]=y;X.ambient[1]=z;X.ambient[2]=D;j=Sa;u.enableLighting.value=j.directional.length+j.point.length;u.ambientLightColor.value=j.ambient;u.directionalLightColor.value=j.directional.colors;u.directionalLightDirection.value=j.directional.positions;u.pointLightColor.value=j.point.colors;u.pointLightPosition.value=j.point.positions;
 u.pointLightDistance.value=j.point.distances}if(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial){u.diffuse.value=k.color;u.opacity.value=k.opacity;u.map.texture=k.map;u.lightMap.texture=k.lightMap;u.envMap.texture=k.envMap;u.reflectivity.value=k.reflectivity;u.refractionRatio.value=k.refractionRatio;u.combine.value=k.combine;u.useRefract.value=k.envMap&&k.envMap.mapping instanceof THREE.CubeRefractionMapping}if(k instanceof THREE.LineBasicMaterial){u.diffuse.value=
-k.color;u.opacity.value=k.opacity}else if(k instanceof THREE.ParticleBasicMaterial){u.psColor.value=k.color;u.opacity.value=k.opacity;u.size.value=k.size;u.scale.value=S.height/2;u.map.texture=k.map}else if(k instanceof THREE.MeshPhongMaterial){u.ambient.value=k.ambient;u.specular.value=k.specular;u.shininess.value=k.shininess}else if(k instanceof THREE.MeshDepthMaterial){u.mNear.value=f.near;u.mFar.value=f.far;u.opacity.value=k.opacity}else if(k instanceof THREE.MeshNormalMaterial)u.opacity.value=
+k.color;u.opacity.value=k.opacity}else if(k instanceof THREE.ParticleBasicMaterial){u.psColor.value=k.color;u.opacity.value=k.opacity;u.size.value=k.size;u.scale.value=ga.height/2;u.map.texture=k.map}else if(k instanceof THREE.MeshPhongMaterial){u.ambient.value=k.ambient;u.specular.value=k.specular;u.shininess.value=k.shininess}else if(k instanceof THREE.MeshDepthMaterial){u.mNear.value=f.near;u.mFar.value=f.far;u.opacity.value=k.opacity}else if(k instanceof THREE.MeshNormalMaterial)u.opacity.value=
 k.opacity;for(var i in u)if(z=w.uniforms[i]){A=u[i];y=A.type;j=A.value;if(y=="i")c.uniform1i(z,j);else if(y=="f")c.uniform1f(z,j);else if(y=="fv1")c.uniform1fv(z,j);else if(y=="fv")c.uniform3fv(z,j);else if(y=="v2")c.uniform2f(z,j.x,j.y);else if(y=="v3")c.uniform3f(z,j.x,j.y,j.z);else if(y=="v4")c.uniform4f(z,j.x,j.y,j.z,j.w);else if(y=="c")c.uniform3f(z,j.r,j.g,j.b);else if(y=="t"){c.uniform1i(z,j);if(A=A.texture)if(A.image instanceof Array&&A.image.length==6){if(A.image.length==6){if(A.needsUpdate){if(A.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,
-A.image.__webglTextureCube);for(y=0;y<6;++y)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,0,0,c.RGBA,c.UNSIGNED_BYTE,A.image[y])}else{A.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,A.image.__webglTextureCube);for(y=0;y<6;++y)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,A.image[y]);A.__webglInit=!0}Z(c.TEXTURE_CUBE_MAP,A,A.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);A.needsUpdate=!1}c.activeTexture(c.TEXTURE0+j);c.bindTexture(c.TEXTURE_CUBE_MAP,
+A.image.__webglTextureCube);for(y=0;y<6;++y)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,0,0,c.RGBA,c.UNSIGNED_BYTE,A.image[y])}else{A.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,A.image.__webglTextureCube);for(y=0;y<6;++y)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,A.image[y]);A.__webglInit=!0}$(c.TEXTURE_CUBE_MAP,A,A.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);A.needsUpdate=!1}c.activeTexture(c.TEXTURE0+j);c.bindTexture(c.TEXTURE_CUBE_MAP,
 A.image.__webglTextureCube)}}else K(A,j)}}c.uniformMatrix4fv(x.modelViewMatrix,!1,m._modelViewMatrixArray);c.uniformMatrix3fv(x.normalMatrix,!1,m._normalMatrixArray);(k instanceof THREE.MeshShaderMaterial||k instanceof THREE.MeshPhongMaterial||k.envMap)&&c.uniform3f(x.cameraPosition,f.position.x,f.position.y,f.position.z);(k instanceof THREE.MeshShaderMaterial||k.envMap||k.skinning)&&c.uniformMatrix4fv(x.objectMatrix,!1,m._objectMatrixArray);(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial||
-k instanceof THREE.MeshShaderMaterial||k.skinning)&&c.uniformMatrix4fv(x.viewMatrix,!1,Xa);if(k instanceof THREE.ShadowVolumeDynamicMaterial){f=u.directionalLightDirection.value;f[0]=-s[1].position.x;f[1]=-s[1].position.y;f[2]=-s[1].position.z;c.uniform3fv(x.directionalLightDirection,f);c.uniformMatrix4fv(x.objectMatrix,!1,m._objectMatrixArray);c.uniformMatrix4fv(x.viewMatrix,!1,Xa)}if(k.skinning){c.uniformMatrix4fv(x.cameraInverseMatrix,!1,Xa);c.uniformMatrix4fv(x.boneGlobalMatrices,!1,m.boneMatrices)}return w}
-function g(f,s,j,k,m,w){if(k.opacity!=0){var x;f=e(f,s,j,k,w).attributes;if(k.morphTargets){s=k.program.attributes;w.morphTargetBase!==-1?c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[w.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);c.vertexAttribPointer(s.position,3,c.FLOAT,!1,0,0);if(w.morphTargetForcedOrder.length){j=0;for(var u=w.morphTargetForcedOrder,A=w.morphTargetInfluences;j<k.numSupportedMorphTargets&&j<u.length;){c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[u[j]]);
-c.vertexAttribPointer(s["morphTarget"+j],3,c.FLOAT,!1,0,0);w.__webglMorphTargetInfluences[j]=A[u[j]];j++}}else{u=[];var t=-1,y=0;A=w.morphTargetInfluences;var z,D=A.length;j=0;for(w.morphTargetBase!==-1&&(u[w.morphTargetBase]=!0);j<k.numSupportedMorphTargets;){for(z=0;z<D;z++)if(!u[z]&&A[z]>t){y=z;t=A[y]}c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[y]);c.vertexAttribPointer(s["morphTarget"+j],3,c.FLOAT,!1,0,0);w.__webglMorphTargetInfluences[j]=t;u[y]=1;t=-1;j++}}c.uniform1fv(k.program.uniforms.morphTargetInfluences,
-w.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(m.__webglCustomAttributes)for(x in m.__webglCustomAttributes)if(f[x]>=0){s=m.__webglCustomAttributes[x];c.bindBuffer(c.ARRAY_BUFFER,s.buffer);c.vertexAttribPointer(f[x],s.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglNormalBuffer);
+k instanceof THREE.MeshShaderMaterial||k.skinning)&&c.uniformMatrix4fv(x.viewMatrix,!1,Xa);if(k instanceof THREE.ShadowVolumeDynamicMaterial){f=u.directionalLightDirection.value;f[0]=-r[1].position.x;f[1]=-r[1].position.y;f[2]=-r[1].position.z;c.uniform3fv(x.directionalLightDirection,f);c.uniformMatrix4fv(x.objectMatrix,!1,m._objectMatrixArray);c.uniformMatrix4fv(x.viewMatrix,!1,Xa)}if(k.skinning){c.uniformMatrix4fv(x.cameraInverseMatrix,!1,Xa);c.uniformMatrix4fv(x.boneGlobalMatrices,!1,m.boneMatrices)}return w}
+function g(f,r,j,k,m,w){if(k.opacity!=0){var x;f=e(f,r,j,k,w).attributes;if(k.morphTargets){r=k.program.attributes;w.morphTargetBase!==-1?c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[w.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,!1,0,0);if(w.morphTargetForcedOrder.length){j=0;for(var u=w.morphTargetForcedOrder,A=w.morphTargetInfluences;j<k.numSupportedMorphTargets&&j<u.length;){c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[u[j]]);
+c.vertexAttribPointer(r["morphTarget"+j],3,c.FLOAT,!1,0,0);w.__webglMorphTargetInfluences[j]=A[u[j]];j++}}else{u=[];var t=-1,y=0;A=w.morphTargetInfluences;var z,D=A.length;j=0;for(w.morphTargetBase!==-1&&(u[w.morphTargetBase]=!0);j<k.numSupportedMorphTargets;){for(z=0;z<D;z++)if(!u[z]&&A[z]>t){y=z;t=A[y]}c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[y]);c.vertexAttribPointer(r["morphTarget"+j],3,c.FLOAT,!1,0,0);w.__webglMorphTargetInfluences[j]=t;u[y]=1;t=-1;j++}}c.uniform1fv(k.program.uniforms.morphTargetInfluences,
+w.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(m.__webglCustomAttributes)for(x in m.__webglCustomAttributes)if(f[x]>=0){r=m.__webglCustomAttributes[x];c.bindBuffer(c.ARRAY_BUFFER,r.buffer);c.vertexAttribPointer(f[x],r.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglNormalBuffer);
 c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(m.__webglUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webglUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(m.__webglUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webglUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);
 if(k.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,
-4,c.FLOAT,!1,0,0)}if(w instanceof THREE.Mesh)if(k.wireframe){c.lineWidth(k.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer);c.drawElements(c.LINES,m.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer);c.drawElements(c.TRIANGLES,m.__webglFaceCount,c.UNSIGNED_SHORT,0)}else if(w instanceof THREE.Line){w=w.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(k.linewidth);c.drawArrays(w,0,m.__webglLineCount)}else if(w instanceof
-THREE.ParticleSystem)c.drawArrays(c.POINTS,0,m.__webglParticleCount);else w instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,m.__webglVertexCount)}}function h(f,s,j){if(!f.__webglVertexBuffer)f.__webglVertexBuffer=c.createBuffer();if(!f.__webglNormalBuffer)f.__webglNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(s.attributes.position);c.vertexAttribPointer(s.attributes.position,
-3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webglNormalBuffer);if(j==THREE.FlatShading){var k,m,w,x,u,A,t,y,z,D,B=f.count*3;for(D=0;D<B;D+=9){j=f.normalArray;k=j[D];m=j[D+1];w=j[D+2];x=j[D+3];A=j[D+4];y=j[D+5];u=j[D+6];t=j[D+7];z=j[D+8];k=(k+x+u)/3;m=(m+A+t)/3;w=(w+y+z)/3;j[D]=k;j[D+1]=m;j[D+2]=w;j[D+3]=k;j[D+4]=m;j[D+5]=w;j[D+6]=k;j[D+7]=m;j[D+8]=w}}c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(s.attributes.normal);c.vertexAttribPointer(s.attributes.normal,
-3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function o(f){if(ma!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ma=f.doubleSided}if(na!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);na=f.flipSided}}function n(f){if(Y!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);Y=f}}function p(f){$[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);$[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);$[2].set(f.n41+f.n21,f.n42+f.n22,
-f.n43+f.n23,f.n44+f.n24);$[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);$[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);$[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var s;for(f=0;f<6;f++){s=$[f];s.divideScalar(Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z))}}function q(f){for(var s=f.matrixWorld,j=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),k=0;k<6;k++){f=$[k].x*s.n14+$[k].y*s.n24+$[k].z*s.n34+$[k].w;if(f<=j)return!1}return!0}function v(f,
-s){f.list[f.count]=s;f.count+=1}function E(f){var s,j,k=f.object,m=f.opaque,w=f.transparent;w.count=0;f=m.count=0;for(s=k.materials.length;f<s;f++){j=k.materials[f];j.transparent?v(w,j):v(m,j)}}function F(f){var s,j,k,m,w=f.object,x=f.buffer,u=f.opaque,A=f.transparent;A.count=0;f=u.count=0;for(k=w.materials.length;f<k;f++){s=w.materials[f];if(s instanceof THREE.MeshFaceMaterial){s=0;for(j=x.materials.length;s<j;s++)(m=x.materials[s])&&(m.transparent?v(A,m):v(u,m))}else(m=s)&&(m.transparent?v(A,m):
-v(u,m))}}function H(f,s){return s.z-f.z}function I(f){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var s,j=f.lights.length,k,m=f.lights,w=[],x,u,A,t,y,z=f.__webglShadowVolumes.length;for(s=0;s<j;s++){k=f.lights[s];if(k instanceof THREE.DirectionalLight){w[0]=-k.position.x;
-w[1]=-k.position.y;w[2]=-k.position.z;for(y=0;y<z;y++){k=f.__webglShadowVolumes[y].object;x=f.__webglShadowVolumes[y].buffer;u=k.materials[0];u.program||aa.initMaterial(u,m,undefined,k);u=u.program;A=u.uniforms;t=u.attributes;if(ra!==u){c.useProgram(u);ra=u;c.uniformMatrix4fv(A.projectionMatrix,!1,Ta);c.uniformMatrix4fv(A.viewMatrix,!1,Xa);c.uniform3fv(A.directionalLightDirection,w)}k.matrixWorld.flattenToArray(k._objectMatrixArray);c.uniformMatrix4fv(A.objectMatrix,!1,k._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,
-x.__webglVertexBuffer);c.vertexAttribPointer(t.position,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,x.__webglNormalBuffer);c.vertexAttribPointer(t.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);c.cullFace(c.FRONT);c.drawElements(c.TRIANGLES,x.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,x.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,
-c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);ga="";ra=R.program;c.useProgram(R.program);c.uniformMatrix4fv(R.projectionLocation,!1,Ta);c.uniform1f(R.darknessLocation,R.darkness);c.bindBuffer(c.ARRAY_BUFFER,R.vertexBuffer);c.vertexAttribPointer(R.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(R.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,R.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);
-c.enable(c.DEPTH_TEST);c.depthMask(ta)}function M(f,s){var j,k,m;j=_sprite.attributes;var w=_sprite.uniforms,x=za/ya,u,A=[],t=ya*0.5,y=za*0.5,z=!0;c.useProgram(_sprite.program);ra=_sprite.program;ga="";if(!ob){c.enableVertexAttribArray(_sprite.attributes.position);c.enableVertexAttribArray(_sprite.attributes.uv);ob=!0}c.disable(c.CULL_FACE);c.enable(c.BLEND);c.depthMask(!0);c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.vertexAttribPointer(j.position,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(j.uv,
-2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.uniformMatrix4fv(w.projectionMatrix,!1,Ta);c.activeTexture(c.TEXTURE0);c.uniform1i(w.map,0);j=0;for(k=f.__webglSprites.length;j<k;j++){m=f.__webglSprites[j];if(m.useScreenCoordinates)m.z=-m.position.z;else{m._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);m.z=-m._modelViewMatrix.n34}}f.__webglSprites.sort(H);j=0;for(k=f.__webglSprites.length;j<k;j++){m=f.__webglSprites[j];if(m.material===
-undefined&&m.map&&m.map.image&&m.map.image.width){if(m.useScreenCoordinates){c.uniform1i(w.useScreenCoordinates,1);c.uniform3f(w.screenPosition,(m.position.x-t)/t,(y-m.position.y)/y,Math.max(0,Math.min(1,m.position.z)))}else{c.uniform1i(w.useScreenCoordinates,0);c.uniform1i(w.affectedByDistance,m.affectedByDistance?1:0);c.uniformMatrix4fv(w.modelViewMatrix,!1,m._modelViewMatrixArray)}u=m.map.image.width/(m.affectedByDistance?1:za);A[0]=u*x*m.scale.x;A[1]=u*m.scale.y;c.uniform2f(w.uvScale,m.uvScale.x,
-m.uvScale.y);c.uniform2f(w.uvOffset,m.uvOffset.x,m.uvOffset.y);c.uniform2f(w.alignment,m.alignment.x,m.alignment.y);c.uniform1f(w.opacity,m.opacity);c.uniform1f(w.rotation,m.rotation);c.uniform2fv(w.scale,A);if(m.mergeWith3D&&!z){c.enable(c.DEPTH_TEST);z=!0}else if(!m.mergeWith3D&&z){c.disable(c.DEPTH_TEST);z=!1}oa(m.blending);K(m.map,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function N(f,s){var j,k,m=f.__webglLensFlares.length,
-w,x,u,A=new THREE.Vector3,t=za/ya,y=ya*0.5,z=za*0.5,D=16/za,B=[D*t,D],O=[1,1,0],W=[1,1],P=J.uniforms;j=J.attributes;c.useProgram(J.program);ra=J.program;ga="";if(!pb){c.enableVertexAttribArray(J.attributes.vertex);c.enableVertexAttribArray(J.attributes.uv);pb=!0}c.uniform1i(P.occlusionMap,0);c.uniform1i(P.map,1);c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.vertexAttribPointer(j.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(j.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);
-c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.activeTexture(c.TEXTURE1);for(k=0;k<m;k++){j=f.__webglLensFlares[k].object;A.set(j.matrixWorld.n14,j.matrixWorld.n24,j.matrixWorld.n34);s.matrixWorldInverse.multiplyVector3(A);s.projectionMatrix.multiplyVector3(A);O[0]=A.x;O[1]=A.y;O[2]=A.z;W[0]=O[0]*y+y;W[1]=O[1]*z+z;if(J.hasVertexTexture||W[0]>0&&W[0]<ya&&W[1]>0&&W[1]<za){c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,
-0,c.RGB,W[0]-8,W[1]-8,16,16,0);c.uniform1i(P.renderType,0);c.uniform2fv(P.scale,B);c.uniform3fv(P.screenPosition,O);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,W[0]-8,W[1]-8,16,16,0);c.uniform1i(P.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);j.positionScreen.x=O[0];j.positionScreen.y=
-O[1];j.positionScreen.z=O[2];j.customUpdateCallback?j.customUpdateCallback(j):j.updateLensFlares();c.uniform1i(P.renderType,2);c.enable(c.BLEND);w=0;for(x=j.lensFlares.length;w<x;w++){u=j.lensFlares[w];if(u.opacity>0.0010&&u.scale>0.0010){O[0]=u.x;O[1]=u.y;O[2]=u.z;D=u.size*u.scale/za;B[0]=D*t;B[1]=D;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,u.rotation);c.uniform1f(P.opacity,u.opacity);oa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,
-0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function V(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function L(f){var s,j,k,m,w;if(f instanceof THREE.Mesh){j=f.geometry;for(s in j.geometryGroups){k=j.geometryGroups[s];w=!1;for(m in k.__webglCustomAttributes)if(k.__webglCustomAttributes[m].needsUpdate){w=!0;break}if(j.__dirtyVertices||
-j.__dirtyMorphTargets||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,u=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,D=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0,T=void 0,Q=void 0,U=void 0,ua=void 0;z=void 0;D=void 0;t=void 0;B=void 0;t=void 0;var r=void 0,G=void 0;z=void 0;r=void 0;G=void 0;var i=void 0,Ka=void 0;r=void 0;G=void 0;i=void 0;Ka=void 0;r=void 0;G=void 0;i=void 0;Ka=void 0;r=void 0;
-G=void 0;i=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;r=void 0;G=void 0;i=void 0;var Va=void 0,va=0,Aa=0,Za=0,$a=0,Ja=0,La=0,ea=0,Ma=0,xa=0,C=0,Ba=0;G=r=0;var Ca=k.__vertexArray,fb=k.__uvArray,gb=k.__uv2Array,Qa=k.__normalArray,ha=k.__tangentArray,Da=k.__colorArray,ia=k.__skinVertexAArray,ja=k.__skinVertexBArray,ka=k.__skinIndexArray,la=k.__skinWeightArray,hb=k.__morphTargetsArrays,Ra=k.__webglCustomAttributes;i=void 0;var Na=k.__faceArray,Oa=k.__lineArray,qb=k.__needsSmoothNormals;W=k.__vertexColorType;
+4,c.FLOAT,!1,0,0)}if(w instanceof THREE.Mesh){if(k.wireframe){c.lineWidth(k.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer);c.drawElements(c.LINES,m.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer);c.drawElements(c.TRIANGLES,m.__webglFaceCount,c.UNSIGNED_SHORT,0)}V.data.vertices+=m.__webglFaceCount;V.data.faces+=m.__webglFaceCount/3}else if(w instanceof THREE.Line){w=w.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(k.linewidth);
+c.drawArrays(w,0,m.__webglLineCount)}else if(w instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,m.__webglParticleCount);else w instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,m.__webglVertexCount)}}function h(f,r,j){if(!f.__webglVertexBuffer)f.__webglVertexBuffer=c.createBuffer();if(!f.__webglNormalBuffer)f.__webglNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(r.attributes.position);
+c.vertexAttribPointer(r.attributes.position,3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webglNormalBuffer);if(j==THREE.FlatShading){var k,m,w,x,u,A,t,y,z,D,B=f.count*3;for(D=0;D<B;D+=9){j=f.normalArray;k=j[D];m=j[D+1];w=j[D+2];x=j[D+3];A=j[D+4];y=j[D+5];u=j[D+6];t=j[D+7];z=j[D+8];k=(k+x+u)/3;m=(m+A+t)/3;w=(w+y+z)/3;j[D]=k;j[D+1]=m;j[D+2]=w;j[D+3]=k;j[D+4]=m;j[D+5]=w;j[D+6]=k;j[D+7]=m;j[D+8]=w}}c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(r.attributes.normal);
+c.vertexAttribPointer(r.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function o(f){if(na!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);na=f.doubleSided}if(oa!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);oa=f.flipSided}}function n(f){if(Z!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);Z=f}}function p(f){aa[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);aa[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+
+f.n14);aa[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);aa[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);aa[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);aa[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var r;for(f=0;f<6;f++){r=aa[f];r.divideScalar(Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z))}}function q(f){for(var r=f.matrixWorld,j=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),k=0;k<6;k++){f=aa[k].x*r.n14+aa[k].y*r.n24+aa[k].z*
+r.n34+aa[k].w;if(f<=j)return!1}return!0}function v(f,r){f.list[f.count]=r;f.count+=1}function E(f){var r,j,k=f.object,m=f.opaque,w=f.transparent;w.count=0;f=m.count=0;for(r=k.materials.length;f<r;f++){j=k.materials[f];j.transparent?v(w,j):v(m,j)}}function F(f){var r,j,k,m,w=f.object,x=f.buffer,u=f.opaque,A=f.transparent;A.count=0;f=u.count=0;for(k=w.materials.length;f<k;f++){r=w.materials[f];if(r instanceof THREE.MeshFaceMaterial){r=0;for(j=x.materials.length;r<j;r++)(m=x.materials[r])&&(m.transparent?
+v(A,m):v(u,m))}else(m=r)&&(m.transparent?v(A,m):v(u,m))}}function H(f,r){return r.z-f.z}function I(f){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var r,j=f.lights.length,k,m=f.lights,w=[],x,u,A,t,y,z=f.__webglShadowVolumes.length;for(r=0;r<j;r++){k=f.lights[r];if(k instanceof
+THREE.DirectionalLight){w[0]=-k.position.x;w[1]=-k.position.y;w[2]=-k.position.z;for(y=0;y<z;y++){k=f.__webglShadowVolumes[y].object;x=f.__webglShadowVolumes[y].buffer;u=k.materials[0];u.program||V.initMaterial(u,m,undefined,k);u=u.program;A=u.uniforms;t=u.attributes;if(sa!==u){c.useProgram(u);sa=u;c.uniformMatrix4fv(A.projectionMatrix,!1,Ta);c.uniformMatrix4fv(A.viewMatrix,!1,Xa);c.uniform3fv(A.directionalLightDirection,w)}k.matrixWorld.flattenToArray(k._objectMatrixArray);c.uniformMatrix4fv(A.objectMatrix,
+!1,k._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,x.__webglVertexBuffer);c.vertexAttribPointer(t.position,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,x.__webglNormalBuffer);c.vertexAttribPointer(t.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);c.cullFace(c.FRONT);c.drawElements(c.TRIANGLES,x.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,x.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,
+!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);ha="";sa=R.program;c.useProgram(R.program);c.uniformMatrix4fv(R.projectionLocation,!1,Ta);c.uniform1f(R.darknessLocation,R.darkness);c.bindBuffer(c.ARRAY_BUFFER,R.vertexBuffer);c.vertexAttribPointer(R.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(R.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,R.elementBuffer);c.drawElements(c.TRIANGLES,
+6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function M(f,r){var j,k,m;j=_sprite.attributes;var w=_sprite.uniforms,x=Aa/za,u,A=[],t=za*0.5,y=Aa*0.5,z=!0;c.useProgram(_sprite.program);sa=_sprite.program;ha="";if(!ob){c.enableVertexAttribArray(_sprite.attributes.position);c.enableVertexAttribArray(_sprite.attributes.uv);ob=!0}c.disable(c.CULL_FACE);c.enable(c.BLEND);c.depthMask(!0);c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.vertexAttribPointer(j.position,
+2,c.FLOAT,!1,16,0);c.vertexAttribPointer(j.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.uniformMatrix4fv(w.projectionMatrix,!1,Ta);c.activeTexture(c.TEXTURE0);c.uniform1i(w.map,0);j=0;for(k=f.__webglSprites.length;j<k;j++){m=f.__webglSprites[j];if(m.useScreenCoordinates)m.z=-m.position.z;else{m._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);m.z=-m._modelViewMatrix.n34}}f.__webglSprites.sort(H);j=0;for(k=f.__webglSprites.length;j<
+k;j++){m=f.__webglSprites[j];if(m.material===undefined&&m.map&&m.map.image&&m.map.image.width){if(m.useScreenCoordinates){c.uniform1i(w.useScreenCoordinates,1);c.uniform3f(w.screenPosition,(m.position.x-t)/t,(y-m.position.y)/y,Math.max(0,Math.min(1,m.position.z)))}else{c.uniform1i(w.useScreenCoordinates,0);c.uniform1i(w.affectedByDistance,m.affectedByDistance?1:0);c.uniformMatrix4fv(w.modelViewMatrix,!1,m._modelViewMatrixArray)}u=m.map.image.width/(m.affectedByDistance?1:Aa);A[0]=u*x*m.scale.x;A[1]=
+u*m.scale.y;c.uniform2f(w.uvScale,m.uvScale.x,m.uvScale.y);c.uniform2f(w.uvOffset,m.uvOffset.x,m.uvOffset.y);c.uniform2f(w.alignment,m.alignment.x,m.alignment.y);c.uniform1f(w.opacity,m.opacity);c.uniform1f(w.rotation,m.rotation);c.uniform2fv(w.scale,A);if(m.mergeWith3D&&!z){c.enable(c.DEPTH_TEST);z=!0}else if(!m.mergeWith3D&&z){c.disable(c.DEPTH_TEST);z=!1}pa(m.blending);K(m.map,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function N(f,
+r){var j,k,m=f.__webglLensFlares.length,w,x,u,A=new THREE.Vector3,t=Aa/za,y=za*0.5,z=Aa*0.5,D=16/Aa,B=[D*t,D],O=[1,1,0],W=[1,1],P=J.uniforms;j=J.attributes;c.useProgram(J.program);sa=J.program;ha="";if(!pb){c.enableVertexAttribArray(J.attributes.vertex);c.enableVertexAttribArray(J.attributes.uv);pb=!0}c.uniform1i(P.occlusionMap,0);c.uniform1i(P.map,1);c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.vertexAttribPointer(j.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(j.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+J.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.activeTexture(c.TEXTURE1);for(k=0;k<m;k++){j=f.__webglLensFlares[k].object;A.set(j.matrixWorld.n14,j.matrixWorld.n24,j.matrixWorld.n34);r.matrixWorldInverse.multiplyVector3(A);r.projectionMatrix.multiplyVector3(A);O[0]=A.x;O[1]=A.y;O[2]=A.z;W[0]=O[0]*y+y;W[1]=O[1]*z+z;if(J.hasVertexTexture||W[0]>0&&W[0]<za&&W[1]>0&&W[1]<Aa){c.bindTexture(c.TEXTURE_2D,J.tempTexture);
+c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,W[0]-8,W[1]-8,16,16,0);c.uniform1i(P.renderType,0);c.uniform2fv(P.scale,B);c.uniform3fv(P.screenPosition,O);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,W[0]-8,W[1]-8,16,16,0);c.uniform1i(P.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);j.positionScreen.x=
+O[0];j.positionScreen.y=O[1];j.positionScreen.z=O[2];j.customUpdateCallback?j.customUpdateCallback(j):j.updateLensFlares();c.uniform1i(P.renderType,2);c.enable(c.BLEND);w=0;for(x=j.lensFlares.length;w<x;w++){u=j.lensFlares[w];if(u.opacity>0.001&&u.scale>0.001){O[0]=u.x;O[1]=u.y;O[2]=u.z;D=u.size*u.scale/Aa;B[0]=D*t;B[1]=D;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,u.rotation);c.uniform1f(P.opacity,u.opacity);pa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,
+6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Y)}function U(f,r){f._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function L(f){var r,j,k,m,w;if(f instanceof THREE.Mesh){j=f.geometry;for(r in j.geometryGroups){k=j.geometryGroups[r];w=!1;for(m in k.__webglCustomAttributes)if(k.__webglCustomAttributes[m].needsUpdate){w=!0;break}if(j.__dirtyVertices||
+j.__dirtyMorphTargets||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,u=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,D=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0,S=void 0,Q=void 0,T=void 0,ta=void 0;z=void 0;D=void 0;t=void 0;B=void 0;t=void 0;var s=void 0,G=void 0;z=void 0;s=void 0;G=void 0;var i=void 0,Ka=void 0;s=void 0;G=void 0;i=void 0;Ka=void 0;s=void 0;G=void 0;i=void 0;Ka=void 0;s=void 0;
+G=void 0;i=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;s=void 0;G=void 0;i=void 0;var Va=void 0,ua=0,Ba=0,Za=0,$a=0,Ja=0,La=0,ea=0,Ma=0,wa=0,C=0,Ca=0;G=s=0;var Da=k.__vertexArray,fb=k.__uvArray,gb=k.__uv2Array,Qa=k.__normalArray,ia=k.__tangentArray,Ea=k.__colorArray,ja=k.__skinVertexAArray,ka=k.__skinVertexBArray,la=k.__skinIndexArray,ma=k.__skinWeightArray,hb=k.__morphTargetsArrays,Ra=k.__webglCustomAttributes;i=void 0;var Na=k.__faceArray,Oa=k.__lineArray,qb=k.__needsSmoothNormals;W=k.__vertexColorType;
 O=k.__uvType;P=k.__normalType;var Ha=f.geometry,ib=Ha.__dirtyVertices,jb=Ha.__dirtyElements,eb=Ha.__dirtyUvs,kb=Ha.__dirtyNormals,lb=Ha.__dirtyTangents,mb=Ha.__dirtyColors,nb=Ha.__dirtyMorphTargets,ab=Ha.vertices,rb=k.faces,ub=Ha.faces,sb=Ha.faceVertexUvs[0],tb=Ha.faceVertexUvs[1],bb=Ha.skinVerticesA,cb=Ha.skinVerticesB,db=Ha.skinIndices,Wa=Ha.skinWeights,Ya=f instanceof THREE.ShadowVolume?Ha.edgeFaces:undefined;morphTargets=Ha.morphTargets;if(Ra)for(Va in Ra){Ra[Va].offset=0;Ra[Va].offsetSrc=0}x=
-0;for(u=rb.length;x<u;x++){A=rb[x];t=ub[A];sb&&(X=sb[A]);tb&&(Ga=tb[A]);A=t.vertexNormals;y=t.normal;z=t.vertexColors;D=t.color;B=t.vertexTangents;if(t instanceof THREE.Face3){if(ib){T=ab[t.a].position;Q=ab[t.b].position;U=ab[t.c].position;Ca[Aa]=T.x;Ca[Aa+1]=T.y;Ca[Aa+2]=T.z;Ca[Aa+3]=Q.x;Ca[Aa+4]=Q.y;Ca[Aa+5]=Q.z;Ca[Aa+6]=U.x;Ca[Aa+7]=U.y;Ca[Aa+8]=U.z;Aa+=9}if(Ra)for(Va in Ra){i=Ra[Va];if(i.needsUpdate){r=i.offset;G=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[r+
-0]=i.value[t.a];i.array[r+1]=i.value[t.b];i.array[r+2]=i.value[t.c]}else if(i.boundTo==="faces"){i.array[r+0]=i.value[G];i.array[r+1]=i.value[G];i.array[r+2]=i.value[G];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[r+0]=i.value[G+0];i.array[r+1]=i.value[G+1];i.array[r+2]=i.value[G+2];i.offsetSrc+=3}i.offset+=3}else{if(i.boundTo===undefined||i.boundTo==="vertices"){T=i.value[t.a];Q=i.value[t.b];U=i.value[t.c]}else if(i.boundTo==="faces"){T=i.value[G];Q=i.value[G];U=i.value[G];i.offsetSrc++}else if(i.boundTo===
-"faceVertices"){T=i.value[G+0];Q=i.value[G+1];U=i.value[G+2];i.offsetSrc+=3}if(i.size===2){i.array[r+0]=T.x;i.array[r+1]=T.y;i.array[r+2]=Q.x;i.array[r+3]=Q.y;i.array[r+4]=U.x;i.array[r+5]=U.y;i.offset+=6}else if(i.size===3){if(i.type==="c"){i.array[r+0]=T.r;i.array[r+1]=T.g;i.array[r+2]=T.b;i.array[r+3]=Q.r;i.array[r+4]=Q.g;i.array[r+5]=Q.b;i.array[r+6]=U.r;i.array[r+7]=U.g;i.array[r+8]=U.b}else{i.array[r+0]=T.x;i.array[r+1]=T.y;i.array[r+2]=T.z;i.array[r+3]=Q.x;i.array[r+4]=Q.y;i.array[r+5]=Q.z;
-i.array[r+6]=U.x;i.array[r+7]=U.y;i.array[r+8]=U.z}i.offset+=9}else{i.array[r+0]=T.x;i.array[r+1]=T.y;i.array[r+2]=T.z;i.array[r+3]=T.w;i.array[r+4]=Q.x;i.array[r+5]=Q.y;i.array[r+6]=Q.z;i.array[r+7]=Q.w;i.array[r+8]=U.x;i.array[r+9]=U.y;i.array[r+10]=U.z;i.array[r+11]=U.w;i.offset+=12}}}}if(nb){r=0;for(G=morphTargets.length;r<G;r++){T=morphTargets[r].vertices[t.a].position;Q=morphTargets[r].vertices[t.b].position;U=morphTargets[r].vertices[t.c].position;i=hb[r];i[Ba+0]=T.x;i[Ba+1]=T.y;i[Ba+2]=T.z;
-i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=U.x;i[Ba+7]=U.y;i[Ba+8]=U.z}Ba+=9}if(Wa.length){r=Wa[t.a];G=Wa[t.b];i=Wa[t.c];la[C]=r.x;la[C+1]=r.y;la[C+2]=r.z;la[C+3]=r.w;la[C+4]=G.x;la[C+5]=G.y;la[C+6]=G.z;la[C+7]=G.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;r=db[t.a];G=db[t.b];i=db[t.c];ka[C]=r.x;ka[C+1]=r.y;ka[C+2]=r.z;ka[C+3]=r.w;ka[C+4]=G.x;ka[C+5]=G.y;ka[C+6]=G.z;ka[C+7]=G.w;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=i.w;r=bb[t.a];G=bb[t.b];i=bb[t.c];ia[C]=r.x;ia[C+1]=r.y;ia[C+2]=r.z;
-ia[C+3]=1;ia[C+4]=G.x;ia[C+5]=G.y;ia[C+6]=G.z;ia[C+7]=1;ia[C+8]=i.x;ia[C+9]=i.y;ia[C+10]=i.z;ia[C+11]=1;r=cb[t.a];G=cb[t.b];i=cb[t.c];ja[C]=r.x;ja[C+1]=r.y;ja[C+2]=r.z;ja[C+3]=1;ja[C+4]=G.x;ja[C+5]=G.y;ja[C+6]=G.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;C+=12}if(mb&&W){if(z.length==3&&W==THREE.VertexColors){t=z[0];r=z[1];G=z[2]}else G=r=t=D;Da[xa]=t.r;Da[xa+1]=t.g;Da[xa+2]=t.b;Da[xa+3]=r.r;Da[xa+4]=r.g;Da[xa+5]=r.b;Da[xa+6]=G.r;Da[xa+7]=G.g;Da[xa+8]=G.b;xa+=9}if(lb&&Ha.hasTangents){z=
-B[0];D=B[1];t=B[2];ha[ea]=z.x;ha[ea+1]=z.y;ha[ea+2]=z.z;ha[ea+3]=z.w;ha[ea+4]=D.x;ha[ea+5]=D.y;ha[ea+6]=D.z;ha[ea+7]=D.w;ha[ea+8]=t.x;ha[ea+9]=t.y;ha[ea+10]=t.z;ha[ea+11]=t.w;ea+=12}if(kb&&P)if(A.length==3&&qb)for(B=0;B<3;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<3;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(eb&&X!==undefined&&O)for(B=0;B<3;B++){A=X[B];fb[Za]=A.u;fb[Za+1]=A.v;Za+=2}if(eb&&Ga!==undefined&&O)for(B=0;B<3;B++){A=Ga[B];gb[$a]=A.u;gb[$a+1]=A.v;$a+=2}if(jb){Na[Ja]=
-va;Na[Ja+1]=va+1;Na[Ja+2]=va+2;Ja+=3;Oa[Ma]=va;Oa[Ma+1]=va+1;Oa[Ma+2]=va;Oa[Ma+3]=va+2;Oa[Ma+4]=va+1;Oa[Ma+5]=va+2;Ma+=6;va+=3}}else if(t instanceof THREE.Face4){if(ib){T=ab[t.a].position;Q=ab[t.b].position;U=ab[t.c].position;ua=ab[t.d].position;Ca[Aa]=T.x;Ca[Aa+1]=T.y;Ca[Aa+2]=T.z;Ca[Aa+3]=Q.x;Ca[Aa+4]=Q.y;Ca[Aa+5]=Q.z;Ca[Aa+6]=U.x;Ca[Aa+7]=U.y;Ca[Aa+8]=U.z;Ca[Aa+9]=ua.x;Ca[Aa+10]=ua.y;Ca[Aa+11]=ua.z;Aa+=12}if(Ra)for(Va in Ra){i=Ra[Va];if(i.needsUpdate){r=i.offset;G=i.offsetSrc;if(i.size===1){if(i.boundTo===
-undefined||i.boundTo==="vertices"){i.array[r+0]=i.value[t.a];i.array[r+1]=i.value[t.b];i.array[r+2]=i.value[t.c];i.array[r+2]=i.value[t.d]}else if(i.boundTo==="faces"){i.array[r+0]=i.value[G];i.array[r+1]=i.value[G];i.array[r+2]=i.value[G];i.array[r+2]=i.value[G];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[r+0]=i.value[G+0];i.array[r+1]=i.value[G+1];i.array[r+2]=i.value[G+2];i.array[r+2]=i.value[G+3];i.offsetSrc+=4}i.offset+=4}else{if(i.boundTo===undefined||i.boundTo==="vertices"){T=
-i.value[t.a];Q=i.value[t.b];U=i.value[t.c];ua=i.value[t.d]}else if(i.boundTo==="faces"){T=i.value[G];Q=i.value[G];U=i.value[G];ua=i.value[G];i.offsetSrc++}else if(i.boundTo==="faceVertices"){T=i.value[G+0];Q=i.value[G+1];U=i.value[G+2];ua=i.value[G+3];i.offsetSrc+=4}if(i.size===2){i.array[r+0]=T.x;i.array[r+1]=T.y;i.array[r+2]=Q.x;i.array[r+3]=Q.y;i.array[r+4]=U.x;i.array[r+5]=U.y;i.array[r+6]=ua.x;i.array[r+7]=ua.y;i.offset+=8}else if(i.size===3){if(i.type==="c"){i.array[r+0]=T.r;i.array[r+1]=T.g;
-i.array[r+2]=T.b;i.array[r+3]=Q.r;i.array[r+4]=Q.g;i.array[r+5]=Q.b;i.array[r+6]=U.r;i.array[r+7]=U.g;i.array[r+8]=U.b;i.array[r+9]=ua.r;i.array[r+10]=ua.g;i.array[r+11]=ua.b}else{i.array[r+0]=T.x;i.array[r+1]=T.y;i.array[r+2]=T.z;i.array[r+3]=Q.x;i.array[r+4]=Q.y;i.array[r+5]=Q.z;i.array[r+6]=U.x;i.array[r+7]=U.y;i.array[r+8]=U.z;i.array[r+9]=ua.x;i.array[r+10]=ua.y;i.array[r+11]=ua.z}i.offset+=12}else{i.array[r+0]=T.x;i.array[r+1]=T.y;i.array[r+2]=T.z;i.array[r+3]=T.w;i.array[r+4]=Q.x;i.array[r+
-5]=Q.y;i.array[r+6]=Q.z;i.array[r+7]=Q.w;i.array[r+8]=U.x;i.array[r+9]=U.y;i.array[r+10]=U.z;i.array[r+11]=U.w;i.array[r+12]=ua.x;i.array[r+13]=ua.y;i.array[r+14]=ua.z;i.array[r+15]=ua.w;i.offset+=16}}}}if(nb){r=0;for(G=morphTargets.length;r<G;r++){T=morphTargets[r].vertices[t.a].position;Q=morphTargets[r].vertices[t.b].position;U=morphTargets[r].vertices[t.c].position;ua=morphTargets[r].vertices[t.d].position;i=hb[r];i[Ba+0]=T.x;i[Ba+1]=T.y;i[Ba+2]=T.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=
-U.x;i[Ba+7]=U.y;i[Ba+8]=U.z;i[Ba+9]=ua.x;i[Ba+10]=ua.y;i[Ba+11]=ua.z}Ba+=12}if(Wa.length){r=Wa[t.a];G=Wa[t.b];i=Wa[t.c];Ka=Wa[t.d];la[C]=r.x;la[C+1]=r.y;la[C+2]=r.z;la[C+3]=r.w;la[C+4]=G.x;la[C+5]=G.y;la[C+6]=G.z;la[C+7]=G.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;la[C+12]=Ka.x;la[C+13]=Ka.y;la[C+14]=Ka.z;la[C+15]=Ka.w;r=db[t.a];G=db[t.b];i=db[t.c];Ka=db[t.d];ka[C]=r.x;ka[C+1]=r.y;ka[C+2]=r.z;ka[C+3]=r.w;ka[C+4]=G.x;ka[C+5]=G.y;ka[C+6]=G.z;ka[C+7]=G.w;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;
-ka[C+11]=i.w;ka[C+12]=Ka.x;ka[C+13]=Ka.y;ka[C+14]=Ka.z;ka[C+15]=Ka.w;r=bb[t.a];G=bb[t.b];i=bb[t.c];Ka=bb[t.d];ia[C]=r.x;ia[C+1]=r.y;ia[C+2]=r.z;ia[C+3]=1;ia[C+4]=G.x;ia[C+5]=G.y;ia[C+6]=G.z;ia[C+7]=1;ia[C+8]=i.x;ia[C+9]=i.y;ia[C+10]=i.z;ia[C+11]=1;ia[C+12]=Ka.x;ia[C+13]=Ka.y;ia[C+14]=Ka.z;ia[C+15]=1;r=cb[t.a];G=cb[t.b];i=cb[t.c];t=cb[t.d];ja[C]=r.x;ja[C+1]=r.y;ja[C+2]=r.z;ja[C+3]=1;ja[C+4]=G.x;ja[C+5]=G.y;ja[C+6]=G.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;ja[C+12]=t.x;ja[C+13]=
-t.y;ja[C+14]=t.z;ja[C+15]=1;C+=16}if(mb&&W){if(z.length==4&&W==THREE.VertexColors){t=z[0];r=z[1];G=z[2];z=z[3]}else z=G=r=t=D;Da[xa]=t.r;Da[xa+1]=t.g;Da[xa+2]=t.b;Da[xa+3]=r.r;Da[xa+4]=r.g;Da[xa+5]=r.b;Da[xa+6]=G.r;Da[xa+7]=G.g;Da[xa+8]=G.b;Da[xa+9]=z.r;Da[xa+10]=z.g;Da[xa+11]=z.b;xa+=12}if(lb&&Ha.hasTangents){z=B[0];D=B[1];t=B[2];B=B[3];ha[ea]=z.x;ha[ea+1]=z.y;ha[ea+2]=z.z;ha[ea+3]=z.w;ha[ea+4]=D.x;ha[ea+5]=D.y;ha[ea+6]=D.z;ha[ea+7]=D.w;ha[ea+8]=t.x;ha[ea+9]=t.y;ha[ea+10]=t.z;ha[ea+11]=t.w;ha[ea+
-12]=B.x;ha[ea+13]=B.y;ha[ea+14]=B.z;ha[ea+15]=B.w;ea+=16}if(kb&&P)if(A.length==4&&qb)for(B=0;B<4;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<4;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(eb&&X!==undefined&&O)for(B=0;B<4;B++){A=X[B];fb[Za]=A.u;fb[Za+1]=A.v;Za+=2}if(eb&&Ga!==undefined&&O)for(B=0;B<4;B++){A=Ga[B];gb[$a]=A.u;gb[$a+1]=A.v;$a+=2}if(jb){Na[Ja]=va;Na[Ja+1]=va+1;Na[Ja+2]=va+3;Na[Ja+3]=va+1;Na[Ja+4]=va+2;Na[Ja+5]=va+3;Ja+=6;Oa[Ma]=va;Oa[Ma+1]=va+1;Oa[Ma+2]=
-va;Oa[Ma+3]=va+3;Oa[Ma+4]=va+1;Oa[Ma+5]=va+2;Oa[Ma+6]=va+2;Oa[Ma+7]=va+3;Ma+=8;va+=4}}}if(Ya){x=0;for(u=Ya.length;x<u;x++){Na[Ja]=Ya[x].a;Na[Ja+1]=Ya[x].b;Na[Ja+2]=Ya[x].c;Na[Ja+3]=Ya[x].a;Na[Ja+4]=Ya[x].c;Na[Ja+5]=Ya[x].d;Ja+=6}}if(ib){c.bindBuffer(c.ARRAY_BUFFER,k.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Ca,w)}if(Ra)for(Va in Ra){i=Ra[Va];if(i.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,i.buffer);c.bufferData(c.ARRAY_BUFFER,i.array,w);i.needsUpdate=!1}}if(nb){r=0;for(G=morphTargets.length;r<
-G;r++){c.bindBuffer(c.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[r]);c.bufferData(c.ARRAY_BUFFER,hb[r],w)}}if(mb&&xa>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Da,w)}if(kb){c.bindBuffer(c.ARRAY_BUFFER,k.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,w)}if(lb&&Ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,k.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,w)}if(eb&&Za>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,fb,w)}if(eb&&
-$a>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,gb,w)}if(jb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,w)}if(C>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,w);c.bindBuffer(c.ARRAY_BUFFER,
-k.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ka,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,la,w)}}}j.__dirtyVertices=!1;j.__dirtyMorphTargets=!1;j.__dirtyElements=!1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=!1;j.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){j=f.geometry;if(j.__dirtyVertices||j.__dirtyColors){f=j;s=c.DYNAMIC_DRAW;W=f.vertices;k=f.colors;P=W.length;w=k.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors;
-if(f.__dirtyVertices){for(u=0;u<P;u++){O=W[u].position;m=u*3;X[m]=O.x;X[m+1]=O.y;X[m+2]=O.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,X,s)}if(Ga){for(u=0;u<w;u++){color=k[u];m=u*3;x[m]=color.r;x[m+1]=color.g;x[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,x,s)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(f instanceof THREE.Line){j=f.geometry;if(j.__dirtyVertices||j.__dirtyColors){f=j;s=c.DYNAMIC_DRAW;W=f.vertices;
-k=f.colors;P=W.length;w=k.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<P;u++){O=W[u].position;m=u*3;X[m]=O.x;X[m+1]=O.y;X[m+2]=O.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,X,s)}if(Ga){for(u=0;u<w;u++){color=k[u];m=u*3;x[m]=color.r;x[m+1]=color.g;x[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,x,s)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(f instanceof THREE.ParticleSystem){j=
-f.geometry;(j.__dirtyVertices||j.__dirtyColors||f.sortParticles)&&d(j,c.DYNAMIC_DRAW,f);j.__dirtyVertices=!1;j.__dirtyColors=!1}}function sa(f){function s(D){var B=[];j=0;for(k=D.length;j<k;j++)D[j]==undefined?B.push("undefined"):B.push(D[j].id);return B.join("_")}var j,k,m,w,x,u,A,t,y={},z=f.morphTargets!==undefined?f.morphTargets.length:0;f.geometryGroups={};m=0;for(w=f.faces.length;m<w;m++){x=f.faces[m];u=x.materials;A=s(u);y[A]==undefined&&(y[A]={hash:A,counter:0});t=y[A].hash+"_"+y[A].counter;
-f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:u,vertices:0,numMorphTargets:z});x=x instanceof THREE.Face3?3:4;if(f.geometryGroups[t].vertices+x>65535){y[A].counter+=1;t=y[A].hash+"_"+y[A].counter;f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:u,vertices:0,numMorphTargets:z})}f.geometryGroups[t].faces.push(m);f.geometryGroups[t].vertices+=x}}function da(f,s,j){f.push({buffer:s,object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function oa(f){if(f!=
-ga){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}ga=f}}function Z(f,s,j){if((j.width&j.width-1)==0&&(j.height&
-j.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,fa(s.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,fa(s.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,fa(s.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,fa(s.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,Ea(s.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,Ea(s.minFilter))}}function K(f,s){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D,
-f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{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);f.__webglInit=!0}Z(c.TEXTURE_2D,f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+s);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function Ia(f){if(f&&!f.__webglFramebuffer){if(f.depthBuffer===undefined)f.depthBuffer=!0;if(f.stencilBuffer===
+0;for(u=rb.length;x<u;x++){A=rb[x];t=ub[A];sb&&(X=sb[A]);tb&&(Ga=tb[A]);A=t.vertexNormals;y=t.normal;z=t.vertexColors;D=t.color;B=t.vertexTangents;if(t instanceof THREE.Face3){if(ib){S=ab[t.a].position;Q=ab[t.b].position;T=ab[t.c].position;Da[Ba]=S.x;Da[Ba+1]=S.y;Da[Ba+2]=S.z;Da[Ba+3]=Q.x;Da[Ba+4]=Q.y;Da[Ba+5]=Q.z;Da[Ba+6]=T.x;Da[Ba+7]=T.y;Da[Ba+8]=T.z;Ba+=9}if(Ra)for(Va in Ra){i=Ra[Va];if(i.needsUpdate){s=i.offset;G=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[s+
+0]=i.value[t.a];i.array[s+1]=i.value[t.b];i.array[s+2]=i.value[t.c]}else if(i.boundTo==="faces"){i.array[s+0]=i.value[G];i.array[s+1]=i.value[G];i.array[s+2]=i.value[G];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[s+0]=i.value[G+0];i.array[s+1]=i.value[G+1];i.array[s+2]=i.value[G+2];i.offsetSrc+=3}i.offset+=3}else{if(i.boundTo===undefined||i.boundTo==="vertices"){S=i.value[t.a];Q=i.value[t.b];T=i.value[t.c]}else if(i.boundTo==="faces"){S=i.value[G];Q=i.value[G];T=i.value[G];i.offsetSrc++}else if(i.boundTo===
+"faceVertices"){S=i.value[G+0];Q=i.value[G+1];T=i.value[G+2];i.offsetSrc+=3}if(i.size===2){i.array[s+0]=S.x;i.array[s+1]=S.y;i.array[s+2]=Q.x;i.array[s+3]=Q.y;i.array[s+4]=T.x;i.array[s+5]=T.y;i.offset+=6}else if(i.size===3){if(i.type==="c"){i.array[s+0]=S.r;i.array[s+1]=S.g;i.array[s+2]=S.b;i.array[s+3]=Q.r;i.array[s+4]=Q.g;i.array[s+5]=Q.b;i.array[s+6]=T.r;i.array[s+7]=T.g;i.array[s+8]=T.b}else{i.array[s+0]=S.x;i.array[s+1]=S.y;i.array[s+2]=S.z;i.array[s+3]=Q.x;i.array[s+4]=Q.y;i.array[s+5]=Q.z;
+i.array[s+6]=T.x;i.array[s+7]=T.y;i.array[s+8]=T.z}i.offset+=9}else{i.array[s+0]=S.x;i.array[s+1]=S.y;i.array[s+2]=S.z;i.array[s+3]=S.w;i.array[s+4]=Q.x;i.array[s+5]=Q.y;i.array[s+6]=Q.z;i.array[s+7]=Q.w;i.array[s+8]=T.x;i.array[s+9]=T.y;i.array[s+10]=T.z;i.array[s+11]=T.w;i.offset+=12}}}}if(nb){s=0;for(G=morphTargets.length;s<G;s++){S=morphTargets[s].vertices[t.a].position;Q=morphTargets[s].vertices[t.b].position;T=morphTargets[s].vertices[t.c].position;i=hb[s];i[Ca+0]=S.x;i[Ca+1]=S.y;i[Ca+2]=S.z;
+i[Ca+3]=Q.x;i[Ca+4]=Q.y;i[Ca+5]=Q.z;i[Ca+6]=T.x;i[Ca+7]=T.y;i[Ca+8]=T.z}Ca+=9}if(Wa.length){s=Wa[t.a];G=Wa[t.b];i=Wa[t.c];ma[C]=s.x;ma[C+1]=s.y;ma[C+2]=s.z;ma[C+3]=s.w;ma[C+4]=G.x;ma[C+5]=G.y;ma[C+6]=G.z;ma[C+7]=G.w;ma[C+8]=i.x;ma[C+9]=i.y;ma[C+10]=i.z;ma[C+11]=i.w;s=db[t.a];G=db[t.b];i=db[t.c];la[C]=s.x;la[C+1]=s.y;la[C+2]=s.z;la[C+3]=s.w;la[C+4]=G.x;la[C+5]=G.y;la[C+6]=G.z;la[C+7]=G.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;s=bb[t.a];G=bb[t.b];i=bb[t.c];ja[C]=s.x;ja[C+1]=s.y;ja[C+2]=s.z;
+ja[C+3]=1;ja[C+4]=G.x;ja[C+5]=G.y;ja[C+6]=G.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;s=cb[t.a];G=cb[t.b];i=cb[t.c];ka[C]=s.x;ka[C+1]=s.y;ka[C+2]=s.z;ka[C+3]=1;ka[C+4]=G.x;ka[C+5]=G.y;ka[C+6]=G.z;ka[C+7]=1;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=1;C+=12}if(mb&&W){if(z.length==3&&W==THREE.VertexColors){t=z[0];s=z[1];G=z[2]}else G=s=t=D;Ea[wa]=t.r;Ea[wa+1]=t.g;Ea[wa+2]=t.b;Ea[wa+3]=s.r;Ea[wa+4]=s.g;Ea[wa+5]=s.b;Ea[wa+6]=G.r;Ea[wa+7]=G.g;Ea[wa+8]=G.b;wa+=9}if(lb&&Ha.hasTangents){z=
+B[0];D=B[1];t=B[2];ia[ea]=z.x;ia[ea+1]=z.y;ia[ea+2]=z.z;ia[ea+3]=z.w;ia[ea+4]=D.x;ia[ea+5]=D.y;ia[ea+6]=D.z;ia[ea+7]=D.w;ia[ea+8]=t.x;ia[ea+9]=t.y;ia[ea+10]=t.z;ia[ea+11]=t.w;ea+=12}if(kb&&P)if(A.length==3&&qb)for(B=0;B<3;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<3;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(eb&&X!==undefined&&O)for(B=0;B<3;B++){A=X[B];fb[Za]=A.u;fb[Za+1]=A.v;Za+=2}if(eb&&Ga!==undefined&&O)for(B=0;B<3;B++){A=Ga[B];gb[$a]=A.u;gb[$a+1]=A.v;$a+=2}if(jb){Na[Ja]=
+ua;Na[Ja+1]=ua+1;Na[Ja+2]=ua+2;Ja+=3;Oa[Ma]=ua;Oa[Ma+1]=ua+1;Oa[Ma+2]=ua;Oa[Ma+3]=ua+2;Oa[Ma+4]=ua+1;Oa[Ma+5]=ua+2;Ma+=6;ua+=3}}else if(t instanceof THREE.Face4){if(ib){S=ab[t.a].position;Q=ab[t.b].position;T=ab[t.c].position;ta=ab[t.d].position;Da[Ba]=S.x;Da[Ba+1]=S.y;Da[Ba+2]=S.z;Da[Ba+3]=Q.x;Da[Ba+4]=Q.y;Da[Ba+5]=Q.z;Da[Ba+6]=T.x;Da[Ba+7]=T.y;Da[Ba+8]=T.z;Da[Ba+9]=ta.x;Da[Ba+10]=ta.y;Da[Ba+11]=ta.z;Ba+=12}if(Ra)for(Va in Ra){i=Ra[Va];if(i.needsUpdate){s=i.offset;G=i.offsetSrc;if(i.size===1){if(i.boundTo===
+undefined||i.boundTo==="vertices"){i.array[s+0]=i.value[t.a];i.array[s+1]=i.value[t.b];i.array[s+2]=i.value[t.c];i.array[s+2]=i.value[t.d]}else if(i.boundTo==="faces"){i.array[s+0]=i.value[G];i.array[s+1]=i.value[G];i.array[s+2]=i.value[G];i.array[s+2]=i.value[G];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[s+0]=i.value[G+0];i.array[s+1]=i.value[G+1];i.array[s+2]=i.value[G+2];i.array[s+2]=i.value[G+3];i.offsetSrc+=4}i.offset+=4}else{if(i.boundTo===undefined||i.boundTo==="vertices"){S=
+i.value[t.a];Q=i.value[t.b];T=i.value[t.c];ta=i.value[t.d]}else if(i.boundTo==="faces"){S=i.value[G];Q=i.value[G];T=i.value[G];ta=i.value[G];i.offsetSrc++}else if(i.boundTo==="faceVertices"){S=i.value[G+0];Q=i.value[G+1];T=i.value[G+2];ta=i.value[G+3];i.offsetSrc+=4}if(i.size===2){i.array[s+0]=S.x;i.array[s+1]=S.y;i.array[s+2]=Q.x;i.array[s+3]=Q.y;i.array[s+4]=T.x;i.array[s+5]=T.y;i.array[s+6]=ta.x;i.array[s+7]=ta.y;i.offset+=8}else if(i.size===3){if(i.type==="c"){i.array[s+0]=S.r;i.array[s+1]=S.g;
+i.array[s+2]=S.b;i.array[s+3]=Q.r;i.array[s+4]=Q.g;i.array[s+5]=Q.b;i.array[s+6]=T.r;i.array[s+7]=T.g;i.array[s+8]=T.b;i.array[s+9]=ta.r;i.array[s+10]=ta.g;i.array[s+11]=ta.b}else{i.array[s+0]=S.x;i.array[s+1]=S.y;i.array[s+2]=S.z;i.array[s+3]=Q.x;i.array[s+4]=Q.y;i.array[s+5]=Q.z;i.array[s+6]=T.x;i.array[s+7]=T.y;i.array[s+8]=T.z;i.array[s+9]=ta.x;i.array[s+10]=ta.y;i.array[s+11]=ta.z}i.offset+=12}else{i.array[s+0]=S.x;i.array[s+1]=S.y;i.array[s+2]=S.z;i.array[s+3]=S.w;i.array[s+4]=Q.x;i.array[s+
+5]=Q.y;i.array[s+6]=Q.z;i.array[s+7]=Q.w;i.array[s+8]=T.x;i.array[s+9]=T.y;i.array[s+10]=T.z;i.array[s+11]=T.w;i.array[s+12]=ta.x;i.array[s+13]=ta.y;i.array[s+14]=ta.z;i.array[s+15]=ta.w;i.offset+=16}}}}if(nb){s=0;for(G=morphTargets.length;s<G;s++){S=morphTargets[s].vertices[t.a].position;Q=morphTargets[s].vertices[t.b].position;T=morphTargets[s].vertices[t.c].position;ta=morphTargets[s].vertices[t.d].position;i=hb[s];i[Ca+0]=S.x;i[Ca+1]=S.y;i[Ca+2]=S.z;i[Ca+3]=Q.x;i[Ca+4]=Q.y;i[Ca+5]=Q.z;i[Ca+6]=
+T.x;i[Ca+7]=T.y;i[Ca+8]=T.z;i[Ca+9]=ta.x;i[Ca+10]=ta.y;i[Ca+11]=ta.z}Ca+=12}if(Wa.length){s=Wa[t.a];G=Wa[t.b];i=Wa[t.c];Ka=Wa[t.d];ma[C]=s.x;ma[C+1]=s.y;ma[C+2]=s.z;ma[C+3]=s.w;ma[C+4]=G.x;ma[C+5]=G.y;ma[C+6]=G.z;ma[C+7]=G.w;ma[C+8]=i.x;ma[C+9]=i.y;ma[C+10]=i.z;ma[C+11]=i.w;ma[C+12]=Ka.x;ma[C+13]=Ka.y;ma[C+14]=Ka.z;ma[C+15]=Ka.w;s=db[t.a];G=db[t.b];i=db[t.c];Ka=db[t.d];la[C]=s.x;la[C+1]=s.y;la[C+2]=s.z;la[C+3]=s.w;la[C+4]=G.x;la[C+5]=G.y;la[C+6]=G.z;la[C+7]=G.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;
+la[C+11]=i.w;la[C+12]=Ka.x;la[C+13]=Ka.y;la[C+14]=Ka.z;la[C+15]=Ka.w;s=bb[t.a];G=bb[t.b];i=bb[t.c];Ka=bb[t.d];ja[C]=s.x;ja[C+1]=s.y;ja[C+2]=s.z;ja[C+3]=1;ja[C+4]=G.x;ja[C+5]=G.y;ja[C+6]=G.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;ja[C+12]=Ka.x;ja[C+13]=Ka.y;ja[C+14]=Ka.z;ja[C+15]=1;s=cb[t.a];G=cb[t.b];i=cb[t.c];t=cb[t.d];ka[C]=s.x;ka[C+1]=s.y;ka[C+2]=s.z;ka[C+3]=1;ka[C+4]=G.x;ka[C+5]=G.y;ka[C+6]=G.z;ka[C+7]=1;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=1;ka[C+12]=t.x;ka[C+13]=
+t.y;ka[C+14]=t.z;ka[C+15]=1;C+=16}if(mb&&W){if(z.length==4&&W==THREE.VertexColors){t=z[0];s=z[1];G=z[2];z=z[3]}else z=G=s=t=D;Ea[wa]=t.r;Ea[wa+1]=t.g;Ea[wa+2]=t.b;Ea[wa+3]=s.r;Ea[wa+4]=s.g;Ea[wa+5]=s.b;Ea[wa+6]=G.r;Ea[wa+7]=G.g;Ea[wa+8]=G.b;Ea[wa+9]=z.r;Ea[wa+10]=z.g;Ea[wa+11]=z.b;wa+=12}if(lb&&Ha.hasTangents){z=B[0];D=B[1];t=B[2];B=B[3];ia[ea]=z.x;ia[ea+1]=z.y;ia[ea+2]=z.z;ia[ea+3]=z.w;ia[ea+4]=D.x;ia[ea+5]=D.y;ia[ea+6]=D.z;ia[ea+7]=D.w;ia[ea+8]=t.x;ia[ea+9]=t.y;ia[ea+10]=t.z;ia[ea+11]=t.w;ia[ea+
+12]=B.x;ia[ea+13]=B.y;ia[ea+14]=B.z;ia[ea+15]=B.w;ea+=16}if(kb&&P)if(A.length==4&&qb)for(B=0;B<4;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<4;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(eb&&X!==undefined&&O)for(B=0;B<4;B++){A=X[B];fb[Za]=A.u;fb[Za+1]=A.v;Za+=2}if(eb&&Ga!==undefined&&O)for(B=0;B<4;B++){A=Ga[B];gb[$a]=A.u;gb[$a+1]=A.v;$a+=2}if(jb){Na[Ja]=ua;Na[Ja+1]=ua+1;Na[Ja+2]=ua+3;Na[Ja+3]=ua+1;Na[Ja+4]=ua+2;Na[Ja+5]=ua+3;Ja+=6;Oa[Ma]=ua;Oa[Ma+1]=ua+1;Oa[Ma+2]=
+ua;Oa[Ma+3]=ua+3;Oa[Ma+4]=ua+1;Oa[Ma+5]=ua+2;Oa[Ma+6]=ua+2;Oa[Ma+7]=ua+3;Ma+=8;ua+=4}}}if(Ya){x=0;for(u=Ya.length;x<u;x++){Na[Ja]=Ya[x].a;Na[Ja+1]=Ya[x].b;Na[Ja+2]=Ya[x].c;Na[Ja+3]=Ya[x].a;Na[Ja+4]=Ya[x].c;Na[Ja+5]=Ya[x].d;Ja+=6}}if(ib){c.bindBuffer(c.ARRAY_BUFFER,k.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Da,w)}if(Ra)for(Va in Ra){i=Ra[Va];if(i.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,i.buffer);c.bufferData(c.ARRAY_BUFFER,i.array,w);i.needsUpdate=!1}}if(nb){s=0;for(G=morphTargets.length;s<
+G;s++){c.bindBuffer(c.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[s]);c.bufferData(c.ARRAY_BUFFER,hb[s],w)}}if(mb&&wa>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Ea,w)}if(kb){c.bindBuffer(c.ARRAY_BUFFER,k.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,w)}if(lb&&Ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,k.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ia,w)}if(eb&&Za>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,fb,w)}if(eb&&
+$a>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,gb,w)}if(jb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,w)}if(C>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ja,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ka,w);c.bindBuffer(c.ARRAY_BUFFER,
+k.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,la,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,ma,w)}}}j.__dirtyVertices=!1;j.__dirtyMorphTargets=!1;j.__dirtyElements=!1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=!1;j.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){j=f.geometry;if(j.__dirtyVertices||j.__dirtyColors){f=j;r=c.DYNAMIC_DRAW;W=f.vertices;k=f.colors;P=W.length;w=k.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors;
+if(f.__dirtyVertices){for(u=0;u<P;u++){O=W[u].position;m=u*3;X[m]=O.x;X[m+1]=O.y;X[m+2]=O.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,X,r)}if(Ga){for(u=0;u<w;u++){color=k[u];m=u*3;x[m]=color.r;x[m+1]=color.g;x[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,x,r)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(f instanceof THREE.Line){j=f.geometry;if(j.__dirtyVertices||j.__dirtyColors){f=j;r=c.DYNAMIC_DRAW;W=f.vertices;
+k=f.colors;P=W.length;w=k.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<P;u++){O=W[u].position;m=u*3;X[m]=O.x;X[m+1]=O.y;X[m+2]=O.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,X,r)}if(Ga){for(u=0;u<w;u++){color=k[u];m=u*3;x[m]=color.r;x[m+1]=color.g;x[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,x,r)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(f instanceof THREE.ParticleSystem){j=
+f.geometry;(j.__dirtyVertices||j.__dirtyColors||f.sortParticles)&&d(j,c.DYNAMIC_DRAW,f);j.__dirtyVertices=!1;j.__dirtyColors=!1}}function ra(f){function r(D){var B=[];j=0;for(k=D.length;j<k;j++)D[j]==undefined?B.push("undefined"):B.push(D[j].id);return B.join("_")}var j,k,m,w,x,u,A,t,y={},z=f.morphTargets!==undefined?f.morphTargets.length:0;f.geometryGroups={};m=0;for(w=f.faces.length;m<w;m++){x=f.faces[m];u=x.materials;A=r(u);y[A]==undefined&&(y[A]={hash:A,counter:0});t=y[A].hash+"_"+y[A].counter;
+f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:u,vertices:0,numMorphTargets:z});x=x instanceof THREE.Face3?3:4;if(f.geometryGroups[t].vertices+x>65535){y[A].counter+=1;t=y[A].hash+"_"+y[A].counter;f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:u,vertices:0,numMorphTargets:z})}f.geometryGroups[t].faces.push(m);f.geometryGroups[t].vertices+=x}}function da(f,r,j){f.push({buffer:r,object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function pa(f){if(f!=
+ha){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}ha=f}}function $(f,r,j){if((j.width&j.width-1)==0&&(j.height&
+j.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,fa(r.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,fa(r.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,fa(r.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,fa(r.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,Fa(r.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,Fa(r.minFilter))}}function K(f,r){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D,
+f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{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);f.__webglInit=!0}$(c.TEXTURE_2D,f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+r);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function Ia(f){if(f&&!f.__webglFramebuffer){if(f.depthBuffer===undefined)f.depthBuffer=!0;if(f.stencilBuffer===
 undefined)f.stencilBuffer=!0;f.__webglFramebuffer=c.createFramebuffer();f.__webglRenderbuffer=c.createRenderbuffer();f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,fa(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,fa(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,fa(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,fa(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,fa(f.format),f.width,f.height,
 0,fa(f.format),fa(f.type),null);c.bindRenderbuffer(c.RENDERBUFFER,f.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,f.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webglTexture,0);if(f.depthBuffer&&!f.stencilBuffer){c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else if(f.depthBuffer&&f.stencilBuffer){c.renderbufferStorage(c.RENDERBUFFER,
-c.DEPTH_STENCIL,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,f.width,f.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var s,j;if(f){s=f.__webglFramebuffer;j=f.width;f=f.height}else{s=null;j=ya;f=za}if(s!=Fa){c.bindFramebuffer(c.FRAMEBUFFER,s);c.viewport(wa,qa,j,f);Fa=s}}function ca(f,s){var j;if(f=="fragment")j=
-c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(j=c.createShader(c.VERTEX_SHADER));c.shaderSource(j,s);c.compileShader(j);if(!c.getShaderParameter(j,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(j));console.error(s);return null}return j}function Ea(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function fa(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;
+c.DEPTH_STENCIL,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,f.width,f.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var r,j;if(f){r=f.__webglFramebuffer;j=f.width;f=f.height}else{r=null;j=za;f=Aa}if(r!=ya){c.bindFramebuffer(c.FRAMEBUFFER,r);c.viewport(va,qa,j,f);ya=r}}function ca(f,r){var j;if(f=="fragment")j=
+c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(j=c.createShader(c.VERTEX_SHADER));c.shaderSource(j,r);c.compileShader(j);if(!c.getShaderParameter(j,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(j));console.error(r);return null}return j}function Fa(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function fa(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;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;
-case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var c,S=document.createElement("canvas"),pa=[],ra=null,Fa=null,ta=!0,aa=this,ma=null,na=null,ga=null,Y=null,wa=
-0,qa=0,ya=0,za=0,$=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Pa=new THREE.Matrix4,Ta=new Float32Array(16),Xa=new Float32Array(16),Ua=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):
-new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.maxMorphTargets=8;this.domElement=S;this.autoClear=!0;this.sortObjects=!0;(function(f,s,j,k){try{if(!(c=S.getContext("experimental-webgl",{antialias:f,stencil:k})))throw"Error creating WebGL context.";}catch(m){console.error(m)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));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.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(s.r,s.g,s.b,j)})(antialias,clearColor,clearAlpha,stencil);this.context=c;if(stencil){var R={};R.vertices=new Float32Array(12);R.faces=new Uint16Array(6);R.darkness=0.5;R.vertices[0]=-20;R.vertices[1]=-20;R.vertices[2]=-1;R.vertices[3]=20;R.vertices[4]=-20;R.vertices[5]=-1;R.vertices[6]=
-20;R.vertices[7]=20;R.vertices[8]=-1;R.vertices[9]=-20;R.vertices[10]=20;R.vertices[11]=-1;R.faces[0]=0;R.faces[1]=1;R.faces[2]=2;R.faces[3]=0;R.faces[4]=2;R.faces[5]=3;R.vertexBuffer=c.createBuffer();R.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,R.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,R.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,R.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,R.faces,c.STATIC_DRAW);R.program=c.createProgram();c.attachShader(R.program,ca("fragment",
-THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(R.program,ca("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(R.program);R.vertexLocation=c.getAttribLocation(R.program,"position");R.projectionLocation=c.getUniformLocation(R.program,"projectionMatrix");R.darknessLocation=c.getUniformLocation(R.program,"darkness")}var J={};J.vertices=new Float32Array(16);J.faces=new Uint16Array(6);b=0;J.vertices[b++]=-1;J.vertices[b++]=-1;J.vertices[b++]=0;J.vertices[b++]=0;J.vertices[b++]=
-1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;b=0;J.faces[b++]=0;J.faces[b++]=1;J.faces[b++]=2;J.faces[b++]=0;J.faces[b++]=2;J.faces[b++]=3;J.vertexBuffer=c.createBuffer();J.elementBuffer=c.createBuffer();J.tempTexture=c.createTexture();J.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,
-J.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,
-J.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);if(c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){J.hasVertexTexture=!1;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlare.fragmentShader));
-c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{J.hasVertexTexture=!0;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}c.linkProgram(J.program);J.attributes={};J.uniforms={};J.attributes.vertex=c.getAttribLocation(J.program,"position");J.attributes.uv=c.getAttribLocation(J.program,"UV");J.uniforms.renderType=
-c.getUniformLocation(J.program,"renderType");J.uniforms.map=c.getUniformLocation(J.program,"map");J.uniforms.occlusionMap=c.getUniformLocation(J.program,"occlusionMap");J.uniforms.opacity=c.getUniformLocation(J.program,"opacity");J.uniforms.scale=c.getUniformLocation(J.program,"scale");J.uniforms.rotation=c.getUniformLocation(J.program,"rotation");J.uniforms.screenPosition=c.getUniformLocation(J.program,"screenPosition");var pb=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);
-b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;
-_sprite.faces[b++]=3;_sprite.vertexBuffer=c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,ca("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,ca("vertex",THREE.ShaderLib.sprite.vertexShader));
-c.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");
-_sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=
-c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");var ob=!1;this.setSize=function(f,s){S.width=f;S.height=s;this.setViewport(0,0,S.width,S.height)};this.setViewport=function(f,s,j,k){wa=f;qa=s;ya=j;za=k;c.viewport(wa,qa,ya,za)};this.setScissor=function(f,s,j,k){c.scissor(f,s,j,k)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){ta=
-f;c.depthMask(f)};this.setClearColorHex=function(f,s){var j=new THREE.Color(f);c.clearColor(j.r,j.g,j.b,s)};this.setClearColor=function(f,s){c.clearColor(f.r,f.g,f.b,s)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){R.darkness=f};this.initMaterial=function(f,s,j,k){var m,w,x;if(f instanceof THREE.MeshDepthMaterial)x="depth";else if(f instanceof THREE.ShadowVolumeDynamicMaterial)x="shadowVolumeDynamic";else if(f instanceof
-THREE.MeshNormalMaterial)x="normal";else if(f instanceof THREE.MeshBasicMaterial)x="basic";else if(f instanceof THREE.MeshLambertMaterial)x="lambert";else if(f instanceof THREE.MeshPhongMaterial)x="phong";else if(f instanceof THREE.LineBasicMaterial)x="basic";else f instanceof THREE.ParticleBasicMaterial&&(x="particle_basic");if(x){var u=THREE.ShaderLib[x];f.uniforms=THREE.UniformsUtils.clone(u.uniforms);f.vertexShader=u.vertexShader;f.fragmentShader=u.fragmentShader}var A,t,y;A=y=u=0;for(t=s.length;A<
-t;A++){w=s[A];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&u++}if(u+y<=4)s=y;else{s=Math.ceil(4*y/(u+y));u=4-s}w={directional:s,point:u};y=50;if(k!==undefined&&k instanceof THREE.SkinnedMesh)y=k.bones.length;var z;a:{A=f.fragmentShader;t=f.vertexShader;u=f.uniforms;s=f.attributes;j={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:j,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,maxMorphTargets:this.maxMorphTargets,
-maxDirLights:w.directional,maxPointLights:w.point,maxBones:y};var D;w=[];if(x)w.push(x);else{w.push(A);w.push(t)}for(D in j){w.push(D);w.push(j[D])}x=w.join();D=0;for(w=pa.length;D<w;D++)if(pa[D].code==x){z=pa[D].program;break a}D=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,j.fog?"#define USE_FOG":"",j.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",j.map?"#define USE_MAP":
-"",j.envMap?"#define USE_ENVMAP":"",j.lightMap?"#define USE_LIGHTMAP":"",j.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,"#define MAX_BONES "+j.maxBones,j.map?"#define USE_MAP":"",j.envMap?"#define USE_ENVMAP":"",j.lightMap?"#define USE_LIGHTMAP":"",j.vertexColors?
-"#define USE_COLOR":"",j.skinning?"#define USE_SKINNING":"",j.morphTargets?"#define USE_MORPHTARGETS":"",j.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var V=this,c,ga=document.createElement("canvas"),xa=[],sa=null,ya=null,Y=!0,na=null,oa=null,ha=null,Z=null,va=
+0,qa=0,za=0,Aa=0,aa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Pa=new THREE.Matrix4,Ta=new Float32Array(16),Xa=new Float32Array(16),Ua=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):
+new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0,faces:0};this.maxMorphTargets=8;this.domElement=ga;this.autoClear=!0;this.sortObjects=!0;(function(f,r,j,k){try{if(!(c=ga.getContext("experimental-webgl",{antialias:f,stencil:k})))throw"Error creating WebGL context.";}catch(m){console.error(m)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));
+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.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(r.r,r.g,r.b,j)})(antialias,clearColor,clearAlpha,stencil);this.context=c;if(stencil){var R={};R.vertices=new Float32Array(12);R.faces=new Uint16Array(6);R.darkness=0.5;R.vertices[0]=-20;R.vertices[1]=-20;R.vertices[2]=-1;R.vertices[3]=20;R.vertices[4]=
+-20;R.vertices[5]=-1;R.vertices[6]=20;R.vertices[7]=20;R.vertices[8]=-1;R.vertices[9]=-20;R.vertices[10]=20;R.vertices[11]=-1;R.faces[0]=0;R.faces[1]=1;R.faces[2]=2;R.faces[3]=0;R.faces[4]=2;R.faces[5]=3;R.vertexBuffer=c.createBuffer();R.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,R.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,R.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,R.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,R.faces,c.STATIC_DRAW);R.program=c.createProgram();
+c.attachShader(R.program,ca("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(R.program,ca("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(R.program);R.vertexLocation=c.getAttribLocation(R.program,"position");R.projectionLocation=c.getUniformLocation(R.program,"projectionMatrix");R.darknessLocation=c.getUniformLocation(R.program,"darkness")}var J={};J.vertices=new Float32Array(16);J.faces=new Uint16Array(6);b=0;J.vertices[b++]=-1;J.vertices[b++]=-1;J.vertices[b++]=
+0;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;b=0;J.faces[b++]=0;J.faces[b++]=1;J.faces[b++]=2;J.faces[b++]=0;J.faces[b++]=2;J.faces[b++]=3;J.vertexBuffer=c.createBuffer();J.elementBuffer=c.createBuffer();J.tempTexture=c.createTexture();J.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);
+c.bufferData(c.ARRAY_BUFFER,J.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
+c.NEAREST);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);if(c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){J.hasVertexTexture=!1;J.program=c.createProgram();c.attachShader(J.program,
+ca("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{J.hasVertexTexture=!0;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}c.linkProgram(J.program);J.attributes={};J.uniforms={};J.attributes.vertex=c.getAttribLocation(J.program,"position");J.attributes.uv=
+c.getAttribLocation(J.program,"UV");J.uniforms.renderType=c.getUniformLocation(J.program,"renderType");J.uniforms.map=c.getUniformLocation(J.program,"map");J.uniforms.occlusionMap=c.getUniformLocation(J.program,"occlusionMap");J.uniforms.opacity=c.getUniformLocation(J.program,"opacity");J.uniforms.scale=c.getUniformLocation(J.program,"scale");J.uniforms.rotation=c.getUniformLocation(J.program,"rotation");J.uniforms.screenPosition=c.getUniformLocation(J.program,"screenPosition");var pb=!1;_sprite=
+{};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=
+1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,ca("fragment",THREE.ShaderLib.sprite.fragmentShader));
+c.attachShader(_sprite.program,ca("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=c.getUniformLocation(_sprite.program,
+"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=
+c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");var ob=!1;this.setSize=function(f,r){ga.width=f;ga.height=r;this.setViewport(0,0,ga.width,ga.height)};this.setViewport=function(f,r,j,k){va=f;qa=r;za=j;Aa=k;c.viewport(va,qa,za,Aa)};this.setScissor=function(f,r,j,k){c.scissor(f,r,j,k)};this.enableScissorTest=function(f){f?
+c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){Y=f;c.depthMask(f)};this.setClearColorHex=function(f,r){var j=new THREE.Color(f);c.clearColor(j.r,j.g,j.b,r)};this.setClearColor=function(f,r){c.clearColor(f.r,f.g,f.b,r)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){R.darkness=f};this.initMaterial=function(f,r,j,k){var m,w,x;if(f instanceof THREE.MeshDepthMaterial)x="depth";
+else if(f instanceof THREE.ShadowVolumeDynamicMaterial)x="shadowVolumeDynamic";else if(f instanceof THREE.MeshNormalMaterial)x="normal";else if(f instanceof THREE.MeshBasicMaterial)x="basic";else if(f instanceof THREE.MeshLambertMaterial)x="lambert";else if(f instanceof THREE.MeshPhongMaterial)x="phong";else if(f instanceof THREE.LineBasicMaterial)x="basic";else f instanceof THREE.ParticleBasicMaterial&&(x="particle_basic");if(x){var u=THREE.ShaderLib[x];f.uniforms=THREE.UniformsUtils.clone(u.uniforms);
+f.vertexShader=u.vertexShader;f.fragmentShader=u.fragmentShader}var A,t,y;A=y=u=0;for(t=r.length;A<t;A++){w=r[A];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&u++}if(u+y<=4)r=y;else{r=Math.ceil(4*y/(u+y));u=4-r}w={directional:r,point:u};y=50;if(k!==undefined&&k instanceof THREE.SkinnedMesh)y=k.bones.length;var z;a:{A=f.fragmentShader;t=f.vertexShader;u=f.uniforms;r=f.attributes;j={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:j,sizeAttenuation:f.sizeAttenuation,
+skinning:f.skinning,morphTargets:f.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:w.directional,maxPointLights:w.point,maxBones:y};var D;w=[];if(x)w.push(x);else{w.push(A);w.push(t)}for(D in j){w.push(D);w.push(j[D])}x=w.join();D=0;for(w=xa.length;D<w;D++)if(xa[D].code==x){z=xa[D].program;break a}D=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,j.fog?"#define USE_FOG":
+"",j.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",j.map?"#define USE_MAP":"",j.envMap?"#define USE_ENVMAP":"",j.lightMap?"#define USE_LIGHTMAP":"",j.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+j.maxDirLights,"#define MAX_POINT_LIGHTS "+j.maxPointLights,"#define MAX_BONES "+j.maxBones,j.map?"#define USE_MAP":"",
+j.envMap?"#define USE_ENVMAP":"",j.lightMap?"#define USE_LIGHTMAP":"",j.vertexColors?"#define USE_COLOR":"",j.skinning?"#define USE_SKINNING":"",j.morphTargets?"#define USE_MORPHTARGETS":"",j.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
 c.attachShader(D,ca("fragment",prefix_fragment+A));c.attachShader(D,ca("vertex",prefix_vertex+t));c.linkProgram(D);c.getProgramParameter(D,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(D,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");D.uniforms={};D.attributes={};var B;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(B in u)A.push(B);
-B=A;u=0;for(A=B.length;u<A;u++){t=B[u];D.uniforms[t]=c.getUniformLocation(D,t)}A=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(B=0;B<j.maxMorphTargets;B++)A.push("morphTarget"+B);for(z in s)A.push(z);z=A;B=0;for(s=z.length;B<s;B++){j=z[B];D.attributes[j]=c.getAttribLocation(D,j)}pa.push({program:D,code:x});z=D}f.program=z;z=f.program.attributes;c.enableVertexAttribArray(z.position);z.color>=0&&c.enableVertexAttribArray(z.color);z.normal>=
+B=A;u=0;for(A=B.length;u<A;u++){t=B[u];D.uniforms[t]=c.getUniformLocation(D,t)}A=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(B=0;B<j.maxMorphTargets;B++)A.push("morphTarget"+B);for(z in r)A.push(z);z=A;B=0;for(r=z.length;B<r;B++){j=z[B];D.attributes[j]=c.getAttribLocation(D,j)}xa.push({program:D,code:x});z=D}f.program=z;z=f.program.attributes;c.enableVertexAttribArray(z.position);z.color>=0&&c.enableVertexAttribArray(z.color);z.normal>=
 0&&c.enableVertexAttribArray(z.normal);z.tangent>=0&&c.enableVertexAttribArray(z.tangent);if(f.skinning&&z.skinVertexA>=0&&z.skinVertexB>=0&&z.skinIndex>=0&&z.skinWeight>=0){c.enableVertexAttribArray(z.skinVertexA);c.enableVertexAttribArray(z.skinVertexB);c.enableVertexAttribArray(z.skinIndex);c.enableVertexAttribArray(z.skinWeight)}for(m in f.attributes)z[m]>=0&&c.enableVertexAttribArray(z[m]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(z.morphTarget0>=0){c.enableVertexAttribArray(z.morphTarget0);
 f.numSupportedMorphTargets++}if(z.morphTarget1>=0){c.enableVertexAttribArray(z.morphTarget1);f.numSupportedMorphTargets++}if(z.morphTarget2>=0){c.enableVertexAttribArray(z.morphTarget2);f.numSupportedMorphTargets++}if(z.morphTarget3>=0){c.enableVertexAttribArray(z.morphTarget3);f.numSupportedMorphTargets++}if(z.morphTarget4>=0){c.enableVertexAttribArray(z.morphTarget4);f.numSupportedMorphTargets++}if(z.morphTarget5>=0){c.enableVertexAttribArray(z.morphTarget5);f.numSupportedMorphTargets++}if(z.morphTarget6>=
-0){c.enableVertexAttribArray(z.morphTarget6);f.numSupportedMorphTargets++}if(z.morphTarget7>=0){c.enableVertexAttribArray(z.morphTarget7);f.numSupportedMorphTargets++}k.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);f=0;for(m=this.maxMorphTargets;f<m;f++)k.__webglMorphTargetInfluences[f]=0}};this.render=function(f,s,j,k){var m,w,x,u,A,t,y,z,D=f.lights,B=f.fog;s.matrixAutoUpdate&&s.updateMatrix();f.update(undefined,!1,s);s.matrixWorldInverse.flattenToArray(Xa);s.projectionMatrix.flattenToArray(Ta);
-Pa.multiply(s.projectionMatrix,s.matrixWorldInverse);p(Pa);this.initWebGLObjects(f);Ia(j);(this.autoClear||k)&&this.clear();A=f.__webglObjects.length;for(k=0;k<A;k++){m=f.__webglObjects[k];y=m.object;if(y.visible)if(!(y instanceof THREE.Mesh)||q(y)){y.matrixWorld.flattenToArray(y._objectMatrixArray);V(y,s);F(m);m.render=!0;if(this.sortObjects){Ua.copy(y.position);Pa.multiplyVector3(Ua);m.z=Ua.z}}else m.render=!1;else m.render=!1}this.sortObjects&&f.__webglObjects.sort(H);t=f.__webglObjectsImmediate.length;
-for(k=0;k<t;k++){m=f.__webglObjectsImmediate[k];y=m.object;if(y.visible){y.matrixAutoUpdate&&y.matrixWorld.flattenToArray(y._objectMatrixArray);V(y,s);E(m)}}oa(THREE.NormalBlending);for(k=0;k<A;k++){m=f.__webglObjects[k];if(m.render){y=m.object;z=m.buffer;x=m.opaque;o(y);for(m=0;m<x.count;m++){u=x.list[m];n(u.depthTest);g(s,D,B,u,z,y)}}}for(k=0;k<t;k++){m=f.__webglObjectsImmediate[k];y=m.object;if(y.visible){x=m.opaque;o(y);for(m=0;m<x.count;m++){u=x.list[m];n(u.depthTest);w=e(s,D,B,u,y);y.render(function(O){h(O,
-w,u.shading)})}}}for(k=0;k<A;k++){m=f.__webglObjects[k];if(m.render){y=m.object;z=m.buffer;x=m.transparent;o(y);for(m=0;m<x.count;m++){u=x.list[m];oa(u.blending);n(u.depthTest);g(s,D,B,u,z,y)}}}for(k=0;k<t;k++){m=f.__webglObjectsImmediate[k];y=m.object;if(y.visible){x=m.transparent;o(y);for(m=0;m<x.count;m++){u=x.list[m];oa(u.blending);n(u.depthTest);w=e(s,D,B,u,y);y.render(function(O){h(O,w,u.shading)})}}}f.__webglSprites.length&&M(f,s);stencil&&f.__webglShadowVolumes.length&&f.lights.length&&I(f);
-f.__webglLensFlares.length&&N(f,s);if(j&&j.minFilter!==THREE.NearestFilter&&j.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,j.__webglTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[];f.__webglShadowVolumes=[];f.__webglLensFlares=[];f.__webglSprites=[]}for(;f.__objectsAdded.length;){var s=f.__objectsAdded[0],j=f,k=void 0,m=void 0,w=void 0;if(s._modelViewMatrix==
-undefined){s._modelViewMatrix=new THREE.Matrix4;s._normalMatrixArray=new Float32Array(9);s._modelViewMatrixArray=new Float32Array(16);s._objectMatrixArray=new Float32Array(16);s.matrixWorld.flattenToArray(s._objectMatrixArray)}if(s instanceof THREE.Mesh){m=s.geometry;m.geometryGroups==undefined&&sa(m);for(k in m.geometryGroups){w=m.geometryGroups[k];if(!w.__webglVertexBuffer){var x=w;x.__webglVertexBuffer=c.createBuffer();x.__webglNormalBuffer=c.createBuffer();x.__webglTangentBuffer=c.createBuffer();
-x.__webglColorBuffer=c.createBuffer();x.__webglUVBuffer=c.createBuffer();x.__webglUV2Buffer=c.createBuffer();x.__webglSkinVertexABuffer=c.createBuffer();x.__webglSkinVertexBBuffer=c.createBuffer();x.__webglSkinIndicesBuffer=c.createBuffer();x.__webglSkinWeightsBuffer=c.createBuffer();x.__webglFaceBuffer=c.createBuffer();x.__webglLineBuffer=c.createBuffer();if(x.numMorphTargets){var u=void 0,A=void 0;x.__webglMorphTargetsBuffers=[];u=0;for(A=x.numMorphTargets;u<A;u++)x.__webglMorphTargetsBuffers.push(c.createBuffer())}x=
-w;u=s;var t=void 0,y=void 0,z=void 0;z=void 0;var D=void 0,B=void 0,O=void 0,W=O=A=0;y=void 0;z=void 0;var P=void 0;t=void 0;y=void 0;D=u.geometry;P=D.faces;B=x.faces;t=0;for(y=B.length;t<y;t++){z=B[t];z=P[z];if(z instanceof THREE.Face3){A+=3;O+=1;W+=3}else if(z instanceof THREE.Face4){A+=4;O+=2;W+=4}}t=x;y=u;P=void 0;B=void 0;var X=void 0,Ga=void 0;X=void 0;z=[];P=0;for(B=y.materials.length;P<B;P++){X=y.materials[P];if(X instanceof THREE.MeshFaceMaterial){X=0;for(l=t.materials.length;X<l;X++)(Ga=
+0){c.enableVertexAttribArray(z.morphTarget6);f.numSupportedMorphTargets++}if(z.morphTarget7>=0){c.enableVertexAttribArray(z.morphTarget7);f.numSupportedMorphTargets++}k.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);f=0;for(m=this.maxMorphTargets;f<m;f++)k.__webglMorphTargetInfluences[f]=0}};this.render=function(f,r,j,k){var m,w,x,u,A,t,y,z,D=f.lights,B=f.fog;V.data.vertices=0;V.data.faces=0;r.matrixAutoUpdate&&r.update(undefined,!0);f.update(undefined,!1,r);r.matrixWorldInverse.flattenToArray(Xa);
+r.projectionMatrix.flattenToArray(Ta);Pa.multiply(r.projectionMatrix,r.matrixWorldInverse);p(Pa);this.initWebGLObjects(f);Ia(j);(this.autoClear||k)&&this.clear();A=f.__webglObjects.length;for(k=0;k<A;k++){m=f.__webglObjects[k];y=m.object;if(y.visible)if(!(y instanceof THREE.Mesh)||q(y)){y.matrixWorld.flattenToArray(y._objectMatrixArray);U(y,r);F(m);m.render=!0;if(this.sortObjects){Ua.copy(y.position);Pa.multiplyVector3(Ua);m.z=Ua.z}}else m.render=!1;else m.render=!1}this.sortObjects&&f.__webglObjects.sort(H);
+t=f.__webglObjectsImmediate.length;for(k=0;k<t;k++){m=f.__webglObjectsImmediate[k];y=m.object;if(y.visible){y.matrixAutoUpdate&&y.matrixWorld.flattenToArray(y._objectMatrixArray);U(y,r);E(m)}}pa(THREE.NormalBlending);for(k=0;k<A;k++){m=f.__webglObjects[k];if(m.render){y=m.object;z=m.buffer;x=m.opaque;o(y);for(m=0;m<x.count;m++){u=x.list[m];n(u.depthTest);g(r,D,B,u,z,y)}}}for(k=0;k<t;k++){m=f.__webglObjectsImmediate[k];y=m.object;if(y.visible){x=m.opaque;o(y);for(m=0;m<x.count;m++){u=x.list[m];n(u.depthTest);
+w=e(r,D,B,u,y);y.render(function(O){h(O,w,u.shading)})}}}for(k=0;k<A;k++){m=f.__webglObjects[k];if(m.render){y=m.object;z=m.buffer;x=m.transparent;o(y);for(m=0;m<x.count;m++){u=x.list[m];pa(u.blending);n(u.depthTest);g(r,D,B,u,z,y)}}}for(k=0;k<t;k++){m=f.__webglObjectsImmediate[k];y=m.object;if(y.visible){x=m.transparent;o(y);for(m=0;m<x.count;m++){u=x.list[m];pa(u.blending);n(u.depthTest);w=e(r,D,B,u,y);y.render(function(O){h(O,w,u.shading)})}}}f.__webglSprites.length&&M(f,r);stencil&&f.__webglShadowVolumes.length&&
+f.lights.length&&I(f);f.__webglLensFlares.length&&N(f,r);if(j&&j.minFilter!==THREE.NearestFilter&&j.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,j.__webglTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[];f.__webglShadowVolumes=[];f.__webglLensFlares=[];f.__webglSprites=[]}for(;f.__objectsAdded.length;){var r=f.__objectsAdded[0],j=f,k=void 0,m=void 0,w=void 0;
+if(r._modelViewMatrix==undefined){r._modelViewMatrix=new THREE.Matrix4;r._normalMatrixArray=new Float32Array(9);r._modelViewMatrixArray=new Float32Array(16);r._objectMatrixArray=new Float32Array(16);r.matrixWorld.flattenToArray(r._objectMatrixArray)}if(r instanceof THREE.Mesh){m=r.geometry;m.geometryGroups==undefined&&ra(m);for(k in m.geometryGroups){w=m.geometryGroups[k];if(!w.__webglVertexBuffer){var x=w;x.__webglVertexBuffer=c.createBuffer();x.__webglNormalBuffer=c.createBuffer();x.__webglTangentBuffer=
+c.createBuffer();x.__webglColorBuffer=c.createBuffer();x.__webglUVBuffer=c.createBuffer();x.__webglUV2Buffer=c.createBuffer();x.__webglSkinVertexABuffer=c.createBuffer();x.__webglSkinVertexBBuffer=c.createBuffer();x.__webglSkinIndicesBuffer=c.createBuffer();x.__webglSkinWeightsBuffer=c.createBuffer();x.__webglFaceBuffer=c.createBuffer();x.__webglLineBuffer=c.createBuffer();if(x.numMorphTargets){var u=void 0,A=void 0;x.__webglMorphTargetsBuffers=[];u=0;for(A=x.numMorphTargets;u<A;u++)x.__webglMorphTargetsBuffers.push(c.createBuffer())}x=
+w;u=r;var t=void 0,y=void 0,z=void 0;z=void 0;var D=void 0,B=void 0,O=void 0,W=O=A=0;y=void 0;z=void 0;var P=void 0;t=void 0;y=void 0;D=u.geometry;P=D.faces;B=x.faces;t=0;for(y=B.length;t<y;t++){z=B[t];z=P[z];if(z instanceof THREE.Face3){A+=3;O+=1;W+=3}else if(z instanceof THREE.Face4){A+=4;O+=2;W+=4}}t=x;y=u;P=void 0;B=void 0;var X=void 0,Ga=void 0;X=void 0;z=[];P=0;for(B=y.materials.length;P<B;P++){X=y.materials[P];if(X instanceof THREE.MeshFaceMaterial){X=0;for(l=t.materials.length;X<l;X++)(Ga=
 t.materials[X])&&z.push(Ga)}else(Ga=X)&&z.push(Ga)}t=z;a:{y=void 0;P=void 0;B=t.length;for(y=0;y<B;y++){P=t[y];if(P.map||P.lightMap||P instanceof THREE.MeshShaderMaterial){y=!0;break a}}y=!1}a:{P=void 0;B=void 0;z=t.length;for(P=0;P<z;P++){B=t[P];if(!(B instanceof THREE.MeshBasicMaterial&&!B.envMap||B instanceof THREE.MeshDepthMaterial)){P=B&&B.shading!=undefined&&B.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}P=!1}a:{B=void 0;z=void 0;X=t.length;for(B=0;B<X;B++){z=
 t[B];if(z.vertexColors){z=z.vertexColors;break a}}z=!1}x.__vertexArray=new Float32Array(A*3);if(P)x.__normalArray=new Float32Array(A*3);if(D.hasTangents)x.__tangentArray=new Float32Array(A*4);if(z)x.__colorArray=new Float32Array(A*3);if(y){if(D.faceUvs.length>0||D.faceVertexUvs.length>0)x.__uvArray=new Float32Array(A*2);if(D.faceUvs.length>1||D.faceVertexUvs.length>1)x.__uv2Array=new Float32Array(A*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length){x.__skinVertexAArray=new Float32Array(A*
 4);x.__skinVertexBArray=new Float32Array(A*4);x.__skinIndexArray=new Float32Array(A*4);x.__skinWeightArray=new Float32Array(A*4)}x.__faceArray=new Uint16Array(O*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0));x.__lineArray=new Uint16Array(W*2);if(x.numMorphTargets){x.__morphTargetsArrays=[];D=0;for(B=x.numMorphTargets;D<B;D++)x.__morphTargetsArrays.push(new Float32Array(A*3))}x.__needsSmoothNormals=P==THREE.SmoothShading;x.__uvType=y;x.__vertexColorType=z;x.__normalType=P;x.__webglFaceCount=
 O*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0);x.__webglLineCount=W*2;D=0;for(B=t.length;D<B;D++)if(t[D].attributes){x.__webglCustomAttributes={};for(a in t[D].attributes){y=t[D].attributes[a];O=1;if(y.type==="v2")O=2;else if(y.type==="v3")O=3;else if(y.type==="v4")O=4;else y.type==="c"&&(O=3);y.size=O;y.needsUpdate=!0;y.array=new Float32Array(A*O);y.buffer=c.createBuffer();x.__webglCustomAttributes[a]=y}}m.__dirtyVertices=!0;m.__dirtyMorphTargets=!0;m.__dirtyElements=!0;m.__dirtyUvs=
-!0;m.__dirtyNormals=!0;m.__dirtyTangents=!0;m.__dirtyColors=!0}s instanceof THREE.ShadowVolume?da(j.__webglShadowVolumes,w,s):da(j.__webglObjects,w,s)}}else if(s instanceof THREE.LensFlare)da(j.__webglLensFlares,undefined,s);else if(s instanceof THREE.Ribbon){m=s.geometry;if(!m.__webglVertexBuffer){k=m;k.__webglVertexBuffer=c.createBuffer();k.__webglColorBuffer=c.createBuffer();k=m;w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__webglVertexCount=
-w;m.__dirtyVertices=!0;m.__dirtyColors=!0}da(j.__webglObjects,m,s)}else if(s instanceof THREE.Line){m=s.geometry;if(!m.__webglVertexBuffer){k=m;k.__webglVertexBuffer=c.createBuffer();k.__webglColorBuffer=c.createBuffer();k=m;w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__webglLineCount=w;m.__dirtyVertices=!0;m.__dirtyColors=!0}da(j.__webglObjects,m,s)}else if(s instanceof THREE.ParticleSystem){m=s.geometry;if(!m.__webglVertexBuffer){k=m;k.__webglVertexBuffer=
-c.createBuffer();k.__webglColorBuffer=c.createBuffer();k=m;w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__sortArray=[];k.__webglParticleCount=w;m.__dirtyVertices=!0;m.__dirtyColors=!0}da(j.__webglObjects,m,s)}else if(THREE.MarchingCubes!==undefined&&s instanceof THREE.MarchingCubes)j.__webglObjectsImmediate.push({object:s,opaque:{list:[],count:0},transparent:{list:[],count:0}});else s instanceof THREE.Sprite&&j.__webglSprites.push(s);f.__objectsAdded.splice(0,
-1)}for(;f.__objectsRemoved.length;){s=f.__objectsRemoved[0];j=f;m=void 0;k=void 0;for(m=j.__webglObjects.length-1;m>=0;m--){k=j.__webglObjects[m].object;if(s==k){j.__webglObjects.splice(m,1);break}}f.__objectsRemoved.splice(0,1)}s=0;for(j=f.__webglObjects.length;s<j;s++)L(f.__webglObjects[s].object,f);s=0;for(j=f.__webglShadowVolumes.length;s<j;s++)L(f.__webglShadowVolumes[s].object,f);s=0;for(j=f.__webglLensFlares.length;s<j;s++)L(f.__webglLensFlares[s].object,f)};this.setFaceCulling=function(f,
-s){if(f){!s||s=="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}};
+!0;m.__dirtyNormals=!0;m.__dirtyTangents=!0;m.__dirtyColors=!0}r instanceof THREE.ShadowVolume?da(j.__webglShadowVolumes,w,r):da(j.__webglObjects,w,r)}}else if(r instanceof THREE.LensFlare)da(j.__webglLensFlares,undefined,r);else if(r instanceof THREE.Ribbon){m=r.geometry;if(!m.__webglVertexBuffer){k=m;k.__webglVertexBuffer=c.createBuffer();k.__webglColorBuffer=c.createBuffer();k=m;w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__webglVertexCount=
+w;m.__dirtyVertices=!0;m.__dirtyColors=!0}da(j.__webglObjects,m,r)}else if(r instanceof THREE.Line){m=r.geometry;if(!m.__webglVertexBuffer){k=m;k.__webglVertexBuffer=c.createBuffer();k.__webglColorBuffer=c.createBuffer();k=m;w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__webglLineCount=w;m.__dirtyVertices=!0;m.__dirtyColors=!0}da(j.__webglObjects,m,r)}else if(r instanceof THREE.ParticleSystem){m=r.geometry;if(!m.__webglVertexBuffer){k=m;k.__webglVertexBuffer=
+c.createBuffer();k.__webglColorBuffer=c.createBuffer();k=m;w=k.vertices.length;k.__vertexArray=new Float32Array(w*3);k.__colorArray=new Float32Array(w*3);k.__sortArray=[];k.__webglParticleCount=w;m.__dirtyVertices=!0;m.__dirtyColors=!0}da(j.__webglObjects,m,r)}else if(THREE.MarchingCubes!==undefined&&r instanceof THREE.MarchingCubes)j.__webglObjectsImmediate.push({object:r,opaque:{list:[],count:0},transparent:{list:[],count:0}});else r instanceof THREE.Sprite&&j.__webglSprites.push(r);f.__objectsAdded.splice(0,
+1)}for(;f.__objectsRemoved.length;){r=f.__objectsRemoved[0];j=f;m=void 0;k=void 0;if(r instanceof THREE.Mesh)for(m=j.__webglObjects.length-1;m>=0;m--){k=j.__webglObjects[m].object;if(r==k){j.__webglObjects.splice(m,1);break}}else if(r instanceof THREE.Sprite)for(m=j.__webglSprites.length-1;m>=0;m--){k=j.__webglSprites[m];if(r==k){j.__webglSprites.splice(m,1);break}}f.__objectsRemoved.splice(0,1)}r=0;for(j=f.__webglObjects.length;r<j;r++)L(f.__webglObjects[r].object,f);r=0;for(j=f.__webglShadowVolumes.length;r<
+j;r++)L(f.__webglShadowVolumes[r].object,f);r=0;for(j=f.__webglLensFlares.length;r<j;r++)L(f.__webglLensFlares[r].object,f)};this.setFaceCulling=function(f,r){if(f){!r||r=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.WebGLRenderTarget=function(b,d,e){this.width=b;this.height=d;e=e||{};this.wrapS=e.wrapS!==undefined?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==undefined?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==undefined?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==undefined?e.minFilter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBAFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==
 undefined?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==undefined?e.stencilBuffer:!0};

+ 1 - 1
examples/canvas_geometry_terrain.html

@@ -31,7 +31,7 @@
 	<body>
 
 		<div id="container"><br /><br /><br /><br /><br />Generating...</div> 
-		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - terrain demo. <a href="geometry_terrain.html">generate another</a></div> 
+		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - terrain demo. <a href="canvas_geometry_terrain.html">generate another</a></div> 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 

+ 2 - 4
examples/misc_lookat.html

@@ -30,8 +30,7 @@
 	<body>
 		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - Object3D::lookAt() demo</div>
 
-		<script type="text/javascript" src="../build/custom/ThreeWebGL.js"></script>
-		<script type="text/javascript" src="../build/custom/ThreeExtras.js"></script>
+		<script type="text/javascript" src="../build/Three.js"></script>
 
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -65,7 +64,7 @@
 
 				scene = new THREE.Scene();
 
-				var geometry = new THREE.Cube( 10, 10, 100 );
+				var geometry = new THREE.Cylinder( 3, 10, 0.1, 100 );
 				var material = new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } );
 
 				target = new THREE.Mesh( new THREE.Sphere( 100, 20, 20 ), material );
@@ -78,7 +77,6 @@
 					mesh.position.y = Math.random() * 4000 - 2000;
 					mesh.position.z = Math.random() * 4000 - 2000;
 					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 4 + 2;
-
 					scene.addObject( mesh );
 
 				}

+ 5 - 6
examples/webgl_materials_grass.html

@@ -42,12 +42,11 @@
 
 				var geometry = new THREE.Plane( 100, 100 );
 
-				var texture = generateTextureBase();
-				texture.needsUpdate = true;
+				var bitmap = generateTextureBase();
 
 				for ( var i = 0; i < 15; i ++ ) {
 
-					mesh = levels[ i ] = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: new THREE.Texture( generateTextureLevel( texture ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping ), depthTest: false } ) );
+					mesh = levels[ i ] = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: new THREE.Texture( generateTextureLevel( bitmap ) ), depthTest: false } ) );
 					mesh.materials[0].map.needsUpdate = true;
 					mesh.rotation.x = - 90 * ( Math.PI / 180 );
 					mesh.position.y = i * 0.25;
@@ -65,8 +64,8 @@
 			function generateTextureBase() {
 
 				var canvas = document.createElement( 'canvas' );
-				canvas.width = 1024;
-				canvas.height = 1024;
+				canvas.width = 512;
+				canvas.height = 512;
 
 				var context = canvas.getContext( '2d' );
 
@@ -74,7 +73,7 @@
 
 					context.fillStyle = 'rgba(0,' + Math.floor( Math.random() * 64 + 32 ) + ',16,1)';
 					context.beginPath();
-					context.arc( Math.random() * canvas.width, Math.random() * canvas.height, Math.random() * 2 + 1, 0, Math.PI * 2, true );
+					context.arc( Math.random() * canvas.width, Math.random() * canvas.height, Math.random() * 1 + 0.5, 0, Math.PI * 2, true );
 					context.closePath();
 					context.fill();
 

+ 9 - 2
examples/webgl_sandbox.html

@@ -52,13 +52,13 @@
 		<script type="text/javascript" src="../src/core/UV.js"></script>
 		<script type="text/javascript" src="../src/core/Geometry.js"></script>
 		<script type="text/javascript" src="../src/core/Spline.js"></script>
-		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
-		<script type="text/javascript" src="../src/animation/Animation.js"></script>
+		<script type="text/javascript" src="../src/core/Edge.js"></script>
 		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
 		<script type="text/javascript" src="../src/lights/Light.js"></script>
 		<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
 		<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
 		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
+		<script type="text/javascript" src="../src/lights/LensFlare.js"></script>
 		<script type="text/javascript" src="../src/materials/Material.js"></script>
 		<script type="text/javascript" src="../src/materials/Mappings.js"></script>
 		<script type="text/javascript" src="../src/materials/LineBasicMaterial.js"></script>
@@ -84,6 +84,7 @@
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
 		<script type="text/javascript" src="../src/objects/LOD.js"></script>
 		<script type="text/javascript" src="../src/objects/ShadowVolume.js"></script>
+		<script type="text/javascript" src="../src/objects/Sprite.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -101,12 +102,15 @@
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
+		<script type="text/javascript" src="../src/extras/animation/AnimationHandler.js"></script>
+		<script type="text/javascript" src="../src/extras/animation/Animation.js"></script>
 		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/cameras/QuakeCamera.js"></script>
 		<script type="text/javascript" src="../src/extras/cameras/PathCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/FlyCamera.js"></script>
 		<script type="text/javascript" src="../src/extras/geometries/Cube.js"></script>
 		<script type="text/javascript" src="../src/extras/geometries/Cylinder.js"></script>
 		<script type="text/javascript" src="../src/extras/geometries/Icosahedron.js"></script>
@@ -118,7 +122,10 @@
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
 		<script type="text/javascript" src="../src/extras/io/JSONLoader.js"></script>
 		<script type="text/javascript" src="../src/extras/io/BinaryLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/SceneLoader.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
+		<script type="text/javascript" src="../src/extras/physics/Collisions.js"></script>
+		<script type="text/javascript" src="../src/extras/physics/CollisionUtils.js"></script>
 
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>

+ 0 - 2
examples/webgl_sprites.html

@@ -94,8 +94,6 @@
 				sprite.opacity = 1;
 				scene.addChild( sprite );
 
-
-
 				// renderer
 
 				renderer = new THREE.WebGLRenderer();

+ 1 - 16
src/cameras/Camera.js

@@ -42,13 +42,6 @@ THREE.Camera.prototype.updateProjectionMatrix = function () {
 
 };
 
-THREE.Camera.prototype.updateMatrix = function () {
-
-	// this.parent === undefined && this.update( undefined, true );
-	this.update( undefined, true );
-
-};
-
 THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camera ) {
 
 	if ( this.useTarget ) {
@@ -77,15 +70,7 @@ THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camer
 
 	} else {
 
-		/*
-		if ( this.matrixAutoUpdate ) {
-
-			// this doesn't make sense, it is endless loop
-			// also updateMatrix() doesn't return anything
-			//forceUpdate |= this.updateMatrix();
-
-		}
-		*/
+		this.matrixAutoUpdate && this.updateMatrix();
 
 		if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 

+ 1 - 1
src/core/Object3D.js

@@ -68,7 +68,7 @@ THREE.Object3D.prototype = {
 
 		// TODO: Add hierarchy support.
 
-		this.matrix.lookAt( this.position, vector, this.up );
+		this.matrix.lookAt( vector, this.position, this.up );
 
 		if ( this.rotationAutoUpdate ) {
 

+ 43 - 0
src/core/Quaternion.js

@@ -1,5 +1,6 @@
 /*
  * @author mikael emtinger / http://gomo.se/
+ * @author alteredq / http://alteredqualia.com/
  */
 
 THREE.Quaternion = function( x, y, z, w ) {
@@ -28,6 +29,17 @@ THREE.Quaternion.prototype = {
 
 	},
 
+	copy : function ( q ) {
+
+		this.x = q.x;
+		this.y = q.y;
+		this.z = q.z;
+		this.w = q.w;
+
+		return this;
+
+	},
+
 	setFromEuler : function ( vec3 ) {
 
 		var c = 0.5 * Math.PI / 360, // 0.5 is an optimization
@@ -41,6 +53,7 @@ THREE.Quaternion.prototype = {
 		s2 = Math.sin( -z ),
 		c3 = Math.cos( x  ),
 		s3 = Math.sin( x  ),
+
 		c1c2 = c1 * c2,
 		s1s2 = s1 * s2;
 
@@ -53,6 +66,23 @@ THREE.Quaternion.prototype = {
 
 	},
 
+	setFromAxisAngle: function ( axis, angle ) {
+
+		// from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
+		// axis have to be normalized
+
+		var halfAngle = angle / 2,
+			s = Math.sin( halfAngle );
+
+		this.x = axis.x * s;
+		this.y = axis.y * s;
+		this.z = axis.z * s;
+		this.w = Math.cos( halfAngle );
+
+		return this;
+
+	},
+	
 	calculateW  : function () {
 
 		this.w = - Math.sqrt( Math.abs( 1.0 - this.x * this.x - this.y * this.y - this.z * this.z ) );
@@ -117,6 +147,19 @@ THREE.Quaternion.prototype = {
 
 	},
 
+	multiply: function ( q1, q2 ) {
+
+		// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
+
+		this.x =  q1.x * q2.w + q1.y * q2.z - q1.z * q2.y + q1.w * q2.x;
+		this.y = -q1.x * q2.z + q1.y * q2.w + q1.z * q2.x + q1.w * q2.y;
+		this.z =  q1.x * q2.y - q1.y * q2.x + q1.z * q2.w + q1.w * q2.z;
+		this.w = -q1.x * q2.x - q1.y * q2.y - q1.z * q2.z + q1.w * q2.w;
+		
+		return this;
+
+	},
+
 	multiplyVector3 : function ( vec, dest ) {
 
 		if( !dest ) { dest = vec; }

+ 3 - 3
src/core/Vector3.js

@@ -290,14 +290,14 @@ THREE.Vector3.prototype = {
 
 	setRotationFromMatrix : function ( m ) {
 
-		this.y = Math.asin( m.n13 );
-
 		var cosY = Math.cos( this.y );
 
+		this.y = Math.asin( m.n13 );
+
 		if ( Math.abs( cosY ) > 0.00001 ) {
 
 			this.x = Math.atan2( - m.n23 / cosY, m.n33 / cosY );
-			this.z = Math.atan2( - m.n13 / cosY, m.n11 / cosY );
+			this.z = Math.atan2( - m.n12 / cosY, m.n11 / cosY );
 
 		} else {
 

+ 23 - 0
src/extras/io/SceneLoader.js

@@ -115,6 +115,15 @@ THREE.SceneLoader.prototype = {
 
 							}
 
+							// dirty hack to handle meshes with multiple materials
+							// just use face materials defined in model
+
+							if ( materials.length > 1 ) {
+
+								materials = [ new THREE.MeshFaceMaterial() ];
+
+							}
+
 							object = new THREE.Mesh( geometry, materials );
 							object.position.set( p[0], p[1], p[2] );
 
@@ -460,6 +469,20 @@ THREE.SceneLoader.prototype = {
 
 						m.parameters[ pp ] = ( m.parameters[ pp ] == "MixOperation" ) ? THREE.MixOperation : THREE.MultiplyOperation;
 
+					} else if ( pp == "vertexColors" ) {
+
+						if ( m.parameters[ pp ] == "face" ) {
+
+							m.parameters[ pp ] = THREE.FaceColors;
+
+						// default to vertex colors if "vertexColors" is anything else face colors or 0 / null / false
+
+						} else if ( m.parameters[ pp ] )   {
+
+							m.parameters[ pp ] = THREE.VertexColors;
+
+						}
+
 					}
 
 				}

+ 18 - 2
src/renderers/CanvasRenderer.js

@@ -4,7 +4,8 @@
 
 THREE.CanvasRenderer = function () {
 
-	var _renderList = null,
+	var _this = this,
+	_renderList = null,
 	_projector = new THREE.Projector(),
 
 	_canvas = document.createElement( 'canvas' ),
@@ -81,6 +82,13 @@ THREE.CanvasRenderer = function () {
 	this.sortObjects = true;
 	this.sortElements = true;
 
+	this.data = {
+
+		vertices: 0,
+		faces: 0
+
+	}
+
 	this.setSize = function ( width, height ) {
 
 		_canvasWidth = width;
@@ -152,6 +160,9 @@ THREE.CanvasRenderer = function () {
 
 		this.autoClear ? this.clear() : _context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
 
+		_this.data.vertices = 0;
+		_this.data.faces = 0;
+
 		_renderList = _projector.projectScene( scene, camera, this.sortElements );
 
 		/* DEBUG
@@ -538,6 +549,9 @@ THREE.CanvasRenderer = function () {
 
 		function renderFace3( v1, v2, v3, uv1, uv2, uv3, element, material, scene ) {
 
+			_this.data.vertices += 3;
+			_this.data.faces ++;
+
 			setOpacity( material.opacity );
 			setBlending( material.blending );
 
@@ -561,7 +575,6 @@ THREE.CanvasRenderer = function () {
 
 				} else if ( material.envMap ) {
 
-
 					if ( material.envMap.mapping instanceof THREE.SphericalReflectionMapping ) {
 
 						var cameraMatrix = camera.matrixWorldInverse;
@@ -684,6 +697,9 @@ THREE.CanvasRenderer = function () {
 
 		function renderFace4( v1, v2, v3, v4, v5, v6, element, material, scene ) {
 
+			_this.data.vertices += 4;
+			_this.data.faces ++;
+
 			setOpacity( material.opacity );
 			setBlending( material.blending );
 

+ 2 - 2
src/renderers/Projector.js

@@ -98,8 +98,8 @@ THREE.Projector = function() {
 		_face4Count = 0;
 		_lineCount = 0;
 		_particleCount = 0;
-
-		camera.matrixAutoUpdate && camera.updateMatrix();
+	
+		camera.matrixAutoUpdate && camera.update( undefined, true );
 
 		scene.update( undefined, false, camera );
 

+ 18 - 5
src/renderers/SVGRenderer.js

@@ -4,7 +4,8 @@
 
 THREE.SVGRenderer = function () {
 
-	var _renderList = null,
+	var _this = this,
+	_renderList = null,
 	_projector = new THREE.Projector(),
 	_svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
 	_svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf,
@@ -34,6 +35,13 @@ THREE.SVGRenderer = function () {
 	this.sortObjects = true;
 	this.sortElements = true;
 
+	this.data = {
+
+		vertices: 0,
+		faces: 0
+
+	}
+
 	this.setQuality = function( quality ) {
 
 		switch(quality) {
@@ -72,11 +80,10 @@ THREE.SVGRenderer = function () {
 
 		var e, el, m, ml, fm, fml, element, material;
 
-		if ( this.autoClear ) {
+		this.autoClear && this.clear();
 
-			this.clear();
-
-		}
+		_this.data.vertices = 0;
+		_this.data.faces = 0;
 
 		_renderList = _projector.projectScene( scene, camera, this.sortElements );
 
@@ -368,6 +375,9 @@ THREE.SVGRenderer = function () {
 
 	function renderFace3( v1, v2, v3, element, material, scene ) {
 
+		_this.data.vertices += 3;
+		_this.data.faces ++;
+
 		_svgNode = getPathNode( _pathCount ++ );
 		_svgNode.setAttribute( 'd', 'M ' + v1.positionScreen.x + ' ' + v1.positionScreen.y + ' L ' + v2.positionScreen.x + ' ' + v2.positionScreen.y + ' L ' + v3.positionScreen.x + ',' + v3.positionScreen.y + 'z' );
 
@@ -424,6 +434,9 @@ THREE.SVGRenderer = function () {
 
 	function renderFace4( v1, v2, v3, v4, element, material, scene ) {
 
+		_this.data.vertices += 4;
+		_this.data.faces ++;
+
 		_svgNode = getPathNode( _pathCount ++ );
 		_svgNode.setAttribute( 'd', 'M ' + v1.positionScreen.x + ' ' + v1.positionScreen.y + ' L ' + v2.positionScreen.x + ' ' + v2.positionScreen.y + ' L ' + v3.positionScreen.x + ',' + v3.positionScreen.y + ' L ' + v4.positionScreen.x + ',' + v4.positionScreen.y + 'z' );
 

+ 141 - 111
src/renderers/WebGLRenderer.js

@@ -20,15 +20,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	// See http://code.google.com/p/chromium/issues/detail?id=63491
 
-	var _gl,
-	_canvas = document.createElement( 'canvas' ),
+	var _this = this,
+	_gl, _canvas = document.createElement( 'canvas' ),
 	_programs = [],
 	_currentProgram = null,
 	_currentFramebuffer = null,
 	_currentDepthMask = true,
 
-	_this = this,
-
 	// gl state cache
 
 	_oldDoubleSided = null,
@@ -79,6 +77,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 	clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 );
 	clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
 
+	this.data = {
+
+		vertices: 0,
+		faces: 0
+
+	}
 
 	this.maxMorphTargets = 8;
 	this.domElement = _canvas;
@@ -2576,6 +2580,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			}
 
+			_this.data.vertices += geometryGroup.__webglFaceCount;
+			_this.data.faces += geometryGroup.__webglFaceCount / 3;
+
 		// render lines
 
 		} else if ( object instanceof THREE.Line ) {
@@ -2924,7 +2931,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 			lights = scene.lights,
 			fog = scene.fog;
 
-		camera.matrixAutoUpdate && camera.updateMatrix();
+		_this.data.vertices = 0;
+		_this.data.faces = 0;
+
+		camera.matrixAutoUpdate && camera.update( undefined, true );
 
 		scene.update( undefined, false, camera );
 
@@ -3133,11 +3143,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 
 		// render 2d
-		
+
 		if ( scene.__webglSprites.length ) {
-			
+
 			renderSprites( scene, camera );
-			
+
 		}
 
 		// render stencil shadows
@@ -3324,23 +3334,22 @@ THREE.WebGLRenderer = function ( parameters ) {
 		var halfViewportWidth = _viewportWidth * 0.5;
 		var halfViewportHeight = _viewportHeight * 0.5;
 		var mergeWith3D = true;
-		
 
 		// setup gl
-		
+
 		_gl.useProgram( _sprite.program );
 		_currentProgram = _sprite.program;
 		_oldBlending = "";
 
 		if ( !_spriteAttributesEnabled ) {
-	
+
 			_gl.enableVertexAttribArray( _sprite.attributes.position );
 			_gl.enableVertexAttribArray( _sprite.attributes.uv );
-			
+
 			_spriteAttributesEnabled = true;
 
 		}
-		
+
 		_gl.disable( _gl.CULL_FACE );
 		_gl.enable( _gl.BLEND );
 		_gl.depthMask( true );
@@ -3350,65 +3359,64 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 2 * 8, 8 );
 
 		_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _sprite.elementBuffer );
-		
+
 		_gl.uniformMatrix4fv( uniforms.projectionMatrix, false, _projectionMatrixArray );
 
 		_gl.activeTexture( _gl.TEXTURE0 );
 		_gl.uniform1i( uniforms.map, 0 );
-		
+
 		// update positions and sort
-		
+
 		for( o = 0, ol = scene.__webglSprites.length; o < ol; o++ ) {
-			
+
 			object = scene.__webglSprites[ o ];
-			
+
 			if( !object.useScreenCoordinates ) {
-			
+
 				object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
 				object.z = -object._modelViewMatrix.n34;
-			
+
 			} else {
-				
+
 				object.z = -object.position.z;
-				
+
 			}
-		
+
 		}
 
 		scene.__webglSprites.sort( painterSort );
-		
 
 		// render all non-custom shader sprites
-				
-		for( o = 0, ol = scene.__webglSprites.length; o < ol; o++ ) {
+
+		for ( o = 0, ol = scene.__webglSprites.length; o < ol; o++ ) {
 
 			object = scene.__webglSprites[ o ];
 
-			if( object.material === undefined ) {
+			if ( object.material === undefined ) {
+
+				if ( object.map && object.map.image && object.map.image.width ) {
+
+					if ( object.useScreenCoordinates ) {
 
-				if( object.map && object.map.image && object.map.image.width ) {
-	
-					if( object.useScreenCoordinates ) {
-						
 						_gl.uniform1i( uniforms.useScreenCoordinates, 1 );
 						_gl.uniform3f( uniforms.screenPosition, ( object.position.x - halfViewportWidth  ) / halfViewportWidth, 
 														        ( halfViewportHeight - object.position.y ) / halfViewportHeight,
 														          Math.max( 0, Math.min( 1, object.position.z )));
-						
+
 					} else {
 
-						
+
 
 						_gl.uniform1i( uniforms.useScreenCoordinates, 0 );
 						_gl.uniform1i( uniforms.affectedByDistance, object.affectedByDistance ? 1 : 0 );
 						_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
-						
+
 					}
-				
+
 					size = object.map.image.width / ( object.affectedByDistance ? 1 : _viewportHeight );
 					scale[ 0 ] = size * invAspect * object.scale.x;
 					scale[ 1 ] = size * object.scale.y;
-				
+
 					_gl.uniform2f( uniforms.uvScale, object.uvScale.x, object.uvScale.y );
 					_gl.uniform2f( uniforms.uvOffset, object.uvOffset.x, object.uvOffset.y );
 					_gl.uniform2f( uniforms.alignment, object.alignment.x, object.alignment.y );
@@ -3416,39 +3424,40 @@ THREE.WebGLRenderer = function ( parameters ) {
 					_gl.uniform1f( uniforms.rotation, object.rotation );
 					_gl.uniform2fv( uniforms.scale, scale );
 
-					if( object.mergeWith3D && !mergeWith3D ) {
-						
+					if ( object.mergeWith3D && !mergeWith3D ) {
+
 						_gl.enable( _gl.DEPTH_TEST );
 						mergeWith3D = true;
-						
-					} else if( !object.mergeWith3D && mergeWith3D ) {
-						
+
+					} else if ( !object.mergeWith3D && mergeWith3D ) {
+
 						_gl.disable( _gl.DEPTH_TEST );
 						mergeWith3D = false;
-						
+
 					}
-	
+
 					setBlending( object.blending );
 					setTexture( object.map, 0 );
-			
+
 					_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
 				}
-				
+
 			} else {
-				
+
 				anyCustom = true;
-				
+
 			}
-			
+
 		}
 
 
 		// loop through all custom
 
-/*		if( anyCustom ) {
-			
+		/*
+		if( anyCustom ) {
+
 		}
-*/
+		*/
 
 		// restore gl
 
@@ -3551,96 +3560,95 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			// screen cull 
-			
-			if(	_lensFlare.hasVertexTexture ||
-			  ( screenPositionPixels[ 0 ] > 0 &&
+
+			if ( _lensFlare.hasVertexTexture || ( screenPositionPixels[ 0 ] > 0 &&
 				screenPositionPixels[ 0 ] < _viewportWidth &&
 				screenPositionPixels[ 1 ] > 0 &&
 				screenPositionPixels[ 1 ] < _viewportHeight )) {
 
 
 				// save current RGB to temp texture
-	
+
 				_gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.tempTexture );
 				_gl.copyTexImage2D( _gl.TEXTURE_2D, 0, _gl.RGB, screenPositionPixels[ 0 ] - 8, screenPositionPixels[ 1 ] - 8, 16, 16, 0 );
 
-	
+
 				// render pink quad
-	
+
 				_gl.uniform1i( uniforms.renderType, 0 );
 				_gl.uniform2fv( uniforms.scale, scale );
 				_gl.uniform3fv( uniforms.screenPosition, screenPosition );
-	
+
 				_gl.disable( _gl.BLEND );
 				_gl.enable( _gl.DEPTH_TEST );
-	
+
 				_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
-	
-	
+
+
 				// copy result to occlusionMap
-	
+
 				_gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.occlusionTexture );
 				_gl.copyTexImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, screenPositionPixels[ 0 ] - 8, screenPositionPixels[ 1 ] - 8, 16, 16, 0 );
-	
-	
+
+
 				// restore graphics
-	
+
 				_gl.uniform1i( uniforms.renderType, 1 );
 				_gl.disable( _gl.DEPTH_TEST );
 				_gl.bindTexture( _gl.TEXTURE_2D, _lensFlare.tempTexture );
 				_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
-	
-	
+
+
 				// update object positions
-	
+
 				object.positionScreen.x = screenPosition[ 0 ];
 				object.positionScreen.y = screenPosition[ 1 ];
 				object.positionScreen.z = screenPosition[ 2 ];
-	
+
 				if ( object.customUpdateCallback ) {
-	
+
 					object.customUpdateCallback( object );
-	
+
 				} else {
-	
+
 					object.updateLensFlares();
-	
+
 				}
-	
-	
+
+
 				// render flares
-	
+
 				_gl.uniform1i( uniforms.renderType, 2 );
 				_gl.enable( _gl.BLEND );
-				
+
 				for ( f = 0, fl = object.lensFlares.length; f < fl; f ++ ) {
-	
+
 					flare = object.lensFlares[ f ];
-	
+
 					if ( flare.opacity > 0.001 && flare.scale > 0.001 ) {
-	
+
 						screenPosition[ 0 ] = flare.x;
 						screenPosition[ 1 ] = flare.y;
 						screenPosition[ 2 ] = flare.z;
-	
+
 						size = flare.size * flare.scale / _viewportHeight;
 						scale[ 0 ] = size * invAspect;
 						scale[ 1 ] = size;
-	
+
 						_gl.uniform3fv( uniforms.screenPosition, screenPosition );
 						_gl.uniform2fv( uniforms.scale, scale );
 						_gl.uniform1f( uniforms.rotation, flare.rotation );
 						_gl.uniform1f( uniforms.opacity, flare.opacity );
-	
+
 						setBlending( flare.blending );
 						setTexture( flare.texture, 1 );
-	
+
 						_gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 );
-	
+
 					}
-	
+
 				}
-			
+
 			}
 
 		}
@@ -3706,11 +3714,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-/*		for ( var o = 0, ol = scene.__webglSprites.length; o < ol; o ++ ) {
+		/*
+		for ( var o = 0, ol = scene.__webglSprites.length; o < ol; o ++ ) {
 
 			updateObject( scene.__webglSprites[ o ].object, scene );
 
-		}*/
+		}
+		*/
 
 	};
 
@@ -3834,11 +3844,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 			addBufferImmediate( scene.__webglObjectsImmediate, object );
 
 		} else if ( object instanceof THREE.Sprite ) {
-			
+
 			scene.__webglSprites.push( object );
 		}
-		
-		
+
 		/*else if ( object instanceof THREE.Particle ) {
 
 		}*/
@@ -3942,20 +3951,39 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		var o, ol, zobject;
 
-		for ( o = scene.__webglObjects.length - 1; o >= 0; o-- ) {
+		if ( object instanceof THREE.Mesh ) {
+
+			for ( o = scene.__webglObjects.length - 1; o >= 0; o -- ) {
+
+				zobject = scene.__webglObjects[ o ].object;
+
+				if ( object == zobject ) {
+
+					scene.__webglObjects.splice( o, 1 );
+					return;
+
+				}
+
+			}
+
+		} else if ( object instanceof THREE.Sprite ) {
+
+			for ( o = scene.__webglSprites.length - 1; o >= 0; o -- ) {
+
+				zobject = scene.__webglSprites[ o ];
 
-			zobject = scene.__webglObjects[ o ].object;
+				if ( object == zobject ) {
 
-			if ( object == zobject ) {
+					scene.__webglSprites.splice( o, 1 );
+					return;
 
-				scene.__webglObjects.splice( o, 1 );
-				return;
+				}
 
 			}
 
 		}
-		
-		// add shadwos/sprites etc.
+
+		// add shadows, etc
 
 	};
 
@@ -4192,7 +4220,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			}
 
 		}
-		
+
 		//console.log( "building new program " );
 
 		//
@@ -4519,6 +4547,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			} else {
 
 				_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
+				// _gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
 				_gl.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
 
 			}
@@ -4561,6 +4590,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 					for ( var i = 0; i < 6; ++i ) {
 
+						// _gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] );
 						_gl.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] );
 
 					}
@@ -4608,29 +4638,29 @@ THREE.WebGLRenderer = function ( parameters ) {
 			_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTexture.__webglFramebuffer );
 
 			_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, renderTexture.__webglTexture, 0 );
-			
-			if( renderTexture.depthBuffer && !renderTexture.stencilBuffer ) {
-				
+
+			if ( renderTexture.depthBuffer && !renderTexture.stencilBuffer ) {
+
 				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height );
 				_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
-		
-		/* For some reason this is not working. Defaulting to RGBA4.	
+
+			/* For some reason this is not working. Defaulting to RGBA4.	
 			} else if( !renderTexture.depthBuffer && renderTexture.stencilBuffer ) {
-			
+
 				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.STENCIL_INDEX8, renderTexture.width, renderTexture.height );
 				_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
 			*/
 			} else if( renderTexture.depthBuffer && renderTexture.stencilBuffer ) {
-				
+
 				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTexture.width, renderTexture.height );
 				_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
-				
+
 			} else {
-				
+
 				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.RGBA4, renderTexture.width, renderTexture.height );
-				
+
 			}
-			
+
 
 			// Release everything
 

+ 9 - 9
utils/build.py

@@ -315,12 +315,6 @@ def compress(text):
 	with os.fdopen(in_tuple[0], 'w') as handle:
 		handle.write(text)
 
-	# uncomment to get concatenated JS if you can't figure out Closure compiler errors :|
-
-	#f = open( "debug.js" , "w" )
-	#f.write(text)
-	#f.close()
-
 	out_tuple = tempfile.mkstemp()
 	# os.system("java -jar yuicompressor-2.4.2.jar %s --type js -o %s --charset utf-8 -v" % (in_tuple[1], out_tuple[1]))
 	os.system("java -jar compiler.jar --language_in=ECMASCRIPT5 --js %s --js_output_file %s" % (in_tuple[1], out_tuple[1]))
@@ -353,7 +347,7 @@ def makeDebug(text):
 	return text
 
 
-def buildLib(files, debug, filename):
+def buildLib(files, debug, unminified, filename):
 
 	text = merge(files)
 
@@ -372,7 +366,10 @@ def buildLib(files, debug, filename):
 	print "Compiling", filename
 	print "=" * 40
 
-	output(addHeader(compress(text), filename), folder + filename)
+	if not unminified:
+		text = compress(text)
+	
+	output(addHeader(text, filename), folder + filename)
 
 
 def buildIncludes(files, filename):
@@ -395,6 +392,7 @@ def parse_args():
 		parser.add_argument('--svg', help='Build ThreeSVG.js', action='store_true')
 		parser.add_argument('--dom', help='Build ThreeDOM.js', action='store_true')
 		parser.add_argument('--debug', help='Generate debug versions', action='store_const', const=True, default=False)
+		parser.add_argument('--unminified', help='Generate unminified versions', action='store_const', const=True, default=False)
 		parser.add_argument('--all', help='Build all Three.js versions', action='store_true')
 
 		args = parser.parse_args()
@@ -409,6 +407,7 @@ def parse_args():
 		parser.add_option('--svg', dest='svg', help='Build ThreeSVG.js', action='store_true')
 		parser.add_option('--dom', dest='dom', help='Build ThreeDOM.js', action='store_true')
 		parser.add_option('--debug', dest='debug', help='Generate debug versions', action='store_const', const=True, default=False)
+		parser.add_option('--unminified', help='Generate unminified versions', action='store_const', const=True, default=False)
 		parser.add_option('--all', dest='all', help='Build all Three.js versions', action='store_true')
 
 		args, remainder = parser.parse_args()
@@ -425,6 +424,7 @@ def main(argv=None):
 
 	args = parse_args()
 	debug = args.debug
+	unminified = args.unminified
 
 	config = [
 	['Three', 'includes', COMMON_FILES + EXTRAS_FILES, args.common],
@@ -437,7 +437,7 @@ def main(argv=None):
 
 	for fname_lib, fname_inc, files, enabled in config:
 		if enabled or args.all:
-			buildLib(files, debug, fname_lib)
+			buildLib(files, debug, unminified, fname_lib)
 			if args.includes:
 				buildIncludes(files, fname_inc)
 

+ 37 - 0
utils/build.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="THREE.JS" basedir="." default="build">
+	<property name="build_dir" value="./" description="THREE.js build directory" />
+	<property name="build_py" value="${build_dir}/build.py" description="THREE.js 'build.py' file" />
+	<property name="python_dir" value="" description="Python directory, leave empty if in classpath or don't forget ending slash" />
+
+    <target name="build" description="Build all THREE.js">
+    	<exec executable="${python_dir}python">
+    	    <arg value="${build_py}"/>
+    	    <arg value="--all"/>
+    	  </exec>
+    </target>
+	
+    <target name="common" description="Build THREE.js commons">
+    	<exec executable="${python_dir}python">
+    	    <arg value="${build_py}"/>
+    	    <arg value="--common"/>
+    	    <arg value="--includes"/>
+    	  </exec>
+    </target>
+
+	<target name="debug" description="Build debug THREE.js">
+    	<exec executable="${python_dir}python">
+    	    <arg value="${build_py}"/>
+    	    <arg value="--all"/>
+    	    <arg value="--debug"/>
+    	  </exec>
+    </target>
+	
+    <target name="unminified" description="Build debug THREE.js">
+    	<exec executable="${python_dir}python">
+    	    <arg value="${build_py}"/>
+    	    <arg value="--all"/>
+    	    <arg value="--unminified"/>
+    	  </exec>
+    </target>
+</project>

+ 76 - 40
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py

@@ -20,7 +20,7 @@
 # Init
 # ################################################################
 
-# To support reload properly, try to access a package var, 
+# To support reload properly, try to access a package var,
 # if it's there, reload everything
 
 if "bpy" in locals():
@@ -43,17 +43,20 @@ bpy.types.Object.THREE_meshCollider = bpy.props.BoolProperty()
 
 bpy.types.Material.THREE_useVertexColors = bpy.props.BoolProperty()
 
+THREE_material_types = [("Basic", "Basic", "Basic"), ("Phong", "Phong", "Phong"), ("Lambert", "Lambert", "Lambert")]
+bpy.types.Material.THREE_materialType = EnumProperty(name = "Material type", description = "Material type", items = THREE_material_types, default = "Lambert")
+
 class OBJECT_PT_hello( bpy.types.Panel ):
-    
+
     bl_label = "THREE"
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
     bl_context = "object"
- 
+
     def draw(self, context):
         layout = self.layout
         obj = context.object
-        
+
         row = layout.row()
         row.label(text="Selected object: " + obj.name )
 
@@ -65,22 +68,26 @@ class OBJECT_PT_hello( bpy.types.Panel ):
 
 
 class MATERIAL_PT_hello( bpy.types.Panel ):
-    
+
     bl_label = "THREE"
     bl_space_type = "PROPERTIES"
     bl_region_type = "WINDOW"
     bl_context = "material"
- 
+
     def draw(self, context):
         layout = self.layout
         mat = context.material
-        
+
         row = layout.row()
         row.label(text="Selected material: " + mat.name )
 
+        row = layout.row()
+        row.prop( mat, "THREE_materialType", text="Material type" )
+
         row = layout.row()
         row.prop( mat, "THREE_useVertexColors", text="Use vertex colors" )
 
+
 # ################################################################
 # Importer
 # ################################################################
@@ -123,20 +130,20 @@ import json
 
 def file_exists(filename):
     """Return true if file exists and accessible for reading.
-    
-    Should be safer than just testing for existence due to links and 
+
+    Should be safer than just testing for existence due to links and
     permissions magic on Unix filesystems.
-    
+
     @rtype: boolean
     """
-    
+
     try:
         f = open(filename, 'r')
         f.close()
         return True
     except IOError:
         return False
-    
+
 def get_settings_fullpath():
     return os.path.join(bpy.app.tempdir, SETTINGS_FILE_EXPORT)
 
@@ -152,41 +159,45 @@ def save_settings_export(properties):
     "option_colors"          : properties.option_colors,
     "option_uv_coords"       : properties.option_uv_coords,
     "option_edges"           : properties.option_edges,
+    "option_faces"           : properties.option_faces,
+    "option_vertices"        : properties.option_vertices,
 
-    "option_truncate"     : properties.option_truncate,
+    "option_vertices_truncate" : properties.option_vertices_truncate,
     "option_scale"        : properties.option_scale,
 
     "align_model"         : properties.align_model
     }
-    
+
     fname = get_settings_fullpath()
     f = open(fname, "w")
     json.dump(settings, f)
-    
+
 def restore_settings_export(properties):
-    
+
     settings = {}
 
     fname = get_settings_fullpath()
     if file_exists(fname):
         f = open(fname, "r")
         settings = json.load(f)
-    
-    properties.option_export_scene = settings.get("option_export_scene", False)
 
-    properties.option_flip_yz = settings.get("option_flip_yz", True)
-
-    properties.option_materials = settings.get("option_materials", True)
+    properties.option_vertices = settings.get("option_vertices", True)
+    properties.option_vertices_truncate = settings.get("option_vertices_truncate", False)
+    properties.option_faces = settings.get("option_faces", True)
     properties.option_normals = settings.get("option_normals", True)
+    properties.option_edges = settings.get("option_edges", False)
+
     properties.option_colors = settings.get("option_colors", True)
     properties.option_uv_coords = settings.get("option_uv_coords", True)
-    properties.option_edges = settings.get("option_edges", False)
-    
-    properties.option_truncate = settings.get("option_truncate", False)
-    properties.option_scale = settings.get("option_scale", 1.0)
-    
+    properties.option_materials = settings.get("option_materials", True)
+
     properties.align_model = settings.get("align_model", "None")
 
+    properties.option_scale = settings.get("option_scale", 1.0)
+    properties.option_flip_yz = settings.get("option_flip_yz", True)
+
+    properties.option_export_scene = settings.get("option_export_scene", False)
+
 # ################################################################
 # Exporter
 # ################################################################
@@ -199,10 +210,13 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
     filename_ext = ".js"
 
-    option_flip_yz = BoolProperty(name = "Flip YZ", description = "Flip YZ", default = True)
-
     option_vertices = BoolProperty(name = "Vertices", description = "Export vertices", default = True)
+    option_vertices_deltas = BoolProperty(name = "Deltas", description = "Delta vertices", default = False)
+    option_vertices_truncate = BoolProperty(name = "Truncate", description = "Truncate vertices", default = False)
+
     option_faces = BoolProperty(name = "Faces", description = "Export faces", default = True)
+    option_faces_deltas = BoolProperty(name = "Deltas", description = "Delta faces", default = False)
+
     option_normals = BoolProperty(name = "Normals", description = "Export normals", default = True)
     option_edges = BoolProperty(name = "Edges", description = "Export edges", default = False)
 
@@ -210,14 +224,14 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
     option_uv_coords = BoolProperty(name = "UVs", description = "Export texture coordinates", default = True)
     option_materials = BoolProperty(name = "Materials", description = "Export materials", default = True)
 
-    option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False)
-
-    option_truncate = BoolProperty(name = "Truncate", description = "Truncate decimals", default = False)
-    option_scale = FloatProperty(name = "Scale", description = "Scale data", min = 0.01, max = 1000.0, soft_min = 0.01, soft_max = 1000.0, default = 1.0)
-
     align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")]
     align_model = EnumProperty(name = "Align model", description = "Align model", items = align_types, default = "None")
 
+    option_scale = FloatProperty(name = "Scale", description = "Scale vertices", min = 0.01, max = 1000.0, soft_min = 0.01, soft_max = 1000.0, default = 1.0)
+    option_flip_yz = BoolProperty(name = "Flip YZ", description = "Flip YZ", default = True)
+
+    option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False)
+
     def invoke(self, context, event):
         restore_settings_export(self.properties)
         return ExportHelper.invoke(self, context, event)
@@ -242,25 +256,34 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
         layout = self.layout
 
         row = layout.row()
-        row.prop(self.properties, "option_export_scene")
-        layout.separator()
+        row.label(text="Geometry:")
 
         row = layout.row()
-        row.prop(self.properties, "option_flip_yz")
+        row.prop(self.properties, "option_vertices")
+        row = layout.row()
+        row.enabled = self.properties.option_vertices
+        # row.prop(self.properties, "option_vertices_deltas")
+        row.prop(self.properties, "option_vertices_truncate")
         layout.separator()
 
         row = layout.row()
-        row.prop(self.properties, "align_model")
+        row.prop(self.properties, "option_faces")
+        row = layout.row()
+        row.enabled = self.properties.option_faces
+        # row.prop(self.properties, "option_faces_deltas")
         layout.separator()
 
         row = layout.row()
-        row.prop(self.properties, "option_vertices")
         row.prop(self.properties, "option_normals")
+        layout.separator()
+
         row = layout.row()
-        row.prop(self.properties, "option_faces")
         row.prop(self.properties, "option_edges")
         layout.separator()
 
+        row = layout.row()
+        row.label(text="Materials:")
+
         row = layout.row()
         row.prop(self.properties, "option_uv_coords")
         row.prop(self.properties, "option_colors")
@@ -269,8 +292,21 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
         layout.separator()
 
         row = layout.row()
-        row.prop(self.properties, "option_truncate")
+        row.label(text="Settings:")
+
+        row = layout.row()
+        row.prop(self.properties, "align_model")
+        row = layout.row()
+        row.prop(self.properties, "option_flip_yz")
         row.prop(self.properties, "option_scale")
+        layout.separator()
+
+        row = layout.row()
+        row.label(text="Beta:")
+
+        row = layout.row()
+        row.prop(self.properties, "option_export_scene")
+        layout.separator()
 
 
 # ################################################################

+ 212 - 201
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py

@@ -49,7 +49,7 @@ DEFAULTS = {
 "rotation" : [-math.pi/2, 0, 0],
 "scale"    : [1, 1, 1],
 
-"camera"  : 
+"camera"  :
     {
         "name" : "default_camera",
         "type" : "perspective",
@@ -71,7 +71,7 @@ DEFAULTS = {
  }
 }
 
-# default colors for debugging (each material gets one distinct color): 
+# default colors for debugging (each material gets one distinct color):
 # white, red, green, blue, yellow, cyan, magenta
 COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
 
@@ -90,7 +90,7 @@ TEMPLATE_SCENE_ASCII = """\
  * geometries: %(ngeometries)s
  * materials:  %(nmaterials)s
  * textures:   %(ntextures)s
- */  
+ */
 
 var scene = {
 
@@ -99,14 +99,14 @@ var scene = {
 
 %(sections)s
 
-"transform" : 
+"transform" :
 {
     "position"  : %(position)s,
     "rotation"  : %(rotation)s,
     "scale"     : %(scale)s,
 },
 
-"defaults" : 
+"defaults" :
 {
     "bgcolor" : %(bgcolor)s,
     "bgalpha" : %(bgalpha)f,
@@ -120,7 +120,7 @@ close();
 """
 
 TEMPLATE_SECTION = """
-"%s" : 
+"%s" :
 {
 %s
 },
@@ -154,7 +154,7 @@ TEMPLATE_TEXTURE = """\
 TEMPLATE_MATERIAL_SCENE = """\
     %(material_id)s : {
         "type": %(type)s,
-        "parameters": { %(parameters)s } 
+        "parameters": { %(parameters)s }
     }"""
 
 TEMPLATE_CAMERA_PERSPECTIVE = """\
@@ -225,9 +225,9 @@ TEMPLATE_FILE_ASCII = """\
 var model = {
 
     "version" : 2,
-    
+
     "scale" : %(scale)f,
-    
+
     "materials": [%(materials)s],
 
     "vertices": [%(vertices)s],
@@ -271,15 +271,15 @@ def veckey3d(v):
 
 def veckey2d(v):
     return round(v[0], 6), round(v[1], 6)
-    
+
 def get_normal_indices(v, normals, mesh):
     n = []
     mv = mesh.vertices
 
     for i in v:
-        normal = mv[i].normal        
+        normal = mv[i].normal
         key = veckey3d(normal)
-        
+
         n.append( normals[key] )
 
     return n
@@ -315,7 +315,7 @@ def write_file(fname, content):
 
 def ensure_folder_exist(foldername):
     """Create folder (with whole path) if it doesn't exist yet."""
-    
+
     if not os.access(foldername, os.R_OK|os.W_OK|os.X_OK):
         os.makedirs(foldername)
 
@@ -323,13 +323,13 @@ def ensure_extension(filepath, extension):
     if not filepath.lower().endswith(extension):
         filepath += extension
     return filepath
-    
+
 def generate_mesh_filename(meshname, filepath):
     normpath = os.path.normpath(filepath)
     path, ext = os.path.splitext(normpath)
     return "%s.%s%s" % (path, meshname, ext)
-    
-    
+
+
 # #####################################################
 # Utils - alignment
 # #####################################################
@@ -410,36 +410,36 @@ def bottom(vertices):
     translate(vertices, [-cx,-cy,-cz])
 
 # #####################################################
-# Elements rendering 
+# Elements rendering
 # #####################################################
 
 def hexcolor(c):
     return ( int(c[0] * 255) << 16  ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255)
 
-def generate_vertices(vertices, option_truncate, option_vertices):
+def generate_vertices(vertices, option_vertices_truncate, option_vertices):
     if not option_vertices:
         return ""
 
-    return ",".join(generate_vertex(v, option_truncate) for v in vertices)
+    return ",".join(generate_vertex(v, option_vertices_truncate) for v in vertices)
 
-def generate_vertex(v, option_truncate):
-    if not option_truncate:
+def generate_vertex(v, option_vertices_truncate):
+    if not option_vertices_truncate:
         return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z)
     else:
         return TEMPLATE_VERTEX_TRUNCATE % (v.co.x, v.co.y, v.co.z)
 
 def generate_normal(n):
     return TEMPLATE_N % (n[0], n[1], n[2])
-    
+
 def generate_vertex_color(c):
     return TEMPLATE_C % c
-    
+
 def generate_uv(uv):
     return TEMPLATE_UV % (uv[0], 1.0 - uv[1])
 
 def generate_edge(e):
     return TEMPLATE_EDGE % (e.vertices[0], e.vertices[1])
-    
+
 # #####################################################
 # Model exporter - faces
 # #####################################################
@@ -460,20 +460,20 @@ def generate_faces(normals, uvs, colors, mesh, option_normals, option_colors, op
 
 def generate_face(f, faceIndex, normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz):
     isTriangle = ( len(f.vertices) == 3 )
-    
+
     if isTriangle:
         nVertices = 3
     else:
         nVertices = 4
-        
+
     hasMaterial = option_materials
-    
+
     hasFaceUvs = False # not supported in Blender
     hasFaceVertexUvs = option_uv_coords
 
     hasFaceNormals = False # don't export any face normals (as they are computed in engine)
     hasFaceVertexNormals = option_normals
-    
+
     hasFaceColors = False       # not supported in Blender
     hasFaceVertexColors = option_colors
 
@@ -485,12 +485,12 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, option_normals, opti
     faceType = setBit(faceType, 4, hasFaceNormals)
     faceType = setBit(faceType, 5, hasFaceVertexNormals)
     faceType = setBit(faceType, 6, hasFaceColors)
-    faceType = setBit(faceType, 7, hasFaceVertexColors)    
-    
+    faceType = setBit(faceType, 7, hasFaceVertexColors)
+
     faceData = []
-    
+
     # order is important, must match order in JSONLoader
-    
+
     # face type
     # vertex indices
     # material index
@@ -498,15 +498,15 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, option_normals, opti
     # face vertex uvs indices
     # face color index
     # face vertex colors indices
-    
-    faceData.append(faceType)    
-    
+
+    faceData.append(faceType)
+
     # must clamp in case on polygons bigger than quads
 
     for i in range(nVertices):
         index = f.vertices[i]
         faceData.append(index)
-    
+
     if hasMaterial:
         faceData.append( f.material_index )
 
@@ -521,7 +521,7 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, option_normals, opti
         for i in range(nVertices):
             index = n[i]
             faceData.append(index)
-            
+
     if hasFaceVertexColors:
         c = get_color_indices(faceIndex, colors, mesh)
         for i in range(nVertices):
@@ -544,10 +544,10 @@ def extract_vertex_normals(mesh, option_normals):
 
     for f in mesh.faces:
         for v in f.vertices:
-            
-            normal = mesh.vertices[v].normal            
+
+            normal = mesh.vertices[v].normal
             key = veckey3d(normal)
-                
+
             if key not in normals:
                 normals[key] = count
                 count += 1
@@ -569,7 +569,7 @@ def generate_normals(normals, option_normals):
 # #####################################################
 
 def extract_vertex_colors(mesh, option_colors):
-    
+
     if not option_colors:
         return {}, 0
 
@@ -579,10 +579,10 @@ def extract_vertex_colors(mesh, option_colors):
     color_layer = mesh.vertex_colors.active.data
 
     for face_index, face in enumerate(mesh.faces):
-        
+
         face_colors = color_layer[face_index]
         face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
-    
+
         for c in face_colors:
             key = hexcolor(c)
             if key not in colors:
@@ -697,7 +697,7 @@ def generate_materials(mtl, materials, draw_type):
         if draw_type in [ "BOUNDS", "WIRE" ]:
             mtl[m]['wireframe'] = True
             mtl[m]['DbgColor'] = 0xff0000
-            
+
         mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
         mtl_string = "\t{\n%s\n\t}" % mtl_raw
         mtl_array.append([index, mtl_string])
@@ -712,7 +712,7 @@ def extract_materials(mesh, scene, option_colors):
         if m:
             materials[m.name] = {}
             material = materials[m.name]
-            
+
             material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0],
                                         m.diffuse_intensity * m.diffuse_color[1],
                                         m.diffuse_intensity * m.diffuse_color[2]]
@@ -724,7 +724,7 @@ def extract_materials(mesh, scene, option_colors):
             world_ambient_color = [0, 0, 0]
             if world:
                 world_ambient_color = world.ambient_color
-                
+
             material['colorAmbient'] = [m.ambient * world_ambient_color[0],
                                         m.ambient * world_ambient_color[1],
                                         m.ambient * world_ambient_color[2]]
@@ -744,13 +744,15 @@ def extract_materials(mesh, scene, option_colors):
                 material['mapDiffuse'] = fn_strip
 
             material["vertexColors"] = m.THREE_useVertexColors and option_colors
-            
+
             # can't really use this reliably to tell apart Phong from Lambert
             # as Blender defaults to non-zero specular color
             #if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0):
             #    material['shading'] = "Phong"
             #else:
             #    material['shading'] = "Lambert"
+            
+            material['shading'] = m.THREE_materialType
 
     return materials
 
@@ -771,11 +773,11 @@ def generate_materials_string(mesh, scene, option_colors, draw_type):
         materials = { 'default':0 }
 
     # default dummy materials
-    
+
     mtl = generate_mtl(materials)
 
     # extract real materials from the mesh
-    
+
     mtl.update(extract_materials(mesh, scene, option_colors))
 
     return generate_materials(mtl, materials, draw_type)
@@ -784,18 +786,18 @@ def generate_materials_string(mesh, scene, option_colors, draw_type):
 # ASCII model generator
 # #####################################################
 
-def generate_ascii_model(mesh, scene, 
-                         option_vertices, 
-                         option_faces, 
-                         option_normals, 
-                         option_edges, 
-                         option_uv_coords, 
-                         option_materials, 
-                         option_colors, 
-                         align_model, 
-                         flipyz, 
-                         option_truncate, 
-                         option_scale, 
+def generate_ascii_model(mesh, scene,
+                         option_vertices,
+                         option_vertices_truncate,
+                         option_faces,
+                         option_normals,
+                         option_edges,
+                         option_uv_coords,
+                         option_materials,
+                         option_colors,
+                         align_model,
+                         flipyz,
+                         option_scale,
                          draw_type):
 
     vertices = mesh.vertices[:]
@@ -813,15 +815,15 @@ def generate_ascii_model(mesh, scene,
 
     materials_string = ""
     nmaterial = 0
-    
+
     edges_string = ""
     nedges = 0
-    
+
     if option_materials:
         materials_string, nmaterial = generate_materials_string(mesh, scene, option_colors, draw_type)
 
     if option_edges:
-        nedges = len(mesh.edges) 
+        nedges = len(mesh.edges)
         edges_string  = ",".join(generate_edge(e) for e in mesh.edges)
 
     text = TEMPLATE_FILE_ASCII % {
@@ -841,7 +843,7 @@ def generate_ascii_model(mesh, scene,
 
     "materials" : materials_string,
 
-    "vertices" : generate_vertices(vertices, option_truncate, option_vertices),
+    "vertices" : generate_vertices(vertices, option_vertices_truncate, option_vertices),
 
     "faces"    : generate_faces(normals, uvs, colors, mesh, option_normals, option_colors, option_uv_coords, option_materials, flipyz, option_faces),
 
@@ -851,29 +853,29 @@ def generate_ascii_model(mesh, scene,
 
     return text
 
-    
+
 # #####################################################
 # Model exporter - export single mesh
 # #####################################################
 
-def export_mesh(obj, scene, filepath, 
-                option_vertices, 
-                option_faces, 
-                option_normals, 
-                option_edges, 
-                option_uv_coords, 
-                option_materials, 
-                option_colors, 
-                align_model, 
-                flipyz, 
-                option_truncate, 
-                option_scale, 
+def export_mesh(obj, scene, filepath,
+                option_vertices,
+                option_vertices_truncate,
+                option_faces,
+                option_normals,
+                option_edges,
+                option_uv_coords,
+                option_materials,
+                option_colors,
+                align_model,
+                flipyz,
+                option_scale,
                 export_single_model):
 
     """Export single mesh"""
 
     # collapse modifiers into mesh
-    
+
     mesh = obj.create_mesh(scene, True, 'RENDER')
 
     if not mesh:
@@ -910,18 +912,18 @@ def export_mesh(obj, scene, filepath,
         if not active_col_layer:
             option_colors = False
 
-    text = generate_ascii_model(mesh, scene, 
-                                option_vertices, 
-                                option_faces, 
-                                option_normals, 
-                                option_edges, 
-                                option_uv_coords, 
-                                option_materials, 
-                                option_colors, 
-                                align_model, 
-                                flipyz, 
-                                option_truncate, 
-                                option_scale, 
+    text = generate_ascii_model(mesh, scene,
+                                option_vertices,
+                                option_vertices_truncate,
+                                option_faces,
+                                option_normals,
+                                option_edges,
+                                option_uv_coords,
+                                option_materials,
+                                option_colors,
+                                align_model,
+                                flipyz,
+                                option_scale,
                                 obj.draw_type)
 
     write_file(filepath, text)
@@ -931,8 +933,8 @@ def export_mesh(obj, scene, filepath,
     bpy.data.meshes.remove(mesh)
 
     print("writing", filepath, "done")
-    
-    
+
+
 # #####################################################
 # Scene exporter - render elements
 # #####################################################
@@ -948,49 +950,49 @@ def generate_vec2(vec):
 
 def generate_hex(number):
     return TEMPLATE_HEX % number
-    
+
 def generate_string(s):
     return TEMPLATE_STRING % s
-    
+
 def generate_string_list(src_list):
     return ", ".join(generate_string(item) for item in src_list)
-    
+
 def generate_section(label, content):
     return TEMPLATE_SECTION % (label, content)
-    
+
 def get_mesh_filename(mesh):
     object_id = mesh["data"]["name"]
     filename = "%s.js" % sanitize(object_id)
     return filename
-    
+
 def generate_material_id_list(materials):
     chunks = []
     for material in materials:
         chunks.append(material.name)
-    
+
     return chunks
-    
+
 def generate_group_id_list(obj):
     chunks = []
-    
+
     for group in bpy.data.groups:
         if obj.name in group.objects:
             chunks.append(group.name)
-        
+
     return chunks
-    
+
 def generate_bool_property(property):
     if property:
         return "true"
     return "false"
-    
+
 # #####################################################
 # Scene exporter - objects
 # #####################################################
 
 def generate_objects(data):
     chunks = []
-    
+
     for obj in data["objects"]:
         if obj.type == "MESH":
             object_id = obj.name
@@ -1018,11 +1020,12 @@ def generate_objects(data):
 
             castsShadow = obj.THREE_castsShadow
             meshCollider = obj.THREE_meshCollider
-                
+
             visible = True
-            if obj.draw_type in ["BOUNDS", "WIRE"] and meshCollider:
+            #if obj.draw_type in ["BOUNDS", "WIRE"] and meshCollider:
+            if meshCollider:
                 visible = False
-            
+
             object_string = TEMPLATE_OBJECT % {
             "object_id"   : generate_string(object_id),
             "geometry_id" : generate_string(geometry_id),
@@ -1039,55 +1042,55 @@ def generate_objects(data):
             "visible"      : generate_bool_property(visible)
             }
             chunks.append(object_string)
-        
+
     return ",\n\n".join(chunks), len(chunks)
-    
+
 # #####################################################
 # Scene exporter - geometries
 # #####################################################
 
 def generate_geometries(data):
     chunks = []
-    
+
     geo_set = set()
-    
+
     for obj in data["objects"]:
         if obj.type == "MESH":
-            
+
             if len(obj.modifiers) > 0:
                 name = obj.name
             else:
                 name = obj.data.name
-            
+
             if name not in geo_set:
 
                 geometry_id = "geo_%s" % name
                 model_filename = os.path.basename(generate_mesh_filename(name, data["filepath"]))
-                
+
                 geometry_string = TEMPLATE_GEOMETRY % {
                 "geometry_id" : generate_string(geometry_id),
                 "model_file"  : generate_string(model_filename)
                 }
                 chunks.append(geometry_string)
-                
+
                 geo_set.add(name)
-        
+
     return ",\n\n".join(chunks), len(chunks)
-    
+
 # #####################################################
 # Scene exporter - textures
 # #####################################################
 
 def generate_textures_scene(data):
     chunks = []
-    
+
     # TODO: extract just textures actually used by some objects in the scene
-    
+
     for img in bpy.data.images:
-        
+
         texture_id = img.name
         texture_file = extract_texture_filename(img)
-    
+
         texture_string = TEMPLATE_TEXTURE % {
         "texture_id"   : generate_string(texture_id),
         "texture_file" : generate_string(texture_file)
@@ -1101,16 +1104,16 @@ def extract_texture_filename(image):
     fn = os.path.normpath(fn)
     fn_strip = os.path.basename(fn)
     return fn_strip
-    
+
 # #####################################################
 # Scene exporter - materials
 # #####################################################
 
-def extract_material_data(m):
+def extract_material_data(m, option_colors):
     world = bpy.context.scene.world
-    
+
     material = { 'name': m.name }
-    
+
     material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0],
                                 m.diffuse_intensity * m.diffuse_color[1],
                                 m.diffuse_intensity * m.diffuse_color[2]]
@@ -1122,7 +1125,7 @@ def extract_material_data(m):
     world_ambient_color = [0, 0, 0]
     if world:
         world_ambient_color = world.ambient_color
-        
+
     material['colorAmbient'] = [m.ambient * world_ambient_color[0],
                                 m.ambient * world_ambient_color[1],
                                 m.ambient * world_ambient_color[2]]
@@ -1137,8 +1140,10 @@ def extract_material_data(m):
 
     material['mapDiffuse'] = ""
     material['mapLight'] = ""
-    material['mapNormal'] = ""    
-        
+    material['mapNormal'] = ""
+
+    material["vertexColors"] = m.THREE_useVertexColors and option_colors
+    
     # just take first textures of each, for the moment three.js materials can't handle more
 
     for i in range(len(m.texture_slots)):
@@ -1155,25 +1160,27 @@ def extract_material_data(m):
                         material['mapDiffuse'] = name
                     else:
                         material['mapLight'] = name
-                
+
                 if material['mapDiffuse'] and material['mapNormal'] and material['mapLight']:
                     break
-        
-    if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0):
-        material['shading'] = "Phong"
-    else:
-        material['shading'] = "Lambert"
-        
+
+    #if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0):
+    #    material['shading'] = "Phong"
+    #else:
+    #    material['shading'] = "Lambert"
+
+    material['shading'] = m.THREE_materialType
+
     return material
-    
+
 def generate_material_string(material):
     type_map = {
     "Lambert"   : "MeshLambertMaterial",
     "Phong"     : "MeshPhongMaterial"
     }
-    
+
     material_id = material["name"]
-    shading = material["shading"]
+    shading = material.get("shading", "Lambert")
     material_type = type_map.get(shading, "MeshBasicMaterial")
 
     #parameters = "color: %s" % generate_hex(rgb2int(material["colorDiffuse"]))
@@ -1198,21 +1205,24 @@ def generate_material_string(material):
     if normalMap:
         parameters += ", normalMap: %s" % generate_string(normalMap)
 
+    if material['vertexColors']:
+        parameters += ', vertexColors: "vertex"'
+        
     material_string = TEMPLATE_MATERIAL_SCENE % {
     "material_id" : generate_string(material_id),
     "type"        : generate_string(material_type),
     "parameters"  : parameters
     }
-    
+
     return material_string
-    
+
 def generate_materials_scene(data):
     chunks = []
 
     # TODO: extract just materials actually used by some objects in the scene
-    
+
     for m in bpy.data.materials:
-        material = extract_material_data(m)
+        material = extract_material_data(m, data["usecolors"])
         material_string = generate_material_string(material)
         chunks.append(material_string)
 
@@ -1226,7 +1236,7 @@ def generate_cameras(data):
     cameras = data.get("cameras", [])
     if not cameras:
         cameras.append(DEFAULTS["camera"])
-        
+
     chunks = []
     for camera in cameras:
 
@@ -1253,9 +1263,9 @@ def generate_cameras(data):
             "position"  : generate_vec3(camera["position"]),
             "target"    : generate_vec3(camera["target"])
             }
-            
+
         chunks.append(camera_string)
-        
+
     return ",\n\n".join(chunks)
 
 # #####################################################
@@ -1266,7 +1276,7 @@ def generate_lights(data):
     lights = data.get("lights", [])
     if not lights:
         lights.append(DEFAULTS["light"])
-        
+
     chunks = []
     for light in lights:
 
@@ -1287,9 +1297,9 @@ def generate_lights(data):
             "color"         : rgb2int(light["color"]),
             "intensity"     : light["intensity"]
             }
-            
+
         chunks.append(light_string)
-            
+
     return ",\n\n".join(chunks)
 
 # #####################################################
@@ -1305,7 +1315,7 @@ def generate_ascii_scene(data):
 
     cameras = generate_cameras(data)
     lights = generate_lights(data)
-    
+
     sections = [
     ["objects",    objects],
     ["geometries", geometries],
@@ -1314,16 +1324,16 @@ def generate_ascii_scene(data):
     ["cameras",    cameras],
     ["lights",     lights]
     ]
-    
+
     chunks = []
     for label, content in sections:
         if content:
             chunks.append(generate_section(label, content))
 
     sections_string = "\n".join(chunks)
-    
+
     default_camera = "default_camera"
-    
+
     parameters = {
     "fname"     : data["source_file"],
 
@@ -1337,17 +1347,17 @@ def generate_ascii_scene(data):
     "ngeometries"   : ngeometries,
     "ntextures"     : ntextures,
     "nmaterials"    : nmaterials,
-    
+
     "position"      : generate_vec3(DEFAULTS["position"]),
     "rotation"      : generate_vec3(DEFAULTS["rotation"]),
     "scale"         : generate_vec3(DEFAULTS["scale"])
     }
 
     text = TEMPLATE_SCENE_ASCII % parameters
-    
+
     return text
-    
-def export_scene(scene, filepath, flipyz):
+
+def export_scene(scene, filepath, flipyz, option_colors):
 
     source_file = os.path.basename(bpy.data.filepath)
 
@@ -1357,28 +1367,29 @@ def export_scene(scene, filepath, flipyz):
     "objects"     : scene.objects,
     "source_file" : source_file,
     "filepath"    : filepath,
-    "flipyz"      : flipyz
+    "flipyz"      : flipyz,
+    "usecolors"   : option_colors
     }
     scene_text += generate_ascii_scene(data)
-    
+
     write_file(filepath, scene_text)
 
 # #####################################################
 # Main
 # #####################################################
 
-def save(operator, context, filepath = "", 
-         option_flip_yz = True, 
-         option_vertices = True, 
-         option_faces = True, 
-         option_normals = True, 
-         option_edges = False, 
-         option_uv_coords = True, 
-         option_materials = True, 
-         option_colors = True, 
-         align_model = 0, 
-         option_export_scene = False, 
-         option_truncate = False, 
+def save(operator, context, filepath = "",
+         option_flip_yz = True,
+         option_vertices = True,
+         option_vertices_truncate = False,
+         option_faces = True,
+         option_normals = True,
+         option_edges = False,
+         option_uv_coords = True,
+         option_materials = True,
+         option_colors = True,
+         align_model = 0,
+         option_export_scene = False,
          option_scale = 1.0):
 
     filepath = ensure_extension(filepath, '.js')
@@ -1390,19 +1401,19 @@ def save(operator, context, filepath = "",
 
     if option_export_scene:
 
-        export_scene(scene, filepath, option_flip_yz)
+        export_scene(scene, filepath, option_flip_yz, option_colors)
 
         geo_set = set()
-        
+
         for obj in scene.objects:
             if obj.type == "MESH":
-                
+
                 # create extra copy of geometry with applied modifiers
                 # (if they exist)
-                
+
                 if len(obj.modifiers) > 0:
                     name = obj.name
-                    
+
                 # otherwise can share geometry
 
                 else:
@@ -1410,18 +1421,18 @@ def save(operator, context, filepath = "",
 
                 if name not in geo_set:
                     fname = generate_mesh_filename(name, filepath)
-                    export_mesh(obj, scene, fname, 
-                                option_vertices, 
-                                option_faces, 
-                                option_normals, 
-                                option_edges, 
-                                option_uv_coords, 
-                                option_materials, 
-                                option_colors, 
-                                False, 
-                                option_flip_yz, 
-                                option_truncate, 
-                                option_scale, 
+                    export_mesh(obj, scene, fname,
+                                option_vertices,
+                                option_vertices_truncate,
+                                option_faces,
+                                option_normals,
+                                option_edges,
+                                option_uv_coords,
+                                option_materials,
+                                option_colors,
+                                False,
+                                option_flip_yz,
+                                option_scale,
                                 False)
 
                     geo_set.add(name)
@@ -1432,19 +1443,19 @@ def save(operator, context, filepath = "",
         if not obj:
             raise Exception("Error, Select 1 active object or select 'export scene'")
 
-        export_mesh(obj, scene, filepath, 
-                    option_vertices, 
-                    option_faces, 
-                    option_normals, 
-                    option_edges, 
-                    option_uv_coords, 
-                    option_materials, 
-                    option_colors, 
-                    align_model, 
-                    option_flip_yz, 
-                    option_truncate, 
-                    option_scale, 
+        export_mesh(obj, scene, filepath,
+                    option_vertices,
+                    option_vertices_truncate,
+                    option_faces,
+                    option_normals,
+                    option_edges,
+                    option_uv_coords,
+                    option_materials,
+                    option_colors,
+                    align_model,
+                    option_flip_yz,
+                    option_scale,
                     True)
 
-    
+
     return {'FINISHED'}