Browse Source

Merge remote branch 'alteredq/master'

Mr.doob 14 years ago
parent
commit
05dbe81dfa
4 changed files with 684 additions and 490 deletions
  1. 141 136
      build/Three.js
  2. 143 138
      build/ThreeDebug.js
  3. 122 117
      build/ThreeExtras.js
  4. 278 99
      src/renderers/WebGLRenderer.js

+ 141 - 136
build/Three.js

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

+ 143 - 138
build/ThreeDebug.js

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

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


+ 278 - 99
src/renderers/WebGLRenderer.js

@@ -31,7 +31,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	// ubershader material constants
 
-	BASIC = 0, LAMBERT = 1, PHONG = 2,
+	LAMBERT = 1, PHONG = 2,
 
 	// heuristics to create shader parameters according to lights in the scene
 	// (not to blow over maxLights budget)
@@ -380,6 +380,37 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
+	function refreshUniforms( material, fog ) {
+		
+		material.uniforms.color.value.setHex( material.color.hex );
+		material.uniforms.opacity.value = material.opacity;
+		material.uniforms.map.texture = material.map;
+		
+		material.uniforms.env_map.texture = material.env_map;
+		material.uniforms.reflectivity.value = material.reflectivity;
+		material.uniforms.refraction_ratio.value = material.refraction_ratio;
+		material.uniforms.combine.value = material.combine;
+		material.uniforms.useRefract.value = material.env_map && material.env_map.mapping instanceof THREE.CubeRefractionMapping;
+		
+		if ( fog ) {
+
+			material.uniforms.fogColor.value.setHex( fog.color.hex );
+			
+			if ( fog instanceof THREE.Fog ) {
+				
+				material.uniforms.fogNear.value = fog.near;
+				material.uniforms.fogFar.value = fog.far;
+				
+			} else if ( fog instanceof THREE.FogExp2 ) {
+				
+				material.uniforms.fogDensity.value = fog.density;
+				
+			}
+
+		}
+		
+	};
+	
 	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk ) {
 
 		var mColor, mOpacity, mReflectivity,
@@ -392,24 +423,31 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( material instanceof THREE.MeshShaderMaterial ||
 			 material instanceof THREE.MeshDepthMaterial ||
-			 material instanceof THREE.MeshNormalMaterial ) {
+			 material instanceof THREE.MeshNormalMaterial || 
+			 material instanceof THREE.MeshBasicMaterial ) {
 
 			if ( !material.program ) {
 
 				if ( material instanceof THREE.MeshDepthMaterial ) {
 
-					setMaterialShaders( material, ShaderLib[ 'depth' ] );
+					setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] );
 
 					material.uniforms.mNear.value = camera.near;
 					material.uniforms.mFar.value = camera.far;
 
 				} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
-					setMaterialShaders( material, ShaderLib[ 'normal' ] );
+					setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] );
 
+				} else if ( material instanceof THREE.MeshBasicMaterial ) {
+					
+					setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+					
+					refreshUniforms( material, fog );
+					
 				}
 
-				material.program = buildProgram( material.fragment_shader, material.vertex_shader, null );
+				material.program = buildProgram( material.fragment_shader, material.vertex_shader, { fog: fog, map: material.map, env_map: material.env_map } );
 
 				identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
 				for( u in material.uniforms ) {
@@ -447,9 +485,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 		this.loadCamera( program, camera );
 		this.loadMatrices( program );
 
+		if ( material instanceof THREE.MeshBasicMaterial ) {
+			
+			refreshUniforms( material, fog );
+		
+		}
+		
 		if ( material instanceof THREE.MeshShaderMaterial ||
 		     material instanceof THREE.MeshDepthMaterial ||
-			 material instanceof THREE.MeshNormalMaterial ) {
+			 material instanceof THREE.MeshNormalMaterial ||
+			 material instanceof THREE.MeshBasicMaterial ) {
 
 			mWireframe = material.wireframe;
 			mLineWidth = material.wireframe_linewidth;
@@ -461,8 +506,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 
 		if ( material instanceof THREE.MeshPhongMaterial ||
-			 material instanceof THREE.MeshLambertMaterial ||
-			 material instanceof THREE.MeshBasicMaterial ) {
+			 material instanceof THREE.MeshLambertMaterial ) {
 
 			mColor = material.color;
 			mOpacity = material.opacity;
@@ -524,10 +568,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			_gl.uniform1i( program.uniforms.material, LAMBERT );
 
-		} else if ( material instanceof THREE.MeshBasicMaterial ) {
-
-			_gl.uniform1i( program.uniforms.material, BASIC );
-
 		}
 
 		if ( mMap ) {
@@ -950,7 +990,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearAlpha );
 
 	};
-
+		
 	function generateFragmentShader( maxDirLights, maxPointLights ) {
 
 		var chunks = [
@@ -958,7 +998,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			maxDirLights   ? "#define MAX_DIR_LIGHTS " + maxDirLights     : "",
 			maxPointLights ? "#define MAX_POINT_LIGHTS " + maxPointLights : "",
 
-			"uniform int material;", // 0 - Basic, 1 - Lambert, 2 - Phong
+			"uniform int material;", // 1 - Lambert, 2 - Phong
 
 			"uniform bool enableMap;",
 			"uniform bool enableCubeMap;",
@@ -975,18 +1015,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			"uniform vec4 mSpecular;",
 			"uniform float mShininess;",
 
-			"#ifdef USE_FOG",
-				"uniform vec3 fogColor;",
-				
-				"#ifdef FOG_EXP2",
-					"uniform float fogDensity;",
-				"#else",
-					"uniform float fogNear;",
-					"uniform float fogFar;",
-				"#endif",
-				
-			"#endif",
-
+			THREE.Snippets[ "fog_uniforms" ],
+			
 			"uniform int pointLightNumber;",
 			"uniform int directionalLightNumber;",
 
@@ -1125,38 +1155,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 					"}",
 
-				// Basic: unlit color / texture
-
-				"} else {",
-
-					"if ( mixEnvMap ) {",
-
-						"gl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );",
-
-					"} else {",
-
-						"gl_FragColor = mColor * mapColor * cubeColor;",
-
-					"}",
-
 				"}",
 
-				"#ifdef USE_FOG",
+				THREE.Snippets[ "fog_fragment" ],
 				
-					"float depth = gl_FragCoord.z / gl_FragCoord.w;",
-
-					"#ifdef FOG_EXP2",
-						"const float LOG2 = 1.442695;",
-						"float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );",
-						"fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );",
-					"#else",
-						"float fogFactor = smoothstep( fogNear, fogFar, depth );",
-					"#endif",
-					
-					"gl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );",
-
-				"#endif",
-
 			"}" ];
 
 		return chunks.join("\n");
@@ -1260,7 +1262,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function buildProgram( fragment_shader, vertex_shader, fog ) {
+	function buildProgram( fragment_shader, vertex_shader, parameters ) {
 
 		var program = _gl.createProgram(),
 
@@ -1269,8 +1271,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 			"precision highp float;",
 			"#endif",
 
-			fog ? "#define USE_FOG" : "",
-			fog instanceof THREE.FogExp2 ? "#define FOG_EXP2" : "",
+			parameters.fog ? "#define USE_FOG" : "",
+			parameters.fog instanceof THREE.FogExp2 ? "#define FOG_EXP2" : "",
+		
+			parameters.map ? "#define USE_MAP" : "",
+			parameters.env_map ? "#define USE_ENVMAP" : "",
 
 			"uniform mat4 viewMatrix;",
 			"uniform vec3 cameraPosition;",
@@ -1280,6 +1285,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 		prefix_vertex = [
 			maxVertexTextures() > 0 ? "#define VERTEX_TEXTURES" : "",
 
+			parameters.map ? "#define USE_MAP" : "",
+			parameters.env_map ? "#define USE_ENVMAP" : "",
+
 			"uniform mat4 objectMatrix;",
 			"uniform mat4 modelViewMatrix;",
 			"uniform mat4 projectionMatrix;",
@@ -1449,15 +1457,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 	};
 
 	function initUbershader( maxDirLights, maxPointLights, fog ) {
-
+		
 		var vertex_shader = generateVertexShader( maxDirLights, maxPointLights ),
 			fragment_shader = generateFragmentShader( maxDirLights, maxPointLights ),
 			program;
 
-		//log ( vertex_shader );
-		//log ( fragment_shader );
+		//console.log ( vertex_shader );
+		//console.log ( fragment_shader );
 
-		program = buildProgram( fragment_shader, vertex_shader, fog );
+		program = buildProgram( fragment_shader, vertex_shader, { fog: fog } );
 
 		_gl.useProgram( program );
 
@@ -1677,73 +1685,244 @@ THREE.WebGLRenderer = function ( parameters ) {
 	}
 	*/
 
-	var ShaderLib = {
+};
 
-		'depth': {
+THREE.Snippets = {
+	
+	fog_uniforms: [
 
-			uniforms: { "mNear": { type: "f", value: 1.0 },
-						"mFar" : { type: "f", value: 2000.0 } },
+	"#ifdef USE_FOG",
+	
+		"uniform vec3 fogColor;",
+		
+		"#ifdef FOG_EXP2",
+			"uniform float fogDensity;",
+		"#else",
+			"uniform float fogNear;",
+			"uniform float fogFar;",
+		"#endif",
+		
+	"#endif"
+	
+	].join("\n"),
 
-			fragment_shader: [
+	fog_fragment: [
 
-				"uniform float mNear;",
-				"uniform float mFar;",
+	"#ifdef USE_FOG",
+	
+		"float depth = gl_FragCoord.z / gl_FragCoord.w;",
+
+		"#ifdef FOG_EXP2",
+			"const float LOG2 = 1.442695;",
+			"float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );",
+			"fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );",
+		"#else",
+			"float fogFactor = smoothstep( fogNear, fogFar, depth );",
+		"#endif",
+		
+		"gl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );",
 
-				"void main() {",
+	"#endif"
+	
+	].join("\n")
+	
+};
 
-					"float depth = gl_FragCoord.z / gl_FragCoord.w;",
-					"float color = 1.0 - smoothstep( mNear, mFar, depth );",
-					"gl_FragColor = vec4( vec3( color ), 1.0 );",
+THREE.ShaderLib = {
 
-				"}"
+	'depth': {
 
-			].join("\n"),
+		uniforms: { "mNear": { type: "f", value: 1.0 },
+					"mFar" : { type: "f", value: 2000.0 } },
 
-			vertex_shader: [
+		fragment_shader: [
 
-				"void main() {",
+			"uniform float mNear;",
+			"uniform float mFar;",
 
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+			"void main() {",
 
-				"}"
+				"float depth = gl_FragCoord.z / gl_FragCoord.w;",
+				"float color = 1.0 - smoothstep( mNear, mFar, depth );",
+				"gl_FragColor = vec4( vec3( color ), 1.0 );",
 
-			].join("\n")
+			"}"
 
-		},
+		].join("\n"),
 
-		'normal': {
+		vertex_shader: [
 
-			uniforms: { },
+			"void main() {",
 
-			fragment_shader: [
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
 
-				"varying vec3 vNormal;",
+			"}"
 
-				"void main() {",
+		].join("\n")
 
-					"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );",
+	},
 
-				"}"
+	'normal': {
 
-			].join("\n"),
+		uniforms: { },
 
-			vertex_shader: [
+		fragment_shader: [
 
-				"varying vec3 vNormal;",
+			"varying vec3 vNormal;",
 
-				"void main() {",
+			"void main() {",
 
-					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
-					"vNormal = normalize( normalMatrix * normal );",
+				"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );",
 
-					"gl_Position = projectionMatrix * mvPosition;",
+			"}"
 
-				"}"
+		].join("\n"),
 
-			].join("\n")
+		vertex_shader: [
 
-		}
+			"varying vec3 vNormal;",
 
-	};
+			"void main() {",
+
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+				"vNormal = normalize( normalMatrix * normal );",
+
+				"gl_Position = projectionMatrix * mvPosition;",
+
+			"}"
+
+		].join("\n")
+
+	},
+	
+	'basic': {
+		
+		uniforms: { "color"   : { type: "c", value: new THREE.Color( 0xeeeeee ) },
+					"opacity" : { type: "f", value: 1 },
+					"map"     : { type: "t", value: 0, texture: null },
+					"env_map" 		  : { type: "t", value: 1, texture: null },
+					"useRefract"	  : { type: "i", value: 0 },
+					"reflectivity"    : { type: "f", value: 1 },
+					"refraction_ratio": { type: "f", value: 0.98 },
+					"combine"		  : { type: "i", value: 0 },
+					"fogDensity": { type: "f", value: 0.00025 },
+					"fogNear"	: { type: "f", value: 1 },
+					"fogFar"	: { type: "f", value: 2000 },
+					"fogColor"	: { type: "c", value: new THREE.Color( 0xffffff ) }
+				},
+		
+		fragment_shader: [
+			
+			"uniform vec3 color;",
+			"uniform float opacity;",
+			
+			"#ifdef USE_MAP",
+				
+				"varying vec2 vUv;",
+				"uniform sampler2D map;",
+				  
+			"#endif",
+			
+			"#ifdef USE_ENVMAP",
+			
+				"varying vec3 vReflect;",
+				"uniform float reflectivity;",
+				"uniform samplerCube env_map;",
+				"uniform int combine;",
+				
+			"#endif",
+
+			THREE.Snippets[ "fog_uniforms" ],
+				
+			"void main() {",
+					
+				"vec4 mColor = vec4( color, opacity );",
+				"vec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );",
+				"vec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );",
+
+				// diffuse map
+
+				"#ifdef USE_MAP",
+
+					"mapColor = texture2D( map, vUv );",
+
+				"#endif",
+
+				// environment map
+				
+				"#ifdef USE_ENVMAP",
+
+					"cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );",
+					
+					"if ( combine == 1 ) {",
+
+						"gl_FragColor = mix( mColor * mapColor, cubeColor, reflectivity );",
+
+					"} else {",
+
+						"gl_FragColor = mColor * mapColor * cubeColor;",
+
+					"}",
+				
+				"#else",
+				
+					"gl_FragColor = mColor * mapColor;",
+
+				"#endif",
+				
+				THREE.Snippets[ "fog_fragment" ],
+				
+			"}"
+
+		].join("\n"),
+		
+		vertex_shader: [
+		
+			"#ifdef USE_MAP",
+			
+				"varying vec2 vUv;",
+
+			"#endif",
+			
+			"#ifdef USE_ENVMAP",
+			
+				"varying vec3 vReflect;",
+				"uniform float refraction_ratio;",
+				"uniform bool useRefract;",
+				
+			"#endif",
+			
+			"void main() {",
+		
+				"#ifdef USE_MAP",
+				
+					"vUv = uv;",
+					
+				"#endif",
+
+				"#ifdef USE_ENVMAP",
+				
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+					"vec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;",
+				
+					"if ( useRefract ) {",
+
+						"vReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );",
+
+					"} else {",
+
+						"vReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );",
+
+					"}",
+
+				"#endif",
+				
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n")
+		
+	}		
 
 };

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